From: Jithu Joseph <jithu.joseph@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v4 6/9] igc: Introduce igc_unmap_tx_buffer() helper
Date: Mon, 22 Feb 2021 01:09:33 -0800 [thread overview]
Message-ID: <20210222090936.6768-7-jithu.joseph@intel.com> (raw)
In-Reply-To: <20210222090936.6768-1-jithu.joseph@intel.com>
From: Andre Guedes <andre.guedes@intel.com>
In preparation for AF_XDP zero-copy support, encapsulate the code that
unmaps tx buffers into its own local helper so we can reuse it, avoiding
code duplication.
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
Signed-off-by: Vedang Patel <vedang.patel@intel.com>
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
drivers/net/ethernet/intel/igc/igc_main.c | 49 +++++++----------------
1 file changed, 15 insertions(+), 34 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 389df007f050..fbb6aeea95cd 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -171,6 +171,14 @@ static void igc_get_hw_control(struct igc_adapter *adapter)
ctrl_ext | IGC_CTRL_EXT_DRV_LOAD);
}
+static void igc_unmap_tx_buffer(struct device *dev, struct igc_tx_buffer *buf)
+{
+ dma_unmap_single(dev, dma_unmap_addr(buf, dma),
+ dma_unmap_len(buf, len), DMA_TO_DEVICE);
+
+ dma_unmap_len_set(buf, len, 0);
+}
+
/**
* igc_clean_tx_ring - Free Tx Buffers
* @tx_ring: ring to be cleaned
@@ -188,11 +196,7 @@ static void igc_clean_tx_ring(struct igc_ring *tx_ring)
else
dev_kfree_skb_any(tx_buffer->skb);
- /* unmap skb header data */
- dma_unmap_single(tx_ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
+ igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
/* check for eop_desc to determine the end of the packet */
eop_desc = tx_buffer->next_to_watch;
@@ -211,10 +215,7 @@ static void igc_clean_tx_ring(struct igc_ring *tx_ring)
/* unmap any remaining paged data */
if (dma_unmap_len(tx_buffer, len))
- dma_unmap_page(tx_ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
+ igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
}
/* move us one more past the eop_desc for start of next pkt */
@@ -1218,11 +1219,7 @@ static int igc_tx_map(struct igc_ring *tx_ring,
/* clear dma mappings for failed tx_buffer_info map */
while (tx_buffer != first) {
if (dma_unmap_len(tx_buffer, len))
- dma_unmap_page(tx_ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
- dma_unmap_len_set(tx_buffer, len, 0);
+ igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
if (i-- == 0)
i += tx_ring->count;
@@ -1230,11 +1227,7 @@ static int igc_tx_map(struct igc_ring *tx_ring,
}
if (dma_unmap_len(tx_buffer, len))
- dma_unmap_single(tx_ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
- dma_unmap_len_set(tx_buffer, len, 0);
+ igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
dev_kfree_skb_any(tx_buffer->skb);
tx_buffer->skb = NULL;
@@ -2320,14 +2313,7 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget)
else
napi_consume_skb(tx_buffer->skb, napi_budget);
- /* unmap skb header data */
- dma_unmap_single(tx_ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
-
- /* clear tx_buffer data */
- dma_unmap_len_set(tx_buffer, len, 0);
+ igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
/* clear last DMA location and unmap remaining buffers */
while (tx_desc != eop_desc) {
@@ -2341,13 +2327,8 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget)
}
/* unmap any remaining paged data */
- if (dma_unmap_len(tx_buffer, len)) {
- dma_unmap_page(tx_ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
- dma_unmap_len_set(tx_buffer, len, 0);
- }
+ if (dma_unmap_len(tx_buffer, len))
+ igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
}
/* move us one more past the eop_desc for start of next pkt */
--
2.17.1
next prev parent reply other threads:[~2021-02-22 9:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 9:09 [Intel-wired-lan] [PATCH v4 0/9] igc: Add support for AF_XDP zero-copy Jithu Joseph
2021-02-22 9:09 ` [Intel-wired-lan] [PATCH v4 1/9] igc: Move igc_xdp_is_enabled() Jithu Joseph
2021-02-22 9:09 ` [Intel-wired-lan] [PATCH v4 2/9] igc: Refactor __igc_xdp_run_prog() Jithu Joseph
2021-02-22 9:09 ` [Intel-wired-lan] [PATCH v4 3/9] igc: Refactor igc_clean_rx_ring() Jithu Joseph
2021-02-22 9:09 ` [Intel-wired-lan] [PATCH v4 4/9] igc: Refactor XDP rxq info registration Jithu Joseph
2021-02-22 9:32 ` =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=
2021-02-26 0:15 ` Joseph, Jithu
2021-02-22 9:09 ` [Intel-wired-lan] [PATCH v4 5/9] igc: Introduce TX/RX stats helpers Jithu Joseph
2021-02-22 9:09 ` Jithu Joseph [this message]
2021-02-22 9:09 ` [Intel-wired-lan] [PATCH v4 7/9] igc: Replace IGC_TX_FLAGS_XDP flag by an enum Jithu Joseph
2021-02-22 9:09 ` [Intel-wired-lan] [PATCH v4 8/9] igc: Enable RX via AF_XDP zero-copy Jithu Joseph
2021-02-22 9:09 ` [Intel-wired-lan] [PATCH v4 9/9] igc: Enable TX " Jithu Joseph
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=20210222090936.6768-7-jithu.joseph@intel.com \
--to=jithu.joseph@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