From: Andre Guedes <andre.guedes@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v4 4/9] igc: Introduce igc_get_rx_frame_truesize() helper
Date: Tue, 3 Nov 2020 19:12:05 -0800 [thread overview]
Message-ID: <20201104031210.27772-5-andre.guedes@intel.com> (raw)
In-Reply-To: <20201104031210.27772-1-andre.guedes@intel.com>
The RX frame truesize calculation is scattered throughout the RX code.
This patch creates the helper function igc_get_rx_frame_truesize() and
uses it where applicable.
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
drivers/net/ethernet/intel/igc/igc_main.c | 29 ++++++++++++++---------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 31dc58a82cf3..15c67e5763d3 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -1523,6 +1523,22 @@ static void igc_rx_buffer_flip(struct igc_rx_buffer *buffer,
#endif
}
+static unsigned int igc_get_rx_frame_truesize(struct igc_ring *ring,
+ unsigned int size)
+{
+ unsigned int truesize;
+
+#if (PAGE_SIZE < 8192)
+ truesize = igc_rx_pg_size(ring) / 2;
+#else
+ truesize = ring_uses_build_skb(ring) ?
+ SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
+ SKB_DATA_ALIGN(IGC_SKB_PAD + size) :
+ SKB_DATA_ALIGN(size);
+#endif
+ return truesize;
+}
+
/**
* igc_add_rx_frag - Add contents of Rx buffer to sk_buff
* @rx_ring: rx descriptor ring to transact packets on
@@ -1557,12 +1573,7 @@ static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring,
unsigned int size)
{
void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
-#if (PAGE_SIZE < 8192)
- unsigned int truesize = igc_rx_pg_size(rx_ring) / 2;
-#else
- unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
- SKB_DATA_ALIGN(IGC_SKB_PAD + size);
-#endif
+ unsigned int truesize = igc_get_rx_frame_truesize(rx_ring, size);
struct sk_buff *skb;
/* prefetch first cache line of first page */
@@ -1587,11 +1598,7 @@ static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring,
unsigned int size)
{
void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
-#if (PAGE_SIZE < 8192)
- unsigned int truesize = igc_rx_pg_size(rx_ring) / 2;
-#else
- unsigned int truesize = SKB_DATA_ALIGN(size);
-#endif
+ unsigned int truesize = igc_get_rx_frame_truesize(rx_ring, size);
unsigned int headlen;
struct sk_buff *skb;
--
2.28.0
next prev parent reply other threads:[~2020-11-04 3:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-04 3:12 [Intel-wired-lan] [PATCH v4 0/9] igc: Add XDP support Andre Guedes
2020-11-04 3:12 ` [Intel-wired-lan] [PATCH v4 1/9] igc: Fix igc_ptp_rx_pktstamp() Andre Guedes
2020-11-04 3:12 ` [Intel-wired-lan] [PATCH v4 2/9] igc: Remove unused argument from igc_tx_cmd_type() Andre Guedes
2020-11-04 3:12 ` [Intel-wired-lan] [PATCH v4 3/9] igc: Introduce igc_rx_buffer_flip() helper Andre Guedes
2020-11-04 3:12 ` Andre Guedes [this message]
2020-11-04 3:12 ` [Intel-wired-lan] [PATCH v4 5/9] igc: Refactor rx timestamp handling Andre Guedes
2020-11-04 3:12 ` [Intel-wired-lan] [PATCH v4 6/9] igc: Add set/clear large buffer helpers Andre Guedes
2020-11-04 3:12 ` [Intel-wired-lan] [PATCH v4 7/9] igc: Add initial XDP support Andre Guedes
2020-11-12 9:13 ` Neftin, Sasha
2020-11-12 21:58 ` Andre Guedes
2020-11-12 22:18 ` Jesse Brandeburg
2020-11-04 3:12 ` [Intel-wired-lan] [PATCH v4 8/9] igc: Add support for XDP_TX action Andre Guedes
2020-11-04 3:12 ` [Intel-wired-lan] [PATCH v4 9/9] igc: Add support for XDP_REDIRECT action Andre Guedes
2020-11-12 9:03 ` Neftin, Sasha
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=20201104031210.27772-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox