Received: from eggs.gnu.org ([2001:4830:134:3::10]:57539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC2KQ-0008Nv-9b for qemu-devel@nongnu.org; Wed, 30 Nov 2016 05:41:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC2KL-0007Rg-8u for qemu-devel@nongnu.org; Wed, 30 Nov 2016 05:41:30 -0500 References: <1480356795-8043-1-git-send-email-andrew.smirnov@gmail.com> From: Jason Wang Message-ID: Date: Wed, 30 Nov 2016 18:41:12 +0800 MIME-Version: 1.0 In-Reply-To: <1480356795-8043-1-git-send-email-andrew.smirnov@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrey Smirnov , qemu-ppc@nongnu.org Cc: qemu-devel@nongnu.org, agraf@suse.de, scottwood@freescale.com On 2016=E5=B9=B411=E6=9C=8829=E6=97=A5 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 i= s > 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 payloa= d > 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 > --- > 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 uint= 8_t *buf, size_t size) > /* CRC padding (We don't have to compute the CRC) */ > etsec->rx_padding =3D 4; > =20 > + /* > + * 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 +=3D 60 - etsec->rx_buffer_len; > + > etsec->rx_first_in_frame =3D 1; > etsec->rx_remaining_data =3D etsec->rx_buffer_len; > RING_DEBUG("%s: rx_buffer_len:%u rx_padding+crc:%u\n", __func__, Applied, thanks.