summaryrefslogtreecommitdiff
path: root/io_uring
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2026-03-23 12:43:53 +0000
committerJens Axboe <axboe@kernel.dk>2026-04-01 10:21:12 -0600
commit06fc3b6d388dfa9c3df62830e07be828324b99e3 (patch)
treea621c223a40c3461705b99a25646890b87342f54 /io_uring
parentb8d6eb6c1c80852dfcad8642f346c26aabf34833 (diff)
io_uring/zcrx: extract netdev+area init into a helper
In preparation to following patches, add a function that is responsibly for looking up a netdev, creating an area, DMA mapping it and opening a queue. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://patch.msgid.link/88cb6f746ecb496a9030756125419df273d0b003.1774261953.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/zcrx.c72
1 files changed, 43 insertions, 29 deletions
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index a6a08ee48b34..b0f889b11b73 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -751,10 +751,50 @@ err:
return ret;
}
+static int zcrx_register_netdev(struct io_zcrx_ifq *ifq,
+ struct io_uring_zcrx_ifq_reg *reg,
+ struct io_uring_zcrx_area_reg *area)
+{
+ struct pp_memory_provider_params mp_param = {};
+ unsigned if_rxq = reg->if_rxq;
+ int ret;
+
+ ifq->netdev = netdev_get_by_index_lock(current->nsproxy->net_ns,
+ reg->if_idx);
+ if (!ifq->netdev)
+ return -ENODEV;
+
+ netdev_hold(ifq->netdev, &ifq->netdev_tracker, GFP_KERNEL);
+
+ ifq->dev = netdev_queue_get_dma_dev(ifq->netdev, if_rxq);
+ if (!ifq->dev) {
+ ret = -EOPNOTSUPP;
+ goto netdev_put_unlock;
+ }
+ get_device(ifq->dev);
+
+ ret = io_zcrx_create_area(ifq, area, reg);
+ if (ret)
+ goto netdev_put_unlock;
+
+ if (reg->rx_buf_len)
+ mp_param.rx_page_size = 1U << ifq->niov_shift;
+ mp_param.mp_ops = &io_uring_pp_zc_ops;
+ mp_param.mp_priv = ifq;
+ ret = __net_mp_open_rxq(ifq->netdev, if_rxq, &mp_param, NULL);
+ if (ret)
+ goto netdev_put_unlock;
+
+ ifq->if_rxq = if_rxq;
+ ret = 0;
+netdev_put_unlock:
+ netdev_unlock(ifq->netdev);
+ return ret;
+}
+
int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
struct io_uring_zcrx_ifq_reg __user *arg)
{
- struct pp_memory_provider_params mp_param = {};
struct io_uring_zcrx_area_reg area;
struct io_uring_zcrx_ifq_reg reg;
struct io_uring_region_desc rd;
@@ -821,33 +861,9 @@ int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
if (ret)
goto err;
- ifq->netdev = netdev_get_by_index_lock(current->nsproxy->net_ns, reg.if_idx);
- if (!ifq->netdev) {
- ret = -ENODEV;
- goto err;
- }
- netdev_hold(ifq->netdev, &ifq->netdev_tracker, GFP_KERNEL);
-
- ifq->dev = netdev_queue_get_dma_dev(ifq->netdev, reg.if_rxq);
- if (!ifq->dev) {
- ret = -EOPNOTSUPP;
- goto netdev_put_unlock;
- }
- get_device(ifq->dev);
-
- ret = io_zcrx_create_area(ifq, &area, &reg);
- if (ret)
- goto netdev_put_unlock;
-
- if (reg.rx_buf_len)
- mp_param.rx_page_size = 1U << ifq->niov_shift;
- mp_param.mp_ops = &io_uring_pp_zc_ops;
- mp_param.mp_priv = ifq;
- ret = __net_mp_open_rxq(ifq->netdev, reg.if_rxq, &mp_param, NULL);
+ ret = zcrx_register_netdev(ifq, &reg, &area);
if (ret)
- goto netdev_put_unlock;
- netdev_unlock(ifq->netdev);
- ifq->if_rxq = reg.if_rxq;
+ goto err;
reg.zcrx_id = id;
@@ -867,8 +883,6 @@ int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
goto err;
}
return 0;
-netdev_put_unlock:
- netdev_unlock(ifq->netdev);
err:
scoped_guard(mutex, &ctx->mmap_lock)
xa_erase(&ctx->zcrx_ctxs, id);