Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Emil Tantilov <emil.s.tantilov@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH 1/9] ixgbevf: add function for checking if we can reuse page
Date: Mon, 11 Dec 2017 10:36:49 -0800	[thread overview]
Message-ID: <20171211183649.21524.3888.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20171211183537.21524.10133.stgit@localhost6.localdomain6>

Introduce ixgbevf_can_reuse_page() similar to the change in ixgbe from
commit af43da0dba0b
("ixgbe: Add function for checking to see if we can reuse page")

Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
---
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c |   59 ++++++++++++---------
 1 file changed, 33 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index ed5c3ae..7ffd429 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -754,6 +754,38 @@ static inline bool ixgbevf_page_is_reserved(struct page *page)
 	return (page_to_nid(page) != numa_mem_id()) || page_is_pfmemalloc(page);
 }
 
+static bool ixgbevf_can_reuse_rx_page(struct ixgbevf_rx_buffer *rx_buffer,
+				      struct page *page,
+				      const unsigned int truesize)
+{
+	/* avoid re-using remote pages */
+	if (unlikely(ixgbevf_page_is_reserved(page)))
+		return false;
+
+#if (PAGE_SIZE < 8192)
+	/* if we are only owner of page we can reuse it */
+	if (unlikely(page_count(page) != 1))
+		return false;
+
+	/* flip page offset to other buffer */
+	rx_buffer->page_offset ^= IXGBEVF_RX_BUFSZ;
+
+#else
+	/* move offset up to the next cache line */
+	rx_buffer->page_offset += truesize;
+
+	if (rx_buffer->page_offset > (PAGE_SIZE - IXGBEVF_RX_BUFSZ))
+		return false;
+
+#endif
+	/* Even if we own the page, we are not allowed to use atomic_set()
+	 * This would break get_page_unless_zero() users.
+	 */
+	page_ref_inc(page);
+
+	return true;
+}
+
 /**
  * ixgbevf_add_rx_frag - Add contents of Rx buffer to sk_buff
  * @rx_ring: rx descriptor ring to transact packets on
@@ -815,32 +847,7 @@ static bool ixgbevf_add_rx_frag(struct ixgbevf_ring *rx_ring,
 	skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
 			(unsigned long)va & ~PAGE_MASK, size, truesize);
 
-	/* avoid re-using remote pages */
-	if (unlikely(ixgbevf_page_is_reserved(page)))
-		return false;
-
-#if (PAGE_SIZE < 8192)
-	/* if we are only owner of page we can reuse it */
-	if (unlikely(page_count(page) != 1))
-		return false;
-
-	/* flip page offset to other buffer */
-	rx_buffer->page_offset ^= IXGBEVF_RX_BUFSZ;
-
-#else
-	/* move offset up to the next cache line */
-	rx_buffer->page_offset += truesize;
-
-	if (rx_buffer->page_offset > (PAGE_SIZE - IXGBEVF_RX_BUFSZ))
-		return false;
-
-#endif
-	/* Even if we own the page, we are not allowed to use atomic_set()
-	 * This would break get_page_unless_zero() users.
-	 */
-	page_ref_inc(page);
-
-	return true;
+	return ixgbevf_can_reuse_rx_page(rx_buffer, page, truesize);
 }
 
 static struct sk_buff *ixgbevf_fetch_rx_buffer(struct ixgbevf_ring *rx_ring,


  reply	other threads:[~2017-12-11 18:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-11 18:36 [Intel-wired-lan] [PATCH 0/9] ixgbevf: update Rx/Tx code path for build_skb Emil Tantilov
2017-12-11 18:36 ` Emil Tantilov [this message]
2018-01-04 15:41   ` [Intel-wired-lan] [PATCH 1/9] ixgbevf: add function for checking if we can reuse page Singh, Krishneil K
2017-12-11 18:36 ` [Intel-wired-lan] [PATCH 2/9] ixgbevf: only DMA sync frame length Emil Tantilov
2018-01-04 15:43   ` Singh, Krishneil K
2018-02-26 15:55   ` Singh, Krishneil K
2017-12-11 18:36 ` [Intel-wired-lan] [PATCH 3/9] ixgbevf: use length to determine if descriptor is done Emil Tantilov
2018-01-04 15:44   ` Singh, Krishneil K
2018-02-26 15:57   ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 4/9] ixgbevf: add support for DMA_ATTR_SKIP_CPU_SYNC/WEAK_ORDERING Emil Tantilov
2018-01-04 15:46   ` Singh, Krishneil K
2018-02-26 15:54   ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 5/9] ixgbevf: update code to better handle incrementing page count Emil Tantilov
2018-01-04 15:46   ` Singh, Krishneil K
2018-02-26 15:56   ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 6/9] ixgbevf: add counters for Rx page allocations Emil Tantilov
2018-01-04 15:47   ` Singh, Krishneil K
2018-02-26 15:54   ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 7/9] ixgbevf: clear rx_buffer_info in configure instead of clean Emil Tantilov
2018-01-04 15:48   ` Singh, Krishneil K
2018-02-26 15:55   ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 8/9] ixgbevf: improve performance and reduce size of ixgbevf_tx_map() Emil Tantilov
2018-01-04 15:49   ` Singh, Krishneil K
2018-02-26 15:54   ` Singh, Krishneil K
2017-12-11 18:37 ` [Intel-wired-lan] [PATCH 9/9] ixgbevf: don't bother clearing tx_buffer_info in ixgbevf_clean_tx_ring() Emil Tantilov
2018-01-04 15:50   ` Singh, Krishneil K
2018-02-26 15:57   ` Singh, Krishneil K

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=20171211183649.21524.3888.stgit@localhost6.localdomain6 \
    --to=emil.s.tantilov@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