@@ -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;
@@ -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()
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(-)