From nobody Fri Apr 19 22:11:48 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=1674534749; cv=none; d=zohomail.com; s=zohoarc; b=Bo77KleEDoR22PNnseBBp+7CNqgDQfw531uK0+hZAr9eeveZN6hfH5AxJdT/QhIPs5pQ/SWj4rBnJ2s6zdAx1Jdbuhnnl83F3mIsLcQFjc01GQHJczFIGnrEShcNOMeEO8qeS7Z40IPEIMKJV5ECWBFSfq27rJzkHsgDpuPxrW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534749; 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=zDAKcWpTYbDOO3LuGJJdy8BnwvPWdlP9pR4e/xi7C2o=; b=Sz2vncwKPad9qeTxWTVygwCaxvW0Zy7vdbqzc59I9OCwz5H6rdPp24ey1ZO0kuxevqtBkgUZcHycUC2lhMssVh+nsGDtq5MAMRJwv+L+WRqiWo2e2QzLsPS6MaYrYujBLq119t1C90Q+kQibWPbXksukortSO00dhYGoyhn2iEU= 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 16745347493970.5430847457497521; Mon, 23 Jan 2023 20:32:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAyY-0002Gw-Q8; Mon, 23 Jan 2023 23:32:02 -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 1pKAyX-0002GO-51 for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:01 -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 1pKAyU-0002L2-Ck for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:00 -0500 Received: by mail-pl1-x62e.google.com with SMTP id be8so695717plb.7 for ; Mon, 23 Jan 2023 20:31:57 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:31: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=zDAKcWpTYbDOO3LuGJJdy8BnwvPWdlP9pR4e/xi7C2o=; b=J/YsZ9eyspHHU7oWcj8NUBHkHy8/SEFn9np7Kb6Os59aqhdOTfdC8vh1ptPONf3UOP JzEbTd2OvhPWDcvr0QrHo/8TCW7KozwFjN7FQaRiZJ6DobNildUG5xfEWUQsdba7iMP+ HUqx4p4jL9zTnXycB/IUpu+t49QPVRrqc73Rs+8GlBxDes6C6ot2pjC8oD9lmOgAN+AE 6qlHsb655sy8jmjWkS61bP5H77eEs2JJPdpb4n307Ru7MFZwjZbHF2z+SIl5tax01VHO LZK60y/6+GoqCQvp2zRVxO4fNIpmCtmjnZuEA3+6szGGca/LSbNEELvV7NVn5yu3PrTa T6KA== 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=zDAKcWpTYbDOO3LuGJJdy8BnwvPWdlP9pR4e/xi7C2o=; b=13Ipiy+JRn7pf7yz6JswBPjTeKcEHBU82nZ0szMq9ZTgRAOleVSxj/4BWaNT0rrwsj iJwgy/3oI0ZmbCcu3orHHry0zkToE9ApBd65Ewt2XPXqJ2MjpHnl/lNfJKhg/NBRhaLk TEAdiPjgEf6Nbeh7/wKw1jox2WIxpKkItZUjGVve9SiOb5jVITNYPLjQOq3JeEpIljKV NwwM3QymoUl4S0a847P8kohF1i1gXRmSrlY3n3/PjGxmGBPhbQZBkHvLLPO5uA62W6al e7IvU1yBlW93uwjyzn2YNsylmevc1gJbqVyFP8HDEm7yywWLkyknML78SFZFBcQYNK4t F1Dg== X-Gm-Message-State: AFqh2kpOPhvaWBUXm7vEg7R0B8uvy1R3pLuRh+mz3SlOiXohpQ86/8mL SqjKC5zpzYvN/df8cczOvAGnnQ== X-Google-Smtp-Source: AMrXdXta2uUMbJ/qP0cl99i2WgmYIgpvrrHUBZOibTfSvJ/UcC0nch4bFWRP5CNrOZm9QiFhpmfKJQ== X-Received: by 2002:a17:902:d88a:b0:194:9f55:73e2 with SMTP id b10-20020a170902d88a00b001949f5573e2mr27165891plz.23.1674534716679; Mon, 23 Jan 2023 20:31: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 , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 01/26] e1000e: Fix the code style Date: Tue, 24 Jan 2023 13:31:18 +0900 Message-Id: <20230124043143.5515-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674534751268100003 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.0 From nobody Fri Apr 19 22:11:49 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=1674534995; cv=none; d=zohomail.com; s=zohoarc; b=fQEKzdnsBqjS/9Qsl0DtmB8bPp831x+Bob7BqvN7I+I8e0abzf2d4EzvZt7Hco2Z3xq+Bjr5QU5jvMI++4tcuPE0CKQLN+80FGPS9zZWni+9Aa/kX4oeYFnWsxwV8flAh30yse/P/LptKcsB6WA/YxpP5Nhls4uOgpjH3r25rz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534995; 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=9PWo/3yuXwCzGwiugSwLMDSJ6LiuTMrmM+EjkJDwWIM=; b=jHTxucrYtMv2nW4IrtgsAQezHWJgerOScUCxe62VlH9Adej5tX5aG2WJi2wXdE/k+wQZ0i/2K4VxnffDgX82a7UnwlLEHmhePHOPliflIumbkXAl5nX//Ei3+vx/i2tn3A5gIaqkC+ijP6JyMWzy1s7aViycP362JgBDBZFgMsM= 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 1674534995932180.8425781173106; Mon, 23 Jan 2023 20:36:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAya-0002HZ-Cr; Mon, 23 Jan 2023 23:32:04 -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 1pKAyY-0002Gm-Dw for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:02 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAyW-0002LU-Ox for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:02 -0500 Received: by mail-pl1-x630.google.com with SMTP id jl3so13571354plb.8 for ; Mon, 23 Jan 2023 20:32:00 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:31: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=9PWo/3yuXwCzGwiugSwLMDSJ6LiuTMrmM+EjkJDwWIM=; b=JVAt81e9UvMSonYRkhin1kqOKWnk258zAnSkpWL4K2gH+u3IZHhfFwANRsjc5fNops xKpcG4XF+R9NuHVg2c6/J/Z+PnIsaw2xWgcQyLqmSYSNERhpHqWoSJ+/saumCSYZVW/f uy4pWjawJK6BR0XC9rVnGtv6LqwizfKLP92DosOqySAs8UWBPidTfxOc3hX6nIOEeNLT MGFxgeEpMQCsqpVSZwvcUCwqt11dKzlPk8b8GtSUVJstKGX2IVVH4NeZKLD9AaDyfN4i hUH3zYrM1C4r3rVVwVfEL4sBFZztoN5wEmYUpHFC0DlBxVOA61iyb973wQLc3nlpegFE YqFw== 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=9PWo/3yuXwCzGwiugSwLMDSJ6LiuTMrmM+EjkJDwWIM=; b=5HuGq0uPTx9EG4wYz3tXVoGBRluOpsiOB9ppDV9pVnsZxMKmEMjjGdCBc9jOnoIsy7 nM72gHWzuVS7/uCeqbhIUPVwL5XxgLRPf0J57mIkKCM/ULrdcoo5cm292YZ3AxqDGBWW YKEnxk4DJqD1F58lj/Jv6A833CZxX2JH4m7mtzWh96ksadu6yNULbBzs6dAE+KGa24Mr cJt2SRXjvxSuAWHJncdbVuzjPz50SlaKRkEmfDPTpx8udp1ktVInaSxki7G5i8/7b0Qn pnaLIJyOVHKbnIhJcYVrHx8aXPxvM3wJbEIZdRUlbRPQ6gb7LCB3u5CwFFdW6BzVsYQ2 zXnw== X-Gm-Message-State: AFqh2kpegh8x27ZpkQUmEHFrEXdu2V3bGc2fdZnoEoFEu36ORbuGBeHU MYYNjljpZnC7VtTB0amA9SpvXw== X-Google-Smtp-Source: AMrXdXtzWUtXw3kVcdekZ9K+DhNBK2PCfC16gsYa55dk0z1uGpFulc/lBZ7B2Ghcc9D0eHO2jxCVhQ== X-Received: by 2002:a17:903:32c1:b0:194:7c95:dc3c with SMTP id i1-20020a17090332c100b001947c95dc3cmr37583208plr.12.1674534719617; Mon, 23 Jan 2023 20:31: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 , Akihiko Odaki Subject: [PATCH v2 02/26] hw/net: Add more MII definitions Date: Tue, 24 Jan 2023 13:31:19 +0900 Message-Id: <20230124043143.5515-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::630; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674534997282100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674535012; cv=none; d=zohomail.com; s=zohoarc; b=Qo4ORoLlovK6MJkkWLM+fy8u4cLinlIHNUWJccTdWzzTiacbiLWbT97x0XHey5nKKmQBf5Q9SW/ZRo5mzqyK1QcQ5w1BB6sdAlZA514nAytkJLILHR4nQGpb/4viMVfuhRa4/lBrWBEFhkUNqQsajY6I6/D4juZE95vPJXnOi7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535012; 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=0i7Kw3c1DoYeaaxoqW0X3vy9giTgxDhjUmdFrIhOu+8=; b=aIeUtt4R3zgfSJdhG77AQD0RFoAiEhqtD1JRQDQ8uZkLshbkaaxeN0D1/3JjJlfrJz9zLkEwpxGyzcqTFwpCLa67xkUY5inLOUuqk7Pzbaiiic+U1KMM91Lhb7zT2LinZr20vMdcG9DDCERHBC325AXBtI3qWKzWIIjJVkXWEHo= 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 1674535012779171.39400055112208; Mon, 23 Jan 2023 20:36:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAyd-0002IR-G9; Mon, 23 Jan 2023 23:32:07 -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 1pKAyb-0002IC-N1 for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:05 -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 1pKAya-0002MI-0q for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:05 -0500 Received: by mail-pj1-x102b.google.com with SMTP id 88so2077192pjo.3 for ; Mon, 23 Jan 2023 20:32:03 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32: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=0i7Kw3c1DoYeaaxoqW0X3vy9giTgxDhjUmdFrIhOu+8=; b=mLCW2YWUB7lvAHADXGcZ2OqIF0AeebjZJvrU7sBTsSyKCSX1Hzu2LeINoTp9ymkyx/ cxEoh3l4l4vY3ftdcb1QHpJxeFzU5n4QhGA5luKwQAkU+H13oUQX4k/n5l3GqjPUstXW STRlbE12FXVl19zMkMhLYrhg9k5rcEag39+WXlEJGOfhoWKxF9DT5W5EhgddwC3/AFTm kQMd2UnIQUjoruxI4goEv8VG/CUh491EXaJVLDgLE1F2Gdh3RWhGqvuqabrWHHrXKWVp vFVbCKK6P0mnwd7mzhzknWsAVbD2LP5wPPqLMzeEUVRCIXMylzOrARNsgz87SwQRoesd VB/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0i7Kw3c1DoYeaaxoqW0X3vy9giTgxDhjUmdFrIhOu+8=; b=fQKFpTvPIwJEj4LFvqyqvnp7O8dBk5PdrLpudfiNPG7Ldk5VuRKcHyxwPq7wWLMX+l J5HOb690c9ePgnUKo65MPB/iNSCNXvUd8k2hAAZpA1/LWcTkEUqjhCdyYufaLqugwFoT 5vMNThrlxgfL7zKzuaINxCHBjujyyFw8qVhhPUPtJPmGz633qOltQfz5ICHJTyf7MzR3 XH6DYYmNUvPhQ3cGKtE/biQz+Pxp9SSBY/0m14xtUh6GQ4gPWWub1RWwqVXJKmPU8E+n hI2KYJiGkrFC81/Hoo7mimjrzAHEfFtQDxwzoKZhQlu2gKqy5eMvQinLakLUFdpmh+2f pfNg== X-Gm-Message-State: AFqh2kpuWYv7ANgvhDZKWQuzGAOZiWxMOy7IWVLOs/5kBHrQxtUK5xsE Y8Dmqi4b7tFpyx388MIoDpUmAg== X-Google-Smtp-Source: AMrXdXuTgxo/XTEDTWLFBanSN/m0GoKHvGgYPFFOGWcyJBDsNYDJDpM/U9lHy6YHAEwhNctp9jYb/Q== X-Received: by 2002:a17:902:8b81:b0:194:87e1:41a with SMTP id ay1-20020a1709028b8100b0019487e1041amr29212967plb.42.1674534722843; Mon, 23 Jan 2023 20:32:02 -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 , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 03/26] fsl_etsec: Use hw/net/mii.h Date: Tue, 24 Jan 2023 13:31:20 +0900 Message-Id: <20230124043143.5515-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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::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: 1674535013325100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674534776; cv=none; d=zohomail.com; s=zohoarc; b=ivg9R049DC6r4rs9l+/cVtYJpwxt22nmMI8+LuU7pcL2S1IwdglxnfShkwTCy1pNEpYWXPX6ClkEIS4lyk8r4fqnz7Je4t1R2C15QUiyzEEffrhKV+Gr2G8Xufr7B7i6IxmeFITDaDLAutwrHr0Xa6LaxlbjqDOs2l6t5pKBPSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534776; 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=YVRDyD64c0M4p7T5sY/nAaYTlWv5GZlluwjtdfRSPJU=; b=O8AUmC6HRqpAv9MpakSpy+aGNR/kSVyW41IDJGrheO7FetHT6QuPyvCLob4s9dHMWgOMgWS/nKpWQHcH80eBSpynkRNA13g2s5hHfdqGGfcD+t8PowebQ1qRs+zDP2DFYP3IERSehzJC92psy5HJu2t68QLiddVVeJVEPqmLitg= 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 1674534776526488.983582921716; Mon, 23 Jan 2023 20:32:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAyg-0002JQ-V6; Mon, 23 Jan 2023 23:32:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAyg-0002J4-0I for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:10 -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 1pKAyd-0002Mn-Bi for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:09 -0500 Received: by mail-pj1-x1034.google.com with SMTP id k10-20020a17090a590a00b0022ba875a1a4so10338350pji.3 for ; Mon, 23 Jan 2023 20:32:07 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:05 -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=YVRDyD64c0M4p7T5sY/nAaYTlWv5GZlluwjtdfRSPJU=; b=tPBoaoHheSPjgMxVx+LDtmRURyuxG+1X01aIIpjgoZI9Fi1fjTI5rb4hX1XMLIS9T6 jMQlBJJR0lw1vEYrlrD1/DAt44T3EqR69aC50I/dR8+q8KiBlChuQYR09F7Cjvlt1mdl VJ72AsJ6R5mC1EQitqPwHCIENaQGuc4wKGfog3GzgpYrJU1YczB/AkXAgHZHxGjT8Vq3 Kf4uMs4cOhyVNArzx0IMe0/6Tw7v3/HeCEsOZ6nn7zvOEVyoKnp9EMTGdEwJqst/IxhV x3kxXa1yZNSSfN6wbV6AmyliiGDo0jD27cFf9ao309nMPyQ4fe6gizowUM6GxMKrVbdY u+pA== 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=YVRDyD64c0M4p7T5sY/nAaYTlWv5GZlluwjtdfRSPJU=; b=U26Qeolg+TuP5PZo0KlMgnFy9ePJg9Krdg4CTZinpl213ZKlGjf7SjmibzLilBvRSA kt6zIcK/GX6sA4HYePoANxsKGPYAfxXjoTufHjy/LPlhuIibbzgat0Xe2/JzAw3iZdoV dQyXcf8hb05FA3kNk2qMiio3RaTT6BY3b1+wjqyn9CNkR2Cg0f2UWlbf9/+yQ89CRb/Q hikgdQzfDkZvQxgH4nuEfAOdSMuWl4TyA0pdhFq9M1xvW39yMdIy96BrJsADk0Clc5TU Ift9jDoDwrV5v3ZTmVeYSXSf2LihCH0qtbLEPh9WhKvJde10VBIo6731fYJjH/M3ipWH 7UHg== X-Gm-Message-State: AFqh2koPSIfmxbSxcpDjNN36fZ8K/n/k3svZir3XETpQdcjAHTYs0nj6 75bT3YIExOhMqwYcIg/hUltFRA== X-Google-Smtp-Source: AMrXdXsR2bX8A6XZ4mvfWCfEx0tuilQoMw4OadAGD2vWGfERCxK2eDBAf9HucQPyjiVc9BHEnC1TkQ== X-Received: by 2002:a17:902:ebc9:b0:194:85da:16 with SMTP id p9-20020a170902ebc900b0019485da0016mr29005486plg.13.1674534725993; Mon, 23 Jan 2023 20:32:05 -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 , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 04/26] e1000: Use hw/net/mii.h Date: Tue, 24 Jan 2023 13:31:21 +0900 Message-Id: <20230124043143.5515-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1034; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674534777948100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674534803; cv=none; d=zohomail.com; s=zohoarc; b=jSMFOJXtRitmfPzMG+0VEW+msWYCxiThNpibI/PYOenEia6fWPUfudOCsZSqbKMuEvIFT1xPazbwNjyh/IPjklIqu8oDdAMuDg6+POZAYQ496hwYC2CMCf5xz6HYvhIDT8WzLe6Mzeew6GzDsn5DJwRZsMf4mkdfBcdzbGkb8yI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534803; 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=n5oQQgVkIpxn8nbwvHbUnnlMSNPxf1WiQ2d9LLeBryk=; b=RcBl7GBuLqXsZOm0OFCpMjJMnVdxwiZOYnk3VzBRZJzaqCz0j1ABEfDohzu0yLXIrMo/BbEH+re6DyQKHQJyT+Pdm7/an2tOp4xBhIcPHoeLmz40Ioj5fxkx37aqkEE9wnLhsKvLbdEr6PNRsFKdfp9zeVRxNDfRDr9lW2urspA= 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 1674534803733102.02065222394197; Mon, 23 Jan 2023 20:33:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAyj-0002K8-Ay; Mon, 23 Jan 2023 23:32: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 1pKAyh-0002Jv-SP for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:12 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAyg-0002N8-4u for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:11 -0500 Received: by mail-pl1-x632.google.com with SMTP id v23so13609082plo.1 for ; Mon, 23 Jan 2023 20:32:09 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:08 -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=n5oQQgVkIpxn8nbwvHbUnnlMSNPxf1WiQ2d9LLeBryk=; b=ZS7EKryOx/LPDfpcGNbIokwKRm0BiGmuu6qkagd7p9Oqvw53F7a6JViPpCCbhIA8iO 0cKN+pNTWSkDHG71bepa9//LNXv7iINZmq2TjL56bo/RmdITLJ5CIU5bg0GVLsYy+KJA S7C8rVFm6NHV6DEHIGeJ+5QpQYHUEcIio9aDmbhgC+uZsdfMlJHIiCX4jymb6zWiulrP sABiiEwovBKKZpqrCeA/tua0oZFYv01gIXEJ/dG0W7R3VjKoOfGzb/6Bx+OXOebifLs2 OoDwQ5EnH2wFgb/3x89HOHZqDyO+ipGFuW2rDD+DiD9CUziOa8wqjBkwzMnAdd34W05x udJg== 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=n5oQQgVkIpxn8nbwvHbUnnlMSNPxf1WiQ2d9LLeBryk=; b=nl7q0iTOF4ANaQP0OGTPnWpkL/QA5tWRP+/vPTdK3W5M8JoqyTybPkg5sP9az9ljX/ eAOlqND6cQsOS4zWkTUwbqt3xbs7ioPh1Nrt7ANdE34ZVzKcuLlTScuw5PGHO46htU1l DLCoh514bAlHm5OiKHos6bJQaHsWorf4xuhZHNIHNa0zhTzw591/z0rX6ce7fD1vqRO9 OV27yOpy+YytLmRj88g1ReH5i8YIG5rQ2TkjKA0n+H4idvqXWX0EgknGtUQGdZPNgSOq qIfXC0G7By1zztVtXFdtMgpUySAcJrDfdYQmxV3arHtsJ/vfEeyIV5BFfnyKsB7sP7+x oMrw== X-Gm-Message-State: AFqh2kolJS8DlEBlhOjxRnqUZ+oGjhPfCMycZRJsjqJGbkUQLSLN3Xgt S0GdhzhR7IPm2ftnwb4qiBRIzw== X-Google-Smtp-Source: AMrXdXszJkFXH7fSx33ipEiARfh2vqUVnLsa5ziiy/9BasNmpaJgjpJTLbRjqO7zdOc0PGEOl7PYcQ== X-Received: by 2002:a17:902:aa05:b0:194:52ed:7a2b with SMTP id be5-20020a170902aa0500b0019452ed7a2bmr27773289plb.39.1674534728896; Mon, 23 Jan 2023 20:32:08 -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 , Akihiko Odaki Subject: [PATCH v2 05/26] e1000: Mask registers when writing Date: Tue, 24 Jan 2023 13:31:22 +0900 Message-Id: <20230124043143.5515-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::632; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x632.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674534804010100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674534810; cv=none; d=zohomail.com; s=zohoarc; b=Q1Z9jfhko8CHrBusYL/XNrI4xXba6vVj7g6WJXcwMR2h2J163Vp4M13p6vuZOmpCL5xnn7bLCkfyL5CRBacAeqjezuM7DQbU+KQkBNDAScSLnd0zTuYQCJfSme5w0etIGhDc6ySY6MO+73zPyWSNskeE1OlGM7ijDqnD5JUnTfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534810; 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=qQAThEFT+OOf4M3xlMKLI4kuAC9hcUfjxpclwetq4QM=; b=l0Ho/uv/fu6G4/pYtzlfikbF9Sa8o9upwkYMnauFtTjXinc7N2hmNmA7zqEgt0s/XZuwq3CkDhLjIdbOSlCdJA9KFCxERGCs9ZwWNo180L/IY2AAP1y4mdICAA0B808x9iQlZmOPZjZwVS4vMK0GWJSh4m+qJG0qM3JzSISsFco= 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 1674534810759256.74237366664636; Mon, 23 Jan 2023 20:33:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAym-0002Lm-PR; Mon, 23 Jan 2023 23:32:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAyk-0002Kj-TG for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:14 -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 1pKAyj-0002Nm-0t for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:14 -0500 Received: by mail-pj1-x102e.google.com with SMTP id b10so13684254pjo.1 for ; Mon, 23 Jan 2023 20:32:12 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:11 -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=qQAThEFT+OOf4M3xlMKLI4kuAC9hcUfjxpclwetq4QM=; b=kdf6DqrXKLpL+m2jc0q27dYR6HUwNa/bXeKlKLDO3kN4NubhOAQl4uetM+taoA471+ CZBS2vChthOW+KdS0H1ON8zBsnqv21NGsKnLiOBAtJfuaHKEMF/APH0tCE07P0/JEVAP YiUTNcUyFoyWJSobgtMhO3xhZu90CEeP5tGGRyLy8yzUsxuySUAOxSWr0zdqyP1/bKG2 xsFx7miH+vPwP9mb/hYHp1mY1cI+0bpw4H7cyBYIOIhdSHGJp2ZnmfoXBtnnH5hWm+Zu N8JWudTuTNCgTYqeUZQ69RobOtUkSG10weq9ykdbIejsg+NB/yhW0MfiA9pzlynCYFZK B/hg== 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=qQAThEFT+OOf4M3xlMKLI4kuAC9hcUfjxpclwetq4QM=; b=7BxMsYkuGl5qrhyK2reyULKyWNWTyhoVrIHeG7/Spnd2c5hUcY2FeuOw8Tby/3e8NF 8b4/7Z4gnB0bk9KecIWYWuntDenbx1/rHU5h27gXoUOa+c9RRdrocEbAkfLFaI4Cokil myzM/FyYNPQYD465XDuKqft1viubeJL7Ofhwl+SRqRomhOH+S1oChaaGirO6yJv8pYdR IucbbgryO/siJJmzStvBSV365D9OkbDLINsLYd1YoGabrZccX93avUHP9AbisSocOm5s QFAvDDTGA2ti/xEZVkh/XK5Mbga+Qvsesh0oWkPKD0ZXvBeiJpLqsvETQfr1FXyiJLEk 9Q4Q== X-Gm-Message-State: AFqh2koEYBQGm+DtIcWMj29x/dMHrzh6+x8b0ucEAUBlOks8hctuCApl UkJjNCSrDuBVtWwIyxSI0bW//qoCWZxDqN1l X-Google-Smtp-Source: AMrXdXvRPIKeUPPZeU0nELbBL7PUff17Dqq6c+1i8Gklq9JQu/duEktVvWXyBZLKf1Xb+p/rVE27gw== X-Received: by 2002:a17:902:e54b:b0:194:7efa:702f with SMTP id n11-20020a170902e54b00b001947efa702fmr35711244plf.53.1674534731852; Mon, 23 Jan 2023 20:32:11 -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 , Akihiko Odaki Subject: [PATCH v2 06/26] e1000e: Mask registers when writing Date: Tue, 24 Jan 2023 13:31:23 +0900 Message-Id: <20230124043143.5515-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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: 1674534811960100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674534995; cv=none; d=zohomail.com; s=zohoarc; b=MWOmWQZKGE+fj1J9N9riILYb4jMtnHZFacf+43BF+qnXMcXk8uNlv1QK8rhmxhSmTCvncVrbmOAUPdiOoJr6s0/VyMNkihXxx9m54QAEejPjam43MtLD1uOmJYT/Egxf/Az8uLyNczZc6NebYx+Jamv2hpxAJMbe167o6SCSeCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534995; 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=DeSwxIIF4Jth3AqEMShTMZwzFnXESjinfyzNZ4cR+Go=; b=CBL9U1gUaC0pCBzqNOeOiEdSWTbnPEqRSoUHu/7FjbeofIhJauo63j+z6CSSlG1alUDMCwVab0jRmnGL4G5xgC0uQBobzvJ/MbFX4xLEFDHwveHyLNUT1zrmY4+WQ0poSQiepKvTcJNCAwNfbqttIFBojAhOqv3bDi+ZBcThNL8= 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 1674534995558446.0872010717254; Mon, 23 Jan 2023 20:36:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAyp-0002O9-Ge; Mon, 23 Jan 2023 23:32:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAyo-0002MI-8M for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:18 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAym-0002OT-1f for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:17 -0500 Received: by mail-pj1-x102e.google.com with SMTP id y3-20020a17090a390300b00229add7bb36so12910819pjb.4 for ; Mon, 23 Jan 2023 20:32:15 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:14 -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=DeSwxIIF4Jth3AqEMShTMZwzFnXESjinfyzNZ4cR+Go=; b=DOOKrCoRRQnmJoFgGFUTYzoHd5riCN0UwVBzmVDCkQiBcNqoANGkR/S8VUEq2pnSQI 6P1824ElPZcd8YdIKUPw3633oMyF7tfAqudUsT1uDjvfWolC0dn+ruQXuNyL+Cq5g9vn vP+xdBM2W3AzBna/Mxu8TdR3APV++yR/b8RST/9oB2SBDdZamq6/8Q6K/OsWKCG6x3xC J+VFbixnOrHYyNCaSU9e27+kZ+p+83VlWTH+ecQkmQXldQVN6FSnu9Xtwh8NKeFRDWwj QlwKH1cEfHE4nQBuKGxF0BIxgG0I+gxpvBCGKOMWT3qdu7wpT8sqsfsEda5gC6+ryGUH brow== 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=DeSwxIIF4Jth3AqEMShTMZwzFnXESjinfyzNZ4cR+Go=; b=hCHdcSHK8VVdL2/QOLSC2u6p7HrxyF+0m4VzVrxfNuzoOvdShL9YK0Gi4p90dEaO18 49JY9TxRO4a7vI4QbgXN30Wk/n+1ujeUv8lft/38hSNIvQJNnCir2IPijwOrizdbhnZ7 vhFI9WxXLcA1SyZsQYxnM/6NOFkmoTvxJxdpMPk7nOyIpzEya4AhknYmFYFgz2RR0QJT r2Mjn9imsGjGSw3AcVmiqkIJsR35DYW8LmNaY3e+H0C5goX0qoExxlmuvSJW1Q2eDoK6 6DcMQ/0Pz32pELS2f2Lo47J/2UaGFBFX58cbEfHVfaC+k11mAvcbnyrBnxLNkzK9zwrm xKSg== X-Gm-Message-State: AFqh2kqh8x0828P3aDFOTzwwkJQHfHW17GqSieYQTxQyndqVa/0YDoi6 tn7NU15/wiAOajsN81mPgjOs7Q== X-Google-Smtp-Source: AMrXdXtC3arMbIpxUam9mDWPBiqbeCFdw2solNsmVoUiePLDYAvKRT08pyOCLp5VxxKFjHTw0qe8eQ== X-Received: by 2002:a17:902:b18f:b0:193:234:443a with SMTP id s15-20020a170902b18f00b001930234443amr24719857plr.45.1674534734954; Mon, 23 Jan 2023 20:32:14 -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 , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 07/26] e1000: Use more constant definitions Date: Tue, 24 Jan 2023 13:31:24 +0900 Message-Id: <20230124043143.5515-8-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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: 1674534997299100002 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.0 From nobody Fri Apr 19 22:11:49 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=1674535092; cv=none; d=zohomail.com; s=zohoarc; b=kbOJlyv3Okq53wlTrNWUD5hv+TDxNk2VFEtv17m3cHhvU/XJ8NNnVQaK/DvYxA7zzoMGc35ul9h9G51nVgtE+xgp4m41dCXy4iMx/ypomdMdgHBXXyl7DQHe60KgDdLtqMqEYorKmHDb0xp+WuJzufcPN87vXfrBl7D25ZfRhHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535092; 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=i/s1msb7FYntIfC/zCNxdz9yjGGhjcUimenvxfoR2xo=; b=evVkczxeCgIgkyDNtZkGYF+I5l6P9jsSpclUvIOAhpyM4rBUAgeqAeu66scPt8FYA/rTtQlvrq+mbl4p8xLA80ihmhZHrnwng3pFVbss2rOfucuS2XPoQrGauJPSHdvkewdlTnTAFo9o1RJgPzDednyL9meNY9N3M9p5T35bFSU= 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 1674535092316113.51473325586392; Mon, 23 Jan 2023 20:38:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAys-0002QG-3o; Mon, 23 Jan 2023 23:32:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAyq-0002Pe-Ms for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:20 -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 1pKAyo-0002MI-Mw for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:20 -0500 Received: by mail-pj1-x102b.google.com with SMTP id 88so2077637pjo.3 for ; Mon, 23 Jan 2023 20:32:18 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:17 -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=i/s1msb7FYntIfC/zCNxdz9yjGGhjcUimenvxfoR2xo=; b=BPAKXrOHIeUEa/CqpmwILDgcUfXESKUdR85ydZDcAqVH+veHqCh/XdxTPVdPge5wym WspX6rTq/0z7Y/PcVO6PulhefBUPdkkwGlxqDUurXNYuAvCHRlRCv9m5TPi8CyfWb0zd yGqQtbFvySmtQMLk+M/CgsuOJ8B4nFHvEfFH+1N3ePhdnPzjIm5ShHZQlPj116G95fZo Vw9hUokU/iTax6PV0J0ETMfjuQLqCiYJVEUzkfj8gTwv7FgOQH0eTb55jIl4jYa0+86u 4MG9ddqIAIWfunvT+dIuishD2OqFpbWeDBpXMFV87r2xGcn48cj2HcaU/LtFbpLWmAd1 QGog== 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=i/s1msb7FYntIfC/zCNxdz9yjGGhjcUimenvxfoR2xo=; b=EBhfi7NIrRF/QLTlRcvCcKoCbnmlAg2hPnstbs3L0omLBDiPP6x8Idin9OMl6pzcP3 N8HN7JGwjz1m6adcwxY2l0fo1HDRpd2xWYBXj7Gks2vDdzZsYgTB8pw2n2fryigvOXge d92FNWD3nK3y+1hmbYI1BVHekKzs2O5R5Gcki/ev4XrrKD5ZiRC0LvZmyy4Sz6oBp3qk EVj4TLVtrCLRfWCZ+6t+Ml0eieb9fXgKPk+3JKsD24jStzA7FX96Mzbhh4w7urPYnr+R pvfbvETpyZpeY5pWe73wESErrneNt/7S12oAq3OBxNb9iCPE8l6K3QADKB4gZLfh2LDo SHjQ== X-Gm-Message-State: AFqh2krtDofwWo7sgH4OiJ8BvkCqg3xZmkgNmJOBNsnSqx2VXX456f5A zMYSbHCCxj0ofXmlTRCMpWeZLA== X-Google-Smtp-Source: AMrXdXscF1++i5g5/C0wvNoGvGe0/cJ7F7tbrWEFvw+se995vR0+ZcNCsdroTjuhRO/+ypsXd8Cd8A== X-Received: by 2002:a17:902:cec3:b0:194:d9b5:3bf0 with SMTP id d3-20020a170902cec300b00194d9b53bf0mr21892848plg.18.1674534737961; Mon, 23 Jan 2023 20:32:17 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH v2 08/26] e1000e: Use more constant definitions Date: Tue, 24 Jan 2023 13:31:25 +0900 Message-Id: <20230124043143.5515-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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: 1674535093650100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674535053; cv=none; d=zohomail.com; s=zohoarc; b=RF0K9gini8/pgu4NX+MwvYtYa8G+kSpGA2sG0YlUk0wpxqb0sjGRNOIjWoUmPowTanKpKbit8jX6OsliGqrgxTLAjWiVcZ4mCWB6uyP9GW9Sl4ADa4jSOLH9NhqVLqjxLubOYfKXDZE606xA36dpNkb8I0NVsFocYjm1Hz3BfRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535053; 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=ATFnSDPaq/tF+IEyDiXxbVKp09i00iyKysrIH40kCSg=; b=iH4uvbGiBA349n/iS9eH/k55zGHa6F/2IJIna+sJGVd3H1h+YJQRp6HwxTCjGZ6qb2fH0wVDEyi5d88Ucp74W2rdT2A13/szFukDfPcXMC5bRkRi1vxDnQvJpbRztD9/F6PJA6G+riRlKurFfZDeFoszztY4Vm7pu6deXa7tufU= 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 1674535053692126.63367105506973; Mon, 23 Jan 2023 20:37:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAyv-0002Vt-0b; Mon, 23 Jan 2023 23:32: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 1pKAyt-0002Sy-0G for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:23 -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 1pKAyr-0002MI-Gd for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:22 -0500 Received: by mail-pj1-x102b.google.com with SMTP id 88so2077717pjo.3 for ; Mon, 23 Jan 2023 20:32:21 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ATFnSDPaq/tF+IEyDiXxbVKp09i00iyKysrIH40kCSg=; b=GzULZ14UUCNT6JWC5sZDKfbTqFj4BE9RNdfvcD8m6wzl0pyBaBYh0rzJmVLBwrTBRX qcQOiVwXDhL2vSUmaRLTmUPF3ENRJ2Nj/bDBxY9YWeujkvyZLJGSy7jBxaJxljO6Peoc AaCGUj0Irb4nBuaFtGGWOGaSAbIF/X3/0sCe78T0JGqDccc08QDIzIG2H7rugeDZ4Dx4 TXkqsArqoP3/vV/JZeovv4B0k2xRDP0k0jXC9FJCvlsy+wf3rVJ01+0cIkxyLwvMhpuH 3UCMILZf6C9gQf2O2bK3bVIglfgUJCQ6Hbg1DHivHRqplfTR/eiWrukc8gS7RlXfYl8o IGKw== 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=ATFnSDPaq/tF+IEyDiXxbVKp09i00iyKysrIH40kCSg=; b=4DmXWeRrCDsH3Mbt1JJ7osk9M7G7Q5SCPPGdCGw6aQ8PtH22kvz15ubnpVSqAnRrw5 cMkenoDIf8W0RZDYI09Fi9AG7VhnKqtoIUEMSFzQN5tqx4snTYrzp2453JK3Rc1pLnap 29QnTdNpYJA1vP/VHrGAcb/rjCbAlS4V2qCrIaXyUxzLMrz7QfXtBHGA3aZI/OySSfDf 0hNwZYiJm8D/EgH6VIBjNPo1NwTl+RQsQnxnDnVqyL/byBzjG1W3mME/EBObObzzr0FF I9jKf5HZlFAydVHPSMF1ZznlDkcJRE0/BWzebczMbPqKKtZKanOahllh8hLGbC1jEPex LbjQ== X-Gm-Message-State: AFqh2kqkYtAWhJAW3ObheUW7Pt8nWab76Tkrxngc++v2OC8ZOOvkcka9 6KAuhHm9bpL9Dj5q9E7/WPL3UQ== X-Google-Smtp-Source: AMrXdXsE9D9ySTK+/xu2AT5PDdcaY9YisH5nNGafF5EaG9hdKJq1++fqx0zzz7rM9Ftu3NQLFVEOqw== X-Received: by 2002:a17:902:d888:b0:192:991f:d8e8 with SMTP id b8-20020a170902d88800b00192991fd8e8mr28762964plz.53.1674534740891; Mon, 23 Jan 2023 20:32:20 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH v2 09/26] e1000: Use memcpy to intialize registers Date: Tue, 24 Jan 2023 13:31:26 +0900 Message-Id: <20230124043143.5515-10-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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: 1674535055644100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674535062; cv=none; d=zohomail.com; s=zohoarc; b=dlOFp0/+U/RrFcpcuANv9APXRqRXB1REk1H6+dtXl4fiILL1cACGMe3s9EOQ0KyLNskEr5aaMx+AjvV3bWRXYsrLf+rGkbs4k5Dz7ZWxO4JRSpD5mpbJGNFjTfFPlbiO0Pune2csfKkM+jECsR648xeTUS8KxC2SZ4bLI3ABS2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535062; 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=DfHbFzEFpZAIU4LZ6NgwvgYjQ8+Nr9IG/Jg0A+8VsYk=; b=I3C2Iu8qDSMXZKo9J6ikS/sgH+uLT38g/SdOyPbg/L7TMFTMI7fVI4aKenOoQ02+PakNmrybBkOdPxbUZRkFXSxF05UUd0x0vcUuus2vVUw7U+fgkk92E46U+lErLGV7RL1/5ZYLDfHhE8MiRbKpmyvIuaz3xMs7pACkpVP0IDo= 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 1674535062577332.08329974291075; Mon, 23 Jan 2023 20:37:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAyx-0002ZM-Q0; Mon, 23 Jan 2023 23:32:27 -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 1pKAyw-0002YQ-6T for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:26 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAyu-0002Nm-J4 for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:25 -0500 Received: by mail-pj1-x102e.google.com with SMTP id b10so13684605pjo.1 for ; Mon, 23 Jan 2023 20:32:24 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DfHbFzEFpZAIU4LZ6NgwvgYjQ8+Nr9IG/Jg0A+8VsYk=; b=Fhmnr2EHsR39b4q+VOdsBEWJyMvD1DSLY+X4jghngFhEb1O4Pc7XoMLLwrkdZ67mwI IzIXk9G3OblZS/H0jyObhJYSPk70oqY/PtvY+cwcV69cstI9gOMDwKyIPxIrzXpdJp+u 63v2ph+5u5+cjvFlp01m8LfMHZfnPqKJUNKn5VQbRm4TUC7zK16iRku10X9HavWzLUxL AwlJPVRswOUhYdNpw5ZxalR/wvoPhN3zfQrGDYgKq5wpefGZWbU82xP+AipRHplh1mtT rFQKEuz0k19Ay1qc62NnLmalRp8IRrW4YJMMLdB5ulzzogUznIy9iaV6dMcBs2W2RrEO 1xNg== 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=DfHbFzEFpZAIU4LZ6NgwvgYjQ8+Nr9IG/Jg0A+8VsYk=; b=Iwz+NBSg8CfMlLIx8q4wEkMSqfjXKWaQKUJJGjTMyo96YUWAovqRvTJMjQeg156T24 A/PE0gzrzNxzmoNu6kNQwoVxSD3A9h+0FRaOvhRV4FtO1WZ4Aovk3XxoUGfPjt6noH62 FgxbclXjL/zNVIFx0VZeLkbwZ5mC9vMdPTqW90sSlHKQGFvY4jbMS0NM9/lG6FS5Mpp0 cBE6lSvMNIUxBhiUyU6iowRaMtfDDe/rcOV+DOpwB1typfm2uewgrFHwzBcWvoG6WprP F9H2956n8Sb0UWvJ7HGAecob9FBDkMTJWNkHWMELpQV2rUno0uK5lLaaPXF/VBGLEg3V cQwA== X-Gm-Message-State: AFqh2kqWXEEn26M8GeNJvfNJPVW/1ha0EdXiXNRS2JCFgECe1VvBZZCM z7r3gw2gXyUH7Gl2P+gj34LRfQ== X-Google-Smtp-Source: AMrXdXsrFZuvGcpy50qDMGWicVK2NpwWwFA9K9jkl/94AfkeLBfRo1ZlYUetrRFroBQ94hbD4ssLcA== X-Received: by 2002:a17:902:9b97:b0:194:a1f6:65ae with SMTP id y23-20020a1709029b9700b00194a1f665aemr25530601plp.12.1674534743954; Mon, 23 Jan 2023 20:32:23 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH v2 10/26] e1000e: Use memcpy to intialize registers Date: Tue, 24 Jan 2023 13:31:27 +0900 Message-Id: <20230124043143.5515-11-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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: 1674535063528100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674535093; cv=none; d=zohomail.com; s=zohoarc; b=ljVstFO+C1o/VvMAJH7W+Mc3cyzkcbhsKUKz9MdymEWNksqjQBLYGrzhSXSvZ79fBhq3AVJqC9pSLsbqQl6si15ZBTRIe0stH8oDvZoKSL+Keyth3Z5JtyZZsWn52VK33Kn5VsgVzGl94aXnVNn3Wm4IdnZctylW3e1jyIdd/r0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535093; 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=T4yso4SBta5kLCJWlhtBgfBYFQ1YfwCjClaXWJVZl6s=; b=gfkc4WzDNfCKl0lpqWuqqLYoqDYgNuR40H/hWXwRu6coaqRT5tNeyhEt5H9DnMe2kKsXX0p4nqdU9uUUYgxSb9jghRMhp4Z7agTCl92BoBn9ghlRlCRo+WmcPhPUqvXRDNMRcrukTANHQbVFUjQ90eBE4I7dPV7GUEcofq/57bo= 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 1674535093924742.0560239622758; Mon, 23 Jan 2023 20:38:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAz2-0002hH-4z; Mon, 23 Jan 2023 23:32: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 1pKAyz-0002fH-NY for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:29 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAyy-0002Rb-3s for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:29 -0500 Received: by mail-pj1-x1030.google.com with SMTP id v6-20020a17090ad58600b00229eec90a7fso805558pju.0 for ; Mon, 23 Jan 2023 20:32:27 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T4yso4SBta5kLCJWlhtBgfBYFQ1YfwCjClaXWJVZl6s=; b=IgtxGqyT5Q4s6BdrECETO9HT2uFk+CqlJiQJ6N5t3zz5CeDu8KLN4NNIlti1u17/H7 6IaH1g/RkZ1q7we8H0GgYIMwvqMJ+qCRhY13IP6wYiKezW3z0yX57hqkILXUcwNvcfQH o/sry1Za2jruNnK8r3pQxLXCA4deZYBk+uR7cQtD+yMqWV2MFbh9n7csEF1a4fyljM4T Qqy8qZuejwiDoRrpEVcdD7hRPv6YBvJwDWKF48XXzsvFJ3sn8Fm2q1rUYXS6o3Iyf6/z gEy8IPgh3iLjT1LupF4KTdRKD/syLmXJsw1FNQUTKEiXvaH9j92HSE0UoPrPVz78fKkX 0gvg== 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=T4yso4SBta5kLCJWlhtBgfBYFQ1YfwCjClaXWJVZl6s=; b=7Xso7ouDna6xha32is4M8t8Ef7Qn37DNOczvP7eUh63FUEe6ShCbVPEvitorLoI5XY FzG2slCdDSgnmevMGkMHokMnXEXZijXL2HfFtnvgzhLTKL7pOpHba5USJiHBUG34MREW bGG7kuOsg+xmCSrR6t0vCLArFzofvO39JKqPHY+/mP07mJJmG7Un6OHyLcffAOvcxNUk 27TtpnEnY5x8l9g+71cGvoNZXrH9xubF7mhA0KE2MBOIJiiTnZQ4dTCAscl1BVTxm7cF uG9eDwt7MTP4Ajz/KTTra6LUJRZ/1bQQXPc/jEnB2PQbhlxFjwsFTaM5ty57Adx0PsSu MzJw== X-Gm-Message-State: AFqh2koiHVKg6ZXuC9bKNB2KFWVFYcLfSceIzTeVUMEaEeshugZt3e9k UV30FsgVxlsbmmvK1uWdqwmV4A== X-Google-Smtp-Source: AMrXdXuq/aDVT2k95mGljW5iBLAELw2KZ3+TqAD/tbIBst1DifB0V4N/EkbQ/beztS9cUTd8lyw9oA== X-Received: by 2002:a17:902:da90:b0:189:469c:dc0 with SMTP id j16-20020a170902da9000b00189469c0dc0mr39108590plx.7.1674534746857; Mon, 23 Jan 2023 20:32:26 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH v2 11/26] e1000e: Remove pending interrupt flags Date: Tue, 24 Jan 2023 13:31:28 +0900 Message-Id: <20230124043143.5515-12-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1030; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674535095650100003 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.0 From nobody Fri Apr 19 22:11:49 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=1674535029; cv=none; d=zohomail.com; s=zohoarc; b=FcmIqIMx3IRkARG9KdYQC7xh1S/ntu1FfDuBOQz5pKOW2aEye8WLMDGm3824cmgINZW61idngWKTd04mSKGxVtgkrqG8kBHv+8JQBe47Sl/gImqWfrKM74nHvRCT6BOOsGMzLIF/MnkutP2BcWCJl6uUBGMpD5Plc0A3i1W7Ylg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535029; 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=VWqHO+rRahXUGWAQnJsH+iI5jUXWsg5ZhWUH3RvHdms=; b=N9WPebn9RC8RqzSlHkxnK7snN5s7jhYTY6c4yXI1Df22Wb4P5po/lxnceIh2hYfyk87nOZKNwbWD5n++4hV4MD5C8hDG7w5IJCHNAHLtOyy1YOt1Ni3tJsTgyHPOt45eZKXHU4Rc4bL8OiElCm29wKw1QviG3YHyyByaejrghGE= 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 1674535029206120.18370155830428; Mon, 23 Jan 2023 20:37:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAz4-0002ib-IP; Mon, 23 Jan 2023 23:32:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAz2-0002hw-Sw for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:32 -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 1pKAz1-0002SO-0q for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:32 -0500 Received: by mail-pj1-x1035.google.com with SMTP id e10-20020a17090a630a00b0022bedd66e6dso771794pjj.1 for ; Mon, 23 Jan 2023 20:32:30 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:29 -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=VWqHO+rRahXUGWAQnJsH+iI5jUXWsg5ZhWUH3RvHdms=; b=h8kSWldfVHoXsQ6M1ocNcxOmA8FsbictoWOKpmrQrafi1M2Lvk6JUFLzQu7wnlgrFn ScNiAB1/fHNncIl1jExVijOBWiY+O5vEaGHUueyMjchVpVEdijhXBInig5Jq3HEjoYgi PGZ+bo4o/1ARSvF0xQaIiwM2WJ/nrXFy/PMEqITwqWUYbN7FDpho2L7Um2nFRcgHxW7s t5F1HlmWzZh3yJsIcW1MAplCEmhbQAQP4AjfnEJMg9MeDLDbNjfO1r1a90HPj7WBy4NM w0TlC+aJLqEG9SH3F1TnfaKAlJ+SXScQubiKsMDysIG4CcuFNbQ1gNsfzgtmBtxaj5ha OAAQ== 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=VWqHO+rRahXUGWAQnJsH+iI5jUXWsg5ZhWUH3RvHdms=; b=oo3pZmkzie3PapzCZyWKr0eRvVq3PSWMFes4OB/Ra/lOZcQytdCKLXGxvR+690WiNI m8hHve2+QR3vyNdzkwc+O1+BRbzB1Gq2hoVrSpLp3oYr2WsR3VhN01XZiz8M4tfMg4Lk PvbjP2C9WHVCEVx7KVacbXj/Rt7oUYggqETdHv9J4tHhor/ForW4Tr/JQjBXv7Bekpew e0et3yd6oD4FFC2woDPTMtcsPP5/01sPoG+diZg7woL/PsIvVvq4+Oc9Qmb9+KR4VcPi pWr6mSE/JWletCwrL0ZXIDHv2XtrmpHNmFsyR5BKHa1CfqHcjt2SGbDudWoOABkjMnm9 8/2A== X-Gm-Message-State: AFqh2kp8Sn1ya5CDd/9G4u1A7Etfg/t4QRGlRq04Nz2rGkj1NVHtLGlF gdLoJgtnOUmjRItJOQoB1sHLWQ== X-Google-Smtp-Source: AMrXdXvYIGNaYlWJlE7kqFiC17dYU6Xmu52lb6FGDb/OWfqPgoSR9Noc1Bzk+B6dtMG8Qmc4g32LGA== X-Received: by 2002:a17:902:d2cd:b0:195:e457:341a with SMTP id n13-20020a170902d2cd00b00195e457341amr20018654plc.4.1674534749765; Mon, 23 Jan 2023 20:32:29 -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 , Akihiko Odaki Subject: [PATCH v2 12/26] e1000e: Improve software reset Date: Tue, 24 Jan 2023 13:31:29 +0900 Message-Id: <20230124043143.5515-13-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1035; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674535029404100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674535108; cv=none; d=zohomail.com; s=zohoarc; b=gMuYlUS7SrLwR2YWxxQZPKaFM6LPw6LcUhloouffGAjV808b3adUxTvoF/gJHb54UCIrP1QK1puM/HTVHuB6vx92VQUvrYHDTjgbYjc568GMxdAuaYqrOEm/yODa0LBlN/jpNIoDN5XL+LQ4pHpRcqj22iOqXVFMLcWnTEr9+kA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535108; 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=o59WGdHhwe8iSCsWwjunxDpf/pqoUB2o+GMOEcSVcy8=; b=nZnZA21gacbjca/RvhNVveRKZ1eke2tjxOB042CqND98+RF9d+Q3JXeu5m4EnpYsc3YDgMycSx7y3yePpgLHajXJL74ATHlvESujW+IvWb/Jyw8Sx2FdqwSQZHCYmE7AEhFhVqP3dA+dQkNcl8k3XAr84PKaA6SJceFumYiYMDk= 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 1674535108952184.85218902215775; Mon, 23 Jan 2023 20:38:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAz6-0002jg-6V; Mon, 23 Jan 2023 23:32: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 1pKAz5-0002jF-5S for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:35 -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 1pKAz3-0002OT-Ki for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:34 -0500 Received: by mail-pj1-x102e.google.com with SMTP id y3-20020a17090a390300b00229add7bb36so12911325pjb.4 for ; Mon, 23 Jan 2023 20:32:33 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:32 -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=o59WGdHhwe8iSCsWwjunxDpf/pqoUB2o+GMOEcSVcy8=; b=kOlUYtVf4vSztB0C74exGPeN0nt12owkrmZvnYngfYdWJ7K8kxvfn3ivHJWT3BjX/r +j4ntHgQE8JCbZW4cndkCTAY48znNqM9z7cw1kVtrKwU71OFPGPEu0UoCw4Oev+KW4UJ Xqhv7WSanUZ27W+stfdZAeDEhn9mlV27N7YxEUrODITUtrGmI5qeam03fNO7Rm63y2Ee O2avdawf9ID79Y/Jp/ikuUBM5qU1yCjJYJQEV23wqe1afufmk9ybgPJ9JdJLLLglmNDN KZGlKr04q/H5nICKYOBLsh1qAmmROBrdGy4H9m5R/cdm2p4WXaAowauS90ROlRgVMw5Y 4fiw== 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=o59WGdHhwe8iSCsWwjunxDpf/pqoUB2o+GMOEcSVcy8=; b=S+LVwQ64pz5WQAsHtUUjpWSn6m1afDDm4At5z21O4r8AgOvCbzkAsk1gEuN9ZMgBFm SHj9p12Pj7e6pJNOUXoo6CN/R3DG7Ejl6CduwNrQPFfDflr+7szC/rFhzpZS3d3h/mVh 50q0oa2xnxrWl7iorkqMnuW3+rBGQAP6onM1tsuF/pNStTY4wqwzaukpy7uLCPaq3UCG TCoTjI+78/sjfsiV3z3fVK7ewcm2lfyZvKrdM1fnntsFgCSa6k4T0562lViq+HaTv8cs Q7zDbTIVe5N4hD6Ng2MqINX93Zd1hwcfbyC5aKacbNM94V8gQvtMtM/0l+9GTHrnrA7S Korw== X-Gm-Message-State: AFqh2krZJ960T1TFWUWkyxUr8A6SA42GAwtOhI9GqBIVMmu+gf7dV7ed o+I/A7GYCGE28melQqKiUKMgtw== X-Google-Smtp-Source: AMrXdXtgp1025rBEBQW/DQZx3AwPHNCih7IyDWQI67ayYTc59kJ0azUNyYZXsGlZNsHkkBnQouz5Dg== X-Received: by 2002:a17:902:8492:b0:18f:438a:cfe1 with SMTP id c18-20020a170902849200b0018f438acfe1mr25390093plo.59.1674534753014; Mon, 23 Jan 2023 20:32:33 -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 , Akihiko Odaki , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 13/26] e1000: Configure ResettableClass Date: Tue, 24 Jan 2023 13:31:30 +0900 Message-Id: <20230124043143.5515-14-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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: 1674535109822100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674534942; cv=none; d=zohomail.com; s=zohoarc; b=TUGnXZ6SZArFMx8VC4yYoj1eksgX2OPcE3SontP/tYsWa0iUQx8gzGiWmSFvBan7PvQ5GCzuZRI4VsTvE5oo9m4jNHrhiDuDeuRvj0owaMnF2FKihUHuRxDPJVsNfYXAb99V/szyTaEZR88P+NgWwvEYr8BE1x/M8jcg+qJQF8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534942; 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=2TXcfvyQzXAA7MGVWAEaiJaTJw6CggHuTf+FoxIGKhw=; b=PBEgMfp6qjb5EGI30w4DDZproKVXSx0V84IHJXsRcZKXxByOpMW0WGZhzhTiC7vCZl41l34V7RpteQTma5vaeMTNhJctBJ/G7SasE2uzasljuf8+6oIfjRI6uhRm+hY+6BODeUpnb8C/2Olwtc7avL5eNDAgnfUAGvMnf+YaboA= 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 167453494259297.57210801446183; Mon, 23 Jan 2023 20:35:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzA-0002ni-Sm; Mon, 23 Jan 2023 23:32:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAz8-0002mc-ON for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:38 -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 1pKAz7-0002TI-B8 for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:38 -0500 Received: by mail-pl1-x62e.google.com with SMTP id k18so13583667pll.5 for ; Mon, 23 Jan 2023 20:32:37 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:36 -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=2TXcfvyQzXAA7MGVWAEaiJaTJw6CggHuTf+FoxIGKhw=; b=KuYPbSuum7ymvRNr/P0ZH1Q1/zLHwvtT+fYJWwhajtbOTIDRA6YF0tHzBHYULaO/nB Rluz6A2L7nfS2JZbkm3uYoRwBN8u6bTNkezaBvSSWAey15ZG20k2+0qS66xPDj8G9KRJ +EnB8/jLfx8nyi3onzdw7SgKxGaK7VA8RjzBrUivKQ2uvM7mTDAAzlPmKy3shwh5FAXX /yqkEFqX75SH0q5gplkaw8DzHdhHEbC/9ruTMTZb1ndTU+uBSohp57Lq4fx7F+yAHt26 zQ5QHod21kwn8IBB5i/yeu6ygOvUyjVu1cFA7w5THA7AhIsK/18FrjheOuppQAPtB4vU 7Jvw== 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=2TXcfvyQzXAA7MGVWAEaiJaTJw6CggHuTf+FoxIGKhw=; b=M7g5tfaWYu7CbC54E8NwvUpf+5IgVorBV2Z+FeMunHNd7Cu3kxV0gvet9Z4cL3NdrI k+K8/8ik5dQXdjPhn/fLI4oesnYSgaHwB8GxD2t+8JsEfKNLpmoXJ8kRsCra9sKKPhiM KDu+LO25Y0EapGWW57QDhswDHFHARqSDv+gtqqn91GGzZzH2nuHMNXG+lVb4B4Psca3s wUW/725YpAfpswGKhXHbE4LIhJRyKzBC0p7qBzn+5VeyCqglj/Acf2Q06VJ2b6In0CK7 BhG1qoUY31gDumPRieuWpu/rVbKn0eQaKZvPgdlVWyZcq95DTTLEcptfwIFOOotJflbd jubQ== X-Gm-Message-State: AFqh2kq66be419bhhrUjfU3uF63Va11iaHepNI9oUdTiULSVh4DWPKkM 1EWfdMfVYNjITtEqDkEN7ovwDg== X-Google-Smtp-Source: AMrXdXvdC6BK2NnvcjjzlCwU3DbhcVJIVHYSKbikfczwP2YZr3jzvRvbkUyx4SeaVDG7OS7JJ5K6rw== X-Received: by 2002:a17:902:8492:b0:193:1aa7:c7d9 with SMTP id c18-20020a170902849200b001931aa7c7d9mr25489889plo.44.1674534756275; Mon, 23 Jan 2023 20:32:36 -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 , Akihiko Odaki , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 14/26] e1000e: Configure ResettableClass Date: Tue, 24 Jan 2023 13:31:31 +0900 Message-Id: <20230124043143.5515-15-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1674534944770100003 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.0 From nobody Fri Apr 19 22:11:49 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=1674535099; cv=none; d=zohomail.com; s=zohoarc; b=H0iaLmsAHFlPc1B9xejLZzZuRovgLz1f3es/MYMDEywZte4gRorV+0yoo/lyGzVbKUeEFlZJ+oxZqJsTcPl50xf6ROXMChUNp3JnR3z00Xyc4XHD3r597G/auco9xeYWIbMOgpO0BtrBqrgOFr1FLlGpQLBy5JRhiJFd9pqyvpE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535099; 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=OWlFLD5ygT+tWS9MzrjqLMpgJNI+nJdKdHyIRvJKJ6U=; b=VRV6YyDhEnpcm8SmRxIS1gdYiBKuaCGBURugoIgkNdE1KTH5eJEtzP1XHbdW588Z5fRYZJPTbMpfYtePondUM7GI0xzmBLWlfj9rmBbzXWCpXxCxhvKuX+gCzDDDz99NgHoH/79q5O6z3qtHcH7yz2j7vQ+G+fIAI7ehtjfIA2A= 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 167453509947897.92714067361692; Mon, 23 Jan 2023 20:38:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzD-0002pK-GY; Mon, 23 Jan 2023 23:32:43 -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 1pKAzC-0002os-Bd for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:42 -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 1pKAzA-0002Tj-BJ for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:42 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9so13564541pll.9 for ; Mon, 23 Jan 2023 20:32:40 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OWlFLD5ygT+tWS9MzrjqLMpgJNI+nJdKdHyIRvJKJ6U=; b=6rAT6597t7eEAmRCS7UWNpMGFefC5J6wyzhBYurXYh3q9Wfu6hs0PjUIsD13JWBs6+ GUTwaFPuJlSJpREmKMExa1Qo2MriwawptGmDjc5jVFY4Cy+CPmFHZ3htsx6g+fVeWsyy KFx3a3lqAH5hqbYaos+n2827ggw7fS2g+xnyK+bDhXHcyH2FdDWKBTE2s4uA/zCYjlHN TRTrPdjmDjGeJ6O8jIHuHBqjyTVxO5TcPJflkKDXFNhaiqsDO/JodCg7lq9Jv/QTwh62 Yk0eK/W9k+0NfHdWwEHhY7k82xfNvtsg5GaOWbLssTsJNF2a6cGvq5Zh2kF9rBYZkcg0 dmNg== 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=OWlFLD5ygT+tWS9MzrjqLMpgJNI+nJdKdHyIRvJKJ6U=; b=mD+/+tPoR22fPt2ipn7Ky6KPuIqlAUM2fTvyDp1BoRP49UqXBim9vr2gc6wcoG4pap 9kXQ3BosznXyiW+slVrdw4Tz5C89a7QGRsybnhxCm53G4q1aIgnQT1OODDHzcsf7gu/r eXFxUNOlqCDfAZJpblBocZa8M/0yIKF37Wywqo1aTdir3gfN0wu6VcwFH4W27x3Sfgw+ yHXj0C9XgF/JKXvdV84XP45os8bT1owtsz5KRtdCpm1ka9FsQRwTkdf4XzmeIj54gE8+ 8hhsKutoQjE1cqky/n70JLEYKldzXfD4wkCykEEkqBN5pCv19dPIaIUxmtOb9QOg/A/W cQpg== X-Gm-Message-State: AFqh2kpFlfpz6PNGTAXCM0Dr2OEmoGuary+YIstlOyN0FZG7hnbdpKqm VOTuStAd3X+qL7wXVxqHMbpO+Q== X-Google-Smtp-Source: AMrXdXsR7QmW2sk/8Tz4LfY5Wkby0sAtOttLe/FVAhJI8GEzOnli/vspOJTq3SqMTg3i8EP8oEgdGA== X-Received: by 2002:a17:903:32cb:b0:194:dd83:613d with SMTP id i11-20020a17090332cb00b00194dd83613dmr22408003plr.21.1674534759183; Mon, 23 Jan 2023 20:32:39 -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 , Akihiko Odaki Subject: [PATCH v2 15/26] e1000e: Introduce e1000_rx_desc_union Date: Tue, 24 Jan 2023 13:31:32 +0900 Message-Id: <20230124043143.5515-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1674535099718100003 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.0 From nobody Fri Apr 19 22:11:49 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=1674534827; cv=none; d=zohomail.com; s=zohoarc; b=cfEkoQWq/dp1SJogSeRdJb5WT64y3HzxEwEqI+oQ7upDIEuZdznxznEJvseDo8LOIKRHynv9jlpPD5X4b12Gsv587JpHsDXeRSkQTZ/qIjF0Cc1SQjbAilWNfnJ2yImRhWwQ7kMu4jI+cxiZ645kYGKxuqVIwFo8BOf+aYpCUS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534827; 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=S2yWCEgQIhN3QzPkw0K6Wvtt0U+sc6KSxASGdiiNxV0=; b=AQWKRL3SBF7ohi5Fks8pbHR82CbctdoEN/UPtT9J9iEFEi+9BUHS6FLqq45CurC0pjGmFGuzDf90zv71EVZozCBqwgyEq8gQPbzJNZNPJUjYpfH8y+1FoYhGTJfuGEgelhgk/N4ozHtPJzv4XqZiwpbR7s50SbM2UpSz78C+SQ4= 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 1674534827693939.0649001610263; Mon, 23 Jan 2023 20:33:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzF-0002rk-EH; Mon, 23 Jan 2023 23:32:45 -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 1pKAzE-0002po-7k for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:44 -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 1pKAzC-0002SO-RG for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:43 -0500 Received: by mail-pj1-x1035.google.com with SMTP id e10-20020a17090a630a00b0022bedd66e6dso772142pjj.1 for ; Mon, 23 Jan 2023 20:32:42 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:42 -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=S2yWCEgQIhN3QzPkw0K6Wvtt0U+sc6KSxASGdiiNxV0=; b=BIN7zeEhj0fi7vIUsUEKNXhW2jnfX2BVVVuH24zwtlyYuOGK5FUHzapQXYqmyEf9JT mddijqUl6mxBhB/5Rtj3MeAp0sY3VQW0z3pdVMzzaa01IdqiAVrjDWaAY3qVDIYTOy4t i2wwWO5jPtEICrMw3uNg6GH8aW0fHh8hbJSBI2yuOXiZkOZsDABroEYsELEQ0lDSYaZC g0ENRAuMGO0tbmhgb3DI1MjB4P8HsFvlJv14nXTHe0HuofujZ0W+PNBumtm50/0k/fcv dWZbksxhssEIu+65I/r5jx9ab9F2xwP6rLav7knmViOcdTn/x9zKA1nfOZ91NQrzDHFn jYOQ== 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=S2yWCEgQIhN3QzPkw0K6Wvtt0U+sc6KSxASGdiiNxV0=; b=u+KHX0zgzvcAbu7I9YMSwnIuWcCZoIhZNBXSLo20VpacOj6dn2BoauxnZMwD1RzZIF 5PsVvN7tTgXmU1Kobi4CygnhmToq72kGeo2A9MbteTf5d4/dQgOh1Venmtp9D9KdcNQz 99anmjlbAG+mUyETF/BJ6qNMJEPejYfUCZ2KBdhKXUvlGrcBzM/yccFWvLQA92mWHQVT xc4Bx4nERqNDphByg7t10Ra9wWwDgjiryLjKrn2e+45K+DY+eV7PTiyckaUdGx1817N0 D7nqp14R1JIsE3qPlNs0jIe/2KH6vRjAhdensALxMXW2d5OC+ez1JBlD/BQ8FR709vlF 1Hkw== X-Gm-Message-State: AFqh2koQvDo7m54L4b+6Dm4aV/01GN9nzzwd6u39ari/RaoGSYqb+kdS A+76NiTHq6J8cz329fxJqRTwKg== X-Google-Smtp-Source: AMrXdXsg0kzLuhC07x6OvjBFlI4oTz7pSPro9cJtMFEiiDudfcJdLNewsVzdW9yOmGGJ5QeiRY9BbQ== X-Received: by 2002:a17:903:2284:b0:194:9480:fbc4 with SMTP id b4-20020a170903228400b001949480fbc4mr38524512plh.30.1674534762223; Mon, 23 Jan 2023 20:32:42 -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 , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 16/26] e1000e: Set MII_ANER_NWAY Date: Tue, 24 Jan 2023 13:31:33 +0900 Message-Id: <20230124043143.5515-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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::1035; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674534828125100002 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.0 From nobody Fri Apr 19 22:11:49 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=1674534973; cv=none; d=zohomail.com; s=zohoarc; b=Q8DAdF7506GvfFgca7++CHV8kwVMYdpnfpFp5blWhB4Vv8SXCVEjeumdjcTdywciGxl2rGYuHXlbFiHFuQdu9R7ngwOn3QcWPcduNMHeOzLhHlciQtNJrvZSx27TkpZWxGbZyHBaiYrKCQbY7hbuGDEz3uYI6IW4sjtKio1qe+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534973; 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=yqahPieSTesSQ3ytgQT7EouT1GVK8PvqW8EjKRNmOFQ=; b=Pa5RkRtCnh4nJC43HRfEnTwty7WZ2zP/kNveQCHF3X74HZwAvxMVeeLCd0ameEH3ljSfR5E1DGH/OBl442K7O7x2jJXyqsAQVTsPe1eOixSo71FEdIcME8e+zLIV2oS0+oA0i7L8i+uwZDzMVCVR2ORaA4Km8QPw/HkKUfkNdw0= 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 1674534973398335.82401232429174; Mon, 23 Jan 2023 20:36:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzJ-0002up-Te; Mon, 23 Jan 2023 23:32:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAzI-0002st-8V for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:48 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAzG-0002Uv-Br for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:47 -0500 Received: by mail-pl1-x629.google.com with SMTP id jm10so13539915plb.13 for ; Mon, 23 Jan 2023 20:32:46 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:45 -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=yqahPieSTesSQ3ytgQT7EouT1GVK8PvqW8EjKRNmOFQ=; b=BP56+WkABFuzs0TawnMBM4tcBeNrHHY3W8//jdOHLfeYX7L0gfFrPZTyclvoMPSwum t3naezUcS0OoH8qC5ZT6yRWvA/1sno4y4eKxPZxer0xd5L/1yeE06UXlEK+8B4ycL3qp X78XKUxJNlqjKXCNFyMl5wMcJhk4puFlYm+0+qghVQrwIsfQgBdZc/h023zwLLphpnTt h8SSITjR2P+cssfcvT/EpuxOvmlBtyM/7qz+0xUN72zqZa00m/nKU32szNWMj1jFDawx hNlJU72ierp2qcj2zNVs+OnwHU6CfA1RZ7yNgonY1j4UUsAr+fUiJN0QpOblKqWcDDCR SNxg== 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=yqahPieSTesSQ3ytgQT7EouT1GVK8PvqW8EjKRNmOFQ=; b=WishojT+cxQd39vBAWjWUaHGqUYMfWXDDcTaLe5xYIp3b78Q0Jm5t+uGZo0HNXRHgt EVCgTXNfjhgv92r9NjGqhJICAsGObmVdw+9MsAj6RMRVCRGe0XyL5KICAVcNsF7NebwV 79yAKeniuT4TCyAqBi4/1SEBePOgvrFE3kbG1VO9xZFCGfYTX+1kvcSuLqk8Lq64B6mS 5c+79f9c0JzXO94H/0h06nNjQ9b7SS2rTciEt794ABXJgtNSXzL8aVX0xjPvdm4nBa9E YsXUQQmZvxaSJ3O3UpMoeMobl+wwqhhdcuX+riTlzVqK4C6e/J7fKHPFxw/TQ1aCdPyU UUxg== X-Gm-Message-State: AFqh2kqN2vl8pbgNCjLgXud1yESt9+51rjiUilikQypIuRGdWtgEftPv cc2EBaVL4UbQsY+KeH/q3qOzwA== X-Google-Smtp-Source: AMrXdXtiXFspd08foHreJboOkVnDoDqVf77WA/gysrhNxTfCoOFcD7qMYduuOOP6qWNf7qyHbfxI6Q== X-Received: by 2002:a17:902:f705:b0:191:1e89:35de with SMTP id h5-20020a170902f70500b001911e8935demr29826958plo.9.1674534765292; Mon, 23 Jan 2023 20:32:45 -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 , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 17/26] e1000e: Remove extra pointer indirection Date: Tue, 24 Jan 2023 13:31:34 +0900 Message-Id: <20230124043143.5515-18-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::629; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1674534975212100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674535079; cv=none; d=zohomail.com; s=zohoarc; b=V4lfYUNI7UcZWbarumvV77IK2I8Jz+KybJRnsjD/ZhEep/UNziyugTYODMTjf1NwNGiUDRkZGHs4UPWjAh9VqguXEqLwUtbPThk4Cmh1Deex7cf59j2dDAqbN1wBv0ZzyJGL9arRA8SlDuJuzHW6PY3QY/JtdNvWCLxu+8bj6HQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535079; 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=XKj6hB3CbJPG3MzPqJKXu/piFOPlauwQguDrOreBKaM=; b=kD9Nkq+nKmqu//YwDh0dU3JKcwcXypQRdWJz3TvZpX5mF0HpTtGT/wb9pCR0viDXi0aHH+mKHZgMy3yaDRb/MjSG8V6iu32jYB60wWqseABfJdYlbmqgRWddOzJMvT/2KBii3YDbHJqfbw9tPIb5uq/eONi/1OQquTkLWgTKXFU= 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 1674535079213338.1670616957572; Mon, 23 Jan 2023 20:37:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzL-0002vr-Hs; Mon, 23 Jan 2023 23:32: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 1pKAzK-0002vD-In for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:50 -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 1pKAzI-0002OV-Ta for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:50 -0500 Received: by mail-pj1-x1036.google.com with SMTP id h5-20020a17090a9c0500b0022bb85eb35dso8524801pjp.3 for ; Mon, 23 Jan 2023 20:32:48 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32:48 -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=XKj6hB3CbJPG3MzPqJKXu/piFOPlauwQguDrOreBKaM=; b=gqIp+OUxmKBKHxW3bkBnfW4/3T8KZJ/R9sOs1ZS4fbvu2rWlZ5BkkKK2ytzoNgAfA+ Xfxnevzv7is/VIPve0tLOkhQNQfo5AHFJSQkx+1aHc6ryhOcZw69yytt2RtizaNskx0U ej18yDMTrK6SSzb81MVFDXQl437A7qA8k7y53yAuilXGMUO2gcAFcZxdrMMWTeBiMUtt GJqQ0aDZ8rL+7DXVjfEbbPKaVdMsM7mHqtYQgN4FYte9g0f6cvWkonGkZjH2oV8nw1AO yb0yd1u4iqBnsLOZTq8EPjFwR/yXvObonFkaf0JW88tCNM3Wn/SOzNf90q12ui4kPipa F1oQ== 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=XKj6hB3CbJPG3MzPqJKXu/piFOPlauwQguDrOreBKaM=; b=O63tGsdXaSXKgoaLb/9a5LuZN7aQu9Mb6wd83Y1w1ZrIjHXjL1BPZpCgxWlDFnZkHk udoecrX8X/SQJ4reILyNu4URyuMyuLlPnW8YN+dZGtjcW86aDLwn0dho4GUEKpYzPkcV lbdaShFhdb3znl3YpYFImw17PmYW7MAl584JU5kgaAb7tLEVJ1RCslwAAagzZtu1JZTc 59L9S5VIdAmz+dSLGSwCtdpki+w69buMmh/b9FhFmTPYU6MYSaccAre/Fk8dkzdgPhKt 8Hr6M/QKgSCOKyg3hRwro11oAX8dDq5qNGQ27oJTsIcN8qe7BcKPoVLfWEM+fGzCPoc/ FvTQ== X-Gm-Message-State: AFqh2ko9iEUQ1QFW+2MKNGj1WNJMSYPQXYdbMqwj+Xe61pQ0JwEVxmm1 dDa3IVN2HK2/I0I0UKZ5LtBmow== X-Google-Smtp-Source: AMrXdXvc5ZF2HGPG2JXP3WsGu6U+kBUrzzdJvr4/FMYW430vZlxaAi9EXpijojKFsC04viG5n9XvXA== X-Received: by 2002:a17:902:9b8b:b0:194:812b:6737 with SMTP id y11-20020a1709029b8b00b00194812b6737mr28818991plp.23.1674534768313; Mon, 23 Jan 2023 20:32:48 -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 , Akihiko Odaki Subject: [PATCH v2 18/26] net: Check L4 header size Date: Tue, 24 Jan 2023 13:31:35 +0900 Message-Id: <20230124043143.5515-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1036; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1036.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674535079645100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674534783; cv=none; d=zohomail.com; s=zohoarc; b=dpmeF/s5FQPilNLyBg5TOk8hpRPbc2RikAWUoKObwGoWa4EYJbeWBIQvMkSMNkTDIszSMS6f/JzD0XDUpWcEZjtT7YTVVRqEOMC8jh+VHdORIpKrB5SZ9zM94nwBEzR6dQ2xaM0xB+sRCkBPkTU1gfz3KAlOgzrzWBEblwGsB+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534783; 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=xMZNXf1LQaeShgyN+MpgiuScQuKYbGmXM0CXuVBsdv4=; b=DDEnjFJhO38lHWFkdvEW3deuTSY28NWKQ0eTc8a0GCeTIQSQMmGLu97gOmJ3tUbUp0z2korgkOnd00yMbW09pbhZf6/xFPnU2dkimfaGjpFpm3Egn/6b1vRPFSCaXctDne+KxTXy4gg5ihKVQOt9X3GATozCWQpeZ7pRkxmbxbE= 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 1674534783232910.1204637839353; Mon, 23 Jan 2023 20:33:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzP-00030g-T2; Mon, 23 Jan 2023 23:32: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 1pKAzN-0002wm-Nd for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:53 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAzM-0002Vp-9c for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:53 -0500 Received: by mail-pl1-x630.google.com with SMTP id c6so13605783pls.4 for ; Mon, 23 Jan 2023 20:32:51 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32: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=xMZNXf1LQaeShgyN+MpgiuScQuKYbGmXM0CXuVBsdv4=; b=1ZbXOaucZ6Me2MqstLMPwnQOdlMEoH50MhmRWHiks7e9ZhKpCgPrangN8vVQUXc3nK crbP7AWUcMo0CU8JFmYLw0zxlurortIJvHtr5S5ZQpQF+NWkLnO5IxH7zT783xvVOIoI FYZq0qivuxy2OCs5VXgYMH8KkzwIddZtF+DUBqerQ5TvfTv/cyjQhQ0Co4C/XiX6OuQi kQzTEB9bMP4K6WXVjdoDFOID6FmwcVf8/tgm4kDODz3JB3qkdyE12kdA8c+cYtJI5UQU eW1bdtuB+FaszkGI0rvFQti6PPloVAdRQaHCATnN/Ap77iwklzfTbHTBeS+kFK7ZvTgE I8Mg== 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=xMZNXf1LQaeShgyN+MpgiuScQuKYbGmXM0CXuVBsdv4=; b=6lJKDJUjLy1xcyCfPrC7Ff61yP8D7WOB+oVqVsrOKDntbO7/gTfpJfkeDIWFB/cnBf Zsila6n1vvboExvfxOtVaOK7utpNAGd2V0gjYZnggGjbr2UkLTEo7ZsDPP3azHMsNZCS a++2ePzPmhsyot/JYrf2Wmh4ij4cR17vhl2WRk76CQ8Lg6OilmNSw39UQSBhCQ2RTPYq XrxBtQWprBRBT2XCq5d6zvNQu2TJ6NL2qsxz8RM897u5XOa3bEdZlrQZXaqvUmplC06p 2XBG+stmvNBGueqf3Yse7kV7qR4sHptgLnt2VA7nGbv36dCk3v7jguwtk33ru0CEr5EM JSrw== X-Gm-Message-State: AO0yUKUazVS3IE/b4XS7YJhMhtXfcgADqQzJj8E8nWkvidHWSA6R+vYn 7lnHQd52yGy95LQk9ySsZ4TvkQ== X-Google-Smtp-Source: AK7set8JoLxLs0cm1985Uqf3NEgqZqfsRKPwE8P+l7+wXm40FaVlS5P49c7hgV1eC0fSWNNaxx8RMA== X-Received: by 2002:a17:903:ca:b0:196:186b:cbed with SMTP id x10-20020a17090300ca00b00196186bcbedmr58731plc.45.1674534771226; Mon, 23 Jan 2023 20:32:51 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH v2 19/26] e1000x: Alter the signature of e1000x_is_vlan_packet Date: Tue, 24 Jan 2023 13:31:36 +0900 Message-Id: <20230124043143.5515-20-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::630; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674534783886100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674535011; cv=none; d=zohomail.com; s=zohoarc; b=NFXnesZd0aeUOtoRPtHxPFTw6XBDcKxKt9CeG9t1DHk8cBECnj6QC+/Kj7hErzbymC5udl6TqvlDBn9RolJgWwDtncrSNTQuiokgXXqbD4u8+qZ9hyhTvC7hNn2k/1gQZOpgHt5AICeyioR2moHfKTbQMk4xhIpZoUelQyq2MUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535011; 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=EvxROB9lrXSfSw27Ce9ZPGZ8VT7Veq+eQFf4W+3a7D8=; b=LiIhplrzS7+VwcvKS9DjzAZQltZx9ezUpnqoHLdLU1hlIKgOIjaure9ep+at7JUnNcz2qjiTQjhr4JT7OfVvxUD03wA2KD3Vwwzp8h+B5fb+1sWhYs5FMWuQk3RFwdHAJPWNGyD38Z7+OKN6+QI1R4XlgJhL5kR4Z2kRuWFcf84= 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 1674535011601784.1972701746332; Mon, 23 Jan 2023 20:36:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzS-00033O-9m; Mon, 23 Jan 2023 23:32: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 1pKAzQ-000323-Jb for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:56 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAzO-0002RA-Pt for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:32:56 -0500 Received: by mail-pj1-x1030.google.com with SMTP id z4-20020a17090a170400b00226d331390cso12909864pjd.5 for ; Mon, 23 Jan 2023 20:32:54 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32: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=EvxROB9lrXSfSw27Ce9ZPGZ8VT7Veq+eQFf4W+3a7D8=; b=r7ehfVGchjp9F924uc5KucmruiLmd9z2Kqrm75JVw43de436aLBHbapI3ruO+XQ4sB prO7tSZv/qR3BWOqDQfZCyh20eqvJEoKiTtVcryJuJiOZUnte9FQIptp55YBbpRP51jM 3Xjr39PAU2AT3uHEMuattpKVycg5/2fV3XJT8AqZDsyDwW793xYyCklppdn54mE6kO+g ekI7kh9RiYiaPqgAG3/Gg5ZkWfr1K4IIOLhagU1g4BMMVDy4G0GCwMyvYybp++1avDIp IKSFhIGaGHq/PwTgsUbnb4Y2WC2e0i778FB6WDd0MhX1V9u+6JuoOeJ9aQ9pHr5Knfqw oUpg== 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=EvxROB9lrXSfSw27Ce9ZPGZ8VT7Veq+eQFf4W+3a7D8=; b=38skrK3IJ3rMuK93QlFah7vnCEVvV+kB588+cYsnL6byqFu6fVpTJ34S2eOZN+Y3Dq MUO2cwEmmnIkbE5frhH6CyMlgjwvyh3yrg2sT2CMH42kf0rYnlcIZn8575n3Ug747KbV jvUBY2/QnCpebkF0PzAc8XoA0ieR/ledXE5PG78XOxbjBd1vCEUqGULtRwhQXo+rE9Lu N56lxYI5TMT6t0YN9LzkO33sEVkaPXV1jW21iOJduxDnqE6bLf2JHXDW9nquSDYtsTRx LDpufMkvqlDLkwQyYMYiLVKkKvA+8MVxQNdmsAlfKk8DNNSjgp3fGBJI8pf2sLiVnK7N IBdw== X-Gm-Message-State: AFqh2kpYlIPdDAeR1DC3pFAFZ5tmjlsfEMpa6MDmhoDTtfyrFd6JZOPs 8K1cWGrPYideXJe74Wl+KRuXfQ== X-Google-Smtp-Source: AMrXdXsAodvdAlAsTqRZwlNOHkrSbBypMB0QvSfdrmaylXZq8dTnYMObsI2lLxjOcMav4ROg+FAueQ== X-Received: by 2002:a17:902:e84e:b0:193:2ed4:560d with SMTP id t14-20020a170902e84e00b001932ed4560dmr37359121plg.55.1674534774115; Mon, 23 Jan 2023 20:32:54 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH v2 20/26] net: Strip virtio-net header when dumping Date: Tue, 24 Jan 2023 13:31:37 +0900 Message-Id: <20230124043143.5515-21-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1030; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1674535013344100002 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.0 From nobody Fri Apr 19 22:11:49 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=1674534827; cv=none; d=zohomail.com; s=zohoarc; b=J4rBluHsKLeWfMHxB/yOgsff3BoXWkzFoiiMn4o9wjAtO46rxtOAbtYEepcMU7utVGLD7AlmZP0HvhzVdswcQbncY2N1g0zkRnRiv2twTKhhGYEBByUeEterijKO/vj6epZnDzD4OHCzLzEE8gxliyMo+tlLLKrFBYZJIOJVaeM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534827; 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=TjvUSqMTfO2wV26xg5K6Oe2+KYUhWxBAs71v1THgt1g=; b=PslrhRLnhMrLNTkcOMzkhSXzE2sPtKrucQnpBsjBXaFgSavFyyi763C6Y/SBOvUY0lcz2EzAhYRFNS1c94F1cECx8iI/puCEryhrYK4W42m2JhIYZnWPI9pQAfm+c9dEyaLhYT6oweZocWEpKcr3+mYKMC8QYxFLjkgU2MYdk+k= 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 1674534827115651.1296103115196; Mon, 23 Jan 2023 20:33:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzV-00034i-KI; Mon, 23 Jan 2023 23:33:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAzU-000341-Cn for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:00 -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 1pKAzS-0002Ws-Iz for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:00 -0500 Received: by mail-pl1-x62f.google.com with SMTP id jl3so13572812plb.8 for ; Mon, 23 Jan 2023 20:32:58 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32: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=TjvUSqMTfO2wV26xg5K6Oe2+KYUhWxBAs71v1THgt1g=; b=bmgtxzm5A8drFzo6WWktGy0e0hdvsbqvyY6sPo9t2YPbI14yf7/sTdOMiy2Y2YCNTE 9jiveC2oxylja51KClJFXs2OB1ioLq9E0UnYG53ya5QYFj4983YK6msSM58SaRjVGNCd EMQuKBcRkseQFQR8TEko+nR9rWmEG7Oj1h2iGT/axcabqCD/cltoHESdMu2S1qcf6Vvt t940dZrOi2OjEqHd+VAoNJAfkFWRgIQ5ob9/vGKqd6JncPP7JVSwaEKAy9Ploi2SkAB0 YmshbR+RLyJIKOCJ7S4jo6rR9cg9lU8II/NnGoHeUJYe7qbAfbt+Z/bdj4oKdN88CZsN ttgQ== 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=TjvUSqMTfO2wV26xg5K6Oe2+KYUhWxBAs71v1THgt1g=; b=qc7IOMQJpx3twZC6P/0kxzihXPAHYKKBbkaMlF3imf5aVRSahOTfVyPcGkeFcQry5Y 54v2k0EvFQ2MRnzLsZdtoPpbNkzrie9MYdYRUypQ87pEKA6ohu5NhpxbZMDMMBVtAAqG iC59AZn2Nyrxo+IfJ2FHYGlFTab5QqsAZUhOu0f5ClzkBFgufnGXXNgkl6x81ka4ZtuT 25gtJyBGTnDX9ccbqt+BFiLee86Z0zb5Nbv8ULhaWX+TogDMv9YxSxKQWp4eTCtRnQpv PK3KXfInZC1P9MHrm9sW7253HPMRCkzbWS/Mxvp6E8l3akW3gU+d9MMRBqeCdAuOZGAp yVvQ== X-Gm-Message-State: AFqh2kpHF3p1xpT1rRpjI1OdgCjcDs0cYmqYrcAL4XtpE6MIvpHj+sED /GJIyE0dcemBtwZrstg6uLBQxw== X-Google-Smtp-Source: AMrXdXuXu1K6nnUVSDyE0g2cRPxkWSqpDkip5dDRHDb6D+isJjNDIjNMJRjYugPIXl5LP2gd1kgh3w== X-Received: by 2002:a05:6a21:3987:b0:af:be2a:208f with SMTP id ad7-20020a056a21398700b000afbe2a208fmr27845265pzc.33.1674534777219; Mon, 23 Jan 2023 20:32:57 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH v2 21/26] hw/net/net_tx_pkt: Automatically determine if virtio-net header is used Date: Tue, 24 Jan 2023 13:31:38 +0900 Message-Id: <20230124043143.5515-22-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674534828072100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674534967; cv=none; d=zohomail.com; s=zohoarc; b=k6vhB2QKBUQ1KS0TXuFBUz+iL9NquDg/2YJmz2T+r0hwQWhs/hMljplyWpw5blS8cVuQdzdhyXXKkoDhZe3lL3oVR2YKcPd+H0Dw00paPnxOD9td8D05/7mB1IfoDF/XMrZleN1Hzdl2nDDiIOU7QnVtk5EvJw5D9rVThmoDJcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534967; 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=B77RV4TtBdAQzqtrHO3fFDqRdUobChj6wVp39uSxdwo=; b=WicpUda/PHBBn19iQJiabWch13g8CLQkpLgIusfQjFUHWT6mhmKUfD5jOf5LZwKcFR3qf7V2RwVi0XGo+9Lwefen7ZIoKuQ/fefksrkM7qs6O4B94t+CapaeCYlNvgg2EmxCD58/lGSr/m+mWjyAuhuhPrFBurV8iZOczzglA/8= 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 16745349670311019.1215695375301; Mon, 23 Jan 2023 20:36:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzY-0003IR-BE; Mon, 23 Jan 2023 23:33:04 -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 1pKAzW-00037G-Ko for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:02 -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 1pKAzU-0002Tj-Qf for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:02 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9so13565086pll.9 for ; Mon, 23 Jan 2023 20:33:00 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:32: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=B77RV4TtBdAQzqtrHO3fFDqRdUobChj6wVp39uSxdwo=; b=fYjctuMO2H5vp6gp6/n5/i79CpTMgAFRZlsJxFl8v07G8GuI33Ph5PeDkVCuYR6eQR 9H6s4XWQvauNUD6xAdmM4x1dNmS/QAEr8YfafkhAElBk5fIQHOHZuUKzMAaUIdl1AJYe FOKzyX7iMHZtsAWEciBA6Q9KGa3jW8NGWpIXo1UBTiEMSqyOrUFele8fgno1w11pjFHE nbQ/6RzKDWhy5eASvKmrZKKHTeC2HTBH2WS/B1hqutntE/NRbij3Dk8vN1INwI7LoBPl Pg2MNjtiSKn0dI1sAHDGo+c2f99amBU3FYTN22NkSjheBEekDRDaCVIzJ7y5jGII75wo TGgw== 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=B77RV4TtBdAQzqtrHO3fFDqRdUobChj6wVp39uSxdwo=; b=onbSXLYsnXKK7KYDBCvWlAwXmMnhrb83Q6mX5PsqMCcDvEdCUZm0qCT5uISQ88hWau 9JxJpr3JGRSbYRBaJd3t7WoKppgl1YqyXmMHx3ITesZG65QI+T3CMCE94B5g/XJRt2k0 hhQz67HJYGOjvxaBXikOId/xR7aAt1lUJuDDusCw+ZkWt0eLrKAmaL0paLOmgtVnhXjM ILLE8x7e5qbBUzZGXoInTqsQvaaS/rSNTR8HcEeHPR2/V14PRS8aiHJOOs/nXpnIVqS0 24GNRpu11N3NVMNsY0ABTh9zPUjlafKZ9bZCHEo7Qjp80lh4tDUkMOLFp2O1gkcmo7vJ CBBQ== X-Gm-Message-State: AFqh2korJvuzR37XqbCNzEycm/rNZqUq2PktPY4gBJnW55nKJFKQi1cl 1mlVhpkszp5327qSM2Q9ZgUlCw== X-Google-Smtp-Source: AMrXdXtj2oEgkw8cxU24rARM4EVeUo8XofINZDa//1q3jxFAl9/Sni1Y6/p7vqMsAR16qsEpfvxMQA== X-Received: by 2002:a17:902:ab50:b0:194:d5ed:b9ea with SMTP id ij16-20020a170902ab5000b00194d5edb9eamr14991804plb.57.1674534780151; Mon, 23 Jan 2023 20:33:00 -0800 (PST) From: Akihiko Odaki To: Cc: Jason Wang , Dmitry Fleytman , Thomas Huth , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Yan Vugenfirer , Yuri Benditovich , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH v2 22/26] hw/net/net_rx_pkt: Remove net_rx_pkt_has_virt_hdr Date: Tue, 24 Jan 2023 13:31:39 +0900 Message-Id: <20230124043143.5515-23-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=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: 1674534968900100003 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.0 From nobody Fri Apr 19 22:11:49 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=1674535029; cv=none; d=zohomail.com; s=zohoarc; b=BhfYcRswUk8PPNfUmJ2xCSeToUXmAe8ED70XIsgRtn2o32iK8vX5/8g6Udwe0GIoeiv+byBliuSaqx+RvSDJkfXxQXAfuMtGCac99/bxtNecM4kw1XVMlWUBdxZpCVRJAxUceLWO3gT4H5LsTJKi9CuPfSq9jVfL9y9oVEr7Ljs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535029; 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=KaadaPMK6uWJPt4YhPihzFrJlBo8FnzXz7TPA7AF+Gk=; b=nCcdY3Lb0U2peGvV9IN30oABEu4z1OKjIAfAsm7EfftX8YSySZ0nj8dMVyXDRQ86Qw7QGSDm+S3qqy3HXod8/6nrCUk9/9OIpbZSqfr9/jk9hdS8uKeAz4Fbux/5yHAzROUvG//pfAcfD///b2+Y/U0rJ8cALI9t7COt7oLR2Ek= 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 1674535029264538.691164925601; Mon, 23 Jan 2023 20:37:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzc-0003mV-PP; Mon, 23 Jan 2023 23:33:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAza-0003Yp-LA for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:06 -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 1pKAzY-0002Ws-4T for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:06 -0500 Received: by mail-pl1-x62f.google.com with SMTP id jl3so13572985plb.8 for ; Mon, 23 Jan 2023 20:33:03 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:33: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=KaadaPMK6uWJPt4YhPihzFrJlBo8FnzXz7TPA7AF+Gk=; b=NnhRg7DT7RLxNsuGvgJ9Yb2ZRZ1BHW2+bAs/3d0TQlbBg7DQV1TbtD0O6qbvX72mXp ydWQ2SM8vxLQ22mLrblp5LXQbVK6gygNCpgO2sAOOgPEHC4sujkrud/qhDy2wosSjmi4 C0mC1cmTeKAf52DxqZ5YpC3xjljv8OhNbk3ULYYZFi7NmtVIZLfVxUJn4y2JvTML0nKN euKY0WPrxzyiGIyqXcGMk/QY7SqeXbnSlJwdzJAZOd0C9bASoy8Tt0ECegpV82gujyWY FQLnPjXHdI/j3icc5S8BfF/O4i2hzw0RyZgzpvgmMKoJ3b6VwRhOK74C0jO2YwZyMfkH 9Nig== 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=KaadaPMK6uWJPt4YhPihzFrJlBo8FnzXz7TPA7AF+Gk=; b=FVDF4b9fR5HiUuLhiU+0zti0LesJGLOOwBIC/DsDr5KI7Fix+FlYKiyEsicTlZTeAy 8LBR14kRS4O/nm8B0yGAoREy384yJcjlOb0DoCgbolnG2E2WeMWt+0mlVxA5I/3G4CWh SqGIgQbSd6nkGVC2khb9BzUAgT/tSL89yV3WaU8BIyY9VFcMWPkmdX2rWjCfhetA0YVf LJUiKDiFYc3TAh+z+VTqzL+m8wWHcFVqC3O2Ot2D/+PWXHQIdenP+OVCeP7sdshET1nm 71OsiKQbBZAV5JSNKmfjvMoN2yHAmUq+zPoQRp+bArrghxoZ1/WbIau9P4eJNyOlnbSs /qww== X-Gm-Message-State: AFqh2kpoefbwmPeMAZiu6nVJwzOOzkws2g0VgPJgr/yj/1UBk5mvMpJH xZ8rD/7HY0RsrGKCkYsk41/EOA== X-Google-Smtp-Source: AMrXdXumqSgjzWlKvip85+xx2//6GHThVxUkJJHwWl4DLf+RNRUL5Rr8St86nyuE+fc7TaXZeaszKg== X-Received: by 2002:a17:902:ea0a:b0:191:24a:63e3 with SMTP id s10-20020a170902ea0a00b00191024a63e3mr34597527plg.50.1674534783110; Mon, 23 Jan 2023 20:33: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 , Akihiko Odaki Subject: [PATCH v2 23/26] e1000e: Perform software segmentation for loopback Date: Tue, 24 Jan 2023 13:31:40 +0900 Message-Id: <20230124043143.5515-24-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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: 1674535031393100009 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.0 From nobody Fri Apr 19 22:11:49 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=1674535101; cv=none; d=zohomail.com; s=zohoarc; b=WksfEfBec/G7ECFhB/7fWR8AmL/0ZbDQ28eUw0shUhGkEwDiQWU/Azrgk+ZQVUvTlaJ/p+yMSnQn5UcbOH9wXLSVfEyFjvAEanjUaMuImojWFFXNvo9+cfvZDJxIuynrIqMhw3rPJu3UrspC3NcanC2tv1LQOGybMrciWRa4K3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535101; 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=0mHoD1Tnncyz8QzeZ+uspGd7KTzBCQZHcn6A/b1UkGo=; b=fVRIf7DiikdzflG+aUDsiDwedjCVgQOi4J6nHS0XqLAhbpkRd2562RWYi6sis+ojZxdPOFtE2RFAynr4DBZDdSU2Rb1W1+PP5Fw5m7cDXj22GlNJqi/cSS9SRCsGDhqGAFS03vTD0Ulvg9p4E2h0F2Ea3JV39n5T7QILTQ9D+2s= 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 1674535101148321.36304373697874; Mon, 23 Jan 2023 20:38:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzf-0003t1-Jy; Mon, 23 Jan 2023 23:33:11 -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 1pKAze-0003qW-6b for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:10 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKAza-0002RA-OP for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:08 -0500 Received: by mail-pj1-x1030.google.com with SMTP id z4-20020a17090a170400b00226d331390cso12910211pjd.5 for ; Mon, 23 Jan 2023 20:33:06 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:33:05 -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=0mHoD1Tnncyz8QzeZ+uspGd7KTzBCQZHcn6A/b1UkGo=; b=KVC+jtropCoZAjqWqlbW6XA/v2ce5VdwjurG5XOMvltgSBOhdFDRarPci7WMIhPwE5 R+gX2qDSq0JYaBjcmPRNLe166S6w/nycrBsZBpH8wE2rWBUZfatSmHNwmZr9Bo2FnKNc BeimtCP7LzcTJPNoVQmpUiYsSRJrD7BzpnOuA+dx7RxGKkqsUzzLkVbqaFrTULQTGzVT 0+mB/zsPC/QBDmYyFxjYmFWLQ7GbI847BM2F2XoswdPAtKp50aQ53Z1WoIhts9bOAiQo 4YNsbzK3F53z1OpilzxUmZsTOYLbiLsMYaKzCqw4dGpA8Q1N1WpV7lWpBO5xfKCx8R3A AYkg== 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=0mHoD1Tnncyz8QzeZ+uspGd7KTzBCQZHcn6A/b1UkGo=; b=G1EF9ftmTE6V9pNPmiZxRKdyjkYs5W9Cs5O81hCgz9rrVkfK8aYstvNnAyuo+GzYyQ X4M5lTzHJRJbp1uznji1narI6uWkVy090In8BrkNxsRBT3/IcxtacWEx+zIiP43pNXeT ihvd2SWyDPP/uWXTZzew6eco9mQHNu5boLJp1GKz5R9GLv1VnUIu41+IwtJU8NIWU91F 4FwZI6CU48X3zG3PVzp6kWyDezFqvqA9DBoHVSjHrLD9EqI+ATMWvUofz0R8Kr2k4fRq Yj4DFb8T1GnV8cX1ZtqTRmqvIPYNp8lB9obGhMHZFNtzZ6RF8GliV7uGD3OTX+kxr0v/ iI2A== X-Gm-Message-State: AFqh2kpcplPAxkeoN3fAs4VC1Bv9QnBhWSabw0qRIhTmiZ9pwXC/kMRn Y8f2Lzm7oaLJneS2MjmPhUixmw== X-Google-Smtp-Source: AMrXdXv7CTfeLAvfdQQwZ2pxbRLambvcYBJLBzbuoRImYjk6WtlkBZX3PmfcdEJxQJpOEiBlUTE4Kw== X-Received: by 2002:a17:902:d88a:b0:194:9f55:73e2 with SMTP id b10-20020a170902d88a00b001949f5573e2mr27168232plz.23.1674534786019; Mon, 23 Jan 2023 20:33: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 , Akihiko Odaki Subject: [PATCH v2 24/26] hw/net/net_tx_pkt: Implement TCP segmentation Date: Tue, 24 Jan 2023 13:31:41 +0900 Message-Id: <20230124043143.5515-25-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1030; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674535101715100007 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 | 244 ++++++++++++++++++++++++++++++++++++-------- include/net/eth.h | 5 - net/eth.c | 27 ----- 3 files changed, 203 insertions(+), 73 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 6afd3f6693..e5c3e1e10b 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,221 @@ 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); + + (*src_idx)++; + if (*src_idx >=3D pkt->payload_frags + NET_TX_PKT_PL_START_FRAG) { + g_free(l4->iov_base); + return false; + } + + bytes_read +=3D pkt->vec[*src_idx].iov_len; + } + + *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; + + case VIRTIO_NET_HDR_GSO_UDP: + net_tx_pkt_udp_fragment_init(pkt, &pl_idx, &l4hdr_len, + &src_idx, &src_offset, &src_len); + break; + + default: + abort(); + } =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); + 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 - more_frags =3D (fragment_offset + fragment_len < pkt->payload_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); + break; =20 - eth_setup_ip4_fragmentation(l2_iov_base, l2_iov_len, l3_iov_base, - l3_iov_len, fragment_len, fragment_offset, more_frags); + case VIRTIO_NET_HDR_GSO_UDP: + net_tx_pkt_udp_fragment_fix(pkt, fragment, fragment_offset, + fragment_len); + break; + } =20 - eth_fix_ip4_checksum(l3_iov_base, l3_iov_len); + net_tx_pkt_do_sw_csum(pkt, fragment + NET_TX_PKT_L2HDR_FRAG, + dst_idx - NET_TX_PKT_L2HDR_FRAG, + l4hdr_len + fragment_len); =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 +787,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 +800,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.0 From nobody Fri Apr 19 22:11:49 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=1674534952; cv=none; d=zohomail.com; s=zohoarc; b=S5et1QTq8/+aiKkaNcBo/xL0TO10yfdvdPM0oHpSn3CmIRVJ1WvyYnh+tjdPp690UIIQHVvLglZNG63TNq2Q5ebwmjdQbJKE11sfKDmsl2BmslFDqAt3g934rQNODDYTWNFXmnBmARJYs5t19XkN6vbYcqw68fEWSUViVA1wIZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674534952; 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=hHOPmxTcrXEL/dD6E3rURwQlKT0zRB74xfOULXZtt+A=; b=lDtaZstrjfOjRUhBViVX9Q3DsegjHW5Gi5ZYJn1tIv4JxOf5iMxgCfjaQH6Gd3mKP37WGHp+NGrB02KsJTSxFAQSZMHDWsVeUVmI0yrVjwfkB7j3D1G+js6lFtSVR+w7kufe7+RViaHh/AjcCo+fStPruccocl9RBQ5Xu5/f8lM= 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 1674534952287262.786789500713; Mon, 23 Jan 2023 20:35:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzg-0003uE-8s; Mon, 23 Jan 2023 23:33: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 1pKAzf-0003sw-FD for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:11 -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 1pKAzd-0002SO-Tf for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:11 -0500 Received: by mail-pj1-x1035.google.com with SMTP id e10-20020a17090a630a00b0022bedd66e6dso772893pjj.1 for ; Mon, 23 Jan 2023 20:33:09 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:33:08 -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=hHOPmxTcrXEL/dD6E3rURwQlKT0zRB74xfOULXZtt+A=; b=FqxRknscxPCfDIn2nK09MhJM16RdroiiSTxdEQcJw6q0LGyH0vUQeyDwGj3MhV5DmL utssMqOKFA1StLRCi1olMiodqviVnu1B7+RpD6upV63o3ByXxIdblo7n9t8Pzjpy32J5 jq4yiIPCcF0MhpgYQwf0HYjRTZbig5liKUHJCoGEXs8xaFdDz4TYCbKN6Htt9v8q5kcH RjG/a0ONIvOOuZSS0OBPjbwCjEDliRmZJVm2OrNzb8XhPlYGK65C/R+3/zNtxO2yzo1L /6MvtYqxsuSt8FOCfw5BPc7I8tDD8+NA5Ptg4BgSatVHbykDZMNtKOCNbtsgf0ZlNe2O JI8Q== 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=hHOPmxTcrXEL/dD6E3rURwQlKT0zRB74xfOULXZtt+A=; b=ogdONfN7fdwEK02hpYM5sUrFJ4ip1spD7pyXUw67Ycyuqau1ahb9oetRRC+hpWIdGg y3nE9Ki+f2ztFHmPFOndnXN8Uhxn9gJej8ZeYF4AD06868EbA5AYtUQTZ+ilT1HuKiQK MU2jBksCsi4fO+XUvdqmoVcUdNpFqBNpMhox6I7U/2/GhrjPuqOgpdV1q3QyGb/DeiQh qt8AhXlQAS/oZ5TNaYtw/yzgz+ApzmRb/uQRJwUAbR2SLan0pJi82CTvLAf6bCalBx5x 0j06NinPwtPuv4dAJtUfZvtMY1JzRE9wJBaawXdjyjfJeAh/iaPcUPjS6xEFCPeI7ROv Vlpw== X-Gm-Message-State: AFqh2kqd2oe7MmaRleDJZcTVVFYMFeuUHQxhnGz5Evnkvo5JPUZUFDw3 ErP9Msykz3ghPdorpwKAzzNe3w== X-Google-Smtp-Source: AMrXdXskoD6OSXesldfedjPRinaGig4T9PbAdXajd7Lt5aZUPpzgGpr+qicNxxzTrSCjISTVYdimRg== X-Received: by 2002:a17:902:b598:b0:194:645a:fa9a with SMTP id a24-20020a170902b59800b00194645afa9amr26470633pls.8.1674534788951; Mon, 23 Jan 2023 20:33:08 -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 , Akihiko Odaki Subject: [PATCH v2 25/26] MAINTAINERS: Add Akihiko Odaki as a e1000e reviewer Date: Tue, 24 Jan 2023 13:31:42 +0900 Message-Id: <20230124043143.5515-26-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-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: 1674534952772100001 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.0 From nobody Fri Apr 19 22:11:49 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=1674535029; cv=none; d=zohomail.com; s=zohoarc; b=WonmJWveIlANDf3gvUvDUXfdo4NjgjxVj/G+XCiR+QkIvMditj3nwTLB/rrRCozouNYJLJBKsndfXZF/96CAyjJmBntYjXvpQYqLqJFWm190xbkFOFyAiurT4fJeUAfETUFKxNhNgTBpkkd5fuUt81l5sOw5TnbSE+o+vMfBt54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674535029; 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=/BNZZO3nQWU75JUJdd7G9yhzR1Cl/QQbtT2FKQab3nE=; b=TwHbBUF396dgXa2Sim/3EQKgZsO0HwuTf0D4rVkYyWXPhIb/E7Hl6FaSmV9eCR07AxyAYV7gkS5aNSwsQM01srvyPmvCOr2zRwLqkFJowx/x/VLmpk6zPnOUOMF/lDy3JXv/Hzxd8TCDqR7QjC//G/0ReUGfmnJ5ZkpeawS9BSE= 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 1674535029137514.6589571040001; Mon, 23 Jan 2023 20:37:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKAzk-0003wA-MX; Mon, 23 Jan 2023 23:33:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKAzi-0003vB-NR for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:14 -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 1pKAzh-0002ZK-6K for qemu-devel@nongnu.org; Mon, 23 Jan 2023 23:33:14 -0500 Received: by mail-pj1-x1029.google.com with SMTP id m11so1831324pji.0 for ; Mon, 23 Jan 2023 20:33:12 -0800 (PST) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id z5-20020a170902708500b00196030312ccsm548033plk.78.2023.01.23.20.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 20:33:11 -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=/BNZZO3nQWU75JUJdd7G9yhzR1Cl/QQbtT2FKQab3nE=; b=Wes1cEbol0ihWPvd1jwBNK0/ga6/f/jf2lIpeLKB5iuY9Ek3ZwUNvlCWKNhOnuCsky E8for3lvevZa/LRnTD907eDvhfvfHTUQPUcfJnkOsBOHIUXMj254liCpGYRp9X/ZsvW5 EdM10C79rB7NKXdaPOLCSOpoVlvnhLWuHnBuecAKJppY7MDkSOFNQu/yADdCTumKGAfY Fw4YBTWvyU39736p7vVpHciD96+FaJYCro66M1xsP1qjbLsvvBaZA0nVP2f8gNaY4FCP d9X6uCVomwjBhlaUISCqHCZe58OfyGuO39x0eH83F7o3up3uvNxHitnYDHrlwl1/Ch3x VQSQ== 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=/BNZZO3nQWU75JUJdd7G9yhzR1Cl/QQbtT2FKQab3nE=; b=5V9N4NI2874A0CeQhpKA9DYSnDT7H+UtUL8waQgJ5a6KkXpNlWHbx0qp5xgVoc7lE8 Ggmm3OYlWchqnkTmimsVlTu5s1fg7K1biIuAGiYVppbLGPWaJ46ZZ9KDE7Lqx0I3+s78 v4+wyQGk3KmEmiKZubuhr5qRJDXGCChdr1kfL7c/nsvZL/1Xu5u1dOwC+aQ06unkGGCI Dnlv4ZgB3slpVekihX5eiV4SRG3unU5U3HjkEAENtvoDnBdGuU/NRpmXt/meB31nzIy/ tj7CdbYmw1hZ6HbW+D9e23JgAH+BpoeE1xxd4FoEk6dAESnK4n8xtG0ZXH6YXm+thivO NlHg== X-Gm-Message-State: AFqh2kp7cp/eKX2kJZ85d8A3yvC/MG91YsIVqw8aJ7oE/5MmNnIYvkLC q02rKvFk0UgOdF9VI4t3Yb2EXA== X-Google-Smtp-Source: AMrXdXsCG0CO0RQ/p4PkL4vEF/4n0Lq6y+m4BfPXdDHbwPiQmA/koFWu8tFflU37ojtvEa3wn8wbGw== X-Received: by 2002:a17:902:d543:b0:189:ea22:6d6a with SMTP id z3-20020a170902d54300b00189ea226d6amr29680300plf.60.1674534791869; Mon, 23 Jan 2023 20:33:11 -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 , Akihiko Odaki Subject: [PATCH v2 26/26] MAINTAINERS: Add e1000e test files Date: Tue, 24 Jan 2023 13:31:43 +0900 Message-Id: <20230124043143.5515-27-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124043143.5515-1-akihiko.odaki@daynix.com> References: <20230124043143.5515-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1029; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674535029419100002 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..3b648a89d7 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.c =20 eepro100 M: Stefan Weil --=20 2.39.0