cxgb4: Set mac addr from vpd, when we can't contact firmware
[cascardo/linux.git] / drivers / net / ethernet / chelsio / cxgb4 / cxgb4.h
index 4ab5a2d..4d627a8 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/timer.h>
 #include <linux/vmalloc.h>
+#include <linux/etherdevice.h>
 #include <asm/io.h>
 #include "cxgb4_uld.h"
 
 #define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
 
 enum {
-       MAX_NPORTS = 4,     /* max # of ports */
-       SERNUM_LEN = 24,    /* Serial # length */
-       EC_LEN     = 16,    /* E/C length */
-       ID_LEN     = 16,    /* ID length */
-       PN_LEN     = 16,    /* Part Number length */
+       MAX_NPORTS      = 4,     /* max # of ports */
+       SERNUM_LEN      = 24,    /* Serial # length */
+       EC_LEN          = 16,    /* E/C length */
+       ID_LEN          = 16,    /* ID length */
+       PN_LEN          = 16,    /* Part Number length */
+       MACADDR_LEN     = 12,    /* MAC Address length */
 };
 
 enum {
@@ -280,6 +282,7 @@ struct vpd_params {
        u8 sn[SERNUM_LEN + 1];
        u8 id[ID_LEN + 1];
        u8 pn[PN_LEN + 1];
+       u8 na[MACADDR_LEN + 1];
 };
 
 struct pci_params {
@@ -945,6 +948,22 @@ static inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val)
        writeq(val, adap->regs + reg_addr);
 }
 
+/**
+ * t4_set_hw_addr - store a port's MAC address in SW
+ * @adapter: the adapter
+ * @port_idx: the port index
+ * @hw_addr: the Ethernet address
+ *
+ * Store the Ethernet address of the given port in SW.  Called by the common
+ * code when it retrieves a port's Ethernet address from EEPROM.
+ */
+static inline void t4_set_hw_addr(struct adapter *adapter, int port_idx,
+                                 u8 hw_addr[])
+{
+       ether_addr_copy(adapter->port[port_idx]->dev_addr, hw_addr);
+       ether_addr_copy(adapter->port[port_idx]->perm_addr, hw_addr);
+}
+
 /**
  * netdev2pinfo - return the port_info structure associated with a net_device
  * @dev: the netdev
@@ -1251,7 +1270,8 @@ unsigned int t4_get_regs_len(struct adapter *adapter);
 void t4_get_regs(struct adapter *adap, void *buf, size_t buf_size);
 
 int t4_seeprom_wp(struct adapter *adapter, bool enable);
-int get_vpd_params(struct adapter *adapter, struct vpd_params *p);
+int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p);
+int t4_get_vpd_params(struct adapter *adapter, struct vpd_params *p);
 int t4_read_flash(struct adapter *adapter, unsigned int addr,
                  unsigned int nwords, u32 *data, int byte_oriented);
 int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);