From nobody Mon Apr 29 19:19:41 2024 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=1679458912; cv=none; d=zohomail.com; s=zohoarc; b=FJYWDwZSTzYem1e1WlXzeVYk/7XmS7YLCS3WrQDdLpjmkDPXSnQYIsVKDc3eJbagWz+nXsMUeIumNnPFw61QRWvL/aNbhtLvDrYsj6jcnSul/62mMWI+zh0m4VpccSmdpqnFltNGwbWehIxaBk9HjPqSnjlIby8FSasTySC3YuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679458912; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject; bh=9L2/5sYCp+YP7XCsKeBzXQzihKkwgSFDtEJfzakkyRY=; b=YbQmvcxRynwtmGKd7pVhhNCdAbeMU+EAWPWorKNXfo2/yDyhOKvismpZGM3sHFEx2C/sS75byIQUFXo2I+StaBkXXKLxQwaaWOPu2S2d3WPTy3BJi8/4em5qjmq94DYZCjgH2lEXkwAGbt9AUoYEE5MyRssM49hebTNq0hdfcvs= 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 1679458912403448.6213077445334; Tue, 21 Mar 2023 21:21:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pepy6-0000IK-KD; Wed, 22 Mar 2023 00:20:58 -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 1pepy5-0000Hs-32 for qemu-devel@nongnu.org; Wed, 22 Mar 2023 00:20:57 -0400 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 1pepy3-0006Bx-3q for qemu-devel@nongnu.org; Wed, 22 Mar 2023 00:20:56 -0400 Received: by mail-pj1-x1034.google.com with SMTP id e15-20020a17090ac20f00b0023d1b009f52so22461181pjt.2 for ; Tue, 21 Mar 2023 21:20:54 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id d13-20020aa78e4d000000b00622e01989cbsm9302760pfr.176.2023.03.21.21.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 21:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; t=1679458853; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9L2/5sYCp+YP7XCsKeBzXQzihKkwgSFDtEJfzakkyRY=; b=HeLXSOjnIXvKdN0RW6FCXQzIwFiqwM3X5cpUZMPU7MoJXUhTSFLpcT+H5B988aHeTz p9bRjPmkLbejLgEf+59LA64HuXZWmA2az7NcpIujjzbpoATYjSdsGzNEapGywMLdtfUr Sks2Tzk4a7QwrS+HTiFXFEjTBqcyBRmL6jUH1jvbMVnMZ5/0oUpQzjpYGSu1pa/7twPf 3+z5zapwi51/JE/bG80T8eyDt+XjCbgEvIyT2t9jGYADfUnPt5sq7KXJOLzsG1W2oE+A YEAsu4APD0g4LDFrP7YMV3696KZc/t8mQtT3YYnH0jk9mxb+rhdqwsoziGRHP/d4Fo// bZ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679458853; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9L2/5sYCp+YP7XCsKeBzXQzihKkwgSFDtEJfzakkyRY=; b=avSXlEISRYrqPNzJ2vIAJKiiQIOUss+wM6bRyJ3PQy6GJ/2zGQXraMHhj+8XUMu9uz HOql3UdmKUFRmc9tcpN6y+mHFuY/gd0xe6s3+qmFebk8Htq0YrQ1gjyLOEV/crhY2JgV F5xfKriAj4jqAETcLrcDZ0RYtEbIUmprF6YZDAmiQUXW5hl/HswU9wYsgsHS6RWHlRcZ SWknLaQdOzKpDO7Y2iHPQEmnp14MRCXTlfoZrQerQOsjoDLSU+EwVnSgJoFGI9a5TxNZ hiPY/sPMu59m4lbuCfHRquQnU21yAxcs0WZr2cUq9syVDv+HjVPrY/Sclneoqa5lWATa em7Q== X-Gm-Message-State: AO0yUKWLZ7v6+Nd091eJrdgM0j2sKSw+Kkf2vTKQ7rJ7jSzoNjDK4VLD 6mFR6VRHgRTpeueHXIMfCRrUtluZhhMhHwfF7wXMig== X-Google-Smtp-Source: AK7set+RRaPxiobRDZ63OoGyxac2RLy+p25uWnbc4uBboy30HC4J5R1lRljFGGi+wPN/IgobZALChw== X-Received: by 2002:a05:6a20:c754:b0:da:6dd4:84a2 with SMTP id hj20-20020a056a20c75400b000da6dd484a2mr4165303pzb.13.1679458853048; Tue, 21 Mar 2023 21:20:53 -0700 (PDT) From: Akihiko Odaki To: Cc: "qemu-devel @ nongnu . org" , Jason Wang , Dmitry Fleytman , "quintela @ redhat . com" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sriram Yagnaraman , Akihiko Odaki Subject: [PATCH for 8.0 v2] igb: Save more Tx states Date: Wed, 22 Mar 2023 13:20:44 +0900 Message-Id: <20230322042044.25136-1-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.39.2 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::1034; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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: 1679458914482100001 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 --- V1 -> V2: Removed references to old variables in igb_reset() Supersedes: <20230316155707.27007-1-akihiko.odaki@daynix.com> hw/net/igb.c | 25 ++++++++++++++++++------- hw/net/igb_core.c | 39 +++++++++++++++++++-------------------- hw/net/igb_core.h | 8 +++----- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/hw/net/igb.c b/hw/net/igb.c index c6d753df87..7c05896325 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -502,16 +502,27 @@ 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), + } +}; + +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