Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4499294rdb; Tue, 12 Dec 2023 00:47:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtzcq2KoreE9bA8iW89OMVUCSVh8vqq+/9EE19Q+amTXnczEmj5dWMMdYMuvrE3wTcQ6YS X-Received: by 2002:ac8:5a12:0:b0:423:6d43:a287 with SMTP id n18-20020ac85a12000000b004236d43a287mr7444904qta.38.1702370846291; Tue, 12 Dec 2023 00:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702370846; cv=none; d=google.com; s=arc-20160816; b=EyYlfVL46FK6BYY0lIKYNNv8A0peub3xC5nJYIGNVL5hB/dW9UZSP48p5lup6XyNeN YJ0biWIWQBe9MNUgzLJW8TQmNMV9eGuRZPw2/JxKG1XCsJXl/LsCrcJU02UPbvj+au1n vT/3IHMqeKMkVex/S06rwLiUqw77ZR6kqG18Id27slPp4ygjmXGaFrZL1MWrz1Fd4sBp Ivd7TByQhvMx+lGBu0zIfgNyMvpXiGYJvqvdASQzYWB9+HkvfspWJcw1mEe2hsBe1HNY yu3GDscHSBs+CQ4z/y1D47JuKhiPOSin9syVzEOkHMbTv0Nsp25DA+L3j6FP7AmRbPSv JJDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=o3Esymi5ByzC7rwfXTDqKACdsV8LTKaFP3AmR7fL9HI=; fh=H7DxMfm/ATiu3tVyPItSY0FvYxA7aN+5BobM5v06lgo=; b=ws2xHs8347WvtGGl5lfQxSPSnA3zBQQX8bG7xe3xjID4da44k9BrIkXQmuvo47rawU 2Lr4cAP3nZbywGIS9Ib9jYRH1PgLDyeRvGq8Tl7ljQXpsXl7zNp7YKiw9yhKAwHds2hO ONHFDBd2A/KeDbap1IPhA5yiArbKn1WNC6IM6enaxEXwZ9BTtfXL2wnClL2nKYYvvQCt kD79XnJWLdUN7ngPOFAdQMHLaJ8aXVD48xI9/R0gUjAqxgldVRY2wzvRqNH6zErxNXIy HRfgu87m5k8yVrpvmCvP+U2SdWXph/WiPk1hPeKkhVERO7D82+CdZehXYp5ejEgIye7i /2JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Ljbkgwxk; spf=pass (google.com: domain of linux-crypto+bounces-735-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-735-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w3-20020a05622a134300b00425b43ab0cesi7014495qtk.116.2023.12.12.00.47.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:47:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-735-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Ljbkgwxk; spf=pass (google.com: domain of linux-crypto+bounces-735-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-735-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4C9B21C21395 for ; Tue, 12 Dec 2023 08:47:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21A593B18F; Tue, 12 Dec 2023 08:47:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Ljbkgwxk" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16681CD for ; Tue, 12 Dec 2023 00:47:06 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-50bef9b7a67so6141431e87.1 for ; Tue, 12 Dec 2023 00:47:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1702370824; x=1702975624; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=o3Esymi5ByzC7rwfXTDqKACdsV8LTKaFP3AmR7fL9HI=; b=LjbkgwxkBKbrQZBbAQXUMU4trTL5FVJlNE/7yhYMFFOgk45G2YNf0fWI0U0b8kh4JJ UmbAtAHoBiRNuKYYkvvN4sUhuJKVzkQq7Mw1enXEJJNnu1SDnBWkA8PqdejAQdh6dP/7 E2BOrfRI/qds19q7ysoSyNRovo7YXFYazDfGk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702370824; x=1702975624; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=o3Esymi5ByzC7rwfXTDqKACdsV8LTKaFP3AmR7fL9HI=; b=Kdt7nJNspMri3+X8zO5Prs2OizzX/YHwlGC5RaTzFdvKvPYFIqEIKBjPoXkrRWenrs rVjnebE2pCGtZzDe/qOT391kAOCyYO/RmQCluxgodYLmL5avtxtxzmCMUPm1BZeto0wi c1DzLcuKM9oEQCXF41PrXa5aBXJbLeV5t55OjAUKAhkl0vl5TwJvDhqHnisRiIWrp20h 4IMTbioI6cLYm83b3J0dOIYgrCWP6xt5P5MAvyxoMWBxS6YOTwmomKUEWODSFYCbFcMo 8TPWqd+bE+YFzKqeXKZQ0xx5LXFrrgJCKrxDcO4s8pWo4kT77gdvc55PjayyB5zL8UjW Bi5A== X-Gm-Message-State: AOJu0YwPJChVcER8ELV1ZgzRxHiaoxCYyQOykM8CRj1ohFXwGWWPHVX9 EMfZCrNXQYWdfGzOelxMEXkEy3gB/mAhCw2EeP1sog== X-Received: by 2002:a05:6512:3053:b0:50d:faa1:acce with SMTP id b19-20020a056512305300b0050dfaa1accemr1879516lfb.56.1702370823974; Tue, 12 Dec 2023 00:47:03 -0800 (PST) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231212051730.386088-1-schalla@marvell.com> <20231212051730.386088-3-schalla@marvell.com> In-Reply-To: <20231212051730.386088-3-schalla@marvell.com> From: Kalesh Anakkur Purayil Date: Tue, 12 Dec 2023 14:16:51 +0530 Message-ID: Subject: Re: [PATCH net-next v2 02/10] crypto: octeontx2: add SGv2 support for CN10KB or CN10KA B0 To: Srujana Challa Cc: herbert@gondor.apana.org.au, davem@davemloft.net, kuba@kernel.org, linux-crypto@vger.kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, bbrezillon@kernel.org, arno@natisbad.org, pabeni@redhat.com, edumazet@google.com, corbet@lwn.net, sgoutham@marvell.com, bbhushan2@marvell.com, jerinj@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, lcherian@marvell.com, gakula@marvell.com, ndabilpuram@marvell.com Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="00000000000046679f060c4c18c0" --00000000000046679f060c4c18c0 Content-Type: multipart/alternative; boundary="0000000000003d9282060c4c1846" --0000000000003d9282060c4c1846 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Few minor nits in line. On Tue, Dec 12, 2023 at 10:48=E2=80=AFAM Srujana Challa wrote: > Scatter Gather input format for CPT has changed on CN10KB/CN10KA B0 HW > to make it compatible with NIX Scatter Gather format to support SG mode > for inline IPsec. This patch modifies the code to make the driver works > for the same. This patch also enables CPT firmware load for these chips. > > Signed-off-by: Srujana Challa > --- > drivers/crypto/marvell/octeontx2/cn10k_cpt.c | 17 +- > drivers/crypto/marvell/octeontx2/cn10k_cpt.h | 1 + > .../marvell/octeontx2/otx2_cpt_common.h | 34 +- > .../marvell/octeontx2/otx2_cpt_hw_types.h | 3 + > .../marvell/octeontx2/otx2_cpt_reqmgr.h | 298 ++++++++++++++++++ > drivers/crypto/marvell/octeontx2/otx2_cptlf.h | 3 + > .../marvell/octeontx2/otx2_cptpf_main.c | 21 ++ > .../marvell/octeontx2/otx2_cptpf_mbox.c | 2 +- > .../marvell/octeontx2/otx2_cptpf_ucode.c | 33 +- > .../marvell/octeontx2/otx2_cptpf_ucode.h | 3 +- > drivers/crypto/marvell/octeontx2/otx2_cptvf.h | 2 + > .../marvell/octeontx2/otx2_cptvf_main.c | 11 + > .../marvell/octeontx2/otx2_cptvf_mbox.c | 26 ++ > .../marvell/octeontx2/otx2_cptvf_reqmgr.c | 160 +--------- > 14 files changed, 439 insertions(+), 175 deletions(-) > > diff --git a/drivers/crypto/marvell/octeontx2/cn10k_cpt.c > b/drivers/crypto/marvell/octeontx2/cn10k_cpt.c > index 93d22b328991..f148e85882ca 100644 > --- a/drivers/crypto/marvell/octeontx2/cn10k_cpt.c > +++ b/drivers/crypto/marvell/octeontx2/cn10k_cpt.c > @@ -14,12 +14,14 @@ static struct cpt_hw_ops otx2_hw_ops =3D { > .send_cmd =3D otx2_cpt_send_cmd, > .cpt_get_compcode =3D otx2_cpt_get_compcode, > .cpt_get_uc_compcode =3D otx2_cpt_get_uc_compcode, > + .cpt_sg_info_create =3D otx2_sg_info_create, > }; > > static struct cpt_hw_ops cn10k_hw_ops =3D { > .send_cmd =3D cn10k_cpt_send_cmd, > .cpt_get_compcode =3D cn10k_cpt_get_compcode, > .cpt_get_uc_compcode =3D cn10k_cpt_get_uc_compcode, > + .cpt_sg_info_create =3D otx2_sg_info_create, > }; > > static void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 > insts_num, > @@ -78,12 +80,9 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptv= f) > struct pci_dev *pdev =3D cptvf->pdev; > resource_size_t offset, size; > > - if (!test_bit(CN10K_LMTST, &cptvf->cap_flag)) { > - cptvf->lfs.ops =3D &otx2_hw_ops; > + if (!test_bit(CN10K_LMTST, &cptvf->cap_flag)) > return 0; > - } > > - cptvf->lfs.ops =3D &cn10k_hw_ops; > offset =3D pci_resource_start(pdev, PCI_MBOX_BAR_NUM); > size =3D pci_resource_len(pdev, PCI_MBOX_BAR_NUM); > /* Map VF LMILINE region */ > @@ -96,3 +95,13 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptv= f) > return 0; > } > EXPORT_SYMBOL_NS_GPL(cn10k_cptvf_lmtst_init, CRYPTO_DEV_OCTEONTX2_CPT); > + > +void cptvf_hw_ops_get(struct otx2_cptvf_dev *cptvf) > +{ > + if (!test_bit(CN10K_LMTST, &cptvf->cap_flag)) { > + cptvf->lfs.ops =3D &otx2_hw_ops; > + return; > [Kalesh] instead of return use "else" here. > + } > + cptvf->lfs.ops =3D &cn10k_hw_ops; > +} > +EXPORT_SYMBOL_NS_GPL(cptvf_hw_ops_get, CRYPTO_DEV_OCTEONTX2_CPT); > diff --git a/drivers/crypto/marvell/octeontx2/cn10k_cpt.h > b/drivers/crypto/marvell/octeontx2/cn10k_cpt.h > index aaefc7e38e06..44805a0717d7 100644 > --- a/drivers/crypto/marvell/octeontx2/cn10k_cpt.h > +++ b/drivers/crypto/marvell/octeontx2/cn10k_cpt.h > @@ -30,5 +30,6 @@ static inline u8 otx2_cpt_get_uc_compcode(union > otx2_cpt_res_s *result) > > int cn10k_cptpf_lmtst_init(struct otx2_cptpf_dev *cptpf); > int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf); > +void cptvf_hw_ops_get(struct otx2_cptvf_dev *cptvf); > > #endif /* __CN10K_CPTLF_H */ > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cpt_common.h > b/drivers/crypto/marvell/octeontx2/otx2_cpt_common.h > index 46b778bbbee4..284bbdef06ca 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cpt_common.h > +++ b/drivers/crypto/marvell/octeontx2/otx2_cpt_common.h > @@ -102,7 +102,10 @@ union otx2_cpt_eng_caps { > u64 kasumi:1; > u64 des:1; > u64 crc:1; > - u64 reserved_14_63:50; > + u64 mmul:1; > + u64 reserved_15_33:19; > + u64 pdcp_chain:1; > + u64 reserved_35_63:29; > }; > }; > > @@ -145,6 +148,35 @@ static inline bool is_dev_otx2(struct pci_dev *pdev) > return false; > } > > +static inline bool is_dev_cn10ka(struct pci_dev *pdev) > +{ > + return pdev->subsystem_device =3D=3D CPT_PCI_SUBSYS_DEVID_CN10K_A= ; > +} > + > +static inline bool is_dev_cn10ka_ax(struct pci_dev *pdev) > +{ > + if (pdev->subsystem_device =3D=3D CPT_PCI_SUBSYS_DEVID_CN10K_A && > + ((pdev->revision & 0xFF) =3D=3D 4 || (pdev->revision & 0xFF) = =3D=3D > 0x50 || > + (pdev->revision & 0xff) =3D=3D 0x51)) > + return true; > + > + return false; > +} > + > +static inline bool is_dev_cn10kb(struct pci_dev *pdev) > +{ > + return pdev->subsystem_device =3D=3D CPT_PCI_SUBSYS_DEVID_CN10K_B= ; > +} > + > +static inline bool is_dev_cn10ka_b0(struct pci_dev *pdev) > +{ > + if (pdev->subsystem_device =3D=3D CPT_PCI_SUBSYS_DEVID_CN10K_A && > + (pdev->revision & 0xFF) =3D=3D 0x54) > + return true; > + > + return false; > +} > + > static inline void otx2_cpt_set_hw_caps(struct pci_dev *pdev, > unsigned long *cap_flag) > { > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h > b/drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h > index 6f947978e4e8..756aee0c2b05 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h > +++ b/drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h > @@ -13,6 +13,9 @@ > #define CN10K_CPT_PCI_PF_DEVICE_ID 0xA0F2 > #define CN10K_CPT_PCI_VF_DEVICE_ID 0xA0F3 > > +#define CPT_PCI_SUBSYS_DEVID_CN10K_A 0xB900 > +#define CPT_PCI_SUBSYS_DEVID_CN10K_B 0xBD00 > + > /* Mailbox interrupts offset */ > #define OTX2_CPT_PF_MBOX_INT 6 > #define OTX2_CPT_PF_INT_VEC_E_MBOXX(x, a) ((x) + (a)) > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h > b/drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h > index dbb1ee746f4c..d459066b5368 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h > +++ b/drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h > @@ -27,6 +27,13 @@ > > #define OTX2_CPT_MAX_REQ_SIZE 65535 > > +#define SG_COMPS_MAX 4 > +#define SGV2_COMPS_MAX 3 > + > +#define SG_COMP_3 3 > +#define SG_COMP_2 2 > +#define SG_COMP_1 1 > + > union otx2_cpt_opcode { > u16 flags; > struct { > @@ -143,6 +150,8 @@ struct otx2_cpt_inst_info { > unsigned long time_in; > u32 dlen; > u32 dma_len; > + u64 gthr_sz; > + u64 sctr_sz; > u8 extra_time; > }; > > @@ -157,6 +166,16 @@ struct otx2_cpt_sglist_component { > __be64 ptr3; > }; > > +struct cn10kb_cpt_sglist_component { > + u16 len0; > + u16 len1; > + u16 len2; > + u16 valid_segs; > + u64 ptr0; > + u64 ptr1; > + u64 ptr2; > +}; > + > static inline void otx2_cpt_info_destroy(struct pci_dev *pdev, > struct otx2_cpt_inst_info *info) > { > @@ -188,6 +207,285 @@ static inline void otx2_cpt_info_destroy(struct > pci_dev *pdev, > kfree(info); > } > > +static inline int setup_sgio_components(struct pci_dev *pdev, > + struct otx2_cpt_buf_ptr *list, > + int buf_count, u8 *buffer) > +{ > + struct otx2_cpt_sglist_component *sg_ptr; > + int ret =3D 0, i, j; > + int components; > [Kalesh]: maintain RCT order > + > + if (unlikely(!list)) { > + dev_err(&pdev->dev, "Input list pointer is NULL\n"); > + return -EINVAL; > + } > + > + for (i =3D 0; i < buf_count; i++) { > + if (unlikely(!list[i].vptr)) > + continue; > + list[i].dma_addr =3D dma_map_single(&pdev->dev, list[i].v= ptr, > + list[i].size, > + DMA_BIDIRECTIONAL); > + if (unlikely(dma_mapping_error(&pdev->dev, > list[i].dma_addr))) { > + dev_err(&pdev->dev, "Dma mapping failed\n"); > + ret =3D -EIO; > [Kalesh]: I do not think you need the "ret" variable. In case of failure, return -EIO and in case of success return 0. > + goto sg_cleanup; > + } > + } > + components =3D buf_count / SG_COMPS_MAX; > + sg_ptr =3D (struct otx2_cpt_sglist_component *)buffer; > + for (i =3D 0; i < components; i++) { > + sg_ptr->len0 =3D cpu_to_be16(list[i * SG_COMPS_MAX + > 0].size); > + sg_ptr->len1 =3D cpu_to_be16(list[i * SG_COMPS_MAX + > 1].size); > + sg_ptr->len2 =3D cpu_to_be16(list[i * SG_COMPS_MAX + > 2].size); > + sg_ptr->len3 =3D cpu_to_be16(list[i * SG_COMPS_MAX + > 3].size); > + sg_ptr->ptr0 =3D cpu_to_be64(list[i * SG_COMPS_MAX + > 0].dma_addr); > + sg_ptr->ptr1 =3D cpu_to_be64(list[i * SG_COMPS_MAX + > 1].dma_addr); > + sg_ptr->ptr2 =3D cpu_to_be64(list[i * SG_COMPS_MAX + > 2].dma_addr); > + sg_ptr->ptr3 =3D cpu_to_be64(list[i * SG_COMPS_MAX + > 3].dma_addr); > + sg_ptr++; > + } > + components =3D buf_count % SG_COMPS_MAX; > + > + switch (components) { > + case SG_COMP_3: > + sg_ptr->len2 =3D cpu_to_be16(list[i * SG_COMPS_MAX + > 2].size); > + sg_ptr->ptr2 =3D cpu_to_be64(list[i * SG_COMPS_MAX + > 2].dma_addr); > + fallthrough; > + case SG_COMP_2: > + sg_ptr->len1 =3D cpu_to_be16(list[i * SG_COMPS_MAX + > 1].size); > + sg_ptr->ptr1 =3D cpu_to_be64(list[i * SG_COMPS_MAX + > 1].dma_addr); > + fallthrough; > + case SG_COMP_1: > + sg_ptr->len0 =3D cpu_to_be16(list[i * SG_COMPS_MAX + > 0].size); > + sg_ptr->ptr0 =3D cpu_to_be64(list[i * SG_COMPS_MAX + > 0].dma_addr); > + break; > + default: > + break; > + } > + return ret; > + > +sg_cleanup: > + for (j =3D 0; j < i; j++) { > + if (list[j].dma_addr) { > + dma_unmap_single(&pdev->dev, list[j].dma_addr, > + list[j].size, DMA_BIDIRECTIONAL)= ; > + } > + > + list[j].dma_addr =3D 0; > + } > + return ret; > +} > + > +static inline int sgv2io_components_setup(struct pci_dev *pdev, > + struct otx2_cpt_buf_ptr *list, > + int buf_count, u8 *buffer) > +{ > + struct cn10kb_cpt_sglist_component *sg_ptr; > + int ret =3D 0, i, j; > + int components; > + > + if (unlikely(!list)) { > + dev_err(&pdev->dev, "Input list pointer is NULL\n"); > + return -EFAULT; > + } > + > + for (i =3D 0; i < buf_count; i++) { > + if (unlikely(!list[i].vptr)) > + continue; > + list[i].dma_addr =3D dma_map_single(&pdev->dev, list[i].v= ptr, > + list[i].size, > + DMA_BIDIRECTIONAL); > + if (unlikely(dma_mapping_error(&pdev->dev, > list[i].dma_addr))) { > + dev_err(&pdev->dev, "Dma mapping failed\n"); > + ret =3D -EIO; > [Kalesh]: Same comment as above > + goto sg_cleanup; > + } > + } > + components =3D buf_count / SGV2_COMPS_MAX; > + sg_ptr =3D (struct cn10kb_cpt_sglist_component *)buffer; > + for (i =3D 0; i < components; i++) { > + sg_ptr->len0 =3D list[i * SGV2_COMPS_MAX + 0].size; > + sg_ptr->len1 =3D list[i * SGV2_COMPS_MAX + 1].size; > + sg_ptr->len2 =3D list[i * SGV2_COMPS_MAX + 2].size; > + sg_ptr->ptr0 =3D list[i * SGV2_COMPS_MAX + 0].dma_addr; > + sg_ptr->ptr1 =3D list[i * SGV2_COMPS_MAX + 1].dma_addr; > + sg_ptr->ptr2 =3D list[i * SGV2_COMPS_MAX + 2].dma_addr; > + sg_ptr->valid_segs =3D SGV2_COMPS_MAX; > + sg_ptr++; > + } > + components =3D buf_count % SGV2_COMPS_MAX; > + > + sg_ptr->valid_segs =3D components; > + switch (components) { > + case SG_COMP_2: > + sg_ptr->len1 =3D list[i * SGV2_COMPS_MAX + 1].size; > + sg_ptr->ptr1 =3D list[i * SGV2_COMPS_MAX + 1].dma_addr; > + fallthrough; > + case SG_COMP_1: > + sg_ptr->len0 =3D list[i * SGV2_COMPS_MAX + 0].size; > + sg_ptr->ptr0 =3D list[i * SGV2_COMPS_MAX + 0].dma_addr; > + break; > + default: > + break; > + } > + return ret; > + > +sg_cleanup: > + for (j =3D 0; j < i; j++) { > + if (list[j].dma_addr) { > + dma_unmap_single(&pdev->dev, list[j].dma_addr, > + list[j].size, DMA_BIDIRECTIONAL)= ; > + } > + > + list[j].dma_addr =3D 0; > + } > + return ret; > +} > + > +static inline struct otx2_cpt_inst_info * > +cn10k_sgv2_info_create(struct pci_dev *pdev, struct otx2_cpt_req_info > *req, > + gfp_t gfp) > +{ > + u32 dlen =3D 0, g_len, sg_len, info_len; > + int align =3D OTX2_CPT_DMA_MINALIGN; > + struct otx2_cpt_inst_info *info; > + u16 g_sz_bytes, s_sz_bytes; > + u32 total_mem_len; > + int i; > [Kalesh]: maintain RCT order > + > + g_sz_bytes =3D ((req->in_cnt + 2) / 3) * > + sizeof(struct cn10kb_cpt_sglist_component); > + s_sz_bytes =3D ((req->out_cnt + 2) / 3) * > + sizeof(struct cn10kb_cpt_sglist_component); > + > + g_len =3D ALIGN(g_sz_bytes, align); > + sg_len =3D ALIGN(g_len + s_sz_bytes, align); > + info_len =3D ALIGN(sizeof(*info), align); > + total_mem_len =3D sg_len + info_len + sizeof(union otx2_cpt_res_s= ); > + > + info =3D kzalloc(total_mem_len, gfp); > + if (unlikely(!info)) > + return NULL; > + > + for (i =3D 0; i < req->in_cnt; i++) > + dlen +=3D req->in[i].size; > + > + info->dlen =3D dlen; > + info->in_buffer =3D (u8 *)info + info_len; > + info->gthr_sz =3D req->in_cnt; > + info->sctr_sz =3D req->out_cnt; > + > + /* Setup gather (input) components */ > + if (sgv2io_components_setup(pdev, req->in, req->in_cnt, > + info->in_buffer)) { > + dev_err(&pdev->dev, "Failed to setup gather list\n"); > + goto destroy_info; > + } > + > + if (sgv2io_components_setup(pdev, req->out, req->out_cnt, > + &info->in_buffer[g_len])) { > + dev_err(&pdev->dev, "Failed to setup scatter list\n"); > + goto destroy_info; > + } > + > + info->dma_len =3D total_mem_len - info_len; > + info->dptr_baddr =3D dma_map_single(&pdev->dev, info->in_buffer, > + info->dma_len, > DMA_BIDIRECTIONAL); > + if (unlikely(dma_mapping_error(&pdev->dev, info->dptr_baddr))) { > + dev_err(&pdev->dev, "DMA Mapping failed for cpt req\n"); > + goto destroy_info; > + } > + info->rptr_baddr =3D info->dptr_baddr + g_len; > + /* > + * Get buffer for union otx2_cpt_res_s response > + * structure and its physical address > + */ > + info->completion_addr =3D info->in_buffer + sg_len; > + info->comp_baddr =3D info->dptr_baddr + sg_len; > + > + return info; > + > +destroy_info: > + otx2_cpt_info_destroy(pdev, info); > + return NULL; > +} > + > +/* SG list header size in bytes */ > +#define SG_LIST_HDR_SIZE 8 > +static inline struct otx2_cpt_inst_info * > +otx2_sg_info_create(struct pci_dev *pdev, struct otx2_cpt_req_info *req, > + gfp_t gfp) > +{ > + int align =3D OTX2_CPT_DMA_MINALIGN; > + struct otx2_cpt_inst_info *info; > + u32 dlen, align_dlen, info_len; > + u16 g_sz_bytes, s_sz_bytes; > + u32 total_mem_len; > + > + if (unlikely(req->in_cnt > OTX2_CPT_MAX_SG_IN_CNT || > + req->out_cnt > OTX2_CPT_MAX_SG_OUT_CNT)) { > + dev_err(&pdev->dev, "Error too many sg components\n"); > + return NULL; > + } > + > + g_sz_bytes =3D ((req->in_cnt + 3) / 4) * > + sizeof(struct otx2_cpt_sglist_component); > + s_sz_bytes =3D ((req->out_cnt + 3) / 4) * > + sizeof(struct otx2_cpt_sglist_component); > + > + dlen =3D g_sz_bytes + s_sz_bytes + SG_LIST_HDR_SIZE; > + align_dlen =3D ALIGN(dlen, align); > + info_len =3D ALIGN(sizeof(*info), align); > + total_mem_len =3D align_dlen + info_len + sizeof(union > otx2_cpt_res_s); > + > + info =3D kzalloc(total_mem_len, gfp); > + if (unlikely(!info)) > + return NULL; > + > + info->dlen =3D dlen; > + info->in_buffer =3D (u8 *)info + info_len; > + > + ((u16 *)info->in_buffer)[0] =3D req->out_cnt; > + ((u16 *)info->in_buffer)[1] =3D req->in_cnt; > + ((u16 *)info->in_buffer)[2] =3D 0; > + ((u16 *)info->in_buffer)[3] =3D 0; > + cpu_to_be64s((u64 *)info->in_buffer); > + > + /* Setup gather (input) components */ > + if (setup_sgio_components(pdev, req->in, req->in_cnt, > + &info->in_buffer[8])) { > + dev_err(&pdev->dev, "Failed to setup gather list\n"); > + goto destroy_info; > + } > + > + if (setup_sgio_components(pdev, req->out, req->out_cnt, > + &info->in_buffer[8 + g_sz_bytes])) { > + dev_err(&pdev->dev, "Failed to setup scatter list\n"); > + goto destroy_info; > + } > + > + info->dma_len =3D total_mem_len - info_len; > + info->dptr_baddr =3D dma_map_single(&pdev->dev, info->in_buffer, > + info->dma_len, > DMA_BIDIRECTIONAL); > + if (unlikely(dma_mapping_error(&pdev->dev, info->dptr_baddr))) { > + dev_err(&pdev->dev, "DMA Mapping failed for cpt req\n"); > + goto destroy_info; > + } > + /* > + * Get buffer for union otx2_cpt_res_s response > + * structure and its physical address > + */ > + info->completion_addr =3D info->in_buffer + align_dlen; > + info->comp_baddr =3D info->dptr_baddr + align_dlen; > + > + return info; > + > +destroy_info: > + otx2_cpt_info_destroy(pdev, info); > + return NULL; > +} > + > struct otx2_cptlf_wqe; > int otx2_cpt_do_request(struct pci_dev *pdev, struct otx2_cpt_req_info > *req, > int cpu_num); > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptlf.h > b/drivers/crypto/marvell/octeontx2/otx2_cptlf.h > index 5302fe3d0e6f..679b0f7b70c3 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptlf.h > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptlf.h > @@ -99,6 +99,9 @@ struct cpt_hw_ops { > struct otx2_cptlf_info *lf); > u8 (*cpt_get_compcode)(union otx2_cpt_res_s *result); > u8 (*cpt_get_uc_compcode)(union otx2_cpt_res_s *result); > + struct otx2_cpt_inst_info * > + (*cpt_sg_info_create)(struct pci_dev *pdev, struct > otx2_cpt_req_info *req, > + gfp_t gfp); > }; > > struct otx2_cptlfs_info { > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c > b/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c > index 5436b0d3685c..1d27dc3218c9 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c > @@ -14,6 +14,8 @@ > #define OTX2_CPT_DRV_STRING "Marvell RVU CPT Physical Function Driver" > > #define CPT_UC_RID_CN9K_B0 1 > +#define CPT_UC_RID_CN10K_A 4 > +#define CPT_UC_RID_CN10K_B 5 > > static void cptpf_enable_vfpf_mbox_intr(struct otx2_cptpf_dev *cptpf, > int num_vfs) > @@ -587,6 +589,24 @@ static int cpt_is_pf_usable(struct otx2_cptpf_dev > *cptpf) > return 0; > } > > +static void cptpf_get_rid(struct pci_dev *pdev, struct otx2_cptpf_dev > *cptpf) > +{ > + struct otx2_cpt_eng_grps *eng_grps =3D &cptpf->eng_grps; > + u64 reg_val =3D 0x0; > + > + if (is_dev_otx2(pdev)) { > + eng_grps->rid =3D pdev->revision; > + return; > + } > + otx2_cpt_read_af_reg(&cptpf->afpf_mbox, pdev, CPT_AF_CTL, ®_va= l, > + BLKADDR_CPT0); > + if ((is_dev_cn10ka_b0(pdev) && (reg_val & BIT_ULL(18))) || > + is_dev_cn10ka_ax(pdev)) > + eng_grps->rid =3D CPT_UC_RID_CN10K_A; > + else if (is_dev_cn10kb(pdev) || is_dev_cn10ka_b0(pdev)) > + eng_grps->rid =3D CPT_UC_RID_CN10K_B; > +} > + > static void cptpf_check_block_implemented(struct otx2_cptpf_dev *cptpf) > { > u64 cfg; > @@ -658,6 +678,7 @@ static int cptpf_sriov_enable(struct pci_dev *pdev, > int num_vfs) > if (ret) > goto destroy_flr; > > + cptpf_get_rid(pdev, cptpf); > /* Get CPT HW capabilities using LOAD_FVC operation. */ > ret =3D otx2_cpt_discover_eng_capabilities(cptpf); > if (ret) > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c > b/drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c > index 480b3720f15a..390ed146d309 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c > @@ -78,7 +78,7 @@ static int handle_msg_get_caps(struct otx2_cptpf_dev > *cptpf, > rsp->hdr.sig =3D OTX2_MBOX_RSP_SIG; > rsp->hdr.pcifunc =3D req->pcifunc; > rsp->cpt_pf_drv_version =3D OTX2_CPT_PF_DRV_VERSION; > - rsp->cpt_revision =3D cptpf->pdev->revision; > + rsp->cpt_revision =3D cptpf->eng_grps.rid; > memcpy(&rsp->eng_caps, &cptpf->eng_caps, sizeof(rsp->eng_caps)); > > return 0; > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c > b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c > index 1958b797a421..7fccc348f66e 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c > @@ -117,12 +117,10 @@ static char *get_ucode_type_str(int ucode_type) > > static int get_ucode_type(struct device *dev, > struct otx2_cpt_ucode_hdr *ucode_hdr, > - int *ucode_type) > + int *ucode_type, u16 rid) > { > - struct otx2_cptpf_dev *cptpf =3D dev_get_drvdata(dev); > char ver_str_prefix[OTX2_CPT_UCODE_VER_STR_SZ]; > char tmp_ver_str[OTX2_CPT_UCODE_VER_STR_SZ]; > - struct pci_dev *pdev =3D cptpf->pdev; > int i, val =3D 0; > u8 nn; > > @@ -130,7 +128,7 @@ static int get_ucode_type(struct device *dev, > for (i =3D 0; i < strlen(tmp_ver_str); i++) > tmp_ver_str[i] =3D tolower(tmp_ver_str[i]); > > - sprintf(ver_str_prefix, "ocpt-%02d", pdev->revision); > + sprintf(ver_str_prefix, "ocpt-%02d", rid); > if (!strnstr(tmp_ver_str, ver_str_prefix, > OTX2_CPT_UCODE_VER_STR_SZ)) > return -EINVAL; > > @@ -359,7 +357,7 @@ static int cpt_attach_and_enable_cores(struct > otx2_cpt_eng_grp_info *eng_grp, > } > > static int load_fw(struct device *dev, struct fw_info_t *fw_info, > - char *filename) > + char *filename, u16 rid) > { > struct otx2_cpt_ucode_hdr *ucode_hdr; > struct otx2_cpt_uc_info_t *uc_info; > @@ -375,7 +373,7 @@ static int load_fw(struct device *dev, struct > fw_info_t *fw_info, > goto free_uc_info; > > ucode_hdr =3D (struct otx2_cpt_ucode_hdr *)uc_info->fw->data; > - ret =3D get_ucode_type(dev, ucode_hdr, &ucode_type); > + ret =3D get_ucode_type(dev, ucode_hdr, &ucode_type, rid); > if (ret) > goto release_fw; > > @@ -389,6 +387,7 @@ static int load_fw(struct device *dev, struct > fw_info_t *fw_info, > set_ucode_filename(&uc_info->ucode, filename); > memcpy(uc_info->ucode.ver_str, ucode_hdr->ver_str, > OTX2_CPT_UCODE_VER_STR_SZ); > + uc_info->ucode.ver_str[OTX2_CPT_UCODE_VER_STR_SZ] =3D 0; > uc_info->ucode.ver_num =3D ucode_hdr->ver_num; > uc_info->ucode.type =3D ucode_type; > uc_info->ucode.size =3D ucode_size; > @@ -448,7 +447,8 @@ static void print_uc_info(struct fw_info_t *fw_info) > } > } > > -static int cpt_ucode_load_fw(struct pci_dev *pdev, struct fw_info_t > *fw_info) > +static int cpt_ucode_load_fw(struct pci_dev *pdev, struct fw_info_t > *fw_info, > + u16 rid) > { > char filename[OTX2_CPT_NAME_LENGTH]; > char eng_type[8] =3D {0}; > @@ -462,9 +462,9 @@ static int cpt_ucode_load_fw(struct pci_dev *pdev, > struct fw_info_t *fw_info) > eng_type[i] =3D tolower(eng_type[i]); > > snprintf(filename, sizeof(filename), "mrvl/cpt%02d/%s.out= ", > - pdev->revision, eng_type); > + rid, eng_type); > /* Request firmware for each engine type */ > - ret =3D load_fw(&pdev->dev, fw_info, filename); > + ret =3D load_fw(&pdev->dev, fw_info, filename, rid); > if (ret) > goto release_fw; > } > @@ -1155,7 +1155,7 @@ int otx2_cpt_create_eng_grps(struct otx2_cptpf_dev > *cptpf, > if (eng_grps->is_grps_created) > goto unlock; > > - ret =3D cpt_ucode_load_fw(pdev, &fw_info); > + ret =3D cpt_ucode_load_fw(pdev, &fw_info, eng_grps->rid); > if (ret) > goto unlock; > > @@ -1230,14 +1230,16 @@ int otx2_cpt_create_eng_grps(struct otx2_cptpf_de= v > *cptpf, > */ > rnm_to_cpt_errata_fixup(&pdev->dev); > > + otx2_cpt_read_af_reg(&cptpf->afpf_mbox, pdev, CPT_AF_CTL, ®_va= l, > + BLKADDR_CPT0); > /* > * Configure engine group mask to allow context prefetching > * for the groups and enable random number request, to enable > * CPT to request random numbers from RNM. > */ > + reg_val |=3D OTX2_CPT_ALL_ENG_GRPS_MASK << 3 | BIT_ULL(16); > otx2_cpt_write_af_reg(&cptpf->afpf_mbox, pdev, CPT_AF_CTL, > - OTX2_CPT_ALL_ENG_GRPS_MASK << 3 | > BIT_ULL(16), > - BLKADDR_CPT0); > + reg_val, BLKADDR_CPT0); > /* > * Set interval to periodically flush dirty data for the next > * CTX cache entry. Set the interval count to maximum supported > @@ -1412,7 +1414,7 @@ static int create_eng_caps_discovery_grps(struct > pci_dev *pdev, > int ret; > > mutex_lock(&eng_grps->lock); > - ret =3D cpt_ucode_load_fw(pdev, &fw_info); > + ret =3D cpt_ucode_load_fw(pdev, &fw_info, eng_grps->rid); > if (ret) { > mutex_unlock(&eng_grps->lock); > return ret; > @@ -1686,13 +1688,14 @@ int otx2_cpt_dl_custom_egrp_create(struct > otx2_cptpf_dev *cptpf, > goto err_unlock; > } > INIT_LIST_HEAD(&fw_info.ucodes); > - ret =3D load_fw(dev, &fw_info, ucode_filename[0]); > + > + ret =3D load_fw(dev, &fw_info, ucode_filename[0], eng_grps->rid); > if (ret) { > dev_err(dev, "Unable to load firmware %s\n", > ucode_filename[0]); > goto err_unlock; > } > if (ucode_idx > 1) { > - ret =3D load_fw(dev, &fw_info, ucode_filename[1]); > + ret =3D load_fw(dev, &fw_info, ucode_filename[1], > eng_grps->rid); > if (ret) { > dev_err(dev, "Unable to load firmware %s\n", > ucode_filename[1]); > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h > b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h > index e69320a54b5d..365fe8943bd9 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h > @@ -73,7 +73,7 @@ struct otx2_cpt_ucode_hdr { > }; > > struct otx2_cpt_ucode { > - u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ];/* > + u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ + 1];/* > * ucode version in readabl= e > * format > */ > @@ -150,6 +150,7 @@ struct otx2_cpt_eng_grps { > int engs_num; /* total number of engines > supported */ > u8 eng_ref_cnt[OTX2_CPT_MAX_ENGINES];/* engines reference count *= / > bool is_grps_created; /* Is the engine groups are already created > */ > + u16 rid; > }; > struct otx2_cptpf_dev; > int otx2_cpt_init_eng_grps(struct pci_dev *pdev, > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf.h > b/drivers/crypto/marvell/octeontx2/otx2_cptvf.h > index 994291e90da1..11ab9af1df15 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptvf.h > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf.h > @@ -22,6 +22,7 @@ struct otx2_cptvf_dev { > int blkaddr; > void *bbuf_base; > unsigned long cap_flag; > + u64 eng_caps[OTX2_CPT_MAX_ENG_TYPES]; > }; > > irqreturn_t otx2_cptvf_pfvf_mbox_intr(int irq, void *arg); > @@ -29,5 +30,6 @@ void otx2_cptvf_pfvf_mbox_handler(struct work_struct > *work); > int otx2_cptvf_send_eng_grp_num_msg(struct otx2_cptvf_dev *cptvf, int > eng_type); > int otx2_cptvf_send_kvf_limits_msg(struct otx2_cptvf_dev *cptvf); > int otx2_cpt_mbox_bbuf_init(struct otx2_cptvf_dev *cptvf, struct pci_dev > *pdev); > +int otx2_cptvf_send_caps_msg(struct otx2_cptvf_dev *cptvf); > > #endif /* __OTX2_CPTVF_H */ > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c > b/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c > index bac729c885f9..d3eaac072ff2 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c > @@ -380,6 +380,17 @@ static int otx2_cptvf_probe(struct pci_dev *pdev, > goto destroy_pfvf_mbox; > > cptvf->blkaddr =3D BLKADDR_CPT0; > + > + cptvf_hw_ops_get(cptvf); > + > + ret =3D otx2_cptvf_send_caps_msg(cptvf); > + if (ret) { > + dev_err(&pdev->dev, "Couldn't get CPT engine > capabilities.\n"); > + goto unregister_interrupts; > + } > + if (cptvf->eng_caps[OTX2_CPT_SE_TYPES] & BIT_ULL(35)) > + cptvf->lfs.ops->cpt_sg_info_create =3D > cn10k_sgv2_info_create; > + > /* Initialize CPT LFs */ > ret =3D cptvf_lf_init(cptvf); > if (ret) > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c > b/drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c > index 75c403f2b1d9..f68da1d08fdf 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c > @@ -72,6 +72,7 @@ static void process_pfvf_mbox_mbox_msg(struct > otx2_cptvf_dev *cptvf, > struct otx2_cptlfs_info *lfs =3D &cptvf->lfs; > struct otx2_cpt_kvf_limits_rsp *rsp_limits; > struct otx2_cpt_egrp_num_rsp *rsp_grp; > + struct otx2_cpt_caps_rsp *eng_caps; > struct cpt_rd_wr_reg_msg *rsp_reg; > struct msix_offset_rsp *rsp_msix; > int i; > @@ -127,6 +128,11 @@ static void process_pfvf_mbox_mbox_msg(struct > otx2_cptvf_dev *cptvf, > rsp_limits =3D (struct otx2_cpt_kvf_limits_rsp *) msg; > cptvf->lfs.kvf_limits =3D rsp_limits->kvf_limits; > break; > + case MBOX_MSG_GET_CAPS: > + eng_caps =3D (struct otx2_cpt_caps_rsp *)msg; > + memcpy(cptvf->eng_caps, eng_caps->eng_caps, > + sizeof(cptvf->eng_caps)); > [Kalesh]: This can be fit in one line? > + break; > default: > dev_err(&cptvf->pdev->dev, "Unsupported msg %d > received.\n", > msg->id); > @@ -205,3 +211,23 @@ int otx2_cptvf_send_kvf_limits_msg(struct > otx2_cptvf_dev *cptvf) > > return otx2_cpt_send_mbox_msg(mbox, pdev); > } > + > +int otx2_cptvf_send_caps_msg(struct otx2_cptvf_dev *cptvf) > +{ > + struct otx2_mbox *mbox =3D &cptvf->pfvf_mbox; > + struct pci_dev *pdev =3D cptvf->pdev; > + struct mbox_msghdr *req; > + > + req =3D (struct mbox_msghdr *) > + otx2_mbox_alloc_msg_rsp(mbox, 0, sizeof(*req), > + sizeof(struct otx2_cpt_caps_rsp)); > + if (!req) { > + dev_err(&pdev->dev, "RVU MBOX failed to get message.\n"); > + return -EFAULT; > + } > + req->id =3D MBOX_MSG_GET_CAPS; > + req->sig =3D OTX2_MBOX_REQ_SIG; > + req->pcifunc =3D OTX2_CPT_RVU_PFFUNC(cptvf->vf_id, 0); > + > + return otx2_cpt_send_mbox_msg(mbox, pdev); > +} > diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c > b/drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c > index 811ded72ce5f..997a2eb60c66 100644 > --- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c > +++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c > @@ -4,9 +4,6 @@ > #include "otx2_cptvf.h" > #include "otx2_cpt_common.h" > > -/* SG list header size in bytes */ > -#define SG_LIST_HDR_SIZE 8 > - > /* Default timeout when waiting for free pending entry in us */ > #define CPT_PENTRY_TIMEOUT 1000 > #define CPT_PENTRY_STEP 50 > @@ -26,9 +23,9 @@ static void otx2_cpt_dump_sg_list(struct pci_dev *pdev, > > pr_debug("Gather list size %d\n", req->in_cnt); > for (i =3D 0; i < req->in_cnt; i++) { > - pr_debug("Buffer %d size %d, vptr 0x%p, dmaptr 0x%p\n", i= , > + pr_debug("Buffer %d size %d, vptr 0x%p, dmaptr 0x%llx\n", > i, > req->in[i].size, req->in[i].vptr, > - (void *) req->in[i].dma_addr); > + req->in[i].dma_addr); > pr_debug("Buffer hexdump (%d bytes)\n", > req->in[i].size); > print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, > @@ -36,9 +33,9 @@ static void otx2_cpt_dump_sg_list(struct pci_dev *pdev, > } > pr_debug("Scatter list size %d\n", req->out_cnt); > for (i =3D 0; i < req->out_cnt; i++) { > - pr_debug("Buffer %d size %d, vptr 0x%p, dmaptr 0x%p\n", i= , > + pr_debug("Buffer %d size %d, vptr 0x%p, dmaptr 0x%llx\n", > i, > req->out[i].size, req->out[i].vptr, > - (void *) req->out[i].dma_addr); > + req->out[i].dma_addr); > pr_debug("Buffer hexdump (%d bytes)\n", req->out[i].size)= ; > print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, > req->out[i].vptr, req->out[i].size, > false); > @@ -84,149 +81,6 @@ static inline void free_pentry(struct > otx2_cpt_pending_entry *pentry) > pentry->busy =3D false; > } > > -static inline int setup_sgio_components(struct pci_dev *pdev, > - struct otx2_cpt_buf_ptr *list, > - int buf_count, u8 *buffer) > -{ > - struct otx2_cpt_sglist_component *sg_ptr =3D NULL; > - int ret =3D 0, i, j; > - int components; > - > - if (unlikely(!list)) { > - dev_err(&pdev->dev, "Input list pointer is NULL\n"); > - return -EFAULT; > - } > - > - for (i =3D 0; i < buf_count; i++) { > - if (unlikely(!list[i].vptr)) > - continue; > - list[i].dma_addr =3D dma_map_single(&pdev->dev, list[i].v= ptr, > - list[i].size, > - DMA_BIDIRECTIONAL); > - if (unlikely(dma_mapping_error(&pdev->dev, > list[i].dma_addr))) { > - dev_err(&pdev->dev, "Dma mapping failed\n"); > - ret =3D -EIO; > - goto sg_cleanup; > - } > - } > - components =3D buf_count / 4; > - sg_ptr =3D (struct otx2_cpt_sglist_component *)buffer; > - for (i =3D 0; i < components; i++) { > - sg_ptr->len0 =3D cpu_to_be16(list[i * 4 + 0].size); > - sg_ptr->len1 =3D cpu_to_be16(list[i * 4 + 1].size); > - sg_ptr->len2 =3D cpu_to_be16(list[i * 4 + 2].size); > - sg_ptr->len3 =3D cpu_to_be16(list[i * 4 + 3].size); > - sg_ptr->ptr0 =3D cpu_to_be64(list[i * 4 + 0].dma_addr); > - sg_ptr->ptr1 =3D cpu_to_be64(list[i * 4 + 1].dma_addr); > - sg_ptr->ptr2 =3D cpu_to_be64(list[i * 4 + 2].dma_addr); > - sg_ptr->ptr3 =3D cpu_to_be64(list[i * 4 + 3].dma_addr); > - sg_ptr++; > - } > - components =3D buf_count % 4; > - > - switch (components) { > - case 3: > - sg_ptr->len2 =3D cpu_to_be16(list[i * 4 + 2].size); > - sg_ptr->ptr2 =3D cpu_to_be64(list[i * 4 + 2].dma_addr); > - fallthrough; > - case 2: > - sg_ptr->len1 =3D cpu_to_be16(list[i * 4 + 1].size); > - sg_ptr->ptr1 =3D cpu_to_be64(list[i * 4 + 1].dma_addr); > - fallthrough; > - case 1: > - sg_ptr->len0 =3D cpu_to_be16(list[i * 4 + 0].size); > - sg_ptr->ptr0 =3D cpu_to_be64(list[i * 4 + 0].dma_addr); > - break; > - default: > - break; > - } > - return ret; > - > -sg_cleanup: > - for (j =3D 0; j < i; j++) { > - if (list[j].dma_addr) { > - dma_unmap_single(&pdev->dev, list[j].dma_addr, > - list[j].size, DMA_BIDIRECTIONAL)= ; > - } > - > - list[j].dma_addr =3D 0; > - } > - return ret; > -} > - > -static inline struct otx2_cpt_inst_info *info_create(struct pci_dev *pde= v, > - struct otx2_cpt_req_info > *req, > - gfp_t gfp) > -{ > - int align =3D OTX2_CPT_DMA_MINALIGN; > - struct otx2_cpt_inst_info *info; > - u32 dlen, align_dlen, info_len; > - u16 g_sz_bytes, s_sz_bytes; > - u32 total_mem_len; > - > - if (unlikely(req->in_cnt > OTX2_CPT_MAX_SG_IN_CNT || > - req->out_cnt > OTX2_CPT_MAX_SG_OUT_CNT)) { > - dev_err(&pdev->dev, "Error too many sg components\n"); > - return NULL; > - } > - > - g_sz_bytes =3D ((req->in_cnt + 3) / 4) * > - sizeof(struct otx2_cpt_sglist_component); > - s_sz_bytes =3D ((req->out_cnt + 3) / 4) * > - sizeof(struct otx2_cpt_sglist_component); > - > - dlen =3D g_sz_bytes + s_sz_bytes + SG_LIST_HDR_SIZE; > - align_dlen =3D ALIGN(dlen, align); > - info_len =3D ALIGN(sizeof(*info), align); > - total_mem_len =3D align_dlen + info_len + sizeof(union > otx2_cpt_res_s); > - > - info =3D kzalloc(total_mem_len, gfp); > - if (unlikely(!info)) > - return NULL; > - > - info->dlen =3D dlen; > - info->in_buffer =3D (u8 *)info + info_len; > - > - ((u16 *)info->in_buffer)[0] =3D req->out_cnt; > - ((u16 *)info->in_buffer)[1] =3D req->in_cnt; > - ((u16 *)info->in_buffer)[2] =3D 0; > - ((u16 *)info->in_buffer)[3] =3D 0; > - cpu_to_be64s((u64 *)info->in_buffer); > - > - /* Setup gather (input) components */ > - if (setup_sgio_components(pdev, req->in, req->in_cnt, > - &info->in_buffer[8])) { > - dev_err(&pdev->dev, "Failed to setup gather list\n"); > - goto destroy_info; > - } > - > - if (setup_sgio_components(pdev, req->out, req->out_cnt, > - &info->in_buffer[8 + g_sz_bytes])) { > - dev_err(&pdev->dev, "Failed to setup scatter list\n"); > - goto destroy_info; > - } > - > - info->dma_len =3D total_mem_len - info_len; > - info->dptr_baddr =3D dma_map_single(&pdev->dev, info->in_buffer, > - info->dma_len, > DMA_BIDIRECTIONAL); > - if (unlikely(dma_mapping_error(&pdev->dev, info->dptr_baddr))) { > - dev_err(&pdev->dev, "DMA Mapping failed for cpt req\n"); > - goto destroy_info; > - } > - /* > - * Get buffer for union otx2_cpt_res_s response > - * structure and its physical address > - */ > - info->completion_addr =3D info->in_buffer + align_dlen; > - info->comp_baddr =3D info->dptr_baddr + align_dlen; > - > - return info; > - > -destroy_info: > - otx2_cpt_info_destroy(pdev, info); > - return NULL; > -} > - > static int process_request(struct pci_dev *pdev, struct otx2_cpt_req_inf= o > *req, > struct otx2_cpt_pending_queue *pqueue, > struct otx2_cptlf_info *lf) > @@ -247,7 +101,7 @@ static int process_request(struct pci_dev *pdev, > struct otx2_cpt_req_info *req, > if (unlikely(!otx2_cptlf_started(lf->lfs))) > return -ENODEV; > > - info =3D info_create(pdev, req, gfp); > + info =3D lf->lfs->ops->cpt_sg_info_create(pdev, req, gfp); > if (unlikely(!info)) { > dev_err(&pdev->dev, "Setting up cpt inst info failed"); > return -ENOMEM; > @@ -303,8 +157,8 @@ static int process_request(struct pci_dev *pdev, > struct otx2_cpt_req_info *req, > > /* 64-bit swap for microcode data reads, not needed for addresses= */ > cpu_to_be64s(&iq_cmd.cmd.u); > - iq_cmd.dptr =3D info->dptr_baddr; > - iq_cmd.rptr =3D 0; > + iq_cmd.dptr =3D info->dptr_baddr | info->gthr_sz << 60; > + iq_cmd.rptr =3D info->rptr_baddr | info->sctr_sz << 60; > iq_cmd.cptr.u =3D 0; > iq_cmd.cptr.s.grp =3D ctrl->s.grp; > > -- > 2.25.1 > > > --=20 Regards, Kalesh A P --0000000000003d9282060c4c1846 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Few minor nits in line.

On Tue, Dec 12, 2023 at 10:48= =E2=80=AFAM Srujana Challa <schal= la@marvell.com> wrote:
Scatter Gather input format for CPT has changed on CN10KB/CN1= 0KA B0 HW
to make it compatible with NIX Scatter Gather format to support SG mode
for inline IPsec. This patch modifies the code to make the driver works
for the same. This patch also enables CPT firmware load for these chips.
Signed-off-by: Srujana Challa <schalla@marvell.com>
---
=C2=A0drivers/crypto/marvell/octeontx2/cn10k_cpt.c=C2=A0 |=C2=A0 17 +-
=C2=A0drivers/crypto/marvell/octeontx2/cn10k_cpt.h=C2=A0 |=C2=A0 =C2=A01 +<= br> =C2=A0.../marvell/octeontx2/otx2_cpt_common.h=C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 34 +-
=C2=A0.../marvell/octeontx2/otx2_cpt_hw_types.h=C2=A0 =C2=A0 =C2=A0|=C2=A0 = =C2=A03 +
=C2=A0.../marvell/octeontx2/otx2_cpt_reqmgr.h=C2=A0 =C2=A0 =C2=A0 =C2=A0| 2= 98 ++++++++++++++++++
=C2=A0drivers/crypto/marvell/octeontx2/otx2_cptlf.h |=C2=A0 =C2=A03 +
=C2=A0.../marvell/octeontx2/otx2_cptpf_main.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 21 ++
=C2=A0.../marvell/octeontx2/otx2_cptpf_mbox.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 =C2=A02 +-
=C2=A0.../marvell/octeontx2/otx2_cptpf_ucode.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 = 33 +-
=C2=A0.../marvell/octeontx2/otx2_cptpf_ucode.h=C2=A0 =C2=A0 =C2=A0 |=C2=A0 = =C2=A03 +-
=C2=A0drivers/crypto/marvell/octeontx2/otx2_cptvf.h |=C2=A0 =C2=A02 +
=C2=A0.../marvell/octeontx2/otx2_cptvf_main.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 11 +
=C2=A0.../marvell/octeontx2/otx2_cptvf_mbox.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 26 ++
=C2=A0.../marvell/octeontx2/otx2_cptvf_reqmgr.c=C2=A0 =C2=A0 =C2=A0| 160 +-= --------
=C2=A014 files changed, 439 insertions(+), 175 deletions(-)

diff --git a/drivers/crypto/marvell/octeontx2/cn10k_cpt.c b/drivers/crypto/= marvell/octeontx2/cn10k_cpt.c
index 93d22b328991..f148e85882ca 100644
--- a/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
+++ b/drivers/crypto/marvell/octeontx2/cn10k_cpt.c
@@ -14,12 +14,14 @@ static struct cpt_hw_ops otx2_hw_ops =3D {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .send_cmd =3D otx2_cpt_send_cmd,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .cpt_get_compcode =3D otx2_cpt_get_compcode, =C2=A0 =C2=A0 =C2=A0 =C2=A0 .cpt_get_uc_compcode =3D otx2_cpt_get_uc_compco= de,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.cpt_sg_info_create =3D otx2_sg_info_create, =C2=A0};

=C2=A0static struct cpt_hw_ops cn10k_hw_ops =3D {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .send_cmd =3D cn10k_cpt_send_cmd,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .cpt_get_compcode =3D cn10k_cpt_get_compcode, =C2=A0 =C2=A0 =C2=A0 =C2=A0 .cpt_get_uc_compcode =3D cn10k_cpt_get_uc_compc= ode,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.cpt_sg_info_create =3D otx2_sg_info_create, =C2=A0};

=C2=A0static void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 in= sts_num,
@@ -78,12 +80,9 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct pci_dev *pdev =3D cptvf->pdev;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 resource_size_t offset, size;

-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!test_bit(CN10K_LMTST, &cptvf->cap_f= lag)) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cptvf->lfs.ops = =3D &otx2_hw_ops;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!test_bit(CN10K_LMTST, &cptvf->cap_f= lag))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0}

-=C2=A0 =C2=A0 =C2=A0 =C2=A0cptvf->lfs.ops =3D &cn10k_hw_ops;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 offset =3D pci_resource_start(pdev, PCI_MBOX_BA= R_NUM);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 size =3D pci_resource_len(pdev, PCI_MBOX_BAR_NU= M);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Map VF LMILINE region */
@@ -96,3 +95,13 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
=C2=A0}
=C2=A0EXPORT_SYMBOL_NS_GPL(cn10k_cptvf_lmtst_init, CRYPTO_DEV_OCTEONTX2_CPT= );
+
+void cptvf_hw_ops_get(struct otx2_cptvf_dev *cptvf)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!test_bit(CN10K_LMTST, &cptvf->cap_f= lag)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cptvf->lfs.ops = =3D &otx2_hw_ops;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return;
[Kalesh] instead of return use "else" here.=C2=A0
=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0cptvf->lfs.ops =3D &cn10k_hw_ops;
+}
+EXPORT_SYMBOL_NS_GPL(cptvf_hw_ops_get, CRYPTO_DEV_OCTEONTX2_CPT);
diff --git a/drivers/crypto/marvell/octeontx2/cn10k_cpt.h b/drivers/crypto/= marvell/octeontx2/cn10k_cpt.h
index aaefc7e38e06..44805a0717d7 100644
--- a/drivers/crypto/marvell/octeontx2/cn10k_cpt.h
+++ b/drivers/crypto/marvell/octeontx2/cn10k_cpt.h
@@ -30,5 +30,6 @@ static inline u8 otx2_cpt_get_uc_compcode(union otx2_cpt_= res_s *result)

=C2=A0int cn10k_cptpf_lmtst_init(struct otx2_cptpf_dev *cptpf);
=C2=A0int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf);
+void cptvf_hw_ops_get(struct otx2_cptvf_dev *cptvf);

=C2=A0#endif /* __CN10K_CPTLF_H */
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cpt_common.h b/drivers/c= rypto/marvell/octeontx2/otx2_cpt_common.h
index 46b778bbbee4..284bbdef06ca 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cpt_common.h
+++ b/drivers/crypto/marvell/octeontx2/otx2_cpt_common.h
@@ -102,7 +102,10 @@ union otx2_cpt_eng_caps {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 u64 kasumi:1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 u64 des:1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 u64 crc:1;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0u64 reserved_14_63:= 50;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0u64 mmul:1;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0u64 reserved_15_33:= 19;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0u64 pdcp_chain:1; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0u64 reserved_35_63:= 29;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 };
=C2=A0};

@@ -145,6 +148,35 @@ static inline bool is_dev_otx2(struct pci_dev *pdev) =C2=A0 =C2=A0 =C2=A0 =C2=A0 return false;
=C2=A0}

+static inline bool is_dev_cn10ka(struct pci_dev *pdev)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return pdev->subsystem_device =3D=3D CPT_PCI= _SUBSYS_DEVID_CN10K_A;
+}
+
+static inline bool is_dev_cn10ka_ax(struct pci_dev *pdev)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (pdev->subsystem_device =3D=3D CPT_PCI_SU= BSYS_DEVID_CN10K_A &&
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((pdev->revision & 0xFF) = =3D=3D 4 || (pdev->revision & 0xFF) =3D=3D 0x50 ||
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (pdev->revision & 0xff) = =3D=3D 0x51))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return true;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return false;
+}
+
+static inline bool is_dev_cn10kb(struct pci_dev *pdev)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return pdev->subsystem_device =3D=3D CPT_PCI= _SUBSYS_DEVID_CN10K_B;
+}
+
+static inline bool is_dev_cn10ka_b0(struct pci_dev *pdev)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (pdev->subsystem_device =3D=3D CPT_PCI_SU= BSYS_DEVID_CN10K_A &&
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(pdev->revision & 0xFF) = =3D=3D 0x54)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return true;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return false;
+}
+
=C2=A0static inline void otx2_cpt_set_hw_caps(struct pci_dev *pdev,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned= long *cap_flag)
=C2=A0{
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h b/drivers= /crypto/marvell/octeontx2/otx2_cpt_hw_types.h
index 6f947978e4e8..756aee0c2b05 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h
+++ b/drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h
@@ -13,6 +13,9 @@
=C2=A0#define CN10K_CPT_PCI_PF_DEVICE_ID 0xA0F2
=C2=A0#define CN10K_CPT_PCI_VF_DEVICE_ID 0xA0F3

+#define CPT_PCI_SUBSYS_DEVID_CN10K_A 0xB900
+#define CPT_PCI_SUBSYS_DEVID_CN10K_B 0xBD00
+
=C2=A0/* Mailbox interrupts offset */
=C2=A0#define OTX2_CPT_PF_MBOX_INT=C2=A0 =C2=A06
=C2=A0#define OTX2_CPT_PF_INT_VEC_E_MBOXX(x, a) ((x) + (a))
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h b/drivers/c= rypto/marvell/octeontx2/otx2_cpt_reqmgr.h
index dbb1ee746f4c..d459066b5368 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h
+++ b/drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h
@@ -27,6 +27,13 @@

=C2=A0#define OTX2_CPT_MAX_REQ_SIZE 65535

+#define SG_COMPS_MAX=C2=A0 =C2=A0 4
+#define SGV2_COMPS_MAX=C2=A0 3
+
+#define SG_COMP_3=C2=A0 =C2=A0 3
+#define SG_COMP_2=C2=A0 =C2=A0 2
+#define SG_COMP_1=C2=A0 =C2=A0 1
+
=C2=A0union otx2_cpt_opcode {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 u16 flags;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct {
@@ -143,6 +150,8 @@ struct otx2_cpt_inst_info {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long time_in;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 u32 dlen;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 u32 dma_len;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u64 gthr_sz;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u64 sctr_sz;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 u8 extra_time;
=C2=A0};

@@ -157,6 +166,16 @@ struct otx2_cpt_sglist_component {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 __be64 ptr3;
=C2=A0};

+struct cn10kb_cpt_sglist_component {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u16 len0;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u16 len1;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u16 len2;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u16 valid_segs;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u64 ptr0;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u64 ptr1;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u64 ptr2;
+};
+
=C2=A0static inline void otx2_cpt_info_destroy(struct pci_dev *pdev,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0st= ruct otx2_cpt_inst_info *info)
=C2=A0{
@@ -188,6 +207,285 @@ static inline void otx2_cpt_info_destroy(struct pci_d= ev *pdev,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree(info);
=C2=A0}

+static inline int setup_sgio_components(struct pci_dev *pdev,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct ot= x2_cpt_buf_ptr *list,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int buf_c= ount, u8 *buffer)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct otx2_cpt_sglist_component *sg_ptr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int ret =3D 0, i, j;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int components;
[Kalesh]: = maintain RCT order=C2=A0
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(!list)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&pdev-&= gt;dev, "Input list pointer is NULL\n");
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EINVAL;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < buf_count; i++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(!list[= i].vptr))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0continue;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0list[i].dma_addr = =3D dma_map_single(&pdev->dev, list[i].vptr,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0list[i].size,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0DMA_BIDIRECTIONAL);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(dma_ma= pping_error(&pdev->dev, list[i].dma_addr))) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0dev_err(&pdev->dev, "Dma mapping failed\n");
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0ret =3D -EIO;
[Kalesh]: I do not think you n= eed the "ret" variable. In case of failure, return -EIO and in ca= se of success return 0.=C2=A0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0goto sg_cleanup;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0components =3D buf_count / SG_COMPS_MAX;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr =3D (struct otx2_cpt_sglist_component *)= buffer;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < components; i++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len0 =3D= cpu_to_be16(list[i * SG_COMPS_MAX + 0].size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len1 =3D= cpu_to_be16(list[i * SG_COMPS_MAX + 1].size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len2 =3D= cpu_to_be16(list[i * SG_COMPS_MAX + 2].size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len3 =3D= cpu_to_be16(list[i * SG_COMPS_MAX + 3].size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr0 =3D= cpu_to_be64(list[i * SG_COMPS_MAX + 0].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr1 =3D= cpu_to_be64(list[i * SG_COMPS_MAX + 1].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr2 =3D= cpu_to_be64(list[i * SG_COMPS_MAX + 2].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr3 =3D= cpu_to_be64(list[i * SG_COMPS_MAX + 3].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr++;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0components =3D buf_count % SG_COMPS_MAX;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0switch (components) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0case SG_COMP_3:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len2 =3D= cpu_to_be16(list[i * SG_COMPS_MAX + 2].size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr2 =3D= cpu_to_be64(list[i * SG_COMPS_MAX + 2].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fallthrough;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0case SG_COMP_2:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len1 =3D= cpu_to_be16(list[i * SG_COMPS_MAX + 1].size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr1 =3D= cpu_to_be64(list[i * SG_COMPS_MAX + 1].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fallthrough;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0case SG_COMP_1:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len0 =3D= cpu_to_be16(list[i * SG_COMPS_MAX + 0].size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr0 =3D= cpu_to_be64(list[i * SG_COMPS_MAX + 0].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return ret;
+
+sg_cleanup:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0for (j =3D 0; j < i; j++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (list[j].dma_add= r) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0dma_unmap_single(&pdev->dev, list[j].dma_addr,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 list[j].= size, DMA_BIDIRECTIONAL);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0list[j].dma_addr = =3D 0;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return ret;
+}
+
+static inline int sgv2io_components_setup(struct pci_dev *pdev,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0st= ruct otx2_cpt_buf_ptr *list,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0in= t buf_count, u8 *buffer)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct cn10kb_cpt_sglist_component *sg_ptr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int ret =3D 0, i, j;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int components;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(!list)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&pdev-&= gt;dev, "Input list pointer is NULL\n");
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EFAULT;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < buf_count; i++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(!list[= i].vptr))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0continue;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0list[i].dma_addr = =3D dma_map_single(&pdev->dev, list[i].vptr,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0list[i].size,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0DMA_BIDIRECTIONAL);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(dma_ma= pping_error(&pdev->dev, list[i].dma_addr))) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0dev_err(&pdev->dev, "Dma mapping failed\n");
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0ret =3D -EIO;
[Kalesh]: Same comment as abov= e=C2=A0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0goto sg_cleanup;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0components =3D buf_count / SGV2_COMPS_MAX;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr =3D (struct cn10kb_cpt_sglist_component = *)buffer;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < components; i++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len0 =3D= list[i * SGV2_COMPS_MAX + 0].size;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len1 =3D= list[i * SGV2_COMPS_MAX + 1].size;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len2 =3D= list[i * SGV2_COMPS_MAX + 2].size;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr0 =3D= list[i * SGV2_COMPS_MAX + 0].dma_addr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr1 =3D= list[i * SGV2_COMPS_MAX + 1].dma_addr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr2 =3D= list[i * SGV2_COMPS_MAX + 2].dma_addr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->valid_se= gs =3D SGV2_COMPS_MAX;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr++;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0components =3D buf_count % SGV2_COMPS_MAX;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->valid_segs =3D components;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0switch (components) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0case SG_COMP_2:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len1 =3D= list[i * SGV2_COMPS_MAX + 1].size;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr1 =3D= list[i * SGV2_COMPS_MAX + 1].dma_addr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fallthrough;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0case SG_COMP_1:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len0 =3D= list[i * SGV2_COMPS_MAX + 0].size;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr0 =3D= list[i * SGV2_COMPS_MAX + 0].dma_addr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return ret;
+
+sg_cleanup:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0for (j =3D 0; j < i; j++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (list[j].dma_add= r) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0dma_unmap_single(&pdev->dev, list[j].dma_addr,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 list[j].= size, DMA_BIDIRECTIONAL);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0list[j].dma_addr = =3D 0;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return ret;
+}
+
+static inline struct otx2_cpt_inst_info *
+cn10k_sgv2_info_create(struct pci_dev *pdev, struct otx2_cpt_req_info *req= ,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 gfp_t gfp)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 dlen =3D 0, g_len, sg_len, info_len;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int align =3D OTX2_CPT_DMA_MINALIGN;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct otx2_cpt_inst_info *info;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u16 g_sz_bytes, s_sz_bytes;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 total_mem_len;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int i;
[Kalesh]: maintain = RCT order=C2=A0=C2=A0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 default:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_err(&cptvf-= >pdev->dev, "Unsupported msg %d received.\n",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 msg->id);
@@ -205,3 +211,23 @@ int otx2_cptvf_send_kvf_limits_msg(struct otx2_cptvf_d= ev *cptvf)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 return otx2_cpt_send_mbox_msg(mbox, pdev);
=C2=A0}
+
+int otx2_cptvf_send_caps_msg(struct otx2_cptvf_dev *cptvf)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct otx2_mbox *mbox =3D &cptvf->pfvf_= mbox;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct pci_dev *pdev =3D cptvf->pdev;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct mbox_msghdr *req;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0req =3D (struct mbox_msghdr *)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0otx2_mbox_alloc_msg_rsp(mb= ox, 0, sizeof(*req),
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sizeof(struct ot= x2_cpt_caps_rsp));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!req) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&pdev-&= gt;dev, "RVU MBOX failed to get message.\n");
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EFAULT;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0req->id =3D MBOX_MSG_GET_CAPS;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0req->sig =3D OTX2_MBOX_REQ_SIG;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0req->pcifunc =3D OTX2_CPT_RVU_PFFUNC(cptvf-&= gt;vf_id, 0);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return otx2_cpt_send_mbox_msg(mbox, pdev);
+}
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c b/drivers= /crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c
index 811ded72ce5f..997a2eb60c66 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c
@@ -4,9 +4,6 @@
=C2=A0#include "otx2_cptvf.h"
=C2=A0#include "otx2_cpt_common.h"

-/* SG list header size in bytes */
-#define SG_LIST_HDR_SIZE=C2=A0 =C2=A0 =C2=A0 =C2=A08
-
=C2=A0/* Default timeout when waiting for free pending entry in us */
=C2=A0#define CPT_PENTRY_TIMEOUT=C2=A0 =C2=A0 =C2=A01000
=C2=A0#define CPT_PENTRY_STEP=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 50
@@ -26,9 +23,9 @@ static void otx2_cpt_dump_sg_list(struct pci_dev *pdev,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 pr_debug("Gather list size %d\n", req= ->in_cnt);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (i =3D 0; i < req->in_cnt; i++) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pr_debug("Buff= er %d size %d, vptr 0x%p, dmaptr 0x%p\n", i,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pr_debug("Buff= er %d size %d, vptr 0x%p, dmaptr 0x%llx\n", i,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0req->in[i].size, req->in[i].vptr,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (void *) req->in[i].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 req->in[i].dma_addr);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pr_debug("Buff= er hexdump (%d bytes)\n",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0req->in[i].size);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print_hex_dump_debu= g("", DUMP_PREFIX_NONE, 16, 1,
@@ -36,9 +33,9 @@ static void otx2_cpt_dump_sg_list(struct pci_dev *pdev, =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 pr_debug("Scatter list size %d\n", re= q->out_cnt);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (i =3D 0; i < req->out_cnt; i++) { -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pr_debug("Buff= er %d size %d, vptr 0x%p, dmaptr 0x%p\n", i,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pr_debug("Buff= er %d size %d, vptr 0x%p, dmaptr 0x%llx\n", i,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0req->out[i].size, req->out[i].vptr,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (void *) req->out[i].dma_addr);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 req->out[i].dma_addr);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pr_debug("Buff= er hexdump (%d bytes)\n", req->out[i].size);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print_hex_dump_debu= g("", DUMP_PREFIX_NONE, 16, 1,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0req->out[i].v= ptr, req->out[i].size, false);
@@ -84,149 +81,6 @@ static inline void free_pentry(struct otx2_cpt_pending_= entry *pentry)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 pentry->busy =3D false;
=C2=A0}

-static inline int setup_sgio_components(struct pci_dev *pdev,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct ot= x2_cpt_buf_ptr *list,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int buf_c= ount, u8 *buffer)
-{
-=C2=A0 =C2=A0 =C2=A0 =C2=A0struct otx2_cpt_sglist_component *sg_ptr =3D NU= LL;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0int ret =3D 0, i, j;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0int components;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(!list)) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&pdev-&= gt;dev, "Input list pointer is NULL\n");
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EFAULT;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < buf_count; i++) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(!list[= i].vptr))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0continue;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0list[i].dma_addr = =3D dma_map_single(&pdev->dev, list[i].vptr,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0list[i].size,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0DMA_BIDIRECTIONAL);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(dma_ma= pping_error(&pdev->dev, list[i].dma_addr))) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0dev_err(&pdev->dev, "Dma mapping failed\n");
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0ret =3D -EIO;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0goto sg_cleanup;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
-=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-=C2=A0 =C2=A0 =C2=A0 =C2=A0components =3D buf_count / 4;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr =3D (struct otx2_cpt_sglist_component *)= buffer;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < components; i++) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len0 =3D= cpu_to_be16(list[i * 4 + 0].size);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len1 =3D= cpu_to_be16(list[i * 4 + 1].size);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len2 =3D= cpu_to_be16(list[i * 4 + 2].size);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len3 =3D= cpu_to_be16(list[i * 4 + 3].size);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr0 =3D= cpu_to_be64(list[i * 4 + 0].dma_addr);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr1 =3D= cpu_to_be64(list[i * 4 + 1].dma_addr);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr2 =3D= cpu_to_be64(list[i * 4 + 2].dma_addr);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr3 =3D= cpu_to_be64(list[i * 4 + 3].dma_addr);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr++;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-=C2=A0 =C2=A0 =C2=A0 =C2=A0components =3D buf_count % 4;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0switch (components) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0case 3:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len2 =3D= cpu_to_be16(list[i * 4 + 2].size);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr2 =3D= cpu_to_be64(list[i * 4 + 2].dma_addr);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fallthrough;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0case 2:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len1 =3D= cpu_to_be16(list[i * 4 + 1].size);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr1 =3D= cpu_to_be64(list[i * 4 + 1].dma_addr);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fallthrough;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0case 1:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->len0 =3D= cpu_to_be16(list[i * 4 + 0].size);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sg_ptr->ptr0 =3D= cpu_to_be64(list[i * 4 + 0].dma_addr);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0default:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-=C2=A0 =C2=A0 =C2=A0 =C2=A0return ret;
-
-sg_cleanup:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0for (j =3D 0; j < i; j++) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (list[j].dma_add= r) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0dma_unmap_single(&pdev->dev, list[j].dma_addr,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 list[j].= size, DMA_BIDIRECTIONAL);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0list[j].dma_addr = =3D 0;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-=C2=A0 =C2=A0 =C2=A0 =C2=A0return ret;
-}
-
-static inline struct otx2_cpt_inst_info *info_create(struct pci_dev *pdev,=
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0struct otx2_cpt_req_info *req,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0gfp_t gfp)
-{
-=C2=A0 =C2=A0 =C2=A0 =C2=A0int align =3D OTX2_CPT_DMA_MINALIGN;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0struct otx2_cpt_inst_info *info;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 dlen, align_dlen, info_len;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0u16 g_sz_bytes, s_sz_bytes;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 total_mem_len;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(req->in_cnt > OTX2_CPT_MAX_S= G_IN_CNT ||
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 req-= >out_cnt > OTX2_CPT_MAX_SG_OUT_CNT)) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&pdev-&= gt;dev, "Error too many sg components\n");
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return NULL;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0g_sz_bytes =3D ((req->in_cnt + 3) / 4) *
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0sizeof(struct otx2_cpt_sglist_component);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0s_sz_bytes =3D ((req->out_cnt + 3) / 4) * -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0sizeof(struct otx2_cpt_sglist_component);
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0dlen =3D g_sz_bytes + s_sz_bytes + SG_LIST_HDR_= SIZE;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0align_dlen =3D ALIGN(dlen, align);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0info_len =3D ALIGN(sizeof(*info), align);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0total_mem_len =3D align_dlen + info_len + sizeo= f(union otx2_cpt_res_s);
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0info =3D kzalloc(total_mem_len, gfp);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(!info))
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return NULL;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0info->dlen =3D dlen;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0info->in_buffer =3D (u8 *)info + info_len; -
-=C2=A0 =C2=A0 =C2=A0 =C2=A0((u16 *)info->in_buffer)[0] =3D req->out_= cnt;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0((u16 *)info->in_buffer)[1] =3D req->in_c= nt;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0((u16 *)info->in_buffer)[2] =3D 0;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0((u16 *)info->in_buffer)[3] =3D 0;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0cpu_to_be64s((u64 *)info->in_buffer);
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0/* Setup gather (input) components */
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (setup_sgio_components(pdev, req->in, req= ->in_cnt,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&info->in_buffer[8])) {=
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&pdev-&= gt;dev, "Failed to setup gather list\n");
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto destroy_info;<= br> -=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (setup_sgio_components(pdev, req->out, re= q->out_cnt,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&info->in_buffer[8 + g_= sz_bytes])) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&pdev-&= gt;dev, "Failed to setup scatter list\n");
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto destroy_info;<= br> -=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0info->dma_len =3D total_mem_len - info_len;<= br> -=C2=A0 =C2=A0 =C2=A0 =C2=A0info->dptr_baddr =3D dma_map_single(&pde= v->dev, info->in_buffer,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0in= fo->dma_len, DMA_BIDIRECTIONAL);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (unlikely(dma_mapping_error(&pdev->de= v, info->dptr_baddr))) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&pdev-&= gt;dev, "DMA Mapping failed for cpt req\n");
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto destroy_info;<= br> -=C2=A0 =C2=A0 =C2=A0 =C2=A0}
-=C2=A0 =C2=A0 =C2=A0 =C2=A0/*
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Get buffer for union otx2_cpt_res_s response=
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 * structure and its physical address
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
-=C2=A0 =C2=A0 =C2=A0 =C2=A0info->completion_addr =3D info->in_buffer= + align_dlen;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0info->comp_baddr =3D info->dptr_baddr + a= lign_dlen;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0return info;
-
-destroy_info:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0otx2_cpt_info_destroy(pdev, info);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0return NULL;
-}
-
=C2=A0static int process_request(struct pci_dev *pdev, struct otx2_cpt_req_= info *req,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0struct otx2_cpt_pending_queue *pqueue,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0struct otx2_cptlf_info *lf)
@@ -247,7 +101,7 @@ static int process_request(struct pci_dev *pdev, struct= otx2_cpt_req_info *req,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (unlikely(!otx2_cptlf_started(lf->lfs)))<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENODEV;

-=C2=A0 =C2=A0 =C2=A0 =C2=A0info =3D info_create(pdev, req, gfp);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0info =3D lf->lfs->ops->cpt_sg_info_cre= ate(pdev, req, gfp);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (unlikely(!info)) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_err(&pdev-&= gt;dev, "Setting up cpt inst info failed");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENOMEM;
@@ -303,8 +157,8 @@ static int process_request(struct pci_dev *pdev, struct= otx2_cpt_req_info *req,

=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* 64-bit swap for microcode data reads, not ne= eded for addresses*/
=C2=A0 =C2=A0 =C2=A0 =C2=A0 cpu_to_be64s(&iq_cmd.cmd.u);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0iq_cmd.dptr =3D info->dptr_baddr;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0iq_cmd.rptr =3D 0;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0iq_cmd.dptr =3D info->dptr_baddr | info->= gthr_sz << 60;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0iq_cmd.rptr =3D info->rptr_baddr | info->= sctr_sz << 60;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 iq_cmd.cptr.u =3D 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 iq_cmd.cptr.s.grp =3D ctrl->s.grp;

--
2.25.1




--
Regards,
Kalesh A P
--0000000000003d9282060c4c1846-- --00000000000046679f060c4c18c0 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQiwYJKoZIhvcNAQcCoIIQfDCCEHgCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3iMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSMdHiDgXD1UnRSIudKo+moQ6YlCOu4t rVWO/EiXfYnK7zeop26ry1RpKtogB7/O115zultAz64ydQYLe+a1e/czkALg3sgTcOOcFZTXk38e aqsXsipoX1vsNurqPtnC27TWsA7pk4uKXscFjkeUE8JZu9BDKaswZygxBOPBQBwrA5+20Wxlk6k1 e6EKaaNaNZUy30q3ArEf30ZDpXyfCtiXnupjSK8WU2cK4qsEtj09JS4+mhi0CTCrCnXAzum3tgcH cHRg0prcSzzEUDQWoFxyuqwiwhHu3sPQNmFOMwIDAQABo4IB2jCCAdYwDgYDVR0PAQH/BAQDAgGG MGAGA1UdJQRZMFcGCCsGAQUFBwMCBggrBgEFBQcDBAYKKwYBBAGCNxQCAgYKKwYBBAGCNwoDBAYJ KwYBBAGCNxUGBgorBgEEAYI3CgMMBggrBgEFBQcDBwYIKwYBBQUHAxEwEgYDVR0TAQH/BAgwBgEB /wIBADAdBgNVHQ4EFgQUljPR5lgXWzR1ioFWZNW+SN6hj88wHwYDVR0jBBgwFoAUj/BLf6guRSSu TVD6Y5qL3uLdG7wwegYIKwYBBQUHAQEEbjBsMC0GCCsGAQUFBzABhiFodHRwOi8vb2NzcC5nbG9i YWxzaWduLmNvbS9yb290cjMwOwYIKwYBBQUHMAKGL2h0dHA6Ly9zZWN1cmUuZ2xvYmFsc2lnbi5j b20vY2FjZXJ0L3Jvb3QtcjMuY3J0MDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwuZ2xvYmFs c2lnbi5jb20vcm9vdC1yMy5jcmwwWgYDVR0gBFMwUTALBgkrBgEEAaAyASgwQgYKKwYBBAGgMgEo CjA0MDIGCCsGAQUFBwIBFiZodHRwczovL3d3dy5nbG9iYWxzaWduLmNvbS9yZXBvc2l0b3J5LzAN BgkqhkiG9w0BAQsFAAOCAQEAdAXk/XCnDeAOd9nNEUvWPxblOQ/5o/q6OIeTYvoEvUUi2qHUOtbf jBGdTptFsXXe4RgjVF9b6DuizgYfy+cILmvi5hfk3Iq8MAZsgtW+A/otQsJvK2wRatLE61RbzkX8 9/OXEZ1zT7t/q2RiJqzpvV8NChxIj+P7WTtepPm9AIj0Keue+gS2qvzAZAY34ZZeRHgA7g5O4TPJ /oTd+4rgiU++wLDlcZYd/slFkaT3xg4qWDepEMjT4T1qFOQIL+ijUArYS4owpPg9NISTKa1qqKWJ jFoyms0d0GwOniIIbBvhI2MJ7BSY9MYtWVT5jJO3tsVHwj4cp92CSFuGwunFMzCCA18wggJHoAMC AQICCwQAAAAAASFYUwiiMA0GCSqGSIb3DQEBCwUAMEwxIDAeBgNVBAsTF0dsb2JhbFNpZ24gUm9v dCBDQSAtIFIzMRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTA5 MDMxODEwMDAwMFoXDTI5MDMxODEwMDAwMFowTDEgMB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENB IC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wggEiMA0GCSqG SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMJXaQeQZ4Ihb1wIO2hMoonv0FdhHFrYhy/EYCQ8eyip0E XyTLLkvhYIJG4VKrDIFHcGzdZNHr9SyjD4I9DCuul9e2FIYQebs7E4B3jAjhSdJqYi8fXvqWaN+J J5U4nwbXPsnLJlkNc96wyOkmDoMVxu9bi9IEYMpJpij2aTv2y8gokeWdimFXN6x0FNx04Druci8u nPvQu7/1PQDhBjPogiuuU6Y6FnOM3UEOIDrAtKeh6bJPkC4yYOlXy7kEkmho5TgmYHWyn3f/kRTv riBJ/K1AFUjRAjFhGV64l++td7dkmnq/X8ET75ti+w1s4FRpFqkD2m7pg5NxdsZphYIXAgMBAAGj QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSP8Et/qC5FJK5N UPpjmove4t0bvDANBgkqhkiG9w0BAQsFAAOCAQEAS0DbwFCq/sgM7/eWVEVJu5YACUGssxOGhigH M8pr5nS5ugAtrqQK0/Xx8Q+Kv3NnSoPHRHt44K9ubG8DKY4zOUXDjuS5V2yq/BKW7FPGLeQkbLmU Y/vcU2hnVj6DuM81IcPJaP7O2sJTqsyQiunwXUaMld16WCgaLx3ezQA3QY/tRG3XUyiXfvNnBB4V 14qWtNPeTCekTBtzc3b0F5nCH3oO4y0IrQocLP88q1UOD5F+NuvDV0m+4S4tfGCLw0FREyOdzvcy a5QBqJnnLDMfOjsl0oZAzjsshnjJYS8Uuu7bVW/fhO4FCU29KNhyztNiUGUe65KXgzHZs7XKR1g/ XzCCBWowggRSoAMCAQICDDfBRQmwNSI92mit0zANBgkqhkiG9w0BAQsFADBbMQswCQYDVQQGEwJC RTEZMBcGA1UEChMQR2xvYmFsU2lnbiBudi1zYTExMC8GA1UEAxMoR2xvYmFsU2lnbiBHQ0MgUjMg UGVyc29uYWxTaWduIDIgQ0EgMjAyMDAeFw0yMjA5MTAwODI5NTZaFw0yNTA5MTAwODI5NTZaMIGi MQswCQYDVQQGEwJJTjESMBAGA1UECBMJS2FybmF0YWthMRIwEAYDVQQHEwlCYW5nYWxvcmUxFjAU BgNVBAoTDUJyb2FkY29tIEluYy4xHzAdBgNVBAMTFkthbGVzaCBBbmFra3VyIFB1cmF5aWwxMjAw BgkqhkiG9w0BCQEWI2thbGVzaC1hbmFra3VyLnB1cmF5aWxAYnJvYWRjb20uY29tMIIBIjANBgkq hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxnv1Reaeezfr6NEmg3xZlh4cz9m7QCN13+j4z1scrX+b JfnV8xITT5yvwdQv3R3p7nzD/t29lTRWK3wjodUd2nImo6vBaH3JbDwleIjIWhDXLNZ4u7WIXYwx aQ8lYCdKXRsHXgGPY0+zSx9ddpqHZJlHwcvas3oKnQN9WgzZtsM7A8SJefWkNvkcOtef6bL8Ew+3 FBfXmtsPL9I2vita8gkYzunj9Nu2IM+MnsP7V/+Coy/yZDtFJHp30hDnYGzuOhJchDF9/eASvE8T T1xqJODKM9xn5xXB1qezadfdgUs8k8QAYyP/oVBafF9uqDudL6otcBnziyDBQdFCuAQN7wIDAQAB o4IB5DCCAeAwDgYDVR0PAQH/BAQDAgWgMIGjBggrBgEFBQcBAQSBljCBkzBOBggrBgEFBQcwAoZC aHR0cDovL3NlY3VyZS5nbG9iYWxzaWduLmNvbS9jYWNlcnQvZ3NnY2NyM3BlcnNvbmFsc2lnbjJj YTIwMjAuY3J0MEEGCCsGAQUFBzABhjVodHRwOi8vb2NzcC5nbG9iYWxzaWduLmNvbS9nc2djY3Iz cGVyc29uYWxzaWduMmNhMjAyMDBNBgNVHSAERjBEMEIGCisGAQQBoDIBKAowNDAyBggrBgEFBQcC ARYmaHR0cHM6Ly93d3cuZ2xvYmFsc2lnbi5jb20vcmVwb3NpdG9yeS8wCQYDVR0TBAIwADBJBgNV HR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmdsb2JhbHNpZ24uY29tL2dzZ2NjcjNwZXJzb25hbHNp Z24yY2EyMDIwLmNybDAuBgNVHREEJzAlgSNrYWxlc2gtYW5ha2t1ci5wdXJheWlsQGJyb2FkY29t LmNvbTATBgNVHSUEDDAKBggrBgEFBQcDBDAfBgNVHSMEGDAWgBSWM9HmWBdbNHWKgVZk1b5I3qGP zzAdBgNVHQ4EFgQUI3+tdStI+ABRGSqksMsiCmO9uDAwDQYJKoZIhvcNAQELBQADggEBAGfe1o9b 4wUud0FMjb/FNdc433meL15npjdYWUeioHdlCGB5UvEaMGu71QysfoDOfUNeyO9YKp0h0fm7clvo cBqeWe4CPv9TQbmLEtXKdEpj5kFZBGmav69mGTlu1A9KDQW3y0CDzCPG2Fdm4s73PnkwvemRk9E2 u9/kcZ8KWVeS+xq+XZ78kGTKQ6Wii3dMK/EHQhnDfidadoN/n+x2ySC8yyDNvy81BocnblQzvbuB a30CvRuhokNO6Jzh7ZFtjKVMzYas3oo6HXgA+slRszMu4pc+fRPO41FHjeDM76e6P5OnthhnD+NY x6xokUN65DN1bn2MkeNs0nQpizDqd0QxggJtMIICaQIBATBrMFsxCzAJBgNVBAYTAkJFMRkwFwYD VQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBSMyBQZXJzb25h bFNpZ24gMiBDQSAyMDIwAgw3wUUJsDUiPdpordMwDQYJYIZIAWUDBAIBBQCggdQwLwYJKoZIhvcN AQkEMSIEIFVdwzkuOvueEfBP5syJbbidhS7/+ScNPM7x5+I8rgN2MBgGCSqGSIb3DQEJAzELBgkq hkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTIzMTIxMjA4NDcwNFowaQYJKoZIhvcNAQkPMVwwWjAL BglghkgBZQMEASowCwYJYIZIAWUDBAEWMAsGCWCGSAFlAwQBAjAKBggqhkiG9w0DBzALBgkqhkiG 9w0BAQowCwYJKoZIhvcNAQEHMAsGCWCGSAFlAwQCATANBgkqhkiG9w0BAQEFAASCAQB0xCpgTR/e /QRYn5glRF7VI3ZB6BFySUl1Xl95Bx+m5QBriFR0E+3Oc5j0DwW+P1Xiauaf4h2aIESBfbVm8Moz Osdyq6GXu3nZ6owMBn7zHNdeJVJrJgXpEzzpMVt8ymR2mAox/ocGXeNaA1MlD9rs9Ss9Eeu33jMc MhTjFe/qmfRI7n9FM+3BIe6+4jYgtIfyDNy2307YxZ3TSDZGy/5vmTtst1cJrbYNDQbx+8GsAAXk eKbuOsBBtOO/1Lv2oCLmg0CcwsHxnyNqEQj7fdmcTMbFOsZQFSdQWCjtm6SXqMMOpLzbSsKD/Fwc RWv0iMkDMZN1trmJc/KZMqfRIavI --00000000000046679f060c4c18c0--