[PATCH 6/7] net: cpsw: replace global NetRxPackets with per-interface allocation
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Mar 13 04:07:03 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.
Switch over the driver to allocate the receive buffers needed.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/net/cpsw.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 42fb32bde2f5..3f24c21594c1 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -215,6 +215,8 @@ struct cpsw_priv {
unsigned int slave_size;
unsigned int sliver_ofs;
+ void *rx_buffer[PKTBUFSRX - 2];
+
struct cpdma_desc *descs;
struct cpdma_desc *desc_free;
struct cpdma_chan rx_chan, tx_chan;
@@ -980,7 +982,7 @@ static int cpsw_setup(struct device *dev)
/* submit rx descs */
for (i = 0; i < PKTBUFSRX - 2; i++) {
- ret = cpdma_submit(priv, &priv->rx_chan, NetRxPackets[i],
+ ret = cpdma_submit(priv, &priv->rx_chan, priv->rx_buffer[i],
PKTSIZE, 0);
if (ret < 0) {
dev_err(dev, "error %d submitting rx desc\n", ret);
@@ -1350,6 +1352,10 @@ static int cpsw_probe(struct device *dev)
priv = xzalloc(sizeof(*priv));
priv->dev = dev;
+ ret = net_alloc_packets(priv->rx_buffer, ARRAY_SIZE(priv->rx_buffer));
+ if (ret)
+ goto out;
+
if (dev->of_node) {
ret = cpsw_probe_dt(priv);
if (ret)
--
2.39.2
More information about the barebox
mailing list