xref: /linux/include/net/netdev_rx_queue.h (revision 68ab8ba927758d77439785661f1f8b2a47318c5a)
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 <net/netdev_queues.h>
11 #include <net/rps-types.h>
12 
13 /* This structure contains an instance of an RX queue. */
14 struct netdev_rx_queue {
15 	struct xdp_rxq_info		xdp_rxq;
16 #ifdef CONFIG_RPS
17 	struct rps_map __rcu		*rps_map;
18 	rps_tag_ptr			rps_flow_table;
19 #endif
20 	struct kobject			kobj;
21 	const struct attribute_group	**groups;
22 	struct net_device		*dev;
23 	netdevice_tracker		dev_tracker;
24 
25 	/* All fields below are "ops protected",
26 	 * see comment about net_device::lock
27 	 */
28 #ifdef CONFIG_XDP_SOCKETS
29 	struct xsk_buff_pool            *pool;
30 #endif
31 	struct napi_struct		*napi;
32 	struct netdev_queue_config	qcfg;
33 	struct pp_memory_provider_params mp_params;
34 } ____cacheline_aligned_in_smp;
35 
36 /*
37  * RX queue sysfs structures and functions.
38  */
39 struct rx_queue_attribute {
40 	struct attribute attr;
41 	ssize_t (*show)(struct netdev_rx_queue *queue, char *buf);
42 	ssize_t (*store)(struct netdev_rx_queue *queue,
43 			 const char *buf, size_t len);
44 };
45 
46 static inline struct netdev_rx_queue *
47 __netif_get_rx_queue(struct net_device *dev, unsigned int rxq)
48 {
49 	return dev->_rx + rxq;
50 }
51 
52 static inline unsigned int
53 get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
54 {
55 	struct net_device *dev = queue->dev;
56 	int index = queue - dev->_rx;
57 
58 	BUG_ON(index >= dev->num_rx_queues);
59 	return index;
60 }
61 
62 int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq);
63 
64 #endif
65