]> git.baikalelectronics.ru Git - kernel.git/commit
xsk: remove explicit ring structure from uapi
authorBjörn Töpel <bjorn.topel@intel.com>
Tue, 22 May 2018 07:34:59 +0000 (09:34 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 22 May 2018 08:25:06 +0000 (10:25 +0200)
commitc230b35952b328bda49ce3ebea5751c1ad6546d8
tree40260bda517d9f1e16ee3f529a0bbc50df495be7
parenta488cd110f033e66deba40de96a5abb02b059871
xsk: remove explicit ring structure from uapi

In this commit we remove the explicit ring structure from the the
uapi. It is tricky for an uapi to depend on a certain L1 cache line
size, since it can differ for variants of the same architecture. Now,
we let the user application determine the offsets of the producer,
consumer and descriptors by asking the socket via getsockopt.

A typical flow would be (Rx ring):

  struct xdp_mmap_offsets off;
  struct xdp_desc *ring;
  u32 *prod, *cons;
  void *map;
  ...

  getsockopt(fd, SOL_XDP, XDP_MMAP_OFFSETS, &off, &optlen);

  map = mmap(NULL, off.rx.desc +
   NUM_DESCS * sizeof(struct xdp_desc),
   PROT_READ | PROT_WRITE,
   MAP_SHARED | MAP_POPULATE, sfd,
   XDP_PGOFF_RX_RING);
  prod = map + off.rx.producer;
  cons = map + off.rx.consumer;
  ring = map + off.rx.desc;

Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/uapi/linux/if_xdp.h
net/xdp/xsk.c
net/xdp/xsk_queue.h