public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nambiar, Amritha" <amritha.nambiar@intel.com>
To: Jakub Kicinski <kuba@kernel.org>, <ast@kernel.org>
Cc: <netdev@vger.kernel.org>, <bpf@vger.kernel.org>,
	<hawk@kernel.org>, <aleksander.lobakin@intel.com>,
	<mst@redhat.com>, <jasowang@redhat.com>,
	<xuanzhuo@linux.alibaba.com>, <daniel@iogearbox.net>,
	<andrii@kernel.org>, <martin.lau@linux.dev>, <song@kernel.org>,
	<yonghong.song@linux.dev>, <john.fastabend@gmail.com>,
	<kpsingh@kernel.org>, <sdf@google.com>, <haoluo@google.com>,
	<jolsa@kernel.org>, <bjorn@kernel.org>,
	<magnus.karlsson@intel.com>, <maciej.fijalkowski@intel.com>,
	<jonathan.lemon@gmail.com>, <gregkh@linuxfoundation.org>,
	<wangyufen@huawei.com>,
	<virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH bpf-next 2/3] net: move struct netdev_rx_queue out of netdevice.h
Date: Wed, 2 Aug 2023 12:42:51 -0700	[thread overview]
Message-ID: <ec094a06-e61b-0138-d258-d1952934f6b2@intel.com> (raw)
In-Reply-To: <20230802003246.2153774-3-kuba@kernel.org>

On 8/1/2023 5:32 PM, Jakub Kicinski wrote:
> 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.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: mst@redhat.com
> CC: jasowang@redhat.com
> CC: xuanzhuo@linux.alibaba.com
> CC: ast@kernel.org
> CC: daniel@iogearbox.net
> CC: andrii@kernel.org
> CC: martin.lau@linux.dev
> CC: song@kernel.org
> CC: yonghong.song@linux.dev
> CC: john.fastabend@gmail.com
> CC: kpsingh@kernel.org
> CC: sdf@google.com
> CC: haoluo@google.com
> CC: jolsa@kernel.org
> CC: bjorn@kernel.org
> CC: magnus.karlsson@intel.com
> CC: maciej.fijalkowski@intel.com
> CC: jonathan.lemon@gmail.com
> CC: hawk@kernel.org
> CC: gregkh@linuxfoundation.org
> CC: wangyufen@huawei.com
> CC: virtualization@lists.linux-foundation.org
> CC: bpf@vger.kernel.org
> ---
>   drivers/net/virtio_net.c      |  1 +
>   include/linux/netdevice.h     | 44 -----------------------------
>   include/net/netdev_rx_queue.h | 53 +++++++++++++++++++++++++++++++++++
>   net/bpf/test_run.c            |  1 +
>   net/core/dev.c                |  1 +
>   net/core/net-sysfs.c          |  1 +
>   net/xdp/xsk.c                 |  1 +
>   7 files changed, 58 insertions(+), 44 deletions(-)
>   create mode 100644 include/net/netdev_rx_queue.h
> 

Reviewed-by: Amritha Nambiar <amritha.nambiar@intel.com>

> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 0db14f6b87d3..5bcfd69333ea 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -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);
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 3800d0479698..5563c8a210b5 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -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
> index 000000000000..cdcafb30d437
> --- /dev/null
> +++ b/include/net/netdev_rx_queue.h
> @@ -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
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index 7d47f53f20c1..4ed68141d9a3 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -21,6 +21,7 @@
>   #include <linux/sock_diag.h>
>   #include <linux/netfilter.h>
>   #include <net/xdp.h>
> +#include <net/netdev_rx_queue.h>
>   #include <net/netfilter/nf_bpf_link.h>
>   
>   #define CREATE_TRACE_POINTS
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 8e7d0cb540cd..1fee2372b633 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -151,6 +151,7 @@
>   #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"
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 15e3f4606b5f..fccaa5bac0ed 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -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"
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 4f1e0599146e..82aaec1b079f 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -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"

  reply	other threads:[~2023-08-02 19:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02  0:32 [PATCH bpf-next 0/3] net: struct netdev_rx_queue and xdp.h reshuffling Jakub Kicinski
2023-08-02  0:32 ` [PATCH bpf-next 1/3] eth: add missing xdp.h includes in drivers Jakub Kicinski
2023-08-02  2:26   ` Wei Fang
2023-08-02 16:00   ` Alexander Lobakin
2023-08-02 18:06   ` Gerhard Engleder
2023-08-02  0:32 ` [PATCH bpf-next 2/3] net: move struct netdev_rx_queue out of netdevice.h Jakub Kicinski
2023-08-02 19:42   ` Nambiar, Amritha [this message]
2023-08-02  0:32 ` [PATCH bpf-next 3/3] net: invert the netdevice.h vs xdp.h dependency Jakub Kicinski
2023-08-02  2:31 ` [PATCH bpf-next 0/3] net: struct netdev_rx_queue and xdp.h reshuffling Alexei Starovoitov
2023-08-02  3:11   ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec094a06-e61b-0138-d258-d1952934f6b2@intel.com \
    --to=amritha.nambiar@intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=haoluo@google.com \
    --cc=hawk@kernel.org \
    --cc=jasowang@redhat.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=jonathan.lemon@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wangyufen@huawei.com \
    --cc=xuanzhuo@linux.alibaba.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox