mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
Add io_zcrx_area that represents a region of userspace memory that is used for zero copy. During ifq registration, userspace passes in the uaddr and len of userspace memory, which is then pinned by the kernel. Each net_iov is mapped to one of these pages. The freelist is a spinlock protected list that keeps track of all the net_iovs/pages that aren't used. For now, there is only one area per ifq and area registration happens implicitly as part of ifq registration. There is no API for adding/removing areas yet. The struct for area registration is there for future extensibility once we support multiple areas and TCP devmem. Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: David Wei <dw@davidwei.uk> Acked-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/r/20250215000947.789731-3-dw@davidwei.uk Signed-off-by: Jens Axboe <axboe@kernel.dk>
52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef IOU_ZC_RX_H
|
|
#define IOU_ZC_RX_H
|
|
|
|
#include <linux/io_uring_types.h>
|
|
#include <net/page_pool/types.h>
|
|
|
|
struct io_zcrx_area {
|
|
struct net_iov_area nia;
|
|
struct io_zcrx_ifq *ifq;
|
|
|
|
u16 area_id;
|
|
struct page **pages;
|
|
|
|
/* freelist */
|
|
spinlock_t freelist_lock ____cacheline_aligned_in_smp;
|
|
u32 free_count;
|
|
u32 *freelist;
|
|
};
|
|
|
|
struct io_zcrx_ifq {
|
|
struct io_ring_ctx *ctx;
|
|
struct io_zcrx_area *area;
|
|
|
|
struct io_uring *rq_ring;
|
|
struct io_uring_zcrx_rqe *rqes;
|
|
u32 rq_entries;
|
|
|
|
u32 if_rxq;
|
|
};
|
|
|
|
#if defined(CONFIG_IO_URING_ZCRX)
|
|
int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
|
|
struct io_uring_zcrx_ifq_reg __user *arg);
|
|
void io_unregister_zcrx_ifqs(struct io_ring_ctx *ctx);
|
|
void io_shutdown_zcrx_ifqs(struct io_ring_ctx *ctx);
|
|
#else
|
|
static inline int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
|
|
struct io_uring_zcrx_ifq_reg __user *arg)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
static inline void io_unregister_zcrx_ifqs(struct io_ring_ctx *ctx)
|
|
{
|
|
}
|
|
static inline void io_shutdown_zcrx_ifqs(struct io_ring_ctx *ctx)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#endif
|