Skip to contentSkip to conversation

xsk: Have xsk_umem_peek_addr_rq() return chunk-aligned handles.

PATCH In review Jonathan Lemon 3 participants 3 messages Apr 17, 2019 – Apr 18, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xsk: Have xsk_umem_peek_addr_rq() return chunk-aligned handles.

xkq_peek_addr() returns chunk-aligned handles, so have the rq behave the same way. Clean up callsites.

Cc Björn Töpel <[email protected]>
Cc Maxim Mikityanskiy <[email protected]>
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c          | 2 --
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c        | 2 --
 drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c | 2 +-
 include/net/xdp_sock.h                              | 2 +-
 4 files changed, 2 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_xsk.c +0 -2
index d28b629afc8a..d2e212d007c3 100644
@@ -285,8 +285,6 @@ static bool i40e_alloc_buffer_slow_zc(struct i40e_ring *rx_ring,
 		return false;
 	}
 
-	handle &= rx_ring->xsk_umem->chunk_mask;
-
 	hr = umem->headroom + XDP_PACKET_HEADROOM;
 
 	bi->dma = xdp_umem_get_dma(umem, handle);
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +0 -2
index 582d83d35f7e..fc5ca35b4dbf 100644
@@ -343,8 +343,6 @@ static bool ixgbe_alloc_buffer_slow_zc(struct ixgbe_ring *rx_ring,
 		return false;
 	}
 
-	handle &= rx_ring->xsk_umem->chunk_mask;
-
 	hr = umem->headroom + XDP_PACKET_HEADROOM;
 
 	bi->dma = xdp_umem_get_dma(umem, handle);
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c +1 -1
index 61d75a7b3ce2..2f0b5fd1ee97 100644
@@ -309,7 +309,7 @@ int mlx5e_xsk_page_alloc_umem(struct mlx5e_rq *rq,
 
 static inline void mlx5e_xsk_recycle_frame(struct mlx5e_rq *rq, u64 handle)
 {
-	xsk_umem_fq_reuse(rq->umem, handle & rq->umem->chunk_mask);
+	xsk_umem_fq_reuse(rq->umem, handle);
 }
 
 /* XSKRQ uses pages from UMEM, they must not be released. They are returned to
include/net/xdp_sock.h +1 -1
index 7ebcb62fedf1..9d97ae73a287 100644
@@ -118,7 +118,7 @@ static inline u64 *xsk_umem_peek_addr_rq(struct xdp_umem *umem, u64 *addr)
 	if (!rq->length)
 		return xsk_umem_peek_addr(umem, addr);
 
-	*addr = rq->handles[rq->length - 1];
+	*addr = rq->handles[rq->length - 1] & umem->chunk_mask;
 	return addr;
 }
 
Signature · 1 line
2.17.1
#1 lore raw

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c int mlx5e_xsk_page_alloc_umem(struct mlx5e_rq *rq, · line 314

Quoted 12 lines · Jonathan Lemon
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c +1 -1
index 61d75a7b3ce2..2f0b5fd1ee97 100644
@@ -309,7 +309,7 @@ int mlx5e_xsk_page_alloc_umem(struct mlx5e_rq *rq,
 
 static inline void mlx5e_xsk_recycle_frame(struct mlx5e_rq *rq, u64 handle)
 {
-	xsk_umem_fq_reuse(rq->umem, handle & rq->umem->chunk_mask);
+	xsk_umem_fq_reuse(rq->umem, handle);
 }
 

The mlx5 af_xdp stuff you're using is not upstream :)

Acked-by on v1 1/1
#2 lore raw
In reply to Jonathan Lemon
Quoted 4 lines · Jonathan Lemon

xkq_peek_addr() returns chunk-aligned handles, so have the rq behave the same way. Clean up callsites.

Nice cleanup!

This should go to the bpf-next tree, and the non-upstreamed mlx5 parts should obviously be removed (but I have to admit, I like it! ;-)).

For the i40e/ixgbe/xsk parts:

Quoted 66 lines
Cc Björn Töpel <[email protected]>
Cc Maxim Mikityanskiy <[email protected]>
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c          | 2 --
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c        | 2 --
 drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c | 2 +-
 include/net/xdp_sock.h                              | 2 +-
 4 files changed, 2 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_xsk.c +0 -2
index d28b629afc8a..d2e212d007c3 100644
@@ -285,8 +285,6 @@ static bool i40e_alloc_buffer_slow_zc(struct i40e_ring *rx_ring,
                return false;
        }
 
-       handle &= rx_ring->xsk_umem->chunk_mask;
-
        hr = umem->headroom + XDP_PACKET_HEADROOM;
 
        bi->dma = xdp_umem_get_dma(umem, handle);
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +0 -2
index 582d83d35f7e..fc5ca35b4dbf 100644
@@ -343,8 +343,6 @@ static bool ixgbe_alloc_buffer_slow_zc(struct ixgbe_ring *rx_ring,
                return false;
        }
 
-       handle &= rx_ring->xsk_umem->chunk_mask;
-
        hr = umem->headroom + XDP_PACKET_HEADROOM;
 
        bi->dma = xdp_umem_get_dma(umem, handle);
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c +1 -1
index 61d75a7b3ce2..2f0b5fd1ee97 100644
@@ -309,7 +309,7 @@ int mlx5e_xsk_page_alloc_umem(struct mlx5e_rq *rq,
 
 static inline void mlx5e_xsk_recycle_frame(struct mlx5e_rq *rq, u64 handle)
 {
-       xsk_umem_fq_reuse(rq->umem, handle & rq->umem->chunk_mask);
+       xsk_umem_fq_reuse(rq->umem, handle);
 }
 
 /* XSKRQ uses pages from UMEM, they must not be released. They are returned to
include/net/xdp_sock.h +1 -2
index 7ebcb62fedf1..9d97ae73a287 100644
@@ -118,7 +118,7 @@ static inline u64 *xsk_umem_peek_addr_rq(struct xdp_umem *umem, u64 *addr)
        if (!rq->length)
                return xsk_umem_peek_addr(umem, addr);
 
-       *addr = rq->handles[rq->length - 1];
+       *addr = rq->handles[rq->length - 1] & umem->chunk_mask;
        return addr;
 }
 
--

2.17.1