Skip to content

Commit b875cc3

Browse files
IronShendavem330
authored andcommitted
net: hns3: Mask the packet statistics query when NIC is down
Update the HNS3_NIC_STATE_DOWN bit when NIC state changes. When NIC is down, mask the packet statistics for querying with ifconfig command. It's a common practice. Signed-off-by: Jian Shen <[email protected]> Signed-off-by: Peng Li <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c5f6548 commit b875cc3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ static int hns3_nic_net_up(struct net_device *netdev)
247247
if (ret)
248248
goto out_start_err;
249249

250+
clear_bit(HNS3_NIC_STATE_DOWN, &priv->state);
251+
250252
return 0;
251253

252254
out_start_err:
@@ -286,6 +288,9 @@ static void hns3_nic_net_down(struct net_device *netdev)
286288
const struct hnae3_ae_ops *ops;
287289
int i;
288290

291+
if (test_and_set_bit(HNS3_NIC_STATE_DOWN, &priv->state))
292+
return;
293+
289294
/* stop ae_dev */
290295
ops = priv->ae_handle->ae_algo->ops;
291296
if (ops->stop)
@@ -1135,6 +1140,9 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
11351140
u64 tx_pkts = 0;
11361141
u64 rx_pkts = 0;
11371142

1143+
if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state))
1144+
return;
1145+
11381146
handle->ae_algo->ops->update_stats(handle, &netdev->stats);
11391147

11401148
for (idx = 0; idx < queue_num; idx++) {

0 commit comments

Comments
 (0)