mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/9] Reduce usage of NetRxPackets[]
@ 2022-09-19  8:01 Sascha Hauer
  2022-09-19  8:01 ` [PATCH 1/9] net: tap: Allocate own receive buffer Sascha Hauer
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Usage of the globally allocted network receive buffers NetRxPackets[] is
inherently broken. Some drivers queue these buffers in the hardware.
When multiple of these drivers are active at the same time then they
stamp over each others packets and bad things happen.

The goal is to remove NetRxPackets[] entirely in favor of per device
packet buffers. This series is a first step into that direction. It
removes the simple cases where only NetRxPackets[0] is used to store the
single packet that is pulled out of the hardware before net_receive() is
called.

Sascha

Sascha Hauer (9):
  net: tap: Allocate own receive buffer
  net: macb: Allocate own receive buffer
  net: cs8900: Allocate own receive buffer
  net: liteeth: Do not use NetRxPackets
  net: efi-snp: Allocate own receive buffer
  net: smc91111: Allocate own receive buffer
  net: smc911x: Allocate own receive buffer
  net: ks8851_mll: Allocate own receive buffer
  net: remove altera_tse driver

 drivers/net/Kconfig      |  16 --
 drivers/net/Makefile     |   1 -
 drivers/net/altera_tse.c | 563 ---------------------------------------
 drivers/net/altera_tse.h | 296 --------------------
 drivers/net/cs8900.c     |   7 +-
 drivers/net/efi-snp.c    |   6 +-
 drivers/net/ks8851_mll.c |   9 +-
 drivers/net/liteeth.c    |   8 +-
 drivers/net/macb.c       |  12 +-
 drivers/net/smc91111.c   |  10 +-
 drivers/net/smc911x.c    |   8 +-
 drivers/net/tap.c        |   7 +-
 12 files changed, 45 insertions(+), 898 deletions(-)
 delete mode 100644 drivers/net/altera_tse.c
 delete mode 100644 drivers/net/altera_tse.h

-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/9] net: tap: Allocate own receive buffer
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  2022-09-19  8:01 ` [PATCH 2/9] net: macb: " Sascha Hauer
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Use a driver private buffer as network receive buffer rather than the
globally allocated ones which will be removed soon.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/tap.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 1fbfa085b1..8a659c125e 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -15,6 +15,7 @@
 struct tap_priv {
 	int fd;
 	char *name;
+	char *rx_buf;
 };
 
 static int tap_eth_send(struct eth_device *edev, void *packet, int length)
@@ -30,10 +31,10 @@ static int tap_eth_rx(struct eth_device *edev)
 	struct tap_priv *priv = edev->priv;
 	int length;
 
-	length = linux_read_nonblock(priv->fd, NetRxPackets[0], PKTSIZE);
+	length = linux_read_nonblock(priv->fd, priv->rx_buf, PKTSIZE);
 
 	if (length > 0)
-		net_receive(edev, NetRxPackets[0], length);
+		net_receive(edev, priv->rx_buf, length);
 
 	return 0;
 }
@@ -73,6 +74,8 @@ static int tap_probe(struct device_d *dev)
 		goto out;
 	}
 
+	priv->rx_buf = xmalloc(PKTSIZE);
+
 	edev = xzalloc(sizeof(struct eth_device));
 	edev->priv = priv;
 	edev->parent = dev;
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/9] net: macb: Allocate own receive buffer
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
  2022-09-19  8:01 ` [PATCH 1/9] net: tap: Allocate own receive buffer Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  2022-09-19  8:01 ` [PATCH 3/9] net: cs8900: " Sascha Hauer
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Use a driver private buffer as network receive buffer rather than the
globally allocated ones which will be removed soon.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/macb.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 511846122a..5dbca1553e 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -64,6 +64,7 @@ struct macb_device {
 
 	void			*rx_buffer;
 	void			*tx_buffer;
+	void			*rx_packet_buf;
 	struct macb_dma_desc	*rx_ring;
 	struct macb_dma_desc	*tx_ring;
 	struct macb_dma_desc	*gem_q1_descs;
@@ -230,16 +231,15 @@ static int macb_recv(struct eth_device *edev)
 				taillen = length - headlen;
 				dma_sync_single_for_cpu((unsigned long)buffer,
 							headlen, DMA_FROM_DEVICE);
-				memcpy((void *)NetRxPackets[0], buffer, headlen);
+				memcpy(macb->rx_packet_buf, buffer, headlen);
 				dma_sync_single_for_cpu((unsigned long)macb->rx_buffer,
 							taillen, DMA_FROM_DEVICE);
-				memcpy((void *)NetRxPackets[0] + headlen,
-					macb->rx_buffer, taillen);
+				memcpy(macb->rx_packet_buf + headlen, macb->rx_buffer, taillen);
 				dma_sync_single_for_device((unsigned long)buffer,
 							headlen, DMA_FROM_DEVICE);
 				dma_sync_single_for_device((unsigned long)macb->rx_buffer,
 							taillen, DMA_FROM_DEVICE);
-				net_receive(edev, NetRxPackets[0], length);
+				net_receive(edev, macb->rx_packet_buf, length);
 			} else {
 				dma_sync_single_for_cpu((unsigned long)buffer, length,
 							DMA_FROM_DEVICE);
@@ -898,6 +898,8 @@ static int macb_probe(struct device_d *dev)
 		macb->gem_q1_descs = dma_alloc_coherent(GEM_Q1_DESC_BYTES,
 				DMA_ADDRESS_BROKEN);
 
+	macb->rx_packet_buf = xmalloc(PKTSIZE);
+
 	macb_reset_hw(macb);
 	ncfgr = macb_mdc_clk_div(macb);
 	ncfgr |= MACB_BIT(PAE);		/* PAuse Enable */
@@ -921,6 +923,8 @@ static void macb_remove(struct device_d *dev)
 	struct macb_device *macb = dev->priv;
 
 	macb_halt(&macb->netdev);
+
+	free(macb->rx_packet_buf);
 }
 
 static const struct macb_config fu540_c000_config = {
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/9] net: cs8900: Allocate own receive buffer
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
  2022-09-19  8:01 ` [PATCH 1/9] net: tap: Allocate own receive buffer Sascha Hauer
  2022-09-19  8:01 ` [PATCH 2/9] net: macb: " Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  2022-09-19  8:01 ` [PATCH 4/9] net: liteeth: Do not use NetRxPackets Sascha Hauer
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Use a driver private buffer as network receive buffer rather than the
globally allocated ones which will be removed soon.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/cs8900.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index 75bbbd79e1..16e1d498c7 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -180,6 +180,7 @@ struct cs8900_priv {
 	void *regs;
 	struct cs89x0_product *product;
 	struct cs89x0_chip *chip;
+	void *rx_buf;
 };
 
 /* Read a 16-bit value from PacketPage Memory using I/O Space operation */
@@ -294,13 +295,13 @@ static int cs8900_recv(struct eth_device *dev)
 	status = readw(priv->regs + CS8900_RTDATA0);
 	len = readw(priv->regs + CS8900_RTDATA0);
 
-	for (addr = (u16 *) NetRxPackets[0], i = len >> 1; i > 0; i--) {
+	for (addr = (u16 *)priv->rx_buf, i = len >> 1; i > 0; i--) {
 		*addr++ = readw(priv->regs + CS8900_RTDATA0);
 	}
 	if (len & 1) {
 		*addr++ = readw(priv->regs + CS8900_RTDATA0);
 	}
-	net_receive(dev, NetRxPackets[0], len);
+	net_receive(dev, priv->rx_buf, len);
 
 	return len;
 }
@@ -442,6 +443,8 @@ static int cs8900_probe(struct device_d *dev)
 		return -1;
 	}
 
+	priv->rx_buf = xmalloc(PKTSIZE);
+
 	edev = (struct eth_device *)xmalloc(sizeof(struct eth_device));
 	edev->priv = priv;
 
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/9] net: liteeth: Do not use NetRxPackets
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
                   ` (2 preceding siblings ...)
  2022-09-19  8:01 ` [PATCH 3/9] net: cs8900: " Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  2022-09-19  8:01 ` [PATCH 5/9] net: efi-snp: Allocate own receive buffer Sascha Hauer
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Use a driver private buffer as network receive buffer rather than the
globally allocated ones which will be removed soon.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/liteeth.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/liteeth.c b/drivers/net/liteeth.c
index 771f57eead..547f5486ae 100644
--- a/drivers/net/liteeth.c
+++ b/drivers/net/liteeth.c
@@ -73,6 +73,8 @@ struct liteeth {
 	int rx_slot;
 	int num_rx_slots;
 	void __iomem *rx_base;
+
+	void *rx_buf;
 };
 
 static inline void litex_write8(void __iomem *addr, u8 val)
@@ -230,9 +232,9 @@ static int liteeth_eth_rx(struct eth_device *edev)
 
 	rx_slot = litex_read8(priv->base + LITEETH_WRITER_SLOT);
 
-	memcpy(NetRxPackets[0], priv->rx_base + rx_slot * LITEETH_BUFFER_SIZE, len);
+	memcpy(priv->rx_buf, priv->rx_base + rx_slot * LITEETH_BUFFER_SIZE, len);
 
-	net_receive(edev, NetRxPackets[0], len);
+	net_receive(edev, priv->rx_buf, len);
 
 	litex_write8(priv->base + LITEETH_WRITER_EV_PENDING, reg);
 
@@ -323,6 +325,8 @@ static int liteeth_probe(struct device_d *dev)
 	priv->tx_base = buf_base + priv->num_rx_slots * LITEETH_BUFFER_SIZE;
 	priv->tx_slot = 0;
 
+	priv->rx_buf = xmalloc(PKTSIZE);
+
 	edev->init = liteeth_init_dev;
 	edev->open = liteeth_eth_open;
 	edev->send = liteeth_eth_send;
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5/9] net: efi-snp: Allocate own receive buffer
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
                   ` (3 preceding siblings ...)
  2022-09-19  8:01 ` [PATCH 4/9] net: liteeth: Do not use NetRxPackets Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  2022-09-19  8:01 ` [PATCH 6/9] net: smc91111: " Sascha Hauer
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Use a driver private buffer as network receive buffer rather than the
globally allocated ones which will be removed soon.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/efi-snp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/efi-snp.c b/drivers/net/efi-snp.c
index 9cb7144187..d30da820a0 100644
--- a/drivers/net/efi-snp.c
+++ b/drivers/net/efi-snp.c
@@ -120,6 +120,7 @@ struct efi_snp_priv {
 	struct device_d *dev;
 	struct eth_device edev;
 	struct efi_simple_network *snp;
+	void *rx_buf;
 };
 
 static inline struct efi_snp_priv *to_priv(struct eth_device *edev)
@@ -163,7 +164,7 @@ static int efi_snp_eth_rx(struct eth_device *edev)
 	long bufsize = PKTSIZE;
 	efi_status_t efiret;
 
-	efiret = priv->snp->receive(priv->snp, NULL, &bufsize, NetRxPackets[0], NULL, NULL, NULL);
+	efiret = priv->snp->receive(priv->snp, NULL, &bufsize, priv->rx_buf, NULL, NULL, NULL);
 	if (efiret == EFI_NOT_READY)
 		return 0;
 
@@ -172,7 +173,7 @@ static int efi_snp_eth_rx(struct eth_device *edev)
 		return -efi_errno(efiret);
 	}
 
-	net_receive(edev, NetRxPackets[0], bufsize);
+	net_receive(edev, priv->rx_buf, bufsize);
 
 	return 0;
 }
@@ -285,6 +286,7 @@ static int efi_snp_probe(struct efi_device *efidev)
 	priv = xzalloc(sizeof(struct efi_snp_priv));
 	priv->snp = efidev->protocol;
 	priv->dev = &efidev->dev;
+	priv->rx_buf = xmalloc(PKTSIZE);
 
 	dev_dbg(&efidev->dev, "perm: %02x:%02x:%02x:%02x:%02x:%02x\n",
 			priv->snp->Mode->PermanentAddress.Addr[0],
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 6/9] net: smc91111: Allocate own receive buffer
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
                   ` (4 preceding siblings ...)
  2022-09-19  8:01 ` [PATCH 5/9] net: efi-snp: Allocate own receive buffer Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  2022-09-19  8:01 ` [PATCH 7/9] net: smc911x: " Sascha Hauer
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Use a driver private buffer as network receive buffer rather than the
globally allocated ones which will be removed soon.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/smc91111.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index d503535c25..3b23bfedfd 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -446,6 +446,7 @@ struct smc91c111_priv {
 	int revision;
 	unsigned int control_setup;
 	unsigned int config_setup;
+	void *rx_buf;
 };
 
 #if (SMC_DEBUG > 2 )
@@ -1302,14 +1303,14 @@ static int smc91c111_eth_rx(struct eth_device *edev)
 		   to send the DWORDs or the bytes first, or some
 		   mixture.  A mixture might improve already slow PIO
 		   performance	*/
-		SMC_insl(priv, SMC91111_DATA_REG , NetRxPackets[0],
+		SMC_insl(priv, SMC91111_DATA_REG , priv->rx_buf,
 				packet_length >> 2);
 		/* read the left over bytes */
 		if (packet_length & 3) {
 			int i;
 
 			unsigned char *tail =
-					(unsigned char *)(NetRxPackets[0] +
+					(unsigned char *)(priv->rx_buf +
 					(packet_length & ~3));
 			unsigned long leftover = SMC_inl(priv,
 					SMC91111_DATA_REG);
@@ -1320,7 +1321,7 @@ static int smc91c111_eth_rx(struct eth_device *edev)
 
 #if	SMC_DEBUG > 2
 		printf("Receiving Packet\n");
-		print_packet( NetRxPackets[0], packet_length );
+		print_packet(priv->rx_buf, packet_length );
 #endif
 	} else {
 		/* error ... */
@@ -1343,7 +1344,7 @@ static int smc91c111_eth_rx(struct eth_device *edev)
 
 	if (!is_error) {
 		/* Pass the packet up to the protocol layers. */
-		net_receive(edev, NetRxPackets[0], packet_length);
+		net_receive(edev, priv->rx_buf, packet_length);
 		return 0;
 	}
 
@@ -1445,6 +1446,7 @@ static int smc91c111_probe(struct device_d *dev)
 
 	priv = edev->priv;
 	priv->a = access_via_32bit;
+	priv->rx_buf = xmalloc(PKTSIZE);
 
 	if (dev->platform_data) {
 		struct smc91c111_pdata *pdata = dev->platform_data;
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 7/9] net: smc911x: Allocate own receive buffer
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
                   ` (5 preceding siblings ...)
  2022-09-19  8:01 ` [PATCH 6/9] net: smc91111: " Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  2022-09-19  8:01 ` [PATCH 8/9] net: ks8851_mll: " Sascha Hauer
  2022-09-19  8:01 ` [PATCH 9/9] net: remove altera_tse driver Sascha Hauer
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Use a driver private buffer as network receive buffer rather than the
globally allocated ones which will be removed soon.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/smc911x.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 1edc16ce44..7fd5c2aadb 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -32,6 +32,8 @@ struct smc911x_priv {
 	unsigned int using_extphy;
 	unsigned int phy_mask;
 
+	void *rx_buf;
+
 	u32 (*reg_read)(struct smc911x_priv *priv, u32 reg);
 	void (*reg_write)(struct smc911x_priv *priv, u32 reg, u32 val);
 };
@@ -447,7 +449,7 @@ static void smc911x_eth_halt(struct eth_device *edev)
 static int smc911x_eth_rx(struct eth_device *edev)
 {
 	struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv;
-	u32 *data = (u32 *)NetRxPackets[0];
+	u32 *data = priv->rx_buf;
 	u32 pktlen, tmplen;
 	u32 status;
 
@@ -465,7 +467,7 @@ static int smc911x_eth_rx(struct eth_device *edev)
 			dev_err(&edev->dev, "dropped bad packet. Status: 0x%08x\n",
 				status);
 		else
-			net_receive(edev, NetRxPackets[0], pktlen);
+			net_receive(edev, priv->rx_buf, pktlen);
 	}
 
 	return 0;
@@ -608,6 +610,8 @@ static int smc911x_probe(struct device_d *dev)
 	dev_info(dev, "LAN911x identified, idrev: 0x%08X, generation: %d\n",
 		   val, priv->generation);
 
+	priv->rx_buf = xmalloc(PKTSIZE);
+
 	edev = &priv->edev;
 	edev->priv = priv;
 
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 8/9] net: ks8851_mll: Allocate own receive buffer
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
                   ` (6 preceding siblings ...)
  2022-09-19  8:01 ` [PATCH 7/9] net: smc911x: " Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  2022-09-19  8:01 ` [PATCH 9/9] net: remove altera_tse driver Sascha Hauer
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

Use a driver private buffer as network receive buffer rather than the
globally allocated ones which will be removed soon.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/ks8851_mll.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index b037e19633..7609623ad1 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -366,6 +366,7 @@ struct ks_net {
 	void __iomem		*hw_addr_cmd;
 	struct platform_device	*pdev;
 	int			bus_width;
+	void			*rx_buf;
 };
 
 #define BE3             0x8000      /* Byte Enable 3 */
@@ -659,7 +660,6 @@ static void ks_setup(struct ks_net *ks)
 static int ks8851_rx_frame(struct ks_net *ks)
 {
 	struct device_d *dev = &ks->edev.dev;
-	u16 *rdptr = (u16 *) NetRxPackets[0];
 	u16 RxStatus, RxLen = 0;
 	u16 tmp_rxqcr;
 
@@ -679,14 +679,14 @@ static int ks8851_rx_frame(struct ks_net *ks)
 	tmp_rxqcr = ks_rdreg16(ks, KS_RXQCR);
 	ks_wrreg16(ks, KS_RXQCR, tmp_rxqcr | RXQCR_SDA);
 	/* read 2 bytes for dummy, 2 for status, 2 for len*/
-	ks_inblk(ks, rdptr, 2 + 2 + 2);
-	ks_inblk(ks, rdptr, ALIGN(RxLen, 4));
+	ks_inblk(ks, ks->rx_buf, 2 + 2 + 2);
+	ks_inblk(ks, ks->rx_buf, ALIGN(RxLen, 4));
 	ks_wrreg16(ks, KS_RXQCR, tmp_rxqcr);
 
 	if (RxStatus & RXFSHR_RXFV) {
 		/* Pass to upper layer */
 		dev_dbg(dev, "passing packet to upper layer\n\n");
-		net_receive(&ks->edev, NetRxPackets[0], RxLen);
+		net_receive(&ks->edev, ks->rx_buf, RxLen);
 		return RxLen;
 	} else if (RxStatus & RXFSHR_ERR) {
 		dev_err(dev, "RxStatus error 0x%04x\n", RxStatus & RXFSHR_ERR);
@@ -827,6 +827,7 @@ static int ks8851_probe(struct device_d *dev)
 	ks->hw_addr_cmd = IOMEM(iores->start);
 
 	ks->bus_width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
+	ks->rx_buf = xmalloc(PKTSIZE);
 
 	edev->init = ks8851_init_dev;
 	edev->open = ks8851_eth_open;
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 9/9] net: remove altera_tse driver
  2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
                   ` (7 preceding siblings ...)
  2022-09-19  8:01 ` [PATCH 8/9] net: ks8851_mll: " Sascha Hauer
@ 2022-09-19  8:01 ` Sascha Hauer
  8 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2022-09-19  8:01 UTC (permalink / raw)
  To: Barebox List

The driver is unused throughout the tree and isn't compiled in any
defconfig. Remove it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/Kconfig      |  16 --
 drivers/net/Makefile     |   1 -
 drivers/net/altera_tse.c | 563 ---------------------------------------
 drivers/net/altera_tse.h | 296 --------------------
 4 files changed, 876 deletions(-)
 delete mode 100644 drivers/net/altera_tse.c
 delete mode 100644 drivers/net/altera_tse.h

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 27d0c4ec8b..84a01c5328 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -283,22 +283,6 @@ config DRIVER_NET_AG71XX
 	help
 	  This option enables support for Atheros AG71XX ethernet chip.
 
-config DRIVER_NET_TSE
-	depends on NIOS2
-	bool "Altera TSE ethernet driver"
-	select PHYLIB
-	help
-	  This option enables support for the Altera TSE MAC.
-
-config TSE_USE_DEDICATED_DESC_MEM
-	depends on DRIVER_NET_TSE
-	bool "Altera TSE uses dedicated descriptor memory"
-	help
-	  This option tells the TSE driver to use an onchip memory
-	  to store SGDMA descriptors. Descriptor memory is not
-	  reserved with a malloc but directly mapped to the memory
-	  address (defined in config.h)
-
 config DRIVER_NET_LITEETH
 	bool "LiteX ethernet driver"
 	select PHYLIB
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index a3eb10d1df..47ad749943 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -39,7 +39,6 @@ obj-$(CONFIG_DRIVER_NET_SJA1105)	+= sja1105.o
 obj-$(CONFIG_DRIVER_NET_SMC911X)	+= smc911x.o
 obj-$(CONFIG_DRIVER_NET_SMC91111)	+= smc91111.o
 obj-$(CONFIG_DRIVER_NET_TAP)		+= tap.o
-obj-$(CONFIG_DRIVER_NET_TSE)		+= altera_tse.o
 obj-$(CONFIG_DRIVER_NET_EFI_SNP)	+= efi-snp.o
 obj-$(CONFIG_DRIVER_NET_VIRTIO)		+= virtio.o
 obj-$(CONFIG_DRIVER_NET_AG71XX)		+= ag71xx.o
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
deleted file mode 100644
index f1dfe5952c..0000000000
--- a/drivers/net/altera_tse.c
+++ /dev/null
@@ -1,563 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Altera TSE Network driver
- *
- * Copyright (C) 2008 Altera Corporation.
- * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
- * Copyright (C) 2011 Franck JULLIEN, <elec4fun@gmail.com>
- */
-
-#include <common.h>
-#include <dma.h>
-#include <net.h>
-#include <init.h>
-#include <clock.h>
-#include <linux/mii.h>
-#include <linux/phy.h>
-#include <linux/err.h>
-
-#include <io.h>
-#include <asm/dma-mapping.h>
-
-#include "altera_tse.h"
-
-/* This is a generic routine that the SGDMA mode-specific routines
- * call to populate a descriptor.
- * arg1     :pointer to first SGDMA descriptor.
- * arg2     :pointer to next  SGDMA descriptor.
- * arg3     :Address to where data to be written.
- * arg4     :Address from where data to be read.
- * arg5     :no of byte to transaction.
- * arg6     :variable indicating to generate start of packet or not
- * arg7     :read fixed
- * arg8     :write fixed
- * arg9     :read burst
- * arg10    :write burst
- * arg11    :atlantic_channel number
- */
-static void alt_sgdma_construct_descriptor_burst(
-	struct alt_sgdma_descriptor *desc,
-	struct alt_sgdma_descriptor *next,
-	uint32_t *read_addr,
-	uint32_t *write_addr,
-	uint16_t length_or_eop,
-	uint8_t generate_eop,
-	uint8_t read_fixed,
-	uint8_t write_fixed_or_sop,
-	uint8_t read_burst,
-	uint8_t write_burst,
-	uint8_t atlantic_channel)
-{
-	uint32_t temp;
-
-	/*
-	 * Mark the "next" descriptor as "not" owned by hardware. This prevents
-	 * The SGDMA controller from continuing to process the chain. This is
-	 * done as a single IO write to bypass cache, without flushing
-	 * the entire descriptor, since only the 8-bit descriptor status must
-	 * be flushed.
-	 */
-	if (!next)
-		printf("Next descriptor not defined!!\n");
-
-	temp = readb(&next->descriptor_control);
-	writeb(temp & ~ALT_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK,
-		&next->descriptor_control);
-
-	writel((uint32_t)read_addr, &desc->source);
-	writel((uint32_t)write_addr, &desc->destination);
-	writel((uint32_t)next, &desc->next);
-
-	writel(0, &desc->source_pad);
-	writel(0, &desc->destination_pad);
-	writel(0, &desc->next_pad);
-	writew(length_or_eop, &desc->bytes_to_transfer);
-	writew(0, &desc->actual_bytes_transferred);
-	writeb(0, &desc->descriptor_status);
-
-	/* SGDMA burst not currently supported */
-	writeb(0, &desc->read_burst);
-	writeb(0, &desc->write_burst);
-
-	/*
-	 * Set the descriptor control block as follows:
-	 * - Set "owned by hardware" bit
-	 * - Optionally set "generate EOP" bit
-	 * - Optionally set the "read from fixed address" bit
-	 * - Optionally set the "write to fixed address bit (which serves
-	 *   serves as a "generate SOP" control bit in memory-to-stream mode).
-	 * - Set the 4-bit atlantic channel, if specified
-	 *
-	 * Note this step is performed after all other descriptor information
-	 * has been filled out so that, if the controller already happens to be
-	 * pointing at this descriptor, it will not run (via the "owned by
-	 * hardware" bit) until all other descriptor has been set up.
-	 */
-
-	writeb((ALT_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK) |
-		(generate_eop ? ALT_SGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_MSK : 0) |
-		(read_fixed ? ALT_SGDMA_DESCRIPTOR_CONTROL_READ_FIXED_ADDRESS_MSK : 0) |
-		(write_fixed_or_sop ? ALT_SGDMA_DESCRIPTOR_CONTROL_WRITE_FIXED_ADDRESS_MSK : 0) |
-		(atlantic_channel ? ((atlantic_channel & 0x0F) << 3) : 0),
-		&desc->descriptor_control);
-}
-
-static int alt_sgdma_do_sync_transfer(struct alt_sgdma_registers *dev,
-					struct alt_sgdma_descriptor *desc)
-{
-	uint32_t temp;
-	uint64_t start;
-	uint64_t tout;
-
-	/* Wait for any pending transfers to complete */
-	tout = ALT_TSE_SGDMA_BUSY_WATCHDOG_TOUT * MSECOND;
-
-	start = get_time_ns();
-
-	while (readl(&dev->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
-		if (is_timeout(start, tout)) {
-			debug("Timeout waiting sgdma in do sync!\n");
-			break;
-		}
-	}
-
-	/*
-	 * Clear any (previous) status register information
-	 * that might occlude our error checking later.
-	 */
-	writel(0xFF, &dev->status);
-
-	/* Point the controller at the descriptor */
-	writel((uint32_t)desc, &dev->next_descriptor_pointer);
-	debug("next desc in sgdma 0x%x\n", (uint32_t)dev->next_descriptor_pointer);
-
-	/*
-	 * Set up SGDMA controller to:
-	 * - Disable interrupt generation
-	 * - Run once a valid descriptor is written to controller
-	 * - Stop on an error with any particular descriptor
-	 */
-	writel(ALT_SGDMA_CONTROL_RUN_MSK | ALT_SGDMA_CONTROL_STOP_DMA_ER_MSK,
-		&dev->control);
-
-	/* Wait for the descriptor (chain) to complete */
-	debug("wait for sgdma....");
-	start = get_time_ns();
-
-	while (readl(&dev->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
-		if (is_timeout(start, tout)) {
-			debug("Timeout waiting sgdma in do sync!\n");
-			break;
-		}
-	}
-
-	debug("done\n");
-
-	/* Clear Run */
-	temp = readl(&dev->control);
-	writel(temp & ~ALT_SGDMA_CONTROL_RUN_MSK, &dev->control);
-
-	/* Get & clear status register contents */
-	debug("tx sgdma status = 0x%x", readl(&dev->status));
-	writel(0xFF, &dev->status);
-
-	return 0;
-}
-
-static int alt_sgdma_do_async_transfer(struct alt_sgdma_registers *dev,
-					struct alt_sgdma_descriptor *desc)
-{
-	uint64_t start;
-	uint64_t tout;
-
-	/* Wait for any pending transfers to complete */
-	tout = ALT_TSE_SGDMA_BUSY_WATCHDOG_TOUT * MSECOND;
-
-	start = get_time_ns();
-
-	while (readl(&dev->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
-		if (is_timeout(start, tout)) {
-			debug("Timeout waiting sgdma in do async!\n");
-			break;
-		}
-	}
-
-	/*
-	 * Clear any (previous) status register information
-	 * that might occlude our error checking later.
-	 */
-	writel(0xFF, &dev->status);
-
-	/* Point the controller at the descriptor */
-	writel((uint32_t)desc, &dev->next_descriptor_pointer);
-
-	/*
-	 * Set up SGDMA controller to:
-	 * - Disable interrupt generation
-	 * - Run once a valid descriptor is written to controller
-	 * - Stop on an error with any particular descriptor
-	 */
-	writel(ALT_SGDMA_CONTROL_RUN_MSK | ALT_SGDMA_CONTROL_STOP_DMA_ER_MSK,
-		&dev->control);
-
-	return 0;
-}
-
-static int tse_get_ethaddr(struct eth_device *edev, unsigned char *m)
-{
-	struct altera_tse_priv *priv = edev->priv;
-	struct alt_tse_mac *mac_dev = priv->tse_regs;
-
-	m[5] = (readl(&mac_dev->mac_addr_1) >> 8)  && 0xFF;
-	m[4] = (readl(&mac_dev->mac_addr_1))       && 0xFF;
-	m[3] = (readl(&mac_dev->mac_addr_0) >> 24) && 0xFF;
-	m[2] = (readl(&mac_dev->mac_addr_0) >> 16) && 0xFF;
-	m[1] = (readl(&mac_dev->mac_addr_0) >>  8) && 0xFF;
-	m[0] = (readl(&mac_dev->mac_addr_0))       && 0xFF;
-
-	return 0;
-}
-
-static int tse_set_ethaddr(struct eth_device *edev, const unsigned char *m)
-{
-	struct altera_tse_priv *priv = edev->priv;
-	struct alt_tse_mac *mac_dev = priv->tse_regs;
-
-	debug("Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n",
-		m[0], m[1], m[2], m[3], m[4], m[5]);
-
-	writel(m[3] << 24 | m[2] << 16 | m[1] << 8 | m[0], &mac_dev->mac_addr_0);
-	writel((m[5] << 8 | m[4]) & 0xFFFF, &mac_dev->mac_addr_1);
-
-	return 0;
-}
-
-static int tse_phy_read(struct mii_bus *bus, int phy_addr, int reg)
-{
-	struct altera_tse_priv *priv = bus->priv;
-	struct alt_tse_mac *mac_dev = priv->tse_regs;
-	uint32_t *mdio_regs;
-
-	writel(phy_addr, &mac_dev->mdio_phy1_addr);
-
-	mdio_regs = (uint32_t *)&mac_dev->mdio_phy1;
-
-	return readl(&mdio_regs[reg]) & 0xFFFF;
-}
-
-static int tse_phy_write(struct mii_bus *bus, int phy_addr, int reg, u16 val)
-{
-	struct altera_tse_priv *priv = bus->priv;
-	struct alt_tse_mac *mac_dev = priv->tse_regs;
-	uint32_t *mdio_regs;
-
-	writel(phy_addr, &mac_dev->mdio_phy1_addr);
-
-	mdio_regs = (uint32_t *)&mac_dev->mdio_phy1;
-
-	writel((uint32_t)val, &mdio_regs[reg]);
-
-	return 0;
-}
-
-static void tse_reset(struct eth_device *edev)
-{
-	/* stop sgdmas, disable tse receive */
-	struct altera_tse_priv *priv = edev->priv;
-	struct alt_tse_mac *mac_dev = priv->tse_regs;
-	struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx_regs;
-	struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx_regs;
-	struct alt_sgdma_descriptor *rx_desc = priv->rx_desc;
-	struct alt_sgdma_descriptor *tx_desc = priv->tx_desc;
-	uint64_t start;
-	uint64_t tout;
-
-	tout = ALT_TSE_SGDMA_BUSY_WATCHDOG_TOUT * MSECOND;
-
-	/* clear rx desc & wait for sgdma to complete */
-	writeb(0, &rx_desc->descriptor_control);
-	writel(0, &rx_sgdma->control);
-
-	writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &rx_sgdma->control);
-	writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &rx_sgdma->control);
-	mdelay(100);
-
-	start = get_time_ns();
-
-	while (readl(&rx_sgdma->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
-		if (is_timeout(start, tout)) {
-			printf("Timeout waiting for rx sgdma!\n");
-			writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &rx_sgdma->control);
-			writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &rx_sgdma->control);
-			break;
-		}
-	}
-
-	/* clear tx desc & wait for sgdma to complete */
-	writeb(0, &tx_desc->descriptor_control);
-	writel(0, &tx_sgdma->control);
-
-	writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control);
-	writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control);
-	mdelay(100);
-
-	start = get_time_ns();
-
-	while (readl(&tx_sgdma->status) & ALT_SGDMA_STATUS_BUSY_MSK) {
-		if (is_timeout(start, tout)) {
-			printf("Timeout waiting for tx sgdma!\n");
-			writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control);
-			writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control);
-			break;
-		}
-	}
-
-	/* reset the mac */
-	writel(ALTERA_TSE_CMD_TX_ENA_MSK | ALTERA_TSE_CMD_RX_ENA_MSK |
-		ALTERA_TSE_CMD_SW_RESET_MSK, &mac_dev->command_config);
-
-	start = get_time_ns();
-	tout = ALT_TSE_SW_RESET_WATCHDOG_TOUT * MSECOND;
-
-	while (readl(&mac_dev->command_config) & ALTERA_TSE_CMD_SW_RESET_MSK) {
-		if (is_timeout(start, tout)) {
-			printf("TSEMAC SW reset bit never cleared!\n");
-			break;
-		}
-	}
-}
-
-static int tse_eth_open(struct eth_device *edev)
-{
-	struct altera_tse_priv *priv = edev->priv;
-	int ret;
-
-	ret = phy_device_connect(edev, priv->miibus, priv->phy_addr, NULL, 0,
-				 PHY_INTERFACE_MODE_NA);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static int tse_eth_send(struct eth_device *edev, void *packet, int length)
-{
-
-	struct altera_tse_priv *priv = edev->priv;
-	struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx_regs;
-	struct alt_sgdma_descriptor *tx_desc = priv->tx_desc;
-	struct alt_sgdma_descriptor *tx_desc_cur = tx_desc;
-
-	flush_dcache_range((uint32_t)packet, (uint32_t)packet + length);
-	alt_sgdma_construct_descriptor_burst(
-		(struct alt_sgdma_descriptor *)&tx_desc[0],
-		(struct alt_sgdma_descriptor *)&tx_desc[1],
-		(uint32_t *)packet,	/* read addr */
-		(uint32_t *)0,		/*           */
-		length,			/* length or EOP ,will change for each tx */
-		0x1,			/* gen eop */
-		0x0,			/* read fixed */
-		0x1,			/* write fixed or sop */
-		0x0,			/* read burst */
-		0x0,			/* write burst */
-		0x0			/* channel */
-		);
-
-	alt_sgdma_do_sync_transfer(tx_sgdma, tx_desc_cur);
-
-	return 0;
-}
-
-static void tse_eth_halt(struct eth_device *edev)
-{
-	struct altera_tse_priv *priv = edev->priv;
-	struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx_regs;
-	struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx_regs;
-
-	writel(0, &rx_sgdma->control); /* Stop the controller and reset settings */
-	writel(0, &tx_sgdma->control); /* Stop the controller and reset settings */
-}
-
-static int tse_eth_rx(struct eth_device *edev)
-{
-	uint16_t packet_length = 0;
-
-	struct altera_tse_priv *priv = edev->priv;
-	struct alt_sgdma_descriptor *rx_desc = priv->rx_desc;
-	struct alt_sgdma_descriptor *rx_desc_cur = rx_desc;
-	struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx_regs;
-
-	if (rx_desc_cur->descriptor_status &
-		ALT_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK) {
-
-		packet_length = rx_desc->actual_bytes_transferred;
-		net_receive(edev, NetRxPackets[0], packet_length);
-
-		/* Clear Run */
-		rx_sgdma->control = (rx_sgdma->control & (~ALT_SGDMA_CONTROL_RUN_MSK));
-
-		/* start descriptor again */
-		flush_dcache_range((uint32_t)(NetRxPackets[0]), (uint32_t)(NetRxPackets[0]) + PKTSIZE);
-		alt_sgdma_construct_descriptor_burst(
-			(struct alt_sgdma_descriptor *)&rx_desc[0],
-			(struct alt_sgdma_descriptor *)&rx_desc[1],
-			(uint32_t)0x0,			/* read addr */
-			(uint32_t *)NetRxPackets[0],	/*           */
-			0x0,				/* length or EOP */
-			0x0,				/* gen eop */
-			0x0,				/* read fixed */
-			0x0,				/* write fixed or sop */
-			0x0,				/* read burst */
-			0x0,				/* write burst */
-			0x0				/* channel */
-		);
-
-		/* setup the sgdma */
-		alt_sgdma_do_async_transfer(priv->sgdma_rx_regs, rx_desc);
-	}
-
-	return 0;
-}
-
-static int tse_init_dev(struct eth_device *edev)
-{
-	struct altera_tse_priv *priv = edev->priv;
-	struct alt_tse_mac *mac_dev = priv->tse_regs;
-	struct alt_sgdma_descriptor *tx_desc = priv->tx_desc;
-	struct alt_sgdma_descriptor *rx_desc = priv->rx_desc;
-	struct alt_sgdma_descriptor *rx_desc_cur;
-
-	rx_desc_cur = rx_desc;
-
-	tse_reset(edev);
-
-	/* need to create sgdma */
-	alt_sgdma_construct_descriptor_burst(
-		(struct alt_sgdma_descriptor *)&tx_desc[0],
-		(struct alt_sgdma_descriptor *)&tx_desc[1],
-		(uint32_t *)NULL,	/* read addr */
-		(uint32_t *)0,		/*           */
-		0,			/* length or EOP ,will change for each tx */
-		0x1,			/* gen eop */
-		0x0,			/* read fixed */
-		0x1,			/* write fixed or sop */
-		0x0,			/* read burst */
-		0x0,			/* write burst */
-		0x0			/* channel */
-		);
-
-	flush_dcache_range((uint32_t)(NetRxPackets[0]), (uint32_t)(NetRxPackets[0]) + PKTSIZE);
-	alt_sgdma_construct_descriptor_burst(
-		(struct alt_sgdma_descriptor *)&rx_desc[0],
-		(struct alt_sgdma_descriptor *)&rx_desc[1],
-		(uint32_t)0x0,			/* read addr */
-		(uint32_t *)NetRxPackets[0],	/*           */
-		0x0,				/* length or EOP */
-		0x0,				/* gen eop */
-		0x0,				/* read fixed */
-		0x0,				/* write fixed or sop */
-		0x0,				/* read burst */
-		0x0,				/* write burst */
-		0x0				/* channel */
-		);
-
-	/* start rx async transfer */
-	alt_sgdma_do_async_transfer(priv->sgdma_rx_regs, rx_desc_cur);
-
-	/* Initialize MAC registers */
-	writel(PKTSIZE, &mac_dev->max_frame_length);
-
-	/* NO Shift */
-	writel(0, &mac_dev->rx_cmd_stat);
-	writel(0, &mac_dev->tx_cmd_stat);
-
-	/* enable MAC */
-	writel(ALTERA_TSE_CMD_TX_ENA_MSK | ALTERA_TSE_CMD_RX_ENA_MSK, &mac_dev->command_config);
-
-	return 0;
-}
-
-static int tse_probe(struct device_d *dev)
-{
-	struct resource *iores;
-	struct altera_tse_priv *priv;
-	struct mii_bus *miibus;
-	struct eth_device *edev;
-	struct alt_sgdma_descriptor *rx_desc;
-	struct alt_sgdma_descriptor *tx_desc;
-#ifndef CONFIG_TSE_USE_DEDICATED_DESC_MEM
-	uint32_t dma_handle;
-#endif
-	edev = xzalloc(sizeof(struct eth_device));
-	priv = xzalloc(sizeof(struct altera_tse_priv));
-	miibus = xzalloc(sizeof(struct mii_bus));
-
-	edev->priv = priv;
-
-	edev->init = tse_init_dev;
-	edev->open = tse_eth_open;
-	edev->send = tse_eth_send;
-	edev->recv = tse_eth_rx;
-	edev->halt = tse_eth_halt;
-	edev->get_ethaddr = tse_get_ethaddr;
-	edev->set_ethaddr = tse_set_ethaddr;
-	edev->parent = dev;
-
-#ifdef CONFIG_TSE_USE_DEDICATED_DESC_MEM
-	iores = dev_request_mem_resource(dev, 3);
-	if (IS_ERR(iores))
-		return PTR_ERR(iores);
-	tx_desc = IOMEM(iores->start);
-	rx_desc = tx_desc + 2;
-#else
-	tx_desc = dma_alloc_coherent(sizeof(*tx_desc) * (3 + PKTBUFSRX), (dma_addr_t *)&dma_handle);
-	rx_desc = tx_desc + 2;
-
-	if (!tx_desc) {
-		free(edev);
-		free(miibus);
-		return 0;
-	}
-#endif
-
-	memset(rx_desc, 0, (sizeof *rx_desc) * (PKTBUFSRX + 1));
-	memset(tx_desc, 0, (sizeof *tx_desc) * 2);
-
-	iores = dev_request_mem_resource(dev, 0);
-	if (IS_ERR(iores))
-		return PTR_ERR(iores);
-	priv->tse_regs = IOMEM(iores->start);
-	iores = dev_request_mem_resource(dev, 1);
-	if (IS_ERR(iores))
-		return PTR_ERR(iores);
-	priv->sgdma_rx_regs = IOMEM(iores->start);
-
-	iores = dev_request_mem_resource(dev, 2);
-	if (IS_ERR(iores))
-		return PTR_ERR(iores);
-	priv->sgdma_tx_regs = IOMEM(iores->start);
-	priv->rx_desc = rx_desc;
-	priv->tx_desc = tx_desc;
-
-	priv->miibus = miibus;
-
-	miibus->read = tse_phy_read;
-	miibus->write = tse_phy_write;
-	miibus->priv = priv;
-	miibus->parent = dev;
-
-	if (dev->platform_data != NULL)
-		priv->phy_addr = *((int8_t *)(dev->platform_data));
-	else
-		priv->phy_addr = -1;
-
-	mdiobus_register(miibus);
-
-	return eth_register(edev);
-}
-
-static struct driver_d altera_tse_driver = {
-	.name = "altera_tse",
-	.probe = tse_probe,
-};
-device_platform_driver(altera_tse_driver);
diff --git a/drivers/net/altera_tse.h b/drivers/net/altera_tse.h
deleted file mode 100644
index 7bff14de81..0000000000
--- a/drivers/net/altera_tse.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Altera 10/100/1000 triple speed ethernet mac
- *
- * Copyright (C) 2008 Altera Corporation.
- * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
- * Copyright (C) 2011 Franck JULLIEN <elec4fun@gmail.com>
- */
-#ifndef _ALTERA_TSE_H_
-#define _ALTERA_TSE_H_
-
-/* SGDMA Stuff */
-#define ALT_SGDMA_STATUS_ERROR_MSK			(0x00000001)
-#define ALT_SGDMA_STATUS_EOP_ENCOUNTERED_MSK		(0x00000002)
-#define ALT_SGDMA_STATUS_DESC_COMPLETED_MSK		(0x00000004)
-#define ALT_SGDMA_STATUS_CHAIN_COMPLETED_MSK		(0x00000008)
-#define ALT_SGDMA_STATUS_BUSY_MSK			(0x00000010)
-
-#define ALT_SGDMA_CONTROL_IE_ERROR_MSK			(0x00000001)
-#define ALT_SGDMA_CONTROL_IE_EOP_ENCOUNTERED_MSK	(0x00000002)
-#define ALT_SGDMA_CONTROL_IE_DESC_COMPLETED_MSK		(0x00000004)
-#define ALT_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK	(0x00000008)
-#define ALT_SGDMA_CONTROL_IE_GLOBAL_MSK			(0x00000010)
-#define ALT_SGDMA_CONTROL_RUN_MSK			(0x00000020)
-#define ALT_SGDMA_CONTROL_STOP_DMA_ER_MSK		(0x00000040)
-#define ALT_SGDMA_CONTROL_IE_MAX_DESC_PROCESSED_MSK	(0x00000080)
-#define ALT_SGDMA_CONTROL_MAX_DESC_PROCESSED_MSK	(0x0000FF00)
-#define ALT_SGDMA_CONTROL_SOFTWARERESET_MSK		(0x00010000)
-#define ALT_SGDMA_CONTROL_PARK_MSK			(0x00020000)
-#define ALT_SGDMA_CONTROL_CLEAR_INTERRUPT_MSK		(0x80000000)
-
-#define ALTERA_TSE_SGDMA_INTR_MASK  (ALT_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK \
-			| ALT_SGDMA_STATUS_DESC_COMPLETED_MSK \
-			| ALT_SGDMA_CONTROL_IE_GLOBAL_MSK)
-
-/*
- * Descriptor control bit masks & offsets
- *
- * Note: The control byte physically occupies bits [31:24] in memory.
- *	 The following bit-offsets are expressed relative to the LSB of
- *	 the control register bitfield.
- */
-#define ALT_SGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_MSK		(0x00000001)
-#define ALT_SGDMA_DESCRIPTOR_CONTROL_READ_FIXED_ADDRESS_MSK	(0x00000002)
-#define ALT_SGDMA_DESCRIPTOR_CONTROL_WRITE_FIXED_ADDRESS_MSK	(0x00000004)
-#define ALT_SGDMA_DESCRIPTOR_CONTROL_ATLANTIC_CHANNEL_MSK	(0x00000008)
-#define ALT_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK		(0x00000080)
-
-/*
- * Descriptor status bit masks & offsets
- *
- * Note: The status byte physically occupies bits [23:16] in memory.
- *	 The following bit-offsets are expressed relative to the LSB of
- *	 the status register bitfield.
- */
-#define ALT_SGDMA_DESCRIPTOR_STATUS_E_CRC_MSK			(0x00000001)
-#define ALT_SGDMA_DESCRIPTOR_STATUS_E_PARITY_MSK		(0x00000002)
-#define ALT_SGDMA_DESCRIPTOR_STATUS_E_OVERFLOW_MSK		(0x00000004)
-#define ALT_SGDMA_DESCRIPTOR_STATUS_E_SYNC_MSK			(0x00000008)
-#define ALT_SGDMA_DESCRIPTOR_STATUS_E_UEOP_MSK			(0x00000010)
-#define ALT_SGDMA_DESCRIPTOR_STATUS_E_MEOP_MSK			(0x00000020)
-#define ALT_SGDMA_DESCRIPTOR_STATUS_E_MSOP_MSK			(0x00000040)
-#define ALT_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK	(0x00000080)
-#define ALT_SGDMA_DESCRIPTOR_STATUS_ERROR_MSK			(0x0000007F)
-
-/*
- * The SGDMA controller buffer descriptor allocates
- * 64 bits for each address. To support ANSI C, the
- * struct implementing a descriptor places 32-bits
- * of padding directly above each address; each pad must
- * be cleared when initializing a descriptor.
- */
-
-/*
- * Buffer Descriptor data structure
- *
- */
-struct alt_sgdma_descriptor {
-	unsigned int *source;           /* the address of data to be read. */
-	unsigned int source_pad;
-
-	unsigned int *destination;     /* the address to write data */
-	unsigned int destination_pad;
-
-	unsigned int *next;            /* the next descriptor in the list. */
-	unsigned int next_pad;
-
-	unsigned short bytes_to_transfer; /* the number of bytes to transfer */
-	unsigned char read_burst;
-	unsigned char write_burst;
-
-	unsigned short actual_bytes_transferred;/* bytes transferred by DMA */
-	unsigned char descriptor_status;
-	unsigned char descriptor_control;
-
-} __attribute__ ((packed, aligned(1)));
-
-/* SG-DMA Control/Status Slave registers map */
-
-struct alt_sgdma_registers {
-	unsigned int status;
-	unsigned int status_pad[3];
-	unsigned int control;
-	unsigned int control_pad[3];
-	unsigned int next_descriptor_pointer;
-	unsigned int descriptor_pad[3];
-};
-
-/* TSE Stuff */
-#define ALTERA_TSE_CMD_TX_ENA_MSK		(0x00000001)
-#define ALTERA_TSE_CMD_RX_ENA_MSK		(0x00000002)
-#define ALTERA_TSE_CMD_XON_GEN_MSK		(0x00000004)
-#define ALTERA_TSE_CMD_ETH_SPEED_MSK		(0x00000008)
-#define ALTERA_TSE_CMD_PROMIS_EN_MSK		(0x00000010)
-#define ALTERA_TSE_CMD_PAD_EN_MSK		(0x00000020)
-#define ALTERA_TSE_CMD_CRC_FWD_MSK		(0x00000040)
-#define ALTERA_TSE_CMD_PAUSE_FWD_MSK		(0x00000080)
-#define ALTERA_TSE_CMD_PAUSE_IGNORE_MSK		(0x00000100)
-#define ALTERA_TSE_CMD_TX_ADDR_INS_MSK		(0x00000200)
-#define ALTERA_TSE_CMD_HD_ENA_MSK		(0x00000400)
-#define ALTERA_TSE_CMD_EXCESS_COL_MSK		(0x00000800)
-#define ALTERA_TSE_CMD_LATE_COL_MSK		(0x00001000)
-#define ALTERA_TSE_CMD_SW_RESET_MSK		(0x00002000)
-#define ALTERA_TSE_CMD_MHASH_SEL_MSK		(0x00004000)
-#define ALTERA_TSE_CMD_LOOPBACK_MSK		(0x00008000)
-/* Bits (18:16) = address select */
-#define ALTERA_TSE_CMD_TX_ADDR_SEL_MSK		(0x00070000)
-#define ALTERA_TSE_CMD_MAGIC_ENA_MSK		(0x00080000)
-#define ALTERA_TSE_CMD_SLEEP_MSK		(0x00100000)
-#define ALTERA_TSE_CMD_WAKEUP_MSK		(0x00200000)
-#define ALTERA_TSE_CMD_XOFF_GEN_MSK		(0x00400000)
-#define ALTERA_TSE_CMD_CNTL_FRM_ENA_MSK		(0x00800000)
-#define ALTERA_TSE_CMD_NO_LENGTH_CHECK_MSK	(0x01000000)
-#define ALTERA_TSE_CMD_ENA_10_MSK		(0x02000000)
-#define ALTERA_TSE_CMD_RX_ERR_DISC_MSK		(0x04000000)
-/* Bits (30..27) reserved */
-#define ALTERA_TSE_CMD_CNT_RESET_MSK		(0x80000000)
-
-#define ALTERA_TSE_TX_CMD_STAT_TX_SHIFT16	(0x00040000)
-#define ALTERA_TSE_TX_CMD_STAT_OMIT_CRC		(0x00020000)
-
-#define ALTERA_TSE_RX_CMD_STAT_RX_SHIFT16	(0x02000000)
-
-#define ALT_TSE_SW_RESET_WATCHDOG_CNTR		10000
-#define ALT_TSE_SGDMA_BUSY_WATCHDOG_CNTR	90000000
-
-#define ALT_TSE_SW_RESET_WATCHDOG_TOUT		1    /* ms */
-#define ALT_TSE_SGDMA_BUSY_WATCHDOG_TOUT	5    /* ms */
-
-struct alt_tse_mdio {
-	unsigned int control; /*PHY device operation control register */
-	unsigned int status;  /*PHY device operation status register */
-	unsigned int phy_id1; /*Bits 31:16 of PHY identifier. */
-	unsigned int phy_id2; /*Bits 15:0 of PHY identifier. */
-	unsigned int auto_negotiation_advertisement;
-	unsigned int remote_partner_base_page_ability;
-
-	unsigned int reg6;
-	unsigned int reg7;
-	unsigned int reg8;
-	unsigned int reg9;
-	unsigned int rega;
-	unsigned int regb;
-	unsigned int regc;
-	unsigned int regd;
-	unsigned int rege;
-	unsigned int regf;
-	unsigned int reg10;
-	unsigned int reg11;
-	unsigned int reg12;
-	unsigned int reg13;
-	unsigned int reg14;
-	unsigned int reg15;
-	unsigned int reg16;
-	unsigned int reg17;
-	unsigned int reg18;
-	unsigned int reg19;
-	unsigned int reg1a;
-	unsigned int reg1b;
-	unsigned int reg1c;
-	unsigned int reg1d;
-	unsigned int reg1e;
-	unsigned int reg1f;
-};
-
-/* MAC register Space */
-
-struct alt_tse_mac {
-	unsigned int megacore_revision;
-	unsigned int scratch_pad;
-	unsigned int command_config;
-	unsigned int mac_addr_0;
-	unsigned int mac_addr_1;
-	unsigned int max_frame_length;
-	unsigned int pause_quanta;
-	unsigned int rx_sel_empty_threshold;
-	unsigned int rx_sel_full_threshold;
-	unsigned int tx_sel_empty_threshold;
-	unsigned int tx_sel_full_threshold;
-	unsigned int rx_almost_empty_threshold;
-	unsigned int rx_almost_full_threshold;
-	unsigned int tx_almost_empty_threshold;
-	unsigned int tx_almost_full_threshold;
-	unsigned int mdio_phy0_addr;
-	unsigned int mdio_phy1_addr;
-
-	/* only if 100/1000 BaseX PCS, reserved otherwise */
-	unsigned int reservedx44[5];
-
-	unsigned int reg_read_access_status;
-	unsigned int min_tx_ipg_length;
-
-	/* IEEE 802.3 oEntity Managed Object Support */
-	unsigned int aMACID_1;	/*The MAC addresses */
-	unsigned int aMACID_2;
-	unsigned int aFramesTransmittedOK;
-	unsigned int aFramesReceivedOK;
-	unsigned int aFramesCheckSequenceErrors;
-	unsigned int aAlignmentErrors;
-	unsigned int aOctetsTransmittedOK;
-	unsigned int aOctetsReceivedOK;
-
-	/* IEEE 802.3 oPausedEntity Managed Object Support */
-	unsigned int aTxPAUSEMACCtrlFrames;
-	unsigned int aRxPAUSEMACCtrlFrames;
-
-	/* IETF MIB (MIB-II) Object Support */
-	unsigned int ifInErrors;
-	unsigned int ifOutErrors;
-	unsigned int ifInUcastPkts;
-	unsigned int ifInMulticastPkts;
-	unsigned int ifInBroadcastPkts;
-	unsigned int ifOutDiscards;
-	unsigned int ifOutUcastPkts;
-	unsigned int ifOutMulticastPkts;
-	unsigned int ifOutBroadcastPkts;
-
-	/* IETF RMON MIB Object Support */
-	unsigned int etherStatsDropEvent;
-	unsigned int etherStatsOctets;
-	unsigned int etherStatsPkts;
-	unsigned int etherStatsUndersizePkts;
-	unsigned int etherStatsOversizePkts;
-	unsigned int etherStatsPkts64Octets;
-	unsigned int etherStatsPkts65to127Octets;
-	unsigned int etherStatsPkts128to255Octets;
-	unsigned int etherStatsPkts256to511Octets;
-	unsigned int etherStatsPkts512to1023Octets;
-	unsigned int etherStatsPkts1024to1518Octets;
-
-	unsigned int etherStatsPkts1519toXOctets;
-	unsigned int etherStatsJabbers;
-	unsigned int etherStatsFragments;
-
-	unsigned int reservedxE4;
-
-	/*FIFO control register. */
-	unsigned int tx_cmd_stat;
-	unsigned int rx_cmd_stat;
-
-	unsigned int ipaccTxConf;
-	unsigned int ipaccRxConf;
-	unsigned int ipaccRxStat;
-	unsigned int ipaccRxStatSum;
-
-	/*Multicast address resolution table */
-	unsigned int hash_table[64];
-
-	/*Registers 0 to 31 within PHY device 0/1 */
-	struct alt_tse_mdio mdio_phy0;
-	struct alt_tse_mdio mdio_phy1;
-
-	/*4 Supplemental MAC Addresses */
-	unsigned int supp_mac_addr_0_0;
-	unsigned int supp_mac_addr_0_1;
-	unsigned int supp_mac_addr_1_0;
-	unsigned int supp_mac_addr_1_1;
-	unsigned int supp_mac_addr_2_0;
-	unsigned int supp_mac_addr_2_1;
-	unsigned int supp_mac_addr_3_0;
-	unsigned int supp_mac_addr_3_1;
-
-	unsigned int reservedx320[56];
-};
-
-struct altera_tse_priv {
-	void __iomem *tse_regs;
-	void __iomem *sgdma_rx_regs;
-	void __iomem *sgdma_tx_regs;
-	void __iomem *rx_desc;
-	void __iomem *tx_desc;
-	int phy_addr;
-	struct mii_bus *miibus;
-};
-
-#endif /* _ALTERA_TSE_H_ */
-- 
2.30.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-19  8:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19  8:01 [PATCH 0/9] Reduce usage of NetRxPackets[] Sascha Hauer
2022-09-19  8:01 ` [PATCH 1/9] net: tap: Allocate own receive buffer Sascha Hauer
2022-09-19  8:01 ` [PATCH 2/9] net: macb: " Sascha Hauer
2022-09-19  8:01 ` [PATCH 3/9] net: cs8900: " Sascha Hauer
2022-09-19  8:01 ` [PATCH 4/9] net: liteeth: Do not use NetRxPackets Sascha Hauer
2022-09-19  8:01 ` [PATCH 5/9] net: efi-snp: Allocate own receive buffer Sascha Hauer
2022-09-19  8:01 ` [PATCH 6/9] net: smc91111: " Sascha Hauer
2022-09-19  8:01 ` [PATCH 7/9] net: smc911x: " Sascha Hauer
2022-09-19  8:01 ` [PATCH 8/9] net: ks8851_mll: " Sascha Hauer
2022-09-19  8:01 ` [PATCH 9/9] net: remove altera_tse driver Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox