]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
i40e: Change size to truesize when using i40e_rx_buffer_flip()
authorTirthendu Sarkar <tirthendu.sarkar@intel.com>
Thu, 9 Mar 2023 18:56:11 +0000 (00:26 +0530)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 9 Mar 2023 21:11:09 +0000 (13:11 -0800)
Truesize is now passed directly to i40e_rx_buffer_flip() instead of size
so that it does not need to recalculate truesize from size using
i40e_rx_frame_truesize() before adjusting page offset.

With these change the function can now be used during skb building and
adding frags. In later patches it will also be easier for adjusting
page offsets for multi-buffers.

Signed-off-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com>
Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/i40e/i40e_txrx.c

index a7fba294a8f425a9dc0271384d98c289249d2cdb..fa44a2c353b239c6cf45507311024c1001e80a7e 100644 (file)
@@ -2018,6 +2018,21 @@ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer,
        return true;
 }
 
+/**
+ * i40e_rx_buffer_flip - adjusted rx_buffer to point to an unused region
+ * @rx_buffer: Rx buffer to adjust
+ * @truesize: Size of adjustment
+ **/
+static void i40e_rx_buffer_flip(struct i40e_rx_buffer *rx_buffer,
+                               unsigned int truesize)
+{
+#if (PAGE_SIZE < 8192)
+       rx_buffer->page_offset ^= truesize;
+#else
+       rx_buffer->page_offset += truesize;
+#endif
+}
+
 /**
  * i40e_add_rx_frag - Add contents of Rx buffer to sk_buff
  * @rx_ring: rx descriptor ring to transact packets on
@@ -2045,11 +2060,7 @@ static void i40e_add_rx_frag(struct i40e_ring *rx_ring,
                        rx_buffer->page_offset, size, truesize);
 
        /* page is being used so we must update the page offset */
-#if (PAGE_SIZE < 8192)
-       rx_buffer->page_offset ^= truesize;
-#else
-       rx_buffer->page_offset += truesize;
-#endif
+       i40e_rx_buffer_flip(rx_buffer, truesize);
 }
 
 /**
@@ -2154,11 +2165,7 @@ static struct sk_buff *i40e_construct_skb(struct i40e_ring *rx_ring,
                                size, truesize);
 
                /* buffer is used by skb, update page_offset */
-#if (PAGE_SIZE < 8192)
-               rx_buffer->page_offset ^= truesize;
-#else
-               rx_buffer->page_offset += truesize;
-#endif
+               i40e_rx_buffer_flip(rx_buffer, truesize);
        } else {
                /* buffer is unused, reset bias back to rx_buffer */
                rx_buffer->pagecnt_bias++;
@@ -2209,11 +2216,7 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
                skb_metadata_set(skb, metasize);
 
        /* buffer is used by skb, update page_offset */
-#if (PAGE_SIZE < 8192)
-       rx_buffer->page_offset ^= truesize;
-#else
-       rx_buffer->page_offset += truesize;
-#endif
+       i40e_rx_buffer_flip(rx_buffer, truesize);
 
        return skb;
 }
@@ -2326,25 +2329,6 @@ xdp_out:
        return result;
 }
 
-/**
- * i40e_rx_buffer_flip - adjusted rx_buffer to point to an unused region
- * @rx_ring: Rx ring
- * @rx_buffer: Rx buffer to adjust
- * @size: Size of adjustment
- **/
-static void i40e_rx_buffer_flip(struct i40e_ring *rx_ring,
-                               struct i40e_rx_buffer *rx_buffer,
-                               unsigned int size)
-{
-       unsigned int truesize = i40e_rx_frame_truesize(rx_ring, size);
-
-#if (PAGE_SIZE < 8192)
-       rx_buffer->page_offset ^= truesize;
-#else
-       rx_buffer->page_offset += truesize;
-#endif
-}
-
 /**
  * i40e_xdp_ring_update_tail - Updates the XDP Tx ring tail register
  * @xdp_ring: XDP Tx ring
@@ -2513,7 +2497,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget,
                if (xdp_res) {
                        if (xdp_res & (I40E_XDP_TX | I40E_XDP_REDIR)) {
                                xdp_xmit |= xdp_res;
-                               i40e_rx_buffer_flip(rx_ring, rx_buffer, size);
+                               i40e_rx_buffer_flip(rx_buffer, xdp.frame_sz);
                        } else {
                                rx_buffer->pagecnt_bias++;
                        }