Skip to content

Commit 0f5a484

Browse files
Edwin Peerdavem330
authored andcommitted
bnxt_en: introduce initial link state of unknown
This will force link state to always be logged for initial NIC open. Signed-off-by: Edwin Peer <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 02acd39 commit 0f5a484

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9300,7 +9300,7 @@ void bnxt_tx_enable(struct bnxt *bp)
93009300
/* Make sure napi polls see @dev_state change */
93019301
synchronize_net();
93029302
netif_tx_wake_all_queues(bp->dev);
9303-
if (bp->link_info.link_up)
9303+
if (BNXT_LINK_IS_UP(bp))
93049304
netif_carrier_on(bp->dev);
93059305
}
93069306

@@ -9330,7 +9330,7 @@ static char *bnxt_report_fec(struct bnxt_link_info *link_info)
93309330

93319331
void bnxt_report_link(struct bnxt *bp)
93329332
{
9333-
if (bp->link_info.link_up) {
9333+
if (BNXT_LINK_IS_UP(bp)) {
93349334
const char *signal = "";
93359335
const char *flow_ctrl;
93369336
const char *duplex;
@@ -9466,7 +9466,7 @@ int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
94669466
struct bnxt_link_info *link_info = &bp->link_info;
94679467
struct hwrm_port_phy_qcfg_output *resp;
94689468
struct hwrm_port_phy_qcfg_input *req;
9469-
u8 link_up = link_info->link_up;
9469+
u8 link_state = link_info->link_state;
94709470
bool support_changed = false;
94719471
int rc;
94729472

@@ -9567,14 +9567,14 @@ int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
95679567
/* TODO: need to add more logic to report VF link */
95689568
if (chng_link_state) {
95699569
if (link_info->phy_link_status == BNXT_LINK_LINK)
9570-
link_info->link_up = 1;
9570+
link_info->link_state = BNXT_LINK_STATE_UP;
95719571
else
9572-
link_info->link_up = 0;
9573-
if (link_up != link_info->link_up)
9572+
link_info->link_state = BNXT_LINK_STATE_DOWN;
9573+
if (link_state != link_info->link_state)
95749574
bnxt_report_link(bp);
95759575
} else {
9576-
/* alwasy link down if not require to update link state */
9577-
link_info->link_up = 0;
9576+
/* always link down if not require to update link state */
9577+
link_info->link_state = BNXT_LINK_STATE_DOWN;
95789578
}
95799579
hwrm_req_drop(bp, req);
95809580

@@ -9774,7 +9774,18 @@ static int bnxt_hwrm_shutdown_link(struct bnxt *bp)
97749774
return rc;
97759775

97769776
req->flags = cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE_LINK_DWN);
9777-
return hwrm_req_send(bp, req);
9777+
rc = hwrm_req_send(bp, req);
9778+
if (!rc) {
9779+
mutex_lock(&bp->link_lock);
9780+
/* Device is not obliged link down in certain scenarios, even
9781+
* when forced. Setting the state unknown is consistent with
9782+
* driver startup and will force link state to be reported
9783+
* during subsequent open based on PORT_PHY_QCFG.
9784+
*/
9785+
bp->link_info.link_state = BNXT_LINK_STATE_UNKNOWN;
9786+
mutex_unlock(&bp->link_lock);
9787+
}
9788+
return rc;
97789789
}
97799790

97809791
static int bnxt_fw_reset_via_optee(struct bnxt *bp)
@@ -10205,7 +10216,7 @@ static int bnxt_update_phy_setting(struct bnxt *bp)
1020510216
/* The last close may have shutdown the link, so need to call
1020610217
* PHY_CFG to bring it back up.
1020710218
*/
10208-
if (!bp->link_info.link_up)
10219+
if (!BNXT_LINK_IS_UP(bp))
1020910220
update_link = true;
1021010221

1021110222
if (!bnxt_eee_config_ok(bp))
@@ -11437,7 +11448,7 @@ static void bnxt_timer(struct timer_list *t)
1143711448
if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
1143811449
bnxt_fw_health_check(bp);
1143911450

11440-
if (bp->link_info.link_up && bp->stats_coal_ticks) {
11451+
if (BNXT_LINK_IS_UP(bp) && bp->stats_coal_ticks) {
1144111452
set_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event);
1144211453
bnxt_queue_sp_work(bp);
1144311454
}

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,11 @@ struct bnxt_link_info {
11751175
#define BNXT_PHY_STATE_ENABLED 0
11761176
#define BNXT_PHY_STATE_DISABLED 1
11771177

1178-
u8 link_up;
1178+
u8 link_state;
1179+
#define BNXT_LINK_STATE_UNKNOWN 0
1180+
#define BNXT_LINK_STATE_DOWN 1
1181+
#define BNXT_LINK_STATE_UP 2
1182+
#define BNXT_LINK_IS_UP(bp) ((bp)->link_info.link_state == BNXT_LINK_STATE_UP)
11791183
u8 duplex;
11801184
#define BNXT_LINK_DUPLEX_HALF PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF
11811185
#define BNXT_LINK_DUPLEX_FULL PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ static u32 bnxt_get_link(struct net_device *dev)
21352135
struct bnxt *bp = netdev_priv(dev);
21362136

21372137
/* TODO: handle MF, VF, driver close case */
2138-
return bp->link_info.link_up;
2138+
return BNXT_LINK_IS_UP(bp);
21392139
}
21402140

21412141
int bnxt_hwrm_nvm_get_dev_info(struct bnxt *bp,
@@ -3383,7 +3383,7 @@ static int bnxt_disable_an_for_lpbk(struct bnxt *bp,
33833383
return rc;
33843384

33853385
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB;
3386-
if (bp->link_info.link_up)
3386+
if (BNXT_LINK_IS_UP(bp))
33873387
fw_speed = bp->link_info.link_speed;
33883388
else if (fw_advertising & BNXT_LINK_SPEED_MSK_10GB)
33893389
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB;

0 commit comments

Comments
 (0)