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

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@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))

Preparation for per driver instance allocated data structures.
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com --- drivers/net/e1000.c | 26 +++++++++++++++----------- drivers/net/e1000.h | 5 +++++ 2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 8dccf29c7e..08c84ce3d1 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -61,10 +61,9 @@ tested on both gig copper and gig fiber boards */ 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); +DEFINE_ALIGN_BUFFER(unsigned char, _packet, 4096, E1000_BUFFER_ALIGN);
static int tx_tail; -static int rx_tail, rx_last; static int num_cards; /* Number of E1000 devices seen so far */
static struct pci_device_id e1000_supported[] = { @@ -5090,12 +5089,13 @@ e1000_sw_init(struct e1000_hw *hw) void fill_rx(struct e1000_hw *hw) { + unsigned char *packet = hw->rx_packet; struct e1000_rx_desc *rd; unsigned long flush_start, flush_end;
- rx_last = rx_tail; - rd = rx_base + rx_tail; - rx_tail = (rx_tail + 1) % NUM_RX_DESC; + hw->rx_last = hw->rx_tail; + rd = hw->rx_base + hw->rx_tail; + hw->rx_tail = (hw->rx_tail + 1) % NUM_RX_DESC; memset(rd, 0, 16); rd->buffer_addr = cpu_to_le64(virt_to_phys(packet));
@@ -5111,7 +5111,7 @@ fill_rx(struct e1000_hw *hw) flush_end = flush_start + roundup(sizeof(*rd), ARCH_DMA_MINALIGN); flush_dcache_range(flush_start, flush_end);
- E1000_WRITE_REG(hw, RDT, rx_tail); + E1000_WRITE_REG(hw, RDT, hw->rx_tail); }
/** @@ -5248,7 +5248,7 @@ static void e1000_configure_rx(struct e1000_hw *hw) { unsigned long rctl, ctrl_ext; - rx_tail = 0; + hw->rx_tail = 0;
/* make sure receives are disabled while setting up the descriptors */ rctl = E1000_READ_REG(hw, RCTL); @@ -5269,8 +5269,8 @@ e1000_configure_rx(struct e1000_hw *hw) E1000_WRITE_FLUSH(hw); } /* Setup the Base and Length of the Rx Descriptor Ring */ - 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, RDBAL, lower_32_bits(virt_to_phys(hw->rx_base))); + E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(hw->rx_base)));
E1000_WRITE_REG(hw, RDLEN, NUM_RX_DESC * sizeof(struct e1000_rx_desc));
@@ -5298,12 +5298,13 @@ POLL - Wait for a frame static int _e1000_poll(struct e1000_hw *hw) { + unsigned char *packet = hw->rx_packet; struct e1000_rx_desc *rd; unsigned long inval_start, inval_end; uint32_t len;
/* return true if there's an ethernet packet ready to read */ - rd = rx_base + rx_last; + rd = hw->rx_base + hw->rx_last;
/* Re-load the descriptor from RAM. */ inval_start = ((unsigned long)rd) & ~(ARCH_DMA_MINALIGN - 1); @@ -5469,6 +5470,9 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, return -EPERM; }
+ hw->rx_base = rx_base; + hw->rx_packet = _packet; + /* Are these variables needed? */ hw->fc = e1000_fc_default; hw->original_fc = e1000_fc_default; @@ -5663,7 +5667,7 @@ static int e1000_eth_recv(struct udevice *dev, int flags, uchar **packetp)
len = _e1000_poll(hw); if (len) - *packetp = packet; + *packetp = hw->rx_packet;
return len ? len : -EAGAIN; } diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h index 69882ba66f..f83e3a0b33 100644 --- a/drivers/net/e1000.h +++ b/drivers/net/e1000.h @@ -1134,6 +1134,11 @@ struct e1000_hw { bool initialize_hw_bits_disable; e1000_smart_speed smart_speed; e1000_dsp_config dsp_config_state; + + struct e1000_rx_desc *rx_base; + unsigned char *rx_packet; + int rx_tail; + int rx_last; };
#define E1000_EEPROM_SWDPIN0 0x0001 /* SWDPIN 0 EEPROM Value */

Hi all
Preparation for per driver instance allocated data structures.
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com
gentle ping - what can I do better to get some feedback, RBs, etc faster? This experience is quite frustrating and it happens for me from time to time for U-Boot patches :(
Patch 1 of this series got a RB few days ago and the others are still open.
drivers/net/e1000.c | 26 +++++++++++++++----------- drivers/net/e1000.h | 5 +++++ 2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 8dccf29c7e..08c84ce3d1 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -61,10 +61,9 @@ tested on both gig copper and gig fiber boards */ 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); +DEFINE_ALIGN_BUFFER(unsigned char, _packet, 4096, E1000_BUFFER_ALIGN);
static int tx_tail; -static int rx_tail, rx_last; static int num_cards; /* Number of E1000 devices seen so far */
static struct pci_device_id e1000_supported[] = { @@ -5090,12 +5089,13 @@ e1000_sw_init(struct e1000_hw *hw) void fill_rx(struct e1000_hw *hw) {
unsigned char *packet = hw->rx_packet; struct e1000_rx_desc *rd; unsigned long flush_start, flush_end;
rx_last = rx_tail;
rd = rx_base + rx_tail;
rx_tail = (rx_tail + 1) % NUM_RX_DESC;
hw->rx_last = hw->rx_tail;
rd = hw->rx_base + hw->rx_tail;
hw->rx_tail = (hw->rx_tail + 1) % NUM_RX_DESC; memset(rd, 0, 16); rd->buffer_addr = cpu_to_le64(virt_to_phys(packet));
@@ -5111,7 +5111,7 @@ fill_rx(struct e1000_hw *hw) flush_end = flush_start + roundup(sizeof(*rd), ARCH_DMA_MINALIGN); flush_dcache_range(flush_start, flush_end);
E1000_WRITE_REG(hw, RDT, rx_tail);
E1000_WRITE_REG(hw, RDT, hw->rx_tail);
}
/** @@ -5248,7 +5248,7 @@ static void e1000_configure_rx(struct e1000_hw *hw) { unsigned long rctl, ctrl_ext;
rx_tail = 0;
hw->rx_tail = 0; /* make sure receives are disabled while setting up the descriptors */ rctl = E1000_READ_REG(hw, RCTL);
@@ -5269,8 +5269,8 @@ e1000_configure_rx(struct e1000_hw *hw) E1000_WRITE_FLUSH(hw); } /* Setup the Base and Length of the Rx Descriptor Ring */
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, RDBAL, lower_32_bits(virt_to_phys(hw->rx_base)));
E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(hw->rx_base))); E1000_WRITE_REG(hw, RDLEN, NUM_RX_DESC * sizeof(struct e1000_rx_desc));
@@ -5298,12 +5298,13 @@ POLL - Wait for a frame static int _e1000_poll(struct e1000_hw *hw) {
unsigned char *packet = hw->rx_packet; struct e1000_rx_desc *rd; unsigned long inval_start, inval_end; uint32_t len; /* return true if there's an ethernet packet ready to read */
rd = rx_base + rx_last;
rd = hw->rx_base + hw->rx_last; /* Re-load the descriptor from RAM. */ inval_start = ((unsigned long)rd) & ~(ARCH_DMA_MINALIGN - 1);
@@ -5469,6 +5470,9 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, return -EPERM; }
hw->rx_base = rx_base;
hw->rx_packet = _packet;
/* Are these variables needed? */ hw->fc = e1000_fc_default; hw->original_fc = e1000_fc_default;
@@ -5663,7 +5667,7 @@ static int e1000_eth_recv(struct udevice *dev, int flags, uchar **packetp)
len = _e1000_poll(hw); if (len)
*packetp = packet;
*packetp = hw->rx_packet; return len ? len : -EAGAIN;
} diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h index 69882ba66f..f83e3a0b33 100644 --- a/drivers/net/e1000.h +++ b/drivers/net/e1000.h @@ -1134,6 +1134,11 @@ struct e1000_hw { bool initialize_hw_bits_disable; e1000_smart_speed smart_speed; e1000_dsp_config dsp_config_state;
struct e1000_rx_desc *rx_base;
unsigned char *rx_packet;
int rx_tail;
int rx_last;
};
#define E1000_EEPROM_SWDPIN0 0x0001 /* SWDPIN 0 EEPROM Value */
2.39.2

On Wed, Apr 05, 2023 at 09:50:08AM +0200, Christian Gmeiner wrote:
Hi all
Preparation for per driver instance allocated data structures.
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com
gentle ping - what can I do better to get some feedback, RBs, etc faster? This experience is quite frustrating and it happens for me from time to time for U-Boot patches :(
Patch 1 of this series got a RB few days ago and the others are still open.
Unfortunately there's a number of areas where we just don't have a lot of maintainers. Now that v2023.04 is out I expect to be picking up assorted patches that look right, soon. Sorry for the delay.

On Wed, Apr 05, 2023 at 09:50:08AM +0200, Christian Gmeiner wrote:
Hi all
Preparation for per driver instance allocated data structures.
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com
gentle ping - what can I do better to get some feedback, RBs, etc faster? This experience is quite frustrating and it happens for me from time to time for U-Boot patches :(
Patch 1 of this series got a RB few days ago and the others are still open.
Unfortunately there's a number of areas where we just don't have a lot of maintainers. Now that v2023.04 is out I expect to be picking up assorted patches that look right, soon. Sorry for the delay.
Thanks for your reasoning. Out of this I started to review some k3 patches :)

Signed-off-by: Christian Gmeiner christian.gmeiner@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@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@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;

When facing a very busy network, the single rx packet buffer was oftentimes overwritten before a desired response packet (e.g. a Ping reply) could have been processed. This change improves resistance to this by utilising multiple buffers.
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com --- drivers/net/e1000.c | 30 ++++++++++++++++++++++-------- drivers/net/e1000.h | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index ea9ca76917..86300898af 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -5086,7 +5086,7 @@ e1000_sw_init(struct e1000_hw *hw) void fill_rx(struct e1000_hw *hw) { - unsigned char *packet = hw->rx_packet; + unsigned char *packet = hw->rx_packet[hw->rx_tail]; struct e1000_rx_desc *rd; unsigned long flush_start, flush_end;
@@ -5284,6 +5284,9 @@ e1000_configure_rx(struct e1000_hw *hw) mdelay(20); }
+ for (int i = 0; i < NUM_RX_DESC; i++) + memset(&hw->rx_base[i], 0, 16); + E1000_WRITE_REG(hw, RCTL, rctl);
fill_rx(hw); @@ -5295,9 +5298,9 @@ POLL - Wait for a frame static int _e1000_poll(struct e1000_hw *hw) { - unsigned char *packet = hw->rx_packet; struct e1000_rx_desc *rd; unsigned long inval_start, inval_end; + unsigned char *packet; uint32_t len;
/* return true if there's an ethernet packet ready to read */ @@ -5310,6 +5313,9 @@ _e1000_poll(struct e1000_hw *hw)
if (!(rd->status & E1000_RXD_STAT_DD)) return 0; + + packet = (unsigned char *)rd->buffer_addr; + /* DEBUGOUT("recv: packet len=%d\n", rd->length); */ /* Packet received, make sure the data are re-loaded from RAM. */ len = le16_to_cpu(rd->length); @@ -5403,8 +5409,8 @@ _e1000_init(struct e1000_hw *hw, unsigned char enetaddr[6]) return ret_val; } e1000_configure_tx(hw); - e1000_setup_rctl(hw); e1000_configure_rx(hw); + e1000_setup_rctl(hw); return 0; }
@@ -5474,12 +5480,14 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, }
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); + if (!hw->rx_base) return -ENOMEM; + + for (int i = 0; i < NUM_RX_DESC; i++) { + hw->rx_packet[i] = e1000_alloc(4096); + if (!hw->rx_packet[i]) + goto out_alloc_fail; }
/* Are these variables needed? */ @@ -5529,6 +5537,12 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, #endif
return 0; + +out_alloc_fail: + for (int i = 0; i < NUM_RX_DESC; i++) + free(hw->rx_packet[i]); + + return -ENOMEM; }
/* Put the name of a device in a string */ @@ -5676,7 +5690,7 @@ static int e1000_eth_recv(struct udevice *dev, int flags, uchar **packetp)
len = _e1000_poll(hw); if (len) - *packetp = hw->rx_packet; + *packetp = hw->rx_packet[hw->rx_last];
return len ? len : -EAGAIN; } diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h index f83e3a0b33..be3fce4bb6 100644 --- a/drivers/net/e1000.h +++ b/drivers/net/e1000.h @@ -1136,7 +1136,7 @@ struct e1000_hw { e1000_dsp_config dsp_config_state;
struct e1000_rx_desc *rx_base; - unsigned char *rx_packet; + unsigned char *rx_packet[NUM_RX_DESC]; int rx_tail; int rx_last; };

On Fri, Mar 03, 2023 at 09:48:44PM +0100, Christian Gmeiner wrote:
When facing a very busy network, the single rx packet buffer was oftentimes overwritten before a desired response packet (e.g. a Ping reply) could have been processed. This change improves resistance to this by utilising multiple buffers.
Signed-off-by: Christian Gmeiner christian.gmeiner@gmail.com
This results in: drivers/net/e1000.c:5317:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 5317 | packet = (unsigned char *)rd->buffer_addr; | ^
On platforms such as qemu_arm.

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@gmail.com
gentle ping

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@gmail.com
gentle ping
Adding some more people to CC - maybe this helps.

On Fri, Mar 3, 2023 at 10:49 PM Christian Gmeiner christian.gmeiner@gmail.com wrote:
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@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
Reviewed-by: Ramon Fried rfried.dev@gmail.com

Am Sa., 1. Apr. 2023 um 21:01 Uhr schrieb Ramon Fried rfried.dev@gmail.com:
On Fri, Mar 3, 2023 at 10:49 PM Christian Gmeiner christian.gmeiner@gmail.com wrote:
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@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
Reviewed-by: Ramon Fried rfried.dev@gmail.com
Who is responsible for this change and maybe the other 3 patches in this series make their way into master?
participants (3)
-
Christian Gmeiner
-
Ramon Fried
-
Tom Rini