[PATCH 2/7] net: ep93xx: replace global NetRxPackets with per-interface allocation
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Mar 13 04:06:59 PDT 2024
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 at 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
More information about the barebox
mailing list