Skip to content

Commit 55fd0cf

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add external loopback test to ethtool selftest.
Add code to detect firmware support for external loopback and the extra test entry for external loopback. Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e795892 commit 55fd0cf

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6337,6 +6337,10 @@ static int bnxt_hwrm_phy_qcaps(struct bnxt *bp)
63376337
bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) &
63386338
PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_MASK;
63396339
}
6340+
if (resp->flags & PORT_PHY_QCAPS_RESP_FLAGS_EXTERNAL_LPBK_SUPPORTED) {
6341+
if (bp->test_info)
6342+
bp->test_info->flags |= BNXT_TEST_FL_EXT_LPBK;
6343+
}
63406344
if (resp->supported_speeds_auto_mode)
63416345
link_info->support_auto_speeds =
63426346
le16_to_cpu(resp->supported_speeds_auto_mode);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,8 @@ struct bnxt_led_info {
990990

991991
struct bnxt_test_info {
992992
u8 offline_mask;
993+
u8 flags;
994+
#define BNXT_TEST_FL_EXT_LPBK 0x1
993995
u16 timeout;
994996
char string[BNXT_MAX_TEST][ETH_GSTRING_LEN];
995997
};

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,15 +2397,18 @@ static int bnxt_disable_an_for_lpbk(struct bnxt *bp,
23972397
return rc;
23982398
}
23992399

2400-
static int bnxt_hwrm_phy_loopback(struct bnxt *bp, bool enable)
2400+
static int bnxt_hwrm_phy_loopback(struct bnxt *bp, bool enable, bool ext)
24012401
{
24022402
struct hwrm_port_phy_cfg_input req = {0};
24032403

24042404
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_CFG, -1, -1);
24052405

24062406
if (enable) {
24072407
bnxt_disable_an_for_lpbk(bp, &req);
2408-
req.lpbk = PORT_PHY_CFG_REQ_LPBK_LOCAL;
2408+
if (ext)
2409+
req.lpbk = PORT_PHY_CFG_REQ_LPBK_EXTERNAL;
2410+
else
2411+
req.lpbk = PORT_PHY_CFG_REQ_LPBK_LOCAL;
24092412
} else {
24102413
req.lpbk = PORT_PHY_CFG_REQ_LPBK_NONE;
24112414
}
@@ -2538,15 +2541,17 @@ static int bnxt_run_fw_tests(struct bnxt *bp, u8 test_mask, u8 *test_results)
25382541
return rc;
25392542
}
25402543

2541-
#define BNXT_DRV_TESTS 3
2544+
#define BNXT_DRV_TESTS 4
25422545
#define BNXT_MACLPBK_TEST_IDX (bp->num_tests - BNXT_DRV_TESTS)
25432546
#define BNXT_PHYLPBK_TEST_IDX (BNXT_MACLPBK_TEST_IDX + 1)
2544-
#define BNXT_IRQ_TEST_IDX (BNXT_MACLPBK_TEST_IDX + 2)
2547+
#define BNXT_EXTLPBK_TEST_IDX (BNXT_MACLPBK_TEST_IDX + 2)
2548+
#define BNXT_IRQ_TEST_IDX (BNXT_MACLPBK_TEST_IDX + 3)
25452549

25462550
static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,
25472551
u64 *buf)
25482552
{
25492553
struct bnxt *bp = netdev_priv(dev);
2554+
bool do_ext_lpbk = false;
25502555
bool offline = false;
25512556
u8 test_results = 0;
25522557
u8 test_mask = 0;
@@ -2560,6 +2565,10 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,
25602565
return;
25612566
}
25622567

2568+
if ((etest->flags & ETH_TEST_FL_EXTERNAL_LB) &&
2569+
(bp->test_info->flags & BNXT_TEST_FL_EXT_LPBK))
2570+
do_ext_lpbk = true;
2571+
25632572
if (etest->flags & ETH_TEST_FL_OFFLINE) {
25642573
if (bp->pf.active_vfs) {
25652574
etest->flags |= ETH_TEST_FL_FAILED;
@@ -2600,13 +2609,22 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,
26002609
buf[BNXT_MACLPBK_TEST_IDX] = 0;
26012610

26022611
bnxt_hwrm_mac_loopback(bp, false);
2603-
bnxt_hwrm_phy_loopback(bp, true);
2612+
bnxt_hwrm_phy_loopback(bp, true, false);
26042613
msleep(1000);
26052614
if (bnxt_run_loopback(bp)) {
26062615
buf[BNXT_PHYLPBK_TEST_IDX] = 1;
26072616
etest->flags |= ETH_TEST_FL_FAILED;
26082617
}
2609-
bnxt_hwrm_phy_loopback(bp, false);
2618+
if (do_ext_lpbk) {
2619+
etest->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE;
2620+
bnxt_hwrm_phy_loopback(bp, true, true);
2621+
msleep(1000);
2622+
if (bnxt_run_loopback(bp)) {
2623+
buf[BNXT_EXTLPBK_TEST_IDX] = 1;
2624+
etest->flags |= ETH_TEST_FL_FAILED;
2625+
}
2626+
}
2627+
bnxt_hwrm_phy_loopback(bp, false, false);
26102628
bnxt_half_close_nic(bp);
26112629
bnxt_open_nic(bp, false, true);
26122630
}
@@ -2707,6 +2725,8 @@ void bnxt_ethtool_init(struct bnxt *bp)
27072725
strcpy(str, "Mac loopback test (offline)");
27082726
} else if (i == BNXT_PHYLPBK_TEST_IDX) {
27092727
strcpy(str, "Phy loopback test (offline)");
2728+
} else if (i == BNXT_EXTLPBK_TEST_IDX) {
2729+
strcpy(str, "Ext loopback test (offline)");
27102730
} else if (i == BNXT_IRQ_TEST_IDX) {
27112731
strcpy(str, "Interrupt_test (offline)");
27122732
} else {

0 commit comments

Comments
 (0)