~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/io_uring/napi.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 
  3 #ifndef IOU_NAPI_H
  4 #define IOU_NAPI_H
  5 
  6 #include <linux/kernel.h>
  7 #include <linux/io_uring.h>
  8 #include <net/busy_poll.h>
  9 
 10 #ifdef CONFIG_NET_RX_BUSY_POLL
 11 
 12 void io_napi_init(struct io_ring_ctx *ctx);
 13 void io_napi_free(struct io_ring_ctx *ctx);
 14 
 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);
 17 
 18 void __io_napi_add(struct io_ring_ctx *ctx, struct socket *sock);
 19 
 20 void __io_napi_adjust_timeout(struct io_ring_ctx *ctx,
 21                 struct io_wait_queue *iowq, ktime_t to_wait);
 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);
 24 
 25 static inline bool io_napi(struct io_ring_ctx *ctx)
 26 {
 27         return !list_empty(&ctx->napi_list);
 28 }
 29 
 30 static inline void io_napi_adjust_timeout(struct io_ring_ctx *ctx,
 31                                           struct io_wait_queue *iowq,
 32                                           ktime_t to_wait)
 33 {
 34         if (!io_napi(ctx))
 35                 return;
 36         __io_napi_adjust_timeout(ctx, iowq, to_wait);
 37 }
 38 
 39 static inline void io_napi_busy_loop(struct io_ring_ctx *ctx,
 40                                      struct io_wait_queue *iowq)
 41 {
 42         if (!io_napi(ctx))
 43                 return;
 44         __io_napi_busy_loop(ctx, iowq);
 45 }
 46 
 47 /*
 48  * io_napi_add() - Add napi id to the busy poll list
 49  * @req: pointer to io_kiocb request
 50  *
 51  * Add the napi id of the socket to the napi busy poll list and hash table.
 52  */
 53 static inline void io_napi_add(struct io_kiocb *req)
 54 {
 55         struct io_ring_ctx *ctx = req->ctx;
 56         struct socket *sock;
 57 
 58         if (!READ_ONCE(ctx->napi_enabled))
 59                 return;
 60 
 61         sock = sock_from_file(req->file);
 62         if (sock)
 63                 __io_napi_add(ctx, sock);
 64 }
 65 
 66 #else
 67 
 68 static inline void io_napi_init(struct io_ring_ctx *ctx)
 69 {
 70 }
 71 static inline void io_napi_free(struct io_ring_ctx *ctx)
 72 {
 73 }
 74 static inline int io_register_napi(struct io_ring_ctx *ctx, void __user *arg)
 75 {
 76         return -EOPNOTSUPP;
 77 }
 78 static inline int io_unregister_napi(struct io_ring_ctx *ctx, void __user *arg)
 79 {
 80         return -EOPNOTSUPP;
 81 }
 82 static inline bool io_napi(struct io_ring_ctx *ctx)
 83 {
 84         return false;
 85 }
 86 static inline void io_napi_add(struct io_kiocb *req)
 87 {
 88 }
 89 static inline void io_napi_adjust_timeout(struct io_ring_ctx *ctx,
 90                                           struct io_wait_queue *iowq,
 91                                           ktime_t to_wait)
 92 {
 93 }
 94 static inline void io_napi_busy_loop(struct io_ring_ctx *ctx,
 95                                      struct io_wait_queue *iowq)
 96 {
 97 }
 98 static inline int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx)
 99 {
100         return 0;
101 }
102 #endif /* CONFIG_NET_RX_BUSY_POLL */
103 
104 #endif
105 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php