[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen master] fsl_etsec: Pad short payloads with zeros



commit 64f441d2e53ac6ed8b4ef199e1995529d2012000
Author:     Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
AuthorDate: Mon Nov 28 10:13:14 2016 -0800
Commit:     Jason Wang <jasowang@xxxxxxxxxx>
CommitDate: Mon Dec 5 17:45:14 2016 +0800

    fsl_etsec: Pad short payloads with zeros
    
    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@xxxxxxxxx>
    Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx>
---
 hw/net/fsl_etsec/rings.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
index 79d2f14..54c0127 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -474,6 +474,14 @@ 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__,
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.