Skip to content

Commit 94ecc5c

Browse files
tohojoMartin KaFai Lau
authored andcommitted
xsk: Add cb area to struct xdp_buff_xsk
Add an area after the xdp_buff in struct xdp_buff_xsk that drivers can use to stash extra information to use in metadata kfuncs. The maximum size of 24 bytes means the full xdp_buff_xsk structure will take up exactly two cache lines (with the cb field spanning both). Also add a macro drivers can use to check their own wrapping structs against the available size. Cc: John Fastabend <john.fastabend@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Martin KaFai Lau <martin.lau@linux.dev> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Willem de Bruijn <willemb@google.com> Cc: Jesper Dangaard Brouer <brouer@redhat.com> Cc: Anatoly Burakov <anatoly.burakov@intel.com> Cc: Alexander Lobakin <alexandr.lobakin@intel.com> Cc: Magnus Karlsson <magnus.karlsson@gmail.com> Cc: Maryam Tahhan <mtahhan@redhat.com> Cc: xdp-hints@xdp-project.net Cc: netdev@vger.kernel.org Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Link: https://lore.kernel.org/r/20230119221536.3349901-15-sdf@google.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
1 parent ab46182 commit 94ecc5c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/net/xsk_buff_pool.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ struct xdp_sock;
1919
struct device;
2020
struct page;
2121

22+
#define XSK_PRIV_MAX 24
23+
2224
struct xdp_buff_xsk {
2325
struct xdp_buff xdp;
26+
u8 cb[XSK_PRIV_MAX];
2427
dma_addr_t dma;
2528
dma_addr_t frame_dma;
2629
struct xsk_buff_pool *pool;
2730
u64 orig_addr;
2831
struct list_head free_list_node;
2932
};
3033

34+
#define XSK_CHECK_PRIV_TYPE(t) BUILD_BUG_ON(sizeof(t) > offsetofend(struct xdp_buff_xsk, cb))
35+
3136
struct xsk_dma_map {
3237
dma_addr_t *dma_pages;
3338
struct device *dev;

0 commit comments

Comments
 (0)