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 5/7] net: ethoc: replace global NetRxPackets with per-interface allocation
Date: Wed, 13 Mar 2024 12:07:02 +0100	[thread overview]
Message-ID: <20240313110704.1095554-6-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.

Switch over the driver to allocate the receive buffers needed.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/ethoc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index c878f498a447..a31d3bb52173 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -178,6 +178,8 @@ struct ethoc {
 	u32 cur_rx;
 
 	struct mii_bus miibus;
+
+	void *rx_buffer[PKTBUFSRX];
 };
 
 /**
@@ -266,7 +268,7 @@ static int ethoc_init_ring(struct ethoc *dev)
 		if (i == dev->num_rx - 1)
 			bd.stat |= RX_BD_WRAP;
 
-		bd.addr = (u32)NetRxPackets[i];
+		bd.addr = (u32)dev->rx_buffer[i];
 		ethoc_write_bd(dev, dev->num_tx + i, &bd);
 
 		flush_dcache_range(bd.addr, bd.addr + PKTSIZE);
@@ -534,12 +536,18 @@ static int ethoc_probe(struct device *dev)
 	struct resource *iores;
 	struct eth_device *edev;
 	struct ethoc *priv;
+	int ret;
 
 	edev = xzalloc(sizeof(struct eth_device) +
 		       sizeof(struct ethoc));
 	edev->priv = (struct ethoc *)(edev + 1);
 
 	priv = edev->priv;
+
+	ret = net_alloc_packets(priv->rx_buffer, ARRAY_SIZE(priv->rx_buffer));
+	if (ret)
+		return ret;
+
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
 		return PTR_ERR(iores);
-- 
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 ` [PATCH 2/7] net: ep93xx: replace global NetRxPackets with per-interface allocation Ahmad Fatoum
2024-03-13 11:07 ` [PATCH 3/7] net: enc28j60: " Ahmad Fatoum
2024-03-13 11:07 ` [PATCH 4/7] net: gianfar: " Ahmad Fatoum
2024-03-13 11:07 ` Ahmad Fatoum [this message]
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-6-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