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 3D2B8A0524; Sun, 26 Jul 2020 16:57:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 448821C0D8; Sun, 26 Jul 2020 16:56:04 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2057.outbound.protection.outlook.com [40.107.21.57]) by dpdk.org (Postfix) with ESMTP id 522CF1C0B7 for ; Sun, 26 Jul 2020 16:55:57 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PktsIY6LBRXG6x98d3N4FFTwJpiMqpONMYs2E2B07cS6zDAmzkCLzj1sVOqVzdMFIL6XK8CpfoqXtWkJxLLZANxegesGlP8Hk/FWl037wtm6iY6rNSXYw18U8uwTTzn9Wq9yvuaL80lXCIKY/M6SRmcYqNUO22fE+arbJ2mjmk0JSPtMdVo/jTpC7jhZqGRk//lWR43FuEYbQ80rfc+Tk48u+x/a7gnEO9lbkNxCli5uh2WqVdO4T8CIxyRPY+jvgIJXGzwC4FaLWk0judde4PFRGZdNTt9OgqjaI3BQPP3wlknxd+iQ3mLE0IwOPkWo1u05C1TDgoYNYcYZf5oTTQ== 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=DrdFgL/sR9Hx75nA9MxClsyx2wnK/P35XrmbEJvWIoeIsGaXUCMt0xz9quWYRNfnRMNTzmGrZJg3ymEEU05T5HdNIUV+8tEgK07w1kaZkzP0IQ/mzSomKYqbVZJpMsWwBFcSA7E8moIFKzOj1ogWw+TeJkfkwPtePiI/nLEvyYxCcTX20jGhZbKWJJGVgKDeBqJH016lWuYGpNEmaC+t/bJc96o3oPwrJhWD8mUJc7/OkY+AZk/XJDVh343ul/wbsDR+BhcVtyFgaSLErq7BH26qO/vo4WElUk0kURJHXdt6It4cGdHP2Eg6hlzU1AeRALKJFLqqETSmSu0IUnLN4A== 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=m8rp+WnxgnEHRFvvIYKVfhAPbzii/92IEd44iYbcZheHQiQ4ovkvTxsmlQWaH1ykpUkUYLn7JCKG5TuQ1+tzqEUHNY5IvHIXofrgM9KMR9TxE4UM6r32K4Xof5kxpE9OPIo/emLNm5IHglJerdekNAZCGFRhSwNl2pQdHVUOl1Y= 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 AM0PR05MB6225.eurprd05.prod.outlook.com (2603:10a6:208:117::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.27; Sun, 26 Jul 2020 14:55:56 +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.031; Sun, 26 Jul 2020 14:55:56 +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: Sun, 26 Jul 2020 17:55:20 +0300 Message-Id: <20200726145524.149355-7-parav@mellanox.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200726145524.149355-1-parav@mellanox.com> References: <20200610171728.89-2-parav@mellanox.com> <20200726145524.149355-1-parav@mellanox.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DM5PR04CA0045.namprd04.prod.outlook.com (2603:10b6:3:12b::31) 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 DM5PR04CA0045.namprd04.prod.outlook.com (2603:10b6:3:12b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23 via Frontend Transport; Sun, 26 Jul 2020 14:55:54 +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: 0b5b0a3a-bdfa-4cd6-0db4-08d83173fffb X-MS-TrafficTypeDiagnostic: AM0PR05MB6225: 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: syYlq3GZGNveBCH7/++nehYBmuRfYyp7vOio9TCm3WzY1dnbhigLheH9+Pp0KOPYqY8C7TnRi9VyTILRRhKrOarAEj/OlZJG4HqJweIg6TqTxFgDDnIO8oUhhZQhGCJ8vNUWPktqtzsRIqG5tC805IlBv0cAi+It2J9yHiHYxEOk+eLmwjVfzN+QQfumb54qgJeLziMqLCXTLPD2bJOH1eTu9bCaN9C09KrS8utvWx1Y07rfSJ4XUNtP7RAn7lj2HFw1K3SOUfoDrstjiMcduMfn69i3UQunWc8QiARlEHuUzRomMC/DEyxTfP1DG9c/ 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)(366004)(396003)(346002)(39860400002)(136003)(376002)(6486002)(66476007)(8936002)(66556008)(6512007)(2616005)(956004)(186003)(66946007)(26005)(16526019)(8676002)(1076003)(6666004)(316002)(83380400001)(54906003)(6506007)(4326008)(36756003)(478600001)(2906002)(86362001)(52116002)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CRhJrgGw/3JHkxkBSyrLGlOXAjmF6VqFCWZhIyFJC2D3N+IOUst4brwS9fgn7y5EQWNbzbcWWMndsb7SZDFFv6ekHz+/Fd06NPesmp4pk6Tz18hr5hi6/E4AXYz4h3Lz32w/XJ3w9hJzmFF9qoB+bJkDnpbn3QSUMqiNSUODVgufu/SrklXEX+NEtheZvPUKyaP+npw0ImG2J+zZa4zlvlvJr2RdoE04OpHnAg53Q97dYmURkFASMc7tpE1e+Tlxx0NgUepsAZ4Tc2zko78VEExA3JwFN/9xAdhyJO8IrPPravpVw3cKSjbLFYp+D/iMq4O49yraNvXX/WLScUN0MU/Abir588YG7vC0yHpR21klkSsPqha9rrliBuymru/3PxStnvYKU3QeskmwBUFEuIqi5g0PRu7RjFD/mrpIDFnva/Rz7YLQwkg91zHHZNuD7VjYCKVxtoC/PcIkDg98clebjbPodCxExiLdzrCjbvyUM/cNNJaIo227WWRJhOBk X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b5b0a3a-bdfa-4cd6-0db4-08d83173fffb X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4866.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2020 14:55:56.1896 (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: uLld7eWUa4DD8eTAmxl/DW0DEpCqpDMOKw9rIpTH/UNhDL0xd/Py13KFTd+NoM13Otvq/bH3TJzlB+iAOHpbXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6225 Subject: [dpdk-dev] [PATCH v11 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