From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DCDADA0C41; Thu, 15 Jul 2021 18:43:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1362141337; Thu, 15 Jul 2021 18:42:28 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2044.outbound.protection.outlook.com [40.107.94.44]) by mails.dpdk.org (Postfix) with ESMTP id 5B07441284 for ; Thu, 15 Jul 2021 18:42:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V9JfSM7QobuL3DWWJUf1Sf84x9xkpjESjgvEmqXoxolf4NpPWS41jQIdWcQ7tivAan+rv4ZHUhwPoQxRph9QcJaA55Ch/nwTDO9jexs/yALk982sqcewL+rj0bBQxhfegbhLkNuWkWDRs8uhjxZZZbSBKQLyNkyb5nQfCbH0hmMdglQcfsJt2BsNfZy6wYBavUNuOlM4x+iv7NDTn8EKjUxXe7j+KgBt8V8VvnFURu7I27uSMhT1YeYcPE3LGpK+OY7BqWjW3+JL+/UlV8Ze9b+4joi/4uKT4bwM6/Y+73t14O/kx/BhpKTViudYvyBeft8o/r+vhVb1gZG57aJx2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wVwQ7Eqq76RE+rii2v4RFdk1WzYL7s/6A3OWdXzqUwg=; b=LvwMWl1HAqSNifubZ/d10myoUpW6+7LGr+s9jkpk2PqfHl+i9bWwH7+DgVXA/gTdgVDLsdotBHBCH5WMCn9QGmfphyHpAkQg7knMDt5PkW/FWa3EOBd0KjAym9b+KUHD/oTq2Brx6l8/OOkfeQsRVDbEZCLEUnFOTVnJzHNby68WCrrBZx5gyu1qpOzleoJbw1LlJjwPhmYrLSDj3iDe5ALzqu6VkbHeWo8ZQZ+Zr/e6T9/PNqv8juncg44PmVVVR/Ye3Zwa/nDJougwENuwcbP1VDITYTPrefms/n/HzpTOVVcp6SGMAvGxbn9kqJ0+zAo9c+2vbBEMY0i91QBDOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wVwQ7Eqq76RE+rii2v4RFdk1WzYL7s/6A3OWdXzqUwg=; b=KZ1DYnpdpO9uN4dogAVqRBK94NG6QwYIBCJkO+cSHoqwsg9pTr5TmIww0UbGC82hfa6oxkPT5UO2jKvAZkkhiyH602fdGTB9ZFUiF2Kh/3kjM83hnwirlXyAyUO4x9q8a5sBbXfgLVIz739ekdDF7pGYvZUXl8Ph8H8uQpfsxz/n0MyOZh5ok/gaLr+ZJexDSUNIT+kilPlYyWMP4wb28oi7W+WAV3rZamGwPyZBsreFY7rQWhRwSklAs9B47IjwECanly2K5PLs8+9u1/JKSvGWxs4t71PtBs3YdmVoIFWbaRtgLXq0gGC0SUEy9FtKfq++ARmzSosnYvj8fWUKwQ== Received: from MW4P221CA0001.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::6) by SN1PR12MB2399.namprd12.prod.outlook.com (2603:10b6:802:2b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Thu, 15 Jul 2021 16:42:20 +0000 Received: from CO1NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::17) by MW4P221CA0001.outlook.office365.com (2603:10b6:303:8b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 16:42:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT015.mail.protection.outlook.com (10.13.175.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 16:42:20 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 15 Jul 2021 16:42:17 +0000 From: Shiri Kuzin To: CC: , , , Date: Thu, 15 Jul 2021 19:41:21 +0300 Message-ID: <20210715164126.54073-12-shirik@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210715164126.54073-1-shirik@nvidia.com> References: <20210715150817.51485-1-shirik@nvidia.com> <20210715164126.54073-1-shirik@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 384f8a86-6741-4fcf-daf7-08d947af83c7 X-MS-TrafficTypeDiagnostic: SN1PR12MB2399: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:295; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z1w3nn/z9UpkBWd70ZqpAdWx0J54rK0xMsIJEIVCRACj3aYqgvQxxcaBBU8/C2IHvbCbk2Cs1ugUSwWowz6l4k/Yqja+849yORlHCrM2g1UihHYojzGolAstNKAMnob7prjV8KiMhzruadtYAf9+igDRyzWQSoMZdTGsIoUnxzA5m2w8mltR+ugCGFj8K6GrnkzESGCgaVE68QArzx0bpAqnXrL+AQVIXtgFa5reNsqYzDQkDZcNMnCB6ZgYtHv8a0JuJqcPUVwNe0BCmRYdDCgSO9Mw6r/vkaq6/u3CvIG+AKwvHNeaaJ//y9CjCFCb1lJ6hoxR5OSjibxwI0HxIcAmq36Oqk7pBJ25MteSBx41uRJT4uMbo6j98/mZ+AXLL6bkyFENcoFphGKUyOn7VUGjku+B1CdRlAIfmq9zXPxwJBukVh8jWkU0OkSPKhLO0cKvBd2eOfQu7XyImPZJQPleAg6FWu4uMgw5DT0goac/pqLAUygcF0DFEpYDobOeGD7YXCFRVK2PmSRQ+hey7PAzF4BYfzxrAczfHFVt0aEb0LrvoXkcUMAClU3dcos7+R1B5sim6NI70ng7d6kcFCnnCtOB6AYVtbPjZ8TiLKNiaOwZ2P1gJLDHkqE54hBD7QlyAjuO9vaIIY9TrSq9NdlbebT4HtfcyUCg9dHgiVImr5rUX2Az2ZfYejmLUXRsE9q/ZfgRLDthLJ6xMfAS+txhtScBVitu2q7ji8zMtNQ= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(136003)(39860400002)(396003)(346002)(376002)(46966006)(36840700001)(82310400003)(34020700004)(356005)(83380400001)(7636003)(2906002)(7696005)(36906005)(316002)(36756003)(86362001)(55016002)(54906003)(36860700001)(47076005)(82740400003)(26005)(5660300002)(8936002)(6666004)(8676002)(70586007)(70206006)(16526019)(478600001)(186003)(4326008)(6286002)(2616005)(336012)(426003)(6916009)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 16:42:20.4608 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 384f8a86-6741-4fcf-daf7-08d947af83c7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2399 Subject: [dpdk-dev] [PATCH v8 11/16] crypto/mlx5: add WQE set initialization X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Suanming Mou Currently, HW handles the WQEs much faster than the software, Using the constant WQE set layout can initialize most of the WQE segments in advanced, and software only needs to configure very limited segments in datapath. This accelerates the software WQE organize in datapath. This commit initializes the fixed WQE set segments. Signed-off-by: Suanming Mou Signed-off-by: Matan Azrad --- drivers/crypto/mlx5/mlx5_crypto.c | 83 +++++++++++++++++++++++++++++-- drivers/crypto/mlx5/mlx5_crypto.h | 10 +++- 2 files changed, 87 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index fc251f3f4c..e5f8d96ff7 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -297,6 +297,69 @@ mlx5_crypto_qp2rts(struct mlx5_crypto_qp *qp) return 0; } +static void +mlx5_crypto_qp_init(struct mlx5_crypto_priv *priv, struct mlx5_crypto_qp *qp) +{ + uint32_t i; + + for (i = 0 ; i < qp->entries_n; i++) { + struct mlx5_wqe_cseg *cseg = RTE_PTR_ADD(qp->umem_buf, i * + priv->wqe_set_size); + struct mlx5_wqe_umr_cseg *ucseg = (struct mlx5_wqe_umr_cseg *) + (cseg + 1); + struct mlx5_wqe_umr_bsf_seg *bsf = + (struct mlx5_wqe_umr_bsf_seg *)(RTE_PTR_ADD(cseg, + priv->umr_wqe_size)) - 1; + struct mlx5_wqe_rseg *rseg; + + /* Init UMR WQE. */ + cseg->sq_ds = rte_cpu_to_be_32((qp->qp_obj->id << 8) | + (priv->umr_wqe_size / MLX5_WSEG_SIZE)); + cseg->flags = RTE_BE32(MLX5_COMP_ONLY_FIRST_ERR << + MLX5_COMP_MODE_OFFSET); + cseg->misc = rte_cpu_to_be_32(qp->mkey[i]->id); + ucseg->if_cf_toe_cq_res = RTE_BE32(1u << MLX5_UMRC_IF_OFFSET); + ucseg->mkey_mask = RTE_BE64(1u << 0); /* Mkey length bit. */ + ucseg->ko_to_bs = rte_cpu_to_be_32 + ((RTE_ALIGN(priv->max_segs_num, 4u) << + MLX5_UMRC_KO_OFFSET) | (4 << MLX5_UMRC_TO_BS_OFFSET)); + bsf->keytag = priv->keytag; + /* Init RDMA WRITE WQE. */ + cseg = RTE_PTR_ADD(cseg, priv->umr_wqe_size); + cseg->flags = RTE_BE32((MLX5_COMP_ALWAYS << + MLX5_COMP_MODE_OFFSET) | + MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE); + rseg = (struct mlx5_wqe_rseg *)(cseg + 1); + rseg->rkey = rte_cpu_to_be_32(qp->mkey[i]->id); + } +} + +static int +mlx5_crypto_indirect_mkeys_prepare(struct mlx5_crypto_priv *priv, + struct mlx5_crypto_qp *qp) +{ + struct mlx5_umr_wqe *umr; + uint32_t i; + struct mlx5_devx_mkey_attr attr = { + .pd = priv->pdn, + .umr_en = 1, + .crypto_en = 1, + .set_remote_rw = 1, + .klm_num = RTE_ALIGN(priv->max_segs_num, 4), + }; + + for (umr = (struct mlx5_umr_wqe *)qp->umem_buf, i = 0; + i < qp->entries_n; i++, umr = RTE_PTR_ADD(umr, priv->wqe_set_size)) { + attr.klm_array = (struct mlx5_klm *)&umr->kseg[0]; + qp->mkey[i] = mlx5_devx_cmd_mkey_create(priv->ctx, &attr); + if (!qp->mkey[i]) { + DRV_LOG(ERR, "Failed to allocate indirect mkey."); + return -1; + } + } + return 0; +} + static int mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf, @@ -307,7 +370,7 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, struct mlx5_crypto_qp *qp; uint16_t log_nb_desc = rte_log2_u32(qp_conf->nb_descriptors); uint32_t umem_size = RTE_BIT32(log_nb_desc) * - MLX5_CRYPTO_WQE_SET_SIZE + + priv->wqe_set_size + sizeof(*qp->db_rec) * 2; uint32_t alloc_size = sizeof(*qp); struct mlx5_devx_cq_attr cq_attr = { @@ -317,7 +380,9 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, if (dev->data->queue_pairs[qp_id] != NULL) mlx5_crypto_queue_pair_release(dev, qp_id); alloc_size = RTE_ALIGN(alloc_size, RTE_CACHE_LINE_SIZE); - alloc_size += sizeof(struct rte_crypto_op *) * RTE_BIT32(log_nb_desc); + alloc_size += (sizeof(struct rte_crypto_op *) + + sizeof(struct mlx5_devx_obj *)) * + RTE_BIT32(log_nb_desc); qp = rte_zmalloc_socket(__func__, alloc_size, RTE_CACHE_LINE_SIZE, socket_id); if (qp == NULL) { @@ -362,8 +427,7 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, attr.wq_umem_id = qp->umem_obj->umem_id; attr.wq_umem_offset = 0; attr.dbr_umem_id = qp->umem_obj->umem_id; - attr.dbr_address = RTE_BIT64(log_nb_desc) * - MLX5_CRYPTO_WQE_SET_SIZE; + attr.dbr_address = RTE_BIT64(log_nb_desc) * priv->wqe_set_size; qp->qp_obj = mlx5_devx_cmd_create_qp(priv->ctx, &attr); if (qp->qp_obj == NULL) { DRV_LOG(ERR, "Failed to create QP(%u).", rte_errno); @@ -372,8 +436,17 @@ mlx5_crypto_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, qp->db_rec = RTE_PTR_ADD(qp->umem_buf, (uintptr_t)attr.dbr_address); if (mlx5_crypto_qp2rts(qp)) goto error; - qp->ops = (struct rte_crypto_op **)RTE_ALIGN((uintptr_t)(qp + 1), + qp->mkey = (struct mlx5_devx_obj **)RTE_ALIGN((uintptr_t)(qp + 1), RTE_CACHE_LINE_SIZE); + qp->ops = (struct rte_crypto_op **)(qp->mkey + RTE_BIT32(log_nb_desc)); + qp->entries_n = 1 << log_nb_desc; + if (mlx5_crypto_indirect_mkeys_prepare(priv, qp)) { + DRV_LOG(ERR, "Cannot allocate indirect memory regions."); + rte_errno = ENOMEM; + goto error; + } + mlx5_crypto_qp_init(priv, qp); + qp->priv = priv; dev->data->queue_pairs[qp_id] = qp; return 0; error: diff --git a/drivers/crypto/mlx5/mlx5_crypto.h b/drivers/crypto/mlx5/mlx5_crypto.h index 7a386fe76a..d9b1ff8e99 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.h +++ b/drivers/crypto/mlx5/mlx5_crypto.h @@ -16,7 +16,6 @@ #define MLX5_CRYPTO_DEK_HTABLE_SZ (1 << 11) #define MLX5_CRYPTO_KEY_LENGTH 80 -#define MLX5_CRYPTO_WQE_SET_SIZE 1024 struct mlx5_crypto_priv { TAILQ_ENTRY(mlx5_crypto_priv) next; @@ -24,6 +23,7 @@ struct mlx5_crypto_priv { struct rte_pci_device *pci_dev; struct rte_cryptodev *crypto_dev; void *uar; /* User Access Region. */ + volatile uint64_t *uar_addr; uint32_t pdn; /* Protection Domain number. */ uint32_t max_segs_num; /* Maximum supported data segs. */ struct ibv_pd *pd; @@ -39,13 +39,21 @@ struct mlx5_crypto_priv { }; struct mlx5_crypto_qp { + struct mlx5_crypto_priv *priv; struct mlx5_devx_cq cq_obj; struct mlx5_devx_obj *qp_obj; + struct rte_cryptodev_stats stats; struct mlx5dv_devx_umem *umem_obj; void *umem_buf; volatile uint32_t *db_rec; struct rte_crypto_op **ops; + struct mlx5_devx_obj **mkey; /* WQE's indirect mekys. */ struct mlx5_mr_ctrl mr_ctrl; + uint8_t *wqe; + uint16_t entries_n; + uint16_t pi; + uint16_t ci; + uint16_t db_pi; }; struct mlx5_crypto_dek { -- 2.27.0