mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-18 17:37:40 +07:00
samples/bpf: Fix to xdpsock to avoid recycling frames
The txpush program in the xdpsock sample application is supposed
to send out all packets in the umem in a round-robin fashion.
The problem is that it only cycled through the first BATCH_SIZE
worth of packets. Fixed this so that it cycles through all buffers
in the umem as intended.
Fixes: 248c7f9c0e
("samples/bpf: convert xdpsock to use libbpf for AF_XDP access")
Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Björn Töpel <bjorn.topel@intel.com>
Link: https://lore.kernel.org/bpf/20200828161717.42705-1-weqaar.a.janjua@intel.com
This commit is contained in:
parent
c8a039a47f
commit
b69e56cf76
@ -1010,7 +1010,7 @@ static void rx_drop_all(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tx_only(struct xsk_socket_info *xsk, u32 frame_nb, int batch_size)
|
static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size)
|
||||||
{
|
{
|
||||||
u32 idx;
|
u32 idx;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -1023,14 +1023,14 @@ static void tx_only(struct xsk_socket_info *xsk, u32 frame_nb, int batch_size)
|
|||||||
for (i = 0; i < batch_size; i++) {
|
for (i = 0; i < batch_size; i++) {
|
||||||
struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk->tx,
|
struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk->tx,
|
||||||
idx + i);
|
idx + i);
|
||||||
tx_desc->addr = (frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT;
|
tx_desc->addr = (*frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT;
|
||||||
tx_desc->len = PKT_SIZE;
|
tx_desc->len = PKT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
xsk_ring_prod__submit(&xsk->tx, batch_size);
|
xsk_ring_prod__submit(&xsk->tx, batch_size);
|
||||||
xsk->outstanding_tx += batch_size;
|
xsk->outstanding_tx += batch_size;
|
||||||
frame_nb += batch_size;
|
*frame_nb += batch_size;
|
||||||
frame_nb %= NUM_FRAMES;
|
*frame_nb %= NUM_FRAMES;
|
||||||
complete_tx_only(xsk, batch_size);
|
complete_tx_only(xsk, batch_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,7 +1086,7 @@ static void tx_only_all(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < num_socks; i++)
|
for (i = 0; i < num_socks; i++)
|
||||||
tx_only(xsks[i], frame_nb[i], batch_size);
|
tx_only(xsks[i], &frame_nb[i], batch_size);
|
||||||
|
|
||||||
pkt_cnt += batch_size;
|
pkt_cnt += batch_size;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user