mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/7] net: ep93xx: replace global NetRxPackets with per-interface allocation
Date: Wed, 13 Mar 2024 12:06:59 +0100	[thread overview]
Message-ID: <20240313110704.1095554-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240313110704.1095554-1-a.fatoum@pengutronix.de>

NetRxPackets is a remnant of times, where a board had at most one
Ethernet controller. This is outdated and we should drop NetRxPackets.

The driver already had an unused rx_buffer, so let's make use of it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/ep93xx.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
index 77f8aa63db76..bd954e7a17b0 100644
--- a/drivers/net/ep93xx.c
+++ b/drivers/net/ep93xx.c
@@ -62,7 +62,7 @@ static void dump_dev(struct eth_device *edev)
 	printf("  rx_sq.end	     %p\n", priv->rx_sq.end);
 
 	for (i = 0; i < NUMRXDESC; i++)
-		printf("  rx_buffer[%2.d]      %p\n", i, NetRxPackets[i]);
+		printf("  rx_buffer[%2.d]      %p\n", i, priv->rx_buffer[i]);
 
 	printf("  tx_dq.base	     %p\n", priv->tx_dq.base);
 	printf("  tx_dq.current	     %p\n", priv->tx_dq.current);
@@ -258,7 +258,7 @@ static int ep93xx_eth_open(struct eth_device *edev)
 	 */
 	for (i = 0; i < NUMRXDESC; i++) {
 		/* set buffer address */
-		(priv->rx_dq.base + i)->word1 = (uint32_t)NetRxPackets[i];
+		(priv->rx_dq.base + i)->word1 = (uint32_t)priv->rx_buffer[i];
 
 		/* set buffer length, clear buffer index and NSOF */
 		(priv->rx_dq.base + i)->word2 = EP93XX_MAX_PKT_SIZE;
@@ -324,7 +324,7 @@ static int ep93xx_eth_rcv_packet(struct eth_device *edev)
 			/*
 			 * We have a good frame. Extract the frame's length
 			 * from the current rx_status_queue entry, and copy
-			 * the frame's data into NetRxPackets[] of the
+			 * the frame's data into priv->rx_buffer of the
 			 * protocol stack. We track the total number of
 			 * bytes in the frame (nbytes_frame) which will be
 			 * used when we pass the data off to the protocol
@@ -532,6 +532,12 @@ static int ep93xx_eth_probe(struct device *dev)
 		goto eth_probe_failed_3;
 	}
 
+	ret = net_alloc_packets(priv->rx_buffer, NUMRXDESC);
+	if (ret) {
+		pr_err("net_alloc_packet() failed: rx_buffer");
+		goto eth_probe_failed_4;
+	}
+
 	mdiobus_register(&priv->miibus);
 	eth_register(edev);
 
@@ -539,6 +545,10 @@ static int ep93xx_eth_probe(struct device *dev)
 
 	goto eth_probe_done;
 
+eth_probe_failed_4:
+	free(priv->rx_sq.base);
+	/* Fall through */
+
 eth_probe_failed_3:
 	free(priv->rx_dq.base);
 	/* Fall through */
-- 
2.39.2




  parent reply	other threads:[~2024-03-13 11:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 11:06 [PATCH 0/7] net: replace global NetRxPackets arrays " Ahmad Fatoum
2024-03-13 11:06 ` [PATCH 1/7] net: add net_alloc_packets helper Ahmad Fatoum
2024-03-13 11:06 ` Ahmad Fatoum [this message]
2024-03-13 11:07 ` [PATCH 3/7] net: enc28j60: replace global NetRxPackets with per-interface allocation Ahmad Fatoum
2024-03-13 11:07 ` [PATCH 4/7] net: gianfar: " Ahmad Fatoum
2024-03-13 11:07 ` [PATCH 5/7] net: ethoc: " Ahmad Fatoum
2024-03-13 11:07 ` [PATCH 6/7] net: cpsw: " Ahmad Fatoum
2024-03-13 11:07 ` [PATCH 7/7] net: retire global NetRxPackets arrays Ahmad Fatoum
2024-03-13 11:38 ` [PATCH 0/7] net: replace global NetRxPackets arrays with per-interface allocation Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240313110704.1095554-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox