提交 94ecc5ca 编写于 作者: T Toke Høiland-Jørgensen 提交者: Martin KaFai Lau

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: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NToke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: NStanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/20230119221536.3349901-15-sdf@google.comSigned-off-by: NMartin KaFai Lau <martin.lau@kernel.org>
上级 ab46182d
...@@ -19,8 +19,11 @@ struct xdp_sock; ...@@ -19,8 +19,11 @@ struct xdp_sock;
struct device; struct device;
struct page; struct page;
#define XSK_PRIV_MAX 24
struct xdp_buff_xsk { struct xdp_buff_xsk {
struct xdp_buff xdp; struct xdp_buff xdp;
u8 cb[XSK_PRIV_MAX];
dma_addr_t dma; dma_addr_t dma;
dma_addr_t frame_dma; dma_addr_t frame_dma;
struct xsk_buff_pool *pool; struct xsk_buff_pool *pool;
...@@ -28,6 +31,8 @@ struct xdp_buff_xsk { ...@@ -28,6 +31,8 @@ struct xdp_buff_xsk {
struct list_head free_list_node; struct list_head free_list_node;
}; };
#define XSK_CHECK_PRIV_TYPE(t) BUILD_BUG_ON(sizeof(t) > offsetofend(struct xdp_buff_xsk, cb))
struct xsk_dma_map { struct xsk_dma_map {
dma_addr_t *dma_pages; dma_addr_t *dma_pages;
struct device *dev; struct device *dev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册