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 F1C40A0A02; Tue, 4 May 2021 19:57:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1903410DB; Tue, 4 May 2021 19:57:12 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2067.outbound.protection.outlook.com [40.107.236.67]) by mails.dpdk.org (Postfix) with ESMTP id 5A659410DB for ; Tue, 4 May 2021 19:57:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dz0Ecv1PY8qcJic9j1uCnLLUG78umcli5py4mj2VHmGl0x2N/FqZuHkNhv/ndzxrHFQtN+zUlSsYLbOffo++/zqWEQYNT04uj5krQmVxzVg7mUMr7hgWnLOJac6LPQyyrdLlL1qWpiRVShSIFW8G34FYsoIkCMWzmJZPZMvNR21lu7YHdf6WtWT9MTA4GzZL9uND/GK55JsnDG6Lsp+N6nGcZi/2qFqYGiUYyxyVN3HJkPEg9y4jn2RXiNryAL5YLcSOI36dqwkcLz2sAAhGHXXMygRaEvK41hPWIhFx62IV9d4wtWimUXo9bvkEIV/mqwT57nrl+eaBrVOyPsL1kw== 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=eldTWrj598M/tCPZ6qAJ+aLJpc5tdmKvKqI2iCrZuxA=; b=FQiFuGuu8HNnepSqOVzCyZimjeWJeBrv85mEgtj6ZSRIGZAaBvb9U/ZIb5OVjOMzSDjeTRjflBgaxvMkheg4ZwSK6wDhqp6S0NKmyvAL9seLLpwNioO3HlhrSbobbq4elJY1tLjdy8Vh2tTPDL3NMUlrRqkyWnFWgeWZSe68xANIt/2lzOejZVB6QjhjT8bxfyTSI3rQKW9fSQxKRt+jhAfdH0YVCLWfMG809XW3soGbg7UHAPuuIkECVv9lMpo5DkScxfETmVN95I9PEuY84Dbffrd4hDbikZdbhiAOwawjrX0FefhqPYybZQ9KOb1eENceD2CXe0BdI5ly2I4NvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net 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=eldTWrj598M/tCPZ6qAJ+aLJpc5tdmKvKqI2iCrZuxA=; b=MnlkXD3J6UCllmjw/zS7BYYO1MlqtFVIiWTioWSAxUav5AdLrK+NBUet+K46PF2v9E+o9uTJ9eB5NDIJkUeLgGreAy5RWXWWQyu6SYDBSr7TY09Hje2OW/CT0XZL6gOcuMoRZhathlI5FrtstRzK27or9uMA3k3s/kYoiGUxnQfvcUv8IK/5gzBuC3gqwnwT8sQbcDwmq2LJ5ms7xJ5bNbmr3ZXcBZwZct0QTF08FAsN+aURvhFtOYFYuwRE7zw5+BBGX2koEms/PjPENRLAykR8zpyA1EUhGMzp5WPKlg9xtTmoCZdlt3Pr/ZaOPuZGcQkpDbgOdNLCgQ/o4YXclg== Received: from DS7PR03CA0136.namprd03.prod.outlook.com (2603:10b6:5:3b4::21) by MW2PR12MB4666.namprd12.prod.outlook.com (2603:10b6:302:13::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.42; Tue, 4 May 2021 17:57:07 +0000 Received: from DM6NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b4:cafe::b9) by DS7PR03CA0136.outlook.office365.com (2603:10b6:5:3b4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Tue, 4 May 2021 17:57:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 DM6NAM11FT019.mail.protection.outlook.com (10.13.172.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.27 via Frontend Transport; Tue, 4 May 2021 17:57:07 +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; Tue, 4 May 2021 17:57:05 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:57 +0300 Message-ID: <20210504175500.3385811-13-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210504175500.3385811-1-matan@nvidia.com> References: <20210429154335.2820028-1-matan@nvidia.com> <20210504175500.3385811-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: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b1895579-2fd9-46ff-3c6f-08d90f26084b X-MS-TrafficTypeDiagnostic: MW2PR12MB4666: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4W2bexXFi6vz3OtwF/no6CmX2o2EkqsnwV87nr179CeYiV3Ysg6LB2q6HiLR+uiQVZTPxEyuGnsvrEg1HAljCGvZ3uhNdu8qFcUkX2QB3kEpsW4Ct1tHSpLsIawcO+Tz3+17JrM+enHg3aPu8NhG+F/Uriopo1dDjI2DAtArJuAWC9dn6dAeoRy+Fv0XSlUnKUhVtfomu8FMy+0JNZcbNJrV/DImCZ329j79PdeRSSU8Yt85eg+FY3ZEHb6Lz8SbmG5ZfelPi6kOkZfGkLnXhNgjwyUIZbgFmIoUU/ed4rtI7UkRAiganw5d5Tj0+PCKuYS25Q5o2XVNgm6gJ2b5trSZadT87RtGTVLdwyRV6agiev600YdKpsygxzSEWcdHqtWFrAQ3GzFllD0PNhU8RhnTCkwB4w3NFoI5u2gZwzJgAh1Pbs0LAK73/pAxKkY2+PsY/KU6U/3yQNaLRK8A/3reguUg4UT1gTOQ7sUMf0QZv+APHhvZKL82Qbj5Lr8n3vlX74ugOcd62rjYV9RcMW2DO1vfc5LKQwmTtVNqJJpfS2cU8ahAAlxRhM2nxo1jvEgNrHORFACJj2ZvBKg94SzS9vkO7LDtnOuUNuedAxs/2ISHjGzWkhLt1BHhZ3fEokVi28woZ4O7QhQo2pxFDG6R7NOsDtha1PE6j7hVXZ0= 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)(346002)(376002)(136003)(396003)(39860400002)(46966006)(36840700001)(6916009)(2906002)(82310400003)(54906003)(316002)(5660300002)(6666004)(55016002)(8676002)(8936002)(36906005)(4326008)(1076003)(47076005)(426003)(7696005)(82740400003)(356005)(7636003)(86362001)(70206006)(36756003)(36860700001)(6286002)(107886003)(478600001)(16526019)(70586007)(2616005)(336012)(186003)(83380400001)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:57:07.0808 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1895579-2fd9-46ff-3c6f-08d90f26084b 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: DM6NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB4666 Subject: [dpdk-dev] [PATCH v3 12/15] common/mlx5: support general obj CREDENTIAL create 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: Dekel Peled CREDENTIAL object is used for any crypto operation in wrapped mode. This patch add support of CREDENTIAL object create operation. Add reading of CREDENTIAL support capability. Add function to create general object type CREDENTIAL, using DevX API. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 53 +++++++++++++++++++++++++++- drivers/common/mlx5/mlx5_devx_cmds.h | 17 +++++++-- drivers/common/mlx5/mlx5_prm.h | 23 ++++++++++++ drivers/common/mlx5/version.map | 1 + 4 files changed, 91 insertions(+), 3 deletions(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index c0061741e8..c0a0853c3a 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -754,6 +754,8 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, MLX5_GENERAL_OBJ_TYPES_CAP_DEK); attr->import_kek = !!(general_obj_types_supported & MLX5_GENERAL_OBJ_TYPES_CAP_IMPORT_KEK); + attr->credential = !!(general_obj_types_supported & + MLX5_GENERAL_OBJ_TYPES_CAP_CREDENTIAL); attr->crypto_login = !!(general_obj_types_supported & MLX5_GENERAL_OBJ_TYPES_CAP_CRYPTO_LOGIN); /* Add reading of other GENERAL_OBJ_TYPES_CAP bits above this line. */ @@ -2512,6 +2514,55 @@ mlx5_devx_cmd_create_import_kek_obj(void *ctx, return import_kek_obj; } +/** + * Create general object of type CREDENTIAL using DevX API. + * + * @param[in] ctx + * Context returned from mlx5 open_device() glue function. + * @param [in] attr + * Pointer to CREDENTIAL attributes structure. + * + * @return + * The DevX object created, NULL otherwise and rte_errno is set. + */ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_credential_obj(void *ctx, + struct mlx5_devx_credential_attr *attr) +{ + uint32_t in[MLX5_ST_SZ_DW(create_credential_in)] = {0}; + uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0}; + struct mlx5_devx_obj *credential_obj = NULL; + void *ptr = NULL, *credential_addr = NULL; + + credential_obj = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*credential_obj), + 0, SOCKET_ID_ANY); + if (credential_obj == NULL) { + DRV_LOG(ERR, "Failed to allocate CREDENTIAL object data"); + rte_errno = ENOMEM; + return NULL; + } + ptr = MLX5_ADDR_OF(create_credential_in, in, hdr); + MLX5_SET(general_obj_in_cmd_hdr, ptr, opcode, + MLX5_CMD_OP_CREATE_GENERAL_OBJECT); + MLX5_SET(general_obj_in_cmd_hdr, ptr, obj_type, + MLX5_GENERAL_OBJ_TYPE_CREDENTIAL); + ptr = MLX5_ADDR_OF(create_credential_in, in, credential); + MLX5_SET(credential, ptr, credential_role, attr->credential_role); + credential_addr = MLX5_ADDR_OF(credential, ptr, credential); + memcpy(credential_addr, (void *)(attr->credential), + MLX5_CRYPTO_CREDENTIAL_SIZE); + credential_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), + out, sizeof(out)); + if (credential_obj->obj == NULL) { + rte_errno = errno; + DRV_LOG(ERR, "Failed to create CREDENTIAL object using DevX."); + mlx5_free(credential_obj); + return NULL; + } + credential_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id); + return credential_obj; +} + /** * Create general object of type CRYPTO_LOGIN using DevX API. * @@ -2551,7 +2602,7 @@ mlx5_devx_cmd_create_crypto_login_obj(void *ctx, attr->session_import_kek_ptr); credential_addr = MLX5_ADDR_OF(crypto_login, ptr, credential); memcpy(credential_addr, (void *)(attr->credential), - MLX5_CRYPTO_LOGIN_CREDENTIAL_SIZE); + MLX5_CRYPTO_CREDENTIAL_SIZE); crypto_login_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out)); if (crypto_login_obj->obj == NULL) { diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index 709e28bfba..811e7a1462 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.h +++ b/drivers/common/mlx5/mlx5_devx_cmds.h @@ -143,6 +143,7 @@ struct mlx5_hca_attr { uint32_t aes_xts:1; /* AES-XTS crypto is supported. */ uint32_t dek:1; /* General obj type DEK is supported. */ uint32_t import_kek:1; /* General obj type IMPORT_KEK supported. */ + uint32_t credential:1; /* General obj type CREDENTIAL supported. */ uint32_t crypto_login:1; /* General obj type CRYPTO_LOGIN supported. */ uint32_t regexp_num_of_engines; uint32_t log_max_ft_sampler_num:8; @@ -459,13 +460,20 @@ struct mlx5_devx_import_kek_attr { uint8_t key[MLX5_CRYPTO_KEY_MAX_SIZE]; }; -#define MLX5_CRYPTO_LOGIN_CREDENTIAL_SIZE 48 +#define MLX5_CRYPTO_CREDENTIAL_SIZE 48 + +struct mlx5_devx_credential_attr { + uint64_t modify_field_select; + uint32_t state:8; + uint32_t credential_role:8; + uint8_t credential[MLX5_CRYPTO_CREDENTIAL_SIZE]; +}; struct mlx5_devx_crypto_login_attr { uint64_t modify_field_select; uint32_t credential_pointer:24; uint32_t session_import_kek_ptr:24; - uint8_t credential[MLX5_CRYPTO_LOGIN_CREDENTIAL_SIZE]; + uint8_t credential[MLX5_CRYPTO_CREDENTIAL_SIZE]; }; /* mlx5_devx_cmds.c */ @@ -629,6 +637,11 @@ struct mlx5_devx_obj * mlx5_devx_cmd_create_import_kek_obj(void *ctx, struct mlx5_devx_import_kek_attr *attr); +__rte_internal +struct mlx5_devx_obj * +mlx5_devx_cmd_create_credential_obj(void *ctx, + struct mlx5_devx_credential_attr *attr); + __rte_internal struct mlx5_devx_obj * mlx5_devx_cmd_create_crypto_login_obj(void *ctx, diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index a9dcbfa63c..432c8fdb63 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -1187,6 +1187,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_DEK) #define MLX5_GENERAL_OBJ_TYPES_CAP_IMPORT_KEK \ (1ULL << MLX5_GENERAL_OBJ_TYPE_IMPORT_KEK) +#define MLX5_GENERAL_OBJ_TYPES_CAP_CREDENTIAL \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_CREDENTIAL) #define MLX5_GENERAL_OBJ_TYPES_CAP_CRYPTO_LOGIN \ (1ULL << MLX5_GENERAL_OBJ_TYPE_CRYPTO_LOGIN) @@ -2490,6 +2492,7 @@ enum { MLX5_GENERAL_OBJ_TYPE_VIRTQ = 0x000d, MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS = 0x001c, MLX5_GENERAL_OBJ_TYPE_IMPORT_KEK = 0x001d, + MLX5_GENERAL_OBJ_TYPE_CREDENTIAL = 0x001e, MLX5_GENERAL_OBJ_TYPE_CRYPTO_LOGIN = 0x001f, MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH = 0x0022, MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO = 0x0024, @@ -2603,6 +2606,26 @@ struct mlx5_ifc_create_import_kek_in_bits { struct mlx5_ifc_import_kek_bits import_kek; }; +enum { + MLX5_CREDENTIAL_ROLE_OFFICER = 0x0, + MLX5_CREDENTIAL_ROLE_USER = 0x1, +}; + +struct mlx5_ifc_credential_bits { + u8 modify_field_select[0x40]; + u8 state[0x8]; + u8 reserved_at_48[0x10]; + u8 credential_role[0x8]; + u8 reserved_at_60[0x1a0]; + u8 credential[0x180]; + u8 reserved_at_380[0x480]; +}; + +struct mlx5_ifc_create_credential_in_bits { + struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; + struct mlx5_ifc_credential_bits credential; +}; + struct mlx5_ifc_crypto_login_bits { u8 modify_field_select[0x40]; u8 reserved_at_40[0x48]; diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 5706c6bbef..04b2179b2c 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -16,6 +16,7 @@ INTERNAL { mlx5_devx_cmd_alloc_pd; mlx5_devx_cmd_create_cq; + mlx5_devx_cmd_create_credential_obj; mlx5_devx_cmd_create_crypto_login_obj; mlx5_devx_cmd_create_dek_obj; mlx5_devx_cmd_create_flex_parser; -- 2.25.1