bnx2x: Link flap avoidance added
cover bnx2x: Link flap avoidance added
Hi Dave,
In various flows in the bnx2x driver, the link is toggled unnecessarily - In such flows, if the link is already up it would be pulled down than raised up again, even if no change in the link was requested by the user.
This patch series tries to eliminate this problem, or at least to greatly reduce the number of cases that would actually cause such a scenario to happen.
Please consider applying this patch series to 'net-next'.
Thanks,
Yuval
PATCH 1/3 bnx2x: link code refactoring
From: Yaniv Rosner <[email protected]>
Separate the interrupt setting part of each external PHY to a specific function.
This allows calling the interrupt setting in case of link-flap avoidance, since some link owners may not enable the interrupt on their own.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 192 +++++++++++++--------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h | 1 + 2 files changed, 114 insertions(+), 79 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +113 -79
@@ -7203,6 +7203,22 @@ static void bnx2x_8073_set_pause_cl37(struct link_params *params,msleep (500 ); } +static void bnx2x_8073_specific_func (struct bnx2x_phy *phy, +struct link_params *params, +u32 action) +{ +struct bnx2x *bp = params->bp; +switch (action) { +case PHY_INIT : +/* Enable LASI */ +bnx2x_cl45_write (bp, phy, +MDIO_PMA_DEVAD ,MDIO_PMA_LASI_RXCTRL , (1 <<2 )); +bnx2x_cl45_write (bp, phy, +MDIO_PMA_DEVAD ,MDIO_PMA_LASI_CTRL ,0x0004 ); +break ; + } +} +static int bnx2x_8073_config_init (struct bnx2x_phy *phy,struct link_params *params,struct link_vars *vars)
@@ -7223,12 +7239,7 @@ static int bnx2x_8073_config_init(struct bnx2x_phy *phy,bnx2x_set_gpio (bp,MISC_REGISTERS_GPIO_1 ,MISC_REGISTERS_GPIO_OUTPUT_HIGH , gpio_port); -/* Enable LASI */ -bnx2x_cl45_write (bp, phy, -MDIO_PMA_DEVAD ,MDIO_PMA_LASI_RXCTRL , (1 <<2 )); -bnx2x_cl45_write (bp, phy, -MDIO_PMA_DEVAD ,MDIO_PMA_LASI_CTRL ,0x0004 ); - +bnx2x_8073_specific_func (phy, params,PHY_INIT );bnx2x_8073_set_pause_cl37 (params, phy, vars); bnx2x_cl45_read(bp, phy,
@@ -8263,7 +8274,7 @@ static void bnx2x_8727_specific_func(struct bnx2x_phy *phy, u32 action) {struct bnx2x *bp = params->bp; - +u16 val;switch (action) {case DISABLE_TX :bnx2x_sfp_set_transmitter (params, phy,0 );
@@ -8272,6 +8283,40 @@ static void bnx2x_8727_specific_func(struct bnx2x_phy *phy,if (!(phy->flags &FLAGS_SFP_NOT_APPROVED ))bnx2x_sfp_set_transmitter (params, phy,1 );break ; +case PHY_INIT : +bnx2x_cl45_write (bp, phy, +MDIO_PMA_DEVAD ,MDIO_PMA_LASI_RXCTRL , + (1 <<2 ) | (1 <<5 )); +bnx2x_cl45_write (bp, phy, +MDIO_PMA_DEVAD ,MDIO_PMA_LASI_TXCTRL , +0 ); +bnx2x_cl45_write (bp, phy, +MDIO_PMA_DEVAD ,MDIO_PMA_LASI_CTRL ,0x0006 ); +/* Make MOD_ABS give interrupt on change */ +bnx2x_cl45_read (bp, phy,MDIO_PMA_DEVAD , +MDIO_PMA_REG_8727_PCS_OPT_CTRL , + &val); + val |= (1 <<12 ); +if (phy->flags &FLAGS_NOC ) + val |= (3 <<5 ); +/* Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 +* status which reflect SFP+ module over-current +*/ +if (!(phy->flags &FLAGS_NOC )) + val &=0xff8f ;/* Reset bits 4-6 */ +bnx2x_cl45_write (bp, phy, +MDIO_PMA_DEVAD ,MDIO_PMA_REG_8727_PCS_OPT_CTRL , + val); + +/* Set 2-wire transfer rate of SFP+ module EEPROM +* to 100Khz since some DACs(direct attached cables) do +* not work at 400Khz. +*/ +bnx2x_cl45_write (bp, phy, +MDIO_PMA_DEVAD , +MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR , +0xa001 ); +break ;default :DP (NETIF_MSG_LINK ,"Function 0x%x not supported by 8727\n" , action);
@@ -9054,28 +9099,15 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy, struct link_vars *vars) {u32 tx_en_mode; -u16 tmp1, val, mod_abs, tmp2; -u16 rx_alarm_ctrl_val; -u16 lasi_ctrl_val; +u16 tmp1, mod_abs, tmp2;struct bnx2x *bp = params->bp;/* Enable PMD link, MOD_ABS_FLT, and 1G link alarm */ bnx2x_wait_reset_complete (bp, phy, params); - rx_alarm_ctrl_val = (1 <<2 ) | (1 <<5 ) ; -/* Should be 0x6 to enable XS on Tx side. */ - lasi_ctrl_val =0x0006 ;DP (NETIF_MSG_LINK ,"Initializing BCM8727\n" ); -/* Enable LASI */ -bnx2x_cl45_write (bp, phy, -MDIO_PMA_DEVAD ,MDIO_PMA_LASI_RXCTRL , - rx_alarm_ctrl_val); -bnx2x_cl45_write (bp, phy, -MDIO_PMA_DEVAD ,MDIO_PMA_LASI_TXCTRL , -0 ); -bnx2x_cl45_write (bp, phy, -MDIO_PMA_DEVAD ,MDIO_PMA_LASI_CTRL , lasi_ctrl_val); +bnx2x_8727_specific_func (phy, params,PHY_INIT );/* Initially configure MOD_ABS to interrupt when module is * presence( bit 8) */
@@ -9091,25 +9123,9 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy,bnx2x_cl45_write (bp, phy,MDIO_PMA_DEVAD ,MDIO_PMA_REG_PHY_IDENTIFIER , mod_abs); -/* Enable/Disable PHY transmitter output */ bnx2x_set_disable_pmd_transmit (params, phy,0 ); -/* Make MOD_ABS give interrupt on change */ -bnx2x_cl45_read (bp, phy,MDIO_PMA_DEVAD ,MDIO_PMA_REG_8727_PCS_OPT_CTRL , - &val); - val |= (1 <<12 ); -if (phy->flags &FLAGS_NOC ) - val |= (3 <<5 ); - -/* Set 8727 GPIOs to input to allow reading from the 8727 GPIO0 -* status which reflect SFP+ module over-current -*/ -if (!(phy->flags &FLAGS_NOC )) - val &=0xff8f ;/* Reset bits 4-6 */ -bnx2x_cl45_write (bp, phy, -MDIO_PMA_DEVAD ,MDIO_PMA_REG_8727_PCS_OPT_CTRL , val); -bnx2x_8727_power_module (bp, phy,1 ); bnx2x_cl45_read(bp, phy,
@@ -9119,13 +9135,7 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy, MDIO_PMA_DEVAD, MDIO_PMA_LASI_RXSTAT, &tmp1);bnx2x_8727_config_speed (phy, params); -/* Set 2-wire transfer rate of SFP+ module EEPROM -* to 100Khz since some DACs(direct attached cables) do -* not work at 400Khz. -*/ -bnx2x_cl45_write (bp, phy, -MDIO_PMA_DEVAD ,MDIO_PMA_REG_8727_TWO_WIRE_SLAVE_ADDR , -0xa001 ); +/* Set TX PreEmphasis if needed */ if ((params->feature_config_flags &
@@ -9554,6 +9564,29 @@ static void bnx2x_848xx_set_led(struct bnx2x *bp, 0xFFFB, 0xFFFD); } +static void bnx2x_848xx_specific_func (struct bnx2x_phy *phy, +struct link_params *params, +u32 action) +{ +struct bnx2x *bp = params->bp; +switch (action) { +case PHY_INIT : +if (phy->type !=PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833 ) { +/* Save spirom version */ +bnx2x_save_848xx_spirom_version (phy, bp, params->port); + } +/* This phy uses the NIG latch mechanism since link indication +* arrives through its LED4 and not via its LASI signal, so we +* get steady signal instead of clear on read +*/ +bnx2x_bits_en (bp,NIG_REG_LATCH_BC_0 + params->port*4 , +1 <<NIG_LATCH_BC_ENABLE_MI_INT ); + +bnx2x_848xx_set_led (bp, phy); +break ; + } +} +static int bnx2x_848xx_cmn_config_init (struct bnx2x_phy *phy,struct link_params *params,struct link_vars *vars)
@@ -9561,22 +9594,10 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy,struct bnx2x *bp = params->bp;u16 autoneg_val, an_1000_val, an_10_100_val, an_10g_val; -if (phy->type !=PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833 ) { -/* Save spirom version */ -bnx2x_save_848xx_spirom_version (phy, bp, params->port); - } -/* This phy uses the NIG latch mechanism since link indication -* arrives through its LED4 and not via its LASI signal, so we -* get steady signal instead of clear on read -*/ -bnx2x_bits_en (bp,NIG_REG_LATCH_BC_0 + params->port*4 , -1 <<NIG_LATCH_BC_ENABLE_MI_INT ); - +bnx2x_848xx_specific_func (phy, params,PHY_INIT );bnx2x_cl45_write (bp, phy,MDIO_PMA_DEVAD ,MDIO_PMA_REG_CTRL ,0x0000 ); -bnx2x_848xx_set_led (bp, phy); -/* set 1000 speed advertisement */ bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL,
@@ -10565,6 +10586,35 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy,/******************************************************************/ /* 54618SE PHY SECTION */ /******************************************************************/ +static void bnx2x_54618se_specific_func (struct bnx2x_phy *phy, +struct link_params *params, +u32 action) +{ +struct bnx2x *bp = params->bp; +u16 temp; +switch (action) { +case PHY_INIT : +/* Configure LED4: set to INTR (0x6). */ +/* Accessing shadow register 0xe. */ +bnx2x_cl22_write (bp, phy, +MDIO_REG_GPHY_SHADOW , +MDIO_REG_GPHY_SHADOW_LED_SEL2 ); +bnx2x_cl22_read (bp, phy, +MDIO_REG_GPHY_SHADOW , + &temp); + temp &= ~(0xf <<4 ); + temp |= (0x6 <<4 ); +bnx2x_cl22_write (bp, phy, +MDIO_REG_GPHY_SHADOW , +MDIO_REG_GPHY_SHADOW_WR_ENA | temp); +/* Configure INTR based on link status change. */ +bnx2x_cl22_write (bp, phy, +MDIO_REG_INTR_MASK , + ~MDIO_REG_INTR_MASK_LINK_STATUS ); +break ; + } +} +static int bnx2x_54618se_config_init (struct bnx2x_phy *phy,struct link_params *params,struct link_vars *vars)
@@ -10602,24 +10652,8 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy,/* Wait for GPHY to reset */ msleep (50 ); -/* Configure LED4: set to INTR (0x6). */ -/* Accessing shadow register 0xe. */ -bnx2x_cl22_write (bp, phy, -MDIO_REG_GPHY_SHADOW , -MDIO_REG_GPHY_SHADOW_LED_SEL2 ); -bnx2x_cl22_read (bp, phy, -MDIO_REG_GPHY_SHADOW , - &temp); - temp &= ~(0xf <<4 ); - temp |= (0x6 <<4 ); -bnx2x_cl22_write (bp, phy, -MDIO_REG_GPHY_SHADOW , -MDIO_REG_GPHY_SHADOW_WR_ENA | temp); -/* Configure INTR based on link status change. */ -bnx2x_cl22_write (bp, phy, -MDIO_REG_INTR_MASK , - ~MDIO_REG_INTR_MASK_LINK_STATUS ); +bnx2x_54618se_specific_func (phy, params,PHY_INIT );/* Flip the signal detect polarity (set 0x1c.0x1e[8]). */ bnx2x_cl22_write(bp, phy, MDIO_REG_GPHY_SHADOW,
@@ -11349,7 +11383,7 @@ static struct bnx2x_phy phy_8073 = { .format_fw_ver = (format_fw_ver_t)bnx2x_format_ver, .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)NULL, - .phy_specific_func = (phy_specific_func_t)NULL + .phy_specific_func = (phy_specific_func_t)bnx2x_8073_specific_func };static struct bnx2x_phy phy_8705 = { .type =PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705 ,
@@ -11542,7 +11576,7 @@ static struct bnx2x_phy phy_84823 = { .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, - .phy_specific_func = (phy_specific_func_t)NULL + .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func };static struct bnx2x_phy phy_84833 = {
@@ -11578,7 +11612,7 @@ static struct bnx2x_phy phy_84833 = { .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, - .phy_specific_func = (phy_specific_func_t)NULL + .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func };static struct bnx2x_phy phy_54618se = {
@@ -11612,7 +11646,7 @@ static struct bnx2x_phy phy_54618se = { .format_fw_ver = (format_fw_ver_t)NULL, .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)bnx2x_5461x_set_link_led, - .phy_specific_func = (phy_specific_func_t)NULL + .phy_specific_func = (phy_specific_func_t)bnx2x_54618se_specific_func };/*****************************************************************/ /* */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h +1 -0
@@ -216,6 +216,7 @@ struct bnx2x_phy {phy_specific_func_t phy_specific_func;#define DISABLE_TX 1#define ENABLE_TX 2 +#define PHY_INIT 3 };/* Inputs parameters to the CLC */
Signature · 1 line
1.7.9.rc2
PATCH 2/3 bnx2x: Link Flap Avoidance
In reply to Yuval MintzFrom: Yaniv Rosner <[email protected]>
Various flows in the bnx2x driver cause a link-flap - if the link is up, it would be toggled down (after a mac/phy reset) and then taken back up.
In many of these cases, there is no need to do cause such a flap, as the associated flows should not actually affect the link.
This patch adds the 'Link Flap Avoidance' mechanism, which allows the driver to better determine if a given flow requires a link change, and thus minimize the number of link flaps caused by the driver.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 48 +++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 435 +++++++++++++++++++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h | 2 + 3 files changed, 437 insertions(+), 48 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h +48 -0
@@ -1909,6 +1909,54 @@ struct lldp_local_mib { };/***END OF DCBX STRUCTURES DECLARATIONS***/ +/***********************************************************/ +/* Elink section */ +/***********************************************************/ +#define SHMEM_LINK_CONFIG_SIZE 2 +struct shmem_lfa { +u32 req_duplex; +#define REQ_DUPLEX_PHY0_MASK 0x0000ffff +#define REQ_DUPLEX_PHY0_SHIFT 0 +#define REQ_DUPLEX_PHY1_MASK 0xffff0000 +#define REQ_DUPLEX_PHY1_SHIFT 16 +u32 req_flow_ctrl; +#define REQ_FLOW_CTRL_PHY0_MASK 0x0000ffff +#define REQ_FLOW_CTRL_PHY0_SHIFT 0 +#define REQ_FLOW_CTRL_PHY1_MASK 0xffff0000 +#define REQ_FLOW_CTRL_PHY1_SHIFT 16 +u32 req_line_speed;/* Also determine AutoNeg */ +#define REQ_LINE_SPD_PHY0_MASK 0x0000ffff +#define REQ_LINE_SPD_PHY0_SHIFT 0 +#define REQ_LINE_SPD_PHY1_MASK 0xffff0000 +#define REQ_LINE_SPD_PHY1_SHIFT 16 +u32 speed_cap_mask[SHMEM_LINK_CONFIG_SIZE ]; +u32 additional_config; +#define REQ_FC_AUTO_ADV_MASK 0x0000ffff +#define REQ_FC_AUTO_ADV0_SHIFT 0 +#define NO_LFA_DUE_TO_DCC_MASK 0x00010000 +u32 lfa_sts; +#define LFA_LINK_FLAP_REASON_OFFSET 0 +#define LFA_LINK_FLAP_REASON_MASK 0x000000ff +#define LFA_LINK_DOWN 0x1 +#define LFA_LOOPBACK_ENABLED 0x2 +#define LFA_DUPLEX_MISMATCH 0x3 +#define LFA_MFW_IS_TOO_OLD 0x4 +#define LFA_LINK_SPEED_MISMATCH 0x5 +#define LFA_FLOW_CTRL_MISMATCH 0x6 +#define LFA_SPEED_CAP_MISMATCH 0x7 +#define LFA_DCC_LFA_DISABLED 0x8 +#define LFA_EEE_MISMATCH 0x9 + +#define LINK_FLAP_AVOIDANCE_COUNT_OFFSET 8 +#define LINK_FLAP_AVOIDANCE_COUNT_MASK 0x0000ff00 + +#define LINK_FLAP_COUNT_OFFSET 16 +#define LINK_FLAP_COUNT_MASK 0x00ff0000 + +#define LFA_FLAGS_MASK 0xff000000 +#define SHMEM_LFA_DONT_CLEAR_STAT (1<<24) +}; +struct ncsi_oem_fcoe_features {u32 fcoe_features1;#define FCOE_FEATURES1_IOS_PER_CONNECTION_MASK 0x0000FFFF
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +387 -48
561 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h +2 -0
@@ -305,6 +305,8 @@ struct link_params {struct bnx2x *bp;u16 req_fc_auto_adv;/* Should be set to TX / BOTH when req_flow_ctrl is set to AUTO */ +u16 rsrv1; +u32 lfa_base; };/* Output parameters */
Signature · 1 line
1.7.9.rc2
PATCH 3/3 bnx2x: Utilize Link Flap Avoidance
In reply to Yuval MintzChange various flows in the bnx2x driver which up until now flapped the link - these flows now benefit from the link flap avoidance mechanism.
This includes the removal of the link reset made upon nic init, as it is possible the link is already active at that time.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 12 +++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 16 +++++++-- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 10 +++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 3 ++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 34 +++++++++++++------- 6 files changed, 51 insertions(+), 26 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +6 -6
@@ -2283,7 +2283,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)/* Wait for all pending SP commands to complete */ if (!bnx2x_wait_sp_comp (bp, ~0x0UL )) {BNX2X_ERR ("Timeout waiting for SP elements to complete\n" ); -bnx2x_nic_unload (bp,UNLOAD_CLOSE ); +bnx2x_nic_unload (bp,UNLOAD_CLOSE , false);return -EBUSY ; }
@@ -2331,7 +2331,7 @@ load_error0: }/* must be called with rtnl_lock */ -int bnx2x_nic_unload (struct bnx2x *bp,int unload_mode) +int bnx2x_nic_unload (struct bnx2x *bp,int unload_mode,bool keep_link) {int i;bool global = false;
@@ -2393,7 +2393,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode)/* Cleanup the chip if needed */ if (unload_mode !=UNLOAD_RECOVERY ) -bnx2x_chip_cleanup (bp, unload_mode); +bnx2x_chip_cleanup (bp, unload_mode, keep_link);else {/* Send the UNLOAD_REQUEST to the MCP */ bnx2x_send_unload_req (bp, unload_mode);
@@ -2417,7 +2417,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode)bnx2x_free_irq (bp);/* Report UNLOAD_DONE to MCP */ -bnx2x_send_unload_done (bp); +bnx2x_send_unload_done (bp, false); }/*
@@ -3768,7 +3768,7 @@ int bnx2x_reload_if_running(struct net_device *dev)if (unlikely (!netif_running (dev)))return 0 ; -bnx2x_nic_unload (bp,UNLOAD_NORMAL ); +bnx2x_nic_unload (bp,UNLOAD_NORMAL , true);return bnx2x_nic_load (bp,LOAD_NORMAL ); }
@@ -3965,7 +3965,7 @@ int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state)netif_device_detach (dev); -bnx2x_nic_unload (bp,UNLOAD_CLOSE ); +bnx2x_nic_unload (bp,UNLOAD_CLOSE , false);bnx2x_set_power_state (bp,pci_choose_state (pdev, state));
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +13 -3
@@ -83,8 +83,9 @@ u32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode);* bnx2x_send_unload_done - send UNLOAD_DONE command to the MCP. * * @bp: driver handle +* @keep_link: true iff link should be kept up */ -void bnx2x_send_unload_done (struct bnx2x *bp); +void bnx2x_send_unload_done (struct bnx2x *bp,bool keep_link);/** * bnx2x_config_rss_pf - configure RSS parameters in a PF.
@@ -153,6 +154,14 @@ u8 bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode);void bnx2x_link_set (struct bnx2x *bp);/** +* bnx2x_force_link_reset - Forces link reset, and put the PHY +* in reset as well. +* +* @bp: driver handle +*/ +void bnx2x_force_link_reset (struct bnx2x *bp); + +/** * bnx2x_link_test - query link status. * * @bp: driver handle
@@ -312,12 +321,13 @@ void bnx2x_set_num_queues(struct bnx2x *bp);* * @bp: driver handle * @unload_mode: COMMON, PORT, FUNCTION +* @keep_link: true iff link should be kept up. * * - Cleanup MAC configuration. * - Closes clients. * - etc. */ -void bnx2x_chip_cleanup (struct bnx2x *bp,int unload_mode); +void bnx2x_chip_cleanup (struct bnx2x *bp,int unload_mode,bool keep_link);/** * bnx2x_acquire_hw_lock - acquire HW lock.
@@ -446,7 +456,7 @@ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl);bool bnx2x_test_firmware_version (struct bnx2x *bp,bool is_err);/* dev_close main block */ -int bnx2x_nic_unload (struct bnx2x *bp,int unload_mode); +int bnx2x_nic_unload (struct bnx2x *bp,int unload_mode,bool keep_link);/* dev_open main block */ int bnx2x_nic_load (struct bnx2x *bp,int load_mode);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +6 -4
@@ -905,6 +905,7 @@ static int bnx2x_nway_reset(struct net_device *dev)if (netif_running (dev)) {bnx2x_stats_handle (bp,STATS_EVENT_STOP ); +bnx2x_force_link_reset (bp);bnx2x_link_set (bp); }
@@ -1733,6 +1734,7 @@ static int bnx2x_set_eee(struct net_device *dev, struct ethtool_eee *edata)/* Restart link to propogate changes */ if (netif_running (dev)) {bnx2x_stats_handle (bp,STATS_EVENT_STOP ); +bnx2x_force_link_reset (bp);bnx2x_link_set (bp); }
@@ -2257,7 +2259,7 @@ static int bnx2x_test_ext_loopback(struct bnx2x *bp)if (!netif_running (bp->dev))return BNX2X_EXT_LOOPBACK_FAILED ; -bnx2x_nic_unload (bp,UNLOAD_NORMAL ); +bnx2x_nic_unload (bp,UNLOAD_NORMAL , false); rc =bnx2x_nic_load (bp,LOAD_LOOPBACK_EXT );if (rc) { DP(BNX2X_MSG_ETHTOOL,
@@ -2408,7 +2410,7 @@ static void bnx2x_self_test(struct net_device *dev, link_up = bp->link_vars.link_up; -bnx2x_nic_unload (bp,UNLOAD_NORMAL ); +bnx2x_nic_unload (bp,UNLOAD_NORMAL , false); rc =bnx2x_nic_load (bp,LOAD_DIAG );if (rc) { etest->flags |=ETH_TEST_FL_FAILED ;
@@ -2440,7 +2442,7 @@ static void bnx2x_self_test(struct net_device *dev, etest->flags |=ETH_TEST_FL_EXTERNAL_LB_DONE ; } -bnx2x_nic_unload (bp,UNLOAD_NORMAL ); +bnx2x_nic_unload (bp,UNLOAD_NORMAL , false);/* restore input for TX port IF */ REG_WR (bp,NIG_REG_EGRESS_UMP0_IN_EN + port*4 , val);
@@ -2934,7 +2936,7 @@ static int bnx2x_set_channels(struct net_device *dev,bnx2x_change_num_queues (bp, channels->combined_count);return 0 ; } -bnx2x_nic_unload (bp,UNLOAD_NORMAL ); +bnx2x_nic_unload (bp,UNLOAD_NORMAL , true);bnx2x_change_num_queues (bp, channels->combined_count);return bnx2x_nic_load (bp,LOAD_NORMAL ); }
drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h +3 -0
@@ -1286,6 +1286,9 @@ struct drv_func_mb {#define DRV_MSG_CODE_SET_MF_BW_MIN_MASK 0x00ff0000#define DRV_MSG_CODE_SET_MF_BW_MAX_MASK 0xff000000 +#define DRV_MSG_CODE_UNLOAD_SKIP_LINK_RESET 0x00000002 + +#define DRV_MSG_CODE_LOAD_REQ_WITH_LFA 0x0000100au32 fw_mb_header;#define FW_MSG_CODE_MASK 0xffff0000#define FW_MSG_CODE_DRV_LOAD_COMMON 0x10100000
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h +1 -1
@@ -359,7 +359,7 @@ int bnx2x_phy_init(struct link_params *params, struct link_vars *vars);to 0 */ int bnx2x_link_reset (struct link_params *params,struct link_vars *vars,u8 reset_ext_phy); - +int bnx2x_lfa_reset (struct link_params *params,struct link_vars *vars);/* bnx2x_link_update should be called upon link interrupt */ int bnx2x_link_update (struct link_params *params,struct link_vars *vars);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +22 -12
@@ -2171,7 +2171,6 @@ void bnx2x_link_set(struct bnx2x *bp) {if (!BP_NOMCP (bp)) {bnx2x_acquire_phy_lock (bp); -bnx2x_link_reset (&bp->link_params, &bp->link_vars,1 );bnx2x_phy_init (&bp->link_params, &bp->link_vars);bnx2x_release_phy_lock (bp);
@@ -2184,12 +2183,19 @@ static void bnx2x__link_reset(struct bnx2x *bp) {if (!BP_NOMCP (bp)) {bnx2x_acquire_phy_lock (bp); -bnx2x_link_reset (&bp->link_params, &bp->link_vars,1 ); +bnx2x_lfa_reset (&bp->link_params, &bp->link_vars);bnx2x_release_phy_lock (bp); }else BNX2X_ERR ("Bootcode is missing - can not reset link\n" ); } +void bnx2x_force_link_reset (struct bnx2x *bp) +{ +bnx2x_acquire_phy_lock (bp); +bnx2x_link_reset (&bp->link_params, &bp->link_vars,1 ); +bnx2x_release_phy_lock (bp); +} +u8 bnx2x_link_test (struct bnx2x *bp,u8 is_serdes) {u8 rc =0 ;
@@ -6757,7 +6763,6 @@ static int bnx2x_init_hw_port(struct bnx2x *bp)u32 low, high;u32 val; -bnx2x__link_reset (bp);DP (NETIF_MSG_HW ,"starting port init port %d\n" , port);
@@ -8244,12 +8249,15 @@ u32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode)* bnx2x_send_unload_done - send UNLOAD_DONE command to the MCP. * * @bp: driver handle +* @keep_link: true iff link should be kept up */ -void bnx2x_send_unload_done (struct bnx2x *bp) +void bnx2x_send_unload_done (struct bnx2x *bp,bool keep_link) { +u32 reset_param = keep_link ?DRV_MSG_CODE_UNLOAD_SKIP_LINK_RESET :0 ; +/* Report UNLOAD_DONE to MCP */ if (!BP_NOMCP (bp)) -bnx2x_fw_command (bp,DRV_MSG_CODE_UNLOAD_DONE ,0 ); +bnx2x_fw_command (bp,DRV_MSG_CODE_UNLOAD_DONE , reset_param); }static int bnx2x_func_wait_started (struct bnx2x *bp)
@@ -8318,7 +8326,7 @@ static int bnx2x_func_wait_started(struct bnx2x *bp)return 0 ; } -void bnx2x_chip_cleanup (struct bnx2x *bp,int unload_mode) +void bnx2x_chip_cleanup (struct bnx2x *bp,int unload_mode,bool keep_link) {int port =BP_PORT (bp);int i, rc =0 ;
@@ -8440,7 +8448,7 @@ unload_error:/* Report UNLOAD_DONE to MCP */ -bnx2x_send_unload_done (bp); +bnx2x_send_unload_done (bp, keep_link); }void bnx2x_disable_close_the_gate (struct bnx2x *bp)
@@ -8852,7 +8860,8 @@ int bnx2x_leader_reset(struct bnx2x *bp)* driver is owner of the HW */ if (!global && !BP_NOMCP (bp)) { - load_code =bnx2x_fw_command (bp,DRV_MSG_CODE_LOAD_REQ ,0 ); + load_code =bnx2x_fw_command (bp,DRV_MSG_CODE_LOAD_REQ , +DRV_MSG_CODE_LOAD_REQ_WITH_LFA );if (!load_code) {BNX2X_ERR ("MCP response failure, aborting\n" ); rc = -EAGAIN ;
@@ -8958,7 +8967,7 @@ static void bnx2x_parity_recover(struct bnx2x *bp)/* Stop the driver */ /* If interface has been removed - break */ -if (bnx2x_nic_unload (bp,UNLOAD_RECOVERY )) +if (bnx2x_nic_unload (bp,UNLOAD_RECOVERY , false))return ; bp->recovery_state =BNX2X_RECOVERY_WAIT ;
@@ -9124,7 +9133,7 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work) bp->sp_rtnl_state =0 ;smp_mb (); -bnx2x_nic_unload (bp,UNLOAD_NORMAL ); +bnx2x_nic_unload (bp,UNLOAD_NORMAL , true);bnx2x_nic_load (bp,LOAD_NORMAL ); goto sp_rtnl_exit;
@@ -9310,7 +9319,8 @@ static void __devinit bnx2x_prev_unload_undi_inc(struct bnx2x *bp, u8 port,static int __devinit bnx2x_prev_mcp_done (struct bnx2x *bp) { -u32 rc =bnx2x_fw_command (bp,DRV_MSG_CODE_UNLOAD_DONE ,0 ); +u32 rc =bnx2x_fw_command (bp,DRV_MSG_CODE_UNLOAD_DONE , +DRV_MSG_CODE_UNLOAD_SKIP_LINK_RESET );if (!rc) {BNX2X_ERR ("MCP response failure, aborting\n" );return -EBUSY ;
@@ -11005,7 +11015,7 @@ static int bnx2x_close(struct net_device *dev)struct bnx2x *bp =netdev_priv (dev);/* Unload the driver, release IRQs */ -bnx2x_nic_unload (bp,UNLOAD_CLOSE ); +bnx2x_nic_unload (bp,UNLOAD_CLOSE , false);/* Power off */ bnx2x_set_power_state (bp, PCI_D3hot);
Signature · 1 line
1.7.9.rc2
David Miller
maintainerFrom: "Yuval Mintz" <[email protected]>
Date: Thu, 13 Sep 2012 15:56:18 +0300
Quoted 10 lines
In various flows in the bnx2x driver, the link is toggled unnecessarily - In such flows, if the link is already up it would be pulled down than raised up again, even if no change in the link was requested by the user.
This patch series tries to eliminate this problem, or at least to greatly reduce the number of cases that would actually cause such a scenario to happen.
Please consider applying this patch series to 'net-next'.
All applied, thanks.