]>
git.ipfire.org Git - thirdparty/kernel/linux.git/blob - io_uring/napi.h
1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <linux/kernel.h>
7 #include <linux/io_uring.h>
8 #include <net/busy_poll.h>
10 #ifdef CONFIG_NET_RX_BUSY_POLL
12 void io_napi_init(struct io_ring_ctx
*ctx
);
13 void io_napi_free(struct io_ring_ctx
*ctx
);
15 int io_register_napi(struct io_ring_ctx
*ctx
, void __user
*arg
);
16 int io_unregister_napi(struct io_ring_ctx
*ctx
, void __user
*arg
);
18 void __io_napi_add(struct io_ring_ctx
*ctx
, struct socket
*sock
);
20 void __io_napi_adjust_timeout(struct io_ring_ctx
*ctx
,
21 struct io_wait_queue
*iowq
, struct timespec64
*ts
);
22 void __io_napi_busy_loop(struct io_ring_ctx
*ctx
, struct io_wait_queue
*iowq
);
23 int io_napi_sqpoll_busy_poll(struct io_ring_ctx
*ctx
);
25 static inline bool io_napi(struct io_ring_ctx
*ctx
)
27 return !list_empty(&ctx
->napi_list
);
30 static inline void io_napi_adjust_timeout(struct io_ring_ctx
*ctx
,
31 struct io_wait_queue
*iowq
,
32 struct timespec64
*ts
)
36 __io_napi_adjust_timeout(ctx
, iowq
, ts
);
39 static inline void io_napi_busy_loop(struct io_ring_ctx
*ctx
,
40 struct io_wait_queue
*iowq
)
44 __io_napi_busy_loop(ctx
, iowq
);
48 * io_napi_add() - Add napi id to the busy poll list
49 * @req: pointer to io_kiocb request
51 * Add the napi id of the socket to the napi busy poll list and hash table.
53 static inline void io_napi_add(struct io_kiocb
*req
)
55 struct io_ring_ctx
*ctx
= req
->ctx
;
58 if (!READ_ONCE(ctx
->napi_busy_poll_to
))
61 sock
= sock_from_file(req
->file
);
63 __io_napi_add(ctx
, sock
);
68 static inline void io_napi_init(struct io_ring_ctx
*ctx
)
71 static inline void io_napi_free(struct io_ring_ctx
*ctx
)
74 static inline int io_register_napi(struct io_ring_ctx
*ctx
, void __user
*arg
)
78 static inline int io_unregister_napi(struct io_ring_ctx
*ctx
, void __user
*arg
)
82 static inline bool io_napi(struct io_ring_ctx
*ctx
)
86 static inline void io_napi_add(struct io_kiocb
*req
)
89 static inline void io_napi_adjust_timeout(struct io_ring_ctx
*ctx
,
90 struct io_wait_queue
*iowq
,
91 struct timespec64
*ts
)
94 static inline void io_napi_busy_loop(struct io_ring_ctx
*ctx
,
95 struct io_wait_queue
*iowq
)
98 static inline int io_napi_sqpoll_busy_poll(struct io_ring_ctx
*ctx
)
102 #endif /* CONFIG_NET_RX_BUSY_POLL */