All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Guedes <andre.guedes@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v2 03/10] igc: Introduce igc_rx_buffer_flip() helper
Date: Wed, 28 Oct 2020 13:19:36 -0700	[thread overview]
Message-ID: <20201028201943.93147-4-andre.guedes@intel.com> (raw)
In-Reply-To: <20201028201943.93147-1-andre.guedes@intel.com>

The igc driver implements the same page recycling scheme from other
Intel drivers which reuses the page by flipping the buffer. The code
to handle buffer flips is duplicated in many locations so this patch
introduces the igc_rx_buffer_flip() helper and uses it where applicable.

Signed-off-by: Andre Guedes <andre.guedes@intel.com>
---
 drivers/net/ethernet/intel/igc/igc_main.c | 42 +++++++++++------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 5ce9253cca19..31dc58a82cf3 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -1513,6 +1513,16 @@ static struct igc_rx_buffer *igc_get_rx_buffer(struct igc_ring *rx_ring,
 	return rx_buffer;
 }
 
+static void igc_rx_buffer_flip(struct igc_rx_buffer *buffer,
+			       unsigned int truesize)
+{
+#if (PAGE_SIZE < 8192)
+	buffer->page_offset ^= truesize;
+#else
+	buffer->page_offset += truesize;
+#endif
+}
+
 /**
  * igc_add_rx_frag - Add contents of Rx buffer to sk_buff
  * @rx_ring: rx descriptor ring to transact packets on
@@ -1527,20 +1537,18 @@ static void igc_add_rx_frag(struct igc_ring *rx_ring,
 			    struct sk_buff *skb,
 			    unsigned int size)
 {
+	unsigned int truesize;
 #if (PAGE_SIZE < 8192)
-	unsigned int truesize = igc_rx_pg_size(rx_ring) / 2;
-
-	skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page,
-			rx_buffer->page_offset, size, truesize);
-	rx_buffer->page_offset ^= truesize;
+	truesize = igc_rx_pg_size(rx_ring) / 2;
 #else
-	unsigned int truesize = ring_uses_build_skb(rx_ring) ?
-				SKB_DATA_ALIGN(IGC_SKB_PAD + size) :
-				SKB_DATA_ALIGN(size);
+	truesize = ring_uses_build_skb(rx_ring) ?
+		   SKB_DATA_ALIGN(IGC_SKB_PAD + size) :
+		   SKB_DATA_ALIGN(size);
+#endif
 	skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page,
 			rx_buffer->page_offset, size, truesize);
-	rx_buffer->page_offset += truesize;
-#endif
+
+	igc_rx_buffer_flip(rx_buffer, truesize);
 }
 
 static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring,
@@ -1569,13 +1577,7 @@ static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring,
 	skb_reserve(skb, IGC_SKB_PAD);
 	__skb_put(skb, size);
 
-	/* update buffer offset */
-#if (PAGE_SIZE < 8192)
-	rx_buffer->page_offset ^= truesize;
-#else
-	rx_buffer->page_offset += truesize;
-#endif
-
+	igc_rx_buffer_flip(rx_buffer, truesize);
 	return skb;
 }
 
@@ -1621,11 +1623,7 @@ static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring,
 		skb_add_rx_frag(skb, 0, rx_buffer->page,
 				(va + headlen) - page_address(rx_buffer->page),
 				size, truesize);
-#if (PAGE_SIZE < 8192)
-		rx_buffer->page_offset ^= truesize;
-#else
-		rx_buffer->page_offset += truesize;
-#endif
+		igc_rx_buffer_flip(rx_buffer, truesize);
 	} else {
 		rx_buffer->pagecnt_bias++;
 	}
-- 
2.28.0


  parent reply	other threads:[~2020-10-28 20:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 20:19 [Intel-wired-lan] [PATCH v2 00/10] igc: Add XDP support Andre Guedes
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 01/10] igc: Fix igc_ptp_rx_pktstamp() Andre Guedes
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 02/10] igc: Remove unused argument from igc_tx_cmd_type() Andre Guedes
2020-10-28 20:19 ` Andre Guedes [this message]
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 04/10] igc: Introduce igc_get_rx_frame_truesize() helper Andre Guedes
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 05/10] igc: Refactor rx timestamp handling Andre Guedes
2020-10-29 14:07   ` Maciej Fijalkowski
2020-10-29 23:59     ` Andre Guedes
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 06/10] igc: Add set/clear large buffer helpers Andre Guedes
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 07/10] igc: Add initial XDP support Andre Guedes
2020-10-29 14:13   ` Maciej Fijalkowski
2020-10-30  0:00     ` Andre Guedes
2020-10-30 21:05       ` Andre Guedes
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 08/10] igc: Add support for XDP_TX action Andre Guedes
2020-10-29 14:30   ` Maciej Fijalkowski
2020-10-30  0:00     ` Andre Guedes
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 09/10] igc: Add support for XDP_REDIRECT action Andre Guedes
2020-10-28 20:19 ` [Intel-wired-lan] [PATCH v2 10/10] igc: Implement ndo_xdp_xmit callback Andre Guedes
2020-10-29 14:34   ` Maciej Fijalkowski
2020-10-30  0:00     ` Andre Guedes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201028201943.93147-4-andre.guedes@intel.com \
    --to=andre.guedes@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.