• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_NETDEV_RX_QUEUE_H
3 #define _LINUX_NETDEV_RX_QUEUE_H
4 
5 #include <linux/kobject.h>
6 #include <linux/netdevice.h>
7 #include <linux/sysfs.h>
8 #include <net/xdp.h>
9 #include <net/page_pool/types.h>
10 #include <linux/android_kabi.h>
11 
12 /* This structure contains an instance of an RX queue. */
13 struct netdev_rx_queue {
14 	struct xdp_rxq_info		xdp_rxq;
15 #ifdef CONFIG_RPS
16 	struct rps_map __rcu		*rps_map;
17 	struct rps_dev_flow_table __rcu	*rps_flow_table;
18 #endif
19 	struct kobject			kobj;
20 	struct net_device		*dev;
21 	netdevice_tracker		dev_tracker;
22 
23 #ifdef CONFIG_XDP_SOCKETS
24 	struct xsk_buff_pool            *pool;
25 #endif
26 	/* NAPI instance for the queue
27 	 * Readers and writers must hold RTNL
28 	 */
29 	struct napi_struct		*napi;
30 	struct pp_memory_provider_params mp_params;
31 	ANDROID_KABI_RESERVE(1);
32 	ANDROID_KABI_RESERVE(2);
33 	ANDROID_KABI_RESERVE(3);
34 	ANDROID_KABI_RESERVE(4);
35 } ____cacheline_aligned_in_smp;
36 
37 /*
38  * RX queue sysfs structures and functions.
39  */
40 struct rx_queue_attribute {
41 	struct attribute attr;
42 	ssize_t (*show)(struct netdev_rx_queue *queue, char *buf);
43 	ssize_t (*store)(struct netdev_rx_queue *queue,
44 			 const char *buf, size_t len);
45 };
46 
47 static inline struct netdev_rx_queue *
__netif_get_rx_queue(struct net_device * dev,unsigned int rxq)48 __netif_get_rx_queue(struct net_device *dev, unsigned int rxq)
49 {
50 	return dev->_rx + rxq;
51 }
52 
53 static inline unsigned int
get_netdev_rx_queue_index(struct netdev_rx_queue * queue)54 get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
55 {
56 	struct net_device *dev = queue->dev;
57 	int index = queue - dev->_rx;
58 
59 	BUG_ON(index >= dev->num_rx_queues);
60 	return index;
61 }
62 
63 int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq);
64 
65 #endif
66