@@ -473,20 +473,14 @@ static void hns3_mask_vector_irq(struct hns3_enet_tqp_vector *tqp_vector,
473
473
writel (mask_en , tqp_vector -> mask_addr );
474
474
}
475
475
476
- static void hns3_vector_enable (struct hns3_enet_tqp_vector * tqp_vector )
476
+ static void hns3_irq_enable (struct hns3_enet_tqp_vector * tqp_vector )
477
477
{
478
478
napi_enable (& tqp_vector -> napi );
479
479
enable_irq (tqp_vector -> vector_irq );
480
-
481
- /* enable vector */
482
- hns3_mask_vector_irq (tqp_vector , 1 );
483
480
}
484
481
485
- static void hns3_vector_disable (struct hns3_enet_tqp_vector * tqp_vector )
482
+ static void hns3_irq_disable (struct hns3_enet_tqp_vector * tqp_vector )
486
483
{
487
- /* disable vector */
488
- hns3_mask_vector_irq (tqp_vector , 0 );
489
-
490
484
disable_irq (tqp_vector -> vector_irq );
491
485
napi_disable (& tqp_vector -> napi );
492
486
cancel_work_sync (& tqp_vector -> rx_group .dim .work );
@@ -707,11 +701,42 @@ static int hns3_set_rx_cpu_rmap(struct net_device *netdev)
707
701
return 0 ;
708
702
}
709
703
704
+ static void hns3_enable_irqs_and_tqps (struct net_device * netdev )
705
+ {
706
+ struct hns3_nic_priv * priv = netdev_priv (netdev );
707
+ struct hnae3_handle * h = priv -> ae_handle ;
708
+ u16 i ;
709
+
710
+ for (i = 0 ; i < priv -> vector_num ; i ++ )
711
+ hns3_irq_enable (& priv -> tqp_vector [i ]);
712
+
713
+ for (i = 0 ; i < priv -> vector_num ; i ++ )
714
+ hns3_mask_vector_irq (& priv -> tqp_vector [i ], 1 );
715
+
716
+ for (i = 0 ; i < h -> kinfo .num_tqps ; i ++ )
717
+ hns3_tqp_enable (h -> kinfo .tqp [i ]);
718
+ }
719
+
720
+ static void hns3_disable_irqs_and_tqps (struct net_device * netdev )
721
+ {
722
+ struct hns3_nic_priv * priv = netdev_priv (netdev );
723
+ struct hnae3_handle * h = priv -> ae_handle ;
724
+ u16 i ;
725
+
726
+ for (i = 0 ; i < h -> kinfo .num_tqps ; i ++ )
727
+ hns3_tqp_disable (h -> kinfo .tqp [i ]);
728
+
729
+ for (i = 0 ; i < priv -> vector_num ; i ++ )
730
+ hns3_mask_vector_irq (& priv -> tqp_vector [i ], 0 );
731
+
732
+ for (i = 0 ; i < priv -> vector_num ; i ++ )
733
+ hns3_irq_disable (& priv -> tqp_vector [i ]);
734
+ }
735
+
710
736
static int hns3_nic_net_up (struct net_device * netdev )
711
737
{
712
738
struct hns3_nic_priv * priv = netdev_priv (netdev );
713
739
struct hnae3_handle * h = priv -> ae_handle ;
714
- int i , j ;
715
740
int ret ;
716
741
717
742
ret = hns3_nic_reset_all_ring (h );
@@ -720,23 +745,13 @@ static int hns3_nic_net_up(struct net_device *netdev)
720
745
721
746
clear_bit (HNS3_NIC_STATE_DOWN , & priv -> state );
722
747
723
- /* enable the vectors */
724
- for (i = 0 ; i < priv -> vector_num ; i ++ )
725
- hns3_vector_enable (& priv -> tqp_vector [i ]);
726
-
727
- /* enable rcb */
728
- for (j = 0 ; j < h -> kinfo .num_tqps ; j ++ )
729
- hns3_tqp_enable (h -> kinfo .tqp [j ]);
748
+ hns3_enable_irqs_and_tqps (netdev );
730
749
731
750
/* start the ae_dev */
732
751
ret = h -> ae_algo -> ops -> start ? h -> ae_algo -> ops -> start (h ) : 0 ;
733
752
if (ret ) {
734
753
set_bit (HNS3_NIC_STATE_DOWN , & priv -> state );
735
- while (j -- )
736
- hns3_tqp_disable (h -> kinfo .tqp [j ]);
737
-
738
- for (j = i - 1 ; j >= 0 ; j -- )
739
- hns3_vector_disable (& priv -> tqp_vector [j ]);
754
+ hns3_disable_irqs_and_tqps (netdev );
740
755
}
741
756
742
757
return ret ;
@@ -823,17 +838,9 @@ static void hns3_reset_tx_queue(struct hnae3_handle *h)
823
838
static void hns3_nic_net_down (struct net_device * netdev )
824
839
{
825
840
struct hns3_nic_priv * priv = netdev_priv (netdev );
826
- struct hnae3_handle * h = hns3_get_handle (netdev );
827
841
const struct hnae3_ae_ops * ops ;
828
- int i ;
829
842
830
- /* disable vectors */
831
- for (i = 0 ; i < priv -> vector_num ; i ++ )
832
- hns3_vector_disable (& priv -> tqp_vector [i ]);
833
-
834
- /* disable rcb */
835
- for (i = 0 ; i < h -> kinfo .num_tqps ; i ++ )
836
- hns3_tqp_disable (h -> kinfo .tqp [i ]);
843
+ hns3_disable_irqs_and_tqps (netdev );
837
844
838
845
/* stop ae_dev */
839
846
ops = priv -> ae_handle -> ae_algo -> ops ;
@@ -5864,8 +5871,6 @@ int hns3_set_channels(struct net_device *netdev,
5864
5871
void hns3_external_lb_prepare (struct net_device * ndev , bool if_running )
5865
5872
{
5866
5873
struct hns3_nic_priv * priv = netdev_priv (ndev );
5867
- struct hnae3_handle * h = priv -> ae_handle ;
5868
- int i ;
5869
5874
5870
5875
if (!if_running )
5871
5876
return ;
@@ -5876,11 +5881,7 @@ void hns3_external_lb_prepare(struct net_device *ndev, bool if_running)
5876
5881
netif_carrier_off (ndev );
5877
5882
netif_tx_disable (ndev );
5878
5883
5879
- for (i = 0 ; i < priv -> vector_num ; i ++ )
5880
- hns3_vector_disable (& priv -> tqp_vector [i ]);
5881
-
5882
- for (i = 0 ; i < h -> kinfo .num_tqps ; i ++ )
5883
- hns3_tqp_disable (h -> kinfo .tqp [i ]);
5884
+ hns3_disable_irqs_and_tqps (ndev );
5884
5885
5885
5886
/* delay ring buffer clearing to hns3_reset_notify_uninit_enet
5886
5887
* during reset process, because driver may not be able
@@ -5896,7 +5897,6 @@ void hns3_external_lb_restore(struct net_device *ndev, bool if_running)
5896
5897
{
5897
5898
struct hns3_nic_priv * priv = netdev_priv (ndev );
5898
5899
struct hnae3_handle * h = priv -> ae_handle ;
5899
- int i ;
5900
5900
5901
5901
if (!if_running )
5902
5902
return ;
@@ -5912,11 +5912,7 @@ void hns3_external_lb_restore(struct net_device *ndev, bool if_running)
5912
5912
5913
5913
clear_bit (HNS3_NIC_STATE_DOWN , & priv -> state );
5914
5914
5915
- for (i = 0 ; i < priv -> vector_num ; i ++ )
5916
- hns3_vector_enable (& priv -> tqp_vector [i ]);
5917
-
5918
- for (i = 0 ; i < h -> kinfo .num_tqps ; i ++ )
5919
- hns3_tqp_enable (h -> kinfo .tqp [i ]);
5915
+ hns3_enable_irqs_and_tqps (ndev );
5920
5916
5921
5917
netif_tx_wake_all_queues (ndev );
5922
5918
0 commit comments