Skip to content

Commit 434aaea

Browse files
orospivecera
authored andcommitted
xsk: add functions to fill control buffer
JIRA: https://issues.redhat.com/browse/RHEL-31890 Upstream commit(s): commit b4e352f Author: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Date: Tue Dec 5 22:08:36 2023 +0100 xsk: add functions to fill control buffer Commit 94ecc5c ("xsk: Add cb area to struct xdp_buff_xsk") has added a buffer for custom data to xdp_buff_xsk. Particularly, this memory is used for data, consumed by XDP hints kfuncs. It does not always change on a per-packet basis and some parts can be set for example, at the same time as RX queue info. Add functions to fill all cbs in xsk_buff_pool with the same metadata. Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/r/20231205210847.28460-8-larysa.zaremba@intel.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Petr Oros <poros@redhat.com>
1 parent a5da5ee commit 434aaea

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

include/net/xdp_sock_drv.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
#ifdef CONFIG_XDP_SOCKETS
1616

17+
struct xsk_cb_desc {
18+
void *src;
19+
u8 off;
20+
u8 bytes;
21+
};
22+
1723
void xsk_tx_completed(struct xsk_buff_pool *pool, u32 nb_entries);
1824
bool xsk_tx_peek_desc(struct xsk_buff_pool *pool, struct xdp_desc *desc);
1925
u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 max);
@@ -47,6 +53,12 @@ static inline void xsk_pool_set_rxq_info(struct xsk_buff_pool *pool,
4753
xp_set_rxq_info(pool, rxq);
4854
}
4955

56+
static inline void xsk_pool_fill_cb(struct xsk_buff_pool *pool,
57+
struct xsk_cb_desc *desc)
58+
{
59+
xp_fill_cb(pool, desc);
60+
}
61+
5062
static inline unsigned int xsk_pool_get_napi_id(struct xsk_buff_pool *pool)
5163
{
5264
#ifdef CONFIG_NET_RX_BUSY_POLL
@@ -274,6 +286,11 @@ static inline void xsk_pool_set_rxq_info(struct xsk_buff_pool *pool,
274286
{
275287
}
276288

289+
static inline void xsk_pool_fill_cb(struct xsk_buff_pool *pool,
290+
struct xsk_cb_desc *desc)
291+
{
292+
}
293+
277294
static inline unsigned int xsk_pool_get_napi_id(struct xsk_buff_pool *pool)
278295
{
279296
return 0;

include/net/xsk_buff_pool.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
struct xsk_buff_pool;
1414
struct xdp_rxq_info;
15+
struct xsk_cb_desc;
1516
struct xsk_queue;
1617
struct xdp_desc;
1718
struct xdp_umem;
@@ -135,6 +136,7 @@ static inline void xp_init_xskb_dma(struct xdp_buff_xsk *xskb, struct xsk_buff_p
135136

136137
/* AF_XDP ZC drivers, via xdp_sock_buff.h */
137138
void xp_set_rxq_info(struct xsk_buff_pool *pool, struct xdp_rxq_info *rxq);
139+
void xp_fill_cb(struct xsk_buff_pool *pool, struct xsk_cb_desc *desc);
138140
int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev,
139141
unsigned long attrs, struct page **pages, u32 nr_pages);
140142
void xp_dma_unmap(struct xsk_buff_pool *pool, unsigned long attrs);

net/xdp/xsk_buff_pool.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ void xp_set_rxq_info(struct xsk_buff_pool *pool, struct xdp_rxq_info *rxq)
125125
}
126126
EXPORT_SYMBOL(xp_set_rxq_info);
127127

128+
void xp_fill_cb(struct xsk_buff_pool *pool, struct xsk_cb_desc *desc)
129+
{
130+
u32 i;
131+
132+
for (i = 0; i < pool->heads_cnt; i++) {
133+
struct xdp_buff_xsk *xskb = &pool->heads[i];
134+
135+
memcpy(xskb->cb + desc->off, desc->src, desc->bytes);
136+
}
137+
}
138+
EXPORT_SYMBOL(xp_fill_cb);
139+
128140
static void xp_disable_drv_zc(struct xsk_buff_pool *pool)
129141
{
130142
struct netdev_bpf bpf;

0 commit comments

Comments
 (0)