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 0C58CA0547; Thu, 29 Apr 2021 17:45:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B47DF4133E; Thu, 29 Apr 2021 17:44:52 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2081.outbound.protection.outlook.com [40.107.101.81]) by mails.dpdk.org (Postfix) with ESMTP id EF0EC41320 for ; Thu, 29 Apr 2021 17:44:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C1zu9I3fVPKka4OIINX5gNFDy5e738VDrf8d49ObX2Ps7EeQDR2xEu8JIZ1wglAx+CsTfLBg/kVVa4x1Evz2/+uqfUphcyQJFL5uuyoWMPSjLmSeJFpdlJl7Ze3XY1pqvnWPFpxJ1E2T4Ge6vshBQvTI0MOIeqzDdyrTROlB5/9cVQLV89yEwYoHg/BkjnYNryjAn01zqQG9xEHTRI1mGhRJPmWDT+2PcSc1TmUEDSjeKPCUW3TYTApdgPdeiWNKqD9/DE9kwSEonBp7L6YhKl4Eoew8Z/g/NUSZDjk19cusaU9cBcqQclVov/znywX5B1U+qroIUC9Eo5d9Njag2Q== 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=xrMfW9V04o7f/mg/JsFlYlTR2//wKjoVlmx6xQi0Arw=; b=lycrFi4My6Sc/TSK4kg+4ovdlm5PZ6E+6VgFEmkJ8e6bszG4g9EsfCZb8GgwxYyYodbo7BxJzcgnGWyEI6f62sJGsqoTUJffHjcTpO6yL0wVphqY0SH8j27Jg56AU09oo3U0vTPWcU9+z7wxAgvNWoCjeWcbxDiobC4P1vj/A8eTBrQFrV/NGl7ghbmJt2rXlDR/lTu4VQDj+odG63sGw0s1uvIIAKJnx5XWBdTANZ9azQCtW5vsKjMrpXZO/A8It2/TsgA5kxDxuN01mNLNYu86/+QoVTTMftwymtzuZeQRk0oB/LCBCIJrzLfIROAWPPHygltU/rAhudPjzma+Vg== 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=xrMfW9V04o7f/mg/JsFlYlTR2//wKjoVlmx6xQi0Arw=; b=KW+vMj5JrtXL9NzbSnMSyfGAO/s9cKdjlOn+6bvvZ1dqNbdJG+mrwr3gc79z/RD7pNRpw5bTm/mkXeW+zcE9SWBZaCx08yBjIFqWNVwZvLo3cqOfd0wqF0mLKA2XT3Sl9kdrPVepiA1BoGoW4RAww4lZfGmX0Ny/kT3PvQpZNOuynva4ya4b+YbG7+F6aNYhQr5cqh+hf6yLXxdVZutM2bsAd2bg1ZTcpM/NBIzr2PpH/MX5yPH3wCC51XpRGoGD2qHkCbMBBIbeJvHBUE9nj1mwpFMpfT67ksOfL9CFxQK1zj+SAtIKiZOwXZT+czHgDJfcE+ALh2uWCyjZuNOOdA== Received: from DM5PR04CA0063.namprd04.prod.outlook.com (2603:10b6:3:ef::25) by BYAPR12MB2919.namprd12.prod.outlook.com (2603:10b6:a03:12c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.25; Thu, 29 Apr 2021 15:44:48 +0000 Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ef:cafe::1e) by DM5PR04CA0063.outlook.office365.com (2603:10b6:3:ef::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.25 via Frontend Transport; Thu, 29 Apr 2021 15:44:48 +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 DM6NAM11FT039.mail.protection.outlook.com (10.13.172.83) 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:44:47 +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:44:45 +0000 From: Matan Azrad To: CC: , , , "Dekel Peled" Date: Thu, 29 Apr 2021 18:43:27 +0300 Message-ID: <20210429154335.2820028-9-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210429154335.2820028-1-matan@nvidia.com> References: <20210408204849.9543-1-shirik@nvidia.com> <20210429154335.2820028-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: f5b248b6-2cb1-4b9d-783f-08d90b25b804 X-MS-TrafficTypeDiagnostic: BYAPR12MB2919: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PDuTkpsjEphsfWzpuaZfCXd/V2YPt0h0+oIF9ICLcWYu3c1xU83M2uoUlqjNQS8umfH+OYyHMP5SsoFljzsDDYQol/sOTCvR5CYO+XFbXQ10iZFzg7EtjGC17kPBt0meKur7K2ytoDcy0hKgNWGjK09VvDihLb5XcVWoNAhSp6eSdoRlaGV6g49LQN+1wN2HmQP421MmI6QoP1xK4MQ+Xa70L2Racn+VdoW40gBKgM7N9RL7NrVc9lYJdhCoPUt/4H4u+QSBSa8WN7Iw8z5VlgLmi025/Lo86ap1aDRRKaITKV8j4TkbkCvJl+9OLsIMamdHR2O3sSBbT04BET62cK5n13PRafdHtvJqvQyj6jhjE9lYbeR4D8zth5NrQXxr4us8Rz359wUoET7jfOE0Xou6LB6AbJb0x1JMZNKCojg9u34agxMFKCKJpv/ml+WN6noeJyL0ikv3TEQmikDUc2nMe0xgw31FgI3fbkwKPKQyw5gVIiscNFLSM8K3w5i+GtUmmYO80F2i7enMXd2eDvTMYLjh+7+Gor5lRWi60NlLO7KVVIzIjOx0GYRJGJi9qC06P3eeU62yctzuRR7sYohWspil2Ks5PGLaLW7p3MT8cVCpPbbgILjLFYDvBz+OV7VrBa3MdZWsSNyKOpvn5gFiLcCwC8DCX2QMZUeZj7g= 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)(39860400002)(396003)(346002)(376002)(136003)(36840700001)(46966006)(2906002)(8936002)(82310400003)(7696005)(4326008)(478600001)(6916009)(8676002)(7636003)(1076003)(54906003)(36906005)(82740400003)(356005)(36756003)(2616005)(6286002)(186003)(316002)(16526019)(70206006)(426003)(70586007)(26005)(336012)(107886003)(6666004)(47076005)(83380400001)(36860700001)(5660300002)(86362001)(55016002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 15:44:47.7432 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5b248b6-2cb1-4b9d-783f-08d90b25b804 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: DM6NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2919 Subject: [dpdk-dev] [PATCH v2 08/16] common/mlx5: support general obj IMPORT KEK 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 IMPORT_KEK object is used to wrap (encrypt) critical security parameters, such as other keys and credentials, when those need to be passed between the device and the software. This patch add support of IMPORT_KEK object create operation. Add reading of IMPORT_KEK support capability. Add function to create general object type IMPORT_KEK, using DevX API. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 50 ++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 13 ++++++++ drivers/common/mlx5/mlx5_prm.h | 18 ++++++++++ drivers/common/mlx5/version.map | 1 + 4 files changed, 82 insertions(+) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 7e3c8b55fa..afef7a5f63 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -752,6 +752,8 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT); attr->dek = !!(general_obj_types_supported & MLX5_GENERAL_OBJ_TYPES_CAP_DEK); + attr->import_kek = !!(general_obj_types_supported & + MLX5_GENERAL_OBJ_TYPES_CAP_IMPORT_KEK); /* Add reading of other GENERAL_OBJ_TYPES_CAP bits above this line. */ attr->log_max_cq = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq); attr->log_max_qp = MLX5_GET(cmd_hca_cap, hcattr, log_max_qp); @@ -2459,3 +2461,51 @@ mlx5_devx_cmd_create_dek_obj(void *ctx, struct mlx5_devx_dek_attr *attr) dek_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id); return dek_obj; } + +/** + * Create general object of type IMPORT_KEK using DevX API. + * + * @param[in] ctx + * Context returned from mlx5 open_device() glue function. + * @param [in] attr + * Pointer to IMPORT_KEK attributes structure. + * + * @return + * The DevX object created, NULL otherwise and rte_errno is set. + */ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_import_kek_obj(void *ctx, + struct mlx5_devx_import_kek_attr *attr) +{ + uint32_t in[MLX5_ST_SZ_DW(create_import_kek_in)] = {0}; + uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0}; + struct mlx5_devx_obj *import_kek_obj = NULL; + void *ptr = NULL, *key_addr = NULL; + + import_kek_obj = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*import_kek_obj), + 0, SOCKET_ID_ANY); + if (import_kek_obj == NULL) { + DRV_LOG(ERR, "Failed to allocate IMPORT_KEK object data"); + rte_errno = ENOMEM; + return NULL; + } + ptr = MLX5_ADDR_OF(create_import_kek_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_IMPORT_KEK); + ptr = MLX5_ADDR_OF(create_import_kek_in, in, import_kek); + MLX5_SET(import_kek, ptr, key_size, attr->key_size); + key_addr = MLX5_ADDR_OF(import_kek, ptr, key); + memcpy(key_addr, (void *)(attr->key), MLX5_CRYPTO_KEY_MAX_SIZE); + import_kek_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), + out, sizeof(out)); + if (import_kek_obj->obj == NULL) { + rte_errno = errno; + DRV_LOG(ERR, "Failed to create IMPORT_KEK object using DevX."); + mlx5_free(import_kek_obj); + return NULL; + } + import_kek_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id); + return import_kek_obj; +} diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index 600577f18a..6423610dae 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.h +++ b/drivers/common/mlx5/mlx5_devx_cmds.h @@ -142,6 +142,7 @@ struct mlx5_hca_attr { uint32_t crypto:1; /* Crypto engine is supported. */ 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 regexp_num_of_engines; uint32_t log_max_ft_sampler_num:8; uint32_t geneve_tlv_opt; @@ -450,6 +451,13 @@ struct mlx5_devx_dek_attr { uint8_t key[MLX5_CRYPTO_KEY_MAX_SIZE]; }; +struct mlx5_devx_import_kek_attr { + uint64_t modify_field_select; + uint32_t state:8; + uint32_t key_size:4; + uint8_t key[MLX5_CRYPTO_KEY_MAX_SIZE]; +}; + /* mlx5_devx_cmds.c */ __rte_internal @@ -606,4 +614,9 @@ __rte_internal struct mlx5_devx_obj * mlx5_devx_cmd_create_dek_obj(void *ctx, struct mlx5_devx_dek_attr *attr); +__rte_internal +struct mlx5_devx_obj * +mlx5_devx_cmd_create_import_kek_obj(void *ctx, + struct mlx5_devx_import_kek_attr *attr); + #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */ diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 25f6f8ff00..bc339566a6 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -1119,6 +1119,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_GENEVE_TLV_OPT) #define MLX5_GENERAL_OBJ_TYPES_CAP_DEK \ (1ULL << MLX5_GENERAL_OBJ_TYPE_DEK) +#define MLX5_GENERAL_OBJ_TYPES_CAP_IMPORT_KEK \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_IMPORT_KEK) enum { MLX5_HCA_CAP_OPMOD_GET_MAX = 0, @@ -2419,6 +2421,7 @@ enum { MLX5_GENERAL_OBJ_TYPE_DEK = 0x000c, 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_FLEX_PARSE_GRAPH = 0x0022, MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO = 0x0024, MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025, @@ -2516,6 +2519,21 @@ struct mlx5_ifc_create_dek_in_bits { struct mlx5_ifc_dek_bits dek; }; +struct mlx5_ifc_import_kek_bits { + u8 modify_field_select[0x40]; + u8 state[0x8]; + u8 reserved_at_48[0xc]; + u8 key_size[0x4]; + u8 reserved_at_58[0x1a8]; + u8 key[0x400]; + u8 reserved_at_600[0x200]; +}; + +struct mlx5_ifc_create_import_kek_in_bits { + struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; + struct mlx5_ifc_import_kek_bits import_kek; +}; + enum { MLX5_VIRTQ_STATE_INIT = 0, MLX5_VIRTQ_STATE_RDY = 1, diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 2976edce0b..56a1b77b0a 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -28,6 +28,7 @@ INTERNAL { mlx5_devx_cmd_create_flow_meter_aso_obj; mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_create_dek_obj; + mlx5_devx_cmd_create_import_kek_obj; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc; mlx5_devx_cmd_flow_counter_query; -- 2.25.1