[PATCH 1/4] net: e1000: add and make use of NUM_RX_DESC macro

Christian Gmeiner christian.gmeiner at gmail.com
Fri Mar 3 21:48:41 CET 2023


The call to DEFINE_ALIGN_BUFFER for the rx_desc array
conained an icnonsistency as 16 receive descriptors
were allocated when the remaining code would only use
8 of them.

Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
---
 drivers/net/e1000.c | 6 +++---
 drivers/net/e1000.h | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 41e6ba760e..8dccf29c7e 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -60,7 +60,7 @@ tested on both gig copper and gig fiber boards
  * move these buffers and the tx/rx 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, 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;
@@ -5095,7 +5095,7 @@ fill_rx(struct e1000_hw *hw)
 
 	rx_last = rx_tail;
 	rd = rx_base + rx_tail;
-	rx_tail = (rx_tail + 1) % 8;
+	rx_tail = (rx_tail + 1) % NUM_RX_DESC;
 	memset(rd, 0, 16);
 	rd->buffer_addr = cpu_to_le64(virt_to_phys(packet));
 
@@ -5272,7 +5272,7 @@ e1000_configure_rx(struct e1000_hw *hw)
 	E1000_WRITE_REG(hw, RDBAL, lower_32_bits(virt_to_phys(rx_base)));
 	E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(rx_base)));
 
-	E1000_WRITE_REG(hw, RDLEN, 128);
+	E1000_WRITE_REG(hw, RDLEN, NUM_RX_DESC * sizeof(struct e1000_rx_desc));
 
 	/* Setup the HW Rx Head and Tail Descriptor Pointers */
 	E1000_WRITE_REG(hw, RDH, 0);
diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
index f788394da8..69882ba66f 100644
--- a/drivers/net/e1000.h
+++ b/drivers/net/e1000.h
@@ -42,6 +42,8 @@
 #define DEBUGOUT(fmt, args...)	do { } while (0)
 #endif
 
+#define NUM_RX_DESC            8
+
 /* I/O wrapper functions */
 #define E1000_WRITE_REG(a, reg, value) \
 	writel((value), ((a)->hw_addr + E1000_##reg))
-- 
2.39.2



More information about the U-Boot mailing list