* [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros
@ 2016-11-28 18:13 Andrey Smirnov
2016-11-28 18:13 ` [Qemu-devel] [PATCH 2/2] fsl_etsec: Fix various small problems in hexdump code Andrey Smirnov
2016-11-30 10:41 ` [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros Jason Wang
0 siblings, 2 replies; 4+ messages in thread
From: Andrey Smirnov @ 2016-11-28 18:13 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, agraf, scottwood, jasowang, Andrey Smirnov
Depending on QEMU network setup it is possible for us to receive a
complete Ethernet packet that is less 64 bytes long. One such example is
when QEMU is configured to use a standalone TAP device (not set to be a
part of any bridge) receives and ARP packet. In cases like that we need
to add more than just 4-bytes of CRC padding and ensure that our payload
is at least 60 bytes long, such that, when combined with CRC padding
bytes the resulting size is at least 802.3 minimum MTU bytes
long (64). Failing to do that results in code in etsec_walk_rx_ring()
setting BD_RX_SH which, in turn, makes corresponding Linux driver of
emulated host to reject buffer as a runt packet
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
hw/net/fsl_etsec/rings.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
index 79d2f14..1434c91 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -474,6 +474,13 @@ static void rx_init_frame(eTSEC *etsec, const uint8_t *buf, size_t size)
/* CRC padding (We don't have to compute the CRC) */
etsec->rx_padding = 4;
+ /*
+ * Ensure that payload length + CRC length is at least 802.3
+ * minimum MTU size bytes long (64)
+ */
+ if (etsec->rx_buffer_len < 60)
+ etsec->rx_padding += 60 - etsec->rx_buffer_len;
+
etsec->rx_first_in_frame = 1;
etsec->rx_remaining_data = etsec->rx_buffer_len;
RING_DEBUG("%s: rx_buffer_len:%u rx_padding+crc:%u\n", __func__,
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] fsl_etsec: Fix various small problems in hexdump code
2016-11-28 18:13 [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros Andrey Smirnov
@ 2016-11-28 18:13 ` Andrey Smirnov
2016-11-30 10:41 ` Jason Wang
2016-11-30 10:41 ` [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros Jason Wang
1 sibling, 1 reply; 4+ messages in thread
From: Andrey Smirnov @ 2016-11-28 18:13 UTC (permalink / raw)
To: qemu-ppc; +Cc: qemu-devel, agraf, scottwood, jasowang, Andrey Smirnov
Fix various small problems in hexdump code, such as:
- Reference to non-existing field etsec->nic->nc.name is replaced
with nc->name
- Type mismatch warnings
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
hw/net/fsl_etsec/etsec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
index b5c777f..1093d8b 100644
--- a/hw/net/fsl_etsec/etsec.c
+++ b/hw/net/fsl_etsec/etsec.c
@@ -348,8 +348,8 @@ static ssize_t etsec_receive(NetClientState *nc,
eTSEC *etsec = qemu_get_nic_opaque(nc);
#if defined(HEX_DUMP)
- fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size);
- qemu_hexdump(buf, stderr, "", size);
+ fprintf(stderr, "%s receive size:%zd\n", nc->name, size);
+ qemu_hexdump((void *)buf, stderr, "", size);
#endif
/* Flush is unnecessary as are already in receiving path */
etsec->need_flush = false;
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros
2016-11-28 18:13 [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros Andrey Smirnov
2016-11-28 18:13 ` [Qemu-devel] [PATCH 2/2] fsl_etsec: Fix various small problems in hexdump code Andrey Smirnov
@ 2016-11-30 10:41 ` Jason Wang
1 sibling, 0 replies; 4+ messages in thread
From: Jason Wang @ 2016-11-30 10:41 UTC (permalink / raw)
To: Andrey Smirnov, qemu-ppc; +Cc: qemu-devel, agraf, scottwood
On 2016年11月29日 02:13, Andrey Smirnov wrote:
> Depending on QEMU network setup it is possible for us to receive a
> complete Ethernet packet that is less 64 bytes long. One such example is
> when QEMU is configured to use a standalone TAP device (not set to be a
> part of any bridge) receives and ARP packet. In cases like that we need
> to add more than just 4-bytes of CRC padding and ensure that our payload
> is at least 60 bytes long, such that, when combined with CRC padding
> bytes the resulting size is at least 802.3 minimum MTU bytes
> long (64). Failing to do that results in code in etsec_walk_rx_ring()
> setting BD_RX_SH which, in turn, makes corresponding Linux driver of
> emulated host to reject buffer as a runt packet
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> hw/net/fsl_etsec/rings.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
> index 79d2f14..1434c91 100644
> --- a/hw/net/fsl_etsec/rings.c
> +++ b/hw/net/fsl_etsec/rings.c
> @@ -474,6 +474,13 @@ static void rx_init_frame(eTSEC *etsec, const uint8_t *buf, size_t size)
> /* CRC padding (We don't have to compute the CRC) */
> etsec->rx_padding = 4;
>
> + /*
> + * Ensure that payload length + CRC length is at least 802.3
> + * minimum MTU size bytes long (64)
> + */
> + if (etsec->rx_buffer_len < 60)
> + etsec->rx_padding += 60 - etsec->rx_buffer_len;
> +
> etsec->rx_first_in_frame = 1;
> etsec->rx_remaining_data = etsec->rx_buffer_len;
> RING_DEBUG("%s: rx_buffer_len:%u rx_padding+crc:%u\n", __func__,
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] fsl_etsec: Fix various small problems in hexdump code
2016-11-28 18:13 ` [Qemu-devel] [PATCH 2/2] fsl_etsec: Fix various small problems in hexdump code Andrey Smirnov
@ 2016-11-30 10:41 ` Jason Wang
0 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2016-11-30 10:41 UTC (permalink / raw)
To: Andrey Smirnov, qemu-ppc; +Cc: qemu-devel, agraf, scottwood
On 2016年11月29日 02:13, Andrey Smirnov wrote:
> Fix various small problems in hexdump code, such as:
> - Reference to non-existing field etsec->nic->nc.name is replaced
> with nc->name
>
> - Type mismatch warnings
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> hw/net/fsl_etsec/etsec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
> index b5c777f..1093d8b 100644
> --- a/hw/net/fsl_etsec/etsec.c
> +++ b/hw/net/fsl_etsec/etsec.c
> @@ -348,8 +348,8 @@ static ssize_t etsec_receive(NetClientState *nc,
> eTSEC *etsec = qemu_get_nic_opaque(nc);
>
> #if defined(HEX_DUMP)
> - fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size);
> - qemu_hexdump(buf, stderr, "", size);
> + fprintf(stderr, "%s receive size:%zd\n", nc->name, size);
> + qemu_hexdump((void *)buf, stderr, "", size);
> #endif
> /* Flush is unnecessary as are already in receiving path */
> etsec->need_flush = false;
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-30 10:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-28 18:13 [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros Andrey Smirnov
2016-11-28 18:13 ` [Qemu-devel] [PATCH 2/2] fsl_etsec: Fix various small problems in hexdump code Andrey Smirnov
2016-11-30 10:41 ` Jason Wang
2016-11-30 10:41 ` [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros Jason Wang
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).