1io_uring_prep_provide_buffers(3)liburing Manualio_uring_prep_provide_buffers(3)
2
3
4

NAME

6       io_uring_prep_provide_buffers - prepare a provide buffers request
7

SYNOPSIS

9       #include <liburing.h>
10
11       void io_uring_prep_provide_buffers(struct io_uring_sqe *sqe,
12                                          void *addr,
13                                          int len,
14                                          int nr,
15                                          int bgid,
16                                          int bid);
17

DESCRIPTION

19       The  io_uring_prep_provide_buffers(3)  function  prepares a request for
20       providing the kernel with buffers. The submission queue  entry  sqe  is
21       setup  to  consume  nr number of len sized buffers starting at addr and
22       identified by the buffer group ID of  bgid  and  numbered  sequentially
23       starting at bid.
24
25       This function sets up a request to provide buffers to the io_uring con‐
26       text that can be used by read or receive operations. This  is  done  by
27       filling  in  the SQE buf_group field and setting IOSQE_BUFFER_SELECT in
28       the SQE flags member. If buffer selection is used  for  a  request,  no
29       buffer  should  be provided in the address field. Instead, the group ID
30       is set to match one that was previously provided  to  the  kernel.  The
31       kernel  will then select a buffer from this group for the IO operation.
32       On successful completion of the IO request, the CQE  flags  field  will
33       have  IORING_CQE_F_BUFFER  set and the selected buffer ID will be indi‐
34       cated by the upper 16-bits of the flags field.
35
36       Different buffer group IDs can be used by the application to have  dif‐
37       ferent sizes or types of buffers available. Once a buffer has been con‐
38       sumed for an operation, it is no longer known to io_uring. It  must  be
39       re-provided  if  so  desired  or  freed by the application if no longer
40       needed.
41
42       The buffer IDs are internally tracked from bid and sequentially ascend‐
43       ing  from that value. If 16 buffers are provided and start with an ini‐
44       tial bid of 0, then the buffer IDs will range from 0..15.  The applica‐
45       tion  must  be aware of this to make sense of the buffer ID passed back
46       in the CQE.
47
48       Buffer IDs always range from 0 to 65535 , as  there  are  only  16-bits
49       available  in  the  CQE to pass them back. This range is independent of
50       how the buffer group initially got created. Attempting  to  add  buffer
51       IDs  larger  than  that,  or  buffer  IDs that will wrap when cast to a
52       16-bit value, will cause the request to fail with -E2BIG or -EINVAL .
53
54       Not all requests support buffer selection,  as  it  only  really  makes
55       sense  for requests that receive data from the kernel rather than write
56       or provide data.  Currently, this mode of operation  is  supported  for
57       any  file  read or socket receive request. Attempting to use IOSQE_BUF‐
58       FER_SELECT with a command that doesn't support it will result in a  CQE
59       res  error of -EINVAL.  Buffer selection will work with operations that
60       take a struct iovec as its data destination, but only  if  1  iovec  is
61       provided.
62

RETURN VALUE

64       None
65

ERRORS

67       These  are  the  errors that are reported in the CQE res field. On suc‐
68       cess, res will contain 0 or the number of  successfully  provided  buf‐
69       fers.
70
71       -ENOMEM
72              The kernel was unable to allocate memory for the request.
73
74       -EINVAL
75              One of the fields set in the SQE was invalid.
76
77       -E2BIG The  number  of buffers provided was too big, or the bid was too
78              big. A max value of USHRT_MAX buffers can be specified.
79
80       -EFAULT
81              Some of the user memory given was invalid for the application.
82
83       -EOVERFLOW
84              The product of len and nr exceed the valid amount or overflowed,
85              or the sum of addr and the length of buffers overflowed.
86
87       -EBUSY Attempt to update a slot that is already used.
88

SEE ALSO

90       io_uring_get_sqe(3),  io_uring_submit(3),  io_uring_register(2), io_ur‐
91       ing_prep_remove_buffers(3)
92
93
94
95liburing-2.2                    March 13, 2022io_uring_prep_provide_buffers(3)
Impressum