net: move struct netdev_rx_queue out of netdevice.h
authorJakub Kicinski <kuba@kernel.org>
Thu, 3 Aug 2023 01:02:29 +0000 (18:02 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 3 Aug 2023 15:38:07 +0000 (08:38 -0700)
struct netdev_rx_queue is touched in only a few places
and having it defined in netdevice.h brings in the dependency
on xdp.h, because struct xdp_rxq_info gets embedded in
struct netdev_rx_queue.

In prep for removal of xdp.h from netdevice.h move all
the netdev_rx_queue stuff to a new header.

We could technically break the new header up to avoid
the sysfs.h include but it's so rarely included it
doesn't seem to be worth it at this point.

Reviewed-by: Amritha Nambiar <amritha.nambiar@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
Link: https://lore.kernel.org/r/20230803010230.1755386-3-kuba@kernel.org
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
drivers/net/virtio_net.c
include/linux/netdevice.h
include/net/netdev_rx_queue.h [new file with mode: 0644]
net/bpf/test_run.c
net/core/dev.c
net/core/net-sysfs.c
net/xdp/xsk.c

index 0db14f6b87d3ed76195beb242d894f434628ade8..5bcfd69333eaa2e5377c784420f6ab06fa60ea3e 100644 (file)
@@ -22,6 +22,7 @@
 #include <net/route.h>
 #include <net/xdp.h>
 #include <net/net_failover.h>
+#include <net/netdev_rx_queue.h>
 
 static int napi_weight = NAPI_POLL_WEIGHT;
 module_param(napi_weight, int, 0444);
index 3800d047969842d425d0fde82f8f3f6662835c7a..5563c8a210b5494bb53a79358ce44e38c9e08844 100644 (file)
@@ -782,32 +782,6 @@ bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, u32 flow_id,
 #endif
 #endif /* CONFIG_RPS */
 
-/* This structure contains an instance of an RX queue. */
-struct netdev_rx_queue {
-       struct xdp_rxq_info             xdp_rxq;
-#ifdef CONFIG_RPS
-       struct rps_map __rcu            *rps_map;
-       struct rps_dev_flow_table __rcu *rps_flow_table;
-#endif
-       struct kobject                  kobj;
-       struct net_device               *dev;
-       netdevice_tracker               dev_tracker;
-
-#ifdef CONFIG_XDP_SOCKETS
-       struct xsk_buff_pool            *pool;
-#endif
-} ____cacheline_aligned_in_smp;
-
-/*
- * RX queue sysfs structures and functions.
- */
-struct rx_queue_attribute {
-       struct attribute attr;
-       ssize_t (*show)(struct netdev_rx_queue *queue, char *buf);
-       ssize_t (*store)(struct netdev_rx_queue *queue,
-                        const char *buf, size_t len);
-};
-
 /* XPS map type and offset of the xps map within net_device->xps_maps[]. */
 enum xps_map_type {
        XPS_CPUS = 0,
@@ -3828,24 +3802,6 @@ static inline int netif_set_real_num_rx_queues(struct net_device *dev,
 int netif_set_real_num_queues(struct net_device *dev,
                              unsigned int txq, unsigned int rxq);
 
-static inline struct netdev_rx_queue *
-__netif_get_rx_queue(struct net_device *dev, unsigned int rxq)
-{
-       return dev->_rx + rxq;
-}
-
-#ifdef CONFIG_SYSFS
-static inline unsigned int get_netdev_rx_queue_index(
-               struct netdev_rx_queue *queue)
-{
-       struct net_device *dev = queue->dev;
-       int index = queue - dev->_rx;
-
-       BUG_ON(index >= dev->num_rx_queues);
-       return index;
-}
-#endif
-
 int netif_get_num_default_rss_queues(void);
 
 void dev_kfree_skb_irq_reason(struct sk_buff *skb, enum skb_drop_reason reason);
diff --git a/include/net/netdev_rx_queue.h b/include/net/netdev_rx_queue.h
new file mode 100644 (file)
index 0000000..cdcafb3
--- /dev/null
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_NETDEV_RX_QUEUE_H
+#define _LINUX_NETDEV_RX_QUEUE_H
+
+#include <linux/kobject.h>
+#include <linux/netdevice.h>
+#include <linux/sysfs.h>
+#include <net/xdp.h>
+
+/* This structure contains an instance of an RX queue. */
+struct netdev_rx_queue {
+       struct xdp_rxq_info             xdp_rxq;
+#ifdef CONFIG_RPS
+       struct rps_map __rcu            *rps_map;
+       struct rps_dev_flow_table __rcu *rps_flow_table;
+#endif
+       struct kobject                  kobj;
+       struct net_device               *dev;
+       netdevice_tracker               dev_tracker;
+
+#ifdef CONFIG_XDP_SOCKETS
+       struct xsk_buff_pool            *pool;
+#endif
+} ____cacheline_aligned_in_smp;
+
+/*
+ * RX queue sysfs structures and functions.
+ */
+struct rx_queue_attribute {
+       struct attribute attr;
+       ssize_t (*show)(struct netdev_rx_queue *queue, char *buf);
+       ssize_t (*store)(struct netdev_rx_queue *queue,
+                        const char *buf, size_t len);
+};
+
+static inline struct netdev_rx_queue *
+__netif_get_rx_queue(struct net_device *dev, unsigned int rxq)
+{
+       return dev->_rx + rxq;
+}
+
+#ifdef CONFIG_SYSFS
+static inline unsigned int
+get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
+{
+       struct net_device *dev = queue->dev;
+       int index = queue - dev->_rx;
+
+       BUG_ON(index >= dev->num_rx_queues);
+       return index;
+}
+#endif
+#endif
index 7d47f53f20c10943fa00bc11a7715c29ea547e99..0aac76c13fd4abfcd496f0743bd6e5e3b7394664 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/smp.h>
 #include <linux/sock_diag.h>
 #include <linux/netfilter.h>
+#include <net/netdev_rx_queue.h>
 #include <net/xdp.h>
 #include <net/netfilter/nf_bpf_link.h>
 
index 002fec07de7393bc9127837e0eb49f683cd08e4a..1916ec990f58b496195061dfd190a0f7d4f5006b 100644 (file)
 #include <linux/pm_runtime.h>
 #include <linux/prandom.h>
 #include <linux/once_lite.h>
+#include <net/netdev_rx_queue.h>
 
 #include "dev.h"
 #include "net-sysfs.h"
index 15e3f4606b5f994727488f0a618fc781956bc0a6..fccaa5bac0ed0a34a55bef1f4f6487a81285f286 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/of.h>
 #include <linux/of_net.h>
 #include <linux/cpu.h>
+#include <net/netdev_rx_queue.h>
 
 #include "dev.h"
 #include "net-sysfs.h"
index 4f1e0599146e2cde9dea5907feda8c9b136540d2..82aaec1b079fc37ccda5f0beace2ce552d87abb0 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/vmalloc.h>
 #include <net/xdp_sock_drv.h>
 #include <net/busy_poll.h>
+#include <net/netdev_rx_queue.h>
 #include <net/xdp.h>
 
 #include "xsk_queue.h"