From nobody Wed Feb 11 02:55:21 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=1682223985; cv=none; d=zohomail.com; s=zohoarc; b=EgUFPF/2GC97Nrgwvk473i/P9EDKYgLGhja6kujjGINH0XaqtEEMP3Y6TyGjISWDqYqvjQ+rYWHR9l1OkfPwcSXKuZBNmB6iSStMGAZsGO8LR/+VsVr8xDnJvM+G7j69uN/f+A2NvP1R28BRihU3/eRO/WP7thEPSJsuqrk34ek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682223985; 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=g+t5fiLqAbkIrFjnTR4krSe/HSVuK1J6sXhsTLG871WUtqfweHa3Yv5vHikwmABxgk73ypYpvLZB0smjkBpi6eKFlQFiwSTBdMHSaXL/aiI5H/alfamg8IT0vA+uX2Dt+5XkCzJoSwBspDeoWiF+9Hy8GeGjMojoqSxwkPBhps8= 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 1682223985237947.3066068909203; Sat, 22 Apr 2023 21:26:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqRCQ-0001xv-Dy; Sun, 23 Apr 2023 00:19:42 -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 1pqRCO-0001xE-RC for qemu-devel@nongnu.org; Sun, 23 Apr 2023 00:19:40 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqRCM-0000pQ-Iz for qemu-devel@nongnu.org; Sun, 23 Apr 2023 00:19:40 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-63b5465fb99so2946436b3a.1 for ; Sat, 22 Apr 2023 21:19:38 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id f1-20020a170902ff0100b001a5059861adsm4596996plj.224.2023.04.22.21.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 21:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1682223577; x=1684815577; 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=u4tiGKW0AOJr6YyBZGicJ3Y7z09Nin8AbJfN/0IG+iQ3T97ppjubVF2WLl8yc8kGiM 3fvgao5iF+9ZkuoJKMEwsCVtjK+fsPTufQcHV16g4bklwIEnkxIwz9Uxoy/DcQe00/Ox IkF6vFNzmGYXWCLu+PjujuE4RPO8+TPZsi6x28Jb27aV+nSoRPYJBzL74W+bFl0oPTKq EBFeZrhKsIvH5tNR8aHYFbr3+80UCWPBF7/u8agOYj6rCL7z0zu/mJmUaU5dUa95lKYR D99qfn7nTh7DjE1bDVybGAb9l/A+z+qdRM+ZdpuvhC4qiwngpvy2fSzRhlBC2g3kefa2 yMCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682223577; x=1684815577; 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=TYRIb6dzgP4tR2hT35ppdLFG8V/ZO5tKEqpKVFAETAtDqpMptmSRCW+tRayje3wEHy yN/7tQfrZgZgOAmahm4CKhyWo1qYZH39c1YSxLTL9ikJSmduMeqF57Q0wi4/rkt12Q1N GL3RDYc3fkk3EmEvSJawM0cpmZ4u4NWTIVVxNDByztTxx8uhFSJAB15DWhEDwRs9RW1P 7sKRW2qv0hJPTEJ7uQbBjq6PxbAUDREEKuUBPUJSQbMIkITRUnWXSy+yC8d/ZiDw4WIf zc/R8uo7bkBKpuuQjpSBIWEfRPlZsxdaPkuVk9MCFKTRtggy7QObQtIGwIz7TIM45eVg TjVQ== X-Gm-Message-State: AAQBX9fNdVLWKWGd4KTL9CAAjkO4Zy6jhTYm34QC0pW/tniVHO0lwmw0 yXyPugyGQ8ZmTwgkWVUMxo0JBw== X-Google-Smtp-Source: AKy350bWfkhMcuuN/wiWgg9WUn55rJeNmCiHTD40KgOU7/79AQM+g0Nl/YIp6/AtoeTNorys86Ujeg== X-Received: by 2002:a17:902:e88c:b0:1a1:a830:cef8 with SMTP id w12-20020a170902e88c00b001a1a830cef8mr13757449plg.27.1682223577444; Sat, 22 Apr 2023 21:19:37 -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 v3 16/47] e1000x: Take CRC into consideration for size check Date: Sun, 23 Apr 2023 13:18:02 +0900 Message-Id: <20230423041833.5302-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230423041833.5302-1-akihiko.odaki@daynix.com> References: <20230423041833.5302-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::435; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x435.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: 1682223986967100011 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