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 CCEC4A0547; Thu, 29 Apr 2021 17:45:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6D3F841348; Thu, 29 Apr 2021 17:45:00 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.78]) by mails.dpdk.org (Postfix) with ESMTP id 6ABC141345 for ; Thu, 29 Apr 2021 17:44:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ljNLz5PgFHvn6ijpd4+OhHiZRW4gNHbkaIbaD+1790WcHgN1Cn956giyxIkhVm2mXfoldLFh0gUnU8AblG9R7rRshnc8GOH36+Kk16kojOn1Gjr+YYMhpRnQ42/0o6PWUSaev28cbOsykDzoE5CdjehIsqTtimN5T0N3cvHA6J6vA8U923SP/V6nw0Erei/fv66OMQT8+0J39T4tL4QMLgQYr9JSw0HM88k8qeLxpFCaxQCe5YOfxI9kw6bauDP55LdbGs6GbFZ7e9+ge9hvUkv0drqRwpVg0PTxuApGnbOmm53PKFiFegrmnvQggvyroOKUYg2JvArFy/IsQP7BDQ== 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=CdGrnfOHvihx5SdmRa7ROGmvbZUcwgcQd2L1d3dlsZU=; b=eXge8PCYcqBBviK1jVyKFp1bnQLqYrHjE/pMPi67MuoOsr8fGc4NwFPl7NViiSKJ4K2GCSCcKO+5ReM3tVKTam42qQn5VegToe2xhaemUtSqJkhEFpKWcUOzQxywwreolR5kXEu+7lFL/oytOhaXonSMmn9Xj3wmaAosdzuQeMPNiQ+hmBWbTa3SiGoz8SDf4hQPshJGJNciSJTy9GVIzHFKqCkl9GdI0/kRSx7iiRnXJXxpkHstr2PlJWJDyDhKp+IyjBIJkwqIpuVMD9RLIXV8HkXQaUEqznlIcWw/EXXl0JAlF+45dJoeR+8Nj0/XqAGWOpaUv534DMb/5Q6sNQ== 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=CdGrnfOHvihx5SdmRa7ROGmvbZUcwgcQd2L1d3dlsZU=; b=qKGQDwXDxF7Nzrv2mcBBvbqoXSohKmgwCAoSSBnITQBdkI2uHGGM/Kty6j25FpSP1c7Ti6WxqAS2Q8yb30EncIEY74PA5+vSAmXp0qjSIEmqMQ2cPhLpyrAsHe9CvFileHO90LBf7JAHzXUASB0bFZ0S2eOCvHsuqWp75P7oaZnu7ZMt0ihDl47YwYbmWEY3XbEyUYoZKybJaRU/oTxQ9HGXWwvmYWj7j9KBFND0R4cUbZ95kq3yhTqG8jmm9wqjtlM2es8IyTd+9tJRXZdAdMrm8xO13bGaUtDy/k4LIwHEmjPXpRsri5UJz5EBkHGW+UvMvMSe5C7DBjm7+Siu+g== Received: from DM5PR12CA0009.namprd12.prod.outlook.com (2603:10b6:4:1::19) by BY5PR12MB4100.namprd12.prod.outlook.com (2603:10b6:a03:200::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Thu, 29 Apr 2021 15:44:52 +0000 Received: from DM6NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:4:1:cafe::23) by DM5PR12CA0009.outlook.office365.com (2603:10b6:4:1::19) 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:51 +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 DM6NAM11FT044.mail.protection.outlook.com (10.13.173.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.27 via Frontend Transport; Thu, 29 Apr 2021 15:44:51 +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:49 +0000 From: Matan Azrad To: CC: , , , "Dekel Peled" Date: Thu, 29 Apr 2021 18:43:28 +0300 Message-ID: <20210429154335.2820028-10-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: d4d83c71-b3bc-4dff-029d-08d90b25ba68 X-MS-TrafficTypeDiagnostic: BY5PR12MB4100: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oEAiiYB6/X2/lmpO3J2s7it+GX6VbrwSJw5l8z49lfu5Y98Mc1TQcLkfc6ac3mzOjGBR6hN9CKQAZslSMlOXToYkL8GJZB16EbzPiSLp0z/xv9loPThI30iaCjhTdVAMLGT1EFOENmZQduJjWM+RXbSF2XKpYldgWFD++0gphyP2jiOaOYCQtEt2qMEH+AK3ykyk3Fpky+OzNN53P/CgommGXrgC00I99B4Um37zCK87vnR2eOV5Ujyp21VY2xdJFHw0RFJR+P2CqhGklnk1bWLxIeC66jh0fd3YWlyLz/+X5dUtvf99oHu/Or13YnHngn9SENBz0K/4YQvRyV8LU33nEV7s0178zYp76kyiJQzfDVPba3FmRRgodmhXR+CaiGJvT1DIBKyQBlVDLPTLeRjxYnShahSs6Qybngf/cPQhCjk0p0wLY4CH0YIrERxL4o/NRB/znbAek/lx147X7TvbWkr9aMPgcRiZcZqSdnngAWS0z5Kqm+JyVjhaf92eER+avfcQzeELrEXMsPoyWYkA3aahgL9Z9cg5R3oTfHbtR1BHolNe8gFM4QVvYAsd2eiOb3ogae4Qg3LE3Mo4FGpVUhU38uyHHy1/NEqs3l0yDMA+jMppzaJQIq4hVA+ieVmS293B57RxiH6SZxXhZ/ysFlwWxEUY9LYRZ6lYvFk= 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)(396003)(39860400002)(376002)(346002)(136003)(36840700001)(46966006)(107886003)(7696005)(6916009)(7636003)(82310400003)(5660300002)(55016002)(36906005)(1076003)(6286002)(47076005)(26005)(186003)(8936002)(70586007)(4326008)(426003)(16526019)(86362001)(36860700001)(70206006)(83380400001)(336012)(6666004)(2906002)(36756003)(478600001)(82740400003)(2616005)(8676002)(316002)(356005)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 15:44:51.7750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4d83c71-b3bc-4dff-029d-08d90b25ba68 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: DM6NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4100 Subject: [dpdk-dev] [PATCH v2 09/16] common/mlx5: support general obj CRYPTO LOGIN 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 CRYPTO_LOGIN Object is used to login to the device as crypto user or crypto officer. Required in order to perform any crypto related control operations. This patch adds support of CRYPTO_LOGIN object create operation. Add reading of CRYPTO_LOGIN support capability. Add function to create general object type CRYPTO_LOGIN, using DevX API. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 15 ++++++++ drivers/common/mlx5/mlx5_prm.h | 19 ++++++++++ drivers/common/mlx5/version.map | 1 + 4 files changed, 89 insertions(+) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index afef7a5f63..5e082ebb78 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->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. */ 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); @@ -2509,3 +2511,55 @@ mlx5_devx_cmd_create_import_kek_obj(void *ctx, import_kek_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id); return import_kek_obj; } + +/** + * Create general object of type CRYPTO_LOGIN using DevX API. + * + * @param[in] ctx + * Context returned from mlx5 open_device() glue function. + * @param [in] attr + * Pointer to CRYPTO_LOGIN attributes structure. + * + * @return + * The DevX object created, NULL otherwise and rte_errno is set. + */ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_crypto_login_obj(void *ctx, + struct mlx5_devx_crypto_login_attr *attr) +{ + uint32_t in[MLX5_ST_SZ_DW(create_crypto_login_in)] = {0}; + uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0}; + struct mlx5_devx_obj *crypto_login_obj = NULL; + void *ptr = NULL, *credential_addr = NULL; + + crypto_login_obj = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*crypto_login_obj), + 0, SOCKET_ID_ANY); + if (crypto_login_obj == NULL) { + DRV_LOG(ERR, "Failed to allocate CRYPTO_LOGIN object data"); + rte_errno = ENOMEM; + return NULL; + } + ptr = MLX5_ADDR_OF(create_crypto_login_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_CRYPTO_LOGIN); + ptr = MLX5_ADDR_OF(create_crypto_login_in, in, crypto_login); + MLX5_SET(crypto_login, ptr, credential_pointer, + attr->credential_pointer); + MLX5_SET(crypto_login, ptr, session_import_kek_ptr, + 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); + crypto_login_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), + out, sizeof(out)); + if (crypto_login_obj->obj == NULL) { + rte_errno = errno; + DRV_LOG(ERR, "Failed to create CRYPTO_LOGIN obj using DevX."); + mlx5_free(crypto_login_obj); + return NULL; + } + crypto_login_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id); + return crypto_login_obj; +} diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index 6423610dae..709e28bfba 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 crypto_login:1; /* General obj type CRYPTO_LOGIN supported. */ uint32_t regexp_num_of_engines; uint32_t log_max_ft_sampler_num:8; uint32_t geneve_tlv_opt; @@ -458,6 +459,15 @@ struct mlx5_devx_import_kek_attr { uint8_t key[MLX5_CRYPTO_KEY_MAX_SIZE]; }; +#define MLX5_CRYPTO_LOGIN_CREDENTIAL_SIZE 48 + +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]; +}; + /* mlx5_devx_cmds.c */ __rte_internal @@ -619,4 +629,9 @@ 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_crypto_login_obj(void *ctx, + struct mlx5_devx_crypto_login_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 bc339566a6..a2437faec0 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -1121,6 +1121,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_CRYPTO_LOGIN \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_CRYPTO_LOGIN) enum { MLX5_HCA_CAP_OPMOD_GET_MAX = 0, @@ -2422,6 +2424,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_CRYPTO_LOGIN = 0x001f, MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH = 0x0022, MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO = 0x0024, MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025, @@ -2534,6 +2537,22 @@ struct mlx5_ifc_create_import_kek_in_bits { struct mlx5_ifc_import_kek_bits import_kek; }; +struct mlx5_ifc_crypto_login_bits { + u8 modify_field_select[0x40]; + u8 reserved_at_40[0x48]; + u8 credential_pointer[0x18]; + u8 reserved_at_a0[0x8]; + u8 session_import_kek_ptr[0x18]; + u8 reserved_at_c0[0x140]; + u8 credential[0x180]; + u8 reserved_at_380[0x480]; +}; + +struct mlx5_ifc_create_crypto_login_in_bits { + struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; + struct mlx5_ifc_crypto_login_bits crypto_login; +}; + 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 56a1b77b0a..bbef436fde 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -29,6 +29,7 @@ INTERNAL { mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_create_dek_obj; mlx5_devx_cmd_create_import_kek_obj; + mlx5_devx_cmd_create_crypto_login_obj; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc; mlx5_devx_cmd_flow_counter_query; -- 2.25.1