[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH-for-9.0 v2 01/11] hw/net/lan9118: Replace magic '2048' value by M
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH-for-9.0 v2 01/11] hw/net/lan9118: Replace magic '2048' value by MIL_TXFIFO_SIZE definition |
Date: |
Tue, 9 Apr 2024 15:37:50 +0200 |
The magic 2048 is explained in the LAN9211 datasheet (DS00002414A)
in chapter 1.4, "10/100 Ethernet MAC":
The MAC Interface Layer (MIL), within the MAC, contains a
2K Byte transmit and a 128 Byte receive FIFO which is separate
from the TX and RX FIFOs. [...]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
(Not including Peter R-b from v1 due to semantic change)
hw/net/lan9118.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index 47ff25b441..8214569a2c 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -150,6 +150,12 @@ do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0)
#define GPT_TIMER_EN 0x20000000
+/*
+ * The MAC Interface Layer (MIL), within the MAC, contains a 2K Byte transmit
+ * and a 128 Byte receive FIFO which is separate from the TX and RX FIFOs.
+ */
+#define MIL_TXFIFO_SIZE 2048
+
enum tx_state {
TX_IDLE,
TX_B,
@@ -166,7 +172,7 @@ typedef struct {
int32_t pad;
int32_t fifo_used;
int32_t len;
- uint8_t data[2048];
+ uint8_t data[MIL_TXFIFO_SIZE];
} LAN9118Packet;
static const VMStateDescription vmstate_lan9118_packet = {
@@ -182,7 +188,7 @@ static const VMStateDescription vmstate_lan9118_packet = {
VMSTATE_INT32(pad, LAN9118Packet),
VMSTATE_INT32(fifo_used, LAN9118Packet),
VMSTATE_INT32(len, LAN9118Packet),
- VMSTATE_UINT8_ARRAY(data, LAN9118Packet, 2048),
+ VMSTATE_UINT8_ARRAY(data, LAN9118Packet, MIL_TXFIFO_SIZE),
VMSTATE_END_OF_LIST()
}
};
@@ -544,7 +550,7 @@ static ssize_t lan9118_receive(NetClientState *nc, const
uint8_t *buf,
return -1;
}
- if (size >= 2048 || size < 14) {
+ if (size >= MIL_TXFIFO_SIZE || size < 14) {
return -1;
}
--
2.41.0
- [PATCH-for-9.0 v2 00/11] hw/net/lan9118: Fix overflow in TX FIFO, Philippe Mathieu-Daudé, 2024/04/09
- [PATCH-for-9.0 v2 01/11] hw/net/lan9118: Replace magic '2048' value by MIL_TXFIFO_SIZE definition,
Philippe Mathieu-Daudé <=
- [PATCH-for-9.0 v2 02/11] hw/net/lan9118: Fix overflow in MIL TX FIFO, Philippe Mathieu-Daudé, 2024/04/09
- [PATCH-for-9.1 v2 03/11] hw/net/lan9118: Remove duplicated assignment, Philippe Mathieu-Daudé, 2024/04/09
- [PATCH-for-9.1 v2 04/11] hw/net/lan9118: Replace magic '5' value by TX_FIF_SZ_RESET definition, Philippe Mathieu-Daudé, 2024/04/09
- [PATCH-for-9.1 v2 06/11] hw/net/lan9118: Use TX_DATA_FIFO_BYTES definition, Philippe Mathieu-Daudé, 2024/04/09
- [PATCH-for-9.1 v2 07/11] hw/net/lan9118: Rename tx_fifo_size -> tx_fifo_bytes, Philippe Mathieu-Daudé, 2024/04/09