]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
i40e: Add ndo_get_phys_port_id() callback support
authorNeerav Parikh <neerav.parikh@intel.com>
Wed, 12 Feb 2014 01:45:31 +0000 (01:45 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 16 Jul 2014 18:57:22 +0000 (11:57 -0700)
This patch adds a new API to get the port mac address from firmware.
It also adds support to the ndo_get_phys_port_id() callback to provide
port specific unique id to the netdev layer.
If the adapter has a valid per-port mac address then that
would be used for this purpose and is expected to be unique
on a per-port basis.

The information can be viewed by reading the phys_port_id
attribute in sysfs for each netdev or via IF netlink
interface.

Change-ID: I341fa6fff9c112f1f6d987189309e730e0b50e8b
Signed-off-by: Neerav Parikh <neerav.parikh@intel.com>
Acked-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e.h
drivers/net/ethernet/intel/i40e/i40e_common.c
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40e/i40e_prototype.h
drivers/net/ethernet/intel/i40e/i40e_type.h

index 0fbb32a8ad420373a74aecb9e29e08f4b608e45c..f7bf69fa15c7d1eeccb99e935b2d0392d598c310 100644 (file)
@@ -279,6 +279,7 @@ struct i40e_pf {
 #ifdef CONFIG_I40E_VXLAN
 #define I40E_FLAG_VXLAN_FILTER_SYNC            (u64)(1 << 27)
 #endif
+#define I40E_FLAG_PORT_ID_VALID                (u64)(1 << 28)
 #define I40E_FLAG_DCB_CAPABLE                  (u64)(1 << 29)
 
        /* tracks features that get auto disabled by errors */
index bf808d4cb7b8cf1ece404790ee7dccdbcc7b5c01..51087b5c7d911367618865749b07a5c11395bc89 100644 (file)
@@ -654,6 +654,31 @@ i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
        return status;
 }
 
+/**
+ * i40e_get_port_mac_addr - get Port MAC address
+ * @hw: pointer to the HW structure
+ * @mac_addr: pointer to Port MAC address
+ *
+ * Reads the adapter's Port MAC address
+ **/
+i40e_status i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
+{
+       struct i40e_aqc_mac_address_read_data addrs;
+       i40e_status status;
+       u16 flags = 0;
+
+       status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
+       if (status)
+               return status;
+
+       if (flags & I40E_AQC_PORT_ADDR_VALID)
+               memcpy(mac_addr, &addrs.port_mac, sizeof(addrs.port_mac));
+       else
+               status = I40E_ERR_INVALID_MAC_ADDR;
+
+       return status;
+}
+
 /**
  * i40e_pre_tx_queue_cfg - pre tx queue configure
  * @hw: pointer to the HW structure
index 2899f783ee1d17d0e86b79f04a3dff2a846041cf..1f72eeca00cee259da68fc2034260d6e370b4295 100644 (file)
@@ -7018,6 +7018,22 @@ static void i40e_del_vxlan_port(struct net_device *netdev,
 }
 
 #endif
+static int i40e_get_phys_port_id(struct net_device *netdev,
+                                struct netdev_phys_port_id *ppid)
+{
+       struct i40e_netdev_priv *np = netdev_priv(netdev);
+       struct i40e_pf *pf = np->vsi->back;
+       struct i40e_hw *hw = &pf->hw;
+
+       if (!(pf->flags & I40E_FLAG_PORT_ID_VALID))
+               return -EOPNOTSUPP;
+
+       ppid->id_len = min_t(int, sizeof(hw->mac.port_addr), sizeof(ppid->id));
+       memcpy(ppid->id, hw->mac.port_addr, ppid->id_len);
+
+       return 0;
+}
+
 #ifdef HAVE_FDB_OPS
 #ifdef USE_CONST_DEV_UC_CHAR
 static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
@@ -7137,6 +7153,7 @@ static const struct net_device_ops i40e_netdev_ops = {
        .ndo_add_vxlan_port     = i40e_add_vxlan_port,
        .ndo_del_vxlan_port     = i40e_del_vxlan_port,
 #endif
+       .ndo_get_phys_port_id   = i40e_get_phys_port_id,
 #ifdef HAVE_FDB_OPS
        .ndo_fdb_add            = i40e_ndo_fdb_add,
 #ifndef USE_DEFAULT_FDB_DEL_DUMP
@@ -8686,6 +8703,9 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
        dev_info(&pdev->dev, "MAC address: %pM\n", hw->mac.addr);
        ether_addr_copy(hw->mac.perm_addr, hw->mac.addr);
+       i40e_get_port_mac_addr(hw, hw->mac.port_addr);
+       if (is_valid_ether_addr(hw->mac.port_addr))
+               pf->flags |= I40E_FLAG_PORT_ID_VALID;
 
        pci_set_drvdata(pdev, pf);
        pci_save_state(pdev);
index b6849fb47db78af85018e3e574e2baf794d50220..9383f08ff4e3e3fc2f9e6cb155b1dacf3dc46335 100644 (file)
@@ -230,8 +230,8 @@ i40e_status i40e_pf_reset(struct i40e_hw *hw);
 void i40e_clear_hw(struct i40e_hw *hw);
 void i40e_clear_pxe_mode(struct i40e_hw *hw);
 bool i40e_get_link_status(struct i40e_hw *hw);
-i40e_status i40e_get_mac_addr(struct i40e_hw *hw,
-                                               u8 *mac_addr);
+i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
+i40e_status i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
 i40e_status i40e_validate_mac_addr(u8 *mac_addr);
 void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable);
 /* prototype for functions used for NVM access */
index 380eb53a83b332d1cf2f6a915eb26ec2f341e248..1fcf2205ffe619228af502c915c748812e34a774 100644 (file)
@@ -246,6 +246,7 @@ struct i40e_mac_info {
        u8 addr[ETH_ALEN];
        u8 perm_addr[ETH_ALEN];
        u8 san_addr[ETH_ALEN];
+       u8 port_addr[ETH_ALEN];
        u16 max_fcoeq;
 };