diff options
| author | Björn Töpel <bjorn.topel@intel.com> | 2018-06-04 07:57:13 -0400 |
|---|---|---|
| committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-06-04 11:21:02 -0400 |
| commit | bbff2f321a864ee07c9d3d1245af498023146951 (patch) | |
| tree | 962414a03f749ce22e52ed553780a74216992d0a /include/uapi/linux | |
| parent | a509a95536a86ef84deb16c656d741437791b414 (diff) | |
xsk: new descriptor addressing scheme
Currently, AF_XDP only supports a fixed frame-size memory scheme where
each frame is referenced via an index (idx). A user passes the frame
index to the kernel, and the kernel acts upon the data. Some NICs,
however, do not have a fixed frame-size model, instead they have a
model where a memory window is passed to the hardware and multiple
frames are filled into that window (referred to as the "type-writer"
model).
By changing the descriptor format from the current frame index
addressing scheme, AF_XDP can in the future be extended to support
these kinds of NICs.
In the index-based model, an idx refers to a frame of size
frame_size. Addressing a frame in the UMEM is done by offseting the
UMEM starting address by a global offset, idx * frame_size + offset.
Communicating via the fill- and completion-rings are done by means of
idx.
In this commit, the idx is removed in favor of an address (addr),
which is a relative address ranging over the UMEM. To convert an
idx-based address to the new addr is simply: addr = idx * frame_size +
offset.
We also stop referring to the UMEM "frame" as a frame. Instead it is
simply called a chunk.
To transfer ownership of a chunk to the kernel, the addr of the chunk
is passed in the fill-ring. Note, that the kernel will mask addr to
make it chunk aligned, so there is no need for userspace to do
that. E.g., for a chunk size of 2k, passing an addr of 2048, 2050 or
3000 to the fill-ring will refer to the same chunk.
On the completion-ring, the addr will match that of the Tx descriptor,
passed to the kernel.
Changing the descriptor format to use chunks/addr will allow for
future changes to move to a type-writer based model, where multiple
frames can reside in one chunk. In this model passing one single chunk
into the fill-ring, would potentially result in multiple Rx
descriptors.
This commit changes the uapi of AF_XDP sockets, and updates the
documentation.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/if_xdp.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h index 4737cfe222f5..e411d6f9ac65 100644 --- a/include/uapi/linux/if_xdp.h +++ b/include/uapi/linux/if_xdp.h | |||
| @@ -48,8 +48,8 @@ struct xdp_mmap_offsets { | |||
| 48 | struct xdp_umem_reg { | 48 | struct xdp_umem_reg { |
| 49 | __u64 addr; /* Start of packet data area */ | 49 | __u64 addr; /* Start of packet data area */ |
| 50 | __u64 len; /* Length of packet data area */ | 50 | __u64 len; /* Length of packet data area */ |
| 51 | __u32 frame_size; /* Frame size */ | 51 | __u32 chunk_size; |
| 52 | __u32 frame_headroom; /* Frame head room */ | 52 | __u32 headroom; |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | struct xdp_statistics { | 55 | struct xdp_statistics { |
| @@ -66,13 +66,11 @@ struct xdp_statistics { | |||
| 66 | 66 | ||
| 67 | /* Rx/Tx descriptor */ | 67 | /* Rx/Tx descriptor */ |
| 68 | struct xdp_desc { | 68 | struct xdp_desc { |
| 69 | __u32 idx; | 69 | __u64 addr; |
| 70 | __u32 len; | 70 | __u32 len; |
| 71 | __u16 offset; | 71 | __u32 options; |
| 72 | __u8 flags; | ||
| 73 | __u8 padding[5]; | ||
| 74 | }; | 72 | }; |
| 75 | 73 | ||
| 76 | /* UMEM descriptor is __u32 */ | 74 | /* UMEM descriptor is __u64 */ |
| 77 | 75 | ||
| 78 | #endif /* _LINUX_IF_XDP_H */ | 76 | #endif /* _LINUX_IF_XDP_H */ |
