xref: /openbmc/linux/include/net/netdev_rx_queue.h (revision 49e47a5b)
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 
10 /* This structure contains an instance of an RX queue. */
11 struct netdev_rx_queue {
12 	struct xdp_rxq_info		xdp_rxq;
13 #ifdef CONFIG_RPS
14 	struct rps_map __rcu		*rps_map;
15 	struct rps_dev_flow_table __rcu	*rps_flow_table;
16 #endif
17 	struct kobject			kobj;
18 	struct net_device		*dev;
19 	netdevice_tracker		dev_tracker;
20 
21 #ifdef CONFIG_XDP_SOCKETS
22 	struct xsk_buff_pool            *pool;
23 #endif
24 } ____cacheline_aligned_in_smp;
25 
26 /*
27  * RX queue sysfs structures and functions.
28  */
29 struct rx_queue_attribute {
30 	struct attribute attr;
31 	ssize_t (*show)(struct netdev_rx_queue *queue, char *buf);
32 	ssize_t (*store)(struct netdev_rx_queue *queue,
33 			 const char *buf, size_t len);
34 };
35 
36 static inline struct netdev_rx_queue *
__netif_get_rx_queue(struct net_device * dev,unsigned int rxq)37 __netif_get_rx_queue(struct net_device *dev, unsigned int rxq)
38 {
39 	return dev->_rx + rxq;
40 }
41 
42 #ifdef CONFIG_SYSFS
43 static inline unsigned int
get_netdev_rx_queue_index(struct netdev_rx_queue * queue)44 get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
45 {
46 	struct net_device *dev = queue->dev;
47 	int index = queue - dev->_rx;
48 
49 	BUG_ON(index >= dev->num_rx_queues);
50 	return index;
51 }
52 #endif
53 #endif
54