From patchwork Mon Nov 28 18:13:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9449873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D0DB8600CB for ; Mon, 28 Nov 2016 18:14:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C817727FAD for ; Mon, 28 Nov 2016 18:14:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCC9727FB1; Mon, 28 Nov 2016 18:14:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3196227FAD for ; Mon, 28 Nov 2016 18:14:13 +0000 (UTC) Received: from localhost ([::1]:60458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBQRQ-0003b2-Gz for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Nov 2016 13:14:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBQR2-0003Z1-OB for qemu-devel@nongnu.org; Mon, 28 Nov 2016 13:13:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBQR2-0006v7-1R for qemu-devel@nongnu.org; Mon, 28 Nov 2016 13:13:48 -0500 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:34346) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cBQQv-0006tQ-Oq; Mon, 28 Nov 2016 13:13:41 -0500 Received: by mail-pg0-x241.google.com with SMTP id e9so13734850pgc.1; Mon, 28 Nov 2016 10:13:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=61y2XWsEL5+qo1cwmwV9+JNiNFZ2KPMa+MtrAGtx6j8=; b=i+Yjx7PuT7U7c13OuWbA6UXe1Kla9ysT13m1RD9PoscIz6EoR5ArccbmDOPY5lk9Fy hVjDjDsAI/ieHYXE9+TRnR5yTU4crFTBTNT9yDYzrTgyH7LU2uP/2y2hYKRadwTE4ZA/ avbEyoGTYpD9XTrNfrH7VJ7CswfTnwgzPhij0+9l9XXLSHWDZ6eSOwfI7b4EZYLDyEtL U2ea3suZmhUBvgF+9hTyWKgu41SQOq40iG+ocsVupj3kY0gVveLFSSDfiX0qAgS30hqf Hh1beb3HGrBmL9jdQxZmb9ne3nPcdJ5GIDsc4iRv+Dh0ojcFcMlMJG/iqLpyEBjiIgNd +MGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=61y2XWsEL5+qo1cwmwV9+JNiNFZ2KPMa+MtrAGtx6j8=; b=kPGdG04oxsX8YDD5erwxBjWKwIa+eFTrTZobLqn2vtmgbTgXwIB2s2YkirkWvhzNJq GJ43dgK5UUFyQ2ntpF+MVMoXkBFKRv2jhJ5YIHtn9E1fCX7beY0hHsHj8QR7SrsAoCEk GQmrBJW8e62Nj0V5urkA8bD50aNCyiDCb1IkIf994mTem1ZiFRfyfSav9K+kO+t+3pit ACWyxuOHOH8s69VAPEUPNc42f/J0rOVwDENY51dzMWk2JjnOCxKOcDBjuY9BQ87BpJ78 pRHeG93uJS/v47mOhOggJZnGOkEu2bKl/7etoXFAxn5nNlM0CLEE2lOjIvfTbCUZuC+I afBw== X-Gm-Message-State: AKaTC00IvXrWFd/38u9aWLw6YH6hz36nO5Z8DeNCo+duX6Tr5VJ1js3iMgiKN6LfA/n5PA== X-Received: by 10.98.97.7 with SMTP id v7mr23174058pfb.39.1480356819276; Mon, 28 Nov 2016 10:13:39 -0800 (PST) Received: from squirtle.localdomain.andrews-space.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id s2sm88872688pfi.10.2016.11.28.10.13.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:13:38 -0800 (PST) From: Andrey Smirnov To: qemu-ppc@nongnu.org Date: Mon, 28 Nov 2016 10:13:14 -0800 Message-Id: <1480356795-8043-1-git-send-email-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.5.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: scottwood@freescale.com, Andrey Smirnov , jasowang@redhat.com, qemu-devel@nongnu.org, agraf@suse.de Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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__,