Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Add queue and napi association

Add the napi pointer in netdev queue for tracking the napi
instance for each queue. This achieves the queue<->napi mapping.

Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
Reviewed-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
Link: https://lore.kernel.org/r/170147331483.5260.15723438819994285695.stgit@anambiarhost.jf.intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Amritha Nambiar and committed by
Jakub Kicinski
2a502ff0 bc877956

+49
+8
include/linux/netdevice.h
··· 665 665 #ifdef CONFIG_XDP_SOCKETS 666 666 struct xsk_buff_pool *pool; 667 667 #endif 668 + /* NAPI instance for the queue 669 + * Readers and writers must hold RTNL 670 + */ 671 + struct napi_struct *napi; 668 672 /* 669 673 * write-mostly part 670 674 */ ··· 2660 2656 * example Ethernet, Wireless LAN, Bluetooth, WiMAX etc. 2661 2657 */ 2662 2658 #define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype)) 2659 + 2660 + void netif_queue_set_napi(struct net_device *dev, unsigned int queue_index, 2661 + enum netdev_queue_type type, 2662 + struct napi_struct *napi); 2663 2663 2664 2664 /* Default NAPI poll() weight 2665 2665 * Device drivers are strongly advised to not use bigger value
+4
include/net/netdev_rx_queue.h
··· 21 21 #ifdef CONFIG_XDP_SOCKETS 22 22 struct xsk_buff_pool *pool; 23 23 #endif 24 + /* NAPI instance for the queue 25 + * Readers and writers must hold RTNL 26 + */ 27 + struct napi_struct *napi; 24 28 } ____cacheline_aligned_in_smp; 25 29 26 30 /*
+37
net/core/dev.c
··· 6400 6400 } 6401 6401 EXPORT_SYMBOL(dev_set_threaded); 6402 6402 6403 + /** 6404 + * netif_queue_set_napi - Associate queue with the napi 6405 + * @dev: device to which NAPI and queue belong 6406 + * @queue_index: Index of queue 6407 + * @type: queue type as RX or TX 6408 + * @napi: NAPI context, pass NULL to clear previously set NAPI 6409 + * 6410 + * Set queue with its corresponding napi context. This should be done after 6411 + * registering the NAPI handler for the queue-vector and the queues have been 6412 + * mapped to the corresponding interrupt vector. 6413 + */ 6414 + void netif_queue_set_napi(struct net_device *dev, unsigned int queue_index, 6415 + enum netdev_queue_type type, struct napi_struct *napi) 6416 + { 6417 + struct netdev_rx_queue *rxq; 6418 + struct netdev_queue *txq; 6419 + 6420 + if (WARN_ON_ONCE(napi && !napi->dev)) 6421 + return; 6422 + if (dev->reg_state >= NETREG_REGISTERED) 6423 + ASSERT_RTNL(); 6424 + 6425 + switch (type) { 6426 + case NETDEV_QUEUE_TYPE_RX: 6427 + rxq = __netif_get_rx_queue(dev, queue_index); 6428 + rxq->napi = napi; 6429 + return; 6430 + case NETDEV_QUEUE_TYPE_TX: 6431 + txq = netdev_get_tx_queue(dev, queue_index); 6432 + txq->napi = napi; 6433 + return; 6434 + default: 6435 + return; 6436 + } 6437 + } 6438 + EXPORT_SYMBOL(netif_queue_set_napi); 6439 + 6403 6440 void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi, 6404 6441 int (*poll)(struct napi_struct *, int), int weight) 6405 6442 {