From nobody Fri Mar 29 00:58:29 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=1675222573; cv=none; d=zohomail.com; s=zohoarc; b=OyUGE73I/UqODU8UeEaalO7n6RuaGa0FZjA9lBd5Mc7Jl9kSbCZrcmNUFmZbRN/Aks2R4D+7a66NJGVFFVPybF7maavq9YJfOT7ozV973kWHQcbcoA856w+gUh7+LX2luPah628dh1gOSP+BQMVgm/psRKrhk2Q5DnLBH8TTYBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222573; 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=ltyNpeciop0iwZDxIWVRQ8L6ssyxAAuybwL/ZEucfOj+UUOR0OjB6bhGhWWflNqs1TN/6rPv6u+Fjc4uo567Ci2JGivOleAeR3biyhSSGIws2mb5m13zoSHzjORL3UmgwtVsY+ylOSK13JyDo51eeC6S89DenLHi92FVNYu09bY= 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 1675222573257289.33005912986937; Tue, 31 Jan 2023 19:36:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3ul-0006Bc-Jj; Tue, 31 Jan 2023 22:36: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 1pN3uj-0006Ab-Gs for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:01 -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 1pN3ua-0000LO-Tq for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:01 -0500 Received: by mail-pl1-x632.google.com with SMTP id jh15so8129128plb.8 for ; Tue, 31 Jan 2023 19:35:52 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:35: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=LEVUzcjDweu3RxATasMPdWrNCDFTC29sZxdxxneukjs=; b=zbGyH3e0Qh7CMauYrWx+FpPzCayj7ZMoBC47/zcVRqkPnoESL4waPU1RtC3nNRCW0r a4cQ2o5rUjEOn262JmTnbYZuwxFtWF1npCfyoiCt3rzdCau2213iSs//1vEgPCtM/W7M CM3KpEZ6q6MsWK1Dvqc+LQgd0CTT1+LSHE44l62uwsRN1yF4p1V8q4DJNRLoD9FqgX1u UleSTBdxREGn10FbMhLpmA8gVpqR47bouQgloIMTyUEXpVCw+PDEJFc/5q4Sx1IosAum B/HcVG/cWN9jjl25LmsxQIZfcp1pnMGYfmYbfR979IZYABuHOYlk7kZryNlWUJgWzF6k 7NUA== 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=e8yXglHV5w0cdQAaefQo1x//P3fsxepqvDneJuvim18uqh+9hDayKcQlR+5xriIekG ZlAidhSioNedQyzV136EjJ/dPceY2kCYRQ1FWhzxzji5Wfj2vYY6HuztVVGGHrmfQ6wr 9/PCA7sHSCXJFQOyyOjsaN4Dq7JD/srOzXr1ghpWXQ5aYbUg+F/rWNyy4DwEVrWijlv1 +4lKH+W5IbY4Rr4Dj8xns4Dn5piPKehr1GDk0C2pz5QlXyG5gUbpR5XtT8nMB/TQp6Hj yP+788Ja7W69oRcT+qJvM7JtIt2fgfuja351i/+OsMkoAjOJETNxbjDZP6WA+I9SNWez iKXg== X-Gm-Message-State: AO0yUKUlmJTe6k/jVDMxIA16qSiR5srnnjyjmGB5tNYHYpGI6LjcADo/ V6PJ8KoExQWXGEfhpAvd5NQhSA== X-Google-Smtp-Source: AK7set81TqQERqQ+FsAEf6SYx6mfibaWs6f5ZM09TB01qM/V4l1QbHYkKgQRw98Ewoqgsa63SClYnw== X-Received: by 2002:a17:902:e1d2:b0:196:6eaf:736b with SMTP id t18-20020a170902e1d200b001966eaf736bmr1178997pla.1.1675222550919; Tue, 31 Jan 2023 19:35: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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 01/29] e1000e: Fix the code style Date: Wed, 1 Feb 2023 12:35:11 +0900 Message-Id: <20230201033539.30049-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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=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: 1675222573909100006 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 Fri Mar 29 00:58:29 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=1675222715; cv=none; d=zohomail.com; s=zohoarc; b=AEjTDcjVb0OkVqCljjC4UJLmLk+YXfeehUUVIXW4TpX2+1nnaD1fxmJc2XnusO20sLBtQx35UCjcngKktcCYlDNzxUTAnTB85pdakD+CtL2zPXqH4MKVL4dbjURUzGMqqN3vB0AvDBxC/3RqbAWJzrlR21uqoE0FF/nK+WUxJbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222715; 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=iely50PNurckAKC5RdBRMa/eApbd9RRgLxyTZaIWs+Gi3ateg0v4icGkpCSA4lYwakMtXCCCiYOEt8ZpRbP0NsL7W7fgAhuDesDGWnQXl4wpfwnR8JtxOKL2T2Jhp+DB70RFQvwpeCjL5Dp/8Wc2G4UJvIi6P+H3vk0axROHYAU= 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 1675222715580197.129861324574; Tue, 31 Jan 2023 19:38:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3ur-0006D1-3w; Tue, 31 Jan 2023 22:36: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 1pN3uk-0006BQ-Qm for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:02 -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 1pN3uj-0000Lm-7z for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:02 -0500 Received: by mail-pl1-x630.google.com with SMTP id h9so8571784plf.9 for ; Tue, 31 Jan 2023 19:35:55 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:35: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=mc6N+3X4DyWhP6LHvz3xiMiOtzW5YFnluXUsmSP0zdw=; b=J8cmZEeYZJ3uPH7Z7sddcu3hcCI7vqsNtHkFvv1TDSTcB0iTNnVvhT890Pt2dBu9NR 2+HVk8j+4Oi796sbIPbQred5kaKI5pvRM/yMLAtNt0ulhDiJuRQ3PwYS+O7frbfoXNPI P09yag2KV1yE3uZHVytuaJVunXuWSAkNerUZgPMWzpVuKWcNHB688gM7K8HG1Oe3DB22 f/l1lHKaCb/IJ60TJLK1oWaHGe4UxW5q480tBJ6KypwuSxQTvFrpKqMEcC9kyo26oeY8 YngAlqROvIRG1zHiJ7SwhiD6TfFQSb/3OOtcuA/XSEACIxXOiZ04XCDb482qZ9JlYJOT UK1g== 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=xZTIJ0LI+Hz32Dlw5tlXbvk3yTjOWmEqS3NJ3JMMQjzVsUa6g36TWA+IgfN1DMzV6M nloxfNwgUMnPnnXTDnkb3Y6WrnKvmzfx098/i2EuF5fG/7USY4yeGY7Vef1ExP0ygYjE ipNuyQwbknaFwR0ZSDCFs8xpMOw6bQ5lQydBKFK2Hj8earRZMePvHpH0DfCQZM1MikLU DzbSMm501/GxZRxPkJoY3FM/HK8zOxU2sJn7uWJ+kyJwBa10kJZYywovHMOg5Ib2ydNG YCfnroH4xQSIq/qr9YmQR6mOdlezooqaSlpsce4C0aEerTYCvUCQbLTGZSlwk1kHzZqC v5iA== X-Gm-Message-State: AO0yUKUQNb3vBaKqdjnbcTVn02wsZ7OqGJmuMjkaD4B5rK8nFTsXl7wS cdNnbK44POQCaSUiTX9eOhLtwA== X-Google-Smtp-Source: AK7set/WOMtU6WmuyFwsXSLEP6uayAJh6hS9nlQTEZKJSsxcKjS6f0Rf3AOZLMcGxjKNWi2gfbCb2w== X-Received: by 2002:a17:903:2283:b0:198:a347:44b8 with SMTP id b3-20020a170903228300b00198a34744b8mr1574485plh.31.1675222554109; Tue, 31 Jan 2023 19:35: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 v5 02/29] hw/net: Add more MII definitions Date: Wed, 1 Feb 2023 12:35:12 +0900 Message-Id: <20230201033539.30049-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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: 1675222716461100001 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 Fri Mar 29 00:58:29 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=1675222647; cv=none; d=zohomail.com; s=zohoarc; b=TFDJa+ot+Z3aCqA4hU/YEG+vUuCZ/mXiFFOJVaZQ9lgJwMbynqcfXyzPcz+ZxC5hBePtalK6Oda6KNKaU5toPqEV9kbkrxLTPll6E0CgKR02sjrMeSvInLBmchdG6FqnpP4aTkoqYLM2BtbX3u7SJp9YDfSKA7tbSQGEQBQ6CK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222647; 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=Ywtco+4vTdltSciOrwueWy/OXkfKkFUD12r8QZgPj8MvYxPTE1Ys7fV3GV4VVfXQzu2/f6/zTp2AqNf2eZq3CIqIOzMBRl8BHNJ44PydqZ2bPToxrUilhOkSH9ji47xlEZ2k4wNVLRtAO/+xHEkP5Wly912/lwRGyWPjilAL7xU= 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 1675222647921389.1996371043941; Tue, 31 Jan 2023 19:37:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3uz-0006Kd-AG; Tue, 31 Jan 2023 22:36: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 1pN3ul-0006Be-L9 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:03 -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 1pN3uj-0000NJ-8v for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:03 -0500 Received: by mail-pl1-x62e.google.com with SMTP id be8so17165387plb.7 for ; Tue, 31 Jan 2023 19:35:58 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:35: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=TIOeRLbPMJAuFIcNQlo+uN8HcDv0eMoJ6T+gd5Ur6Ps=; b=q9Ks1XSTynEDTDcJmGqpFotvu3TGpiZxqmm/ingbvr6v+ml5SUzmxuRQFqNoXDwA6Z nRmrakFklUAClq5gh+E/dAfvqrcj6pXl+rLIWiRY56t6B0O5mpz5YleCAokA5t+yQt8I UjbBvi2cPKo0CHXjMtPo2IV6B5dmWgjoSXPqnswTsZc1Ift/8IGShTsy4lqfFXaL4Q07 lIR5hivqyJEDO9iV+k06ovsrISYPFJPuNcFR/f5wITITIFs4WJeD7LF+VIo3/Gx9g4Ct fXGyXy+qf5YwKk06Kn0DgRl7aBL0N8TgH5eaC3HRhWqu/thF1t7zzHlRXPetKXa5s8+t 28PA== 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=bVJTAeGkshf3+qrDAvZIlwI+WgpGxxcYG1+luaof9nne1Rc1+BO9XS8boEgya8d76Q aL69/MMRyveqlmkV2fEJVEwduvDrgRCdaLnwlxiUdG1BrDyo50cE4iEwIpjKZ7pUfTtg up9JSxeMhpuE4ReYeBtCxrZ8bWM17eSNTi/wTBjtyxAGVM+2COo6o1SQmgvmaOlkKeSG UYbgQb+BSfoT4fWDPdUyk5R0bXon1d8c2l72FXV+vawgnncKiyVZIctHkZnx748T59uE 8HG6W1GFR8E/GtTYbfjTUIPopVzdVXa6dU4f2HJn/aQtl6e/yd/KtNqT7kj/vN2lS0/a cLZQ== X-Gm-Message-State: AO0yUKUaCIcuq/vi4wDmk5+mr1+skQZ7pv3yaqvWAabnFpr4rqFWVZSK xI6104w/GsHvrV/4sFBRODdnYA== X-Google-Smtp-Source: AK7set/e8/xoE1vYd4M9HQwArkvnl1UW0Fl6FByAcQJU21d2F5YdtrRL+lnIsvyWVmQovXkOLon6Gg== X-Received: by 2002:a17:902:e811:b0:196:893e:cbdb with SMTP id u17-20020a170902e81100b00196893ecbdbmr1679924plg.6.1675222557328; Tue, 31 Jan 2023 19:35: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 v5 03/29] fsl_etsec: Use hw/net/mii.h Date: Wed, 1 Feb 2023 12:35:13 +0900 Message-Id: <20230201033539.30049-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::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=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: 1675222648163100001 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 Fri Mar 29 00:58:29 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=1675222665; cv=none; d=zohomail.com; s=zohoarc; b=JcfdGFk9dZ8v8DK/Jo2fC97TG8K7DQRAtoK1stdFzeqEbNCJdehBo12wrS9rRkHDOb2n3tzlxlCbYi8nrwcNkqJMb6Vy2aw933WuUsu1SrSbbUsOZdqdL32wHJ7wSUnvtsy2UI3TGH47xzFvN82SjqajWrr4f3K53ykURftEqXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222665; 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=G1h04WG5Y+mVZyQM5OdWxkajSxw6fnNV8EJs76kG2RG6HNRcA9Ei5GdHxiz8K1H6KBtG5y5ae3/FBriYE7jRV+F1vZzFOmPynPiNR9uxjhTKcdPcseKIX5xgmUE9tMPWXz9vFyTObZRPGICKSfP7h0cxAoMqlOiB56ZtkCnJayU= 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 1675222665206650.8967128697835; Tue, 31 Jan 2023 19:37:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3uz-0006KM-9l; Tue, 31 Jan 2023 22:36: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 1pN3un-0006Co-EH for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:06 -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 1pN3uj-0000Nb-SN for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:04 -0500 Received: by mail-pj1-x102e.google.com with SMTP id j5so16057688pjn.5 for ; Tue, 31 Jan 2023 19:36:01 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36: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=vuOZkh7/FsK7pTAIZRY0T7k4W6zYsds58jVwZOXAh5g=; b=g6d9QTPy7D5pQTtSQoE6w+NYFMjbwBhW8Zeko3w1Qt7hjIswnr5/flTLrfeRxe8duG aTg2KEjjx/do5//JYaTwWZ/aYQdIgosflmv1J/OS1r5S578Zr3pqwbZmJ8UprRw4Rm5N V/5/XOIHIZ3JfiWz81x66eQzhCpITsjZUtDqPRk4dQHeYWxPQTrNQuYzzeUKDamiEcxh nPEPa/6WKn3aKIS3EpZZd0X5lLRpwHwL3n8vkJJMea/dJ9uU2aN3UnxOU1OlsrDPM1Up drEn7s6LLd62raT23T7TZbIFHoogTR4mRUY7MX8gE2GhBsvk95CjymwgbPD9SbGMz73u NlsA== 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=xPTJNrX7yKlCBh4A8c9ee5JmCo/gwuShzVrxTClPgdcIYVkA+RDwC771uE4FR8mt/A ldHoTcNUufzrgh9yD7/RmNEyD/npHYhEaWD9hAdoXv4csrrU2JSDReFsNXbOvEz4qv4Q 2BeUSl86qFmczFQDB1iQfHAKcDw5iTUdVd0F9Wss9pZ4nnDaZwY4IV3bGg0Tu467/p9Y XnXL6E16SVQ0bMndhabf1V+Ef3kL76We3QB/QMD4FwstgAQNgjyRO838FJID6oO+UF1R GOtoOMugtTcL0asTiPAlui7r3OFsu7cN++B9dOeVPPAoD49frrrA+4egCpnH86QLyJy+ uMVA== X-Gm-Message-State: AO0yUKUPjEmY8BpBvWUDrPK3Xz6rTNKji9MrRhCaMNg5DS39AgdbdnMJ S10GEE+BVfHNOgGw3EWtZ+q+pA== X-Google-Smtp-Source: AK7set9LLxGvb9UAGH6Mu1Ng5WSopuY2fxHhQ9NQqN/+qWx1U1BBv2AwCkWKt18cotGEQgAjBb4HWg== X-Received: by 2002:a17:902:e313:b0:196:47f0:50b6 with SMTP id q19-20020a170902e31300b0019647f050b6mr939610plc.47.1675222560605; Tue, 31 Jan 2023 19:36: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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 04/29] e1000: Use hw/net/mii.h Date: Wed, 1 Feb 2023 12:35:14 +0900 Message-Id: <20230201033539.30049-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::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: 1675222666288100004 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 Fri Mar 29 00:58:29 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=1675222666; cv=none; d=zohomail.com; s=zohoarc; b=IHlKUeEA7Rrq8mM032R6q5AgB3GbWyZup1imS/ZESB9zi+jsK2GpV/BXVP8ripdAjqAhXaZY10mA8bO6UZpBek76T7bUseZqUdG3GN15+BlPkmHQToaiaqd3XGPg1ur6lkCDieI6jjkesE/lVVyCj0EzrG6pVtYsk0v82HNdv7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222666; 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=Ikw59xmq+nMdiYXWTXTWfF6G+QoPQLCEMGwMyOpc3r48dhr6rPGQe42M2yJgZ5QEMBQLYOV3nR21numCu3/Ut81T4RqQXxwf1em2Tc4aDIFTEMwFt5oTnSm9E5WsPI8YiSKTwf6PC6tEJiYffqs111Fxm/vSp8J+AqkyPsvTUbc= 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 1675222666479740.722261431863; Tue, 31 Jan 2023 19:37:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3v2-0006SC-1Y; Tue, 31 Jan 2023 22:36: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 1pN3up-0006DQ-03 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:07 -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 1pN3un-0000Oi-7P for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:06 -0500 Received: by mail-pj1-x1034.google.com with SMTP id cq16-20020a17090af99000b0022c9791ac39so722390pjb.4 for ; Tue, 31 Jan 2023 19:36:04 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36: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=vaQBmuAwUG3bfNy5ZDg+YwZ/WikcZ/GlFG+7O8mJJRU=; b=WB/b0K2dtIZ0FKMldq41mKMEtJkj5EgjOvMOKTOrdEPpX3/Jt5WQJjN5wZVmqW9QmY AXacua6aI+pnqS0lRNTUFMjY5G4CLnrl1c/x4ugfcP+76BHhyaqycVFQ/E4ejTI0jq8G tUFqswE04eyU4si9y64eZOvkAFnEZhKKM3RjAZ4UtKIGpBupjyn/Xj2yWkUNMpH+qtsg pknN2N1jK1MEt9VBN2RLxbI6yLqT3v1YRxNrqLl4Wc/63cvnWr151x0PNUh5xfwkM/l7 PsTSX+lCFoksebyEB3T4BnsLsKwl8ICQbMEkQ3EzYnxIMvUcE+YzOrgbADACKXc0TpPO IU8g== 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=6R32aA/cBxpnwAxiry4ZlO6781ULmjDGeB8dugXkXPKMLxS5knSWOqCc//9415/5aq aMJKwGf2gbAqXQ/difDE+3WkSEa4rbNuy4LecepGMKjyfw9fOBgjkzXq6O1ftMpx/5sn 17sJpRhz/VJ0QoFna7np6AClf3AEPAHcm7E+ScxkAH6xlD/+o6FA2ZOC6HGSS7NLFQmr PR0HN4XZ8zHGgjV2mv/OUS6hqz6QELX+HoHuSpZ6ujMO3Hqmc3NsrrYmHM9yoNMvjQQx 8SaIx4luqRo9Dyoly3G/S4IquS7m4CoABIRIP25adMxyKbuhB/9fLHTF9LIUC7suc6Q4 S5bQ== X-Gm-Message-State: AO0yUKXuZy1EzeGpv3zhL7Y4ksvzplOLKT3Ud5PMstDJuu01pGri9Q25 ta5keJv8fbwCLw0upUw63ASd70d9IuC8Ghw5 X-Google-Smtp-Source: AK7set+fexlQKjzGH7banz5DIphCfO0t+f9lrBHO4c4ewiuDgQeFY6RaXrhBdtyNCyyEkqmGM7NdOA== X-Received: by 2002:a17:902:ecc1:b0:196:11c2:2fb3 with SMTP id a1-20020a170902ecc100b0019611c22fb3mr1576735plh.36.1675222563642; Tue, 31 Jan 2023 19:36: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 v5 05/29] e1000: Mask registers when writing Date: Wed, 1 Feb 2023 12:35:15 +0900 Message-Id: <20230201033539.30049-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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: 1675222668271100011 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 Fri Mar 29 00:58:29 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=1675222864; cv=none; d=zohomail.com; s=zohoarc; b=c+Cj2Hdwxi3XH/18XRsZyJpefc7Agb1uRNb/qaK0Y7OxpOH0df5TK8JmSpxBaAlAJdhOgB98bAmprJnFWTtIU3+z/QiWSdC/Bn8G+D9br/2ys3Po4kayTZDKgFqB4ngQxg1qVl9kXPncePakapTsBNl6PghspIHsNf6mSNBBU9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222864; 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=zhixYsnwPS64o81GnZYaSZ66bIpojrSC+9lwRiPl30c=; b=G55jJkqta0c06fnqKdUI7+egadVzNsK9wJlbUWYVjG7my+1yGGlvLQG7PVPxn7K4UqnLZmdRCGhVlcQfOFNTlSLewILJ93I7iSGSlRe0T+E3mnKlYoLcKb2MNsREzPhRafvJIwA0k2fmAPKURr5OoWSzNQEMjES3Mgz2FgBZSp8= 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 167522286408940.13133208533361; Tue, 31 Jan 2023 19:41:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3v3-0006TB-BI; Tue, 31 Jan 2023 22:36: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 1pN3us-0006GV-Pk for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:11 -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 1pN3up-0000PI-Sv for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:09 -0500 Received: by mail-pj1-x1030.google.com with SMTP id n20-20020a17090aab9400b00229ca6a4636so780800pjq.0 for ; Tue, 31 Jan 2023 19:36:07 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36: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=zhixYsnwPS64o81GnZYaSZ66bIpojrSC+9lwRiPl30c=; b=ateyqDf9esS9EtpsGYHVE4dZf3Hb9s8Lm2y0aCf+O/E7/+lO8W+79M1VfIViaewh0+ VDYlOCoCJemfEFCN1mWuMyvNCWgMKIpajLnOqywp4+qdSa/kmvUzwN5LXxz+bGUaETgs ThYqtZ3t9QTpJzPlVrTPf1XzRnXB2eC+yWS8LGCTH6WeVwoW72uLIRnfI+U3g9j0W1KN ncZe07G78Qu9FSqkgz8mwhcaF6li2no3176GWTIAN9EvhpJguC0FZxHjE8sQODF1rKz4 NSBwH9aZ0vJMqMRuPzolm2Eaj/5PHaf05txQm/CrwKCI2F0Qef3Be2Pn1LG6KkWT9h3y B63g== 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=zhixYsnwPS64o81GnZYaSZ66bIpojrSC+9lwRiPl30c=; b=o6W5rCA9Csjo/OWJD3bl4KxvYytu08ld7menwUrk3HWBuJTx48bzckt2rXuw34VdSk UdVwIfxvevscwqVY34o81X2CMQZR0JI7eOycUitk8R3CK6I+qn2CrzavHMNPoc5tdEJv NoAYttSvtpJx//q29wRk6LE8/JR6rxHPOypKzhBTUDolivRTNCqdhqe546PgDBDiF+CK n/M94hKeQAwvHHvK6BcFP3t72Egm0QL44cEZ+4+e9uZ63V9jzgr62R53Tl+Lcl1D9YWp IeAlma5WjGm0yY3jV6VOYp/7MTmMrGSVh3EEZmhm475QC2onkFfWGHP7rz8HFYbMbJ2r +DOA== X-Gm-Message-State: AO0yUKWs0okdy969L5KIU/zjPWX39gDEfc3BGJUu1JWs7ct4sCzoMVEV 9oh0tYbdfm3o8ExXcN6PxrJUSA== X-Google-Smtp-Source: AK7set/dF5C2CCMRdP4hQEPA1ogDjtwze0WphA2n9of0MIVay0m5RNEruvmKeeINmHfVDdRlm5XU2Q== X-Received: by 2002:a17:902:ea0b:b0:198:a845:fb96 with SMTP id s11-20020a170902ea0b00b00198a845fb96mr806686plg.20.1675222566694; Tue, 31 Jan 2023 19:36:06 -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 v5 06/29] e1000e: Mask registers when writing Date: Wed, 1 Feb 2023 12:35:16 +0900 Message-Id: <20230201033539.30049-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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: 1675222865268100001 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 | 94 +++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 54 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 181c1e0c2a..e6fc85ea51 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2440,17 +2440,19 @@ 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(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 e1000e_set_vet(E1000ECore *core, int index, uint32_t val) @@ -2621,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) { @@ -2930,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), @@ -3066,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, @@ -3091,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, @@ -3108,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, @@ -3134,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), @@ -3157,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), @@ -3222,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, @@ -3261,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 Fri Mar 29 00:58:29 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=1675222870; cv=none; d=zohomail.com; s=zohoarc; b=YuJJDWBl6CuSv3x4KiWT08a0FPUcxoHJuDvyUD78L9ERNp9sEK1EwqNIb8X9uq7S99P/xrlC7LWI8R9eVywuVztAK4BI5hg9J3KRebbNR2NxmI/NkAoZ1gviM+wdgGrBaftY7lbzfSs5qw/ZnvUaAdM4Cd0X0WaHzImz/8bZzyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222870; 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=IxtdSJO5EwkrENOnllA8Ui7YyexRM3O9qVndxs2IgjY+X0ShWhpd3FZbGA3RhJGY4NL1kSXnVf2jP1NV7XuQz4QUtOF81JZ6rROmAxbMRhGyTkwa30ZmiQ69hBqoWA/q+Q3wWF+9AWxYf8gBgFnB38qnPw/keQ3dP8yEkZ+XdjA= 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 1675222870732927.9392618056178; Tue, 31 Jan 2023 19:41:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3v1-0006Qd-Lr; Tue, 31 Jan 2023 22:36:19 -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 1pN3uv-0006JC-Cz for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:15 -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 1pN3ut-0000Pi-6X for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:12 -0500 Received: by mail-pj1-x1030.google.com with SMTP id o13so16076062pjg.2 for ; Tue, 31 Jan 2023 19:36:10 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:09 -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=T7LEGpUosFY3Kh029oCzSkZhdB7p7qQfiBr7XGA1BZiJSpwKjyth9YndiehwO0E0Ud 3VOVH+3wowncTcFV+4jNyo5eDFUZSzr0eTQkgZ+DOsx6Jn7TVIVjeRRIpe2MbqB8FBzj mcEso1yoqjO/WdmZAMZ0sgZRPdYLYLRjB8T24BIk6tItiJ0e0M/hcfj8cjFU06tMRV6+ tFRsUvjQd+RTUHaRuFrvCQVTUt66GhiPi2TWa4sVnuEPKhmzyBEY92TU0wJisO6gjnwd zNo7H4kSFmCBqdd3kv4j7nIZVCRSqfARsl/GcezlPwvD34d905JEd+bWfkgQtkp9Isy5 Ok4w== 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=ZcIxvSkJ9FslH4u+M5CsvlWOturW6lvNSq+5mWCRzqtd/l+9wJpsqtyMLK1HUJ2AdA YahcEuxSjiZet9rqlOqvK2ehRBDajcOQIoX7ARlGozUGdlNhxxRvhSoBnX11YB3YfYVL M+ZW5xZm7ukvgXCFzR6kFuYg1xOUmI59dHMM3/d2ayXoowYmcRl3g9/h1f1PpwXiePuE LSxLEz7pUtxy2aKZjwZZFn5T2cQ0paSEW27qx17LoswcYG6SHLC1F42DBoBgiVbDqc2M eNIDzaOMmIhgMxCkv6fO8yWao5SAPepmgyBwF683KiQeWb5+drsFx3xPxOpegb7IYbcO jWMg== X-Gm-Message-State: AO0yUKUH9LdPktWH17QB9HxKx7QDCum2QsWJ4g8tKDiHjdHZszwToxVp hCtc7xj5g+5olPEbJe405LtYUg== X-Google-Smtp-Source: AK7set/wW7WmPehS2lPPB/Edo93pZXmjfUuXPgUPqqq035ekXNkuLf55+v64WnBpNaXl5gFfWSqhgg== X-Received: by 2002:a17:902:ce10:b0:196:8db5:fd67 with SMTP id k16-20020a170902ce1000b001968db5fd67mr1478445plg.2.1675222569894; Tue, 31 Jan 2023 19:36:09 -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 v5 07/29] e1000: Use more constant definitions Date: Wed, 1 Feb 2023 12:35:17 +0900 Message-Id: <20230201033539.30049-8-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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=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: 1675222871478100003 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 Fri Mar 29 00:58:29 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=1675222847; cv=none; d=zohomail.com; s=zohoarc; b=fNpJNOKFozyQhHbN+Ofdh9PvRLMC38JiVIGkwTKqoT1U6pH4mFrXv0q6WhJGPj68uQvOUBmrB+YHI56ukrRcIXMhxIn5at9/jjouQg9f2ee/5h16hQuJEzJmA1fVPj7ib9eVEz7eptsJa9xEUQZxk/C+vbJ1sO+kwLNpdkR4qkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222847; 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=gp7r872L8MtThvTjuzUsGUQfdD8oGOLIKLj1lGgyNiXlKiBeQc0vRc1XqJlqjdxI3daWnVhmtpDEVDiLlRnatVDxi2tcCukRcauGGz9eabGM9Z/uKQ2U8HZDRMZEKpPsY+VeteZb5R+Mq57WnvQUDixWovqpqeHUbido+4oWoDc= 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 167522284712687.2396265588385; Tue, 31 Jan 2023 19:40:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3v6-0006Ut-96; Tue, 31 Jan 2023 22:36: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 1pN3uy-0006KK-0K for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:16 -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 1pN3uw-0000QI-5R for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:15 -0500 Received: by mail-pl1-x630.google.com with SMTP id v23so17188049plo.1 for ; Tue, 31 Jan 2023 19:36:13 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:12 -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=C9tYmN6WO9C0qQ+gymSdVmDEUK6Lzy+eOd/RZFAnWSi8CqN1KXpqkQiW1XLNnUA4q2 beP5m91j2ESSQzHNSFbcTyGK32b6Cbj5K4mxODmEadUKBVwI1BXPzuIUpNjUd5g//9ID 57Q4tPcpQjFsZaCY3Np/8nsqtgyE95TixUwc7vkdV2NAYCLBayGBOfNpTIfyx+bExHHX m1ZihDlacTmEPMu6UX5vQpPNLxPIqEj+prJAp34CettjeS1j/DmVCoH+d2nzEnFLbDP7 9KwQw7wwSNGnQBPf9MvdO+RKqeEoPS5mjqIZojIeGuvynz/mGmIqr7o6hRnPah98I2pJ x13g== 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=OC8LINQewplzM2jtZT2WMwp1A0CeT+lef6sWGvhafCvyeqs+aaN5b7riSQNaT7rvP8 AbskmCB/WLmRycPivYaK9lH5CHTUaX4zvWYqu10b//ormsyAOKxX0kBJqkkiayt3ZR0S Ck1ZfZWIyXS3EK7bpDn9JkdwIhPT755fp0czp+tGlJEjgq3dgUlbCR7d659/TecZuV/E it9KOHZ0rfARzfoDsWIhH4wrQffsqF9NDlX0jVv/WhgyQuY6cvyN1BkMQQvI0tInRlkd y2fjZ+/X7UYz7+yZIBPJtjnTqDs/NNg1N+CQTal94z+ITJwAfA0xnieZNVcCPr5tWhY5 dmPg== X-Gm-Message-State: AO0yUKUeWiIb/rgqTZ2khu4y7OC5n2rQ/j25SZ0vN9jP+Qv84y0kkp78 X+AIS7abMH0NH9tV6MDXitc3gA== X-Google-Smtp-Source: AK7set/t+5nN0Bgu1Fek6UKQRlGMHCjM8C8Enw8n0NQwwN++rz+xmwlWHDg+hz5YT1yFcq3z0YRy6Q== X-Received: by 2002:a17:902:f392:b0:196:6671:d68c with SMTP id f18-20020a170902f39200b001966671d68cmr1120690ple.35.1675222572948; Tue, 31 Jan 2023 19:36:12 -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 v5 08/29] e1000e: Use more constant definitions Date: Wed, 1 Feb 2023 12:35:18 +0900 Message-Id: <20230201033539.30049-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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=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: 1675222849169100005 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 Fri Mar 29 00:58:29 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=1675222758; cv=none; d=zohomail.com; s=zohoarc; b=B6vvqmpV28vpSUCp1u4lGYYE+//3vZo8Ko0mgTAi5wu3SqzA4vJT77H/uPnQYdu7ERZn4Q2dtUyN+5nO00m4vY+F5iiRlUTUI1/3APewq4Y0FU6T1FNW4nCYAJKZdD7ZMrgEMjXmpbk1bYUA4eNy5wfia1JfkEJI+5opyjD3bg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222758; 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=nm3YA/MszAaf+yADmNaNj1Sqhcve4D8CdjU80kq3sIA2vx2y6MBDQ5loapkhzq0gc85kD/YfIgoWcl3OgFPQfigUMq7bv25an17dAIXd35lUfshLQi+Nf8abNnZdqPUcoLTRlVg/rnmDgy+jtDagh3CLwGsza2hXxrKCM6p/DLo= 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 1675222758560695.4975775486777; Tue, 31 Jan 2023 19:39:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3v4-0006Ts-1X; Tue, 31 Jan 2023 22:36:22 -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 1pN3v0-0006NN-Nz for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:18 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3uz-0000Qf-BO for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:18 -0500 Received: by mail-pl1-x629.google.com with SMTP id z1so9641303plg.6 for ; Tue, 31 Jan 2023 19:36:17 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:15 -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=CuSi38gqao9Oo/YJDrfWlWIcvDAeFdeH+yl+n2DkcEkTwbXQZbpMtl1/ad/2zy+WqA iCQwUx6H4nhQD+fd2h6XrAnAWk9HkQ1j8RvtU1p5UZdCT9vjjvSTaILqdxlMSjc7OFyL Cr4cTe7/pkijs7/SW8JEVJywVs4dFIssBxm3XYJQUxYBhBfS0DwjcgqP5gd1FDxbBHQo XZXxikZYWrmz+SRlmDQ8VFV9rg2izf5yQyvkaGNKFsx8+Oz1PlgH9QNZ/mLWdmwxmSng WnnFdbHuXO+zXt6vboXoO3VAtNG+QmsJkQR3/NOjFSi8dhxZ2b8zv1XnqHKBGOehxg0r SmAg== 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=KT+Bup+vqDC88ZgwzdgzfqAQoCyuB3Q3i1mw7a1u06hq14tK7j10NDIOt5Hn/YpnOq D0ujqnjNeLJUaxpwazcGeWtDifiFt/V6g+WeaS0TyqLVrFoncT73VWBVgwNF4DQof3qS HwILIiRNH3QtNGdJsARYoE4T8ST10tjnlmWYYzF4bQ6IUF6mDQQutcxzlWNtOHt8sC4F vfK+Q658OYlccxG8Rd2JEXP9R3ksyW/G6kp4r1bvxds06QE+W4lDAWBjjb1EYKuBQrOl yilTs3UOECTNOImsiE+jRwSO/dr9pixtgoYiUE94zm90dIlsjFUZbmP6jWYB+x0WMu/M PwYw== X-Gm-Message-State: AO0yUKUCwseB8vTqAtljD9WkGKXBhZpEJb7RLvDKkd5Ao4IPnHny3KtL yWS7yf++WCXndCltlwbe+AWGuQ== X-Google-Smtp-Source: AK7set8oMMWO0l42d6bLvGJB/0C1+GARS08hZ5c1G2wws1IHv1rm1J9RhStAHaq0YlxGWvfwUTAsvA== X-Received: by 2002:a17:902:ca83:b0:194:52ed:7a2b with SMTP id v3-20020a170902ca8300b0019452ed7a2bmr1078593pld.39.1675222576019; Tue, 31 Jan 2023 19:36:16 -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 v5 09/29] e1000: Use memcpy to intialize registers Date: Wed, 1 Feb 2023 12:35:19 +0900 Message-Id: <20230201033539.30049-10-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::629; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x629.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: 1675222760726100001 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 Fri Mar 29 00:58:29 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=1675222688; cv=none; d=zohomail.com; s=zohoarc; b=bskbKX+qk6GmHA3pXMkBSRGb0Zc/EupsNydKtcTS8MKdCji8D/gqqOUA1UfofQz+5A7kjMQ7CIoNE2QpNa49W6HweVM+dSARfCt3C/Ekey822WFwXurKZNgkU2UmLz2mp4993aipXeqENjb6JUQopRpvxfWQ4Oca5vDJId2gVlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222688; 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=MfcsIBzkAe0v0S6XKQ+ifwrOiG/uq0Sf9tfXqURgwDhwBIqdn6I2jEJJRImV48s/NHzpZQBBx0tCzDnwqhPPDbUObftpRJ/+LNpf1SLHanf7o3tvk8GlifCfbpJzHM6QFn3NVuwLzY2jyU3mP6834ypNhH0Vv4vh6/+MkplaqvI= 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 1675222688091352.89848960868824; Tue, 31 Jan 2023 19:38:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3v5-0006US-3J; Tue, 31 Jan 2023 22:36: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 1pN3v3-0006Sx-4P for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:21 -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 1pN3v1-0000QI-M6 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:20 -0500 Received: by mail-pl1-x630.google.com with SMTP id v23so17188239plo.1 for ; Tue, 31 Jan 2023 19:36:19 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:18 -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=W84Vc4NE0Ry/t8z8OJXstgFgBS8i5Ambhw82ArubGEagajhrhYZMd/oQxa+13frs5D Nkh3dtqgDd67x0JgBTRZrOfZu3qOWRm0jNbAXsVm0zWmSFTmLkziL9dEg43t7VrjwASr eGUmlXPkwzi2/lqwNniZw3ocSFwdmK8jdAN4cbTBcMYLhKdxbPq4vcVHPt+dG7Xaga8t yvrQO53vVG9mrh7/YuObGDF4FKKVi1CwQ/Z/PxrlfAxlRs6ghQZzO1LCudaFf4UjgT2Y /fuqHEqmNoZ7a5YlbuJSswgU/h/QA4lz5zoTrj2QGQnFtXzZaPQU0hHdc6nz1fHmb2Qs cgTg== 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=s1q+fOMRmgmECPhIk6aaWs8qrc86Gr5XvjQpWWLAEtj5GLrIWOQOy00ELZF8IjUteK Ol2nxa3NfsYAWXZFrtQ+fJgrgi6nOtNgKhedbHz2N4ds7pH1lX1yxESYp/3mk6HrE9M6 dP/gl5D/9LBFWiLVewG+3fElD7Lm4oH1dVpEqIK94aDFZrTkPUgzZcmM5g99JbeVEQUo Pc8q7cVYSYolW8zBRb8lowID5h6VXWt5HTry5lhC6XxHwpp7n71ayqjJcfqd/TZMrCLa Zm1/VcjsXw5d+wjDEEVRPC9ASxNX+RBKf5f1OnzMRP7HbZLEABpfB3VxkPvS7BmlAZl9 qtuA== X-Gm-Message-State: AO0yUKXBgkcygDDJp61MUV2PMTKpOJ/d4LmCI6+7e/ZOyt8bOixRbpw2 7NU2RFvR5+aNEArPTMD26YrCnw== X-Google-Smtp-Source: AK7set+whwaMntuHqZqwezAI+wHvJY8JuViom609LpfY5KPqeo6+bTppeyY7oxqhrpTZg8bv/lSpKA== X-Received: by 2002:a17:902:d50e:b0:196:82b6:3d8d with SMTP id b14-20020a170902d50e00b0019682b63d8dmr1362454plg.46.1675222579062; Tue, 31 Jan 2023 19:36:19 -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 v5 10/29] e1000e: Use memcpy to intialize registers Date: Wed, 1 Feb 2023 12:35:20 +0900 Message-Id: <20230201033539.30049-11-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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=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: 1675222688323100001 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 Fri Mar 29 00:58:29 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=1675222689; cv=none; d=zohomail.com; s=zohoarc; b=jq22iftoMfCNhHgDU1MGTXLPPD90LVD46fGVrt9zAfGzJ+BhwFdbKTJ45DvKx/PLrDycBx3ta4462HhmC+3HRcYAiCni3aQ9HySOv7ZdVh2Xm1V+iWbGLHa9YeWilQ9PQeRUUtFP+1MczhhkpM8nl98bu4lUDSaiY/NS/DyokG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222689; 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=kW7sAQU7ZYABWqryi2ML28icTxRX+YB+4hGrLHtc2ncdY240P3pad7AM5tmXrRGvfMOkWzfOoC/bobcitjiqReoLqjZ8TR4j7SzfkJKSOrih2dV5gPayJnEEVgHUYGs830HF1eftMemtFgQ9ftf78/GkHuJZb9pWYcrnmcFXOl8= 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 1675222689705515.2440981594776; Tue, 31 Jan 2023 19:38:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3v7-0006VN-Hr; Tue, 31 Jan 2023 22:36: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 1pN3v6-0006Uu-Cj for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:24 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3v4-0000Qg-Pw for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:24 -0500 Received: by mail-pl1-x636.google.com with SMTP id n13so1678433plf.11 for ; Tue, 31 Jan 2023 19:36:22 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:21 -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=k01BSWJkh3WYJNEXBO/f7d7PXMSmgB48bEaP4frGJx3S8qDSOAkfINSD7/Fa9U3I0e 6f7cqtMx8xjBGV1C42P+FJW60ujrfP5k7F1B78aZVDby6HbAB2M/ZpiGHht45lXT7B59 WndR45i/rzS7W/kk99do8s4ikqeARFbM8O8KvfhxVe06f5gjqoK4vJPqZ6fXvYdaJl5a rdQ4UZaCKdPp/xO20k3a4mqJ9PbD4GUg6X6ltTkTBYZQ6S0zrrPhz+5hGl7Z/df1TpDU OB7uP8ggKcDlA31WTfYWZ1FvU6w5zP40ae1yUCqnj1wDuc7LSWFprSu0ebzC5iTuHFvp I46w== 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=ajm/WD9CRbEDNvL+lo+RQern8gUwO99K7erUK7NmdtB5QSHsKhoRWkDU6DudvCVaoh hSDNa1cEww5vGts5g4ie0eyGwyJuma4nu5a73ID1P/oO01pbNSE9SZNQENwgUBq9r/hK 4GnTOWihu4zkCYZbLh3jHU/4UA/uJHloZF5BAUm5KDH7Unz8ZDC38ovxdvG+TkiXppAo EySTPR0Su7RtKrDBq3FeJYS+ITxwTeNJ1r1Na51JS3JmSl0koU/UxfGR5H2yTo6k5s2S lH/d/lcqU2gQWIk6caorm6P1yzRKqn81LrmasR+28VMxXg7JU/E26NCB1ezSY/nKbl26 0VyQ== X-Gm-Message-State: AO0yUKUFwraCPqOuVfwWt+II44LUgzUoGPGo+gqKdaHpeT9Lr5N0DUFD 9w388/snZz5P00E7oZTotzn7mQ== X-Google-Smtp-Source: AK7set9Fcfgm6v0eNDeRo/a4CwDEHOub4X706dgyY7mR86ahUm7U2EhJLh38JDTfEaMoIE80xBHz8g== X-Received: by 2002:a05:6a20:4411:b0:bf:e16:f3f with SMTP id ce17-20020a056a20441100b000bf0e160f3fmr1127166pzb.33.1675222582116; Tue, 31 Jan 2023 19:36:22 -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 v5 11/29] e1000e: Remove pending interrupt flags Date: Wed, 1 Feb 2023 12:35:21 +0900 Message-Id: <20230201033539.30049-12-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::636; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x636.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: 1675222690335100005 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 Fri Mar 29 00:58:29 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=1675222672; cv=none; d=zohomail.com; s=zohoarc; b=JPj+URLapNVTbAYIhmy+49PYLfjRIklolPu/6HkkRSJkpRJMld70LnPP+8LOyhG/2/MTfLQDJM141fh6pF6zJOIIpACy5mI8dY7DJJwI3wOQrGaOgHg76Pq91hVSsvh8EsUtkr25QeXZJ7vsNBltdGCBiak5khKMgDEfv6W2hXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222672; 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=mPMJ7Kv/0F3YBxalkMZQMfbd6g01qHajBcsIhuSB+WWCBpkeqg+IWs5Rd/GxAdcJ+B8MuPKJBOHXiQC6TDUs4D2VDt0+fMFhftg0l7zfqR2OIIeSZh5NtcHOXema1LGS9cv5PPj6S7s8sPLe2HNS8aRXUPYykd2DEsTaoKOQMYs= 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 167522267284038.94424044473851; Tue, 31 Jan 2023 19:37:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vA-0006Zu-OS; Tue, 31 Jan 2023 22:36: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 1pN3v9-0006YW-Fe for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:27 -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 1pN3v7-0000NJ-RT for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:27 -0500 Received: by mail-pl1-x62e.google.com with SMTP id be8so17166196plb.7 for ; Tue, 31 Jan 2023 19:36:25 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36: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=EHclpSWk2JKU9ohNpbqjRIyblKNi65CiMHRdVnsb5nQ=; b=rNw0A64wjxMV61wQPTuLLQ3PtdXLCBYlHmuyeScl961FOQunSZnCejdLyBppPTxMZr wlN7w9DQceS/t4IMaERfCJST/zdQWoHQjMb/O+fUN2XY5YW2ZH0JVnxLuyi7358socC/ bXqhBQvQRonNX/ETlCKzKcPv+U/a3EN7UxevV59/Rm9Lro12NYzVTSPbB0WVY/etspjl TFP/QjMQx+SNQGcv2Hu3Kgt5wQzgk+7wABTtU67p8MRJ+dviOF9YuXyjosfjU0bnuJiS hZeALelPqYWdQ5p4paTBIIA61vtxJm9cvjwUqt0M83SokkGl/DPIUZFj7IROrsEVqV5y wBnA== 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=UlPoqm6ApdhE/Q4+PqP6jYCBfP/pkvhushnIF0OB3K68k90689Wn58pfkljRVfxVxp NHxqXPNJvMrI09uBo0yB41YBKP+R0rfKo8VEBevwMFbwkR6Qz4kpYJ8xBEOAJNatDWJf BGf2Htsh9I9UYcd+0DuEGVRmqg9lF8puhA/QAhKUsE9HNQrrPHmCRRjCqz5D+V6LNFkg YRu9AgaRumhcVN0YCWBvjxoWcOHGIBiobulI0Vw233lCoNhEkGVSu7+RhyY0dhx8QXhZ Fk/aBlBf94ELu/jEFUm1XoY/mHoYsKGkftOICJyHmKsoviiC1QiRQM72TejrWnjGuuSL SOng== X-Gm-Message-State: AO0yUKU0mNtxAIz4s1/IhDNbYCYq3Q+qPw6JNY+E5SJqP3leE7jhPlJx PVLjmr5mlteiCL3FJdlYZx3BCg== X-Google-Smtp-Source: AK7set/Po9x73WnliW3k7OVvdOZ46PbK9qhsxuTdwTWnsugV8aKZKehaRY2HzGBjYFrY31n4kKX6Cw== X-Received: by 2002:a17:902:d505:b0:196:844e:5f49 with SMTP id b5-20020a170902d50500b00196844e5f49mr1648298plg.65.1675222585205; Tue, 31 Jan 2023 19:36:25 -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 v5 12/29] e1000e: Improve software reset Date: Wed, 1 Feb 2023 12:35:22 +0900 Message-Id: <20230201033539.30049-13-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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=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: 1675222674296100003 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 Fri Mar 29 00:58:29 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=1675222743; cv=none; d=zohomail.com; s=zohoarc; b=O8u7epx4ltm2iNn2YY1v08i5HVo7sM1VlimqRGAaJpA2J6uJsXbZM5MmJFKSgI/5SzCNzNxkV1hwHtkmltao4vaN1YpG8xcImh7owD1OyCmfnrfeByTBayVqz29sL2gICfzMcXQ7v47N2eSC1uJFJ1g1GyQ0Te463qfDa6DskV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222743; 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=bisfqAVw8Caheyv9XCNWD/1UlltWtJ6GgF/ikS9q5F5PSrDf3Q3l/6xjgBBU03XmswP2h8TMKjSSq+ehBdqb0INXv4mK9kItAkFo9MICTead+5ZE8byBp/yH5R7UJokRVvaye+G0lBJEUiVuFR7WA3ZGInYMHdHK/ZrSO4I3zRY= 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 1675222743391587.2995191342376; Tue, 31 Jan 2023 19:39:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vE-0006ch-ID; Tue, 31 Jan 2023 22:36:32 -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 1pN3vC-0006aY-PD for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:30 -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 1pN3vB-0000QI-7Q for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:30 -0500 Received: by mail-pl1-x630.google.com with SMTP id v23so17188518plo.1 for ; Tue, 31 Jan 2023 19:36:28 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:28 -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=fnn9BjvMtkCZObEsS03e6iTtKAkJi4wti+iKRcqp8gZ56fv/ciimB9orwcFrGNy8nE yYCpY54/zvNBStKubdf26L+ODe3M+uyBkMXNxEYqzQeCCOAmTh0noMnWolvLWsdPsOnS 6HT0X0kFdnJwEFCisTffrxOXdfNte26xznVRvjjJlm9RASwpg0o3+jMGD1RYX0YIZb00 UiB+YYoVeR5SqdnYPIQdsNOHdLU68G26iraNQO054N+b8qBw3mR+e72JYeUVgqY+1LBS y2yEGMTEiLoCwaZYyqcxhgnr2cnx3dTHb0U+M/Fb/YL7CxJ4p8AYIAdsHtl2Jw10Nw4P JyPQ== 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=jmCe6IG/By2xwqZTMwEI4Bp/jCbI7YisjHURXkM+RA6Pk00Pvg1Bkx5+7J1gYhmoWg 7c5DldiMQ09CDb7x/U5adE1fS0//iX38AHLlbuFh7QVDDSG1chUl0VfXmTrqvHFybu4D QPJjxRkCu6Gp+tRDdGFxHPKkPVmZkLnvgwnMnyu+4eNMFqnRwDgMeoAgexZGhTt6hKq1 SBbi80Ci9ubEdXc8GW6h5eDfiNsvS0aTKqYurbLHLhXBs6IAf4ShLkVffXPAlSxcqAhm 2vFGXoFyxqaLwQDf+bmuBi98L9qHTGCIFpyaMHQGT7h+MjAjGpyD97hCiW5PDsFsRtco 03gg== X-Gm-Message-State: AO0yUKXPzFTgrdXyeJ5Ks2KPiHXnZ548Nz1vactK4Lid+cIkGSrMuvtz bVF5dCN9mZCL6tK0tDAMDV9DoQ== X-Google-Smtp-Source: AK7set/WxohywLbjKTqj05gM5YS2wiarYPup+fjTgxmjn3UL9yS/QpCzDeS59TtDqdl+ZQqqvZJ5tA== X-Received: by 2002:a17:903:2283:b0:198:a347:44b8 with SMTP id b3-20020a170903228300b00198a34744b8mr1575953plh.31.1675222588625; Tue, 31 Jan 2023 19:36:28 -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 v5 13/29] e1000: Configure ResettableClass Date: Wed, 1 Feb 2023 12:35:23 +0900 Message-Id: <20230201033539.30049-14-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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: 1675222744602100001 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 Fri Mar 29 00:58:29 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=1675222875; cv=none; d=zohomail.com; s=zohoarc; b=acGKUA8lTm7tlbQX9IFqD/tBiaatgUOFKVuwMwuEHQp8iH3xPjk/BwYjefELVm5es3XX8zMXeGTQaHAN/4iVTHNvLQaISvLe4Ueh3ECjzxOEP53rUjMLb7Kv3qVyS+PvcsFt/T93Vhon5oENfLXfuVzR/fmnkBF5La+Vn3/unQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222875; 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=M8dEk8lm16tjo7T4UMc3v9WO3kpLNxGVyHoLUmfkMzH3jkmUbyrEissdIvy6nhjVuOpvZNSL6oCyDaEakBpqy/kIktEgYsRr1rRBYLRYlwyt+sXdreUpDPbIGplSkwzAl7kwB8f3OEQLcbswOOzcevfBNEFSnPukK3c3tBzDG40= 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 1675222875812600.6053367275848; Tue, 31 Jan 2023 19:41:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vI-0006iA-IO; Tue, 31 Jan 2023 22:36:36 -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 1pN3vG-0006eF-Bz for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:34 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vE-0000PH-PI for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:34 -0500 Received: by mail-pl1-x629.google.com with SMTP id e6so8951215plg.12 for ; Tue, 31 Jan 2023 19:36:32 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:31 -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=ZcvVBZWQUGQ0UxlYQxl3IpZ1lJMdv61l8aXjsIUSuwrQAAdftzv8ossBmX7F089ow4 JnBmP5aS6I338COFrRSx7K+LNAtyUR3o4R4lqHxGM47qbGGDVuCSsd3iUOTTFrspr3S5 uUEDOYTGfA3XGs2AQiEGenMjrErb5BZKEYVT198rfpu5NoNYTTY3O6Cg7uKYwk4XkL5q cBmOcCX7PK5tOz2lMze0+bEwUj1IcVJh6nPuQCJ+z217Se+us1NdvKzN9vHvLcirHnlb mbAkBYkac4mdwsTkCL9ppkLZxAPGO45mNea87COXlEhMmRnLJxxH2dhjWuLfvAGNtMK5 jIPw== 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=c+H6n01pQlG7VLBLBT5Y5yDtFutH4/6OuET1vYRoXMv/NzMG/4lE1zmi/4pbehuqTW KacZRNRsh0oQlzEwyvVTIPaGp0wyhIfJFPI/7yB8y4I80e1TttJV8rR0FWYYgp6+9dCU kC6Ouq7QWugJvZRTfyhRibYgg5hChX2BmAGz6cooIxHKDNiZhDSUUALjXOFR09CZyxNR OHvwJtjkjghT27ix8bet8bc5/t8Xxni+yNRB1ZuDuqCp/DmatSKFBTJIXs7FiouSQVdo lRRNetRHf+lNoC0KZp/TL7mImL6gvY/eiB0Lcy5bxYIpiGGkT4MWV7iceSlTcSh11tdo VTlw== X-Gm-Message-State: AO0yUKVX8e3bgp7fhW+Ya+rU8f1xj7FPolnZgoDdMYPedSkc/+6bTLzW FjBK/c3gUBPA3TrZg3pdmV/TEg== X-Google-Smtp-Source: AK7set/YzOZIyU4GQzH6PbYnUPbBDV//f9RdxdjCoHdb+qbAlxSuEzYh5Y+WiCfQAWqPTncVX0dgkA== X-Received: by 2002:a17:902:dac8:b0:194:645a:fa9a with SMTP id q8-20020a170902dac800b00194645afa9amr1694365plx.8.1675222592022; Tue, 31 Jan 2023 19:36:32 -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 v5 14/29] e1000e: Configure ResettableClass Date: Wed, 1 Feb 2023 12:35:24 +0900 Message-Id: <20230201033539.30049-15-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::629; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x629.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: 1675222877306100001 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 Fri Mar 29 00:58:30 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=1675222665; cv=none; d=zohomail.com; s=zohoarc; b=evEpsCBlZKhxuphlmXLkwZYCy7ZI49HILGgl8V7rgcyou3DbbSm0f3n9Tw7wHn5PLcjM98kogjR7q4KFrtDkUto+yoHUC6BYP4KMDbxHzp6KV9X3F9QsRYoyrMJkhMZ9Kyrijj3AftW+1E1fvHAjgvUaa7FOhzwXvYmq0qikPcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222665; 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=CUXhFeZXe2zMGF+sagZ0RdCpconJKo/4KYgC6GRRuB0lQ9ug1iIDc73ZehNeFODs20jrHG5Zwju7sk7C9pzS6F7tVVTBKLlYvxydpOaZOTHGphiUrmcD2aaaE6zLU/qw6y+YQUxoyQmG0sr5CtWtZ14zI3Rp53wAhxo4aINV7ns= 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 1675222665083705.9223786133293; Tue, 31 Jan 2023 19:37:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vK-0006tH-PD; Tue, 31 Jan 2023 22:36: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 1pN3vJ-0006qS-TI for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:37 -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 1pN3vH-0000QI-OM for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:37 -0500 Received: by mail-pl1-x630.google.com with SMTP id v23so17188722plo.1 for ; Tue, 31 Jan 2023 19:36:35 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:34 -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=X6hB2yQzTmtxglBbGr8+44kQaY9GFndKZh9DTIEiX0SrWrcqridfkHAy8RzH19ztm2 CBVsCzMaBnfztQ1i/pV1cI0if7LMJVKQMAvKgH4IWKh3k2D+qRYIz49Co1FqSkr2WBGF gOdJos4OJFU1bq5y4CmQFg2u+ydBy6uMhxqKgKSk8BzOQds8AriNqgsHLWY/A0q4Dlee SAC2P/X3LVKyn9c5N46NEK+dO+DohhtzsA4uwqmlMRwbPDNb2vXE7G03ppzZzdtBpFO6 rvEIi9iA7l6AZINSxShbOgQiqYnw0c2aU8+Lc6P4Zvv9xnkg8ofiLW1rYh/z7ld4oBX4 1YxQ== 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=yWk5TWybF1o3hOUJM7QBm7qt7YNC3UTwTW37UHW3nvw6cH3FSM6KEMmiT30lJUg0HJ 2j2UoLUPbhjBsMZbpC7ePyHcRTjw/1jmtvbYuGW35sEYk3L6Sxj+n4i9PVvt8K7sFXqn nqoml3yjCGzKPiPjoqlXq/oHc+BgKIS1cWWmLnAf0hbBQZPuYtuTxc0uXGajQEXW7UW9 QtvEJkGuEQY58aU2I++YK2sHQzIhfBpqtffwHrj8jNLHcMiXhAqWnuHS6yAozLPxpg2b FfatDCPI41Rwpmq2lSdio68+zDuayDmImtS1deMD3Fv/wOiJfJSqLFS9d7M5cxB4mvv5 2lmQ== X-Gm-Message-State: AO0yUKUVk3KyGw0IEsuTBNhNMSQIrlXs4n+seQrGcj9lu1u8TVxMy8qL XqW6Lu6M54kIVT2wwgQNFuij2Q== X-Google-Smtp-Source: AK7set/EYQyJmXeyVHbHVNvjw+YG7IA7ogBvDRW6V95zuXb4vtMgGKMgpP8dq5utQiA08FKgi5qyhA== X-Received: by 2002:a17:903:1c6:b0:195:e590:c7c6 with SMTP id e6-20020a17090301c600b00195e590c7c6mr1513366plh.22.1675222595069; Tue, 31 Jan 2023 19:36:35 -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 v5 15/29] e1000e: Introduce e1000_rx_desc_union Date: Wed, 1 Feb 2023 12:35:25 +0900 Message-Id: <20230201033539.30049-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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: 1675222666248100003 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 Fri Mar 29 00:58:30 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=1675222655; cv=none; d=zohomail.com; s=zohoarc; b=oFt/3WPi732oGW6CLGdJq6BNgmLgvR7F7gCT5UZPGOMyTKzoe+Wt2vPD2YwHDORLMjF53jOKQ9XYT+iDo3fs2RZtGPEeUsf4gElM/IjCdqKdkA9rFqY3sdicMgwbE3/ATv2zUefGjHWSA7/wQN/Vxpxe956t42Eqjdits8pS4jc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222655; 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=OWVkPusNMbYLPV3HzFNR/f7ThitFTXoDF3vmg5QjJzPJpkiFsyzj7OpypiAT2jWQFYYfjlnuOBt9owre3dbXkD8jD5J1nwK9XjdxC+RsJBhA7f2ZpUJ76svxtquCFkOm9Cgk5jf96cjs1gX1G7W0BjaIEVoRy1mLbxMXNZPh1VY= 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 1675222655647631.4511762055771; Tue, 31 Jan 2023 19:37:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vS-0006y0-96; Tue, 31 Jan 2023 22:36:46 -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 1pN3vQ-0006uv-QO for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:45 -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 1pN3vL-0000Tr-OK for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:40 -0500 Received: by mail-pl1-x62f.google.com with SMTP id jh15so8130449plb.8 for ; Tue, 31 Jan 2023 19:36:39 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:38 -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=L8mCLd4v3BSUybE9fRMSAGDN6e9G/K5ZmoHSwYLnLP228rMtHYJyNEjTbDNB/Qx9OY zeWAM7+EcXPXd9YGuiT8jWHFtgEqDVHMfn0cHgfHsALevXQPR8XuN0nE67P2bUZS9Rw/ XcQYPKZdl5VtWAsesAboIu2TFMhejf7GIIvm80LVpEsB6+If9Zab+ulvVzCVs4qriuvI Rzx4Rq/Il6lQbW/uapl2jJQYBJcJUvDlKkcqdc6uc9Mg5E9iG2CWOmpu+JlaX6ocJl+u mnJnfif8BLONh7o83WYYWyZGEPbOQEf9nrXwYWvLDtotiCIzp9qsjAoVpCkejPOrxpd9 87Jg== 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=AzmldjkxdD8wEAvBJEluX//cMmiORXG3+hwZJbEOZhZI5r/Kd6CuTwKv3InxaJ7c8P IfnHDEXLd6+gNZ1oeLchcJI0JoMtTObB/74Rj8T33wEnpYQbE7+r8xlP0TK5ExLfa1Ud T5P3ZG7dV9HsCFExRl2msWc4zYUYGmEYzlisVFv+JvvNgXVu4XD0GsiRgSpusCTFOCDR Y0YAsNdAPvUWsjSJZ1owuoQejQFfMyIPoejS+Gc9T9if4ru7K3dHrS9Ox1SsrA9eaUIB NjwIDZvmxTSdqz/0bM0UEf9y7Fs1PihgKj3kxeJZx7DGQFjPjimT/RQObrK5saIn+c+4 88uQ== X-Gm-Message-State: AO0yUKV+ueBotyFOf37SChssXOvNjiG8aPcp8/ShnOlR4hJUuEsK4lGq FA4YfN2UA+s3Iyed0Ja3930Qsg== X-Google-Smtp-Source: AK7set/F+tI6qDsNLyJnIy5q3Pu0NWJM9j3GjuAsg5I0ZbQmhwxm9WF6yoJpTJDytkJkRv4LHWOddw== X-Received: by 2002:a17:902:f0c4:b0:193:6520:73a4 with SMTP id v4-20020a170902f0c400b00193652073a4mr1064377pla.61.1675222598295; Tue, 31 Jan 2023 19:36:38 -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 v5 16/29] e1000e: Set MII_ANER_NWAY Date: Wed, 1 Feb 2023 12:35:26 +0900 Message-Id: <20230201033539.30049-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::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: 1675222656162100001 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 Fri Mar 29 00:58:30 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=1675222752; cv=none; d=zohomail.com; s=zohoarc; b=MiYCoGRS2A/sezoYn0FLcMSx+SGe4pUN3T2/5URY15TgKJ+6wpefiXSm4hlBvx72uD2vLwww9yWBE1ZCn2LyJPSKG5SpZ+4I3/JI0LFilRc4BJKkgsuILzQZAU0jqUpzVJtLkrMfiyKp6XqIqT4vMf6woa0I4nzdpzF9g9oh3lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222752; 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=GNjELo4tcuzI50Czzz0s3+9eiGC4NrKMUiBUUnzXb0yTKoYL05wqoZR0UePr+kk4jgZtbQoLt2fRzmIbAOzD3Bi5RaYYi9S9Xhshk20Tk7web7XyF/XjijUU3MTK3nHFxqYP8vYbwoar8PXJAmb6RM3OFO7rhv7nCKFBeMbSnqQ= 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 1675222752216958.4910989312834; Tue, 31 Jan 2023 19:39:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vU-0007Cd-Bn; Tue, 31 Jan 2023 22:36:48 -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 1pN3vS-0006zJ-CF for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:46 -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 1pN3vQ-0000VV-Ip for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:46 -0500 Received: by mail-pl1-x62d.google.com with SMTP id b5so9927972plz.5 for ; Tue, 31 Jan 2023 19:36:42 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:41 -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=Q2ao6LKiPc03tYuhEAiQXlQpnt3d7cuN7szw254pZhKnR2TUhTs7i3W4p5nITT8C6r 4FijBCLzHqDb2DWHyuHp/znQ7CG/bdjvCyxM48YS8vbi6WL0Ez5Vwpa9tEdmLWt21VXm 5B7OjpSfS7avB52o8T0SPzIO0Pcldw3/PGBkHA2bEpukBjU18Uu6Ve6S5rFfZ5mV700M jjUbyzx5vwI/OZJN0U+GpQwa4P/3fdQtgmpFYPNa9mEB264cDsIEFFL55Dsk/i6yfaUz xy/i3GOzXyclVhS1qS++sx9vVPEfT/oduFV3uQyqjHVt23PUmJHzpm+2gUR8isW2XQSa aN4w== 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=dGXqM7ou7vOTES+1jfv2mgyttXyAIPAVsi+LK5sMdsytD5WWulSt1XJQnheQ8b+GBo HRDEMw0tiFFknJNFY/PqbvKVLRlEZo1DdlNYZgGDAt3tunirIJbautHdLjtH8D++f3sj gUQVajpa9oqgJjcboJYPhV4D3XTpEWFmoyOP7Hgnu40ssByvyNYRWsBUvyehHXSz9fr1 6QNZxzq6+n3QjhaqdtI6at9vNss+LgV/OIvTmEuoEHS9VfCVdIFJVoNIb8KSNi1RU1f6 nOAsBB5yQmYRFLd/dsEYjU4o58G5grnTni4LV5s7L2Iz6ISKYOdM753FrI2UyQcWJjfQ hp+A== X-Gm-Message-State: AO0yUKWETb/9DkpidorDzU6kHDRGIG/q+hALFNtXBkpj8wRojis7n9QE GYF5xDWl/Ag6/KvkYTy67u8gYw== X-Google-Smtp-Source: AK7set8lqmyNMOBrk2uTAaYeOrjqcTnfvcNenoFY3GwqfG3VoKAVtiQaC54intx8L8rjTOgjFaQalA== X-Received: by 2002:a17:902:f28c:b0:194:afe4:3011 with SMTP id k12-20020a170902f28c00b00194afe43011mr1118943plc.52.1675222601561; Tue, 31 Jan 2023 19:36:41 -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 v5 17/29] e1000e: Remove extra pointer indirection Date: Wed, 1 Feb 2023 12:35:27 +0900 Message-Id: <20230201033539.30049-18-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::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: 1675222752692100001 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 Fri Mar 29 00:58:30 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=1675222684; cv=none; d=zohomail.com; s=zohoarc; b=AActZpCVWrbc1o8pgm+Gb8ry2mSsLB8SHqJ14HDgDqRpI9OWvDu4uPKk318N7/RuHtj/vqKKzm43DX0Su/mXbmywGlc/PPQqU+/4YA8WorkYUyeLXWTY4qd7wddZXEHhCWlHEICMt6j9R3ccFASAiEJts6qMb0uQgMOQvMNswec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222684; 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=ANZ2tvlymfXtSy2NHTRVgvdqaQF3589MS4UmOOzy0ME=; b=O08wVPL1Ig2bjzAZoGR91UG1l91D6IHAr08/f5Mnh06xlzz9SgwzCCbTttWQ0orWO6bAVs8tzWDpbnvNKEBxu9WM2K8NFYzOoZDk9QkzGOY90hD/e4PYfeOdV4M3Ca797DExEaAmhkc7OWf4OseCzVXgUZEZ82w4HB52dCKjfyA= 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 1675222684111497.93698157362076; Tue, 31 Jan 2023 19:38:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vV-0007KC-85; Tue, 31 Jan 2023 22:36:49 -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 1pN3vU-0007BJ-18 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:48 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vR-0000Qg-Ai for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:47 -0500 Received: by mail-pl1-x636.google.com with SMTP id n13so1679075plf.11 for ; Tue, 31 Jan 2023 19:36:44 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36: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=ANZ2tvlymfXtSy2NHTRVgvdqaQF3589MS4UmOOzy0ME=; b=jI55CIV84ClhDtgHX3v2dxwrmtZoyUNkOcre8T7g4NlgpE06Q6vuE8GMGMwhx0XzcI a8DEXdS4/LUD20H+6/jf3HNWd0ygyilRBEZ1oH91NOXC2pip32H2QtphXwr8ipEUbbZ9 gEhMLw6RKW/8ui6QMAqD0hyJGgubFBK1fWuv23HGQ+623Ks6G+EEMoSaBX+X44kV0YV4 sfogy+HUSWzrYrWYlEzABeE7WOGw1ZHdCwZ03NJxsalKAY3s47JjdO5/awiCygBluXur IwTcey48vc/dEF292de0tYy8TtqtF3E4hyFHSaCFGldUhbgpLSgnbWdfZNg7hsLqQRyw 9gFw== 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=ANZ2tvlymfXtSy2NHTRVgvdqaQF3589MS4UmOOzy0ME=; b=YG+fnSFK/nLTEdkj5Mt9LfjKKOSW1aS/uqcZTEFEMBhzGclNZA/Yy8uW6cIkwkcQLg Vvo5IoEc1+qQ52hs5UZhPgGZq4xY0y3MqAKgC9/UD/2+UO/HrV9N+2zi5MR7gr8uzXmi ttoEXUamyeJKO72xgqN4IijBBPpWfFvCMGQus/HA7SWguRfqBY94lAGuX9F4NGfe/bwr 7YqBxhZc3RBW/83jJxoM67wVppPxBVoHgHVAKfpb2Wcp0m2dprfZVsO+5SvsctaqOSek ZllzmjrMSdR9WCFK6hEHz2kQeiXFDuj0VMX249sevjviP5byOjr0Ld2e8vvrf4OnFKfU iTog== X-Gm-Message-State: AO0yUKXmJMGtl88PIg0MjJxPu5cjYgFJrLrQMUq7DcaeroRn/PIwz6DH DsAle6QgPJXunrVx/GiDSqa1cg== X-Google-Smtp-Source: AK7set/LFxC97SllwUQSL/uzttOqBaXOp2Egv3WKRAPfpInQvcRVHqjuw3eWmh1xLyJuJ8FSTHQEyQ== X-Received: by 2002:a17:902:e34a:b0:196:7a96:cd8a with SMTP id p10-20020a170902e34a00b001967a96cd8amr1113289plc.32.1675222604632; Tue, 31 Jan 2023 19:36: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 Subject: [PATCH v5 18/29] net: Check L4 header size Date: Wed, 1 Feb 2023 12:35:28 +0900 Message-Id: <20230201033539.30049-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::636; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x636.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: 1675222684391100001 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 d2ab527ef4..c63bbb59bd 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 Fri Mar 29 00:58:30 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=1675222690; cv=none; d=zohomail.com; s=zohoarc; b=UmXq0F/k4FHNE8/NpmP1K/nUCK2gRBLcjYKdCmV+4l4ajdXB8/uPoi88A0uI67+fh13LbvwrPoLoU6Sjg9okOb7yXrBQ5eBfXnsVwmnKwg+7wA9uvmZa/vg+Vs2njm7KzfgcBQelTSPHg1/PgQSZuLnHe+fgA91P3Mv/7DmiImM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222690; 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=nMVAK7xdiABkwOyMnKK7kPiirmq7+6AZVjgYf+UHg3hH7tky4PEpRWaiAQADmyBWb1JEWgHg83ywACLF4OTlPWwHDFGc+JpHxKEOIsryxOzQ8lXsQxwqthYSWXLtJub5V6hfgChnpppXxr5tPXTGgA4zbmcEHZJiZ3K7FMm+iOc= 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 167522269031856.50199783127209; Tue, 31 Jan 2023 19:38:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vY-0007jm-Hj; Tue, 31 Jan 2023 22:36: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 1pN3vW-0007X0-OP for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:50 -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 1pN3vV-0000X7-47 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:50 -0500 Received: by mail-pj1-x1033.google.com with SMTP id v6-20020a17090ad58600b00229eec90a7fso2694732pju.0 for ; Tue, 31 Jan 2023 19:36:48 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36: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=eJS1Pbqh9Ag1EwpA1FCoisIP0ormv59FdxySXT2YRbY=; b=RGKxhxwOsdNLCDXSbtD9eAnEZog4mdDyYeDOA8BsLwidwZgqJ4hc8ks7Y60j48S9jD Qn6Llxlry+8wuoaRbJQbSe6IXpO+Z3cIK61XerlsHmE4KlRwXReFWqO+luTyVWrv7elL d9TYoKh8Eb+I28TS1XKpv9ddC+zAcdoa813wXtTz+Uy/j8hloNjMIWAivMb+MRrfLmmU P14aGadR2k48i1M44Ta8Cj6rnWc1k2owgYSbu4TOWT7ZSGdiHK6vrr1VHqqBftD31mH/ pIYq2fF81ixb9ZlMKBe85VKgkWni7MsdDOWtOTTO2EKfI7INjcArB6LH9NW86Efj67PC +2Xg== 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=21SRTPf6z++v3DwntLiH+zjqJWQqmlEWpKAUyddRvrlb7jr59Zsb4meRMR4TTscAs9 pb1erow/4cPOTUDuL2xlizpKSA1NdGSz4o4OuTJLNXao13RkfQ/Hxlv4ayuTb3Un8uOS iH9YOmg9+kafT62DfgxR5GobtHqQPgxzAwDokFnv9nIuEVZl7Qka7gB45G8Ut37Djamw VJ0Ga6UpV2/4pKFWJ5B3y1isgo/SPzR8CO7ItH0Ocelykw1zsH1BQxYaOV+WJQHaDN9t ldBzXs6qv6LNZr2CH7GXwshgJi8Uru+zPfESQiJ4xybt6M5izw9fRGOtALAroub/oh/J WG4g== X-Gm-Message-State: AO0yUKVCSbJH3Y4hB8kPeARoHLU5hVD38YuKWC11dZEaCgJLByMhCNdD n5DpXz9U/VD8i72E0COXZ5saUA== X-Google-Smtp-Source: AK7set+o6HOaNCzJj6OwZdQGzkO5zi+PRr9CVUzU2tJm0N0AQQEIUHL/OxhstiG4lMLeB1EH3Mj5rw== X-Received: by 2002:a17:903:11c7:b0:196:489a:a79f with SMTP id q7-20020a17090311c700b00196489aa79fmr1663046plh.6.1675222607808; Tue, 31 Jan 2023 19:36: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 v5 19/29] e1000x: Alter the signature of e1000x_is_vlan_packet Date: Wed, 1 Feb 2023 12:35:29 +0900 Message-Id: <20230201033539.30049-20-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::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: 1675222692364100009 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 Fri Mar 29 00:58:30 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=1675222701; cv=none; d=zohomail.com; s=zohoarc; b=L6wZBcnXiyXcDy2QLtxPCX7HVl2VwiH0CYruCvClK1dQ7ONzEqXmhKLvw1UzZv3fJp5TfUtIIizBBSPjbNatmOjtO0nFWR6pjjnBZRx3KGveln+Nxa7sJ01bOolaUHG4cp85rg+ACudfjKHe057fZD+XjJomV9U2RCSxYF0TwDQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222701; 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=08HI+/g3J/zU/4EQGD9UqV5IbiaomXGENBnHx0g0yIg=; b=m26eTZLRrCVjH0m4d50Pg8c7OryCjRNNArtkzKyMOfgIv/vNb0CwmeJq1bSVQEEQvUp14KuX49mjYblFl5jhdsu+pN5SJ7afAKovUfvDt27Rlb1PZxj/cWQw68CDpAkq9JrMEwPhbct12/kt1YMXlwp0xTaq+y7QYuspZ2lfDS0= 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 1675222701251551.5663901250578; Tue, 31 Jan 2023 19:38:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vb-0007qV-0K; Tue, 31 Jan 2023 22:36: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 1pN3va-0007qF-2d for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:54 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vY-0000YA-9r for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:53 -0500 Received: by mail-pj1-x102b.google.com with SMTP id cl23-20020a17090af69700b0022c745bfdc3so691296pjb.3 for ; Tue, 31 Jan 2023 19:36:51 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36: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=08HI+/g3J/zU/4EQGD9UqV5IbiaomXGENBnHx0g0yIg=; b=J2zLQb7TjcbNbMrKB6YBWyduishRC6iDPMhRgrFtJL7DLeiop3fmJ2CXvgUV+LrXxF NauBM2EVKPCWs/ScbBvjGqBg17aPDyzLWoZbNWSAUQWitgWtMWcAvpciQeZF3q3Qwt1T UzK+suO/5HXKC/CUlur+iuAC1oZPHJIt4w426sTJj5IvmAKTlrweovRbfiS8rcBueWXq qmA7dbBQRBPUWpB/YrGyrga0hh/63zKjRQ6Ks0pslRKPXeG6b4wnbVMgTQJSHJ8ELchG HXDYa77/Fk4kfeiaifyJTlW0ZHGwB06IM7F9UW6a28VkSEyOMIx60cJj0X94yjAsnn8N V2MA== 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=08HI+/g3J/zU/4EQGD9UqV5IbiaomXGENBnHx0g0yIg=; b=ZVQGxLN6HdfEq007aIrCskwnP1S8WL+ijIIrE6HKJLmJIVU8f5vLuiirEv//sLb4AI j4CL6dsHCZi6kKYr3T34qh65u0cxtaPKq5VCLV6bta5z+UfJg34Z0GMQWFb2orzzJ45N 8gl7F9V/ZBlfrR572ThUmcKcUBCdUPcSLTkJ0OnhSrFl62/sKB2hnU7ODcyQylz190AW rLiJgX0CgEjDkvFmtAdMqx36j+5T02/R0YL2S89rMlWqDCGkoIDXtHv42tW7+vXWHwwL er0DbHb0BuSuAzQWiGFYHTOhvMtF3Q3QD2vjeWoipy9feGBjFVXuYT0Aqw3I5KrHVcHN e9eg== X-Gm-Message-State: AO0yUKUpS3A5ie22UlpbC9iwi8urpBX5ALsAS08E8s61tpwUuyUy8oDy 3lmLMULj7UgixNICY09KBG3kNA== X-Google-Smtp-Source: AK7set/ULqgqhfPPlwzbOaj6ClPVHlR0WvWOWJq+VBvMNN1XV68QJtZM/mhk4hGYLlh8Zqmn85WRkg== X-Received: by 2002:a17:903:214d:b0:196:8292:e879 with SMTP id s13-20020a170903214d00b001968292e879mr1136053ple.1.1675222610848; Tue, 31 Jan 2023 19:36: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 v5 20/29] net: Strip virtio-net header when dumping Date: Wed, 1 Feb 2023 12:35:30 +0900 Message-Id: <20230201033539.30049-21-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::102b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102b.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: 1675222702395100001 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 dc20b31e9f..4b2d72b3fc 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; @@ -183,9 +187,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 2d01472998..03f17de5fc 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 Fri Mar 29 00:58:30 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=1675222843; cv=none; d=zohomail.com; s=zohoarc; b=nVhZiuAOfJeB7ev0mEXyZWR7Tdmbs2+33rF7LbC/J46a56N+PkFAWMuxojnciPZ9PqekmXnWVYqNJMtQD3ig1atEGklDNitpT1rrzNEbPRWVeDzCGkvE8pK/57UjWVwLzoQkZX4lXW7n4KD4z+NyNZFJD0pdYRvXIYNXMwYpiSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222843; 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=UcFLTjDv45KCpptCdC/ryRw5eMMuSI6G2rmXSFY7zGk=; b=Fots4KQdpNgGZuZRViIPjX38tzOojcncOLF5gnxOaYw5Bm2lYv/cpmdMZ3KIaf98tozWZsCgctYKBDLifyKAuu01ywryt7+YOubmGNseqUhxgHYUQGrUUopE0c4XeMCp831oPqvdxzEewo146TTScr5PP7TR7kD+xLW79fcyQ6A= 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 167522284348477.09876115583836; Tue, 31 Jan 2023 19:40:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vd-0007sT-QP; Tue, 31 Jan 2023 22:36: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 1pN3vc-0007rH-7i for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:56 -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 1pN3va-0000QI-JX for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:56 -0500 Received: by mail-pl1-x630.google.com with SMTP id v23so17189230plo.1 for ; Tue, 31 Jan 2023 19:36:54 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36: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=UcFLTjDv45KCpptCdC/ryRw5eMMuSI6G2rmXSFY7zGk=; b=kCXnf+ZQr/7KNfEWn+Picyl3U46D8//d7x4azXwi2QJcJqF9InuVB8kWyiNDYF5fPQ El/v5zo7Hg7YiUqHvneA7s3QqWdYja0sY6Ctwa4ieUzQWV2GTIajWhbZNXHR7BloEiAn ArWNcJhU6dXPr1NkgqYYISjkDN5kXOHRXOUXji+sIWuTjZCF7Z1iUjOK/FuSm7aYlZXc r0vSViZ8bf0ekP6012cg3mWja+UQAbqzZ2hDpqEVndhEZBiz+BtV9VCQ2UmNBV3O4apV kkQyxRRmuMrmIJs0CDwx6tPO+09NdGdg9tpC6ddbhqxtHuEJ71p1aYxpFaCngem+vzA5 ej9w== 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=UcFLTjDv45KCpptCdC/ryRw5eMMuSI6G2rmXSFY7zGk=; b=hk04aGuzXr0sbq+IwkSe1KBX635CyvcTQy7+sx5UQVZynE/PPThVz/Fv3FRUAnc5vg NJPBbiyfS0E+aOhJRf7993CpstVjbkTr//Q9yrbslBmtPW9bF2UvwYWoI8SdR7Ujys5Y /3pAfxO06M7oXkztf6uZTkbLDd+oqyWwnVHoRF8wx5pJbMI3l3mXQ7s96UYKrbinpkzf hRxOPPMwNsEWLzyaHPkrq16XESfyH2A20Nl0AwYIrDglJPn/0hSca72H/5J67WVJDuxu yAVWBhrawxNbslWDC3l8UfIl9pdapoyUgKVyP91ZsTM4uA+6GS+sjlIXa3VYrh6ilde+ N6ng== X-Gm-Message-State: AO0yUKVBRetBD8tf+254w2VGsw+vKLK44vtwB2qliF21SvzUrZfHVdsf yw8q1xHkK1+SagsANjdiNX/SJQ== X-Google-Smtp-Source: AK7set8/pk5zfTvPq34fINoC6BN9m5Be54dk5c5fXRAoFdrqmN02T3M579dOc6+AXLkB7ptC5TsDsg== X-Received: by 2002:a17:902:e191:b0:196:35cf:3b17 with SMTP id y17-20020a170902e19100b0019635cf3b17mr1258220pla.36.1675222613956; Tue, 31 Jan 2023 19:36: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 Subject: [PATCH v5 21/29] hw/net/net_tx_pkt: Automatically determine if virtio-net header is used Date: Wed, 1 Feb 2023 12:35:31 +0900 Message-Id: <20230201033539.30049-22-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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: 1675222845151100001 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 c63bbb59bd..8c3f5d6e14 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 Fri Mar 29 00:58:30 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=1675222650; cv=none; d=zohomail.com; s=zohoarc; b=byhcFBSDRSXQAUemRyTL6xRWFbkWIlVSztLp3As/C9i9+JmtACD1eCS+WRee3CRRYPRXBUgRcG+F5X9qvdr5WNENIWtvmkMEc2o4TOlh2LJIF9TKIbJeaK6nu/qzpnYvY+/5suxb0ffsW+eqB3PMDMOxly2CEAfAuDnObRfLFOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222650; 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=7I3zAPfeFojTupunid/+QowtllUnj9+g6fk7fhj7MBo=; b=H6vD7k0CvoUii7hQuQeHEgLfHKH+Em2ZLJt8N7SgutyHZ71VBgjl3lA0DoYXZAA18EfBVfQ97KthKXeM7WSbSsmI5SNMofWng1h7mq6C2f/X+6zLR7xQv11luiLs/ZLbYUtY5Y+lDsLv/v9PVGI5iXWRrt9XWNGRE5UqPmUqh0U= 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 1675222649993783.1790678661778; Tue, 31 Jan 2023 19:37:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vg-0007vi-Vr; Tue, 31 Jan 2023 22:37:01 -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 1pN3vf-0007tz-Im for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:59 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vd-0000Vt-Nl for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:36:59 -0500 Received: by mail-pj1-x102b.google.com with SMTP id n20-20020a17090aab9400b00229ca6a4636so782309pjq.0 for ; Tue, 31 Jan 2023 19:36:57 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:56 -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=7I3zAPfeFojTupunid/+QowtllUnj9+g6fk7fhj7MBo=; b=sCcdWuNan7LZXE/TMPvWhAhxIiAimZMhQLO1z/pIX1/qNunjtiNFBlv8t5S3LYPyNg roqXITTowiuXF2NUwRWuhnodb+Ao6Mdk22vxmw+ZYufjJGGEKcjmq7LPIhhnx6UQ8y3l iBQrl5yboXXf6D8wQBlZ3SwriYoXqmGeyAT76ytOK8Qc1UQwDqBh8nDZTqQj93xwqK60 UfT1oqZXvZbj3QWYza8ZeZ0h2YLJAqecpoj/MWiN36gkl+eNoZ58qd3Cfo6bBcddALeY 43Ymo0cQK11cFnZUHEH6AkbQ6zEAwWl0kGPvQu1HeaHKG1Fg/fRLotmLeQM14a6h0/eT 4kSg== 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=7I3zAPfeFojTupunid/+QowtllUnj9+g6fk7fhj7MBo=; b=VmbXCyH5oe2OKbDNPzdtI7PBsYslAXo91hge4KUgUEerW4TclB7h6MR9N6hlYn3Ux/ ga/0Zz4wUsBLoxH9xq2sRtdWvlA81w07oGiQ2pbYCyLV+LjHGtc1Pw0Jm2dz1ZQoi41a 8fO2qCdiFc2EKRDQ0HwKDcgw2gWO49ky8LOIqhJ2CCngKca8YkHnXXicRIecxqpMxJQT ZktJD4YJOSBKg6oWc/Rwll1AD3hENH23UogAb3+aI0lAOPZxzNKwRuxfEaP1t1KXWQ4I SvLyopS3Nk2exy83wc1JkNhhUPgsssMhY5nRcdFKiITo8Xyoer/j2s6zT184FezzgTLH 6H4w== X-Gm-Message-State: AO0yUKWlh0c7gMJX+RqXEfMy0E+9cMQS2TdB8OxKAK33SYw4+gLJLvPE DfG6t+gf3IsnzLeJsl1vovTWGw== X-Google-Smtp-Source: AK7set82K431Lz4jURwzdHfZ/GhpFu5EDF2l10rGmIOXDhGn4WXrLOtSPstjdjmT+kBh3wl4VNNasQ== X-Received: by 2002:a17:902:e313:b0:196:6671:d68b with SMTP id q19-20020a170902e31300b001966671d68bmr1155443plc.45.1675222617063; Tue, 31 Jan 2023 19:36: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 v5 22/29] hw/net/net_rx_pkt: Remove net_rx_pkt_has_virt_hdr Date: Wed, 1 Feb 2023 12:35:32 +0900 Message-Id: <20230201033539.30049-23-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::102b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102b.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: 1675222652192100001 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 8c3f5d6e14..f0ded333aa 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 Fri Mar 29 00:58:30 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=1675222769; cv=none; d=zohomail.com; s=zohoarc; b=fociN7WxxGZBgEeM99Rqc1BEqq7HyOist4q/JSrOBRXJOUHBvFbUA4R0YTXG8jkKasU+DFEARYaFz1Uw8XwzpSBzpFPf7ngOeZADU5mTWC1kdI7k4DNgVoVidBuzkvz3lTyzfc1geI3gQ/aWAEzU1EXcVu0uGUGEgTYoXouD9lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222769; 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=AWaDKMwFgux7RF2soo/DFpNFMMb58N1ppmsY6h/tDI6Xs1KcLoj6J7ychznmQK9o313a+79/W1FUMTMPk32r13jjhWTAZfwhGBrDg6zKYqJLsbPCxS2bdyn6EFD82gIb97rUtwI/uP5DO58hIrvhSxwFmD/lOJjFj/kdnkukoe0= 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 1675222769777310.1659832116866; Tue, 31 Jan 2023 19:39:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vo-000872-Fx; Tue, 31 Jan 2023 22:37:08 -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 1pN3vj-0007zH-NO for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:03 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vh-0000ad-9k for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:03 -0500 Received: by mail-pl1-x636.google.com with SMTP id m13so5275566plx.13 for ; Tue, 31 Jan 2023 19:37:00 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:36:59 -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=DrV2eRTYje5K5lkCaljM3+WE0zd/ynN28P/pM0gNFf7fYIBI2TYB4RV2zu0zlGuR+E sfwdKYDX349RuNV56Jy61Tla7tAy/KnLErUatxbZPV4Xw5aGHJVvuL7EHbhwh8ouZomn uDbaveo5aX1miPN5NgC2+CPz7lTLnxP8cqdsDFm9Jm9ubkoKF9Yq/8OW/aN8wL6OypZz yzcknej1Q0VRBfi5qtINSYMufoC0DORPsdiax8UH8/Z692+1OwjTe1JOYA28h0aqj77a 4u2nh+9m5iXdk1UfK+kGTJg8+TvJuYI2OZ89uHRfIW9ef0y+Fsz9kS3t/Hph/7qlLToK Cb+A== 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=VDUVtNFWua5tWUAOtXu5zXfv+MvUGx5Qeb+OSN60cQPnaSmZNambxUAX1Ry6xgy9Qz 5hydxrg4fVhvUgnp/0kKmOGTcRuLHkvrhE1G8qnzOmLIRuSsg2sQ31fiaYHrhcbjn7aY nI6Gy1fz2oAiSM74062jH7x+hazZPu7DP6uaa/kMSjRzErtzmShiuqdQt5cJmuGcshPr azObX1rZP7ZC2UsAvK7ZtY/84rkKgqpcTU2rsHpiON4t8IQXF4VuOQtAJTn31L+Cc3a/ g7ygy7S0xXRP7aW/nt8qEWmjvAiNnA4eCX1ZASg/30XcLXg2PV4nmy1D1YKku78aZLvA mQRA== X-Gm-Message-State: AO0yUKXvDgUQ4E8e6MrlfCa3Qtj3WNVlmvs0WCUQeIHiin3DVmH0KDh5 tZAIsI8vinkIC3D+CZeOZOxaGw== X-Google-Smtp-Source: AK7set8tFSCAb38Dlob4sgXr+LaFb/T6tQM/zMEUl2xTr+mgnWO5sXRi8fAcOnE4tThI3AGNukBKNA== X-Received: by 2002:a17:902:f10b:b0:194:d7d5:f3b7 with SMTP id e11-20020a170902f10b00b00194d7d5f3b7mr10829784plb.35.1675222620147; Tue, 31 Jan 2023 19:37: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 v5 23/29] e1000e: Perform software segmentation for loopback Date: Wed, 1 Feb 2023 12:35:33 +0900 Message-Id: <20230201033539.30049-24-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::636; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x636.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: 1675222770764100001 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 Fri Mar 29 00:58:30 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=1675222696; cv=none; d=zohomail.com; s=zohoarc; b=CM3tYBOkuWc5wk9g6TtIKJv1EiWoxKvy/USC2sUJ0zebe/hp3op4VdOKtC5NCRQ8LEHPhWW8q0wefmlA/eR0Zk+Zxd4OU588yeQHjtyxz87jGaRKYxoM30tjSZm3M7A0WnSWarStO1gIz8GtmHfbnnAnIo4tF7bo/oMRgFSPXGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222696; 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=MOrPA4baLX/w3gP2nelnyTj4IM1dmQeINDONwYELihC33+CBagVZhjnatcB4ukdyYi5zQE8nKI2Dy8RsBXFmDABFqLTN0jnkfkBx8A3JjJlJO+SzSI8+lj69ElkAhfUFdBcj8MxV67/T+yQJjQK/uCiHhaulgJz67b59CRamzwU= 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 1675222696042259.2324314942499; Tue, 31 Jan 2023 19:38:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vw-0008WP-SJ; Tue, 31 Jan 2023 22:37:16 -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 1pN3vm-000849-8m for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:07 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vk-0000SU-16 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:06 -0500 Received: by mail-pl1-x634.google.com with SMTP id r8so10320948pls.2 for ; Tue, 31 Jan 2023 19:37:03 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:37: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=jv/afEJcthyHIvIcMbqTIPEoZmHEVzJWfRny7dTpMv8=; b=PnDSNIGN9euqV9THwePUCtKSTir2QKhhYdC+LvnQHOoRn8Vw2dPv4Gbp9Oe1vidazx e7JMnl4JWpNDrsU9b9Ovi3NfRuaPMBiN9t5vFl7gQT4wW8t+1WwB8Kuo5FpEWI7+fjuo f9J9t6hs1FmZgqHN7FjssedCgNn6F2YVP7oK+GxNOteL650Z/FVYztNWNm3/op+TdXpw U2yF1MCX9Zim6Fg36oIVj1pq5XUCw8YpJOEpj7y7e68hc/I1GZNzGN6vJgeYuJNbiXh8 tajn1+EuuSU3ytiuTHIIulRJUV8mUwqZ+rqXTDfXiXv6F1IlGt43IX2k4ql2u34RunCs 5cjQ== 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=5eyV1xa+8vwQ77IRj55V5s0DQITLBAXLI9E8Y+yFMELQxwYMv7bgsDMQm3RZZnkr6k a5buDxaKm7l/R9tLukllzNdrBQ0gHjpDJEmtOSW+STnsjaKI2JEZlXAsn/5NNGFMw+TE 2iPE/pUbD4sXCtgZUUx2Je0q2/Rh6Gp6en3e7jQ6SmT5yDTfy5fXpVFHvBPDw42VXW30 V9XTn6rWyHYMVGsa0kFmTS57iR7N0cxX8Cg/G9f3s1Gc0UYCaF6eqZebJj2h52Ov3881 d7GEtdeS9bcHf/EVcobiqvoTdnC66mXDWmS/JQih2btFHBWij/7x8s1pG+F0W8UiC+kF Ming== X-Gm-Message-State: AO0yUKVI2IkRI+JD+/tztt0CZBdslopt+I0uIXTA8QVAmUIPYt4+amtr rnezaEL6SsdIMV+PSpY/WDrpSQ== X-Google-Smtp-Source: AK7set+RqRivFZqzSjjLIB6tczKBOyp/weSeFdOum7XJQQ0JLvrc/ylud0L7jEJKBvzSCz4643+ZTA== X-Received: by 2002:a17:903:2444:b0:195:f06f:84ff with SMTP id l4-20020a170903244400b00195f06f84ffmr1507153pls.50.1675222623280; Tue, 31 Jan 2023 19:37: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 v5 24/29] hw/net/net_tx_pkt: Implement TCP segmentation Date: Wed, 1 Feb 2023 12:35:34 +0900 Message-Id: <20230201033539.30049-25-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::634; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x634.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: 1675222696447100001 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 Fri Mar 29 00:58:30 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=1675222730; cv=none; d=zohomail.com; s=zohoarc; b=aqUzJXR/JpIUJLhjaal74HVeuZFruODqoejxeHGR4hgg2d+w4/0O10uVl7l5kTvn6KHd0dvZou31CeR8fw1XG6N5CWihT2bw0RmJ0POu3gvRp49zL+J73M2xr6YDERlPNMOv69bdsQ6Bw2W1ueN+/qLh2YvCFHzStJ6ZkLoXAFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222730; 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=eSmTuqMrINqpl3bFQVn6haEAIj2Satq9I9yKxCdeeZOt2thPQkTABUF2gh2J8ixBUNo8JewiDhIQWvSOdK4pwvf6MUwOa7QBdKqrb9gwcGDH+FHbaFfcRB7NkUk0c61hX/PPydCX36G59Nn0U9T4JWHacobMgsynHiUC7NUzy7Y= 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 167522273036052.11376083498453; Tue, 31 Jan 2023 19:38:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3w0-0000hC-Cx; Tue, 31 Jan 2023 22:37: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 1pN3vp-0008CX-OA for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:10 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vo-0000cS-0V for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:09 -0500 Received: by mail-pj1-x102a.google.com with SMTP id l4-20020a17090a850400b0023013402671so720828pjn.5 for ; Tue, 31 Jan 2023 19:37:07 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:37: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=5140iHkZNuZn3I2k8biDJLxaiQwsOPdwZlAn0pvvLx0=; b=JRryQ5dAfQ6FnJmKIJg1YrIOiE6WIf1GTs6L4ILTl7af5+BE9b3fKh2r0qARGGpmBb dQJyuhLVX/pYoJk3SzJkddEj/l92+k01qS1Thb8TxIKZCIvFz+XtdVRW3Khnmk1jntpQ +hOkeVSohklQjuH6m8FlbIM96RQBKqTisGDTg4RZvY1Aprwg9TgDVMtbGWDH/40+Aipi o5qGQzZIQtivheJNdLymGCKF8ZS/pWenq4uSA8i92CB5EQnAOAdVbMHZi4Q4V8yjBf4r yxSMvYptaHLP8bV7MnBgIvfsl4lNHkvBrZpedaGmjhcQE8MRnWtvPcNnPCJ1xRh4NIea +m2w== 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=xhQcfn/O0vwv+Os5wH81Sy6dHsiPqNzSmjwuXOFyDev+pwvA6V6VCAAkua3HNUY4mY +oCOZyTvHlXocDGAKxV9lOYARq1Wl6wtUHCnurBQ1TmXdwexqHFhk3l0aXTBjTl1OLBT FMYZxAO82MRvFiC9cW13h8EgZCX82Wd4nAkdBihx8X3g2dtTz8Ymcmt6/tVjG8zG36Yj pRPJTXR5pcyaDY+ktgGTRZDVtOHFHu+e/+N4AEWctGc4l2wfKfAlUxqc1OY5xz1o5UIe ZrGUAj7Lb0bugQxEaVUTdii32Yxw9h8Dt5c1GCV2ziGD9+YEHHWC7dOO6vOlx4sZJ74W IIdg== X-Gm-Message-State: AO0yUKXWYbLZ2CukX4ZAxid7A1taIG8udyVU4O023udbQmO7CRE+h4Zx kQb5FIpKn8Z2esCs97rqNWuybw== X-Google-Smtp-Source: AK7set9nnmuS2niuuw0UV6kLNYIf91TnlL+tEwLXbGqjMvz3VNcmQ0pq63V0Cty4PG9sLVLTE9RKpA== X-Received: by 2002:a17:903:2309:b0:196:7a90:5f5a with SMTP id d9-20020a170903230900b001967a905f5amr1996160plh.26.1675222626358; Tue, 31 Jan 2023 19:37:06 -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 v5 25/29] hw/net/net_tx_pkt: Check the payload length Date: Wed, 1 Feb 2023 12:35:35 +0900 Message-Id: <20230201033539.30049-26-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::102a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102a.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: 1675222730592100002 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 Fri Mar 29 00:58:30 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=1675222875; cv=none; d=zohomail.com; s=zohoarc; b=QP4BQWR3AhouZVKMVIhNcLOJZ2UabpNGPxhdHkEOwTPaf3RNnHZiyxenTekzYTWnNNwE91ZwjhGcLCYooP+0sUjuPrLs9aSsf2VUDqr0VRUehiTO7xjHjPHlRC4p8P+d624cC87X/PoRBbkgW7celJo7Va9fzz6Hr6cUl+X+USs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222875; 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=etAmC/UO0+bCfhkvC9hY7JMoVEDf7EyRjJVURw8l+zT+CJ8Xtz9PVt8VyWndwY/QTcJ8WwCG2fDiP3A9wZ2LMNxZ6UjjaYhmnJaHgRkxBYIFj+rGKTwcsx4CLPU/xFHyJOMCHf8yPDV6p3dzoT84pXvZ8XqGUPGvC4sIhFmNVTI= 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 167522287552051.15041377021748; Tue, 31 Jan 2023 19:41:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3vy-0000RT-TX; Tue, 31 Jan 2023 22:37:18 -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 1pN3vt-0008Tz-2g for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:14 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vq-0000d6-PV for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:12 -0500 Received: by mail-pj1-x102c.google.com with SMTP id rm7-20020a17090b3ec700b0022c05558d22so684296pjb.5 for ; Tue, 31 Jan 2023 19:37:10 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:37:09 -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=FD5GgBhf1FJ3Rewd+L8+qDqtjy3sFI0yZ/QNNu2871KgiQ1ozUMPJqW1xF2p/mjigC lfCTLlSoP2GduiJ3HqzShaY1pH3l+g7TQOcaXl2vPKuFce0yJ8xzCRX6oS8PtriGeBlS s97K0W8P+TDWa9LXSIvsKIt+o5/r7uizV3zf5c55HPj9Sxs7jSJXH8hYWVP7wOhEvnNv wwB8tzCoh4qYvcQRnEF+LnjsEWTJtAYpB+K0Z5cgALGx2/wLGev6sOXP73TkWMW5Gqz8 Ewl5QoFrBbi3A/1qddZgtA5CAKRzJ36IsEa+8M5qkglMqHGQQHj5Asr9S5lZ/xMPRVrd L5oQ== 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=EPhNhSdCCKtXxKBtBCdb3GEvq9RkqWmYH/4ShpM7KxqQ6odSrYFbUriGfEWoe+fWvA ZPRNgSfvwR/VTGAXRIn1MfbfTw75IBRkfhVbEolC+g15qMmNwbk6WrQkTJhuvpYHgTxV nDd2PxwJ65nlFDx8h2h0doWtoRZAUZj0vxOE9cnAsawz89rMBRoQls0sGV/MYU4h9UVC qGerFlJchK7skITashCoO82dlW2tJoss/n0MupRGxogqjjbaz014Me9MadI80TbV0mvT 4X7C6c4KCSkG5Z6j4OBcnO56D2TDh19eAywNFYD6wt2WVIBBvMayDh9vJm2c3sxlpyGD pkHg== X-Gm-Message-State: AO0yUKXjI/AOCuvnbx5WidZEeY/8H6ihkwdY7IIkAHYJ72+8DuD8I9+U 2uJb8MyTd4+sb0zykFpqZMAYcA== X-Google-Smtp-Source: AK7set8bxmWdAuApEIXeoNSM3Hpkj2aLepey5A3/QI31xcnLnyHmNw6B0WHFfZ8wYEL2f4msp6ReJg== X-Received: by 2002:a17:902:f549:b0:198:a54a:f6e7 with SMTP id h9-20020a170902f54900b00198a54af6e7mr1717885plf.57.1675222629500; Tue, 31 Jan 2023 19:37:09 -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 v5 26/29] e1000e: Do not assert when MSI-X is disabled later Date: Wed, 1 Feb 2023 12:35:36 +0900 Message-Id: <20230201033539.30049-27-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::102c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102c.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: 1675222877321100002 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 Fri Mar 29 00:58:30 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=1675222746; cv=none; d=zohomail.com; s=zohoarc; b=gwkdDnt8/AioazdsD28D67xEetuSXTDy3eI2fH4YszL/2IcV/t3eQSLatyV62JP2av1lTs/MKzwm0szx7b+4B1Bd7bvuoZQGYjh+neqqj8+BF+wHHl+Aby2EXuPZ+NbwavTQ2QAuZ5EfTS5MqlrrEGc0Rt4rnh01K43GDl2hN5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222746; 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=ohMf18caqqQPgi91C0B3lsVIHsHFjokkBE5D4OLJEvE=; b=afjyDBhnyZquzZvqhd9tjEOptXMx4jMy2PcwamJD/C6krBPDgWoPESlL4Z7eii9P1v/trnd6gs4+kpQ0kUFxdJaMWDL8S+JSP5eVDQEjSGPx8vF0/eMhbgrHjwPlhKyb9z/sUqPN4c/jBB/nhuRLNv5R/7QLqzKk0GfRt0p4vtA= 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 1675222746567923.1436009040325; Tue, 31 Jan 2023 19:39:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3w0-0000jh-No; Tue, 31 Jan 2023 22:37: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 1pN3vu-0008Us-SE for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:16 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3vt-0000d7-5d for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:14 -0500 Received: by mail-pj1-x102b.google.com with SMTP id nm12-20020a17090b19cc00b0022c2155cc0bso685530pjb.4 for ; Tue, 31 Jan 2023 19:37:12 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:37:12 -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=ohMf18caqqQPgi91C0B3lsVIHsHFjokkBE5D4OLJEvE=; b=tfB3smQzM9Vpw0rLtYqk84SycPqOJOnTaFuUvCzFuv8Uz1w3OCYs7oWElzWpvBGrfK gRQ7txZPx0NCS+DokpJt2UoNmUfdp22wbE4r1frpBHE0jKjheBCzLIc/Nmw6FsYWLpMs ug5j58lqin/4yCI5NqlpI509sEB3bNMX4f5Hi2rPeMcfWd11kD5zcVmCTawjU5oxnQrV T1xMjR0+LEvqXYTGMK5OqVAVD1lf1hNToxXCFiirBJ0B0vql5vwmw/PfnbxTn5dwuNVF 79vCg5lD2jHfVPP+hNDWmrsgl8VY+aiYUFCrdfV7AlomVtaU7Mqx4+vlniO2e/9yKHYc dpFQ== 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=ohMf18caqqQPgi91C0B3lsVIHsHFjokkBE5D4OLJEvE=; b=MYHMsMdQcgRDE6bu09QJMg94/K35g98zCGSCVhseLiU2ndOJ8B+UWrFlufn4bVkzae 5oZWpBK9bYJl9O7vqdiaZyKqJWe8aOQzgtpyC6JY/mBMLKqC+BRPSUorFS9fFddzVTHC Z5IPVqzkyFGBc/RKwovX7dcbMwq5Dcolz8YI5HXrF/mz7Ow5erNEd9lWwaE1rDAYxXS4 xHqpeEq/vN2iaAVTG/mJDgLqtYZ/OzlPK4JySW8Hh4ykEsDvjKnvJS43nyArUmhWczth 07dZ+D7xHXROkdCaiVqF7Jlkc2mjfgwh9iqUox3MOjd6TGtCmjWBaXJMJ8MRN486O/GD 8O9A== X-Gm-Message-State: AO0yUKUeJ2PBAfUuPlsrMhYxmJrzzOFdt5+H8Cp1rF29H49ygdjoTysa vt8DeChWyKauFE3GTUmSi6HWcg== X-Google-Smtp-Source: AK7set/aXNholJjc0GQpXBCrAX4vTejpmZKgiHSNH9csu9knPlcJ8QmTryFBH9LY1XQVVnDn3XMw2g== X-Received: by 2002:a17:903:1c8:b0:198:adc4:2299 with SMTP id e8-20020a17090301c800b00198adc42299mr441633plh.20.1675222632538; Tue, 31 Jan 2023 19:37:12 -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 v5 27/29] MAINTAINERS: Add Akihiko Odaki as a e1000e reviewer Date: Wed, 1 Feb 2023 12:35:37 +0900 Message-Id: <20230201033539.30049-28-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::102b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102b.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: 1675222748623100001 Content-Type: text/plain; charset="utf-8" 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 08ad1e5341..958915f227 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2208,11 +2208,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 Fri Mar 29 00:58:30 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=1675222863; cv=none; d=zohomail.com; s=zohoarc; b=NhSNLnpdXxuyTfgsjiRzbXCIDkYtul0zV+86DawqSmx0YCiXpZeu81oKBJtryo0U6SineJbSrvGp3cLjpEcHkTpWwE/zElLdKUrYRoV2Py8pBlJ938xc4YvvoqMAcoewPLfkKyV1GFqVi5rgYxSP008rY2gPTMq5xC0hRb6HOhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222863; 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=hJjgj3IIFVAqBly66Z6Xi8AkW/Nl2V0Vhn07Bk+a+M4=; b=Z10NdpGQdlR3ZLDxYY2hVhmzDWYnFHRTcUWpSFziJ82XL82b6Nx388h7SJgN2wxE1YZjrP1lOZ2nTZw5TDDtZPvNoALzJeDr2LpfQEauJlhu6AnYgpbzc4ovwehUsrGnfIIs0tYBc3KYNQkKbNi4xcU+Oryamt6QqKr/Y5vqvS0= 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 1675222863326643.6570978537491; Tue, 31 Jan 2023 19:41:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3w1-0000tP-Kd; Tue, 31 Jan 2023 22:37: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 1pN3vx-0000Gz-Ts for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:17 -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 1pN3vw-0000b5-9B for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:17 -0500 Received: by mail-pj1-x1035.google.com with SMTP id l4-20020a17090a850400b0023013402671so721113pjn.5 for ; Tue, 31 Jan 2023 19:37:15 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:37:15 -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=hJjgj3IIFVAqBly66Z6Xi8AkW/Nl2V0Vhn07Bk+a+M4=; b=AijaghDHWViBWEw684xxN83QmxXwWUjwMrb8D6W7Mg26SAR9iCGl/CnqA51LtT9vYa OZWtl9Zs2BaH8WuJ2z3KyanRF3MENEPuCSDUzEdUCt+JbsYVqgzxsOAFL38eXKtY+9cD IS11BL47D6inu1ngtjbXK0Y7zUqlKORRUSb4DVFt+iCD4F7hZgqFmzZtxhLvgJEcBO2d F7fCL/d+97ta3gfRpd5O82l4ryJaHvuUUVme8qAGwfZ8+VMPtsVV8BP5FpyPfbzIzfKD ZpTZiL92yEm2NgVvcyPb72CXRBbADnCvVkKhjyAJ3Sbao6tLDq+YVxUABd8g8dFHTYMV bBYg== 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=hJjgj3IIFVAqBly66Z6Xi8AkW/Nl2V0Vhn07Bk+a+M4=; b=k0vVo22IbhDyksNpv2kkYEmiY94I4lvIFzf8qfkrQT1i4o95GSEsTHIcWpaTnjGsDZ th0U+ga/mGsHYm9zzIcon1UDtlNllx4feIBhjpSoOyWR6J9iA8l5oeuUJ0gH7QMnU9h7 krgw4pmWaBCa877cH6c+Bt8M3AWIwxL2w07XOFM8kx1tXSNVK7x/7IHA0zO0tcZH2ivR vAI3imHzIE+1Og0PdDmfdvfoO1+mCT041gFTRVnpzAbBMs+bWLUnL4cM+vpRGOyhUkC/ uCSj3gq7xHDaxEdF2hAyBabjuVSmr9cwTswJDTb6SqRkykmBUwUj5TIOjPFj6cSLsb8E gqAA== X-Gm-Message-State: AO0yUKVpDXcIfZOoSS0Z46L29dv+mSsRZqg0nD0G9jZ/oOwLhUw0sIqc fYHSgkupZHLVdhuR8uYfrDt3Lw== X-Google-Smtp-Source: AK7set9IpyN8A+jmOdomN5kStyYhPCtRV+v0WNPQNsmKcprrIgs3sftmnEvjnCrSaBsUICDqNO9dCg== X-Received: by 2002:a17:902:db08:b0:196:6577:5a96 with SMTP id m8-20020a170902db0800b0019665775a96mr1695532plx.30.1675222635660; Tue, 31 Jan 2023 19:37:15 -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 v5 28/29] MAINTAINERS: Add e1000e test files Date: Wed, 1 Feb 2023 12:35:38 +0900 Message-Id: <20230201033539.30049-29-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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: 1675222865280100002 Content-Type: text/plain; charset="utf-8" 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 958915f227..e920d0061e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2218,6 +2218,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 Fri Mar 29 00:58:30 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=1675222846; cv=none; d=zohomail.com; s=zohoarc; b=J1RYxTVqYUGKbFU8T8dHpDdeG/ETZivEEX5jHM7vdMKHKC2exF0xk6UFAoibhU04+m3SEu5Uqr8+6ywkvNdI4fmqlrDcwNCo6s7Pk9gkIJGbZ73ZdSDyyXGFVftgOVlmTjt8df14byha6+4ow/OLX4zHxmi6Y7yLma82b2APi2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675222846; 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=mBn6aocdl/0qkoPEm/wxYqznqJyfF6dAba9EmUAhZQ7DNEBT7SoowlWmxaNvXLJMc/OhsRQwWEKTOdDGSOTibQsve/60eh8SRqqLn/KSoEXw5cRktg4bS79WRU2M4pFozU3froPiw+hzviSHvTarKsHEiH0qMfc2sAXQCORflo0= 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 1675222846607917.3484018675321; Tue, 31 Jan 2023 19:40:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pN3w3-0001Ac-Mn; Tue, 31 Jan 2023 22:37: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 1pN3w1-0000vf-QA for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:21 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pN3w0-0000fb-11 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 22:37:21 -0500 Received: by mail-pl1-x631.google.com with SMTP id z1so9643068plg.6 for ; Tue, 31 Jan 2023 19:37:19 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001968b529c98sm4185557plg.128.2023.01.31.19.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 19:37:18 -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=V4RPtpSqaO8XQG+pvyCSUwWDFuapm3YN1iDb5ARbPGChK+TmJdt81sug0pKLElKsxn AnK2zGLfSRnS+V67Q0IpXk4FHLvmcwR63EYsayg1dV9Sz9ZHtDdpz713ZWDCsv/N/wQy p2+vFayhbujVdr7h/zZvLsQc46clkVa08bb1nQePx1dwGDsYMBdlTycKtUO7xgouSm67 g88iC6gPPr0fPBYXDFtlPOVisJqsdN7aRnis0A3rbh+vQ5/Bwol3admbP/r7ShJS4izU 0v5EJXIa4J3BkqQmekHXM+Ou3Usboznoq6POBiViVgLickAMxgGc2UkDktZkAyvkFKLC qz6A== 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=0V4OAPBEorv6mbQfXjzf0+xJfeAhkimnpu4t106V2JO/zi3PRUryAjV76cx9dYpGXZ EhjUwoIZbsenibilc1MTMlmq+Y4r6h4Irlmd5J0VN8KCxIcOzVp3807uVciVMVFK3w22 Qun7mfMRxXssAKGFIg/8WuozGOQI3SpWE6fgwf19f8YKP1l5KY3fdAWEzgbqiKpRA3T9 Yn80ImVnDcF8e0LHokyMKIYqopNEoYWiQuzueLWYL9TODUIgsyTmP1pziW+1VS7yZbfO I0RRbm8VNUiJQSSqsQlMlZdC+iW6/H2BjzNFYW+RY6M8/ADHVXZOqaGfjyUCoYjBXXOX opWQ== X-Gm-Message-State: AO0yUKWwAkRogUe4gtORslPEQS6KFlYREQr3RTPPjhjIdDLGCAuKux3h lh+ahEhXdWpAfO4AsH/fb7KbZw== X-Google-Smtp-Source: AK7set+gpw1My7NE1FRoICA2UUFjnjqR0gT4L3UsklFrHhGOAcoYcXjQG43RZiYmPMv94rqVhcG1dA== X-Received: by 2002:a05:6a20:a581:b0:bb:ccef:f896 with SMTP id bc1-20020a056a20a58100b000bbcceff896mr1074887pzb.12.1675222638704; Tue, 31 Jan 2023 19:37:18 -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 v5 29/29] e1000e: Combine rx traces Date: Wed, 1 Feb 2023 12:35:39 +0900 Message-Id: <20230201033539.30049-30-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201033539.30049-1-akihiko.odaki@daynix.com> References: <20230201033539.30049-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::631; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x631.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: 1675222847192100001 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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