From patchwork Tue May 4 17:54:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92745 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CC3F9A0A02; Tue, 4 May 2021 19:55:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8A1E406FF; Tue, 4 May 2021 19:55:37 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2054.outbound.protection.outlook.com [40.107.244.54]) by mails.dpdk.org (Postfix) with ESMTP id C43F64014E for ; Tue, 4 May 2021 19:55:35 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJQuRM42faF7SM1IxMa7BUD35fMFiiwKX0Cm2ENA/5KLl5NDK0c4LKp5JzE3FL41c8Ztiuy3C3gSzTMPsxq5gIBofz+pzf1v8JkEOEHO2CRECcxtsisB28SIhsOm5P6wAxfqAO/b4knl2SypVpHgGYd7rcmx0ZSqsX3s+co9a+oEOqWjo92sR2bs8n9ZrnAwli2lFN2QoPXk8lWPVAAQudG3RMx7GzBgI/UX6tskL5VvoUudyOnp9zd94C38S7cMXBm/IeDRXI2Q5qXI7foIJo9MlOufJbWdyTkRBeWk8Mcn1QtNiOT7NoPR9Q2wofDnt+r8pqTCxc589Rcq7elUUw== 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=xHhBfwk2MKImluyH/8ak9KXRoOeksLrqK25mwBv6kkg=; b=gVpFsXdS1k9EB9AI99362UY7ge1YDv9tZ3o82k5OguPqPyAKLpvHrD/q23ZQiBe1M5BwbH203+Mkk5HqKtMuA2Q0cBtkHXIGkuakkW3hkEkIidX4tBej6lVh8vonhBj8ob+65ITUFnxc86z+LLToEmlBR2mCI4sR3ru8yXIU0ALW5wm0HnbeUXjt0QLwxf45vjtj14IZRYJGOwMJ18vbmRSt1J31R8eEz8c5YzKvSIktlSuyA6brmGOkNbpADYx8+IZQaRDM3+jzfXRtrhrIXU7OJ378nriBppimCXP7LfP2PuGGFVYNBKj04+vACtDrR6vI5i18aEPbFnVJOMnAYg== 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=xHhBfwk2MKImluyH/8ak9KXRoOeksLrqK25mwBv6kkg=; b=WYlfFgnKXNGzt3vivNizDEnlfSFoxLDg6fL+s6vtEyyg64I6MvPVtdaYhWbjvmx8usM7a9kM8bism7TueIC+WiAt8hPkHlQ9FF2wAmBl1MAx2tJ/zFMZL6rV2wh8zonhyoci9fzZrK9ibKspnn+jB6kPQy2jG2iWL6vcAzPLtyVbzHEx/0PK1TEdvh8+OARX0Lj8uv7TBNP8wAcZfjcHkMOLLWiVtGDYvrqgDeVaVwhV29TM2UVj7GRR6fwZfPj24v3/ctDQCMUS8TWoER0caq87LfiUEBBI3taVErOyceHf0jHT8KqV0SYql9IUARRSgtc/PmznBFQQ3xUfjjRqxQ== Received: from DM6PR02CA0119.namprd02.prod.outlook.com (2603:10b6:5:1b4::21) by BL1PR12MB5159.namprd12.prod.outlook.com (2603:10b6:208:318::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.38; Tue, 4 May 2021 17:55:34 +0000 Received: from DM6NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::69) by DM6PR02CA0119.outlook.office365.com (2603:10b6:5:1b4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Tue, 4 May 2021 17:55:34 +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 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; Tue, 4 May 2021 17:55:33 +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:55:31 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:46 +0300 Message-ID: <20210504175500.3385811-2-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 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: 908953d4-4513-46dc-8496-08d90f25d0cd X-MS-TrafficTypeDiagnostic: BL1PR12MB5159: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P+0HwXNgxYXPU/LLN0WJqSXvIfPy7qXC7tjXhobCfoQqh+pe9IN7hUH3s63wyhv/RE9/E5QHvmVmHs0QqFs1pnDmaWxQzFF8y5ukU1kLg8vBRjy7zKKe8rqbD/dkCXcbK0rQatfm4p+QMMa7NdLgrdV1ecWoYR3ng+QAsi0HZNTC4eJcDWrQ2kl8TsBn5KO+cRZVmXu4nVLCgLd+eUw8Qbe2AQRSxpLxSh7178rFi8cSK45hpndWFBNzJmGSq/UGJO6fiS3Nv5n7QP8Du0dmunwEm7rG2XaJl1S5dO8586ypgRTSnoN8t0TVq1XJVU1c37pcHY5mV+gd+J5i9cj84y7sCIEK5sOS1Q3rXtd1eO89dv29P9it53lqLAqkNBLZkjBPCvW9bZktGVBMBNYe5mX61qNijKoxPusjFoOhvKzDsH2dpt1IVLu8LKhJKeq6Z4yeGj210gRdjQVHoNRP+EEhNHHU3/ptr0pkazDE5lCcE7KU8CYRHffUqimSWPa1cKwYDWbF4TzFKIS/Q3ltnRIHMIvP4IDUbrDeUZ+Kdda9x1OUKHB1sICCUa3qdGiD/FWA5ISC9UF7H82vtmar5MFAPZElewpVUOGqsp0gutSmORwCTejN1SdaHSjG/oLOJ2CPs723c7+Oi2HLKypylXYTqtSD7Gh4RyMUWUYYV+s= 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)(39860400002)(136003)(396003)(376002)(36840700001)(46966006)(356005)(8676002)(336012)(7636003)(1076003)(82310400003)(83380400001)(2616005)(426003)(47076005)(7696005)(36756003)(4326008)(86362001)(8936002)(107886003)(6286002)(36906005)(6916009)(54906003)(16526019)(186003)(36860700001)(478600001)(316002)(70586007)(6666004)(55016002)(26005)(70206006)(5660300002)(2906002)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:55:33.9383 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 908953d4-4513-46dc-8496-08d90f25d0cd 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: BL1PR12MB5159 Subject: [dpdk-dev] [PATCH v3 01/15] common/mlx5: remove redundant spaces in header file 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 File drivers/common/mlx5/mlx5_prm.h includes structs representing data items as defined in PRM document. Some of these structs were copied as-is from kernel file mlx5_ifc.h. As result the structs are not all aligned with the same spacing. This patch removes redundant spaces and new lines from several structs, to align all structs in mlx5_prm.h to the same format. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_prm.h | 334 +++++++++++++++------------------ 1 file changed, 155 insertions(+), 179 deletions(-) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index efa5ae67bf..da1510ac1e 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -953,163 +953,139 @@ enum { /* Flow counters. */ struct mlx5_ifc_alloc_flow_counter_out_bits { - u8 status[0x8]; - u8 reserved_at_8[0x18]; - u8 syndrome[0x20]; - u8 flow_counter_id[0x20]; - u8 reserved_at_60[0x20]; + u8 status[0x8]; + u8 reserved_at_8[0x18]; + u8 syndrome[0x20]; + u8 flow_counter_id[0x20]; + u8 reserved_at_60[0x20]; }; struct mlx5_ifc_alloc_flow_counter_in_bits { - u8 opcode[0x10]; - u8 reserved_at_10[0x10]; - u8 reserved_at_20[0x10]; - u8 op_mod[0x10]; - u8 flow_counter_id[0x20]; - u8 reserved_at_40[0x18]; - u8 flow_counter_bulk[0x8]; + u8 opcode[0x10]; + u8 reserved_at_10[0x10]; + u8 reserved_at_20[0x10]; + u8 op_mod[0x10]; + u8 flow_counter_id[0x20]; + u8 reserved_at_40[0x18]; + u8 flow_counter_bulk[0x8]; }; struct mlx5_ifc_dealloc_flow_counter_out_bits { - u8 status[0x8]; - u8 reserved_at_8[0x18]; - u8 syndrome[0x20]; - u8 reserved_at_40[0x40]; + u8 status[0x8]; + u8 reserved_at_8[0x18]; + u8 syndrome[0x20]; + u8 reserved_at_40[0x40]; }; struct mlx5_ifc_dealloc_flow_counter_in_bits { - u8 opcode[0x10]; - u8 reserved_at_10[0x10]; - u8 reserved_at_20[0x10]; - u8 op_mod[0x10]; - u8 flow_counter_id[0x20]; - u8 reserved_at_60[0x20]; + u8 opcode[0x10]; + u8 reserved_at_10[0x10]; + u8 reserved_at_20[0x10]; + u8 op_mod[0x10]; + u8 flow_counter_id[0x20]; + u8 reserved_at_60[0x20]; }; struct mlx5_ifc_traffic_counter_bits { - u8 packets[0x40]; - u8 octets[0x40]; + u8 packets[0x40]; + u8 octets[0x40]; }; struct mlx5_ifc_query_flow_counter_out_bits { - u8 status[0x8]; - u8 reserved_at_8[0x18]; - u8 syndrome[0x20]; - u8 reserved_at_40[0x40]; + u8 status[0x8]; + u8 reserved_at_8[0x18]; + u8 syndrome[0x20]; + u8 reserved_at_40[0x40]; struct mlx5_ifc_traffic_counter_bits flow_statistics[]; }; struct mlx5_ifc_query_flow_counter_in_bits { - u8 opcode[0x10]; - u8 reserved_at_10[0x10]; - u8 reserved_at_20[0x10]; - u8 op_mod[0x10]; - u8 reserved_at_40[0x20]; - u8 mkey[0x20]; - u8 address[0x40]; - u8 clear[0x1]; - u8 dump_to_memory[0x1]; - u8 num_of_counters[0x1e]; - u8 flow_counter_id[0x20]; + u8 opcode[0x10]; + u8 reserved_at_10[0x10]; + u8 reserved_at_20[0x10]; + u8 op_mod[0x10]; + u8 reserved_at_40[0x20]; + u8 mkey[0x20]; + u8 address[0x40]; + u8 clear[0x1]; + u8 dump_to_memory[0x1]; + u8 num_of_counters[0x1e]; + u8 flow_counter_id[0x20]; }; #define MLX5_MAX_KLM_BYTE_COUNT 0x80000000u #define MLX5_MIN_KLM_FIXED_BUFFER_SIZE 0x1000u - struct mlx5_ifc_klm_bits { - u8 byte_count[0x20]; - u8 mkey[0x20]; - u8 address[0x40]; + u8 byte_count[0x20]; + u8 mkey[0x20]; + u8 address[0x40]; }; struct mlx5_ifc_mkc_bits { - u8 reserved_at_0[0x1]; - u8 free[0x1]; - u8 reserved_at_2[0x1]; - u8 access_mode_4_2[0x3]; - u8 reserved_at_6[0x7]; - u8 relaxed_ordering_write[0x1]; - u8 reserved_at_e[0x1]; - u8 small_fence_on_rdma_read_response[0x1]; - u8 umr_en[0x1]; - u8 a[0x1]; - u8 rw[0x1]; - u8 rr[0x1]; - u8 lw[0x1]; - u8 lr[0x1]; - u8 access_mode_1_0[0x2]; - u8 reserved_at_18[0x8]; - - u8 qpn[0x18]; - u8 mkey_7_0[0x8]; - - u8 reserved_at_40[0x20]; - - u8 length64[0x1]; - u8 bsf_en[0x1]; - u8 sync_umr[0x1]; - u8 reserved_at_63[0x2]; - u8 expected_sigerr_count[0x1]; - u8 reserved_at_66[0x1]; - u8 en_rinval[0x1]; - u8 pd[0x18]; - - u8 start_addr[0x40]; - - u8 len[0x40]; - - u8 bsf_octword_size[0x20]; - - u8 reserved_at_120[0x80]; - - u8 translations_octword_size[0x20]; - - u8 reserved_at_1c0[0x19]; - u8 relaxed_ordering_read[0x1]; - u8 reserved_at_1da[0x1]; - u8 log_page_size[0x5]; - - u8 reserved_at_1e0[0x20]; + u8 reserved_at_0[0x1]; + u8 free[0x1]; + u8 reserved_at_2[0x1]; + u8 access_mode_4_2[0x3]; + u8 reserved_at_6[0x7]; + u8 relaxed_ordering_write[0x1]; + u8 reserved_at_e[0x1]; + u8 small_fence_on_rdma_read_response[0x1]; + u8 umr_en[0x1]; + u8 a[0x1]; + u8 rw[0x1]; + u8 rr[0x1]; + u8 lw[0x1]; + u8 lr[0x1]; + u8 access_mode_1_0[0x2]; + u8 reserved_at_18[0x8]; + u8 qpn[0x18]; + u8 mkey_7_0[0x8]; + u8 reserved_at_40[0x20]; + u8 length64[0x1]; + u8 bsf_en[0x1]; + u8 sync_umr[0x1]; + u8 reserved_at_63[0x2]; + u8 expected_sigerr_count[0x1]; + u8 reserved_at_66[0x1]; + u8 en_rinval[0x1]; + u8 pd[0x18]; + u8 start_addr[0x40]; + u8 len[0x40]; + u8 bsf_octword_size[0x20]; + u8 reserved_at_120[0x80]; + u8 translations_octword_size[0x20]; + u8 reserved_at_1c0[0x19]; + u8 relaxed_ordering_read[0x1]; + u8 reserved_at_1da[0x1]; + u8 log_page_size[0x5]; + u8 reserved_at_1e0[0x20]; }; struct mlx5_ifc_create_mkey_out_bits { - u8 status[0x8]; - u8 reserved_at_8[0x18]; - - u8 syndrome[0x20]; - - u8 reserved_at_40[0x8]; - u8 mkey_index[0x18]; - - u8 reserved_at_60[0x20]; + u8 status[0x8]; + u8 reserved_at_8[0x18]; + u8 syndrome[0x20]; + u8 reserved_at_40[0x8]; + u8 mkey_index[0x18]; + u8 reserved_at_60[0x20]; }; struct mlx5_ifc_create_mkey_in_bits { - u8 opcode[0x10]; - u8 reserved_at_10[0x10]; - - u8 reserved_at_20[0x10]; - u8 op_mod[0x10]; - - u8 reserved_at_40[0x20]; - - u8 pg_access[0x1]; - u8 reserved_at_61[0x1f]; - + u8 opcode[0x10]; + u8 reserved_at_10[0x10]; + u8 reserved_at_20[0x10]; + u8 op_mod[0x10]; + u8 reserved_at_40[0x20]; + u8 pg_access[0x1]; + u8 reserved_at_61[0x1f]; struct mlx5_ifc_mkc_bits memory_key_mkey_entry; - - u8 reserved_at_280[0x80]; - - u8 translations_octword_actual_size[0x20]; - - u8 mkey_umem_id[0x20]; - - u8 mkey_umem_offset[0x40]; - - u8 reserved_at_380[0x500]; - - u8 klm_pas_mtt[][0x20]; + u8 reserved_at_280[0x80]; + u8 translations_octword_actual_size[0x20]; + u8 mkey_umem_id[0x20]; + u8 mkey_umem_offset[0x40]; + u8 reserved_at_380[0x500]; + u8 klm_pas_mtt[][0x20]; }; enum { @@ -2272,27 +2248,27 @@ enum { }; struct mlx5_ifc_flow_meter_parameters_bits { - u8 valid[0x1]; // 00h - u8 bucket_overflow[0x1]; - u8 start_color[0x2]; - u8 both_buckets_on_green[0x1]; - u8 meter_mode[0x2]; - u8 reserved_at_1[0x19]; - u8 reserved_at_2[0x20]; //04h - u8 reserved_at_3[0x3]; - u8 cbs_exponent[0x5]; // 08h - u8 cbs_mantissa[0x8]; - u8 reserved_at_4[0x3]; - u8 cir_exponent[0x5]; - u8 cir_mantissa[0x8]; - u8 reserved_at_5[0x20]; // 0Ch - u8 reserved_at_6[0x3]; - u8 ebs_exponent[0x5]; // 10h - u8 ebs_mantissa[0x8]; - u8 reserved_at_7[0x3]; - u8 eir_exponent[0x5]; - u8 eir_mantissa[0x8]; - u8 reserved_at_8[0x60]; // 14h-1Ch + u8 valid[0x1]; + u8 bucket_overflow[0x1]; + u8 start_color[0x2]; + u8 both_buckets_on_green[0x1]; + u8 meter_mode[0x2]; + u8 reserved_at_1[0x19]; + u8 reserved_at_2[0x20]; + u8 reserved_at_3[0x3]; + u8 cbs_exponent[0x5]; + u8 cbs_mantissa[0x8]; + u8 reserved_at_4[0x3]; + u8 cir_exponent[0x5]; + u8 cir_mantissa[0x8]; + u8 reserved_at_5[0x20]; + u8 reserved_at_6[0x3]; + u8 ebs_exponent[0x5]; + u8 ebs_mantissa[0x8]; + u8 reserved_at_7[0x3]; + u8 eir_exponent[0x5]; + u8 eir_mantissa[0x8]; + u8 reserved_at_8[0x60]; }; #define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FFFFFF) #define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8 @@ -2359,46 +2335,46 @@ struct mlx5_ifc_cqc_bits { }; struct mlx5_ifc_health_buffer_bits { - u8 reserved_0[0x100]; - u8 assert_existptr[0x20]; - u8 assert_callra[0x20]; - u8 reserved_1[0x40]; - u8 fw_version[0x20]; - u8 hw_id[0x20]; - u8 reserved_2[0x20]; - u8 irisc_index[0x8]; - u8 synd[0x8]; - u8 ext_synd[0x10]; + u8 reserved_0[0x100]; + u8 assert_existptr[0x20]; + u8 assert_callra[0x20]; + u8 reserved_1[0x40]; + u8 fw_version[0x20]; + u8 hw_id[0x20]; + u8 reserved_2[0x20]; + u8 irisc_index[0x8]; + u8 synd[0x8]; + u8 ext_synd[0x10]; }; struct mlx5_ifc_initial_seg_bits { - u8 fw_rev_minor[0x10]; - u8 fw_rev_major[0x10]; - u8 cmd_interface_rev[0x10]; - u8 fw_rev_subminor[0x10]; - u8 reserved_0[0x40]; - u8 cmdq_phy_addr_63_32[0x20]; - u8 cmdq_phy_addr_31_12[0x14]; - u8 reserved_1[0x2]; - u8 nic_interface[0x2]; - u8 log_cmdq_size[0x4]; - u8 log_cmdq_stride[0x4]; - u8 command_doorbell_vector[0x20]; - u8 reserved_2[0xf00]; - u8 initializing[0x1]; - u8 nic_interface_supported[0x7]; - u8 reserved_4[0x18]; + u8 fw_rev_minor[0x10]; + u8 fw_rev_major[0x10]; + u8 cmd_interface_rev[0x10]; + u8 fw_rev_subminor[0x10]; + u8 reserved_0[0x40]; + u8 cmdq_phy_addr_63_32[0x20]; + u8 cmdq_phy_addr_31_12[0x14]; + u8 reserved_1[0x2]; + u8 nic_interface[0x2]; + u8 log_cmdq_size[0x4]; + u8 log_cmdq_stride[0x4]; + u8 command_doorbell_vector[0x20]; + u8 reserved_2[0xf00]; + u8 initializing[0x1]; + u8 nic_interface_supported[0x7]; + u8 reserved_4[0x18]; struct mlx5_ifc_health_buffer_bits health_buffer; - u8 no_dram_nic_offset[0x20]; - u8 reserved_5[0x6de0]; - u8 internal_timer_h[0x20]; - u8 internal_timer_l[0x20]; - u8 reserved_6[0x20]; - u8 reserved_7[0x1f]; - u8 clear_int[0x1]; - u8 health_syndrome[0x8]; - u8 health_counter[0x18]; - u8 reserved_8[0x17fc0]; + u8 no_dram_nic_offset[0x20]; + u8 reserved_5[0x6de0]; + u8 internal_timer_h[0x20]; + u8 internal_timer_l[0x20]; + u8 reserved_6[0x20]; + u8 reserved_7[0x1f]; + u8 clear_int[0x1]; + u8 health_syndrome[0x8]; + u8 health_counter[0x18]; + u8 reserved_8[0x17fc0]; }; struct mlx5_ifc_create_cq_out_bits { From patchwork Tue May 4 17:54:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92746 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 16B94A0A02; Tue, 4 May 2021 19:55:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1B00410F2; Tue, 4 May 2021 19:55:45 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2056.outbound.protection.outlook.com [40.107.236.56]) by mails.dpdk.org (Postfix) with ESMTP id 0CB1C410E5 for ; Tue, 4 May 2021 19:55:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eK2W45JhTHiHuQrCK4knVUKWhW0gOCJwSdZ4rXAp/K4X2qeF45NzMfvVH+yYUBTBxjgEFKzkZNIwuzb5rxDvNNbmPU4+J83oOOF+xDzqNm5wQ2kcvlIBKtyD6ZHoFBUItK7E1E4V9Rb8fiw3qSl3/J9fCULMv9NAlwJIBKdovzQFme14HQgP3eiOCKlQRrattdfYZfnf5PrkK0k1XOdKpXpnsp3UthFtfJtvizHelEGXnXKL3RFwRmlShmKl+Xyrd00VlI4gRynr7uKzE/AbFR65c33Wtwj8b6LEEqKTDH9Pok0ThRdVOQ1zUFqdzXnJAQV8YWqvP6PCccp+dOhQNw== 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=ADxW5wqMZL908x9yQehOjoYXJwojfY1Bv4Q+oMlRJ8E=; b=WcOhVNLzx4BGqFoVpFkDvqLHPkcECgQBugKaS/tNNji2njwztkDjao/4WNBP8UStaDJX7xNyTk1eR7v+WE1VTrGirAR4wv9aoUPrNkUllk54VQOTHO/Qrq6SFcNPn4Jw3XTtyRLgacQ6HLetMcnNH8xfuVgWi7vnvq4Fzgy7zMetrKE0GVLhp2EhS6qeXV5qfPdWhzKDU5sr7OH2jQOf80fHOD4om6FAwBkLdcq2hdS0T8hYBBEgBPSPSNRM89OBJQqaqlYQVioYRr1kavfI93EpCoqOnWWS4mDP1Q+KurkedUmLxKOLOFftpdAoUjRNiQRhFybuo9Y361nlIj34Kg== 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=ADxW5wqMZL908x9yQehOjoYXJwojfY1Bv4Q+oMlRJ8E=; b=dXpFfxNgd3XGb4VCmJxm1217w01krhCmDeIAlIwd9a/ivk8pQ1olUbVR620RhFf9A9P7DVEkhIUt8XsG8gVt6JPMNaoJxai7p0muK+zF3p+/xgWV9U5MMtGWmEDIHTfrJhdUKbV2oWrbygvamtsAebVMNz0qZaW22MTItUGD4ns1UnB9fALWLUJdiUuTulyFxkQ6PiUK1QRTM7PGWMdVs0/FKrc3aqm5kJtQUcbHnlHu3eGGqGXPuazD9wb9LrFNyienpNWkAhVT5m7qjvb8zfXwl8XlaBQb0oLdQJga4aCLmvJL8KtT1253kDhgMja5PYBxDqrc3NrJFqdEhGFrtg== Received: from DM6PR11CA0070.namprd11.prod.outlook.com (2603:10b6:5:14c::47) by BN9PR12MB5131.namprd12.prod.outlook.com (2603:10b6:408:118::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.40; Tue, 4 May 2021 17:55:43 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::d9) by DM6PR11CA0070.outlook.office365.com (2603:10b6:5:14c::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 4 May 2021 17:55:42 +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 DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) 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:55:42 +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:55:40 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:47 +0300 Message-ID: <20210504175500.3385811-3-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 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: 1f0f3ef1-45af-42de-ab55-08d90f25d60b X-MS-TrafficTypeDiagnostic: BN9PR12MB5131: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tts2Fhly6Zw27+pOjd3dwYqrRKOuJW1vzsGj3fxFGhHxWJhOouDFoNctYGzQeZNYpRu+Yo745/O0UKxFh7Al/q+HBXwnuqC7iPFLiPhjItUby/aOY8EGP5wiUh9VoGpLjEr0W4ECIbzkYuuav8Gu7uCSV3zohnbijDqRO4SnYJDczFdUyr14hwVmYrN2KLhqOvt5kHpnTWsCDVpDqIEZLH+lltPnEwJwQnDthUfSjulOVfS6UtuMPY1KlQE/S2Px0eE22DVfp0kgj0pWTIP4mT3QyaXwxyE/fKIe8T5lU6/GNetH+FWzPc7Bq/lHJ9iuN/dAwWiT1EH5LGouAZY1yDeSet8mmNIaN/glqjtOfeI/Cv7LXxhmn1ZmaYooNy4oY3ulRYBfFDT36xgpCY9caqnrUi5+vvN1FiYs+QPLjo85jaNLXK2HZ8NPBxEuBENx7mTU1/tf2iRN9B4olUT/rZbXvYxoZ2k/U2OF1eHBeCMZ3XETzbwOXdvy3jBpe4TiVhjdr9mLIvZg0lvVXmFDfRRPGs6MYNbM/hhgnwb42MIM7OgbS5/njxrsGOBdAvRnQl5boYzOFdPHmmdeG+lS32XpP93SrP/EtwchujUNKZpokatAAjHX3ji41zxYx7hWeGVoPsMnTA6Ob7QeLGWs0SRm6w09IpAKfmotAg9hARc= 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)(39860400002)(136003)(396003)(346002)(46966006)(36840700001)(7636003)(82740400003)(1076003)(7696005)(70586007)(426003)(336012)(8936002)(86362001)(186003)(16526019)(478600001)(70206006)(36860700001)(5660300002)(83380400001)(316002)(54906003)(6286002)(6916009)(36756003)(107886003)(82310400003)(2906002)(55016002)(47076005)(36906005)(356005)(4326008)(8676002)(26005)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:55:42.7772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f0f3ef1-45af-42de-ab55-08d90f25d60b 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5131 Subject: [dpdk-dev] [PATCH v3 02/15] common/mlx5: update GENEVE TLV OPT obj name 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 Rename MLX5_OBJ_TYPE_GENEVE_TLV_OPT as MLX5_GENERAL_OBJ_TYPE_GENEVE_TLV_OPT, to align with other general objects names. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 2 +- drivers/common/mlx5/mlx5_prm.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 79fff6457c..831175efc5 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -2265,7 +2265,7 @@ mlx5_devx_cmd_create_geneve_tlv_option(void *ctx, MLX5_SET(general_obj_in_cmd_hdr, hdr, opcode, MLX5_CMD_OP_CREATE_GENERAL_OBJECT); MLX5_SET(general_obj_in_cmd_hdr, hdr, obj_type, - MLX5_OBJ_TYPE_GENEVE_TLV_OPT); + MLX5_GENERAL_OBJ_TYPE_GENEVE_TLV_OPT); MLX5_SET(geneve_tlv_option, opt, option_class, rte_be_to_cpu_16(class)); MLX5_SET(geneve_tlv_option, opt, option_type, type); diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index da1510ac1e..2e5e42f6e9 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -1108,7 +1108,7 @@ enum { #define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO \ (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO) #define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \ - (1ULL << MLX5_OBJ_TYPE_GENEVE_TLV_OPT) + (1ULL << MLX5_GENERAL_OBJ_TYPE_GENEVE_TLV_OPT) enum { MLX5_HCA_CAP_OPMOD_GET_MAX = 0, @@ -2402,7 +2402,7 @@ struct mlx5_ifc_create_cq_in_bits { }; enum { - MLX5_OBJ_TYPE_GENEVE_TLV_OPT = 0x000b, + MLX5_GENERAL_OBJ_TYPE_GENEVE_TLV_OPT = 0x000b, MLX5_GENERAL_OBJ_TYPE_VIRTQ = 0x000d, MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS = 0x001c, MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH = 0x0022, From patchwork Tue May 4 17:54:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92747 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 47782A0A02; Tue, 4 May 2021 19:55:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 34C49410E9; Tue, 4 May 2021 19:55:54 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2050.outbound.protection.outlook.com [40.107.243.50]) by mails.dpdk.org (Postfix) with ESMTP id 6A78D40147 for ; Tue, 4 May 2021 19:55:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EjudDJau6NFC6tjWkLf6r6PzpTyPCkPX5IB3NzuVJ5SiTWHbJ4P3jz8uLCXVv88suMnWI2rXuJq1+/THagBoV8DDF63PlWcanUI9pAyiwGFL2s11YzGOkt551UyyRjCQ0i8ImvMzOX+dC96K2fyMPZH1pAoL7sBSCYiFZ+l2t4AyUGXc0eGKTB3SB5/eMtLh0niRMzRDtVtFHJov2sy49uNXJoXmcp7Az2qpx/dMGTkW05SvnLcEzlrwqMPTqWKSbaf3DhRRegsYMKN2BdWcWPctFjkd3W9UoQUwWScs6gsWMm5IQQzDog//OUH4h3xjaKrg/ZwhHhov2blizUoA8A== 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=atbM8SjIAc3Y3X7lr0ErctHTbVilFq3OoAh98waUX6g=; b=H1fKxF/HwV3ePbZC0yzLry/m1jE5vTi30fC3tlUYuqpk3ttEpJdytRVYUYzvpBJ3qQbeCOZ8SsP1RQhwuudBBB8JFuLeuBjQe7xz0VnQZzk2AS2zhibuSAIxLuzeYOh/YCTm0F1M3jDPhnAYoA0Dt2WGYnaNdO0KdaR2EpibWnO+F9GDTgwXub9PInqvc7za6UWqF4L2iEyTBlGr3CGqsc+f/edCTvYdmb4mprDZ9QAVrhT9bF172qR05YHBLn/d1xppXtlXbc7fNBnMkxKs594fKDXNW9CEru7r2gxUJeDlRrTF5PNwfk+fYd2rqNR8wgtChXKltcXg7+UDptFPlg== 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=atbM8SjIAc3Y3X7lr0ErctHTbVilFq3OoAh98waUX6g=; b=ZyR6JrJfTPHoX9h6o6oE8tbvE6gc/ZmjgiKzuLK1EnMyDBtL3aJO0pBk6uJpixuqhgZZh8k2kjRD86gu2xuT+agoGjkzB/tHnQ2ihSDNAnHqiHqZPOFsAIIc/SPHS5aFbkzCMsHiUIYTDRpL8W6TiKXdxv+i+l8TvdlWfELhm/+ai0ppmmAZaFZGIZys2Rs6bb/ifXItP/oPmP7QAVX2aZi6g4NhyY9aAdSNUW3EAVq6tir0D2PKaQHqBrSEvbC7Bo08zEH0Fm6XcD20UH1mnc3YHHLRCQeSYp2vc4ZOP8KpfGlJEfeypCsl0kqS/Znkumd99i3/IgskxiAdDyPXtQ== Received: from DM6PR02CA0167.namprd02.prod.outlook.com (2603:10b6:5:332::34) by SN6PR12MB2733.namprd12.prod.outlook.com (2603:10b6:805:77::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.41; Tue, 4 May 2021 17:55:51 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::e1) by DM6PR02CA0167.outlook.office365.com (2603:10b6:5:332::34) 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:55:51 +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 DM6NAM11FT027.mail.protection.outlook.com (10.13.172.205) 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:55:50 +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:55:48 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:48 +0300 Message-ID: <20210504175500.3385811-4-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 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: 5ae8b0ca-e8be-4481-ca8e-08d90f25dae9 X-MS-TrafficTypeDiagnostic: SN6PR12MB2733: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 29QrigdKbNBIVyI2ObXp/Eu1WY4CrarlJjUpI577FikUnam2dh6j/6R8TP8at0kC+ejZoFndWmp8pgPbjvCWpShPNj0ibaONcz7EgS/F930K2ZrIj/h5Hhvpfyj3uz21Y5cXWHdejX8NREuFbDKiqWCqB7m1GU7kxqQTRsy0OGsL2186hswS/jFIPfvD3fmwArK3j9i8MOAHiBAgLLc3OlqrvikDuvUCKJRzUB5Kcbit6eNKJzFLAhJegP4WWan7A9+OKOh7LbnZQx6C3wivTk4u0tfQa6xL38j2ovJmez4XICZRattVnzUHz5iOqxvzp9BYTqhlrd/E8jBOwTdJcuQKe9GzIgvtoclCwa2UPgzvycHZNBzkRSa/EvhwiCsYNt7R9uURb1dzXK0zOxBmHxlX97KOM9VlXapNJ93zwIm8yJde1nJ6sy8j1SJx8hwgZBWadAj9cyEleAk0X2xPPLIB6ZLGN99Ji3/dPqXrPPD9HCQl8rTFIPVYWRvK7yJRrGvyXlM+qviW1U7IQQ2D7dTkTUwYEjKrBUPgAqU3bwQmg12CEji/7LXBu8hTX5HnM8yhjfG5uczNOPcA4x0+N2NgDDIapAB9eOLjr6VgjNmq6f/qne1NwK6q9EmjXAllKwou9tBD1JxkXRSwkDUxY+OfoYmbz4HogErHoekuV7Y= 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)(376002)(396003)(346002)(136003)(36840700001)(46966006)(47076005)(316002)(8936002)(1076003)(336012)(70586007)(6916009)(70206006)(86362001)(82740400003)(186003)(478600001)(54906003)(36860700001)(55016002)(5660300002)(36906005)(7636003)(82310400003)(83380400001)(356005)(8676002)(6286002)(107886003)(4326008)(16526019)(36756003)(26005)(7696005)(426003)(2616005)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:55:50.9507 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ae8b0ca-e8be-4481-ca8e-08d90f25dae9 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: DM6NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2733 Subject: [dpdk-dev] [PATCH v3 03/15] common/mlx5: optimize read of general obj type caps 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 General object types support is indicated in bitmap general_obj_types, which is part of HCA capabilities list. Currently this bitmap is read multiple times, and each time a different bit is extracted. This patch optimizes the code, reading the bitmap once into a local variable, and then extracting the required bits. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 831175efc5..a0bf0d3009 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -647,6 +647,7 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, uint32_t out[MLX5_ST_SZ_DW(query_hca_cap_out)] = {0}; void *hcattr; int status, syndrome, rc, i; + uint64_t general_obj_types_supported = 0; MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP); MLX5_SET(query_hca_cap_in, in, op_mod, @@ -725,12 +726,22 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->regex = MLX5_GET(cmd_hca_cap, hcattr, regexp); attr->regexp_num_of_engines = MLX5_GET(cmd_hca_cap, hcattr, regexp_num_of_engines); - attr->flow_hit_aso = !!(MLX5_GET64(cmd_hca_cap, hcattr, - general_obj_types) & + /* Read the general_obj_types bitmap and extract the relevant bits. */ + general_obj_types_supported = MLX5_GET64(cmd_hca_cap, hcattr, + general_obj_types); + attr->vdpa.valid = !!(general_obj_types_supported & + MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q); + attr->vdpa.queue_counters_valid = + !!(general_obj_types_supported & + MLX5_GENERAL_OBJ_TYPES_CAP_VIRTIO_Q_COUNTERS); + attr->parse_graph_flex_node = + !!(general_obj_types_supported & + MLX5_GENERAL_OBJ_TYPES_CAP_PARSE_GRAPH_FLEX_NODE); + attr->flow_hit_aso = !!(general_obj_types_supported & MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO); - attr->geneve_tlv_opt = !!(MLX5_GET64(cmd_hca_cap, hcattr, - general_obj_types) & - MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT); + attr->geneve_tlv_opt = !!(general_obj_types_supported & + MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT); + /* 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); attr->log_max_cq_sz = MLX5_GET(cmd_hca_cap, hcattr, log_max_cq_sz); From patchwork Tue May 4 17:54:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92748 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EBC18A0A02; Tue, 4 May 2021 19:56:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D4C004068E; Tue, 4 May 2021 19:56:06 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2049.outbound.protection.outlook.com [40.107.237.49]) by mails.dpdk.org (Postfix) with ESMTP id 026304068E for ; Tue, 4 May 2021 19:56:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YsSpJupdjRj97xsF6dKsJSAGpFs4PYLiWDdhJy9QDadL8BiIn2y5EAVXNX21w/euD2j8ymVFStB1F+7sXKn3cx8erbZwjDu3wzPm1HM5GxtcqvYvwwdjGDppyCcpkIWDR3x73aePt4dhuBliMalnkYqmU2Kau+7p7VWmlOb0oKmA+NIK1hVrlNHUR9knxRdfbHouLt0mSb7L+HcFfmrQJBO1r0dNCwO6gWx9JOS1tAIt0m+wtEu75VOWlaCOaODmBlc1vqreRtNrNx7t0LDfoPbanaQdzzp8J7/bjgSNFHdZuB4AlQHbA38YGZIrUmGykHDSZaLbnnA4Mo2VhIbtcQ== 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=xI/cBrNreW1ghKjOyMAG24nLoCDig9vyRrCXyiNA+p0=; b=E+K+RyTFf1wNBquX4LZSS3FNjnslDskK5F1F2GxyttaeW2sTJ38lMhg4ODJPbVQzle9KzCCmT292eNikqUsBNPb5V2cY5xuMAX0AEbMHjKqx/572nnQp/RqktDAXsz2RNRXBtEilEpIQKDtzx+jNY2u46CrEhA8VCCY2e8jVivQk1d5cQsmSG1I2JEtGyXsuJa/iFiXo4muJTATcf32kr55npRdHVqlx6mXYWcFsqDR5IvCbw4taOCgJDcfq81bWk4fa1DOJk0mNTAgqa1T5tHwaylQ8SPymBbm1KzfhUxljizEObzjqFHsp2sU+b6UmUXtirgAgAry7dfbV3i/kHA== 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=xI/cBrNreW1ghKjOyMAG24nLoCDig9vyRrCXyiNA+p0=; b=TgKtX2Gb3vykKMsxJPXSNGHSVZZpJC63b+YTiH7/byUZkGe1dYdZc3WP/82GbdqOZ6g1LigYD+VDapmn9DlPutRokQOadl60rl2YCATWpBfe5RM47fLCxawmoHB9MRs+33d9bhyH2sWiKtXW3kWV4m2iIgotIjCGjDdtvWwB8ugIRNhUZNCE7UyNBXTqlYZUiCIpLal4gi7Xi45kGEEV+NlB4XDbvgA+HsI8ucm/JPrshLU01kqVlhcMXkO5DSBJBs9CCj2NSvyDCaib+7YBz/ZBo2BGDwPy9aErDOlZ5UdLnVvV+sfXk5xy97m5zg56IrD4T+AsjVFfXGiGvK9XCw== Received: from DM5PR12CA0008.namprd12.prod.outlook.com (2603:10b6:4:1::18) by DM6PR12MB4153.namprd12.prod.outlook.com (2603:10b6:5:212::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.41; Tue, 4 May 2021 17:56:01 +0000 Received: from DM6NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:4:1:cafe::cc) by DM5PR12CA0008.outlook.office365.com (2603:10b6:4:1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Tue, 4 May 2021 17:56:01 +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 DM6NAM11FT045.mail.protection.outlook.com (10.13.173.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.32 via Frontend Transport; Tue, 4 May 2021 17:56:01 +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:55:59 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:49 +0300 Message-ID: <20210504175500.3385811-5-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 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: 4bb89a94-eba6-45ec-4bad-08d90f25e0ed X-MS-TrafficTypeDiagnostic: DM6PR12MB4153: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qDlwM0464bS30uO7eRrv5xFF2kuZZ/zT9hHPnVXVyurKNm6BSay07xnmpQ9bW4sjPwAQ4lypSaatYXo5qJ4VZkF7B9vXNn7ET5c32QOG109NF4czGzzyEEf7XmxJ1H1wP7olzP44jn7C+KTuUD8hWoBFle3iRdNM/bMXCi2sK6luvTAns3tkdG1SVqiFpKYeMUCHhbf5wMP7cWdKge6JIAWPB8drhnyRMi8zkpnc/pRc0BEIndiZlyWwsGwem1mBaav/BiMz2txFlUqikjMbqolj3h7Y1T3irXOctPcwGFC4qtPh1E72+2S7pfWkz7pbqsNYts7pWzflOMtiIn0xLEQgRFwiBTjPFA1Xu2gW/P0BoauG3RGc/y2LaBZOzPevNB66CmjTtAn8jU8+E8dTm0NkjyZ+CBPIw3i2EHVUGyxDa7p4R2ogkQUXe+nCkFNUGKJp6qafxf3FAqx2PSY16FtNRICfRmTDv4Fy6x0fLuhD8DCHR0o+iL56yu9BGp8HhcncapjbbEOw65XsL5Y6mT3YtjOfar21lReF4XgeJTLY5Z9xqIjKerU9l06/sIvJHCrOb5KNjbbmCUaFSNSedyArMLmZJNvYC+j1jrwkiYWIGhMLM89yDZdb3xbp2aGMWIlshrkVTzoK42tKYkqBA6nc6BdC9mDWIkfV7iasNtI= 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)(36840700001)(46966006)(4326008)(2616005)(26005)(5660300002)(356005)(8936002)(478600001)(70586007)(70206006)(2906002)(36756003)(7636003)(86362001)(55016002)(16526019)(1076003)(82310400003)(186003)(83380400001)(6286002)(7696005)(36906005)(336012)(316002)(47076005)(6916009)(36860700001)(426003)(107886003)(82740400003)(54906003)(6666004)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:01.0420 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bb89a94-eba6-45ec-4bad-08d90f25e0ed 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: DM6NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4153 Subject: [dpdk-dev] [PATCH v3 04/15] common/mlx5: add HCA cap for AES-XTS crypto 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 Update the PRM structure and HCA capabilities reading, to include relevant capabilities for AES-XTS crypto. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 2 ++ drivers/common/mlx5/mlx5_prm.h | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index a0bf0d3009..7ca767944e 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -771,6 +771,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, MLX5_GET(cmd_hca_cap, hcattr, umr_indirect_mkey_disabled); attr->umr_modify_entity_size_disabled = MLX5_GET(cmd_hca_cap, hcattr, umr_modify_entity_size_disabled); + attr->crypto = MLX5_GET(cmd_hca_cap, hcattr, crypto); + if (attr->crypto) + attr->aes_xts = MLX5_GET(cmd_hca_cap, hcattr, aes_xts); if (attr->qos.sup) { MLX5_SET(query_hca_cap_in, in, op_mod, MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP | diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index 870bdb6b30..28ade5bbc4 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.h +++ b/drivers/common/mlx5/mlx5_devx_cmds.h @@ -137,6 +137,8 @@ struct mlx5_hca_attr { uint32_t qp_ts_format:2; uint32_t regex:1; uint32_t reg_c_preserve:1; + uint32_t crypto:1; /* Crypto engine is supported. */ + uint32_t aes_xts:1; /* AES-XTS crypto is supported. */ uint32_t regexp_num_of_engines; uint32_t log_max_ft_sampler_num:8; uint32_t geneve_tlv_opt; diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 2e5e42f6e9..a8fbfbb0f5 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -1427,7 +1427,10 @@ struct mlx5_ifc_cmd_hca_cap_bits { u8 sq_ts_format[0x2]; u8 rq_ts_format[0x2]; u8 reserved_at_444[0x1C]; - u8 reserved_at_460[0x10]; + u8 reserved_at_460[0x8]; + u8 aes_xts[0x1]; + u8 crypto[0x1]; + u8 reserved_at_46a[0x6]; u8 max_num_eqs[0x10]; u8 reserved_at_480[0x3]; u8 log_max_l2_table[0x5]; From patchwork Tue May 4 17:54:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92749 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3CA25A0A02; Tue, 4 May 2021 19:56:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25A7C410FC; Tue, 4 May 2021 19:56:12 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2042.outbound.protection.outlook.com [40.107.236.42]) by mails.dpdk.org (Postfix) with ESMTP id 531124014D for ; Tue, 4 May 2021 19:56:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jthpk/octpWlgqVdFmlIarUzhkTCeeTKIP/IRBnQKIHV7/HGClww4i0fslVEsjsn03yNHxQcGnq9GkOLXZjf4GGHMe4o0JQ4rp9cpHQ+zxDmiecE+MTcRl+6B4pEURmA3ixGChT8DSX9HCcDswr21O01KXtQs8gDcDvEQGGIl57W0aPERxW1IBs+JbGLy5aFZ1+pZ+E/S/WNll+6SVoggYeWvIMpy34Gw3sL8ox6SorHEQS6uubW4dwMRw2NYxcXe18BYj2/3sH2dWJdWrb2TY9NAnPGLfAFd4e2nHEF9Zzot2EeXlxLBvJ+TprjwvR/DgH+/KZE4wsBaZm17ipytA== 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=m7qx+2aj0EImozp+TsvVihcmloV85KASscfderTQu9o=; b=HsR/Mnx0hJvjbetbPtc2tXPjjHrtCfGcrPyunjpziaACvxXsytne+sHAkqwUX5M85Iivl/cs+csW3rxVxpqIhWoqUSiXkBuvrsQgq98kAFva44hSoq2ladzQWy9ihJfy3IPW06W5VUcsMH8D14kxu8FSIB44jKewcP7JMrFgByb1UM7DVncWcgb6U7e9zLgFYrOB8JYA08uS1ATpP3P7YIa6JDR+0TVTXIyO8VhehO8Z9cCCpQMIMirj5MVFiYqOgqNJzZVP4rNiNjN0pG+UDmdtZjsBHQGsiTpTB+xp6to6/j0EifDDk2CAIZOvq+nHsvXB1IuFjdDbiXpm4x75WA== 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=m7qx+2aj0EImozp+TsvVihcmloV85KASscfderTQu9o=; b=XSBGe/zNW/ht0NeQIl8XfiROWCjgIQSN6DABR3GbCE7NNAL0IKERUXapESruFPfu807lWFx8EOg0DxwLDsD8X6FwdKMcKNsvOpMT1p/smwk+ZoPya5ZvsR92rGzadLvh9ipf4QJntQ2m2UBrW0BNERbCji9e+ihxdpALNWzIGZR8teXk1/KoRJs0/isXKkjX7jDTRwlnnkOJe3oBw5vxF1rlya9Uu/xe+x++2N//wqDvYxykG0w2AIU0vRuvb2P6HYGQhejxTh740gSQr1ePfPpZWfJZwznczMwQaG5sqNvCfWhq85cR3uoJT89gx72hwtKh73+4NHi5TEDgzcV1Iw== Received: from DM6PR02CA0142.namprd02.prod.outlook.com (2603:10b6:5:332::9) by MWHPR1201MB0093.namprd12.prod.outlook.com (2603:10b6:301:54::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Tue, 4 May 2021 17:56:08 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::16) by DM6PR02CA0142.outlook.office365.com (2603:10b6:5:332::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 4 May 2021 17:56:08 +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 DM6NAM11FT027.mail.protection.outlook.com (10.13.172.205) 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:56:08 +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:56:06 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:50 +0300 Message-ID: <20210504175500.3385811-6-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 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: f3591220-a566-441c-cece-08d90f25e56f X-MS-TrafficTypeDiagnostic: MWHPR1201MB0093: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V2t4hr52WPcLGER8mGFkRDSIjfunH6RikBjEN1ffWOxirezuZ1+ECYzvSfM/YOqwYPHNA3ymipg1jU8kRXVqzu1PJKpZgFrbnpExll9Wn66Z4sV+/9xT8Qfs+G/toND0eUjklc1mWMoGAbkCe/4WafCjNnMPsnRGphQtmHNouA9GAtTL9il41X1uPMGPlK9s33zWk0Xl0F7B1RsbdkcA1LkFonr7z40NjQyYMi9vOfHAgKojHAKqcAB9LqjB/m/aolwoHjPfLhHTRZ0VEFB+zP2nDNtqQKgMZd7r/1YTgLEKV6R4qswC3lOMP3hIYIY0gkNFyjF7wuGYCgw6soZHYjXBPvor4lIgVqppiJn7gWJ6rnvLz4QVcKoZhd37xvvgqNY5eE6cVeSJxwhXu2K0qHd7x/PbDlt6HxMoyxaj5fX2u6otZVvE0qSkjDkmXhzgZN/4VUyK4oN4bGpQDe0G9GmGNpQIFkkCHi6RKg5llSOfwdp0P7mRv7aVDj36bN8Ftz3eMx2PMY/9H7DV249gI14DMdzgBzUW5KpvGXjcjGTPUiB4q3DH7FKD2/t//Tgqp7iZSq6XeTcqgRf2eScPtoTV2DftcpYofl0tFGKUNzIMtVu75kO5RG231aWht04RVQKUTm5zkyaEpDK+pB2pKQ== 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)(396003)(346002)(376002)(136003)(46966006)(36840700001)(55016002)(83380400001)(426003)(356005)(6286002)(478600001)(6916009)(107886003)(336012)(36906005)(316002)(54906003)(2616005)(26005)(16526019)(4326008)(186003)(2906002)(86362001)(82740400003)(6666004)(7696005)(5660300002)(8676002)(70586007)(36756003)(47076005)(82310400003)(36860700001)(1076003)(8936002)(7636003)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:08.5933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3591220-a566-441c-cece-08d90f25e56f 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: DM6NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0093 Subject: [dpdk-dev] [PATCH v3 05/15] common/mlx5: support general object DEK create op 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 Data Encryption Keys (DEKs) are the keys used for data encryption/decryption operations. Add reading of DEK support capability. Add function to create general object type DEK, using DevX API. Arrange common version.map file in alphabetical order. 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 | 39 ++++++++++++++++++++ drivers/common/mlx5/version.map | 55 ++++++++++++++++------------ 4 files changed, 140 insertions(+), 24 deletions(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 7ca767944e..742c82cca4 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -741,6 +741,8 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO); attr->geneve_tlv_opt = !!(general_obj_types_supported & MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT); + attr->dek = !!(general_obj_types_supported & + MLX5_GENERAL_OBJ_TYPES_CAP_DEK); /* 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); @@ -2397,3 +2399,54 @@ mlx5_devx_cmd_queue_counter_query(struct mlx5_devx_obj *dcs, int clear, *out_of_buffers = MLX5_GET(query_q_counter_out, out, out_of_buffer); return 0; } + +/** + * Create general object of type DEK using DevX API. + * + * @param[in] ctx + * Context returned from mlx5 open_device() glue function. + * @param [in] attr + * Pointer to DEK attributes structure. + * + * @return + * The DevX object created, NULL otherwise and rte_errno is set. + */ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_dek_obj(void *ctx, struct mlx5_devx_dek_attr *attr) +{ + uint32_t in[MLX5_ST_SZ_DW(create_dek_in)] = {0}; + uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0}; + struct mlx5_devx_obj *dek_obj = NULL; + void *ptr = NULL, *key_addr = NULL; + + dek_obj = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*dek_obj), + 0, SOCKET_ID_ANY); + if (dek_obj == NULL) { + DRV_LOG(ERR, "Failed to allocate DEK object data"); + rte_errno = ENOMEM; + return NULL; + } + ptr = MLX5_ADDR_OF(create_dek_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_DEK); + ptr = MLX5_ADDR_OF(create_dek_in, in, dek); + MLX5_SET(dek, ptr, key_size, attr->key_size); + MLX5_SET(dek, ptr, has_keytag, attr->has_keytag); + MLX5_SET(dek, ptr, key_purpose, attr->key_purpose); + MLX5_SET(dek, ptr, pd, attr->pd); + MLX5_SET64(dek, ptr, opaque, attr->opaque); + key_addr = MLX5_ADDR_OF(dek, ptr, key); + memcpy(key_addr, (void *)(attr->key), MLX5_CRYPTO_KEY_MAX_SIZE); + dek_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), + out, sizeof(out)); + if (dek_obj->obj == NULL) { + rte_errno = errno; + DRV_LOG(ERR, "Failed to create DEK obj using DevX."); + mlx5_free(dek_obj); + return NULL; + } + dek_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id); + return dek_obj; +} diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index 28ade5bbc4..b9ff7ab87d 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.h +++ b/drivers/common/mlx5/mlx5_devx_cmds.h @@ -139,6 +139,7 @@ struct mlx5_hca_attr { uint32_t reg_c_preserve:1; 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 regexp_num_of_engines; uint32_t log_max_ft_sampler_num:8; uint32_t geneve_tlv_opt; @@ -435,6 +436,18 @@ struct mlx5_devx_graph_node_attr { struct mlx5_devx_graph_arc_attr out[MLX5_GRAPH_NODE_ARC_NUM]; }; +/* Encryption key size is up to 1024 bit, 128 bytes. */ +#define MLX5_CRYPTO_KEY_MAX_SIZE 128 + +struct mlx5_devx_dek_attr { + uint32_t key_size:4; + uint32_t has_keytag:1; + uint32_t key_purpose:4; + uint32_t pd:24; + uint64_t opaque; + uint8_t key[MLX5_CRYPTO_KEY_MAX_SIZE]; +}; + /* mlx5_devx_cmds.c */ __rte_internal @@ -587,4 +600,8 @@ int mlx5_devx_cmd_queue_counter_query(struct mlx5_devx_obj *dcs, int clear, __rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx, uint32_t pd, uint32_t log_obj_size); +__rte_internal +struct mlx5_devx_obj * +mlx5_devx_cmd_create_dek_obj(void *ctx, struct mlx5_devx_dek_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 a8fbfbb0f5..bc9f58ad03 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -1109,6 +1109,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO) #define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \ (1ULL << MLX5_GENERAL_OBJ_TYPE_GENEVE_TLV_OPT) +#define MLX5_GENERAL_OBJ_TYPES_CAP_DEK \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_DEK) enum { MLX5_HCA_CAP_OPMOD_GET_MAX = 0, @@ -2406,6 +2408,7 @@ struct mlx5_ifc_create_cq_in_bits { enum { MLX5_GENERAL_OBJ_TYPE_GENEVE_TLV_OPT = 0x000b, + MLX5_GENERAL_OBJ_TYPE_DEK = 0x000c, MLX5_GENERAL_OBJ_TYPE_VIRTQ = 0x000d, MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS = 0x001c, MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH = 0x0022, @@ -2469,6 +2472,42 @@ struct mlx5_ifc_create_geneve_tlv_option_in_bits { struct mlx5_ifc_geneve_tlv_option_bits geneve_tlv_opt; }; +enum { + MLX5_CRYPTO_KEY_SIZE_128b = 0x0, + MLX5_CRYPTO_KEY_SIZE_256b = 0x1, +}; + +enum { + MLX5_CRYPTO_KEY_PURPOSE_TLS = 0x1, + MLX5_CRYPTO_KEY_PURPOSE_IPSEC = 0x2, + MLX5_CRYPTO_KEY_PURPOSE_AES_XTS = 0x3, + MLX5_CRYPTO_KEY_PURPOSE_MACSEC = 0x4, + MLX5_CRYPTO_KEY_PURPOSE_GCM = 0x5, + MLX5_CRYPTO_KEY_PURPOSE_PSP = 0x6, +}; + +struct mlx5_ifc_dek_bits { + u8 modify_field_select[0x40]; + u8 state[0x8]; + u8 reserved_at_48[0xc]; + u8 key_size[0x4]; + u8 has_keytag[0x1]; + u8 reserved_at_59[0x3]; + u8 key_purpose[0x4]; + u8 reserved_at_60[0x8]; + u8 pd[0x18]; + u8 reserved_at_80[0x100]; + u8 opaque[0x40]; + u8 reserved_at_1c0[0x40]; + u8 key[0x400]; + u8 reserved_at_600[0x200]; +}; + +struct mlx5_ifc_create_dek_in_bits { + struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; + struct mlx5_ifc_dek_bits dek; +}; + 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 18dc96276d..42bb985fb1 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -12,21 +12,24 @@ INTERNAL { mlx5_dev_to_pci_addr; # WINDOWS_NO_EXPORT + mlx5_devx_alloc_uar; # WINDOWS_NO_EXPORT + mlx5_devx_cmd_alloc_pd; mlx5_devx_cmd_create_cq; + mlx5_devx_cmd_create_dek_obj; mlx5_devx_cmd_create_flex_parser; + mlx5_devx_cmd_create_flow_hit_aso_obj; + mlx5_devx_cmd_create_flow_meter_aso_obj; + mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_create_qp; mlx5_devx_cmd_create_rq; mlx5_devx_cmd_create_rqt; mlx5_devx_cmd_create_sq; - mlx5_devx_cmd_create_tir; mlx5_devx_cmd_create_td; + mlx5_devx_cmd_create_tir; mlx5_devx_cmd_create_tis; mlx5_devx_cmd_create_virtio_q_counters; # WINDOWS_NO_EXPORT mlx5_devx_cmd_create_virtq; - mlx5_devx_cmd_create_flow_hit_aso_obj; - mlx5_devx_cmd_create_flow_meter_aso_obj; - mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc; mlx5_devx_cmd_flow_counter_query; @@ -48,41 +51,49 @@ INTERNAL { mlx5_devx_cmd_queue_counter_query; # WINDOWS_NO_EXPORT mlx5_devx_cmd_register_read; mlx5_devx_cmd_wq_query; # WINDOWS_NO_EXPORT - mlx5_devx_get_out_command_status; - mlx5_devx_alloc_uar; # WINDOWS_NO_EXPORT mlx5_devx_cq_create; mlx5_devx_cq_destroy; + + mlx5_devx_get_out_command_status; + mlx5_devx_rq_create; mlx5_devx_rq_destroy; mlx5_devx_sq_create; mlx5_devx_sq_destroy; + mlx5_free; + mlx5_get_ifname_sysfs; # WINDOWS_NO_EXPORT mlx5_glue; + mlx5_malloc; + mlx5_malloc_mem_select; + + mlx5_memory_stat_dump; # WINDOWS_NO_EXPORT + mlx5_mp_init_primary; # WINDOWS_NO_EXPORT - mlx5_mp_uninit_primary; # WINDOWS_NO_EXPORT mlx5_mp_init_secondary; # WINDOWS_NO_EXPORT - mlx5_mp_uninit_secondary; # WINDOWS_NO_EXPORT mlx5_mp_req_mr_create; # WINDOWS_NO_EXPORT mlx5_mp_req_queue_state_modify; mlx5_mp_req_verbs_cmd_fd; # WINDOWS_NO_EXPORT + mlx5_mp_uninit_primary; # WINDOWS_NO_EXPORT + mlx5_mp_uninit_secondary; # WINDOWS_NO_EXPORT - mlx5_mr_btree_init; - mlx5_mr_btree_free; - mlx5_mr_btree_dump; mlx5_mr_addr2mr_bh; - mlx5_mr_release_cache; + mlx5_mr_btree_dump; + mlx5_mr_btree_free; + mlx5_mr_btree_init; + mlx5_mr_create_primary; mlx5_mr_dump_cache; - mlx5_mr_rebuild_cache; + mlx5_mr_flush_local_cache; + mlx5_mr_free; mlx5_mr_insert_cache; mlx5_mr_lookup_cache; mlx5_mr_lookup_list; - mlx5_mr_create_primary; - mlx5_mr_flush_local_cache; - mlx5_mr_free; + mlx5_mr_rebuild_cache; + mlx5_mr_release_cache; mlx5_nl_allmulti; # WINDOWS_NO_EXPORT mlx5_nl_devlink_family_id_get; # WINDOWS_NO_EXPORT @@ -102,20 +113,16 @@ INTERNAL { mlx5_nl_vlan_vmwa_create; # WINDOWS_NO_EXPORT mlx5_nl_vlan_vmwa_delete; # WINDOWS_NO_EXPORT + mlx5_pci_driver_register; + mlx5_os_alloc_pd; mlx5_os_dealloc_pd; mlx5_os_dereg_mr; mlx5_os_reg_mr; - mlx5_os_umem_reg; mlx5_os_umem_dereg; + mlx5_os_umem_reg; - mlx5_translate_port_name; # WINDOWS_NO_EXPORT - - mlx5_malloc_mem_select; - mlx5_memory_stat_dump; # WINDOWS_NO_EXPORT - mlx5_malloc; mlx5_realloc; - mlx5_free; - mlx5_pci_driver_register; + mlx5_translate_port_name; # WINDOWS_NO_EXPORT }; From patchwork Tue May 4 17:54:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92750 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A5FAEA0A02; Tue, 4 May 2021 19:56:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 891B34067E; Tue, 4 May 2021 19:56:19 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061.outbound.protection.outlook.com [40.107.236.61]) by mails.dpdk.org (Postfix) with ESMTP id 8ED4B4014E for ; Tue, 4 May 2021 19:56:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AENvXORPwSjG7SGYRP5CvAnypH5lQuFuNX2EvcoesD7IQ9Qb8Q3NiPN11PqvfgzMRk344kZsBYs6qg5O2fQwXYNFk0oHZ3BHOzGCi1/HZ+vtO5/kUIsrHAfn087uEcGIpf4phzDKdTFXQReuBzQIkxqjUGMdwm+7bCaFUpV6bWbkK2WDKDtf/0i5zGZusaeM6vK1p8Kcg617SqnUc1wiZLZMy1LBGyJnHFvTr/W1q1XlSubvAa7zaweFjGxkeDbTdQ6kwmDxnspuHfA25xi08uqIJMnLaD5ItJ218dAR7e5faXzD9vh2ZeyIRep04u3tJ9twl6eCZN+r+Apag7GEyw== 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=jltACnE23OSkVE6J/+RMwkM4GFekAT5g2pFmvcyLNDk=; b=LxC3+oWvmTepzuhzG8e8ln6JbydE9XftA7ErEyStyVbmxQC1bY1kr2TbiaGzaPzY9mty2sloseweHgTYqkT6CcEXtNLkIwXu1VDmfCWrPRkajt+Kxny97LAbpPN9uhBOA5X0mY/UINm4jjXj+FZ4bgjbBjngA9rDEQn4LbqOV74TOdXOVx9GnRS6d64LNTCqGfevqnNvt8+6nlCXs3qEEmWopKUFPD5MAD9RB9JDCaPxMAB1Y8aOt8EPFirt8fZLJ9MKkbBfaYh2ZzmW/eR9lRuqZN1bYvO4bta04L9r7oQwmTdvqka34r2Nos1Ggzy8UX1s6UScgIMszyudmgp7TQ== 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=jltACnE23OSkVE6J/+RMwkM4GFekAT5g2pFmvcyLNDk=; b=bG6BXycL/jWrjHPoj50IJU1dZMu4sTgQKQ1bneJVdNdXKArnJjj2Bsj9VuG7JiMi2ULb7bFqeVHsE7Ylyo5z1oy1Ga+y9/5i8CQsZViyU67BwmHX/02iNbBYi3Veh2mGhkwJ0fpcoSMmsZu1uAZMa9ZxDo7M1Q/lYQp0mtMbeHs+FS+0e6kS9dqmbSS07kX6gxAqeTo7Qr7OS2qPfC9oNF3IFf7sXCfL36YLKPwNUPkb7Qx3Qe3PtONme4iqjxBE7CqGGHPzJqdK0qjIUd0M09FJDWc4eGIh90uyZhwZL3zPpt7Rj2n7yxdlN/CXqxBW9tA3+9yqFWILHjD+fv3JJQ== Received: from DS7PR03CA0194.namprd03.prod.outlook.com (2603:10b6:5:3b6::19) by MWHPR1201MB0093.namprd12.prod.outlook.com (2603:10b6:301:54::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Tue, 4 May 2021 17:56:17 +0000 Received: from DM6NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b6:cafe::aa) by DS7PR03CA0194.outlook.office365.com (2603:10b6:5:3b6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 4 May 2021 17:56:17 +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 DM6NAM11FT065.mail.protection.outlook.com (10.13.172.109) 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:56:17 +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:56:15 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:51 +0300 Message-ID: <20210504175500.3385811-7-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 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: 550acdd8-cb44-4d47-9f78-08d90f25ea81 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0093: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr 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: tPCNdUCPFsUpzeG8g3Y1dH5XSPvPMPMVbqCd9hyAtf546Ui0nlq5VI/HOkDtcMGo/qOw5MY3eoUWJU61FhdW3ZkGDTZ7MWx+Rbfxv6/26XPKIzD1NagmKS34247meQzRkULK2D2fAOJnV9OqRDvVwBmwmjYq6DPpYqpchcAz/cGXzpMlHYnO4VzLU/zlujvgEP53o4tHRSrnkcA+5M3Uzi0BzCvyXHLyI6axNLODYQzWwS9XyWHLC3UTQNR5LXFUO51U36wOBo4WDVuubU+2eKgfNbYC5C2QCg9iBKx4joNCjhfajJX0jkCah9EQ93uUt5EPzApnnP5UA5DjLryvzygyWpiZpgC9uIJ8B7YtPW9LzMxNVwWMbX1DSFWbPgt1Ah8PXDte7Y+yUENkVsMaU81KDiI6j9ntdhd/z2hFd0ffwkmG1eu/3mRxIWYY0kcegn8S7k/fOl39wOt0DhQzz9RE7zXTPx4LzmVxUKepIr9JUgiB3j8kW6rHIJADpyO7cFOrUSnO8K8u96YD1LO5+IvNsqdYm5qpP6+57FjAv4fT/fOooL4qePYfrznhvQLbQywL48x1+Dk+r+jcndiLIq0VrtTYvp6E0pFsUiaDw4+G1tC58SmRcRBQEjpU/1r25vSiNbSzKIaN4BVigDZ97QYYjgmHQQp4su4BcoTp6Vc= 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)(396003)(346002)(376002)(136003)(46966006)(36840700001)(55016002)(83380400001)(426003)(356005)(6286002)(478600001)(6916009)(107886003)(336012)(36906005)(316002)(54906003)(2616005)(26005)(16526019)(4326008)(186003)(2906002)(86362001)(82740400003)(6666004)(7696005)(5660300002)(8676002)(70586007)(36756003)(47076005)(82310400003)(36860700001)(1076003)(8936002)(7636003)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:17.1046 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 550acdd8-cb44-4d47-9f78-08d90f25ea81 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: DM6NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0093 Subject: [dpdk-dev] [PATCH v3 06/15] common/mlx5: adjust DevX MKEY fields for crypto 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 MKEY that will be used for crypto purposes must be created with crypto_en and remote access attributes. This patch adds support for them in the DevX MKEY context. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 9 +++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 2 ++ drivers/common/mlx5/mlx5_prm.h | 10 +++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 742c82cca4..7e3c8b55fa 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -263,6 +263,10 @@ mlx5_devx_cmd_mkey_create(void *ctx, MLX5_SET(create_mkey_in, in, pg_access, attr->pg_access); MLX5_SET(mkc, mkc, lw, 0x1); MLX5_SET(mkc, mkc, lr, 0x1); + if (attr->set_remote_rw) { + MLX5_SET(mkc, mkc, rw, 0x1); + MLX5_SET(mkc, mkc, rr, 0x1); + } MLX5_SET(mkc, mkc, qpn, 0xffffff); MLX5_SET(mkc, mkc, pd, attr->pd); MLX5_SET(mkc, mkc, mkey_7_0, attr->umem_id & 0xFF); @@ -273,6 +277,11 @@ mlx5_devx_cmd_mkey_create(void *ctx, MLX5_SET(mkc, mkc, relaxed_ordering_read, attr->relaxed_ordering_read); MLX5_SET64(mkc, mkc, start_addr, attr->addr); MLX5_SET64(mkc, mkc, len, attr->size); + MLX5_SET(mkc, mkc, crypto_en, attr->crypto_en); + if (attr->crypto_en) { + MLX5_SET(mkc, mkc, bsf_en, attr->crypto_en); + MLX5_SET(mkc, mkc, bsf_octword_size, 4); + } mkey->obj = mlx5_glue->devx_obj_create(ctx, in, in_size_dw * 4, out, sizeof(out)); if (!mkey->obj) { diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index b9ff7ab87d..600577f18a 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.h +++ b/drivers/common/mlx5/mlx5_devx_cmds.h @@ -32,6 +32,8 @@ struct mlx5_devx_mkey_attr { uint32_t relaxed_ordering_write:1; uint32_t relaxed_ordering_read:1; uint32_t umr_en:1; + uint32_t crypto_en:2; + uint32_t set_remote_rw:1; struct mlx5_klm *klm_array; int klm_num; }; diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index bc9f58ad03..25f6f8ff00 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -1059,7 +1059,15 @@ struct mlx5_ifc_mkc_bits { u8 relaxed_ordering_read[0x1]; u8 reserved_at_1da[0x1]; u8 log_page_size[0x5]; - u8 reserved_at_1e0[0x20]; + u8 reserved_at_1e0[0x3]; + u8 crypto_en[0x2]; + u8 reserved_at_1e5[0x1b]; +}; + +/* Range of values for MKEY context crypto_en field. */ +enum { + MLX5_MKEY_CRYPTO_DISABLED = 0x0, + MLX5_MKEY_CRYPTO_ENABLED = 0x1, }; struct mlx5_ifc_create_mkey_out_bits { From patchwork Tue May 4 17:54:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92751 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6FC1AA0A02; Tue, 4 May 2021 19:56:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 558E4410F4; Tue, 4 May 2021 19:56:28 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2065.outbound.protection.outlook.com [40.107.244.65]) by mails.dpdk.org (Postfix) with ESMTP id 6150F4014E for ; Tue, 4 May 2021 19:56:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aT5x/F5Qa7j/HemFe6oERVawEqjbwt6ptSIuH1QcHWbY+SkSfdmVudsfonACxrAGYXWpZ71roHZeXRVAoXbI3tCjEBEmbo8oxYvGY65QZOi3iYOt5V9PjE1GWYcqxQGPXkHOd6waRGeE7uk6TGqeekSR/gmjCjFi5CoTQkRmE1lyH1Nfo8gOIFfjLfxUxHvzb8Xuk6f+YRE+WnEjMzff14t/7WHD92TgAmMu+boeRJxr0rdolIOwHylih4iYivi+/p8IEJT/O8Vgw1fF8Uu2lnqppptNMXTZmnjzTARlpB5kciEZjhxQuypJPVmvmxVqbbTZmEI5GrcLhxYsrfLYkQ== 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=g7xM29uppSNuhI1yZ3cFPBqwulIE5X9UXoJnvUDeKfo=; b=j/8+y6F0NplnO4idaKNZvGc6k7vhjJzqIhsw4ZGRnncJASAK1xOIiSPIQq7bAwyc/P3q9DSZ4SPKEwKwi/4WC4jJmoD6u5NKf17Cmt9DZFP/fu8U8xGLEDtYgis7kt2sKqW5T8C13UAzSl4zbSrIJkdg33ggbl1ftl8D/J1NIIt15qKtqXUrkCP3paph0IvsWS5Oj3vscBxpAISedMkRujMvAL7lqvQ4NSe6ra5ae4jS2uhi2iaU3CT/ZTelpOHHdTd0aAxG9Bmo7H/ihfpwf6GDedhw372ZWCyTq3WgDsPfy1+Yz1pQh099RTCAPllY1Tec0pZPQtvDugt6a1FaTQ== 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=g7xM29uppSNuhI1yZ3cFPBqwulIE5X9UXoJnvUDeKfo=; b=lN/s6x2HCNnlkVV9g1yKfYfMhZYtvRkGeh0fQE83XL5XFvvIRY8B3oMs3GmyuP9j86n7qokqLa2pn9rw0hbehGhg5EqSAAH28oVbTxTFwrUZ6HM17h+efUZl/WbQqSI/raDjt9Rg2I1J8CP5QKiixyQrkQsizYDpwRoAcU418EAg1E82fFJcbRmvU263nlxURz0NzEyHCVSVwwGqqBKWaLF/7Qe6HCiRJFmdd5psu7b4VXK+OtyYrYOHfw9BQSpDU0JTHhmoyuQs8+/RXblUrSlsU37Dkvn7v8JmIrcysV8Fr52V9OaRoY/+2xAnJMFqx9q9SsPSsi+GNSULAL6rWw== Received: from DM5PR20CA0020.namprd20.prod.outlook.com (2603:10b6:3:93::30) by BN6PR12MB1268.namprd12.prod.outlook.com (2603:10b6:404:1a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.38; Tue, 4 May 2021 17:56:24 +0000 Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:3:93:cafe::ba) by DM5PR20CA0020.outlook.office365.com (2603:10b6:3:93::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.28 via Frontend Transport; Tue, 4 May 2021 17:56:24 +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 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; Tue, 4 May 2021 17:56:24 +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:56:22 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:52 +0300 Message-ID: <20210504175500.3385811-8-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 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: e3afe9ab-59bf-40c6-68d9-08d90f25eee4 X-MS-TrafficTypeDiagnostic: BN6PR12MB1268: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MN7L83mQk0kJkwecjQrTCJTNaGce/zUzgf5+upYCeY07u1Qc+s2PfsV7lSst2116FgvTvJeY7ptXy970WWlqVGzboH0gK+0cSBWiLT76730nywgqYSYjYbmhu23tl0q4VnA41cq4R4g5Mi52t0tijOG6NBCYriLHlI+0Cj7unf3YWPYrVMGVwzb5HEKKpfnZHxnTgoHm46Qj2NbnVwrw4txxu3iwN4YygV0BXueEpgfF+JSj5N38ObpabakzjH6o1V0AaiSLqDrwbD7gxoBwgeet2q0v4U2wa6wXE4YcApT1j8+1uBQtir0FBzyO1Km1wg/iimylQ+e8AyK17Cazsl47/z17qinquGXFDkn8DS2/XTk8MPmup6v0KpjZuZBL6STRRa9nZ9qwqcqgr0LhfkxqmFK1qe4ut9mX4CyuayqP/0Cvz+QPNdCtsAphPA/bHew7OBU1coWava0pg0fyceKwZMJyGVNmsFTkyTh7WLNnSnyjf9XkjnfodGSVfqtg/Q6rGu4B7BiRO+YDnkfADF1moDJ4Fj+oGelP4jfVAslnI1p6SxuRgSGvSLiTj/P2dLCgF0qHu6DMZ7aRI2k/j8yPPqwdUybvCEEUaR9rt+L4fXbR+Q9cRH/AFrb6fixxEkXl2Xpr17NJTXF0ILzQWsMGgFyx0N00X/Pa4RYPxQM= 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)(39850400004)(136003)(396003)(376002)(46966006)(36840700001)(70206006)(70586007)(47076005)(1076003)(82740400003)(7636003)(6286002)(6916009)(36860700001)(83380400001)(26005)(16526019)(4326008)(356005)(36756003)(6666004)(478600001)(316002)(7696005)(55016002)(336012)(82310400003)(8936002)(54906003)(2906002)(8676002)(36906005)(186003)(86362001)(426003)(2616005)(5660300002)(107886003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:24.4599 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3afe9ab-59bf-40c6-68d9-08d90f25eee4 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: BN6PR12MB1268 Subject: [dpdk-dev] [PATCH v3 07/15] 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 42bb985fb1..60bff5f799 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -21,6 +21,7 @@ INTERNAL { mlx5_devx_cmd_create_flow_hit_aso_obj; mlx5_devx_cmd_create_flow_meter_aso_obj; mlx5_devx_cmd_create_geneve_tlv_option; + mlx5_devx_cmd_create_import_kek_obj; mlx5_devx_cmd_create_qp; mlx5_devx_cmd_create_rq; mlx5_devx_cmd_create_rqt; From patchwork Tue May 4 17:54:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92752 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A87F1A0A02; Tue, 4 May 2021 19:56:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9096D410E5; Tue, 4 May 2021 19:56:35 +0200 (CEST) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-eopbgr750053.outbound.protection.outlook.com [40.107.75.53]) by mails.dpdk.org (Postfix) with ESMTP id 2328C406A2 for ; Tue, 4 May 2021 19:56:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MuYbFSNZ9WKjDpVbtvDzS90k0byqXsnaiKCuTYSt5ik31momp68QAblMh2knPSmxO+Wd7OctT8nw0bcMvFB+KyBu6n3FGy4X/PQK0a7CgzMCEOm24Qxg9n63Qq8vYjRg9gJAWAT5bndVCDxCV6X31SO1Jcin+/2BDXjVIEdOg5aX4Xuflb8h7FN6cOyTxKw5is0syKnwm4c3RflkOE9YNAYiVLG9y2r2IbsVMTyfMBNcrw+jdJ2mg1U1mG5tmvvQp+yaThWG5o8rt+WzeFTjdRaGd045+EQZgo5Qp9IQfcjPPNNzv5l3VGxv0WP+rqI3ZnBbA9e6johExt4LL754+w== 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=yKQjOwkjVoIohSknmmul6IEFOgu0IQknBKhQn6pLr0o=; b=TxxdiYDqoLZ6rgUSkftJxyPB3gTG2WOQpqb7KdenRHgT1hRUIFksstpbEh3TZoUb08nYYv/2yXA1Rt3a1E9YPTEsJb38mN1lICQ7z/F+eh3XxZ+1hEAcDZ90gWfsnG1YIiC/E2+CosVlO4lXstz0G+U8C9NuGMdmQKiIYfvTACa0d6RFkj3M3GIyNb/HRJVI+9Uc+mkboUCbPypLMw7X1Uh2ajWC2uc6VUOwJzOVTHwIITVPD6TXd3x8y7LwQepf4cnqPHuPJSQIGOoUsRYdHhxNNGR+d9SLV7OaQ4jy0pq6f+jcXnMVGNKfzwfdT6PFCjC5G4XrA7n5p232fD8a/Q== 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=yKQjOwkjVoIohSknmmul6IEFOgu0IQknBKhQn6pLr0o=; b=ZkGWDLpaA+JWOO6PlosK9nuOnAOT5+8Hono4f38ThANIHkVA/c3BlKkrhZZTKbS1qjFYjgIhIVdOhDB+THf1SpcMMmQRm+3cnGo8bKawunXd+TIwh7F7jriUwxZSDwvdZWxpKS6velXknHftHq7YwK/Lq+l3h+A5HJrAcs06Z+UXRXlYkmCHN0hoCjied1svhgpIll/lUheEEscDRCT2BqSsBz+LWLFp+JoLceXzFGFjee315cxcq8q+3OlAfmaUiBrReTqvkW6gu78OGa4hdI78lBI5e2lXkUQUT3IQIy+HGXUnetwa/PO4fM7ZoMj7MfaJbQDhhh2devu5oBvfew== Received: from DM6PR03CA0093.namprd03.prod.outlook.com (2603:10b6:5:333::26) by MN2PR12MB3054.namprd12.prod.outlook.com (2603:10b6:208:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.40; Tue, 4 May 2021 17:56:32 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:5:333:cafe::e6) by DM6PR03CA0093.outlook.office365.com (2603:10b6:5:333::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Tue, 4 May 2021 17:56:32 +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 DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) 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:56:32 +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:56:30 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:53 +0300 Message-ID: <20210504175500.3385811-9-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 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: 302cff5a-473d-4d75-5ec2-08d90f25f387 X-MS-TrafficTypeDiagnostic: MN2PR12MB3054: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MGwxmR354Ao3u8DICTiQFVc6MuCd97E5cPKWDl4fgOFKOXfUHXR8B7cHYVBobBpPuqEAOwFQ+yzr+d+4Vr+d8anIChKStBIm9S9O3uX2J3EawmbyBG7da8m1R3aAByKzjD8b+bPLPu4lA5EgbzSky+kaPE0eUVBTAoffS8g/aY7OanvmGhM1hISQtkQkUWUtXTS1b1eimAM6BGa8VPdPMAcmIkSoaHTYKIn24m5xFMmd1AAeUSrVyrWpDYIwNsmp3N4u0jB0rC2aTlWMIl/9VhA7KYNkn+twd2xSaVstez2UhbMnKNROtixuN5/B9HV1mdPn6xofHrbYe2WzHloSYrJmViXtRHSNMTgaPBz0SeIWORk1ID1VBQ5blRijoV9rinjfSuvNmMp5ZFzXMOXPEf7KC0xOeEh/s+qID5TcphjE3/nYkC48aHoi/Bb6P+jobcM6brRrncDPvE/KLLqBCv53pY61KPTEgjzC2SkeSot12dLIcHrz57uIPcwhqJFAxT/jjqW3Kuc4vpsqikHrgvT9A1/trLwS2OsjBM9ZTmy2RfugZdLqrXOI10Q49NPsQC9ycb83xQOUvreEB4RgOH3huX+y8WB9CDeRXw9h74H2xcBpKIMxZjT9N5JpuwIfifhYiwwVz7ferE6iJrwTDaC1uzBa440sXe62vxHh+4w= 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)(136003)(376002)(39860400002)(346002)(46966006)(36840700001)(86362001)(16526019)(54906003)(26005)(478600001)(47076005)(6286002)(186003)(55016002)(4326008)(107886003)(336012)(70206006)(316002)(2906002)(83380400001)(6916009)(36756003)(82740400003)(70586007)(8936002)(36906005)(6666004)(7696005)(426003)(7636003)(2616005)(8676002)(36860700001)(82310400003)(356005)(1076003)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:32.2578 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 302cff5a-473d-4d75-5ec2-08d90f25f387 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: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3054 Subject: [dpdk-dev] [PATCH v3 08/15] 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 60bff5f799..89f0ee04cb 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_crypto_login_obj; mlx5_devx_cmd_create_dek_obj; mlx5_devx_cmd_create_flex_parser; mlx5_devx_cmd_create_flow_hit_aso_obj; From patchwork Tue May 4 17:54:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92753 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 102EAA0A02; Tue, 4 May 2021 19:56:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED89F410F8; Tue, 4 May 2021 19:56:43 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) by mails.dpdk.org (Postfix) with ESMTP id 48EF3406A2 for ; Tue, 4 May 2021 19:56:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lbtPNrYV2xIJte6/WDLzxbQIblyNgBHO4Sih/gqfYJPDCfOHSFbYx7VhgZAGki0ouAr+omUQ1Q1cES3luyKuBG6BXyJuVAG1u7/Sz6PdJHRoI5W4mNSw+nkMr8S2QKUKXapQcMz1ZOXSTIV6VtVbULjGCccrVLkbtkBYiiDGMThLgqbZRhUNHiGOAsyv0KYGnsLAuR/OsbWXDGy/Al4T4qZcAwCTRMorKVYcsI+fNMLbi3HSmOxinE5D+qT/IccHj5AA0ZonmyJBwKEvlQ/KuSJpuPfbR6VvX9Ncid/1jPHOMMjL79xPjunP/lMNv16C5UOZiYdhnCxzapfG+f/mqg== 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=mPr5rMpTdg+eF6DreyYQLjm8SqOm1l6YttcLm5KoD2g=; b=cBGmV8e5cl0Dld52FwDylOhIEr78g0v3zkQPpG9vE9eMT6nABU+GgqgLAjjTd+0Hw4EWIgu3S4yL0I7hJcsmVFBh3uIh9hGCGBtMEzFfWJvn22O3q2GIdOgHY/lZqaGciGNKyaT89PNpiEmzqTa3aZ6JR0tMkKpFCrKf4o74Uw4NHqPQz6jM+CyY/xH1pgytApBGMTPtVyuJ2PpULhab3Ct7Iue7QVwoUKoDvNAls72OnuGZXbhs1KHbP3YFu4HrRyPnldtE2tavW0+UICzC0ndweJJRA9xxXUcv4aCXA98635Rbjx18hpOPA1cG0A1WepT6sAhq3i2dlRgbjBIoTg== 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=mPr5rMpTdg+eF6DreyYQLjm8SqOm1l6YttcLm5KoD2g=; b=tGnUiwqTuInLJ8DB2vNBgYmp4amCuVqf7fah9MGW0DqWdehRiqoBBUT4hDanDYRlWSAecg9vSmOgXX3fok4jJ+4Q/Bemrk7KVE7aKfhjHywGTXJwS8eJEo4fLio6s+rca33Tyk++nL35TR4XKKh5YpbZwb40QIVfQpWyRd/FBvzTmRFsZL59fhCI6eZf7jsOhCg0yUZngqSDuKT3NOcf8tbhFokkF0U97RdN5nMxmdoYVpnTtrGF8BdsV/UBFKM1uUO73Gsx8gWtQV4X2O48PHVeXdha9HF2xEgWWbaPCsbZAhrFmconyRAFb1Nzt4CJ4DdvIVbkfiF409ydMxv7FA== Received: from DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) by PH0PR12MB5420.namprd12.prod.outlook.com (2603:10b6:510:e8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.40; Tue, 4 May 2021 17:56:41 +0000 Received: from DM6NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::e2) by DM6PR18CA0010.outlook.office365.com (2603:10b6:5:15b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Tue, 4 May 2021 17:56:41 +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 DM6NAM11FT037.mail.protection.outlook.com (10.13.172.122) 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:56:40 +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:56:38 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:54 +0300 Message-ID: <20210504175500.3385811-10-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 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: fcd071f2-73e6-4009-d6ab-08d90f25f8af X-MS-TrafficTypeDiagnostic: PH0PR12MB5420: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2043; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OnqQhc9iLeJ57gtEKdry/Q7as25fbckofVJByLkvcBLhvM784S0OTi8/diddu7nrEEG9XshxTXs3RXiqNPPhA4rTon7XbouRMcXVCM9BIggIL7YJJGI+SzShJJ68I+on6NMjaIVyr9R1NfjcbSah1ZAATyQy1/P8h2vejk6X4YGeBWwFyKkHAA+0XLNoSuZOg7dc6yGuMyKIZXg3EjpvLZhhGiOtLDsQ/cGaOLNqhv0M+w1by9ABp1o/0mqOrltAciDxU1XHicZNWZAAZfkfiYjr/Gyjif3hiNJAwxz8abgI2xiNGXdj21ZxjnafTXIWU8egBYDq/rcmX8Y/xET/Gv4eMyFCO1zu1nNBVWQppc7FNvObWjUdwad4yd4fjehxaHCUDWbVbxXgYx84/ZI8DIF8iQ6z9NUy2AB7HF6vmOKaFSuEC3M+LLmywDDg7uX0evOE7jrpUDFOTOPdwmKIPVGp3c5pgFy1hCbzsTDqoECaxIVz2ocnxSfQgLBFsRxKy/rkyMPGDiEkIdXmNbo5a8+BqNAgN3tT2ZWYTQ4ZplFQgmMOXIWrW73PLWbUFV5UF8RXGJbZwI2DcyEYOZp3tyfKA9JQlx064lEsLt4WDZ7/fkEyd7nv2Bg5rFJEQZOG1wLVw9bXvmvxcrv2ZNYDK9eZ5k3tdUsKUq6o3XFFwdk= 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)(346002)(376002)(136003)(39860400002)(46966006)(36840700001)(186003)(1076003)(16526019)(6286002)(70206006)(107886003)(70586007)(36756003)(47076005)(7696005)(478600001)(55016002)(83380400001)(426003)(4326008)(8676002)(5660300002)(26005)(36860700001)(2616005)(86362001)(6666004)(36906005)(6916009)(316002)(8936002)(54906003)(2906002)(82740400003)(7636003)(356005)(82310400003)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:40.8916 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fcd071f2-73e6-4009-d6ab-08d90f25f8af 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: DM6NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5420 Subject: [dpdk-dev] [PATCH v3 09/15] common/mlx5: add crypto BSF struct and defines 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 This patch adds the struct defining crypto BSF segment of UMR WQE, and the related value definitions and offsets. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_prm.h | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index a2437faec0..a9dcbfa63c 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -1096,6 +1096,72 @@ struct mlx5_ifc_create_mkey_in_bits { u8 klm_pas_mtt[][0x20]; }; +enum { + MLX5_BSF_SIZE_16B = 0x0, + MLX5_BSF_SIZE_32B = 0x1, + MLX5_BSF_SIZE_64B = 0x2, + MLX5_BSF_SIZE_128B = 0x3, +}; + +enum { + MLX5_BSF_P_TYPE_SIGNATURE = 0x0, + MLX5_BSF_P_TYPE_CRYPTO = 0x1, +}; + +enum { + MLX5_ENCRYPTION_ORDER_ENCRYPTED_WIRE_SIGNATURE = 0x0, + MLX5_ENCRYPTION_ORDER_ENCRYPTED_MEMORY_SIGNATURE = 0x1, + MLX5_ENCRYPTION_ORDER_ENCRYPTED_RAW_WIRE = 0x2, + MLX5_ENCRYPTION_ORDER_ENCRYPTED_RAW_MEMORY = 0x3, +}; + +enum { + MLX5_ENCRYPTION_STANDARD_AES_XTS = 0x0, +}; + +enum { + MLX5_BLOCK_SIZE_512B = 0x1, + MLX5_BLOCK_SIZE_520B = 0x2, + MLX5_BLOCK_SIZE_4096B = 0x3, + MLX5_BLOCK_SIZE_4160B = 0x4, + MLX5_BLOCK_SIZE_1MB = 0x5, + MLX5_BLOCK_SIZE_4048B = 0x6, +}; + +#define MLX5_BSF_SIZE_OFFSET 30 +#define MLX5_BSF_P_TYPE_OFFSET 24 +#define MLX5_ENCRYPTION_ORDER_OFFSET 16 +#define MLX5_BLOCK_SIZE_OFFSET 24 + +struct mlx5_wqe_umr_bsf_seg { + /* + * bs_bpt_eo_es contains: + * bs bsf_size 2 bits at MLX5_BSF_SIZE_OFFSET + * bpt bsf_p_type 2 bits at MLX5_BSF_P_TYPE_OFFSET + * eo encryption_order 4 bits at MLX5_ENCRYPTION_ORDER_OFFSET + * es encryption_standard 4 bits at offset 0 + */ + uint32_t bs_bpt_eo_es; + uint32_t raw_data_size; + /* + * bsp_res contains: + * bsp crypto_block_size_pointer 8 bits at MLX5_BLOCK_SIZE_OFFSET + * res reserved 24 bits + */ + uint32_t bsp_res; + uint32_t reserved0; + uint8_t xts_initial_tweak[16]; + /* + * res_dp contains: + * res reserved 8 bits + * dp dek_pointer 24 bits at offset 0 + */ + uint32_t res_dp; + uint32_t reserved1; + uint64_t keytag; + uint32_t reserved2[4]; +} __rte_packed; + enum { MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE = 0x0 << 1, MLX5_GET_HCA_CAP_OP_MOD_ETHERNET_OFFLOAD_CAPS = 0x1 << 1, From patchwork Tue May 4 17:54:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92754 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B5BDCA0A02; Tue, 4 May 2021 19:56:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F5F7410FE; Tue, 4 May 2021 19:56:52 +0200 (CEST) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-eopbgr760048.outbound.protection.outlook.com [40.107.76.48]) by mails.dpdk.org (Postfix) with ESMTP id EB0214014E for ; Tue, 4 May 2021 19:56:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nw86kevVYMPJuinzugVvSS9CUv8FvFXBdwMh4JhMFgjsZsdNTC4ONfyYGvoHanKr44R2kGsM3mzMlsA8bPzmodSZV2iPJeZgl5M6JcCWRCCreObzYkgKetyoeCZVo+EZj2It/00k1avawCuajYsVOk/4M1LFYPOsiqkUtQOXKJbXI4Imnvajx8r29S4yXlR6IaAtnSz/v22cLRGHdcuOuN1yfYhOUJq1vWOX2Bh1bxgwz+PFL5iiy/9zNSD+R8eZfBRgKzi08d1v6gZVf5ZDCEl+aACw+zO/phtIaLbgk91ChBWSgus6Xe85RM3bwjiRXiSbxTKa84sqZqMpzq7nWg== 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=0xBYqf259yUjwcT5g8zKnmNXJGJs3ZKUKlqumgn6LTU=; b=M0RLfrv5OzatS4in1cQYC8b9zmRDRLRjoz4ndltQbWTcrRTyGAN0Pv8WKxGchH0M86S9wM6O1hcFTb9sm9qK9vKrAovAuaWg1lDrn/tX6+HKBjaGvNotTj2rzBxNxYwMzNRyoHTB3D2Wxaa4MQv6YIO1bIv1dykB8RV+d2QZDmVYNL9AxAfS2f51GH6hjve+k1IvYtVcoRAxapWFGsDlutrLRNXGO3Sxa4Nkx4DfBVgMU5gOqNzuJznaANdWXY2durAlk314c7pmjLbnG2K7HLU3kFBEw+rmQ4+3dvC8PgiXEaYDMIeWLBrPj9nxGl8ZhsEFi4BHi6bw4gpCfrwgjQ== 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=0xBYqf259yUjwcT5g8zKnmNXJGJs3ZKUKlqumgn6LTU=; b=Qo8ThvTuh62Ft92VsBe/liSfNa7HxbQTstgzKOva5FC9PDGUWVexQTJlK1kM7+/O06uQeFJw16SLR11QElRhmN6a+AFXZjyimUMS4s6DoarezQD584TSLRvOTKP8UysBoYrGuWwOBs/0uj1cjXdpLSdKUb2v0NyuNqonnqqGwWw8rXFgxcYvLQNP3wqsfFXHeBguSjKq9uWwg/UJhS3SnfionYmTqVGsCAel0dd7HTCCpF9bLBL2/OKCgADNqEv12kLbhdQhRK0qsJJCNokPBLTkv1Z3FuvcsMEDPphBdui/ATez1vEknkOpsCTyLtm/Di7CckXdqhmMpBP1vGN9uA== Received: from DM3PR11CA0018.namprd11.prod.outlook.com (2603:10b6:0:54::28) by BY5PR12MB4145.namprd12.prod.outlook.com (2603:10b6:a03:212::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.40; Tue, 4 May 2021 17:56:48 +0000 Received: from DM6NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:0:54:cafe::2a) by DM3PR11CA0018.outlook.office365.com (2603:10b6:0:54::28) 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:56:48 +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 DM6NAM11FT015.mail.protection.outlook.com (10.13.172.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.32 via Frontend Transport; Tue, 4 May 2021 17:56:48 +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:56:45 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Shiri Kuzin Date: Tue, 4 May 2021 20:54:55 +0300 Message-ID: <20210504175500.3385811-11-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 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: 6f1e365c-023b-47aa-9667-08d90f25fd39 X-MS-TrafficTypeDiagnostic: BY5PR12MB4145: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:171; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VzD4asywePJXfHuEYevGDuukxVP0qlRo25cYK7a7b0vW+JEYwSHEQZuuv2vFOoe/DrYuw4XTRZ6TEi6v7aRhmZ8FFa9giWEZIu0WrpICO4o6yDfCBT7lLkpG5P9W348vwpYxpLNIUFahGPH8KSmILhjF0zRAjaI6ey251dhm9wNFpXZnvHPGIKntvTKHHof7m1PT0icqd6PFQhutIhbmLrEHAcdrwtzKWju+E0BG2tau9s7fH/HUBs0ykXJ+YCn+OF/1nX1OD3dcNR+3iZTK8iZpjhIzWnL8itNcWgvmwzPGxz8M2T7eu1YXeKCi4HuXneUaZckIlq9fZSVow2PyHiqe1L/Yi+Tz5UG0NnKmwrhWilA0oyJm44RThxScnNdQu5/ZeX8/uQgwhPEdne8589GuoevtKWjCVtB6JYHUdWgmhc8TeJWHsidSBVTwnB9A30BRjd/IRLJ9ndFybBNCr1Jqe3JLRJ6cIb7Ezeo5dewUi0YffWpToCXj9PO5pR3e6/P08YfDpZ7bR3SZxqejQTosVl13LYnvCd0wcTbc5cALt+hEZuJKtdVvlfrWr/AlkZ1qhounSVEqqooJ30acqoQd1C2XAfNpmnUbOxalSVPpCqrGSac1QfDs2Nl9qw9WQqXSIepYMYTWKGhd/dWRPQ== 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)(346002)(136003)(396003)(376002)(36840700001)(46966006)(55016002)(7696005)(107886003)(2616005)(30864003)(6286002)(8676002)(86362001)(8936002)(336012)(426003)(26005)(16526019)(186003)(83380400001)(36756003)(36860700001)(1076003)(2906002)(4326008)(82310400003)(6916009)(36906005)(82740400003)(6666004)(5660300002)(7636003)(478600001)(70206006)(356005)(54906003)(70586007)(47076005)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:48.5022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f1e365c-023b-47aa-9667-08d90f25fd39 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: DM6NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4145 Subject: [dpdk-dev] [PATCH v3 10/15] common/mlx5: share hash list tool 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: Shiri Kuzin In order to use the hash list defined in net in other drivers, the hash list is moved to common utilities. In addition, the log definition was moved from the common utilities to a dedicated new log file in common in order to prevent a conflict. Signed-off-by: Shiri Kuzin Acked-by: Matan Azrad --- drivers/common/mlx5/linux/mlx5_common_os.c | 2 +- drivers/common/mlx5/linux/mlx5_nl.c | 2 +- drivers/common/mlx5/meson.build | 15 +- drivers/common/mlx5/mlx5_common.c | 2 +- drivers/common/mlx5/mlx5_common_devx.c | 2 +- drivers/common/mlx5/mlx5_common_log.h | 21 ++ drivers/common/mlx5/mlx5_common_mp.c | 2 +- drivers/common/mlx5/mlx5_common_mr.c | 2 +- drivers/common/mlx5/mlx5_common_pci.c | 4 +- drivers/common/mlx5/mlx5_common_utils.c | 221 +++++++++++++++++++ drivers/common/mlx5/mlx5_common_utils.h | 202 ++++++++++++++++- drivers/common/mlx5/mlx5_devx_cmds.c | 2 +- drivers/common/mlx5/mlx5_malloc.c | 2 +- drivers/common/mlx5/version.map | 6 + drivers/common/mlx5/windows/mlx5_common_os.c | 2 +- drivers/common/mlx5/windows/mlx5_glue.c | 2 +- drivers/net/mlx5/mlx5_utils.c | 209 ------------------ drivers/net/mlx5/mlx5_utils.h | 194 +--------------- 18 files changed, 465 insertions(+), 427 deletions(-) create mode 100644 drivers/common/mlx5/mlx5_common_log.h create mode 100644 drivers/common/mlx5/mlx5_common_utils.c diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index 5cf9576921..fba8245b8b 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -15,7 +15,7 @@ #include #include "mlx5_common.h" -#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" #include "mlx5_glue.h" #ifdef MLX5_GLUE diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c index 752c57b33d..f0d04f9473 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.c +++ b/drivers/common/mlx5/linux/mlx5_nl.c @@ -20,7 +20,7 @@ #include #include "mlx5_nl.h" -#include "mlx5_common_utils.h" +#include "../mlx5_common_log.h" #include "mlx5_malloc.h" #ifdef HAVE_DEVLINK #include diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build index e78b4f47bc..c7ce4c7045 100644 --- a/drivers/common/mlx5/meson.build +++ b/drivers/common/mlx5/meson.build @@ -9,13 +9,14 @@ endif deps += ['hash', 'pci', 'bus_pci', 'net', 'eal', 'kvargs'] sources += files( - 'mlx5_devx_cmds.c', - 'mlx5_common.c', - 'mlx5_common_mp.c', - 'mlx5_common_mr.c', - 'mlx5_malloc.c', - 'mlx5_common_pci.c', - 'mlx5_common_devx.c', + 'mlx5_devx_cmds.c', + 'mlx5_common.c', + 'mlx5_common_mp.c', + 'mlx5_common_mr.c', + 'mlx5_malloc.c', + 'mlx5_common_pci.c', + 'mlx5_common_devx.c', + 'mlx5_common_utils.c', ) cflags_options = [ diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index f92f05bda5..d397459a3d 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -11,7 +11,7 @@ #include "mlx5_common.h" #include "mlx5_common_os.h" -#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" #include "mlx5_common_pci.h" uint8_t haswell_broadwell_cpu; diff --git a/drivers/common/mlx5/mlx5_common_devx.c b/drivers/common/mlx5/mlx5_common_devx.c index d19be122bd..22c8d356c4 100644 --- a/drivers/common/mlx5/mlx5_common_devx.c +++ b/drivers/common/mlx5/mlx5_common_devx.c @@ -12,7 +12,7 @@ #include "mlx5_prm.h" #include "mlx5_devx_cmds.h" -#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" #include "mlx5_malloc.h" #include "mlx5_common.h" #include "mlx5_common_devx.h" diff --git a/drivers/common/mlx5/mlx5_common_log.h b/drivers/common/mlx5/mlx5_common_log.h new file mode 100644 index 0000000000..26b13fedaf --- /dev/null +++ b/drivers/common/mlx5/mlx5_common_log.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2019 Mellanox Technologies, Ltd + */ + +#ifndef RTE_PMD_MLX5_COMMON_LOG_H_ +#define RTE_PMD_MLX5_COMMON_LOG_H_ + +#include "mlx5_common.h" + + +extern int mlx5_common_logtype; + +#define MLX5_COMMON_LOG_PREFIX "mlx5_common" +/* Generic printf()-like logging macro with automatic line feed. */ +#define DRV_LOG(level, ...) \ + PMD_DRV_LOG_(level, mlx5_common_logtype, MLX5_COMMON_LOG_PREFIX, \ + __VA_ARGS__ PMD_DRV_LOG_STRIP PMD_DRV_LOG_OPAREN, \ + PMD_DRV_LOG_CPAREN) + +#endif /* RTE_PMD_MLX5_COMMON_LOG_H_ */ + diff --git a/drivers/common/mlx5/mlx5_common_mp.c b/drivers/common/mlx5/mlx5_common_mp.c index 40e3956e45..673a7c31de 100644 --- a/drivers/common/mlx5/mlx5_common_mp.c +++ b/drivers/common/mlx5/mlx5_common_mp.c @@ -10,7 +10,7 @@ #include #include "mlx5_common_mp.h" -#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" #include "mlx5_malloc.h" /** diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index e1ed0caf3a..afb5b3d0a7 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -11,7 +11,7 @@ #include "mlx5_glue.h" #include "mlx5_common_mp.h" #include "mlx5_common_mr.h" -#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" #include "mlx5_malloc.h" struct mr_find_contig_memsegs_data { diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index 5a73ffa60a..3f16cd21cf 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -4,7 +4,9 @@ #include #include -#include "mlx5_common_utils.h" +#include + +#include "mlx5_common_log.h" #include "mlx5_common_pci.h" struct mlx5_pci_device { diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c new file mode 100644 index 0000000000..ad2011e858 --- /dev/null +++ b/drivers/common/mlx5/mlx5_common_utils.c @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2019 Mellanox Technologies, Ltd + */ + +#include +#include +#include + +#include + +#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" + +/********************* Hash List **********************/ + +static struct mlx5_hlist_entry * +mlx5_hlist_default_create_cb(struct mlx5_hlist *h, uint64_t key __rte_unused, + void *ctx __rte_unused) +{ + return mlx5_malloc(MLX5_MEM_ZERO, h->entry_sz, 0, SOCKET_ID_ANY); +} + +static void +mlx5_hlist_default_remove_cb(struct mlx5_hlist *h __rte_unused, + struct mlx5_hlist_entry *entry) +{ + mlx5_free(entry); +} + +struct mlx5_hlist * +mlx5_hlist_create(const char *name, uint32_t size, uint32_t entry_size, + uint32_t flags, mlx5_hlist_create_cb cb_create, + mlx5_hlist_match_cb cb_match, mlx5_hlist_remove_cb cb_remove) +{ + struct mlx5_hlist *h; + uint32_t act_size; + uint32_t alloc_size; + uint32_t i; + + if (!size || !cb_match || (!cb_create ^ !cb_remove)) + return NULL; + /* Align to the next power of 2, 32bits integer is enough now. */ + if (!rte_is_power_of_2(size)) { + act_size = rte_align32pow2(size); + DRV_LOG(DEBUG, "Size 0x%" PRIX32 " is not power of 2, " + "will be aligned to 0x%" PRIX32 ".", size, act_size); + } else { + act_size = size; + } + alloc_size = sizeof(struct mlx5_hlist) + + sizeof(struct mlx5_hlist_bucket) * act_size; + /* Using zmalloc, then no need to initialize the heads. */ + h = mlx5_malloc(MLX5_MEM_ZERO, alloc_size, RTE_CACHE_LINE_SIZE, + SOCKET_ID_ANY); + if (!h) { + DRV_LOG(ERR, "No memory for hash list %s creation", + name ? name : "None"); + return NULL; + } + if (name) + snprintf(h->name, MLX5_HLIST_NAMESIZE, "%s", name); + h->table_sz = act_size; + h->mask = act_size - 1; + h->entry_sz = entry_size; + h->direct_key = !!(flags & MLX5_HLIST_DIRECT_KEY); + h->write_most = !!(flags & MLX5_HLIST_WRITE_MOST); + h->cb_create = cb_create ? cb_create : mlx5_hlist_default_create_cb; + h->cb_match = cb_match; + h->cb_remove = cb_remove ? cb_remove : mlx5_hlist_default_remove_cb; + for (i = 0; i < act_size; i++) + rte_rwlock_init(&h->buckets[i].lock); + DRV_LOG(DEBUG, "Hash list with %s size 0x%" PRIX32 " is created.", + h->name, act_size); + return h; +} + +static struct mlx5_hlist_entry * +__hlist_lookup(struct mlx5_hlist *h, uint64_t key, uint32_t idx, + void *ctx, bool reuse) +{ + struct mlx5_hlist_head *first; + struct mlx5_hlist_entry *node; + + MLX5_ASSERT(h); + first = &h->buckets[idx].head; + LIST_FOREACH(node, first, next) { + if (!h->cb_match(h, node, key, ctx)) { + if (reuse) { + __atomic_add_fetch(&node->ref_cnt, 1, + __ATOMIC_RELAXED); + DRV_LOG(DEBUG, "Hash list %s entry %p " + "reuse: %u.", + h->name, (void *)node, node->ref_cnt); + } + break; + } + } + return node; +} + +static struct mlx5_hlist_entry * +hlist_lookup(struct mlx5_hlist *h, uint64_t key, uint32_t idx, + void *ctx, bool reuse) +{ + struct mlx5_hlist_entry *node; + + MLX5_ASSERT(h); + rte_rwlock_read_lock(&h->buckets[idx].lock); + node = __hlist_lookup(h, key, idx, ctx, reuse); + rte_rwlock_read_unlock(&h->buckets[idx].lock); + return node; +} + +struct mlx5_hlist_entry * +mlx5_hlist_lookup(struct mlx5_hlist *h, uint64_t key, void *ctx) +{ + uint32_t idx; + + if (h->direct_key) + idx = (uint32_t)(key & h->mask); + else + idx = rte_hash_crc_8byte(key, 0) & h->mask; + return hlist_lookup(h, key, idx, ctx, false); +} + +struct mlx5_hlist_entry* +mlx5_hlist_register(struct mlx5_hlist *h, uint64_t key, void *ctx) +{ + uint32_t idx; + struct mlx5_hlist_head *first; + struct mlx5_hlist_bucket *b; + struct mlx5_hlist_entry *entry; + uint32_t prev_gen_cnt = 0; + + if (h->direct_key) + idx = (uint32_t)(key & h->mask); + else + idx = rte_hash_crc_8byte(key, 0) & h->mask; + MLX5_ASSERT(h); + b = &h->buckets[idx]; + /* Use write lock directly for write-most list. */ + if (!h->write_most) { + prev_gen_cnt = __atomic_load_n(&b->gen_cnt, __ATOMIC_ACQUIRE); + entry = hlist_lookup(h, key, idx, ctx, true); + if (entry) + return entry; + } + rte_rwlock_write_lock(&b->lock); + /* Check if the list changed by other threads. */ + if (h->write_most || + prev_gen_cnt != __atomic_load_n(&b->gen_cnt, __ATOMIC_ACQUIRE)) { + entry = __hlist_lookup(h, key, idx, ctx, true); + if (entry) + goto done; + } + first = &b->head; + entry = h->cb_create(h, key, ctx); + if (!entry) { + rte_errno = ENOMEM; + DRV_LOG(DEBUG, "Can't allocate hash list %s entry.", h->name); + goto done; + } + entry->idx = idx; + entry->ref_cnt = 1; + LIST_INSERT_HEAD(first, entry, next); + __atomic_add_fetch(&b->gen_cnt, 1, __ATOMIC_ACQ_REL); + DRV_LOG(DEBUG, "Hash list %s entry %p new: %u.", + h->name, (void *)entry, entry->ref_cnt); +done: + rte_rwlock_write_unlock(&b->lock); + return entry; +} + +int +mlx5_hlist_unregister(struct mlx5_hlist *h, struct mlx5_hlist_entry *entry) +{ + uint32_t idx = entry->idx; + + rte_rwlock_write_lock(&h->buckets[idx].lock); + MLX5_ASSERT(entry && entry->ref_cnt && entry->next.le_prev); + DRV_LOG(DEBUG, "Hash list %s entry %p deref: %u.", + h->name, (void *)entry, entry->ref_cnt); + if (--entry->ref_cnt) { + rte_rwlock_write_unlock(&h->buckets[idx].lock); + return 1; + } + LIST_REMOVE(entry, next); + /* Set to NULL to get rid of removing action for more than once. */ + entry->next.le_prev = NULL; + h->cb_remove(h, entry); + rte_rwlock_write_unlock(&h->buckets[idx].lock); + DRV_LOG(DEBUG, "Hash list %s entry %p removed.", + h->name, (void *)entry); + return 0; +} + +void +mlx5_hlist_destroy(struct mlx5_hlist *h) +{ + uint32_t idx; + struct mlx5_hlist_entry *entry; + + MLX5_ASSERT(h); + for (idx = 0; idx < h->table_sz; ++idx) { + /* No LIST_FOREACH_SAFE, using while instead. */ + while (!LIST_EMPTY(&h->buckets[idx].head)) { + entry = LIST_FIRST(&h->buckets[idx].head); + LIST_REMOVE(entry, next); + /* + * The owner of whole element which contains data entry + * is the user, so it's the user's duty to do the clean + * up and the free work because someone may not put the + * hlist entry at the beginning(suggested to locate at + * the beginning). Or else the default free function + * will be used. + */ + h->cb_remove(h, entry); + } + } + mlx5_free(h); +} diff --git a/drivers/common/mlx5/mlx5_common_utils.h b/drivers/common/mlx5/mlx5_common_utils.h index 6cba39c8cc..ed378ce9bd 100644 --- a/drivers/common/mlx5/mlx5_common_utils.h +++ b/drivers/common/mlx5/mlx5_common_utils.h @@ -7,14 +7,202 @@ #include "mlx5_common.h" +#define MLX5_HLIST_DIRECT_KEY 0x0001 /* Use the key directly as hash index. */ +#define MLX5_HLIST_WRITE_MOST 0x0002 /* List mostly used for append new. */ -extern int mlx5_common_logtype; +/** Maximum size of string for naming the hlist table. */ +#define MLX5_HLIST_NAMESIZE 32 -#define MLX5_COMMON_LOG_PREFIX "mlx5_common" -/* Generic printf()-like logging macro with automatic line feed. */ -#define DRV_LOG(level, ...) \ - PMD_DRV_LOG_(level, mlx5_common_logtype, MLX5_COMMON_LOG_PREFIX, \ - __VA_ARGS__ PMD_DRV_LOG_STRIP PMD_DRV_LOG_OPAREN, \ - PMD_DRV_LOG_CPAREN) +struct mlx5_hlist; + +/** + * Structure of the entry in the hash list, user should define its own struct + * that contains this in order to store the data. The 'key' is 64-bits right + * now and its user's responsibility to guarantee there is no collision. + */ +struct mlx5_hlist_entry { + LIST_ENTRY(mlx5_hlist_entry) next; /* entry pointers in the list. */ + uint32_t idx; /* Bucket index the entry belongs to. */ + uint32_t ref_cnt; /* Reference count. */ +}; + +/** Structure for hash head. */ +LIST_HEAD(mlx5_hlist_head, mlx5_hlist_entry); + +/** + * Type of callback function for entry removal. + * + * @param list + * The hash list. + * @param entry + * The entry in the list. + */ +typedef void (*mlx5_hlist_remove_cb)(struct mlx5_hlist *list, + struct mlx5_hlist_entry *entry); + +/** + * Type of function for user defined matching. + * + * @param list + * The hash list. + * @param entry + * The entry in the list. + * @param key + * The new entry key. + * @param ctx + * The pointer to new entry context. + * + * @return + * 0 if matching, non-zero number otherwise. + */ +typedef int (*mlx5_hlist_match_cb)(struct mlx5_hlist *list, + struct mlx5_hlist_entry *entry, + uint64_t key, void *ctx); + +/** + * Type of function for user defined hash list entry creation. + * + * @param list + * The hash list. + * @param key + * The key of the new entry. + * @param ctx + * The pointer to new entry context. + * + * @return + * Pointer to allocated entry on success, NULL otherwise. + */ +typedef struct mlx5_hlist_entry *(*mlx5_hlist_create_cb) + (struct mlx5_hlist *list, + uint64_t key, void *ctx); + +/* Hash list bucket head. */ +struct mlx5_hlist_bucket { + struct mlx5_hlist_head head; /* List head. */ + rte_rwlock_t lock; /* Bucket lock. */ + uint32_t gen_cnt; /* List modification will update generation count. */ +} __rte_cache_aligned; + +/** + * Hash list table structure + * + * Entry in hash list could be reused if entry already exists, reference + * count will increase and the existing entry returns. + * + * When destroy an entry from list, decrease reference count and only + * destroy when no further reference. + */ +struct mlx5_hlist { + char name[MLX5_HLIST_NAMESIZE]; /**< Name of the hash list. */ + /**< number of heads, need to be power of 2. */ + uint32_t table_sz; + uint32_t entry_sz; /**< Size of entry, used to allocate entry. */ + /**< mask to get the index of the list heads. */ + uint32_t mask; + bool direct_key; /* Use the new entry key directly as hash index. */ + bool write_most; /* List mostly used for append new or destroy. */ + void *ctx; + mlx5_hlist_create_cb cb_create; /**< entry create callback. */ + mlx5_hlist_match_cb cb_match; /**< entry match callback. */ + mlx5_hlist_remove_cb cb_remove; /**< entry remove callback. */ + struct mlx5_hlist_bucket buckets[] __rte_cache_aligned; + /**< list bucket arrays. */ +}; + +/** + * Create a hash list table, the user can specify the list heads array size + * of the table, now the size should be a power of 2 in order to get better + * distribution for the entries. Each entry is a part of the whole data element + * and the caller should be responsible for the data element's allocation and + * cleanup / free. Key of each entry will be calculated with CRC in order to + * generate a little fairer distribution. + * + * @param name + * Name of the hash list(optional). + * @param size + * Heads array size of the hash list. + * @param entry_size + * Entry size to allocate if cb_create not specified. + * @param flags + * The hash list attribute flags. + * @param cb_create + * Callback function for entry create. + * @param cb_match + * Callback function for entry match. + * @param cb_destroy + * Callback function for entry destroy. + * @return + * Pointer of the hash list table created, NULL on failure. + */ +__rte_internal +struct mlx5_hlist *mlx5_hlist_create(const char *name, uint32_t size, + uint32_t entry_size, uint32_t flags, + mlx5_hlist_create_cb cb_create, + mlx5_hlist_match_cb cb_match, + mlx5_hlist_remove_cb cb_destroy); + +/** + * Search an entry matching the key. + * + * Result returned might be destroyed by other thread, must use + * this function only in main thread. + * + * @param h + * Pointer to the hast list table. + * @param key + * Key for the searching entry. + * @param ctx + * Common context parameter used by entry callback function. + * + * @return + * Pointer of the hlist entry if found, NULL otherwise. + */ +__rte_internal +struct mlx5_hlist_entry *mlx5_hlist_lookup(struct mlx5_hlist *h, uint64_t key, + void *ctx); + +/** + * Insert an entry to the hash list table, the entry is only part of whole data + * element and a 64B key is used for matching. User should construct the key or + * give a calculated hash signature and guarantee there is no collision. + * + * @param h + * Pointer to the hast list table. + * @param entry + * Entry to be inserted into the hash list table. + * @param ctx + * Common context parameter used by callback function. + * + * @return + * registered entry on success, NULL otherwise + */ +__rte_internal +struct mlx5_hlist_entry *mlx5_hlist_register(struct mlx5_hlist *h, uint64_t key, + void *ctx); + +/** + * Remove an entry from the hash list table. User should guarantee the validity + * of the entry. + * + * @param h + * Pointer to the hast list table. (not used) + * @param entry + * Entry to be removed from the hash list table. + * @return + * 0 on entry removed, 1 on entry still referenced. + */ +__rte_internal +int mlx5_hlist_unregister(struct mlx5_hlist *h, struct mlx5_hlist_entry *entry); + +/** + * Destroy the hash list table, all the entries already inserted into the lists + * will be handled by the callback function provided by the user (including + * free if needed) before the table is freed. + * + * @param h + * Pointer to the hast list table. + */ +__rte_internal +void mlx5_hlist_destroy(struct mlx5_hlist *h); #endif /* RTE_PMD_MLX5_COMMON_UTILS_H_ */ diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 5e082ebb78..c0061741e8 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -9,7 +9,7 @@ #include "mlx5_prm.h" #include "mlx5_devx_cmds.h" -#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" #include "mlx5_malloc.h" diff --git a/drivers/common/mlx5/mlx5_malloc.c b/drivers/common/mlx5/mlx5_malloc.c index 9d30cedbaa..b19501e1bc 100644 --- a/drivers/common/mlx5/mlx5_malloc.c +++ b/drivers/common/mlx5/mlx5_malloc.c @@ -8,7 +8,7 @@ #include #include -#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" #include "mlx5_common_os.h" #include "mlx5_malloc.h" diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 89f0ee04cb..40b0d713ac 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -70,6 +70,12 @@ INTERNAL { mlx5_glue; + mlx5_hlist_create; + mlx5_hlist_lookup; + mlx5_hlist_register; + mlx5_hlist_unregister; + mlx5_hlist_destroy; + mlx5_malloc; mlx5_malloc_mem_select; diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c index cebf42d53c..78975d9d4d 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.c +++ b/drivers/common/mlx5/windows/mlx5_common_os.c @@ -11,7 +11,7 @@ #include #include "mlx5_devx_cmds.h" -#include "mlx5_common_utils.h" +#include "../mlx5_common_log.h" #include "mlx5_common.h" #include "mlx5_common_os.h" #include "mlx5_malloc.h" diff --git a/drivers/common/mlx5/windows/mlx5_glue.c b/drivers/common/mlx5/windows/mlx5_glue.c index aef6d3b5f4..535487a8d4 100644 --- a/drivers/common/mlx5/windows/mlx5_glue.c +++ b/drivers/common/mlx5/windows/mlx5_glue.c @@ -12,7 +12,7 @@ #include #include "mlx5_glue.h" -#include "mlx5_common_utils.h" +#include "../mlx5_common_log.h" #include "mlx5_win_ext.h" /* diff --git a/drivers/net/mlx5/mlx5_utils.c b/drivers/net/mlx5/mlx5_utils.c index a39b5edddc..18fe23e4fb 100644 --- a/drivers/net/mlx5/mlx5_utils.c +++ b/drivers/net/mlx5/mlx5_utils.c @@ -3,220 +3,11 @@ */ #include -#include #include #include "mlx5_utils.h" -/********************* Hash List **********************/ - -static struct mlx5_hlist_entry * -mlx5_hlist_default_create_cb(struct mlx5_hlist *h, uint64_t key __rte_unused, - void *ctx __rte_unused) -{ - return mlx5_malloc(MLX5_MEM_ZERO, h->entry_sz, 0, SOCKET_ID_ANY); -} - -static void -mlx5_hlist_default_remove_cb(struct mlx5_hlist *h __rte_unused, - struct mlx5_hlist_entry *entry) -{ - mlx5_free(entry); -} - -struct mlx5_hlist * -mlx5_hlist_create(const char *name, uint32_t size, uint32_t entry_size, - uint32_t flags, mlx5_hlist_create_cb cb_create, - mlx5_hlist_match_cb cb_match, mlx5_hlist_remove_cb cb_remove) -{ - struct mlx5_hlist *h; - uint32_t act_size; - uint32_t alloc_size; - uint32_t i; - - if (!size || !cb_match || (!cb_create ^ !cb_remove)) - return NULL; - /* Align to the next power of 2, 32bits integer is enough now. */ - if (!rte_is_power_of_2(size)) { - act_size = rte_align32pow2(size); - DRV_LOG(DEBUG, "Size 0x%" PRIX32 " is not power of 2, " - "will be aligned to 0x%" PRIX32 ".", size, act_size); - } else { - act_size = size; - } - alloc_size = sizeof(struct mlx5_hlist) + - sizeof(struct mlx5_hlist_bucket) * act_size; - /* Using zmalloc, then no need to initialize the heads. */ - h = mlx5_malloc(MLX5_MEM_ZERO, alloc_size, RTE_CACHE_LINE_SIZE, - SOCKET_ID_ANY); - if (!h) { - DRV_LOG(ERR, "No memory for hash list %s creation", - name ? name : "None"); - return NULL; - } - if (name) - snprintf(h->name, MLX5_HLIST_NAMESIZE, "%s", name); - h->table_sz = act_size; - h->mask = act_size - 1; - h->entry_sz = entry_size; - h->direct_key = !!(flags & MLX5_HLIST_DIRECT_KEY); - h->write_most = !!(flags & MLX5_HLIST_WRITE_MOST); - h->cb_create = cb_create ? cb_create : mlx5_hlist_default_create_cb; - h->cb_match = cb_match; - h->cb_remove = cb_remove ? cb_remove : mlx5_hlist_default_remove_cb; - for (i = 0; i < act_size; i++) - rte_rwlock_init(&h->buckets[i].lock); - DRV_LOG(DEBUG, "Hash list with %s size 0x%" PRIX32 " is created.", - h->name, act_size); - return h; -} - -static struct mlx5_hlist_entry * -__hlist_lookup(struct mlx5_hlist *h, uint64_t key, uint32_t idx, - void *ctx, bool reuse) -{ - struct mlx5_hlist_head *first; - struct mlx5_hlist_entry *node; - - MLX5_ASSERT(h); - first = &h->buckets[idx].head; - LIST_FOREACH(node, first, next) { - if (!h->cb_match(h, node, key, ctx)) { - if (reuse) { - __atomic_add_fetch(&node->ref_cnt, 1, - __ATOMIC_RELAXED); - DRV_LOG(DEBUG, "Hash list %s entry %p " - "reuse: %u.", - h->name, (void *)node, node->ref_cnt); - } - break; - } - } - return node; -} - -static struct mlx5_hlist_entry * -hlist_lookup(struct mlx5_hlist *h, uint64_t key, uint32_t idx, - void *ctx, bool reuse) -{ - struct mlx5_hlist_entry *node; - - MLX5_ASSERT(h); - rte_rwlock_read_lock(&h->buckets[idx].lock); - node = __hlist_lookup(h, key, idx, ctx, reuse); - rte_rwlock_read_unlock(&h->buckets[idx].lock); - return node; -} - -struct mlx5_hlist_entry * -mlx5_hlist_lookup(struct mlx5_hlist *h, uint64_t key, void *ctx) -{ - uint32_t idx; - - if (h->direct_key) - idx = (uint32_t)(key & h->mask); - else - idx = rte_hash_crc_8byte(key, 0) & h->mask; - return hlist_lookup(h, key, idx, ctx, false); -} - -struct mlx5_hlist_entry* -mlx5_hlist_register(struct mlx5_hlist *h, uint64_t key, void *ctx) -{ - uint32_t idx; - struct mlx5_hlist_head *first; - struct mlx5_hlist_bucket *b; - struct mlx5_hlist_entry *entry; - uint32_t prev_gen_cnt = 0; - - if (h->direct_key) - idx = (uint32_t)(key & h->mask); - else - idx = rte_hash_crc_8byte(key, 0) & h->mask; - MLX5_ASSERT(h); - b = &h->buckets[idx]; - /* Use write lock directly for write-most list. */ - if (!h->write_most) { - prev_gen_cnt = __atomic_load_n(&b->gen_cnt, __ATOMIC_ACQUIRE); - entry = hlist_lookup(h, key, idx, ctx, true); - if (entry) - return entry; - } - rte_rwlock_write_lock(&b->lock); - /* Check if the list changed by other threads. */ - if (h->write_most || - prev_gen_cnt != __atomic_load_n(&b->gen_cnt, __ATOMIC_ACQUIRE)) { - entry = __hlist_lookup(h, key, idx, ctx, true); - if (entry) - goto done; - } - first = &b->head; - entry = h->cb_create(h, key, ctx); - if (!entry) { - rte_errno = ENOMEM; - DRV_LOG(DEBUG, "Can't allocate hash list %s entry.", h->name); - goto done; - } - entry->idx = idx; - entry->ref_cnt = 1; - LIST_INSERT_HEAD(first, entry, next); - __atomic_add_fetch(&b->gen_cnt, 1, __ATOMIC_ACQ_REL); - DRV_LOG(DEBUG, "Hash list %s entry %p new: %u.", - h->name, (void *)entry, entry->ref_cnt); -done: - rte_rwlock_write_unlock(&b->lock); - return entry; -} - -int -mlx5_hlist_unregister(struct mlx5_hlist *h, struct mlx5_hlist_entry *entry) -{ - uint32_t idx = entry->idx; - - rte_rwlock_write_lock(&h->buckets[idx].lock); - MLX5_ASSERT(entry && entry->ref_cnt && entry->next.le_prev); - DRV_LOG(DEBUG, "Hash list %s entry %p deref: %u.", - h->name, (void *)entry, entry->ref_cnt); - if (--entry->ref_cnt) { - rte_rwlock_write_unlock(&h->buckets[idx].lock); - return 1; - } - LIST_REMOVE(entry, next); - /* Set to NULL to get rid of removing action for more than once. */ - entry->next.le_prev = NULL; - h->cb_remove(h, entry); - rte_rwlock_write_unlock(&h->buckets[idx].lock); - DRV_LOG(DEBUG, "Hash list %s entry %p removed.", - h->name, (void *)entry); - return 0; -} - -void -mlx5_hlist_destroy(struct mlx5_hlist *h) -{ - uint32_t idx; - struct mlx5_hlist_entry *entry; - - MLX5_ASSERT(h); - for (idx = 0; idx < h->table_sz; ++idx) { - /* No LIST_FOREACH_SAFE, using while instead. */ - while (!LIST_EMPTY(&h->buckets[idx].head)) { - entry = LIST_FIRST(&h->buckets[idx].head); - LIST_REMOVE(entry, next); - /* - * The owner of whole element which contains data entry - * is the user, so it's the user's duty to do the clean - * up and the free work because someone may not put the - * hlist entry at the beginning(suggested to locate at - * the beginning). Or else the default free function - * will be used. - */ - h->cb_remove(h, entry); - } - } - mlx5_free(h); -} /********************* Cache list ************************/ diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h index 289941cebc..b54517c6df 100644 --- a/drivers/net/mlx5/mlx5_utils.h +++ b/drivers/net/mlx5/mlx5_utils.h @@ -18,6 +18,7 @@ #include #include +#include #include "mlx5_defs.h" @@ -261,199 +262,6 @@ log2above(unsigned int v) return l + r; } -#define MLX5_HLIST_DIRECT_KEY 0x0001 /* Use the key directly as hash index. */ -#define MLX5_HLIST_WRITE_MOST 0x0002 /* List mostly used for append new. */ - -/** Maximum size of string for naming the hlist table. */ -#define MLX5_HLIST_NAMESIZE 32 - -struct mlx5_hlist; - -/** - * Structure of the entry in the hash list, user should define its own struct - * that contains this in order to store the data. The 'key' is 64-bits right - * now and its user's responsibility to guarantee there is no collision. - */ -struct mlx5_hlist_entry { - LIST_ENTRY(mlx5_hlist_entry) next; /* entry pointers in the list. */ - uint32_t idx; /* Bucket index the entry belongs to. */ - uint32_t ref_cnt; /* Reference count. */ -}; - -/** Structure for hash head. */ -LIST_HEAD(mlx5_hlist_head, mlx5_hlist_entry); - -/** - * Type of callback function for entry removal. - * - * @param list - * The hash list. - * @param entry - * The entry in the list. - */ -typedef void (*mlx5_hlist_remove_cb)(struct mlx5_hlist *list, - struct mlx5_hlist_entry *entry); - -/** - * Type of function for user defined matching. - * - * @param list - * The hash list. - * @param entry - * The entry in the list. - * @param key - * The new entry key. - * @param ctx - * The pointer to new entry context. - * - * @return - * 0 if matching, non-zero number otherwise. - */ -typedef int (*mlx5_hlist_match_cb)(struct mlx5_hlist *list, - struct mlx5_hlist_entry *entry, - uint64_t key, void *ctx); - -/** - * Type of function for user defined hash list entry creation. - * - * @param list - * The hash list. - * @param key - * The key of the new entry. - * @param ctx - * The pointer to new entry context. - * - * @return - * Pointer to allocated entry on success, NULL otherwise. - */ -typedef struct mlx5_hlist_entry *(*mlx5_hlist_create_cb) - (struct mlx5_hlist *list, - uint64_t key, void *ctx); - -/* Hash list bucket head. */ -struct mlx5_hlist_bucket { - struct mlx5_hlist_head head; /* List head. */ - rte_rwlock_t lock; /* Bucket lock. */ - uint32_t gen_cnt; /* List modification will update generation count. */ -} __rte_cache_aligned; - -/** - * Hash list table structure - * - * Entry in hash list could be reused if entry already exists, reference - * count will increase and the existing entry returns. - * - * When destroy an entry from list, decrease reference count and only - * destroy when no further reference. - */ -struct mlx5_hlist { - char name[MLX5_HLIST_NAMESIZE]; /**< Name of the hash list. */ - /**< number of heads, need to be power of 2. */ - uint32_t table_sz; - uint32_t entry_sz; /**< Size of entry, used to allocate entry. */ - /**< mask to get the index of the list heads. */ - uint32_t mask; - bool direct_key; /* Use the new entry key directly as hash index. */ - bool write_most; /* List mostly used for append new or destroy. */ - void *ctx; - mlx5_hlist_create_cb cb_create; /**< entry create callback. */ - mlx5_hlist_match_cb cb_match; /**< entry match callback. */ - mlx5_hlist_remove_cb cb_remove; /**< entry remove callback. */ - struct mlx5_hlist_bucket buckets[] __rte_cache_aligned; - /**< list bucket arrays. */ -}; - -/** - * Create a hash list table, the user can specify the list heads array size - * of the table, now the size should be a power of 2 in order to get better - * distribution for the entries. Each entry is a part of the whole data element - * and the caller should be responsible for the data element's allocation and - * cleanup / free. Key of each entry will be calculated with CRC in order to - * generate a little fairer distribution. - * - * @param name - * Name of the hash list(optional). - * @param size - * Heads array size of the hash list. - * @param entry_size - * Entry size to allocate if cb_create not specified. - * @param flags - * The hash list attribute flags. - * @param cb_create - * Callback function for entry create. - * @param cb_match - * Callback function for entry match. - * @param cb_destroy - * Callback function for entry destroy. - * @return - * Pointer of the hash list table created, NULL on failure. - */ -struct mlx5_hlist *mlx5_hlist_create(const char *name, uint32_t size, - uint32_t entry_size, uint32_t flags, - mlx5_hlist_create_cb cb_create, - mlx5_hlist_match_cb cb_match, - mlx5_hlist_remove_cb cb_destroy); - -/** - * Search an entry matching the key. - * - * Result returned might be destroyed by other thread, must use - * this function only in main thread. - * - * @param h - * Pointer to the hast list table. - * @param key - * Key for the searching entry. - * @param ctx - * Common context parameter used by entry callback function. - * - * @return - * Pointer of the hlist entry if found, NULL otherwise. - */ -struct mlx5_hlist_entry *mlx5_hlist_lookup(struct mlx5_hlist *h, uint64_t key, - void *ctx); - -/** - * Insert an entry to the hash list table, the entry is only part of whole data - * element and a 64B key is used for matching. User should construct the key or - * give a calculated hash signature and guarantee there is no collision. - * - * @param h - * Pointer to the hast list table. - * @param entry - * Entry to be inserted into the hash list table. - * @param ctx - * Common context parameter used by callback function. - * - * @return - * registered entry on success, NULL otherwise - */ -struct mlx5_hlist_entry *mlx5_hlist_register(struct mlx5_hlist *h, uint64_t key, - void *ctx); - -/** - * Remove an entry from the hash list table. User should guarantee the validity - * of the entry. - * - * @param h - * Pointer to the hast list table. (not used) - * @param entry - * Entry to be removed from the hash list table. - * @return - * 0 on entry removed, 1 on entry still referenced. - */ -int mlx5_hlist_unregister(struct mlx5_hlist *h, struct mlx5_hlist_entry *entry); - -/** - * Destroy the hash list table, all the entries already inserted into the lists - * will be handled by the callback function provided by the user (including - * free if needed) before the table is freed. - * - * @param h - * Pointer to the hast list table. - */ -void mlx5_hlist_destroy(struct mlx5_hlist *h); - /************************ cache list *****************************/ /** Maximum size of string for naming. */ From patchwork Tue May 4 17:54:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92755 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A4F4CA0A02; Tue, 4 May 2021 19:57:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 912DA410F6; Tue, 4 May 2021 19:57:02 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2055.outbound.protection.outlook.com [40.107.220.55]) by mails.dpdk.org (Postfix) with ESMTP id 4FFE040150 for ; Tue, 4 May 2021 19:57:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HcatgnzGiOJa2GX4kZX1H5VAQl5yzAcTFIMGN8LIEAVxDnQHZTys40L+L39a6WXtcwHgSAr9Db9XlHT7/sB7cc0SuYOfZ2ZdswHpKz+EzTw9bua24Eas6/TmT28ncfGLZ8rexaGSmh7yoG6zoq9nCyFtJnnA7Jn+g1Kaj6+lwSyVm/LXlMw1O9dIBAlJj2pmC2YGt1cMpZq4JIkHVeQuHw5ZTwgxLlph9+uQqK38S0o0IgZo6CPXOwdRA957zkqEcYFfYG2fy4VpkkjR1DMTSBpPdLq4GXEHYbuBuKOqtbCzX21DQs5Vn2I7K4jMCplfF4KLGYuehpmwdRzqxK3PBg== 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=jH0VLPcCbhMfVNOCvbqZ9lbZuXw5ibc7Ngebjcaghw8=; b=l+JwL8+/MySJGvuebJBH1Z4Uy9EbENhrtPDBrmCJ2AgyNn9UiEYluwEt/hVBTfLHQ+/YuvK1Y+FZn5Ce7F6cRjP0k0EsBsE6GqvbJNNIgRh7/tLweOJfsUeMVLDVeeryBHi584UHbgBMdluqkiR+ESWKnTba3ts+QeQH9Z185K6rEJuY2fNZoSjWKGpGBV7k0OPQicsJ3TivmKdwHSx6v9z4FOVa8Y1OmUMYkQsOZbsyNqwXzw0eujUuBK2jr8Y6snhGZHoWuadYtpQyG+CuhVVr9eXpOxgFlP0hL8mvktX8wAX+KXvsub+BJIKT32c0YKW8Lna2+FH5T5cTSAt9ww== 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=jH0VLPcCbhMfVNOCvbqZ9lbZuXw5ibc7Ngebjcaghw8=; b=VnzV2miwI3QKg262CJZoQXz1iZYVpdof24DZw9nKa65fn9r+SudMgKilUEcSE8ltPtE7IFvdkYXUhw+ScJ5U5y7aeqbt2q04DK5I2vKZxzBd/MT2J4w3rHOGtHgs4lJRLMnw2hSfWTzVetzXoJQqQU3+aUpawfnRGjJDdkHvCsKFkVug3zN7vjeIYOfDUsUL5eI2kcw2QeNJNINyGcufDbX4afLnPj0NFrsv4HIwrEPFv4KhJvLFhhKjyQrGdfA7Dnl+vypFHyfbBg8gfW6Zxsp26ABwmPTW0OW3ndruxzK/C58bbTAljDDykHbusCaSHMnVnBRM4JmlaUyoV9daGw== Received: from DS7PR03CA0258.namprd03.prod.outlook.com (2603:10b6:5:3b3::23) by MWHPR12MB1822.namprd12.prod.outlook.com (2603:10b6:300:114::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.43; Tue, 4 May 2021 17:56:59 +0000 Received: from DM6NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::ef) by DS7PR03CA0258.outlook.office365.com (2603:10b6:5:3b3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.28 via Frontend Transport; Tue, 4 May 2021 17:56:59 +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 DM6NAM11FT046.mail.protection.outlook.com (10.13.172.121) 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:56:59 +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:56:57 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Shiri Kuzin Date: Tue, 4 May 2021 20:54:56 +0300 Message-ID: <20210504175500.3385811-12-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 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: f1e6a9ac-7820-4903-4625-08d90f2603ad X-MS-TrafficTypeDiagnostic: MWHPR12MB1822: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:873; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d131zrVNGkuVFm+hx88q9SeRph+fM9Qyaukpk1q1kqkC4jkA+L8FjMtA1NYn/+hc2yQBAHcdzs7inZxnwWwl5nlwhamdx7DlmwpU/2Y9is+M2Lgwle0+pC7+nL4VYoAVcWi48uRfywhGyQ6ZAFHk+QfbkBr11yfaMyt/+GL+W3B1BT6fz2TS+3afi92sPaePa9SxDA/WKubGeCohvMDgwKGttqvkpnAseWmDvGZA8gA5WelTW6T87AWyEQSpyxwSyXx1QOy9vul6wAuQ6q5AlrWPtgHpe7iR02jKGuPjcXGftvv68nMe8PVenhEUzcRjklFdfCM6aPuBe7FESsApQPz5DnqtCp7rBrVILoPi/mTkDGhnN2YaPXkEUSqT34tjBF88LUaGCFkoQRyf1pHiOVcrPVGgGDIh/vRrMgLLoTzPtGaleVshoSTYYycBhQkNMGdTIx8I3GK3X4oF3bc5E7nlQ0m7pwmmUvp5W3axuKaAz15ics+hISPk8Lx83cHQSmIL3u7JXXRkoD5zevFvrsSKTxXo5kszG10ofRExBJ+iHuq5aMgWvs1gHa5Zn8m3gBoDLdV7fg5KcK2apiY7am2mFJN4WWo04V/IEZT318+HY0mTTztvER15bjuM1ie2ueV1S39eUvnwAO59O5SlGTydxhCkhSkmGk9jhf8FfQM= 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)(39850400004)(396003)(36840700001)(46966006)(54906003)(83380400001)(8936002)(7636003)(426003)(1076003)(36860700001)(5660300002)(478600001)(47076005)(356005)(8676002)(86362001)(55016002)(336012)(70206006)(82310400003)(6916009)(70586007)(36756003)(107886003)(6286002)(4326008)(26005)(2616005)(16526019)(36906005)(316002)(7696005)(186003)(2906002)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:59.3477 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1e6a9ac-7820-4903-4625-08d90f2603ad 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: DM6NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1822 Subject: [dpdk-dev] [PATCH v3 11/15] common/mlx5: share get ib device match function 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: Shiri Kuzin The get_ib_device_match function iterates over the list of ib devices returned by the get_device_list glue function and returns the ib device matching the provided address. Since this function is in use by several drivers, in this patch we share the function in common part. Signed-off-by: Shiri Kuzin Acked-by: Matan Azrad --- drivers/common/mlx5/linux/mlx5_common_os.c | 28 +++++++++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 5 ++++ drivers/common/mlx5/mlx5_common.h | 1 + drivers/common/mlx5/version.map | 1 + drivers/compress/mlx5/mlx5_compress.c | 30 +------------------- drivers/regex/mlx5/mlx5_regex.c | 30 ++------------------ drivers/vdpa/mlx5/mlx5_vdpa.c | 32 ++-------------------- 7 files changed, 40 insertions(+), 87 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index fba8245b8b..ea0b71e425 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -16,6 +16,7 @@ #include "mlx5_common.h" #include "mlx5_common_log.h" +#include "mlx5_common_os.h" #include "mlx5_glue.h" #ifdef MLX5_GLUE @@ -423,3 +424,30 @@ mlx5_glue_constructor(void) mlx5_glue = NULL; } +struct ibv_device * +mlx5_os_get_ibv_device(struct rte_pci_addr *addr) +{ + int n; + struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n); + struct ibv_device *ibv_match = NULL; + + if (ibv_list == NULL) { + rte_errno = ENOSYS; + return NULL; + } + while (n-- > 0) { + struct rte_pci_addr paddr; + + DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name); + if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &paddr) != 0) + continue; + if (rte_pci_addr_cmp(addr, &paddr) != 0) + continue; + ibv_match = ibv_list[n]; + break; + } + if (ibv_match == NULL) + rte_errno = ENOENT; + mlx5_glue->free_device_list(ibv_list); + return ibv_match; +} diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h index d1c7e3dce0..72d6bf828b 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.h +++ b/drivers/common/mlx5/linux/mlx5_common_os.h @@ -288,4 +288,9 @@ mlx5_os_free(void *addr) { free(addr); } + +__rte_internal +struct ibv_device * +mlx5_os_get_ibv_device(struct rte_pci_addr *addr); + #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */ diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index f3c6beb23b..1fbefe0fa6 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -18,6 +18,7 @@ #include "mlx5_prm.h" #include "mlx5_devx_cmds.h" +#include "mlx5_common_os.h" /* Reported driver name. */ #define MLX5_PCI_DRIVER_NAME "mlx5_pci" diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 40b0d713ac..5706c6bbef 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -126,6 +126,7 @@ INTERNAL { mlx5_os_alloc_pd; mlx5_os_dealloc_pd; mlx5_os_dereg_mr; + mlx5_os_get_ibv_device; # WINDOWS_NO_EXPORT mlx5_os_reg_mr; mlx5_os_umem_dereg; mlx5_os_umem_reg; diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index ec3c237512..0581dee505 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -647,34 +647,6 @@ mlx5_compress_dequeue_burst(void *queue_pair, struct rte_comp_op **ops, return i; } -static struct ibv_device * -mlx5_compress_get_ib_device_match(struct rte_pci_addr *addr) -{ - int n; - struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n); - struct ibv_device *ibv_match = NULL; - - if (ibv_list == NULL) { - rte_errno = ENOSYS; - return NULL; - } - while (n-- > 0) { - struct rte_pci_addr paddr; - - DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name); - if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &paddr) != 0) - continue; - if (rte_pci_addr_cmp(addr, &paddr) != 0) - continue; - ibv_match = ibv_list[n]; - break; - } - if (ibv_match == NULL) - rte_errno = ENOENT; - mlx5_glue->free_device_list(ibv_list); - return ibv_match; -} - static void mlx5_compress_hw_global_release(struct mlx5_compress_priv *priv) { @@ -774,7 +746,7 @@ mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv, rte_errno = ENOTSUP; return -rte_errno; } - ibv = mlx5_compress_get_ib_device_match(&pci_dev->addr); + ibv = mlx5_os_get_ibv_device(&pci_dev->addr); if (ibv == NULL) { DRV_LOG(ERR, "No matching IB device for PCI slot " PCI_PRI_FMT ".", pci_dev->addr.domain, diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c index 82c485e50c..dd96436d42 100644 --- a/drivers/regex/mlx5/mlx5_regex.c +++ b/drivers/regex/mlx5/mlx5_regex.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -52,33 +53,6 @@ mlx5_regex_close(struct rte_regexdev *dev __rte_unused) return 0; } -static struct ibv_device * -mlx5_regex_get_ib_device_match(struct rte_pci_addr *addr) -{ - int n; - struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n); - struct ibv_device *ibv_match = NULL; - - if (!ibv_list) { - rte_errno = ENOSYS; - return NULL; - } - while (n-- > 0) { - struct rte_pci_addr pci_addr; - - DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name); - if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &pci_addr)) - continue; - if (rte_pci_addr_cmp(addr, &pci_addr)) - continue; - ibv_match = ibv_list[n]; - break; - } - if (!ibv_match) - rte_errno = ENOENT; - mlx5_glue->free_device_list(ibv_list); - return ibv_match; -} static int mlx5_regex_engines_status(struct ibv_context *ctx, int num_engines) { @@ -121,7 +95,7 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, int ret; uint32_t val; - ibv = mlx5_regex_get_ib_device_match(&pci_dev->addr); + ibv = mlx5_os_get_ibv_device(&pci_dev->addr); if (!ibv) { DRV_LOG(ERR, "No matching IB device for PCI slot " PCI_PRI_FMT ".", pci_dev->addr.domain, diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 898e50f807..17753ae63f 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -472,34 +472,6 @@ static struct rte_vdpa_dev_ops mlx5_vdpa_ops = { .reset_stats = mlx5_vdpa_reset_stats, }; -static struct ibv_device * -mlx5_vdpa_get_ib_device_match(struct rte_pci_addr *addr) -{ - int n; - struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n); - struct ibv_device *ibv_match = NULL; - - if (!ibv_list) { - rte_errno = ENOSYS; - return NULL; - } - while (n-- > 0) { - struct rte_pci_addr pci_addr; - - DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name); - if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &pci_addr)) - continue; - if (rte_pci_addr_cmp(addr, &pci_addr)) - continue; - ibv_match = ibv_list[n]; - break; - } - if (!ibv_match) - rte_errno = ENOENT; - mlx5_glue->free_device_list(ibv_list); - return ibv_match; -} - /* Try to disable ROCE by Netlink\Devlink. */ static int mlx5_vdpa_nl_roce_disable(const char *addr) @@ -595,7 +567,7 @@ mlx5_vdpa_roce_disable(struct rte_pci_addr *addr, struct ibv_device **ibv) struct ibv_device *ibv_new; for (r = MLX5_VDPA_MAX_RETRIES; r; r--) { - ibv_new = mlx5_vdpa_get_ib_device_match(addr); + ibv_new = mlx5_os_get_ibv_device(addr); if (ibv_new) { *ibv = ibv_new; return 0; @@ -698,7 +670,7 @@ mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct mlx5_hca_attr attr; int ret; - ibv = mlx5_vdpa_get_ib_device_match(&pci_dev->addr); + ibv = mlx5_os_get_ibv_device(&pci_dev->addr); if (!ibv) { DRV_LOG(ERR, "No matching IB device for PCI slot " PCI_PRI_FMT ".", pci_dev->addr.domain, From patchwork Tue May 4 17:54:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92756 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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; From patchwork Tue May 4 17:54:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92757 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8362EA0A02; Tue, 4 May 2021 19:57:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 595394067E; Tue, 4 May 2021 19:57:17 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2067.outbound.protection.outlook.com [40.107.220.67]) by mails.dpdk.org (Postfix) with ESMTP id 5CF0B410FB for ; Tue, 4 May 2021 19:57:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HcOJDcsCFm7vk4eSZEBRPfxhRoS+9x7598PF78uFihF+GDThSL53Uk1wPvmKs2IGw3LcfyH+aZ61e7c3mVJBevx0TSrnyJr2rJdTWizu4bEvzR1zkeEQzu1M/v31sdcWAq53NyvKmdd1tvkEYT30hfuc2NAuDCNrLRmbokOYqOeVyUvoL1HLUrVy16Om3ughhO1tG6fJjJodIJ/WPxIaBxWgG12WONAINMnMLqaeV6ilmcMTM8ZV0LFA8tlHmyKGPN0aNf2NyHlEoMBiPacPoHbuXprxpt2KXKc0Pjt24QLzkrF4zXjAnn3qP3cHAUWJo/FitUp8KT/H/8cKSdU0UA== 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=5+yMpMZHcpWxvo55rWEB6SjMiw3bv9AggldrRGEhyY8=; b=KWEQVMaSofDvp3MnXzjsO+5b7082omZbQ46jOf5WhUn/sE561emAjl45nwqWfxkCzYdzD8nuF44I9xuEwrrHjmrZgUYrGRzSdlv+y5JeCAWFrFq+bqxJ9SX18n5+vafNExrYxWSgvrQ6dMPvNGrJh+VxQtB/ogvweTLLneRqymS09F73S1lJ+PtgozOlZ05DMhgqe1852ieeB1CfJTQ9LIOgwzbKuJ1IrxIm1wWksz3qC65+EsNYvHcX7nddbkqUXJzAESIi3OFzxBBebJfUMHU4QH9HqaxrbAg17rBBE69iYIOhEf2EsJbCrdF+k3niaW8GUZyu4/9xTKwVh1uAFA== 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=5+yMpMZHcpWxvo55rWEB6SjMiw3bv9AggldrRGEhyY8=; b=RE7uY6mpS1b7wzjwM9HWIzJUPlqy9tF2Cp+2hqDZCc9SevdS7yZ401TPFfNPg+Uqh/0NN+aimhsYkAPE1+iMrqQYVaDxy+jnd4wgfUSs3JcDJlIy7VjMQ9UiK1cEKHo7SDAiu5dmWDh5SurYNv6HVm8fxaCBqlHM69itSw9iXN071Rz44lSiYATD0Z360mpifmA15LYFeirquJTS4F/+P6nOFNzL0Ept0hq6I90+ANhlMVuK+ETmxh6e+83Zys3aRPkrB+usSVJfGplqsxrEo8dj77QhHRVLZ4ld3XpizOSSY4yUbT50HY3Ax19HlRTW29Kuk0IVNZH+4PtUVzg/jQ== Received: from DM6PR02CA0142.namprd02.prod.outlook.com (2603:10b6:5:332::9) by DM6PR12MB4532.namprd12.prod.outlook.com (2603:10b6:5:2af::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.41; Tue, 4 May 2021 17:57:14 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:5:332:cafe::47) by DM6PR02CA0142.outlook.office365.com (2603:10b6:5:332::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 4 May 2021 17:57:14 +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 DM6NAM11FT047.mail.protection.outlook.com (10.13.172.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.32 via Frontend Transport; Tue, 4 May 2021 17:57:14 +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:12 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:58 +0300 Message-ID: <20210504175500.3385811-14-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 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: 4143b41b-2771-441a-e10a-08d90f260c7c X-MS-TrafficTypeDiagnostic: DM6PR12MB4532: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +osLzw19U9NMouiVialnsfSoQ9MvLrStw+EEmionvrlsfK1uXf+WaUxP5Ou78Nc2v3Rh+ntlTz+LwimzCJFlX0BuWsoEAykYzAwFp/MkqPamZ/3KxI9TovV0wS2UPUT38RoNjwLsi8KzMwCCTc12x8qOENloxLmuDpWhYHm7p9lFTwUa3gf21lx9hRzdchVe37fpkyk6Un2Y9Rhuig/2BfC5hatMb8XyyUpnnV/No8oa7TY1YBQRG5f46e1X9b+bxQJBBA/RFKuh2uS+iD0SZ0LEH3pW8yp3YVhhRiqFhrhBmi1ETCOHw9KQRFy2M9R2QKmeK0BonS6xBbtRZYLQomez31tsrQ4ky+9ZOlxhKRgjem0AqwfaKIXVoNWuG/I1lmi5Ny/L/7xvViBSCPtTYjPXe+FeiexM+nsq6QZkVpYCUHMrmVaqDa1fV2LCvhgnHKwqqXCL99d6pbpnHX1d+BeUL94L+Dv5QhRMDueRZIuZE8PURDqGfQ24Ueo2qTUARFEC3XwVI/e/AIw1JSDwA/n5LHTzonUeRcgVLfLLeVEbIyIzKylYmsKgZWZ2v487iee4nC9sOzOen7HQgMvCeMlJK6TErIOnu0CpkDi/87Vr9J1FVxjGEdXpZ0ROrPyqH20YnSMtK9QWsAMfjFAzI94UMcUY+z2bHJfsoJFFqrc= 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)(346002)(396003)(136003)(376002)(46966006)(36840700001)(107886003)(7696005)(82740400003)(70206006)(6916009)(70586007)(36756003)(2906002)(82310400003)(4326008)(16526019)(6286002)(8936002)(26005)(1076003)(6666004)(186003)(336012)(426003)(36860700001)(7636003)(8676002)(2616005)(54906003)(316002)(47076005)(356005)(55016002)(5660300002)(36906005)(478600001)(83380400001)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:57:14.1141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4143b41b-2771-441a-e10a-08d90f260c7c 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: DM6NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4532 Subject: [dpdk-dev] [PATCH v3 13/15] common/mlx5: add crypto register structs and defs 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 Encryption key management requires use of several related registers. This patch adds the relevant structs and values, according to PRM definitions. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_prm.h | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 432c8fdb63..c2cd2d9f70 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -3307,6 +3307,10 @@ enum { enum { MLX5_REGISTER_ID_MTUTC = 0x9055, + MLX5_CRYPTO_OPERATIONAL_REGISTER_ID = 0xC002, + MLX5_CRYPTO_COMMISSIONING_REGISTER_ID = 0xC003, + MLX5_IMPORT_KEK_HANDLE_REGISTER_ID = 0xC004, + MLX5_CREDENTIAL_HANDLE_REGISTER_ID = 0xC005, }; struct mlx5_ifc_register_mtutc_bits { @@ -3324,6 +3328,43 @@ struct mlx5_ifc_register_mtutc_bits { #define MLX5_MTUTC_TIMESTAMP_MODE_INTERNAL_TIMER 0 #define MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME 1 +struct mlx5_ifc_crypto_operational_register_bits { + u8 wrapped_crypto_operational[0x1]; + u8 reserved_at_1[0x1b]; + u8 kek_size[0x4]; + u8 reserved_at_20[0x20]; + u8 credential[0x140]; + u8 kek[0x100]; + u8 reserved_at_280[0x180]; +}; + +struct mlx5_ifc_crypto_commissioning_register_bits { + u8 token[0x1]; /* TODO: add size after PRM update */ +}; + +struct mlx5_ifc_import_kek_handle_register_bits { + struct mlx5_ifc_crypto_login_bits crypto_login_object; + struct mlx5_ifc_import_kek_bits import_kek_object; + u8 reserved_at_200[0x4]; + u8 write_operation[0x4]; + u8 import_kek_id[0x18]; + u8 reserved_at_220[0xe0]; +}; + +struct mlx5_ifc_credential_handle_register_bits { + struct mlx5_ifc_crypto_login_bits crypto_login_object; + struct mlx5_ifc_credential_bits credential_object; + u8 reserved_at_200[0x4]; + u8 write_operation[0x4]; + u8 credential_id[0x18]; + u8 reserved_at_220[0xe0]; +}; + +enum { + MLX5_REGISTER_ADD_OPERATION = 0x1, + MLX5_REGISTER_DELETE_OPERATION = 0x2, +}; + struct mlx5_ifc_parse_graph_arc_bits { u8 start_inner_tunnel[0x1]; u8 reserved_at_1[0x7]; From patchwork Tue May 4 17:54:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92758 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5EE11A0A02; Tue, 4 May 2021 19:57:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 86DB940697; Tue, 4 May 2021 19:57:25 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2074.outbound.protection.outlook.com [40.107.243.74]) by mails.dpdk.org (Postfix) with ESMTP id 0AF414014E for ; Tue, 4 May 2021 19:57:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oe/aqSYB1wV3iPTSRZcjMkZrIRGS0pl6uoQWxZqx7IR14JsHhzYk+HAv3947Sp5IBwXRgpKtMc4987sTBRRNliCuqh3EYxCtGQjzrlvHDW0RkOCViVGOai5xPAD55bgc1yqemaNAEa6UGAXlRiUUqkHe1ZThyU+fJKumRbfXoOgfeTfl6jBi1oz3Mft0tBpgN9H5PuJZpRXt3QQR4f1p8QZ0ckQEZZndlIQVibbRRHvX3mNtxzp4Spj1sGu/ZBx3tKRxtsfBbUG1dzpRWuTncfVQQw46s5l8LHgQxNofBBMnYrSjyM5y667vMGm9b0MR7nT+up5rCt/E6GT5zQavPQ== 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=e09v/aLk9NQKN4GBKVF/GxI7q4CpuWJ33sYrLCdYxUI=; b=eIv0wAHLdZMyGrCbyLxRa/kgb21XNLKZ7/O4G/XzobVi9cElFozV5ki484szw3ZLUo12YyMD6QXh7Uh00qZUJDQZwFpEGbTrTKaIp5KXr1sJqPlDQt57Krd0KfMYlMr5lde6tTW6JD29YQztQDJUpoGOz3bpDhHe9m9wd/EvLBTtn1llQa0MeyX+Ia+IhDxVl84/zAuXj0bq4bqnMJxIr0OlNqd8n3SQRWU+NI3OM5bQeQYHZqtC9I+qHKI4GkqqrdpD+ofr8q0w9XvFn92qsZmWPqU/pDq6eMhVcrkJ3jt6FkpUyy5qvJ9u51/cMYHhoTkw+H8LbFut7CM94WxPRg== 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=e09v/aLk9NQKN4GBKVF/GxI7q4CpuWJ33sYrLCdYxUI=; b=SQYa2edkcGsOSj+k9G51pbJCpAprp8OkrCmVQjp8OfZzEQSXtHQTqhpiNM0N2m4GtVBRrg0tFOjOPQADtvRdTjj92456u/YZVN93okws92euf8pc6kaxR3xPlPSt9dQF61mq+6NCB32Qm7so5xl+k0s9TziIFZOqLYUPHLYCGIJ1yv4kjCiPV4R8O+vdIHscxbKvqkYONprLjKoNBZZmraOzmOum6t1x9OtH4Tqnfnh/0COP1IGhmfB62vZBibsG3ZnoTVw3GEU+aDUV+iBobb2JH7zFG0cApAGq1sfQFahGzJcO9Lre2WbSfNSTyoq9VYDC9YUtab2+EDcbPXiZYA== Received: from DM5PR15CA0070.namprd15.prod.outlook.com (2603:10b6:3:ae::32) by CH2PR12MB4231.namprd12.prod.outlook.com (2603:10b6:610:7d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Tue, 4 May 2021 17:57:23 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ae:cafe::aa) by DM5PR15CA0070.outlook.office365.com (2603:10b6:3:ae::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 4 May 2021 17:57:23 +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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) 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:23 +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:21 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:59 +0300 Message-ID: <20210504175500.3385811-15-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 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: e87e45bf-158a-4653-8c4d-08d90f261228 X-MS-TrafficTypeDiagnostic: CH2PR12MB4231: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VoSLM1ugWY0yk3hPpJ9XYoUS9s8fOcVjUCPeDiWVmO7RDCFs8+VX2aaSEi8eszXh9ijzO0lJ9rql6pZdgrADJKiB+fXucUhEG1fSXiZ62KH8Y9MrrwlNC0PB4XU1sHpWAaKFpnKhoB5O/T04tLBjvESMg+AWmth+xFpZmros6VCEnBenGq62uIuTiRgVUs646w6rX6UqK8LY52qVgybSBi0CMuV45NhqO0LHfTtP0tGP7Wrb5CjOsrSgvusFMhBYPS5Qv9ojw8McWzOXuiprqXtiS7fBQ6Kt7QThzx2uqhaLjkfHHAqsouyscscJg61k7/Z9EFbkzrKCaQl2dRDjcOPJstFk3HnaItt2sIw53Gqd+d1O3EB7OYWEC9TJWAJUzr3psc0y/lSC9eLleyHW3OoPck+HhyEN+Smve7sdkAGm242qh7GbRwfvTyNp9UKOIUFXm3V27nItwEimEaB7S1Ww0nqIwLL7cWG/fVyj9RSWF+ySfnK7h0Plxo9qAkB1hNaVP9iujstgR8oXsfJgGZ6DBdcznuymv8xc/3J9WQej9AuTiTvzLYL2R9QgAfyR2YwVEFDqAxxq4ze6jqREWm4O53N7a5GDOzPbqNr/mDzCmA/sM2Vma+X/IhDAPaOe4RYEpobw9ToBdXZnF920KrJFsY/nwLk0lYSpk9P4fus= 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)(136003)(39860400002)(376002)(346002)(36840700001)(46966006)(8676002)(2616005)(8936002)(82310400003)(186003)(6916009)(2906002)(7636003)(82740400003)(4326008)(83380400001)(356005)(107886003)(54906003)(1076003)(70206006)(36756003)(70586007)(426003)(336012)(7696005)(5660300002)(86362001)(26005)(36906005)(16526019)(55016002)(6666004)(36860700001)(478600001)(316002)(47076005)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:57:23.6457 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e87e45bf-158a-4653-8c4d-08d90f261228 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4231 Subject: [dpdk-dev] [PATCH v3 14/15] common/mlx5: support register write access 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 This patch adds support of write operation to NIC registers. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 67 +++++++++++++++++++++++++++- drivers/common/mlx5/mlx5_devx_cmds.h | 4 ++ drivers/common/mlx5/version.map | 1 + 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index c0a0853c3a..0b421933ce 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -12,7 +12,6 @@ #include "mlx5_common_log.h" #include "mlx5_malloc.h" - /** * Perform read access to the registers. Reads data from register * and writes ones to the specified buffer. @@ -61,7 +60,7 @@ mlx5_devx_cmd_register_read(void *ctx, uint16_t reg_id, uint32_t arg, if (status) { int syndrome = MLX5_GET(access_register_out, out, syndrome); - DRV_LOG(DEBUG, "Failed to access NIC register 0x%X, " + DRV_LOG(DEBUG, "Failed to read access NIC register 0x%X, " "status %x, syndrome = %x", reg_id, status, syndrome); return -1; @@ -74,6 +73,70 @@ mlx5_devx_cmd_register_read(void *ctx, uint16_t reg_id, uint32_t arg, return rc; } +/** + * Perform write access to the registers. + * + * @param[in] ctx + * Context returned from mlx5 open_device() glue function. + * @param[in] reg_id + * Register identifier according to the PRM. + * @param[in] arg + * Register access auxiliary parameter according to the PRM. + * @param[out] data + * Pointer to the buffer containing data to write. + * @param[in] dw_cnt + * Buffer size in double words (32bit units). + * + * @return + * 0 on success, a negative value otherwise. + */ +int +mlx5_devx_cmd_register_write(void *ctx, uint16_t reg_id, uint32_t arg, + uint32_t *data, uint32_t dw_cnt) +{ + uint32_t in[MLX5_ST_SZ_DW(access_register_in) + + MLX5_ACCESS_REGISTER_DATA_DWORD_MAX] = {0}; + uint32_t out[MLX5_ST_SZ_DW(access_register_out)] = {0}; + int status, rc; + void *ptr; + + MLX5_ASSERT(data && dw_cnt); + MLX5_ASSERT(dw_cnt <= MLX5_ACCESS_REGISTER_DATA_DWORD_MAX); + if (dw_cnt > MLX5_ACCESS_REGISTER_DATA_DWORD_MAX) { + DRV_LOG(ERR, "Data to write exceeds max size"); + return -1; + } + MLX5_SET(access_register_in, in, opcode, + MLX5_CMD_OP_ACCESS_REGISTER_USER); + MLX5_SET(access_register_in, in, op_mod, + MLX5_ACCESS_REGISTER_IN_OP_MOD_WRITE); + MLX5_SET(access_register_in, in, register_id, reg_id); + MLX5_SET(access_register_in, in, argument, arg); + ptr = MLX5_ADDR_OF(access_register_in, in, register_data); + memcpy(ptr, data, dw_cnt * sizeof(uint32_t)); + rc = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out, sizeof(out)); + + rc = mlx5_glue->devx_general_cmd(ctx, in, + MLX5_ST_SZ_BYTES(access_register_in) + + dw_cnt * sizeof(uint32_t), + out, sizeof(out)); + if (rc) + goto error; + status = MLX5_GET(access_register_out, out, status); + if (status) { + int syndrome = MLX5_GET(access_register_out, out, syndrome); + + DRV_LOG(DEBUG, "Failed to write access NIC register 0x%X, " + "status %x, syndrome = %x", + reg_id, status, syndrome); + return -1; + } + return 0; +error: + rc = (rc > 0) ? -rc : rc; + return rc; +} + /** * Allocate flow counters via devx interface. * diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index 811e7a1462..ce570ad28a 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.h +++ b/drivers/common/mlx5/mlx5_devx_cmds.h @@ -566,6 +566,10 @@ __rte_internal int mlx5_devx_cmd_register_read(void *ctx, uint16_t reg_id, uint32_t arg, uint32_t *data, uint32_t dw_cnt); +__rte_internal +int mlx5_devx_cmd_register_write(void *ctx, uint16_t reg_id, + uint32_t arg, uint32_t *data, uint32_t dw_cnt); + __rte_internal struct mlx5_devx_obj * mlx5_devx_cmd_create_geneve_tlv_option(void *ctx, diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 04b2179b2c..c630696213 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -53,6 +53,7 @@ INTERNAL { mlx5_devx_cmd_queue_counter_alloc; # WINDOWS_NO_EXPORT mlx5_devx_cmd_queue_counter_query; # WINDOWS_NO_EXPORT mlx5_devx_cmd_register_read; + mlx5_devx_cmd_register_write; mlx5_devx_cmd_wq_query; # WINDOWS_NO_EXPORT mlx5_devx_cq_create; From patchwork Tue May 4 17:55:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 92759 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EE0DAA0A02; Tue, 4 May 2021 19:57:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF44041101; Tue, 4 May 2021 19:57:30 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2089.outbound.protection.outlook.com [40.107.243.89]) by mails.dpdk.org (Postfix) with ESMTP id 2F8CD410FF for ; Tue, 4 May 2021 19:57:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZPrsKDRLL9BBqbHPJgynJkE8KY9t+jLCQn0uGD6lFV+d5KTkv9T8/x1DPJku38dCzTOUlCtJuUS9HHf5jPdX+yW/hebThxSWBDr0UyHjQJhYGBQcSOdDidJ0omz+3gAl6dhHoMZYbWuAcFfOK64LEfwvxntuQxxIoOp+pt3Jqm6yg8OIanKEKbF8kQ71/M50KOisIUm2cKcn1/KiW0IgbxTpWpTEjs7o3oDQ8BlvKQyX1KnkmBw11f1IyONBl/DDfYNI8y+1aAOrfdcr9Q0IHUD6Mq8V55s+bUu9GlxJXJkv5EZii8IOOCxXbMvjh9+Io6txnpZYDWwrMfMzf4Wy5g== 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=rp6vOSaAuzukWT2OIVUyLyZCxGX1gmWEL71A566xJz4=; b=LLDxtUbCrs66xUIaoW86xmQ3L4RLw4N6zHjcpYm/kwifkgsgguC5HhVEJNooaWJhLkyk6e9uS3EqzBIT+bavJ3en1mpiIAmQUmLFCjgADldagWlHpitu/25qHkv1Q/WET9HnXol6+YU0bnDZLuoGumeZj/aiMK0e59jVd6iqgKXueVmSV0cC5IfnnoACNoHb+gpVBbB/UzaL4M/ZjHQPI8uAmcz9opgns69LJLZi4QIAtsXJptnhTqUNFPtbACDgBf7tXv+fiKMjidZNR1pnc0LKJqte1DK0kRfqkN5OxPimxQlKGn6q9uvJpYdj2bURBcVHUYCNzJDuts31veGY5A== 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=rp6vOSaAuzukWT2OIVUyLyZCxGX1gmWEL71A566xJz4=; b=I3BWBkmB6IgbVemj+nWE08LhMJrWDDA60ueZXkSv3QHnyqYtcZcS1mgZYG8G8aigyQdn7iTYvGyTreVNIFwdBhe3r5ewTmkr974JYJ2AEbO/qw3gQIhb0Ms46YpBfOCeZKzO6JFTSDNwHWXLWMa6Vh24czKcZHKnufzeSt/bV8Hoo/HWRHA6hHbDFyCR1/f858VaOTgBoIhNBoef0XZjmE6b6twMekLhYeqUgP77yxmF6IZoZQgbp6M/SI6CUDacQU8u7GfDO5/sOFI41saVDoOJIeDoq5E46zezOiWsHtqQB+cL/DdjxSO9o6ZZa++lbM+BWkCTa7A+uIs3+0Mecg== Received: from DM5PR18CA0068.namprd18.prod.outlook.com (2603:10b6:3:22::30) by DM6PR12MB2924.namprd12.prod.outlook.com (2603:10b6:5:183::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.35; Tue, 4 May 2021 17:57:27 +0000 Received: from DM6NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:3:22:cafe::a6) by DM5PR18CA0068.outlook.office365.com (2603:10b6:3:22::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 4 May 2021 17:57:27 +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 DM6NAM11FT024.mail.protection.outlook.com (10.13.172.159) 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:27 +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:25 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" Date: Tue, 4 May 2021 20:55:00 +0300 Message-ID: <20210504175500.3385811-16-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 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: e7d80591-2c59-4193-4d4a-08d90f261444 X-MS-TrafficTypeDiagnostic: DM6PR12MB2924: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7JDbybyGQjfA0x5UEF2lblK/iNlgv8+scswGeLpI8R+G03utc1W3Hq8xmDknj0Bnu9IJLnGattTCzLxLK0JJGNqWwBF0R+P4kkUW4vsY6qOpFmhJgOOHMZd6P5gJGb8WVV0DCGWDLdHb5EZiozGuGKqwaW/L+pJ1hRmj8sVtaVoHAcFxziR2CCCMeqsuz3+eWd2fMdoCsI14o5r8BLezBFDekBwwEPytqGUiit5AcrR4nM6RKW8elQY3JhTIMXhvERplGLHv2co66zyNPOhDto6QCwdPSGFAK+q42edt7gNNYC/StB2Xm/LVl77N0HNilXXfImdeR/XCgFeTQhpUgEHTumNKomsbxUHCOOXpbwaFkJUSnsoLztVDLltwrYCgTmI6vZVpshP8e9e2tqKtVNiZxPsT1c2RwoZT7XZYPXg/VhQHnR3CMp8/KahdXE2zAr0h0lCaDuIpLKabZo5ksQg80IikUmaTDsnZZeb20hGxehVSzScomQKjpEwM4hXZG9a93gli6GO/g2hWG//ur2f8r5AGPMIzslyiOa0nM/ShM1QL/dBe+/vQDR5HprQZ3zIz7tn0PRYA5hMd/QZk5orfGjcR18VMXwnkcYzMfWexl3mgkrEJgkySo0vxYI4aF9w+v2/+UGuvIltVwReHafOIvMXLoKnlzjEZx4+lz7k= 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)(136003)(346002)(39860400002)(396003)(376002)(46966006)(36840700001)(7696005)(186003)(16526019)(47076005)(82740400003)(356005)(82310400003)(36756003)(2616005)(6286002)(1076003)(5660300002)(36860700001)(7636003)(26005)(316002)(54906003)(86362001)(6916009)(336012)(6666004)(426003)(478600001)(36906005)(2906002)(55016002)(83380400001)(70586007)(8676002)(4326008)(70206006)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:57:27.1760 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e7d80591-2c59-4193-4d4a-08d90f261444 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: DM6NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2924 Subject: [dpdk-dev] [PATCH v3 15/15] common/mlx5: add UMR and RDMA write WQE defines 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 This patch adds the struct defining UMR and RDMA write WQEs. Signed-off-by: Suanming Mou Signed-off-by: Matan Azrad --- drivers/common/mlx5/mlx5_prm.h | 187 +++++++++++++++++++++------------ 1 file changed, 121 insertions(+), 66 deletions(-) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index c2cd2d9f70..1ffee5fd56 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -412,6 +412,127 @@ struct mlx5_cqe_ts { uint8_t op_own; }; +struct mlx5_wqe_rseg { + uint64_t raddr; + uint32_t rkey; + uint32_t reserved; +} __rte_packed; + +#define MLX5_UMRC_IF_OFFSET 31u +#define MLX5_UMRC_KO_OFFSET 16u +#define MLX5_UMRC_TO_BS_OFFSET 0u + +struct mlx5_wqe_umr_cseg { + uint32_t if_cf_toe_cq_res; + uint32_t ko_to_bs; + uint64_t mkey_mask; + uint32_t rsvd1[8]; +} __rte_packed; + +struct mlx5_wqe_mkey_cseg { + uint32_t fr_res_af_sf; + uint32_t qpn_mkey; + uint32_t reserved2; + uint32_t flags_pd; + uint64_t start_addr; + uint64_t len; + uint32_t bsf_octword_size; + uint32_t reserved3[4]; + uint32_t translations_octword_size; + uint32_t res4_lps; + uint32_t reserved; +} __rte_packed; + +enum { + MLX5_BSF_SIZE_16B = 0x0, + MLX5_BSF_SIZE_32B = 0x1, + MLX5_BSF_SIZE_64B = 0x2, + MLX5_BSF_SIZE_128B = 0x3, +}; + +enum { + MLX5_BSF_P_TYPE_SIGNATURE = 0x0, + MLX5_BSF_P_TYPE_CRYPTO = 0x1, +}; + +enum { + MLX5_ENCRYPTION_ORDER_ENCRYPTED_WIRE_SIGNATURE = 0x0, + MLX5_ENCRYPTION_ORDER_ENCRYPTED_MEMORY_SIGNATURE = 0x1, + MLX5_ENCRYPTION_ORDER_ENCRYPTED_RAW_WIRE = 0x2, + MLX5_ENCRYPTION_ORDER_ENCRYPTED_RAW_MEMORY = 0x3, +}; + +enum { + MLX5_ENCRYPTION_STANDARD_AES_XTS = 0x0, +}; + +enum { + MLX5_BLOCK_SIZE_512B = 0x1, + MLX5_BLOCK_SIZE_520B = 0x2, + MLX5_BLOCK_SIZE_4096B = 0x3, + MLX5_BLOCK_SIZE_4160B = 0x4, + MLX5_BLOCK_SIZE_1MB = 0x5, + MLX5_BLOCK_SIZE_4048B = 0x6, +}; + +#define MLX5_BSF_SIZE_OFFSET 30 +#define MLX5_BSF_P_TYPE_OFFSET 24 +#define MLX5_ENCRYPTION_ORDER_OFFSET 16 +#define MLX5_BLOCK_SIZE_OFFSET 24 + +struct mlx5_wqe_umr_bsf_seg { + /* + * bs_bpt_eo_es contains: + * bs bsf_size 2 bits at MLX5_BSF_SIZE_OFFSET + * bpt bsf_p_type 2 bits at MLX5_BSF_P_TYPE_OFFSET + * eo encryption_order 4 bits at MLX5_ENCRYPTION_ORDER_OFFSET + * es encryption_standard 4 bits at offset 0 + */ + uint32_t bs_bpt_eo_es; + uint32_t raw_data_size; + /* + * bsp_res contains: + * bsp crypto_block_size_pointer 8 bits at MLX5_BLOCK_SIZE_OFFSET + * res reserved 24 bits + */ + uint32_t bsp_res; + uint32_t reserved0; + uint8_t xts_initial_tweak[16]; + /* + * res_dp contains: + * res reserved 8 bits + * dp dek_pointer 24 bits at offset 0 + */ + uint32_t res_dp; + uint32_t reserved1; + uint64_t keytag; + uint32_t reserved2[4]; +} __rte_packed; + +#ifdef PEDANTIC +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + +struct mlx5_umr_wqe { + struct mlx5_wqe_cseg ctr; + struct mlx5_wqe_umr_cseg ucseg; + struct mlx5_wqe_mkey_cseg mkc; + union { + struct mlx5_wqe_dseg kseg[0]; + struct mlx5_wqe_umr_bsf_seg bsf[0]; + }; +} __rte_packed; + +struct mlx5_rdma_write_wqe { + struct mlx5_wqe_cseg ctr; + struct mlx5_wqe_rseg rseg; + struct mlx5_wqe_dseg dseg[0]; +} __rte_packed; + +#ifdef PEDANTIC +#pragma GCC diagnostic error "-Wpedantic" +#endif + /* GGA */ /* MMO metadata segment */ @@ -1096,72 +1217,6 @@ struct mlx5_ifc_create_mkey_in_bits { u8 klm_pas_mtt[][0x20]; }; -enum { - MLX5_BSF_SIZE_16B = 0x0, - MLX5_BSF_SIZE_32B = 0x1, - MLX5_BSF_SIZE_64B = 0x2, - MLX5_BSF_SIZE_128B = 0x3, -}; - -enum { - MLX5_BSF_P_TYPE_SIGNATURE = 0x0, - MLX5_BSF_P_TYPE_CRYPTO = 0x1, -}; - -enum { - MLX5_ENCRYPTION_ORDER_ENCRYPTED_WIRE_SIGNATURE = 0x0, - MLX5_ENCRYPTION_ORDER_ENCRYPTED_MEMORY_SIGNATURE = 0x1, - MLX5_ENCRYPTION_ORDER_ENCRYPTED_RAW_WIRE = 0x2, - MLX5_ENCRYPTION_ORDER_ENCRYPTED_RAW_MEMORY = 0x3, -}; - -enum { - MLX5_ENCRYPTION_STANDARD_AES_XTS = 0x0, -}; - -enum { - MLX5_BLOCK_SIZE_512B = 0x1, - MLX5_BLOCK_SIZE_520B = 0x2, - MLX5_BLOCK_SIZE_4096B = 0x3, - MLX5_BLOCK_SIZE_4160B = 0x4, - MLX5_BLOCK_SIZE_1MB = 0x5, - MLX5_BLOCK_SIZE_4048B = 0x6, -}; - -#define MLX5_BSF_SIZE_OFFSET 30 -#define MLX5_BSF_P_TYPE_OFFSET 24 -#define MLX5_ENCRYPTION_ORDER_OFFSET 16 -#define MLX5_BLOCK_SIZE_OFFSET 24 - -struct mlx5_wqe_umr_bsf_seg { - /* - * bs_bpt_eo_es contains: - * bs bsf_size 2 bits at MLX5_BSF_SIZE_OFFSET - * bpt bsf_p_type 2 bits at MLX5_BSF_P_TYPE_OFFSET - * eo encryption_order 4 bits at MLX5_ENCRYPTION_ORDER_OFFSET - * es encryption_standard 4 bits at offset 0 - */ - uint32_t bs_bpt_eo_es; - uint32_t raw_data_size; - /* - * bsp_res contains: - * bsp crypto_block_size_pointer 8 bits at MLX5_BLOCK_SIZE_OFFSET - * res reserved 24 bits - */ - uint32_t bsp_res; - uint32_t reserved0; - uint8_t xts_initial_tweak[16]; - /* - * res_dp contains: - * res reserved 8 bits - * dp dek_pointer 24 bits at offset 0 - */ - uint32_t res_dp; - uint32_t reserved1; - uint64_t keytag; - uint32_t reserved2[4]; -} __rte_packed; - enum { MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE = 0x0 << 1, MLX5_GET_HCA_CAP_OP_MOD_ETHERNET_OFFLOAD_CAPS = 0x1 << 1,