Skip to content

Commit 257e4f2

Browse files
Huazhong Tandavem330
authored andcommitted
net: hns3: use HNS3_NIC_STATE_RESETTING to indicate resetting
While hclge is going to reset, it will notify its client with HNAE3_DOWN_CLIENT, so this client should get into a resetting status from this moment, other operations from the stack need to be blocked as well. And when the reset is finished, the client will be notified with HNAE3_UP_CLIENT, so this is the end of the resetting status. This patch uses HNS3_NIC_STATE_RESETTING flag to implement that, and adds hns3_nic_resetting() to indicate which operation is not allowed. Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8df0fa9 commit 257e4f2

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets)
99
{
1010
struct hnae3_handle *h = hns3_get_handle(ndev);
1111

12+
if (hns3_nic_resetting(ndev))
13+
return -EBUSY;
14+
1215
if (h->kinfo.dcb_ops->ieee_getets)
1316
return h->kinfo.dcb_ops->ieee_getets(h, ets);
1417

@@ -20,6 +23,9 @@ int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets)
2023
{
2124
struct hnae3_handle *h = hns3_get_handle(ndev);
2225

26+
if (hns3_nic_resetting(ndev))
27+
return -EBUSY;
28+
2329
if (h->kinfo.dcb_ops->ieee_setets)
2430
return h->kinfo.dcb_ops->ieee_setets(h, ets);
2531

@@ -31,6 +37,9 @@ int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc)
3137
{
3238
struct hnae3_handle *h = hns3_get_handle(ndev);
3339

40+
if (hns3_nic_resetting(ndev))
41+
return -EBUSY;
42+
3443
if (h->kinfo.dcb_ops->ieee_getpfc)
3544
return h->kinfo.dcb_ops->ieee_getpfc(h, pfc);
3645

@@ -42,6 +51,9 @@ int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
4251
{
4352
struct hnae3_handle *h = hns3_get_handle(ndev);
4453

54+
if (hns3_nic_resetting(ndev))
55+
return -EBUSY;
56+
4557
if (h->kinfo.dcb_ops->ieee_setpfc)
4658
return h->kinfo.dcb_ops->ieee_setpfc(h, pfc);
4759

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ static int hns3_nic_net_open(struct net_device *netdev)
384384
struct hnae3_knic_private_info *kinfo;
385385
int i, ret;
386386

387+
if (hns3_nic_resetting(netdev))
388+
return -EBUSY;
389+
387390
netif_carrier_off(netdev);
388391

389392
ret = hns3_nic_set_real_num_queue(netdev);
@@ -3749,6 +3752,10 @@ static int hns3_reset_notify_down_enet(struct hnae3_handle *handle)
37493752
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
37503753
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
37513754
struct net_device *ndev = kinfo->netdev;
3755+
struct hns3_nic_priv *priv = netdev_priv(ndev);
3756+
3757+
if (test_and_set_bit(HNS3_NIC_STATE_RESETTING, &priv->state))
3758+
return 0;
37523759

37533760
/* it is cumbersome for hardware to pick-and-choose entries for deletion
37543761
* from table space. Hence, for function reset software intervention is
@@ -3768,6 +3775,7 @@ static int hns3_reset_notify_down_enet(struct hnae3_handle *handle)
37683775
static int hns3_reset_notify_up_enet(struct hnae3_handle *handle)
37693776
{
37703777
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
3778+
struct hns3_nic_priv *priv = netdev_priv(kinfo->netdev);
37713779
int ret = 0;
37723780

37733781
if (netif_running(kinfo->netdev)) {
@@ -3780,6 +3788,8 @@ static int hns3_reset_notify_up_enet(struct hnae3_handle *handle)
37803788
handle->last_reset_time = jiffies;
37813789
}
37823790

3791+
clear_bit(HNS3_NIC_STATE_RESETTING, &priv->state);
3792+
37833793
return ret;
37843794
}
37853795

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,13 @@ static inline bool hns3_dev_ongoing_func_reset(struct hnae3_ae_dev *ae_dev)
599599
#define hns3_read_dev(a, reg) \
600600
hns3_read_reg((a)->io_base, (reg))
601601

602+
static inline bool hns3_nic_resetting(struct net_device *netdev)
603+
{
604+
struct hns3_nic_priv *priv = netdev_priv(netdev);
605+
606+
return test_bit(HNS3_NIC_STATE_RESETTING, &priv->state);
607+
}
608+
602609
#define hns3_write_dev(a, reg, value) \
603610
hns3_write_reg((a)->io_base, (reg), (value))
604611

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,11 @@ static void hns3_self_test(struct net_device *ndev,
291291
int test_index = 0;
292292
u32 i;
293293

294+
if (hns3_nic_resetting(ndev)) {
295+
netdev_err(ndev, "dev resetting!");
296+
return;
297+
}
298+
294299
/* Only do offline selftest, or pass by default */
295300
if (eth_test->flags != ETH_TEST_FL_OFFLINE)
296301
return;
@@ -530,6 +535,11 @@ static void hns3_get_ringparam(struct net_device *netdev,
530535
struct hnae3_handle *h = priv->ae_handle;
531536
int queue_num = h->kinfo.num_tqps;
532537

538+
if (hns3_nic_resetting(netdev)) {
539+
netdev_err(netdev, "dev resetting!");
540+
return;
541+
}
542+
533543
param->tx_max_pending = HNS3_RING_MAX_PENDING;
534544
param->rx_max_pending = HNS3_RING_MAX_PENDING;
535545

@@ -760,6 +770,9 @@ static int hns3_set_ringparam(struct net_device *ndev,
760770
u32 old_desc_num, new_desc_num;
761771
int ret;
762772

773+
if (hns3_nic_resetting(ndev))
774+
return -EBUSY;
775+
763776
if (param->rx_mini_pending || param->rx_jumbo_pending)
764777
return -EINVAL;
765778

@@ -872,6 +885,9 @@ static int hns3_get_coalesce_per_queue(struct net_device *netdev, u32 queue,
872885
struct hnae3_handle *h = priv->ae_handle;
873886
u16 queue_num = h->kinfo.num_tqps;
874887

888+
if (hns3_nic_resetting(netdev))
889+
return -EBUSY;
890+
875891
if (queue >= queue_num) {
876892
netdev_err(netdev,
877893
"Invalid queue value %d! Queue max id=%d\n",
@@ -1033,6 +1049,9 @@ static int hns3_set_coalesce(struct net_device *netdev,
10331049
int ret;
10341050
int i;
10351051

1052+
if (hns3_nic_resetting(netdev))
1053+
return -EBUSY;
1054+
10361055
ret = hns3_check_coalesce_para(netdev, cmd);
10371056
if (ret)
10381057
return ret;

0 commit comments

Comments
 (0)