Skip to content

Commit 0742ed7

Browse files
Huazhong Tandavem330
authored andcommitted
net: hns3: move some reset information from hnae3_handle into hclge_dev/hclgevf_dev
Saving reset related information in the hclge_dev/hclgevf_dev structure is more suitable than the hnae3_handle, since hardware related information is kept in these two structure. Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7cea834 commit 0742ed7

File tree

7 files changed

+28
-34
lines changed

7 files changed

+28
-34
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,6 @@ struct hnae3_handle {
534534
struct hnae3_ae_algo *ae_algo; /* the class who provides this handle */
535535
u64 flags; /* Indicate the capabilities for this handle*/
536536

537-
unsigned long last_reset_time;
538-
enum hnae3_reset_type reset_level;
539-
540537
union {
541538
struct net_device *netdev; /* first member */
542539
struct hnae3_knic_private_info kinfo;

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ static int hns3_nic_net_up(struct net_device *netdev)
379379

380380
static int hns3_nic_net_open(struct net_device *netdev)
381381
{
382-
struct hns3_nic_priv *priv = netdev_priv(netdev);
383382
struct hnae3_handle *h = hns3_get_handle(netdev);
384383
struct hnae3_knic_private_info *kinfo;
385384
int i, ret;
@@ -406,7 +405,6 @@ static int hns3_nic_net_open(struct net_device *netdev)
406405
kinfo->prio_tc[i]);
407406
}
408407

409-
priv->ae_handle->last_reset_time = jiffies;
410408
return 0;
411409
}
412410

@@ -1648,10 +1646,9 @@ static void hns3_nic_net_timeout(struct net_device *ndev)
16481646

16491647
priv->tx_timeout_count++;
16501648

1651-
if (time_before(jiffies, (h->last_reset_time + ndev->watchdog_timeo)))
1652-
return;
1653-
1654-
/* request the reset */
1649+
/* request the reset, and let the hclge to determine
1650+
* which reset level should be done
1651+
*/
16551652
if (h->ae_algo->ops->reset_event)
16561653
h->ae_algo->ops->reset_event(h->pdev, h);
16571654
}
@@ -3370,7 +3367,6 @@ static int hns3_client_init(struct hnae3_handle *handle)
33703367
priv->dev = &pdev->dev;
33713368
priv->netdev = netdev;
33723369
priv->ae_handle = handle;
3373-
priv->ae_handle->last_reset_time = jiffies;
33743370
priv->tx_timeout_count = 0;
33753371

33763372
handle->kinfo.netdev = netdev;
@@ -3390,11 +3386,6 @@ static int hns3_client_init(struct hnae3_handle *handle)
33903386
/* Carrier off reporting is important to ethtool even BEFORE open */
33913387
netif_carrier_off(netdev);
33923388

3393-
if (handle->flags & HNAE3_SUPPORT_VF)
3394-
handle->reset_level = HNAE3_VF_RESET;
3395-
else
3396-
handle->reset_level = HNAE3_FUNC_RESET;
3397-
33983389
ret = hns3_get_ring_config(priv);
33993390
if (ret) {
34003391
ret = -ENOMEM;
@@ -3785,7 +3776,6 @@ static int hns3_reset_notify_up_enet(struct hnae3_handle *handle)
37853776
"hns net up fail, ret=%d!\n", ret);
37863777
return ret;
37873778
}
3788-
handle->last_reset_time = jiffies;
37893779
}
37903780

37913781
clear_bit(HNS3_NIC_STATE_RESETTING, &priv->state);

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,15 +2465,14 @@ static void hclge_clear_reset_cause(struct hclge_dev *hdev)
24652465
static void hclge_reset(struct hclge_dev *hdev)
24662466
{
24672467
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
2468-
struct hnae3_handle *handle;
24692468

24702469
/* Initialize ae_dev reset status as well, in case enet layer wants to
24712470
* know if device is undergoing reset
24722471
*/
24732472
ae_dev->reset_type = hdev->reset_type;
24742473
hdev->reset_count++;
2474+
hdev->last_reset_time = jiffies;
24752475
/* perform reset of the stack & ae device for a client */
2476-
handle = &hdev->vport[0].nic;
24772476
rtnl_lock();
24782477
hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
24792478
rtnl_unlock();
@@ -2493,7 +2492,6 @@ static void hclge_reset(struct hclge_dev *hdev)
24932492
}
24942493

24952494
hclge_notify_client(hdev, HNAE3_UP_CLIENT);
2496-
handle->last_reset_time = jiffies;
24972495
rtnl_unlock();
24982496
ae_dev->reset_type = HNAE3_NONE_RESET;
24992497
}
@@ -2521,24 +2519,24 @@ static void hclge_reset_event(struct pci_dev *pdev, struct hnae3_handle *handle)
25212519
if (!handle)
25222520
handle = &hdev->vport[0].nic;
25232521

2524-
if (time_before(jiffies, (handle->last_reset_time + 3 * HZ)))
2522+
if (time_before(jiffies, (hdev->last_reset_time + 3 * HZ)))
25252523
return;
25262524
else if (hdev->default_reset_request)
2527-
handle->reset_level =
2525+
hdev->reset_level =
25282526
hclge_get_reset_level(hdev,
25292527
&hdev->default_reset_request);
2530-
else if (time_after(jiffies, (handle->last_reset_time + 4 * 5 * HZ)))
2531-
handle->reset_level = HNAE3_FUNC_RESET;
2528+
else if (time_after(jiffies, (hdev->last_reset_time + 4 * 5 * HZ)))
2529+
hdev->reset_level = HNAE3_FUNC_RESET;
25322530

25332531
dev_info(&hdev->pdev->dev, "received reset event , reset type is %d",
2534-
handle->reset_level);
2532+
hdev->reset_level);
25352533

25362534
/* request reset & schedule reset task */
2537-
set_bit(handle->reset_level, &hdev->reset_request);
2535+
set_bit(hdev->reset_level, &hdev->reset_request);
25382536
hclge_reset_task_schedule(hdev);
25392537

2540-
if (handle->reset_level < HNAE3_GLOBAL_RESET)
2541-
handle->reset_level++;
2538+
if (hdev->reset_level < HNAE3_GLOBAL_RESET)
2539+
hdev->reset_level++;
25422540
}
25432541

25442542
static void hclge_set_def_reset_request(struct hnae3_ae_dev *ae_dev,
@@ -2560,6 +2558,7 @@ static void hclge_reset_subtask(struct hclge_dev *hdev)
25602558
* b. else, we can come back later to check this status so re-sched
25612559
* now.
25622560
*/
2561+
hdev->last_reset_time = jiffies;
25632562
hdev->reset_type = hclge_get_reset_level(hdev, &hdev->reset_pending);
25642563
if (hdev->reset_type != HNAE3_NONE_RESET)
25652564
hclge_reset(hdev);
@@ -6670,6 +6669,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
66706669
hdev->pdev = pdev;
66716670
hdev->ae_dev = ae_dev;
66726671
hdev->reset_type = HNAE3_NONE_RESET;
6672+
hdev->reset_level = HNAE3_FUNC_RESET;
66736673
ae_dev->priv = hdev;
66746674

66756675
ret = hclge_pci_init(hdev);
@@ -6814,6 +6814,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
68146814
hclge_enable_vector(&hdev->misc_vector, true);
68156815

68166816
hclge_state_init(hdev);
6817+
hdev->last_reset_time = jiffies;
68176818

68186819
pr_info("%s driver initialization finished.\n", HCLGE_DRIVER_NAME);
68196820
return 0;

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,10 @@ struct hclge_dev {
593593
struct hclge_misc_vector misc_vector;
594594
struct hclge_hw_stats hw_stats;
595595
unsigned long state;
596+
unsigned long last_reset_time;
596597

597598
enum hnae3_reset_type reset_type;
599+
enum hnae3_reset_type reset_level;
598600
unsigned long default_reset_request;
599601
unsigned long reset_request; /* reset has been requested */
600602
unsigned long reset_pending; /* client rst is pending to be served */

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,17 +1234,17 @@ static void hclgevf_reset_event(struct pci_dev *pdev,
12341234
dev_info(&hdev->pdev->dev, "received reset request from VF enet\n");
12351235

12361236
if (!hdev->default_reset_request)
1237-
handle->reset_level =
1237+
hdev->reset_level =
12381238
hclgevf_get_reset_level(hdev,
12391239
&hdev->default_reset_request);
12401240
else
1241-
handle->reset_level = HNAE3_VF_RESET;
1241+
hdev->reset_level = HNAE3_VF_RESET;
12421242

12431243
/* reset of this VF requested */
12441244
set_bit(HCLGEVF_RESET_REQUESTED, &hdev->reset_state);
12451245
hclgevf_reset_task_schedule(hdev);
12461246

1247-
handle->last_reset_time = jiffies;
1247+
hdev->last_reset_time = jiffies;
12481248
}
12491249

12501250
static void hclgevf_set_def_reset_request(struct hnae3_ae_dev *ae_dev,
@@ -1372,7 +1372,7 @@ static void hclgevf_reset_service_task(struct work_struct *work)
13721372
*/
13731373
if (hdev->reset_attempts > 3) {
13741374
/* prepare for full reset of stack + pcie interface */
1375-
hdev->nic.reset_level = HNAE3_VF_FULL_RESET;
1375+
hdev->reset_level = HNAE3_VF_FULL_RESET;
13761376

13771377
/* "defer" schedule the reset task again */
13781378
set_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state);
@@ -1985,6 +1985,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
19851985
}
19861986

19871987
hclgevf_state_init(hdev);
1988+
hdev->reset_level = HNAE3_VF_RESET;
19881989

19891990
ret = hclgevf_misc_irq_init(hdev);
19901991
if (ret) {
@@ -2026,6 +2027,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
20262027
goto err_config;
20272028
}
20282029

2030+
hdev->last_reset_time = jiffies;
20292031
pr_info("finished initializing %s driver\n", HCLGEVF_DRIVER_NAME);
20302032

20312033
return 0;

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ struct hclgevf_dev {
146146
struct hclgevf_rss_cfg rss_cfg;
147147
unsigned long state;
148148
unsigned long default_reset_request;
149+
unsigned long last_reset_time;
150+
enum hnae3_reset_type reset_level;
149151

150152
#define HCLGEVF_RESET_REQUESTED 0
151153
#define HCLGEVF_RESET_PENDING 1
@@ -198,14 +200,14 @@ static inline bool hclgevf_dev_ongoing_reset(struct hclgevf_dev *hdev)
198200
{
199201
return (hdev &&
200202
(test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) &&
201-
(hdev->nic.reset_level == HNAE3_VF_RESET));
203+
(hdev->reset_level == HNAE3_VF_RESET));
202204
}
203205

204206
static inline bool hclgevf_dev_ongoing_full_reset(struct hclgevf_dev *hdev)
205207
{
206208
return (hdev &&
207209
(test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) &&
208-
(hdev->nic.reset_level == HNAE3_VF_FULL_RESET));
210+
(hdev->reset_level == HNAE3_VF_FULL_RESET));
209211
}
210212

211213
int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode,

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev)
267267
* has been completely reset. After this stack should
268268
* eventually be re-initialized.
269269
*/
270-
hdev->nic.reset_level = HNAE3_VF_RESET;
270+
hdev->reset_level = HNAE3_VF_RESET;
271271
set_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state);
272272
hclgevf_reset_task_schedule(hdev);
273273

0 commit comments

Comments
 (0)