From nobody Tue Feb 10 19:49:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1679672497; cv=none; d=zohomail.com; s=zohoarc; b=dyZzyc5K6lVSMUYIFd/zgwdfaLwTjrAJPdXzYVDHrXNEUlHd6mmNBMlnJ17WSGTyDbl+egTtON41cbu1XRWLHE31XkdhrDSqkwA7r9p9CGCsUjjDj4GUZNJirCIufS/W3TbXJENrMSu8ci5ZoXXRqut/VIEYdjn6myCsYbXbuTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679672497; 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=olWpSyjuRKBpQwlTJORZDyycQD/rB1S8WMk6WD7U5zY=; b=V95uf/JhtxTl068hTWAZssKouABBVM7Q61jS2o70NhFZWwyyu0IHDwuhzxaPJj3C0CtQwwlNcD/tBd+ne/4Fc6yFJQ+zWZCMN9sCTzhtS2dfQloTJvMs1zXqC+DisgMaSSyB68bhc0ee2/J1SPZZSQA2Np1LTqzT42RP2Nq+E54= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679672497153393.17715733876685; Fri, 24 Mar 2023 08:41:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfe9R-0005HR-3n; Fri, 24 Mar 2023 05:56:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfe9N-0005H2-Ly for qemu-devel@nongnu.org; Fri, 24 Mar 2023 05:55:57 -0400 Received: from mail-pj1-f50.google.com ([209.85.216.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfe8v-0003RJ-8h for qemu-devel@nongnu.org; Fri, 24 Mar 2023 05:55:55 -0400 Received: by mail-pj1-f50.google.com with SMTP id q102so1064416pjq.3 for ; Fri, 24 Mar 2023 02:55:18 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id h5-20020a170902748500b001963bc7bdb8sm13785614pll.274.2023.03.24.02.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 02:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; t=1679651706; 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=olWpSyjuRKBpQwlTJORZDyycQD/rB1S8WMk6WD7U5zY=; b=Vxf2BUreUP4SkUvuYCgX62QEZLr3KYFGbM/5O1WXrQsw+5s/rB/9fNtI3n6OESAjys FATaFdlnFAeybg3R3NlO7oAf0qtRnHbE+JHMFq8jHchJpnkuFAMQBzA6U4GQ5oQFqNnf rfk3Dr5zi5VfxZPmxNwFIxEqdf7S9VcaCVGrjNTEpHmHLc/l18sN7d9ns8Bo/k1IGRJ2 Xu7/tC13RZ4JT/GMpwyloOGDflz31fy3co0heeiv7cjR5CFcwkKIHDQW2Jd4wajqB+DF dITHxMPdugtQb4Q8s7Pka0+J+5WniLfjGLWwDk9FnE9abzYJFiwp8xwMHUuK87QhA2jb t71Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679651706; 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=olWpSyjuRKBpQwlTJORZDyycQD/rB1S8WMk6WD7U5zY=; b=W709FqzrHK+Vbf0addZ5oCwSmi/ONkcD1coQz5du0MRsY51urQeXDVqkNrbkRaxVyi MM3Xko7H/kr6W9Iw0QTE2zctqAp3UxZZexObUyhIpXR3LBvXZYZstDk/Jrlxp3RI4tPf k9hvSPI4xAX2AB/BE/IT3B90WQxFjHazTIPqvukUZ+jJNHaPLzzZeYrbGAPvTBxpTI6b piLJHPH6kOdikRnGv2PjtP+E02V2Qy7GbCtXtt/dHVAD7ReUEGF3+M2cCo1EsWz8y+X6 q0UfNxTWGqaFd9UyPQ6tWK7pw6gX1VBJfgHirYmJDigFvgYrlWQhUGup8a58ix2iF600 RtkQ== X-Gm-Message-State: AAQBX9eMk4N/ywpaXkm+t4zs2tgEa+UA84/wTqdTbA+LfFqaS5JLgvkS ZnJpG3bda725JUZ2ZLNRZvks8+tmKWp4A+RHKF8Z8g== X-Google-Smtp-Source: AKy350Y/HiEfcm/eYjFjQSAdq8xPEIW2rxYr6K5//s+zcRse/Sq+hw99KoCglVUNT/WtODzQw1cPZA== X-Received: by 2002:a17:902:c405:b0:199:2a89:f912 with SMTP id k5-20020a170902c40500b001992a89f912mr2792650plk.20.1679651701405; Fri, 24 Mar 2023 02:55:01 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Dmitry Fleytman , Sriram Yagnaraman , Jason Wang , Akihiko Odaki Subject: [PATCH for 8.0 1/4] igb: Save more Tx states Date: Fri, 24 Mar 2023 18:54:31 +0900 Message-Id: <20230324095434.44973-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324095434.44973-1-akihiko.odaki@daynix.com> References: <20230324095434.44973-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=209.85.216.50; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-f50.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, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1679672499102100005 Content-Type: text/plain; charset="utf-8" The current implementation of igb uses only part of a advanced Tx context descriptor and first data descriptor because it misses some features and sniffs the trait of the packet instead of respecting the packet type specified in the descriptor. However, we will certainly need the entire Tx context descriptor when we update igb to respect these ignored fields. Save the entire context descriptor and first data descriptor except the buffer address to prepare for such a change. This also introduces the distinction of contexts with different indexes, which was not present in e1000e but in igb. Signed-off-by: Akihiko Odaki Reviewed-by: Sriram Yagnaraman --- hw/net/igb.c | 26 +++++++++++++++++++------- hw/net/igb_core.c | 39 +++++++++++++++++++-------------------- hw/net/igb_core.h | 8 +++----- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/hw/net/igb.c b/hw/net/igb.c index c6d753df87..51a7e9133e 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -502,16 +502,28 @@ static int igb_post_load(void *opaque, int version_id) return igb_core_post_load(&s->core); } =20 -static const VMStateDescription igb_vmstate_tx =3D { - .name =3D "igb-tx", +static const VMStateDescription igb_vmstate_tx_ctx =3D { + .name =3D "igb-tx-ctx", .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_UINT16(vlan, struct igb_tx), - VMSTATE_UINT16(mss, struct igb_tx), - VMSTATE_BOOL(tse, struct igb_tx), - VMSTATE_BOOL(ixsm, struct igb_tx), - VMSTATE_BOOL(txsm, struct igb_tx), + VMSTATE_UINT32(vlan_macip_lens, struct e1000_adv_tx_context_desc), + VMSTATE_UINT32(seqnum_seed, struct e1000_adv_tx_context_desc), + VMSTATE_UINT32(type_tucmd_mlhl, struct e1000_adv_tx_context_desc), + VMSTATE_UINT32(mss_l4len_idx, struct e1000_adv_tx_context_desc), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription igb_vmstate_tx =3D { + .name =3D "igb-tx", + .version_id =3D 2, + .minimum_version_id =3D 2, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT_ARRAY(ctx, struct igb_tx, 2, 0, igb_vmstate_tx_ctx, + struct e1000_adv_tx_context_desc), + VMSTATE_UINT32(first_cmd_type_len, struct igb_tx), + VMSTATE_UINT32(first_olinfo_status, struct igb_tx), VMSTATE_BOOL(first, struct igb_tx), VMSTATE_BOOL(skip_cp, struct igb_tx), VMSTATE_END_OF_LIST() diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index a7c7bfdc75..7708333c2a 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -389,8 +389,10 @@ igb_rss_parse_packet(IGBCore *core, struct NetRxPkt *p= kt, bool tx, static bool igb_setup_tx_offloads(IGBCore *core, struct igb_tx *tx) { - if (tx->tse) { - if (!net_tx_pkt_build_vheader(tx->tx_pkt, true, true, tx->mss)) { + if (tx->first_cmd_type_len & E1000_ADVTXD_DCMD_TSE) { + uint32_t idx =3D (tx->first_olinfo_status >> 4) & 1; + uint32_t mss =3D tx->ctx[idx].mss_l4len_idx >> 16; + if (!net_tx_pkt_build_vheader(tx->tx_pkt, true, true, mss)) { return false; } =20 @@ -399,13 +401,13 @@ igb_setup_tx_offloads(IGBCore *core, struct igb_tx *t= x) return true; } =20 - if (tx->txsm) { + if (tx->first_olinfo_status & E1000_ADVTXD_POTS_TXSM) { if (!net_tx_pkt_build_vheader(tx->tx_pkt, false, true, 0)) { return false; } } =20 - if (tx->ixsm) { + if (tx->first_olinfo_status & E1000_ADVTXD_POTS_IXSM) { net_tx_pkt_update_ip_hdr_checksum(tx->tx_pkt); } =20 @@ -527,7 +529,7 @@ igb_process_tx_desc(IGBCore *core, { struct e1000_adv_tx_context_desc *tx_ctx_desc; uint32_t cmd_type_len; - uint32_t olinfo_status; + uint32_t idx; uint64_t buffer_addr; uint16_t length; =20 @@ -538,20 +540,19 @@ igb_process_tx_desc(IGBCore *core, E1000_ADVTXD_DTYP_DATA) { /* advanced transmit data descriptor */ if (tx->first) { - olinfo_status =3D le32_to_cpu(tx_desc->read.olinfo_status); - - tx->tse =3D !!(cmd_type_len & E1000_ADVTXD_DCMD_TSE); - tx->ixsm =3D !!(olinfo_status & E1000_ADVTXD_POTS_IXSM); - tx->txsm =3D !!(olinfo_status & E1000_ADVTXD_POTS_TXSM); - + tx->first_cmd_type_len =3D cmd_type_len; + tx->first_olinfo_status =3D le32_to_cpu(tx_desc->read.olin= fo_status); tx->first =3D false; } } else if ((cmd_type_len & E1000_ADVTXD_DTYP_CTXT) =3D=3D E1000_ADVTXD_DTYP_CTXT) { /* advanced transmit context descriptor */ tx_ctx_desc =3D (struct e1000_adv_tx_context_desc *)tx_desc; - tx->vlan =3D le32_to_cpu(tx_ctx_desc->vlan_macip_lens) >> 16; - tx->mss =3D le32_to_cpu(tx_ctx_desc->mss_l4len_idx) >> 16; + idx =3D (le32_to_cpu(tx_ctx_desc->mss_l4len_idx) >> 4) & 1; + tx->ctx[idx].vlan_macip_lens =3D le32_to_cpu(tx_ctx_desc->vlan= _macip_lens); + tx->ctx[idx].seqnum_seed =3D le32_to_cpu(tx_ctx_desc->seqnum_s= eed); + tx->ctx[idx].type_tucmd_mlhl =3D le32_to_cpu(tx_ctx_desc->type= _tucmd_mlhl); + tx->ctx[idx].mss_l4len_idx =3D le32_to_cpu(tx_ctx_desc->mss_l4= len_idx); return; } else { /* unknown descriptor type */ @@ -575,8 +576,10 @@ igb_process_tx_desc(IGBCore *core, if (cmd_type_len & E1000_TXD_CMD_EOP) { if (!tx->skip_cp && net_tx_pkt_parse(tx->tx_pkt)) { if (cmd_type_len & E1000_TXD_CMD_VLE) { - net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, tx->vlan, - core->mac[VET] & 0xffff); + idx =3D (tx->first_olinfo_status >> 4) & 1; + uint16_t vlan =3D tx->ctx[idx].vlan_macip_lens >> 16; + uint16_t vet =3D core->mac[VET] & 0xffff; + net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, vlan, vet); } if (igb_tx_pkt_send(core, tx, queue_index)) { igb_on_tx_done_update_stats(core, tx->tx_pkt); @@ -4024,11 +4027,7 @@ static void igb_reset(IGBCore *core, bool sw) for (i =3D 0; i < ARRAY_SIZE(core->tx); i++) { tx =3D &core->tx[i]; net_tx_pkt_reset(tx->tx_pkt); - tx->vlan =3D 0; - tx->mss =3D 0; - tx->tse =3D false; - tx->ixsm =3D false; - tx->txsm =3D false; + memset(tx->ctx, 0, sizeof(tx->ctx)); tx->first =3D true; tx->skip_cp =3D false; } diff --git a/hw/net/igb_core.h b/hw/net/igb_core.h index 814c1e264b..8914e0b801 100644 --- a/hw/net/igb_core.h +++ b/hw/net/igb_core.h @@ -72,11 +72,9 @@ struct IGBCore { QEMUTimer *autoneg_timer; =20 struct igb_tx { - uint16_t vlan; /* VLAN Tag */ - uint16_t mss; /* Maximum Segment Size */ - bool tse; /* TCP/UDP Segmentation Enable */ - bool ixsm; /* Insert IP Checksum */ - bool txsm; /* Insert TCP/UDP Checksum */ + struct e1000_adv_tx_context_desc ctx[2]; + uint32_t first_cmd_type_len; + uint32_t first_olinfo_status; =20 bool first; bool skip_cp; --=20 2.39.2 From nobody Tue Feb 10 19:49:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1679670054; cv=none; d=zohomail.com; s=zohoarc; b=VEMHVZ+fz8LhpfBAt+DiajjErWdn/pM94jLx2HnVvpVs8P3Nmkic4XlgqBW4ZxE8RlZlLJ7I53x7YIXQlMEYusHFRx5GRVuKeIn5Tt3iHrhg+9gyADablyy3TOE6JRuu/wFr540tvU4NqMbFRKuOVHhW2Cl31xKzD3N2/bKp+XQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679670054; 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=+8gAoCq9svhNvT0uN2j6sX7fDer4Kg0xH49mLwsRo18=; b=BOSynJs5ThfhX2QgNO0GahBumcuXR/QfKLUSJf/FLXVWa2vRyZVGQIOFbgQgK7PvQbkB1Yy+B5wShz6MlnQpBfG/e/Nl8pleJSzqSFQLbaDPTyGYklbQvgYOGgjuP+bsAXeONKWirUWp93IIOqYXfoQxxpK/I93B9b/pL/LrZCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679670054250585.9939390174889; Fri, 24 Mar 2023 08:00:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfgzU-0006as-FH; Fri, 24 Mar 2023 08:57:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfgzQ-0006aS-E6 for qemu-devel@nongnu.org; Fri, 24 Mar 2023 08:57:52 -0400 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfgz0-0004UE-2o for qemu-devel@nongnu.org; Fri, 24 Mar 2023 08:57:52 -0400 Received: by mail-oi1-x22d.google.com with SMTP id w133so1204268oib.1 for ; Fri, 24 Mar 2023 05:57:25 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id h5-20020a170902748500b001963bc7bdb8sm13785614pll.274.2023.03.24.02.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 02:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; t=1679662635; 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=+8gAoCq9svhNvT0uN2j6sX7fDer4Kg0xH49mLwsRo18=; b=e8K8jZzmKQ8cZzw2IiZ8XVT/KdD+WgOumUTt+0PpsCv1C/QvXO8mEsPy62NlfWGfto lat3CJwfza1qwvTKvXQcw0dhMmGbyJJtpolZbWB0bYiH9csE5GMaZh376UhaO69jM1jp qPtU39vYE//VLAAaeT5KcVdzSU+eJH8b52pEiNGtIepcMqoqTmVQqFvfFLatU8lFDC8I 9eo87t1oytaNFJSszSdhUWaPHBHyyMiVl00OfUiKndawhA9qCNNVmZalecOFjzQ22S3Q ZY67cPfp+Z/MqtoMixlxjvvhczMQIEzGGo2SWyAorvzeQB1NfnWbGpT1udJiJ74Eg5ms Igpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679662635; 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=+8gAoCq9svhNvT0uN2j6sX7fDer4Kg0xH49mLwsRo18=; b=g1iVZ1IayDr0pPaPt9pD5RgYzPg/XyNi+6BQVE2ipesG3SB9/AuC7MDIK1qZnU10Pe +qVKIsLGBc9s8L5h9xwkjWIh8J0SKpC4wHe9Fq4n56ZuIbjO2N/kVuRs98dtvYub7kos 5+P/Shs/kBkI+g+faqGSR3Ys6T+E7Zl0kOFsamCj/fnrpW4Mo34CNynnGUQKpMD9BLot wwfVKtrt5v42LdSXQkY4FgOYwYSMRzbTWIKnXw7FlNQd06JG5xTTLMtJE6c4xnWLMRFx y/hD3Ic/MB9lhKAm+SKsVut6n1KmpZudkpwZ1ZYuKSP9wjaTv0vAaBhy1tKTovN+dfFU c7PA== X-Gm-Message-State: AO0yUKWbRA6BIbhrd6q21guEjnaWbKdEQ4csX4kU4Ou8LD8u1P1xJjyE LQlXtn2mEhPqI0ZCgWtgkwqFw4lvObj+FoehoZZDow== X-Google-Smtp-Source: AKy350ZohLsJTHwiWEzP6yp1/aMxDrxPNcW8okkgLYf1aN2vj1tutghfqDmxhn9cLUvAAXkje9Ha3w== X-Received: by 2002:a17:903:110e:b0:1a1:f5dd:2dd5 with SMTP id n14-20020a170903110e00b001a1f5dd2dd5mr2908594plh.13.1679651703169; Fri, 24 Mar 2023 02:55:03 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Dmitry Fleytman , Sriram Yagnaraman , Jason Wang , Akihiko Odaki Subject: [PATCH for 8.0 2/4] igb: Fix DMA requester specification for Tx packet Date: Fri, 24 Mar 2023 18:54:32 +0900 Message-Id: <20230324095434.44973-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324095434.44973-1-akihiko.odaki@daynix.com> References: <20230324095434.44973-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::22d; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x22d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1679670056727100003 Content-Type: text/plain; charset="utf-8" igb used to specify the PF as DMA requester when reading Tx packets. This made Tx requests from VFs to be performed on the address space of the PF, defeating the purpose of SR-IOV. Add some logic to change the requester depending on the queue, which can be assigned to a VF. Fixes: 3a977deebe ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki --- hw/net/e1000e_core.c | 6 +++--- hw/net/igb_core.c | 13 ++++++++----- hw/net/net_tx_pkt.c | 3 ++- hw/net/net_tx_pkt.h | 3 ++- hw/net/vmxnet3.c | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 4d9679ca0b..c0c09b6965 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -765,7 +765,7 @@ e1000e_process_tx_desc(E1000ECore *core, } =20 tx->skip_cp =3D false; - net_tx_pkt_reset(tx->tx_pkt); + net_tx_pkt_reset(tx->tx_pkt, core->owner); =20 tx->sum_needed =3D 0; tx->cptse =3D 0; @@ -3447,7 +3447,7 @@ e1000e_core_pci_uninit(E1000ECore *core) qemu_del_vm_change_state_handler(core->vmstate); =20 for (i =3D 0; i < E1000E_NUM_QUEUES; i++) { - net_tx_pkt_reset(core->tx[i].tx_pkt); + net_tx_pkt_reset(core->tx[i].tx_pkt, core->owner); net_tx_pkt_uninit(core->tx[i].tx_pkt); } =20 @@ -3572,7 +3572,7 @@ static void e1000e_reset(E1000ECore *core, bool sw) e1000x_reset_mac_addr(core->owner_nic, core->mac, core->permanent_mac); =20 for (i =3D 0; i < ARRAY_SIZE(core->tx); i++) { - net_tx_pkt_reset(core->tx[i].tx_pkt); + net_tx_pkt_reset(core->tx[i].tx_pkt, core->owner); memset(&core->tx[i].props, 0, sizeof(core->tx[i].props)); core->tx[i].skip_cp =3D false; } diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 7708333c2a..78d30738e6 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -523,6 +523,7 @@ igb_on_tx_done_update_stats(IGBCore *core, struct NetTx= Pkt *tx_pkt) =20 static void igb_process_tx_desc(IGBCore *core, + PCIDevice *dev, struct igb_tx *tx, union e1000_adv_tx_desc *tx_desc, int queue_index) @@ -588,7 +589,7 @@ igb_process_tx_desc(IGBCore *core, =20 tx->first =3D true; tx->skip_cp =3D false; - net_tx_pkt_reset(tx->tx_pkt); + net_tx_pkt_reset(tx->tx_pkt, dev); } } =20 @@ -803,6 +804,8 @@ igb_start_xmit(IGBCore *core, const IGB_TxRing *txr) d =3D core->owner; } =20 + net_tx_pkt_reset(txr->tx->tx_pkt, d); + while (!igb_ring_empty(core, txi)) { base =3D igb_ring_head_descr(core, txi); =20 @@ -811,7 +814,7 @@ igb_start_xmit(IGBCore *core, const IGB_TxRing *txr) trace_e1000e_tx_descr((void *)(intptr_t)desc.read.buffer_addr, desc.read.cmd_type_len, desc.wb.status); =20 - igb_process_tx_desc(core, txr->tx, &desc, txi->idx); + igb_process_tx_desc(core, d, txr->tx, &desc, txi->idx); igb_ring_advance(core, txi, 1); eic |=3D igb_txdesc_writeback(core, base, &desc, txi); } @@ -3828,7 +3831,7 @@ igb_core_pci_realize(IGBCore *core, core->vmstate =3D qemu_add_vm_change_state_handler(igb_vm_state_change= , core); =20 for (i =3D 0; i < IGB_NUM_QUEUES; i++) { - net_tx_pkt_init(&core->tx[i].tx_pkt, core->owner, E1000E_MAX_TX_FR= AGS); + net_tx_pkt_init(&core->tx[i].tx_pkt, NULL, E1000E_MAX_TX_FRAGS); } =20 net_rx_pkt_init(&core->rx_pkt); @@ -3853,7 +3856,7 @@ igb_core_pci_uninit(IGBCore *core) qemu_del_vm_change_state_handler(core->vmstate); =20 for (i =3D 0; i < IGB_NUM_QUEUES; i++) { - net_tx_pkt_reset(core->tx[i].tx_pkt); + net_tx_pkt_reset(core->tx[i].tx_pkt, NULL); net_tx_pkt_uninit(core->tx[i].tx_pkt); } =20 @@ -4026,7 +4029,7 @@ static void igb_reset(IGBCore *core, bool sw) =20 for (i =3D 0; i < ARRAY_SIZE(core->tx); i++) { tx =3D &core->tx[i]; - net_tx_pkt_reset(tx->tx_pkt); + net_tx_pkt_reset(tx->tx_pkt, NULL); memset(tx->ctx, 0, sizeof(tx->ctx)); tx->first =3D true; tx->skip_cp =3D false; diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 986a3adfe9..cb606cc84b 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -443,7 +443,7 @@ void net_tx_pkt_dump(struct NetTxPkt *pkt) #endif } =20 -void net_tx_pkt_reset(struct NetTxPkt *pkt) +void net_tx_pkt_reset(struct NetTxPkt *pkt, PCIDevice *pci_dev) { int i; =20 @@ -467,6 +467,7 @@ void net_tx_pkt_reset(struct NetTxPkt *pkt) pkt->raw[i].iov_len, DMA_DIRECTION_TO_DEVICE, 0); } } + pkt->pci_dev =3D pci_dev; pkt->raw_frags =3D 0; =20 pkt->hdr_len =3D 0; diff --git a/hw/net/net_tx_pkt.h b/hw/net/net_tx_pkt.h index f57b4e034b..e5ce6f20bc 100644 --- a/hw/net/net_tx_pkt.h +++ b/hw/net/net_tx_pkt.h @@ -148,9 +148,10 @@ void net_tx_pkt_dump(struct NetTxPkt *pkt); * reset tx packet private context (needed to be called between packets) * * @pkt: packet + * @dev: PCI device processing the next packet * */ -void net_tx_pkt_reset(struct NetTxPkt *pkt); +void net_tx_pkt_reset(struct NetTxPkt *pkt, PCIDevice *dev); =20 /** * Send packet to qemu. handles sw offloads if vhdr is not supported. diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 1068b80868..f7b874c139 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -678,7 +678,7 @@ static void vmxnet3_process_tx_queue(VMXNET3State *s, i= nt qidx) vmxnet3_complete_packet(s, qidx, txd_idx); s->tx_sop =3D true; s->skip_current_tx_pkt =3D false; - net_tx_pkt_reset(s->tx_pkt); + net_tx_pkt_reset(s->tx_pkt, PCI_DEVICE(s)); } } } @@ -1159,7 +1159,7 @@ static void vmxnet3_deactivate_device(VMXNET3State *s) { if (s->device_active) { VMW_CBPRN("Deactivating vmxnet3..."); - net_tx_pkt_reset(s->tx_pkt); + net_tx_pkt_reset(s->tx_pkt, PCI_DEVICE(s)); net_tx_pkt_uninit(s->tx_pkt); net_rx_pkt_uninit(s->rx_pkt); s->device_active =3D false; --=20 2.39.2 From nobody Tue Feb 10 19:49:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1679672153; cv=none; d=zohomail.com; s=zohoarc; b=K7fwMHVHJblK5KUrCMKeQj437bT1Q7DZVyb2YVC801QhcUW38/b4nhuTjbhJuDDrftv3BY+ZhtrMEUVGfrJbd6fm3xVW3l/GVnu1LRJ/D44hMq1WV/fdX8yXzkaFFoZbaIzkQuyD9x0f/xpJHLyNaOC3ywd4O7DE4O/hGZqMYdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679672153; 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=n1R+aEVDBOJIlT2PKegpb/El2YxGuu/QJmhVuq/d/KI=; b=UAYOgZ020ofCQmnrA9mSYQJdR4tZFubCXsGH+yNxhK36BJ8MGyyFbegpUCTLe7VXHJ7zd7RsA4WwsfXY6SIFkFXudmz4NDF184nzJHLC4RU1yTt+HxZV2zrU3r45oc51U5PMJ6DOmdhAm8zgcabjZfSm0VY5IbzVpta9klQ5AcA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679672153491802.811891071322; Fri, 24 Mar 2023 08:35:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfeGB-0005b5-JO; Fri, 24 Mar 2023 06:02:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfeGA-0005ax-D8 for qemu-devel@nongnu.org; Fri, 24 Mar 2023 06:02:58 -0400 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfeG3-0004x6-SE for qemu-devel@nongnu.org; Fri, 24 Mar 2023 06:02:58 -0400 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-5447d217bc6so23904827b3.7 for ; Fri, 24 Mar 2023 03:02:51 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id h5-20020a170902748500b001963bc7bdb8sm13785614pll.274.2023.03.24.02.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 02:55:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; t=1679652169; 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=n1R+aEVDBOJIlT2PKegpb/El2YxGuu/QJmhVuq/d/KI=; b=A232QgSpaVpGvT6bzpssEj+Zzvj/Ppv0zhux13tfaqasWzCccUULldCnBBAizFGgEo y8W0YUdTnZFYFD4ycwlsVsI/acPNgiQBD/09V9h/g1YOxJ+hn+v5H3yX+uVR6mE3Mwrk OSTY7QhKqCuvcTB32tgiy2wTgYoTsUdvQEXlF8nbMaXX4cSkDxdLFz/Ucx8WHoKs/n+F wJhEQ/FEjJJnfxXhZ0uMtsMzS+GKXTYIhttZENb9DglmvxHSktpyTJQ33HEE43fC2clg Nx49V6pcehn51GQhPlpIIjXAY/uJ5lTfJ9t9r+I8g6fRPtQk62sCHUsTPW44Rl5oO0qS ZgRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679652169; 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=n1R+aEVDBOJIlT2PKegpb/El2YxGuu/QJmhVuq/d/KI=; b=GrlTYHnK065lJJceLxF85M6Y99xwJyvO6BLiKhyQ6gIk+Lco7gOURydyKYtRpQArWw qetV1DKnjgRb7P+e98fHXdjpznBp7NskwRE07fjk0+f/JLDXhxto9nZIpVCnMbEzGQyy Hnc9xfrI/zE9eJ/8hRJbaVdtYhWium/+Os2zIN/jd/PpFxEpEnaiS8OWakqgITBp6wa1 gm/PUkEfgnzJeGFEUAal2L+Fc5TZJWVl8XumF9PaCn+O250mu0W5Klc2z1GDdUjstG3C fNIhk6YzRg6F0GlsQiSg4ZHf1pN8oHzOI+7uN0t/yCKNZfLC1Itf2Mr5H3XwS/G3mB93 E5KQ== X-Gm-Message-State: AAQBX9dIZBESp7Qpxc5WM7mQcs7Xmur6PZNvEOlNkj5DIHYoXzpTlNuW VveoKIaB5bfaTYgWt8I/lZ2Yg6Us9jsFgrMt7uF9Hw== X-Google-Smtp-Source: AKy350Y0eTw+pJPsfHyZVpZ/BFf2Gr+pckqbA497JXHXVanWK5neK4/o07ZoqP/BAWgD0QLTDm2TWQ== X-Received: by 2002:a17:902:ec91:b0:1a1:dd3a:7509 with SMTP id x17-20020a170902ec9100b001a1dd3a7509mr2368911plg.48.1679651704969; Fri, 24 Mar 2023 02:55:04 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Dmitry Fleytman , Sriram Yagnaraman , Jason Wang , Akihiko Odaki Subject: [PATCH for 8.0 3/4] hw/net/net_tx_pkt: Ignore ECN bit Date: Fri, 24 Mar 2023 18:54:33 +0900 Message-Id: <20230324095434.44973-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324095434.44973-1-akihiko.odaki@daynix.com> References: <20230324095434.44973-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1131; envelope-from=akihiko.odaki@daynix.com; helo=mail-yw1-x1131.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1679672154619100001 Content-Type: text/plain; charset="utf-8" No segmentation should be performed if gso type is VIRTIO_NET_HDR_GSO_NONE even if ECN bit is set. Fixes: e263cd49c7 ("Packet abstraction for VMWARE network devices") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1544 Signed-off-by: Akihiko Odaki --- hw/net/net_tx_pkt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index cb606cc84b..efe80b1a80 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -796,11 +796,13 @@ bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, boo= l offload, { assert(pkt); =20 + uint8_t gso_type =3D pkt->virt_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN; + /* * Since underlying infrastructure does not support IP datagrams longer * than 64K we should drop such packets and don't even try to send */ - if (VIRTIO_NET_HDR_GSO_NONE !=3D pkt->virt_hdr.gso_type) { + if (VIRTIO_NET_HDR_GSO_NONE !=3D gso_type) { if (pkt->payload_len > ETH_MAX_IP_DGRAM_LEN - pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len) { @@ -808,7 +810,7 @@ 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 || 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, --=20 2.39.2 From nobody Tue Feb 10 19:49:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1679669299; cv=none; d=zohomail.com; s=zohoarc; b=EUDuAv66jom3Z6lVTTJiVicDZ2wegKEvrm/kjxwDLYGzJxIDz2o63IbANLs/oBwFP4e/0QfRse64DihjQO07mWIMRc2qzLL+u/15j1AKZN2cQLozES5dLCvAeBHlnM1+RMe0Gzx92vedFLbrMIDVN29pprdxafQ5U9qutZqY+/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679669299; 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=nPrC4YQ9uSCz+WV5O3PwaouONcUDnlpw4YEX3MYIyy8=; b=LBA0exaGDRps4LBuwUsH1II7Si7JRQaSf0OtjppLOiDRxmfjzMb7SgQmDzaj4g+AxJqf2JXou+aUnIuv+Rksuz51/FI3Zn8dP86X3StlDa8qCCeaF8CuvyE96vGE+ohBdpBY04VU2Ndazn3KWUDgCXD/rRuqRWdnKenwetqFCiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16796692992551014.7253633139203; Fri, 24 Mar 2023 07:48:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfe9j-0005I6-Px; Fri, 24 Mar 2023 05:56:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfe9h-0005Hj-LN for qemu-devel@nongnu.org; Fri, 24 Mar 2023 05:56:17 -0400 Received: from mail-pj1-f53.google.com ([209.85.216.53]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfe9H-0003RN-QW for qemu-devel@nongnu.org; Fri, 24 Mar 2023 05:56:17 -0400 Received: by mail-pj1-f53.google.com with SMTP id a16so1059302pjs.4 for ; Fri, 24 Mar 2023 02:55:49 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id h5-20020a170902748500b001963bc7bdb8sm13785614pll.274.2023.03.24.02.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 02:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; t=1679651711; 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=nPrC4YQ9uSCz+WV5O3PwaouONcUDnlpw4YEX3MYIyy8=; b=Tnq6U9ZLZUtGwWK6O7g9blXcFscXaSV/deNUfbj/yCu/eb145rQ1qiNwg8qLuRVWEB zMPsyLPP5GagHScO2Qj8AO7rRhy6822dx/PxTeN3ee/x1bYjpA0UqgTB1Osbxdmv3xdY 6rSCgDA5fyltEPNp0xZ1ZPT1I/yut1b+Wez6zvP61XRcpZDIZi8DyNFCC/WtPl4b4V3h rDKZZxbV7Oly8v9p3MJbjLp/jJWvPaq76Boyrr/ipH3AxpL9HX/wHu+uevG5P6MhcqCB IOtEGVod1r/1BbMvm6N1rq1qIvMaIeIEohn60WfIOjVre0h+16LYUPenKycQvfs8EBKK YjVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679651711; 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=nPrC4YQ9uSCz+WV5O3PwaouONcUDnlpw4YEX3MYIyy8=; b=jrVLomvz0YxYfJllHeaTahPgjEJHSD1jk4OqBgKOSPOzxOrC9czcoUT7eiV+bPjYRR KONqWuVsJzkmtmQ+BkIuK9niirBNBTi576RNen7MpciE5D0Kpq08gtEx+GGsJIE/9r8D rlXralxyCb7MzPSbh+xoYDeSMckEznS34nEhyfdrwvkUWYpth6f2yJnq6+drkkpbR+ma TnNLF/S/cGavmGk6feU2y96j4JZlit3UZaWGVZp4k7q6i+hy7TnBPjkOp8RmHSqqg7EF XE+jrjw00e5apCMfLewl1bForM68Sf4Cs/nUiDK3GZhcJYkds+iCCCeJt4IvBmjFVX5R q2Nw== X-Gm-Message-State: AAQBX9dz5shMpBF0w33Pb5yW5lFbcMOlLoteCvHIoHJnHGzhe2V1NjUe 2WCTRCghWVRI4W/jMrnKpMP6GI66BjFKpCriraLgVg== X-Google-Smtp-Source: AKy350YuuiC6/3W4vhLDAqwgDlDbfsfl17Hv2KFEKXieZetxy/rGqz+MekEij/uqugtTJRwRcT7P6w== X-Received: by 2002:a17:902:e545:b0:1a1:bede:5e4a with SMTP id n5-20020a170902e54500b001a1bede5e4amr2749243plf.49.1679651707057; Fri, 24 Mar 2023 02:55:07 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Dmitry Fleytman , Sriram Yagnaraman , Jason Wang , Akihiko Odaki Subject: [PATCH for 8.0 4/4] hw/net/net_tx_pkt: Align l3_hdr Date: Fri, 24 Mar 2023 18:54:34 +0900 Message-Id: <20230324095434.44973-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324095434.44973-1-akihiko.odaki@daynix.com> References: <20230324095434.44973-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=209.85.216.53; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-f53.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, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1679669301120100003 Content-Type: text/plain; charset="utf-8" Align the l3_hdr member of NetTxPkt by defining it as a union of ip_header, ip6_header, and an array of octets. Fixes: e263cd49c7 ("Packet abstraction for VMWARE network devices") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1544 Signed-off-by: Akihiko Odaki --- hw/net/net_tx_pkt.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index efe80b1a80..8dc8568ba2 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -43,7 +43,11 @@ struct NetTxPkt { struct iovec *vec; =20 uint8_t l2_hdr[ETH_MAX_L2_HDR_LEN]; - uint8_t l3_hdr[ETH_MAX_IP_DGRAM_LEN]; + union { + struct ip_header ip; + struct ip6_header ip6; + uint8_t octets[ETH_MAX_IP_DGRAM_LEN]; + } l3_hdr; =20 uint32_t payload_len; =20 @@ -89,16 +93,14 @@ void net_tx_pkt_update_ip_hdr_checksum(struct NetTxPkt = *pkt) { uint16_t csum; assert(pkt); - struct ip_header *ip_hdr; - ip_hdr =3D pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base; =20 - ip_hdr->ip_len =3D cpu_to_be16(pkt->payload_len + + pkt->l3_hdr.ip.ip_len =3D cpu_to_be16(pkt->payload_len + pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len); =20 - ip_hdr->ip_sum =3D 0; - csum =3D net_raw_checksum((uint8_t *)ip_hdr, + pkt->l3_hdr.ip.ip_sum =3D 0; + csum =3D net_raw_checksum(pkt->l3_hdr.octets, pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len); - ip_hdr->ip_sum =3D cpu_to_be16(csum); + pkt->l3_hdr.ip.ip_sum =3D cpu_to_be16(csum); } =20 void net_tx_pkt_update_ip_checksums(struct NetTxPkt *pkt) @@ -832,15 +834,14 @@ void net_tx_pkt_fix_ip6_payload_len(struct NetTxPkt *= pkt) { struct iovec *l2 =3D &pkt->vec[NET_TX_PKT_L2HDR_FRAG]; if (eth_get_l3_proto(l2, 1, l2->iov_len) =3D=3D ETH_P_IPV6) { - struct ip6_header *ip6 =3D (struct ip6_header *) pkt->l3_hdr; /* * TODO: if qemu would support >64K packets - add jumbo option che= ck * something like that: * 'if (ip6->ip6_plen =3D=3D 0 && !has_jumbo_option(ip6)) {' */ - if (ip6->ip6_plen =3D=3D 0) { + if (pkt->l3_hdr.ip6.ip6_plen =3D=3D 0) { if (pkt->payload_len <=3D ETH_MAX_IP_DGRAM_LEN) { - ip6->ip6_plen =3D htons(pkt->payload_len); + pkt->l3_hdr.ip6.ip6_plen =3D htons(pkt->payload_len); } /* * TODO: if qemu would support >64K packets --=20 2.39.2