Commit 745fc05c authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Add bp->rx_dir field for rx buffer DMA direction.

When driver is running in XDP mode, rx buffers are DMA mapped as
DMA_BIDIRECTIONAL.  Add a field so the code will map/unmap rx buffers
according to this field.
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 11cd119d
...@@ -584,7 +584,7 @@ static inline u8 *__bnxt_alloc_rx_data(struct bnxt *bp, dma_addr_t *mapping, ...@@ -584,7 +584,7 @@ static inline u8 *__bnxt_alloc_rx_data(struct bnxt *bp, dma_addr_t *mapping,
return NULL; return NULL;
*mapping = dma_map_single(&pdev->dev, data + BNXT_RX_DMA_OFFSET, *mapping = dma_map_single(&pdev->dev, data + BNXT_RX_DMA_OFFSET,
bp->rx_buf_use_size, PCI_DMA_FROMDEVICE); bp->rx_buf_use_size, bp->rx_dir);
if (dma_mapping_error(&pdev->dev, *mapping)) { if (dma_mapping_error(&pdev->dev, *mapping)) {
kfree(data); kfree(data);
...@@ -772,7 +772,7 @@ static struct sk_buff *bnxt_rx_skb(struct bnxt *bp, ...@@ -772,7 +772,7 @@ static struct sk_buff *bnxt_rx_skb(struct bnxt *bp,
skb = build_skb(data, 0); skb = build_skb(data, 0);
dma_unmap_single(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, dma_unmap_single(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size,
PCI_DMA_FROMDEVICE); bp->rx_dir);
if (!skb) { if (!skb) {
kfree(data); kfree(data);
return NULL; return NULL;
...@@ -878,15 +878,14 @@ static inline struct sk_buff *bnxt_copy_skb(struct bnxt_napi *bnapi, u8 *data, ...@@ -878,15 +878,14 @@ static inline struct sk_buff *bnxt_copy_skb(struct bnxt_napi *bnapi, u8 *data,
if (!skb) if (!skb)
return NULL; return NULL;
dma_sync_single_for_cpu(&pdev->dev, mapping, dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copy_thresh,
bp->rx_copy_thresh, PCI_DMA_FROMDEVICE); bp->rx_dir);
memcpy(skb->data - NET_IP_ALIGN, data - NET_IP_ALIGN, memcpy(skb->data - NET_IP_ALIGN, data - NET_IP_ALIGN,
len + NET_IP_ALIGN); len + NET_IP_ALIGN);
dma_sync_single_for_device(&pdev->dev, mapping, dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copy_thresh,
bp->rx_copy_thresh, bp->rx_dir);
PCI_DMA_FROMDEVICE);
skb_put(skb, len); skb_put(skb, len);
return skb; return skb;
...@@ -1261,7 +1260,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, ...@@ -1261,7 +1260,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp,
skb = build_skb(data, 0); skb = build_skb(data, 0);
dma_unmap_single(&bp->pdev->dev, mapping, bp->rx_buf_use_size, dma_unmap_single(&bp->pdev->dev, mapping, bp->rx_buf_use_size,
PCI_DMA_FROMDEVICE); bp->rx_dir);
if (!skb) { if (!skb) {
kfree(data); kfree(data);
...@@ -1878,11 +1877,9 @@ static void bnxt_free_rx_skbs(struct bnxt *bp) ...@@ -1878,11 +1877,9 @@ static void bnxt_free_rx_skbs(struct bnxt *bp)
if (!data) if (!data)
continue; continue;
dma_unmap_single( dma_unmap_single(&pdev->dev, tpa_info->mapping,
&pdev->dev, bp->rx_buf_use_size,
tpa_info->mapping, bp->rx_dir);
bp->rx_buf_use_size,
PCI_DMA_FROMDEVICE);
tpa_info->data = NULL; tpa_info->data = NULL;
...@@ -1898,8 +1895,7 @@ static void bnxt_free_rx_skbs(struct bnxt *bp) ...@@ -1898,8 +1895,7 @@ static void bnxt_free_rx_skbs(struct bnxt *bp)
continue; continue;
dma_unmap_single(&pdev->dev, rx_buf->mapping, dma_unmap_single(&pdev->dev, rx_buf->mapping,
bp->rx_buf_use_size, bp->rx_buf_use_size, bp->rx_dir);
PCI_DMA_FROMDEVICE);
rx_buf->data = NULL; rx_buf->data = NULL;
...@@ -2563,6 +2559,7 @@ void bnxt_set_ring_params(struct bnxt *bp) ...@@ -2563,6 +2559,7 @@ void bnxt_set_ring_params(struct bnxt *bp)
static int bnxt_set_rx_skb_mode(struct bnxt *bp) static int bnxt_set_rx_skb_mode(struct bnxt *bp)
{ {
bp->rx_dir = DMA_FROM_DEVICE;
bp->rx_skb_func = bnxt_rx_skb; bp->rx_skb_func = bnxt_rx_skb;
return 0; return 0;
} }
......
...@@ -997,6 +997,7 @@ struct bnxt { ...@@ -997,6 +997,7 @@ struct bnxt {
u32 rx_buf_size; u32 rx_buf_size;
u32 rx_buf_use_size; /* useable size */ u32 rx_buf_use_size; /* useable size */
enum dma_data_direction rx_dir;
u32 rx_ring_size; u32 rx_ring_size;
u32 rx_agg_ring_size; u32 rx_agg_ring_size;
u32 rx_copy_thresh; u32 rx_copy_thresh;
......
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