@@ -2456,7 +2456,7 @@ struct net_device {
2456
2456
* Drivers are free to use it for other protection.
2457
2457
*
2458
2458
* Protects:
2459
- * @net_shaper_hierarchy, @reg_state
2459
+ * @napi_list, @ net_shaper_hierarchy, @reg_state
2460
2460
*
2461
2461
* Partially protects (writers must hold both @lock and rtnl_lock):
2462
2462
* @up
@@ -2712,8 +2712,19 @@ static inline void netif_napi_set_irq(struct napi_struct *napi, int irq)
2712
2712
*/
2713
2713
#define NAPI_POLL_WEIGHT 64
2714
2714
2715
- void netif_napi_add_weight (struct net_device * dev , struct napi_struct * napi ,
2716
- int (* poll )(struct napi_struct * , int ), int weight );
2715
+ void netif_napi_add_weight_locked (struct net_device * dev ,
2716
+ struct napi_struct * napi ,
2717
+ int (* poll )(struct napi_struct * , int ),
2718
+ int weight );
2719
+
2720
+ static inline void
2721
+ netif_napi_add_weight (struct net_device * dev , struct napi_struct * napi ,
2722
+ int (* poll )(struct napi_struct * , int ), int weight )
2723
+ {
2724
+ netdev_lock (dev );
2725
+ netif_napi_add_weight_locked (dev , napi , poll , weight );
2726
+ netdev_unlock (dev );
2727
+ }
2717
2728
2718
2729
/**
2719
2730
* netif_napi_add() - initialize a NAPI context
@@ -2731,6 +2742,13 @@ netif_napi_add(struct net_device *dev, struct napi_struct *napi,
2731
2742
netif_napi_add_weight (dev , napi , poll , NAPI_POLL_WEIGHT );
2732
2743
}
2733
2744
2745
+ static inline void
2746
+ netif_napi_add_locked (struct net_device * dev , struct napi_struct * napi ,
2747
+ int (* poll )(struct napi_struct * , int ))
2748
+ {
2749
+ netif_napi_add_weight_locked (dev , napi , poll , NAPI_POLL_WEIGHT );
2750
+ }
2751
+
2734
2752
static inline void
2735
2753
netif_napi_add_tx_weight (struct net_device * dev ,
2736
2754
struct napi_struct * napi ,
@@ -2741,6 +2759,15 @@ netif_napi_add_tx_weight(struct net_device *dev,
2741
2759
netif_napi_add_weight (dev , napi , poll , weight );
2742
2760
}
2743
2761
2762
+ static inline void
2763
+ netif_napi_add_config_locked (struct net_device * dev , struct napi_struct * napi ,
2764
+ int (* poll )(struct napi_struct * , int ), int index )
2765
+ {
2766
+ napi -> index = index ;
2767
+ napi -> config = & dev -> napi_config [index ];
2768
+ netif_napi_add_weight_locked (dev , napi , poll , NAPI_POLL_WEIGHT );
2769
+ }
2770
+
2744
2771
/**
2745
2772
* netif_napi_add_config - initialize a NAPI context with persistent config
2746
2773
* @dev: network device
@@ -2752,9 +2779,9 @@ static inline void
2752
2779
netif_napi_add_config (struct net_device * dev , struct napi_struct * napi ,
2753
2780
int (* poll )(struct napi_struct * , int ), int index )
2754
2781
{
2755
- napi -> index = index ;
2756
- napi -> config = & dev -> napi_config [ index ] ;
2757
- netif_napi_add_weight (dev , napi , poll , NAPI_POLL_WEIGHT );
2782
+ netdev_lock ( dev ) ;
2783
+ netif_napi_add_config_locked ( dev , napi , poll , index ) ;
2784
+ netdev_unlock (dev );
2758
2785
}
2759
2786
2760
2787
/**
@@ -2774,6 +2801,8 @@ static inline void netif_napi_add_tx(struct net_device *dev,
2774
2801
netif_napi_add_tx_weight (dev , napi , poll , NAPI_POLL_WEIGHT );
2775
2802
}
2776
2803
2804
+ void __netif_napi_del_locked (struct napi_struct * napi );
2805
+
2777
2806
/**
2778
2807
* __netif_napi_del - remove a NAPI context
2779
2808
* @napi: NAPI context
@@ -2782,7 +2811,18 @@ static inline void netif_napi_add_tx(struct net_device *dev,
2782
2811
* containing @napi. Drivers might want to call this helper to combine
2783
2812
* all the needed RCU grace periods into a single one.
2784
2813
*/
2785
- void __netif_napi_del (struct napi_struct * napi );
2814
+ static inline void __netif_napi_del (struct napi_struct * napi )
2815
+ {
2816
+ netdev_lock (napi -> dev );
2817
+ __netif_napi_del_locked (napi );
2818
+ netdev_unlock (napi -> dev );
2819
+ }
2820
+
2821
+ static inline void netif_napi_del_locked (struct napi_struct * napi )
2822
+ {
2823
+ __netif_napi_del_locked (napi );
2824
+ synchronize_net ();
2825
+ }
2786
2826
2787
2827
/**
2788
2828
* netif_napi_del - remove a NAPI context
0 commit comments