From nobody Wed Feb 11 00:55:43 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1682505548; cv=none; d=zohomail.com; s=zohoarc; b=CzqlXXUDs6Eq7fwWmA0O2nViKpGmOFJrbnau/TqhwMeuBeUCaHDg8qXXO0VqpgP1fpD7yy6DTG1HZ0A+VpC7MYn4ZSOU8jIRnivbfeE6EermHjbpZ0obIxOElDw4Nz9QIkK7rXoZknrykvYzeZzKFFN/QaLdlFS/c/8KS3Sk74s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682505548; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=rwy5rvMUqP3oelPjHxfIZcxpBNQc9ghPL/3JUmVe4oU=; b=euv+2xg0HZ/n5QbEDQky/STTkjIj+ToUO0Hm1EJjzkDS/4OT/FDGjCF186uDqOOxiUCxdI7nCBWa0BFpbfzLtgfqmjj7KwY2f2a6qL7lie4VQB/X3G8T2dNSPxvUgh9r4oCDcQVRpHRwtQUDhIzghl1RHStVD4v7BPTgieUDsv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682505548250784.1213088011414; Wed, 26 Apr 2023 03:39:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prcXa-0001Ui-1T; Wed, 26 Apr 2023 06:38:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prcXY-0001MR-Cz for qemu-devel@nongnu.org; Wed, 26 Apr 2023 06:38:24 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1prcXW-00036C-OR for qemu-devel@nongnu.org; Wed, 26 Apr 2023 06:38:23 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-63f273b219eso3370027b3a.1 for ; Wed, 26 Apr 2023 03:38:22 -0700 (PDT) Received: from alarm.u-tokyo.ac.jp ([157.82.194.15]) by smtp.gmail.com with ESMTPSA id m11-20020a63580b000000b0051322a5aa64sm9317919pgb.3.2023.04.26.03.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 03:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1682505501; x=1685097501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rwy5rvMUqP3oelPjHxfIZcxpBNQc9ghPL/3JUmVe4oU=; b=0MLh28W8nT2dLpm+PmyKJbvKoo70w2guKkOeT6qvcJCmJd5y+SZQJHxLN+NyTyP5Tc JtOEEXIbn1iE4zBLSrOfqlrUFFMnBg2ADWWFuEiJoHk5L481VhpodiZdro0Emtn9YKwO 90+kcw1r/5WOBU8RHbDqxSJCy15SZ6htq+HE6PLaa6M4ycqML+7YxYFq/KYJKqhNxM6d RIgnsOctbk2VD4lovcFPxmPE1ezD9eTas2/YVI9PWWcDohHSz1diBx3w/340GJT8mC+q w26n9BsvQJmotlPAdru1plt1V+pmR4iYsdtq//GCN7W2je07YXKDpMIPd39RnCFA6hWs 6SHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682505501; x=1685097501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rwy5rvMUqP3oelPjHxfIZcxpBNQc9ghPL/3JUmVe4oU=; b=ZOY/uSGe03BSuwxB8fUKKfbNTxm9m8kfFZP7l6fTczF9AExmtO3KDCPBf9oFL9AGu4 3hFzymiUXsWHSqpPNwHEzngtjs4ZsLq+mG+XzXcTEvHxsyMBAS3O0VZn+e2r7I3EjKDH X3QPRdobVSlIe37k/t0Wbj0XOWM9KHWdh31Fp2m05pmAIVd+COyAjGtgC+a0b318mpQr 3BHoAlz7AlQ4ptWsJvbdichze309f6KSdkeb5NBWT7PYmLLTlquGysgKAxhu2XzdcQd3 E2cLlxpbwiWiltw0Ddq7M/wXB2iamaQr5RWWdy5+e3BehKnSi0Ld9AqxhF9h7aGpo7RU aTuQ== X-Gm-Message-State: AAQBX9dCZjB7LK8Z75W5Oz4P48l1SRcbQ8b3JeOdMJRkYazvkEYCO8RK FZBNxAdlUdkRw1NCAYu+tZuKxQ== X-Google-Smtp-Source: AKy350arCH229KHj6sNierzRm5VuvD+Ij4+qgpoWa5vk+c9wBwU3ngS/LrNEZPCIn7pBRpVyge5Paw== X-Received: by 2002:a05:6a00:b46:b0:63b:6b43:78c with SMTP id p6-20020a056a000b4600b0063b6b43078cmr26301469pfo.29.1682505501457; Wed, 26 Apr 2023 03:38:21 -0700 (PDT) From: Akihiko Odaki To: Cc: Sriram Yagnaraman , Jason Wang , Dmitry Fleytman , "Michael S . Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta , Beraldo Leal , Cleber Rosa , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, Tomasz Dzieciol , Akihiko Odaki Subject: [PATCH v4 16/48] e1000x: Take CRC into consideration for size check Date: Wed, 26 Apr 2023 19:36:44 +0900 Message-Id: <20230426103716.26279-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230426103716.26279-1-akihiko.odaki@daynix.com> References: <20230426103716.26279-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::430; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1682505550399100007 Content-Type: text/plain; charset="utf-8" Section 13.7.15 Receive Length Error Count says: > Packets over 1522 bytes are oversized if LongPacketEnable is 0b > (RCTL.LPE). If LongPacketEnable (LPE) is 1b, then an incoming packet > is considered oversized if it exceeds 16384 bytes. > These lengths are based on bytes in the received packet from > through , inclusively. As QEMU processes packets without CRC, the number of bytes for CRC need to be subtracted. This change adds some size definitions to be used to derive the new size thresholds to eth.h. Signed-off-by: Akihiko Odaki --- include/net/eth.h | 2 ++ hw/net/e1000x_common.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/net/eth.h b/include/net/eth.h index e8af5742be..05f56931e7 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -32,6 +32,8 @@ #define ETH_ALEN 6 #define ETH_HLEN 14 #define ETH_ZLEN 60 /* Min. octets in frame without FCS */ +#define ETH_FCS_LEN 4 +#define ETH_MTU 1500 =20 struct eth_header { uint8_t h_dest[ETH_ALEN]; /* destination eth addr */ diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c index 6cc23138a8..212873fd77 100644 --- a/hw/net/e1000x_common.c +++ b/hw/net/e1000x_common.c @@ -140,16 +140,16 @@ bool e1000x_hw_rx_enabled(uint32_t *mac) =20 bool e1000x_is_oversized(uint32_t *mac, size_t size) { + size_t header_size =3D sizeof(struct eth_header) + sizeof(struct vlan_= header); /* this is the size past which hardware will drop packets when setting LPE=3D0 */ - static const int maximum_ethernet_vlan_size =3D 1522; + size_t maximum_short_size =3D header_size + ETH_MTU; /* this is the size past which hardware will drop packets when setting LPE=3D1 */ - static const int maximum_ethernet_lpe_size =3D 16 * KiB; + size_t maximum_large_size =3D 16 * KiB - ETH_FCS_LEN; =20 - if ((size > maximum_ethernet_lpe_size || - (size > maximum_ethernet_vlan_size - && !(mac[RCTL] & E1000_RCTL_LPE))) + if ((size > maximum_large_size || + (size > maximum_short_size && !(mac[RCTL] & E1000_RCTL_LPE))) && !(mac[RCTL] & E1000_RCTL_SBP)) { e1000x_inc_reg_if_not_full(mac, ROC); trace_e1000x_rx_oversized(size); --=20 2.40.0