From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org, almasrymina@google.com,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 3/3] netdevsim: allow normal queue reset while down
Date: Wed, 5 Feb 2025 11:01:31 -0800 [thread overview]
Message-ID: <20250205190131.564456-4-kuba@kernel.org> (raw)
In-Reply-To: <20250205190131.564456-1-kuba@kernel.org>
Resetting queues while the device is down should be legal.
Allow it, test it. Ideally we'd test this with a real device
supporting devmem but I don't have access to such devices.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/netdevsim/netdev.c | 8 +++-----
tools/testing/selftests/net/nl_netdev.py | 17 ++++++++++++++++-
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 42f247cbdcee..d26b2fb1cabc 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -644,6 +644,9 @@ nsim_queue_mem_alloc(struct net_device *dev, void *per_queue_mem, int idx)
if (ns->rq_reset_mode > 3)
return -EINVAL;
+ /* Only "mode 0" works when device is down */
+ if (!netif_running(ns->netdev) && ns->rq_reset_mode)
+ return -ENETDOWN;
if (ns->rq_reset_mode == 1)
return nsim_create_page_pool(&qmem->pp, &ns->rq[idx]->napi);
@@ -754,11 +757,6 @@ nsim_qreset_write(struct file *file, const char __user *data,
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;
diff --git a/tools/testing/selftests/net/nl_netdev.py b/tools/testing/selftests/net/nl_netdev.py
index 93e8cb671c3d..9a03e3fe7e31 100755
--- a/tools/testing/selftests/net/nl_netdev.py
+++ b/tools/testing/selftests/net/nl_netdev.py
@@ -35,6 +35,20 @@ from lib.py import NetdevFamily, NetdevSimDev, ip
comment=f"queue count after reset queue {q} mode {i}")
+def nsim_rxq_reset_down(nf) -> None:
+ """
+ Test that the queue API supports resetting a queue
+ while the interface is down. We should convert this
+ test to testing real HW once more devices support
+ queue API.
+ """
+ with NetdevSimDev(queue_count=4) as nsimdev:
+ nsim = nsimdev.nsims[0]
+
+ ip(f"link set dev {nsim.ifname} down")
+ nsim.dfs_write("queue_reset", f"1 0")
+
+
def page_pool_check(nf) -> None:
with NetdevSimDev() as nsimdev:
nsim = nsimdev.nsims[0]
@@ -106,7 +120,8 @@ from lib.py import NetdevFamily, NetdevSimDev, ip
def main() -> None:
nf = NetdevFamily()
- ksft_run([empty_check, lo_check, page_pool_check, napi_list_check],
+ ksft_run([empty_check, lo_check, page_pool_check, napi_list_check,
+ nsim_rxq_reset_down],
args=(nf, ))
ksft_exit()
--
2.48.1
next prev parent reply other threads:[~2025-02-05 19:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 19:01 [PATCH net-next 0/3] net: improve core queue API handling while device is down Jakub Kicinski
2025-02-05 19:01 ` [PATCH net-next 1/3] net: refactor netdev_rx_queue_restart() to use local qops Jakub Kicinski
2025-02-05 20:27 ` Mina Almasry
2025-02-05 19:01 ` [PATCH net-next 2/3] net: devmem: don't call queue stop / start when the interface is down Jakub Kicinski
2025-02-05 20:35 ` Mina Almasry
2025-02-06 1:26 ` Jakub Kicinski
2025-02-06 16:34 ` Mina Almasry
2025-02-05 19:01 ` Jakub Kicinski [this message]
2025-02-06 16:43 ` [PATCH net-next 3/3] netdevsim: allow normal queue reset while down Mina Almasry
2025-02-06 17:17 ` 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=20250205190131.564456-4-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@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;
as well as URLs for NNTP newsgroup(s).