[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.11 55/59] hw/net/lan9118: Replace magic '2048' value by MIL_
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.11 55/59] hw/net/lan9118: Replace magic '2048' value by MIL_TXFIFO_SIZE definition |
Date: |
Thu, 18 Apr 2024 23:02:15 +0300 |
From: Philippe Mathieu-Daudé <philmd@linaro.org>
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. [...]
Note, the use of the constant in lan9118_receive() reveals that
our implementation is using the same buffer for both tx and rx.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20240409133801.23503-2-philmd@linaro.org>
(cherry picked from commit a45223467e4e185fff1c76a6483784fa379ded77)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index bf81c84984..f269d72d9e 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -155,6 +155,12 @@ do { fprintf(stderr, "lan9118: error: " 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,
@@ -171,7 +177,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 = {
@@ -187,7 +193,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()
}
};
@@ -549,7 +555,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.39.2
- [Stable-7.2.11 50/59] hw/block/nand: Have blk_load() take unsigned offset and return boolean, (continued)
- [Stable-7.2.11 50/59] hw/block/nand: Have blk_load() take unsigned offset and return boolean, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 53/59] backends/cryptodev: Do not abort for invalid session ID, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 48/59] qemu-options: Fix CXL Fixed Memory Window interleave-granularity typo, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 45/59] hw/display/virtio-gpu: Protect from DMA re-entrancy bugs, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 47/59] hw/virtio/virtio-crypto: Protect from DMA re-entrancy bugs, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 51/59] hw/block/nand: Fix out-of-bound access in NAND block buffer, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 52/59] hw/misc/applesmc: Fix memory leak in reset() handler, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 49/59] hw/block/nand: Factor nand_load_iolen() method out, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 54/59] hw/net/lan9118: Fix overflow in MIL TX FIFO, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 56/59] hw/sd/sdhci: Do not update TRNMOD when Command Inhibit (DAT) is set, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 55/59] hw/net/lan9118: Replace magic '2048' value by MIL_TXFIFO_SIZE definition,
Michael Tokarev <=
- [Stable-7.2.11 57/59] target/sh4: add missing CHECK_NOT_DELAY_SLOT, Michael Tokarev, 2024/04/18
- [Stable-7.2.11 58/59] ppc/spapr: Introduce SPAPR_IRQ_NR_IPIS to refer IRQ range for CPU IPIs., Michael Tokarev, 2024/04/18
- [Stable-7.2.11 59/59] ppc/spapr: Initialize max_cpus limit to SPAPR_IRQ_NR_IPIS., Michael Tokarev, 2024/04/18