]> Git Repo - J-linux.git/blobdiff - drivers/net/ethernet/intel/i40e/i40e_xsk.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[J-linux.git] / drivers / net / ethernet / intel / i40e / i40e_xsk.c
index 4a49848f778160aa6fd309b34d9268071d770976..e99fa854d17f1bd695fa54d95c98b24c0091f26d 100644 (file)
@@ -433,12 +433,12 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
        unsigned int total_rx_bytes = 0, total_rx_packets = 0;
        u16 next_to_process = rx_ring->next_to_process;
        u16 next_to_clean = rx_ring->next_to_clean;
-       u16 count_mask = rx_ring->count - 1;
        unsigned int xdp_res, xdp_xmit = 0;
        struct xdp_buff *first = NULL;
+       u32 count = rx_ring->count;
        struct bpf_prog *xdp_prog;
+       u32 entries_to_alloc;
        bool failure = false;
-       u16 cleaned_count;
 
        if (next_to_process != next_to_clean)
                first = *i40e_rx_bi(rx_ring, next_to_clean);
@@ -471,7 +471,8 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
                                                      qword);
                        bi = *i40e_rx_bi(rx_ring, next_to_process);
                        xsk_buff_free(bi);
-                       next_to_process = (next_to_process + 1) & count_mask;
+                       if (++next_to_process == count)
+                               next_to_process = 0;
                        continue;
                }
 
@@ -489,7 +490,8 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
                else if (i40e_add_xsk_frag(rx_ring, first, bi, size))
                        break;
 
-               next_to_process = (next_to_process + 1) & count_mask;
+               if (++next_to_process == count)
+                       next_to_process = 0;
 
                if (i40e_is_non_eop(rx_ring, rx_desc))
                        continue;
@@ -509,10 +511,10 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
 
        rx_ring->next_to_clean = next_to_clean;
        rx_ring->next_to_process = next_to_process;
-       cleaned_count = (next_to_clean - rx_ring->next_to_use - 1) & count_mask;
 
-       if (cleaned_count >= I40E_RX_BUFFER_WRITE)
-               failure |= !i40e_alloc_rx_buffers_zc(rx_ring, cleaned_count);
+       entries_to_alloc = I40E_DESC_UNUSED(rx_ring);
+       if (entries_to_alloc >= I40E_RX_BUFFER_WRITE)
+               failure |= !i40e_alloc_rx_buffers_zc(rx_ring, entries_to_alloc);
 
        i40e_finalize_xdp_rx(rx_ring, xdp_xmit);
        i40e_update_rx_stats(rx_ring, total_rx_bytes, total_rx_packets);
@@ -748,14 +750,16 @@ int i40e_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
 
 void i40e_xsk_clean_rx_ring(struct i40e_ring *rx_ring)
 {
-       u16 count_mask = rx_ring->count - 1;
        u16 ntc = rx_ring->next_to_clean;
        u16 ntu = rx_ring->next_to_use;
 
-       for ( ; ntc != ntu; ntc = (ntc + 1)  & count_mask) {
+       while (ntc != ntu) {
                struct xdp_buff *rx_bi = *i40e_rx_bi(rx_ring, ntc);
 
                xsk_buff_free(rx_bi);
+               ntc++;
+               if (ntc >= rx_ring->count)
+                       ntc = 0;
        }
 }
 
This page took 0.029461 seconds and 4 git commands to generate.