From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147779; cv=none; d=zohomail.com; s=zohoarc; b=ap/AlKhNldBCK/ahrzdZTF2OFPdHwNExPQy1cvT7kkxa059nPgIQOrmLqkReBekgUfOeVbNzHnn+CJuvgnYzXu5NRy1ibYxfGn6FKmWzc779zc0G1qVyOg64eeqQ2Lz342V74khzAy3aNCfL+ZW4NoQMZtifkfD6KIPme+8Ous4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147779; h=Content-Type: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=LEVUzcjDweu3RxATasMPdWrNCDFTC29sZxdxxneukjs=; b=YkN0UFnL/PVhrmRCvjbTBBoFefZIU3eazssMITh4QdVgFTLPS2ohWVlSq8ce+y5bnbWw6WErK/3GxJQ16OaJlC8bKuy2hM/Tzyx2nuiC5WhpQFc6Go6UxEPkaDy+90lTe4ThI6uuB6x4+VVImIiaUajmOKVFfqO7evPmTKyQjFA= 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+importer2=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 1677147779522846.4217591717143; Thu, 23 Feb 2023 02:22:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8ic-0005sz-Ig; Thu, 23 Feb 2023 05:20:54 -0500 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 1pV8ia-0005sF-9g for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:20:52 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8iX-0000wf-1P for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:20:52 -0500 Received: by mail-pj1-x1033.google.com with SMTP id q31-20020a17090a17a200b0023750b69614so3842488pja.5 for ; Thu, 23 Feb 2023 02:20:48 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=LEVUzcjDweu3RxATasMPdWrNCDFTC29sZxdxxneukjs=; b=WqxJaecGmzciL9DCVJGZyjIS8/n5zn6n8TGvEIAyTJNjkHM80+J23Xnw2NrDWpiwyx LPRHYVOy6C78vIlSDuD1GT3fP+JFS318DndiNN3ubVN6w9trd5KhI+AE28DqhRs4/ndI 1En+8eVRq2eoSN7mpKKGHSZd1fHJxmWnIjI+XtyChAY5T7JDSr3PzTgsAHzD9AzKumIe /xHOJWX+BilS9WiHbx0FB0xBQjgc9MPtfianVL8Nc9E34wA5/m/vhx2dqA8s2xW4HxPv VF8Wtaq41YSyBL6Mav/UvqZeV5oQJKu3WGHsT85JbjeE8SsajyT9jWFnjwAF9t0fbUcd Vvpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=LEVUzcjDweu3RxATasMPdWrNCDFTC29sZxdxxneukjs=; b=Xtd+gFUW7nOi23gNTd3mgByBZj+9Nh6E+ZEDRKoFKhKXbaa5H+dpy9qozVmCCSgB0R z/RGmsxusE4DSwgiLEmmvL3aGarPGUS+UlRlg9YFggl1KXOJwCQbDUZgYEPu72Me2v7n /uvQOFfth3bKzAvDh+bp53Hi6njPYW0xqDMsmD8HiiXU/gzQFDnBtOSBRAoGQ14p7+yL SAMatwW1WKtSU08jtmSuS+Ppi34bXpddncK8+SEWwxGTS70v+LYmqHpQidy8GgigddCP wPerzuDHq9nTqXsOzUzQziXYbAlq7dJ9+kXAWUgSpDM3VPZ4Uq7SOrnP1k7KDz1AaqcG kdPQ== X-Gm-Message-State: AO0yUKURcPDCYAwhVnGkWsh1ptGzXmytsbiiCXt/mK58jzjEVmJaRyDU 6Oqplte1A2sxjKSS8LVbGdmZ9Q== X-Google-Smtp-Source: AK7set/nojJH+XiFkOkENDuVIhdvuG8a6Cl/5hvtrvJ2Cuwtzh2BvQ8nQ0xrgNP2ilWTvqyVpY1waw== X-Received: by 2002:a17:902:c411:b0:19a:9833:708 with SMTP id k17-20020a170902c41100b0019a98330708mr14006722plk.64.1677147647115; Thu, 23 Feb 2023 02:20:47 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 01/34] e1000e: Fix the code style Date: Thu, 23 Feb 2023 19:19:45 +0900 Message-Id: <20230223102018.141748-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1033; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1033.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147780307100009 igb implementation first starts off by copying e1000e code. Correct the code style before that. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/e1000.c | 41 ++++++++-------- hw/net/e1000e.c | 72 ++++++++++++++-------------- hw/net/e1000e_core.c | 103 ++++++++++++++++++++++------------------- hw/net/e1000e_core.h | 66 +++++++++++++------------- hw/net/e1000x_common.h | 44 +++++++++--------- 5 files changed, 168 insertions(+), 158 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 7efb8a4c52..8ee30aa37c 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -808,10 +808,11 @@ receive_filter(E1000State *s, const uint8_t *buf, int= size) if (e1000x_is_vlan_packet(buf, le16_to_cpu(s->mac_reg[VET])) && e1000x_vlan_rx_filter_enabled(s->mac_reg)) { uint16_t vid =3D lduw_be_p(buf + 14); - uint32_t vfta =3D ldl_le_p((uint32_t*)(s->mac_reg + VFTA) + + uint32_t vfta =3D ldl_le_p((uint32_t *)(s->mac_reg + VFTA) + ((vid >> 5) & 0x7f)); - if ((vfta & (1 << (vid & 0x1f))) =3D=3D 0) + if ((vfta & (1 << (vid & 0x1f))) =3D=3D 0) { return 0; + } } =20 if (!isbcast && !ismcast && (rctl & E1000_RCTL_UPE)) { /* promiscuous = ucast */ @@ -1220,16 +1221,16 @@ static const readops macreg_readops[] =3D { [TDFPC] =3D mac_low13_read, [AIT] =3D mac_low16_read, =20 - [CRCERRS ... MPC] =3D &mac_readreg, - [IP6AT ... IP6AT+3] =3D &mac_readreg, [IP4AT ... IP4AT+6] =3D &mac_= readreg, - [FFLT ... FFLT+6] =3D &mac_low11_read, - [RA ... RA+31] =3D &mac_readreg, - [WUPM ... WUPM+31] =3D &mac_readreg, - [MTA ... MTA+127] =3D &mac_readreg, - [VFTA ... VFTA+127] =3D &mac_readreg, - [FFMT ... FFMT+254] =3D &mac_low4_read, - [FFVT ... FFVT+254] =3D &mac_readreg, - [PBM ... PBM+16383] =3D &mac_readreg, + [CRCERRS ... MPC] =3D &mac_readreg, + [IP6AT ... IP6AT + 3] =3D &mac_readreg, [IP4AT ... IP4AT + 6] =3D &= mac_readreg, + [FFLT ... FFLT + 6] =3D &mac_low11_read, + [RA ... RA + 31] =3D &mac_readreg, + [WUPM ... WUPM + 31] =3D &mac_readreg, + [MTA ... MTA + 127] =3D &mac_readreg, + [VFTA ... VFTA + 127] =3D &mac_readreg, + [FFMT ... FFMT + 254] =3D &mac_low4_read, + [FFVT ... FFVT + 254] =3D &mac_readreg, + [PBM ... PBM + 16383] =3D &mac_readreg, }; enum { NREADOPS =3D ARRAY_SIZE(macreg_readops) }; =20 @@ -1252,14 +1253,14 @@ static const writeops macreg_writeops[] =3D { [RDTR] =3D set_16bit, [RADV] =3D set_16bit, [TADV] =3D set_1= 6bit, [ITR] =3D set_16bit, =20 - [IP6AT ... IP6AT+3] =3D &mac_writereg, [IP4AT ... IP4AT+6] =3D &mac_wr= itereg, - [FFLT ... FFLT+6] =3D &mac_writereg, - [RA ... RA+31] =3D &mac_writereg, - [WUPM ... WUPM+31] =3D &mac_writereg, - [MTA ... MTA+127] =3D &mac_writereg, - [VFTA ... VFTA+127] =3D &mac_writereg, - [FFMT ... FFMT+254] =3D &mac_writereg, [FFVT ... FFVT+254] =3D &mac_wr= itereg, - [PBM ... PBM+16383] =3D &mac_writereg, + [IP6AT ... IP6AT + 3] =3D &mac_writereg, [IP4AT ... IP4AT + 6] =3D &ma= c_writereg, + [FFLT ... FFLT + 6] =3D &mac_writereg, + [RA ... RA + 31] =3D &mac_writereg, + [WUPM ... WUPM + 31] =3D &mac_writereg, + [MTA ... MTA + 127] =3D &mac_writereg, + [VFTA ... VFTA + 127] =3D &mac_writereg, + [FFMT ... FFMT + 254] =3D &mac_writereg, [FFVT ... FFVT + 254] =3D &ma= c_writereg, + [PBM ... PBM + 16383] =3D &mac_writereg, }; =20 enum { NWRITEOPS =3D ARRAY_SIZE(macreg_writeops) }; diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index 7523e9f5d2..8635ca16c6 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -1,37 +1,37 @@ /* -* QEMU INTEL 82574 GbE NIC emulation -* -* Software developer's manuals: -* http://www.intel.com/content/dam/doc/datasheet/82574l-gbe-controller-dat= asheet.pdf -* -* Copyright (c) 2015 Ravello Systems LTD (http://ravellosystems.com) -* Developed by Daynix Computing LTD (http://www.daynix.com) -* -* Authors: -* Dmitry Fleytman -* Leonid Bloch -* Yan Vugenfirer -* -* Based on work done by: -* Nir Peleg, Tutis Systems Ltd. for Qumranet Inc. -* Copyright (c) 2008 Qumranet -* Based on work done by: -* Copyright (c) 2007 Dan Aloni -* Copyright (c) 2004 Antony T Curtis -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see . -*/ + * QEMU INTEL 82574 GbE NIC emulation + * + * Software developer's manuals: + * http://www.intel.com/content/dam/doc/datasheet/82574l-gbe-controller-da= tasheet.pdf + * + * Copyright (c) 2015 Ravello Systems LTD (http://ravellosystems.com) + * Developed by Daynix Computing LTD (http://www.daynix.com) + * + * Authors: + * Dmitry Fleytman + * Leonid Bloch + * Yan Vugenfirer + * + * Based on work done by: + * Nir Peleg, Tutis Systems Ltd. for Qumranet Inc. + * Copyright (c) 2008 Qumranet + * Based on work done by: + * Copyright (c) 2007 Dan Aloni + * Copyright (c) 2004 Antony T Curtis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ =20 #include "qemu/osdep.h" #include "qemu/units.h" @@ -239,9 +239,9 @@ static NetClientInfo net_e1000e_info =3D { }; =20 /* -* EEPROM (NVM) contents documented in Table 36, section 6.1 -* and generally 6.1.2 Software accessed words. -*/ + * EEPROM (NVM) contents documented in Table 36, section 6.1 + * and generally 6.1.2 Software accessed words. + */ static const uint16_t e1000e_eeprom_template[64] =3D { /* Address | Compat. | ImVer | Compat. */ 0x0000, 0x0000, 0x0000, 0x0420, 0xf746, 0x2010, 0xffff, 0xffff, diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index fc9cdb4528..c4be782558 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1,37 +1,37 @@ /* -* Core code for QEMU e1000e emulation -* -* Software developer's manuals: -* http://www.intel.com/content/dam/doc/datasheet/82574l-gbe-controller-dat= asheet.pdf -* -* Copyright (c) 2015 Ravello Systems LTD (http://ravellosystems.com) -* Developed by Daynix Computing LTD (http://www.daynix.com) -* -* Authors: -* Dmitry Fleytman -* Leonid Bloch -* Yan Vugenfirer -* -* Based on work done by: -* Nir Peleg, Tutis Systems Ltd. for Qumranet Inc. -* Copyright (c) 2008 Qumranet -* Based on work done by: -* Copyright (c) 2007 Dan Aloni -* Copyright (c) 2004 Antony T Curtis -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see . -*/ + * Core code for QEMU e1000e emulation + * + * Software developer's manuals: + * http://www.intel.com/content/dam/doc/datasheet/82574l-gbe-controller-da= tasheet.pdf + * + * Copyright (c) 2015 Ravello Systems LTD (http://ravellosystems.com) + * Developed by Daynix Computing LTD (http://www.daynix.com) + * + * Authors: + * Dmitry Fleytman + * Leonid Bloch + * Yan Vugenfirer + * + * Based on work done by: + * Nir Peleg, Tutis Systems Ltd. for Qumranet Inc. + * Copyright (c) 2008 Qumranet + * Based on work done by: + * Copyright (c) 2007 Dan Aloni + * Copyright (c) 2004 Antony T Curtis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ =20 #include "qemu/osdep.h" #include "qemu/log.h" @@ -49,8 +49,9 @@ =20 #include "trace.h" =20 -#define E1000E_MIN_XITR (500) /* No more then 7813 interrupts per - second according to spec 10.2.4.2 */ +/* No more then 7813 interrupts per second according to spec 10.2.4.2 */ +#define E1000E_MIN_XITR (500) + #define E1000E_MAX_TX_FRAGS (64) =20 static inline void @@ -282,14 +283,18 @@ e1000e_intrmgr_delay_rx_causes(E1000ECore *core, uint= 32_t *causes) core->delayed_causes |=3D *causes & delayable_causes; *causes &=3D ~delayable_causes; =20 - /* Check if delayed RX interrupts disabled by client - or if there are causes that cannot be delayed */ + /* + * Check if delayed RX interrupts disabled by client + * or if there are causes that cannot be delayed + */ if ((rdtr =3D=3D 0) || (*causes !=3D 0)) { return false; } =20 - /* Check if delayed RX ACK interrupts disabled by client - and there is an ACK packet received */ + /* + * Check if delayed RX ACK interrupts disabled by client + * and there is an ACK packet received + */ if ((raid =3D=3D 0) && (core->delayed_causes & E1000_ICR_ACK)) { return false; } @@ -2515,7 +2520,8 @@ e1000e_set_icr(E1000ECore *core, int index, uint32_t = val) } =20 icr =3D core->mac[ICR] & ~val; - /* Windows driver expects that the "receive overrun" bit and other + /* + * Windows driver expects that the "receive overrun" bit and other * ones to be cleared when the "Other" bit (#24) is cleared. */ icr =3D (val & E1000_ICR_OTHER) ? (icr & ~E1000_ICR_OTHER_CAUSES) : ic= r; @@ -3269,10 +3275,12 @@ enum { E1000E_NWRITEOPS =3D ARRAY_SIZE(e1000e_macre= g_writeops) }; =20 enum { MAC_ACCESS_PARTIAL =3D 1 }; =20 -/* The array below combines alias offsets of the index values for the +/* + * The array below combines alias offsets of the index values for the * MAC registers that have aliases, with the indication of not fully * implemented registers (lowest bit). This combination is possible - * because all of the offsets are even. */ + * because all of the offsets are even. + */ static const uint16_t mac_reg_access[E1000E_MAC_SIZE] =3D { /* Alias index offsets */ [FCRTL_A] =3D 0x07fe, [FCRTH_A] =3D 0x0802, @@ -3536,10 +3544,10 @@ void e1000e_core_pre_save(E1000ECore *core) NetClientState *nc =3D qemu_get_queue(core->owner_nic); =20 /* - * If link is down and auto-negotiation is supported and ongoing, - * complete auto-negotiation immediately. This allows us to look - * at MII_SR_AUTONEG_COMPLETE to infer link status on load. - */ + * If link is down and auto-negotiation is supported and ongoing, + * complete auto-negotiation immediately. This allows us to look + * at MII_SR_AUTONEG_COMPLETE to infer link status on load. + */ if (nc->link_down && e1000e_have_autoneg(core)) { core->phy[0][PHY_STATUS] |=3D MII_SR_AUTONEG_COMPLETE; e1000e_update_flowctl_status(core); @@ -3557,7 +3565,8 @@ e1000e_core_post_load(E1000ECore *core) { NetClientState *nc =3D qemu_get_queue(core->owner_nic); =20 - /* nc.link_down can't be migrated, so infer link_down according + /* + * nc.link_down can't be migrated, so infer link_down according * to link status bit in core.mac[STATUS]. */ nc->link_down =3D (core->mac[STATUS] & E1000_STATUS_LU) =3D=3D 0; diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h index 4ddb4d2c39..b8f38c47a0 100644 --- a/hw/net/e1000e_core.h +++ b/hw/net/e1000e_core.h @@ -1,37 +1,37 @@ /* -* Core code for QEMU e1000e emulation -* -* Software developer's manuals: -* http://www.intel.com/content/dam/doc/datasheet/82574l-gbe-controller-dat= asheet.pdf -* -* Copyright (c) 2015 Ravello Systems LTD (http://ravellosystems.com) -* Developed by Daynix Computing LTD (http://www.daynix.com) -* -* Authors: -* Dmitry Fleytman -* Leonid Bloch -* Yan Vugenfirer -* -* Based on work done by: -* Nir Peleg, Tutis Systems Ltd. for Qumranet Inc. -* Copyright (c) 2008 Qumranet -* Based on work done by: -* Copyright (c) 2007 Dan Aloni -* Copyright (c) 2004 Antony T Curtis -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see . -*/ + * Core code for QEMU e1000e emulation + * + * Software developer's manuals: + * http://www.intel.com/content/dam/doc/datasheet/82574l-gbe-controller-da= tasheet.pdf + * + * Copyright (c) 2015 Ravello Systems LTD (http://ravellosystems.com) + * Developed by Daynix Computing LTD (http://www.daynix.com) + * + * Authors: + * Dmitry Fleytman + * Leonid Bloch + * Yan Vugenfirer + * + * Based on work done by: + * Nir Peleg, Tutis Systems Ltd. for Qumranet Inc. + * Copyright (c) 2008 Qumranet + * Based on work done by: + * Copyright (c) 2007 Dan Aloni + * Copyright (c) 2004 Antony T Curtis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ =20 #ifndef HW_NET_E1000E_CORE_H #define HW_NET_E1000E_CORE_H diff --git a/hw/net/e1000x_common.h b/hw/net/e1000x_common.h index b7742775c4..bc1ee75b04 100644 --- a/hw/net/e1000x_common.h +++ b/hw/net/e1000x_common.h @@ -1,26 +1,26 @@ /* -* QEMU e1000(e) emulation - shared code -* -* Copyright (c) 2008 Qumranet -* -* Based on work done by: -* Nir Peleg, Tutis Systems Ltd. for Qumranet Inc. -* Copyright (c) 2007 Dan Aloni -* Copyright (c) 2004 Antony T Curtis -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see . -*/ + * QEMU e1000(e) emulation - shared code + * + * Copyright (c) 2008 Qumranet + * + * Based on work done by: + * Nir Peleg, Tutis Systems Ltd. for Qumranet Inc. + * Copyright (c) 2007 Dan Aloni + * Copyright (c) 2004 Antony T Curtis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ =20 #ifndef HW_NET_E1000X_COMMON_H #define HW_NET_E1000X_COMMON_H --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147708; cv=none; d=zohomail.com; s=zohoarc; b=NAJkUSb7PZjnF2VshP/fol4dkBxS2XSnF1Y+B5TrIzARoFvB9Tq/Wpl6JnLsveD/Av1bfQ1IQZaoVfZxDs6x/gCJ9KEg/iq72odAFqKMFYv2JKJW1PEUYVchHETeqTqfNfwhhN2cWCiaP+tvNhIpjDZVJtUcOTNt9yws/w5LfA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147708; 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=mc6N+3X4DyWhP6LHvz3xiMiOtzW5YFnluXUsmSP0zdw=; b=DJ3nIr2rP9AA7vp0eOvPQDReP2v3wtuVj/XbBKLEDU3TZqyg3dLavK3xiRbMWAYGDqcJiEb1lWroG4xIhhPxp4z0m0L5Jstp3cirUghbJfKpjncMDwz/a6nFJtkJjRme5UzhE4AcY2YUoh4MiqEtzg/B760E+jltoNMjkgQ1ZA0= 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+importer2=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 16771477079881012.035632938238; Thu, 23 Feb 2023 02:21:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8id-0005tO-Re; Thu, 23 Feb 2023 05:20:55 -0500 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 1pV8ib-0005sn-9d for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:20:54 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8iZ-00016b-RP for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:20:53 -0500 Received: by mail-pl1-x62b.google.com with SMTP id l15so13372528pls.1 for ; Thu, 23 Feb 2023 02:20:51 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:20:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=mc6N+3X4DyWhP6LHvz3xiMiOtzW5YFnluXUsmSP0zdw=; b=bXdx5tZURqiMcloATSuB+Fi8uaKCVz2icK42YkcP2huR1AECt0IsatlmdBb/7LQW0O 6d13Flbs6OuHM+2/lQk1xWpx/sslCvjFgDhzqz0F32FfRPaASdjGBzxB2M6XYPZ+f097 hYYlhRIj62yasnZ8G2PBBb1Xwzh7W0yTKyzwn+EkMKHxTzW87EfixLhr6LZS/NvekkPC eAryowJP4cfAbWrLob5Eyiox8ReMr2+TjFqBvBaogXBm4pwx2AYkR36iHGPdVlR0xdY5 5lg31P4czWwa++3WZYGKWjhf2bneBahGxQ5oAmIN1gxC+1DTbBtlLDvAsgnmwDfWWFd2 HH6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=mc6N+3X4DyWhP6LHvz3xiMiOtzW5YFnluXUsmSP0zdw=; b=XAYyjU4bA53kAs0oG/55fPydbXIGEmtGnstzCNYw3QW4kI2xt6V8nmiRQba/FaTLo9 qJleFgJBn99i9+zBky4bwsJlQSpnRXtoIveBb2ULFB7Vb5qKuw75Dyfa71nqFd8VXfyb rJCmcYKdxA6xmgZmUMNWcCrCiS+kJ/rQoTB9PYFNaTQC1rd+DJU26KPmf/CTJRQHvG7+ PPA6dpB+Le7kYRoIu0M/DAX+92hiS+EaoZG5c1UCs6GzZzQcxS1oeoyZGAQFqqqvJ1cg /TAPubw6wxEDYeA1/nyijfGpFjniBc7Gj18zuKg8Xc2rby81r9ZK2xJeDjcZXw5lJrwe r/Ew== X-Gm-Message-State: AO0yUKW8nHizTQ4u8vby9cSZa3NMOJaNpWLQsMleA7lFBeR2kMfukAp4 ZBD6L328FbW6l2R3JeIDzMp0qQ== X-Google-Smtp-Source: AK7set8zQYzO7YDWmw20LUJkXD4UOE2Y7FdYnH41bMoxLJVaph45tUwqGWDR5sk3yxEwNcWe2TGBlQ== X-Received: by 2002:a17:903:124a:b0:196:8d33:f083 with SMTP id u10-20020a170903124a00b001968d33f083mr13764226plh.28.1677147650408; Thu, 23 Feb 2023 02:20:50 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 02/34] hw/net: Add more MII definitions Date: Thu, 23 Feb 2023 19:19:46 +0900 Message-Id: <20230223102018.141748-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62b.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147710174100002 Content-Type: text/plain; charset="utf-8" The definitions will be used by igb. Signed-off-by: Akihiko Odaki --- include/hw/net/mii.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/hw/net/mii.h b/include/hw/net/mii.h index 4ae4dcce7e..c6a767a49a 100644 --- a/include/hw/net/mii.h +++ b/include/hw/net/mii.h @@ -81,20 +81,31 @@ #define MII_ANLPAR_ACK (1 << 14) #define MII_ANLPAR_PAUSEASY (1 << 11) /* can pause asymmetrically */ #define MII_ANLPAR_PAUSE (1 << 10) /* can pause */ +#define MII_ANLPAR_T4 (1 << 9) #define MII_ANLPAR_TXFD (1 << 8) #define MII_ANLPAR_TX (1 << 7) #define MII_ANLPAR_10FD (1 << 6) #define MII_ANLPAR_10 (1 << 5) #define MII_ANLPAR_CSMACD (1 << 0) =20 -#define MII_ANER_NWAY (1 << 0) /* Can do N-way auto-nego */ +#define MII_ANER_NP (1 << 2) /* Next Page Able */ +#define MII_ANER_NWAY (1 << 0) /* Can do N-way auto-nego */ =20 +#define MII_ANNP_MP (1 << 13) /* Message Page */ + +#define MII_CTRL1000_MASTER (1 << 11) /* MASTER-SLAVE Manual Configuration= Value */ +#define MII_CTRL1000_PORT (1 << 10) /* T2_Repeater/DTE bit */ #define MII_CTRL1000_FULL (1 << 9) /* 1000BASE-T full duplex */ #define MII_CTRL1000_HALF (1 << 8) /* 1000BASE-T half duplex */ =20 +#define MII_STAT1000_LOK (1 << 13) /* Local Receiver Status */ +#define MII_STAT1000_ROK (1 << 12) /* Remote Receiver Status */ #define MII_STAT1000_FULL (1 << 11) /* 1000BASE-T full duplex */ #define MII_STAT1000_HALF (1 << 10) /* 1000BASE-T half duplex */ =20 +#define MII_EXTSTAT_1000T_FD (1 << 13) /* 1000BASE-T Full Duplex */ +#define MII_EXTSTAT_1000T_HD (1 << 12) /* 1000BASE-T Half Duplex */ + /* List of vendor identifiers */ /* RealTek 8201 */ #define RTL8201CP_PHYID1 0x0000 --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147763; cv=none; d=zohomail.com; s=zohoarc; b=BjX2+6MD/4EMNXrioOckJaZX4YKgp1lU3hFDhV+40cITbu2MI1fleQDymBmvqDmjWVRJA6Ty19XLQxzUGXs0ADpAlXFXpp3lN55hL2h1wLorq2s78p3zRiz16V4TJsJX37pSvP+VunNPmQBzrt4t3gzJsZgOlzQbfMMYCrDbp18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147763; h=Content-Type: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=TIOeRLbPMJAuFIcNQlo+uN8HcDv0eMoJ6T+gd5Ur6Ps=; b=mq2Z8MDoAqkOOF8kd90Nq4CH9rr5kc5KWIlKEHYiP9K7Yefb+rYHxNLInAS/ai0SNKBC45GKlSIFBIU+cfKI+cFRslvZFoEWke70vARTtL+rn5ZXfQtoaPIcAMMH1W4x2L4SbHWNcPk9Uatf9dU4+f97ob1D4SPb0vKMKL+K0wk= 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+importer2=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 1677147763155480.35312292042; Thu, 23 Feb 2023 02:22:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8if-0005uG-L6; Thu, 23 Feb 2023 05:20:57 -0500 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 1pV8ie-0005u4-OC for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:20:56 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8id-0001AQ-3d for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:20:56 -0500 Received: by mail-pl1-x632.google.com with SMTP id c1so12467338plg.4 for ; Thu, 23 Feb 2023 02:20:54 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:20:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=TIOeRLbPMJAuFIcNQlo+uN8HcDv0eMoJ6T+gd5Ur6Ps=; b=RUSv2iOpdtJzpKY69Qq2qTQCZRma5tYQh+ugZAlULulgwZLPwzQ8SmdzV8cq1qLSuc TEQTeTBwNGun8Dz/fbcOBGZQ8CtGk3NREbEdJ14AQavErIQNiRgCcU46/3mcIcF01sIR wIH1Ip9rlEmE4FH3aIUsdyYRVEBpFB0w8pkU8/t75gVpnXVuQp1OaFIqGTUjFqtOz9s3 zpMhZJzO1u5KKMJHMOIXpHsHjLFr51dviUpG4DWE72arC9NvejxGHBdlR8z8XpJLdmuw QWd3upHoQe9QApvKUOlPL/fv07gBmYBGhuvfOuoEmMtcplREGWnHNAWRwejohPyU6AM/ QgZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=TIOeRLbPMJAuFIcNQlo+uN8HcDv0eMoJ6T+gd5Ur6Ps=; b=bsc7WShlOvMj9KOgnESnjOuH5cfNvJMZks1+fNGSe5/IBDrap6+mdsgCB+vRhtkTj7 bLll6kAPpa/JskWDeWtMP9QB89go2Vuoc90tK/WbEJTy9hWu3Km+ltnFqDWEvrB58nPT DKDnd72dJYer6MOCar6GG17Un8qZ5K175f7qmCH6JZSA0iO0aXqbFqzT5nWr941s9Jwr 50AXBIbO91Tt/zaPXR9Grh4BLQ7N4fOAElNRXTQzLzCT6MuOt9nyaQVWov36FyvbIdlB JcfiRWtz3ina06QrLLWX6nstAU/bVRBymZvQiSFrnpD4EKa/pxxS1uO2KZuVwUfvUo1P B/OA== X-Gm-Message-State: AO0yUKWLF7rRN/Eh7aWxVj2EcucUJ44fzAaxF6VAtQvIhXg41tXUZ8ft 49dJN/XKuddU2Zs3CRT5FUMXAw== X-Google-Smtp-Source: AK7set8j4WFGo5qJiFXnc5rM9lFJHDgJVlcyhmIVRxxtZqhyN08N796SLwHCbdf09NSs0e9tXFFYLA== X-Received: by 2002:a17:902:ec82:b0:198:ff11:2600 with SMTP id x2-20020a170902ec8200b00198ff112600mr13986321plg.2.1677147653814; Thu, 23 Feb 2023 02:20:53 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 03/34] fsl_etsec: Use hw/net/mii.h Date: Thu, 23 Feb 2023 19:19:47 +0900 Message-Id: <20230223102018.141748-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::632; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x632.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147764135100003 hw/net/mii.h provides common definitions for MII. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/fsl_etsec/etsec.c | 11 ++++++----- hw/net/fsl_etsec/etsec.h | 17 ----------------- hw/net/fsl_etsec/miim.c | 5 +++-- include/hw/net/mii.h | 1 + 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c index c753bfb3a8..798ea33d08 100644 --- a/hw/net/fsl_etsec/etsec.c +++ b/hw/net/fsl_etsec/etsec.c @@ -29,6 +29,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" #include "hw/irq.h" +#include "hw/net/mii.h" #include "hw/ptimer.h" #include "hw/qdev-properties.h" #include "etsec.h" @@ -339,11 +340,11 @@ static void etsec_reset(DeviceState *d) etsec->rx_buffer_len =3D 0; =20 etsec->phy_status =3D - MII_SR_EXTENDED_CAPS | MII_SR_LINK_STATUS | MII_SR_AUTONEG_CA= PS | - MII_SR_AUTONEG_COMPLETE | MII_SR_PREAMBLE_SUPPRESS | - MII_SR_EXTENDED_STATUS | MII_SR_100T2_HD_CAPS | MII_SR_100T2_FD_C= APS | - MII_SR_10T_HD_CAPS | MII_SR_10T_FD_CAPS | MII_SR_100X_HD_CA= PS | - MII_SR_100X_FD_CAPS | MII_SR_100T4_CAPS; + MII_BMSR_EXTCAP | MII_BMSR_LINK_ST | MII_BMSR_AUTONEG | + MII_BMSR_AN_COMP | MII_BMSR_MFPS | MII_BMSR_EXTSTAT | + MII_BMSR_100T2_HD | MII_BMSR_100T2_FD | + MII_BMSR_10T_HD | MII_BMSR_10T_FD | + MII_BMSR_100TX_HD | MII_BMSR_100TX_FD | MII_BMSR_100T4; =20 etsec_update_irq(etsec); } diff --git a/hw/net/fsl_etsec/etsec.h b/hw/net/fsl_etsec/etsec.h index 3c625c955c..3860864a3f 100644 --- a/hw/net/fsl_etsec/etsec.h +++ b/hw/net/fsl_etsec/etsec.h @@ -76,23 +76,6 @@ typedef struct eTSEC_rxtx_bd { #define FCB_TX_CTU (1 << 1) #define FCB_TX_NPH (1 << 0) =20 -/* PHY Status Register */ -#define MII_SR_EXTENDED_CAPS 0x0001 /* Extended register capabiliti= es */ -#define MII_SR_JABBER_DETECT 0x0002 /* Jabber Detected */ -#define MII_SR_LINK_STATUS 0x0004 /* Link Status 1 =3D link */ -#define MII_SR_AUTONEG_CAPS 0x0008 /* Auto Neg Capable */ -#define MII_SR_REMOTE_FAULT 0x0010 /* Remote Fault Detect */ -#define MII_SR_AUTONEG_COMPLETE 0x0020 /* Auto Neg Complete */ -#define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */ -#define MII_SR_EXTENDED_STATUS 0x0100 /* Ext. status info in Reg 0x0F= */ -#define MII_SR_100T2_HD_CAPS 0x0200 /* 100T2 Half Duplex Capable */ -#define MII_SR_100T2_FD_CAPS 0x0400 /* 100T2 Full Duplex Capable */ -#define MII_SR_10T_HD_CAPS 0x0800 /* 10T Half Duplex Capable */ -#define MII_SR_10T_FD_CAPS 0x1000 /* 10T Full Duplex Capable */ -#define MII_SR_100X_HD_CAPS 0x2000 /* 100X Half Duplex Capable */ -#define MII_SR_100X_FD_CAPS 0x4000 /* 100X Full Duplex Capable */ -#define MII_SR_100T4_CAPS 0x8000 /* 100T4 Capable */ - /* eTSEC */ =20 /* Number of register in the device */ diff --git a/hw/net/fsl_etsec/miim.c b/hw/net/fsl_etsec/miim.c index 6bba01c82a..b48d2cb57b 100644 --- a/hw/net/fsl_etsec/miim.c +++ b/hw/net/fsl_etsec/miim.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "hw/net/mii.h" #include "etsec.h" #include "registers.h" =20 @@ -140,8 +141,8 @@ void etsec_miim_link_status(eTSEC *etsec, NetClientStat= e *nc) { /* Set link status */ if (nc->link_down) { - etsec->phy_status &=3D ~MII_SR_LINK_STATUS; + etsec->phy_status &=3D ~MII_BMSR_LINK_ST; } else { - etsec->phy_status |=3D MII_SR_LINK_STATUS; + etsec->phy_status |=3D MII_BMSR_LINK_ST; } } diff --git a/include/hw/net/mii.h b/include/hw/net/mii.h index c6a767a49a..ed1bb52b0f 100644 --- a/include/hw/net/mii.h +++ b/include/hw/net/mii.h @@ -55,6 +55,7 @@ #define MII_BMCR_CTST (1 << 7) /* Collision test */ #define MII_BMCR_SPEED1000 (1 << 6) /* MSB of Speed (1000) */ =20 +#define MII_BMSR_100T4 (1 << 15) /* Can do 100mbps T4 */ #define MII_BMSR_100TX_FD (1 << 14) /* Can do 100mbps, full-duplex */ #define MII_BMSR_100TX_HD (1 << 13) /* Can do 100mbps, half-duplex */ #define MII_BMSR_10T_FD (1 << 12) /* Can do 10mbps, full-duplex */ --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147916; cv=none; d=zohomail.com; s=zohoarc; b=KgRw+ix0L3SFF1dTNOjjuHkIHSik52xGYLq9OPl7s4kiMMv4jh8jodGrZYanQuEJkevedtgqHKi+bdw16AVREKP6niA37cSm8rvfOfsO8fLtASCL1VePky1f4YMLyiyDzlrzBUV2d6A6/QZwLP4FM/AMVxhFj+722GTaEWKuqCs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147916; h=Content-Type: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=vuOZkh7/FsK7pTAIZRY0T7k4W6zYsds58jVwZOXAh5g=; b=E2/G4eBDmkiBDWbQoutEiQygkM4kwlrCEsVpYBSJQaw636C3sulmC36hzXiInfVm+Zsxhrpghz0DTNLKrWzml1hUGK23iP5opArUaIxeDokNmnuVFnOHl+JqinjmMvTAd4Fj8riXxZKx7+6iH4J/U5A7WCVm+M1GqdX+nf1tMoc= 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+importer2=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 1677147916775490.78310377690934; Thu, 23 Feb 2023 02:25:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8il-0005wK-C5; Thu, 23 Feb 2023 05:21:03 -0500 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 1pV8ij-0005v5-Mi for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:01 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8ih-0001GF-5E for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:01 -0500 Received: by mail-pj1-x1029.google.com with SMTP id oe18-20020a17090b395200b00236a0d55d3aso12032021pjb.3 for ; Thu, 23 Feb 2023 02:20:58 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:20:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=vuOZkh7/FsK7pTAIZRY0T7k4W6zYsds58jVwZOXAh5g=; b=EgPJ68twT3m5OfwiW9mFdpczro8oYI8enwGViG9lIGyeOQheY0r4hUS1IAbPuls454 /IOV3wrp4kxQWtgtnBcj60GIvv8D/Tefq8+uUrP4yFak9qbh2jGJd8jdX6bhXDTUKiLD 27SrVZDPWM0vi+/2GC5I/iWpD7NCZy18yfNunPuZyzxFgQGLOyET93MVs5ymLHxv9vwp riK/rCgX8HfBkbgrlFUFGyp9bA4NiD1+490xFvh3LweUpfasBaT+6hZbsYRjGUN083fS hRqXIzmCfLM+6iujy/7sxmWSQrMFoMdErj25LX/lbLSYHOo5QBwrgGW24whVRr0su+XE XLOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vuOZkh7/FsK7pTAIZRY0T7k4W6zYsds58jVwZOXAh5g=; b=0B7CzaxkVLRgH/NadOUM9618UaSsYaajmJyWXLop4d3IIz54XKS77OqmDlY8rBVNRJ b19Ekf5QTB32YKMOvN6nRKQFFCch0Cki85YKgruEZWaazaQsgKTgBIA8iXk/s8OJeNji bX48t6dL60UAIPPDHNxuPW+fgcStF6T5Zlei8YCO0Da/DgApnjjNr/g0lkgYvQWhS17w j3j6d9SFrRF6MG7/R1CsKJ1nfizJZkel1gj8JcgzDW+Ara5dqlg5T+srym77075eOZYo 4uJIwCBMAcFpguGHaJkAvNBzyXR8gtRL6D+Er3gu+qYyIBCKNJlQ2Xx8hQTOy5Tfi9IO ErdA== X-Gm-Message-State: AO0yUKV8agio4+FvAXsbAHdBEqGJW+YyMHMtHKU5PVLGgQjmlKTmPJuv teTxI5vqwdRuFAhqWkIzsW0ALg== X-Google-Smtp-Source: AK7set+sL4+fUUBtxBcitE0Q/TpHWmd1b2VAmWSz7Mv6jYtAmt8Y0AS2+M2WIhwXtZjsagQ612Lu4A== X-Received: by 2002:a17:903:1ca:b0:199:41a5:1085 with SMTP id e10-20020a17090301ca00b0019941a51085mr15861093plh.33.1677147657619; Thu, 23 Feb 2023 02:20:57 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 04/34] e1000: Use hw/net/mii.h Date: Thu, 23 Feb 2023 19:19:48 +0900 Message-Id: <20230223102018.141748-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1029; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1029.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147917232100007 hw/net/mii.h provides common definitions for MII. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/e1000.c | 86 ++++++++++++++++++------------------ hw/net/e1000_regs.h | 46 -------------------- hw/net/e1000e.c | 1 + hw/net/e1000e_core.c | 99 +++++++++++++++++++++--------------------- hw/net/e1000x_common.c | 5 ++- hw/net/e1000x_common.h | 8 ++-- 6 files changed, 101 insertions(+), 144 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 8ee30aa37c..9619a2e481 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -26,6 +26,7 @@ =20 =20 #include "qemu/osdep.h" +#include "hw/net/mii.h" #include "hw/pci/pci_device.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" @@ -181,67 +182,67 @@ e1000_autoneg_done(E1000State *s) static bool have_autoneg(E1000State *s) { - return chkflag(AUTONEG) && (s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN); + return chkflag(AUTONEG) && (s->phy_reg[MII_BMCR] & MII_BMCR_AUTOEN); } =20 static void set_phy_ctrl(E1000State *s, int index, uint16_t val) { - /* bits 0-5 reserved; MII_CR_[RESTART_AUTO_NEG,RESET] are self clearin= g */ - s->phy_reg[PHY_CTRL] =3D val & ~(0x3f | - MII_CR_RESET | - MII_CR_RESTART_AUTO_NEG); + /* bits 0-5 reserved; MII_BMCR_[ANRESTART,RESET] are self clearing */ + s->phy_reg[MII_BMCR] =3D val & ~(0x3f | + MII_BMCR_RESET | + MII_BMCR_ANRESTART); =20 /* * QEMU 1.3 does not support link auto-negotiation emulation, so if we * migrate during auto negotiation, after migration the link will be * down. */ - if (have_autoneg(s) && (val & MII_CR_RESTART_AUTO_NEG)) { + if (have_autoneg(s) && (val & MII_BMCR_ANRESTART)) { e1000x_restart_autoneg(s->mac_reg, s->phy_reg, s->autoneg_timer); } } =20 static void (*phyreg_writeops[])(E1000State *, int, uint16_t) =3D { - [PHY_CTRL] =3D set_phy_ctrl, + [MII_BMCR] =3D set_phy_ctrl, }; =20 enum { NPHYWRITEOPS =3D ARRAY_SIZE(phyreg_writeops) }; =20 enum { PHY_R =3D 1, PHY_W =3D 2, PHY_RW =3D PHY_R | PHY_W }; static const char phy_regcap[0x20] =3D { - [PHY_STATUS] =3D PHY_R, [M88E1000_EXT_PHY_SPEC_CTRL] =3D PHY_= RW, - [PHY_ID1] =3D PHY_R, [M88E1000_PHY_SPEC_CTRL] =3D PHY_= RW, - [PHY_CTRL] =3D PHY_RW, [PHY_1000T_CTRL] =3D PHY_= RW, - [PHY_LP_ABILITY] =3D PHY_R, [PHY_1000T_STATUS] =3D PHY_= R, - [PHY_AUTONEG_ADV] =3D PHY_RW, [M88E1000_RX_ERR_CNTR] =3D PHY_= R, - [PHY_ID2] =3D PHY_R, [M88E1000_PHY_SPEC_STATUS] =3D PHY_= R, - [PHY_AUTONEG_EXP] =3D PHY_R, + [MII_BMSR] =3D PHY_R, [M88E1000_EXT_PHY_SPEC_CTRL] =3D PHY_RW, + [MII_PHYID1] =3D PHY_R, [M88E1000_PHY_SPEC_CTRL] =3D PHY_RW, + [MII_BMCR] =3D PHY_RW, [MII_CTRL1000] =3D PHY_RW, + [MII_ANLPAR] =3D PHY_R, [MII_STAT1000] =3D PHY_R, + [MII_ANAR] =3D PHY_RW, [M88E1000_RX_ERR_CNTR] =3D PHY_R, + [MII_PHYID2] =3D PHY_R, [M88E1000_PHY_SPEC_STATUS] =3D PHY_R, + [MII_ANER] =3D PHY_R, }; =20 -/* PHY_ID2 documented in 8254x_GBe_SDM.pdf, pp. 250 */ +/* MII_PHYID2 documented in 8254x_GBe_SDM.pdf, pp. 250 */ static const uint16_t phy_reg_init[] =3D { - [PHY_CTRL] =3D MII_CR_SPEED_SELECT_MSB | - MII_CR_FULL_DUPLEX | - MII_CR_AUTO_NEG_EN, - - [PHY_STATUS] =3D MII_SR_EXTENDED_CAPS | - MII_SR_LINK_STATUS | /* link initially up */ - MII_SR_AUTONEG_CAPS | - /* MII_SR_AUTONEG_COMPLETE: initially NOT completed */ - MII_SR_PREAMBLE_SUPPRESS | - MII_SR_EXTENDED_STATUS | - MII_SR_10T_HD_CAPS | - MII_SR_10T_FD_CAPS | - MII_SR_100X_HD_CAPS | - MII_SR_100X_FD_CAPS, - - [PHY_ID1] =3D 0x141, - /* [PHY_ID2] configured per DevId, from e1000_reset() */ - [PHY_AUTONEG_ADV] =3D 0xde1, - [PHY_LP_ABILITY] =3D 0x1e0, - [PHY_1000T_CTRL] =3D 0x0e00, - [PHY_1000T_STATUS] =3D 0x3c00, + [MII_BMCR] =3D MII_BMCR_SPEED1000 | + MII_BMCR_FD | + MII_BMCR_AUTOEN, + + [MII_BMSR] =3D MII_BMSR_EXTCAP | + MII_BMSR_LINK_ST | /* link initially up */ + MII_BMSR_AUTONEG | + /* MII_BMSR_AN_COMP: initially NOT completed */ + MII_BMSR_MFPS | + MII_BMSR_EXTSTAT | + MII_BMSR_10T_HD | + MII_BMSR_10T_FD | + MII_BMSR_100TX_HD | + MII_BMSR_100TX_FD, + + [MII_PHYID1] =3D 0x141, + /* [MII_PHYID2] configured per DevId, from e1000_reset() */ + [MII_ANAR] =3D 0xde1, + [MII_ANLPAR] =3D 0x1e0, + [MII_CTRL1000] =3D 0x0e00, + [MII_STAT1000] =3D 0x3c00, [M88E1000_PHY_SPEC_CTRL] =3D 0x360, [M88E1000_PHY_SPEC_STATUS] =3D 0xac00, [M88E1000_EXT_PHY_SPEC_CTRL] =3D 0x0d60, @@ -387,7 +388,7 @@ static void e1000_reset(void *opaque) d->mit_ide =3D 0; memset(d->phy_reg, 0, sizeof d->phy_reg); memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init); - d->phy_reg[PHY_ID2] =3D edc->phy_id2; + d->phy_reg[MII_PHYID2] =3D edc->phy_id2; memset(d->mac_reg, 0, sizeof d->mac_reg); memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init); d->rxbuf_min_shift =3D 1; @@ -561,7 +562,7 @@ e1000_send_packet(E1000State *s, const uint8_t *buf, in= t size) PTC1023, PTC1522 }; =20 NetClientState *nc =3D qemu_get_queue(s->nic); - if (s->phy_reg[PHY_CTRL] & MII_CR_LOOPBACK) { + if (s->phy_reg[MII_BMCR] & MII_BMCR_LOOPBACK) { qemu_receive_packet(nc, buf, size); } else { qemu_send_packet(nc, buf, size); @@ -842,7 +843,7 @@ e1000_set_link_status(NetClientState *nc) e1000x_update_regs_on_link_down(s->mac_reg, s->phy_reg); } else { if (have_autoneg(s) && - !(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) { + !(s->phy_reg[MII_BMSR] & MII_BMSR_AN_COMP)) { e1000x_restart_autoneg(s->mac_reg, s->phy_reg, s->autoneg_time= r); } else { e1000_link_up(s); @@ -1416,10 +1417,10 @@ static int e1000_pre_save(void *opaque) /* * If link is down and auto-negotiation is supported and ongoing, * complete auto-negotiation immediately. This allows us to look - * at MII_SR_AUTONEG_COMPLETE to infer link status on load. + * at MII_BMSR_AN_COMP to infer link status on load. */ if (nc->link_down && have_autoneg(s)) { - s->phy_reg[PHY_STATUS] |=3D MII_SR_AUTONEG_COMPLETE; + s->phy_reg[MII_BMSR] |=3D MII_BMSR_AN_COMP; } =20 /* Decide which set of props to migrate in the main structure */ @@ -1458,8 +1459,7 @@ static int e1000_post_load(void *opaque, int version_= id) * Alternatively, restart link negotiation if it was in progress. */ nc->link_down =3D (s->mac_reg[STATUS] & E1000_STATUS_LU) =3D=3D 0; =20 - if (have_autoneg(s) && - !(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) { + if (have_autoneg(s) && !(s->phy_reg[MII_BMSR] & MII_BMSR_AN_COMP)) { nc->link_down =3D false; timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); diff --git a/hw/net/e1000_regs.h b/hw/net/e1000_regs.h index 59e050742b..59d6eb3189 100644 --- a/hw/net/e1000_regs.h +++ b/hw/net/e1000_regs.h @@ -474,20 +474,6 @@ #define E1000_TARC_ENABLE BIT(10) =20 /* PHY 1000 MII Register/Bit Definitions */ -/* PHY Registers defined by IEEE */ -#define PHY_CTRL 0x00 /* Control Register */ -#define PHY_STATUS 0x01 /* Status Regiser */ -#define PHY_ID1 0x02 /* Phy Id Reg (word 1) */ -#define PHY_ID2 0x03 /* Phy Id Reg (word 2) */ -#define PHY_AUTONEG_ADV 0x04 /* Autoneg Advertisement */ -#define PHY_LP_ABILITY 0x05 /* Link Partner Ability (Base Page) */ -#define PHY_AUTONEG_EXP 0x06 /* Autoneg Expansion Reg */ -#define PHY_NEXT_PAGE_TX 0x07 /* Next Page TX */ -#define PHY_LP_NEXT_PAGE 0x08 /* Link Partner Next Page */ -#define PHY_1000T_CTRL 0x09 /* 1000Base-T Control Reg */ -#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */ -#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */ - /* 82574-specific registers */ #define PHY_COPPER_CTRL1 0x10 /* Copper Specific Control Register 1 */ #define PHY_COPPER_STAT1 0x11 /* Copper Specific Status Register 1 */ @@ -539,38 +525,6 @@ #define M88E1000_PHY_VCO_REG_BIT8 0x100 /* Bits 8 & 11 are adjusted for */ #define M88E1000_PHY_VCO_REG_BIT11 0x800 /* improved BER performance */ =20 -/* PHY Control Register */ -#define MII_CR_SPEED_SELECT_MSB 0x0040 /* bits 6,13: 10=3D1000, 01=3D100, = 00=3D10 */ -#define MII_CR_COLL_TEST_ENABLE 0x0080 /* Collision test enable */ -#define MII_CR_FULL_DUPLEX 0x0100 /* FDX =3D1, half duplex =3D0 */ -#define MII_CR_RESTART_AUTO_NEG 0x0200 /* Restart auto negotiation */ -#define MII_CR_ISOLATE 0x0400 /* Isolate PHY from MII */ -#define MII_CR_POWER_DOWN 0x0800 /* Power down */ -#define MII_CR_AUTO_NEG_EN 0x1000 /* Auto Neg Enable */ -#define MII_CR_SPEED_SELECT_LSB 0x2000 /* bits 6,13: 10=3D1000, 01=3D100, = 00=3D10 */ -#define MII_CR_LOOPBACK 0x4000 /* 0 =3D normal, 1 =3D loopback */ -#define MII_CR_RESET 0x8000 /* 0 =3D normal, 1 =3D PHY reset */ - -/* PHY Status Register */ -#define MII_SR_EXTENDED_CAPS 0x0001 /* Extended register capabiliti= es */ -#define MII_SR_JABBER_DETECT 0x0002 /* Jabber Detected */ -#define MII_SR_LINK_STATUS 0x0004 /* Link Status 1 =3D link */ -#define MII_SR_AUTONEG_CAPS 0x0008 /* Auto Neg Capable */ -#define MII_SR_REMOTE_FAULT 0x0010 /* Remote Fault Detect */ -#define MII_SR_AUTONEG_COMPLETE 0x0020 /* Auto Neg Complete */ -#define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */ -#define MII_SR_EXTENDED_STATUS 0x0100 /* Ext. status info in Reg 0x0F= */ -#define MII_SR_100T2_HD_CAPS 0x0200 /* 100T2 Half Duplex Capable */ -#define MII_SR_100T2_FD_CAPS 0x0400 /* 100T2 Full Duplex Capable */ -#define MII_SR_10T_HD_CAPS 0x0800 /* 10T Half Duplex Capable */ -#define MII_SR_10T_FD_CAPS 0x1000 /* 10T Full Duplex Capable */ -#define MII_SR_100X_HD_CAPS 0x2000 /* 100X Half Duplex Capable */ -#define MII_SR_100X_FD_CAPS 0x4000 /* 100X Full Duplex Capable */ -#define MII_SR_100T4_CAPS 0x8000 /* 100T4 Capable */ - -/* PHY Link Partner Ability Register */ -#define MII_LPAR_LPACK 0x4000 /* Acked by link partner */ - /* Interrupt Cause Read */ #define E1000_ICR_TXDW 0x00000001 /* Transmit desc written back */ #define E1000_ICR_TXQE 0x00000002 /* Transmit Queue empty */ diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index 8635ca16c6..d591d01c07 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -42,6 +42,7 @@ #include "qemu/range.h" #include "sysemu/sysemu.h" #include "hw/hw.h" +#include "hw/net/mii.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/qdev-properties.h" diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index c4be782558..181c1e0c2a 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -37,6 +37,7 @@ #include "qemu/log.h" #include "net/net.h" #include "net/tap.h" +#include "hw/net/mii.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "sysemu/runstate.h" @@ -659,7 +660,7 @@ e1000e_tx_pkt_send(E1000ECore *core, struct e1000e_tx *= tx, int queue_index) =20 net_tx_pkt_dump(tx->tx_pkt); =20 - if ((core->phy[0][PHY_CTRL] & MII_CR_LOOPBACK) || + if ((core->phy[0][MII_BMCR] & MII_BMCR_LOOPBACK) || ((core->mac[RCTL] & E1000_RCTL_LBM_MAC) =3D=3D E1000_RCTL_LBM_MAC)= ) { return net_tx_pkt_send_loopback(tx->tx_pkt, queue); } else { @@ -1797,13 +1798,13 @@ e1000e_receive_iov(E1000ECore *core, const struct i= ovec *iov, int iovcnt) static inline bool e1000e_have_autoneg(E1000ECore *core) { - return core->phy[0][PHY_CTRL] & MII_CR_AUTO_NEG_EN; + return core->phy[0][MII_BMCR] & MII_BMCR_AUTOEN; } =20 static void e1000e_update_flowctl_status(E1000ECore *core) { if (e1000e_have_autoneg(core) && - core->phy[0][PHY_STATUS] & MII_SR_AUTONEG_COMPLETE) { + core->phy[0][MII_BMSR] & MII_BMSR_AN_COMP) { trace_e1000e_link_autoneg_flowctl(true); core->mac[CTRL] |=3D E1000_CTRL_TFCE | E1000_CTRL_RFCE; } else { @@ -1821,12 +1822,12 @@ e1000e_link_down(E1000ECore *core) static inline void e1000e_set_phy_ctrl(E1000ECore *core, int index, uint16_t val) { - /* bits 0-5 reserved; MII_CR_[RESTART_AUTO_NEG,RESET] are self clearin= g */ - core->phy[0][PHY_CTRL] =3D val & ~(0x3f | - MII_CR_RESET | - MII_CR_RESTART_AUTO_NEG); + /* bits 0-5 reserved; MII_BMCR_[ANRESTART,RESET] are self clearing */ + core->phy[0][MII_BMCR] =3D val & ~(0x3f | + MII_BMCR_RESET | + MII_BMCR_ANRESTART); =20 - if ((val & MII_CR_RESTART_AUTO_NEG) && + if ((val & MII_BMCR_ANRESTART) && e1000e_have_autoneg(core)) { e1000x_restart_autoneg(core->mac, core->phy[0], core->autoneg_time= r); } @@ -1860,7 +1861,7 @@ e1000e_core_set_link_status(E1000ECore *core) e1000x_update_regs_on_link_down(core->mac, core->phy[0]); } else { if (e1000e_have_autoneg(core) && - !(core->phy[0][PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) { + !(core->phy[0][MII_BMSR] & MII_BMSR_AN_COMP)) { e1000x_restart_autoneg(core->mac, core->phy[0], core->autoneg_timer); } else { @@ -2002,7 +2003,7 @@ static void(*e1000e_phyreg_writeops[E1000E_PHY_PAGES][E1000E_PHY_PAGE_SIZE]) (E1000ECore *, int, uint16_t) =3D { [0] =3D { - [PHY_CTRL] =3D e1000e_set_phy_ctrl, + [MII_BMCR] =3D e1000e_set_phy_ctrl, [PHY_PAGE] =3D e1000e_set_phy_page, [PHY_OEM_BITS] =3D e1000e_set_phy_oem_bits } @@ -2274,19 +2275,19 @@ e1000e_get_reg_index_with_offset(const uint16_t *ma= c_reg_access, hwaddr addr) =20 static const char e1000e_phy_regcap[E1000E_PHY_PAGES][0x20] =3D { [0] =3D { - [PHY_CTRL] =3D PHY_ANYPAGE | PHY_RW, - [PHY_STATUS] =3D PHY_ANYPAGE | PHY_R, - [PHY_ID1] =3D PHY_ANYPAGE | PHY_R, - [PHY_ID2] =3D PHY_ANYPAGE | PHY_R, - [PHY_AUTONEG_ADV] =3D PHY_ANYPAGE | PHY_RW, - [PHY_LP_ABILITY] =3D PHY_ANYPAGE | PHY_R, - [PHY_AUTONEG_EXP] =3D PHY_ANYPAGE | PHY_R, - [PHY_NEXT_PAGE_TX] =3D PHY_ANYPAGE | PHY_RW, - [PHY_LP_NEXT_PAGE] =3D PHY_ANYPAGE | PHY_R, - [PHY_1000T_CTRL] =3D PHY_ANYPAGE | PHY_RW, - [PHY_1000T_STATUS] =3D PHY_ANYPAGE | PHY_R, - [PHY_EXT_STATUS] =3D PHY_ANYPAGE | PHY_R, - [PHY_PAGE] =3D PHY_ANYPAGE | PHY_RW, + [MII_BMCR] =3D PHY_ANYPAGE | PHY_RW, + [MII_BMSR] =3D PHY_ANYPAGE | PHY_R, + [MII_PHYID1] =3D PHY_ANYPAGE | PHY_R, + [MII_PHYID2] =3D PHY_ANYPAGE | PHY_R, + [MII_ANAR] =3D PHY_ANYPAGE | PHY_RW, + [MII_ANLPAR] =3D PHY_ANYPAGE | PHY_R, + [MII_ANER] =3D PHY_ANYPAGE | PHY_R, + [MII_ANNP] =3D PHY_ANYPAGE | PHY_RW, + [MII_ANLPRNP] =3D PHY_ANYPAGE | PHY_R, + [MII_CTRL1000] =3D PHY_ANYPAGE | PHY_RW, + [MII_STAT1000] =3D PHY_ANYPAGE | PHY_R, + [MII_EXTSTAT] =3D PHY_ANYPAGE | PHY_R, + [PHY_PAGE] =3D PHY_ANYPAGE | PHY_RW, =20 [PHY_COPPER_CTRL1] =3D PHY_RW, [PHY_COPPER_STAT1] =3D PHY_R, @@ -3355,7 +3356,7 @@ static void e1000e_autoneg_resume(E1000ECore *core) { if (e1000e_have_autoneg(core) && - !(core->phy[0][PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) { + !(core->phy[0][MII_BMSR] & MII_BMSR_AN_COMP)) { qemu_get_queue(core->owner_nic)->link_down =3D false; timer_mod(core->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); @@ -3430,29 +3431,29 @@ e1000e_core_pci_uninit(E1000ECore *core) static const uint16_t e1000e_phy_reg_init[E1000E_PHY_PAGES][E1000E_PHY_PAGE_SIZE] =3D { [0] =3D { - [PHY_CTRL] =3D MII_CR_SPEED_SELECT_MSB | - MII_CR_FULL_DUPLEX | - MII_CR_AUTO_NEG_EN, - - [PHY_STATUS] =3D MII_SR_EXTENDED_CAPS | - MII_SR_LINK_STATUS | - MII_SR_AUTONEG_CAPS | - MII_SR_PREAMBLE_SUPPRESS | - MII_SR_EXTENDED_STATUS | - MII_SR_10T_HD_CAPS | - MII_SR_10T_FD_CAPS | - MII_SR_100X_HD_CAPS | - MII_SR_100X_FD_CAPS, - - [PHY_ID1] =3D 0x141, - [PHY_ID2] =3D E1000_PHY_ID2_82574x, - [PHY_AUTONEG_ADV] =3D 0xde1, - [PHY_LP_ABILITY] =3D 0x7e0, - [PHY_AUTONEG_EXP] =3D BIT(2), - [PHY_NEXT_PAGE_TX] =3D BIT(0) | BIT(13), - [PHY_1000T_CTRL] =3D BIT(8) | BIT(9) | BIT(10) | BIT(11), - [PHY_1000T_STATUS] =3D 0x3c00, - [PHY_EXT_STATUS] =3D BIT(12) | BIT(13), + [MII_BMCR] =3D MII_BMCR_SPEED1000 | + MII_BMCR_FD | + MII_BMCR_AUTOEN, + + [MII_BMSR] =3D MII_BMSR_EXTCAP | + MII_BMSR_LINK_ST | + MII_BMSR_AUTONEG | + MII_BMSR_MFPS | + MII_BMSR_EXTSTAT | + MII_BMSR_10T_HD | + MII_BMSR_10T_FD | + MII_BMSR_100TX_HD | + MII_BMSR_100TX_FD, + + [MII_PHYID1] =3D 0x141, + [MII_PHYID2] =3D E1000_PHY_ID2_82574x, + [MII_ANAR] =3D 0xde1, + [MII_ANLPAR] =3D 0x7e0, + [MII_ANER] =3D BIT(2), + [MII_ANNP] =3D BIT(0) | BIT(13), + [MII_CTRL1000] =3D BIT(8) | BIT(9) | BIT(10) | BIT(11), + [MII_STAT1000] =3D 0x3c00, + [MII_EXTSTAT] =3D BIT(12) | BIT(13), =20 [PHY_COPPER_CTRL1] =3D BIT(5) | BIT(6) | BIT(8) | BIT(9) | BIT(12) | BIT(13), @@ -3546,10 +3547,10 @@ void e1000e_core_pre_save(E1000ECore *core) /* * If link is down and auto-negotiation is supported and ongoing, * complete auto-negotiation immediately. This allows us to look - * at MII_SR_AUTONEG_COMPLETE to infer link status on load. + * at MII_BMSR_AN_COMP to infer link status on load. */ if (nc->link_down && e1000e_have_autoneg(core)) { - core->phy[0][PHY_STATUS] |=3D MII_SR_AUTONEG_COMPLETE; + core->phy[0][MII_BMSR] |=3D MII_BMSR_AN_COMP; e1000e_update_flowctl_status(core); } =20 diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c index 2f43e8cd13..e79d4c79bd 100644 --- a/hw/net/e1000x_common.c +++ b/hw/net/e1000x_common.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu/units.h" +#include "hw/net/mii.h" #include "hw/pci/pci_device.h" #include "net/net.h" =20 @@ -152,8 +153,8 @@ void e1000x_reset_mac_addr(NICState *nic, uint32_t *mac= _regs, void e1000x_update_regs_on_autoneg_done(uint32_t *mac, uint16_t *phy) { e1000x_update_regs_on_link_up(mac, phy); - phy[PHY_LP_ABILITY] |=3D MII_LPAR_LPACK; - phy[PHY_STATUS] |=3D MII_SR_AUTONEG_COMPLETE; + phy[MII_ANLPAR] |=3D MII_ANLPAR_ACK; + phy[MII_BMSR] |=3D MII_BMSR_AN_COMP; trace_e1000x_link_negotiation_done(); } =20 diff --git a/hw/net/e1000x_common.h b/hw/net/e1000x_common.h index bc1ee75b04..3501e4855a 100644 --- a/hw/net/e1000x_common.h +++ b/hw/net/e1000x_common.h @@ -152,16 +152,16 @@ static inline void e1000x_update_regs_on_link_down(uint32_t *mac, uint16_t *phy) { mac[STATUS] &=3D ~E1000_STATUS_LU; - phy[PHY_STATUS] &=3D ~MII_SR_LINK_STATUS; - phy[PHY_STATUS] &=3D ~MII_SR_AUTONEG_COMPLETE; - phy[PHY_LP_ABILITY] &=3D ~MII_LPAR_LPACK; + phy[MII_BMSR] &=3D ~MII_BMSR_LINK_ST; + phy[MII_BMSR] &=3D ~MII_BMSR_AN_COMP; + phy[MII_ANLPAR] &=3D ~MII_ANLPAR_ACK; } =20 static inline void e1000x_update_regs_on_link_up(uint32_t *mac, uint16_t *phy) { mac[STATUS] |=3D E1000_STATUS_LU; - phy[PHY_STATUS] |=3D MII_SR_LINK_STATUS; + phy[MII_BMSR] |=3D MII_BMSR_LINK_ST; } =20 void e1000x_update_rx_total_stats(uint32_t *mac, --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677148040; cv=none; d=zohomail.com; s=zohoarc; b=Fp3mB8+jHAkMiyKXIOSCT13hVrpKTIN9XDItlzm/NIWLFj3sAOP9CowhkBHwJwExK9pDBAFZ/j7VN2H+FEIftLlctxGWv8DBpb8rwwW3+8SOvUWaSjhQLk8CGXNsMIZuVSEaNmWdh3X0FYO13/s7mHdc1kx1MI21hmvNfVAEIgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677148040; 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=vaQBmuAwUG3bfNy5ZDg+YwZ/WikcZ/GlFG+7O8mJJRU=; b=GaBVbNvP3J2RAdDWXSjqJQSrgemyeuuk1/Sdi3w5ouiI7fezWcoahfd6zjHeMmlZhuJtNT0U3zB5TwttieCDPfJHL3DD0vhp+VY7veHPMWsRptvvcrLz52vdIzcx5TypovhBvx/tkw97UbmlYHxdDHG9nk9/W3nzD0Ify+g2o0k= 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+importer2=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 1677148040777443.0312873845362; Thu, 23 Feb 2023 02:27:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8in-0005wv-9D; Thu, 23 Feb 2023 05:21:05 -0500 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 1pV8il-0005wP-Ql for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:03 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8ik-0001LB-11 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:03 -0500 Received: by mail-pl1-x632.google.com with SMTP id q11so12550554plx.5 for ; Thu, 23 Feb 2023 02:21:01 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=vaQBmuAwUG3bfNy5ZDg+YwZ/WikcZ/GlFG+7O8mJJRU=; b=4CISGaKYGPSUvNfAXpEt+7UFhWiVOqu5j2Ecu9M59dLuciTEcC29ndY1/QGG7PX8nJ LEQAbsSW0YQ90WebUJN8yal7k8Lh37BglfmH73Au4RTOA7iciK0190KuEi/oiN0NDQ22 AwSzx9zHD+UvhVGcwFxWUWxvenCZYMWBBJ/J07DnlqVC0AfutWjF1GpyhQYiSBuN8W39 h4qgeuGJvd8IoUWEOzJzvq4Aea8xsVQTATeuS208CTDTgMBD5nW3TcCaa94CqUCK1lbH l6WeSDn9K+ArLuEAUCWyDaZGb7c9GrCP5Edc4RLm9i2i/Tl2Lo4t3tJ7g3DhfFwlEF7W aYgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vaQBmuAwUG3bfNy5ZDg+YwZ/WikcZ/GlFG+7O8mJJRU=; b=LOtsJm5/1yP7kjisEpeWiUsa3PN1Gwf30Y6CQqVEGSmlTDAXFjefwcKUrw5JEpFTFE T9glfkm5i0tNpwzW4HOSHtha9EbTcgS/vW3eajMiIphJXzZAelgK718TRTNZEPs2KkbL uwo6I731Ahn/j4W5mfdI5ALJ2GX0bTpzaTRBhYY8vQ+AmaTVitxOs8jWbK4EE6jpLxIQ UkYnMGuIBNjgc+UM9L7fLM98p2yS8R60U1ZU5B/AFXp2LFoaxg4Ykuir5Yyre/q20x+M giBVTYbuMIBOuAOrSyXkIvb08Eyf/o0Gff6aAJWy8+FoNIamo7Uc4OAaICiltwIyxgie xh/w== X-Gm-Message-State: AO0yUKUvR9ARcP5uoqDFoPl51z4C9qzRQfzRWeXrzQD6cdysqlaLoT3E JJO+lpMxZfG2GoD+DeSscX2PfA== X-Google-Smtp-Source: AK7set/A4JwCYBTFXopdFaB1VFFWMKBx4Cp3GP1/96cx9DVxgzl2g6npTUIKJkSlTiZ+P6BZpXOLYQ== X-Received: by 2002:a17:902:d2cd:b0:19c:192b:e80f with SMTP id n13-20020a170902d2cd00b0019c192be80fmr13466092plc.54.1677147660815; Thu, 23 Feb 2023 02:21:00 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 05/34] e1000: Mask registers when writing Date: Thu, 23 Feb 2023 19:19:49 +0900 Message-Id: <20230223102018.141748-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::632; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x632.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677148041965100001 Content-Type: text/plain; charset="utf-8" When a register has effective bits fewer than their width, the old code inconsistently masked when writing or reading. Make the code consistent by always masking when writing, and remove some code duplication. Signed-off-by: Akihiko Odaki --- hw/net/e1000.c | 84 +++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 53 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 9619a2e481..0925a99511 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -1062,30 +1062,6 @@ mac_readreg(E1000State *s, int index) return s->mac_reg[index]; } =20 -static uint32_t -mac_low4_read(E1000State *s, int index) -{ - return s->mac_reg[index] & 0xf; -} - -static uint32_t -mac_low11_read(E1000State *s, int index) -{ - return s->mac_reg[index] & 0x7ff; -} - -static uint32_t -mac_low13_read(E1000State *s, int index) -{ - return s->mac_reg[index] & 0x1fff; -} - -static uint32_t -mac_low16_read(E1000State *s, int index) -{ - return s->mac_reg[index] & 0xffff; -} - static uint32_t mac_icr_read(E1000State *s, int index) { @@ -1138,11 +1114,17 @@ set_rdt(E1000State *s, int index, uint32_t val) } } =20 -static void -set_16bit(E1000State *s, int index, uint32_t val) -{ - s->mac_reg[index] =3D val & 0xffff; -} +#define LOW_BITS_SET_FUNC(num) \ + static void \ + set_##num##bit(E1000State *s, int index, uint32_t val) \ + { \ + s->mac_reg[index] =3D val & (BIT(num) - 1); \ + } + +LOW_BITS_SET_FUNC(4) +LOW_BITS_SET_FUNC(11) +LOW_BITS_SET_FUNC(13) +LOW_BITS_SET_FUNC(16) =20 static void set_dlen(E1000State *s, int index, uint32_t val) @@ -1196,7 +1178,9 @@ static const readops macreg_readops[] =3D { getreg(XONRXC), getreg(XONTXC), getreg(XOFFRXC), getreg(XOFFTXC), getreg(RFC), getreg(RJC), getreg(RNBC), getreg(TSCTFC), getreg(MGTPRC), getreg(MGTPDC), getreg(MGTPTC), getreg(GORCL), - getreg(GOTCL), + getreg(GOTCL), getreg(RDFH), getreg(RDFT), getreg(RDFHS), + getreg(RDFTS), getreg(RDFPC), getreg(TDFH), getreg(TDFT), + getreg(TDFHS), getreg(TDFTS), getreg(TDFPC), getreg(AIT), =20 [TOTH] =3D mac_read_clr8, [TORH] =3D mac_read_clr8, [GOTCH] =3D mac_read_clr8, [GORCH] =3D mac_read_clr8, @@ -1214,22 +1198,15 @@ static const readops macreg_readops[] =3D { [MPTC] =3D mac_read_clr4, [ICR] =3D mac_icr_read, [EECD] =3D get_eecd, [EERD] =3D flash_eerd_read, - [RDFH] =3D mac_low13_read, [RDFT] =3D mac_low13_read, - [RDFHS] =3D mac_low13_read, [RDFTS] =3D mac_low13_read, - [RDFPC] =3D mac_low13_read, - [TDFH] =3D mac_low11_read, [TDFT] =3D mac_low11_read, - [TDFHS] =3D mac_low13_read, [TDFTS] =3D mac_low13_read, - [TDFPC] =3D mac_low13_read, - [AIT] =3D mac_low16_read, =20 [CRCERRS ... MPC] =3D &mac_readreg, [IP6AT ... IP6AT + 3] =3D &mac_readreg, [IP4AT ... IP4AT + 6] =3D &= mac_readreg, - [FFLT ... FFLT + 6] =3D &mac_low11_read, + [FFLT ... FFLT + 6] =3D &mac_readreg, [RA ... RA + 31] =3D &mac_readreg, [WUPM ... WUPM + 31] =3D &mac_readreg, [MTA ... MTA + 127] =3D &mac_readreg, [VFTA ... VFTA + 127] =3D &mac_readreg, - [FFMT ... FFMT + 254] =3D &mac_low4_read, + [FFMT ... FFMT + 254] =3D &mac_readreg, [FFVT ... FFVT + 254] =3D &mac_readreg, [PBM ... PBM + 16383] =3D &mac_readreg, }; @@ -1241,26 +1218,27 @@ static const writeops macreg_writeops[] =3D { putreg(PBA), putreg(EERD), putreg(SWSM), putreg(WUFC), putreg(TDBAL), putreg(TDBAH), putreg(TXDCTL), putreg(RDBAH), putreg(RDBAL), putreg(LEDCTL), putreg(VET), putreg(FCRUC), - putreg(TDFH), putreg(TDFT), putreg(TDFHS), putreg(TDFTS), - putreg(TDFPC), putreg(RDFH), putreg(RDFT), putreg(RDFHS), - putreg(RDFTS), putreg(RDFPC), putreg(IPAV), putreg(WUC), - putreg(WUS), putreg(AIT), - - [TDLEN] =3D set_dlen, [RDLEN] =3D set_dlen, [TCTL] =3D set_t= ctl, - [TDT] =3D set_tctl, [MDIC] =3D set_mdic, [ICS] =3D set_i= cs, - [TDH] =3D set_16bit, [RDH] =3D set_16bit, [RDT] =3D set_r= dt, - [IMC] =3D set_imc, [IMS] =3D set_ims, [ICR] =3D set_i= cr, - [EECD] =3D set_eecd, [RCTL] =3D set_rx_control, [CTRL] =3D set_c= trl, - [RDTR] =3D set_16bit, [RADV] =3D set_16bit, [TADV] =3D set_1= 6bit, - [ITR] =3D set_16bit, + putreg(IPAV), putreg(WUC), + putreg(WUS), + + [TDLEN] =3D set_dlen, [RDLEN] =3D set_dlen, [TCTL] =3D set_= tctl, + [TDT] =3D set_tctl, [MDIC] =3D set_mdic, [ICS] =3D set_= ics, + [TDH] =3D set_16bit, [RDH] =3D set_16bit, [RDT] =3D set_= rdt, + [IMC] =3D set_imc, [IMS] =3D set_ims, [ICR] =3D set_= icr, + [EECD] =3D set_eecd, [RCTL] =3D set_rx_control, [CTRL] =3D set_= ctrl, + [RDTR] =3D set_16bit, [RADV] =3D set_16bit, [TADV] =3D set_= 16bit, + [ITR] =3D set_16bit, [TDFH] =3D set_11bit, [TDFT] =3D set_= 11bit, + [TDFHS] =3D set_13bit, [TDFTS] =3D set_13bit, [TDFPC] =3D set_= 13bit, + [RDFH] =3D set_13bit, [RDFT] =3D set_13bit, [RDFHS] =3D set_= 13bit, + [RDFTS] =3D set_13bit, [RDFPC] =3D set_13bit, [AIT] =3D set_= 16bit, =20 [IP6AT ... IP6AT + 3] =3D &mac_writereg, [IP4AT ... IP4AT + 6] =3D &ma= c_writereg, - [FFLT ... FFLT + 6] =3D &mac_writereg, + [FFLT ... FFLT + 6] =3D &set_11bit, [RA ... RA + 31] =3D &mac_writereg, [WUPM ... WUPM + 31] =3D &mac_writereg, [MTA ... MTA + 127] =3D &mac_writereg, [VFTA ... VFTA + 127] =3D &mac_writereg, - [FFMT ... FFMT + 254] =3D &mac_writereg, [FFVT ... FFVT + 254] =3D &ma= c_writereg, + [FFMT ... FFMT + 254] =3D &set_4bit, [FFVT ... FFVT + 254] =3D &ma= c_writereg, [PBM ... PBM + 16383] =3D &mac_writereg, }; =20 --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147715; cv=none; d=zohomail.com; s=zohoarc; b=fMPiINtbtrZ/YItFtAlZ3nwlP5M/BTw2sALUQrVL2ZXOstJkIqlWUA6Y1ZT32RWh0cqvDZavx3cNPWLN0mxbYGBa3BovDu9i/r6qTsZ6eNNTUg9eNLOA3ApyQCnsNAA6GfpQD5UstfJPIeqybeVg4sBStQmogLgXxbFGljQ1vno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147715; 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=eNOjcckbVLx/23/g6t4iefFUn+kYW7NtIXTVzOhDNpg=; b=VBaeuzccEXV9nrrFwhGzq1ap+PDD4PSKbfLFuYsLU8dZPumEkP0hgAwAOlpQfQ4aalBN6hEbkvr6AfZbWGpH1ObbAKV6QwK1RDCgzvBWRIq1dub3wJUA4MdVfrhe2BHy5VpPYbxRuFy+ooEtC7hDx8iCg+xn9gTzM+4/su6hx4E= 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+importer2=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 1677147715496434.2968665029223; Thu, 23 Feb 2023 02:21:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8is-0005z3-TN; Thu, 23 Feb 2023 05:21:10 -0500 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 1pV8ip-0005xQ-0A for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:07 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8in-0001V5-7A for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:06 -0500 Received: by mail-pl1-x62f.google.com with SMTP id i10so3315859plr.9 for ; Thu, 23 Feb 2023 02:21:04 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=eNOjcckbVLx/23/g6t4iefFUn+kYW7NtIXTVzOhDNpg=; b=AZfm2u6CMm13nYuxi5xsVvv9PwUb/chbVesDbPsvaUAlvFGHxuMheD7COUkVsHcGwA PAjUbZT8Ptn1t8+TECPg5eYxCmyaVlMJ1PFqLgJJ6FMMWTT1macHnCdPQxxshfULxX5p VRBbjhnFK6r/889eR5Oe5q1M9SpTe5rwE8yKTPbY9Q3Jq3/rZGD+JxuFoRxz7si9gbvY e1IlHzN4+iNotQ1Wd7QcNIUEgtv3MUQpBOi77R6J6Cs4/wmWxB+lQODmmSdGgCqjwj62 Y5c1u7/LOZsglerwLWhamLG1uEVgSq1MK1YGeiZQubsPCX1aSE+pMtnt1sO4J+Mlbwp4 ZQig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eNOjcckbVLx/23/g6t4iefFUn+kYW7NtIXTVzOhDNpg=; b=JUN5a8Xe9phyXgN5KxLdu2rodIaGu7/GSNQro32+cz+vISsU3Q0URpQgTJ8gwL9ADU Udi2h0tE85avMl0PEeiN7KvLQ3ITebr1EHlqd/x7ynrbzDMhrinmyDiVsrtOE5QzU6rE JuRQYX/Or8A6U4airqgfXP6IU3v0I+v5FqSFWADTjjF4zcZQOS0Ga6j71Aw/xzxpm1pH JJ0pqIS2Hoqn+0SGZkTkEuY1YA+yov5raxMZLjP3HaZhy1U3h1ttD7/YpWspo2xPNS4r 8vl/rmCuxL7i/CfNO1BLK6yZcLjQtal15xvX+r9YBpbhuoRZzDxis9ttpvbaHY804pum lG2g== X-Gm-Message-State: AO0yUKWFG2qOyhQZudIDwZGgaJBRHET82CJ1QtVQl+WrGkhoRnE/xRgS aMeEx+KhaQG4vGNsUF2jnVPq1w== X-Google-Smtp-Source: AK7set8l9mxOQbD78dk6+V5mnaUvXeinBEFeyU23qhHe9JuPdj76Fg7hiszMvitYe85WJZMG6U4a1w== X-Received: by 2002:a17:903:848:b0:19b:3b4:3ae8 with SMTP id ks8-20020a170903084800b0019b03b43ae8mr9534231plb.57.1677147663953; Thu, 23 Feb 2023 02:21:03 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 06/34] e1000e: Introduce E1000E_LOW_BITS_SET_FUNC Date: Thu, 23 Feb 2023 19:19:50 +0900 Message-Id: <20230223102018.141748-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62f.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147715747100003 Content-Type: text/plain; charset="utf-8" e1000e_set_16bit and e1000e_set_12bit look so similar so define a generic macro. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 181c1e0c2a..1cafc38f50 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2440,17 +2440,15 @@ e1000e_set_fcrtl(E1000ECore *core, int index, uint3= 2_t val) core->mac[FCRTL] =3D val & 0x8000FFF8; } =20 -static inline void -e1000e_set_16bit(E1000ECore *core, int index, uint32_t val) -{ - core->mac[index] =3D val & 0xffff; -} +#define E1000E_LOW_BITS_SET_FUNC(num) \ + static void \ + e1000e_set_##num##bit(E1000ECore *core, int index, uint32_t val) \ + { \ + core->mac[index] =3D val & (BIT(num) - 1); \ + } =20 -static void -e1000e_set_12bit(E1000ECore *core, int index, uint32_t val) -{ - core->mac[index] =3D val & 0xfff; -} +E1000E_LOW_BITS_SET_FUNC(12) +E1000E_LOW_BITS_SET_FUNC(16) =20 static void e1000e_set_vet(E1000ECore *core, int index, uint32_t val) --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147780; cv=none; d=zohomail.com; s=zohoarc; b=mf7LUtyPLEwLdt7ZX/GYaeA6Z22LnG0NeMz/4XN7clPC/rrJF0nwjlkc+WTca8CI+BtAIad9LVm1sAx5xUotBH+Laax96Z7ncJeAUFlyqomTuc33RTdJIEKTKkqqrI6YfCJ9iwzmr6ghKD/+wFEJhBeVQozUipnWGfSumKxlxT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147780; 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=tXQU9sPKHPmFpkPbkwyLaiJC9+0cIIZUDhehWaFDECo=; b=Vgmdeq8FiEWEicN/8+XyjxDhXoiOEbQKgs22NG5vlApAnayMx7OJdHmIR+fO6vDLZ9PRGXh/2pENwlJaI7/4hki3QSN+RKCZ77uflRXg5dC5pRkYJAfn9F50Xcmwe3B/+0Tg85dsA/pvfHwtOp8IDFdVZsuBF9xKGmIaVwyWMBs= 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+importer2=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 1677147780030620.0017933179104; Thu, 23 Feb 2023 02:23:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8iu-00060b-I6; Thu, 23 Feb 2023 05:21:12 -0500 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 1pV8ir-0005yU-Of for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:09 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8ip-0001LB-Od for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:09 -0500 Received: by mail-pl1-x632.google.com with SMTP id q11so12550855plx.5 for ; Thu, 23 Feb 2023 02:21:07 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=tXQU9sPKHPmFpkPbkwyLaiJC9+0cIIZUDhehWaFDECo=; b=b33oKukjiSi6tteptTpDfTSkvC7e+bpLjJsa5b1yOFmLs4B3wgsaqOlObotiPv6iuJ ZsoKHzOgyXL0E70AJETFxX0FSEBamSFuz8jdboq1h764eAu4jBg5cL4ASTk6o1SkgFu/ A4FWWRFGrsY14v8mmS+BhrTj4p9iqgjZtwzZvXBZYfKqfweLEupmrBp7kktZ2Sm8sB6h G3kNLw5ZoYz3d/CxqliJGeWtBU0wowiAqg95h88v0leDeHOJkiNAKfiPn0rXBsyI7cy7 4QAFfx+fVnZEpsInAc66x2iZZdTmpc2pUsrAKXNKBFihwduLUuYi3w7aHmTtRP7mAZCD uxUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=tXQU9sPKHPmFpkPbkwyLaiJC9+0cIIZUDhehWaFDECo=; b=cIo+nxTE9cSqtSHy8zHQ01rfiRvbNCZBVFudMWYmXcP8CR9Bu2RIIs5e+Mv6QRdW8H XCl2Sjp7IVsiK20hJjCCxvpx6qcFoEJUnVzygniasnKHHDYczt3dxX+ZWevXXINs0dGs D/JzbyPhVIuBvgRoiy+AXZdRGQWk+XBqCT0sebr7Acx3CjfnsFrSuTPjRtc5OgBYlFud v6lPWfzlMjj2T7u+uBAkMueI7rrGIf+B9B//Zja10fz/oIip4nqojRCgmlZUvruey6cY FsFGNi5yyyPrMZUicfiIl7oat0u3PG652wSbA3JLfBakO1yMOyr8bRM8C0SezMfRIluZ Dpkw== X-Gm-Message-State: AO0yUKXYkb1s0FPFbv/LoMH4iMtMxG/W9Ivb7QnnDsxwPLNgzXu+yBOr Pma0LN6Fz/KEumENgZ2ZYn93Cg== X-Google-Smtp-Source: AK7set/6UVfw0MlRTIOhPCiWmyF3qsoXv15fuWq4q+AihqNDK65gJGTt4592g5i4fn1A61zRJ/CL5g== X-Received: by 2002:a17:90b:4a48:b0:234:b964:570d with SMTP id lb8-20020a17090b4a4800b00234b964570dmr12869028pjb.13.1677147667111; Thu, 23 Feb 2023 02:21:07 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 07/34] e1000e: Mask registers when writing Date: Thu, 23 Feb 2023 19:19:51 +0900 Message-Id: <20230223102018.141748-8-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::632; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x632.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147780270100006 Content-Type: text/plain; charset="utf-8" When a register has effective bits fewer than their width, the old code inconsistently masked when writing or reading. Make the code consistent by always masking when writing, and remove some code duplication. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 76 +++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 1cafc38f50..e6fc85ea51 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2447,7 +2447,11 @@ e1000e_set_fcrtl(E1000ECore *core, int index, uint32= _t val) core->mac[index] =3D val & (BIT(num) - 1); \ } =20 +E1000E_LOW_BITS_SET_FUNC(4) +E1000E_LOW_BITS_SET_FUNC(6) +E1000E_LOW_BITS_SET_FUNC(11) E1000E_LOW_BITS_SET_FUNC(12) +E1000E_LOW_BITS_SET_FUNC(13) E1000E_LOW_BITS_SET_FUNC(16) =20 static void @@ -2619,22 +2623,6 @@ e1000e_mac_ims_read(E1000ECore *core, int index) return core->mac[IMS]; } =20 -#define E1000E_LOW_BITS_READ_FUNC(num) \ - static uint32_t \ - e1000e_mac_low##num##_read(E1000ECore *core, int index) \ - { \ - return core->mac[index] & (BIT(num) - 1); \ - } \ - -#define E1000E_LOW_BITS_READ(num) \ - e1000e_mac_low##num##_read - -E1000E_LOW_BITS_READ_FUNC(4); -E1000E_LOW_BITS_READ_FUNC(6); -E1000E_LOW_BITS_READ_FUNC(11); -E1000E_LOW_BITS_READ_FUNC(13); -E1000E_LOW_BITS_READ_FUNC(16); - static uint32_t e1000e_mac_swsm_read(E1000ECore *core, int index) { @@ -2928,7 +2916,19 @@ static const readops e1000e_macreg_readops[] =3D { e1000e_getreg(LATECOL), e1000e_getreg(SEQEC), e1000e_getreg(XONTXC), + e1000e_getreg(AIT), + e1000e_getreg(TDFH), + e1000e_getreg(TDFT), + e1000e_getreg(TDFHS), + e1000e_getreg(TDFTS), + e1000e_getreg(TDFPC), e1000e_getreg(WUS), + e1000e_getreg(PBS), + e1000e_getreg(RDFH), + e1000e_getreg(RDFT), + e1000e_getreg(RDFHS), + e1000e_getreg(RDFTS), + e1000e_getreg(RDFPC), e1000e_getreg(GORCL), e1000e_getreg(MGTPRC), e1000e_getreg(EERD), @@ -3064,16 +3064,9 @@ static const readops e1000e_macreg_readops[] =3D { [MPTC] =3D e1000e_mac_read_clr4, [IAC] =3D e1000e_mac_read_clr4, [ICR] =3D e1000e_mac_icr_read, - [RDFH] =3D E1000E_LOW_BITS_READ(13), - [RDFHS] =3D E1000E_LOW_BITS_READ(13), - [RDFPC] =3D E1000E_LOW_BITS_READ(13), - [TDFH] =3D E1000E_LOW_BITS_READ(13), - [TDFHS] =3D E1000E_LOW_BITS_READ(13), [STATUS] =3D e1000e_get_status, [TARC0] =3D e1000e_get_tarc, - [PBS] =3D E1000E_LOW_BITS_READ(6), [ICS] =3D e1000e_mac_ics_read, - [AIT] =3D E1000E_LOW_BITS_READ(16), [TORH] =3D e1000e_mac_read_clr8, [GORCH] =3D e1000e_mac_read_clr8, [PRC127] =3D e1000e_mac_read_clr4, @@ -3089,11 +3082,6 @@ static const readops e1000e_macreg_readops[] =3D { [BPTC] =3D e1000e_mac_read_clr4, [TSCTC] =3D e1000e_mac_read_clr4, [ITR] =3D e1000e_mac_itr_read, - [RDFT] =3D E1000E_LOW_BITS_READ(13), - [RDFTS] =3D E1000E_LOW_BITS_READ(13), - [TDFPC] =3D E1000E_LOW_BITS_READ(13), - [TDFT] =3D E1000E_LOW_BITS_READ(13), - [TDFTS] =3D E1000E_LOW_BITS_READ(13), [CTRL] =3D e1000e_get_ctrl, [TARC1] =3D e1000e_get_tarc, [SWSM] =3D e1000e_mac_swsm_read, @@ -3106,10 +3094,10 @@ static const readops e1000e_macreg_readops[] =3D { [WUPM ... WUPM + 31] =3D e1000e_mac_readreg, [MTA ... MTA + 127] =3D e1000e_mac_readreg, [VFTA ... VFTA + 127] =3D e1000e_mac_readreg, - [FFMT ... FFMT + 254] =3D E1000E_LOW_BITS_READ(4), + [FFMT ... FFMT + 254] =3D e1000e_mac_readreg, [FFVT ... FFVT + 254] =3D e1000e_mac_readreg, [MDEF ... MDEF + 7] =3D e1000e_mac_readreg, - [FFLT ... FFLT + 10] =3D E1000E_LOW_BITS_READ(11), + [FFLT ... FFLT + 10] =3D e1000e_mac_readreg, [FTFT ... FTFT + 254] =3D e1000e_mac_readreg, [PBM ... PBM + 10239] =3D e1000e_mac_readreg, [RETA ... RETA + 31] =3D e1000e_mac_readreg, @@ -3132,19 +3120,8 @@ static const writeops e1000e_macreg_writeops[] =3D { e1000e_putreg(LEDCTL), e1000e_putreg(FCAL), e1000e_putreg(FCRUC), - e1000e_putreg(AIT), - e1000e_putreg(TDFH), - e1000e_putreg(TDFT), - e1000e_putreg(TDFHS), - e1000e_putreg(TDFTS), - e1000e_putreg(TDFPC), e1000e_putreg(WUC), e1000e_putreg(WUS), - e1000e_putreg(RDFH), - e1000e_putreg(RDFT), - e1000e_putreg(RDFHS), - e1000e_putreg(RDFTS), - e1000e_putreg(RDFPC), e1000e_putreg(IPAV), e1000e_putreg(TDBAH1), e1000e_putreg(TIMINCA), @@ -3155,7 +3132,6 @@ static const writeops e1000e_macreg_writeops[] =3D { e1000e_putreg(TARC1), e1000e_putreg(FLSWDATA), e1000e_putreg(POEMB), - e1000e_putreg(PBS), e1000e_putreg(MFUTP01), e1000e_putreg(MFUTP23), e1000e_putreg(MANC), @@ -3220,6 +3196,18 @@ static const writeops e1000e_macreg_writeops[] =3D { [TADV] =3D e1000e_set_16bit, [ITR] =3D e1000e_set_itr, [EERD] =3D e1000e_set_eerd, + [AIT] =3D e1000e_set_16bit, + [TDFH] =3D e1000e_set_13bit, + [TDFT] =3D e1000e_set_13bit, + [TDFHS] =3D e1000e_set_13bit, + [TDFTS] =3D e1000e_set_13bit, + [TDFPC] =3D e1000e_set_13bit, + [RDFH] =3D e1000e_set_13bit, + [RDFHS] =3D e1000e_set_13bit, + [RDFT] =3D e1000e_set_13bit, + [RDFTS] =3D e1000e_set_13bit, + [RDFPC] =3D e1000e_set_13bit, + [PBS] =3D e1000e_set_6bit, [GCR] =3D e1000e_set_gcr, [PSRCTL] =3D e1000e_set_psrctl, [RXCSUM] =3D e1000e_set_rxcsum, @@ -3259,11 +3247,11 @@ static const writeops e1000e_macreg_writeops[] =3D { [WUPM ... WUPM + 31] =3D e1000e_mac_writereg, [MTA ... MTA + 127] =3D e1000e_mac_writereg, [VFTA ... VFTA + 127] =3D e1000e_mac_writereg, - [FFMT ... FFMT + 254] =3D e1000e_mac_writereg, + [FFMT ... FFMT + 254] =3D e1000e_set_4bit, [FFVT ... FFVT + 254] =3D e1000e_mac_writereg, [PBM ... PBM + 10239] =3D e1000e_mac_writereg, [MDEF ... MDEF + 7] =3D e1000e_mac_writereg, - [FFLT ... FFLT + 10] =3D e1000e_mac_writereg, + [FFLT ... FFLT + 10] =3D e1000e_set_11bit, [FTFT ... FTFT + 254] =3D e1000e_mac_writereg, [RETA ... RETA + 31] =3D e1000e_mac_writereg, [RSSRK ... RSSRK + 31] =3D e1000e_mac_writereg, --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147849; cv=none; d=zohomail.com; s=zohoarc; b=QSowZbo8PXQUjNHhaMqiUlKmCTrI8uSjHRsSISZ94+DXx4BQZR5RPle0eK4kFl2Z1DGjubA/zPDjdBJGqZbwz2W9YogLLJTjtTPwk+Bco8BpaCgO3ILERC6/pAOnO4ie+LGBnG065luFTSZxYo/xyhGvAsDdstA5c/XeFq+unIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147849; h=Content-Type: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=11tAn5i1ga6o2GC/G+0ctwzPxRVIwWHyxeT3xs8C5X4=; b=Yjq0kNGolTvhi4pxeAUYvei28BITeaG/N1SuPZ7/KFUBT7YAKCulqKLF2nv5PcrE0nIz5yqn+VrRaJazZOT8e7s6tLEJxYrmUYFj/hyL4yrPTXkPYLhH5etdswKMSS4LgOMIVM6kKHdKSV2anZO3C/gUC5X7UYQfxs/Igkrzdl8= 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+importer2=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 1677147849406399.9918733163306; Thu, 23 Feb 2023 02:24:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8ix-00063T-10; Thu, 23 Feb 2023 05:21:15 -0500 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 1pV8iv-00062g-U2 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:13 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8it-00016a-Bw for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:13 -0500 Received: by mail-pj1-x1036.google.com with SMTP id pt11so12970595pjb.1 for ; Thu, 23 Feb 2023 02:21:10 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=11tAn5i1ga6o2GC/G+0ctwzPxRVIwWHyxeT3xs8C5X4=; b=UH1uLpN8ZMf00RInTnqr7YSBzu472scGRkluI3McukjL62nQEwodUilVYQ42LKiwTB t3w+kdoUSBJ90yWvv+jjlXFXaNWke/qLY5piUC8bXQ7wctnMXXDJ2xckryClg8K5RfRh qYWgsgWX55DK9spDrMDcj0ltYIvBCtyECy6nPcV9S1ycnBCup5UyktSSzAbz5islhSME 3MR7aS6eRRSpSS2MrjrDciZDh7sXZAWLLOco3lPqGz1WJ45gIzwb2XpI/LpxWFH/F8X9 SxpP4SOFzACNmKid1B3TYdlQf+Urg6r0jL58w8lj71LXXyF88gU/qRKg6uWB9YqBiVoh PpIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=11tAn5i1ga6o2GC/G+0ctwzPxRVIwWHyxeT3xs8C5X4=; b=WVQPZjAVipHDJRY46mzSrYOYs8HVv8b6kpiWiA5WQM/eX6OZAEYqqUkRAXtubYEX49 goqDEufBYeMc1MYFSylsZjJaPaO06U8xrRJN3nJzlAdwAY4uAZjdZhyLWZyAW+M1S9rY gDuKiMqDgH+GVU2Vt1ncNy2y58oj5ksPkBvvwPwctz+3T64otsdmIwe6jTA/oMkDNDeO 3PYLC2yfAA25OHZVYDGkyb1GMtIdDXMk1dC1/S5SNoY4v/9cWBUH3Nt/GUHTuKZ49DVC X50Vkp8Zu4KaIGPRo8BldPbtI2DIfJjalU76zfodZEOvBM/xh7PuP6/KrzX97YbkVDiz 2Upw== X-Gm-Message-State: AO0yUKVXEBDRULFWJEf9Fj5PcntjKTYmFtJgoxNqL4bFh5KUseGjhzIW 679F6By82TbM+xnLUs1Ab2hhoA== X-Google-Smtp-Source: AK7set/jIXaQd5z4MCM8sHLlwlw0QARkR34DZpg/nvrfKbJ/5+HVqZ27pJAInL04cOWywytACDXjnQ== X-Received: by 2002:a17:903:280d:b0:19a:73fb:6183 with SMTP id kp13-20020a170903280d00b0019a73fb6183mr10404039plb.14.1677147670415; Thu, 23 Feb 2023 02:21:10 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 08/34] e1000: Use more constant definitions Date: Thu, 23 Feb 2023 19:19:52 +0900 Message-Id: <20230223102018.141748-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1036; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1036.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147850868100003 The definitions for E1000_VFTA_ENTRY_SHIFT, E1000_VFTA_ENTRY_MASK, and E1000_VFTA_ENTRY_BIT_SHIFT_MASK were copied from: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drive= rs/net/ethernet/intel/e1000/e1000_hw.h?h=3Dv6.0.9#n306 The definitions for E1000_NUM_UNICAST, E1000_MC_TBL_SIZE, and E1000_VLAN_FILTER_TBL_SIZE were copied from: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drive= rs/net/ethernet/intel/e1000/e1000_hw.h?h=3Dv6.0.9#n707 Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/e1000.c | 50 +++++++++++++++++++++++------------------- hw/net/e1000_regs.h | 9 ++++++++ hw/net/e1000x_common.c | 5 +++-- hw/net/e1000x_common.h | 2 +- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 0925a99511..d9d048f665 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -43,8 +43,6 @@ #include "trace.h" #include "qom/object.h" =20 -static const uint8_t bcast[] =3D {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - /* #define E1000_DEBUG */ =20 #ifdef E1000_DEBUG @@ -67,9 +65,8 @@ static int debugflags =3D DBGBIT(TXERR) | DBGBIT(GENERAL); =20 #define IOPORT_SIZE 0x40 #define PNPMMIO_SIZE 0x20000 -#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS = */ =20 -#define MAXIMUM_ETHERNET_HDR_LEN (14+4) +#define MAXIMUM_ETHERNET_HDR_LEN (ETH_HLEN + 4) =20 /* * HW models: @@ -239,10 +236,16 @@ static const uint16_t phy_reg_init[] =3D { =20 [MII_PHYID1] =3D 0x141, /* [MII_PHYID2] configured per DevId, from e1000_reset() */ - [MII_ANAR] =3D 0xde1, - [MII_ANLPAR] =3D 0x1e0, - [MII_CTRL1000] =3D 0x0e00, - [MII_STAT1000] =3D 0x3c00, + [MII_ANAR] =3D MII_ANAR_CSMACD | MII_ANAR_10 | + MII_ANAR_10FD | MII_ANAR_TX | + MII_ANAR_TXFD | MII_ANAR_PAUSE | + MII_ANAR_PAUSE_ASYM, + [MII_ANLPAR] =3D MII_ANLPAR_10 | MII_ANLPAR_10FD | + MII_ANLPAR_TX | MII_ANLPAR_TXFD, + [MII_CTRL1000] =3D MII_CTRL1000_FULL | MII_CTRL1000_PORT | + MII_CTRL1000_MASTER, + [MII_STAT1000] =3D MII_STAT1000_HALF | MII_STAT1000_FULL | + MII_STAT1000_ROK | MII_STAT1000_LOK, [M88E1000_PHY_SPEC_CTRL] =3D 0x360, [M88E1000_PHY_SPEC_STATUS] =3D 0xac00, [M88E1000_EXT_PHY_SPEC_CTRL] =3D 0x0d60, @@ -548,9 +551,9 @@ putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32= _t css, uint32_t cse) static inline void inc_tx_bcast_or_mcast_count(E1000State *s, const unsigned char *arr) { - if (!memcmp(arr, bcast, sizeof bcast)) { + if (is_broadcast_ether_addr(arr)) { e1000x_inc_reg_if_not_full(s->mac_reg, BPTC); - } else if (arr[0] & 1) { + } else if (is_multicast_ether_addr(arr)) { e1000x_inc_reg_if_not_full(s->mac_reg, MPTC); } } @@ -804,14 +807,16 @@ static int receive_filter(E1000State *s, const uint8_t *buf, int size) { uint32_t rctl =3D s->mac_reg[RCTL]; - int isbcast =3D !memcmp(buf, bcast, sizeof bcast), ismcast =3D (buf[0]= & 1); + int isbcast =3D is_broadcast_ether_addr(buf); + int ismcast =3D is_multicast_ether_addr(buf); =20 if (e1000x_is_vlan_packet(buf, le16_to_cpu(s->mac_reg[VET])) && e1000x_vlan_rx_filter_enabled(s->mac_reg)) { - uint16_t vid =3D lduw_be_p(buf + 14); - uint32_t vfta =3D ldl_le_p((uint32_t *)(s->mac_reg + VFTA) + - ((vid >> 5) & 0x7f)); - if ((vfta & (1 << (vid & 0x1f))) =3D=3D 0) { + uint16_t vid =3D lduw_be_p(&PKT_GET_VLAN_HDR(buf)->h_tci); + uint32_t vfta =3D + ldl_le_p((uint32_t *)(s->mac_reg + VFTA) + + ((vid >> E1000_VFTA_ENTRY_SHIFT) & E1000_VFTA_ENTRY_M= ASK)); + if ((vfta & (1 << (vid & E1000_VFTA_ENTRY_BIT_SHIFT_MASK))) =3D=3D= 0) { return 0; } } @@ -909,7 +914,7 @@ e1000_receive_iov(NetClientState *nc, const struct iove= c *iov, int iovcnt) uint32_t rdh_start; uint16_t vlan_special =3D 0; uint8_t vlan_status =3D 0; - uint8_t min_buf[MIN_BUF_SIZE]; + uint8_t min_buf[ETH_ZLEN]; struct iovec min_iov; uint8_t *filter_buf =3D iov->iov_base; size_t size =3D iov_size(iov, iovcnt); @@ -1204,8 +1209,8 @@ static const readops macreg_readops[] =3D { [FFLT ... FFLT + 6] =3D &mac_readreg, [RA ... RA + 31] =3D &mac_readreg, [WUPM ... WUPM + 31] =3D &mac_readreg, - [MTA ... MTA + 127] =3D &mac_readreg, - [VFTA ... VFTA + 127] =3D &mac_readreg, + [MTA ... MTA + E1000_MC_TBL_SIZE - 1] =3D &mac_readreg, + [VFTA ... VFTA + E1000_VLAN_FILTER_TBL_SIZE - 1] =3D &mac_readreg, [FFMT ... FFMT + 254] =3D &mac_readreg, [FFVT ... FFVT + 254] =3D &mac_readreg, [PBM ... PBM + 16383] =3D &mac_readreg, @@ -1236,8 +1241,8 @@ static const writeops macreg_writeops[] =3D { [FFLT ... FFLT + 6] =3D &set_11bit, [RA ... RA + 31] =3D &mac_writereg, [WUPM ... WUPM + 31] =3D &mac_writereg, - [MTA ... MTA + 127] =3D &mac_writereg, - [VFTA ... VFTA + 127] =3D &mac_writereg, + [MTA ... MTA + E1000_MC_TBL_SIZE - 1] =3D &mac_writereg, + [VFTA ... VFTA + E1000_VLAN_FILTER_TBL_SIZE - 1] =3D &mac_writereg, [FFMT ... FFMT + 254] =3D &set_4bit, [FFVT ... FFVT + 254] =3D &ma= c_writereg, [PBM ... PBM + 16383] =3D &mac_writereg, }; @@ -1603,8 +1608,9 @@ static const VMStateDescription vmstate_e1000 =3D { VMSTATE_UINT32(mac_reg[WUFC], E1000State), VMSTATE_UINT32(mac_reg[VET], E1000State), VMSTATE_UINT32_SUB_ARRAY(mac_reg, E1000State, RA, 32), - VMSTATE_UINT32_SUB_ARRAY(mac_reg, E1000State, MTA, 128), - VMSTATE_UINT32_SUB_ARRAY(mac_reg, E1000State, VFTA, 128), + VMSTATE_UINT32_SUB_ARRAY(mac_reg, E1000State, MTA, E1000_MC_TBL_SI= ZE), + VMSTATE_UINT32_SUB_ARRAY(mac_reg, E1000State, VFTA, + E1000_VLAN_FILTER_TBL_SIZE), VMSTATE_END_OF_LIST() }, .subsections =3D (const VMStateDescription*[]) { diff --git a/hw/net/e1000_regs.h b/hw/net/e1000_regs.h index 59d6eb3189..3f6b5d0c52 100644 --- a/hw/net/e1000_regs.h +++ b/hw/net/e1000_regs.h @@ -1154,6 +1154,11 @@ struct e1000_data_desc { } upper; }; =20 +/* Filters */ +#define E1000_NUM_UNICAST 16 /* Unicast filter entries */ +#define E1000_MC_TBL_SIZE 128 /* Multicast Filter Table (4096 bit= s) */ +#define E1000_VLAN_FILTER_TBL_SIZE 128 /* VLAN Filter Table (4096 bits) */ + /* Management Control */ #define E1000_MANC_SMBUS_EN 0x00000001 /* SMBus Enabled - RO */ #define E1000_MANC_ASF_EN 0x00000002 /* ASF Enabled - RO */ @@ -1202,4 +1207,8 @@ struct e1000_data_desc { #define E1000_IOADDR 0x00 #define E1000_IODATA 0x04 =20 +#define E1000_VFTA_ENTRY_SHIFT 5 +#define E1000_VFTA_ENTRY_MASK 0x7F +#define E1000_VFTA_ENTRY_BIT_SHIFT_MASK 0x1F + #endif /* HW_E1000_REGS_H */ diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c index e79d4c79bd..b3bbf31582 100644 --- a/hw/net/e1000x_common.c +++ b/hw/net/e1000x_common.c @@ -26,6 +26,7 @@ #include "qemu/units.h" #include "hw/net/mii.h" #include "hw/pci/pci_device.h" +#include "net/eth.h" #include "net/net.h" =20 #include "e1000x_common.h" @@ -48,7 +49,7 @@ bool e1000x_rx_ready(PCIDevice *d, uint32_t *mac) =20 bool e1000x_is_vlan_packet(const uint8_t *buf, uint16_t vet) { - uint16_t eth_proto =3D lduw_be_p(buf + 12); + uint16_t eth_proto =3D lduw_be_p(&PKT_GET_ETH_HDR(buf)->h_proto); bool res =3D (eth_proto =3D=3D vet); =20 trace_e1000x_vlan_is_vlan_pkt(res, eth_proto, vet); @@ -67,7 +68,7 @@ bool e1000x_rx_group_filter(uint32_t *mac, const uint8_t = *buf) } ra[0] =3D cpu_to_le32(rp[0]); ra[1] =3D cpu_to_le32(rp[1]); - if (!memcmp(buf, (uint8_t *)ra, 6)) { + if (!memcmp(buf, (uint8_t *)ra, ETH_ALEN)) { trace_e1000x_rx_flt_ucast_match((int)(rp - mac - RA) / 2, MAC_ARG(buf)); return true; diff --git a/hw/net/e1000x_common.h b/hw/net/e1000x_common.h index 3501e4855a..b991d814b1 100644 --- a/hw/net/e1000x_common.h +++ b/hw/net/e1000x_common.h @@ -102,7 +102,7 @@ enum { static inline void e1000x_inc_reg_if_not_full(uint32_t *mac, int index) { - if (mac[index] !=3D 0xffffffff) { + if (mac[index] !=3D UINT32_MAX) { mac[index]++; } } --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147747; cv=none; d=zohomail.com; s=zohoarc; b=JRyagGVRTwVH0xwmQ7ky9wYwsqehtL8SKDzcOj3SrO4BUwOiodaL2wztd5KjDv2exgBHJg1NXxTpv2jXFzudhofT4af1NAQ1Uswq8/nSSwTZRqcAK9uogokuoqYPHeMnXc6JCuc9FtuEW/MNf/fdxc87ShCsPzbxAlFEQFZQScE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147747; 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=FnwZQEUzrMFVzDuTfyE5cJp2RPrgmk3+VIZHYS+vUOs=; b=NhnkAHSxwm6r3sEO0NcWMoiho3XRlD1ffVWcaX4t4Iy7WycAzw8305qNSZEsBQkHv3CmY/CMcC4ZlKJkZR43IyE2Abzq8srosqS0qBlVsiCLHOI+nPftn2Dh/fPr99dJ9Er3ANZxRWI7PULkp6AXbMDTDdoT0LI6szvMqmTeBbI= 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+importer2=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 1677147747721916.5184220595497; Thu, 23 Feb 2023 02:22:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8iz-00064R-Qo; Thu, 23 Feb 2023 05:21:17 -0500 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 1pV8iy-000646-B8 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:16 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8iw-00016b-9p for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:16 -0500 Received: by mail-pl1-x62b.google.com with SMTP id l15so13373647pls.1 for ; Thu, 23 Feb 2023 02:21:13 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=FnwZQEUzrMFVzDuTfyE5cJp2RPrgmk3+VIZHYS+vUOs=; b=ZO6otGMIYQG0JXsDC/R0eVbP2iUgNXPI+NKbn6jUaSKJxa2gJcmbpROqaHN8ktuxCP UhoKw+bJVhgHi7KkIpa75riWizBEOl0GOAXAHHf5I+U1g5kAroN1k7nKoaXP7EGY1F8p so4YlHa35Rl1TJGeVV78wDo15sJvLxVE+jxDU8FNX5c6CLg5EzujOGgq1c+dIJHoChvC DWv9GE5kc//3pafSQ0BATNtVZ+yx4QRSHhh1guocpGdjPubQmhDOcag7F0CNLOFYrFpV JrgejTTig0yUU7GbocoCHQxHO8inEKlm4mh/6b0eyNrYgbwZ/BZk5JpMnD0D4JScGEu/ 84xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=FnwZQEUzrMFVzDuTfyE5cJp2RPrgmk3+VIZHYS+vUOs=; b=EvQ3YKSK02nirT1oaQJQ5kV2KBrgo/mEt+BZppZFQnbXvCyshFgpftU0YV35YOumts 5hf0JPuG6zgImrwE2J3F3k/Aa8+zV9w8bAxkHiXzZ/IURHi9/oSvvrTYfPD9ziOzpmFW 7bQ82AV9mVISLXjDHRgeiFAp15g4I4J+Lo2tL3FNZZ0dVVhwYzDCkPF/egoWbckHEiHw AoqUsTJBjgOb5WY4+/uyGqvSlNdLXLBbjmvhc+KjYdkYTVagGX2HfBibt6jKucWkbjYs 9e3BQDiSwrJIRRpBBhMvmGzeKa1pw4Vwz6rEiXMSB0k9sOeHc3K1ezVyR3fNDYjyqchR dh4w== X-Gm-Message-State: AO0yUKV1jyMPQa4WJgQPz4sZGLAntabXBbL394QRnNbdfCjth7QSkoPE ge1rnHu03T6UPK7QO3SlTO5AQQ== X-Google-Smtp-Source: AK7set/nSoiN6e/MlCOJm7hWseriF6CYbzXXSIJTfxttx6DMyR5eDc6wKehlQoEEpsCHt92rJ/8UFw== X-Received: by 2002:a17:902:6b85:b0:19c:a9b8:43b6 with SMTP id p5-20020a1709026b8500b0019ca9b843b6mr3887834plk.10.1677147673616; Thu, 23 Feb 2023 02:21:13 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 09/34] e1000e: Use more constant definitions Date: Thu, 23 Feb 2023 19:19:53 +0900 Message-Id: <20230223102018.141748-10-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62b.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147747986100007 Content-Type: text/plain; charset="utf-8" The definitions of SW Semaphore Register were copied from: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drive= rs/net/ethernet/intel/e1000e/defines.h?h=3Dv6.0.9#n374 Signed-off-by: Akihiko Odaki --- hw/net/e1000_regs.h | 7 +++++++ hw/net/e1000e_core.c | 49 ++++++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/hw/net/e1000_regs.h b/hw/net/e1000_regs.h index 3f6b5d0c52..6a36573802 100644 --- a/hw/net/e1000_regs.h +++ b/hw/net/e1000_regs.h @@ -525,6 +525,13 @@ #define M88E1000_PHY_VCO_REG_BIT8 0x100 /* Bits 8 & 11 are adjusted for */ #define M88E1000_PHY_VCO_REG_BIT11 0x800 /* improved BER performance */ =20 +/* SW Semaphore Register */ +#define E1000_SWSM_SMBI 0x00000001 /* Driver Semaphore bit */ +#define E1000_SWSM_SWESMBI 0x00000002 /* FW Semaphore bit */ +#define E1000_SWSM_DRV_LOAD 0x00000008 /* Driver Loaded Bit */ + +#define E1000_SWSM2_LOCK 0x00000002 /* Secondary driver semaphore b= it */ + /* Interrupt Cause Read */ #define E1000_ICR_TXDW 0x00000001 /* Transmit desc written back */ #define E1000_ICR_TXQE 0x00000002 /* Transmit Queue empty */ diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index e6fc85ea51..6a4da72bd3 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1022,10 +1022,11 @@ e1000e_receive_filter(E1000ECore *core, const uint8= _t *buf, int size) =20 if (e1000x_is_vlan_packet(buf, core->mac[VET]) && e1000x_vlan_rx_filter_enabled(core->mac)) { - uint16_t vid =3D lduw_be_p(buf + 14); - uint32_t vfta =3D ldl_le_p((uint32_t *)(core->mac + VFTA) + - ((vid >> 5) & 0x7f)); - if ((vfta & (1 << (vid & 0x1f))) =3D=3D 0) { + uint16_t vid =3D lduw_be_p(&PKT_GET_VLAN_HDR(buf)->h_tci); + uint32_t vfta =3D + ldl_le_p((uint32_t *)(core->mac + VFTA) + + ((vid >> E1000_VFTA_ENTRY_SHIFT) & E1000_VFTA_ENTRY_M= ASK)); + if ((vfta & (1 << (vid & E1000_VFTA_ENTRY_BIT_SHIFT_MASK))) =3D=3D= 0) { trace_e1000e_rx_flt_vlan_mismatch(vid); return false; } else { @@ -1679,16 +1680,13 @@ e1000e_rx_fix_l4_csum(E1000ECore *core, struct NetR= xPkt *pkt) } } =20 -/* Min. octets in an ethernet frame sans FCS */ -#define MIN_BUF_SIZE 60 - ssize_t e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt) { - static const int maximum_ethernet_hdr_len =3D (14 + 4); + static const int maximum_ethernet_hdr_len =3D (ETH_HLEN + 4); =20 uint32_t n =3D 0; - uint8_t min_buf[MIN_BUF_SIZE]; + uint8_t min_buf[ETH_ZLEN]; struct iovec min_iov; uint8_t *filter_buf; size_t size, orig_size; @@ -2627,7 +2625,7 @@ static uint32_t e1000e_mac_swsm_read(E1000ECore *core, int index) { uint32_t val =3D core->mac[SWSM]; - core->mac[SWSM] =3D val | 1; + core->mac[SWSM] =3D val | E1000_SWSM_SMBI; return val; } =20 @@ -3092,8 +3090,8 @@ static const readops e1000e_macreg_readops[] =3D { [IP4AT ... IP4AT + 6] =3D e1000e_mac_readreg, [RA ... RA + 31] =3D e1000e_mac_readreg, [WUPM ... WUPM + 31] =3D e1000e_mac_readreg, - [MTA ... MTA + 127] =3D e1000e_mac_readreg, - [VFTA ... VFTA + 127] =3D e1000e_mac_readreg, + [MTA ... MTA + E1000_MC_TBL_SIZE - 1] =3D e1000e_mac_readreg, + [VFTA ... VFTA + E1000_VLAN_FILTER_TBL_SIZE - 1] =3D e1000e_mac_readr= eg, [FFMT ... FFMT + 254] =3D e1000e_mac_readreg, [FFVT ... FFVT + 254] =3D e1000e_mac_readreg, [MDEF ... MDEF + 7] =3D e1000e_mac_readreg, @@ -3245,8 +3243,8 @@ static const writeops e1000e_macreg_writeops[] =3D { [IP4AT ... IP4AT + 6] =3D e1000e_mac_writereg, [RA + 2 ... RA + 31] =3D e1000e_mac_writereg, [WUPM ... WUPM + 31] =3D e1000e_mac_writereg, - [MTA ... MTA + 127] =3D e1000e_mac_writereg, - [VFTA ... VFTA + 127] =3D e1000e_mac_writereg, + [MTA ... MTA + E1000_MC_TBL_SIZE - 1] =3D e1000e_mac_writereg, + [VFTA ... VFTA + E1000_VLAN_FILTER_TBL_SIZE - 1] =3D e1000e_mac_wri= tereg, [FFMT ... FFMT + 254] =3D e1000e_set_4bit, [FFVT ... FFVT + 254] =3D e1000e_mac_writereg, [PBM ... PBM + 10239] =3D e1000e_mac_writereg, @@ -3276,7 +3274,7 @@ static const uint16_t mac_reg_access[E1000E_MAC_SIZE]= =3D { [TDH_A] =3D 0x0cf8, [TDT_A] =3D 0x0cf8, [TIDV_A] =3D 0x0cf8, [TDFH_A] =3D 0xed00, [TDFT_A] =3D 0xed00, [RA_A ... RA_A + 31] =3D 0x14f0, - [VFTA_A ... VFTA_A + 127] =3D 0x1400, + [VFTA_A ... VFTA_A + E1000_VLAN_FILTER_TBL_SIZE - 1] =3D 0x1400, [RDBAL0_A ... RDLEN0_A] =3D 0x09bc, [TDBAL_A ... TDLEN_A] =3D 0x0cf8, /* Access options */ @@ -3433,13 +3431,20 @@ e1000e_phy_reg_init[E1000E_PHY_PAGES][E1000E_PHY_PA= GE_SIZE] =3D { =20 [MII_PHYID1] =3D 0x141, [MII_PHYID2] =3D E1000_PHY_ID2_82574x, - [MII_ANAR] =3D 0xde1, - [MII_ANLPAR] =3D 0x7e0, - [MII_ANER] =3D BIT(2), - [MII_ANNP] =3D BIT(0) | BIT(13), - [MII_CTRL1000] =3D BIT(8) | BIT(9) | BIT(10) | BIT(11), - [MII_STAT1000] =3D 0x3c00, - [MII_EXTSTAT] =3D BIT(12) | BIT(13), + [MII_ANAR] =3D MII_ANAR_CSMACD | MII_ANAR_10 | + MII_ANAR_10FD | MII_ANAR_TX | + MII_ANAR_TXFD | MII_ANAR_PAUSE | + MII_ANAR_PAUSE_ASYM, + [MII_ANLPAR] =3D MII_ANLPAR_10 | MII_ANLPAR_10FD | + MII_ANLPAR_TX | MII_ANLPAR_TXFD | + MII_ANLPAR_T4 | MII_ANLPAR_PAUSE, + [MII_ANER] =3D MII_ANER_NP, + [MII_ANNP] =3D 1 | MII_ANNP_MP, + [MII_CTRL1000] =3D MII_CTRL1000_HALF | MII_CTRL1000_FULL | + MII_CTRL1000_PORT | MII_CTRL1000_MASTER, + [MII_STAT1000] =3D MII_STAT1000_HALF | MII_STAT1000_FULL | + MII_STAT1000_ROK | MII_STAT1000_LOK, + [MII_EXTSTAT] =3D MII_EXTSTAT_1000T_HD | MII_EXTSTAT_100= 0T_FD, =20 [PHY_COPPER_CTRL1] =3D BIT(5) | BIT(6) | BIT(8) | BIT(9) | BIT(12) | BIT(13), --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147979; cv=none; d=zohomail.com; s=zohoarc; b=Jm3fsOOmTrTt8a8BsK5a1eJerUqwnAcGvtM7hzXN93YdMaZZd/ZYwtVZscJApM7VBZl/G0wYthGvPSMOb7zksTSVVQBxla+PjIEYzSBNm/uvaAInY8lbMQsekKVcVfisPIwGdRicqc8fsGCM01XjREF3vbGzEmXRNY9Ty00lOaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147979; 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=LG8tq76sMobR10hriWHj/a6wTqkVZm1W1tagtp7KN+0=; b=HSeUbndYdbFLG58f1913DE+LKKhdtDKpNGl/oPgoCjxEudB8bUiD1Rq2NHaHmoabtmwScVxuVlS5BmRqBMPPiusKFhnAjXOoHdy0BZSn7+HmifIFuQNNN/si2MZGBXrqz9wCObvv0jvItEXw++v8FP+NlReFXIF7x5wNYX6Y+lU= 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+importer2=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 1677147979685576.3870653774821; Thu, 23 Feb 2023 02:26:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8j3-00066G-HX; Thu, 23 Feb 2023 05:21:21 -0500 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 1pV8j1-00065J-Gr for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:19 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8j0-00020i-2A for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:19 -0500 Received: by mail-pl1-x62f.google.com with SMTP id ky4so13410780plb.3 for ; Thu, 23 Feb 2023 02:21:17 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=LG8tq76sMobR10hriWHj/a6wTqkVZm1W1tagtp7KN+0=; b=I8c0tV3IN0m6tHZv0vLS7dwfoManBSz13vH+178e3scNW9Trk7mw4iBfKsxwMyr+v3 FiXkpRVmfQpknvPjmdRGi48jRm2rzyQf6n9ycKcBwmFaqYX6ZaZn/C1ZZaerwB9eanif +Key4hhH5NFQkI8iIITuSZPGK5qy/rru6tQU0A1uhhGbEOAr5xpeYo+PROMrwqxBROT9 1To3LgxZZURpmAE3wtfpNCtOAE6OtvUHYYW3tVf65Mq9Io636FkZ2csHzL4U2xfaj5kv njTnVYg9lHgXdOyR0y7lbCCg8MuYFfi8ZKgvsU8BVtYU3tzOdLVQKrVykGV8j1b6xY/Y zFtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=LG8tq76sMobR10hriWHj/a6wTqkVZm1W1tagtp7KN+0=; b=gtmd0AeMy96hvA7i8B/QSsx27kaR7mcejBmZQmRFKdhpOpxZR2fOA7kZyp4z1g/52i pIlXiRZKKzsMkEILIWq7h5D7goAnupF3PDrqmvwSyUVWyxHYAVvNxZ63yh+enVGbf5p5 MAPnCAeh9YHLQ5+OJPoLURID6TGbTJeouuhdzwzOZ8wruGyZSfo3WY2NfFOZDsmD7OzN CAIp2Ja3SnYSIZaiUtOkTkDJ60ah2AOjSUHZL+j3D/P3Dod9whd4S4H8G3CWnvqvroTv SCUhHm2Je/cxMUs0tg5gopepZokVl1U14/KagdxREcDiJ0ybopufvveq4F+AdMsvuY6L 2Oww== X-Gm-Message-State: AO0yUKX+/eCjv7x6A+FFlvgMIL2W0B9UkrLvXb+VArwyYfvwOEa7OT/q s3RnLZ2jFJk8nOUurkuQACigxQ== X-Google-Smtp-Source: AK7set9JKdl4n/U6ZBKdpsEZ0iEU23VLJyT96qsMc/rKATo1SOL4tL6JOjaJX2DrJfDiPsHbm/i3cw== X-Received: by 2002:a17:902:d486:b0:19a:8b3a:fad with SMTP id c6-20020a170902d48600b0019a8b3a0fadmr16283480plg.20.1677147677013; Thu, 23 Feb 2023 02:21:17 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 10/34] e1000: Use memcpy to intialize registers Date: Thu, 23 Feb 2023 19:19:54 +0900 Message-Id: <20230223102018.141748-11-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62f.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147981485100011 Content-Type: text/plain; charset="utf-8" Use memcpy instead of memmove to initialize registers. The initial register templates and register table instances will never overlap. Signed-off-by: Akihiko Odaki --- hw/net/e1000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index d9d048f665..3353a3752c 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -390,10 +390,10 @@ static void e1000_reset(void *opaque) d->mit_irq_level =3D 0; d->mit_ide =3D 0; memset(d->phy_reg, 0, sizeof d->phy_reg); - memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init); + memcpy(d->phy_reg, phy_reg_init, sizeof phy_reg_init); d->phy_reg[MII_PHYID2] =3D edc->phy_id2; memset(d->mac_reg, 0, sizeof d->mac_reg); - memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init); + memcpy(d->mac_reg, mac_reg_init, sizeof mac_reg_init); d->rxbuf_min_shift =3D 1; memset(&d->tx, 0, sizeof d->tx); =20 --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147860; cv=none; d=zohomail.com; s=zohoarc; b=cfrRwyEHE1Xfl4OMWFFci+qRTidlG8ul8hr0zkkOQaJV5m7BOsgTDdaGYITkAdSZgs39kaM8tEVHSLSj5zMiUpxFGqT3yCEWEDvwe14IMGoLZ2KlVQROxj78e3O4MhQ4+AtoOr7XXOwLkBCcTyrSG/mhT6wo55O65X1lPSUu59U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147860; 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=2I2qnGVaZLWPm0YolfUBdJT/b10cmArelvHHWWX/I+I=; b=JJjA0ORAqu2e7lmqmTKnsaYSVxNOlHIzE66PGQzif8G/xyUh8RTQsu1kfiOeKGEtj85TicXaN2HK/t6wreBuBOyQCEzMf0xDTfleU9unF1fNk8orJgSTF5vvahpV8rrgPmWMfv08JAlo5wdF5FNE/WNVBfAvxqrlVT/6b2PCvB8= 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+importer2=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 1677147860091376.6232680562449; Thu, 23 Feb 2023 02:24:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8j6-00069G-QN; Thu, 23 Feb 2023 05:21:24 -0500 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 1pV8j5-00066r-1A for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:23 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8j3-00023A-GW for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:22 -0500 Received: by mail-pj1-x1036.google.com with SMTP id cp7-20020a17090afb8700b0023756229427so3427563pjb.1 for ; Thu, 23 Feb 2023 02:21:21 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=2I2qnGVaZLWPm0YolfUBdJT/b10cmArelvHHWWX/I+I=; b=4ZJvwLPVk0hsh2wnoiXwneZyluIAFUE0/Blagwp28LqjFx0mwjlVtMk4RsxlYfBBBD f89qOdlYOlsT6xipM7GElYf3YpMjlyM1XMx6REgNOByNrcDCSS3hmCV4fgJQ2Z/gis8G IE8g7Ip7BZ4KSm1MUISMZbUlsw/KHuXgzbh93Hvgw493zpEt13BsaYTqRhAbXuCoJWWo +8C2tZLwoHjNR6NsaWB4xOCV7WpZL6h+kr4nvzibLFWtwMv2ia6DcA90rWw/g9+AdAvV nhW6RzbYOCQ7FkqawKiIQSeV2kgF2NnvD37cvk9BDG8uhy2fPvNdeaOz3OkV4rWPhtHo vLkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=2I2qnGVaZLWPm0YolfUBdJT/b10cmArelvHHWWX/I+I=; b=Fy5VMqn6JxrflJ2ZQjXR16APyBTc9q5ZTX228XUMVcE6DAAhQ9Ni0yG998fGMcg9t2 siM1jdJEWfKhrScOMsOzNjotyWEelT/o6Mn6FI1V82LoYU+Hnii3JN0cHcAQ9sVZV87q hTFoimkKSO08cKaGvQy0bcJW6dBMXxeRazhW1uxE8d5xtDrg340SlLvgPo2Az50e3sMx VIURj0vj+PT204wldNYQ4X3pjDEeuyxZ0wSvs8HOC/BBuLAN5+f+8EYFnCc6FzsTeqfD L3A7083qzw4pZwhBvAu7FFxkmI/wB/oA96GQwonZ85tekjswleHihf7ZabFUkFspSFZq MjWA== X-Gm-Message-State: AO0yUKW7ZLFKAecpnBOlZukb6aygD7sjv95sFQ1Zz+oVBj2oeQL6cZQR 44usaGBaPa/Cw96p44+VhtXZ0A== X-Google-Smtp-Source: AK7set/XohguJuUEXI7Xza+cxNQXxtAI69DT0HKO17Yh4eOSHhWKnXo8rXouU37O5tyXhSpwrz9f8Q== X-Received: by 2002:a17:903:7cc:b0:19a:b343:d9ac with SMTP id ko12-20020a17090307cc00b0019ab343d9acmr9657220plb.65.1677147680432; Thu, 23 Feb 2023 02:21:20 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 11/34] e1000e: Use memcpy to intialize registers Date: Thu, 23 Feb 2023 19:19:55 +0900 Message-Id: <20230223102018.141748-12-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1036; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1036.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147860881100007 Content-Type: text/plain; charset="utf-8" Use memcpy instead of memmove to initialize registers. The initial register templates and register table instances will never overlap. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 6a4da72bd3..87f964cdc1 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -3511,9 +3511,9 @@ e1000e_core_reset(E1000ECore *core) e1000e_intrmgr_reset(core); =20 memset(core->phy, 0, sizeof core->phy); - memmove(core->phy, e1000e_phy_reg_init, sizeof e1000e_phy_reg_init); + memcpy(core->phy, e1000e_phy_reg_init, sizeof e1000e_phy_reg_init); memset(core->mac, 0, sizeof core->mac); - memmove(core->mac, e1000e_mac_reg_init, sizeof e1000e_mac_reg_init); + memcpy(core->mac, e1000e_mac_reg_init, sizeof e1000e_mac_reg_init); =20 core->rxbuf_min_shift =3D 1 + E1000_RING_DESC_LEN_SHIFT; =20 --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147745; cv=none; d=zohomail.com; s=zohoarc; b=iLMB07D1cv0UNvLNQ1DYSizP6DCBEjl4T/7HLfJe7+ZMME7rx/141M1XwL/wSwQWqLYsePE9LFoRMq1jIEugvbQHb79s2jr5Ykq8c4wrx9/7sgXMyW0jFWiIpaZ+oNxv8Qa3aXvMohnjl7GLNXzD5VbLCvqErRZDbH+D2eLcbN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147745; 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=NEMZ+8i6PiEHu0HMZDSd3axjDLwfNLs2Zat3qCkOTgQ=; b=m52Dz+KEEkeHfnOpJmCQwLQfanCWoYmhifUEWccuCtaLQTLRctCG0wHM3frttiAev1oouCj/AJl6Ke04npWDrOZ6G/i6IKJCTE9pKILKXFAVp9f+AiPcfJEMhuUF9lT3vbKO/2+mJdbkjtsIegMx5ME5zjpxBv4bvfGmamgG5vA= 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+importer2=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 1677147745382608.0131717069811; Thu, 23 Feb 2023 02:22:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jA-0006AL-CU; Thu, 23 Feb 2023 05:21:28 -0500 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 1pV8j8-00069c-Jd for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:26 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8j6-00027Y-UZ for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:26 -0500 Received: by mail-pj1-x102e.google.com with SMTP id d1-20020a17090a3b0100b00229ca6a4636so12448073pjc.0 for ; Thu, 23 Feb 2023 02:21:24 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=NEMZ+8i6PiEHu0HMZDSd3axjDLwfNLs2Zat3qCkOTgQ=; b=u2a9fOVi1YgAKzlv5RJzwfktrcZbV1OjJLetnYrHhzi1Zki2yyJQ8CyKVjA1rQp3MO gjzxglGXUNJS+gGVbfngGL1tZmtLHhuc3ioAIq5o5i81K1s3kgU6nh8DuohvZCbco6eu hNMQ4lhiP5y7C7w02RDyKQEtPm/iQahOn/QQN5mZwEmmfdNAFdFIFIgkmjPXzY55b9j4 Nt7iCq6x+35UhjcAddhAU4VtjXwjiS5RttUvpOLNw1a4iGStk9N3iTMh/NnLt6O2z/qJ LMY3sjS672gtphBdVK62Km5Oedc0IU9+DqWikITDtsmWnEhOdRXVnpcxeQ/eIID7BwcM RDOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=NEMZ+8i6PiEHu0HMZDSd3axjDLwfNLs2Zat3qCkOTgQ=; b=rxJ/NBmDAEoGwfT8GcaM+PM2lbhkBzEtOgpdwc84qDVtwoSe3RXNyiTJyN9OjPzPb3 0jRbcaxblpB7//8sjlApXbChiAw1gQznQTrHXTJqJluW3Hwh9mhzLUJxK4IheOJ7pRco 5W0EX7nEteF46ad1qC8pt/UZGaHYaG4b3KezPAOn85quOpIF/odUgUkoljbX9YEeS5Gq ZEIUfqRDKsdXnWHxpLSqEoqT1KciLvVWTVgsTpSRPIq4egRSUtuOsoOp4szU5ZvqPKU3 XJWXx82KnkZOBdNY1cwXujUxy7/cbaMmQ+9gDWO+ZLEmlWP5oK4U4TPda62ID/trGfZt wN1g== X-Gm-Message-State: AO0yUKXAxAJnNbMUfSDs6zvORLkauTe+h8/TzGOuUOzHdyDEjf/MiBhm 2TApzzvzlyfx2SHT3xggTfUl2g== X-Google-Smtp-Source: AK7set+wkQ97ENmCDtvZ/zSaxBzaRplX4ctu6Io9HzTgycWYM+sQOpR5E0BYot34NQRCTLKAsCtHMA== X-Received: by 2002:a17:902:da8e:b0:19a:73fb:6175 with SMTP id j14-20020a170902da8e00b0019a73fb6175mr12899339plx.27.1677147683703; Thu, 23 Feb 2023 02:21:23 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 12/34] e1000e: Remove pending interrupt flags Date: Thu, 23 Feb 2023 19:19:56 +0900 Message-Id: <20230223102018.141748-13-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102e.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147745981100001 Content-Type: text/plain; charset="utf-8" They are duplicate of running throttling timer flags and incomplete as the flags are not cleared when the interrupts are fired or the device is reset. Signed-off-by: Akihiko Odaki --- hw/net/e1000e.c | 5 ++--- hw/net/e1000e_core.c | 19 +++---------------- hw/net/e1000e_core.h | 2 -- hw/net/trace-events | 2 -- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index d591d01c07..0bc222d354 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -631,12 +631,11 @@ static const VMStateDescription e1000e_vmstate =3D { VMSTATE_E1000E_INTR_DELAY_TIMER(core.tidv, E1000EState), =20 VMSTATE_E1000E_INTR_DELAY_TIMER(core.itr, E1000EState), - VMSTATE_BOOL(core.itr_intr_pending, E1000EState), + VMSTATE_UNUSED(1), =20 VMSTATE_E1000E_INTR_DELAY_TIMER_ARRAY(core.eitr, E1000EState, E1000E_MSIX_VEC_NUM), - VMSTATE_BOOL_ARRAY(core.eitr_intr_pending, E1000EState, - E1000E_MSIX_VEC_NUM), + VMSTATE_UNUSED(E1000E_MSIX_VEC_NUM), =20 VMSTATE_UINT32(core.itr_guest_value, E1000EState), VMSTATE_UINT32_ARRAY(core.eitr_guest_value, E1000EState, diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 87f964cdc1..37aec6a970 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -154,11 +154,6 @@ e1000e_intrmgr_on_throttling_timer(void *opaque) =20 timer->running =3D false; =20 - if (!timer->core->itr_intr_pending) { - trace_e1000e_irq_throttling_no_pending_interrupts(); - return; - } - if (msi_enabled(timer->core->owner)) { trace_e1000e_irq_msi_notify_postponed(); /* Clear msi_causes_pending to fire MSI eventually */ @@ -180,11 +175,6 @@ e1000e_intrmgr_on_msix_throttling_timer(void *opaque) =20 timer->running =3D false; =20 - if (!timer->core->eitr_intr_pending[idx]) { - trace_e1000e_irq_throttling_no_pending_vec(idx); - return; - } - trace_e1000e_irq_msix_notify_postponed_vec(idx); msix_notify(timer->core->owner, idx); } @@ -2015,13 +2005,11 @@ e1000e_clear_ims_bits(E1000ECore *core, uint32_t bi= ts) } =20 static inline bool -e1000e_postpone_interrupt(bool *interrupt_pending, - E1000IntrDelayTimer *timer) +e1000e_postpone_interrupt(E1000IntrDelayTimer *timer) { if (timer->running) { trace_e1000e_irq_postponed_by_xitr(timer->delay_reg << 2); =20 - *interrupt_pending =3D true; return true; } =20 @@ -2035,14 +2023,13 @@ e1000e_postpone_interrupt(bool *interrupt_pending, static inline bool e1000e_itr_should_postpone(E1000ECore *core) { - return e1000e_postpone_interrupt(&core->itr_intr_pending, &core->itr); + return e1000e_postpone_interrupt(&core->itr); } =20 static inline bool e1000e_eitr_should_postpone(E1000ECore *core, int idx) { - return e1000e_postpone_interrupt(&core->eitr_intr_pending[idx], - &core->eitr[idx]); + return e1000e_postpone_interrupt(&core->eitr[idx]); } =20 static void diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h index b8f38c47a0..d0a14b4523 100644 --- a/hw/net/e1000e_core.h +++ b/hw/net/e1000e_core.h @@ -95,10 +95,8 @@ struct E1000Core { E1000IntrDelayTimer tidv; =20 E1000IntrDelayTimer itr; - bool itr_intr_pending; =20 E1000IntrDelayTimer eitr[E1000E_MSIX_VEC_NUM]; - bool eitr_intr_pending[E1000E_MSIX_VEC_NUM]; =20 VMChangeStateEntry *vmstate; =20 diff --git a/hw/net/trace-events b/hw/net/trace-events index 4c0ec3fda1..8fa4299704 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -201,10 +201,8 @@ e1000e_rx_metadata_ipv6_filtering_disabled(void) "IPv6= RX filtering disabled by e1000e_vlan_vet(uint16_t vet) "Setting VLAN ethernet type 0x%X" =20 e1000e_irq_msi_notify(uint32_t cause) "MSI notify 0x%x" -e1000e_irq_throttling_no_pending_interrupts(void) "No pending interrupts t= o notify" e1000e_irq_msi_notify_postponed(void) "Sending MSI postponed by ITR" e1000e_irq_legacy_notify_postponed(void) "Raising legacy IRQ postponed by = ITR" -e1000e_irq_throttling_no_pending_vec(int idx) "No pending interrupts for v= ector %d" e1000e_irq_msix_notify_postponed_vec(int idx) "Sending MSI-X postponed by = EITR[%d]" e1000e_irq_legacy_notify(bool level) "IRQ line state: %d" e1000e_irq_msix_notify_vec(uint32_t vector) "MSI-X notify vector 0x%x" --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147993; cv=none; d=zohomail.com; s=zohoarc; b=FESQtLlZBcS5yYm45ReBFDI5q1nzVYsXWc8K/GeL2J1l/e5xBDTP7Ru3AiM994uDt6+akcuZqb5XRlu0s2UAEnXhPXijFWmMYxEW1S8FMG26lSlIPMKibo+jcnqWxZ1crTPu2ABHRRe35nN/cdDctiqoXa8gs9SAKcUJGQGqWco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147993; 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=EHclpSWk2JKU9ohNpbqjRIyblKNi65CiMHRdVnsb5nQ=; b=CC9B4XS1M3QomzIODSyxlwcWwscx7V0GBaBG785//YaytQ90GW5VOPbhu1SUsoC3qwUjL8i1hYi9NpBrTwc9QtxUiaATGDtiw6YKc3Hl1uecT97vw8aiWbcZgOMaPKWSK/lN9jlMMFwa/RoQn22eWLfW3x2yDZQJOFVbeWXu5Bw= 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+importer2=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 1677147993077895.2766180545366; Thu, 23 Feb 2023 02:26:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jD-0006DX-07; Thu, 23 Feb 2023 05:21:31 -0500 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 1pV8jB-0006Af-NU for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:29 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jA-0002Ch-4P for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:29 -0500 Received: by mail-pj1-x1034.google.com with SMTP id u10so12327461pjc.5 for ; Thu, 23 Feb 2023 02:21:27 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=EHclpSWk2JKU9ohNpbqjRIyblKNi65CiMHRdVnsb5nQ=; b=e6yJz+w5/ne3mTyTtakFEQjuYzKtsUzQAUXJr9/7/8RFr+r8j4KFY37YwJevtt/ImQ E5645om+i4bmeoeoekX8YCVi9ahXAEaawtQ5mexQ8rWsyATJHeHl2zWeMjyYnrctjVwB VStHGsxrySet6nfifEhzXow5DIgZ9dBFE9kDL+9bk2zvm8PV5vrz3+d6kfGsuD+qB2fW 2RZ3T2uOcSb+SEd/dX4Wde1+aoWbFWuT9k6uOS5HJ/JruZx+Z+UD69t9CP6YeslqJ172 Bx2OzhdDpzl4xVIe64uB7N0H/wU7HtjDbQCXWok4J+Ak5gk8nSpzgfUTbZE7rRy7dzqO se0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=EHclpSWk2JKU9ohNpbqjRIyblKNi65CiMHRdVnsb5nQ=; b=TsPwpOdSjtPjr2xQYxOUYwgTbcPJw3QQiM+kGpt/0887tdODRJnbO0AFCbvdk0WdVs BA/q9JC01jXHfPhH/PDkF6u6BCqdFKog38gWHl3oa56bdCHikhEGIMetyK277R/3Oeo2 27ToOvdXJNEVjW/52RZOJVucCkaWtbNqmx20K5Xr2E6mg2VU/voRBRvruZLJWlZQYU/C cumf7u0ZD1yM+c96YcRBYNiuL9VZHoUbZR8mxO42RKuCa+lT6TUhtFmFM3Hu8LzZGsXo G0em5sIuD/izM3mceX7N9lCXtFrbKvuwMv8UJaDGuAev+1cFVFVaFnyDI316ZTYpEDof EbJg== X-Gm-Message-State: AO0yUKWBgZ7qEDnuUNN/Xx7nRvbPITLyJTY5aPep2Ph4Ey8dlymsL4QV YENQLNpOLQoBS6kZ1OOPykmY/A== X-Google-Smtp-Source: AK7set9RpFThcxb2ZHirwhYtIzYRVIhuONiND/L6Am3XcXXfcBsYLCkoJM+QtPW8aONXao8bmrd4EQ== X-Received: by 2002:a17:903:786:b0:19a:8338:703b with SMTP id kn6-20020a170903078600b0019a8338703bmr9417853plb.57.1677147686935; Thu, 23 Feb 2023 02:21:26 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 13/34] e1000e: Improve software reset Date: Thu, 23 Feb 2023 19:19:57 +0900 Message-Id: <20230223102018.141748-14-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1034; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1034.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147993605100001 Content-Type: text/plain; charset="utf-8" This change makes e1000e reset more things when software reset was triggered. Some registers are exempted from software reset in the datasheet and this change also implements the behavior accordingly. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 37aec6a970..b8670662c8 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -58,6 +58,8 @@ static inline void e1000e_set_interrupt_cause(E1000ECore *core, uint32_t val); =20 +static void e1000e_reset(E1000ECore *core, bool sw); + static inline void e1000e_process_ts_option(E1000ECore *core, struct e1000_tx_desc *dp) { @@ -1882,7 +1884,7 @@ e1000e_set_ctrl(E1000ECore *core, int index, uint32_t= val) =20 if (val & E1000_CTRL_RST) { trace_e1000e_core_ctrl_sw_reset(); - e1000x_reset_mac_addr(core->owner_nic, core->mac, core->permanent_= mac); + e1000e_reset(core, true); } =20 if (val & E1000_CTRL_PHY_RST) { @@ -3488,8 +3490,7 @@ static const uint32_t e1000e_mac_reg_init[] =3D { [EITR...EITR + E1000E_MSIX_VEC_NUM - 1] =3D E1000E_MIN_XITR, }; =20 -void -e1000e_core_reset(E1000ECore *core) +static void e1000e_reset(E1000ECore *core, bool sw) { int i; =20 @@ -3499,8 +3500,15 @@ e1000e_core_reset(E1000ECore *core) =20 memset(core->phy, 0, sizeof core->phy); memcpy(core->phy, e1000e_phy_reg_init, sizeof e1000e_phy_reg_init); - memset(core->mac, 0, sizeof core->mac); - memcpy(core->mac, e1000e_mac_reg_init, sizeof e1000e_mac_reg_init); + + for (i =3D 0; i < E1000E_MAC_SIZE; i++) { + if (sw && (i =3D=3D PBA || i =3D=3D PBS || i =3D=3D FLA)) { + continue; + } + + core->mac[i] =3D i < ARRAY_SIZE(e1000e_mac_reg_init) ? + e1000e_mac_reg_init[i] : 0; + } =20 core->rxbuf_min_shift =3D 1 + E1000_RING_DESC_LEN_SHIFT; =20 @@ -3517,6 +3525,12 @@ e1000e_core_reset(E1000ECore *core) } } =20 +void +e1000e_core_reset(E1000ECore *core) +{ + e1000e_reset(core, false); +} + void e1000e_core_pre_save(E1000ECore *core) { int i; --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147838; cv=none; d=zohomail.com; s=zohoarc; b=Vp5W3Zjvo1EaZnPRTqUZY9ovIT/MRA8MZefmvQtl7vPikLG+2MhE+hzSf6tuDHFv5lYpKM5sCiy41GGRNkqG2qUum2zvBErAQGumpStfFMBknU38m+Erux7GVw3yHqJ5IulQI7pXezkFbbVZ3rZjdmLM9SLI1z0z3WkWdd21J3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147838; h=Content-Type: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=A95PLfu5QduSNtWNtARVjFG+JlZHlsOhrX6r7BxoUgQ=; b=kT937+X0UaSGQhxyWGLpjApg+dshMOG0Gr/X8hBVmShxeDn3vQTJYWgP1YyKyov2M4L5Pk64Eqff0Q4zwsm2iJSjRW/AxvUs1K4UEdBOCHGs73bI+uMKQaaNPJK30m+GcbuaiNs6fKSaUIJwfGqiE6380Dmnocm155bIEWmFMTA= 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+importer2=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 1677147838553204.82368652708465; Thu, 23 Feb 2023 02:23:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jG-0006GB-8c; Thu, 23 Feb 2023 05:21:34 -0500 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 1pV8jF-0006Fd-AD for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:33 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jD-0002GR-M6 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:32 -0500 Received: by mail-pj1-x1036.google.com with SMTP id qa18-20020a17090b4fd200b0023750b675f5so4105413pjb.3 for ; Thu, 23 Feb 2023 02:21:31 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=A95PLfu5QduSNtWNtARVjFG+JlZHlsOhrX6r7BxoUgQ=; b=qutgqOUhHGfar/oR8rIK0tnfrTA19Nt/ufXOa/KLPac+p6B7TvXSxvI4sF//OcGPI9 Wd3kWa2CMhNpInMq2r8dVilFivIz7eYAG/bUYS8Swj84zmIiWXamtxlbpOlX7ElG7dCm 0BJWjQ+R46a2pNfG89+dd2k7PfwOpIPAPf1SttDv88X7ZuM8woDh59XKlhmO7WjCUMtl tVCCq0oxbaBcB8ju1wAPegUEDxL7CDBqy9TLNjAJlDjSSPdAbEr8TK9Qz0dKlePo8jFS M2BkIC92ZXnUY1N3FE5alnmBpdpfAQjI5TFixL2ZxbfSIHVGjn0XZBLMPq/Div0G5cKy tKmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=A95PLfu5QduSNtWNtARVjFG+JlZHlsOhrX6r7BxoUgQ=; b=dPPeXjgQgO7GG8ZEMz6UiPSxoV3BgY3tfqs8WzkfaJQ1IOBqBg5YtR/oaRzuvrxWyB EY092tTEFCdBD1NXHjwxnePQPzTD5N+SH3L0ku/C1N8jZDfw8zgfXwfYt44HRmuPgDi9 02R1wJdlghnWv7y2mPBRjAsTIL2YauGc/fc6cA+dsb2SfdBgOWQuAZ3ypeN+dYyz+whm x63CBDvwJ9C42HolwA8NNhzfUANAkp4MGqm6jKrPYRp4RTmzTAKZIYVoGUHbQWV62Ewp of+OwdDdedrbs/O0Y1jJtRfBxw16m9U174ATdIAWy1tLVtHl/oshGnkGM+xgpuiQf/J1 26AA== X-Gm-Message-State: AO0yUKUcqeD1Z7l7nrxSsHzSXHORpCZC4MbZk/Y0FgjYo6XiCGecWmu/ Q4KhFyVUAMC8S+uif+rUrD0ZXg== X-Google-Smtp-Source: AK7set+pYT7UGjEWVDukF3eeP/0M9lSeVUEAb/YSJebzjIBsRRIYiMHTeoJ1HtkddOespKTKPkRB+w== X-Received: by 2002:a17:902:ecc1:b0:19a:b67a:5bd8 with SMTP id a1-20020a170902ecc100b0019ab67a5bd8mr13744937plh.55.1677147690550; Thu, 23 Feb 2023 02:21:30 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 14/34] e1000: Configure ResettableClass Date: Thu, 23 Feb 2023 19:19:58 +0900 Message-Id: <20230223102018.141748-15-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1036; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1036.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147840750100003 This is part of recent efforts of refactoring e1000 and e1000e. DeviceClass's reset member is deprecated so migrate to ResettableClass. There is no behavioral difference. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/e1000.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 3353a3752c..c81d914a02 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -377,9 +377,9 @@ static bool e1000_vet_init_need(void *opaque) return chkflag(VET); } =20 -static void e1000_reset(void *opaque) +static void e1000_reset_hold(Object *obj) { - E1000State *d =3D opaque; + E1000State *d =3D E1000(obj); E1000BaseClass *edc =3D E1000_GET_CLASS(d); uint8_t *macaddr =3D d->conf.macaddr.a; =20 @@ -1731,12 +1731,6 @@ static void pci_e1000_realize(PCIDevice *pci_dev, Er= ror **errp) e1000_flush_queue_timer, d); } =20 -static void qdev_e1000_reset(DeviceState *dev) -{ - E1000State *d =3D E1000(dev); - e1000_reset(d); -} - static Property e1000_properties[] =3D { DEFINE_NIC_PROPERTIES(E1000State, conf), DEFINE_PROP_BIT("autonegotiation", E1000State, @@ -1762,6 +1756,7 @@ typedef struct E1000Info { static void e1000_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); E1000BaseClass *e =3D E1000_CLASS(klass); const E1000Info *info =3D data; @@ -1774,9 +1769,9 @@ static void e1000_class_init(ObjectClass *klass, void= *data) k->revision =3D info->revision; e->phy_id2 =3D info->phy_id2; k->class_id =3D PCI_CLASS_NETWORK_ETHERNET; + rc->phases.hold =3D e1000_reset_hold; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); dc->desc =3D "Intel Gigabit Ethernet"; - dc->reset =3D qdev_e1000_reset; dc->vmsd =3D &vmstate_e1000; device_class_set_props(dc, e1000_properties); } --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147724; cv=none; d=zohomail.com; s=zohoarc; b=kg3SVfrGwjengM253wtwF9IKxe1GQCFDMOY7nNcrgAXa3JBJI6hg5sQ81fZigNr4rzSnih0rg3aCTlh8nNbh4gF78NOFDHQMSalzyx93mVZwzJBZ5QIx+HC9eVMhtl9R1FuN3h/npAYBPmNAi4gPln+oF1EGLvFiMVnqbg6FqTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147724; h=Content-Type: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=ZKDVIajL0grC0IZX1mMpfaruSFD28K8Vy5dxxXgXXEo=; b=XbgMyOfOMCNTHf9IGSyQxZFX65S2oVddV0KpZH5TArMR646Pmc0IFLMR6D5jHc3BbHd+XuRKc3CNh36WRGUgZNMeUYVfpFKcKFpIPtGEuqYfyz9F31ZoKgzFfLiVpPyzoA225tvEd8alZZQFD/v5xBCSrqWFNtE3G9dYh83mL9o= 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+importer2=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 1677147724105161.94353405884726; Thu, 23 Feb 2023 02:22:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jK-0006XE-Rm; Thu, 23 Feb 2023 05:21:38 -0500 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 1pV8jI-0006Mt-OM for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:36 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jH-0002Kx-8j for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:36 -0500 Received: by mail-pl1-x630.google.com with SMTP id i3so1777720plg.6 for ; Thu, 23 Feb 2023 02:21:34 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=ZKDVIajL0grC0IZX1mMpfaruSFD28K8Vy5dxxXgXXEo=; b=n80RXDfV45dASeFSbFN3l5fEl0uLsjjW9Z17OiI1UB47WJQhx8gQSawUEgHSGDIabZ SFfMh9nNWzkQK+HiuG36mLjVc8M+yuD6MgKL0VMn2goFPCiTE/8n/j3JQrP5wmhiiISi xDzJpelEvFFxn8oVB8JmCkf4dEkMRybvguc0m46G0eN7liaqHL5bT0cIJ7VlgJ8RukwT Y6qd+NG+AaBCTvsC0butwGAPfN+dJg6xUfvxkJ1BjaVuyYTMsARjdXtfgsEld9+Aixn2 ENXcVQQdeE1295rHgZhDBnpTaTZXpEtQJ501OB6au750+h5nMxnFZJFs5VPjR6/fMu7w w1QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ZKDVIajL0grC0IZX1mMpfaruSFD28K8Vy5dxxXgXXEo=; b=JC5jp0Cx8Qn9uZAndJk1pVtRg8pgt+czv65JfnWXfxa1T8Cel64nh1rWB0+Tebdatc +txxoOF/9ZMAzl7oUQHggr/isF7dTB1q4i5sPQM1Q74tn+LpOuhTDALk8/YI/nlkCt5k a68zsKlilDthFQAg9qT41Wxf7eqvovhIbIYHTFkO3FuWB/R4zq7v6AdE0+oPJqD6VZFs rvfn7/QL8He9NnP0GuO8EHy+sfwfEKvRSLN5NADuu/w7NoNwfPMLyvjpP0WECYVu3gYU 0mVoeYE7Y0SQ/sTQc12Kfo7f1whY6Vofn95+C7OpkP5uboxNQwWedS3SG1Z2Ap43NBrm FgzQ== X-Gm-Message-State: AO0yUKV2Sf1qRh413ieTdxlZyrZM9vUEd6rHMmsFf3CiFPr6FlvzcoOz qIMjjFLMf9lu0MJfWEUZYbJ7UQ== X-Google-Smtp-Source: AK7set8r4wKpk4m3n+lhzTHe9pkCs4Lo0OeQpZ28zJ6zPOHC5N44SfwPridWndl3jHY3f5jVCFtWBw== X-Received: by 2002:a17:90b:5111:b0:237:6adb:4c39 with SMTP id sc17-20020a17090b511100b002376adb4c39mr821595pjb.7.1677147694181; Thu, 23 Feb 2023 02:21:34 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 15/34] e1000e: Configure ResettableClass Date: Thu, 23 Feb 2023 19:19:59 +0900 Message-Id: <20230223102018.141748-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::630; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x630.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147725874100003 This is part of recent efforts of refactoring e1000 and e1000e. DeviceClass's reset member is deprecated so migrate to ResettableClass. There is no behavioral difference. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/e1000e.c | 10 ++++++---- hw/net/trace-events | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index 0bc222d354..ec274319c4 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -513,11 +513,11 @@ static void e1000e_pci_uninit(PCIDevice *pci_dev) msi_uninit(pci_dev); } =20 -static void e1000e_qdev_reset(DeviceState *dev) +static void e1000e_qdev_reset_hold(Object *obj) { - E1000EState *s =3D E1000E(dev); + E1000EState *s =3D E1000E(obj); =20 - trace_e1000e_cb_qdev_reset(); + trace_e1000e_cb_qdev_reset_hold(); =20 e1000e_core_reset(&s->core); =20 @@ -669,6 +669,7 @@ static Property e1000e_properties[] =3D { static void e1000e_class_init(ObjectClass *class, void *data) { DeviceClass *dc =3D DEVICE_CLASS(class); + ResettableClass *rc =3D RESETTABLE_CLASS(class); PCIDeviceClass *c =3D PCI_DEVICE_CLASS(class); =20 c->realize =3D e1000e_pci_realize; @@ -679,8 +680,9 @@ static void e1000e_class_init(ObjectClass *class, void = *data) c->romfile =3D "efi-e1000e.rom"; c->class_id =3D PCI_CLASS_NETWORK_ETHERNET; =20 + rc->phases.hold =3D e1000e_qdev_reset_hold; + dc->desc =3D "Intel 82574L GbE Controller"; - dc->reset =3D e1000e_qdev_reset; dc->vmsd =3D &e1000e_vmstate; =20 e1000e_prop_disable_vnet =3D qdev_prop_uint8; diff --git a/hw/net/trace-events b/hw/net/trace-events index 8fa4299704..c98ad12537 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -251,7 +251,7 @@ e1000e_vm_state_stopped(void) "VM state is stopped" # e1000e.c e1000e_cb_pci_realize(void) "E1000E PCI realize entry" e1000e_cb_pci_uninit(void) "E1000E PCI unit entry" -e1000e_cb_qdev_reset(void) "E1000E qdev reset entry" +e1000e_cb_qdev_reset_hold(void) "E1000E qdev reset hold" e1000e_cb_pre_save(void) "E1000E pre save entry" e1000e_cb_post_load(void) "E1000E post load entry" =20 --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147772; cv=none; d=zohomail.com; s=zohoarc; b=OW+yseHqBYEkh35qmZWiZmMqz4LQzbSNsM4cZiFm/PUMYQMfTN2CM6PoreJc8u/fbELRi8rrvLqNF7xonOfifAA/5HQndfxYAlEoh/q184vMJP1DlD0e5v0dz+kIx179SnvvqQxYhTsIYxE8RBEZnNATcG+DxPGbgZ0WL0UQtQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147772; 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=X6bMQPn27htLIZJGdysKYn/UoRZGCqzC2RjtDpR8YjM=; b=QhKa4FdXoztdPgCWdJy0Qs6pFKDxMWPssdwzYU48OTP5GgQP8REtdbP6JesJrMz4xMRfI+U8pA14NTXfB/Kcl8I5mqL1/qmfw8VpepIxBcv5AH6F7SxR79Nw2bgCxuImVII/vWEAocjgn7rjU7SBFds4jBtarCuJB5vgiCYN65M= 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+importer2=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 167714777238723.367076615810447; Thu, 23 Feb 2023 02:22:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jX-0006i2-Od; Thu, 23 Feb 2023 05:21:52 -0500 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 1pV8jM-0006ch-Vn for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:41 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jL-0002Uc-0o for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:40 -0500 Received: by mail-pl1-x62c.google.com with SMTP id ko13so12858783plb.13 for ; Thu, 23 Feb 2023 02:21:38 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=X6bMQPn27htLIZJGdysKYn/UoRZGCqzC2RjtDpR8YjM=; b=jdtLpRA7B0L87H4ti3hpX7H7TxTQKipHGrV2+zSYOwMV83xjK1KNZ7YBK+L2cETT4M N9Gl7h+IOu9UEH/TQ8OR0qsD6KtQnO9V32kTo3Cg20vyrXOiDCT6Zy6gtMafSLfqiZxK sLo0I91+yxb8Jn99w0jFo+a/psDI/jV6M6TWrHU6gbfEc8YDrvVtsDnJBw7iQbvjv15Y nckNamHRI57cuwpWuk82QC34lqB7Pif7QJArKMoMifmPy0NfO08qfA5uNbQFMmmtSUDt X2bKTcMJVE1eI6I6ZL8e+flJ5HB88z50Aw0oyPq+0VBs5WxZUe2z6k70RWljmDJPY9gn ztKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=X6bMQPn27htLIZJGdysKYn/UoRZGCqzC2RjtDpR8YjM=; b=31Q/dXEkVNGJwPYFQCyD3C2DU5LfuD0ifWL/WFHS39r9gocnvCT1kePHJL796mwvr9 EMb1L3NQaicbf0XWmKa/vfvl36gsN9v+DfpBwf0BIVq9S+jiJo2BwulHDC4MSlkQeoyh r1UdV/7C1WDAKeroQbZpx/7NVRQK1pBEQZlkuZUkpl0UrX7gojKxWrcI0BGJkwEFY11q AraKidTEa/xX1pQx4EKPG0Zf8Dhw9qcwePu/p14+MnRnqEIUspbdC2qhijvWOyFLRGv5 8/IbwoqfXg2yjNXxJshrG5DSg9nA52w4aO/jaY1865jDGa2Hehooe/WVfRfOh50KpPjs 4LAw== X-Gm-Message-State: AO0yUKVnokCW41CN216mZKg/A8iT0Z0zJocidOeR1QiMdlvp9a765mIK dkElQQpXRLmUgssy2rL4JYTI7A== X-Google-Smtp-Source: AK7set+O6AUmEZwkvztbUE2qWrk/eALM07aGpy0uqvOm/fHKqlb8bgFdFKkMBb2QMU2q0f/LYHmfaw== X-Received: by 2002:a17:902:ea01:b0:199:30a6:3756 with SMTP id s1-20020a170902ea0100b0019930a63756mr12197256plg.18.1677147697541; Thu, 23 Feb 2023 02:21:37 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 16/34] e1000e: Introduce e1000_rx_desc_union Date: Thu, 23 Feb 2023 19:20:00 +0900 Message-Id: <20230223102018.141748-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62c.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147774204100003 Content-Type: text/plain; charset="utf-8" Before this change, e1000e_write_packet_to_guest() allocated the receive descriptor buffer as an array of uint8_t. This does not ensure the buffer is sufficiently aligned. Introduce e1000_rx_desc_union type, a union type of all receive descriptor types to correct this. Signed-off-by: Akihiko Odaki --- hw/net/e1000_regs.h | 1 - hw/net/e1000e_core.c | 115 +++++++++++++++++++++---------------------- 2 files changed, 57 insertions(+), 59 deletions(-) diff --git a/hw/net/e1000_regs.h b/hw/net/e1000_regs.h index 6a36573802..4545fe25a6 100644 --- a/hw/net/e1000_regs.h +++ b/hw/net/e1000_regs.h @@ -1061,7 +1061,6 @@ union e1000_rx_desc_packet_split { #define E1000_RING_DESC_LEN_SHIFT (4) =20 #define E1000_MIN_RX_DESC_LEN E1000_RING_DESC_LEN -#define E1000_MAX_RX_DESC_LEN (sizeof(union e1000_rx_desc_packet_split)) =20 /* Receive Descriptor bit definitions */ #define E1000_RXD_STAT_DD 0x01 /* Descriptor Done */ diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index b8670662c8..d8c17baf8f 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -55,6 +55,12 @@ =20 #define E1000E_MAX_TX_FRAGS (64) =20 +union e1000_rx_desc_union { + struct e1000_rx_desc legacy; + union e1000_rx_desc_extended extended; + union e1000_rx_desc_packet_split packet_split; +}; + static inline void e1000e_set_interrupt_cause(E1000ECore *core, uint32_t val); =20 @@ -1053,29 +1059,28 @@ e1000e_receive_filter(E1000ECore *core, const uint8= _t *buf, int size) } =20 static inline void -e1000e_read_lgcy_rx_descr(E1000ECore *core, uint8_t *desc, hwaddr *buff_ad= dr) +e1000e_read_lgcy_rx_descr(E1000ECore *core, struct e1000_rx_desc *desc, + hwaddr *buff_addr) { - struct e1000_rx_desc *d =3D (struct e1000_rx_desc *) desc; - *buff_addr =3D le64_to_cpu(d->buffer_addr); + *buff_addr =3D le64_to_cpu(desc->buffer_addr); } =20 static inline void -e1000e_read_ext_rx_descr(E1000ECore *core, uint8_t *desc, hwaddr *buff_add= r) +e1000e_read_ext_rx_descr(E1000ECore *core, union e1000_rx_desc_extended *d= esc, + hwaddr *buff_addr) { - union e1000_rx_desc_extended *d =3D (union e1000_rx_desc_extended *) d= esc; - *buff_addr =3D le64_to_cpu(d->read.buffer_addr); + *buff_addr =3D le64_to_cpu(desc->read.buffer_addr); } =20 static inline void -e1000e_read_ps_rx_descr(E1000ECore *core, uint8_t *desc, +e1000e_read_ps_rx_descr(E1000ECore *core, + union e1000_rx_desc_packet_split *desc, hwaddr (*buff_addr)[MAX_PS_BUFFERS]) { int i; - union e1000_rx_desc_packet_split *d =3D - (union e1000_rx_desc_packet_split *) desc; =20 for (i =3D 0; i < MAX_PS_BUFFERS; i++) { - (*buff_addr)[i] =3D le64_to_cpu(d->read.buffer_addr[i]); + (*buff_addr)[i] =3D le64_to_cpu(desc->read.buffer_addr[i]); } =20 trace_e1000e_rx_desc_ps_read((*buff_addr)[0], (*buff_addr)[1], @@ -1083,17 +1088,17 @@ e1000e_read_ps_rx_descr(E1000ECore *core, uint8_t *= desc, } =20 static inline void -e1000e_read_rx_descr(E1000ECore *core, uint8_t *desc, +e1000e_read_rx_descr(E1000ECore *core, union e1000_rx_desc_union *desc, hwaddr (*buff_addr)[MAX_PS_BUFFERS]) { if (e1000e_rx_use_legacy_descriptor(core)) { - e1000e_read_lgcy_rx_descr(core, desc, &(*buff_addr)[0]); + e1000e_read_lgcy_rx_descr(core, &desc->legacy, &(*buff_addr)[0]); (*buff_addr)[1] =3D (*buff_addr)[2] =3D (*buff_addr)[3] =3D 0; } else { if (core->mac[RCTL] & E1000_RCTL_DTYP_PS) { - e1000e_read_ps_rx_descr(core, desc, buff_addr); + e1000e_read_ps_rx_descr(core, &desc->packet_split, buff_addr); } else { - e1000e_read_ext_rx_descr(core, desc, &(*buff_addr)[0]); + e1000e_read_ext_rx_descr(core, &desc->extended, &(*buff_addr)[= 0]); (*buff_addr)[1] =3D (*buff_addr)[2] =3D (*buff_addr)[3] =3D 0; } } @@ -1264,7 +1269,7 @@ func_exit: } =20 static inline void -e1000e_write_lgcy_rx_descr(E1000ECore *core, uint8_t *desc, +e1000e_write_lgcy_rx_descr(E1000ECore *core, struct e1000_rx_desc *desc, struct NetRxPkt *pkt, const E1000E_RSSInfo *rss_info, uint16_t length) @@ -1272,71 +1277,66 @@ e1000e_write_lgcy_rx_descr(E1000ECore *core, uint8_= t *desc, uint32_t status_flags, rss, mrq; uint16_t ip_id; =20 - struct e1000_rx_desc *d =3D (struct e1000_rx_desc *) desc; - assert(!rss_info->enabled); =20 - d->length =3D cpu_to_le16(length); - d->csum =3D 0; + desc->length =3D cpu_to_le16(length); + desc->csum =3D 0; =20 e1000e_build_rx_metadata(core, pkt, pkt !=3D NULL, rss_info, &rss, &mrq, &status_flags, &ip_id, - &d->special); - d->errors =3D (uint8_t) (le32_to_cpu(status_flags) >> 24); - d->status =3D (uint8_t) le32_to_cpu(status_flags); + &desc->special); + desc->errors =3D (uint8_t) (le32_to_cpu(status_flags) >> 24); + desc->status =3D (uint8_t) le32_to_cpu(status_flags); } =20 static inline void -e1000e_write_ext_rx_descr(E1000ECore *core, uint8_t *desc, +e1000e_write_ext_rx_descr(E1000ECore *core, union e1000_rx_desc_extended *= desc, struct NetRxPkt *pkt, const E1000E_RSSInfo *rss_info, uint16_t length) { - union e1000_rx_desc_extended *d =3D (union e1000_rx_desc_extended *) d= esc; - - memset(&d->wb, 0, sizeof(d->wb)); + memset(&desc->wb, 0, sizeof(desc->wb)); =20 - d->wb.upper.length =3D cpu_to_le16(length); + desc->wb.upper.length =3D cpu_to_le16(length); =20 e1000e_build_rx_metadata(core, pkt, pkt !=3D NULL, rss_info, - &d->wb.lower.hi_dword.rss, - &d->wb.lower.mrq, - &d->wb.upper.status_error, - &d->wb.lower.hi_dword.csum_ip.ip_id, - &d->wb.upper.vlan); + &desc->wb.lower.hi_dword.rss, + &desc->wb.lower.mrq, + &desc->wb.upper.status_error, + &desc->wb.lower.hi_dword.csum_ip.ip_id, + &desc->wb.upper.vlan); } =20 static inline void -e1000e_write_ps_rx_descr(E1000ECore *core, uint8_t *desc, +e1000e_write_ps_rx_descr(E1000ECore *core, + union e1000_rx_desc_packet_split *desc, struct NetRxPkt *pkt, const E1000E_RSSInfo *rss_info, size_t ps_hdr_len, uint16_t(*written)[MAX_PS_BUFFERS]) { int i; - union e1000_rx_desc_packet_split *d =3D - (union e1000_rx_desc_packet_split *) desc; =20 - memset(&d->wb, 0, sizeof(d->wb)); + memset(&desc->wb, 0, sizeof(desc->wb)); =20 - d->wb.middle.length0 =3D cpu_to_le16((*written)[0]); + desc->wb.middle.length0 =3D cpu_to_le16((*written)[0]); =20 for (i =3D 0; i < PS_PAGE_BUFFERS; i++) { - d->wb.upper.length[i] =3D cpu_to_le16((*written)[i + 1]); + desc->wb.upper.length[i] =3D cpu_to_le16((*written)[i + 1]); } =20 e1000e_build_rx_metadata(core, pkt, pkt !=3D NULL, rss_info, - &d->wb.lower.hi_dword.rss, - &d->wb.lower.mrq, - &d->wb.middle.status_error, - &d->wb.lower.hi_dword.csum_ip.ip_id, - &d->wb.middle.vlan); + &desc->wb.lower.hi_dword.rss, + &desc->wb.lower.mrq, + &desc->wb.middle.status_error, + &desc->wb.lower.hi_dword.csum_ip.ip_id, + &desc->wb.middle.vlan); =20 - d->wb.upper.header_status =3D + desc->wb.upper.header_status =3D cpu_to_le16(ps_hdr_len | (ps_hdr_len ? E1000_RXDPS_HDRSTAT_HDRSP := 0)); =20 trace_e1000e_rx_desc_ps_write((*written)[0], (*written)[1], @@ -1344,20 +1344,21 @@ e1000e_write_ps_rx_descr(E1000ECore *core, uint8_t = *desc, } =20 static inline void -e1000e_write_rx_descr(E1000ECore *core, uint8_t *desc, +e1000e_write_rx_descr(E1000ECore *core, union e1000_rx_desc_union *desc, struct NetRxPkt *pkt, const E1000E_RSSInfo *rss_info, size_t ps_hdr_len, uint16_t(*written)[MAX_PS_BUFFERS]) { if (e1000e_rx_use_legacy_descriptor(core)) { assert(ps_hdr_len =3D=3D 0); - e1000e_write_lgcy_rx_descr(core, desc, pkt, rss_info, (*written)[0= ]); + e1000e_write_lgcy_rx_descr(core, &desc->legacy, pkt, rss_info, + (*written)[0]); } else { if (core->mac[RCTL] & E1000_RCTL_DTYP_PS) { - e1000e_write_ps_rx_descr(core, desc, pkt, rss_info, + e1000e_write_ps_rx_descr(core, &desc->packet_split, pkt, rss_i= nfo, ps_hdr_len, written); } else { assert(ps_hdr_len =3D=3D 0); - e1000e_write_ext_rx_descr(core, desc, pkt, rss_info, + e1000e_write_ext_rx_descr(core, &desc->extended, pkt, rss_info, (*written)[0]); } } @@ -1365,12 +1366,12 @@ struct NetRxPkt *pkt, const E1000E_RSSInfo *rss_inf= o, =20 static inline void e1000e_pci_dma_write_rx_desc(E1000ECore *core, dma_addr_t addr, - uint8_t *desc, dma_addr_t len) + union e1000_rx_desc_union *desc, dma_addr_t l= en) { PCIDevice *dev =3D core->owner; =20 if (e1000e_rx_use_legacy_descriptor(core)) { - struct e1000_rx_desc *d =3D (struct e1000_rx_desc *) desc; + struct e1000_rx_desc *d =3D &desc->legacy; size_t offset =3D offsetof(struct e1000_rx_desc, status); uint8_t status =3D d->status; =20 @@ -1383,8 +1384,7 @@ e1000e_pci_dma_write_rx_desc(E1000ECore *core, dma_ad= dr_t addr, } } else { if (core->mac[RCTL] & E1000_RCTL_DTYP_PS) { - union e1000_rx_desc_packet_split *d =3D - (union e1000_rx_desc_packet_split *) desc; + union e1000_rx_desc_packet_split *d =3D &desc->packet_split; size_t offset =3D offsetof(union e1000_rx_desc_packet_split, wb.middle.status_error); uint32_t status =3D d->wb.middle.status_error; @@ -1397,8 +1397,7 @@ e1000e_pci_dma_write_rx_desc(E1000ECore *core, dma_ad= dr_t addr, pci_dma_write(dev, addr + offset, &status, sizeof(status)); } } else { - union e1000_rx_desc_extended *d =3D - (union e1000_rx_desc_extended *) desc; + union e1000_rx_desc_extended *d =3D &desc->extended; size_t offset =3D offsetof(union e1000_rx_desc_extended, wb.upper.status_error); uint32_t status =3D d->wb.upper.status_error; @@ -1542,7 +1541,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, { PCIDevice *d =3D core->owner; dma_addr_t base; - uint8_t desc[E1000_MAX_RX_DESC_LEN]; + union e1000_rx_desc_union desc; size_t desc_size; size_t desc_offset =3D 0; size_t iov_ofs =3D 0; @@ -1578,7 +1577,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, =20 trace_e1000e_rx_descr(rxi->idx, base, core->rx_desc_len); =20 - e1000e_read_rx_descr(core, desc, &ba); + e1000e_read_rx_descr(core, &desc, &ba); =20 if (ba[0]) { if (desc_offset < size) { @@ -1648,9 +1647,9 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, is_last =3D true; } =20 - e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL, + e1000e_write_rx_descr(core, &desc, is_last ? core->rx_pkt : NULL, rss_info, do_ps ? ps_hdr_len : 0, &bastate.writ= ten); - e1000e_pci_dma_write_rx_desc(core, base, desc, core->rx_desc_len); + e1000e_pci_dma_write_rx_desc(core, base, &desc, core->rx_desc_len); =20 e1000e_ring_advance(core, rxi, core->rx_desc_len / E1000_MIN_RX_DESC_LEN); --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147926; cv=none; d=zohomail.com; s=zohoarc; b=WY9DFRv/ILAQqH+BqdO9b8QchASV5UuZkaEQJpuRYqba/5N56P/PmZ93cgNLHa1TAvIKj+sZ1MaQggc/KUI7VENz+5skdlm/ETinogaFi/WSiXYkAJffETm8hYRva30ClgERjLL0FnBafcLyUZfu4xekZVjtq7wgdZSj8unydgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147926; h=Content-Type: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=eZRgT2FmJP6k2+ivrsYlbkoFP3usbYCinymjfjo1wFU=; b=OMXunAJq9MvRyIX7M50ki1BOmYeEcihWWBnYMmCKEXJoG5KqVQW1MW5/TFA0bgVVOeE97gCSb7qG5SteTRrWO+6IPU6s+H3LPcjsWrR1b7Zkw59h+7n3SXnL0Hg5XBOMMMsb/3Lg7dHqXRg8xQxaPdGi8ofjcshdHq91n5uhtOo= 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+importer2=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 1677147926703256.19642018101536; Thu, 23 Feb 2023 02:25:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jZ-0006mC-CI; Thu, 23 Feb 2023 05:21:53 -0500 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 1pV8jP-0006dr-N5 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:45 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jO-0002V8-5Z for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:43 -0500 Received: by mail-pj1-x1030.google.com with SMTP id z20-20020a17090a8b9400b002372d7f823eso8261390pjn.4 for ; Thu, 23 Feb 2023 02:21:41 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=eZRgT2FmJP6k2+ivrsYlbkoFP3usbYCinymjfjo1wFU=; b=RkD3SdpHjMH1Nd0uVY/p5abQAnxU4FGGwSS+QP99/TtoWsLqmrTYLPzv0Kx/xkAF+3 l9xWob3mIWhf5OT5ivbufYXfjjW5AkBRh3aCMyL8eu5CjFw+Oo3eY7cuILXHTk2MLJcA TUfu6b8cG0iWSqK6fnHS6S5crOfazlmJi73O/oxSoFaZH1w+/ElvXoGgFrYYhLQ9Alci ubk9yHdwual+qi4Faa0iF9k4Ce10FsIZFRF2z5X0SFQIEGVaTl3mqA90p2QswErgXGXP mLMhWQJQEOFzeNszTMNHlXq6gbSYGkk7gWcRD83LxJ+z/M90bbmo+ezUtQDNuAlbyQCS Tp5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eZRgT2FmJP6k2+ivrsYlbkoFP3usbYCinymjfjo1wFU=; b=h7uTBouDEdjJ/6Dc+wEqT3kkv14julFiQJ7roQn11ZOPJeWrIuT5bMhFEqBye4vEle +NRcbugtUMGIhhdwcrfnOWuhGV4cIjBJjgKkoYqlAOdXrHlsD6bVmg4I1KCpo7L6HbwL qhBRVknI4AmuQ8uj7E3KSIToXTXbug1zfKBSBBou7w1d57ZVszdDPwLCQ7oyHOAK6Oaa GUDRn3XD9AJnfs2oKwvfsHvhYc8heEgEczU/4v0lDiN7zEnOkjbamNi+50Uk9KuGM/eR ZrWFnKX7vbSFf61exAXjvj2Ejqpi90oD2cy4z/lnbhSvOB+89BQFEzJGqEYUaWE++xf5 4JFg== X-Gm-Message-State: AO0yUKVIPvF6M/DN3+9eYLh7pU8NPPNqQyNOkE46wf4VXjBsJr4Wix46 MMOyvxP007KbFO4JgOAueUW9I4ilB03gJRo9 X-Google-Smtp-Source: AK7set++mzEIoX7Dh0DVvVparDWYz5sEiTpeparkCXQZcWnwoqinyQw+8ZetJfnpvYqYF/2RliaQDg== X-Received: by 2002:a17:902:ecd0:b0:19b:2332:18cb with SMTP id a16-20020a170902ecd000b0019b233218cbmr14090957plh.1.1677147700974; Thu, 23 Feb 2023 02:21:40 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 17/34] e1000e: Set MII_ANER_NWAY Date: Thu, 23 Feb 2023 19:20:01 +0900 Message-Id: <20230223102018.141748-18-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1030; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1030.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147927308100001 This keeps Windows driver 12.18.9.23 from generating an event with ID 30. The description of the event is as follows: > Intel(R) 82574L Gigabit Network Connection > PROBLEM: The network adapter is configured for auto-negotiation but > the link partner is not. This may result in a duplex mismatch. > ACTION: Configure the link partner for auto-negotiation. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/e1000e_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index d8c17baf8f..736708407c 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -3426,7 +3426,7 @@ e1000e_phy_reg_init[E1000E_PHY_PAGES][E1000E_PHY_PAGE= _SIZE] =3D { [MII_ANLPAR] =3D MII_ANLPAR_10 | MII_ANLPAR_10FD | MII_ANLPAR_TX | MII_ANLPAR_TXFD | MII_ANLPAR_T4 | MII_ANLPAR_PAUSE, - [MII_ANER] =3D MII_ANER_NP, + [MII_ANER] =3D MII_ANER_NP | MII_ANER_NWAY, [MII_ANNP] =3D 1 | MII_ANNP_MP, [MII_CTRL1000] =3D MII_CTRL1000_HALF | MII_CTRL1000_FULL | MII_CTRL1000_PORT | MII_CTRL1000_MASTER, --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147869; cv=none; d=zohomail.com; s=zohoarc; b=DhuZHjDk1SptG6+yCekSiA/mnVbS+ejKuK2ukdrYCsP6tBi3O8+35enDU5BiARPUOEbRcjsmdhYQHtBb1cN1MrpnV8HulTA1020GspgY2I82vfN1mi0QADOOsntAJxqA6O4peGMsB64o3sCEamChkeUz7OPXCu4Jv5IGSw2r2cw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147869; h=Content-Type: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=Lkd52RBk6GEtzLexVG2esWofdxIUyPYLGO6mQp3hTXA=; b=PtX+PF9klyvddQACd8QfHDCHz70XtILAxvzg+2JYNy1InNfdTBoRNtSF+WfX+tO0tHKjdIt3YrU+jCJQ0vlF2fOAV9KX9yxRym476xZFy4oicoQubxxTNF4h45+ygR3BlN3kTRg5u+6mUHdP+67TQbXw3skg941fySG+2b/I64Y= 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+importer2=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 167714786948017.662410082289284; Thu, 23 Feb 2023 02:24:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jZ-0006md-Jx; Thu, 23 Feb 2023 05:21:53 -0500 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 1pV8jU-0006hn-QH for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:50 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jS-0002Vy-0R for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:48 -0500 Received: by mail-pj1-x1032.google.com with SMTP id x20-20020a17090a8a9400b00233ba727724so3613907pjn.1 for ; Thu, 23 Feb 2023 02:21:45 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=Lkd52RBk6GEtzLexVG2esWofdxIUyPYLGO6mQp3hTXA=; b=dXVt1/r9j33gyQwf69w94vfRWZ5V43RQTdYJ8UpoAMDGAUMfiTifJCx6MPCjG4oQmb qqicB9Q6+qsS8iOEhbh3Pe06XE9kIRY30wUne3yjAvIHwTJEwXJ4QdZAnj67SnmVapNi TG73COEpdFEhUN9ABvIUNKGMixFzl2BSbiZCXsa9IieSorNQFjJL1uPP2zM7yvzEHVjj 6SQjLllZqrW6sNksStQ9NHpo3nQAvG38uqFv7RtgilVuUgNtLTMwBqjswVDrhO/LOh5R 03l0gIiqi/2l8fO/8eJ7zTU5RAd5Lm31VKbtXORXpVf3jd7wJl7L8LKhX02yl2+9AOA+ 11og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Lkd52RBk6GEtzLexVG2esWofdxIUyPYLGO6mQp3hTXA=; b=RiM9thd2grpI+sp/Y+aeDmpN3ddyn21ul9oADJa0f6KbrWqnZbMV9yFc+pwL5WFYYS dgf2T81nwD7pmB10seeimbk0HiwfO6ydLpAaBjzaB2uv8l7+Oi7/5QO+Acqr99Lla1aE t6VFnyndlbbyu0gXMUxdjKyJ6Rk7NvpJQq/mkVCWk3w8vJ2FQNkiLKG2FNniJKxxH7W1 Q093sbfBLBZnIqZV6dg7X0ZdZombsKdpyuth/9Gsj8xHsKx8zmNJoruvOGlXcf1dLWRn 3Fuu+NV2VasFtMm5jkT+uM/JNuzkb5agU1xeTYWM2ErWbZfrQODZE2PuZcNiagVEvy9M Rppg== X-Gm-Message-State: AO0yUKVF1a+OkYpl1okkwZ4zjckBa0mShRKek2zo+h3Nqs7hU6jNEM7h V/VLmkbn540yeAH7ikuWK4q4kA== X-Google-Smtp-Source: AK7set+acEZ9VzTHHWaOpdtkKoPNJ3RaObaYe0LtF5KhMWQCx7Z0VrcaUqqOI/nODRt0nszWqwH2IA== X-Received: by 2002:a17:902:d50d:b0:19a:93fc:c4d0 with SMTP id b13-20020a170902d50d00b0019a93fcc4d0mr12688176plg.12.1677147704592; Thu, 23 Feb 2023 02:21:44 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 18/34] e1000e: Remove extra pointer indirection Date: Thu, 23 Feb 2023 19:20:02 +0900 Message-Id: <20230223102018.141748-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1032; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1032.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147871016100003 e1000e_write_packet_to_guest() passes the reference of variable ba as a pointer to an array, and that pointer indirection is just unnecessary; all functions which uses the passed reference performs no pointer operation on the pointer and they simply dereference the passed pointer. Remove the extra pointer indirection. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/e1000e_core.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 736708407c..d143f2ae6f 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1075,31 +1075,31 @@ e1000e_read_ext_rx_descr(E1000ECore *core, union e1= 000_rx_desc_extended *desc, static inline void e1000e_read_ps_rx_descr(E1000ECore *core, union e1000_rx_desc_packet_split *desc, - hwaddr (*buff_addr)[MAX_PS_BUFFERS]) + hwaddr buff_addr[MAX_PS_BUFFERS]) { int i; =20 for (i =3D 0; i < MAX_PS_BUFFERS; i++) { - (*buff_addr)[i] =3D le64_to_cpu(desc->read.buffer_addr[i]); + buff_addr[i] =3D le64_to_cpu(desc->read.buffer_addr[i]); } =20 - trace_e1000e_rx_desc_ps_read((*buff_addr)[0], (*buff_addr)[1], - (*buff_addr)[2], (*buff_addr)[3]); + trace_e1000e_rx_desc_ps_read(buff_addr[0], buff_addr[1], + buff_addr[2], buff_addr[3]); } =20 static inline void e1000e_read_rx_descr(E1000ECore *core, union e1000_rx_desc_union *desc, - hwaddr (*buff_addr)[MAX_PS_BUFFERS]) + hwaddr buff_addr[MAX_PS_BUFFERS]) { if (e1000e_rx_use_legacy_descriptor(core)) { - e1000e_read_lgcy_rx_descr(core, &desc->legacy, &(*buff_addr)[0]); - (*buff_addr)[1] =3D (*buff_addr)[2] =3D (*buff_addr)[3] =3D 0; + e1000e_read_lgcy_rx_descr(core, &desc->legacy, &buff_addr[0]); + buff_addr[1] =3D buff_addr[2] =3D buff_addr[3] =3D 0; } else { if (core->mac[RCTL] & E1000_RCTL_DTYP_PS) { e1000e_read_ps_rx_descr(core, &desc->packet_split, buff_addr); } else { - e1000e_read_ext_rx_descr(core, &desc->extended, &(*buff_addr)[= 0]); - (*buff_addr)[1] =3D (*buff_addr)[2] =3D (*buff_addr)[3] =3D 0; + e1000e_read_ext_rx_descr(core, &desc->extended, &buff_addr[0]); + buff_addr[1] =3D buff_addr[2] =3D buff_addr[3] =3D 0; } } } @@ -1420,14 +1420,14 @@ typedef struct e1000e_ba_state_st { =20 static inline void e1000e_write_hdr_to_rx_buffers(E1000ECore *core, - hwaddr (*ba)[MAX_PS_BUFFERS], + hwaddr ba[MAX_PS_BUFFERS], e1000e_ba_state *bastate, const char *data, dma_addr_t data_len) { assert(data_len <=3D core->rxbuf_sizes[0] - bastate->written[0]); =20 - pci_dma_write(core->owner, (*ba)[0] + bastate->written[0], data, data_= len); + pci_dma_write(core->owner, ba[0] + bastate->written[0], data, data_len= ); bastate->written[0] +=3D data_len; =20 bastate->cur_idx =3D 1; @@ -1435,7 +1435,7 @@ e1000e_write_hdr_to_rx_buffers(E1000ECore *core, =20 static void e1000e_write_to_rx_buffers(E1000ECore *core, - hwaddr (*ba)[MAX_PS_BUFFERS], + hwaddr ba[MAX_PS_BUFFERS], e1000e_ba_state *bastate, const char *data, dma_addr_t data_len) @@ -1447,13 +1447,13 @@ e1000e_write_to_rx_buffers(E1000ECore *core, uint32_t bytes_to_write =3D MIN(data_len, cur_buf_bytes_left); =20 trace_e1000e_rx_desc_buff_write(bastate->cur_idx, - (*ba)[bastate->cur_idx], + ba[bastate->cur_idx], bastate->written[bastate->cur_idx], data, bytes_to_write); =20 pci_dma_write(core->owner, - (*ba)[bastate->cur_idx] + bastate->written[bastate->cur_idx], + ba[bastate->cur_idx] + bastate->written[bastate->cur_idx], data, bytes_to_write); =20 bastate->written[bastate->cur_idx] +=3D bytes_to_write; @@ -1577,7 +1577,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, =20 trace_e1000e_rx_descr(rxi->idx, base, core->rx_desc_len); =20 - e1000e_read_rx_descr(core, &desc, &ba); + e1000e_read_rx_descr(core, &desc, ba); =20 if (ba[0]) { if (desc_offset < size) { @@ -1596,7 +1596,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, iov_copy =3D MIN(ps_hdr_len - ps_hdr_copied, iov->iov_len - iov_ofs); =20 - e1000e_write_hdr_to_rx_buffers(core, &ba, &bas= tate, + e1000e_write_hdr_to_rx_buffers(core, ba, &bast= ate, iov->iov_base, iov_c= opy); =20 copy_size -=3D iov_copy; @@ -1613,7 +1613,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, } else { /* Leave buffer 0 of each descriptor except first = */ /* empty as per spec 7.1.5.1 = */ - e1000e_write_hdr_to_rx_buffers(core, &ba, &bastate, + e1000e_write_hdr_to_rx_buffers(core, ba, &bastate, NULL, 0); } } @@ -1622,7 +1622,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, while (copy_size) { iov_copy =3D MIN(copy_size, iov->iov_len - iov_ofs); =20 - e1000e_write_to_rx_buffers(core, &ba, &bastate, + e1000e_write_to_rx_buffers(core, ba, &bastate, iov->iov_base + iov_ofs, iov_c= opy); =20 copy_size -=3D iov_copy; @@ -1635,7 +1635,7 @@ e1000e_write_packet_to_guest(E1000ECore *core, struct= NetRxPkt *pkt, =20 if (desc_offset + desc_size >=3D total_size) { /* Simulate FCS checksum presence in the last descript= or */ - e1000e_write_to_rx_buffers(core, &ba, &bastate, + e1000e_write_to_rx_buffers(core, ba, &bastate, (const char *) &fcs_pad, e1000x_fcs_len(core->ma= c)); } } --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147976; cv=none; d=zohomail.com; s=zohoarc; b=gr6DvZolXpgoXgHOas8X+XWqMP/H1IRn2loec9MFh0qqn3ePBLT/DzsWSnWttNCNjJtz75DoahX1o2Oo28KpHVDraUtLhh/IsWHgRkZ+/q4lYKoX8LDHXyZBs4qFEG8QRVlF6EMc1xgPBEFJSAmXFKtqQIsX2g+9sarr45APguM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147976; 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=+Nn5/1EiHd6y1mp4HbDaep3H+mrHe6y4dTXgxMZXiFo=; b=TkKMu4JcTMjCRU7dQqfre3KlGXCkYuB4vYHl7pH+a7U0V1gz6rPaNxUkorguy3agBxt8GKFCpWzTvZ3LasBR9mlzIysQq5vbQPgOPexSnwj9PXK/iF7CwyzVbnQt8zmzhjHeX8rrBDYt83DbqbbqzpvwXbJwUzcpfdiZ6gi5yDI= 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+importer2=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 1677147976229737.6705866975902; Thu, 23 Feb 2023 02:26:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8ja-0006qy-AD; Thu, 23 Feb 2023 05:21:54 -0500 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 1pV8jX-0006it-4v for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:51 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jV-0002hK-5M for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:50 -0500 Received: by mail-pj1-x1031.google.com with SMTP id l1so1974055pjt.2 for ; Thu, 23 Feb 2023 02:21:48 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=+Nn5/1EiHd6y1mp4HbDaep3H+mrHe6y4dTXgxMZXiFo=; b=HMLGfGFp9dr31MPXxdDNSVAFxtguGx3Tg0ni1IiVDtLFMX62AaN5C2MUyl353vQ9Rm +NPxRyJT1Ko6oSLIxGQMSC2PZLc8lyQVmL3vGU+e38XnJ2QRtrOa/iWqRD6CgFhK9hQ+ rGe13CJ0shKanKfAL3WRFiMEWyGlfCpC08bgSllQ0IVXm/9usu1Jek/h5YrXDPFmZmpm +ajHPjIs55esdOKtIjl3bFTKg8cuNmn1+cojMCZmjwXMr1tBnca6MDtcXClek1VO8/9B WN+YItcR9huAMGdfa8Gw0ItC8fOeDKBhhOnKgsepT0uVji54Tzc+aedVjTqyzOZqHvtc jXlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=+Nn5/1EiHd6y1mp4HbDaep3H+mrHe6y4dTXgxMZXiFo=; b=PyRcZIayfgmVJXKLIrAF15+f3SvQDMz30DN79FnnGhZwTSTNPZ8x7OUY5G4OUldcNc 8rYbHMVMDCh1N0IrV9cyeNI5mD6PlfY24UEJR350Ygn4r41AZeIik+KBKLjbv6Xk2to5 cvydF/k7CksJ3IyWMPMz+jwgbu7AJDXsHsNX1rfUC0vtU4RWzn2wb+Jjc8HtPRT+BU3S NUdMAGlJlGE8EtPBKOcPVoTdwIHX24fLSl0UyHTUb2bqyH8mfR+AWKORmS/7usnGhPzI JwqdTUpxIeg2wh4G3gp3mlB03JuUju640kBW2lpRfhemdEDmQXPLJZYna/E/7hG/MZGd ztxA== X-Gm-Message-State: AO0yUKUgIOXzsv8P1CgFWDf2kNwnDRFBIg+e+qieHErmBlEAXryH/jwU YU7Vl3k9NnvWINBxIeQmHjJZEw== X-Google-Smtp-Source: AK7set8W8Ji9FZ3nIs3g71AwxkXv7UVzuBjpBxliwoCmY+tz3PzV9PDbpmfa/k8efThonNGbs7w4FQ== X-Received: by 2002:a17:90b:17cd:b0:234:bd18:61e1 with SMTP id me13-20020a17090b17cd00b00234bd1861e1mr11171653pjb.6.1677147707857; Thu, 23 Feb 2023 02:21:47 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 19/34] net: Check L4 header size Date: Thu, 23 Feb 2023 19:20:03 +0900 Message-Id: <20230223102018.141748-20-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1031; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1031.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147977505100005 Content-Type: text/plain; charset="utf-8" net_tx_pkt_build_vheader() inspects TCP header but had no check for the header size, resulting in an undefined behavior. Check the header size and drop the packet if the header is too small. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 19 ++++++++++++++----- hw/net/net_tx_pkt.c | 13 ++++++++++--- hw/net/net_tx_pkt.h | 3 ++- hw/net/vmxnet3.c | 14 +++++++------- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index d143f2ae6f..38d374fba3 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -629,23 +629,30 @@ e1000e_rss_parse_packet(E1000ECore *core, info->queue =3D E1000_RSS_QUEUE(&core->mac[RETA], info->hash); } =20 -static void +static bool e1000e_setup_tx_offloads(E1000ECore *core, struct e1000e_tx *tx) { if (tx->props.tse && tx->cptse) { - net_tx_pkt_build_vheader(tx->tx_pkt, true, true, tx->props.mss); + if (!net_tx_pkt_build_vheader(tx->tx_pkt, true, true, tx->props.ms= s)) { + return false; + } + net_tx_pkt_update_ip_checksums(tx->tx_pkt); e1000x_inc_reg_if_not_full(core->mac, TSCTC); - return; + return true; } =20 if (tx->sum_needed & E1000_TXD_POPTS_TXSM) { - net_tx_pkt_build_vheader(tx->tx_pkt, false, true, 0); + if (!net_tx_pkt_build_vheader(tx->tx_pkt, false, true, 0)) { + return false; + } } =20 if (tx->sum_needed & E1000_TXD_POPTS_IXSM) { net_tx_pkt_update_ip_hdr_checksum(tx->tx_pkt); } + + return true; } =20 static bool @@ -654,7 +661,9 @@ e1000e_tx_pkt_send(E1000ECore *core, struct e1000e_tx *= tx, int queue_index) int target_queue =3D MIN(core->max_queue_num, queue_index); NetClientState *queue =3D qemu_get_subqueue(core->owner_nic, target_qu= eue); =20 - e1000e_setup_tx_offloads(core, tx); + if (!e1000e_setup_tx_offloads(core, tx)) { + return false; + } =20 net_tx_pkt_dump(tx->tx_pkt); =20 diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 2533ea2700..8a23899a4d 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -304,10 +304,11 @@ func_exit: return rc; } =20 -void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable, +bool net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable, bool csum_enable, uint32_t gso_size) { struct tcp_hdr l4hdr; + size_t bytes_read; assert(pkt); =20 /* csum has to be enabled if tso is. */ @@ -328,8 +329,12 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bo= ol tso_enable, =20 case VIRTIO_NET_HDR_GSO_TCPV4: case VIRTIO_NET_HDR_GSO_TCPV6: - iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags, - 0, &l4hdr, sizeof(l4hdr)); + bytes_read =3D iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], + pkt->payload_frags, 0, &l4hdr, sizeof(l4hd= r)); + if (bytes_read < sizeof(l4hdr)) { + return false; + } + pkt->virt_hdr.hdr_len =3D pkt->hdr_len + l4hdr.th_off * sizeof(uin= t32_t); pkt->virt_hdr.gso_size =3D gso_size; break; @@ -354,6 +359,8 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, boo= l tso_enable, break; } } + + return true; } =20 void net_tx_pkt_setup_vlan_header_ex(struct NetTxPkt *pkt, diff --git a/hw/net/net_tx_pkt.h b/hw/net/net_tx_pkt.h index 4ec8bbe9bd..2e38a5fa69 100644 --- a/hw/net/net_tx_pkt.h +++ b/hw/net/net_tx_pkt.h @@ -59,9 +59,10 @@ struct virtio_net_hdr *net_tx_pkt_get_vhdr(struct NetTxP= kt *pkt); * @tso_enable: TSO enabled * @csum_enable: CSO enabled * @gso_size: MSS size for TSO + * @ret: operation result * */ -void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable, +bool net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable, bool csum_enable, uint32_t gso_size); =20 /** diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 56559cda24..d7d492ac5a 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -440,19 +440,19 @@ vmxnet3_setup_tx_offloads(VMXNET3State *s) { switch (s->offload_mode) { case VMXNET3_OM_NONE: - net_tx_pkt_build_vheader(s->tx_pkt, false, false, 0); - break; + return net_tx_pkt_build_vheader(s->tx_pkt, false, false, 0); =20 case VMXNET3_OM_CSUM: - net_tx_pkt_build_vheader(s->tx_pkt, false, true, 0); VMW_PKPRN("L4 CSO requested\n"); - break; + return net_tx_pkt_build_vheader(s->tx_pkt, false, true, 0); =20 case VMXNET3_OM_TSO: - net_tx_pkt_build_vheader(s->tx_pkt, true, true, - s->cso_or_gso_size); - net_tx_pkt_update_ip_checksums(s->tx_pkt); VMW_PKPRN("GSO offload requested."); + if (!net_tx_pkt_build_vheader(s->tx_pkt, true, true, + s->cso_or_gso_size)) { + return false; + } + net_tx_pkt_update_ip_checksums(s->tx_pkt); break; =20 default: --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147827; cv=none; d=zohomail.com; s=zohoarc; b=icyR1BWlkf+97VxYAQuwhSg5EnQltg9gLqxpebuO8hp0N+fnGm7NLoSEiEasR1OvNSwxAIQJDlG155qE1SlK9G7vdloJCLuWQOZh/c7lKCpeVWe+BiRTm+dqRDvJf7gSj04sFX7suMtqp88Psya6SuqtpJa/SrcrHYE4v5wi1Dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147827; 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=eJS1Pbqh9Ag1EwpA1FCoisIP0ormv59FdxySXT2YRbY=; b=Ex5G8FAg9ZkOKqkv386vpveYYuODbGo1U8Ls012lSuVcvijmbO1qxchMuLjo4lY/KcoZeTC12+eIDkbWA7zfT9X8TdJRsvtQetFGvib42R3dHx+UM7nHcEn+hjgu5HbDqnB4jKzT0413ExGOZZlQGLfNuwADrkOJq9LIWQrqJiQ= 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+importer2=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 167714782743994.6442596752953; Thu, 23 Feb 2023 02:23:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jc-00075n-TG; Thu, 23 Feb 2023 05:21:56 -0500 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 1pV8jZ-0006ol-Lr for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:53 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jX-0002Kx-P1 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:53 -0500 Received: by mail-pl1-x630.google.com with SMTP id i3so1778449plg.6 for ; Thu, 23 Feb 2023 02:21:51 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=eJS1Pbqh9Ag1EwpA1FCoisIP0ormv59FdxySXT2YRbY=; b=WKGXgFFD4zqfDiCiaatGnovzRym45Dxs0Ces3N6nxHoLWFX0PDuqVPR54h/zg7uHd4 kUQ53Z2DNVIwh3DAmN5mGQDQhUEpAi2me1CtuZZoW5YWimfX+RA58MSjDJyckyyeoT0U 1SXYjB07ki0YSIWL9OFMPPZ63oFk/OPmfLvVEUd+p970/piD4nYFZSRVbgvZ01jow6XH UH3l8xYyaRnP8145txhdIItH79MrMr4YV8EGz/pOLyvXplOrEQ+TvKma49R7VEl4ezca IOTYgGxqy01YgfV/Fn1LLxvm8jWe7pjMZzesVh8dmvSRhZYF3UM9fKACUjkMVcTF+yxe P9fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eJS1Pbqh9Ag1EwpA1FCoisIP0ormv59FdxySXT2YRbY=; b=pojzGBhcqO0HFY4JeRJ5bKWcQoM3pBH5PmVpNAWYnh3iogb7FnS8Kq4yLVe+pcLZSZ Gc9q4YUrZRh1M40r3P8HFwd74z4hxnVCqq5REse4qEDrhYf5SpV0LeUtuK0+15tr25pI 6BCK+ts6sZvG59pYrLjXhYpA5G1Ppa1fgoeurNUqvC/ayHkUwAH32kRZWtghr2GikKa0 juLKnoQ9R42EnZ+wn7Mi4PAzk3CoIjwqZR+YEtP8x/BXnri6290+PU1V0iFg2caaPZx1 pEIQgyiiy6Q1hzFZwZdEJ/12xid/9fgtgvT4IRd6azeXDowqHlpAf0L9LIRs7IiWLMxF d/6A== X-Gm-Message-State: AO0yUKVe+IpdahUNUCa9h1AJzxaA3Uy/wV8dM/3fdpXe/xSm+zemknaV ShEa/NxwGuxlnkGWuTidKkgbgg== X-Google-Smtp-Source: AK7set907c6NSb7P/o75icaDL4Zu0GNrT7y5kcFaE1bDGTE1S+2n3OGAbpOTsM9tPfDf2R/341mCSw== X-Received: by 2002:a17:903:1ca:b0:199:41a5:1085 with SMTP id e10-20020a17090301ca00b0019941a51085mr15863247plh.33.1677147711139; Thu, 23 Feb 2023 02:21:51 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 20/34] e1000x: Alter the signature of e1000x_is_vlan_packet Date: Thu, 23 Feb 2023 19:20:04 +0900 Message-Id: <20230223102018.141748-21-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::630; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x630.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147828488100003 Content-Type: text/plain; charset="utf-8" e1000x_is_vlan_packet() had a pointer to uint8_t as a parameter, but it does not have to be uint8_t. Change the type to void *. Signed-off-by: Akihiko Odaki --- hw/net/e1000x_common.c | 2 +- hw/net/e1000x_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c index b3bbf31582..e6387dde53 100644 --- a/hw/net/e1000x_common.c +++ b/hw/net/e1000x_common.c @@ -47,7 +47,7 @@ bool e1000x_rx_ready(PCIDevice *d, uint32_t *mac) return true; } =20 -bool e1000x_is_vlan_packet(const uint8_t *buf, uint16_t vet) +bool e1000x_is_vlan_packet(const void *buf, uint16_t vet) { uint16_t eth_proto =3D lduw_be_p(&PKT_GET_ETH_HDR(buf)->h_proto); bool res =3D (eth_proto =3D=3D vet); diff --git a/hw/net/e1000x_common.h b/hw/net/e1000x_common.h index b991d814b1..86a31b69f8 100644 --- a/hw/net/e1000x_common.h +++ b/hw/net/e1000x_common.h @@ -178,7 +178,7 @@ uint32_t e1000x_rxbufsize(uint32_t rctl); =20 bool e1000x_rx_ready(PCIDevice *d, uint32_t *mac); =20 -bool e1000x_is_vlan_packet(const uint8_t *buf, uint16_t vet); +bool e1000x_is_vlan_packet(const void *buf, uint16_t vet); =20 bool e1000x_rx_group_filter(uint32_t *mac, const uint8_t *buf); =20 --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147749; cv=none; d=zohomail.com; s=zohoarc; b=QfFoXuD3T9bK0SqpuWeUDUlWKB68XHESzH7nK/fbfapmoRg6A2nez9rx30A7hxwKilI+MET3gO8QlMl8Ge8jD0gNjN7vLP5HNfsIdJHy9S/VLoryDxVitHOemAMDenGHVqhFJK9WLm8Ygh3Vqf4vl1bEo2G8SaBf7H6/RpgXnCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147749; 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=GKqlj4cTruDk9qJjJPjaaBr7Jpcg7evHMxD9jDdbWOE=; b=X0mYLeUS5XFqNMqgIlfZ74w4Y5ErdK60GxR6pHGLC1oIPolhoSsubD0I+E+dCw8Z0osgODPyNBHVWpC5WF/gfMdLkyoixvm1El6tH6/w+dvWeOjUwaAI/aDsWklwwrOwvn/fYLt/fla9kCie2tfiuhIrxUDJOOJPI87YIpjS19k= 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+importer2=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 1677147749822972.8063551026212; Thu, 23 Feb 2023 02:22:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8jf-0007EY-TE; Thu, 23 Feb 2023 05:21:59 -0500 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 1pV8jd-00077o-6z for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:57 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jb-0002Ud-72 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:21:56 -0500 Received: by mail-pj1-x1035.google.com with SMTP id y2so8050656pjg.3 for ; Thu, 23 Feb 2023 02:21:54 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=GKqlj4cTruDk9qJjJPjaaBr7Jpcg7evHMxD9jDdbWOE=; b=znYOe646fGsI/HXaWBki58EKDNeVNBMe9zfBOjRrPjvfgNOV9xh1qZnAIGh5qeQvX1 LRmmuTXi7vnlg/LGcBXGKrSYNXXVylmE0CnYZxRqdo9e6kEDx1ZXXQwaJ1DB1YfMpiW/ FDwrFp2L8BuU1Jk9MAYFtirQXQbiOi228pqdcHt6Wbz3UkIogPKlRgcJFPHht/e2LXdm 2wicQU02j6s/YPkSmXbF+SVvwcEEzgYrYniK5bEKeh0BHjDssBNL4Fi6xnVHe4S/U86G hvDhftDiBnLeZyOKd6D/5a7iNTAL7coAReXDNzTF6AppHlTBJLYR7MB388Bm85P1Snx5 lbAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=GKqlj4cTruDk9qJjJPjaaBr7Jpcg7evHMxD9jDdbWOE=; b=4fGPJRR7RNLV9mRIoz++8N5ek/hVLAVRN9NDlBeNb0LMoF7nM1/TpMvfOpB2PuHN2A rjM1bOK/lMgNGp2r/4kDvSy/Dlvp7xCIRbz1ndNHi1BHbgFzsFniwDARaL6pMPaNZJrh 1fo6GJtDF+kzMIJgmcC+c5DkuQcHwlXqMBod+tajEmA3Cbm7FnZMOpOVB6a0FjsPJYWT Eely2I0OrlU0BrSUpEZOoHSDxeLt3pH1r09TQH4pwWbuwEmkMDZAYRelcPLd5PSm0iQn nLz5E0gnLuAJxjylMfzvYw8Vv6UZD0v/OD2E0wYY4NNzj0TFkdRUZC4TXZV2B5FvRMMO YlBg== X-Gm-Message-State: AO0yUKVh+7Yt7aIu1KYXBSFoyZAGxMCUptkg2jcQ/cjRK185saTXre1x B9ZoXE8kmuZViSbS7dF7pTnn6w== X-Google-Smtp-Source: AK7set+lsFLiytdVYQCL83RfCCg31gq5yeYlpnHl/23RIMSOaN/TUpVU5VFQ2keg9C2gRgkjqiRlrw== X-Received: by 2002:a17:902:8b85:b0:19a:b74a:7f7e with SMTP id ay5-20020a1709028b8500b0019ab74a7f7emr10285214plb.28.1677147714495; Thu, 23 Feb 2023 02:21:54 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 21/34] net: Strip virtio-net header when dumping Date: Thu, 23 Feb 2023 19:20:05 +0900 Message-Id: <20230223102018.141748-22-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1035; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1035.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147752045100003 Content-Type: text/plain; charset="utf-8" filter-dump specifiees Ethernet as PCAP LinkType, which does not expect virtio-net header. Having virtio-net header in such PCAP file breaks PCAP unconsumable. Unfortunately currently there is no LinkType for virtio-net so for now strip virtio-net header to convert the output to Ethernet. Signed-off-by: Akihiko Odaki --- include/net/net.h | 6 ++++++ net/dump.c | 11 +++++++---- net/net.c | 18 ++++++++++++++++++ net/tap.c | 16 ++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 1d88621c12..1448d00afb 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -56,8 +56,10 @@ typedef RxFilterInfo *(QueryRxFilter)(NetClientState *); typedef bool (HasUfo)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); +typedef bool (GetUsingVnetHdr)(NetClientState *); typedef void (UsingVnetHdr)(NetClientState *, bool); typedef void (SetOffload)(NetClientState *, int, int, int, int, int); +typedef int (GetVnetHdrLen)(NetClientState *); typedef void (SetVnetHdrLen)(NetClientState *, int); typedef int (SetVnetLE)(NetClientState *, bool); typedef int (SetVnetBE)(NetClientState *, bool); @@ -84,8 +86,10 @@ typedef struct NetClientInfo { HasUfo *has_ufo; HasVnetHdr *has_vnet_hdr; HasVnetHdrLen *has_vnet_hdr_len; + GetUsingVnetHdr *get_using_vnet_hdr; UsingVnetHdr *using_vnet_hdr; SetOffload *set_offload; + GetVnetHdrLen *get_vnet_hdr_len; SetVnetHdrLen *set_vnet_hdr_len; SetVnetLE *set_vnet_le; SetVnetBE *set_vnet_be; @@ -185,9 +189,11 @@ void qemu_format_nic_info_str(NetClientState *nc, uint= 8_t macaddr[6]); bool qemu_has_ufo(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); +bool qemu_get_using_vnet_hdr(NetClientState *nc); void qemu_using_vnet_hdr(NetClientState *nc, bool enable); void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, int ecn, int ufo); +int qemu_get_vnet_hdr_len(NetClientState *nc); void qemu_set_vnet_hdr_len(NetClientState *nc, int len); int qemu_set_vnet_le(NetClientState *nc, bool is_le); int qemu_set_vnet_be(NetClientState *nc, bool is_be); diff --git a/net/dump.c b/net/dump.c index 6a63b15359..7d05f16ca7 100644 --- a/net/dump.c +++ b/net/dump.c @@ -61,12 +61,13 @@ struct pcap_sf_pkthdr { uint32_t len; }; =20 -static ssize_t dump_receive_iov(DumpState *s, const struct iovec *iov, int= cnt) +static ssize_t dump_receive_iov(DumpState *s, const struct iovec *iov, int= cnt, + int offset) { struct pcap_sf_pkthdr hdr; int64_t ts; int caplen; - size_t size =3D iov_size(iov, cnt); + size_t size =3D iov_size(iov, cnt) - offset; struct iovec dumpiov[cnt + 1]; =20 /* Early return in case of previous error. */ @@ -84,7 +85,7 @@ static ssize_t dump_receive_iov(DumpState *s, const struc= t iovec *iov, int cnt) =20 dumpiov[0].iov_base =3D &hdr; dumpiov[0].iov_len =3D sizeof(hdr); - cnt =3D iov_copy(&dumpiov[1], cnt, iov, cnt, 0, caplen); + cnt =3D iov_copy(&dumpiov[1], cnt, iov, cnt, offset, caplen); =20 if (writev(s->fd, dumpiov, cnt + 1) !=3D sizeof(hdr) + caplen) { error_report("network dump write error - stopping dump"); @@ -153,8 +154,10 @@ static ssize_t filter_dump_receive_iov(NetFilterState = *nf, NetClientState *sndr, int iovcnt, NetPacketSent *sent_cb) { NetFilterDumpState *nfds =3D FILTER_DUMP(nf); + int offset =3D qemu_get_using_vnet_hdr(nf->netdev) ? + qemu_get_vnet_hdr_len(nf->netdev) : 0; =20 - dump_receive_iov(&nfds->ds, iov, iovcnt); + dump_receive_iov(&nfds->ds, iov, iovcnt, offset); return 0; } =20 diff --git a/net/net.c b/net/net.c index ebc7ce0231..6492ad530e 100644 --- a/net/net.c +++ b/net/net.c @@ -513,6 +513,15 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int len) return nc->info->has_vnet_hdr_len(nc, len); } =20 +bool qemu_get_using_vnet_hdr(NetClientState *nc) +{ + if (!nc || !nc->info->get_using_vnet_hdr) { + return false; + } + + return nc->info->get_using_vnet_hdr(nc); +} + void qemu_using_vnet_hdr(NetClientState *nc, bool enable) { if (!nc || !nc->info->using_vnet_hdr) { @@ -532,6 +541,15 @@ void qemu_set_offload(NetClientState *nc, int csum, in= t tso4, int tso6, nc->info->set_offload(nc, csum, tso4, tso6, ecn, ufo); } =20 +int qemu_get_vnet_hdr_len(NetClientState *nc) +{ + if (!nc || !nc->info->get_vnet_hdr_len) { + return 0; + } + + return nc->info->get_vnet_hdr_len(nc); +} + void qemu_set_vnet_hdr_len(NetClientState *nc, int len) { if (!nc || !nc->info->set_vnet_hdr_len) { diff --git a/net/tap.c b/net/tap.c index 7d7bc1dc5f..1bf085d422 100644 --- a/net/tap.c +++ b/net/tap.c @@ -255,6 +255,13 @@ static bool tap_has_vnet_hdr_len(NetClientState *nc, i= nt len) return !!tap_probe_vnet_hdr_len(s->fd, len); } =20 +static int tap_get_vnet_hdr_len(NetClientState *nc) +{ + TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + + return s->host_vnet_hdr_len; +} + static void tap_set_vnet_hdr_len(NetClientState *nc, int len) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); @@ -268,6 +275,13 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, i= nt len) s->host_vnet_hdr_len =3D len; } =20 +static bool tap_get_using_vnet_hdr(NetClientState *nc) +{ + TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + + return s->using_vnet_hdr; +} + static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); @@ -372,8 +386,10 @@ static NetClientInfo net_tap_info =3D { .has_ufo =3D tap_has_ufo, .has_vnet_hdr =3D tap_has_vnet_hdr, .has_vnet_hdr_len =3D tap_has_vnet_hdr_len, + .get_using_vnet_hdr =3D tap_get_using_vnet_hdr, .using_vnet_hdr =3D tap_using_vnet_hdr, .set_offload =3D tap_set_offload, + .get_vnet_hdr_len =3D tap_get_vnet_hdr_len, .set_vnet_hdr_len =3D tap_set_vnet_hdr_len, .set_vnet_le =3D tap_set_vnet_le, .set_vnet_be =3D tap_set_vnet_be, --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147961; cv=none; d=zohomail.com; s=zohoarc; b=PuZFvBsY+HOzE4YVL1hIIHgt4Vjm1S6tm3hC7IM9IjoXlFFjBQPnDCzH1/xDTwOLL9JK+I1wM3hGNRkHsyn95UL4rfh7ZZ+ETnpCt1ux4T71GfLE1H5hWIr9ARYg+wviZ7ssPAzVtPqUbK0U9UmP+ZlYKMRN6hfo0N4QzmQBA7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147961; 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=3UnhBlJ7YOgsoT/Z//gez5GN4UW4QVUF00a2DHaaF80=; b=Daa31ebIS3iZJwbifbYjZnwjSExzp3uaga3h0SawEvVCAoxlYjYw71Q0sa223dYudwSV+EW4r/I3uCFx7Gx8dHa1PVGIxsBAPMUZKQ0G1SGdXAnPOPyHmuRN+YVhYJXzBqJhkzAk0c8uiYv1Avj7F9J3aC6qebBsDAZ9N8IJjoE= 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+importer2=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 1677147961396512.8322085309301; Thu, 23 Feb 2023 02:26:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k0-0007Qg-Du; Thu, 23 Feb 2023 05:22:20 -0500 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 1pV8jg-0007F5-Gk for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:00 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8je-0002jJ-U1 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:00 -0500 Received: by mail-pj1-x1029.google.com with SMTP id x20-20020a17090a8a9400b00233ba727724so3614273pjn.1 for ; Thu, 23 Feb 2023 02:21:58 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:21:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=3UnhBlJ7YOgsoT/Z//gez5GN4UW4QVUF00a2DHaaF80=; b=F1SHQLeLp+ozLM9LoBFmvNS1mGt4Dd/rEARBxj1yysv0P6odpCNC+rPbeSgCvMzMcR j4g4WXIZkHNcuFcy2UpZRe28YhVu4pqrttnMiUtoKnVwqXR5MKKnsX9IWz4PAcDwYNym 6iDVY7G19/WMVfgqGdTnxQLZMZqy5DhqatO6BiMZJlyvz1m6N7HgFTvM4xVxmTaSFVRS zhq1h4aaJGwLZJJfoTC9ghJacWY7sMoIYXKFEpWUEpFVHTCvXXkulPCq5qCH2Cb2mUhl Tq9zWkS/Bp3zB/tAQKyC7hf+rArhQvXjvv9A37zZaC4Aq0E4gLYE7fRw9dsI01sbkP+u WqZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3UnhBlJ7YOgsoT/Z//gez5GN4UW4QVUF00a2DHaaF80=; b=BzVQb1pNnT+C+C586lfffkdPGwwDjklaR9zbmPx3LwbmKjZgHpDYRL8sUFySNEOVS/ Ln6d6vTqSq2nIcaOupQvmgWEdBHQ2X96eMldNI3TDQPi8DMmGL3US7pdCV7yHMshiC9f M8JdALdJVY2tweMe6+i/GxgWvqoKS4xhui4syk3wABPaADc1L/S8kuUTCEvN7z48vGTT CcUD4Naf1Dl4w7OXtNQwO8KApSTH/nWxlTLf4AWPKSQFTQFR+/c5cUAw0u/pbBzUNUtX vJIIjzukT8iyOmneI/PFkWUYeTEEaTK3kkGozPjWC5FrHR3iDvzUItQQoagrINzY7Wfe 37IQ== X-Gm-Message-State: AO0yUKUwajFwv/feJBAofjQcDCUsDC6StC10tU9XDgMTcwyLSqcC144B s/CFg+J0dDxlhcDpjj0wXYwtZ/1eJuiT0Ues X-Google-Smtp-Source: AK7set9wjSaD2FT4esh0TXW76WhvPbitz/1OhXh/JJ7Ufj2SwrFQNbgLL9CBdaU9ckVw0NE/b4ahmg== X-Received: by 2002:a17:902:f98f:b0:196:790a:8bae with SMTP id ky15-20020a170902f98f00b00196790a8baemr9709955plb.43.1677147717649; Thu, 23 Feb 2023 02:21:57 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 22/34] hw/net/net_tx_pkt: Automatically determine if virtio-net header is used Date: Thu, 23 Feb 2023 19:20:06 +0900 Message-Id: <20230223102018.141748-23-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1029; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1029.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147963401100003 Content-Type: text/plain; charset="utf-8" The new function qemu_get_using_vnet_hdr() allows to automatically determine if virtio-net header is used. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 3 +-- hw/net/net_tx_pkt.c | 19 ++++++++++--------- hw/net/net_tx_pkt.h | 3 +-- hw/net/vmxnet3.c | 6 ++---- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 38d374fba3..954a007151 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -3376,8 +3376,7 @@ e1000e_core_pci_realize(E1000ECore *core, qemu_add_vm_change_state_handler(e1000e_vm_state_change, core); =20 for (i =3D 0; i < E1000E_NUM_QUEUES; i++) { - net_tx_pkt_init(&core->tx[i].tx_pkt, core->owner, - E1000E_MAX_TX_FRAGS, core->has_vnet); + net_tx_pkt_init(&core->tx[i].tx_pkt, core->owner, E1000E_MAX_TX_FR= AGS); } =20 net_rx_pkt_init(&core->rx_pkt, core->has_vnet); diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 8a23899a4d..cf46c8457f 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -35,7 +35,6 @@ struct NetTxPkt { PCIDevice *pci_dev; =20 struct virtio_net_hdr virt_hdr; - bool has_virt_hdr; =20 struct iovec *raw; uint32_t raw_frags; @@ -59,7 +58,7 @@ struct NetTxPkt { }; =20 void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, - uint32_t max_frags, bool has_virt_hdr) + uint32_t max_frags) { struct NetTxPkt *p =3D g_malloc0(sizeof *p); =20 @@ -71,10 +70,8 @@ void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *p= ci_dev, =20 p->max_payload_frags =3D max_frags; p->max_raw_frags =3D max_frags; - p->has_virt_hdr =3D has_virt_hdr; p->vec[NET_TX_PKT_VHDR_FRAG].iov_base =3D &p->virt_hdr; - p->vec[NET_TX_PKT_VHDR_FRAG].iov_len =3D - p->has_virt_hdr ? sizeof p->virt_hdr : 0; + p->vec[NET_TX_PKT_VHDR_FRAG].iov_len =3D sizeof p->virt_hdr; p->vec[NET_TX_PKT_L2HDR_FRAG].iov_base =3D &p->l2_hdr; p->vec[NET_TX_PKT_L3HDR_FRAG].iov_base =3D &p->l3_hdr; =20 @@ -617,9 +614,11 @@ static bool net_tx_pkt_do_sw_fragmentation(struct NetT= xPkt *pkt, =20 bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientState *nc) { + bool using_vnet_hdr =3D qemu_get_using_vnet_hdr(nc->peer); + assert(pkt); =20 - if (!pkt->has_virt_hdr && + if (!using_vnet_hdr && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { net_tx_pkt_do_sw_csum(pkt); } @@ -636,11 +635,13 @@ bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientS= tate *nc) } } =20 - if (pkt->has_virt_hdr || + if (using_vnet_hdr || pkt->virt_hdr.gso_type =3D=3D VIRTIO_NET_HDR_GSO_NONE) { + int index =3D using_vnet_hdr ? + NET_TX_PKT_VHDR_FRAG : NET_TX_PKT_L2HDR_FRAG; net_tx_pkt_fix_ip6_payload_len(pkt); - net_tx_pkt_sendv(pkt, nc, pkt->vec, - pkt->payload_frags + NET_TX_PKT_PL_START_FRAG); + net_tx_pkt_sendv(pkt, nc, pkt->vec + index, + pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - index); return true; } =20 diff --git a/hw/net/net_tx_pkt.h b/hw/net/net_tx_pkt.h index 2e38a5fa69..8d3faa42fb 100644 --- a/hw/net/net_tx_pkt.h +++ b/hw/net/net_tx_pkt.h @@ -32,10 +32,9 @@ struct NetTxPkt; * @pkt: packet pointer * @pci_dev: PCI device processing this packet * @max_frags: max tx ip fragments - * @has_virt_hdr: device uses virtio header. */ void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, - uint32_t max_frags, bool has_virt_hdr); + uint32_t max_frags); =20 /** * Clean all tx packet resources. diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index d7d492ac5a..eab8fa4d0b 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1521,8 +1521,7 @@ static void vmxnet3_activate_device(VMXNET3State *s) =20 /* Preallocate TX packet wrapper */ VMW_CFPRN("Max TX fragments is %u", s->max_tx_frags); - net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s), - s->max_tx_frags, s->peer_has_vhdr); + net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s), s->max_tx_frags); net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr); =20 /* Read rings memory locations for RX queues */ @@ -2402,8 +2401,7 @@ static int vmxnet3_post_load(void *opaque, int versio= n_id) { VMXNET3State *s =3D opaque; =20 - net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s), - s->max_tx_frags, s->peer_has_vhdr); + net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s), s->max_tx_frags); net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr); =20 if (s->msix_used) { --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147975; cv=none; d=zohomail.com; s=zohoarc; b=Hjc/uwB3MFmUFeQukBHtg1Zl6T4wzYsfHX2DDLYLT3mtggfcDiYbJknPxZ42E6X1U3Vdfvg4N9iq2MG5Gr9FvOkn648YFAJaCI5HASjjDlEhmQnkTe2R7fXeFUgmujhsJAM+tceX9Q8zVTKLqaVUceKA1JV2HlD0uRcnQjxN3Vc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147975; 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=OCOzJ5B4Ai3joFX+VOMVNyOV5edsr/6Pvwl3joO9snE=; b=jasd7Ddf2ZegbYjx93IQkDI92pHH9/VC7ZGPK9ASvAVEviL4u/bdG+ulkRByTqlyKqh6MOxsvlvi+2vVlIjjVplmqtXq17g/ddS2Kg/RdQ1kpPuxviBjb7J0LEfYwQtXHQ+b/IGfToNvKrNZcUth2r0T1lUhlKeRyYjbMNl93WA= 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+importer2=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 1677147975449779.7242360797422; Thu, 23 Feb 2023 02:26:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k0-0007Pn-8H; Thu, 23 Feb 2023 05:22:20 -0500 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 1pV8jl-0007Ib-6U for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:06 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8ji-0002k1-4l for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:04 -0500 Received: by mail-pl1-x62d.google.com with SMTP id ky4so13412765plb.3 for ; Thu, 23 Feb 2023 02:22:01 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=OCOzJ5B4Ai3joFX+VOMVNyOV5edsr/6Pvwl3joO9snE=; b=vZhNRyB3uv4QIiXI+ihf15uE7IgLo6juv3XWrGH2yPPH5qvrSHgMi8yzUvs+UMYVnd LMaVSlE41eV0UNmFDATl1g3F9M66O/gNpSZeD5K6dTA57JB1jw01rwvpi3X9oZ5xoREm Srw1O6UrEebo5xdKkaK2BSPTZu7zI9PMDjjNcz/IiOS0TQkI7Txr6n3sl/mzmeJLYRox A9n5UwkBVQhUT4CV92kymDJytMlpy4QTV2iGhpnqEtKf28xz48YIkuctnZE4lrDBYKt9 XUG5w4S+7PnLIdRSM3lYtxepraQbe9VAtIiA+5lmHShuZjVmy9ezq+1QoV1Y1qpCvDNY rwZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=OCOzJ5B4Ai3joFX+VOMVNyOV5edsr/6Pvwl3joO9snE=; b=dGoHOngFzUSFPXCUPC6hnLn/CpRtYBKVyy8x4RvaRnayO/xkBhusFM/ryd+VaSkPzg tCkeRnsVD5FiV/rVqlTU9I9A7W8S6/1zgiPNHOLxCJc3cjGmJo6vHNfQ40E/yxOBZeNT 7TwkmuS9bOe7h4D0inkujTv5wGF9wA+Q3ILViuugCMJKIlwV3AB2xJgXg10xavpHkviL N4fDxGNA04XlKCo5mmAgq8INMhcz3gQFmH8HxgP+1/pEIJ1l049CevIxhcvUIyk3CBdc lxNYnxEJbGTNxVoXC1fM2mOFX44CzCKTyJQtRC80JSntgzl0eTQMkkZCPcuCOEBFt/py YUmQ== X-Gm-Message-State: AO0yUKVkpSRcV8ICJ2/n82JvwiwFi+p3Wrf2Z+LIBcNH7A0S2GgywlsE zd1+MhBPEN+bjkHr6YOQ83Eraw== X-Google-Smtp-Source: AK7set+0K0KEVXbALDLHzw+vUvVhQYB918hOVJQCWYe4KFsNXIHLsR7Tyn5OaioIxpCtKdxDPT1NTg== X-Received: by 2002:a17:903:28c4:b0:19b:5e:327f with SMTP id kv4-20020a17090328c400b0019b005e327fmr9519328plb.33.1677147720968; Thu, 23 Feb 2023 02:22:00 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 23/34] hw/net/net_rx_pkt: Remove net_rx_pkt_has_virt_hdr Date: Thu, 23 Feb 2023 19:20:07 +0900 Message-Id: <20230223102018.141748-24-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147977448100003 Content-Type: text/plain; charset="utf-8" When virtio-net header is not set, net_rx_pkt_get_vhdr() returns zero-filled virtio_net_hdr, which is actually valid. In fact, tap device uses zero-filled virtio_net_hdr when virtio-net header is not provided by the peer. Therefore, we can just remove net_rx_pkt_has_virt_hdr() and always assume NetTxPkt has a valid virtio-net header. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 16 ++++------------ hw/net/net_rx_pkt.c | 11 +---------- hw/net/net_rx_pkt.h | 12 +----------- hw/net/trace-events | 1 - hw/net/virtio-net.c | 2 +- hw/net/vmxnet3.c | 12 ++---------- 6 files changed, 9 insertions(+), 45 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 954a007151..95245c42f5 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1240,12 +1240,6 @@ e1000e_build_rx_metadata(E1000ECore *core, goto func_exit; } =20 - if (!net_rx_pkt_has_virt_hdr(pkt)) { - trace_e1000e_rx_metadata_no_virthdr(); - e1000e_verify_csum_in_sw(core, pkt, status_flags, istcp, isudp); - goto func_exit; - } - vhdr =3D net_rx_pkt_get_vhdr(pkt); =20 if (!(vhdr->flags & VIRTIO_NET_HDR_F_DATA_VALID) && @@ -1671,12 +1665,10 @@ e1000e_write_packet_to_guest(E1000ECore *core, stru= ct NetRxPkt *pkt, static inline void e1000e_rx_fix_l4_csum(E1000ECore *core, struct NetRxPkt *pkt) { - if (net_rx_pkt_has_virt_hdr(pkt)) { - struct virtio_net_hdr *vhdr =3D net_rx_pkt_get_vhdr(pkt); + struct virtio_net_hdr *vhdr =3D net_rx_pkt_get_vhdr(pkt); =20 - if (vhdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { - net_rx_pkt_fix_l4_csum(pkt); - } + if (vhdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { + net_rx_pkt_fix_l4_csum(pkt); } } =20 @@ -3379,7 +3371,7 @@ e1000e_core_pci_realize(E1000ECore *core, net_tx_pkt_init(&core->tx[i].tx_pkt, core->owner, E1000E_MAX_TX_FR= AGS); } =20 - net_rx_pkt_init(&core->rx_pkt, core->has_vnet); + net_rx_pkt_init(&core->rx_pkt); =20 e1000x_core_prepare_eeprom(core->eeprom, eeprom_templ, diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c index 1e1c504e42..b309c2f476 100644 --- a/hw/net/net_rx_pkt.c +++ b/hw/net/net_rx_pkt.c @@ -30,7 +30,6 @@ struct NetRxPkt { uint32_t tot_len; uint16_t tci; size_t ehdr_buf_len; - bool has_virt_hdr; eth_pkt_types_e packet_type; =20 /* Analysis results */ @@ -48,10 +47,9 @@ struct NetRxPkt { eth_l4_hdr_info l4hdr_info; }; =20 -void net_rx_pkt_init(struct NetRxPkt **pkt, bool has_virt_hdr) +void net_rx_pkt_init(struct NetRxPkt **pkt) { struct NetRxPkt *p =3D g_malloc0(sizeof *p); - p->has_virt_hdr =3D has_virt_hdr; p->vec =3D NULL; p->vec_len_total =3D 0; *pkt =3D p; @@ -472,13 +470,6 @@ bool net_rx_pkt_is_vlan_stripped(struct NetRxPkt *pkt) return pkt->ehdr_buf_len ? true : false; } =20 -bool net_rx_pkt_has_virt_hdr(struct NetRxPkt *pkt) -{ - assert(pkt); - - return pkt->has_virt_hdr; -} - uint16_t net_rx_pkt_get_vlan_tag(struct NetRxPkt *pkt) { assert(pkt); diff --git a/hw/net/net_rx_pkt.h b/hw/net/net_rx_pkt.h index 048e3461f0..7277907a22 100644 --- a/hw/net/net_rx_pkt.h +++ b/hw/net/net_rx_pkt.h @@ -37,10 +37,9 @@ void net_rx_pkt_uninit(struct NetRxPkt *pkt); * Init function for rx packet functionality * * @pkt: packet pointer - * @has_virt_hdr: device uses virtio header * */ -void net_rx_pkt_init(struct NetRxPkt **pkt, bool has_virt_hdr); +void net_rx_pkt_init(struct NetRxPkt **pkt); =20 /** * returns total length of data attached to rx context @@ -214,15 +213,6 @@ uint16_t net_rx_pkt_get_vlan_tag(struct NetRxPkt *pkt); */ bool net_rx_pkt_is_vlan_stripped(struct NetRxPkt *pkt); =20 -/** - * notifies caller if the packet has virtio header - * - * @pkt: packet - * @ret: true if packet has virtio header, false otherwize - * - */ -bool net_rx_pkt_has_virt_hdr(struct NetRxPkt *pkt); - /** * attach scatter-gather data to rx packet * diff --git a/hw/net/trace-events b/hw/net/trace-events index c98ad12537..f7257a0693 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -188,7 +188,6 @@ e1000e_rx_metadata_rss(uint32_t rss, uint32_t mrq) "RSS= data: rss: 0x%X, mrq: 0x e1000e_rx_metadata_ip_id(uint16_t ip_id) "the IPv4 ID is 0x%X" e1000e_rx_metadata_ack(void) "the packet is TCP ACK" e1000e_rx_metadata_pkt_type(uint32_t pkt_type) "the packet type is %u" -e1000e_rx_metadata_no_virthdr(void) "the packet has no virt-header" e1000e_rx_metadata_virthdr_no_csum_info(void) "virt-header does not contai= n checksum info" e1000e_rx_metadata_l3_cso_disabled(void) "IP4 CSO is disabled" e1000e_rx_metadata_l4_cso_disabled(void) "TCP/UDP CSO is disabled" diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3ae909041a..1795e1aa7d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3703,7 +3703,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) QTAILQ_INIT(&n->rsc_chains); n->qdev =3D dev; =20 - net_rx_pkt_init(&n->rx_pkt, false); + net_rx_pkt_init(&n->rx_pkt); =20 if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { virtio_net_load_ebpf(n); diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index eab8fa4d0b..6c6bb2ac37 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -851,10 +851,6 @@ static void vmxnet3_rx_need_csum_calculate(struct NetR= xPkt *pkt, uint8_t *data; int len; =20 - if (!net_rx_pkt_has_virt_hdr(pkt)) { - return; - } - vhdr =3D net_rx_pkt_get_vhdr(pkt); if (!VMXNET_FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) { return; @@ -898,10 +894,6 @@ static void vmxnet3_rx_update_descr(struct NetRxPkt *p= kt, rxcd->tci =3D net_rx_pkt_get_vlan_tag(pkt); } =20 - if (!net_rx_pkt_has_virt_hdr(pkt)) { - goto nocsum; - } - vhdr =3D net_rx_pkt_get_vhdr(pkt); /* * Checksum is valid when lower level tell so or when lower level @@ -1522,7 +1514,7 @@ static void vmxnet3_activate_device(VMXNET3State *s) /* Preallocate TX packet wrapper */ VMW_CFPRN("Max TX fragments is %u", s->max_tx_frags); net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s), s->max_tx_frags); - net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr); + net_rx_pkt_init(&s->rx_pkt); =20 /* Read rings memory locations for RX queues */ for (i =3D 0; i < s->rxq_num; i++) { @@ -2402,7 +2394,7 @@ static int vmxnet3_post_load(void *opaque, int versio= n_id) VMXNET3State *s =3D opaque; =20 net_tx_pkt_init(&s->tx_pkt, PCI_DEVICE(s), s->max_tx_frags); - net_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr); + net_rx_pkt_init(&s->rx_pkt); =20 if (s->msix_used) { vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS); --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147793; cv=none; d=zohomail.com; s=zohoarc; b=WJtdGhTxpUj05Ex1UQVgDfVXz9/hZKH1jtbaWNDer03uXXxHzKrJr2RtqegXXg6iu/XJTzMw7Efr5kIGg/Lk0EsOa7TmcA10MowB9nu78uQoEX60yYFQ4X2y+uv/tXO6Kt+LUYaC/kQTrRaT0Tw2mqE8SGsvSciOsrscVvNRH4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147793; 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=oLrWHd65frzqttg6MaHuf9ZrkRsJYxBcXGezoOzJp74=; b=LmK1PMtLP+IrAkH5lU0PicZM001jQrfePQh06EgOH50agI7a9kcwwPhCbi2sw2KU0s/SYDURAE/O6zDEZQkamv2aPbTJ4oBTtDwvyZKaN1c7zJf3CLA+XAJsgpEVhsG9Hw7voM6qWDE8/SN/UiHUAi0ap+qH9beHwgMBogwPYuI= 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+importer2=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 1677147793046608.7574260284874; Thu, 23 Feb 2023 02:23:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k4-0007mU-Bk; Thu, 23 Feb 2023 05:22:24 -0500 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 1pV8jo-0007LN-Ik for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:10 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jm-0002kN-Gg for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:08 -0500 Received: by mail-pl1-x62e.google.com with SMTP id z2so12367408plf.12 for ; Thu, 23 Feb 2023 02:22:05 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=oLrWHd65frzqttg6MaHuf9ZrkRsJYxBcXGezoOzJp74=; b=Lb5YjYspXP9iKqm21KoPXy/twMmfWEsLgLTPw2yUKjDjrtAf3RduhH2nIyGvEn1EIt 6LQ/cR1IUxGep0tQmgluFW2q4O4vv1kdmA1QLYjQ37Jb2fWDSf55rcNLiMOD1eYLXZdw q0Z7oP+2BHlanebWUbz4aosuYPYUnwGetBVtGzB2I9jk0JseHZYJnCHCVFWqWPML8cb+ 4KdxZT/ddFtbfIpkXURBycOjR30/RR0iqrmhxLppFl4t2I+1xqdery6hcePofOKkKwVr 9pKT3BeayISCUyg/aywoPGSTpO3hZy3Iy0pQAJrnvvqmE12sOGLg9r4qUg8Q6jD3yu58 igwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=oLrWHd65frzqttg6MaHuf9ZrkRsJYxBcXGezoOzJp74=; b=b6zNNuxPRBLZ12OE7HdTAVpS8J8YL0Cn65jRE2LXw7EZSu/p/nlSkv9eCu+4s4Aw0A muA70fvigJ3M8WAiukCL1/KeeK8kShZlpH4JDLucIL1jPmKVM6Fwc8QGlIbCI1vb0k2f 1Y2sZ760UkyZNEKsyelLEzwtEFa7tR4i359x/NHVfvSWatmOsM+vR9XqqUaEgtBnw/YQ ueTBCNKxN9Jx6OmYgoN2aln+ApjF72YkHOu1EdHt6CTLd66p9fXaCrkC0Z0ofH61ksIx qeA3r3+BP4DKeuHU0/K9N6zkTrQDYa/y4OHRSOs+F/LqPLTnhmrJUXpfTYEYrk1xOaLf nloQ== X-Gm-Message-State: AO0yUKXVzRZ42AjtiQFPm5qstuifKIVV/2IHHWZwYbnFfJE0ryBgLeug L4jauZha24gCCTtQCSxQIi+CuA== X-Google-Smtp-Source: AK7set9vorw+BaxVepUi7sBtCvuddZrllhQQObVjcdvx7Zhw7Oog4CtC1YqZwNHPjktmSCVZnJkyQg== X-Received: by 2002:a17:902:f54a:b0:19a:a647:1891 with SMTP id h10-20020a170902f54a00b0019aa6471891mr16123469plf.67.1677147724210; Thu, 23 Feb 2023 02:22:04 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 24/34] e1000e: Perform software segmentation for loopback Date: Thu, 23 Feb 2023 19:20:08 +0900 Message-Id: <20230223102018.141748-25-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62e.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147794451100003 Content-Type: text/plain; charset="utf-8" e1000e didn't perform software segmentation for loopback if virtio-net header is enabled, which is wrong. To fix the problem, introduce net_tx_pkt_send_custom(), which allows the caller to specify whether offloading should be assumed or not. net_tx_pkt_send_custom() also allows the caller to provide a custom sending function. Packets with virtio-net headers and ones without virtio-net headers will be provided at the same time so the function can choose the preferred version. In case of e1000e loopback, it prefers to have virtio-net headers as they allows to skip the checksum verification if VIRTIO_NET_HDR_F_DATA_VALID is set. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 27 ++++++++++++++-- hw/net/net_rx_pkt.c | 7 ++++ hw/net/net_rx_pkt.h | 8 +++++ hw/net/net_tx_pkt.c | 76 +++++++++++++++++++++----------------------- hw/net/net_tx_pkt.h | 21 ++++++------ 5 files changed, 88 insertions(+), 51 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 95245c42f5..ff93547f88 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -61,6 +61,10 @@ union e1000_rx_desc_union { union e1000_rx_desc_packet_split packet_split; }; =20 +static ssize_t +e1000e_receive_internal(E1000ECore *core, const struct iovec *iov, int iov= cnt, + bool has_vnet); + static inline void e1000e_set_interrupt_cause(E1000ECore *core, uint32_t val); =20 @@ -655,6 +659,15 @@ e1000e_setup_tx_offloads(E1000ECore *core, struct e100= 0e_tx *tx) return true; } =20 +static void e1000e_tx_pkt_callback(void *core, + const struct iovec *iov, + int iovcnt, + const struct iovec *virt_iov, + int virt_iovcnt) +{ + e1000e_receive_internal(core, virt_iov, virt_iovcnt, true); +} + static bool e1000e_tx_pkt_send(E1000ECore *core, struct e1000e_tx *tx, int queue_index) { @@ -669,7 +682,8 @@ e1000e_tx_pkt_send(E1000ECore *core, struct e1000e_tx *= tx, int queue_index) =20 if ((core->phy[0][MII_BMCR] & MII_BMCR_LOOPBACK) || ((core->mac[RCTL] & E1000_RCTL_LBM_MAC) =3D=3D E1000_RCTL_LBM_MAC)= ) { - return net_tx_pkt_send_loopback(tx->tx_pkt, queue); + return net_tx_pkt_send_custom(tx->tx_pkt, false, + e1000e_tx_pkt_callback, core); } else { return net_tx_pkt_send(tx->tx_pkt, queue); } @@ -1674,6 +1688,13 @@ e1000e_rx_fix_l4_csum(E1000ECore *core, struct NetRx= Pkt *pkt) =20 ssize_t e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt) +{ + return e1000e_receive_internal(core, iov, iovcnt, core->has_vnet); +} + +static ssize_t +e1000e_receive_internal(E1000ECore *core, const struct iovec *iov, int iov= cnt, + bool has_vnet) { static const int maximum_ethernet_hdr_len =3D (ETH_HLEN + 4); =20 @@ -1696,9 +1717,11 @@ e1000e_receive_iov(E1000ECore *core, const struct io= vec *iov, int iovcnt) } =20 /* Pull virtio header in */ - if (core->has_vnet) { + if (has_vnet) { net_rx_pkt_set_vhdr_iovec(core->rx_pkt, iov, iovcnt); iov_ofs =3D sizeof(struct virtio_net_hdr); + } else { + net_rx_pkt_unset_vhdr(core->rx_pkt); } =20 filter_buf =3D iov->iov_base + iov_ofs; diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c index b309c2f476..a53e7561c5 100644 --- a/hw/net/net_rx_pkt.c +++ b/hw/net/net_rx_pkt.c @@ -463,6 +463,13 @@ void net_rx_pkt_set_vhdr_iovec(struct NetRxPkt *pkt, iov_to_buf(iov, iovcnt, 0, &pkt->virt_hdr, sizeof pkt->virt_hdr); } =20 +void net_rx_pkt_unset_vhdr(struct NetRxPkt *pkt) +{ + assert(pkt); + + memset(&pkt->virt_hdr, 0, sizeof(pkt->virt_hdr)); +} + bool net_rx_pkt_is_vlan_stripped(struct NetRxPkt *pkt) { assert(pkt); diff --git a/hw/net/net_rx_pkt.h b/hw/net/net_rx_pkt.h index 7277907a22..8b69ddb2da 100644 --- a/hw/net/net_rx_pkt.h +++ b/hw/net/net_rx_pkt.h @@ -312,6 +312,14 @@ void net_rx_pkt_set_vhdr(struct NetRxPkt *pkt, void net_rx_pkt_set_vhdr_iovec(struct NetRxPkt *pkt, const struct iovec *iov, int iovcnt); =20 +/** + * unset vhdr data from packet context + * + * @pkt: packet + * + */ +void net_rx_pkt_unset_vhdr(struct NetRxPkt *pkt); + /** * save packet type in packet context * diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index cf46c8457f..6afd3f6693 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -53,8 +53,6 @@ struct NetTxPkt { uint16_t hdr_len; eth_pkt_types_e packet_type; uint8_t l4proto; - - bool is_loopback; }; =20 void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, @@ -508,12 +506,6 @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt) iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum); } =20 -enum { - NET_TX_PKT_FRAGMENT_L2_HDR_POS =3D 0, - NET_TX_PKT_FRAGMENT_L3_HDR_POS, - NET_TX_PKT_FRAGMENT_HEADER_NUM -}; - #define NET_MAX_FRAG_SG_LIST (64) =20 static size_t net_tx_pkt_fetch_fragment(struct NetTxPkt *pkt, @@ -522,7 +514,7 @@ static size_t net_tx_pkt_fetch_fragment(struct NetTxPkt= *pkt, size_t fetched =3D 0; struct iovec *src =3D pkt->vec; =20 - *dst_idx =3D NET_TX_PKT_FRAGMENT_HEADER_NUM; + *dst_idx =3D NET_TX_PKT_PL_START_FRAG; =20 while (fetched < IP_FRAG_ALIGN_SIZE(pkt->virt_hdr.gso_size)) { =20 @@ -555,18 +547,22 @@ static size_t net_tx_pkt_fetch_fragment(struct NetTxP= kt *pkt, return fetched; } =20 -static inline void net_tx_pkt_sendv(struct NetTxPkt *pkt, - NetClientState *nc, const struct iovec *iov, int iov_cnt) +static void net_tx_pkt_sendv( + void *opaque, const struct iovec *iov, int iov_cnt, + const struct iovec *virt_iov, int virt_iov_cnt) { - if (pkt->is_loopback) { - qemu_receive_packet_iov(nc, iov, iov_cnt); + NetClientState *nc =3D opaque; + + if (qemu_get_using_vnet_hdr(nc->peer)) { + qemu_sendv_packet(nc, virt_iov, virt_iov_cnt); } else { qemu_sendv_packet(nc, iov, iov_cnt); } } =20 static bool net_tx_pkt_do_sw_fragmentation(struct NetTxPkt *pkt, - NetClientState *nc) + NetTxPktCallback callback, + void *context) { struct iovec fragment[NET_MAX_FRAG_SG_LIST]; size_t fragment_len =3D 0; @@ -578,6 +574,10 @@ static bool net_tx_pkt_do_sw_fragmentation(struct NetT= xPkt *pkt, int src_idx =3D NET_TX_PKT_PL_START_FRAG, dst_idx; size_t src_offset =3D 0; size_t fragment_offset =3D 0; + struct virtio_net_hdr virt_hdr =3D { + .flags =3D pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM ? + VIRTIO_NET_HDR_F_DATA_VALID : 0 + }; =20 l2_iov_base =3D pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_base; l2_iov_len =3D pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len; @@ -585,10 +585,12 @@ static bool net_tx_pkt_do_sw_fragmentation(struct Net= TxPkt *pkt, l3_iov_len =3D pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len; =20 /* Copy headers */ - fragment[NET_TX_PKT_FRAGMENT_L2_HDR_POS].iov_base =3D l2_iov_base; - fragment[NET_TX_PKT_FRAGMENT_L2_HDR_POS].iov_len =3D l2_iov_len; - fragment[NET_TX_PKT_FRAGMENT_L3_HDR_POS].iov_base =3D l3_iov_base; - fragment[NET_TX_PKT_FRAGMENT_L3_HDR_POS].iov_len =3D l3_iov_len; + fragment[NET_TX_PKT_VHDR_FRAG].iov_base =3D &virt_hdr; + fragment[NET_TX_PKT_VHDR_FRAG].iov_len =3D sizeof(virt_hdr); + fragment[NET_TX_PKT_L2HDR_FRAG].iov_base =3D l2_iov_base; + fragment[NET_TX_PKT_L2HDR_FRAG].iov_len =3D l2_iov_len; + fragment[NET_TX_PKT_L3HDR_FRAG].iov_base =3D l3_iov_base; + fragment[NET_TX_PKT_L3HDR_FRAG].iov_len =3D l3_iov_len; =20 =20 /* Put as much data as possible and send */ @@ -603,7 +605,9 @@ static bool net_tx_pkt_do_sw_fragmentation(struct NetTx= Pkt *pkt, =20 eth_fix_ip4_checksum(l3_iov_base, l3_iov_len); =20 - net_tx_pkt_sendv(pkt, nc, fragment, dst_idx); + callback(context, + fragment + NET_TX_PKT_L2HDR_FRAG, dst_idx - NET_TX_PKT_L2= HDR_FRAG, + fragment + NET_TX_PKT_VHDR_FRAG, dst_idx - NET_TX_PKT_VHD= R_FRAG); =20 fragment_offset +=3D fragment_len; =20 @@ -614,12 +618,16 @@ static bool net_tx_pkt_do_sw_fragmentation(struct Net= TxPkt *pkt, =20 bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientState *nc) { - bool using_vnet_hdr =3D qemu_get_using_vnet_hdr(nc->peer); + bool offload =3D qemu_get_using_vnet_hdr(nc->peer); + return net_tx_pkt_send_custom(pkt, offload, net_tx_pkt_sendv, nc); +} =20 +bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, bool offload, + NetTxPktCallback callback, void *context) +{ assert(pkt); =20 - if (!using_vnet_hdr && - pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { + if (!offload && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { net_tx_pkt_do_sw_csum(pkt); } =20 @@ -635,28 +643,16 @@ bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientS= tate *nc) } } =20 - if (using_vnet_hdr || - pkt->virt_hdr.gso_type =3D=3D VIRTIO_NET_HDR_GSO_NONE) { - int index =3D using_vnet_hdr ? - NET_TX_PKT_VHDR_FRAG : NET_TX_PKT_L2HDR_FRAG; + if (offload || pkt->virt_hdr.gso_type =3D=3D VIRTIO_NET_HDR_GSO_NONE) { net_tx_pkt_fix_ip6_payload_len(pkt); - net_tx_pkt_sendv(pkt, nc, pkt->vec + index, - pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - index); + callback(context, pkt->vec + NET_TX_PKT_L2HDR_FRAG, + pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - NET_TX_PK= T_L2HDR_FRAG, + pkt->vec + NET_TX_PKT_VHDR_FRAG, + pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - NET_TX_PK= T_VHDR_FRAG); return true; } =20 - return net_tx_pkt_do_sw_fragmentation(pkt, nc); -} - -bool net_tx_pkt_send_loopback(struct NetTxPkt *pkt, NetClientState *nc) -{ - bool res; - - pkt->is_loopback =3D true; - res =3D net_tx_pkt_send(pkt, nc); - pkt->is_loopback =3D false; - - return res; + return net_tx_pkt_do_sw_fragmentation(pkt, callback, context); } =20 void net_tx_pkt_fix_ip6_payload_len(struct NetTxPkt *pkt) diff --git a/hw/net/net_tx_pkt.h b/hw/net/net_tx_pkt.h index 8d3faa42fb..f57b4e034b 100644 --- a/hw/net/net_tx_pkt.h +++ b/hw/net/net_tx_pkt.h @@ -26,6 +26,8 @@ =20 struct NetTxPkt; =20 +typedef void (* NetTxPktCallback)(void *, const struct iovec *, int, const= struct iovec *, int); + /** * Init function for tx packet functionality * @@ -161,15 +163,16 @@ void net_tx_pkt_reset(struct NetTxPkt *pkt); bool net_tx_pkt_send(struct NetTxPkt *pkt, NetClientState *nc); =20 /** -* Redirect packet directly to receive path (emulate loopback phy). -* Handles sw offloads if vhdr is not supported. -* -* @pkt: packet -* @nc: NetClientState -* @ret: operation result -* -*/ -bool net_tx_pkt_send_loopback(struct NetTxPkt *pkt, NetClientState *nc); + * Send packet with a custom function. + * + * @pkt: packet + * @offload: whether the callback implements offloading + * @callback: a function to be called back for each transformed pack= et + * @context: a pointer to be passed to the callback. + * @ret: operation result + */ +bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, bool offload, + NetTxPktCallback callback, void *context); =20 /** * parse raw packet data and analyze offload requirements. --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147862; cv=none; d=zohomail.com; s=zohoarc; b=U2udsFiJggp3a280DwNr3N1PgIozKJ15YCo8/nl/pQLhT0tCDXsEfIB3Cbiv2QRvxrbxihglzqV8yENVjDL7tBJWePEK3C1iPoSAM2DyKI+u24udCGsn8LmEw62XvKZJVGFXv2I5aqOPopmZOS7WIMwThs16RslXbpv0QorKmKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147862; 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=jv/afEJcthyHIvIcMbqTIPEoZmHEVzJWfRny7dTpMv8=; b=JeHaaTL9UrCt+RB8nS2LQ85xOETcuWZ4+D1+P1Ln/zUAQJRNj95hPg52Tw4RV02ggnymEqixaZf7tibntDTlZ3nB+wTV9fXQN87oFl9BVpbemBXsR4041nHXFpJv0sexC9cu5KXhzeHy1Iqj5bgraJZvUdUfl6fLXmAGLDwDGmc= 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+importer2=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 167714786217653.766634641359815; Thu, 23 Feb 2023 02:24:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k1-0007aa-9J; Thu, 23 Feb 2023 05:22:21 -0500 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 1pV8jq-0007LX-IR for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:11 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jo-0002Vw-A0 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:10 -0500 Received: by mail-pj1-x1031.google.com with SMTP id nw10-20020a17090b254a00b00233d7314c1cso12327793pjb.5 for ; Thu, 23 Feb 2023 02:22:07 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=jv/afEJcthyHIvIcMbqTIPEoZmHEVzJWfRny7dTpMv8=; b=NudaUypXc0OPHY1wmcmEg7zUdLV1lzyLtV5oZ3fZ45Gf4+VbMmo1xq1V1apKPOQCNN 6X66jptVR9IyD0u3gMzHitop9bsy3kZesXCk1cCPLqksUMvAYi0nvTNaPSGgPPyWoa3c qnlS+qazKO8DX7KISxkvYOnNMYvMl0DWyLnmMoLJurJVn4+XJyHChG9sy21Qypt7+UWM nx/5I6oGzI4YM/IzRRqYx32a19Z+BNlc2IpvZNXWERm20iYwMiHYpuJoO2dTtUhMmwMz 1AEFWCWMBPNpiiKeYULm4s9HO0oBQVyrvOvn/tf7+Q5c/tnrR0qA3P0wF92oR/+hB0Ap 8+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=jv/afEJcthyHIvIcMbqTIPEoZmHEVzJWfRny7dTpMv8=; b=ID2Ik1zN5lmKX/4NAhh435BGnF4+CaqpwCekVY6lAHmge868483lxbWP+UgsJandr4 ysQmIq2actcQqToW8+3aN9X63nEDwV2wlvGs75qOjJM7PLf+YWOLfEP3NDtzo8mKijUW 7tVhxLVDy2iy9/giGeU03NIVV/sRzUhVekKzIf4YRujZS8tH6H6NywSN17C/oKLU5wz9 0cFiP1zdFf8aOYp5yWhZCkSIRrMEOo/n6ai4KVfsM/cbClsvOSc9eGCoF54zsN3N10e+ B17Tcz6D0Oa3exH7LeBxUO/MZrLQV+z8yx43IzmLlPhfXNikLqkXHwXZkWtFDk9ht6im HcPw== X-Gm-Message-State: AO0yUKWGoxJcPLOPf8GGCHuJZ2p2p4F4tnf5mCyhE3toplwTXBysDgqQ U9ozXLQai1BlL0RLyoViUOPaUQ== X-Google-Smtp-Source: AK7set+dpn8toQCR0qAVCTtDC4usUY578BmRPp4lFKFhfx6YMQ5dOkb5jax8Cv1UngK8NbnpSrKJXA== X-Received: by 2002:a17:902:ecc4:b0:19a:9945:a7aa with SMTP id a4-20020a170902ecc400b0019a9945a7aamr16600553plh.20.1677147727614; Thu, 23 Feb 2023 02:22:07 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 25/34] hw/net/net_tx_pkt: Implement TCP segmentation Date: Thu, 23 Feb 2023 19:20:09 +0900 Message-Id: <20230223102018.141748-26-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1031; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1031.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147862941100011 Content-Type: text/plain; charset="utf-8" There was no proper implementation of TCP segmentation before this change, and net_tx_pkt relied solely on IPv4 fragmentation. Not only this is not aligned with the specification, but it also resulted in corrupted IPv6 packets. This is particularly problematic for the igb, a new proposed device implementation; igb provides loopback feature for VMDq and the feature relies on software segmentation. Implement proper TCP segmentation in net_tx_pkt to fix such a scenario. Signed-off-by: Akihiko Odaki --- hw/net/net_tx_pkt.c | 248 ++++++++++++++++++++++++++++++++++++-------- include/net/eth.h | 5 - net/eth.c | 27 ----- 3 files changed, 206 insertions(+), 74 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 6afd3f6693..4a35e8429d 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -326,7 +326,8 @@ bool net_tx_pkt_build_vheader(struct NetTxPkt *pkt, boo= l tso_enable, case VIRTIO_NET_HDR_GSO_TCPV6: bytes_read =3D iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags, 0, &l4hdr, sizeof(l4hd= r)); - if (bytes_read < sizeof(l4hdr)) { + if (bytes_read < sizeof(l4hdr) || + l4hdr.th_off * sizeof(uint32_t) < sizeof(l4hdr)) { return false; } =20 @@ -466,15 +467,14 @@ void net_tx_pkt_reset(struct NetTxPkt *pkt) pkt->l4proto =3D 0; } =20 -static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt) +static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt, + struct iovec *iov, uint32_t iov_len, + uint16_t csl) { - struct iovec *iov =3D &pkt->vec[NET_TX_PKT_L2HDR_FRAG]; uint32_t csum_cntr; uint16_t csum =3D 0; uint32_t cso; /* num of iovec without vhdr */ - uint32_t iov_len =3D pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1; - uint16_t csl; size_t csum_offset =3D pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_o= ffset; uint16_t l3_proto =3D eth_get_l3_proto(iov, 1, iov->iov_len); =20 @@ -482,8 +482,6 @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt) iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum); =20 /* Calculate L4 TCP/UDP checksum */ - csl =3D pkt->payload_len; - csum_cntr =3D 0; cso =3D 0; /* add pseudo header to csum */ @@ -509,14 +507,13 @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pk= t) #define NET_MAX_FRAG_SG_LIST (64) =20 static size_t net_tx_pkt_fetch_fragment(struct NetTxPkt *pkt, - int *src_idx, size_t *src_offset, struct iovec *dst, int *dst_idx) + int *src_idx, size_t *src_offset, size_t src_len, + struct iovec *dst, int *dst_idx) { size_t fetched =3D 0; struct iovec *src =3D pkt->vec; =20 - *dst_idx =3D NET_TX_PKT_PL_START_FRAG; - - while (fetched < IP_FRAG_ALIGN_SIZE(pkt->virt_hdr.gso_size)) { + while (fetched < src_len) { =20 /* no more place in fragment iov */ if (*dst_idx =3D=3D NET_MAX_FRAG_SG_LIST) { @@ -531,7 +528,7 @@ static size_t net_tx_pkt_fetch_fragment(struct NetTxPkt= *pkt, =20 dst[*dst_idx].iov_base =3D src[*src_idx].iov_base + *src_offset; dst[*dst_idx].iov_len =3D MIN(src[*src_idx].iov_len - *src_offset, - IP_FRAG_ALIGN_SIZE(pkt->virt_hdr.gso_size) - fetched); + src_len - fetched); =20 *src_offset +=3D dst[*dst_idx].iov_len; fetched +=3D dst[*dst_idx].iov_len; @@ -560,58 +557,223 @@ static void net_tx_pkt_sendv( } } =20 +static bool net_tx_pkt_tcp_fragment_init(struct NetTxPkt *pkt, + struct iovec *fragment, + int *pl_idx, + size_t *l4hdr_len, + int *src_idx, + size_t *src_offset, + size_t *src_len) +{ + struct iovec *l4 =3D fragment + NET_TX_PKT_PL_START_FRAG; + size_t bytes_read =3D 0; + struct tcp_hdr *th; + + if (!pkt->payload_frags) { + return false; + } + + l4->iov_len =3D pkt->virt_hdr.hdr_len - pkt->hdr_len; + l4->iov_base =3D g_malloc(l4->iov_len); + + *src_idx =3D NET_TX_PKT_PL_START_FRAG; + while (pkt->vec[*src_idx].iov_len < l4->iov_len - bytes_read) { + memcpy((char *)l4->iov_base + bytes_read, pkt->vec[*src_idx].iov_b= ase, + pkt->vec[*src_idx].iov_len); + + bytes_read +=3D pkt->vec[*src_idx].iov_len; + + (*src_idx)++; + if (*src_idx >=3D pkt->payload_frags + NET_TX_PKT_PL_START_FRAG) { + g_free(l4->iov_base); + return false; + } + } + + *src_offset =3D l4->iov_len - bytes_read; + memcpy((char *)l4->iov_base + bytes_read, pkt->vec[*src_idx].iov_base, + *src_offset); + + th =3D l4->iov_base; + th->th_flags &=3D ~(TH_FIN | TH_PUSH); + + *pl_idx =3D NET_TX_PKT_PL_START_FRAG + 1; + *l4hdr_len =3D l4->iov_len; + *src_len =3D pkt->virt_hdr.gso_size; + + return true; +} + +static void net_tx_pkt_tcp_fragment_deinit(struct iovec *fragment) +{ + g_free(fragment[NET_TX_PKT_PL_START_FRAG].iov_base); +} + +static void net_tx_pkt_tcp_fragment_fix(struct NetTxPkt *pkt, + struct iovec *fragment, + size_t fragment_len, + uint8_t gso_type) +{ + struct iovec *l3hdr =3D fragment + NET_TX_PKT_L3HDR_FRAG; + struct iovec *l4hdr =3D fragment + NET_TX_PKT_PL_START_FRAG; + struct ip_header *ip =3D l3hdr->iov_base; + struct ip6_header *ip6 =3D l3hdr->iov_base; + size_t len =3D l3hdr->iov_len + l4hdr->iov_len + fragment_len; + + switch (gso_type) { + case VIRTIO_NET_HDR_GSO_TCPV4: + ip->ip_len =3D cpu_to_be16(len); + eth_fix_ip4_checksum(l3hdr->iov_base, l3hdr->iov_len); + break; + + case VIRTIO_NET_HDR_GSO_TCPV6: + len -=3D sizeof(struct ip6_header); + ip6->ip6_ctlun.ip6_un1.ip6_un1_plen =3D cpu_to_be16(len); + break; + } +} + +static void net_tx_pkt_tcp_fragment_advance(struct NetTxPkt *pkt, + struct iovec *fragment, + size_t fragment_len, + uint8_t gso_type) +{ + struct iovec *l3hdr =3D fragment + NET_TX_PKT_L3HDR_FRAG; + struct iovec *l4hdr =3D fragment + NET_TX_PKT_PL_START_FRAG; + struct ip_header *ip =3D l3hdr->iov_base; + struct tcp_hdr *th =3D l4hdr->iov_base; + + if (gso_type =3D=3D VIRTIO_NET_HDR_GSO_TCPV4) { + ip->ip_id =3D cpu_to_be16(be16_to_cpu(ip->ip_id) + 1); + } + + th->th_seq =3D cpu_to_be32(be32_to_cpu(th->th_seq) + fragment_len); + th->th_flags &=3D ~TH_CWR; +} + +static void net_tx_pkt_udp_fragment_init(struct NetTxPkt *pkt, + int *pl_idx, + size_t *l4hdr_len, + int *src_idx, size_t *src_offset, + size_t *src_len) +{ + *pl_idx =3D NET_TX_PKT_PL_START_FRAG; + *l4hdr_len =3D 0; + *src_idx =3D NET_TX_PKT_PL_START_FRAG; + *src_offset =3D 0; + *src_len =3D IP_FRAG_ALIGN_SIZE(pkt->virt_hdr.gso_size); +} + +static void net_tx_pkt_udp_fragment_fix(struct NetTxPkt *pkt, + struct iovec *fragment, + size_t fragment_offset, + size_t fragment_len) +{ + bool more_frags =3D fragment_offset + fragment_len < pkt->payload_len; + uint16_t orig_flags; + struct iovec *l3hdr =3D fragment + NET_TX_PKT_L3HDR_FRAG; + struct ip_header *ip =3D l3hdr->iov_base; + uint16_t frag_off_units =3D fragment_offset / IP_FRAG_UNIT_SIZE; + uint16_t new_ip_off; + + assert(fragment_offset % IP_FRAG_UNIT_SIZE =3D=3D 0); + assert((frag_off_units & ~IP_OFFMASK) =3D=3D 0); + + orig_flags =3D be16_to_cpu(ip->ip_off) & ~(IP_OFFMASK | IP_MF); + new_ip_off =3D frag_off_units | orig_flags | (more_frags ? IP_MF : 0); + ip->ip_off =3D cpu_to_be16(new_ip_off); + ip->ip_len =3D cpu_to_be16(l3hdr->iov_len + fragment_len); + + eth_fix_ip4_checksum(l3hdr->iov_base, l3hdr->iov_len); +} + static bool net_tx_pkt_do_sw_fragmentation(struct NetTxPkt *pkt, NetTxPktCallback callback, void *context) { + uint8_t gso_type =3D pkt->virt_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN; + struct iovec fragment[NET_MAX_FRAG_SG_LIST]; - size_t fragment_len =3D 0; - bool more_frags =3D false; - - /* some pointers for shorter code */ - void *l2_iov_base, *l3_iov_base; - size_t l2_iov_len, l3_iov_len; - int src_idx =3D NET_TX_PKT_PL_START_FRAG, dst_idx; - size_t src_offset =3D 0; + size_t fragment_len; + size_t l4hdr_len; + size_t src_len; + + int src_idx, dst_idx, pl_idx; + size_t src_offset; size_t fragment_offset =3D 0; struct virtio_net_hdr virt_hdr =3D { .flags =3D pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM ? VIRTIO_NET_HDR_F_DATA_VALID : 0 }; =20 - l2_iov_base =3D pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_base; - l2_iov_len =3D pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len; - l3_iov_base =3D pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base; - l3_iov_len =3D pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len; - /* Copy headers */ fragment[NET_TX_PKT_VHDR_FRAG].iov_base =3D &virt_hdr; fragment[NET_TX_PKT_VHDR_FRAG].iov_len =3D sizeof(virt_hdr); - fragment[NET_TX_PKT_L2HDR_FRAG].iov_base =3D l2_iov_base; - fragment[NET_TX_PKT_L2HDR_FRAG].iov_len =3D l2_iov_len; - fragment[NET_TX_PKT_L3HDR_FRAG].iov_base =3D l3_iov_base; - fragment[NET_TX_PKT_L3HDR_FRAG].iov_len =3D l3_iov_len; + fragment[NET_TX_PKT_L2HDR_FRAG] =3D pkt->vec[NET_TX_PKT_L2HDR_FRAG]; + fragment[NET_TX_PKT_L3HDR_FRAG] =3D pkt->vec[NET_TX_PKT_L3HDR_FRAG]; =20 + switch (gso_type) { + case VIRTIO_NET_HDR_GSO_TCPV4: + case VIRTIO_NET_HDR_GSO_TCPV6: + if (!net_tx_pkt_tcp_fragment_init(pkt, fragment, &pl_idx, &l4hdr_l= en, + &src_idx, &src_offset, &src_len)= ) { + return false; + } + break; =20 - /* Put as much data as possible and send */ - do { - fragment_len =3D net_tx_pkt_fetch_fragment(pkt, &src_idx, &src_off= set, - fragment, &dst_idx); + case VIRTIO_NET_HDR_GSO_UDP: + net_tx_pkt_do_sw_csum(pkt, &pkt->vec[NET_TX_PKT_L2HDR_FRAG], + pkt->payload_frags + NET_TX_PKT_PL_START_FRA= G - 1, + pkt->payload_len); + net_tx_pkt_udp_fragment_init(pkt, &pl_idx, &l4hdr_len, + &src_idx, &src_offset, &src_len); + break; =20 - more_frags =3D (fragment_offset + fragment_len < pkt->payload_len); + default: + abort(); + } =20 - eth_setup_ip4_fragmentation(l2_iov_base, l2_iov_len, l3_iov_base, - l3_iov_len, fragment_len, fragment_offset, more_frags); + /* Put as much data as possible and send */ + while (true) { + dst_idx =3D pl_idx; + fragment_len =3D net_tx_pkt_fetch_fragment(pkt, + &src_idx, &src_offset, src_len, fragment, &dst_idx); + if (!fragment_len) { + break; + } =20 - eth_fix_ip4_checksum(l3_iov_base, l3_iov_len); + switch (gso_type) { + case VIRTIO_NET_HDR_GSO_TCPV4: + case VIRTIO_NET_HDR_GSO_TCPV6: + net_tx_pkt_tcp_fragment_fix(pkt, fragment, fragment_len, gso_t= ype); + net_tx_pkt_do_sw_csum(pkt, fragment + NET_TX_PKT_L2HDR_FRAG, + dst_idx - NET_TX_PKT_L2HDR_FRAG, + l4hdr_len + fragment_len); + break; + + case VIRTIO_NET_HDR_GSO_UDP: + net_tx_pkt_udp_fragment_fix(pkt, fragment, fragment_offset, + fragment_len); + break; + } =20 callback(context, fragment + NET_TX_PKT_L2HDR_FRAG, dst_idx - NET_TX_PKT_L2= HDR_FRAG, fragment + NET_TX_PKT_VHDR_FRAG, dst_idx - NET_TX_PKT_VHD= R_FRAG); =20 + if (gso_type =3D=3D VIRTIO_NET_HDR_GSO_TCPV4 || + gso_type =3D=3D VIRTIO_NET_HDR_GSO_TCPV6) { + net_tx_pkt_tcp_fragment_advance(pkt, fragment, fragment_len, + gso_type); + } + fragment_offset +=3D fragment_len; + } =20 - } while (fragment_len && more_frags); + if (gso_type =3D=3D VIRTIO_NET_HDR_GSO_TCPV4 || + gso_type =3D=3D VIRTIO_NET_HDR_GSO_TCPV6) { + net_tx_pkt_tcp_fragment_deinit(fragment); + } =20 return true; } @@ -627,10 +789,6 @@ bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, bool= offload, { assert(pkt); =20 - if (!offload && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { - net_tx_pkt_do_sw_csum(pkt); - } - /* * Since underlying infrastructure does not support IP datagrams longer * than 64K we should drop such packets and don't even try to send @@ -644,6 +802,12 @@ bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, bool= offload, } =20 if (offload || pkt->virt_hdr.gso_type =3D=3D VIRTIO_NET_HDR_GSO_NONE) { + if (!offload && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM)= { + net_tx_pkt_do_sw_csum(pkt, &pkt->vec[NET_TX_PKT_L2HDR_FRAG], + pkt->payload_frags + NET_TX_PKT_PL_START= _FRAG - 1, + pkt->payload_len); + } + net_tx_pkt_fix_ip6_payload_len(pkt); callback(context, pkt->vec + NET_TX_PKT_L2HDR_FRAG, pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - NET_TX_PK= T_L2HDR_FRAG, diff --git a/include/net/eth.h b/include/net/eth.h index 6e699b0d7a..2b4374fae4 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -400,11 +400,6 @@ void eth_get_protocols(const struct iovec *iov, int io= vcnt, eth_ip4_hdr_info *ip4hdr_info, eth_l4_hdr_info *l4hdr_info); =20 -void eth_setup_ip4_fragmentation(const void *l2hdr, size_t l2hdr_len, - void *l3hdr, size_t l3hdr_len, - size_t l3payload_len, - size_t frag_offset, bool more_frags); - void eth_fix_ip4_checksum(void *l3hdr, size_t l3hdr_len); =20 diff --git a/net/eth.c b/net/eth.c index f074b2f9f3..36d39b4357 100644 --- a/net/eth.c +++ b/net/eth.c @@ -314,33 +314,6 @@ eth_strip_vlan_ex(const struct iovec *iov, int iovcnt,= size_t iovoff, return 0; } =20 -void -eth_setup_ip4_fragmentation(const void *l2hdr, size_t l2hdr_len, - void *l3hdr, size_t l3hdr_len, - size_t l3payload_len, - size_t frag_offset, bool more_frags) -{ - const struct iovec l2vec =3D { - .iov_base =3D (void *) l2hdr, - .iov_len =3D l2hdr_len - }; - - if (eth_get_l3_proto(&l2vec, 1, l2hdr_len) =3D=3D ETH_P_IP) { - uint16_t orig_flags; - struct ip_header *iphdr =3D (struct ip_header *) l3hdr; - uint16_t frag_off_units =3D frag_offset / IP_FRAG_UNIT_SIZE; - uint16_t new_ip_off; - - assert(frag_offset % IP_FRAG_UNIT_SIZE =3D=3D 0); - assert((frag_off_units & ~IP_OFFMASK) =3D=3D 0); - - orig_flags =3D be16_to_cpu(iphdr->ip_off) & ~(IP_OFFMASK|IP_MF); - new_ip_off =3D frag_off_units | orig_flags | (more_frags ? IP_MF = : 0); - iphdr->ip_off =3D cpu_to_be16(new_ip_off); - iphdr->ip_len =3D cpu_to_be16(l3payload_len + l3hdr_len); - } -} - void eth_fix_ip4_checksum(void *l3hdr, size_t l3hdr_len) { --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147856; cv=none; d=zohomail.com; s=zohoarc; b=UX/HFE/TbNW+LMa2Azgk8pqLwGsliFzrvcmz0yJ1JACI9gCToG5FWzc9Gb8QpX26iZ3D2z2ghDgV86QKX69AoFFYLZcCvoNAvPfLKuUebKgbxxQK9xPbD6YXE8roItVrQUtzlz2YDTxpBwEPSc66McfbyKdPNaJhQ5xH/+ZXGZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147856; 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=5140iHkZNuZn3I2k8biDJLxaiQwsOPdwZlAn0pvvLx0=; b=UAysUoSDLziaIpNnnSlSGRuARvftdZiYPB4pmGVxdgvB+Kavd7Z0hTw/JU8a0/0GBDBzw1fSdxMfHjVUc9evfDrhCvJ22PHbtUAQVQsaZpKmCg7Es+FGcSa2DHyTV83kTSNUFM+Llz83eXUo7mmXqwjy7FkpjY+AjJFggsuhtak= 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+importer2=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 1677147856984106.16501837801547; Thu, 23 Feb 2023 02:24:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k1-0007dX-VT; Thu, 23 Feb 2023 05:22:21 -0500 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 1pV8jt-0007NM-Jz for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:14 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8js-0002lX-26 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:13 -0500 Received: by mail-pj1-x102d.google.com with SMTP id k21-20020a17090aaa1500b002376652e160so1126438pjq.0 for ; Thu, 23 Feb 2023 02:22:11 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=5140iHkZNuZn3I2k8biDJLxaiQwsOPdwZlAn0pvvLx0=; b=M4VJ6aN/RyPdhKyk/rFA1TpyRpZIKDwB1r20GCc2KRFcOWuKDuBbC6Y/LqGiTu1D+C HB0XSacZnuCTyPA18OHkT9LpABeXPS6ldEP6/fsTyTPcFgfU1Y/6k4lp/e8mKzUCujH5 3Mn8gaS1n6W2C2+fxtTKLguZTVYZZJQdtprpuGeHhc103St/+NeuhQ7PSTjh9k+OVBus dF18r7BJ4DTr1P6Tr3TEfX5kyC7XoYkrYfUcMW5rvCmQYxeAY4bm3wIPCFmIa4WIdJRl aeYHBt9sLd9E2rlPtgFuwsf8pxeOe7G2AcVQaT/E0P3X7Op7TUc8HLGkxB8TLJvqFs0r CQMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=5140iHkZNuZn3I2k8biDJLxaiQwsOPdwZlAn0pvvLx0=; b=XkuCsvgxl5BBCxT2fSdYxAKrYm5ao+zYKFc1WvE4c1uPtzZAYwOJfUst68qE5XFAyO kcVmoQ0b607QT6LhRU6L1AUH/Y0RJzsoJ7dVw5vV9EZKSdUj/ia1RFs1Vy7Wp9Zz0kXG jvqaMFQs1duGMerOjvuE7F3FlNWYDI6G6ICPbg/HJreZPOX8O6Uw78MaRF9q0s4PxuCd IRwM6pLKtrdJHrnzF1GFnJ+v88/srbVcqJUxZz9Tn4RqadtTf91QoqxOurLF6KcFcEhI hBhS44JXUoWsjQ4P+SnqoFe4GxR7+D/NS6Eyjit9YAqthZDyObMw7if34AQ9frjPVk3z cfxQ== X-Gm-Message-State: AO0yUKWNrFqXxxfkzonAn+AzoYTPSqT78iPAEqHJRE5kO3kSnMvwpf7Q 2mijjE3c6/J3haxvMONGktOeQA== X-Google-Smtp-Source: AK7set/tXHs16dGr+zHyR+V/OhnL8xcadGNdW7FOUPWdkoa4rrfICmIEAi81lYkc9gfGGH+ZXe9EVg== X-Received: by 2002:a17:902:c406:b0:19a:990c:9c0 with SMTP id k6-20020a170902c40600b0019a990c09c0mr14592756plk.3.1677147730761; Thu, 23 Feb 2023 02:22:10 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 26/34] hw/net/net_tx_pkt: Check the payload length Date: Thu, 23 Feb 2023 19:20:10 +0900 Message-Id: <20230223102018.141748-27-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102d.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147858866100003 Content-Type: text/plain; charset="utf-8" Check the payload length if checksumming to ensure the payload contains the space for the resulting value. This bug was found by Alexander Bulekov with the fuzzer: https://patchew.org/QEMU/20230129053316.1071513-1-alxndr@bu.edu/ The fixed test case is: fuzz/crash_6aeaa33e7211ecd603726c53e834df4c6d1e08bc Fixes: e263cd49c7 ("Packet abstraction for VMWARE network devices") Signed-off-by: Akihiko Odaki --- hw/net/net_tx_pkt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 4a35e8429d..986a3adfe9 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -342,11 +342,17 @@ bool net_tx_pkt_build_vheader(struct NetTxPkt *pkt, b= ool tso_enable, if (csum_enable) { switch (pkt->l4proto) { case IP_PROTO_TCP: + if (pkt->payload_len < sizeof(struct tcp_hdr)) { + return false; + } pkt->virt_hdr.flags =3D VIRTIO_NET_HDR_F_NEEDS_CSUM; pkt->virt_hdr.csum_start =3D pkt->hdr_len; pkt->virt_hdr.csum_offset =3D offsetof(struct tcp_hdr, th_sum); break; case IP_PROTO_UDP: + if (pkt->payload_len < sizeof(struct udp_hdr)) { + return false; + } pkt->virt_hdr.flags =3D VIRTIO_NET_HDR_F_NEEDS_CSUM; pkt->virt_hdr.csum_start =3D pkt->hdr_len; pkt->virt_hdr.csum_offset =3D offsetof(struct udp_hdr, uh_sum); --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677148010; cv=none; d=zohomail.com; s=zohoarc; b=PLxynnwmmkE9WLrNcRly1jKUs1uyZXKChkP9XeSVAF8ZSuF1Hq3m0iShznJeNvJbv26UhzHvJJQmeizyVJHf1ubeEuY5DXGbkM7MVy6zy7I05rpw5bUrJxM5HoTNcBBlj1PGlKHnuf19ovV7kwda7pz7y6rbn1YWQ+7gEd9fIMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677148010; 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=ZSa3rJ4rdM+JL+7J+WlKqYqNPxt3Id/p0w4TcjJhfgI=; b=PcLNW0SF+nvUz/W9tFZcd39JUtLQjwtFeyH07oToROmJ3xtUHU9NT6gDk1NCCqZT7zBfEOcwq7Ui2iCzfEsLXVvoTI6KhlAoyaF6/lcLKya32Brw91XCg+7aCMm1nkJ4vfoP0zL1K0ng/bQ5gV2jKWVhMOlASNhuLM85onjOcXE= 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+importer2=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 1677148010811971.3063087788112; Thu, 23 Feb 2023 02:26:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k3-0007ju-4k; Thu, 23 Feb 2023 05:22:23 -0500 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 1pV8jx-0007Od-RT for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:18 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jw-0002lt-3J for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:17 -0500 Received: by mail-pj1-x102e.google.com with SMTP id u10so12329741pjc.5 for ; Thu, 23 Feb 2023 02:22:15 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=ZSa3rJ4rdM+JL+7J+WlKqYqNPxt3Id/p0w4TcjJhfgI=; b=xFVs4s7nGIopiaaUmqdKTKVg4rv/sx+LN/49NPhyNwo6VFwScqIsyNNif0ETq43PjJ D64la2gXTAsZ8n1Q//J57vPhJobl5mfwWboHs0gnblV6sLAL1cTbBRLoGwGg7WE575d7 A99zFX+Ys0B+Byxyk+evi6gsjcLzPzPtEhXYzUMR2iZTDCRxNlLMYpnaSInCiuHpcHD8 oigPabqrrbYE25orbbYlhwmU/MCQwIJcWJ8wvAlANrI2fvB66cTalA586u0vms4nxEkR K7r+oi9pi0FjcfCYIBJVooahXekiovmqeibRfT+orTAMucc9f7AeMiUelAKVPRb1KAQt kz6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ZSa3rJ4rdM+JL+7J+WlKqYqNPxt3Id/p0w4TcjJhfgI=; b=CpmCMFRyxGW0f4pOi/VBRc2MBxiVOdyOxY0J192v8/1o1WZ98pufYu12wvaOPlg7KH w41rk9JRK/ABcwOkDDtlyOvTRxpGhzkcNodUO8MaldQqkyLAYb6o3QNGRZBRGtGdxvMs z9ifCTWeSVxusjA8YS7SNmqq1+V63JhkeJI6wyZn0Y4GxQKGSG71ZA7n7EaO+GvPOsup cqEN/zAl4UqGl1Ljrfzec6XJbcGbBWba+3Gz3d86jcY7gSOE6r7goFNP4RCGwrt8zh+6 oEJ0QfKlA49vpVi1ooImVZH90iZH5ureXigRmjvJcYqzSPOeHXWpQ7kfngslJrH3u8bx gYYQ== X-Gm-Message-State: AO0yUKWagjj3dw6uZby/ZWViji7Sk3Ra/9NH2jD0OYAB6hyg8OrD2pu4 EhVQC4Gy/a3vJiuWCHHFgIvxZg== X-Google-Smtp-Source: AK7set9JHY2l1tF/ydcI4QBXivRi6zlU4xq2t954k1GdV10KqMO5r1waA+ZpMPLi5f9SC5GoT9QtoQ== X-Received: by 2002:a17:902:c40d:b0:19a:8284:83a2 with SMTP id k13-20020a170902c40d00b0019a828483a2mr13883527plk.10.1677147733912; Thu, 23 Feb 2023 02:22:13 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 27/34] e1000e: Do not assert when MSI-X is disabled later Date: Thu, 23 Feb 2023 19:20:11 +0900 Message-Id: <20230223102018.141748-28-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102e.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677148011851100001 Content-Type: text/plain; charset="utf-8" Assertions will fail if MSI-X gets disabled while a timer for MSI-X interrupts is running so remove them to avoid abortions. Fortunately, nothing bad happens even if the assertions won't trigger as msix_notify(), called by timer handlers, does nothing when MSI-X is disabled. This bug was found by Alexander Bulekov when fuzzing igb, a new device implementation derived from e1000e: https://patchew.org/QEMU/20230129053316.1071513-1-alxndr@bu.edu/ The fixed test case is: fuzz/crash_aea040166819193cf9fedb810c6d100221da721a Fixes: 6f3fbe4ed0 ("net: Introduce e1000e device emulation") Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index ff93547f88..76c7814cb8 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -162,8 +162,6 @@ e1000e_intrmgr_on_throttling_timer(void *opaque) { E1000IntrDelayTimer *timer =3D opaque; =20 - assert(!msix_enabled(timer->core->owner)); - timer->running =3D false; =20 if (msi_enabled(timer->core->owner)) { @@ -183,8 +181,6 @@ e1000e_intrmgr_on_msix_throttling_timer(void *opaque) E1000IntrDelayTimer *timer =3D opaque; int idx =3D timer - &timer->core->eitr[0]; =20 - assert(msix_enabled(timer->core->owner)); - timer->running =3D false; =20 trace_e1000e_irq_msix_notify_postponed_vec(idx); --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147809; cv=none; d=zohomail.com; s=zohoarc; b=Jr1EyTYvKg1kL9jujtBd5wqXJcUw+GkVDTHiRQ7L3h1Kc8DCvRDBDzb74i/oAatpkhbd2qqKNy/oxZBa4kqIn4KI4fcLwzUH2t8u0vDkXIIowIB7yz5mLB/BHVwxnkt/6qL/wRDA7CMog6Ywgk2139g7ik0KoxCT1jCs5aWsDOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147809; h=Content-Type: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=KVlvUBDvtffulBoPusPqKGRZ0+pngfJ5N/roeZOO/ec=; b=LCzHEINKF4nnGW0gzhzW2vkojeypN3H12nn8YXsqyaoag03L9qIyu/H+Hjl6QFlR+GMwSgEGSz5jSIBnuqUsnt01YRZqwDm9cWNU4vZ1wbbsXbeL+8nyJsEJAvhYMnXhdGiuLB8f2lOXj5/6I0ziDs8+rkf+CPNS5rRArQz40BA= 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+importer2=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 1677147809054515.2553762894391; Thu, 23 Feb 2023 02:23:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k4-0007mR-AF; Thu, 23 Feb 2023 05:22:24 -0500 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 1pV8k0-0007T4-Ft for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:20 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8jy-0002mA-Kq for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:20 -0500 Received: by mail-pj1-x102f.google.com with SMTP id cp7-20020a17090afb8700b0023756229427so3430199pjb.1 for ; Thu, 23 Feb 2023 02:22:18 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=KVlvUBDvtffulBoPusPqKGRZ0+pngfJ5N/roeZOO/ec=; b=xiof4b3LrC6TfEG7mqTlB5XDMYZzTkzQsNrvBczJbicPUfncU01Tr/3DH2WErAJuHs iTqdSZm0zv83nFxlJOkFAZuZRmZwHsne3jyPw7GVqkhUJiTrpT5pMVegNi1enQ5o27pe LQb1rI0JFaRtrthYPvku7SismHDOx4xOSY1BHgNIHQRJgaeYBFe+PBiS+3xg3eCxJ1T6 DjJ6bVsWLlkax6SbFhQ6jDWdje5oPLZJbJbsBtYcZ+v848JBAtnlz6E410IAIq9khVF+ v8vTEWVOo/30k68mA409LL4yPWWu+85x4C2p6LgXUIrY/Te0B9MOGJNDOHPnHWcYfByk 8CoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KVlvUBDvtffulBoPusPqKGRZ0+pngfJ5N/roeZOO/ec=; b=3ZrZwkrAqAzcaaPGbRCXiQyFeIs4K5SSGHVVpIb1j4guWvXLHb/iwYE7FPhdRYWgjE RcnIsUamQXews3Eheo+t5hy52RuvtD+DoVX0WxQ+Nda2hW4rThEUgcegti2i6Kk50Fgi LVJJ2JjMEfUqx1Ry6nbdGeBTsLWHe0us+qlyNnYuS88e25iKDcba9zrgUcQVA4EYGw++ D5iOBJIMFuZDeN7m8VnarmzntATRi2jrF8SlndyDNIHC9aSxFPGUGYu/E1dj4ilnxacT n+cfKgkBSBCvP4JUgnufTrSygjxbPkVFB0Got03xkCPef7DajzSWinm6btFZ8rCFSjdo 9UAA== X-Gm-Message-State: AO0yUKUilnxpX13/ydbDDAPePkQmksrJYbG46kpJhXYdzkO2RmBXYXeI iihbv4rA9w/6DtBMYFXWCdDVd04rnG8k1lXD X-Google-Smtp-Source: AK7set8m9QR62c30CkA9T/gWy3NsaAXr6WnbZsCLfJAk3sFfdZoQE9ZXBx0yYm7AbAHnpwyArSeI2g== X-Received: by 2002:a17:902:dacf:b0:19a:945d:e31 with SMTP id q15-20020a170902dacf00b0019a945d0e31mr12682335plx.13.1677147737256; Thu, 23 Feb 2023 02:22:17 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 28/34] MAINTAINERS: Add Akihiko Odaki as a e1000e reviewer Date: Thu, 23 Feb 2023 19:20:12 +0900 Message-Id: <20230223102018.141748-29-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102f.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147810441100003 I want to know to be notified when there is a new change for e1000e as e1000e is similar to igb and such a change may also be applicable for igb. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 9adb628627..993ebc6e08 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2212,11 +2212,13 @@ F: docs/specs/rocker.txt =20 e1000x M: Dmitry Fleytman +R: Akihiko Odaki S: Maintained F: hw/net/e1000x* =20 e1000e M: Dmitry Fleytman +R: Akihiko Odaki S: Maintained F: hw/net/e1000e* F: tests/qtest/fuzz-e1000e-test.c --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677148025; cv=none; d=zohomail.com; s=zohoarc; b=MtEmUV2ykpcksx9IaPjwfNmNYb5fEPlFCu288vNrwLXV04p0x2C5exbQL9zST3cll+9VPNpq9IMJsr5e6YlBSpplkxEbqjAo2CsiVjgyYWEsj1EMf4U1v+2jMdce10B6woOT23T9YQaxDd25ee4g3RN76wAPp0n0l91Wwu3VvKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677148025; h=Content-Type: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=0u2FbGfNLuWVjYzfInhVxOMxcgmZi2EeYWwRpjCl9mY=; b=oDSin7Fx+MH1Su3Vcmuc0EAMBPKXdOdm/iY3DkHqCbj9r69zdL6ifiGlWb6kyU7mCfQ8NYkXGVD+dBTq2N52ngDcBDPLMO5aMbN7tEQvmRNyzud8gbL2hmVBaBtVD6K6eiZo2w8x/tEuSqTgwhSNLf4pSlaG65K/JtwxrmEZhgo= 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+importer2=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 1677148025311841.2132573823918; Thu, 23 Feb 2023 02:27:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k5-0007tK-Ny; Thu, 23 Feb 2023 05:22:25 -0500 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 1pV8k4-0007m7-0I for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:24 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8k2-0002ml-Jv for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:23 -0500 Received: by mail-pj1-x1034.google.com with SMTP id gi3-20020a17090b110300b0023762f642dcso1536992pjb.4 for ; Thu, 23 Feb 2023 02:22:22 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=0u2FbGfNLuWVjYzfInhVxOMxcgmZi2EeYWwRpjCl9mY=; b=Cuu91zVqX++iMIHbIu1tts2YXG35fqjqFuZNldKrBWIcwGFrx1Rg9ktqt4GWQfwnrW KLClYSScgxLN/TgUk8UUGMoFe3EcGkXr1WNSpNnvlyR3sqAj5dbYJS7cBSpe3i7+Lbpe 8O586ht4ieMOoTK8RG75TsyTWBiPUES49EfkHu4LtwpxnfoaP7zDq8mHYASLDNOxbvAL LPDOBD7FRzBTcoNql8XygrVe4YZdcAw28w3bwXqmg4CqbchnI0XZ9hPbz4rF+GY9A109 2B80SW/gQdPMdccvPM71ITB4P+CWFVJqIbWAR1F2bqGOtjyaYd8UWC8Q9Yd0wHAFHOSr xXPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=0u2FbGfNLuWVjYzfInhVxOMxcgmZi2EeYWwRpjCl9mY=; b=iQXoXFd2oA237B+S1vppobIy9IoSqxTBbMB1a+rgkCZrNbuDhDU5Ph9nmLTImRuFFH lU/w5ej/vgmR32veX4/DMxE/57UssmKqFbwGzzUA54rX53mWfuAu2Zl+LU7nbIQks4TH ZuGogoGs3tjr7Z6dQX32hN6mUHDagiIAcG8/YbbaW3J6LuoSBAk5YWsGEgPG6h3Iqq9A GhdyWg2oovh6eKQCa5KS2FvgcHF9IJ9Drn5XinpxxNUB05knaZ5bUITKfq/LzvRP0RVP vZHwHhPzY5YVaplfzvUwi0wUJUm2AAfEhiRvX7NCS7bWsIH0yHFiCJgzlDoweFztQE2B 8PSA== X-Gm-Message-State: AO0yUKWduqCUdWsmeIC2iDlWFO+4KKlwzRdqitkzostFVU6Z/wAWE/jv 1a7dny6QtW9Zp/hhwFtv5VOIog== X-Google-Smtp-Source: AK7set+KxU7QQ+is8ajMX1ELXk/oQYRsNY+lyYCVV9Tdn+Q4QT5stmPwevTNT1xjtSMh1vA1DHxuHg== X-Received: by 2002:a17:903:2345:b0:19b:110d:28dc with SMTP id c5-20020a170903234500b0019b110d28dcmr13122619plh.19.1677147741504; Thu, 23 Feb 2023 02:22:21 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 29/34] MAINTAINERS: Add e1000e test files Date: Thu, 23 Feb 2023 19:20:13 +0900 Message-Id: <20230223102018.141748-30-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1034; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1034.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677148026012100001 Signed-off-by: Akihiko Odaki Acked-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 993ebc6e08..cc99e38db8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2222,6 +2222,8 @@ R: Akihiko Odaki S: Maintained F: hw/net/e1000e* F: tests/qtest/fuzz-e1000e-test.c +F: tests/qtest/e1000e-test.c +F: tests/qtest/libqos/e1000e.* =20 eepro100 M: Stefan Weil --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147767; cv=none; d=zohomail.com; s=zohoarc; b=EJwqzKbjsESZuF/FW1YyGvfWupI3hXcikp9ISzw+MKQB7bvNFjwyWfyO/qJLkFnZOuKLVGMleIQCbn901m3gCB5jXNjlsgoEXjxz6CV+WZo3GEDTsqEDJuVJO3JjxC2Fn3mFJAYJ4vbkzqsDnT4+lYbmt9H1o9BW7Itx0dAJ1MQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147767; 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=jC2oma+4dx0vXgHNVPLx5yQddrN4Crk9daChNzOuQT8=; b=OeO66XsfE/RKcYG0TdoZw0L7BBskk20C1tJHcI+0juNj0ntxsPTOqNh6jfKnRZYHM/2vJ+YlWUN7woBgxF4vaTyQ4FqmaOR4mlObE2VWLhahwu1k/tz+xQ6KiXgyN5nAIDmgVKewJ6qohd8bNFFOTMOTXjMKXnB3Ua+hG6WoiJo= 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+importer2=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 1677147767542897.242349853278; Thu, 23 Feb 2023 02:22:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8k8-00083U-JF; Thu, 23 Feb 2023 05:22:28 -0500 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 1pV8k7-0007xi-1j for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:27 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8k5-0002lt-DC for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:26 -0500 Received: by mail-pj1-x102e.google.com with SMTP id u10so12330276pjc.5 for ; Thu, 23 Feb 2023 02:22:25 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=jC2oma+4dx0vXgHNVPLx5yQddrN4Crk9daChNzOuQT8=; b=nwLlTwjT0N8Vd/Yz6Z02OXyXSlycLTtKNnXzFGxV26E++Owy9MOCYMOAEexoliW3R4 LLdZCyiFCntyuWjVaSL0kkjopqRB1P69ac31ClXtFlworHXR8ay6G4WvSGz9ZyOv+DbM VrBKipbANg8nc0MVVyxhEomNv5o67tNllZDQWNM74b3MlSxjRdAMjGA2VLm9dRvV2rKY 0QdYdFIwGPyL4+cYz27cbRl/hQtvowtfW3N4UNvqCJrlJFZQY+KSrVq7yFtu/I9TvdfG /JYPFl1cTrPFKjNA+ArhaLGLxR3KWqhRCBlLig5bsMU/2aCMg1d+GtznxA6ckSo5aQ71 dREA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=jC2oma+4dx0vXgHNVPLx5yQddrN4Crk9daChNzOuQT8=; b=z7Yc3+4Nk/3GfnwOMWwFRS9QXgDbFXmf2AO2iiC+HYsxGiUO23G7aeYcwxZGqSjM5H jyAywjHE2rz1Jm2j9U9fkkN/eXZjeudZ/b35PaOTNThmLgB7hM60sSw2PmuxcSDM3eh9 5+T0xKf7NMJlM3TVlfdmvJ2qdy7Lp2R5M5hdIdKGiyMTLPbjANtPlli8MU+dzm79K0sL ySNrBNvjZfPcy96raxz+33VrdXngHbVSedgajxqjrYglEakST/4ugO4oTVCyMV2BzA1C 3Yz3ADBMMw2oDHHzEx7/21sDsR22D/oow7XStGFBlTBXMcMJizUxRPaoGFZ2D1C+/rW0 GrlA== X-Gm-Message-State: AO0yUKXK95P9smQ+tTpRYnBJ9jH9Mq6mf1I2Hs0+2DEnQO4KHA4gfgQD PyvfSOMGteBsxEZmAvC3GAhWcQ== X-Google-Smtp-Source: AK7set/vP1V0oEtadVPsvEG+RGyi7aGVNWH8mcplYsekRYPJ+XQBDurICyB9XcfNS9JqUXYxJ/3wyA== X-Received: by 2002:a17:902:c941:b0:19a:7882:c1a9 with SMTP id i1-20020a170902c94100b0019a7882c1a9mr14293836pla.63.1677147744727; Thu, 23 Feb 2023 02:22:24 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 30/34] e1000e: Combine rx traces Date: Thu, 23 Feb 2023 19:20:14 +0900 Message-Id: <20230223102018.141748-31-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102e.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147768127100003 Content-Type: text/plain; charset="utf-8" Whether a packet will be written back to the guest depends on the remaining space of the queue. Therefore, e1000e_rx_written_to_guest and e1000e_rx_not_written_to_guest should log the index of the queue instead of generated interrupts. This also removes the need of e1000e_rx_rss_dispatched_to_queue, which logs the queue index. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 6 ++---- hw/net/trace-events | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 76c7814cb8..4fec6dfe7e 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1759,8 +1759,6 @@ e1000e_receive_internal(E1000ECore *core, const struc= t iovec *iov, int iovcnt, e1000e_rss_parse_packet(core, core->rx_pkt, &rss_info); e1000e_rx_ring_init(core, &rxr, rss_info.queue); =20 - trace_e1000e_rx_rss_dispatched_to_queue(rxr.i->idx); - total_size =3D net_rx_pkt_get_total_len(core->rx_pkt) + e1000x_fcs_len(core->mac); =20 @@ -1786,12 +1784,12 @@ e1000e_receive_internal(E1000ECore *core, const str= uct iovec *iov, int iovcnt, rdmts_hit =3D e1000e_rx_descr_threshold_hit(core, rxr.i); n |=3D e1000e_rx_wb_interrupt_cause(core, rxr.i->idx, rdmts_hit); =20 - trace_e1000e_rx_written_to_guest(n); + trace_e1000e_rx_written_to_guest(rxr.i->idx); } else { n |=3D E1000_ICS_RXO; retval =3D 0; =20 - trace_e1000e_rx_not_written_to_guest(n); + trace_e1000e_rx_not_written_to_guest(rxr.i->idx); } =20 if (!e1000e_intrmgr_delay_rx_causes(core, &n)) { diff --git a/hw/net/trace-events b/hw/net/trace-events index f7257a0693..d24ba945dc 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -165,8 +165,8 @@ e1000e_rx_descr(int ridx, uint64_t base, uint8_t len) "= Next RX descriptor: ring e1000e_rx_set_rctl(uint32_t rctl) "RCTL =3D 0x%x" e1000e_rx_receive_iov(int iovcnt) "Received vector of %d fragments" e1000e_rx_flt_dropped(void) "Received packet dropped by RX filter" -e1000e_rx_written_to_guest(uint32_t causes) "Received packet written to gu= est (ICR causes %u)" -e1000e_rx_not_written_to_guest(uint32_t causes) "Received packet NOT writt= en to guest (ICR causes %u)" +e1000e_rx_written_to_guest(int queue_idx) "Received packet written to gues= t (queue %d)" +e1000e_rx_not_written_to_guest(int queue_idx) "Received packet NOT written= to guest (queue %d)" e1000e_rx_interrupt_set(uint32_t causes) "Receive interrupt set (ICR cause= s %u)" e1000e_rx_interrupt_delayed(uint32_t causes) "Receive interrupt delayed (I= CR causes %u)" e1000e_rx_set_cso(int cso_state) "RX CSO state set to %d" @@ -180,7 +180,6 @@ e1000e_rx_rss_type(uint32_t type) "RSS type is %u" e1000e_rx_rss_ip4(bool isfragment, bool istcp, uint32_t mrqc, bool tcpipv4= _enabled, bool ipv4_enabled) "RSS IPv4: fragment %d, tcp %d, mrqc 0x%X, tcp= ipv4 enabled %d, ipv4 enabled %d" e1000e_rx_rss_ip6_rfctl(uint32_t rfctl) "RSS IPv6: rfctl 0x%X" e1000e_rx_rss_ip6(bool ex_dis, bool new_ex_dis, bool istcp, bool has_ext_h= eaders, bool ex_dst_valid, bool ex_src_valid, uint32_t mrqc, bool tcpipv6_e= nabled, bool ipv6ex_enabled, bool ipv6_enabled) "RSS IPv6: ex_dis: %d, new_= ex_dis: %d, tcp %d, has_ext_headers %d, ex_dst_valid %d, ex_src_valid %d, m= rqc 0x%X, tcpipv6 enabled %d, ipv6ex enabled %d, ipv6 enabled %d" -e1000e_rx_rss_dispatched_to_queue(int queue_idx) "Packet being dispatched = to queue %d" =20 e1000e_rx_metadata_protocols(bool isip4, bool isip6, bool isudp, bool istc= p) "protocols: ip4: %d, ip6: %d, udp: %d, tcp: %d" e1000e_rx_metadata_vlan(uint16_t vlan_tag) "VLAN tag is 0x%X" --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147779; cv=none; d=zohomail.com; s=zohoarc; b=EWehlbNBDcby8BJyNrBciPfxy90Sh4D730sNfKA3HLD3e2DJll/bhAlroEwplOiL0BHEy2wz1k9Uk9axRDjfBXEKC0RHTYhifTXS2dr1sxuqzz5mvonjRcm3mwuoNNahOSSJSQKlLQ2BtC/bsGxPNnzg8nX7QXqWPHHIFbqM7xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147779; 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=ZbOxJlZ5tx8ymjfKgIQaBeKJIwscq3YDNrk13mRmwgU=; b=g/J8vuEvD6ZyeFafF+tGfib3P7dxX6M6EW46oNxJjJ1ZdrulII6FRecFrn+4w/1Xcw4cJdZMtynvur4BTdzdoF8UYUHI811azp6ow7Eza5lMG5r/qvgeLV7yjX5dg3x+Ez4HZBD3AZEZ0c62g8AKmii+MKt0+tR74EI1u1LM32I= 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+importer2=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 1677147779240656.6718368243373; Thu, 23 Feb 2023 02:22:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8kB-0008BJ-MB; Thu, 23 Feb 2023 05:22:31 -0500 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 1pV8kA-0008AR-EL for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:30 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8k9-0002pV-0M for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:30 -0500 Received: by mail-pl1-x62b.google.com with SMTP id s5so12156758plg.0 for ; Thu, 23 Feb 2023 02:22:28 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=ZbOxJlZ5tx8ymjfKgIQaBeKJIwscq3YDNrk13mRmwgU=; b=yGzDYVIZan75Q1TULmnIM+OHRtLAl+79thJNdfKlGaY0lo7tvxZuJA49lxVWEzaLaX klauZJIN0w1iRqZfCuA0M1xocwqG6LP01fPMMY4Uk8ueZ7adHQKzxlkKzZHlrLpgZr4U y+kLzkE2kWWthYIhNwsJDpU8OrmNQNl+9HAq77c9w9lZzJR7Fp+0Ty4FHhLF0lmQQuwr zZm9D7R2wt0gf1LV8kAvpvZjBfYDANOUF6rpRuugAPl1+giMH4EfWiTTcrE/v0B+kVs9 5EMDcgyoI35f2rsgwhBfjZ19d/9+qhoGD/D5UX1BK/QBABzVIza0ZJB3VDdRn6nfWvgN D8Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ZbOxJlZ5tx8ymjfKgIQaBeKJIwscq3YDNrk13mRmwgU=; b=blyAYUy0K1Po2M9Ih9Kx3Z/MTVbNxoZTEEH1+VABwPTj2/HwcSwEReFxkb0/E4aURA 57iRXUaQ5jx9kAduqjCJBtOyIYNkda05p4OJXcJcnKJu21MeHoWcYGhDVp4j96XU+hgx RxFxRA5nMLPEQSfsNXDWjRynpLo6O3DHp0MokgHQbC0IV0cmZBO+l9QxoYgXQXi8OQBG 9HNWPhPNb6eIa6Uzvd2vx4HcMV3kk0z2yu94m5pienSB/ikM0+58cRmA9KG3fOzfSwIV f0vPTjALhpADQafuvx1HvobTYJ6kdMs8W5VJ4V3kC/o0wvPYm5LAdvm6yUfXVqFt15+A v4Hg== X-Gm-Message-State: AO0yUKXsIjcg3DX4Zl+RFgzUh3UaFcdY8nVsKbAENqanqb2cmDs3l/OO IsKJrzLrATaJYZlwy6JmgCPDAw== X-Google-Smtp-Source: AK7set/7FuEml7ztYCWwhRSkyY8sNr4I8iGIlZxW2k2TcsxdqBcIlvYKYlI1vZKLD6TPt/C5Eh8psg== X-Received: by 2002:a17:902:e74f:b0:199:2e77:fe56 with SMTP id p15-20020a170902e74f00b001992e77fe56mr15263765plf.52.1677147747900; Thu, 23 Feb 2023 02:22:27 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 31/34] e1000: Count CRC in Tx statistics Date: Thu, 23 Feb 2023 19:20:15 +0900 Message-Id: <20230223102018.141748-32-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62b.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 autolearn=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147780270100005 Content-Type: text/plain; charset="utf-8" The Software Developer's Manual 13.7.4.5 "Packets Transmitted (64 Bytes) Count" says: > This register counts the number of packets transmitted that are > exactly 64 bytes (from through , > inclusively) in length. It also says similar for the other Tx statistics registers. Add the number of bytes for CRC to those registers. Signed-off-by: Akihiko Odaki --- hw/net/e1000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index c81d914a02..c8307984fc 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -571,7 +571,7 @@ e1000_send_packet(E1000State *s, const uint8_t *buf, in= t size) qemu_send_packet(nc, buf, size); } inc_tx_bcast_or_mcast_count(s, buf); - e1000x_increase_size_stats(s->mac_reg, PTCregs, size); + e1000x_increase_size_stats(s->mac_reg, PTCregs, size + 4); } =20 static void @@ -635,7 +635,7 @@ xmit_seg(E1000State *s) } =20 e1000x_inc_reg_if_not_full(s->mac_reg, TPT); - e1000x_grow_8reg_if_not_full(s->mac_reg, TOTL, s->tx.size); + e1000x_grow_8reg_if_not_full(s->mac_reg, TOTL, s->tx.size + 4); s->mac_reg[GPTC] =3D s->mac_reg[TPT]; s->mac_reg[GOTCL] =3D s->mac_reg[TOTL]; s->mac_reg[GOTCH] =3D s->mac_reg[TOTH]; --=20 2.39.1 From nobody Sun May 5 04:44:08 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147780; cv=none; d=zohomail.com; s=zohoarc; b=E0inF/H1UjoABsSXdkKLWg5ca6HlHYPebWA334e97UY8Wv7HbwDJ5qHa9mFsIAU+IQBd0pHIfIFNInOZ2EH/7AKG074ymlnZASD6mkc1z9Jnn6WJefhQu7MGTPkCY+YWqxTwXBcIa3TrXrzKVu+DNO5ZNLYlKnHHGROTlZVm1a8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147780; 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=VULQj5NfLj7RDTPoNyYcaS23xm3yQNzy0k0wd+rAKig=; b=Xl9G1TacZycPDuwwAzcA7H8bS3gJwKJaEbMm48KYQejNz001q5cMY6csPpotVNayIEU4R/a9Qkken35T+y/Rvh83OY1m7hW753hFTDK8vE/2SoRFl5XDwiWjwXaav9zanng6tnOLObVR8wFi6I2iLDCz2dgLqvhQjsSW9n/T0as= 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+importer2=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 1677147780195605.4076279006794; Thu, 23 Feb 2023 02:23:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8kF-0008HJ-Ld; Thu, 23 Feb 2023 05:22:35 -0500 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 1pV8kE-0008Fu-DK for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:34 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8kC-0002py-1K for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:34 -0500 Received: by mail-pj1-x1030.google.com with SMTP id l1so1976134pjt.2 for ; Thu, 23 Feb 2023 02:22:31 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=VULQj5NfLj7RDTPoNyYcaS23xm3yQNzy0k0wd+rAKig=; b=LLg6gk94mR0I2qVZ5Vap8dxrRz2suDinZQ3Fmbtck0YHFDwsCedj+Jmv/naIyTpYx4 G3YBPhyhnNO1GsRNw0/zWjyMuB56PPeqHi9izErGl+J4Tk+oZnldz2QKcT3Lln+ko63z NyGOVVgFpZ2S0q8lEjhfWx94Bephx/KrmLa9uvgCYjU1Uc+WFdUc0rTYwBXfk1vL+i/t m04XGMQjhVa7XndT4awEXq+nykpnqkeGIzAGSAgaVkT1qwRvQntbwzFEddRjnmy8gfop 5sxt320+r4ZsSzgZGorR3pTmj0npr/rx+UOGsOq7BFN0pwI2i86ob6YAD5mc/tZs36i1 hZ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=VULQj5NfLj7RDTPoNyYcaS23xm3yQNzy0k0wd+rAKig=; b=w3ne6knhvrWMKcSPzcPMDzdEz86G9fl2Xn3n2WI10796IORp4AqP2TTIAR3rNGrfMy SWOVMl5i1fXNRivm1iUZt1UHReQsS78qO9wLUxRL+RBXbOqVT1uhmuhZUAUIgpW70Q32 tkj7owtMX/JHnAH0RwpcKSeSLlwwUDexN7SvdfPuDmlaRbYMQyqBTFtaTCXc9+uF6hQC 1uqkrfSGIQ0gxa07eezIrMqG6byQPbMIx2U7Cazv0rFhvJF4l1gvBZYpkO0gPIi144uK w0HXAymZdPPbXuPBW8//VMaCv4y/6GLSuH3DV/vXfBISOZ2tce0E30iMrnl4dhtFcocv EjFA== X-Gm-Message-State: AO0yUKU+imrVjMeHvVyee2PdNAWwdLlQsnR190mjLpsvv7CC6c7fS6L0 brOEBCHiNJcK6S4ErbXbyLeKUA== X-Google-Smtp-Source: AK7set/u2zOICp5RiJRvgcPPR2xQRvHTKIS29C2J44N+l2Jr7mtZGx3S3B64BHYcHa0Vs6QyWgVSbw== X-Received: by 2002:a17:903:2289:b0:19a:9833:6f8 with SMTP id b9-20020a170903228900b0019a983306f8mr17747178plh.35.1677147750981; Thu, 23 Feb 2023 02:22:30 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 32/34] e1000e: Count CRC in Tx statistics Date: Thu, 23 Feb 2023 19:20:16 +0900 Message-Id: <20230223102018.141748-33-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1030; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1030.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147782278100015 Content-Type: text/plain; charset="utf-8" The datasheet 8.19.29 "Good Packets Transmitted Count - GPTC (0x04080; RC)" says: > This register counts the number of good (no errors) packets > transmitted. A good transmit packet is considered one that is 64 or > more bytes in length (from through , > inclusively) in length. It also says similar for the other Tx statistics registers. Add the number of bytes for CRC to those registers. Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 4fec6dfe7e..326b9a166d 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -691,7 +691,7 @@ e1000e_on_tx_done_update_stats(E1000ECore *core, struct= NetTxPkt *tx_pkt) static const int PTCregs[6] =3D { PTC64, PTC127, PTC255, PTC511, PTC1023, PTC1522 }; =20 - size_t tot_len =3D net_tx_pkt_get_total_len(tx_pkt); + size_t tot_len =3D net_tx_pkt_get_total_len(tx_pkt) + 4; =20 e1000x_increase_size_stats(core->mac, PTCregs, tot_len); e1000x_inc_reg_if_not_full(core->mac, TPT); --=20 2.39.1 From nobody Sun May 5 04:44:09 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677148005; cv=none; d=zohomail.com; s=zohoarc; b=W+sjj7na1hVtJ1E8CFDwU7GcklX/6nAhPKmv0Vct70Ww3gEb/0ejdwfKjA3eDWGk1sRRxOTRJMaqWrsgEeMI7kqlQbhiQCjDFTqbFZk1lf+kSJVWYHMqSdmSk9FAVm1phzvz4iZabagqEOq2fhwhRC4GBAMwtEeZr7ZNB9bhsbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677148005; 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=FtNP8ggV9yLDfbcYSmXODh6nZac9HheatFlB5fDy0+8=; b=d5KjjiI58JZ823pBZIRzOcre/h32NQ5erDaFUoDQ3nJIdG8KBpUszzFCHxPu+zWWN4ZdrxRo0Z3BwfnUWbBQocVTlqQWWlhytQ6d4A3vT1llZDJzFy9Pz0DhPiwguiDn/Lzqz7RWRtccTyLix94C43qcpUkvo7+2zLZF/JW+/8M= 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+importer2=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 167714800528047.466756076211254; Thu, 23 Feb 2023 02:26:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8kK-0008PT-O1; Thu, 23 Feb 2023 05:22:40 -0500 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 1pV8kI-0008Iu-Ej for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:38 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8kF-0002qM-GS for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:38 -0500 Received: by mail-pj1-x102f.google.com with SMTP id oe18-20020a17090b395200b00236a0d55d3aso12037934pjb.3 for ; Thu, 23 Feb 2023 02:22:35 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=FtNP8ggV9yLDfbcYSmXODh6nZac9HheatFlB5fDy0+8=; b=iN4UyCUlatJhl+u/q1jpeLE1jKGYhUFU8lvAfLUJ/oknUehQUAAMFB4HQFj4JvTDqx UmNHa+NoKqUIPkyu4FNZK6QnGAyyWwd9IVJ0qKvjXdfFArKTPeO7w/DqDKhd82vmtO+j DcciFoTquvkK5GLuqi3g0pluov8BpcVd5c2Vt6XFfsufVh419nXfAyJIXuiw7Uv8h8+C QobrH5WI9Gy2sGl9xpfEGKLOevU5C0bKIQrXaboO8map6z7d/pqqwIOxr76WF9Kgzw7o 7qoP/PLu8E7g7upYmIKJWJuAi4y7DUY634AK06rhY5nHx07gQjBz2PwVz7+AUGAf93ko 3Txg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=FtNP8ggV9yLDfbcYSmXODh6nZac9HheatFlB5fDy0+8=; b=h81xAJ+uJYL479MVXn8NiU0imB8yiAlFNr2wZzTRbM4pZ5S3RROHhdvMHRvUoPpVKA davMEiOEFPYDBtPPy5LiqXitqcVSbjjZCSo9ElWxLlqmSPnJOSLYKG+HB3H7Awfh114Y qva8YUlljov8NW0grvtozXkwZuyw6wU0HQ/NBWBF+BkOuz4HSPfJvELZ5oFiECjRuh2d 7iaSnP0UkpVRZqimxznSPTWcjxxrjDZRPW1IOZCJP4Xc3LosgdHgzqkeF66HLRMA2707 sZPrayFmf+AzOOYyrFxOss3hb2uWurQlK+alnTm9+rd1gIz/HPMMMyiNLrDghA5MDWLx 6yKA== X-Gm-Message-State: AO0yUKUP3Vz7msUybCLdowUDuKkNSenldz7IjlsXCpRgOrz3ut9K51GS jdj/ChMimTE5whskebkPLBibyw== X-Google-Smtp-Source: AK7set8zZzyzOlf1UnH5tiqEGjgBaXq90d9qZ1ymNTTBPjvJN/N75+Uk4L65iH5+NXqp2uiWumGaJw== X-Received: by 2002:a17:902:ecc4:b0:196:8292:e879 with SMTP id a4-20020a170902ecc400b001968292e879mr15728234plh.1.1677147754206; Thu, 23 Feb 2023 02:22:34 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 33/34] net/eth: Report if headers are actually present Date: Thu, 23 Feb 2023 19:20:17 +0900 Message-Id: <20230223102018.141748-34-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102f.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677148005677100001 Content-Type: text/plain; charset="utf-8" The values returned by eth_get_protocols() are used to perform RSS, checksumming and segmentation. Even when a packet signals the use of the protocols which these operations can be applied to, the headers for them may not be present because of too short packet or fragmentation, for example. In such a case, the operations cannot be applied safely. Report the presence of headers instead of whether the use of the protocols are indicated with eth_get_protocols(). This also makes corresponding changes to the callers of eth_get_protocols() to match with its new signature and to remove redundant checks for fragmentation. Fixes: 75020a7021 ("Common definitions for VMWARE devices") Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 65 +++++++++++++++---------------- hw/net/net_rx_pkt.c | 86 ++++++++++++++++++++--------------------- hw/net/net_rx_pkt.h | 12 +++--- hw/net/trace-events | 6 +-- hw/net/virtio-net.c | 32 +++++++--------- hw/net/vmxnet3.c | 20 +++++----- include/net/eth.h | 4 +- net/eth.c | 91 ++++++++++++++++++++------------------------ 8 files changed, 150 insertions(+), 166 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 326b9a166d..a2974631ef 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -497,27 +497,25 @@ typedef struct E1000E_RSSInfo_st { static uint32_t e1000e_rss_get_hash_type(E1000ECore *core, struct NetRxPkt *pkt) { - bool isip4, isip6, isudp, istcp; + bool hasip4, hasip6, hasudp, hastcp; =20 assert(e1000e_rss_enabled(core)); =20 - net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp); + net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &hasudp, &hastcp); =20 - if (isip4) { - bool fragment =3D net_rx_pkt_get_ip4_info(pkt)->fragment; - - trace_e1000e_rx_rss_ip4(fragment, istcp, core->mac[MRQC], + if (hasip4) { + trace_e1000e_rx_rss_ip4(hastcp, core->mac[MRQC], E1000_MRQC_EN_TCPIPV4(core->mac[MRQC]), E1000_MRQC_EN_IPV4(core->mac[MRQC])); =20 - if (!fragment && istcp && E1000_MRQC_EN_TCPIPV4(core->mac[MRQC])) { + if (hastcp && E1000_MRQC_EN_TCPIPV4(core->mac[MRQC])) { return E1000_MRQ_RSS_TYPE_IPV4TCP; } =20 if (E1000_MRQC_EN_IPV4(core->mac[MRQC])) { return E1000_MRQ_RSS_TYPE_IPV4; } - } else if (isip6) { + } else if (hasip6) { eth_ip6_hdr_info *ip6info =3D net_rx_pkt_get_ip6_info(pkt); =20 bool ex_dis =3D core->mac[RFCTL] & E1000_RFCTL_IPV6_EX_DIS; @@ -531,7 +529,7 @@ e1000e_rss_get_hash_type(E1000ECore *core, struct NetRx= Pkt *pkt) * backends like these. */ trace_e1000e_rx_rss_ip6_rfctl(core->mac[RFCTL]); - trace_e1000e_rx_rss_ip6(ex_dis, new_ex_dis, istcp, + trace_e1000e_rx_rss_ip6(ex_dis, new_ex_dis, hastcp, ip6info->has_ext_hdrs, ip6info->rss_ex_dst_valid, ip6info->rss_ex_src_valid, @@ -544,8 +542,7 @@ e1000e_rss_get_hash_type(E1000ECore *core, struct NetRx= Pkt *pkt) (!new_ex_dis || !(ip6info->rss_ex_dst_valid || ip6info->rss_ex_src_valid))) { =20 - if (istcp && !ip6info->fragment && - E1000_MRQC_EN_TCPIPV6(core->mac[MRQC])) { + if (hastcp && E1000_MRQC_EN_TCPIPV6(core->mac[MRQC])) { return E1000_MRQ_RSS_TYPE_IPV6TCP; } =20 @@ -1127,7 +1124,7 @@ static void e1000e_verify_csum_in_sw(E1000ECore *core, struct NetRxPkt *pkt, uint32_t *status_flags, - bool istcp, bool isudp) + bool hastcp, bool hasudp) { bool csum_valid; uint32_t csum_error; @@ -1155,10 +1152,10 @@ e1000e_verify_csum_in_sw(E1000ECore *core, =20 csum_error =3D csum_valid ? 0 : E1000_RXDEXT_STATERR_TCPE; =20 - if (istcp) { + if (hastcp) { *status_flags |=3D E1000_RXD_STAT_TCPCS | csum_error; - } else if (isudp) { + } else if (hasudp) { *status_flags |=3D E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS | csum_error; @@ -1190,7 +1187,7 @@ e1000e_build_rx_metadata(E1000ECore *core, uint16_t *vlan_tag) { struct virtio_net_hdr *vhdr; - bool isip4, isip6, istcp, isudp; + bool hasip4, hasip6, hastcp, hasudp; uint32_t pkt_type; =20 *status_flags =3D E1000_RXD_STAT_DD; @@ -1202,8 +1199,8 @@ e1000e_build_rx_metadata(E1000ECore *core, =20 *status_flags |=3D E1000_RXD_STAT_EOP; =20 - net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp); - trace_e1000e_rx_metadata_protocols(isip4, isip6, isudp, istcp); + net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &hasudp, &hastcp); + trace_e1000e_rx_metadata_protocols(hasip4, hasip6, hasudp, hastcp); =20 /* VLAN state */ if (net_rx_pkt_is_vlan_stripped(pkt)) { @@ -1219,24 +1216,24 @@ e1000e_build_rx_metadata(E1000ECore *core, *mrq =3D cpu_to_le32(rss_info->type | (rss_info->queue << 8)); trace_e1000e_rx_metadata_rss(*rss, *mrq); } - } else if (isip4) { + } else if (hasip4) { *status_flags |=3D E1000_RXD_STAT_IPIDV; *ip_id =3D cpu_to_le16(net_rx_pkt_get_ip_id(pkt)); trace_e1000e_rx_metadata_ip_id(*ip_id); } =20 - if (istcp && e1000e_is_tcp_ack(core, pkt)) { + if (hastcp && e1000e_is_tcp_ack(core, pkt)) { *status_flags |=3D E1000_RXD_STAT_ACK; trace_e1000e_rx_metadata_ack(); } =20 - if (isip6 && (core->mac[RFCTL] & E1000_RFCTL_IPV6_DIS)) { + if (hasip6 && (core->mac[RFCTL] & E1000_RFCTL_IPV6_DIS)) { trace_e1000e_rx_metadata_ipv6_filtering_disabled(); pkt_type =3D E1000_RXD_PKT_MAC; - } else if (istcp || isudp) { - pkt_type =3D isip4 ? E1000_RXD_PKT_IP4_XDP : E1000_RXD_PKT_IP6_XDP; - } else if (isip4 || isip6) { - pkt_type =3D isip4 ? E1000_RXD_PKT_IP4 : E1000_RXD_PKT_IP6; + } else if (hastcp || hasudp) { + pkt_type =3D hasip4 ? E1000_RXD_PKT_IP4_XDP : E1000_RXD_PKT_IP6_XD= P; + } else if (hasip4 || hasip6) { + pkt_type =3D hasip4 ? E1000_RXD_PKT_IP4 : E1000_RXD_PKT_IP6; } else { pkt_type =3D E1000_RXD_PKT_MAC; } @@ -1245,7 +1242,7 @@ e1000e_build_rx_metadata(E1000ECore *core, trace_e1000e_rx_metadata_pkt_type(pkt_type); =20 /* RX CSO information */ - if (isip6 && (core->mac[RFCTL] & E1000_RFCTL_IPV6_XSUM_DIS)) { + if (hasip6 && (core->mac[RFCTL] & E1000_RFCTL_IPV6_XSUM_DIS)) { trace_e1000e_rx_metadata_ipv6_sum_disabled(); goto func_exit; } @@ -1255,20 +1252,20 @@ e1000e_build_rx_metadata(E1000ECore *core, if (!(vhdr->flags & VIRTIO_NET_HDR_F_DATA_VALID) && !(vhdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM)) { trace_e1000e_rx_metadata_virthdr_no_csum_info(); - e1000e_verify_csum_in_sw(core, pkt, status_flags, istcp, isudp); + e1000e_verify_csum_in_sw(core, pkt, status_flags, hastcp, hasudp); goto func_exit; } =20 if (e1000e_rx_l3_cso_enabled(core)) { - *status_flags |=3D isip4 ? E1000_RXD_STAT_IPCS : 0; + *status_flags |=3D hasip4 ? E1000_RXD_STAT_IPCS : 0; } else { trace_e1000e_rx_metadata_l3_cso_disabled(); } =20 if (e1000e_rx_l4_cso_enabled(core)) { - if (istcp) { + if (hastcp) { *status_flags |=3D E1000_RXD_STAT_TCPCS; - } else if (isudp) { + } else if (hasudp) { *status_flags |=3D E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS; } } else { @@ -1512,18 +1509,18 @@ e1000e_rx_descr_threshold_hit(E1000ECore *core, con= st E1000E_RingInfo *rxi) static bool e1000e_do_ps(E1000ECore *core, struct NetRxPkt *pkt, size_t *hdr_len) { - bool isip4, isip6, isudp, istcp; + bool hasip4, hasip6, hasudp, hastcp; bool fragment; =20 if (!e1000e_rx_use_ps_descriptor(core)) { return false; } =20 - net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp); + net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &hasudp, &hastcp); =20 - if (isip4) { + if (hasip4) { fragment =3D net_rx_pkt_get_ip4_info(pkt)->fragment; - } else if (isip6) { + } else if (hasip6) { fragment =3D net_rx_pkt_get_ip6_info(pkt)->fragment; } else { return false; @@ -1533,7 +1530,7 @@ e1000e_do_ps(E1000ECore *core, struct NetRxPkt *pkt, = size_t *hdr_len) return false; } =20 - if (!fragment && (isudp || istcp)) { + if (hasudp || hastcp) { *hdr_len =3D net_rx_pkt_get_l5_hdr_offset(pkt); } else { *hdr_len =3D net_rx_pkt_get_l4_hdr_offset(pkt); diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c index a53e7561c5..0bbe662eb2 100644 --- a/hw/net/net_rx_pkt.c +++ b/hw/net/net_rx_pkt.c @@ -33,10 +33,10 @@ struct NetRxPkt { eth_pkt_types_e packet_type; =20 /* Analysis results */ - bool isip4; - bool isip6; - bool isudp; - bool istcp; + bool hasip4; + bool hasip6; + bool hasudp; + bool hastcp; =20 size_t l3hdr_off; size_t l4hdr_off; @@ -105,12 +105,12 @@ net_rx_pkt_pull_data(struct NetRxPkt *pkt, iov, iovcnt, ploff, pkt->tot_len); } =20 - eth_get_protocols(pkt->vec, pkt->vec_len, &pkt->isip4, &pkt->isip6, - &pkt->isudp, &pkt->istcp, + eth_get_protocols(pkt->vec, pkt->vec_len, &pkt->hasip4, &pkt->hasip6, + &pkt->hasudp, &pkt->hastcp, &pkt->l3hdr_off, &pkt->l4hdr_off, &pkt->l5hdr_off, &pkt->ip6hdr_info, &pkt->ip4hdr_info, &pkt->l4hdr_in= fo); =20 - trace_net_rx_pkt_parsed(pkt->isip4, pkt->isip6, pkt->isudp, pkt->istcp, + trace_net_rx_pkt_parsed(pkt->hasip4, pkt->hasip6, pkt->hasudp, pkt->ha= stcp, pkt->l3hdr_off, pkt->l4hdr_off, pkt->l5hdr_off= ); } =20 @@ -199,22 +199,22 @@ void net_rx_pkt_set_protocols(struct NetRxPkt *pkt, c= onst void *data, =20 assert(pkt); =20 - eth_get_protocols(&iov, 1, &pkt->isip4, &pkt->isip6, - &pkt->isudp, &pkt->istcp, + eth_get_protocols(&iov, 1, &pkt->hasip4, &pkt->hasip6, + &pkt->hasudp, &pkt->hastcp, &pkt->l3hdr_off, &pkt->l4hdr_off, &pkt->l5hdr_off, &pkt->ip6hdr_info, &pkt->ip4hdr_info, &pkt->l4hdr_in= fo); } =20 void net_rx_pkt_get_protocols(struct NetRxPkt *pkt, - bool *isip4, bool *isip6, - bool *isudp, bool *istcp) + bool *hasip4, bool *hasip6, + bool *hasudp, bool *hastcp) { assert(pkt); =20 - *isip4 =3D pkt->isip4; - *isip6 =3D pkt->isip6; - *isudp =3D pkt->isudp; - *istcp =3D pkt->istcp; + *hasip4 =3D pkt->hasip4; + *hasip6 =3D pkt->hasip6; + *hasudp =3D pkt->hasudp; + *hastcp =3D pkt->hastcp; } =20 size_t net_rx_pkt_get_l3_hdr_offset(struct NetRxPkt *pkt) @@ -331,58 +331,58 @@ net_rx_pkt_calc_rss_hash(struct NetRxPkt *pkt, =20 switch (type) { case NetPktRssIpV4: - assert(pkt->isip4); + assert(pkt->hasip4); trace_net_rx_pkt_rss_ip4(); _net_rx_rss_prepare_ip4(&rss_input[0], pkt, &rss_length); break; case NetPktRssIpV4Tcp: - assert(pkt->isip4); - assert(pkt->istcp); + assert(pkt->hasip4); + assert(pkt->hastcp); trace_net_rx_pkt_rss_ip4_tcp(); _net_rx_rss_prepare_ip4(&rss_input[0], pkt, &rss_length); _net_rx_rss_prepare_tcp(&rss_input[0], pkt, &rss_length); break; case NetPktRssIpV6Tcp: - assert(pkt->isip6); - assert(pkt->istcp); + assert(pkt->hasip6); + assert(pkt->hastcp); trace_net_rx_pkt_rss_ip6_tcp(); _net_rx_rss_prepare_ip6(&rss_input[0], pkt, false, &rss_length); _net_rx_rss_prepare_tcp(&rss_input[0], pkt, &rss_length); break; case NetPktRssIpV6: - assert(pkt->isip6); + assert(pkt->hasip6); trace_net_rx_pkt_rss_ip6(); _net_rx_rss_prepare_ip6(&rss_input[0], pkt, false, &rss_length); break; case NetPktRssIpV6Ex: - assert(pkt->isip6); + assert(pkt->hasip6); trace_net_rx_pkt_rss_ip6_ex(); _net_rx_rss_prepare_ip6(&rss_input[0], pkt, true, &rss_length); break; case NetPktRssIpV6TcpEx: - assert(pkt->isip6); - assert(pkt->istcp); + assert(pkt->hasip6); + assert(pkt->hastcp); trace_net_rx_pkt_rss_ip6_ex_tcp(); _net_rx_rss_prepare_ip6(&rss_input[0], pkt, true, &rss_length); _net_rx_rss_prepare_tcp(&rss_input[0], pkt, &rss_length); break; case NetPktRssIpV4Udp: - assert(pkt->isip4); - assert(pkt->isudp); + assert(pkt->hasip4); + assert(pkt->hasudp); trace_net_rx_pkt_rss_ip4_udp(); _net_rx_rss_prepare_ip4(&rss_input[0], pkt, &rss_length); _net_rx_rss_prepare_udp(&rss_input[0], pkt, &rss_length); break; case NetPktRssIpV6Udp: - assert(pkt->isip6); - assert(pkt->isudp); + assert(pkt->hasip6); + assert(pkt->hasudp); trace_net_rx_pkt_rss_ip6_udp(); _net_rx_rss_prepare_ip6(&rss_input[0], pkt, false, &rss_length); _net_rx_rss_prepare_udp(&rss_input[0], pkt, &rss_length); break; case NetPktRssIpV6UdpEx: - assert(pkt->isip6); - assert(pkt->isudp); + assert(pkt->hasip6); + assert(pkt->hasudp); trace_net_rx_pkt_rss_ip6_ex_udp(); _net_rx_rss_prepare_ip6(&rss_input[0], pkt, true, &rss_length); _net_rx_rss_prepare_udp(&rss_input[0], pkt, &rss_length); @@ -404,7 +404,7 @@ uint16_t net_rx_pkt_get_ip_id(struct NetRxPkt *pkt) { assert(pkt); =20 - if (pkt->isip4) { + if (pkt->hasip4) { return be16_to_cpu(pkt->ip4hdr_info.ip4_hdr.ip_id); } =20 @@ -415,7 +415,7 @@ bool net_rx_pkt_is_tcp_ack(struct NetRxPkt *pkt) { assert(pkt); =20 - if (pkt->istcp) { + if (pkt->hastcp) { return TCP_HEADER_FLAGS(&pkt->l4hdr_info.hdr.tcp) & TCP_FLAG_ACK; } =20 @@ -426,7 +426,7 @@ bool net_rx_pkt_has_tcp_data(struct NetRxPkt *pkt) { assert(pkt); =20 - if (pkt->istcp) { + if (pkt->hastcp) { return pkt->l4hdr_info.has_tcp_data; } =20 @@ -492,7 +492,7 @@ bool net_rx_pkt_validate_l3_csum(struct NetRxPkt *pkt, = bool *csum_valid) =20 trace_net_rx_pkt_l3_csum_validate_entry(); =20 - if (!pkt->isip4) { + if (!pkt->hasip4) { trace_net_rx_pkt_l3_csum_validate_not_ip4(); return false; } @@ -523,8 +523,8 @@ _net_rx_pkt_calc_l4_csum(struct NetRxPkt *pkt) =20 trace_net_rx_pkt_l4_csum_calc_entry(); =20 - if (pkt->isip4) { - if (pkt->isudp) { + if (pkt->hasip4) { + if (pkt->hasudp) { csl =3D be16_to_cpu(pkt->l4hdr_info.hdr.udp.uh_ulen); trace_net_rx_pkt_l4_csum_calc_ip4_udp(); } else { @@ -537,7 +537,7 @@ _net_rx_pkt_calc_l4_csum(struct NetRxPkt *pkt) csl, &cso); trace_net_rx_pkt_l4_csum_calc_ph_csum(cntr, csl); } else { - if (pkt->isudp) { + if (pkt->hasudp) { csl =3D be16_to_cpu(pkt->l4hdr_info.hdr.udp.uh_ulen); trace_net_rx_pkt_l4_csum_calc_ip6_udp(); } else { @@ -571,17 +571,17 @@ bool net_rx_pkt_validate_l4_csum(struct NetRxPkt *pkt= , bool *csum_valid) =20 trace_net_rx_pkt_l4_csum_validate_entry(); =20 - if (!pkt->istcp && !pkt->isudp) { + if (!pkt->hastcp && !pkt->hasudp) { trace_net_rx_pkt_l4_csum_validate_not_xxp(); return false; } =20 - if (pkt->isudp && (pkt->l4hdr_info.hdr.udp.uh_sum =3D=3D 0)) { + if (pkt->hasudp && (pkt->l4hdr_info.hdr.udp.uh_sum =3D=3D 0)) { trace_net_rx_pkt_l4_csum_validate_udp_with_no_checksum(); return false; } =20 - if (pkt->isip4 && pkt->ip4hdr_info.fragment) { + if (pkt->hasip4 && pkt->ip4hdr_info.fragment) { trace_net_rx_pkt_l4_csum_validate_ip4_fragment(); return false; } @@ -602,10 +602,10 @@ bool net_rx_pkt_fix_l4_csum(struct NetRxPkt *pkt) =20 trace_net_rx_pkt_l4_csum_fix_entry(); =20 - if (pkt->istcp) { + if (pkt->hastcp) { l4_cso =3D offsetof(struct tcp_header, th_sum); trace_net_rx_pkt_l4_csum_fix_tcp(l4_cso); - } else if (pkt->isudp) { + } else if (pkt->hasudp) { if (pkt->l4hdr_info.hdr.udp.uh_sum =3D=3D 0) { trace_net_rx_pkt_l4_csum_fix_udp_with_no_checksum(); return false; @@ -617,7 +617,7 @@ bool net_rx_pkt_fix_l4_csum(struct NetRxPkt *pkt) return false; } =20 - if (pkt->isip4 && pkt->ip4hdr_info.fragment) { + if (pkt->hasip4 && pkt->ip4hdr_info.fragment) { trace_net_rx_pkt_l4_csum_fix_ip4_fragment(); return false; } diff --git a/hw/net/net_rx_pkt.h b/hw/net/net_rx_pkt.h index 8b69ddb2da..cf9bb790f2 100644 --- a/hw/net/net_rx_pkt.h +++ b/hw/net/net_rx_pkt.h @@ -66,15 +66,15 @@ void net_rx_pkt_set_protocols(struct NetRxPkt *pkt, con= st void *data, * fetches packet analysis results * * @pkt: packet - * @isip4: whether the packet given is IPv4 - * @isip6: whether the packet given is IPv6 - * @isudp: whether the packet given is UDP - * @istcp: whether the packet given is TCP + * @hasip4: whether the packet has an IPv4 header + * @hasip6: whether the packet has an IPv6 header + * @hasudp: whether the packet has a UDP header + * @hastcp: whether the packet has a TCP header * */ void net_rx_pkt_get_protocols(struct NetRxPkt *pkt, - bool *isip4, bool *isip6, - bool *isudp, bool *istcp); + bool *hasip4, bool *hasip6, + bool *hasudp, bool *hastcp); =20 /** * fetches L3 header offset diff --git a/hw/net/trace-events b/hw/net/trace-events index d24ba945dc..9fb0544d72 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -177,11 +177,11 @@ e1000e_rx_start_recv(void) e1000e_rx_rss_started(void) "Starting RSS processing" e1000e_rx_rss_disabled(void) "RSS is disabled" e1000e_rx_rss_type(uint32_t type) "RSS type is %u" -e1000e_rx_rss_ip4(bool isfragment, bool istcp, uint32_t mrqc, bool tcpipv4= _enabled, bool ipv4_enabled) "RSS IPv4: fragment %d, tcp %d, mrqc 0x%X, tcp= ipv4 enabled %d, ipv4 enabled %d" +e1000e_rx_rss_ip4(bool hastcp, uint32_t mrqc, bool tcpipv4_enabled, bool i= pv4_enabled) "RSS IPv4: tcp %d, mrqc 0x%X, tcpipv4 enabled %d, ipv4 enabled= %d" e1000e_rx_rss_ip6_rfctl(uint32_t rfctl) "RSS IPv6: rfctl 0x%X" -e1000e_rx_rss_ip6(bool ex_dis, bool new_ex_dis, bool istcp, bool has_ext_h= eaders, bool ex_dst_valid, bool ex_src_valid, uint32_t mrqc, bool tcpipv6_e= nabled, bool ipv6ex_enabled, bool ipv6_enabled) "RSS IPv6: ex_dis: %d, new_= ex_dis: %d, tcp %d, has_ext_headers %d, ex_dst_valid %d, ex_src_valid %d, m= rqc 0x%X, tcpipv6 enabled %d, ipv6ex enabled %d, ipv6 enabled %d" +e1000e_rx_rss_ip6(bool ex_dis, bool new_ex_dis, bool hastcp, bool has_ext_= headers, bool ex_dst_valid, bool ex_src_valid, uint32_t mrqc, bool tcpipv6_= enabled, bool ipv6ex_enabled, bool ipv6_enabled) "RSS IPv6: ex_dis: %d, new= _ex_dis: %d, tcp %d, has_ext_headers %d, ex_dst_valid %d, ex_src_valid %d, = mrqc 0x%X, tcpipv6 enabled %d, ipv6ex enabled %d, ipv6 enabled %d" =20 -e1000e_rx_metadata_protocols(bool isip4, bool isip6, bool isudp, bool istc= p) "protocols: ip4: %d, ip6: %d, udp: %d, tcp: %d" +e1000e_rx_metadata_protocols(bool hasip4, bool hasip6, bool hasudp, bool h= astcp) "protocols: ip4: %d, ip6: %d, udp: %d, tcp: %d" e1000e_rx_metadata_vlan(uint16_t vlan_tag) "VLAN tag is 0x%X" e1000e_rx_metadata_rss(uint32_t rss, uint32_t mrq) "RSS data: rss: 0x%X, m= rq: 0x%X" e1000e_rx_metadata_ip_id(uint16_t ip_id) "the IPv4 ID is 0x%X" diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 1795e1aa7d..e6067df343 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1731,32 +1731,32 @@ static int receive_filter(VirtIONet *n, const uint8= _t *buf, int size) return 0; } =20 -static uint8_t virtio_net_get_hash_type(bool isip4, - bool isip6, - bool isudp, - bool istcp, +static uint8_t virtio_net_get_hash_type(bool hasip4, + bool hasip6, + bool hasudp, + bool hastcp, uint32_t types) { - if (isip4) { - if (istcp && (types & VIRTIO_NET_RSS_HASH_TYPE_TCPv4)) { + if (hasip4) { + if (hastcp && (types & VIRTIO_NET_RSS_HASH_TYPE_TCPv4)) { return NetPktRssIpV4Tcp; } - if (isudp && (types & VIRTIO_NET_RSS_HASH_TYPE_UDPv4)) { + if (hasudp && (types & VIRTIO_NET_RSS_HASH_TYPE_UDPv4)) { return NetPktRssIpV4Udp; } if (types & VIRTIO_NET_RSS_HASH_TYPE_IPv4) { return NetPktRssIpV4; } - } else if (isip6) { + } else if (hasip6) { uint32_t mask =3D VIRTIO_NET_RSS_HASH_TYPE_TCP_EX | VIRTIO_NET_RSS_HASH_TYPE_TCPv6; =20 - if (istcp && (types & mask)) { + if (hastcp && (types & mask)) { return (types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) ? NetPktRssIpV6TcpEx : NetPktRssIpV6Tcp; } mask =3D VIRTIO_NET_RSS_HASH_TYPE_UDP_EX | VIRTIO_NET_RSS_HASH_TYP= E_UDPv6; - if (isudp && (types & mask)) { + if (hasudp && (types & mask)) { return (types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) ? NetPktRssIpV6UdpEx : NetPktRssIpV6Udp; } @@ -1785,7 +1785,7 @@ static int virtio_net_process_rss(NetClientState *nc,= const uint8_t *buf, struct NetRxPkt *pkt =3D n->rx_pkt; uint8_t net_hash_type; uint32_t hash; - bool isip4, isip6, isudp, istcp; + bool hasip4, hasip6, hasudp, hastcp; static const uint8_t reports[NetPktRssIpV6UdpEx + 1] =3D { VIRTIO_NET_HASH_REPORT_IPv4, VIRTIO_NET_HASH_REPORT_TCPv4, @@ -1800,14 +1800,8 @@ static int virtio_net_process_rss(NetClientState *nc= , const uint8_t *buf, =20 net_rx_pkt_set_protocols(pkt, buf + n->host_hdr_len, size - n->host_hdr_len); - net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp); - if (isip4 && (net_rx_pkt_get_ip4_info(pkt)->fragment)) { - istcp =3D isudp =3D false; - } - if (isip6 && (net_rx_pkt_get_ip6_info(pkt)->fragment)) { - istcp =3D isudp =3D false; - } - net_hash_type =3D virtio_net_get_hash_type(isip4, isip6, isudp, istcp, + net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &hasudp, &hastcp); + net_hash_type =3D virtio_net_get_hash_type(hasip4, hasip6, hasudp, has= tcp, n->rss_data.hash_types); if (net_hash_type > NetPktRssIpV6UdpEx) { if (n->rss_data.populate_hash) { diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 6c6bb2ac37..4d65327732 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -847,7 +847,7 @@ static void vmxnet3_rx_need_csum_calculate(struct NetRx= Pkt *pkt, size_t pkt_len) { struct virtio_net_hdr *vhdr; - bool isip4, isip6, istcp, isudp; + bool hasip4, hasip6, hastcp, hasudp; uint8_t *data; int len; =20 @@ -856,8 +856,8 @@ static void vmxnet3_rx_need_csum_calculate(struct NetRx= Pkt *pkt, return; } =20 - net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp); - if (!(isip4 || isip6) || !(istcp || isudp)) { + net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &hasudp, &hastcp); + if (!(hasip4 || hasip6) || !(hastcp || hasudp)) { return; } =20 @@ -885,7 +885,7 @@ static void vmxnet3_rx_update_descr(struct NetRxPkt *pk= t, struct Vmxnet3_RxCompDesc *rxcd) { int csum_ok, is_gso; - bool isip4, isip6, istcp, isudp; + bool hasip4, hasip6, hastcp, hasudp; struct virtio_net_hdr *vhdr; uint8_t offload_type; =20 @@ -911,16 +911,16 @@ static void vmxnet3_rx_update_descr(struct NetRxPkt *= pkt, goto nocsum; } =20 - net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp); - if ((!istcp && !isudp) || (!isip4 && !isip6)) { + net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &hasudp, &hastcp); + if ((!hastcp && !hasudp) || (!hasip4 && !hasip6)) { goto nocsum; } =20 rxcd->cnc =3D 0; - rxcd->v4 =3D isip4 ? 1 : 0; - rxcd->v6 =3D isip6 ? 1 : 0; - rxcd->tcp =3D istcp ? 1 : 0; - rxcd->udp =3D isudp ? 1 : 0; + rxcd->v4 =3D hasip4 ? 1 : 0; + rxcd->v6 =3D hasip6 ? 1 : 0; + rxcd->tcp =3D hastcp ? 1 : 0; + rxcd->udp =3D hasudp ? 1 : 0; rxcd->fcs =3D rxcd->tuc =3D rxcd->ipc =3D 1; return; =20 diff --git a/include/net/eth.h b/include/net/eth.h index 2b4374fae4..fbac30cf60 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -391,8 +391,8 @@ typedef struct eth_l4_hdr_info_st { } eth_l4_hdr_info; =20 void eth_get_protocols(const struct iovec *iov, int iovcnt, - bool *isip4, bool *isip6, - bool *isudp, bool *istcp, + bool *hasip4, bool *hasip6, + bool *hasudp, bool *hastcp, size_t *l3hdr_off, size_t *l4hdr_off, size_t *l5hdr_off, diff --git a/net/eth.c b/net/eth.c index 36d39b4357..c1c14cf6b9 100644 --- a/net/eth.c +++ b/net/eth.c @@ -137,8 +137,8 @@ _eth_tcp_has_data(bool is_ip4, } =20 void eth_get_protocols(const struct iovec *iov, int iovcnt, - bool *isip4, bool *isip6, - bool *isudp, bool *istcp, + bool *hasip4, bool *hasip6, + bool *hasudp, bool *hastcp, size_t *l3hdr_off, size_t *l4hdr_off, size_t *l5hdr_off, @@ -151,8 +151,9 @@ void eth_get_protocols(const struct iovec *iov, int iov= cnt, size_t l2hdr_len =3D eth_get_l2_hdr_length_iov(iov, iovcnt); size_t input_size =3D iov_size(iov, iovcnt); size_t copied; + uint8_t ip_p; =20 - *isip4 =3D *isip6 =3D *isudp =3D *istcp =3D false; + *hasip4 =3D *hasip6 =3D *hasudp =3D *hastcp =3D false; =20 proto =3D eth_get_l3_proto(iov, iovcnt, l2hdr_len); =20 @@ -166,68 +167,60 @@ void eth_get_protocols(const struct iovec *iov, int i= ovcnt, } =20 copied =3D iov_to_buf(iov, iovcnt, l2hdr_len, iphdr, sizeof(*iphdr= )); - - *isip4 =3D true; - - if (copied < sizeof(*iphdr)) { + if (copied < sizeof(*iphdr) || + IP_HEADER_VERSION(iphdr) !=3D IP_HEADER_VERSION_4) { return; } =20 - if (IP_HEADER_VERSION(iphdr) =3D=3D IP_HEADER_VERSION_4) { - if (iphdr->ip_p =3D=3D IP_PROTO_TCP) { - *istcp =3D true; - } else if (iphdr->ip_p =3D=3D IP_PROTO_UDP) { - *isudp =3D true; - } - } - + *hasip4 =3D true; + ip_p =3D iphdr->ip_p; ip4hdr_info->fragment =3D IP4_IS_FRAGMENT(iphdr); *l4hdr_off =3D l2hdr_len + IP_HDR_GET_LEN(iphdr); =20 fragment =3D ip4hdr_info->fragment; } else if (proto =3D=3D ETH_P_IPV6) { - - *isip6 =3D true; - if (eth_parse_ipv6_hdr(iov, iovcnt, l2hdr_len, - ip6hdr_info)) { - if (ip6hdr_info->l4proto =3D=3D IP_PROTO_TCP) { - *istcp =3D true; - } else if (ip6hdr_info->l4proto =3D=3D IP_PROTO_UDP) { - *isudp =3D true; - } - } else { + if (!eth_parse_ipv6_hdr(iov, iovcnt, l2hdr_len, ip6hdr_info)) { return; } =20 + *hasip6 =3D true; + ip_p =3D ip6hdr_info->l4proto; *l4hdr_off =3D l2hdr_len + ip6hdr_info->full_hdr_len; fragment =3D ip6hdr_info->fragment; + } else { + return; } =20 - if (!fragment) { - if (*istcp) { - *istcp =3D _eth_copy_chunk(input_size, - iov, iovcnt, - *l4hdr_off, sizeof(l4hdr_info->hdr.tc= p), - &l4hdr_info->hdr.tcp); - - if (*istcp) { - *l5hdr_off =3D *l4hdr_off + - TCP_HEADER_DATA_OFFSET(&l4hdr_info->hdr.tcp); - - l4hdr_info->has_tcp_data =3D - _eth_tcp_has_data(proto =3D=3D ETH_P_IP, - &ip4hdr_info->ip4_hdr, - &ip6hdr_info->ip6_hdr, - *l4hdr_off - *l3hdr_off, - &l4hdr_info->hdr.tcp); - } - } else if (*isudp) { - *isudp =3D _eth_copy_chunk(input_size, - iov, iovcnt, - *l4hdr_off, sizeof(l4hdr_info->hdr.ud= p), - &l4hdr_info->hdr.udp); - *l5hdr_off =3D *l4hdr_off + sizeof(l4hdr_info->hdr.udp); + if (fragment) { + return; + } + + switch (ip_p) { + case IP_PROTO_TCP: + *hastcp =3D _eth_copy_chunk(input_size, + iov, iovcnt, + *l4hdr_off, sizeof(l4hdr_info->hdr.tcp), + &l4hdr_info->hdr.tcp); + if (*hastcp) { + *l5hdr_off =3D *l4hdr_off + + TCP_HEADER_DATA_OFFSET(&l4hdr_info->hdr.tcp); + + l4hdr_info->has_tcp_data =3D + _eth_tcp_has_data(proto =3D=3D ETH_P_IP, + &ip4hdr_info->ip4_hdr, + &ip6hdr_info->ip6_hdr, + *l4hdr_off - *l3hdr_off, + &l4hdr_info->hdr.tcp); } + break; + + case IP_PROTO_UDP: + *hasudp =3D _eth_copy_chunk(input_size, + iov, iovcnt, + *l4hdr_off, sizeof(l4hdr_info->hdr.udp), + &l4hdr_info->hdr.udp); + *l5hdr_off =3D *l4hdr_off + sizeof(l4hdr_info->hdr.udp); + break; } } =20 --=20 2.39.1 From nobody Sun May 5 04:44:09 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677147916; cv=none; d=zohomail.com; s=zohoarc; b=WeV8IuC8DnNc/zAFFF+Id1UvYsOQTAH8Ga6fz2XR9WEDRxEHtJiKIEDEZeZje1u/vgFQGUh7GN+mGfu+6RO1c/mXrPSVJmmCHJKuorKvtMHqDeN8NnfNEv2rqyNHB5FraVZNgiRX23DMgaJTAgmjD/lw3eCnkC/rdlOx2LDyXjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677147916; 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=Wug6Iy1NosnQ9gqQ/P6iPpBTYZU2rrUMrqjSH7oT2gw=; b=dJjMQr3juEmLR2t/qauLqxw0iTsMjm7HUInHA3c9cPTti3+u+LHMe2x0XxIwN3VxpTwn+/HbADO+PGLilWHdUOiG/odtW0UJPM/oZgQOZb0NEQFabc07AKVEViXd8ieWeHpqADGgVCUlGAWeTi3mEXANMgNLPEiYMBOqjzaPuQE= 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+importer2=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 1677147916767319.4150993213493; Thu, 23 Feb 2023 02:25:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pV8kM-0008TL-5H; Thu, 23 Feb 2023 05:22:42 -0500 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 1pV8kK-0008Ny-50 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:40 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pV8kI-0002ml-3A for qemu-devel@nongnu.org; Thu, 23 Feb 2023 05:22:39 -0500 Received: by mail-pj1-x1034.google.com with SMTP id gi3-20020a17090b110300b0023762f642dcso1537992pjb.4 for ; Thu, 23 Feb 2023 02:22:37 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b00196217f1219sm4107734plc.70.2023.02.23.02.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 02:22:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; 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=Wug6Iy1NosnQ9gqQ/P6iPpBTYZU2rrUMrqjSH7oT2gw=; b=oEp8xxitenjoFcmvSgzc+gdV56T7GdmiKyJh/2pYFJYAgemyQ93Rj1eH3cQCxOdQeT 6EoS0Y3CTNaIxi/exZdiUCFGGgC72CPNuW0Z99v93wM+6E6J/rs9UfyjTZ/9wL4rUkBv RmIYfmw2rYSDLiOLTvKUiFEjLOLntitPR132xLxyGNOrxore820YaLML9wgHH9Cl/3v8 Ou9k5WTNq2qrXA0Tw2K+0Mv0QzAn4y/7+sylXMBrEoi+4Bky3WARTJLHbV5imXu2kqdz eF/eeFqVJl932ir9t5cVr0YilmtCXpU4qwoKBq6nMEw6alUuZR1fbbaUXiiy37dYa5nr 3XKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Wug6Iy1NosnQ9gqQ/P6iPpBTYZU2rrUMrqjSH7oT2gw=; b=h1eZjGLnPRLBBE05U0kSHSGESFT2dRPaiaf30xSnPcO9uHrBCqW0UPAy/JsX8GdVLy bS3n4GmB0oCi9EaNTxIBDpBXshtEqS19utNMumBqb3+NEIGjb56xsLYdMvEMmriW9tgt uPXalp4kXXO+9W1efyR8iAIbxa7AXyns2nUdvFpao/Wtnhlbaa5gwcHOjIsvWB1RzGEg AchNjksfJ7XGGOFyhy8Ce7aqmj6kHxbsWytIqeQS6jApgjl4D1a59IAcoS63e81R19KL NdJ+zLSMu+jvvYnEAOm8IUu3BQaL0+kKJRad0nL6LGFyhWN1GLqk3IdBsHfodEKgtFco CO7g== X-Gm-Message-State: AO0yUKUCXei9Mepwg9/uFM6+eFIBwP8KOdnVBb2h6fWEHuJ39aC2EA/s G7+cfVy55vpc9X2U8ndOfnH6Ew== X-Google-Smtp-Source: AK7set/dgss0GcAIO8kNtpDPVrBpRNBf6k2vdyh1TcVy9pk8/jM1JbDEJV1sn644zXc8zomDEfyqtg== X-Received: by 2002:a17:902:aa07:b0:19c:a6ba:69f6 with SMTP id be7-20020a170902aa0700b0019ca6ba69f6mr4307814plb.31.1677147757362; Thu, 23 Feb 2023 02:22:37 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v6 34/34] e1000e: Implement system clock Date: Thu, 23 Feb 2023 19:20:18 +0900 Message-Id: <20230223102018.141748-35-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223102018.141748-1-akihiko.odaki@daynix.com> References: <20230223102018.141748-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1034; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1034.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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1677147917204100005 Content-Type: text/plain; charset="utf-8" The system clock is necessary to implement PTP features. While we are not implementing PTP features for e1000e yet, we do have a plan to implement them for igb, a new network device derived from e1000e, so add system clock to the common base first. Signed-off-by: Akihiko Odaki --- hw/core/machine.c | 1 + hw/net/e1000_regs.h | 27 +++++++++++++++++++++++++++ hw/net/e1000e.c | 11 +++++++++++ hw/net/e1000e_core.c | 39 ++++++++++++++++++++++++++++++++++----- hw/net/e1000e_core.h | 2 ++ hw/net/e1000x_common.c | 25 +++++++++++++++++++++++++ hw/net/e1000x_common.h | 3 +++ 7 files changed, 103 insertions(+), 5 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index f73fc4c45c..d438bfcd5b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -41,6 +41,7 @@ #include "hw/virtio/virtio-pci.h" =20 GlobalProperty hw_compat_7_2[] =3D { + { "e1000e", "migrate-timadj", "off" }, { "virtio-mem", "x-early-migration", "false" }, }; const size_t hw_compat_7_2_len =3D G_N_ELEMENTS(hw_compat_7_2); diff --git a/hw/net/e1000_regs.h b/hw/net/e1000_regs.h index 4545fe25a6..77144cb617 100644 --- a/hw/net/e1000_regs.h +++ b/hw/net/e1000_regs.h @@ -908,6 +908,33 @@ #define E1000_EEPROM_CFG_DONE 0x00040000 /* MNG config cycle don= e */ #define E1000_EEPROM_CFG_DONE_PORT_1 0x00080000 /* ...for second port */ =20 +/* HH Time Sync */ +#define E1000_TSYNCTXCTL_MAX_ALLOWED_DLY_MASK 0x0000F000 /* max delay */ +#define E1000_TSYNCTXCTL_SYNC_COMP 0x40000000 /* sync complete = */ +#define E1000_TSYNCTXCTL_START_SYNC 0x80000000 /* initiate sync = */ + +#define E1000_TSYNCTXCTL_VALID 0x00000001 /* Tx timestamp v= alid */ +#define E1000_TSYNCTXCTL_ENABLED 0x00000010 /* enable Tx time= stamping */ + +#define E1000_TSYNCRXCTL_VALID 0x00000001 /* Rx timestamp v= alid */ +#define E1000_TSYNCRXCTL_TYPE_MASK 0x0000000E /* Rx type mask */ +#define E1000_TSYNCRXCTL_TYPE_L2_V2 0x00 +#define E1000_TSYNCRXCTL_TYPE_L4_V1 0x02 +#define E1000_TSYNCRXCTL_TYPE_L2_L4_V2 0x04 +#define E1000_TSYNCRXCTL_TYPE_ALL 0x08 +#define E1000_TSYNCRXCTL_TYPE_EVENT_V2 0x0A +#define E1000_TSYNCRXCTL_ENABLED 0x00000010 /* enable Rx time= stamping */ +#define E1000_TSYNCRXCTL_SYSCFI 0x00000020 /* Sys clock freq= uency */ + +#define E1000_RXMTRL_PTP_V1_SYNC_MESSAGE 0x00000000 +#define E1000_RXMTRL_PTP_V1_DELAY_REQ_MESSAGE 0x00010000 + +#define E1000_RXMTRL_PTP_V2_SYNC_MESSAGE 0x00000000 +#define E1000_RXMTRL_PTP_V2_DELAY_REQ_MESSAGE 0x01000000 + +#define E1000_TIMINCA_INCPERIOD_SHIFT 24 +#define E1000_TIMINCA_INCVALUE_MASK 0x00FFFFFF + /* PCI Express Control */ /* 3GIO Control Register - GCR (0x05B00; RW) */ #define E1000_L0S_ADJUST (1 << 9) diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index ec274319c4..78c07a8f8e 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -82,6 +82,7 @@ struct E1000EState { =20 E1000ECore core; bool init_vet; + bool timadj; }; =20 #define E1000E_MMIO_IDX 0 @@ -554,6 +555,12 @@ static int e1000e_post_load(void *opaque, int version_= id) return e1000e_core_post_load(&s->core); } =20 +static bool e1000e_migrate_timadj(void *opaque, int version_id) +{ + E1000EState *s =3D opaque; + return s->timadj; +} + static const VMStateDescription e1000e_vmstate_tx =3D { .name =3D "e1000e-tx", .version_id =3D 1, @@ -645,6 +652,9 @@ static const VMStateDescription e1000e_vmstate =3D { =20 VMSTATE_STRUCT_ARRAY(core.tx, E1000EState, E1000E_NUM_QUEUES, 0, e1000e_vmstate_tx, struct e1000e_tx), + + VMSTATE_INT64_TEST(core.timadj, E1000EState, e1000e_migrate_timadj= ), + VMSTATE_END_OF_LIST() } }; @@ -663,6 +673,7 @@ static Property e1000e_properties[] =3D { DEFINE_PROP_SIGNED("subsys", E1000EState, subsys, 0, e1000e_prop_subsys, uint16_t), DEFINE_PROP_BOOL("init-vet", E1000EState, init_vet, true), + DEFINE_PROP_BOOL("migrate-timadj", E1000EState, timadj, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index a2974631ef..e8d466b33e 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2902,6 +2902,35 @@ e1000e_set_gcr(E1000ECore *core, int index, uint32_t= val) core->mac[GCR] =3D (val & ~E1000_GCR_RO_BITS) | ro_bits; } =20 +static uint32_t e1000e_get_systiml(E1000ECore *core, int index) +{ + e1000x_timestamp(core->mac, core->timadj, SYSTIML, SYSTIMH); + return core->mac[SYSTIML]; +} + +static uint32_t e1000e_get_rxsatrh(E1000ECore *core, int index) +{ + core->mac[TSYNCRXCTL] &=3D ~E1000_TSYNCRXCTL_VALID; + return core->mac[RXSATRH]; +} + +static uint32_t e1000e_get_txstmph(E1000ECore *core, int index) +{ + core->mac[TSYNCTXCTL] &=3D ~E1000_TSYNCTXCTL_VALID; + return core->mac[TXSTMPH]; +} + +static void e1000e_set_timinca(E1000ECore *core, int index, uint32_t val) +{ + e1000x_set_timinca(core->mac, &core->timadj, val); +} + +static void e1000e_set_timadjh(E1000ECore *core, int index, uint32_t val) +{ + core->mac[TIMADJH] =3D val; + core->timadj +=3D core->mac[TIMADJL] | ((int64_t)core->mac[TIMADJH] <<= 32); +} + #define e1000e_getreg(x) [x] =3D e1000e_mac_readreg typedef uint32_t (*readops)(E1000ECore *, int); static const readops e1000e_macreg_readops[] =3D { @@ -2957,7 +2986,6 @@ static const readops e1000e_macreg_readops[] =3D { e1000e_getreg(GSCL_2), e1000e_getreg(RDBAH1), e1000e_getreg(FLSWDATA), - e1000e_getreg(RXSATRH), e1000e_getreg(TIPG), e1000e_getreg(FLMNGCTL), e1000e_getreg(FLMNGCNT), @@ -2998,7 +3026,6 @@ static const readops e1000e_macreg_readops[] =3D { e1000e_getreg(FLSWCTL), e1000e_getreg(RXDCTL1), e1000e_getreg(RXSATRL), - e1000e_getreg(SYSTIML), e1000e_getreg(RXUDP), e1000e_getreg(TORL), e1000e_getreg(TDLEN1), @@ -3038,7 +3065,6 @@ static const readops e1000e_macreg_readops[] =3D { e1000e_getreg(FLOL), e1000e_getreg(RXDCTL), e1000e_getreg(RXSTMPL), - e1000e_getreg(TXSTMPH), e1000e_getreg(TIMADJH), e1000e_getreg(FCRTL), e1000e_getreg(TDBAH), @@ -3087,6 +3113,9 @@ static const readops e1000e_macreg_readops[] =3D { [TARC1] =3D e1000e_get_tarc, [SWSM] =3D e1000e_mac_swsm_read, [IMS] =3D e1000e_mac_ims_read, + [SYSTIML] =3D e1000e_get_systiml, + [RXSATRH] =3D e1000e_get_rxsatrh, + [TXSTMPH] =3D e1000e_get_txstmph, =20 [CRCERRS ... MPC] =3D e1000e_mac_readreg, [IP6AT ... IP6AT + 3] =3D e1000e_mac_readreg, @@ -3125,7 +3154,6 @@ static const writeops e1000e_macreg_writeops[] =3D { e1000e_putreg(WUS), e1000e_putreg(IPAV), e1000e_putreg(TDBAH1), - e1000e_putreg(TIMINCA), e1000e_putreg(IAM), e1000e_putreg(EIAC), e1000e_putreg(IVAR), @@ -3168,7 +3196,6 @@ static const writeops e1000e_macreg_writeops[] =3D { e1000e_putreg(SYSTIML), e1000e_putreg(SYSTIMH), e1000e_putreg(TIMADJL), - e1000e_putreg(TIMADJH), e1000e_putreg(RXUDP), e1000e_putreg(RXCFGL), e1000e_putreg(TSYNCRXCTL), @@ -3241,6 +3268,8 @@ static const writeops e1000e_macreg_writeops[] =3D { [CTRL_DUP] =3D e1000e_set_ctrl, [RFCTL] =3D e1000e_set_rfctl, [RA + 1] =3D e1000e_mac_setmacaddr, + [TIMINCA] =3D e1000e_set_timinca, + [TIMADJH] =3D e1000e_set_timadjh, =20 [IP6AT ... IP6AT + 3] =3D e1000e_mac_writereg, [IP4AT ... IP4AT + 6] =3D e1000e_mac_writereg, diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h index d0a14b4523..213a70530d 100644 --- a/hw/net/e1000e_core.h +++ b/hw/net/e1000e_core.h @@ -112,6 +112,8 @@ struct E1000Core { void (*owner_start_recv)(PCIDevice *d); =20 uint32_t msi_causes_pending; + + int64_t timadj; }; =20 void diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c index e6387dde53..c497923806 100644 --- a/hw/net/e1000x_common.c +++ b/hw/net/e1000x_common.c @@ -267,3 +267,28 @@ e1000x_read_tx_ctx_descr(struct e1000_context_desc *d, props->tcp =3D (op & E1000_TXD_CMD_TCP) ? 1 : 0; props->tse =3D (op & E1000_TXD_CMD_TSE) ? 1 : 0; } + +void e1000x_timestamp(uint32_t *mac, int64_t timadj, size_t lo, size_t hi) +{ + int64_t ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + uint32_t timinca =3D mac[TIMINCA]; + uint32_t incvalue =3D timinca & E1000_TIMINCA_INCVALUE_MASK; + uint32_t incperiod =3D MAX(timinca >> E1000_TIMINCA_INCPERIOD_SHIFT, 1= ); + int64_t timestamp =3D timadj + muldiv64(ns, incvalue, incperiod * 16); + + mac[lo] =3D timestamp & 0xffffffff; + mac[hi] =3D timestamp >> 32; +} + +void e1000x_set_timinca(uint32_t *mac, int64_t *timadj, uint32_t val) +{ + int64_t ns =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + uint32_t old_val =3D mac[TIMINCA]; + uint32_t old_incvalue =3D old_val & E1000_TIMINCA_INCVALUE_MASK; + uint32_t old_incperiod =3D MAX(old_val >> E1000_TIMINCA_INCPERIOD_SHIF= T, 1); + uint32_t incvalue =3D val & E1000_TIMINCA_INCVALUE_MASK; + uint32_t incperiod =3D MAX(val >> E1000_TIMINCA_INCPERIOD_SHIFT, 1); + + mac[TIMINCA] =3D val; + *timadj +=3D (muldiv64(ns, incvalue, incperiod) - muldiv64(ns, old_inc= value, old_incperiod)) / 16; +} diff --git a/hw/net/e1000x_common.h b/hw/net/e1000x_common.h index 86a31b69f8..72b744b782 100644 --- a/hw/net/e1000x_common.h +++ b/hw/net/e1000x_common.h @@ -213,4 +213,7 @@ typedef struct e1000x_txd_props { void e1000x_read_tx_ctx_descr(struct e1000_context_desc *d, e1000x_txd_props *props); =20 +void e1000x_timestamp(uint32_t *mac, int64_t timadj, size_t lo, size_t hi); +void e1000x_set_timinca(uint32_t *mac, int64_t *timadj, uint32_t val); + #endif --=20 2.39.1