提交 f34d28ea 编写于 作者: E Eilon Greenstein 提交者: David S. Miller

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: NEilon Greenstein <eilong@broadcom.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 52a7a12f
...@@ -900,6 +900,7 @@ struct bnx2x { ...@@ -900,6 +900,7 @@ struct bnx2x {
#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG) #define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG)
#define HW_VLAN_TX_FLAG 0x400 #define HW_VLAN_TX_FLAG 0x400
#define HW_VLAN_RX_FLAG 0x800 #define HW_VLAN_RX_FLAG 0x800
#define MF_FUNC_DIS 0x1000
int func; int func;
#define BP_PORT(bp) (bp->func % PORT_MAX) #define BP_PORT(bp) (bp->func % PORT_MAX)
...@@ -965,7 +966,6 @@ struct bnx2x { ...@@ -965,7 +966,6 @@ struct bnx2x {
#define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000 #define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000
#define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000 #define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
#define BNX2X_STATE_CLOSING_WAIT4_UNLOAD 0x6000 #define BNX2X_STATE_CLOSING_WAIT4_UNLOAD 0x6000
#define BNX2X_STATE_DISABLED 0xd000
#define BNX2X_STATE_DIAG 0xe000 #define BNX2X_STATE_DIAG 0xe000
#define BNX2X_STATE_ERROR 0xf000 #define BNX2X_STATE_ERROR 0xf000
......
...@@ -1043,7 +1043,6 @@ static void bnx2x_sp_event(struct bnx2x_fastpath *fp, ...@@ -1043,7 +1043,6 @@ static void bnx2x_sp_event(struct bnx2x_fastpath *fp,
break; break;
case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_CLOSING_WAIT4_HALT): case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_CLOSING_WAIT4_HALT):
case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_DISABLED):
DP(NETIF_MSG_IFDOWN, "got (un)set mac ramrod\n"); DP(NETIF_MSG_IFDOWN, "got (un)set mac ramrod\n");
bp->set_mac_pending--; bp->set_mac_pending--;
smp_wmb(); smp_wmb();
...@@ -2157,7 +2156,7 @@ static void bnx2x_calc_fc_adv(struct bnx2x *bp) ...@@ -2157,7 +2156,7 @@ static void bnx2x_calc_fc_adv(struct bnx2x *bp)
static void bnx2x_link_report(struct bnx2x *bp) static void bnx2x_link_report(struct bnx2x *bp)
{ {
if (bp->state == BNX2X_STATE_DISABLED) { if (bp->flags & MF_FUNC_DIS) {
netif_carrier_off(bp->dev); netif_carrier_off(bp->dev);
printk(KERN_ERR PFX "%s NIC Link is Down\n", bp->dev->name); printk(KERN_ERR PFX "%s NIC Link is Down\n", bp->dev->name);
return; return;
...@@ -2437,8 +2436,7 @@ static void bnx2x_link_attn(struct bnx2x *bp) ...@@ -2437,8 +2436,7 @@ static void bnx2x_link_attn(struct bnx2x *bp)
memset(&(pstats->mac_stx[0]), 0, memset(&(pstats->mac_stx[0]), 0,
sizeof(struct mac_stx)); sizeof(struct mac_stx));
} }
if ((bp->state == BNX2X_STATE_OPEN) || if (bp->state == BNX2X_STATE_OPEN)
(bp->state == BNX2X_STATE_DISABLED))
bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP); bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP);
} }
...@@ -2481,9 +2479,7 @@ static void bnx2x_link_attn(struct bnx2x *bp) ...@@ -2481,9 +2479,7 @@ static void bnx2x_link_attn(struct bnx2x *bp)
static void bnx2x__link_status_update(struct bnx2x *bp) static void bnx2x__link_status_update(struct bnx2x *bp)
{ {
int func = BP_FUNC(bp); if ((bp->state != BNX2X_STATE_OPEN) || (bp->flags & MF_FUNC_DIS))
if (bp->state != BNX2X_STATE_OPEN)
return; return;
bnx2x_link_status_update(&bp->link_params, &bp->link_vars); 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,14 +2636,19 @@ static void bnx2x_dcc_event(struct bnx2x *bp, u32 dcc_event)
if (dcc_event & DRV_STATUS_DCC_DISABLE_ENABLE_PF) { if (dcc_event & DRV_STATUS_DCC_DISABLE_ENABLE_PF) {
/*
* This is the only place besides the function initialization
* where the bp->flags can change so it is done without any
* locks
*/
if (bp->mf_config & FUNC_MF_CFG_FUNC_DISABLED) { if (bp->mf_config & FUNC_MF_CFG_FUNC_DISABLED) {
DP(NETIF_MSG_IFDOWN, "mf_cfg function disabled\n"); DP(NETIF_MSG_IFDOWN, "mf_cfg function disabled\n");
bp->state = BNX2X_STATE_DISABLED; bp->flags |= MF_FUNC_DIS;
bnx2x_e1h_disable(bp); bnx2x_e1h_disable(bp);
} else { } else {
DP(NETIF_MSG_IFUP, "mf_cfg function enabled\n"); DP(NETIF_MSG_IFUP, "mf_cfg function enabled\n");
bp->state = BNX2X_STATE_OPEN; bp->flags &= ~MF_FUNC_DIS;
bnx2x_e1h_enable(bp); bnx2x_e1h_enable(bp);
} }
...@@ -4695,8 +4696,7 @@ static void bnx2x_timer(unsigned long data) ...@@ -4695,8 +4696,7 @@ static void bnx2x_timer(unsigned long data)
} }
} }
if ((bp->state == BNX2X_STATE_OPEN) || if (bp->state == BNX2X_STATE_OPEN)
(bp->state == BNX2X_STATE_DISABLED))
bnx2x_stats_handle(bp, STATS_EVENT_UPDATE); bnx2x_stats_handle(bp, STATS_EVENT_UPDATE);
timer_restart: timer_restart:
...@@ -7629,7 +7629,7 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode) ...@@ -7629,7 +7629,7 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
if (CHIP_IS_E1H(bp)) if (CHIP_IS_E1H(bp))
if (bp->mf_config & FUNC_MF_CFG_FUNC_DISABLED) { if (bp->mf_config & FUNC_MF_CFG_FUNC_DISABLED) {
DP(NETIF_MSG_IFUP, "mf_cfg function disabled\n"); DP(NETIF_MSG_IFUP, "mf_cfg function disabled\n");
bp->state = BNX2X_STATE_DISABLED; bp->flags |= MF_FUNC_DIS;
} }
if (bp->state == BNX2X_STATE_OPEN) { if (bp->state == BNX2X_STATE_OPEN) {
...@@ -9034,7 +9034,9 @@ static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -9034,7 +9034,9 @@ static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
cmd->supported = bp->port.supported; cmd->supported = bp->port.supported;
cmd->advertising = bp->port.advertising; cmd->advertising = bp->port.advertising;
if (netif_carrier_ok(dev)) { if ((bp->state == BNX2X_STATE_OPEN) &&
!(bp->flags & MF_FUNC_DIS) &&
(bp->link_vars.link_up)) {
cmd->speed = bp->link_vars.line_speed; cmd->speed = bp->link_vars.line_speed;
cmd->duplex = bp->link_vars.duplex; cmd->duplex = bp->link_vars.duplex;
if (IS_E1HMF(bp)) { if (IS_E1HMF(bp)) {
...@@ -9433,6 +9435,9 @@ static u32 bnx2x_get_link(struct net_device *dev) ...@@ -9433,6 +9435,9 @@ static u32 bnx2x_get_link(struct net_device *dev)
{ {
struct bnx2x *bp = netdev_priv(dev); struct bnx2x *bp = netdev_priv(dev);
if (bp->flags & MF_FUNC_DIS)
return 0;
return bp->link_vars.link_up; return bp->link_vars.link_up;
} }
...@@ -9837,8 +9842,7 @@ static int bnx2x_set_eeprom(struct net_device *dev, ...@@ -9837,8 +9842,7 @@ static int bnx2x_set_eeprom(struct net_device *dev,
} else if (eeprom->magic == 0x50485952) { } else if (eeprom->magic == 0x50485952) {
/* 'PHYR' (0x50485952): re-init link after FW upgrade */ /* 'PHYR' (0x50485952): re-init link after FW upgrade */
if ((bp->state == BNX2X_STATE_OPEN) || if (bp->state == BNX2X_STATE_OPEN) {
(bp->state == BNX2X_STATE_DISABLED)) {
bnx2x_acquire_phy_lock(bp); bnx2x_acquire_phy_lock(bp);
rc |= bnx2x_link_reset(&bp->link_params, rc |= bnx2x_link_reset(&bp->link_params,
&bp->link_vars, 1); &bp->link_vars, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册