2025-02-14 16:09:36 -08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef IOU_ZC_RX_H
|
|
|
|
#define IOU_ZC_RX_H
|
|
|
|
|
|
|
|
#include <linux/io_uring_types.h>
|
2025-05-01 13:17:18 +01:00
|
|
|
#include <linux/dma-buf.h>
|
2025-02-14 16:09:41 -08:00
|
|
|
#include <linux/socket.h>
|
2025-02-14 16:09:37 -08:00
|
|
|
#include <net/page_pool/types.h>
|
2025-02-14 16:09:38 -08:00
|
|
|
#include <net/net_trackers.h>
|
2025-02-14 16:09:37 -08:00
|
|
|
|
2025-05-01 13:17:16 +01:00
|
|
|
struct io_zcrx_mem {
|
|
|
|
unsigned long size;
|
2025-05-01 13:17:18 +01:00
|
|
|
bool is_dmabuf;
|
2025-05-01 13:17:16 +01:00
|
|
|
|
|
|
|
struct page **pages;
|
|
|
|
unsigned long nr_folios;
|
2025-07-02 15:29:07 +01:00
|
|
|
struct sg_table page_sg_table;
|
2025-07-16 22:04:09 +01:00
|
|
|
unsigned long account_pages;
|
2025-05-01 13:17:18 +01:00
|
|
|
|
|
|
|
struct dma_buf_attachment *attach;
|
|
|
|
struct dma_buf *dmabuf;
|
|
|
|
struct sg_table *sgt;
|
|
|
|
unsigned long dmabuf_offset;
|
2025-05-01 13:17:16 +01:00
|
|
|
};
|
|
|
|
|
2025-02-14 16:09:37 -08:00
|
|
|
struct io_zcrx_area {
|
|
|
|
struct net_iov_area nia;
|
|
|
|
struct io_zcrx_ifq *ifq;
|
2025-02-14 16:09:39 -08:00
|
|
|
atomic_t *user_refs;
|
2025-02-14 16:09:37 -08:00
|
|
|
|
2025-02-14 16:09:40 -08:00
|
|
|
bool is_mapped;
|
2025-02-14 16:09:37 -08:00
|
|
|
u16 area_id;
|
|
|
|
|
|
|
|
/* freelist */
|
|
|
|
spinlock_t freelist_lock ____cacheline_aligned_in_smp;
|
|
|
|
u32 free_count;
|
|
|
|
u32 *freelist;
|
2025-05-01 13:17:16 +01:00
|
|
|
|
|
|
|
struct io_zcrx_mem mem;
|
2025-02-14 16:09:37 -08:00
|
|
|
};
|
2025-02-14 16:09:36 -08:00
|
|
|
|
|
|
|
struct io_zcrx_ifq {
|
|
|
|
struct io_ring_ctx *ctx;
|
2025-02-14 16:09:37 -08:00
|
|
|
struct io_zcrx_area *area;
|
|
|
|
|
2025-04-05 11:17:49 +01:00
|
|
|
spinlock_t rq_lock ____cacheline_aligned_in_smp;
|
2025-02-14 16:09:36 -08:00
|
|
|
struct io_uring *rq_ring;
|
|
|
|
struct io_uring_zcrx_rqe *rqes;
|
2025-02-14 16:09:39 -08:00
|
|
|
u32 cached_rq_head;
|
2025-04-05 11:17:49 +01:00
|
|
|
u32 rq_entries;
|
2025-02-14 16:09:36 -08:00
|
|
|
|
|
|
|
u32 if_rxq;
|
2025-02-14 16:09:38 -08:00
|
|
|
struct device *dev;
|
|
|
|
struct net_device *netdev;
|
|
|
|
netdevice_tracker netdev_tracker;
|
|
|
|
spinlock_t lock;
|
2025-04-18 13:02:27 +01:00
|
|
|
struct mutex dma_lock;
|
2025-04-20 10:31:19 +01:00
|
|
|
struct io_mapped_region region;
|
2025-02-14 16:09:36 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#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);
|
2025-02-14 16:09:41 -08:00
|
|
|
int io_zcrx_recv(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
|
|
|
|
struct socket *sock, unsigned int flags,
|
2025-02-23 20:13:18 -08:00
|
|
|
unsigned issue_flags, unsigned int *len);
|
2025-04-20 10:31:18 +01:00
|
|
|
struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ctx,
|
|
|
|
unsigned int id);
|
2025-02-14 16:09:36 -08:00
|
|
|
#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)
|
|
|
|
{
|
|
|
|
}
|
2025-02-14 16:09:41 -08:00
|
|
|
static inline int io_zcrx_recv(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
|
|
|
|
struct socket *sock, unsigned int flags,
|
2025-02-23 20:13:18 -08:00
|
|
|
unsigned issue_flags, unsigned int *len)
|
2025-02-14 16:09:41 -08:00
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2025-04-20 10:31:18 +01:00
|
|
|
static inline struct io_mapped_region *io_zcrx_get_region(struct io_ring_ctx *ctx,
|
|
|
|
unsigned int id)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2025-02-14 16:09:36 -08:00
|
|
|
#endif
|
|
|
|
|
2025-02-14 16:09:41 -08:00
|
|
|
int io_recvzc(struct io_kiocb *req, unsigned int issue_flags);
|
|
|
|
int io_recvzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
|
|
|
|
|
2025-02-14 16:09:36 -08:00
|
|
|
#endif
|