diff mbox series

[PATCH-for-9.1,v2,04/11] hw/net/lan9118: Replace magic '5' value by TX_FIF_SZ_RESET definition

Message ID 20240409133801.23503-5-philmd@linaro.org
State New
Headers show
Series hw/net/lan9118: Fix overflow in TX FIFO | expand

Commit Message

Philippe Mathieu-Daudé April 9, 2024, 1:37 p.m. UTC
TX_FIF_SZ is described in chapter 5.3.9,
"HW_CFG — HARDWARE CONFIGURATION REGISTER".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/net/lan9118.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Peter Maydell April 9, 2024, 1:45 p.m. UTC | #1
On Tue, 9 Apr 2024 at 14:39, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> TX_FIF_SZ is described in chapter 5.3.9,
> "HW_CFG — HARDWARE CONFIGURATION REGISTER".
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
diff mbox series

Patch

diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index d6f0e37eb1..a6a869de32 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -71,6 +71,8 @@  do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0)
 #define CSR_E2P_CMD     0xb0
 #define CSR_E2P_DATA    0xb4
 
+#define TX_FIF_SZ_RESET 5
+
 #define E2P_CMD_MAC_ADDR_LOADED 0x100
 
 /* IRQ_CFG */
@@ -435,7 +437,7 @@  static void lan9118_reset(DeviceState *d)
     s->fifo_int = 0x48000000;
     s->rx_cfg = 0;
     s->tx_cfg = 0;
-    s->hw_cfg = s->mode_16bit ? 0x00050000 : 0x00050004;
+    s->hw_cfg = (TX_FIF_SZ_RESET << 16) | (s->mode_16bit << 2);
     s->pmt_ctrl &= 0x45;
     s->gpio_cfg = 0;
     s->txp->state = TX_IDLE;