From nobody Wed Feb 11 00:55:57 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=1682505870; cv=none; d=zohomail.com; s=zohoarc; b=NH0jMOl1pcsrw/C+Z1aeT8WrGSic4+YvxBuQ3851BGSoGTg8tTLBQcNufCV2pjsg9R6/MogkZfgK3CcFZvwDnM3QsHVeMjcmnI+Jy+CWntcoXfaaJWA4N+1B2P1IbDT18rL0sVh7McKhCJrUhDQxhTBvCycIemuhioj73d/XB/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682505870; 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=6M3XBA2ZnKRrmKvfDf9nkh3S989gOSnRI0c+3tpxFkM=; b=f6K7ZzA1wBSfzZ9oZv7rJKiTTaFVb3/35LS+nMDGpHdoFYHH1JeLjwVlKQaG6f/q1mFDLGJMq+ij1wOSFkkY1YWIg7GLbxWtjP72FiupaRfK0EVBWGoQ0WlREZWJnyH3suu6fcaggc6FrsnHJ0X0hXIMe22AqLAwcSNzmS3YLDA= 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 16825058704731010.0721283915898; Wed, 26 Apr 2023 03:44:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prcYl-0007GO-Q5; Wed, 26 Apr 2023 06:39:39 -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 1prcYj-00077a-AP for qemu-devel@nongnu.org; Wed, 26 Apr 2023 06:39:37 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1prcYh-0003ME-Fp for qemu-devel@nongnu.org; Wed, 26 Apr 2023 06:39:36 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-63b57c49c4cso5721228b3a.3 for ; Wed, 26 Apr 2023 03:39:35 -0700 (PDT) Received: from alarm.u-tokyo.ac.jp ([157.82.194.15]) by smtp.gmail.com with ESMTPSA id m11-20020a63580b000000b0051322a5aa64sm9317919pgb.3.2023.04.26.03.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 03:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1682505574; x=1685097574; 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=6M3XBA2ZnKRrmKvfDf9nkh3S989gOSnRI0c+3tpxFkM=; b=fhcfhEGXjLN3fUHeV13/EvfqIgcOkJt4fx5xSdGIpgC+qvRYNwR7yxWmT9TmZ/HRoZ jmdEFKatI1KFbzutUKSv4snfwage8GIf2JOOD0od9LwnZ632JEB9eFeKCaRU2q8cobUk 4vwywpWLCR0B5Cm9C2SOX1DGcIAc2svR1CFCC9m0kzUt+QIYA4jOCdPWwd0BEh2qYF6M zAfIe/rRnUaN9Kb6PxVOQ9ZuuRLTeuM5mFui4vSxE08eNErcuoMuFM5HfFwy6bWVTPSd E/dRwQGDrOB0DH9fvo1LYL9aPX2cCsX0I3jsHDgnO8kaZV8b5plN8VRNQ5yMIOZoOapU f9DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682505574; x=1685097574; 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=6M3XBA2ZnKRrmKvfDf9nkh3S989gOSnRI0c+3tpxFkM=; b=elD0BeXjLigewM/yaqB3PxVzqjEfnv7VEDcJUrueJCiPlwiNKrLsii/vum2rb1uAIl waLRaEc6M2rbb+uVnOf7cPILiRFFuNRB9Ky7JlJ6amfQ67+VN8oS04UjBWAfx/auglWq eM7EPeHHPh3S0UvIx+PY9DqnQ38o4jMg0EchJaLRklxipiUNPY92etjlWpzJCDL9uckM YfThwaHHx9c3dbtjcv5+nCvwC5HbZvIVZw+aW3WwnKm92x4++SoR3WF+tUqgopQFLvrb lHxflYWfSfJoAuI5+hF6FeLweiaT5P1fifbSrZFyhLnSJeza2NTMtfIcjdYjiOA2LWh9 pZzw== X-Gm-Message-State: AC+VfDzMEYY9pV8zOSrY7Wyw+cZ7r4qXhUEPjjGYtqAA7VcFfGqj1B05 UXTMIvB/6/tnCdNfCSc/nQ7Nxg== X-Google-Smtp-Source: ACHHUZ4H1sXD5GINkuDhYMOY/Wr+7tW5euIIiXvWxermW3XRYhaWw/BobTE1H0GTZfuiUsS5MNjrrg== X-Received: by 2002:a05:6a21:587:b0:f4:7cbd:c236 with SMTP id lw7-20020a056a21058700b000f47cbdc236mr154187pzb.54.1682505574445; Wed, 26 Apr 2023 03:39:34 -0700 (PDT) From: Akihiko Odaki To: Cc: Sriram Yagnaraman , Jason Wang , Dmitry Fleytman , "Michael S . Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta , Beraldo Leal , Cleber Rosa , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, Tomasz Dzieciol , Akihiko Odaki Subject: [PATCH v4 37/48] igb: Implement Tx SCTP CSO Date: Wed, 26 Apr 2023 19:37:05 +0900 Message-Id: <20230426103716.26279-38-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230426103716.26279-1-akihiko.odaki@daynix.com> References: <20230426103716.26279-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::434; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 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.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1682505870709100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Akihiko Odaki Reviewed-by: Sriram Yagnaraman --- hw/net/net_tx_pkt.h | 8 ++++++++ hw/net/igb_core.c | 12 +++++++----- hw/net/net_tx_pkt.c | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/hw/net/net_tx_pkt.h b/hw/net/net_tx_pkt.h index 4d7233e975..0a716e74a5 100644 --- a/hw/net/net_tx_pkt.h +++ b/hw/net/net_tx_pkt.h @@ -116,6 +116,14 @@ void net_tx_pkt_update_ip_checksums(struct NetTxPkt *p= kt); */ void net_tx_pkt_update_ip_hdr_checksum(struct NetTxPkt *pkt); =20 +/** + * Calculate the SCTP checksum. + * + * @pkt: packet + * + */ +bool net_tx_pkt_update_sctp_checksum(struct NetTxPkt *pkt); + /** * get length of all populated data. * diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 95d46d6e6d..5eacf1cd8c 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -440,8 +440,9 @@ igb_tx_insert_vlan(IGBCore *core, uint16_t qn, struct i= gb_tx *tx, static bool igb_setup_tx_offloads(IGBCore *core, struct igb_tx *tx) { + uint32_t idx =3D (tx->first_olinfo_status >> 4) & 1; + 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 >> E1000_ADVTXD_MSS_SH= IFT; if (!net_tx_pkt_build_vheader(tx->tx_pkt, true, true, mss)) { return false; @@ -452,10 +453,11 @@ igb_setup_tx_offloads(IGBCore *core, struct igb_tx *t= x) return true; } =20 - if (tx->first_olinfo_status & E1000_ADVTXD_POTS_TXSM) { - if (!net_tx_pkt_build_vheader(tx->tx_pkt, false, true, 0)) { - return false; - } + if ((tx->first_olinfo_status & E1000_ADVTXD_POTS_TXSM) && + !((tx->ctx[idx].type_tucmd_mlhl & E1000_ADVTXD_TUCMD_L4T_SCTP) ? + net_tx_pkt_update_sctp_checksum(tx->tx_pkt) : + net_tx_pkt_build_vheader(tx->tx_pkt, false, true, 0))) { + return false; } =20 if (tx->first_olinfo_status & E1000_ADVTXD_POTS_IXSM) { diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index af8f77a3f0..2e5f58b3c9 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -16,6 +16,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/crc32c.h" #include "net/eth.h" #include "net/checksum.h" #include "net/tap.h" @@ -135,6 +136,23 @@ void net_tx_pkt_update_ip_checksums(struct NetTxPkt *p= kt) pkt->virt_hdr.csum_offset, &csum, sizeof(csum)); } =20 +bool net_tx_pkt_update_sctp_checksum(struct NetTxPkt *pkt) +{ + uint32_t csum =3D 0; + struct iovec *pl_start_frag =3D pkt->vec + NET_TX_PKT_PL_START_FRAG; + + if (iov_from_buf(pl_start_frag, pkt->payload_frags, 8, &csum, sizeof(c= sum)) < sizeof(csum)) { + return false; + } + + csum =3D cpu_to_le32(iov_crc32c(0xffffffff, pl_start_frag, pkt->payloa= d_frags)); + if (iov_from_buf(pl_start_frag, pkt->payload_frags, 8, &csum, sizeof(c= sum)) < sizeof(csum)) { + return false; + } + + return true; +} + static void net_tx_pkt_calculate_hdr_len(struct NetTxPkt *pkt) { pkt->hdr_len =3D pkt->vec[NET_TX_PKT_L2HDR_FRAG].iov_len + --=20 2.40.0