Skip to content

Commit 50ac163

Browse files
committed
Add tx_metadata_len to support AF_XDP Tx
Signed-off-by: tianmuyang <[email protected]>
1 parent f8fffe4 commit 50ac163

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

headers/linux/if_xdp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct xdp_umem_reg {
7070
__u32 chunk_size;
7171
__u32 headroom;
7272
__u32 flags;
73+
__u32 tx_metadata_len;
7374
};
7475

7576
struct xdp_statistics {

headers/xdp/xsk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ struct xsk_umem_config {
201201
__u32 frame_size;
202202
__u32 frame_headroom;
203203
__u32 flags;
204+
__u32 tx_metadata_len;
204205
};
205206

206207
int xsk_setup_xdp_prog(int ifindex, int *xsks_map_fd);

lib/libxdp/xsk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static void xsk_set_umem_config(struct xsk_umem_config *cfg,
160160
cfg->frame_size = XSK_UMEM__DEFAULT_FRAME_SIZE;
161161
cfg->frame_headroom = XSK_UMEM__DEFAULT_FRAME_HEADROOM;
162162
cfg->flags = XSK_UMEM__DEFAULT_FLAGS;
163+
cfg->tx_metadata_len = 0;
163164
return;
164165
}
165166

@@ -168,6 +169,7 @@ static void xsk_set_umem_config(struct xsk_umem_config *cfg,
168169
cfg->frame_size = usr_cfg->frame_size;
169170
cfg->frame_headroom = usr_cfg->frame_headroom;
170171
cfg->flags = usr_cfg->flags;
172+
cfg->tx_metadata_len = usr_cfg->tx_metadata_len;
171173
}
172174

173175
static int xsk_set_xdp_socket_config(struct xsk_socket_config *cfg,
@@ -341,6 +343,7 @@ int xsk_umem__create_with_fd(struct xsk_umem **umem_ptr, int fd,
341343
mr.chunk_size = umem->config.frame_size;
342344
mr.headroom = umem->config.frame_headroom;
343345
mr.flags = umem->config.flags;
346+
mr.tx_metadata_len = umem->config.tx_metadata_len;
344347

345348
err = setsockopt(umem->fd, SOL_XDP, XDP_UMEM_REG, &mr, sizeof(mr));
346349
if (err) {

0 commit comments

Comments
 (0)