@@ -312,6 +312,24 @@ static u16 hns3_get_max_available_channels(struct hnae3_handle *h)
312
312
return min_t (u16 , rss_size , max_rss_size );
313
313
}
314
314
315
+ static void hns3_tqp_enable (struct hnae3_queue * tqp )
316
+ {
317
+ u32 rcb_reg ;
318
+
319
+ rcb_reg = hns3_read_dev (tqp , HNS3_RING_EN_REG );
320
+ rcb_reg |= BIT (HNS3_RING_EN_B );
321
+ hns3_write_dev (tqp , HNS3_RING_EN_REG , rcb_reg );
322
+ }
323
+
324
+ static void hns3_tqp_disable (struct hnae3_queue * tqp )
325
+ {
326
+ u32 rcb_reg ;
327
+
328
+ rcb_reg = hns3_read_dev (tqp , HNS3_RING_EN_REG );
329
+ rcb_reg &= ~BIT (HNS3_RING_EN_B );
330
+ hns3_write_dev (tqp , HNS3_RING_EN_REG , rcb_reg );
331
+ }
332
+
315
333
static int hns3_nic_net_up (struct net_device * netdev )
316
334
{
317
335
struct hns3_nic_priv * priv = netdev_priv (netdev );
@@ -334,6 +352,10 @@ static int hns3_nic_net_up(struct net_device *netdev)
334
352
for (i = 0 ; i < priv -> vector_num ; i ++ )
335
353
hns3_vector_enable (& priv -> tqp_vector [i ]);
336
354
355
+ /* enable rcb */
356
+ for (j = 0 ; j < h -> kinfo .num_tqps ; j ++ )
357
+ hns3_tqp_enable (h -> kinfo .tqp [j ]);
358
+
337
359
/* start the ae_dev */
338
360
ret = h -> ae_algo -> ops -> start ? h -> ae_algo -> ops -> start (h ) : 0 ;
339
361
if (ret )
@@ -344,6 +366,9 @@ static int hns3_nic_net_up(struct net_device *netdev)
344
366
return 0 ;
345
367
346
368
out_start_err :
369
+ while (j -- )
370
+ hns3_tqp_disable (h -> kinfo .tqp [j ]);
371
+
347
372
for (j = i - 1 ; j >= 0 ; j -- )
348
373
hns3_vector_disable (& priv -> tqp_vector [j ]);
349
374
@@ -354,11 +379,13 @@ static int hns3_nic_net_up(struct net_device *netdev)
354
379
355
380
static int hns3_nic_net_open (struct net_device * netdev )
356
381
{
357
- struct hns3_nic_priv * priv = netdev_priv (netdev );
358
382
struct hnae3_handle * h = hns3_get_handle (netdev );
359
383
struct hnae3_knic_private_info * kinfo ;
360
384
int i , ret ;
361
385
386
+ if (hns3_nic_resetting (netdev ))
387
+ return - EBUSY ;
388
+
362
389
netif_carrier_off (netdev );
363
390
364
391
ret = hns3_nic_set_real_num_queue (netdev );
@@ -378,13 +405,13 @@ static int hns3_nic_net_open(struct net_device *netdev)
378
405
kinfo -> prio_tc [i ]);
379
406
}
380
407
381
- priv -> ae_handle -> last_reset_time = jiffies ;
382
408
return 0 ;
383
409
}
384
410
385
411
static void hns3_nic_net_down (struct net_device * netdev )
386
412
{
387
413
struct hns3_nic_priv * priv = netdev_priv (netdev );
414
+ struct hnae3_handle * h = hns3_get_handle (netdev );
388
415
const struct hnae3_ae_ops * ops ;
389
416
int i ;
390
417
@@ -395,6 +422,10 @@ static void hns3_nic_net_down(struct net_device *netdev)
395
422
for (i = 0 ; i < priv -> vector_num ; i ++ )
396
423
hns3_vector_disable (& priv -> tqp_vector [i ]);
397
424
425
+ /* disable rcb */
426
+ for (i = 0 ; i < h -> kinfo .num_tqps ; i ++ )
427
+ hns3_tqp_disable (h -> kinfo .tqp [i ]);
428
+
398
429
/* stop ae_dev */
399
430
ops = priv -> ae_handle -> ae_algo -> ops ;
400
431
if (ops -> stop )
@@ -1615,10 +1646,9 @@ static void hns3_nic_net_timeout(struct net_device *ndev)
1615
1646
1616
1647
priv -> tx_timeout_count ++ ;
1617
1648
1618
- if (time_before (jiffies , (h -> last_reset_time + ndev -> watchdog_timeo )))
1619
- return ;
1620
-
1621
- /* request the reset */
1649
+ /* request the reset, and let the hclge to determine
1650
+ * which reset level should be done
1651
+ */
1622
1652
if (h -> ae_algo -> ops -> reset_event )
1623
1653
h -> ae_algo -> ops -> reset_event (h -> pdev , h );
1624
1654
}
@@ -3337,7 +3367,6 @@ static int hns3_client_init(struct hnae3_handle *handle)
3337
3367
priv -> dev = & pdev -> dev ;
3338
3368
priv -> netdev = netdev ;
3339
3369
priv -> ae_handle = handle ;
3340
- priv -> ae_handle -> last_reset_time = jiffies ;
3341
3370
priv -> tx_timeout_count = 0 ;
3342
3371
3343
3372
handle -> kinfo .netdev = netdev ;
@@ -3357,11 +3386,6 @@ static int hns3_client_init(struct hnae3_handle *handle)
3357
3386
/* Carrier off reporting is important to ethtool even BEFORE open */
3358
3387
netif_carrier_off (netdev );
3359
3388
3360
- if (handle -> flags & HNAE3_SUPPORT_VF )
3361
- handle -> reset_level = HNAE3_VF_RESET ;
3362
- else
3363
- handle -> reset_level = HNAE3_FUNC_RESET ;
3364
-
3365
3389
ret = hns3_get_ring_config (priv );
3366
3390
if (ret ) {
3367
3391
ret = - ENOMEM ;
@@ -3397,6 +3421,8 @@ static int hns3_client_init(struct hnae3_handle *handle)
3397
3421
/* MTU range: (ETH_MIN_MTU(kernel default) - 9706) */
3398
3422
netdev -> max_mtu = HNS3_MAX_MTU - (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN );
3399
3423
3424
+ set_bit (HNS3_NIC_STATE_INITED , & priv -> state );
3425
+
3400
3426
return ret ;
3401
3427
3402
3428
out_reg_netdev_fail :
@@ -3423,6 +3449,11 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)
3423
3449
if (netdev -> reg_state != NETREG_UNINITIALIZED )
3424
3450
unregister_netdev (netdev );
3425
3451
3452
+ if (!test_and_clear_bit (HNS3_NIC_STATE_INITED , & priv -> state )) {
3453
+ netdev_warn (netdev , "already uninitialized\n" );
3454
+ goto out_netdev_free ;
3455
+ }
3456
+
3426
3457
hns3_del_all_fd_rules (netdev , true);
3427
3458
3428
3459
hns3_force_clear_all_rx_ring (handle );
@@ -3443,6 +3474,7 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)
3443
3474
3444
3475
priv -> ring_data = NULL ;
3445
3476
3477
+ out_netdev_free :
3446
3478
free_netdev (netdev );
3447
3479
}
3448
3480
@@ -3708,8 +3740,22 @@ static void hns3_restore_coal(struct hns3_nic_priv *priv)
3708
3740
3709
3741
static int hns3_reset_notify_down_enet (struct hnae3_handle * handle )
3710
3742
{
3743
+ struct hnae3_ae_dev * ae_dev = pci_get_drvdata (handle -> pdev );
3711
3744
struct hnae3_knic_private_info * kinfo = & handle -> kinfo ;
3712
3745
struct net_device * ndev = kinfo -> netdev ;
3746
+ struct hns3_nic_priv * priv = netdev_priv (ndev );
3747
+
3748
+ if (test_and_set_bit (HNS3_NIC_STATE_RESETTING , & priv -> state ))
3749
+ return 0 ;
3750
+
3751
+ /* it is cumbersome for hardware to pick-and-choose entries for deletion
3752
+ * from table space. Hence, for function reset software intervention is
3753
+ * required to delete the entries
3754
+ */
3755
+ if (hns3_dev_ongoing_func_reset (ae_dev )) {
3756
+ hns3_remove_hw_addr (ndev );
3757
+ hns3_del_all_fd_rules (ndev , false);
3758
+ }
3713
3759
3714
3760
if (!netif_running (ndev ))
3715
3761
return 0 ;
@@ -3720,6 +3766,7 @@ static int hns3_reset_notify_down_enet(struct hnae3_handle *handle)
3720
3766
static int hns3_reset_notify_up_enet (struct hnae3_handle * handle )
3721
3767
{
3722
3768
struct hnae3_knic_private_info * kinfo = & handle -> kinfo ;
3769
+ struct hns3_nic_priv * priv = netdev_priv (kinfo -> netdev );
3723
3770
int ret = 0 ;
3724
3771
3725
3772
if (netif_running (kinfo -> netdev )) {
@@ -3729,9 +3776,10 @@ static int hns3_reset_notify_up_enet(struct hnae3_handle *handle)
3729
3776
"hns net up fail, ret=%d!\n" , ret );
3730
3777
return ret ;
3731
3778
}
3732
- handle -> last_reset_time = jiffies ;
3733
3779
}
3734
3780
3781
+ clear_bit (HNS3_NIC_STATE_RESETTING , & priv -> state );
3782
+
3735
3783
return ret ;
3736
3784
}
3737
3785
@@ -3782,16 +3830,22 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
3782
3830
priv -> ring_data = NULL ;
3783
3831
}
3784
3832
3833
+ set_bit (HNS3_NIC_STATE_INITED , & priv -> state );
3834
+
3785
3835
return ret ;
3786
3836
}
3787
3837
3788
3838
static int hns3_reset_notify_uninit_enet (struct hnae3_handle * handle )
3789
3839
{
3790
- struct hnae3_ae_dev * ae_dev = pci_get_drvdata (handle -> pdev );
3791
3840
struct net_device * netdev = handle -> kinfo .netdev ;
3792
3841
struct hns3_nic_priv * priv = netdev_priv (netdev );
3793
3842
int ret ;
3794
3843
3844
+ if (!test_bit (HNS3_NIC_STATE_INITED , & priv -> state )) {
3845
+ netdev_warn (netdev , "already uninitialized\n" );
3846
+ return 0 ;
3847
+ }
3848
+
3795
3849
hns3_force_clear_all_rx_ring (handle );
3796
3850
3797
3851
ret = hns3_nic_uninit_vector_data (priv );
@@ -3806,14 +3860,7 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
3806
3860
if (ret )
3807
3861
netdev_err (netdev , "uninit ring error\n" );
3808
3862
3809
- /* it is cumbersome for hardware to pick-and-choose entries for deletion
3810
- * from table space. Hence, for function reset software intervention is
3811
- * required to delete the entries
3812
- */
3813
- if (hns3_dev_ongoing_func_reset (ae_dev )) {
3814
- hns3_remove_hw_addr (netdev );
3815
- hns3_del_all_fd_rules (netdev , false);
3816
- }
3863
+ clear_bit (HNS3_NIC_STATE_INITED , & priv -> state );
3817
3864
3818
3865
return ret ;
3819
3866
}
0 commit comments