[PATCH v2 2/2] net: Add fsl_enetc network driver support

Sascha Hauer s.hauer at pengutronix.de
Thu Jan 4 04:18:56 PST 2024


On Thu, Jan 04, 2024 at 12:22:41PM +0100, Sascha Hauer wrote:
> This adds support for the fsl_enetc network controller found on several
> Layerscape SoCs. The code is originally from U-Boot-2023.10-rc1.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
> 
> Notes:
>     Changes since v1:
>     
>     - Use get_unaligned to access unaligned pointers
>     - use physical address returned by dma_alloc_coherent()
>     - implement struct pci_driver::remove hook
>     - do not printf in poller function
>     - use write[lwq] to access rx/tx rings to avoid dmb()

Actually this last part is missing, here it is:

---------------------------------8<---------------------------

>From 3b312b7d501be3b0049de27582a26b19fdaf84e1 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer at pengutronix.de>
Date: Wed, 3 Jan 2024 20:55:39 +0100
Subject: [PATCH] fixup! net: Add fsl_enetc network driver support

---
 drivers/net/fsl_enetc.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index eb90c526bb..07e9a6b7c8 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -454,13 +454,10 @@ static int enetc_send(struct eth_device *edev, void *packet, int length)
 	dma = dma_map_single(priv->dev, packet, length, DMA_TO_DEVICE);
 
 	/* prepare Tx BD */
-	memset(&priv->enetc_txbd[pi], 0x0, sizeof(struct enetc_tx_bd));
-	priv->enetc_txbd[pi].addr = cpu_to_le64(dma);
-	priv->enetc_txbd[pi].buf_len = cpu_to_le16(length);
-	priv->enetc_txbd[pi].frm_len = cpu_to_le16(length);
-	priv->enetc_txbd[pi].flags = cpu_to_le16(ENETC_TXBD_FLAGS_F);
-
-	dmb();
+	writeq(cpu_to_le64(dma), &priv->enetc_txbd[pi].addr);
+	writew(cpu_to_le16(length), &priv->enetc_txbd[pi].buf_len);
+	writew(cpu_to_le16(length), &priv->enetc_txbd[pi].frm_len);
+	writew(cpu_to_le16(ENETC_TXBD_FLAGS_F), &priv->enetc_txbd[pi].flags);
 
 	/* send frame: increment producer index */
 	pi = (pi + 1) % txr->bd_count;
@@ -508,9 +505,7 @@ static int enetc_recv(struct eth_device *edev)
 	if (!ENETC_RXBD_STATUS_R(status))
 		return 0;
 
-	dmb();
-
-	len = le16_to_cpu(priv->enetc_rxbd[pi].r.buf_len);
+	len = le16_to_cpu(readw(&priv->enetc_rxbd[pi].r.buf_len));
 
 	dev_dbg(&edev->dev, "RxBD[%d]: len=%d err=%d pkt=0x%p\n", pi, len,
 		  ENETC_RXBD_STATUS_ERRORS(status), pkg);
@@ -520,8 +515,8 @@ static int enetc_recv(struct eth_device *edev)
 	dma_sync_single_for_device(priv->dev, priv->rx_pkg_phys[pi], PKTSIZE, DMA_FROM_DEVICE);
 
 	/* BD clean up and advance to next in ring */
-	memset(&priv->enetc_rxbd[pi], 0, sizeof(union enetc_rx_bd));
-	priv->enetc_rxbd[pi].w.addr = priv->rx_pkg_phys[pi];
+	memset_io(&priv->enetc_rxbd[pi], 0, sizeof(union enetc_rx_bd));
+	writeq(priv->rx_pkg_phys[pi], &priv->enetc_rxbd[pi].w.addr);
 	rxr->next_prod_idx = (pi + 1) % rxr->bd_count;
 	ci = (ci + 1) % rxr->bd_count;
 	rxr->next_cons_idx = ci;
-- 
2.39.2


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list