Openwrt/target/linux/layerscape/patches-5.4/701-net-0047-sdk_dpaa-update-comments-about-recycling-and-back-po.patch

68 lines
2.5 KiB
Diff
Raw Normal View History

From 2d7b6e7daf076b63f461ce9c4ec6022ddc3d15bb Mon Sep 17 00:00:00 2001
From: Camelia Groza <camelia.groza@nxp.com>
Date: Mon, 15 Jan 2018 17:42:42 +0200
Subject: [PATCH] sdk_dpaa: update comments about recycling and back-pointer
storage
Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
@@ -121,6 +121,10 @@ static int _dpa_bp_add_8_bufs(const stru
put_page(virt_to_head_page(new_buf));
goto build_skb_failed;
}
+
+ /* Store the skb back-pointer before the start of the buffer.
+ * Otherwise it will be overwritten by the FMan.
+ */
DPA_WRITE_SKB_PTR(skb, skbh, new_buf, -1);
addr = dma_map_single(dev, new_buf,
@@ -344,7 +348,10 @@ bool dpa_buf_is_recyclable(struct sk_buf
* - buffer address aligned to cacheline bytes
* - offset of data from start of buffer no lower than a minimum value
* - offset of data from start of buffer no higher than a maximum value
+ * - the skb back-pointer is stored safely
*/
+
+ /* guarantee both the minimum size and the minimum data offset */
new = min(skb_end_pointer(skb) - min_size, skb->data - min_offset);
/* left align to the nearest cacheline */
@@ -694,6 +701,9 @@ int __hot skb_to_contig_fd(struct dpa_pr
dma_dir = DMA_BIDIRECTIONAL;
dma_map_size = dpa_bp->size;
+ /* Store the skb back-pointer before the start of the buffer.
+ * Otherwise it will be overwritten by the FMan.
+ */
DPA_WRITE_SKB_PTR(skb, skbh, buffer_start, -1);
*offset = skb_headroom(skb) - fd->offset;
} else
@@ -711,7 +721,7 @@ int __hot skb_to_contig_fd(struct dpa_pr
/* The buffer will be Tx-confirmed, but the TxConf cb must
* necessarily look at our Tx private data to retrieve the
- * skbuff. (In short: can't use DPA_WRITE_SKB_PTR() here.)
+ * skbuff. Store the back-pointer inside the buffer.
*/
DPA_WRITE_SKB_PTR(skb, skbh, buffer_start, 0);
}
@@ -975,7 +985,11 @@ int __hot skb_to_sg_fd(struct dpa_priv_s
fd->length20 = skb->len;
fd->offset = priv->tx_headroom;
- /* DMA map the SGT page */
+ /* DMA map the SGT page
+ *
+ * It's safe to store the skb back-pointer inside the buffer since
+ * S/G frames are non-recyclable.
+ */
DPA_WRITE_SKB_PTR(skb, skbh, sgt_buf, 0);
addr = dma_map_single(dpa_bp->dev, sgt_buf,
priv->tx_headroom + sgt_size,