From nobody Tue Feb 10 19:50:16 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=1681969799; cv=none; d=zohomail.com; s=zohoarc; b=DmxdHAnetf3QG/i1Dcqq1jqNhq68fkB27fbvcFBrdWAQQlKOvgPjPANOsDrbgyDEBS5dak8/Q88HOSIqhyLJxtz1sygi0DA4oZQFmGnHyIgdznBt1qc+OzjUdl4mPSgOtzWWOzagiYg9xSvYL0lWGtR0vf5zHNpdRa7mYLh7Ncg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681969799; 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=lhHRazQ1Xyz5kEvlAe8Bgx9OM5ANAAvESgkitu1uPko=; b=ImqAzw8bSxVQ1PgF7aoAPfE2ec5oeJzfE8zNlqfz8DcSvmcbXLmYHH6MShDo23XYcHRJEX3uTWUhLo4uybBi53YycJhCNwB+vFjzSGGsqhvw6ql32mj40CflLVMhAtnChOmvyNaQ/dTj/jgUofWCkp1mPUHjWQaHBoKaG7DKQhc= 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 1681969799316369.6064584134417; Wed, 19 Apr 2023 22:49:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppNAu-0002EM-Bk; Thu, 20 Apr 2023 01:49:44 -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 1ppNAo-0001Xj-29 for qemu-devel@nongnu.org; Thu, 20 Apr 2023 01:49:39 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ppNAm-0001Uy-CK for qemu-devel@nongnu.org; Thu, 20 Apr 2023 01:49:37 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1a814fe0ddeso8063325ad.2 for ; Wed, 19 Apr 2023 22:49:32 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a17090a46cf00b00247164c1947sm2769255pjg.0.2023.04.19.22.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 22:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1681969772; x=1684561772; 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=lhHRazQ1Xyz5kEvlAe8Bgx9OM5ANAAvESgkitu1uPko=; b=H90fVT2SfgqPG+kOaqBaH4ovrZI/4vmMLGtHKZlDL0Bj4es/jcfgPt/R0yrt5ZtSnA KytOzbY6pXTXCZ5vua0Pz/Ghhjm4ZtWhACNCoG1TAqiTaRhYaVS78ONX5O+QOPIUI7u0 fdPaOGj1MVHD3eXHZSGD4bm4F0ZnUwUdxei0pH5vs3Ax42G9rgPXH2qHCT6sZ9jBGS9Z duqZoPpuNM33uw+5dr2oXVycXsg6rLej9QQJHeeiBBEqT4A2XqRpNEgPKbAVZhhXqIV/ kUMWmfaSL2L7SREFj9fSCCf0Rm7g3F8OjcqLbsdUwGtImWy0pBncN4ft3s105X/yAexz YnEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681969772; x=1684561772; 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=lhHRazQ1Xyz5kEvlAe8Bgx9OM5ANAAvESgkitu1uPko=; b=YUuRwmxmrGaxTcMVKlQpujnvaCNUP1bh+/SxK4qs8Wl7chZpHLCGYu8nzgWeAxc2dz aSNIXCSOTL4qNARVCatEAIznf//h2cj3fWDmXi9lPntLG93E+E/izyUtKGBdJ5cBbidO np1JsDUcKpW/z+hJfniGefOLuO3fPG/Wj8slLlfUEozZtcjplcBevo1W2geFKhUNacLN Rh9TPayZJEj+HyBEoppUeBVf9CWD2x4ha6oDFGN4G8KBTBdI2pBb0kwJyETsOAd/XE2d z+iPTZhW6jzgA5lrD/QUxepggOMq9Sy1Mv6J6luS4dnZtk4DXA/DB+WRa6rz1sEvhhMO 8iRQ== X-Gm-Message-State: AAQBX9fzBG0/6khohnN1oK9mZ6UVoVfTf7WotVat/nofDexNiqMCl1Si rwAk7jqW3VKu5IKv6J7yBpCJqw== X-Google-Smtp-Source: AKy350a2filE4g+Fktu46cSWXeAL0CATyxUdRZgJpewqKQTbKvPUvmx6gfVFFrNNkxSKJudTEsesEQ== X-Received: by 2002:a17:902:ecd0:b0:1a6:8d57:5c0b with SMTP id a16-20020a170902ecd000b001a68d575c0bmr367339plh.67.1681969771922; Wed, 19 Apr 2023 22:49:31 -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 v2 33/41] igb: Implement Tx SCTP CSO Date: Thu, 20 Apr 2023 14:46:49 +0900 Message-Id: <20230420054657.50367-34-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230420054657.50367-1-akihiko.odaki@daynix.com> References: <20230420054657.50367-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::631; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x631.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: 1681969800152100011 Content-Type: text/plain; charset="utf-8" Signed-off-by: Akihiko Odaki --- 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 f5cd44da6f..fc00d7941d 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 b7f7e765a5..00fd163bf3 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -432,8 +432,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; @@ -444,10 +445,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