Commit 61234295 authored by Andre Guedes's avatar Andre Guedes Committed by Tony Nguyen

igc: Introduce igc_unmap_tx_buffer() helper

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: default avatarAndre Guedes <andre.guedes@intel.com>
Signed-off-by: default avatarVedang Patel <vedang.patel@intel.com>
Signed-off-by: default avatarJithu Joseph <jithu.joseph@intel.com>
Reviewed-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: default avatarDvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent a27e6e73
...@@ -171,6 +171,14 @@ static void igc_get_hw_control(struct igc_adapter *adapter) ...@@ -171,6 +171,14 @@ static void igc_get_hw_control(struct igc_adapter *adapter)
ctrl_ext | IGC_CTRL_EXT_DRV_LOAD); 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 * igc_clean_tx_ring - Free Tx Buffers
* @tx_ring: ring to be cleaned * @tx_ring: ring to be cleaned
...@@ -188,11 +196,7 @@ static void igc_clean_tx_ring(struct igc_ring *tx_ring) ...@@ -188,11 +196,7 @@ static void igc_clean_tx_ring(struct igc_ring *tx_ring)
else else
dev_kfree_skb_any(tx_buffer->skb); dev_kfree_skb_any(tx_buffer->skb);
/* unmap skb header data */ igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
dma_unmap_single(tx_ring->dev,
dma_unmap_addr(tx_buffer, dma),
dma_unmap_len(tx_buffer, len),
DMA_TO_DEVICE);
/* check for eop_desc to determine the end of the packet */ /* check for eop_desc to determine the end of the packet */
eop_desc = tx_buffer->next_to_watch; eop_desc = tx_buffer->next_to_watch;
...@@ -211,10 +215,7 @@ static void igc_clean_tx_ring(struct igc_ring *tx_ring) ...@@ -211,10 +215,7 @@ static void igc_clean_tx_ring(struct igc_ring *tx_ring)
/* unmap any remaining paged data */ /* unmap any remaining paged data */
if (dma_unmap_len(tx_buffer, len)) if (dma_unmap_len(tx_buffer, len))
dma_unmap_page(tx_ring->dev, igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
dma_unmap_addr(tx_buffer, dma),
dma_unmap_len(tx_buffer, len),
DMA_TO_DEVICE);
} }
/* move us one more past the eop_desc for start of next pkt */ /* move us one more past the eop_desc for start of next pkt */
...@@ -1219,11 +1220,7 @@ static int igc_tx_map(struct igc_ring *tx_ring, ...@@ -1219,11 +1220,7 @@ static int igc_tx_map(struct igc_ring *tx_ring,
/* clear dma mappings for failed tx_buffer_info map */ /* clear dma mappings for failed tx_buffer_info map */
while (tx_buffer != first) { while (tx_buffer != first) {
if (dma_unmap_len(tx_buffer, len)) if (dma_unmap_len(tx_buffer, len))
dma_unmap_page(tx_ring->dev, igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
dma_unmap_addr(tx_buffer, dma),
dma_unmap_len(tx_buffer, len),
DMA_TO_DEVICE);
dma_unmap_len_set(tx_buffer, len, 0);
if (i-- == 0) if (i-- == 0)
i += tx_ring->count; i += tx_ring->count;
...@@ -1231,11 +1228,7 @@ static int igc_tx_map(struct igc_ring *tx_ring, ...@@ -1231,11 +1228,7 @@ static int igc_tx_map(struct igc_ring *tx_ring,
} }
if (dma_unmap_len(tx_buffer, len)) if (dma_unmap_len(tx_buffer, len))
dma_unmap_single(tx_ring->dev, igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
dma_unmap_addr(tx_buffer, dma),
dma_unmap_len(tx_buffer, len),
DMA_TO_DEVICE);
dma_unmap_len_set(tx_buffer, len, 0);
dev_kfree_skb_any(tx_buffer->skb); dev_kfree_skb_any(tx_buffer->skb);
tx_buffer->skb = NULL; tx_buffer->skb = NULL;
...@@ -2317,14 +2310,7 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget) ...@@ -2317,14 +2310,7 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget)
else else
napi_consume_skb(tx_buffer->skb, napi_budget); napi_consume_skb(tx_buffer->skb, napi_budget);
/* unmap skb header data */ igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
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);
/* clear last DMA location and unmap remaining buffers */ /* clear last DMA location and unmap remaining buffers */
while (tx_desc != eop_desc) { while (tx_desc != eop_desc) {
...@@ -2338,13 +2324,8 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget) ...@@ -2338,13 +2324,8 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget)
} }
/* unmap any remaining paged data */ /* unmap any remaining paged data */
if (dma_unmap_len(tx_buffer, len)) { if (dma_unmap_len(tx_buffer, len))
dma_unmap_page(tx_ring->dev, igc_unmap_tx_buffer(tx_ring->dev, tx_buffer);
dma_unmap_addr(tx_buffer, dma),
dma_unmap_len(tx_buffer, len),
DMA_TO_DEVICE);
dma_unmap_len_set(tx_buffer, len, 0);
}
} }
/* move us one more past the eop_desc for start of next pkt */ /* move us one more past the eop_desc for start of next pkt */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment