From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9892DA053E; Mon, 27 Jul 2020 19:48:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AE4841C0D6; Mon, 27 Jul 2020 19:48:02 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140081.outbound.protection.outlook.com [40.107.14.81]) by dpdk.org (Postfix) with ESMTP id 4F193A3 for ; Mon, 27 Jul 2020 19:47:56 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gkXg1lPpK046+4rme49HxJdOCg6fTHUKBwY6+3N4oPqPElVUXpRjqB0ophh2z+BESV7ZmctLsUxgvPq/2vNwCpqXP2CV1PW3+RbjiJXLs+mTNylBLbLkE21ZDblheQ9/l5QY7pE0BvS1rQ1C/+GtBA9fi1Envh1zujt71wUYyjdwkLmxAebGO8Ztu/dGW5wNi73skhsj/VGHCwkLFfhIy6rZzTWX616HDO8PqD0gUgTKNq3Z+L+ADKKnM4ZaZyVQmdNnLafSev4sEfuG6lUB55aTRoARAkhsXL7FD2Ah9SMgqKzAadYKouQulKe0H8N69Ak7sEW6vMLopvyzDTwJ7w== 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=uE1aG3m3rW+suXJngbZxLa6tmSK5I5Xc8kW4y3TDwWw=; b=KtE+gavh7oNgfyLxpmzLH5d2ACUJLxcEsonhNwcdpu04XBwDG85du2qrEnOlEoZIVHjGHqFXTmnA8gif76bV8i/T20UCHLPXa7nci4m6aZBuJcRawVhKk2D0y64M5AEWIzFBYl392mr9TTb7pGQ6+v5pvTIhv5uQLaEtKXjKyt+EicjoEXx983x+TnNS3UVOP8VKb+xdSSTQ/ZKLXhkvPqroTTh30X1xWJTcyUOz5ym0nvml3trXhCx0RPVH893sDT8RFLqJthO+LiXdbp+h0QkjBfELMIzjkxy2sS9pOzXAhREhJrl5XMZjdxSxJISaOamdaifxV2vWi7wqGeULjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uE1aG3m3rW+suXJngbZxLa6tmSK5I5Xc8kW4y3TDwWw=; b=SZr8tyJsotcRD8r1ji2RZAFKniMoJjFOvmWJ5SyRCLOLPIDsVlHu9K6qiNFpCU1icZ6GFs7o/3AVqYvh8dybefeP6D5j+fxOvF9IflkpCEksHO2MhPYMsMDoKHNRWjK+rCGhY+oS0qfgqMSqHbQMqMjow0xfqU8vexlp6EXO/SA= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4866.eurprd05.prod.outlook.com (2603:10a6:208:c0::32) by AM0PR05MB6227.eurprd05.prod.outlook.com (2603:10a6:208:10f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23; Mon, 27 Jul 2020 17:47:54 +0000 Received: from AM0PR05MB4866.eurprd05.prod.outlook.com ([fe80::eccf:72b3:bacb:f09d]) by AM0PR05MB4866.eurprd05.prod.outlook.com ([fe80::eccf:72b3:bacb:f09d%5]) with mapi id 15.20.3216.033; Mon, 27 Jul 2020 17:47:54 +0000 From: Parav Pandit To: dev@dpdk.org, grive@u256.net, ferruh.yigit@intel.com, thomas@monjalon.net Cc: rasland@mellanox.com, orika@mellanox.com, matan@mellanox.com, joyce.kong@arm.com, Parav Pandit , David Marchand Date: Mon, 27 Jul 2020 20:47:11 +0300 Message-Id: <20200727174715.330117-7-parav@mellanox.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200727174715.330117-1-parav@mellanox.com> References: <20200610171728.89-2-parav@mellanox.com> <20200727174715.330117-1-parav@mellanox.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DM5PR15CA0049.namprd15.prod.outlook.com (2603:10b6:3:ae::11) To AM0PR05MB4866.eurprd05.prod.outlook.com (2603:10a6:208:c0::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sw-mtx-036.mtx.labs.mlnx (208.176.44.194) by DM5PR15CA0049.namprd15.prod.outlook.com (2603:10b6:3:ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.20 via Frontend Transport; Mon, 27 Jul 2020 17:47:53 +0000 X-Mailer: git-send-email 2.26.2 X-Originating-IP: [208.176.44.194] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 19d6ec45-5bcf-4ab6-14b5-08d8325530e1 X-MS-TrafficTypeDiagnostic: AM0PR05MB6227: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:216; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0nASturFr3CUHUmq2XXhcg/cdZmKwrl4/Wbds7b6iqRYs2QAmQJC2rDJI/5ZXz8fxjMnjqEEQhhh3PSuZLFL36aEp1HxAOifn5xhMCE7SFH3aXbAQTEkvo8gxWLoxmFcJLebFDFPMPS007mlcgd3oTmGkrkCKV327J6dmJ7y007kNWFoBlDYi45tGc1JvXcb8FWbDQ56n8qB3HIfzgU+jfoAI+AG6v/C9FMegQYsqVDAC66wuZNUhGVUuzn5KJk54ix/44xG2pzL69KhE2i8bxzZtzSxG+EbKRFystSN4yGOLqGwp8MfBgYAQLxsXzZe X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4866.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(52116002)(6506007)(2906002)(54906003)(316002)(6486002)(1076003)(5660300002)(8936002)(8676002)(478600001)(6666004)(6512007)(26005)(16526019)(186003)(66946007)(66556008)(66476007)(86362001)(2616005)(956004)(4326008)(83380400001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Rr9GRD5fGla/GXbDu6ypumihgL7CaPgXEt1Hytir7YuemMQBPq0y+5JhdJ4aYFuw2ebCPmaAWXlcOO23dHxeM+9iblnEPc9OX0k//YY1k75Uop4oofsEHOxNahF/BDJqsW13ntpNaPqkGZi9isogQ5lpkesVAncwr3nA3ECGzLfZxyJcGwqwQkk8rHm0ywnk/LC08s/ofNC5inj3sTePMg1napXNZH4QlsTncQkFwdo5mOj03jKFgsKY03inQAtEN41ZX7XbCHQh3nXbDOLKsyXOPCxfJeaAu09Yo2iVTRqlX2lPohV505n8EAnU6WSsbquMxNo5jZB1t05ABub0g/D1FCRnmOgroEZihjs+zxExIyZs1UBxELxdkVGRyd+kfYC8a+83QYcrj1l4+WgEp/dJ8538JHN+2o18Q5ZsloNY//s2cMKUef5GufpjWOpV0OFX+NKxwto4fVywsPtR8WdErg9CY1YQLwzCxQyuGrDtDRU8hLKWYLbwFsXipSqU X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19d6ec45-5bcf-4ab6-14b5-08d8325530e1 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4866.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2020 17:47:54.8310 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MyF3B3gzpP5yXqvCjhfloomVASdwcg9v/fav0FLxzekQqvn9RkIfrsTU8IJ0wa9gKpYbFx1SBbTuO2Vy8xIZxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6227 Subject: [dpdk-dev] [PATCH v12 06/10] common/mlx5: avoid using class constructor priority X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" mlx5_common is shared library between mlx5 net, VDPA and regex PMD. It is better to use common initialization helper instead of using RTE_PRIORITY_CLASS priority. Reviewed-by: David Marchand Suggested-by: David Marchand Signed-off-by: Parav Pandit --- Changelog: v7->v8: - new patch --- drivers/common/mlx5/mlx5_common.c | 13 +++++++++++-- drivers/common/mlx5/mlx5_common.h | 3 +++ drivers/common/mlx5/rte_common_mlx5_version.map | 1 + drivers/net/mlx5/mlx5.c | 1 + drivers/regex/mlx5/mlx5_regex.c | 1 + drivers/vdpa/mlx5/mlx5_vdpa.c | 1 + 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 1a67a1b16..2b336bb2d 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -86,12 +86,21 @@ RTE_INIT_PRIO(mlx5_log_init, LOG) rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE); } +static bool mlx5_common_initialized; + /** - * Initialization routine for run-time dependency on glue library. + * One time innitialization routine for run-time dependency on glue library + * for multiple PMDs. Each mlx5 PMD that depends on mlx5_common module, + * must invoke in its constructor. */ -RTE_INIT_PRIO(mlx5_glue_init, CLASS) +void +mlx5_common_init(void) { + if (mlx5_common_initialized) + return; + mlx5_glue_constructor(); + mlx5_common_initialized = true; } /** diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index a811eb6c9..ebe4e9ced 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -260,4 +260,7 @@ int32_t mlx5_release_dbr(struct mlx5_dbr_page_list *head, uint32_t umem_id, uint64_t offset); extern uint8_t haswell_broadwell_cpu; +__rte_internal +void mlx5_common_init(void); + #endif /* RTE_PMD_MLX5_COMMON_H_ */ diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map index 132a0695f..65f25252a 100644 --- a/drivers/common/mlx5/rte_common_mlx5_version.map +++ b/drivers/common/mlx5/rte_common_mlx5_version.map @@ -3,6 +3,7 @@ INTERNAL { mlx5_class_get; + mlx5_common_init; mlx5_common_verbs_reg_mr; mlx5_common_verbs_dereg_mr; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 647ada339..037703d2e 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2111,6 +2111,7 @@ RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE) */ RTE_INIT(rte_mlx5_pmd_init) { + mlx5_common_init(); /* Build the static tables for Verbs conversion. */ mlx5_set_ptype_table(); mlx5_set_cksum_table(); diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c index 36ae9f809..4e0367052 100644 --- a/drivers/regex/mlx5/mlx5_regex.c +++ b/drivers/regex/mlx5/mlx5_regex.c @@ -258,6 +258,7 @@ static struct rte_pci_driver mlx5_regex_driver = { RTE_INIT(rte_mlx5_regex_init) { + mlx5_common_init(); if (mlx5_glue) rte_pci_register(&mlx5_regex_driver); } diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 67e77b11a..85dbcf956 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -846,6 +846,7 @@ RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE) */ RTE_INIT(rte_mlx5_vdpa_init) { + mlx5_common_init(); if (mlx5_glue) rte_pci_register(&mlx5_vdpa_driver); } -- 2.26.2