Now that the recycle stack is always used for the driver umem path, the
driver code path can be simplified.

Signed-off-by: Jonathan Lemon <jonathan.le...@gmail.com>
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c    | 76 ++-----------------
 .../ethernet/intel/ixgbe/ixgbe_txrx_common.h  |  2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c  | 49 +-----------
 3 files changed, 13 insertions(+), 114 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c 
b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
index 7efe5905b0af..ce8650d06962 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
@@ -265,44 +265,16 @@ static bool i40e_alloc_buffer_zc(struct i40e_ring 
*rx_ring,
 }
 
 /**
- * i40e_alloc_buffer_slow_zc - Allocates an i40e_rx_buffer
+ * i40e_alloc_rx_buffers_zc - Allocates a number of Rx buffers
  * @rx_ring: Rx ring
- * @bi: Rx buffer to populate
+ * @count: The number of buffers to allocate
  *
- * This function allocates an Rx buffer. The buffer can come from fill
- * queue, or via the reuse queue.
+ * This function allocates a number of Rx buffers from the fill ring
+ * or the internal recycle mechanism and places them on the Rx ring.
  *
  * Returns true for a successful allocation, false otherwise
  **/
-static bool i40e_alloc_buffer_slow_zc(struct i40e_ring *rx_ring,
-                                     struct i40e_rx_buffer *bi)
-{
-       struct xdp_umem *umem = rx_ring->xsk_umem;
-       u64 handle, hr;
-
-       if (!xsk_umem_peek_addr_rq(umem, &handle)) {
-               rx_ring->rx_stats.alloc_page_failed++;
-               return false;
-       }
-
-       hr = umem->headroom + XDP_PACKET_HEADROOM;
-
-       bi->dma = xdp_umem_get_dma(umem, handle);
-       bi->dma += hr;
-
-       bi->addr = xdp_umem_get_data(umem, handle);
-       bi->addr += hr;
-
-       bi->handle = handle + umem->headroom;
-
-       xsk_umem_discard_addr_rq(umem);
-       return true;
-}
-
-static __always_inline bool
-__i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count,
-                          bool alloc(struct i40e_ring *rx_ring,
-                                     struct i40e_rx_buffer *bi))
+bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count)
 {
        u16 ntu = rx_ring->next_to_use;
        union i40e_rx_desc *rx_desc;
@@ -312,7 +284,7 @@ __i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 
count,
        rx_desc = I40E_RX_DESC(rx_ring, ntu);
        bi = &rx_ring->rx_bi[ntu];
        do {
-               if (!alloc(rx_ring, bi)) {
+               if (!i40e_alloc_buffer_zc(rx_ring, bi)) {
                        ok = false;
                        goto no_buffers;
                }
@@ -344,38 +316,6 @@ __i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 
count,
        return ok;
 }
 
-/**
- * i40e_alloc_rx_buffers_zc - Allocates a number of Rx buffers
- * @rx_ring: Rx ring
- * @count: The number of buffers to allocate
- *
- * This function allocates a number of Rx buffers from the reuse queue
- * or fill ring and places them on the Rx ring.
- *
- * Returns true for a successful allocation, false otherwise
- **/
-bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count)
-{
-       return __i40e_alloc_rx_buffers_zc(rx_ring, count,
-                                         i40e_alloc_buffer_slow_zc);
-}
-
-/**
- * i40e_alloc_rx_buffers_fast_zc - Allocates a number of Rx buffers
- * @rx_ring: Rx ring
- * @count: The number of buffers to allocate
- *
- * This function allocates a number of Rx buffers from the fill ring
- * or the internal recycle mechanism and places them on the Rx ring.
- *
- * Returns true for a successful allocation, false otherwise
- **/
-static bool i40e_alloc_rx_buffers_fast_zc(struct i40e_ring *rx_ring, u16 count)
-{
-       return __i40e_alloc_rx_buffers_zc(rx_ring, count,
-                                         i40e_alloc_buffer_zc);
-}
-
 /**
  * i40e_get_rx_buffer_zc - Return the current Rx buffer
  * @rx_ring: Rx ring
@@ -541,8 +481,8 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int 
budget)
 
                if (cleaned_count >= I40E_RX_BUFFER_WRITE) {
                        failure = failure ||
-                                 !i40e_alloc_rx_buffers_fast_zc(rx_ring,
-                                                                cleaned_count);
+                                 !i40e_alloc_rx_buffers_zc(rx_ring,
+                                                           cleaned_count);
                        cleaned_count = 0;
                }
 
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_txrx_common.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_txrx_common.h
index d93a690aff74..7408fbc2e1e1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_txrx_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_txrx_common.h
@@ -35,7 +35,7 @@ int ixgbe_xsk_umem_setup(struct ixgbe_adapter *adapter, 
struct xdp_umem *umem,
 
 void ixgbe_zca_free(struct zero_copy_allocator *alloc, unsigned long handle);
 
-void ixgbe_alloc_rx_buffers_zc(struct ixgbe_ring *rx_ring, u16 cleaned_count);
+bool ixgbe_alloc_rx_buffers_zc(struct ixgbe_ring *rx_ring, u16 cleaned_count);
 int ixgbe_clean_rx_irq_zc(struct ixgbe_q_vector *q_vector,
                          struct ixgbe_ring *rx_ring,
                          const int budget);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
index 1e09fa7ffb90..65feb16200ea 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
@@ -278,35 +278,7 @@ static bool ixgbe_alloc_buffer_zc(struct ixgbe_ring 
*rx_ring,
        return true;
 }
 
-static bool ixgbe_alloc_buffer_slow_zc(struct ixgbe_ring *rx_ring,
-                                      struct ixgbe_rx_buffer *bi)
-{
-       struct xdp_umem *umem = rx_ring->xsk_umem;
-       u64 handle, hr;
-
-       if (!xsk_umem_peek_addr_rq(umem, &handle)) {
-               rx_ring->rx_stats.alloc_rx_page_failed++;
-               return false;
-       }
-
-       hr = umem->headroom + XDP_PACKET_HEADROOM;
-
-       bi->dma = xdp_umem_get_dma(umem, handle);
-       bi->dma += hr;
-
-       bi->addr = xdp_umem_get_data(umem, handle);
-       bi->addr += hr;
-
-       bi->handle = handle + umem->headroom;
-
-       xsk_umem_discard_addr_rq(umem);
-       return true;
-}
-
-static __always_inline bool
-__ixgbe_alloc_rx_buffers_zc(struct ixgbe_ring *rx_ring, u16 cleaned_count,
-                           bool alloc(struct ixgbe_ring *rx_ring,
-                                      struct ixgbe_rx_buffer *bi))
+bool ixgbe_alloc_rx_buffers_zc(struct ixgbe_ring *rx_ring, u16 cleaned_count)
 {
        union ixgbe_adv_rx_desc *rx_desc;
        struct ixgbe_rx_buffer *bi;
@@ -322,7 +294,7 @@ __ixgbe_alloc_rx_buffers_zc(struct ixgbe_ring *rx_ring, u16 
cleaned_count,
        i -= rx_ring->count;
 
        do {
-               if (!alloc(rx_ring, bi)) {
+               if (!ixgbe_alloc_buffer_zc(rx_ring, bi)) {
                        ok = false;
                        break;
                }
@@ -373,19 +345,6 @@ __ixgbe_alloc_rx_buffers_zc(struct ixgbe_ring *rx_ring, 
u16 cleaned_count,
        return ok;
 }
 
-void ixgbe_alloc_rx_buffers_zc(struct ixgbe_ring *rx_ring, u16 count)
-{
-       __ixgbe_alloc_rx_buffers_zc(rx_ring, count,
-                                   ixgbe_alloc_buffer_slow_zc);
-}
-
-static bool ixgbe_alloc_rx_buffers_fast_zc(struct ixgbe_ring *rx_ring,
-                                          u16 count)
-{
-       return __ixgbe_alloc_rx_buffers_zc(rx_ring, count,
-                                          ixgbe_alloc_buffer_zc);
-}
-
 static struct sk_buff *ixgbe_construct_skb_zc(struct ixgbe_ring *rx_ring,
                                              struct ixgbe_rx_buffer *bi,
                                              struct xdp_buff *xdp)
@@ -441,8 +400,8 @@ int ixgbe_clean_rx_irq_zc(struct ixgbe_q_vector *q_vector,
                /* return some buffers to hardware, one at a time is too slow */
                if (cleaned_count >= IXGBE_RX_BUFFER_WRITE) {
                        failure = failure ||
-                                 !ixgbe_alloc_rx_buffers_fast_zc(rx_ring,
-                                                                cleaned_count);
+                                 !ixgbe_alloc_rx_buffers_zc(rx_ring,
+                                                            cleaned_count);
                        cleaned_count = 0;
                }
 
-- 
2.17.1

Reply via email to