diff options
author | Neerav Parikh <neerav.parikh@intel.com> | 2014-02-11 20:45:31 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2014-07-16 14:57:22 -0400 |
commit | 1f224ad2f760288dcc58b26546892a6b200b2af2 (patch) | |
tree | af206edeafd12963051261f36a284a600619dc84 | |
parent | a84bc2a9013fb123deeca7283480955d021503fb (diff) |
i40e: Add ndo_get_phys_port_id() callback support
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>
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_common.c | 25 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_main.c | 20 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_prototype.h | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_type.h | 1 |
5 files changed, 49 insertions, 2 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index 0fbb32a8ad42..f7bf69fa15c7 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h | |||
@@ -279,6 +279,7 @@ struct i40e_pf { | |||
279 | #ifdef CONFIG_I40E_VXLAN | 279 | #ifdef CONFIG_I40E_VXLAN |
280 | #define I40E_FLAG_VXLAN_FILTER_SYNC (u64)(1 << 27) | 280 | #define I40E_FLAG_VXLAN_FILTER_SYNC (u64)(1 << 27) |
281 | #endif | 281 | #endif |
282 | #define I40E_FLAG_PORT_ID_VALID (u64)(1 << 28) | ||
282 | #define I40E_FLAG_DCB_CAPABLE (u64)(1 << 29) | 283 | #define I40E_FLAG_DCB_CAPABLE (u64)(1 << 29) |
283 | 284 | ||
284 | /* tracks features that get auto disabled by errors */ | 285 | /* tracks features that get auto disabled by errors */ |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c index bf808d4cb7b8..51087b5c7d91 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_common.c +++ b/drivers/net/ethernet/intel/i40e/i40e_common.c | |||
@@ -655,6 +655,31 @@ i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr) | |||
655 | } | 655 | } |
656 | 656 | ||
657 | /** | 657 | /** |
658 | * i40e_get_port_mac_addr - get Port MAC address | ||
659 | * @hw: pointer to the HW structure | ||
660 | * @mac_addr: pointer to Port MAC address | ||
661 | * | ||
662 | * Reads the adapter's Port MAC address | ||
663 | **/ | ||
664 | i40e_status i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr) | ||
665 | { | ||
666 | struct i40e_aqc_mac_address_read_data addrs; | ||
667 | i40e_status status; | ||
668 | u16 flags = 0; | ||
669 | |||
670 | status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL); | ||
671 | if (status) | ||
672 | return status; | ||
673 | |||
674 | if (flags & I40E_AQC_PORT_ADDR_VALID) | ||
675 | memcpy(mac_addr, &addrs.port_mac, sizeof(addrs.port_mac)); | ||
676 | else | ||
677 | status = I40E_ERR_INVALID_MAC_ADDR; | ||
678 | |||
679 | return status; | ||
680 | } | ||
681 | |||
682 | /** | ||
658 | * i40e_pre_tx_queue_cfg - pre tx queue configure | 683 | * i40e_pre_tx_queue_cfg - pre tx queue configure |
659 | * @hw: pointer to the HW structure | 684 | * @hw: pointer to the HW structure |
660 | * @queue: target pf queue index | 685 | * @queue: target pf queue index |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 2899f783ee1d..1f72eeca00ce 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c | |||
@@ -7018,6 +7018,22 @@ static void i40e_del_vxlan_port(struct net_device *netdev, | |||
7018 | } | 7018 | } |
7019 | 7019 | ||
7020 | #endif | 7020 | #endif |
7021 | static int i40e_get_phys_port_id(struct net_device *netdev, | ||
7022 | struct netdev_phys_port_id *ppid) | ||
7023 | { | ||
7024 | struct i40e_netdev_priv *np = netdev_priv(netdev); | ||
7025 | struct i40e_pf *pf = np->vsi->back; | ||
7026 | struct i40e_hw *hw = &pf->hw; | ||
7027 | |||
7028 | if (!(pf->flags & I40E_FLAG_PORT_ID_VALID)) | ||
7029 | return -EOPNOTSUPP; | ||
7030 | |||
7031 | ppid->id_len = min_t(int, sizeof(hw->mac.port_addr), sizeof(ppid->id)); | ||
7032 | memcpy(ppid->id, hw->mac.port_addr, ppid->id_len); | ||
7033 | |||
7034 | return 0; | ||
7035 | } | ||
7036 | |||
7021 | #ifdef HAVE_FDB_OPS | 7037 | #ifdef HAVE_FDB_OPS |
7022 | #ifdef USE_CONST_DEV_UC_CHAR | 7038 | #ifdef USE_CONST_DEV_UC_CHAR |
7023 | static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], | 7039 | 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 = { | |||
7137 | .ndo_add_vxlan_port = i40e_add_vxlan_port, | 7153 | .ndo_add_vxlan_port = i40e_add_vxlan_port, |
7138 | .ndo_del_vxlan_port = i40e_del_vxlan_port, | 7154 | .ndo_del_vxlan_port = i40e_del_vxlan_port, |
7139 | #endif | 7155 | #endif |
7156 | .ndo_get_phys_port_id = i40e_get_phys_port_id, | ||
7140 | #ifdef HAVE_FDB_OPS | 7157 | #ifdef HAVE_FDB_OPS |
7141 | .ndo_fdb_add = i40e_ndo_fdb_add, | 7158 | .ndo_fdb_add = i40e_ndo_fdb_add, |
7142 | #ifndef USE_DEFAULT_FDB_DEL_DUMP | 7159 | #ifndef USE_DEFAULT_FDB_DEL_DUMP |
@@ -8686,6 +8703,9 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
8686 | } | 8703 | } |
8687 | dev_info(&pdev->dev, "MAC address: %pM\n", hw->mac.addr); | 8704 | dev_info(&pdev->dev, "MAC address: %pM\n", hw->mac.addr); |
8688 | ether_addr_copy(hw->mac.perm_addr, hw->mac.addr); | 8705 | ether_addr_copy(hw->mac.perm_addr, hw->mac.addr); |
8706 | i40e_get_port_mac_addr(hw, hw->mac.port_addr); | ||
8707 | if (is_valid_ether_addr(hw->mac.port_addr)) | ||
8708 | pf->flags |= I40E_FLAG_PORT_ID_VALID; | ||
8689 | 8709 | ||
8690 | pci_set_drvdata(pdev, pf); | 8710 | pci_set_drvdata(pdev, pf); |
8691 | pci_save_state(pdev); | 8711 | pci_save_state(pdev); |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_prototype.h b/drivers/net/ethernet/intel/i40e/i40e_prototype.h index b6849fb47db7..9383f08ff4e3 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_prototype.h +++ b/drivers/net/ethernet/intel/i40e/i40e_prototype.h | |||
@@ -230,8 +230,8 @@ i40e_status i40e_pf_reset(struct i40e_hw *hw); | |||
230 | void i40e_clear_hw(struct i40e_hw *hw); | 230 | void i40e_clear_hw(struct i40e_hw *hw); |
231 | void i40e_clear_pxe_mode(struct i40e_hw *hw); | 231 | void i40e_clear_pxe_mode(struct i40e_hw *hw); |
232 | bool i40e_get_link_status(struct i40e_hw *hw); | 232 | bool i40e_get_link_status(struct i40e_hw *hw); |
233 | i40e_status i40e_get_mac_addr(struct i40e_hw *hw, | 233 | i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr); |
234 | u8 *mac_addr); | 234 | i40e_status i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr); |
235 | i40e_status i40e_validate_mac_addr(u8 *mac_addr); | 235 | i40e_status i40e_validate_mac_addr(u8 *mac_addr); |
236 | void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable); | 236 | void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable); |
237 | /* prototype for functions used for NVM access */ | 237 | /* prototype for functions used for NVM access */ |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h index 380eb53a83b3..1fcf2205ffe6 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_type.h +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h | |||
@@ -246,6 +246,7 @@ struct i40e_mac_info { | |||
246 | u8 addr[ETH_ALEN]; | 246 | u8 addr[ETH_ALEN]; |
247 | u8 perm_addr[ETH_ALEN]; | 247 | u8 perm_addr[ETH_ALEN]; |
248 | u8 san_addr[ETH_ALEN]; | 248 | u8 san_addr[ETH_ALEN]; |
249 | u8 port_addr[ETH_ALEN]; | ||
249 | u16 max_fcoeq; | 250 | u16 max_fcoeq; |
250 | }; | 251 | }; |
251 | 252 | ||