From patchwork Fri Dec 18 16:07:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejasree Kondoj X-Patchwork-Id: 85469 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6CB56A09FD; Fri, 18 Dec 2020 16:11:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BA7A2CAD8; Fri, 18 Dec 2020 16:11:45 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 3EA2DCAD1 for ; Fri, 18 Dec 2020 16:11:44 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BIF605e007911; Fri, 18 Dec 2020 07:11:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=w+U32lDGM4so8UvXXS9ayj3/XzMcDWDaKBHz+gTn3tI=; b=ZcsWcn5YuEkCurddGu8nGpSAqI74S9y6tqw/elvcPxHv5uiK5vNRMfr/hIJz25SaSePT mf8IurqYnUd0S8VQyACd7Tqy/yzmimfMNoj6EXJvIvBh9zKy8FRRpAwL2lwtpKBYwo5z NG0GD9pV8PFyqZMCSWX2JUKR7Ast98ZAlXJM9eLIQHCAl8H9tOGhle1/MohR0/7JzhHY x7bqEMe5ZIhFWIm4wfefkRSEXmoP4TJqMX50d5ZpOrPe6F87RnlwLQi6P8UVuOp/N7Vd SME4XyDmVTtLGQD194VbqoYzONTqW8jAL22J+ALt6G6PCv5eweCFoQ+wAmdnghCmWXyC oQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 35g4rp49pk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 18 Dec 2020 07:11:42 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 18 Dec 2020 07:11:41 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 18 Dec 2020 07:11:41 -0800 Received: from hyd1554T5810.caveonetworks.com.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id D85D53F7040; Fri, 18 Dec 2020 07:11:38 -0800 (PST) From: Tejasree Kondoj To: Akhil Goyal , Radu Nicolau CC: Tejasree Kondoj , Anoob Joseph , Ankur Dwivedi , Date: Fri, 18 Dec 2020 21:37:57 +0530 Message-ID: <20201218160757.6165-1-ktejasree@marvell.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-18_10:2020-12-18, 2020-12-18 signatures=0 Subject: [dpdk-dev] [PATCH] crypto/octeontx2: add CN98xx support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" CN98xx SoC comes up with two CPT blocks wrt CN96xx, CN93xx, to achieve higher performance. Adding support to allocate all LFs of VF with even BDF from CPT0 and all LFs of VF with odd BDF from CPT1. If LFs are not available in one block then they will be allocated from alternate block. Signed-off-by: Tejasree Kondoj --- doc/guides/cryptodevs/octeontx2.rst | 10 +++-- doc/guides/rel_notes/release_21_02.rst | 4 ++ drivers/common/octeontx2/hw/otx2_rvu.h | 1 + drivers/crypto/octeontx2/otx2_cryptodev.h | 8 +++- .../octeontx2/otx2_cryptodev_hw_access.c | 10 ++--- .../octeontx2/otx2_cryptodev_hw_access.h | 4 +- .../crypto/octeontx2/otx2_cryptodev_mbox.c | 39 +++++++++++++++---- .../crypto/octeontx2/otx2_cryptodev_mbox.h | 4 +- drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 3 +- drivers/crypto/octeontx2/otx2_cryptodev_qp.h | 2 + .../event/octeontx2/otx2_evdev_crypto_adptr.c | 8 ++-- 11 files changed, 68 insertions(+), 25 deletions(-) diff --git a/doc/guides/cryptodevs/octeontx2.rst b/doc/guides/cryptodevs/octeontx2.rst index 0a38b8662e..a07f99ffa7 100644 --- a/doc/guides/cryptodevs/octeontx2.rst +++ b/doc/guides/cryptodevs/octeontx2.rst @@ -117,11 +117,15 @@ Another way to bind the VF would be to use the ``dpdk-devbind.py`` script: .. note:: - Ensure that sufficient huge pages are available for your application:: + * For CN98xx SoC, it is recommended to use even and odd DBDF VFs to achieve + higher performance as even VF uses one crypto engine and odd one uses + another crypto engine. - echo 8 > /sys/kernel/mm/hugepages/hugepages-524288kB/nr_hugepages + * Ensure that sufficient huge pages are available for your application:: - Refer to :ref:`linux_gsg_hugepages` for more details. + echo 8 > /sys/kernel/mm/hugepages/hugepages-524288kB/nr_hugepages + + Refer to :ref:`linux_gsg_hugepages` for more details. Debugging Options ----------------- diff --git a/doc/guides/rel_notes/release_21_02.rst b/doc/guides/rel_notes/release_21_02.rst index 638f98168b..e255e0c0bc 100644 --- a/doc/guides/rel_notes/release_21_02.rst +++ b/doc/guides/rel_notes/release_21_02.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Marvell OCTEON TX2 crypto PMD.** + + * Updated the OCTEON TX2 crypto PMD with CN98xx support. + Removed Items ------------- diff --git a/drivers/common/octeontx2/hw/otx2_rvu.h b/drivers/common/octeontx2/hw/otx2_rvu.h index 0725152070..b98dbcb1cd 100644 --- a/drivers/common/octeontx2/hw/otx2_rvu.h +++ b/drivers/common/octeontx2/hw/otx2_rvu.h @@ -142,6 +142,7 @@ #define RVU_BLOCK_ADDR_SSOW (0x8ull) #define RVU_BLOCK_ADDR_TIM (0x9ull) #define RVU_BLOCK_ADDR_CPT0 (0xaull) +#define RVU_BLOCK_ADDR_CPT1 (0xbull) #define RVU_BLOCK_ADDR_NDC0 (0xcull) #define RVU_BLOCK_ADDR_NDC1 (0xdull) #define RVU_BLOCK_ADDR_NDC2 (0xeull) diff --git a/drivers/crypto/octeontx2/otx2_cryptodev.h b/drivers/crypto/octeontx2/otx2_cryptodev.h index febb4ee74d..7e8c5de839 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev.h +++ b/drivers/crypto/octeontx2/otx2_cryptodev.h @@ -13,9 +13,11 @@ /* Marvell OCTEON TX2 Crypto PMD device name */ #define CRYPTODEV_NAME_OCTEONTX2_PMD crypto_octeontx2 -#define OTX2_CPT_MAX_LFS 64 +#define OTX2_CPT_MAX_LFS 128 #define OTX2_CPT_MAX_QUEUES_PER_VF 64 +#define OTX2_CPT_MAX_BLKS 2 #define OTX2_CPT_PMD_VERSION 3 +#define OTX2_CPT_REVISION_ID_3 3 /** * Device private data @@ -29,6 +31,10 @@ struct otx2_cpt_vf { /**< Number of crypto queues attached */ uint16_t lf_msixoff[OTX2_CPT_MAX_LFS]; /**< MSI-X offsets */ + uint8_t lf_blkaddr[OTX2_CPT_MAX_LFS]; + /**< CPT0/1 BLKADDR of LFs */ + uint8_t cpt_revision; + /**< CPT revision */ uint8_t err_intr_registered:1; /**< Are error interrupts registered? */ union cpt_eng_caps hw_caps[CPT_MAX_ENG_TYPES]; diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_hw_access.c b/drivers/crypto/octeontx2/otx2_cryptodev_hw_access.c index 9e4f782734..bf90d095fe 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_hw_access.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_hw_access.c @@ -53,7 +53,7 @@ otx2_cpt_err_intr_unregister(const struct rte_cryptodev *dev) uint32_t i; for (i = 0; i < vf->nb_queues; i++) { - base = OTX2_CPT_LF_BAR2(vf, i); + base = OTX2_CPT_LF_BAR2(vf, vf->lf_blkaddr[i], i); otx2_cpt_lf_err_intr_unregister(dev, vf->lf_msixoff[i], base); } @@ -99,7 +99,7 @@ otx2_cpt_err_intr_register(const struct rte_cryptodev *dev) } for (i = 0; i < vf->nb_queues; i++) { - base = OTX2_CPT_LF_BAR2(vf, i); + base = OTX2_CPT_LF_BAR2(vf, vf->lf_blkaddr[i], i); ret = otx2_cpt_lf_err_intr_register(dev, vf->lf_msixoff[i], base); if (ret) @@ -112,7 +112,7 @@ otx2_cpt_err_intr_register(const struct rte_cryptodev *dev) intr_unregister: /* Unregister the ones already registered */ for (j = 0; j < i; j++) { - base = OTX2_CPT_LF_BAR2(vf, j); + base = OTX2_CPT_LF_BAR2(vf, vf->lf_blkaddr[j], j); otx2_cpt_lf_err_intr_unregister(dev, vf->lf_msixoff[j], base); } @@ -144,13 +144,13 @@ otx2_cpt_iq_enable(const struct rte_cryptodev *dev, /* Set engine group mask and priority */ ret = otx2_cpt_af_reg_read(dev, OTX2_CPT_AF_LF_CTL(qp->id), - &af_lf_ctl.u); + qp->blkaddr, &af_lf_ctl.u); if (ret) return ret; af_lf_ctl.s.grp = grp_mask; af_lf_ctl.s.pri = pri ? 1 : 0; ret = otx2_cpt_af_reg_write(dev, OTX2_CPT_AF_LF_CTL(qp->id), - af_lf_ctl.u); + qp->blkaddr, af_lf_ctl.u); if (ret) return ret; diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_hw_access.h b/drivers/crypto/octeontx2/otx2_cryptodev_hw_access.h index a435818e0c..f9981ea8c9 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_hw_access.h +++ b/drivers/crypto/octeontx2/otx2_cryptodev_hw_access.h @@ -44,9 +44,9 @@ #define OTX2_CPT_AF_LF_CTL(a) (0x27000ull | (uint64_t)(a) << 3) #define OTX2_CPT_AF_LF_CTL2(a) (0x29000ull | (uint64_t)(a) << 3) -#define OTX2_CPT_LF_BAR2(vf, q_id) \ +#define OTX2_CPT_LF_BAR2(vf, blk_addr, q_id) \ ((vf)->otx2_dev.bar2 + \ - ((RVU_BLOCK_ADDR_CPT0 << 20) | ((q_id) << 12))) + ((blk_addr << 20) | ((q_id) << 12))) #define OTX2_CPT_QUEUE_HI_PRIO 0x1 diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_mbox.c b/drivers/crypto/octeontx2/otx2_cryptodev_mbox.c index 75e610db5c..0a27507a82 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_mbox.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_mbox.c @@ -36,6 +36,7 @@ otx2_cpt_hardware_caps_get(const struct rte_cryptodev *dev, return -EPIPE; } + vf->cpt_revision = rsp->cpt_revision; memcpy(hw_caps, rsp->eng_caps, sizeof(union cpt_eng_caps) * CPT_MAX_ENG_TYPES); @@ -57,7 +58,7 @@ otx2_cpt_available_queues_get(const struct rte_cryptodev *dev, if (ret) return -EIO; - *nb_queues = rsp->cpt; + *nb_queues = rsp->cpt + rsp->cpt1; return 0; } @@ -66,20 +67,41 @@ otx2_cpt_queues_attach(const struct rte_cryptodev *dev, uint8_t nb_queues) { struct otx2_cpt_vf *vf = dev->data->dev_private; struct otx2_mbox *mbox = vf->otx2_dev.mbox; + int blkaddr[OTX2_CPT_MAX_BLKS]; struct rsrc_attach_req *req; + int blknum = 0; + int i; + + blkaddr[0] = RVU_BLOCK_ADDR_CPT0; + blkaddr[1] = RVU_BLOCK_ADDR_CPT1; /* Ask AF to attach required LFs */ req = otx2_mbox_alloc_msg_attach_resources(mbox); + if ((vf->cpt_revision == OTX2_CPT_REVISION_ID_3) && + (vf->otx2_dev.pf_func & 0x1)) + blknum = (blknum + 1) % OTX2_CPT_MAX_BLKS; + /* 1 LF = 1 queue */ req->cptlfs = nb_queues; - - if (otx2_mbox_process(mbox) < 0) - return -EIO; + req->cpt_blkaddr = blkaddr[blknum]; + + if (otx2_mbox_process(mbox) < 0) { + if (vf->cpt_revision == OTX2_CPT_REVISION_ID_3) { + blknum = (blknum + 1) % OTX2_CPT_MAX_BLKS; + req->cpt_blkaddr = blkaddr[blknum]; + if (otx2_mbox_process(mbox) < 0) + return -EIO; + } else { + return -EIO; + } + } /* Update number of attached queues */ vf->nb_queues = nb_queues; + for (i = 0; i < nb_queues; i++) + vf->lf_blkaddr[i] = req->cpt_blkaddr; return 0; } @@ -120,7 +142,8 @@ otx2_cpt_msix_offsets_get(const struct rte_cryptodev *dev) return ret; for (i = 0; i < vf->nb_queues; i++) - vf->lf_msixoff[i] = rsp->cptlf_msixoff[i]; + vf->lf_msixoff[i] = (vf->lf_blkaddr[i] == RVU_BLOCK_ADDR_CPT1) ? + rsp->cpt1_lf_msixoff[i] : rsp->cptlf_msixoff[i]; return 0; } @@ -144,7 +167,7 @@ otx2_cpt_send_mbox_msg(struct otx2_cpt_vf *vf) int otx2_cpt_af_reg_read(const struct rte_cryptodev *dev, uint64_t reg, - uint64_t *val) + uint8_t blkaddr, uint64_t *val) { struct otx2_cpt_vf *vf = dev->data->dev_private; struct otx2_mbox *mbox = vf->otx2_dev.mbox; @@ -166,6 +189,7 @@ otx2_cpt_af_reg_read(const struct rte_cryptodev *dev, uint64_t reg, msg->is_write = 0; msg->reg_offset = reg; msg->ret_val = val; + msg->blkaddr = blkaddr; ret = otx2_cpt_send_mbox_msg(vf); if (ret < 0) @@ -182,7 +206,7 @@ otx2_cpt_af_reg_read(const struct rte_cryptodev *dev, uint64_t reg, int otx2_cpt_af_reg_write(const struct rte_cryptodev *dev, uint64_t reg, - uint64_t val) + uint8_t blkaddr, uint64_t val) { struct otx2_cpt_vf *vf = dev->data->dev_private; struct otx2_mbox *mbox = vf->otx2_dev.mbox; @@ -202,6 +226,7 @@ otx2_cpt_af_reg_write(const struct rte_cryptodev *dev, uint64_t reg, msg->is_write = 1; msg->reg_offset = reg; msg->val = val; + msg->blkaddr = blkaddr; return otx2_cpt_send_mbox_msg(vf); } diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_mbox.h b/drivers/crypto/octeontx2/otx2_cryptodev_mbox.h index 05efb40495..03323e418c 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_mbox.h +++ b/drivers/crypto/octeontx2/otx2_cryptodev_mbox.h @@ -23,11 +23,11 @@ int otx2_cpt_msix_offsets_get(const struct rte_cryptodev *dev); __rte_internal int otx2_cpt_af_reg_read(const struct rte_cryptodev *dev, uint64_t reg, - uint64_t *val); + uint8_t blkaddr, uint64_t *val); __rte_internal int otx2_cpt_af_reg_write(const struct rte_cryptodev *dev, uint64_t reg, - uint64_t val); + uint8_t blkaddr, uint64_t val); int otx2_cpt_qp_ethdev_bind(const struct rte_cryptodev *dev, struct otx2_cpt_qp *qp, uint16_t port_id); diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c index 5f2ccc0872..faf3600d03 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c @@ -241,7 +241,8 @@ otx2_cpt_qp_create(const struct rte_cryptodev *dev, uint16_t qp_id, qp->iq_dma_addr = iova; qp->id = qp_id; - qp->base = OTX2_CPT_LF_BAR2(vf, qp_id); + qp->blkaddr = vf->lf_blkaddr[qp_id]; + qp->base = OTX2_CPT_LF_BAR2(vf, qp->blkaddr, qp_id); lmtline = vf->otx2_dev.bar2 + (RVU_BLOCK_ADDR_LMT << 20 | qp_id << 12) + diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_qp.h b/drivers/crypto/octeontx2/otx2_cryptodev_qp.h index 96ff4eb41e..189fa3db4f 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_qp.h +++ b/drivers/crypto/octeontx2/otx2_cryptodev_qp.h @@ -15,6 +15,8 @@ struct otx2_cpt_qp { uint32_t id; /**< Queue pair id */ + uint8_t blkaddr; + /**< CPT0/1 BLKADDR of LF */ uintptr_t base; /**< Base address where BAR is mapped */ void *lmtline; diff --git a/drivers/event/octeontx2/otx2_evdev_crypto_adptr.c b/drivers/event/octeontx2/otx2_evdev_crypto_adptr.c index 7197815ae6..4e8a96cb6b 100644 --- a/drivers/event/octeontx2/otx2_evdev_crypto_adptr.c +++ b/drivers/event/octeontx2/otx2_evdev_crypto_adptr.c @@ -38,13 +38,13 @@ otx2_ca_qp_add(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev, rte_memcpy(&qp->ev, event, sizeof(struct rte_event)); ret = otx2_cpt_af_reg_read(cdev, OTX2_CPT_AF_LF_CTL2(qp->id), - &af_lf_ctl2.u); + qp->blkaddr, &af_lf_ctl2.u); if (ret) return ret; af_lf_ctl2.s.sso_pf_func = otx2_sso_pf_func_get(); ret = otx2_cpt_af_reg_write(cdev, OTX2_CPT_AF_LF_CTL2(qp->id), - af_lf_ctl2.u); + qp->blkaddr, af_lf_ctl2.u); if (ret) return ret; @@ -69,13 +69,13 @@ otx2_ca_qp_del(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev, memset(&qp->ev, 0, sizeof(struct rte_event)); ret = otx2_cpt_af_reg_read(cdev, OTX2_CPT_AF_LF_CTL2(qp->id), - &af_lf_ctl2.u); + qp->blkaddr, &af_lf_ctl2.u); if (ret) return ret; af_lf_ctl2.s.sso_pf_func = 0; ret = otx2_cpt_af_reg_write(cdev, OTX2_CPT_AF_LF_CTL2(qp->id), - af_lf_ctl2.u); + qp->blkaddr, af_lf_ctl2.u); return ret; }