bnx2x: enhancement patch series
cover bnx2x: enhancement patch series
Hi Dave,
This series contains several enhancements, mainly the implementation of the PCI shutdown callback which improves the bnx2x support in un-orderly shutdowns, and following that a change in the driver's power scheme which lowers PCI power state only when driver is removed (and as a result enable eeprom access on unloaded interfaces).
Please consider applying these patches to `net-next'.
Thanks,
Yuval Mintz
PATCH 1/6 bnx2x: Zero VFs starting MACs
From: Ariel Elior <[email protected]>
Hypervisor/Supervisor should set the VF's MAC prior to its load; Using a randomly generated MAC as a default is a bad practice.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +5 -1
@@ -11406,7 +11406,7 @@ static int bnx2x_init_bp(struct bnx2x *bp)if (rc)return rc; }else { -random_ether_addr (bp->dev->dev_addr); +eth_zero_addr (bp->dev->dev_addr); }bnx2x_set_modes_bitmap (bp);
@@ -11865,6 +11865,10 @@ static int bnx2x_validate_addr(struct net_device *dev) {struct bnx2x *bp =netdev_priv (dev); +/* query the bulletin board for mac address configured by the PF */ +if (IS_VF (bp)) +bnx2x_sample_bulletin (bp); +if (!bnx2x_is_valid_ether_addr (bp, dev->dev_addr)) {BNX2X_ERR ("Non-valid Ethernet address\n" );return -EADDRNOTAVAIL ;
Signature · 1 line
1.8.1.227.g44fe835
PATCH 2/6 bnx2x: Add and correct PCI link speed prints
In reply to Yuval MintzFrom: Dmitry Kravkov <[email protected]>
This adds the print of the PCI gen3 link speed (8GHz), as well as correcting the same print for 57712 boards (the print erroneously showed a 2.5GHz speed).
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 5 +++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 40 +++++++++++++++--------- 2 files changed, 31 insertions(+), 14 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +5 -0
@@ -2342,4 +2342,9 @@ enum {#define NUM_MACS 8 +enum bnx2x_pci_bus_speed { +BNX2X_PCI_LINK_SPEED_2500 =2500 , +BNX2X_PCI_LINK_SPEED_5000 =5000 , +BNX2X_PCI_LINK_SPEED_8000 =8000 +};#endif /* bnx2x.h */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +26 -14
@@ -12111,15 +12111,26 @@ err_out:return rc; } -static void bnx2x_get_pcie_width_speed (struct bnx2x *bp,int *width,int *speed) +static void bnx2x_get_pcie_width_speed (struct bnx2x *bp,int *width, +enum bnx2x_pci_bus_speed *speed) { -u32 val =0 ; +u32 link_speed, val =0 ;pci_read_config_dword (bp->pdev,PCICFG_LINK_CONTROL , &val); *width = (val &PCICFG_LINK_WIDTH ) >>PCICFG_LINK_WIDTH_SHIFT ; -/* return value of 1=2.5GHz 2=5GHz */ - *speed = (val &PCICFG_LINK_SPEED ) >>PCICFG_LINK_SPEED_SHIFT ; + link_speed = (val &PCICFG_LINK_SPEED ) >>PCICFG_LINK_SPEED_SHIFT ; + +switch (link_speed) { +case 3 : + *speed =BNX2X_PCI_LINK_SPEED_8000 ; +break ; +case 2 : + *speed =BNX2X_PCI_LINK_SPEED_5000 ; +break ; +default : + *speed =BNX2X_PCI_LINK_SPEED_2500 ; + } }static int bnx2x_check_firmware (struct bnx2x *bp)
@@ -12482,7 +12493,8 @@ static int bnx2x_init_one(struct pci_dev *pdev, {struct net_device *dev =NULL ;struct bnx2x *bp; -int pcie_width, pcie_speed; +int pcie_width; +enum bnx2x_pci_bus_speed pcie_speed;int rc, max_non_def_sbs;int rx_count, tx_count, rss_count, doorbell_size;int max_cos_est;
@@ -12634,15 +12646,15 @@ static int bnx2x_init_one(struct pci_dev *pdev,BNX2X_DEV_INFO ("got pcie width %d and speed %d\n" , pcie_width, pcie_speed); -BNX2X_DEV_INFO ( -"%s (%c%d) PCI-E x%d %s found at mem %lx, IRQ %d, node addr %pM\n" , - board_info[ent->driver_data].name, - (CHIP_REV (bp) >>12 ) +'A' , (CHIP_METAL (bp) >>4 ), - pcie_width, - ((!CHIP_IS_E2 (bp) && pcie_speed ==2 ) || - (CHIP_IS_E2 (bp) && pcie_speed ==1 )) ? -"5GHz (Gen2)" :"2.5GHz" , - dev->base_addr, bp->pdev->irq, dev->dev_addr); +BNX2X_DEV_INFO ("%s (%c%d) PCI-E x%d %s found at mem %lx, IRQ %d, node addr %pM\n" , + board_info[ent->driver_data].name, + (CHIP_REV (bp) >>12 ) +'A' , (CHIP_METAL (bp) >>4 ), + pcie_width, + pcie_speed ==BNX2X_PCI_LINK_SPEED_2500 ?"2.5GHz" : + pcie_speed ==BNX2X_PCI_LINK_SPEED_5000 ?"5.0GHz" : + pcie_speed ==BNX2X_PCI_LINK_SPEED_8000 ?"8.0GHz" : +"Unknown" , + dev->base_addr, bp->pdev->irq, dev->dev_addr);return 0 ;
Signature · 1 line
1.8.1.227.g44fe835
PATCH 4/6 bnx2x: Count number of possible FCoE interfaces
In reply to Yuval MintzFrom: Dmitry Kravkov <[email protected]>
Commit 0eb43b4bb081a1a22574daab9c05286a600dd7fe
"bnx2x, bnx2fc: Use per port max exchange resources" has changed the number of available FCoE exchanges, even in scenarios when some of the functions has no FCoE support; This needlessly degraded the available resources.
Remedy this by calculating the maximal number of functions that may actually utilize said connection.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 51 ++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +48 -3
@@ -10795,12 +10795,56 @@ static void bnx2x_get_ext_wwn_info(struct bnx2x *bp, int func) bp->cnic_eth_dev.fcoe_wwn_node_name_lo =MF_CFG_RD (bp, func_ext_config[func].fcoe_wwn_node_name_lower); } + +static int bnx2x_shared_fcoe_funcs (struct bnx2x *bp) +{ +u8 count =0 ; + +if (IS_MF (bp)) { +u8 fid; + +/* iterate over absolute function ids for this path: */ +for (fid =BP_PATH (bp); fid <E2_FUNC_MAX *2 ; fid +=2 ) { +if (IS_MF_SD (bp)) { +u32 cfg =MF_CFG_RD (bp, + func_mf_config[fid].config); + +if (!(cfg &FUNC_MF_CFG_FUNC_HIDE ) && + ((cfg &FUNC_MF_CFG_PROTOCOL_MASK ) == +FUNC_MF_CFG_PROTOCOL_FCOE )) + count++; + }else { +u32 cfg =MF_CFG_RD (bp, + func_ext_config[fid]. + func_cfg); + +if ((cfg &MACP_FUNC_CFG_FLAGS_ENABLED ) && + (cfg &MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD )) + count++; + } + } + }else {/* SF */ +int port, port_cnt =CHIP_MODE_IS_4_PORT (bp) ?2 :1 ; + +for (port =0 ; port < port_cnt; port++) { +u32 lic =SHMEM_RD (bp, + drv_lic_key[port].max_fcoe_conn) ^ +FW_ENCODE_32BIT_PATTERN ; +if (lic) + count++; + } + } + +return count; +} +static void bnx2x_get_fcoe_info (struct bnx2x *bp) {int port =BP_PORT (bp);int func =BP_ABS_FUNC (bp);u32 max_fcoe_conn =FW_ENCODE_32BIT_PATTERN ^SHMEM_RD (bp, drv_lic_key[port].max_fcoe_conn); +u8 num_fcoe_func =bnx2x_shared_fcoe_funcs (bp);if (!CNIC_SUPPORT (bp)) { bp->flags |=NO_FCOE_FLAG ;
@@ -10814,9 +10858,10 @@ static void bnx2x_get_fcoe_info(struct bnx2x *bp)/* Calculate the number of maximum allowed FCoE tasks */ bp->cnic_eth_dev.max_fcoe_exchanges =MAX_NUM_FCOE_TASKS_PER_ENGINE ; -if (IS_MF (bp) ||CHIP_MODE_IS_4_PORT (bp)) - bp->cnic_eth_dev.max_fcoe_exchanges /= -MAX_FCOE_FUNCS_PER_ENGINE ; + +/* check if FCoE resources must be shared between different functions */ +if (num_fcoe_func) + bp->cnic_eth_dev.max_fcoe_exchanges /= num_fcoe_func;/* Read the WWN: */ if (!IS_MF (bp)) {
Signature · 1 line
1.8.1.227.g44fe835
PATCH 5/6 bnx2x: Implement PCI shutdown
In reply to Yuval MintzImplement the PCI shutdown callback to support un-orderly shutdown, i.e., shutdowns in which the remove callback will not be called.
Due to the lack of this functionality, when an un-orderly shutdown occurred, it was possible for wake-on-lan to remain disabled.
This is now fixed as the callback introduces the correct place in which `system_state' can be queried and wake-on-lan be configured accordingly.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 71 ++++++++++++++++++++---- 1 file changed, 59 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +59 -12
@@ -12721,17 +12721,11 @@ init_one_exit:return rc; } -static void bnx2x_remove_one (struct pci_dev *pdev) +static void __bnx2x_remove (struct pci_dev *pdev, +struct net_device *dev, +struct bnx2x *bp, +bool remove_netdev) { -struct net_device *dev =pci_get_drvdata (pdev); -struct bnx2x *bp; - -if (!dev) { -dev_err (&pdev->dev,"BAD net device from bnx2x_init_one\n" ); -return ; - } - bp =netdev_priv (dev); -/* Delete storage MAC address */ if (!NO_FCOE (bp)) {rtnl_lock ();
@@ -12744,7 +12738,15 @@ static void bnx2x_remove_one(struct pci_dev *pdev)bnx2x_dcbnl_update_applist (bp, true);#endif -unregister_netdev (dev); +/* Close the interface - either directly or implicitly */ +if (remove_netdev) { +unregister_netdev (dev); + }else { +rtnl_lock (); +if (netif_running (dev)) +bnx2x_close (dev); +rtnl_unlock (); + }/* Power on: we can't let PCI layer write to us while we are in D3 */ if (IS_PF (bp))
@@ -12766,6 +12768,12 @@ static void bnx2x_remove_one(struct pci_dev *pdev)if (IS_VF (bp))bnx2x_vfpf_release (bp); +/* Assumes no further PCIe PM changes will occur */ +if (system_state ==SYSTEM_POWER_OFF ) { +pci_wake_from_d3 (pdev, bp->wol); +pci_set_power_state (pdev, PCI_D3hot); + } +if (bp->regview)iounmap (bp->regview);
@@ -12780,7 +12788,8 @@ static void bnx2x_remove_one(struct pci_dev *pdev) }bnx2x_free_mem_bp (bp); -free_netdev (dev); +if (remove_netdev) +free_netdev (dev);if (atomic_read (&pdev->enable_cnt) ==1 )pci_release_regions (pdev);
@@ -12789,6 +12798,20 @@ static void bnx2x_remove_one(struct pci_dev *pdev)pci_set_drvdata (pdev,NULL ); } +static void bnx2x_remove_one (struct pci_dev *pdev) +{ +struct net_device *dev =pci_get_drvdata (pdev); +struct bnx2x *bp; + +if (!dev) { +dev_err (&pdev->dev,"BAD net device from bnx2x_init_one\n" ); +return ; + } + bp =netdev_priv (dev); + +__bnx2x_remove (pdev, dev, bp, true); +} +static int bnx2x_eeh_nic_unload (struct bnx2x *bp) { bp->state =BNX2X_STATE_CLOSING_WAIT4_HALT ;
@@ -12968,6 +12991,29 @@ static const struct pci_error_handlers bnx2x_err_handler = { .resume = bnx2x_io_resume, }; +static void bnx2x_shutdown (struct pci_dev *pdev) +{ +struct net_device *dev =pci_get_drvdata (pdev); +struct bnx2x *bp; + +if (!dev) +return ; + + bp =netdev_priv (dev); +if (!bp) +return ; + +rtnl_lock (); +netif_device_detach (dev); +rtnl_unlock (); + +/* Don't remove the netdevice, as there are scenarios which will cause +* the kernel to hang, e.g., when trying to remove bnx2i while the +* rootfs is mounted from SAN. +*/ +__bnx2x_remove (pdev, dev, bp, false); +} +static struct pci_driver bnx2x_pci_driver = { .name =DRV_MODULE_NAME , .id_table = bnx2x_pci_tbl,
@@ -12979,6 +13025,7 @@ static struct pci_driver bnx2x_pci_driver = {#ifdef CONFIG_BNX2X_SRIOV .sriov_configure = bnx2x_sriov_configure, #endif + .shutdown = bnx2x_shutdown, };static int __init bnx2x_init (void )
Signature · 1 line
1.8.1.227.g44fe835
PATCH 3/6 bnx2x: Ack unknown VF messages
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
A PF should ack the firmware when receiving unknown messages through the VF's mailbox. This prevents the VF mailbox from being stuck in case of a VF sending a message unknown to the PF (e.g. VF with more advanced version).
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +4 -1
@@ -1605,8 +1605,11 @@ static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,bnx2x_vf_mbx_resp (bp, vf); }else {/* can't send a response since this VF is unknown to us -* just unlock the channel and be done with. +* just ack the FW to release the mailbox and unlock +* the channel. */ +storm_memset_vf_mbx_ack (bp, vf->abs_vfid); +mmiowb ();bnx2x_unlock_vf_pf_channel (bp, vf, mbx->first_tlv.tl.type); }
Signature · 1 line
1.8.1.227.g44fe835
PATCH 6/6 bnx2x: Change to D3hot only on removal
In reply to Yuval MintzThis changes the PCI power management scheme of the bnx2x driver to be similar to those of most network drivers - the driver will now changes the power state into D3hot whenever the driver will be removed, instead of whenever an interface is unloaded.
This change enables the driver to access its eeprom via ethtool callbacks even when interfaces are unloaded (such access requires the function to be in D0active).
--- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 31 +++++++++++++++++----- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 --- 2 files changed, 24 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +24 -7
@@ -1381,12 +1381,28 @@ static int bnx2x_nvram_read32(struct bnx2x *bp, u32 offset, u32 *buf,return rc; } +static bool bnx2x_is_nvm_accessible (struct bnx2x *bp) +{ +int rc =1 ; +u16 pm =0 ; +struct net_device *dev =pci_get_drvdata (bp->pdev); + +if (bp->pm_cap) + rc =pci_read_config_word (bp->pdev, + bp->pm_cap +PCI_PM_CTRL , &pm); + +if ((rc && !netif_running (dev)) || (!rc && ((pm &PCI_D0 ) !=PCI_D0 ))) +return false; + +return true; +} +static int bnx2x_get_eeprom (struct net_device *dev,struct ethtool_eeprom *eeprom,u8 *eebuf) {struct bnx2x *bp =netdev_priv (dev); -if (!netif_running (dev)) { +if (!bnx2x_is_nvm_accessible (bp)) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"cannot access eeprom when the interface is down\n" );return -EAGAIN ;
@@ -1411,7 +1427,7 @@ static int bnx2x_get_module_eeprom(struct net_device *dev,u8 *user_data = data;unsigned int start_addr = ee->offset, xfer_size =0 ; -if (!netif_running (dev)) { +if (!bnx2x_is_nvm_accessible (bp)) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"cannot access eeprom when the interface is down\n" );return -EAGAIN ;
@@ -1474,7 +1490,7 @@ static int bnx2x_get_module_info(struct net_device *dev,int phy_idx, rc;u8 sff8472_comp, diag_type; -if (!netif_running (dev)) { +if (!bnx2x_is_nvm_accessible (bp)) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"cannot access eeprom when the interface is down\n" );return -EAGAIN ;
@@ -1676,7 +1692,8 @@ static int bnx2x_set_eeprom(struct net_device *dev,int port =BP_PORT (bp);int rc =0 ;u32 ext_phy_config; -if (!netif_running (dev)) { + +if (!bnx2x_is_nvm_accessible (bp)) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"cannot access eeprom when the interface is down\n" );return -EAGAIN ;
@@ -2173,7 +2190,7 @@ static int bnx2x_test_registers(struct bnx2x *bp) { BNX2X_CHIP_MASK_ALL, 0xffffffff, 0, 0x00000000 } }; -if (!netif_running (bp->dev)) { +if (!bnx2x_is_nvm_accessible (bp)) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"cannot access eeprom when the interface is down\n" );return rc;
@@ -2277,7 +2294,7 @@ static int bnx2x_test_memory(struct bnx2x *bp) { NULL, 0xffffffff, {0, 0, 0, 0} } }; -if (!netif_running (bp->dev)) { +if (!bnx2x_is_nvm_accessible (bp)) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"cannot access eeprom when the interface is down\n" );return rc;
@@ -3140,7 +3157,7 @@ static int bnx2x_set_phys_id(struct net_device *dev, {struct bnx2x *bp =netdev_priv (dev); -if (!netif_running (dev)) { +if (!bnx2x_is_nvm_accessible (bp)) {DP (BNX2X_MSG_ETHTOOL |BNX2X_MSG_NVM ,"cannot access eeprom when the interface is down\n" );return -EAGAIN ;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +0 -3
@@ -11643,9 +11643,6 @@ static int bnx2x_close(struct net_device *dev)/* Unload the driver, release IRQs */ bnx2x_nic_unload (bp,UNLOAD_CLOSE , false); -/* Power off */ -bnx2x_set_power_state (bp, PCI_D3hot); -return 0 ; }
Signature · 1 line
1.8.1.227.g44fe835
David Miller
maintainerFrom: "Yuval Mintz" <[email protected]>
Date: Mon, 27 May 2013 17:08:25 +0300
Quoted 7 lines
This series contains several enhancements, mainly the implementation of the PCI shutdown callback which improves the bnx2x support in un-orderly shutdowns, and following that a change in the driver's power scheme which lowers PCI power state only when driver is removed (and as a result enable eeprom access on unloaded interfaces).
Please consider applying these patches to `net-next'.
Series applied, thanks.