aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEilon Greenstein <eilong@broadcom.com>2009-10-15 03:18:08 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-15 03:18:08 -0400
commitf34d28ea0174df63253dc20a95de0b48e3d8145a (patch)
treef3a1617b224b1305f6090ed05c33e16c136d8eb7
parent52a7a12fb560f22dd093ca74f3a768d51b044a40 (diff)
bnx2x: Changing the Disabled state to a flag
When working with DCC, a function can be disabled or enabled (virtual link down or up). Using the function state introduced some race conditions with the load/unload flow. Using a separate flag to indicate that the function is disabled. Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bnx2x.h2
-rw-r--r--drivers/net/bnx2x_main.c34
2 files changed, 20 insertions, 16 deletions
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index 60fa14f31d73..185a6bab2227 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -900,6 +900,7 @@ struct bnx2x {
900#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG) 900#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG)
901#define HW_VLAN_TX_FLAG 0x400 901#define HW_VLAN_TX_FLAG 0x400
902#define HW_VLAN_RX_FLAG 0x800 902#define HW_VLAN_RX_FLAG 0x800
903#define MF_FUNC_DIS 0x1000
903 904
904 int func; 905 int func;
905#define BP_PORT(bp) (bp->func % PORT_MAX) 906#define BP_PORT(bp) (bp->func % PORT_MAX)
@@ -965,7 +966,6 @@ struct bnx2x {
965#define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000 966#define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000
966#define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000 967#define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
967#define BNX2X_STATE_CLOSING_WAIT4_UNLOAD 0x6000 968#define BNX2X_STATE_CLOSING_WAIT4_UNLOAD 0x6000
968#define BNX2X_STATE_DISABLED 0xd000
969#define BNX2X_STATE_DIAG 0xe000 969#define BNX2X_STATE_DIAG 0xe000
970#define BNX2X_STATE_ERROR 0xf000 970#define BNX2X_STATE_ERROR 0xf000
971 971
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 691cf1541892..e7b3b27d16b6 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -1043,7 +1043,6 @@ static void bnx2x_sp_event(struct bnx2x_fastpath *fp,
1043 break; 1043 break;
1044 1044
1045 case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_CLOSING_WAIT4_HALT): 1045 case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_CLOSING_WAIT4_HALT):
1046 case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_DISABLED):
1047 DP(NETIF_MSG_IFDOWN, "got (un)set mac ramrod\n"); 1046 DP(NETIF_MSG_IFDOWN, "got (un)set mac ramrod\n");
1048 bp->set_mac_pending--; 1047 bp->set_mac_pending--;
1049 smp_wmb(); 1048 smp_wmb();
@@ -2157,7 +2156,7 @@ static void bnx2x_calc_fc_adv(struct bnx2x *bp)
2157 2156
2158static void bnx2x_link_report(struct bnx2x *bp) 2157static void bnx2x_link_report(struct bnx2x *bp)
2159{ 2158{
2160 if (bp->state == BNX2X_STATE_DISABLED) { 2159 if (bp->flags & MF_FUNC_DIS) {
2161 netif_carrier_off(bp->dev); 2160 netif_carrier_off(bp->dev);
2162 printk(KERN_ERR PFX "%s NIC Link is Down\n", bp->dev->name); 2161 printk(KERN_ERR PFX "%s NIC Link is Down\n", bp->dev->name);
2163 return; 2162 return;
@@ -2437,8 +2436,7 @@ static void bnx2x_link_attn(struct bnx2x *bp)
2437 memset(&(pstats->mac_stx[0]), 0, 2436 memset(&(pstats->mac_stx[0]), 0,
2438 sizeof(struct mac_stx)); 2437 sizeof(struct mac_stx));
2439 } 2438 }
2440 if ((bp->state == BNX2X_STATE_OPEN) || 2439 if (bp->state == BNX2X_STATE_OPEN)
2441 (bp->state == BNX2X_STATE_DISABLED))
2442 bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP); 2440 bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP);
2443 } 2441 }
2444 2442
@@ -2481,9 +2479,7 @@ static void bnx2x_link_attn(struct bnx2x *bp)
2481 2479
2482static void bnx2x__link_status_update(struct bnx2x *bp) 2480static void bnx2x__link_status_update(struct bnx2x *bp)
2483{ 2481{
2484 int func = BP_FUNC(bp); 2482 if ((bp->state != BNX2X_STATE_OPEN) || (bp->flags & MF_FUNC_DIS))
2485
2486 if (bp->state != BNX2X_STATE_OPEN)
2487 return; 2483 return;
2488 2484
2489 bnx2x_link_status_update(&bp->link_params, &bp->link_vars); 2485 bnx2x_link_status_update(&bp->link_params, &bp->link_vars);
@@ -2640,14 +2636,19 @@ static void bnx2x_dcc_event(struct bnx2x *bp, u32 dcc_event)
2640 2636
2641 if (dcc_event & DRV_STATUS_DCC_DISABLE_ENABLE_PF) { 2637 if (dcc_event & DRV_STATUS_DCC_DISABLE_ENABLE_PF) {
2642 2638
2639 /*
2640 * This is the only place besides the function initialization
2641 * where the bp->flags can change so it is done without any
2642 * locks
2643 */
2643 if (bp->mf_config & FUNC_MF_CFG_FUNC_DISABLED) { 2644 if (bp->mf_config & FUNC_MF_CFG_FUNC_DISABLED) {
2644 DP(NETIF_MSG_IFDOWN, "mf_cfg function disabled\n"); 2645 DP(NETIF_MSG_IFDOWN, "mf_cfg function disabled\n");
2645 bp->state = BNX2X_STATE_DISABLED; 2646 bp->flags |= MF_FUNC_DIS;
2646 2647
2647 bnx2x_e1h_disable(bp); 2648 bnx2x_e1h_disable(bp);
2648 } else { 2649 } else {
2649 DP(NETIF_MSG_IFUP, "mf_cfg function enabled\n"); 2650 DP(NETIF_MSG_IFUP, "mf_cfg function enabled\n");
2650 bp->state = BNX2X_STATE_OPEN; 2651 bp->flags &= ~MF_FUNC_DIS;
2651 2652
2652 bnx2x_e1h_enable(bp); 2653 bnx2x_e1h_enable(bp);
2653 } 2654 }
@@ -4695,8 +4696,7 @@ static void bnx2x_timer(unsigned long data)
4695 } 4696 }
4696 } 4697 }
4697 4698
4698 if ((bp->state == BNX2X_STATE_OPEN) || 4699 if (bp->state == BNX2X_STATE_OPEN)
4699 (bp->state == BNX2X_STATE_DISABLED))
4700 bnx2x_stats_handle(bp, STATS_EVENT_UPDATE); 4700 bnx2x_stats_handle(bp, STATS_EVENT_UPDATE);
4701 4701
4702timer_restart: 4702timer_restart:
@@ -7629,7 +7629,7 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
7629 if (CHIP_IS_E1H(bp)) 7629 if (CHIP_IS_E1H(bp))
7630 if (bp->mf_config & FUNC_MF_CFG_FUNC_DISABLED) { 7630 if (bp->mf_config & FUNC_MF_CFG_FUNC_DISABLED) {
7631 DP(NETIF_MSG_IFUP, "mf_cfg function disabled\n"); 7631 DP(NETIF_MSG_IFUP, "mf_cfg function disabled\n");
7632 bp->state = BNX2X_STATE_DISABLED; 7632 bp->flags |= MF_FUNC_DIS;
7633 } 7633 }
7634 7634
7635 if (bp->state == BNX2X_STATE_OPEN) { 7635 if (bp->state == BNX2X_STATE_OPEN) {
@@ -9034,7 +9034,9 @@ static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
9034 cmd->supported = bp->port.supported; 9034 cmd->supported = bp->port.supported;
9035 cmd->advertising = bp->port.advertising; 9035 cmd->advertising = bp->port.advertising;
9036 9036
9037 if (netif_carrier_ok(dev)) { 9037 if ((bp->state == BNX2X_STATE_OPEN) &&
9038 !(bp->flags & MF_FUNC_DIS) &&
9039 (bp->link_vars.link_up)) {
9038 cmd->speed = bp->link_vars.line_speed; 9040 cmd->speed = bp->link_vars.line_speed;
9039 cmd->duplex = bp->link_vars.duplex; 9041 cmd->duplex = bp->link_vars.duplex;
9040 if (IS_E1HMF(bp)) { 9042 if (IS_E1HMF(bp)) {
@@ -9433,6 +9435,9 @@ static u32 bnx2x_get_link(struct net_device *dev)
9433{ 9435{
9434 struct bnx2x *bp = netdev_priv(dev); 9436 struct bnx2x *bp = netdev_priv(dev);
9435 9437
9438 if (bp->flags & MF_FUNC_DIS)
9439 return 0;
9440
9436 return bp->link_vars.link_up; 9441 return bp->link_vars.link_up;
9437} 9442}
9438 9443
@@ -9837,8 +9842,7 @@ static int bnx2x_set_eeprom(struct net_device *dev,
9837 9842
9838 } else if (eeprom->magic == 0x50485952) { 9843 } else if (eeprom->magic == 0x50485952) {
9839 /* 'PHYR' (0x50485952): re-init link after FW upgrade */ 9844 /* 'PHYR' (0x50485952): re-init link after FW upgrade */
9840 if ((bp->state == BNX2X_STATE_OPEN) || 9845 if (bp->state == BNX2X_STATE_OPEN) {
9841 (bp->state == BNX2X_STATE_DISABLED)) {
9842 bnx2x_acquire_phy_lock(bp); 9846 bnx2x_acquire_phy_lock(bp);
9843 rc |= bnx2x_link_reset(&bp->link_params, 9847 rc |= bnx2x_link_reset(&bp->link_params,
9844 &bp->link_vars, 1); 9848 &bp->link_vars, 1);