From nobody Tue Feb 10 19:50:29 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