Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>,  davem@davemloft.net
Cc: netdev@vger.kernel.org,  edumazet@google.com,  pabeni@redhat.com,
	 dw@davidwei.uk,  almasrymina@google.com,  jdamato@fastly.com,
	 Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next 7/8] netdevsim: add debugfs-triggered queue reset
Date: Tue, 07 Jan 2025 09:04:42 -0500	[thread overview]
Message-ID: <677d347a2c5d8_25382b29488@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <20250103185954.1236510-8-kuba@kernel.org>

Jakub Kicinski wrote:
> Support triggering queue reset via debugfs for an upcoming test.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  drivers/net/netdevsim/netdev.c    | 55 +++++++++++++++++++++++++++++++
>  drivers/net/netdevsim/netdevsim.h |  1 +
>  2 files changed, 56 insertions(+)
> 
> diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
> index 86614292314a..65605d2eb943 100644
> --- a/drivers/net/netdevsim/netdev.c
> +++ b/drivers/net/netdevsim/netdev.c
> @@ -20,6 +20,7 @@
>  #include <linux/netdevice.h>
>  #include <linux/slab.h>
>  #include <net/netdev_queues.h>
> +#include <net/netdev_rx_queue.h>
>  #include <net/page_pool/helpers.h>
>  #include <net/netlink.h>
>  #include <net/net_shaper.h>
> @@ -29,6 +30,8 @@
>  
>  #include "netdevsim.h"
>  
> +MODULE_IMPORT_NS("NETDEV_INTERNAL");
> +
>  #define NSIM_RING_SIZE		256
>  
>  static int nsim_napi_rx(struct nsim_rq *rq, struct sk_buff *skb)
> @@ -723,6 +726,54 @@ static const struct netdev_queue_mgmt_ops nsim_queue_mgmt_ops = {
>  	.ndo_queue_stop		= nsim_queue_stop,
>  };
>  
> +static ssize_t
> +nsim_qreset_write(struct file *file, const char __user *data,
> +		  size_t count, loff_t *ppos)
> +{
> +	struct netdevsim *ns = file->private_data;
> +	unsigned int queue, mode;
> +	char buf[32];
> +	ssize_t ret;
> +
> +	if (count >= sizeof(buf))
> +		return -EINVAL;
> +	if (copy_from_user(buf, data, count))
> +                return -EFAULT;
> +        buf[count] = '\0';
> +
> +	ret = sscanf(buf, "%u %u", &queue, &mode);
> +	if (ret != 2)
> +		return -EINVAL;
> +
> +	rtnl_lock();
> +	if (!netif_running(ns->netdev)) {
> +		ret = -ENETDOWN;
> +		goto exit_unlock;
> +	}
> +
> +	if (queue >= ns->netdev->real_num_rx_queues) {
> +		ret = -EINVAL;
> +		goto exit_unlock;
> +	}
> +
> +	ns->rq_reset_mode = mode;
> +	ret = netdev_rx_queue_restart(ns->netdev, queue);
> +	ns->rq_reset_mode = 0;
> +	if (ret)
> +		goto exit_unlock;
> +
> +	ret = count;
> +exit_unlock:
> +	rtnl_unlock();
> +	return ret;
> +}
> +
> +static const struct file_operations nsim_qreset_fops = {
> +	.open = simple_open,
> +	.write = nsim_qreset_write,
> +	.owner = THIS_MODULE,
> +};
> +
>  static ssize_t
>  nsim_pp_hold_read(struct file *file, char __user *data,
>  		  size_t count, loff_t *ppos)
> @@ -935,6 +986,9 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port)
>  
>  	ns->pp_dfs = debugfs_create_file("pp_hold", 0600, nsim_dev_port->ddir,
>  					 ns, &nsim_pp_hold_fops);
> +	ns->qr_dfs = debugfs_create_file("queue_reset", 0600,
> +					 nsim_dev_port->ddir, ns,
> +					 &nsim_qreset_fops);
>  
>  	return ns;
>  
> @@ -949,6 +1003,7 @@ void nsim_destroy(struct netdevsim *ns)
>  	struct netdevsim *peer;
>  
>  	debugfs_remove(ns->pp_dfs);
> +	debugfs_remove(ns->qr_dfs);

Only since being respun: perhaps free in inverse order of alloc

  parent reply	other threads:[~2025-01-07 14:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-03 18:59 [PATCH net-next 0/8] net: make sure we retain NAPI ordering on netdev->napi_list Jakub Kicinski
2025-01-03 18:59 ` [PATCH net-next 1/8] " Jakub Kicinski
2025-01-06  9:35   ` Eric Dumazet
2025-01-03 18:59 ` [PATCH net-next 2/8] netdev: define NETDEV_INTERNAL Jakub Kicinski
2025-01-06  9:36   ` Eric Dumazet
2025-01-07 21:04   ` Mina Almasry
2025-01-03 18:59 ` [PATCH net-next 3/8] netdevsim: support NAPI config Jakub Kicinski
2025-01-06  9:36   ` Eric Dumazet
2025-01-03 18:59 ` [PATCH net-next 4/8] netdevsim: allocate rqs individually Jakub Kicinski
2025-01-06  9:52   ` Eric Dumazet
2025-01-07 10:33   ` Paolo Abeni
2025-01-03 18:59 ` [PATCH net-next 5/8] netdevsim: add queue alloc/free helpers Jakub Kicinski
2025-01-06  9:57   ` Eric Dumazet
2025-01-07 21:08   ` Mina Almasry
2025-01-07 21:15     ` Jakub Kicinski
2025-01-03 18:59 ` [PATCH net-next 6/8] netdevsim: add queue management API support Jakub Kicinski
2025-01-06 16:45   ` Stanislav Fomichev
2025-01-07 14:03   ` Willem de Bruijn
2025-01-07 14:49     ` Jakub Kicinski
2025-01-07 15:16       ` Willem de Bruijn
2025-01-03 18:59 ` [PATCH net-next 7/8] netdevsim: add debugfs-triggered queue reset Jakub Kicinski
2025-01-06 16:46   ` Stanislav Fomichev
2025-01-07 11:06   ` Paolo Abeni
2025-01-07 14:04   ` Willem de Bruijn [this message]
2025-01-03 18:59 ` [PATCH net-next 8/8] selftests: net: test listing NAPI vs queue resets Jakub Kicinski
2025-01-06 16:47   ` Stanislav Fomichev
2025-01-07 14:06 ` [PATCH net-next 0/8] net: make sure we retain NAPI ordering on netdev->napi_list Willem de Bruijn

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=677d347a2c5d8_25382b29488@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=almasrymina@google.com \
    --cc=davem@davemloft.net \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=jdamato@fastly.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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