Skip to content

Commit 1b725b0

Browse files
mfijalkoAlexei Starovoitov
authored andcommitted
xsk: allow core/drivers to test EOP bit
Drivers are used to check for EOP bit whereas AF_XDP operates on inverted logic - user space indicates that current frag is not the last one and packet continues. For AF_XDP core needs, add xp_mb_desc() that will simply test XDP_PKT_CONTD from xdp_desc::options, but in order to preserve drivers default behavior, introduce an interface for ZC drivers that will negate xp_mb_desc() result and therefore make it easier to test EOP bit from during production of HW Tx descriptors. Signed-off-by: Maciej Fijalkowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent b7f72a3 commit 1b725b0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

include/net/xdp_sock_drv.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ static inline struct xdp_buff *xsk_buff_alloc(struct xsk_buff_pool *pool)
8989
return xp_alloc(pool);
9090
}
9191

92+
static inline bool xsk_is_eop_desc(struct xdp_desc *desc)
93+
{
94+
return !xp_mb_desc(desc);
95+
}
96+
9297
/* Returns as many entries as possible up to max. 0 <= N <= max. */
9398
static inline u32 xsk_buff_alloc_batch(struct xsk_buff_pool *pool, struct xdp_buff **xdp, u32 max)
9499
{
@@ -241,6 +246,11 @@ static inline struct xdp_buff *xsk_buff_alloc(struct xsk_buff_pool *pool)
241246
return NULL;
242247
}
243248

249+
static inline bool xsk_is_eop_desc(struct xdp_desc *desc)
250+
{
251+
return false;
252+
}
253+
244254
static inline u32 xsk_buff_alloc_batch(struct xsk_buff_pool *pool, struct xdp_buff **xdp, u32 max)
245255
{
246256
return 0;

include/net/xsk_buff_pool.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ static inline bool xp_desc_crosses_non_contig_pg(struct xsk_buff_pool *pool,
184184
!(pool->dma_pages[addr >> PAGE_SHIFT] & XSK_NEXT_PG_CONTIG_MASK);
185185
}
186186

187+
static inline bool xp_mb_desc(struct xdp_desc *desc)
188+
{
189+
return desc->options & XDP_PKT_CONTD;
190+
}
191+
187192
static inline u64 xp_aligned_extract_addr(struct xsk_buff_pool *pool, u64 addr)
188193
{
189194
return addr & pool->chunk_mask;

0 commit comments

Comments
 (0)