@@ -2456,7 +2456,7 @@ struct net_device {
24562456 * Drivers are free to use it for other protection.
24572457 *
24582458 * Protects:
2459- * @net_shaper_hierarchy, @reg_state
2459+ * @napi_list, @ net_shaper_hierarchy, @reg_state
24602460 *
24612461 * Partially protects (writers must hold both @lock and rtnl_lock):
24622462 * @up
@@ -2712,8 +2712,19 @@ static inline void netif_napi_set_irq(struct napi_struct *napi, int irq)
27122712 */
27132713#define NAPI_POLL_WEIGHT 64
27142714
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+ }
27172728
27182729/**
27192730 * netif_napi_add() - initialize a NAPI context
@@ -2731,6 +2742,13 @@ netif_napi_add(struct net_device *dev, struct napi_struct *napi,
27312742 netif_napi_add_weight (dev , napi , poll , NAPI_POLL_WEIGHT );
27322743}
27332744
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+
27342752static inline void
27352753netif_napi_add_tx_weight (struct net_device * dev ,
27362754 struct napi_struct * napi ,
@@ -2741,6 +2759,15 @@ netif_napi_add_tx_weight(struct net_device *dev,
27412759 netif_napi_add_weight (dev , napi , poll , weight );
27422760}
27432761
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+
27442771/**
27452772 * netif_napi_add_config - initialize a NAPI context with persistent config
27462773 * @dev: network device
@@ -2752,9 +2779,9 @@ static inline void
27522779netif_napi_add_config (struct net_device * dev , struct napi_struct * napi ,
27532780 int (* poll )(struct napi_struct * , int ), int index )
27542781{
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 );
27582785}
27592786
27602787/**
@@ -2774,6 +2801,8 @@ static inline void netif_napi_add_tx(struct net_device *dev,
27742801 netif_napi_add_tx_weight (dev , napi , poll , NAPI_POLL_WEIGHT );
27752802}
27762803
2804+ void __netif_napi_del_locked (struct napi_struct * napi );
2805+
27772806/**
27782807 * __netif_napi_del - remove a NAPI context
27792808 * @napi: NAPI context
@@ -2782,7 +2811,18 @@ static inline void netif_napi_add_tx(struct net_device *dev,
27822811 * containing @napi. Drivers might want to call this helper to combine
27832812 * all the needed RCU grace periods into a single one.
27842813 */
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+ }
27862826
27872827/**
27882828 * netif_napi_del - remove a NAPI context
0 commit comments