Commit beb3e4b2 authored by Kevin Laatz's avatar Kevin Laatz Committed by Daniel Borkmann
Browse files

mlx5e: modify driver for handling offsets



With the addition of the unaligned chunks option, we need to make sure we
handle the offsets accordingly based on the mode we are currently running
in. This patch modifies the driver to appropriately mask the address for
each case.

Signed-off-by: default avatarKevin Laatz <kevin.laatz@intel.com>
Acked-by: default avatarJonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent d8c3061e
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -122,6 +122,7 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
		      void *va, u16 *rx_headroom, u32 *len, bool xsk)
		      void *va, u16 *rx_headroom, u32 *len, bool xsk)
{
{
	struct bpf_prog *prog = READ_ONCE(rq->xdp_prog);
	struct bpf_prog *prog = READ_ONCE(rq->xdp_prog);
	struct xdp_umem *umem = rq->umem;
	struct xdp_buff xdp;
	struct xdp_buff xdp;
	u32 act;
	u32 act;
	int err;
	int err;
@@ -138,8 +139,11 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
	xdp.rxq = &rq->xdp_rxq;
	xdp.rxq = &rq->xdp_rxq;


	act = bpf_prog_run_xdp(prog, &xdp);
	act = bpf_prog_run_xdp(prog, &xdp);
	if (xsk)
	if (xsk) {
		xdp.handle += xdp.data - xdp.data_hard_start;
		u64 off = xdp.data - xdp.data_hard_start;

		xdp.handle = xsk_umem_adjust_offset(umem, xdp.handle, off);
	}
	switch (act) {
	switch (act) {
	case XDP_PASS:
	case XDP_PASS:
		*rx_headroom = xdp.data - xdp.data_hard_start;
		*rx_headroom = xdp.data - xdp.data_hard_start;
+2 −1
Original line number Original line Diff line number Diff line
@@ -24,7 +24,8 @@ int mlx5e_xsk_page_alloc_umem(struct mlx5e_rq *rq,
	if (!xsk_umem_peek_addr_rq(umem, &handle))
	if (!xsk_umem_peek_addr_rq(umem, &handle))
		return -ENOMEM;
		return -ENOMEM;


	dma_info->xsk.handle = handle + rq->buff.umem_headroom;
	dma_info->xsk.handle = xsk_umem_adjust_offset(umem, handle,
						      rq->buff.umem_headroom);
	dma_info->xsk.data = xdp_umem_get_data(umem, dma_info->xsk.handle);
	dma_info->xsk.data = xdp_umem_get_data(umem, dma_info->xsk.handle);


	/* No need to add headroom to the DMA address. In striding RQ case, we
	/* No need to add headroom to the DMA address. In striding RQ case, we