From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Chuhong Yuan" <hslester96@gmail.com>,
"Jason Wang" <jasowang@redhat.com>,
"Alexander Bulekov" <alxndr@bu.edu>,
qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>
Subject: [PATCH-for-9.1 v2 11/11] hw/net/lan9118: Rename rx_fifo_size -> rx_fifo_wordcount
Date: Tue, 9 Apr 2024 15:38:00 +0200 [thread overview]
Message-ID: <20240409133801.23503-12-philmd@linaro.org> (raw)
In-Reply-To: <20240409133801.23503-1-philmd@linaro.org>
rx_fifo_size is a word count, rename it to avoid confusion.
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/net/lan9118.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index 56cc52d450..3db6bae908 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -263,7 +263,7 @@ struct lan9118_state {
int32_t rx_status_fifo_used;
int32_t rx_status_fifo_head;
uint32_t rx_status_fifo[RX_STATUS_FIFO_BYTES / 4];
- int32_t rx_fifo_size;
+ int32_t rx_fifo_wordcount;
int32_t rx_fifo_used;
int32_t rx_fifo_head;
uint32_t rx_fifo[RX_DATA_FIFO_BYTES / 4];
@@ -335,7 +335,7 @@ static const VMStateDescription vmstate_lan9118 = {
VMSTATE_UINT32_ARRAY(rx_status_fifo, lan9118_state,
RX_STATUS_FIFO_BYTES / 4),
VMSTATE_UNUSED(896 * 4 - RX_STATUS_FIFO_BYTES),
- VMSTATE_INT32(rx_fifo_size, lan9118_state),
+ VMSTATE_INT32(rx_fifo_wordcount, lan9118_state),
VMSTATE_INT32(rx_fifo_used, lan9118_state),
VMSTATE_INT32(rx_fifo_head, lan9118_state),
VMSTATE_UINT32_ARRAY(rx_fifo, lan9118_state,
@@ -462,7 +462,7 @@ static void lan9118_reset(DeviceState *d)
s->txp->fifo_used = 0;
s->tx_fifo_bytes = TX_DATA_FIFO_BYTES;
s->tx_status_fifo_used = 0;
- s->rx_fifo_size = RX_DATA_FIFO_BYTES / 4;
+ s->rx_fifo_wordcount = RX_DATA_FIFO_BYTES / 4;
s->rx_fifo_used = 0;
s->rx_status_fifo_wordcount = RX_STATUS_FIFO_BYTES / 4;
s->rx_status_fifo_used = 0;
@@ -504,8 +504,9 @@ static void rx_fifo_push(lan9118_state *s, uint32_t val)
{
int fifo_pos;
fifo_pos = s->rx_fifo_head + s->rx_fifo_used;
- if (fifo_pos >= s->rx_fifo_size)
- fifo_pos -= s->rx_fifo_size;
+ if (fifo_pos >= s->rx_fifo_wordcount) {
+ fifo_pos -= s->rx_fifo_wordcount;
+ }
s->rx_fifo[fifo_pos] = val;
s->rx_fifo_used++;
}
@@ -584,7 +585,7 @@ static ssize_t lan9118_receive(NetClientState *nc, const uint8_t *buf,
fifo_len = (size + n + 3) >> 2;
/* Add a word for the CRC. */
fifo_len++;
- if (s->rx_fifo_size - s->rx_fifo_used < fifo_len) {
+ if (s->rx_fifo_wordcount - s->rx_fifo_used < fifo_len) {
return -1;
}
@@ -672,8 +673,8 @@ static uint32_t rx_fifo_pop(lan9118_state *s)
} else if (s->rxp_size > 0) {
s->rxp_size--;
val = s->rx_fifo[s->rx_fifo_head++];
- if (s->rx_fifo_head >= s->rx_fifo_size) {
- s->rx_fifo_head -= s->rx_fifo_size;
+ if (s->rx_fifo_head >= s->rx_fifo_wordcount) {
+ s->rx_fifo_head -= s->rx_fifo_wordcount;
}
s->rx_fifo_used--;
} else if (s->rxp_pad > 0) {
@@ -1135,8 +1136,8 @@ static void lan9118_writel(void *opaque, hwaddr offset,
s->rxp_offset = 0;
}
s->rx_fifo_head += s->rxp_size;
- if (s->rx_fifo_head >= s->rx_fifo_size) {
- s->rx_fifo_head -= s->rx_fifo_size;
+ if (s->rx_fifo_head >= s->rx_fifo_wordcount) {
+ s->rx_fifo_head -= s->rx_fifo_wordcount;
}
}
break;
--
2.41.0
next prev parent reply other threads:[~2024-04-09 13:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 13:37 [PATCH-for-9.0 v2 00/11] hw/net/lan9118: Fix overflow in TX FIFO Philippe Mathieu-Daudé
2024-04-09 13:37 ` [PATCH-for-9.0 v2 01/11] hw/net/lan9118: Replace magic '2048' value by MIL_TXFIFO_SIZE definition Philippe Mathieu-Daudé
2024-04-09 13:40 ` Peter Maydell
2024-04-09 13:37 ` [PATCH-for-9.0 v2 02/11] hw/net/lan9118: Fix overflow in MIL TX FIFO Philippe Mathieu-Daudé
2024-04-09 13:41 ` Peter Maydell
2024-04-09 13:37 ` [PATCH-for-9.1 v2 03/11] hw/net/lan9118: Remove duplicated assignment Philippe Mathieu-Daudé
2024-04-09 13:44 ` Peter Maydell
2024-04-09 13:37 ` [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 13:45 ` Peter Maydell
2024-04-09 13:37 ` [PATCH-for-9.1 v2 05/11] hw/net/lan9118: Add definitions for FIFO allocated sizes Philippe Mathieu-Daudé
2024-04-09 13:52 ` Peter Maydell
2024-04-09 13:37 ` [PATCH-for-9.1 v2 06/11] hw/net/lan9118: Use TX_DATA_FIFO_BYTES definition Philippe Mathieu-Daudé
2024-04-09 13:37 ` [PATCH-for-9.1 v2 07/11] hw/net/lan9118: Rename tx_fifo_size -> tx_fifo_bytes Philippe Mathieu-Daudé
2024-04-09 13:55 ` Peter Maydell
2024-04-09 13:37 ` [PATCH-for-9.1 v2 08/11] hw/net/lan9118: Use RX_STATUS_FIFO_BYTES definition Philippe Mathieu-Daudé
2024-04-09 13:59 ` Peter Maydell
2024-04-09 13:37 ` [PATCH-for-9.1 v2 09/11] hw/net/lan9118: Rename rx_status_fifo_size -> rx_status_fifo_wordcount Philippe Mathieu-Daudé
2024-04-09 14:03 ` Peter Maydell
2024-04-09 13:37 ` [PATCH-for-9.1 v2 10/11] hw/net/lan9118: Use RX_DATA_FIFO_BYTES definition Philippe Mathieu-Daudé
2024-04-09 14:05 ` Peter Maydell
2024-04-09 13:38 ` Philippe Mathieu-Daudé [this message]
2024-04-09 14:34 ` [PATCH-for-9.0 v2 00/11] hw/net/lan9118: Fix overflow in TX FIFO Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240409133801.23503-12-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alxndr@bu.edu \
--cc=hslester96@gmail.com \
--cc=jasowang@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).