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 E79BCA0547; Thu, 29 Apr 2021 17:48:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF4A34133B; Thu, 29 Apr 2021 17:48:37 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2082.outbound.protection.outlook.com [40.107.94.82]) by mails.dpdk.org (Postfix) with ESMTP id 61BF341360 for ; Thu, 29 Apr 2021 17:48:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lNMZlTtChuSiODHobjVFfSktgsQQDdsNvK5Aeondlc2ONj4Ben0+JmvfbmXvn9QIGJE8hhi92InF2aQDKQBy4NSRyi9jKJcQARvDQETGdkg6mPNAOPnCsAsK0b54dXig4qK5cpPmyasjrCGP8Ua2WquwuZi5KZWakNzuVvdlBwZi/0AiX4i4eiIv+8npGZyiQ0R+sOZn44ndcq4ayxXLFlKbqic5FzIOCwJR7eLgQTr1nqZyUhz4gmSD+suXkxN5K6d21dXBibKyxYfkgxodKfl1miY0wpMP+dzFKBBxGXgMrwWBNKlb63/9zM6A5QHwXkC0oQpdkROrPdHo7OV09w== 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=bB9umH0+Odl2ZBEoGWqnlFGR+ICM52npfAw6cZ2TV20=; b=aDYjKx0+5Ymo1jTDV6o6vrYJQL+iEj3O3PyJof3OrCDY6s/kih/3V8C5+hLPnm7xC/yz0SSKmjCZQlsOxQNmqbNuVkLNVXXd5JGepGm9xgUYbmh6oJfeu8DwE0uHbxNXAvADK9tA0W2KcvuT1AR+akJnMZV6JTpG+4iypu9Ar/LTp1nuAWG2lO76dSysvxtTftOb+6Ith5q0COb5LJxMoKDccFR91hfarVMa6C53HGxQQwPCzktCJXi4/JMZk/8XaeOxfVUO83i/w+Zx7bo/RknU0d0Z5uAwTcTuETCGv2oD5Ase8kGFK4Ybb6HsEGj8qqI2922fo5yDzjJR17lClQ== 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=bB9umH0+Odl2ZBEoGWqnlFGR+ICM52npfAw6cZ2TV20=; b=rRjTu3uqygnUBV4oB+KMMu44HEj/8jrFhmi7SA6AzNUd05Btpn06KM5z1IR3AqJVC0NFjXps8j0VbYbRcN48ceuQnMf5RrtitDYKn5iGIIcEhQiIJOcB02TiyIvFYITomcwnz2kIxfDgB+cPORMMcBMNMAq8udYtYzdx5Z9LZ67XPjJY/iNUex2b15q2CiCktASVrcb3KwnCtO7oxgjmxRlLaaOYMUfG8e/umvi0DfbA5IgD31V6crFEfmCfk0Lv2mrNh1rJoKY53lsDl7bqUsSrEk8MLLNQVrlPcysmdnO6TPTKJT/qmnHufNP0olqRmNWTW7PySYwgn9RS1IuApw== Received: from DM5PR13CA0035.namprd13.prod.outlook.com (2603:10b6:3:7b::21) by CH0PR12MB5058.namprd12.prod.outlook.com (2603:10b6:610:e1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 29 Apr 2021 15:48:31 +0000 Received: from DM6NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:3:7b:cafe::7a) by DM5PR13CA0035.outlook.office365.com (2603:10b6:3:7b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.8 via Frontend Transport; Thu, 29 Apr 2021 15:48:31 +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 DM6NAM11FT014.mail.protection.outlook.com (10.13.173.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.32 via Frontend Transport; Thu, 29 Apr 2021 15:48:31 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 29 Apr 2021 15:48:29 +0000 From: Matan Azrad To: CC: , , Date: Thu, 29 Apr 2021 18:47:07 +0300 Message-ID: <20210429154712.2820159-11-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210429154712.2820159-1-matan@nvidia.com> References: <20210408204849.9543-1-shirik@nvidia.com> <20210429154712.2820159-1-matan@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.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: a8c5dde6-9940-443c-7008-08d90b263d7a X-MS-TrafficTypeDiagnostic: CH0PR12MB5058: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t0+DBI7RW/9kD5eZaTEt7wfbQch7ixSaEDghOZysMYKfzmmjHdjnm3En+IU46qcYROfj0CU+d3M9C95IXSlcfaMUkZ7rPVq2cPteVjL3Jewwa6YTxRnO52yfuaQ9lXWpoibDf6nhJhDPeJO4bFv0tEKhon8ubfA+Do3VmkBbsAhzcV5EzEnWnwimobHI4Pife0a3E8LK7O8ICYlUVCPS2eu8RF1ypcfuzhtgtZ3i3ep+6etWbrYu4tsJvmZlLy8w5lcC4IuRpyKSmcLdx/thK7W4ZzqwZLDqLIdVwq5sVCv2ZPxMD/3fsGYTE7TtwcXRWLqxWfPaoJTQYBW6idcc63zUXe8yt+ytIJhnsHityd66QMIEU3BEdgFLcKmfBqm0Gvn+FiWnFKuWlJUHwdC0x6JAFGyDIfAH1m/jHfZXHqG+K35XMeyEX7RDFzIMhrMxoB2KK+KKAXK9aDAoIqC/OpQD0GQpGFVVL3JTBem4BAH5oVfd9xti8rmmae+IWottVRAQ9PD0tidwSPL6pgfc4ooSgievMCooKJlrBRbbTCK2ijp9d9+oTpB5CXRYihPf4BK91f/y5e3VQZB/YP+OTCA9oU1BhKezKXCbMsBeSUc7SOM2pQNMQdnwv+9Y80B4wtQjlu6O0iRf55Y8d+bLR67XQ6TZKJ12xEz6gqzYAhs= 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)(376002)(136003)(39860400002)(396003)(346002)(46966006)(36840700001)(5660300002)(83380400001)(6286002)(36906005)(8936002)(2616005)(6916009)(36756003)(26005)(4326008)(55016002)(54906003)(478600001)(82310400003)(426003)(107886003)(70586007)(8676002)(70206006)(6666004)(186003)(356005)(7696005)(86362001)(7636003)(36860700001)(47076005)(16526019)(2906002)(1076003)(82740400003)(336012)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 15:48:31.6703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8c5dde6-9940-443c-7008-08d90b263d7a 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: DM6NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5058 Subject: [dpdk-dev] [PATCH v2 10/15] crypto/mlx5: add keytag device argument 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 A keytag is a piece of data encrypted together with a DEK. When a DEK is referenced by an MKEY.bsf through its index, the keytag is also supplied in the BSF as plaintext. The HW will decrypt the DEK (and the attached keytag) and will fail the operation if the keytags don't match. This commit adds the configuration of the keytag with devargs. Signed-off-by: Suanming Mou Signed-off-by: Matan Azrad --- drivers/crypto/mlx5/mlx5_crypto.c | 50 +++++++++++++++++-------------- drivers/crypto/mlx5/mlx5_crypto.h | 3 +- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 1dcebce04c..9f270e4382 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -468,56 +468,52 @@ mlx5_crypto_args_check_handler(const char *key, const char *val, void *opaque) attr->session_import_kek_ptr = (uint32_t)tmp; else if (strcmp(key, "credential_id") == 0) attr->credential_pointer = (uint32_t)tmp; + else if (strcmp(key, "keytag") == 0) + devarg_prms->keytag = tmp; else DRV_LOG(WARNING, "Invalid key %s.", key); return 0; } -static struct mlx5_devx_obj * -mlx5_crypto_config_login(struct rte_devargs *devargs, - struct ibv_context *ctx) +static int +mlx5_crypto_parse_devargs(struct rte_devargs *devargs, + struct mlx5_crypto_devarg_params *devarg_prms) { - /* - * Set credential pointer and session import KEK pointer to a default - * value of 0. - */ - struct mlx5_crypto_devarg_params login = { - .login_devarg = false, - .login_attr = { - .credential_pointer = 0, - .session_import_kek_ptr = 0, - } - }; + struct mlx5_devx_crypto_login_attr *attr = &devarg_prms->login_attr; struct rte_kvargs *kvlist; + /* Default values. */ + attr->credential_pointer = 0; + attr->session_import_kek_ptr = 0; + devarg_prms->keytag = 0; if (devargs == NULL) { DRV_LOG(ERR, "No login devargs in order to enable crypto operations in the device."); rte_errno = EINVAL; - return NULL; + return -1; } kvlist = rte_kvargs_parse(devargs->args, NULL); if (kvlist == NULL) { DRV_LOG(ERR, "Failed to parse devargs."); rte_errno = EINVAL; - return NULL; + return -1; } if (rte_kvargs_process(kvlist, NULL, mlx5_crypto_args_check_handler, - &login) != 0) { + devarg_prms) != 0) { DRV_LOG(ERR, "Devargs handler function Failed."); rte_kvargs_free(kvlist); rte_errno = EINVAL; - return NULL; + return -1; } rte_kvargs_free(kvlist); - if (login.login_devarg == false) { + if (devarg_prms->login_devarg == false) { DRV_LOG(ERR, "No login credential devarg in order to enable crypto operations " "in the device."); rte_errno = EINVAL; - return NULL; + return -1; } - return mlx5_devx_cmd_create_crypto_login_obj(ctx, &login.login_attr); + return 0; } /** @@ -543,6 +539,7 @@ mlx5_crypto_pci_probe(struct rte_pci_driver *pci_drv, struct ibv_context *ctx; struct mlx5_devx_obj *login; struct mlx5_crypto_priv *priv; + struct mlx5_crypto_devarg_params devarg_prms = { 0 }; struct mlx5_hca_attr attr = { 0 }; struct rte_cryptodev_pmd_init_params init_params = { .name = "", @@ -551,6 +548,8 @@ mlx5_crypto_pci_probe(struct rte_pci_driver *pci_drv, .max_nb_queue_pairs = RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS, }; + int ret; + RTE_SET_USED(pci_drv); if (rte_eal_process_type() != RTE_PROC_PRIMARY) { DRV_LOG(ERR, "Non-primary process type is not supported."); @@ -580,7 +579,13 @@ mlx5_crypto_pci_probe(struct rte_pci_driver *pci_drv, rte_errno = ENOTSUP; return -ENOTSUP; } - login = mlx5_crypto_config_login(pci_dev->device.devargs, ctx); + ret = mlx5_crypto_parse_devargs(pci_dev->device.devargs, &devarg_prms); + if (ret) { + DRV_LOG(ERR, "Failed to parse devargs."); + return -rte_errno; + } + login = mlx5_devx_cmd_create_crypto_login_obj(ctx, + &devarg_prms.login_attr); if (login == NULL) { DRV_LOG(ERR, "Failed to configure login."); return -rte_errno; @@ -620,6 +625,7 @@ 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); pthread_mutex_lock(&priv_list_lock); TAILQ_INSERT_TAIL(&mlx5_crypto_priv_list, priv, next); pthread_mutex_unlock(&priv_list_lock); diff --git a/drivers/crypto/mlx5/mlx5_crypto.h b/drivers/crypto/mlx5/mlx5_crypto.h index 0aef804b92..34c65f9a24 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.h +++ b/drivers/crypto/mlx5/mlx5_crypto.h @@ -30,6 +30,7 @@ struct mlx5_crypto_priv { 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; }; struct mlx5_crypto_qp { @@ -49,10 +50,10 @@ struct mlx5_crypto_dek { bool size_is_48; /* Whether the key\data size is 48 bytes or not. */ }; - struct mlx5_crypto_devarg_params { bool login_devarg; struct mlx5_devx_crypto_login_attr login_attr; + uint64_t keytag; }; int -- 2.25.1