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 18DDCA0A0C; Thu, 1 Jul 2021 15:28:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A91C41314; Thu, 1 Jul 2021 15:27:23 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2083.outbound.protection.outlook.com [40.107.236.83]) by mails.dpdk.org (Postfix) with ESMTP id C919541308 for ; Thu, 1 Jul 2021 15:27:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F5FdQFGpcOzM219MDP+YwvraaSGLGjSne963WWZWLkAPM1DvuuW05V5aZGRUDJrPRaqotlujJXer9auQnNqMiR/sdUtkMdDFa3+sG0YnSjcS22tyboRuSongVZwse1BR3SxShpR49dVnJtIgt0yhpOflupDPvTy8qATuMvUSMrIo/0Bd+DdY7MfAc19i7ugQGu2SwPb5UARop762KJoAz3AS86BhIDlsRvwbo78GpaPmS0URMP69XoNpnQLODoHJ30DiKC1xjtV8h4fITYoaxp1bBHUGjXXMJqOCk6gCO1TeSyOSerBL3VZWHfix4kqR1kwW1Py8yC7CxNVnf+GRCQ== 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=9FzmoclwsRka3U4dP7hRJcgNte1dHvdZP+Y+qsECWKo=; b=KA5CVtTB5W6Etvd+oNtfX9VBYqTu8S8e4xBQaDWIG3ox4yljQLJ41hgTnZ7d4d/CRbXJCfXSDzSOzJjiY7PWRtXIXlh652kV+jhHc0fxliAmMDzdzCZAqoqHyj4l4zjEVnUYYFXedm1ysxaCGBYbg2L4VQQw5E6omURoFTdS1SNOY1W2MDz2uRTkMUoq8wB3sr4rvBJZxhb497TaFmrJhTLsjzEvGFukxoQFie1q3IpAFVY4NF79axhrJO/SlJrF4EkRdSt68+YkQ5u0mJKnWTyPLqpxUoaVFcEZdmXOZUmNi36A+En794/sQKLRlC0DuL5ybW1Th3sjYaH/PU68mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=marvell.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none 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=9FzmoclwsRka3U4dP7hRJcgNte1dHvdZP+Y+qsECWKo=; b=JtFg+Nixe5G+lhlcNBYCJ0WeRfg14mlJmoJsaZRJcaDxgGmzp3PsoHMWniqUO8nkWLR4iZNVDTwOj0nbGKtxl7FiHJoO6RGrQ/gbIxyR0OnxWgWd1GKgXKGUzaW3Ly4ZZUbCYUZ0o1ZwsUqWgEfirPOzP4ShO4vZwM+SXQjfgjICIzk2qzv46JjmUu9VWYM4HbkV0zPBZcan9aN9ABvoDowANDQ8gh5gVYAngtN6hZbh/tz4xUyy1cQakusmf4BnSa8jTj8VaAM+CTScEEy4FPR3g3nwKeZOsVAIY5LWecS37uhhGIH31Cy7e0d3G6ML567NfNGNqj/vRQT6ZVNWhw== Received: from BN8PR12CA0002.namprd12.prod.outlook.com (2603:10b6:408:60::15) by CY4PR12MB1126.namprd12.prod.outlook.com (2603:10b6:903:3d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20; Thu, 1 Jul 2021 13:27:16 +0000 Received: from BN8NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:408:60:cafe::e3) by BN8PR12CA0002.outlook.office365.com (2603:10b6:408:60::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Thu, 1 Jul 2021 13:27:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; marvell.com; dkim=none (message not signed) header.d=none;marvell.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 BN8NAM11FT042.mail.protection.outlook.com (10.13.177.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4287.22 via Frontend Transport; Thu, 1 Jul 2021 13:27:15 +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, 1 Jul 2021 13:27:05 +0000 From: Shiri Kuzin To: CC: , , Date: Thu, 1 Jul 2021 16:26:04 +0300 Message-ID: <20210701132609.53727-11-shirik@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210701132609.53727-1-shirik@nvidia.com> References: <20210509160507.224644-1-matan@nvidia.com> <20210701132609.53727-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: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4855cba-cdae-4c7e-2b7f-08d93c93f1a4 X-MS-TrafficTypeDiagnostic: CY4PR12MB1126: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:193; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iGEsWYXmq7W2zHZ5K6y3hvozWKEWWc72L3EpZlQUa1fOkqGnEswiwuXpsqRxyFo0G4QfNG3iqrOeQJqOr5mK3DrH58L4kKQPCN/9dBPpmy/pQ44S0F47B2ECjdYxXKSDcM95YGOCFO91ZKkcTkkm7a7fj3SdQZvXu8fVnxwXqyNCn216R9y8Yu1ZcmJQ78daQbE4Qy6xkPhEghS10ZqdZGAL3u51ypdl50cxgP+JBH+aFY+5uux20k3FyVGMHy/YzvCgSDLfFdNEwfbgnGvMm0iiKXMr9WBhgo2W5RQBleC5LHMIquTFMNEiaj/O3FW651J3gIPBvaSE3c5YDng/EH7I+Q6JBRNha9rm4/vhkKLLyREORtZ0IoRtpTacmQlYHbMRaoFBokva+s3byOV/pohe+6bnDVYpSOjO0LP/mw1HzvKsBpRuaz6FtgopN5cwGJcZ1Q8TBxkGd5LLXQ33cKRZiBXdBKx6txHJy7rQnRLsWuor2kjdtygI12pnmh+ofNqh/yfYrITt+TZCALbyx0jXFcFsFQHO+l0D+98RnAMmsU0r1Kiyyx1ciw0KSk8RtK1lBVH9CrWVfW7uhk4BQ+Ty0SGdZmZqGqApkoFnFTSkODu0TFVtSy+lPQ8LKLKkQMK2rHhdNp1lFwiv5frIal3NX6KqtMTpK8zzwysUFuPm6tI6ARQFdb/yuMYuKVDmiEN4eguG52h0UBK2Y1N8lg== 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)(39850400004)(346002)(136003)(376002)(396003)(36840700001)(46966006)(7696005)(5660300002)(2906002)(2616005)(8936002)(70206006)(47076005)(478600001)(1076003)(36756003)(36860700001)(82310400003)(8676002)(86362001)(6916009)(70586007)(36906005)(55016002)(54906003)(16526019)(426003)(336012)(7636003)(4326008)(107886003)(83380400001)(6286002)(26005)(316002)(356005)(82740400003)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2021 13:27:15.9724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4855cba-cdae-4c7e-2b7f-08d93c93f1a4 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: BN8NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1126 Subject: [dpdk-dev] [PATCH v5 10/15] crypto/mlx5: add maximum segments devarg 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 The mlx5 HW crypto operations are done by attaching crypto property to a memory region. Once done, every access to the memory via the crypto-enabled memory region will result with in-line encryption or decryption of the data. As a result, the design choice is to provide two types of WQEs. One is UMR WQE which sets the crypto property and the other is rdma write WQE which sends DMA command to copy data from local MR to remote MR. The size of the WQEs will be defined by a new devarg called max_segs_num. This devarg also defines the maximum segments in mbuf chain that will be supported for crypto operations. Signed-off-by: Suanming Mou Signed-off-by: Matan Azrad --- doc/guides/cryptodevs/mlx5.rst | 4 ++++ drivers/crypto/mlx5/mlx5_crypto.c | 33 +++++++++++++++++++++++++++---- drivers/crypto/mlx5/mlx5_crypto.h | 6 ++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/doc/guides/cryptodevs/mlx5.rst b/doc/guides/cryptodevs/mlx5.rst index c3632484a5..dd4705b744 100644 --- a/doc/guides/cryptodevs/mlx5.rst +++ b/doc/guides/cryptodevs/mlx5.rst @@ -120,6 +120,10 @@ Driver options The plaintext of the keytag appanded to the AES-XTS keys, default value is 0. +- ``max_segs_num`` parameter [int] + + Maximum number of mbuf chain segments(src or dest), default value is 8. + Supported NICs -------------- diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 6fd6bd1511..a6949775a9 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -21,6 +21,7 @@ #define MLX5_CRYPTO_DRIVER_NAME mlx5_crypto #define MLX5_CRYPTO_LOG_NAME pmd.crypto.mlx5 #define MLX5_CRYPTO_MAX_QPS 1024 +#define MLX5_CRYPTO_MAX_SEGS 56 #define MLX5_CRYPTO_FEATURE_FLAGS \ (RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | RTE_CRYPTODEV_FF_HW_ACCELERATED | \ @@ -496,14 +497,24 @@ mlx5_crypto_args_check_handler(const char *key, const char *val, void *opaque) DRV_LOG(WARNING, "%s: \"%s\" is an invalid integer.", key, val); return -errno; } - if (strcmp(key, "import_kek_id") == 0) + if (strcmp(key, "max_segs_num") == 0) { + if (!tmp || tmp > MLX5_CRYPTO_MAX_SEGS) { + DRV_LOG(WARNING, "Invalid max_segs_num: %d, should" + " be less than %d.", + (uint32_t)tmp, MLX5_CRYPTO_MAX_SEGS); + rte_errno = EINVAL; + return -rte_errno; + } + devarg_prms->max_segs_num = (uint32_t)tmp; + } else if (strcmp(key, "import_kek_id") == 0) { attr->session_import_kek_ptr = (uint32_t)tmp; - else if (strcmp(key, "credential_id") == 0) + } else if (strcmp(key, "credential_id") == 0) { attr->credential_pointer = (uint32_t)tmp; - else if (strcmp(key, "keytag") == 0) + } else if (strcmp(key, "keytag") == 0) { devarg_prms->keytag = tmp; - else + } else { DRV_LOG(WARNING, "Invalid key %s.", key); + } return 0; } @@ -518,6 +529,7 @@ mlx5_crypto_parse_devargs(struct rte_devargs *devargs, attr->credential_pointer = 0; attr->session_import_kek_ptr = 0; devarg_prms->keytag = 0; + devarg_prms->max_segs_num = 8; if (devargs == NULL) { DRV_LOG(ERR, "No login devargs in order to enable crypto operations in the device."); @@ -614,6 +626,7 @@ mlx5_crypto_pci_probe(struct rte_pci_driver *pci_drv, .max_nb_queue_pairs = RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS, }; + uint16_t rdmw_wqe_size; int ret; RTE_SET_USED(pci_drv); @@ -692,6 +705,18 @@ mlx5_crypto_pci_probe(struct rte_pci_driver *pci_drv, priv->mr_scache.reg_mr_cb = mlx5_common_verbs_reg_mr; priv->mr_scache.dereg_mr_cb = mlx5_common_verbs_dereg_mr; priv->keytag = rte_cpu_to_be_64(devarg_prms.keytag); + priv->max_segs_num = devarg_prms.max_segs_num; + priv->umr_wqe_size = sizeof(struct mlx5_wqe_umr_bsf_seg) + + sizeof(struct mlx5_umr_wqe) + + RTE_ALIGN(priv->max_segs_num, 4) * + sizeof(struct mlx5_wqe_dseg); + rdmw_wqe_size = sizeof(struct mlx5_rdma_write_wqe) + + sizeof(struct mlx5_wqe_dseg) * + (priv->max_segs_num <= 2 ? 2 : 2 + + RTE_ALIGN(priv->max_segs_num - 2, 4)); + priv->wqe_set_size = priv->umr_wqe_size + rdmw_wqe_size; + priv->umr_wqe_stride = priv->umr_wqe_size / MLX5_SEND_WQE_BB; + priv->max_rdmar_ds = rdmw_wqe_size / sizeof(struct mlx5_wqe_dseg); /* Register callback function for global shared MR cache management. */ if (TAILQ_EMPTY(&mlx5_crypto_priv_list)) rte_mem_event_callback_register("MLX5_MEM_EVENT_CB", diff --git a/drivers/crypto/mlx5/mlx5_crypto.h b/drivers/crypto/mlx5/mlx5_crypto.h index ad70052967..48ca1cb9a2 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.h +++ b/drivers/crypto/mlx5/mlx5_crypto.h @@ -25,12 +25,17 @@ struct mlx5_crypto_priv { struct rte_cryptodev *crypto_dev; void *uar; /* User Access Region. */ uint32_t pdn; /* Protection Domain number. */ + uint32_t max_segs_num; /* Maximum supported data segs. */ struct ibv_pd *pd; struct mlx5_hlist *dek_hlist; /* Dek hash list. */ struct rte_cryptodev_config dev_config; struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */ struct mlx5_devx_obj *login_obj; uint64_t keytag; + uint16_t wqe_set_size; + uint16_t umr_wqe_size; + uint16_t umr_wqe_stride; + uint16_t max_rdmar_ds; }; struct mlx5_crypto_qp { @@ -54,6 +59,7 @@ struct mlx5_crypto_devarg_params { bool login_devarg; struct mlx5_devx_crypto_login_attr login_attr; uint64_t keytag; + uint32_t max_segs_num; }; int -- 2.27.0