Commit d8c3061e authored by Kevin Laatz's avatar Kevin Laatz Committed by Daniel Borkmann

ixgbe: 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 2f86c806
...@@ -143,7 +143,9 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter, ...@@ -143,7 +143,9 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter,
struct ixgbe_ring *rx_ring, struct ixgbe_ring *rx_ring,
struct xdp_buff *xdp) struct xdp_buff *xdp)
{ {
struct xdp_umem *umem = rx_ring->xsk_umem;
int err, result = IXGBE_XDP_PASS; int err, result = IXGBE_XDP_PASS;
u64 offset = umem->headroom;
struct bpf_prog *xdp_prog; struct bpf_prog *xdp_prog;
struct xdp_frame *xdpf; struct xdp_frame *xdpf;
u32 act; u32 act;
...@@ -151,7 +153,10 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter, ...@@ -151,7 +153,10 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter,
rcu_read_lock(); rcu_read_lock();
xdp_prog = READ_ONCE(rx_ring->xdp_prog); xdp_prog = READ_ONCE(rx_ring->xdp_prog);
act = bpf_prog_run_xdp(xdp_prog, xdp); act = bpf_prog_run_xdp(xdp_prog, xdp);
xdp->handle += xdp->data - xdp->data_hard_start; offset += xdp->data - xdp->data_hard_start;
xdp->handle = xsk_umem_adjust_offset(umem, xdp->handle, offset);
switch (act) { switch (act) {
case XDP_PASS: case XDP_PASS:
break; break;
...@@ -243,7 +248,7 @@ void ixgbe_zca_free(struct zero_copy_allocator *alloc, unsigned long handle) ...@@ -243,7 +248,7 @@ void ixgbe_zca_free(struct zero_copy_allocator *alloc, unsigned long handle)
bi->addr = xdp_umem_get_data(rx_ring->xsk_umem, handle); bi->addr = xdp_umem_get_data(rx_ring->xsk_umem, handle);
bi->addr += hr; bi->addr += hr;
bi->handle = (u64)handle + rx_ring->xsk_umem->headroom; bi->handle = (u64)handle;
} }
static bool ixgbe_alloc_buffer_zc(struct ixgbe_ring *rx_ring, static bool ixgbe_alloc_buffer_zc(struct ixgbe_ring *rx_ring,
...@@ -269,7 +274,7 @@ static bool ixgbe_alloc_buffer_zc(struct ixgbe_ring *rx_ring, ...@@ -269,7 +274,7 @@ static bool ixgbe_alloc_buffer_zc(struct ixgbe_ring *rx_ring,
bi->addr = xdp_umem_get_data(umem, handle); bi->addr = xdp_umem_get_data(umem, handle);
bi->addr += hr; bi->addr += hr;
bi->handle = handle + umem->headroom; bi->handle = handle;
xsk_umem_discard_addr(umem); xsk_umem_discard_addr(umem);
return true; return true;
...@@ -296,7 +301,7 @@ static bool ixgbe_alloc_buffer_slow_zc(struct ixgbe_ring *rx_ring, ...@@ -296,7 +301,7 @@ static bool ixgbe_alloc_buffer_slow_zc(struct ixgbe_ring *rx_ring,
bi->addr = xdp_umem_get_data(umem, handle); bi->addr = xdp_umem_get_data(umem, handle);
bi->addr += hr; bi->addr += hr;
bi->handle = handle + umem->headroom; bi->handle = handle;
xsk_umem_discard_addr_rq(umem); xsk_umem_discard_addr_rq(umem);
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment