[PATCH 3/4] net: e1000: dynamically allocate rx data buffers per instance
Christian Gmeiner
christian.gmeiner at gmail.com
Fri Mar 3 21:48:43 CET 2023
Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
---
drivers/net/e1000.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 08c84ce3d1..ea9ca76917 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -54,14 +54,11 @@ tested on both gig copper and gig fiber boards
#define E1000_BUFFER_ALIGN 128
/*
- * TODO(sjg at chromium.org): Even with driver model we share these buffers.
- * Concurrent receiving on multiple active Ethernet devices will not work.
- * Normally U-Boot does not support this anyway. To fix it in this driver,
- * move these buffers and the tx/rx pointers to struct e1000_hw.
+ * TODO(sjg at chromium.org): Even with driver model we share tx buffer.
+ * To fix it in this driver, move these buffer and the tx pointers to
+ * struct e1000_hw.
*/
DEFINE_ALIGN_BUFFER(struct e1000_tx_desc, tx_base, 16, E1000_BUFFER_ALIGN);
-DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, NUM_RX_DESC, E1000_BUFFER_ALIGN);
-DEFINE_ALIGN_BUFFER(unsigned char, _packet, 4096, E1000_BUFFER_ALIGN);
static int tx_tail;
static int num_cards; /* Number of E1000 devices seen so far */
@@ -5442,6 +5439,12 @@ void e1000_get_bus_type(struct e1000_hw *hw)
}
}
+static inline void *
+e1000_alloc(size_t size)
+{
+ return memalign(E1000_BUFFER_ALIGN, size);
+}
+
static int e1000_init_one(struct e1000_hw *hw, int cardnum,
struct udevice *devno, unsigned char enetaddr[6])
{
@@ -5470,8 +5473,14 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum,
return -EPERM;
}
- hw->rx_base = rx_base;
- hw->rx_packet = _packet;
+ hw->rx_base = e1000_alloc(NUM_RX_DESC * sizeof(struct e1000_rx_desc));
+ hw->rx_packet = e1000_alloc(4096);
+
+ if (!hw->rx_base || !hw->rx_packet) {
+ free(hw->rx_base);
+ free(hw->rx_packet);
+ return -ENOMEM;
+ }
/* Are these variables needed? */
hw->fc = e1000_fc_default;
--
2.39.2
More information about the U-Boot
mailing list