Skip to content

Commit 5bd088d

Browse files
IronShenPaolo Abeni
authored andcommitted
net: hns3: mark unexcuted loopback test result as UNEXECUTED
Currently, loopback test may be skipped when resetting, but the test result will still show as 'PASS', because the driver doesn't set ETH_TEST_FL_FAILED flag. Fix it by setting the flag and initializating the value to UNEXECUTED. Fixes: 4c8dab1 ("net: hns3: reconstruct function hns3_self_test") Signed-off-by: Jian Shen <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Michal Kubiak <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 93305b7 commit 5bd088d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ static const struct hns3_stats hns3_rxq_stats[] = {
7878
#define HNS3_NIC_LB_TEST_NO_MEM_ERR 1
7979
#define HNS3_NIC_LB_TEST_TX_CNT_ERR 2
8080
#define HNS3_NIC_LB_TEST_RX_CNT_ERR 3
81+
#define HNS3_NIC_LB_TEST_UNEXECUTED 4
82+
83+
static int hns3_get_sset_count(struct net_device *netdev, int stringset);
8184

8285
static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en)
8386
{
@@ -418,18 +421,26 @@ static void hns3_do_external_lb(struct net_device *ndev,
418421
static void hns3_self_test(struct net_device *ndev,
419422
struct ethtool_test *eth_test, u64 *data)
420423
{
424+
int cnt = hns3_get_sset_count(ndev, ETH_SS_TEST);
421425
struct hns3_nic_priv *priv = netdev_priv(ndev);
422426
struct hnae3_handle *h = priv->ae_handle;
423427
int st_param[HNAE3_LOOP_NONE][2];
424428
bool if_running = netif_running(ndev);
429+
int i;
430+
431+
/* initialize the loopback test result, avoid marking an unexcuted
432+
* loopback test as PASS.
433+
*/
434+
for (i = 0; i < cnt; i++)
435+
data[i] = HNS3_NIC_LB_TEST_UNEXECUTED;
425436

426437
if (hns3_nic_resetting(ndev)) {
427438
netdev_err(ndev, "dev resetting!");
428-
return;
439+
goto failure;
429440
}
430441

431442
if (!(eth_test->flags & ETH_TEST_FL_OFFLINE))
432-
return;
443+
goto failure;
433444

434445
if (netif_msg_ifdown(h))
435446
netdev_info(ndev, "self test start\n");
@@ -451,6 +462,10 @@ static void hns3_self_test(struct net_device *ndev,
451462

452463
if (netif_msg_ifdown(h))
453464
netdev_info(ndev, "self test end\n");
465+
return;
466+
467+
failure:
468+
eth_test->flags |= ETH_TEST_FL_FAILED;
454469
}
455470

456471
static void hns3_update_limit_promisc_mode(struct net_device *netdev,

0 commit comments

Comments
 (0)