Skip to content

Commit 5ddccf5

Browse files
tacslontohojo
authored andcommitted
libxdp: Doc adaptation for XSk umem opts-creation
Edit documentation for creating XSk umem by opts, with minor format fix. Signed-off-by: Muyang Tian <[email protected]>
1 parent 3b199c0 commit 5ddccf5

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

lib/libxdp/README.org

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,14 @@ BPF maps which is a must if users want to add their own XDP program.
267267

268268
If there is already a socket created with socket(AF_XDP, SOCK_RAW, 0)
269269
not bound and not tied to any umem, file descriptor of this socket can
270-
be used in an xsk_umem__create_with_fd() variant of the umem creation
271-
function.
270+
be used in param opts of xsk_umem__create_opts(), which is a recommended
271+
way of umem creation.
272272

273273
#+begin_src C
274+
struct xsk_umem *xsk_umem__create_opts(void *umem_area,
275+
struct xsk_ring_prod *fill,
276+
struct xsk_ring_cons *comp,
277+
struct xsk_umem_opts *opts);
274278
int xsk_umem__create(struct xsk_umem **umem,
275279
void *umem_area, __u64 size,
276280
struct xsk_ring_prod *fill,
@@ -324,8 +328,8 @@ int xsk_socket__update_xskmap(struct xsk_socket *xsk, int xsks_map_fd);
324328

325329
To further reduce required level of privileges, an AF_XDP socket can be created
326330
beforehand with socket(AF_XDP, SOCK_RAW, 0) and passed to a non-privileged
327-
process. This socket can be used in xsk_umem__create_with_fd() and later
328-
in xsk_socket__create() with created umem. xsk_socket__create_shared() would
331+
process. This socket can be used in xsk_umem__create_opts() and later in
332+
xsk_socket__create() with created umem. xsk_socket__create_shared() would
329333
still require privileges for AF_XDP socket creation.
330334

331335
** Data path

lib/libxdp/libxdp.3

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,16 @@ BPF maps which is a must if users want to add their own XDP program.
301301
.PP
302302
If there is already a socket created with socket(AF_XDP, SOCK_RAW, 0)
303303
not bound and not tied to any umem, file descriptor of this socket can
304-
be used in an xsk_umem__create_with_fd() variant of the umem creation
305-
function.
304+
be used in param opts of xsk_umem__create_opts(), which is a recommended
305+
way of umem creation.
306306

307307
.RS
308308
.nf
309-
\fCint xsk_umem__create(struct xsk_umem **umem,
309+
\fCstruct xsk_umem *xsk_umem__create_opts(void *umem_area,
310+
struct xsk_ring_prod *fill,
311+
struct xsk_ring_cons *comp,
312+
struct xsk_umem_opts *opts);
313+
int xsk_umem__create(struct xsk_umem **umem,
310314
void *umem_area, __u64 size,
311315
struct xsk_ring_prod *fill,
312316
struct xsk_ring_cons *comp,
@@ -370,8 +374,8 @@ int xsk_socket__update_xskmap(struct xsk_socket *xsk, int xsks_map_fd);
370374
.PP
371375
To further reduce required level of privileges, an AF_XDP socket can be created
372376
beforehand with socket(AF_XDP, SOCK_RAW, 0) and passed to a non-privileged
373-
process. This socket can be used in xsk_umem__create_with_fd() and later
374-
in xsk_socket__create() with created umem. xsk_socket__create_shared() would
377+
process. This socket can be used in xsk_umem__create_opts() and later in
378+
xsk_socket__create() with created umem. xsk_socket__create_shared() would
375379
still require privileges for AF_XDP socket creation.
376380

377381
.SS "Data path"

lib/libxdp/xsk.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ struct xsk_umem *xsk_umem__create_opts(void *umem_area,
350350

351351
mr_size = sizeof(mr);
352352
/* Older kernels don't support tx_metadata_len, skip if we are not setting a value */
353-
if(!mr.tx_metadata_len)
353+
if (!mr.tx_metadata_len)
354354
mr_size = offsetof(struct xdp_umem_reg, tx_metadata_len);
355355
err = setsockopt(umem->fd, SOL_XDP, XDP_UMEM_REG, &mr, mr_size);
356356
if (err) {
@@ -381,7 +381,7 @@ int xsk_umem__create_with_fd(struct xsk_umem **umem_ptr, int fd,
381381
{
382382
struct xsk_umem *umem;
383383

384-
if(!umem_ptr)
384+
if (!umem_ptr)
385385
return -EFAULT;
386386

387387
DECLARE_LIBXDP_OPTS(xsk_umem_opts, opts,
@@ -396,7 +396,7 @@ int xsk_umem__create_with_fd(struct xsk_umem **umem_ptr, int fd,
396396
opts.flags = usr_config->flags;
397397
}
398398
umem = xsk_umem__create_opts(umem_area, fill, comp, &opts);
399-
if(!umem)
399+
if (!umem)
400400
return errno;
401401

402402
*umem_ptr = umem;

0 commit comments

Comments
 (0)