From nobody Thu Apr 25 17:25:34 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=1675086512; cv=none; d=zohomail.com; s=zohoarc; b=m75uAEf9AwURohFRbDsdkQrZlERGiH2CVzVPZbjEF3Zvqllf3R/W/w2pfcGVaJflYuc0t7/ujMw4OA8Le6f4EQ4knnOjytTgjD7PgkkjUBgS2qUnhGM8oPKapWcCxmFzVewsOQUa27VitE7z70Zts105wVrjCmCcCvhvScv7ZBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086512; 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=IscUCEykfjMt62jgpyadfZxEBN7rCsmfBowPZXqzBNFHVwdJkBvwPG2jo2d2x8FoklMm2GgMkusdJxWnEtHfe78SIajptOvTpzkjgSvoqZoMW+iJY2Zs7ankVIZHrtqlft9+5pbtN2w0aEM2nfBR1fap9zpdnfU3LfrHx7QDPPM= 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 1675086512462854.939766795905; Mon, 30 Jan 2023 05:48:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVk-0003sw-PN; Mon, 30 Jan 2023 08:47: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 1pMUVY-0003pS-R8 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:42 -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 1pMUVO-0003X5-00 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:35 -0500 Received: by mail-pj1-x1034.google.com with SMTP id m11so11171612pji.0 for ; Mon, 30 Jan 2023 05:47:29 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47: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=LEVUzcjDweu3RxATasMPdWrNCDFTC29sZxdxxneukjs=; b=kb5b7RL9QvsP6TL1WnrY+VC7vazgwKrfMWvazb20cqrsCpgX79O70O4AER647VySaa He0YOXqXRndPd5wpQdzYJS3ZiHhHiVZqBF1KExJYqLuGXaKtEmMUba2rHynKbtkAWKlD Apbpl6XyFfh7G5VNFIfn3y3l/34b10EoMCnMbSlPXx1T5IUx9xLVb/jbZRknzxNOGYfT zm9hZ/F+7bEEWp9MNfGZib5SJ6foXuMr0g5Mhz2ILSWFVVMtt1Y8VdScbEzswRHzGHph 0bohHnUCFWcV2MwvzxJ/akxPF44ltEurB08+cz9XNQSpK6ItdA9lazsKW9DRfVarMKwO tzyg== 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=2/+/O66JxmyysoZ4b82C+nVPmeOQdn9PmbB+Vkdib8B4VYAYRcOgYdAZ7CWwogUx9Y E3g3QY1IDtscCtHTc40V3BpMqdBrzbrBxPqIdYTPQBP8EMX2h1q8A4mSVRqhfTUj6IHd jCYplGiP6OC8/c7s0dsKRtWLCzqNfwSktlolWITmnZK19fdJEIKjSsc/DoIoiJqZfWLa hNwPR9MD/oG5sVVCHQEV1ifFT6zT/1vjbsT/jjA9VWXWT8S3x2Ur11L1GlWpUQI+E4ay df1G6YRnwtCvsKq5zmFv1v+ED2nMYiagUT8wacS63L67ezdTmXzJwjU5pS4BQkSExu0I 5u7g== X-Gm-Message-State: AO0yUKVxNmcob28VVMvldp5ncNngE6pQTPkW3OPB292fhSisOBXBjJcZ h2QOn1BgXBt6h8Ywyh4XkGWPKw== X-Google-Smtp-Source: AK7set/hoen7sAnry0fMEkY59DD++BDF97PHLM2kZsja3A+FeyQcgRnB5s/xmzsIcQ5hIkOtu3iwMQ== X-Received: by 2002:a17:902:e5c1:b0:196:5f76:e64e with SMTP id u1-20020a170902e5c100b001965f76e64emr11892933plf.0.1675086448416; Mon, 30 Jan 2023 05:47: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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 01/28] e1000e: Fix the code style Date: Mon, 30 Jan 2023 22:46:48 +0900 Message-Id: <20230130134715.76604-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1034; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1675086514269100002 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 Thu Apr 25 17:25:34 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=1675086608; cv=none; d=zohomail.com; s=zohoarc; b=RnTq0oNaPQ1ujVjfN9CjtulcwGc23eCny/GXXaslLhDOPutDNrX/fEu8L+ZHx9R1re8a0a8e1BZqeiZtSGTLPKSqKrN7BRqoQ38IsaFvIWFt+KopoDDR2D0ZpEuoDb0myK8ZRJXCo80f2VMEDEn4STWccjf9QjNLGyfw6y3/JiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086608; 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=QPeypfId6FpbmyzpgGiMFBqzCp5Tvii6IY8twWQkPYaRzLxKzfLYm03aw//IaC92n3NF/+yHqoBggoXlxhL2NiKINbdKDi7v3gcOh8Pu6vGXAINrsyKuFNKm2FyDo8cdaUgk889AIvvod9jCJFo4OK4RcSxK7TJtctKBzmdSiMU= 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 1675086608338485.5076328709197; Mon, 30 Jan 2023 05:50:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVl-0003wD-TL; Mon, 30 Jan 2023 08:47:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMUVY-0003pQ-Rf for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:42 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUVQ-0003Xa-Pb for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:34 -0500 Received: by mail-pj1-x1029.google.com with SMTP id o13so11147776pjg.2 for ; Mon, 30 Jan 2023 05:47:32 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47: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=mc6N+3X4DyWhP6LHvz3xiMiOtzW5YFnluXUsmSP0zdw=; b=Mw5hTrj+k7mgs6V2je8l+pEE/VWt8m8JWT/4jpHfNn0d0PNNOcJaLVyplmwEAT0kgf FB+4e9OyUAwORWsJfPn6CEDNpSWsrMFo3G8MNJncTEKYTYAapjNXdbeLUFwx9wYWL7wF m+x65aisFdIV+4L+D2HzOtdaV3oKP6/nwP2ucmRLiILAvHro4TAaNsrDaE39XXQex2mY BHRSkhVW72IQRFuAlCYJJDJPXcJXP+24sAhBipOXH+z5uNtbzjkuSm0pNExDmX7dG5oW oZLiDon7pwBLiyntjN4TB6cA267U2wGEkDwpDLuX37N84EwHGfgE5sTdjmXStIl+LMuz tpWg== 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=UTh87vCuvz2x3yocPwltfcYNcU8SmRPc195/0/RpLYSbs/hRIcwTPfUalqyCJzy54D jiRPZ5XcZe1nfmt+enaXBU5j/MoN8PaNRNcoZt/aOXouMSAzSoelShMskaTustBdkG+/ pzS5q1sWm5CxbX3Mj5U0UKfvj2jwDUAVucieFHjH9Q8OopH/JewoKPmRLGu9JbQAymGl dgDYs22M5heOBEEGn5dI+26Ss3Y6hmN97a1S0OSflA0oQm0JD3vW0lOQmQvkGKWWuiko V81qqlNX5dAO9jF1K/F2X2e8btL/LL9Fp6ptgEYhn/k4TKIeT59FPalQbEfPY8aCr/Mj 72vQ== X-Gm-Message-State: AO0yUKU79dXwmai5z/qT3rks23RNuFD+vX7wY+cVJ3oUaT9GqySJKMPX mIM5cMXUwGxkfGTvRU9tW3BNiw== X-Google-Smtp-Source: AK7set8QCsyftk0N0QPuINPUN7XgHEX2OesAWNS82WzBr9mK3DTmNc3QFjLVSQAVQ3dFBIuXGJTjOA== X-Received: by 2002:a17:902:f550:b0:196:5f76:1e51 with SMTP id h16-20020a170902f55000b001965f761e51mr10617764plf.64.1675086451531; Mon, 30 Jan 2023 05:47:31 -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 v4 02/28] hw/net: Add more MII definitions Date: Mon, 30 Jan 2023 22:46:49 +0900 Message-Id: <20230130134715.76604-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1029; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1675086608949100005 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 Thu Apr 25 17:25:34 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=1675086926; cv=none; d=zohomail.com; s=zohoarc; b=DxIRyBNTdJ/afKJ4Aa2U/FRxYyFY5lfj/U9XxFA1RGIE4VicVrHu3rcVwpA3tPAalL8gMEZWLaEHDLRFDEUvBaE4RNXwJ3sdgDV2M7xRwkJ4aeBXm+s2WESyFsjxNUId8RzUFJ0RJAAUH4HSRZlUeYrmDSygtI90f5uai/36fKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086926; 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=H4pbjWA9x2hv2Pq8k96eke2FnWuWqLz5tL6/UFDQ1pfd7H7USFg56Q661zjCZS3dWMHL0JONQGL2ZHKX3vP0NZIO6ZNwHLAkPiQx8xnt1hAYfYIKg3+jy1e0nW16UjP6mDS8+g4ZKZYX2+b9r2ZOruA/OtNxgmPYt3J90SIadqs= 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 167508692656225.33270180242596; Mon, 30 Jan 2023 05:55:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVm-0003wY-0G; Mon, 30 Jan 2023 08:47:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMUVb-0003pm-8Y for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:44 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUVY-0003Y8-Ds for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:42 -0500 Received: by mail-pl1-x62c.google.com with SMTP id z1so4123426plg.6 for ; Mon, 30 Jan 2023 05:47:35 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47: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=TIOeRLbPMJAuFIcNQlo+uN8HcDv0eMoJ6T+gd5Ur6Ps=; b=6MN1ayIXiH2EYkBfGW+QA16IAfl42YjEZkyaYo60J2qjmWykJtMTldxBUdVfHLuRua spWx1O7EWjQjc7PL0+IDow8dVvOqt+TBOLhN5wYjkGBScj855IyMbIx7xLgzlmcvrTV5 ApeA5RdcdMpGcOdFn16it2O3qv9n1nl37i1jBu/k3hoOKZtuho2Z5uuRXpLaBmARGoeL kNRrqGAxm8ZHnP3YwB2xruKEg1abZUDboZL/lMQgoKzYs/rrI4iTWIc3G1sLWzPNygQw tw20g7fU0yreEzLxPON0yhYZk8oiJO+GfOSpFPvHkFkgz+HluKd16DvQTCJmFNzIcUgi MiPg== 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=NBVonKuKg5OXsU5xkus+mZi9dj5P7hS5d45pgt4b3Sp5eVd24DoCLAGXZs7ioJl7/x SfxOU9CEX+GIVDQeWJJZAHYO3bC5qeRBgn2gAr5ikbAj221EXtfKMbyKlsz9FbOajnFm 4ewWB0lKbHAh3OL0pOlrpvX3Cq4Qi0dB1ut6fRAUilWWSZqRFMfOlzn1pzRXgAlOW2Cx Rb/Bcq+B7t9Ce8Lb8LIkLA5k4LCmRSRsArGCZu/pQfWOpRtut3Dv/C4vjW1XzQUOfM5j bNmvoxqHvwZUSm+8ueUkwSzF8B1A1Mc34jmrw21Ki87/9gXXPmtffuM2dDNbcdOuMOnf hU+Q== X-Gm-Message-State: AO0yUKVIEIyhERyZ1mwTBWgaEZLvYiz0i/tVAuQNYzDOBgzSYLGrnlLm xXuojrr2ru8rFu6h7hj3LUacZQ== X-Google-Smtp-Source: AK7set/JvmcDl20zpM7sSQJfck/Gjzacz28pa8NqcKCQDFwnFZNr4/kwiY/LNo6TtT5ohciCrRGZlQ== X-Received: by 2002:a17:902:e84b:b0:196:6496:85fa with SMTP id t11-20020a170902e84b00b00196649685famr10923215plg.26.1675086454747; Mon, 30 Jan 2023 05:47:34 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 03/28] fsl_etsec: Use hw/net/mii.h Date: Mon, 30 Jan 2023 22:46:50 +0900 Message-Id: <20230130134715.76604-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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::62c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086930163100007 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 Thu Apr 25 17:25:34 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=1675086753; cv=none; d=zohomail.com; s=zohoarc; b=dRagItqH7re/Nii72GHcc/+ynZ8gjfjiXjOLPDb2Ufpmgignb2fxutZ25RQ0EupA4I3pZWlq/t+bSNqZ75yWq130p2Er7yRJUFEWT/zeKQcVs4Z9WArCwA4AvMFBMb5LCkCm++e4/vnaRBoFxGhdJaLFRgXZ1jQDEzy1EjBkFiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086753; 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=G9SZVLXe0nJZW1lLc3nJm2Q+F+7vnWSTxLIBLPMykXJ/K1Q1QzMctqS7AYm4ajKLWC6rmMxidBE+LVZClZkFOKBe8IFp71eWq7TSPyxcUwfMvqeB2RRka9YBPfNdWP43HFQ0SOpBRUm/FYNA159dCoLH/SNhIaaIFI6givDGPtY= 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 1675086753494509.8545435055844; Mon, 30 Jan 2023 05:52:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVn-0003yc-4Z; Mon, 30 Jan 2023 08:47: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 1pMUVc-0003r2-48 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:44 -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 1pMUVY-0003YP-Ek for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:43 -0500 Received: by mail-pj1-x102e.google.com with SMTP id rm7-20020a17090b3ec700b0022c05558d22so11119888pjb.5 for ; Mon, 30 Jan 2023 05:47:39 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vuOZkh7/FsK7pTAIZRY0T7k4W6zYsds58jVwZOXAh5g=; b=W85r8gtMPBEQiwiiJqPEBxXed6WeOIyvbhReYYbBdg2Cu/dkIUAobmFdeak9c1f/ZF dJrIc5B8Bp91TgSdXsq+45Iqq+3AW5vqn3N8rK6zPO3pAyf/qUr8cvDlXOEQH2Uv9WGM HX8G6gRjluvoOgq+MkkEYlrDeEAyMh7C5VqrrwKA5XgYIqY7kThHFwnhWQz6sllDPXUe JjboWp7pF74Ifqp0YAEsVmx9tJdasnumfJKVuuBSTK9POlLzr5eaeoCDBzeG2TmBaD5e OhOa6se2iZTJMPmA/ZJBYKSL+MhqpNBFRw2pObh2WfkxoYobpjz+nbBXdPkzmdnKj6nb QUqg== 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=CbtwFLmGKDXuFkhhcU23cGEQIFMdqIzwCBDWJ8ljDvMU2kDE2yuTBWhxOkyWFfEjA/ XNagKVvyu8+Ms8Tj37mAX3RGDvJRh6LCpaFUEC6YfKNPC/j/64ZdxAkptjQgIFSIrxkT zIApawA98IsSk29QM5+K88YL170Dtf1k5q02/X8IgCqV3KU6E9Z0MeUAGSoPENkA3hUM bTMvcq/+L/dKCTBWPp6Jr5j5OOT74cpaRCQR3codqT4ih5diSigCididaghwRvpLkd27 3qrEKPUY57pSNcSvXIm9yAEqKfXfyetoKdXeOg5YC+jLGpFZ9SBumcw8I1gM0SiZfSRy mGaw== X-Gm-Message-State: AO0yUKVXe3zQJ+Rxwdp3+owUmTJ0wjktNXnLIbOGAsGazdHuVIW3qq7M wi66rYMwze6brAHaTkcG5Tc+zg== X-Google-Smtp-Source: AK7set9Iuf9Wx0Ob3qk9YT6tBnbZnZ5r409iTjd6KQbX399l6rN7bY7Pxsym8x1olPyhiKB2won7nA== X-Received: by 2002:a05:6a20:8f05:b0:be:a604:c683 with SMTP id b5-20020a056a208f0500b000bea604c683mr1608188pzk.45.1675086458024; Mon, 30 Jan 2023 05:47: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 v4 04/28] e1000: Use hw/net/mii.h Date: Mon, 30 Jan 2023 22:46:51 +0900 Message-Id: <20230130134715.76604-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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: 1675086755804100003 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 Thu Apr 25 17:25:34 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=1675086829; cv=none; d=zohomail.com; s=zohoarc; b=eX2C1W84k+4iFcC3gBTOyQkM/z4TFv/Oa7ckOmy6aa0Zwqtjk1qn5Vz1JMR7Qi0wcPxotZ0GVDVX/QnlFFdJO9yUxnZvxy/8eMqXChsaDtzBeuTn25uV2fyAPkl04k7zX1hL3zXK7mR6BKZC1LHvIhud6cIHW1xAzQ3Mlemguzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086829; 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=Vrmvgr7Xlb0FaiKrSwLOzNpj2cAikAqKRYZ6mzL4e013iHq2ZC6UhkIkJ9Jm0E27OXwJTNsNqwvI/cOg5K7sUiC7L4EYEw7brp23fPNhEoc2uB3ZGjP8CTgrjAj/jr/QQTqxrWEUDInQCka+O23HtAXMy0wN8Uin4NtbLfoiHD8= 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 1675086829167261.8308865016703; Mon, 30 Jan 2023 05:53:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVn-0003zY-Oa; Mon, 30 Jan 2023 08:47: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 1pMUVf-0003ry-62 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:52 -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 1pMUVa-0003Z2-9u for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:44 -0500 Received: by mail-pj1-x1035.google.com with SMTP id n20-20020a17090aab9400b00229ca6a4636so15522823pjq.0 for ; Mon, 30 Jan 2023 05:47:41 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vaQBmuAwUG3bfNy5ZDg+YwZ/WikcZ/GlFG+7O8mJJRU=; b=5T/ubz0f4LIVlPiKK95iuwsA1Oj7o3uAJ13s6frfL9luHTe7qXwt+TvFvS2WtWYtNE G4RobwkvKAYJw1NMon1lpAjLW608KuPKM4fJlRUvXNjNwUx+G5FBXNTS5ARf8TSjtumL 56moomm05/nX7szwrWgD3rzssbhNlvkKQxweDmvUs35j7LlAKC3SmWsjXgSdIkkLpTIt 0wyi1n4xoJm68n3DmKPnYuMLkgs3ceJzntP330xv8Y/WRvLLCpE1arNT0FkGbMzbJ/Bm xctxkPcqUvgHlDUwvJyzCi4y8pybGty4nh/iw7ZfvhETF+qV60rb8q1jG8a+DVaMFaLB j7aA== 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=AKZv1uhlIsFMXffPr5S3EeUw0gMtIvqf9jZYBzhi1ukBozANeOyKm41wXZcrrLM8s3 gQpkWntLhWTszsTpihgWzrtZKKA5ALrLR5YZvuMfUOJ5HQ3Kf5lrKLYGQRSUEgZcXjsb /dir8YslXpxml+gAIxJ7JtBDmxCRKh3ke5rZ76v46StdgCt1unWxxECs/gN4ly1oJ8ho Ps+rbVsbeT4jByBv2jdZ7PXR0Rm5vtU+20KbH/5iwdwOj/JbXR5JGn8jyomEQ5AyKlGX Kup294coNBH+Afg/TPCdvsUzfVZP9g0mJvdXPmo+1Dhr2Hi18PQAEgJxraDzu5r0V8C7 5FTw== X-Gm-Message-State: AO0yUKVTtri+S24uuZoL7QIgCxlQR/fMzQf3RQrNpmBHK2AimkUpqpup Y8qj0XYCvThlEWLKWlPF+DbVTQ== X-Google-Smtp-Source: AK7set+mlYd8GspCN8ZMS3+M1nRrPhaFwjJmyPbqOvidE0rnijD3LgzMu1PzVDdfVPQWzf3vh778QQ== X-Received: by 2002:a17:902:d2cc:b0:196:5cfe:70b2 with SMTP id n12-20020a170902d2cc00b001965cfe70b2mr12549660plc.52.1675086461059; Mon, 30 Jan 2023 05:47: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 Subject: [PATCH v4 05/28] e1000: Mask registers when writing Date: Mon, 30 Jan 2023 22:46:52 +0900 Message-Id: <20230130134715.76604-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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=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: 1675086830640100001 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 Thu Apr 25 17:25:34 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=1675086886; cv=none; d=zohomail.com; s=zohoarc; b=MzpUO8mBxt5vW/kDl6jKFhxbaaJBcBYPkW7lnQzYFmOQADcOJVQmGuNzJ0XD2XWSZiKLYKtj/iB0A/L8lVnXi5bZtmv9OCmXUSJrqskCID/rQ+CF1t7Aeq+vw6OwMkg9n1tKUbMT1OYo96HC7apzl7QBoYypn4lO3Gq4oK26vjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086886; 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=STHI4AJ5xoAIlu69NvERjSWX851riYp3GGuGvZAs1Rbt+54E6v4MkxuhCPF2NUEynWmpsqEh13q+DVvVon3oSQAcT8jthz6q3Pz+fxJOJ3cfSo6Te0U5TfcOGqjtVIBIJFjW0WLh4n+hgFDf9zqMP83A7IyD+mLdZFFsWcdxoXk= 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 1675086886530250.95472282423657; Mon, 30 Jan 2023 05:54:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVq-00042e-U5; Mon, 30 Jan 2023 08:47:58 -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 1pMUVk-0003sU-9J for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:52 -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 1pMUVf-0003aA-08 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:48 -0500 Received: by mail-pj1-x102e.google.com with SMTP id 88so11130818pjo.3 for ; Mon, 30 Jan 2023 05:47:45 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47:43 -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=vTJGJbOQrSgoYb42nFPMzTYI7sC3RYYk6t7Xk+TPhdzjsxIxrFuj+hHXDgZz/sIcft 5/RNdunHx27rDcV2VDxGt1Ji1Xhgtv546T3i0yqFgFHP2mr1KKP7ZmMD99Z8z6oi/FWt BeyE0Ka4ouvhpjAWuRnQaHpzfSsXT0NVSgXQliJzPlhEzOeG0qY02fX5fnX+OoUZW0BC Muv7dtkzerW4NpkD40hbK9+c9cMBXoWRpe0YXTEw9y3TMeXGj7ISBq4rT3TChMV/j25X uk4JyI2/8EKT0bD/jzv0+16YFQf2y9NPbYu4HrQ2mmQ9+Fdw43wMfUwQ9aZqxYybzTjU 8XgQ== 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=HSb562UjMPX3o0Rf701N0o+Uf+KXxrMh2EeV/odZxbKTtnj0wtF2rKN/ODEREQikpA DBm7UjPI9geyFqEWimtXwQ6jxWRog/3UWHwKwaPljFgTzRd65qFttulGTqYKCk/YQe9E MlfxagvC7FUOsIyZlt8+Te/QTQFNotu9Pw+nqO5LYZel/SmIfzioEU/bkcA3n2TzkxI4 6EY7md/nCloooLRtydtY3GcOlBx9Kt5Zj6fPa9xGLy46bbHX3dwjJ4DLVwYvuNi2Hz6H U2gxAiv4R46kr3x6U8kUkxILDSrNpxI+mUj+DFGo4O+y2bKWTUXzmupz0oR4yTXOy9m+ W4BQ== X-Gm-Message-State: AO0yUKXFAcNSLK0LBr00IWFxEHQ5PaiZ8Ipj4Ds/jH8uDs5BZRgOivbf jAAQ/IniS0YdMV58aysTM8JZ1g== X-Google-Smtp-Source: AK7set8lBB/9nVIzKJLMyHIhJG8HdS5/XDDAc8quvlFJpNPm9uqb0LUOA0IyrSoYGO508E18It5dMw== X-Received: by 2002:a17:903:2013:b0:196:37db:b4b7 with SMTP id s19-20020a170903201300b0019637dbb4b7mr12139482pla.62.1675086464190; Mon, 30 Jan 2023 05:47: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 v4 06/28] e1000e: Mask registers when writing Date: Mon, 30 Jan 2023 22:46:53 +0900 Message-Id: <20230130134715.76604-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086886969100001 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 Thu Apr 25 17:25:34 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=1675086734; cv=none; d=zohomail.com; s=zohoarc; b=ZwoYSB8uDq2x6RHdabhy7b6okqM6EgzWWzlKLprZe8yRdpWgTXA61JU/aG4UKxT2PgrsfGZAGE31VjZhM2X/5BjZ0JqEMm3I90bsrmugCdaAKSwvM6tpKkGAlsBFAT7S6BVIXDsb85KLqX8s0fH/1cGm0PLRRWMojjf0N8c7EPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086734; 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=C5wSYZM2kJZGY9/t74EcWZi0tXjb8DP+IwSqGuoa/2v+a6rfPJg/bK3EbaD18dOwVQE6kICwzfMfnAjCnndxb0mazPFyvHqeqAbHiNmLqLTMtQFAtE7mF2UFpF1cwnPt2AKpzdTp//LrubhNPcKoeNqR2DB2zva2qsXrzabzA34= 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 1675086734092789.2213846353912; Mon, 30 Jan 2023 05:52:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVp-00042K-Q3; Mon, 30 Jan 2023 08:47: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 1pMUVm-0003xB-49 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:54 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUVg-0003aY-Ny for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:53 -0500 Received: by mail-pl1-x635.google.com with SMTP id 5so11674925plo.3 for ; Mon, 30 Jan 2023 05:47:48 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47: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=11tAn5i1ga6o2GC/G+0ctwzPxRVIwWHyxeT3xs8C5X4=; b=7UdkQ+jzWd44mj97Iy+dp3wc/a3U7p8fpnksVVvP/RiN374Tk5tJP31A5cWJgFdMyG xjiU0fdS/rWY6PQYkxhsWHtHXvXuNDEQi0l+XSXYLu5K9KDg6tuG07o1SFzrNUJTixcV uU3A2lr1q3sbd/AwnRiWJlVOzpaGW++0M4keN0NnMX9RUlkZHyWnGBNr0JQWBXvqhSYt kf6pPiLN19jKjvt7V47wotUynsvmKyUsY2fEOG2mx7dUlcIALI0lg94rWf+SqNjflBfo l9yiodJ36gkratPxCuAL1KaxNFBYD0aleZVy554kWacNw/yOOwvXa1iwIn7pIGKXLp8N rkQg== 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=oQfBrwiRM20xpK73rNBm3J5YEfcAJl8AJH/KVEUTLPMu/IHDHqaKDKOx16dhuY/rbt rM5z0/Fs1P/ly1l0etsHgX5FTo5zjLM0ANsY7mdrDM4tFd6HG83GPb8/tMgIYKsU4FlT gegqkDd4rz6NrSmslwKGFGwl6mq/LCYqfh+sgCXowUkBdQ1cvMysPGATls/yy6ShoORr dDVjKPYUSSIVUBKus03iyAbD3xoo2/U35iRXrsla/shNfVqpFfSTd/Ca6iOvJ7DmovZV fKlwnMv95/UZWRew2QvEb5Vwm0wootJ3opL9qYrQ3HOW16t65WDueaurUmS6nmNFVmjE j7Aw== X-Gm-Message-State: AO0yUKXDC67HlVYGT9x2KxfRxo0cCcOn5MyeSsDkVCjIAhLZ/nmiNk+n 5LJld447FsGJdQO+gf3nMtkwGtq4Xn/mduOB X-Google-Smtp-Source: AK7set+UW8ZSIXRXpptVR3jTyb2gVIl3FpUc2fNY8pded2INHdYek4FJLG9ocGAl2BFOQuDssp+x6w== X-Received: by 2002:a17:902:e804:b0:196:15a6:7332 with SMTP id u4-20020a170902e80400b0019615a67332mr10202805plg.31.1675086467417; Mon, 30 Jan 2023 05:47:47 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 07/28] e1000: Use more constant definitions Date: Mon, 30 Jan 2023 22:46:54 +0900 Message-Id: <20230130134715.76604-8-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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::635; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x635.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: 1675086734695100001 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 Thu Apr 25 17:25:34 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=1675086867; cv=none; d=zohomail.com; s=zohoarc; b=IrT6l/K5IZ4z53jLocDQ2CwNobmWBypBeb3XHcsfYwQ2GwCNSsydds33uwfDq5MN2MGIHkHsmfuUsMRpDIwUkyP18PbFvn6tr3jo8FsIQaE3MD2wui9PEMRsib2AyfBRKhKv2Gv9XJIZgUOPoSGnj9dq/J03Q9Zj4fTZEcSBepw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086867; 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=CV6aYMViHKyfgH0wNcvF38fdGE72UjpFpDrbP8iVjKkWeV8s9NUSs+Yad5pBXGajN9MnOv+Ciyeo18UeSf+0JXpmnMS4dMjbcTPZeK2g5TpOw0anz842cpACC8T8SP9TOBHamt0bMefFP4KW0r5SOtxW6Lu6zW+S3aTKKau5kvo= 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 1675086867705576.8622039738531; Mon, 30 Jan 2023 05:54:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVp-00042D-83; Mon, 30 Jan 2023 08:47: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 1pMUVn-0003zq-O3 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:55 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUVk-0003Xa-2E for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:55 -0500 Received: by mail-pj1-x1029.google.com with SMTP id o13so11148474pjg.2 for ; Mon, 30 Jan 2023 05:47:50 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47: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=FnwZQEUzrMFVzDuTfyE5cJp2RPrgmk3+VIZHYS+vUOs=; b=0Uyow2t8R5y7sHcBinnWO7mWzA7YkLXUhnAZrCL1Tw/62T0dbh/d58FUVb+evwECLM mmFfMtnpNQcW6FJU68xb2XY1F8L9/LG0gtBCYB/0Ywe0m7/5ZclZf1rwufH3Ql03xMEt PKx9BPgY4UxOj3Mof99ZyiM6fbSFP/kPszxj16kvoYBNNUTj34TA1B5/8yvnjQ2aYDoL 5rC1TPiiAy9owwLIcZ3ZmWDjU/3k4Y54X6m0cOOz4VUX/XdetsAjdlCTnORFR8kcnp6A XyWEc+kASwu4e7EYcviRWcxOS9ZDOa68y+9x4FNUvtyJQi2S/eZnVRhQcGb407oHJXit OIyQ== 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=wABC/cIVEtxJb8ANlB5tpw8m78i6SucbUhdBA83dNI+0nNJ8e+uSL5zQy/dqGd1RjH ykts+7DwurBQL3iRJgSmv9tILrM4Y9re31s3X9+pyloJkM0ImnxSalKzNTlN9jly6AXM /471PAXDQrOFFxKkhErEIzVg3wBD9hoxcNb/3YtPbuN8B3DP621/iQy8VGhyhpXIg7hz 4F+m5RUhmQMjuGZJXRP6FjLodXr3xr2zFIqUy9hX8R9jdGM5220dBXp9OyEQLtk8hzJ8 P/Ok0iCzzt62A1NriWPAtQMtfgXn96z7SJsBOdeeFxthgj7cQ5MqJ5vHag5H+oWTY2tk ApzQ== X-Gm-Message-State: AO0yUKWdXOpCvKLcqlRtEXRobPR+SBgsqKfWpoFP0l2/Dpnze4TVbhIi tW+8WE8i2UoA6rF50C1tOVXLhw== X-Google-Smtp-Source: AK7set/FINuXKqIc1H1uiPkfkvjz4pLPLJANWbJWvR7eNc2ifMLoXtkDjI1horazwkbZlygU5X+aqg== X-Received: by 2002:a17:902:d4c7:b0:196:4468:c309 with SMTP id o7-20020a170902d4c700b001964468c309mr17927591plg.65.1675086470501; Mon, 30 Jan 2023 05:47: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 v4 08/28] e1000e: Use more constant definitions Date: Mon, 30 Jan 2023 22:46:55 +0900 Message-Id: <20230130134715.76604-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1029; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1675086868754100001 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 Thu Apr 25 17:25:34 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=1675086886; cv=none; d=zohomail.com; s=zohoarc; b=JRgM3/VtQnhwKUvXukKlU9NEtEnJmfbCQnRnDpEL3Ju/oeErqknm8/GVIWet7LnvgV7ERh4Ro2+ak6mlgl+yNhmqHp6DOLOHdFu1RMftUh8uAaLBHmmlJLx/Mnd3bQfd725KpXzYZyZhX0valMsbnpTPGMLghQqMJ48am4t0E08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086886; 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=F2HbX0BqHFfB6Yy9pmdJmzLmJx5bIHvs8Fl9u+9DKos64N6oC3Podh1jv+2E+L26v4F3La1uTwcyJ7NimEmVYTVylGMkinUp+WezCaIOw2MKTWZhFUXgaBle70Bsumvatb/FD3T6jGHw8iE5cu1unKvUJJxBYOvrRDBmf1ZkDy4= 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 1675086886273173.7587103811236; Mon, 30 Jan 2023 05:54:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVq-00042O-3X; Mon, 30 Jan 2023 08:47:58 -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 1pMUVn-00040A-Td for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:55 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUVm-0003Y7-BS for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:55 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d3so11628028plr.10 for ; Mon, 30 Jan 2023 05:47:53 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47: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=LG8tq76sMobR10hriWHj/a6wTqkVZm1W1tagtp7KN+0=; b=3qjWLPPm+tUvBO/vcTvB0dhCoX1veJWsV60J/VYvS+CU1CyheAmR9aFSUDsF6CWGP4 Sf3YOpM5m3Ejbpmm0cqHqvZFz1GQxq1sNWzWXxCB1SP1ntT06Nb6iOY3CTdITJNK6cRs ylUz0ezARBzQ474FTWavvPmajavWCemWM+fgxVJPUvK4MkrI1XZgf+Pe2NVSPNaBQMVV x83Hx5FbQr+SabO0Ptu0Ulx2/D+QDtl0wBwrDsi1g9mQS8VQ9vfZbuXViYsYurzuoOHf p5XCjCY6uBhM24sFC0bDNtZUQk37jvXTAmkhG5qtuxyhXxVgnkamzZ9/TzUnoAseMMSD qX6g== 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=E2xfMrtkP+QcME7C8cN21faHPKcjKK/EKkLkEqiJ3+oF3aJixKMKMb9gGaU+08OnA3 zSedJVo3epnf/2ik5QWO7jKm8KPTnZresNJ1/khgRAgbkiktddgltqxv9lzghM32D8tH tjDuj/gZN0kD5wPm94WXGG454g2CWJO4nmrRtqAtJEJ1ArwO4BBk0+o6s5/eE5ZxjJPE MCcHfhFSXQ1qDVtHjyHu2Ue/7Jk3MTYbjURCEO04X+ePvRP9CkjXaTa+ik5zItDyd2EM 20JxTV9ct5d4W8cSOFZx4SxtkKOQoZCFNK1QosWYYNETwSpfWovmV5+g5twNNTuVakAC pq3g== X-Gm-Message-State: AFqh2kq3wgJtj/TDDPv4iQXHjoDqhyG7aAuCe0SAKuOQDnB+UGOFV9l5 KzdnSYzdwH5z5mr9RYzDiczuaQ== X-Google-Smtp-Source: AMrXdXu3OKZASSK1pOpFFuqpemfHQJ9d7e5R3AhGIH8mN9RA+z5nrjbHDx/AOqrh3qrd3Ac1v6bg3A== X-Received: by 2002:a17:902:7597:b0:194:afe4:3011 with SMTP id j23-20020a170902759700b00194afe43011mr44147371pll.52.1675086473694; Mon, 30 Jan 2023 05:47: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 v4 09/28] e1000: Use memcpy to intialize registers Date: Mon, 30 Jan 2023 22:46:56 +0900 Message-Id: <20230130134715.76604-10-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086887002100002 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 Thu Apr 25 17:25:34 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=1675086605; cv=none; d=zohomail.com; s=zohoarc; b=eEvw3xPkyryFEzyv1VaQa8faC2ycRa9IwCO1ybc+POsLqkHvF3IDC7ARc1AIIUuzCrfm/4GVsyU/bIrDi+GEqeAaOEbIm0jk04Qru0syGGIIqkmXCRk6XgIbAhf69j2DzJTO1967c2nwyQkGuaHQqkA9nzsJNqJbCtaN/bzJsW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086605; 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=NEJzni71CDRxPN2c0nlWqhIS20yqGgSKo3gOogiw91VoSyl9wjl/OGF94fU+d19hHOpxM/ZtAuvtL1JoF2xntaWEh7w+3ZpeThr9ypK17c1tL4aduWyExliXygBV4SNh/1/RYGvXVKQDZ2bb3Buma6Kil2nRyChcXqYNa+yr2OM= 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 1675086605833742.5116404050613; Mon, 30 Jan 2023 05:50:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUVy-00046L-Qi; Mon, 30 Jan 2023 08:48:06 -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 1pMUVr-00042m-0v for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:59 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUVp-0003XZ-EX for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:47:58 -0500 Received: by mail-pl1-x62b.google.com with SMTP id k13so11719067plg.0 for ; Mon, 30 Jan 2023 05:47:57 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47: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=2I2qnGVaZLWPm0YolfUBdJT/b10cmArelvHHWWX/I+I=; b=QTLCshtcz/fLY2ur12iJHAx0wZ0wsJFMpoilaZGob9D7nb8DgZGGX0dOO3LffiVoyi V3oTuv42MaST4hkk5HhU6S4tTaTK7nWOm1Cp46P61UhOLSm70Mid+QNXPjhDMHMil1vs UBcfHR0Mw7uLlrbXkpJoZOk4LZElJ06BF/OJ3ZVeliIL89+Gc9iLgptu9bM+Fxz+Hw+o QvBUMBIIiOXkxLTmE0/vcXqUlzR98YGgkTW488iygHcfg32bX+GZQLvRdpqbk3EetEnV I9h57ZwiD8V1wMh/hcck9FhZ/+lIW78uMN5tJ0VRjIlSsxmahmud7Sur+I0VFugybjjg BsGQ== 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=OHuu+/eeGhA15jm3F1XoWSiWFeSY4XyovC4+04GPp0p9qNZKEUKXO6TxgvVt8brDmN UAmPagSzR+eWjYhfptHnvdE1DBVWvEWfpKmPRR1txBxjTY2h47hvd1lF7V2VZ0giJqEq aClKGuoFeNjweDTJNV+9LDl9n4MMMAetcDXuksgv93hHda5OyxnTY53V8aglZFb2w5U5 7voBFEJ5Ov/uthtKTPlkmmsOTtkAu1Uvd19Sx1mNq0B51B+nQRlTguezCO2tiuNAZk2q 6MB3Wx9ni7DiVqcP5y0jtKUoEqF2chNkbGpwZEFQluBrm6l1Iiv3hXdb1XMAvmrFxbAr sEPw== X-Gm-Message-State: AO0yUKX425Ds4KOmjMQyPMIPVMOlOeOBem8fQB6wg56AZ/3KOFha5BfE 1L4bK1h7UxOyFTAUPdeGgWnbuQ== X-Google-Smtp-Source: AK7set8bRH063ylYHXKac6ftJj1sO9FB9pktD+iKmx1JK83w7c4E6KSrWTxi6JQskRqJ2SKoEBh3hg== X-Received: by 2002:a17:902:d102:b0:197:8f7a:b01d with SMTP id w2-20020a170902d10200b001978f7ab01dmr730860plw.10.1675086476838; Mon, 30 Jan 2023 05:47:56 -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 v4 10/28] e1000e: Use memcpy to intialize registers Date: Mon, 30 Jan 2023 22:46:57 +0900 Message-Id: <20230130134715.76604-11-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086606782100001 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 Thu Apr 25 17:25:34 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=1675086724; cv=none; d=zohomail.com; s=zohoarc; b=MeeJzvn4Vx55CIb99CPxJZcNuj973T3CjkeThortxx65pc11VA9NsZrydDrepQhNd0zkFjFyGhz0zRrgLrmAAxqqutLZwPs+mzFACumfgGOd4BCJ4TOZULZ1DVwiw3n8j7/7LyR26n6DOOlLpR0L3y8Q0bcD67VyhqMlgFIQHEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086724; 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=iPXnKE28qQMHyYfDMJ7OAVoU+wq4bcN1N4lyvyhY18xoolyeRLuE1PssSsrtMfT1g7OHbSYUXlKfGLs8huYq2IzZow59Gj7t+HPGBMeOdrCTmvICxDWtkMCQ6Bc3bVaajvAZv7ROhYhxUqhW/4vY+6phE32Kh8QonwMj5c6U/mw= 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 1675086724199855.4402097356647; Mon, 30 Jan 2023 05:52:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUW4-00046x-6S; Mon, 30 Jan 2023 08:48:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMUVx-00045Z-Cu for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:05 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUVs-0003d9-WB for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:05 -0500 Received: by mail-pj1-x1029.google.com with SMTP id nn18-20020a17090b38d200b0022bfb584987so11155098pjb.2 for ; Mon, 30 Jan 2023 05:48:00 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:47: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=NEMZ+8i6PiEHu0HMZDSd3axjDLwfNLs2Zat3qCkOTgQ=; b=7sZrB1nHqhcosZUwdxtS42F+8zwqI+xpKsp4k/+xSxqYLBk1dA7WmoVY2iFZb+7I4f F3gBBiAiXgsHUHjsVMu1X4w3MpSizBzc4SIPxTyG5jV4KKdDkcyK3OsjPFuvcCwWrno1 2rbYa/P6MOamivSMrn0kCRusjpt00b7Wv4Lj/fD57jzhHXTSwGR8KCwZm8s3hO3SUSrU YkZqPH4w10bEod2MV+bUE7kT/o0tkEWUmcelfgqLWZEzj3Cy/VP0zf5GnSawOGXaVble hGyQkC/wuzIW76l1t73I1mCuDW6zix5SSgF2D9fJFd4FpF84egl8glxD/Y7+b3WAlLby A8Qw== 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=1YYkKYpOBufkNpgEC82Efq62we6ryRxgrmhOzXzfWZvzRRfF6u+EwN6t7kl4q1urwK 2QY158EVDW51GNZn2pmANsapW0bSWABJ1eTapFjyouOLF3tXNgLCCQl/vC3FdM2Nm63z hyj6lDz3J9t2/bMQ4o7Ti76Nft99Sq2mDehM9yyDeSMdJp89DZ6A4Xx8ubQWb1pRp9Jf 3yFdPbrCAttN/M3iN7++4V2nQaTCh8idyzkfO44cfTQhv4UwQANfPERJccf4t9JbWbJT CyqWAd5Eo+f8MJAR6AyCBhV4r6VlG5cjXPxx567KCspgO1bCh4KPEI58cyj5qLxo3v1h s0LQ== X-Gm-Message-State: AO0yUKXJLLNMcS5NhNI9c2nY1MgvCfq/PnGUewkQ76Me6JQLaX9kq2Pw GhvWfZKD3bdcWJJF/pRbod10ig== X-Google-Smtp-Source: AK7set/k216iFYTJhQlF9FyI6K1lsQwGNk6VpYkosE2bVmxYZVEbiTCTPFiFor4Cs7hN8SSWKvwnmQ== X-Received: by 2002:a17:902:c412:b0:196:82a0:4187 with SMTP id k18-20020a170902c41200b0019682a04187mr5048809plk.36.1675086479989; Mon, 30 Jan 2023 05:47:59 -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 v4 11/28] e1000e: Remove pending interrupt flags Date: Mon, 30 Jan 2023 22:46:58 +0900 Message-Id: <20230130134715.76604-12-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1029; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1675086724545100001 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 Thu Apr 25 17:25:34 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=1675086829; cv=none; d=zohomail.com; s=zohoarc; b=en6cGxTPN8bUr0e4L+JcLFcvP7u+bHBoi1nDTyFxvNID/5Rxx4KQa37j8lZ1px/+TheG80CmpcwvhQgQp+m/EWPN53d4tPWq3CZgUtcEyODDyHHRlDwoyvtKzGe++EUwRt/0tZo+Z9U4BBZxmJ9Ve8yML+EJJb/blXwVStXLXJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086829; 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=KNqOxc869y70DUI+ihElRMXVX5Uy9ha/AFAfQh/DZ6peNgcX7HOfVO6AoU5I95x+n0gzsBTXw/Jtqj2HsL2MgN0FmflOL/daohH2bAPwmx/K0Y005vrTQ833o7oauKRSOzp6LZHQRuA0gSCUl/eOgesy4mzYLeaYeXFKqcR29y4= 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 1675086829222986.2689503725505; Mon, 30 Jan 2023 05:53:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUW5-00048I-Bn; Mon, 30 Jan 2023 08:48:13 -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 1pMUVy-00046I-Nr for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:06 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUVv-0003aY-Sq for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:06 -0500 Received: by mail-pl1-x635.google.com with SMTP id 5so11675646plo.3 for ; Mon, 30 Jan 2023 05:48:03 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:02 -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=7CGU6XkOSGt7ndxJuP+Ge45LX6YmZiOoGi3lYcJCjD7PY7oBAHPWLmKmi7vxp2HAvQ feaRoQ/UBWeXo/l2t1KvFBCwQpTd+4LsaaerD5Qh1gHHkfEL4nHH06JlSFXrv5wGVTqn abnEwr7CxCci+M5SSix+bq/JBsgj0k84vOAjigEFSBhbVDk4ATY2I0RBvcpSFG6z1+Yb hUqHYuyJQDarf25ZMokxN67bvZ2N2PCGc7NGbjv7b7aELu54RHYGxxEYgoz+NIBDeT8O DkaGVp02s8brL1hk7cW7XZEVPvFwSU3wdqC/uUVQu9o3u32OZxSG8rY4oQXaO5BWdDfo WHXw== 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=iwxzkXS3RfLshY5q7e/mrYU768f747NIAht+91f4Q7ri2+hVF1FF6mkaVtn9fxB5z2 V0pOCeJ8JsK+hBLDJUS0dV8Y3LeBcbZQGq2gn2N6agm5faa/qZSBpubj4Pgr2jynZrRE HCn9NHUs6pPEB2QM2LRGEDa/84IzJcgbzZnHXCUFgW4gRFGRfeSeIi88nPcOftdu5tr1 RiW343qwZLJShxagIIxZgUglJqOmrOab9K0Euzg7MMreydT+hjjS+v6zdKCLGd7zqsQZ jBXefdBu5G098BCX290OndbU4WnwNv5wjj51wWvYr6psRY2e/jmJBkm/XJra+FHkqfJH Jwpw== X-Gm-Message-State: AFqh2kqmEQwdOJANxzR9VbsDnoEDobWdtXa2QOhsP2ovm69+xmKDrCNE zRlEBLTwNS+edKrRQal1So7QzQ== X-Google-Smtp-Source: AMrXdXtYLJ4Y1TXsE8pTs9ojzy9SIkV5NBNZ7W/P/rajhi6vxZGSuEj4IIRfIA7JyohgKTPdYkkUnQ== X-Received: by 2002:a17:902:ccc1:b0:194:7d25:cb78 with SMTP id z1-20020a170902ccc100b001947d25cb78mr56077078ple.46.1675086483091; Mon, 30 Jan 2023 05:48: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 v4 12/28] e1000e: Improve software reset Date: Mon, 30 Jan 2023 22:46:59 +0900 Message-Id: <20230130134715.76604-13-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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::635; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x635.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: 1675086830719100007 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 Thu Apr 25 17:25:34 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=1675086719; cv=none; d=zohomail.com; s=zohoarc; b=UQU9Myi1ZclpAmIOE52Amw3PPV8xigP1k6hQZ4bU2+KURLjxwSNk6Y0tdyz3QUcrSZa4lSh1yGXT59p2p9yRbMOdA0O6Qn3p+77+OwBFlryAof2j5ZO78u9n1Shb3vIpjzRL71jqKJ+Ih1WVISTyauPLiEjBhGWFg9zYoe7vUSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086719; 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=B9+lcCILF1zLHL0jwwAa+R+WS7RB1ACkVqBwvs1ThkT3elPnFiB/pYEuyNZQlYcZ6u35OFjZymx9GnosgGAFMuCPK+m3ZZ/hCgJvN8JrHvg/VOtRvi5udLJQGon8Xl39xmebhS8l01kIIgVoNJcUVvD57qVnDgGp8WBp1s9dULE= 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 1675086719402353.18168232625897; Mon, 30 Jan 2023 05:51:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUW6-00049N-EK; Mon, 30 Jan 2023 08:48:14 -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 1pMUW0-00046z-Qc for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:12 -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 1pMUVz-0003cg-4j for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:08 -0500 Received: by mail-pl1-x636.google.com with SMTP id r8so4805438pls.2 for ; Mon, 30 Jan 2023 05:48:06 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48: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=A95PLfu5QduSNtWNtARVjFG+JlZHlsOhrX6r7BxoUgQ=; b=itliH7M40k4TupH91JQM8HmfroOLFLJkGhaUjD/0RtQT7UK+gE1TdzS93zys77D94P cMSMy35w8G1BU6YEjTJ0w9J9pNGPG1NWJ7+Ei2dRXfK4MtFirElXgvQ9kJcD63qOSu1s 9lYEAYZyR/S1pYOAwyiQoN3zJG3qOeLaSHsl90c0W0OOcL8po9TdQwxU4pdIxooHwYLF xbKgmR57ZPOJM9aGYJ5U06YbX0uPAa+Ae+ryL0eUMlNOaF5jPDg6XdHWeKwdBFunwEn+ gPYQ2ihTKP2GDFN9cE+PnJ3KPg2mNv9AfyDZ404ZBf6DoQLg/fJOXxZdvO9aFyaTEPP7 IJag== 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=FOt5EIpFrMD0IYcK9HKsg8x1SRqjONe+XFUl21D/Ptuk2Ft80BHkxDpnS+CK7c8GD5 lprY5/qisoC8eo5xmG8V36DR1QnqotMPITtipp0xlfrjJMa6xP3slyG1o4W8tE3w7S5a BVukmIrPXZ7yXas1yzC25+4VCnt/qm6PuV6JuTDOW8Y+pKvYz6GLkki6qR5wTG0cnRBk k1FDHL0Z0zfzGgdH/UmeBqB72jyWszKDPJ02VbaGGl5J1Hl6Y/7KHEcI1+Wokaj82+Xg /2vRN2hf73ylSifwNI8n8DO4Vun4Pq/T0uUwp+BzhY5/JERoq6tRB5zs7OB1eU+jMUvb GZ+w== X-Gm-Message-State: AO0yUKWWryDyZrD/Cbx/z/Glvev2oEcG6oekuKphnEP3IAuIs6Knp/I9 0hm2+zfzhHtnY44cOoffQs017A== X-Google-Smtp-Source: AK7set+3/9CxO2SUoWtECAbIKtBDgOrjwvyuKJ51ql8QFLx+rhhYDY3e31UOquwUjM521un3P0BCmA== X-Received: by 2002:a17:902:e5d2:b0:196:5425:9eea with SMTP id u18-20020a170902e5d200b0019654259eeamr15584316plf.41.1675086486457; Mon, 30 Jan 2023 05:48: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 , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 13/28] e1000: Configure ResettableClass Date: Mon, 30 Jan 2023 22:47:00 +0900 Message-Id: <20230130134715.76604-14-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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::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: 1675086720511100003 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 Thu Apr 25 17:25:34 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=1675086742; cv=none; d=zohomail.com; s=zohoarc; b=du7EdXDEI4gvDuGcWeCqAsL1ELj7gxehuBfENVxzKgpJzGhbCGyQSNLAPEj6zW7VHbbjRJeFdBa1JW1q77Gg/buOg6MmEjbfANVQ3uBE5XF8FQv4szJOFybV8GmUSmVjmvf2Xw1Ht895v31FuEK+UlFtW3JKM60KAKkTeJs0jm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086742; 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=featPx2dBg4zLxLaPzv77MMRCKrh3AI5biaWpOFDk/kKe1kZUoYmsFoXlM6z2oHlwDvGSE8yLeP9/8a1A7gv/nZA2W3XphClT/30eaRquGOF3/09+J6svttwZUHOEPJm0RYD53i462ye+NAfQipIp//rj5mihzJrwjBRPqrSvcQ= 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 16750867425528.655825383533966; Mon, 30 Jan 2023 05:52:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUW6-00049c-Lt; Mon, 30 Jan 2023 08:48:14 -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 1pMUW5-00048g-Rz for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:13 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUW3-0003jo-LY for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:13 -0500 Received: by mail-pj1-x1036.google.com with SMTP id z1-20020a17090a66c100b00226f05b9595so11182913pjl.0 for ; Mon, 30 Jan 2023 05:48:10 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48: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=ZKDVIajL0grC0IZX1mMpfaruSFD28K8Vy5dxxXgXXEo=; b=n5USP73N9pFABRwhkq8fV8QNs2CgCRYdB/eUwekLtSxP7NlvFgBZM6u61qPxYNg67i Z2tQZel+FV7t3ZrYJWwnk8M7Tf78s7w7ztR7A2bklTj6Y1s1yDAGVr1MPz4CqCe7zyuO cL3krzrZpzEM9hv/MgZW5JXUgWODoADSazu1MFfIQ6YoLSVdQgP8WlPvufnhzL6pXW7a wt3N4uKk5IL8RaidH1UBtPx5Z6edFTsWhsDRaa4RYlXNaDyiRXavMbi/w6wY4pEuJ0JE DkzMJkG4t4TN6IrSzLaemgQNLDexPRFuahtEDUxI2MfMGFmvKjzoVk+nkujl5ss7CZts GrJg== 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=VZ+a9AgaxuPmzbOdzVMbyruC27jgwnn9Qo4WdaBpjHL+urEJMSg5VgRjc7RMMcMFmM Vm7kdBqhenm0Y22hidP2du9TQh2zAFjjXICh3d2TK4GWGqtIAnHR6CxSe9GU7zYDzn1b TlVxZz8IhBQSbrCXaRMe9VgrkVa53srVZIMtcpfWwIyblvpUMWMV83yEhnyuOb7YpoOh jOb3S9sXAuwSpUIbxMH//TcyP9Ba9O8eNv7G2P/ZSQ4/WjR91Byod5r2YN0tBIeA+wva 08l8PsxL8a3hmjZhHFBwFhEhoGDLPuVHuGV8GJ5jdYuGNYO67Cw0J5dPMKfqTVkIFTO2 ehgQ== X-Gm-Message-State: AFqh2kpFtZnxy4ARXH8UsTmznos2kEcIyLn+rJjMjxOW7hpa2jBKk0Wp ZEpmoGXFc/WaL/FvAIKslpCJuQ== X-Google-Smtp-Source: AMrXdXsljQdbYEJ+bgZAKlhcRb2viKuwQc1CCwXcMDsHqCXLPY0vo41B8tmxeGDDXJkYeixWUSqjAg== X-Received: by 2002:a17:902:a405:b0:194:8b10:3bcf with SMTP id p5-20020a170902a40500b001948b103bcfmr43530733plq.49.1675086489872; Mon, 30 Jan 2023 05:48: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 , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 14/28] e1000e: Configure ResettableClass Date: Mon, 30 Jan 2023 22:47:01 +0900 Message-Id: <20230130134715.76604-15-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1036; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1036.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086744026100001 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 Thu Apr 25 17:25:34 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=1675086545; cv=none; d=zohomail.com; s=zohoarc; b=B49zJyXGOSldF2OhDf4LHYZcKJcUtm/7Sw1vfAv+Zy1aS2px7n7IF3UWU6lFDKX16yREsBJvyMlpBGtnQjLGUoMX6QTQYwLrWgn8KTFerobY2rsosxRNztkW3frLmxzgDwOAnQbx2JINV7qd2VTLjZKPWufla5cMZ8zqDxo+SL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086545; 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=JMHgLBQ9tesVI4iKU14s8544WWwX40Vyg3mLiMmJG3dRgqHKZlmrlTC2Q5uZSoxAgZeV2CgH9NJqkknp4pssFHuEQ17F8azcbx+dQ6uldq2gU6H6neIsXWDz110AIXIS6SAG7CHFzjTt0HnmSzV6uDe6QY118ztrj+RWNNmAv4A= 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 1675086545816502.5825084119741; Mon, 30 Jan 2023 05:49:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUW9-0004BG-RY; Mon, 30 Jan 2023 08:48: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 1pMUW8-0004Ar-M8 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:16 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUW6-0003mE-7I for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:16 -0500 Received: by mail-pj1-x102d.google.com with SMTP id c10-20020a17090a1d0a00b0022e63a94799so564889pjd.2 for ; Mon, 30 Jan 2023 05:48:13 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48: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=X6bMQPn27htLIZJGdysKYn/UoRZGCqzC2RjtDpR8YjM=; b=m2aHn1B1mfVXyg0dl7/2lgQtekYcxLYm5XPD9KFZ5BW9bZ61atCAWkMNyW2Z0mumUh dHmBwuK1vWFGzZHJsK9uSHA5yWmA7vMyRxBUKiCbP3ve6NxG5zbiHXoAAxHac3gcvPLh eM+RtTScMF8IxLWKjwlYvJDVA6RxWHDLCKqKg8krvhBh0PSWqUM/QChhI+eokuKa07qR 0ipfQPZPCOXT/Ui1wt9YPcDc1xsl3dq9s5P458qO/vAH6HIeGwsnV0NqA3zpQerGnzQM R2hq0sKNgCWXMCNeeithidfU0kxCH0iEZg3UP/wJUD5lbAmD0U94gcH/JtEgbF1PhKoH naHA== 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=8Eo9peW+VHkgpsTdVVooOkPbaHIZ3B4DI+wIQSr+SZ7Yb7IQhOZa1yklh0EPLp0jat de81KMPfxpspSjjlKEfTkzk9GX7fzSpEPOSB9uUHetgRWtyh/CUMfJr3NTyUzqPw44N0 D8B5+3QxqL9/mQ4J+hXmzw2+N8yjmKZpSYnDdkhjyBwYAAZr6he3+bvHT95FH8iu2UqI RtqS/ezFTj85YO2UWb9brWmjUxyAMnRXiYD/2vlRaqCNRIZM18V7m87eN+JENEI7TXQL ErU42ngCT7i7xa6QFvUuDG4mMn169WWqkTGna0UheYHDFrjwzrAZMlnaPpYW105G9fIH lu2g== X-Gm-Message-State: AFqh2koTch0ppWgnpIeRCy1c991NL4irxuRVZiKtqWk19Y2mWyoyGMYB OMBtIAOo75sNH3SyVxsfKc1N4A== X-Google-Smtp-Source: AMrXdXuONTHDzRVoWU+QtBfSdhn72ycDiuuYGJ81GWwhhSC8fqHi8soUSUuJ5x933zrMYLqEZwEZAA== X-Received: by 2002:a17:902:a70f:b0:18f:ac9f:2a02 with SMTP id w15-20020a170902a70f00b0018fac9f2a02mr43566811plq.10.1675086492903; Mon, 30 Jan 2023 05:48: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 v4 15/28] e1000e: Introduce e1000_rx_desc_union Date: Mon, 30 Jan 2023 22:47:02 +0900 Message-Id: <20230130134715.76604-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::102d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x102d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086546362100003 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 Thu Apr 25 17:25:34 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=1675086595; cv=none; d=zohomail.com; s=zohoarc; b=Q0Tnv0Ncd4Q54/sIqKeDeLnk2Zb6tysWZaDLEJDpmOq4pSZOGJQIRXp6dvPbK75UYjGE8EcAldNHSxDVUtPgO2SC739IbY+/bEBZbR0YNkFeDuZszUhTBlohuxvDhBd5+H4OY8TTSJIhnD0pZuScfi7xiCmmZqBdVRu0Sr4fw1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086595; 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=SDmFDSZTJJzrJKygJs+BjTUTQz2a8M8sAZTCpqZZr/MzfNWPK6mBDY69lZRCG5Apu5+r4xMcI8WJew6sKqSr+tPSp9/1f7wNrHRqkeAhXuWLWQSsaiKn5ZZXYeaSEt6GhwJn8gkiJ7jYngxJnaNwRLkaJdKhIJsqVEdj9tFNdrU= 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 1675086594857499.0550875746778; Mon, 30 Jan 2023 05:49:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUWC-0004D4-Gd; Mon, 30 Jan 2023 08:48: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 1pMUWA-0004BV-3h for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:18 -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 1pMUW8-0003cg-MO for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:17 -0500 Received: by mail-pl1-x636.google.com with SMTP id r8so4805860pls.2 for ; Mon, 30 Jan 2023 05:48:16 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48: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=eZRgT2FmJP6k2+ivrsYlbkoFP3usbYCinymjfjo1wFU=; b=BHqb9tibDCWVypFmMuXvt/ZKc8VWAe0aQz+AoLxLfxyOlBh+hj+3w8QENbDvHqUvf7 rRg1VVgqTfDP01UHiwLzDwlfVJmR7T+fUc90eXZ6+esixIZ//K41j9qdI66EgM64C0GN dOSh11ZKmrzQ66BzMA47o9hfY+sUmDCAuFJPrt15JnEWHEbtuaN42DP08BCEydqwfA3L me9pFBPHBSqz2gRUp5kFjpqLyWUfM/Kf4rqE8gXMme818IlHgWzi6qKYaTO5eeNfSHj+ TKuPdPs7W5CIqQgWwrzbmBE/Pm4gxHVJZE8lQWNat1DN9c/Sxm7CDGwiCq2eW86nbSvM 1cGQ== 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=EAKAELvPHOnYWfDHidezwjofu7I6Bjj8mltHWvCesNkTqvkq4ZY0ugyuCszjKa8QDR S5n5bhVZ9HhAILe3kYbH8+MqTY2DsO10vro3FfpM4zziARkuQ2GgXPGacjfVWmHVAuDD GPfUV6oA92OecgKlX8wKtGtdyYSlFR/v88biWeONmkb0x2f1bZRxVgf87KwA5i1lfv6W HrYddOhdbzNyDADvMS5LP1ba9eH3wnYaflhM6mok8gZI0PxymfghWKoSmCOITGNsr0uc RVdMdSI9/Ii40KJJ+Dg41NrKRWkDug57m5aKLkp0hiWJYMpfAO/YNwoNhdVbWIqonV8W wIDg== X-Gm-Message-State: AO0yUKXVpuIHZX6r1MgPkZ2MYvIyfCErfpRz0Y/1WcAwCrO/9/yNyiRZ nv4FOdNrryD8BaSCm6krLrIcKg== X-Google-Smtp-Source: AK7set/AmoRekuEOqbLOTn1tO+UwmunqznbOD3Ezt1RflWvevAbUs8lJFPVj7JMM+W/jvTtGJVi/XA== X-Received: by 2002:a17:902:dcc5:b0:194:a7cd:7e09 with SMTP id t5-20020a170902dcc500b00194a7cd7e09mr6122914pll.50.1675086496090; Mon, 30 Jan 2023 05:48: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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 16/28] e1000e: Set MII_ANER_NWAY Date: Mon, 30 Jan 2023 22:47:03 +0900 Message-Id: <20230130134715.76604-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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::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: 1675086596708100003 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 Thu Apr 25 17:25:34 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=1675086863; cv=none; d=zohomail.com; s=zohoarc; b=Yx+Jb95MRKuNa/grUJ85oXsxVoM5RhddHXKRKOCVh2bOH6+ZCgvaWGcAssy4YiFPVIPCW1XeDb6WFewFDo59MByU3i4AF8O1VUstDVZWYSXR0MI+bG2rT/5LwVgKrjpNLjwjROWsGOSk+xAc07sBGegqSAboaoZ5ez/HJ8Srsxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086863; 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=mLMFUhGEIGoC0rsuSqoPZLHsmUKd3UqFnnaXpTT2EfW3407HYKqtR4nSDceLnqGCW70gUPGG/Wozb+WcU7+1bp2+kDO2DjOgBaqi+rlS2t5h4oIahyKtSBJkjcCJpsm4v0JHjMu+DTfKR9WBcLoQq9il7DO7AlW4PldVaB3NmDE= 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 1675086863278557.5673177283212; Mon, 30 Jan 2023 05:54:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUWI-0004Kr-Rg; Mon, 30 Jan 2023 08:48:26 -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 1pMUWD-0004GS-SC for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:26 -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 1pMUWB-0003d8-VQ for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:21 -0500 Received: by mail-pl1-x62f.google.com with SMTP id v23so11677225plo.1 for ; Mon, 30 Jan 2023 05:48:19 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:19 -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=MrorY5+tWgZpKCNJ8f/CS7/PE+YkDPVanwXRTdw0IjBUTBd1b/zNQJGYsNqb+g3L4v oIEu+fQmUK0eVvcL+FZcVpKs2FntXIl4rxT6R3H4eZCEsuvSRvulHP19aN2eB9BbiUoN rrAKzoA3VfCv29CZsjjs2LwlWFxUhMESzQALJNqv4P7wV/0GE2A1kk/5khvJH16DeSPL fnBlrXfi3n1Q5F/K1pOeU22mtO+rnPEX+o0qGcmLYBnBZOCaiqJLoEoWjE4c1oMG56WN EtsMmW+P1Cg/khjQKYqiTZJQH9SXXlHZj4vU9GOsZIZ1btGTmuGeeDPUYI3v+Bpdn+x9 UGiA== 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=ObAQZHOPyaF5F5dTnqiy+EYZHTSYC+8Q5Tr9xxs4Y9PADPNyuO/ErOuVgqT8fUem67 mTVVYVkHOrwfGAS7S5Z0ekcky7A8iBDyoFM/doi6+AgL7PHwokIcAl3HDDRBMt+7cHH7 j9u9bAAKxvGR7sFQFtnvjFEu6mGSqGSk2Vo/i91PKwUuz5mcY//wJZqACgL11Trx/YU3 cMheqagDmwVoK6mkoQMxHCBEc4l5jvSjjD18bXsb0VGzt4m5DukxUoneofp4U0OLlFqS P1Iwsp2NwqQFxJw9eZXbKUfyAjfVpr2rx85rkrFegMEXc4MGg9aefrgaS3QBonmGCJWD 5wAg== X-Gm-Message-State: AO0yUKUkTCshJEdf1++QXLyVwXoh7xae88Lyz9GGl/CwLe9LyMqnc3VM urW2qpIkzAAlMxI8wgEWHE7jAA== X-Google-Smtp-Source: AK7set9qzBFRAC2tuX0/Ae/PxeDj5Yhpzji9AfBm0Y8KyIEWZ1Au1hH7SiTMAX3UPODmKC2ofIARoQ== X-Received: by 2002:a17:903:230b:b0:196:13cd:a49 with SMTP id d11-20020a170903230b00b0019613cd0a49mr27329194plh.27.1675086499265; Mon, 30 Jan 2023 05:48: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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 17/28] e1000e: Remove extra pointer indirection Date: Mon, 30 Jan 2023 22:47:04 +0900 Message-Id: <20230130134715.76604-18-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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: 1675086864670100007 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 Thu Apr 25 17:25:34 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=1675086570; cv=none; d=zohomail.com; s=zohoarc; b=LLHOvI0wjXt7HF83DocnAgUIWwHSaIjphIa7gCgEAaozPSCHgT5GInXzpPM/k+SmHv5LuFNyxrxKuSgUy3nAC6rvR7cxfYnqXzoDnXLkHJzrgXqOafymzaM4v+nlDcFWSQ82qqmrDJSaMqtKys0SzTZ+FmgnFdsWdOTaZcr4sag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086570; 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=Wbv9IN+yB77pGFV5lrMiBuF/7hnPmm2TZC5EZvjiem7ZaCiLpMy7Pqf24z+OKEEYqjpTeI+W32Nwv2jLhPBD8BcEQ0hco+V97hWG4f2zXQRIkpVmtMyUsZX2581Q9v2bRDfg04N+ZVvL7Q0+WxVdzOtaHyYub5mlHN5PKFCGuBc= 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 1675086570744592.8147095587184; Mon, 30 Jan 2023 05:49:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUWM-0004QI-8g; Mon, 30 Jan 2023 08:48:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMUWJ-0004Ns-Og for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:27 -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 1pMUWH-0003o1-Vr for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:27 -0500 Received: by mail-pl1-x62f.google.com with SMTP id jh15so2614594plb.8 for ; Mon, 30 Jan 2023 05:48:23 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:22 -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=1cVMBRZDGmwmYV0dV42cudKwpUYeElECOLY7JgqEknPD0ov9xV9phz3uJnGmtv7vL1 duI6bNrCtH2f/JcYcZ9GBTvZhaxLuwyjXdrl8F1W2nUyebiRry4HMRldUVHgOyH+PrDZ NVngQYUWrxHkGn1IIgOMkJcECcOb6gUjl1GGMl/KppIp6xnX2fhK6xVX+/TvmAB42C8N Viwi8NEUWIKfcwUnMuXWIbRRmKHddSr6/HeF34UWZ9TxtFgIjoSpiPTV9K6B6OxU9toQ kTuAhtfx0xyk2EJFg7znTkIGX87E/YMhem/2HNAp5brjydKvRir6Crl7X37XdoKi4YHE 4sog== 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=zpJS02t+YzhcMNG+qh//Qj/La7MhSTEMn+pHANpm18Sj1zyth3ggIbgGd84as3kKPl DZiKUTPEqWL9+leFkxPfR7tulm7W0ftWIKxQJHMGMzOrEWU3W3finTdxvTgVC0F3QCaK EA24t5MFyWqtPIoA2mizI6jY7eDd2FKHH3YRSbsW8sdcWuhBqf2k0wEgRkj+M8yT5mU6 78YuktXI8Of3gBtICX2MLfGNjGlQLyaCez1q+9ql9s7zQYeTRcRR3/4UE1CcP2boKbqb TbEuU+sdLBs8EC48BKXfkNSkhqCmbZr+5+eVlnGYauNbnEPY2ffooPnDvUsGpoYUy6ya EgYQ== X-Gm-Message-State: AO0yUKUdwFITrl6vQXxuIsJ4yCWXno26f5Mw4NflHhAC7aH5Xp49LyEo KwRfl2ui9anBnnFbG87BBModPg== X-Google-Smtp-Source: AK7set9IMiZ71fM59FehcskyHKHKcryNjl12ybLpYulVDazNSD1tGPrFMcXR5/3gP8xP/lxhorwCdQ== X-Received: by 2002:a17:903:2442:b0:196:3088:5dd6 with SMTP id l2-20020a170903244200b0019630885dd6mr22250066pls.13.1675086502399; Mon, 30 Jan 2023 05:48: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 v4 18/28] net: Check L4 header size Date: Mon, 30 Jan 2023 22:47:05 +0900 Message-Id: <20230130134715.76604-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1675086572917100003 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 Thu Apr 25 17:25:34 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=1675086875; cv=none; d=zohomail.com; s=zohoarc; b=SsukVCJqokUFAtyIMKg4tmVul5e5v+fvMBVZmq3Y7nL0K6QPoeCqf77CjcC/AIoNa2abKnF6MkBuldHGVn1srcx9P7AAWALEwyWoVREecKwnnIF3Fpnc/c6dX4zpq9bIG/wkv3lYCbYKpr0QXW09UokpIvwQJxGybD5wl1CDaEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086875; 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=bUxJJteazUdVp35GiCst4FIOci1eVsK7+gskbABq7hdaPj0vwBl+KchCWo7TCqkc7aBrdr2LhxBNYMAOSQTXVDegGsh4LWYq0htWsq18MI/J+3jYWSYxqF7klfhbCTe4eq9cpG1L+ZgoS4tXVpVzGou5bSsYHWqcUkavLT7txdE= 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 1675086875921860.0733753361066; Mon, 30 Jan 2023 05:54:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUWj-0004nW-Ow; Mon, 30 Jan 2023 08:48:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMUWO-0004Ug-LL for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:32 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUWI-0003oV-Rt for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:32 -0500 Received: by mail-pj1-x1031.google.com with SMTP id cq16-20020a17090af99000b0022c9791ac39so3101856pjb.4 for ; Mon, 30 Jan 2023 05:48:26 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:25 -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=JIyLJ2T4ojfTLXdjr+NIuFRxSId+0RAkzmP0UOca7vlAZYb0C1hrDyFBMXgUwWfQBJ a5S/wKbFYB9GtGcZojArn5KqwFS66iEdziIfkOvz5OvtFyHGSF5kE75PAGZO2hooayZA jW+2DFnW0GflalUiV89h92JkrK+wsRmjSXzsKVAEcUMlLah8X0lKRofaHEyNnUEN288n QyrnJ/JDzdUp9l/anUB6wW9DTYHVdGtmTcjyfO3lGfn9qSRF6NiQBgW3mSokWcWVY3zx WyVO3n7ojbw6qK/yI4f9B/JAG1HqOAsVtmcsc4SRGh14D6FD+0jNfInC/pbB2bXYL8RG GMuQ== 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=2z+Czl0xboR0DE3SRUmmnmtPFHDlNQ4iXtTJyxFH01x6Q8x7n5J3qtAdkcJKzgIuUn FpF9k9NXlDUPJ9/lknCXVNi76ES9gRUh/0CrgsavrEiNA4foz2RHST/BmFyjdlfSyj/a 6RNCJ/ngx/Oz7OXQGnmoNGhF7u/HKgtVSg1MqwuDmMv+sYVrdopYV5mwRrnfSIOaPfUh TA0au1MHrddY/elowY4UcALFOD+O4CbufKfbZwZzMvgB+P8Tra0TU+b12FbceEpsPcKL IfZJ4VuQJgxZv5d5pCfi/C3NI+budSaFpXPJ6cGPuLmxt+AQR2SIbuK08IShoaD17j5F UsVg== X-Gm-Message-State: AFqh2koB8TYhjsjrcb8keVCALaqeGk9J0tUqyXX0JyjIMzN/G0Kocdwi lluhachgrSfAhgYzK56W1PkqkA== X-Google-Smtp-Source: AMrXdXv7stYCX0eiWCsd5nVhZOqzvo6zVnAWLFjX0CxGCdqFF1woDgoy3Y29nY9HpM/5IFld5IGkWA== X-Received: by 2002:a17:902:e845:b0:192:f45e:4197 with SMTP id t5-20020a170902e84500b00192f45e4197mr65841994plg.31.1675086505376; Mon, 30 Jan 2023 05:48: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 v4 19/28] e1000x: Alter the signature of e1000x_is_vlan_packet Date: Mon, 30 Jan 2023 22:47:06 +0900 Message-Id: <20230130134715.76604-20-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1031; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086876724100001 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 Thu Apr 25 17:25:34 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=1675086863; cv=none; d=zohomail.com; s=zohoarc; b=P0SHhEZSWc29ucIPm+ExAE3VFHgLOlw7jTYYeaZJjYNdBD4gvsF/QUc/9gk0aotRlve6ecJg7e+i0VJv5E5Kfb2QuUJ/GLnt3K7BOHl2byr/FMAuAQp6VYt0Kst349nXZ9+Luiz/mG82+N6sy+j49XtA/74xcXtw3QZogBuvwQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086863; 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=SUPrBBjzTpehtQNYB/RfMWRO8iO32WiG1u6x05aTcidw97CXUlSG+dN0rjW2G49z39OrAbv2lVCR+/PNI1p1ywssH7yPUmprVnNdYGrUb5iDWXhsxgb6sRbgssTuyWzDVdzPLBfH0kxne69+6FLHGjwbazVq/pfiOd8sONo/vH0= 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 1675086863057136.96189428720572; Mon, 30 Jan 2023 05:54:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUWO-0004Tf-AT; Mon, 30 Jan 2023 08:48: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 1pMUWN-0004RF-C6 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:31 -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 1pMUWL-0003cg-6U for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:30 -0500 Received: by mail-pl1-x636.google.com with SMTP id r8so4806438pls.2 for ; Mon, 30 Jan 2023 05:48:28 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48: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=08HI+/g3J/zU/4EQGD9UqV5IbiaomXGENBnHx0g0yIg=; b=X7gVeckSeXr0cF98itQctjXzRmCCgRZOxo1o46yzVbeQg+9+Fh+4XoumKc8lyAJ2fX ym9RNjJX04Dz5preKE0xMQsRCVYjQgfqa1aVsk6KKk6dBs4mpzqIT2N13lhORbXAhN+o 3PNols4w/0NN6i4NbEnWj0fWXKeP/fqzfKGqFdcwRVEdnBN4l5rvz6TqQTKMbM3Hzf7s wN3rNGv3rpMWPlp2eFybqz9PGePV9aeZUypdY4J4Bowrok0ry/Yo6r4Vfvf9H5cxGnQp grevR07L+8AZMxd65VFCoPDLv5t77mOx/cpHQFylD7Jb/Y2d7frairA7m/wL0/l4dSZp vzlQ== 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=LQRcUHLnuHEbiYPExy5EXOCyKsqN+y9tbgcRMPYLQI+Dg9o/WGtX4O4AoPqRlPtlD/ 4eExLdIwxrAf2sWNKdZHlWZ7uspL3vAIjqGYPGPV6vvW6BJbRV4L8VsD9dqDkOmG7Y4s gsRVmUPC39UWpeY0CzrInLxTCrHz2y/oJ1Gwt8Dd26/HMRCtc1T8dQ1jKKw0crNcfPvt T/iSgAQB5vZb3POsqYJ7m1nWskSsNr74rCp3gXeC/anzuKOpy8vd4OgD8eqOWRwh3CZi xD/E1X44JPtfiN0KPhctMWA66LU5lckAgTRM23mF0oBgjXOu1Xox6ZG+i6R3G5qnm2SQ 6C8w== X-Gm-Message-State: AFqh2kos/QLJA9oWACCSdUQIqhyMgAXRZ/bUcnvsoO6c3TMa6DUa7l1u 67h8Ve0+qYOEERBG4xenfqXv3A== X-Google-Smtp-Source: AMrXdXsVXJkD090TvFDgYUV4MR/PPp9BLsqSyRtJFPkKRHmmX2aAvyUj/ksurj9ARJnQu/heH6LpWg== X-Received: by 2002:a17:902:b20d:b0:191:4389:f8f5 with SMTP id t13-20020a170902b20d00b001914389f8f5mr49102950plr.34.1675086508461; Mon, 30 Jan 2023 05:48: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 Subject: [PATCH v4 20/28] net: Strip virtio-net header when dumping Date: Mon, 30 Jan 2023 22:47:07 +0900 Message-Id: <20230130134715.76604-21-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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: 1675086864682100008 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 Thu Apr 25 17:25:34 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=1675086675; cv=none; d=zohomail.com; s=zohoarc; b=Yw+C/2/dtG6jCYIaH5HbwGJDmu7WPZFhg2zyqiHO0DKUKAaBYCc9JEH20XrosuEGidsoUWG0jgU8Xjnff0b1j851rKceT0i1ThPFzEutkP3tOqyuPxkj1P1F/hNYDctH48idA5ElDzpwi8aBlKR3UEFBhVCPCWG5wBRc7tDBztU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086675; 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=H01vOpwqxiCLp9c3NvmWytRxVt4Qkfoidlh8O95DDPTHvDLR34uDVPcJDUWNRcHiQbzD/UdTbOLqxN1XsrrBnFxILXZqn2vMv+11S23Smm61m4qinZE5uSb0RKVKwnVqB3DeZPeXXaPn+Gj+bFixX46bYnhg3lhlHxij+9Em330= 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 1675086675575688.5926352486039; Mon, 30 Jan 2023 05:51:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUYF-0007cM-Q7; Mon, 30 Jan 2023 08:50: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 1pMUWQ-0004WM-A3 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:42 -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 1pMUWO-0003po-NU for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:34 -0500 Received: by mail-pj1-x102a.google.com with SMTP id cq16-20020a17090af99000b0022c9791ac39so3102159pjb.4 for ; Mon, 30 Jan 2023 05:48:32 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48: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=UcFLTjDv45KCpptCdC/ryRw5eMMuSI6G2rmXSFY7zGk=; b=vJLxlP1FXN4bExGKd1Sw8X/V8m+cy9r0nyXOL+ZbRkSMzYgJESM2zOdc3XT99HIA/+ hrwV9zIOeAI9g6EeBn2TgGIFUF01cPQY6fN1pdAnvygxNrk4xFfE4ssFhxkIY/49140+ 9lWcCxn7ss0yLTgbmHlJXo1IbPix2VGhA5TrfeF0XIXMFbFPZfUwjb6FH8rwbM2GKLm3 qLOrY6JO/tdoE5VzNAwHRbyMm1JObN2YGbuBQ9728BdKNdpblMhU/aEqEC6K08eyMcqu E99AtlvLSsJ76yTw3rNYhfcnGKd/7RqfmFyKNECY6cbFg2E2Pch4Sy2ENdcO5J61Rxww QgkQ== 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=o4Eg+HW+ICA/keSIdaCtU3BbyUP1tndXdXQ9V1QnPsEAMVPmyAPD1f6FTeP4S19VPG blDpB1e87ARxCNR57boVSkzlEzysZPfDZsvli3+hS2W9aQSTFP21JKR29pZVr2kfI+cv PtHwKM2feOunnRPiMYETH2hGlTAxS7ukeoXBZPNTiLLP6ey+sSPnWe0E5tvz01tDJBGL P4uv2iCr7YvxxTfQdHDQTogg/qJ4ba5/zZDhiP1rTnakWRBSPGbQy3ut/5V4jWvQ5AE6 NZzO64QusCw2B0SrFaB6ohN6hl40joBosfxH6AXTux9SWg/vAV5ZL/GgWIgo4bKwY2GL BUnw== X-Gm-Message-State: AO0yUKWGxlFR26wHUa/dfdN424thO1Baycne7Kb97o1zo/uh7wuabCYQ mUmrLMRBHT2j5hz/OxeC7bVGpg== X-Google-Smtp-Source: AK7set9f04GFuh9D2ke9QtAg/9aa2sNXIWFVZtnkuSABUhbMemF/xc/y8Dd8yr524sleoSm8IHbVvA== X-Received: by 2002:a17:903:2291:b0:196:704e:2c9c with SMTP id b17-20020a170903229100b00196704e2c9cmr9617569plh.23.1675086511567; Mon, 30 Jan 2023 05:48:31 -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 v4 21/28] hw/net/net_tx_pkt: Automatically determine if virtio-net header is used Date: Mon, 30 Jan 2023 22:47:08 +0900 Message-Id: <20230130134715.76604-22-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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: 1675086676146100001 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 Thu Apr 25 17:25:34 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=1675086552; cv=none; d=zohomail.com; s=zohoarc; b=QlRA/UAAd5KenS0Jyz4EUn1BSK6HCPtPki5wf+SNLJtJsp3NUrSYlbxpy/6zLxaqatqh3e0tj+rn75V5oQecgUV2AZoSOEzWjaGJ0QS42sfqHTTOW3nlkQzaKqZofeN3Vtd0WkJKejieLvOe0laqAaahL8dt4uSUWqRHSC63Sxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086552; 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=Kz/Iok3/DT73LSSTziLsdk1X4dWCvsu2TWPvt0V0QtazfAkmZprrdI6jzdqS/AHm/GWuSDRr+F96fIMiI5lVSO0R1QfN0Lb9iHBJOnBKABLXxw9wqjYGAHDgtfjF0lyWlQg6bVh+YgLwl6nGfz4b27EdiME6vJQUBEw23ybvr4Q= 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 1675086552156212.13251535299605; Mon, 30 Jan 2023 05:49:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUWt-0005A8-74; Mon, 30 Jan 2023 08:49: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 1pMUWV-0004ho-4W for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:42 -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 1pMUWS-0003qL-2B for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:37 -0500 Received: by mail-pl1-x631.google.com with SMTP id z1so4126228plg.6 for ; Mon, 30 Jan 2023 05:48:35 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48: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=7I3zAPfeFojTupunid/+QowtllUnj9+g6fk7fhj7MBo=; b=QwKmP1ZRO5J9s3Zspl4rGsQW8TPN2diPVm/EwWx5ckBnD+CNhDRRVtuVuDx0tcyDOb hss+sBwuGmwInrX8O/TahXAgdn1daP/7oZhGvi5YI8QrAtu4r6//9ycV9IJfpv633Au3 bSs2K/JvUOS3SkMJML/pjnxCpOhTxUM+ozkaUQvZFY1Xpa9eTZO/WuxLAdPjx1uUyzOm iFNYRcuMpgl4ujs9YiHv6viYX4ih96keGwim4wo0n96yeDartGf668T9eDaVK9A45BtS CsG0tVbPxCbyLtDHPIbOAUzBNp043u0wvBzberIVb+/v3OOTXZh/osZrSEaiQCK+pex3 KGpA== 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=TXgW5MyBUursjkClJJ3RQuJbfOxjQ6BIQl0tl8s5v29ce4XJgeCIGKPxUsYdpISphJ gAbd63K+aNulb9s9RQbsS9IgSJszcmuGEsIeMFS4pWA+aUC/A4COJa6TxHh4cGYNy9fJ NFvVaAyLgdCle8KO/5RXjgccyvdFEw1VSnDramcXLq4maUXLGAqJI+v7n3NlBML3Ci+F cbd1xFHPdStDImqZ/GnIBxfA6ByGAwOgySxny31ubf0Bvtb3IQ1nAw2mqokE1IsURHoN 7gHxjClRtjx55msyDF4mMn0BhCj3e+hqhkgE3kvWLq6cvCgaLQqM8XRYsK2EaGblqdq0 +I1g== X-Gm-Message-State: AO0yUKUszxkMOBr9d2ZkeSvSQ/x0RWTZicde3skGpEIk+lmnjBZ31wNU 7z1zAfZwuTaT2Ziv/kb+leC9mw== X-Google-Smtp-Source: AK7set9AcfO+Ax7Wv1BzkqCiDVJvGGw1QZUwzVa+gKsPw7X/ZhS9BH5bRSodqfP65dIeUgj4cJf/+A== X-Received: by 2002:a17:902:e74d:b0:196:7103:259f with SMTP id p13-20020a170902e74d00b001967103259fmr8469622plf.7.1675086514692; Mon, 30 Jan 2023 05:48:34 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v4 22/28] hw/net/net_rx_pkt: Remove net_rx_pkt_has_virt_hdr Date: Mon, 30 Jan 2023 22:47:09 +0900 Message-Id: <20230130134715.76604-23-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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=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: 1675086552533100001 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 Thu Apr 25 17:25:34 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=1675086829; cv=none; d=zohomail.com; s=zohoarc; b=NBWhVzmRF3CiQJX3QSKbSJsiXrDIAst/pSp2HthAkBiNICSbQdGSh3DPS6ia7MJpL4xHD6voBaVqXqr+p/q8iEsvOFtuTIc+dCGBPys11U0uEZjlo78qx97pdqfdAl89dbIkYrBprCrc6Ww/V5otx9ZY53XG1DWmCqNa8ELm//E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086829; 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=cvACWc+l2XomMt6YTkL+CHWjGlwkP0EaPMQFdkWwNUk4nFiQl7lqLi9Pq/2i9CBK+UhE7kdf1gj96exOlucrY2aPt4rZX8I6lGtnscyk+vVHIRQCLrBLRnBu4zDbxVamXyTVGqyYZtLNfGqxLrKAkJjpOfqRUDMQVlh3THH1gkM= 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 1675086829616253.93603682084347; Mon, 30 Jan 2023 05:53:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUYY-0008J5-AI; Mon, 30 Jan 2023 08:50: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 1pMUWa-0004jE-9E for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:48 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUWV-0003qg-CF for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:41 -0500 Received: by mail-pj1-x1031.google.com with SMTP id t12-20020a17090aae0c00b00229f4cff534so13312104pjq.1 for ; Mon, 30 Jan 2023 05:48:38 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oLrWHd65frzqttg6MaHuf9ZrkRsJYxBcXGezoOzJp74=; b=6ZBm8/fYRuAm3l5avmCRpAF04BPHfWY3MzNEd0Rh49wzAuWeY2V1p+VQiIMPKV8de8 LTa1PELKZD7EaKqcGgk/cSE5eNvSbq7qeD4gQswl4KT7JB5W/psRzRDe0sw6W0GkMu6o Q18cOtS7yW7nQXAXdzjbEUUl5NHx4Q+KXSXuwkKoNDuvEcOsh/BvI0Jg5KTj63ryCVM6 9+J8aaT30M/FJgG56q+O1kDL3GaQel5U2v9Id2wyCfSLlm+R+0YLLV0p3jF0guVovS3/ +aWOQyc2K/2OPKRRnUBPwcBX72aoUlUvYNKMiRf5npOxT+Dg3BGSjqBZOssUs4ZPN1iZ 4UIA== 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=Qh5fJgYJtyhv8dWkcoDqeZDflhn4YFyKHM81/SSzOqDSDdlQ9X10FSGBIAMCkg7xD7 ed7AbsdgNs8gu4Exufq//6U9KFA44CH9HE7Gnoc+bh/Cs4sTWCKdcnWywVVQWvaR5OVQ jgCSkGnRd8RUQiPEMBOuaD33eLJMDOsbuyKLh4MgtsM+TMulSqMmG5qAIB2hXNIcIk2l +sIlh90VIS+CT1NpKPtLWG6M4foZr3j0eEJtJGnxs0L+l6UFlENW2QVbyUGANktVBikP dA5Q9euKBKGWZZaeZstthj4KaevbY1sEXnAKfconpNiIl3ugp0qgEwKjdp2cbdoAB9Cl /iJg== X-Gm-Message-State: AFqh2kqDKQIpuf8VHHvdEO1BaNKvPrUkstgjCJcUyshgeUZVxugt8txd V+C6+TTBJJIdDrYw+JV1/RAyKQ== X-Google-Smtp-Source: AMrXdXtgAAbLQTcZ34ES2yLwI6i7znVYvekaJ/aUZ481lWLk6oWiuf5zVpkSoAaGHXyXbrnNbnzfiw== X-Received: by 2002:a17:902:778c:b0:194:7a99:d5e2 with SMTP id o12-20020a170902778c00b001947a99d5e2mr46899202pll.62.1675086517832; Mon, 30 Jan 2023 05:48:37 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v4 23/28] e1000e: Perform software segmentation for loopback Date: Mon, 30 Jan 2023 22:47:10 +0900 Message-Id: <20230130134715.76604-24-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1031; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086830727100009 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 Thu Apr 25 17:25:34 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=1675086724; cv=none; d=zohomail.com; s=zohoarc; b=kML1jdBEn582yzrPYuNWaZwJzwSTN3wGtbY9Pnmigliv1Yp+w5aqbJplTEygdFE09HDUs0NX5ETy80vKEH9YVKFcLNyAGkMqFdKDoUxwirXKFj+FmDMOfcVaO8/EfDKLAWY+ROL5GOUiVggZe1seewBr1YkkNry0Zi1iflsh9gE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086724; 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=eYzjEow1z6NPLJ/eAWsqAGAj/yYOq8rvSzUSyifqT8T/EjLo0Z6xUr+pZcoFF03mGx3LA8xEh9evvX5j61DUJ609SvFIFiCFJPg7zinQbGNW8ZJUslj/OThen4TDJyW+wYuMvrDGCpyfppX+31Ty/s7WoVhtI4rlykS6/kL326A= 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 1675086724296128.669728215458; Mon, 30 Jan 2023 05:52:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUXe-0006MN-GM; Mon, 30 Jan 2023 08:49:51 -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 1pMUWd-0004jk-NQ for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:48 -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 1pMUWZ-0003ay-Sd for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:46 -0500 Received: by mail-pl1-x631.google.com with SMTP id jm10so11627544plb.13 for ; Mon, 30 Jan 2023 05:48:41 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jv/afEJcthyHIvIcMbqTIPEoZmHEVzJWfRny7dTpMv8=; b=e0vzqaiKhrsTAJpj0ePrigG9Um4PCQuKiL8fYWYIZ+9c5aEizyFfJsg7d+cW6Mwvo9 xBT5DjD/TQ68AkbfiSTsYz2g4BkQcwOs9bjpY1z4SmTAjqSNI1yy5nKxlnFAtH7qLbPB 74dKbsIsxMShz6aLdjlNexfGU7PxmFJSlXcQ6SWZWVZEeJdklzzvFD+u80dOzAmN0iDN z1J91V90vdanlRBkON5nZgYCVvQeQjJHu9X20tfEo1us+yhlFeOu2eMLQsaF52qcFHg7 vkgFubGvq72i2Q7QSJlvC9IavYfTlUjEsYaVcXL/qoejOUgcXzP9tkDodQkTWpGbBW0y 3L6A== 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=rzUE3xa7LgC8NGdlV+uN+k5KZCGYEWSBCfwJNhrboZKLNamFkfNkOD+aQz7IyOhnES EmcOF7sPjnMF+4fvME7NGZTCk8Hvj3wvIfhG4/S4uSCd025LwFLs0rZlDEQ9U6/gaoN/ dw799Z3hUxizKLN/CK/WawIyJzhruHhA/t+9oDGCNnC/q+nAX0QHqCYg0DMhQCBHbYi3 8eyKBz0/VKfZe/Yrduj8sv9H5EPya9NkkC6VrXqerg2BByGHxjEf1uFUk/GELeNFYxK3 OR2Ueglmi57S/axqZcIX0uOKkGtDXto8CnkVe3Wfs5mpKpQXM7fRSzUXOtrDkFkD+sLy hwMg== X-Gm-Message-State: AO0yUKWJkiv0QKoV9kkhRgxVti7lEplPOkYNm3D3bDoCUBO5VgSumrPb FXXZIuJaOGiv9Wa4QrbzsDMfCQ== X-Google-Smtp-Source: AK7set+cqeiKMNYMt1MIByfaoEpNU9WqqKw7JKY4oU6XHTjq/C0OqlTLpzxEM31MmUg9rZi+4yxxgg== X-Received: by 2002:a17:902:e88d:b0:196:f00:752b with SMTP id w13-20020a170902e88d00b001960f00752bmr28844855plg.66.1675086520892; Mon, 30 Jan 2023 05:48:40 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S . Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Alexander Bulekov , Akihiko Odaki Subject: [PATCH v4 24/28] hw/net/net_tx_pkt: Implement TCP segmentation Date: Mon, 30 Jan 2023 22:47:11 +0900 Message-Id: <20230130134715.76604-25-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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=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: 1675086726626100007 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 Thu Apr 25 17:25:34 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=1675086890; cv=none; d=zohomail.com; s=zohoarc; b=i1IRqUF/sEm5P1RfIevxdGwMJNPzzYCCqNI55hrVlUb1jdS9j6TsxYy50TpV51qohJg/f1tpwLdFU9kf/mGCNr/Lak8EmvSUNyU8YsyA1t2ApZdGBatqfRumXpOPdpL+aH98J7EX5dxcqZqlAWBTH6varjeJ45ZShp6exX5ngmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086890; 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=K/m8rckHf0SCJeiCyjst8kbxj4/qTeuzKSttIe3dtkEDpvm88nUiB1aJUvpXy9cpHFvP8ySlDhnuy0c7ugt2usOqnOXrVm5mQh1fMt9aOtdoT+2Mwswh4Tw/2S4g4uA7f+pRDxufX+xFpAKsUgJz4CnZaVmdHRCT8ZAiEJ7zBJU= 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 1675086890820842.4095654388161; Mon, 30 Jan 2023 05:54:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUXD-0005Xf-FV; Mon, 30 Jan 2023 08:49: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 1pMUWd-0004jj-NQ for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:48 -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 1pMUWb-0003u4-Iy for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:46 -0500 Received: by mail-pl1-x62e.google.com with SMTP id h9so3057673plf.9 for ; Mon, 30 Jan 2023 05:48:45 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:43 -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=rlQN06NEZOePKyC1bw9jjioqwVuQcOlOo1+rOGSQb5LRJQsEQXc9Zk0+YF7qvzKmZB 3n5QCfSo8WRFqX3UdiRQozz9SM7re1YNG+qQ4YSoaRiLPPgbTclZ6CVqQCMtcQcU+snz m4GU6R22O/YnYnqUX9iv1FSRKeUMLogfY+pDaRByfiTlVqyPFqYkdXv+8q/gj3EuwvdH lVHj3kZsJjghaxkx3fibvk8mkVhPC/nZptX/CkRPCcYIlqbj9LmLtHv15CTdCA9x5xeX 9vuSbVkMZkmI7I4er1iEthSNMd/BBJ/W/UceIBQwKexWCP/jwG+sreA3QpLouVjGwqKv cwKA== 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=b6IFDD7YVOOUV9Fv7jxNPj27h5mQ6YQQVYjaq95UCiT8M9zVytFh3qn04PeCokRis7 H8sXckCQvGYhSEHvWbwDQV9uyKMgqmw9ADNf6EdhuTjHK2rbEVfhMCClEJuyifnF4BPW azVJ2THJgR7AW/J8z7QLyeG4qTcoCR+AwqRUZT2WfqEzeu7lqq9fcUqX7hcopbgcxVpi 1+6CVLnevum6OVpUxB6qiA//NcFpCWPeUjXglJ4aJpfU0zWZllO5TS3+rav1YmExVN05 P44mwJNcqsWpvL8KHziX701tYn3yZQ+PnAZ3jMl+B/isTzyxUxw2qCSM4zPxRJMi+XqT lfew== X-Gm-Message-State: AFqh2kr0y3ooVKgxYhIbQ7C0lJRsO8HufAkf03Dy2+0rX2YhGjBPdd11 Fa5rkbyHge8rrtNWS3ubyj8DYQ== X-Google-Smtp-Source: AMrXdXtMN4BHGrHtWDFXXXwLXG0jS8udmcrFNIz6bFUnS4enov2P4od/LwThGs88yR1COlimZJ75Dg== X-Received: by 2002:a17:902:784d:b0:194:92ab:6e23 with SMTP id e13-20020a170902784d00b0019492ab6e23mr40065800pln.27.1675086524046; Mon, 30 Jan 2023 05:48: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 v4 25/28] hw/net/net_tx_pkt: Check the payload length Date: Mon, 30 Jan 2023 22:47:12 +0900 Message-Id: <20230130134715.76604-26-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086892980100005 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 Thu Apr 25 17:25:34 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=1675086766; cv=none; d=zohomail.com; s=zohoarc; b=UoD8UCODn6yDhQu4Dnf/7+NEvTbEj35TEslscrC+pu4idFK2tlTaMLl8EPFa3wLckh8Fl5BjCVEeVt1JqqnkGHYKFrHYk1ixWyc9yWP6v4EQAcELUV6Wbi8pah6G8w5Mr4BPKX8ugL4oiZwVxo6Hx0zfSt2H47CEz9Haawd8wxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086766; 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=dfGW6kBPLoJEmPCo82YuYpsnPwJ2x13d0YrN/fwc5MoBXh04hWw25NHBVDto4WVFh+N4GPKjTj6uo6iLoht19zDf7MbTc+oa5AP5ADcA0Z/UzzaX6/bX7yWNa7WKHzHG4Do59nErqF1nwLiyZTJl+0MUQq9b5qaLAHtq+sTzqe0= 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 1675086766590377.3038343667423; Mon, 30 Jan 2023 05:52:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUYN-0007p5-Oa; Mon, 30 Jan 2023 08:50: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 1pMUWf-0004nh-A1 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:53 -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 1pMUWd-0003n1-Nz for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:49 -0500 Received: by mail-pj1-x102b.google.com with SMTP id cl23-20020a17090af69700b0022c745bfdc3so4551043pjb.3 for ; Mon, 30 Jan 2023 05:48:47 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZSa3rJ4rdM+JL+7J+WlKqYqNPxt3Id/p0w4TcjJhfgI=; b=C8rTS8HwSZLAVNTETPWInzI0QJUP9LQyF/gJy7pSoc53JzW6sxIO7OyWamdAJca8XR R9Eo4YPpI/4qXQyUJJj79PqlMYKBnIcXuH+oRWGS1mkn6MJ7kNPirFgVu9nVpt1LmMQR 59YdWllZXTCm5Jwcv19fZt+dAKzJT1K8IJJ4hWfvl/qzzg+2touTqLcyUMTiCgHOvsIw b9kk+fNtU3iMND0FfayChTecuGazWc8x7s7s7o+BG5Xw0wZC2kTDGWhgXRSE5KthJYwq 0ABWCY+bgxAXrFSj2UoVLwMQORtSunxO4hAOU6L+HFPW8S+1auzIgU7whfd81HbX2iuf WYCA== 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=LkPAHbHrgQeek4kWhRvcNAWPP1yIlEb12GbiYNqa9zylHPWaM7e2mibLwaPZKdcL6M NUT5rLiAyMULWGfdiHprqlVis3sjj2eaoaggOmZ9MCSvw9+Ox91uDJ7b/ux3y4LOzzkC x/1AFol7ptxkzLBbkqUnKklbKWtgfGJHQc2s7DOE746u9E4XVoPEvl/hLd8/CdFNh5s7 Aza9/y3SMwmNMbW6OWkf7R/uPxdtNH/0PGKiwvFdebvSocBQxjJKoYsEtqZsXkzqTvHO cbUvZ2Y4961rjypSJw8feiMFfRG0cUQFRdrF0/uPaWwImJKRRMv5TgTBW5qs4TfjYmhS iZGQ== X-Gm-Message-State: AO0yUKVvW7s53FzxF1rjHKjRyhYxwba4j28tf1zwc2gd0IaySBMBBzEC s9jz9KC7yBS23Vr7mgnj0R5cqA== X-Google-Smtp-Source: AK7set9mUU5IVM/YkpJ7yDYgS1KLJzMOUyJ/k/03I4sEJv99bCAMaZyh0fa0NfjfFuaM0rfM9H8pCw== X-Received: by 2002:a17:902:c60b:b0:196:12de:2810 with SMTP id r11-20020a170902c60b00b0019612de2810mr20392133plr.10.1675086527128; Mon, 30 Jan 2023 05:48: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 v4 26/28] e1000e: Do not assert when MSI-X is disabled later Date: Mon, 30 Jan 2023 22:47:13 +0900 Message-Id: <20230130134715.76604-27-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-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: 1675086767705100001 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 Thu Apr 25 17:25:34 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=1675086829; cv=none; d=zohomail.com; s=zohoarc; b=HIOAnvwGbczJ+eTeUXeIZq4pDQFonU1XKg09IP4EBtZ88LiiXyfTL7Qmirc/Cwjnx5JYFlpPF/r2KZR2yuU6IC8MPdhiM6J5P6wcIscKX75MTtSvfH5wzkgz3aszgOL6NkmjWL2v+9OzdevHu1x5sU+/EPmGZsDU+SBL2+o/J74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086829; 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=DjK7LAaHwQsJXMaj99MRNmkq2ogS1eZ1Ec6DnhBsNH7Zs6G7jcW0CwF9jwLTa7WV/IUGdtQ8DANNSdpnZ/RzsNAceAd2rGZ6BUHn0NNnK1b3VEgC1NQCtPZ5LytLy7GW7RhRQZc3asvghmE8gQN/GsnWgZ6s6JKCzw5W3prvqSc= 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 167508682923890.74857290033503; Mon, 30 Jan 2023 05:53:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUYc-0000Lo-9f; Mon, 30 Jan 2023 08:50:50 -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 1pMUWj-0004oJ-1N for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:53 -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 1pMUWh-0003d8-Ic for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:52 -0500 Received: by mail-pl1-x62f.google.com with SMTP id v23so11678610plo.1 for ; Mon, 30 Jan 2023 05:48:50 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48:49 -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=qjO1UB9Up7j3p20CZBCClrNtzTp6Uz/IKAs8WN68ZDEJVI0jNAf6VHg7POpHyXwLVe vayfVdAzCdT4boukRInshHC4oP+eC+2fbM6p6tXGaLitcmH2bilGigwQbwzRbaS6DZGG SV5+g/waP3z7nMUiDbp3eoMqO4p1UP/Y75hnydwKX0vxmAxDtaXs9ocqHDf3R1qrpJ3I r3LC2dHS+WEY8O+unad4Nc9n0eEv1KLLgfC7nlBn0TvbQprXqARsoKO45FjcHHtuxCHs XjPjvra9ps3qM8+loBLJ4JGynQoSTXadX8ztzGg3Vd4n1u7U5etOgt7vv852VULj8UX8 CfUA== 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=hR+3JOmPz+u7iAbu+GIZz3lSltrgRLIIWgj2VJ1YYQ17t8U/qcu0mvz4ltWZed/VEL 0x2aZe7oBylvZaHNzExC+vtzzHnxNYXRRF2kQZ7m53NtycStPpsPYVYLircmOFEqOoR7 qfeaOoq46DkvIxGPTi6b/U8U02txCSvTJ5iqNBLP78FGwZeHg75cjXRUALxopTRiy9Es 04JZXZGLBk93EfhWb8T734Mzof7XTUSepDnzCG4M3Sbtwut8O00+aaJ6eF3nYGp2jeCT EBSdU1qRo6CWQV3L8LT75FPh807Ky84D+2ZKap0kvJ4j9n2FySRtlsCYvE48O4hSMcI0 SP4g== X-Gm-Message-State: AO0yUKX0X0zPBuNj0Bz7T1W61f8+Xgv2MN2r6sXpdOW9SW1zejjcQoA8 2H8b6trMYeWpGyN2yC8rcYQU2g== X-Google-Smtp-Source: AK7set/7Ap+tJMnWi/yRM6OBUhr0rrSlOgHbOpN5elBf9Q9ZFKLntAjsGrWzIzvFaxzC/0VRDNtCiA== X-Received: by 2002:a17:903:1d1:b0:196:2ade:6e21 with SMTP id e17-20020a17090301d100b001962ade6e21mr24255454plh.14.1675086530147; Mon, 30 Jan 2023 05:48: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 v4 27/28] MAINTAINERS: Add Akihiko Odaki as a e1000e reviewer Date: Mon, 30 Jan 2023 22:47:14 +0900 Message-Id: <20230130134715.76604-28-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1675086830650100002 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 --- 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 Thu Apr 25 17:25:34 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=1675086859; cv=none; d=zohomail.com; s=zohoarc; b=Ly5XwF8z3nAcf0p+XtYiu22zhO38wO99chPqOSp6fU8LFBRR4lZjXlqJyEbzT2tBURz3yAKJ4m2TQPntm1ExF+EZy1dGHIFEbTn9Ir/0IBsbZh7IcRFxpZ+Lyk1p+iaTe4Ut8oyK/vlkm6KN0rpHiQvqxPHCy0dygdcXWieAuwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675086859; 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=Qy2eXKFcRv9oco1Ms73HcRiEgWmBpjk+PPbhm4wfo3wTwgn3qPAC1iHEnlewiZUyvb2PQH/DKMXqZOzt/1mpFNT9UTHNpizXcFLha5FgSNpTg/NV38SEpsIzfXT2s8vDFtqm54TWj+JBMg68IeX+7WChI1tUAnBXoqN1CzCuJsc= 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 167508685996349.39225898869324; Mon, 30 Jan 2023 05:54:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMUXI-0005d6-QG; Mon, 30 Jan 2023 08:49:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMUWn-0004y3-4D for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:57 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMUWk-0003wW-J1 for qemu-devel@nongnu.org; Mon, 30 Jan 2023 08:48:56 -0500 Received: by mail-pj1-x1031.google.com with SMTP id w6-20020a17090ac98600b0022c58cc7a18so6665944pjt.1 for ; Mon, 30 Jan 2023 05:48:54 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id l13-20020a170902d34d00b0018bc4493005sm7815573plk.269.2023.01.30.05.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:48: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=hJjgj3IIFVAqBly66Z6Xi8AkW/Nl2V0Vhn07Bk+a+M4=; b=iu9tOshaiLlVpnb92lRHZDKlKmOyagKE4mmyCGnKM8hVEepDZOYMoCr3wepdprb3zi ewarSxoRRA/F+JDfdUp2DjdnA9RlNebg7qw5as4M0Apr4BVtyWGouzBep3uDNhgj5jDf DwGE/4LYSYDnXgOWo2cNjfp+FABSNSLfzOdF1SBaEBm3VYpjN1iTQUNmQziLF33/wR0/ uO6XD604bGVEAwuV0/9XHKvX3K5xGN0IiIlG3+R0iFJKHE/q9DvOu5QzDx1QuSQC4pCB 48JLtjYezQRZDQ6pt7MVdMbI7qjXg8YH4uuThiZBrwU0aii687DJRJC2iZpUKerji5Az dt0w== 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=muHFLy8d3D9LWXNyBs39/sxpjUAc1kwLFOaXYH9Wk/thj/xWrB/Uuo4Yf012uIUdk8 Z3h5ttc7lPJMdWPK+2hwqMnQJo200NjFY2x0g8YOlx6YOajoTUWxxn0Gb/zgeLEdhi3d Xn+xOjfuMH5bwBIwWfJ0gjxS3TnKluJEmUuBHvm+rIf79nSR8ViYGaT++TgpXQVGPmk9 PvQUC3WP4UVMNWv8iDcwtto0kGgDaSnIkkg0r6/QH7IAxBsKOJG9scr9lHCbfk3neqW9 7bP+KEhs14rCajcGYiHJk9GtxWPjinTV6ySyPHtQRst09jhu8k1ym05DivkAh0LYvJRx ZEFg== X-Gm-Message-State: AO0yUKUGOyiHqiM+slUFGPAFKrqLuH2+1d6TS55MKuSxXJ1J33EsFhGi HfXAgXkETZVvk1qTMN7GgCgnDw== X-Google-Smtp-Source: AK7set+7wlv/2Sa6WKLyK/OyB4I/InkY3Zdj2YKJNsAYTjFZdONX08TG29gNk6+IkqM98A0jgY+kFQ== X-Received: by 2002:a05:6a20:66a7:b0:a3:7d0b:5dcb with SMTP id o39-20020a056a2066a700b000a37d0b5dcbmr7316435pzh.15.1675086533429; Mon, 30 Jan 2023 05:48: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 v4 28/28] MAINTAINERS: Add e1000e test files Date: Mon, 30 Jan 2023 22:47:15 +0900 Message-Id: <20230130134715.76604-29-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130134715.76604-1-akihiko.odaki@daynix.com> References: <20230130134715.76604-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1031; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1675086860625100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Akihiko Odaki Acked-by: Thomas Huth --- 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