common/mlx5: avoid class constructor priority
authorParav Pandit <parav@mellanox.com>
Mon, 27 Jul 2020 17:47:11 +0000 (20:47 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 28 Jul 2020 16:52:11 +0000 (18:52 +0200)
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.

Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
drivers/common/mlx5/mlx5_common.c
drivers/common/mlx5/mlx5_common.h
drivers/common/mlx5/rte_common_mlx5_version.map
drivers/net/mlx5/mlx5.c
drivers/regex/mlx5/mlx5_regex.c
drivers/vdpa/mlx5/mlx5_vdpa.c

index 0693d03..7b367e8 100644 (file)
@@ -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;
 }
 
 /**
index a68e61c..e8b0852 100644 (file)
@@ -258,4 +258,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_ */
index 132a069..65f2525 100644 (file)
@@ -3,6 +3,7 @@ INTERNAL {
 
        mlx5_class_get;
 
+       mlx5_common_init;
        mlx5_common_verbs_reg_mr;
        mlx5_common_verbs_dereg_mr;
 
index 6c7a7ee..2defe4a 100644 (file)
@@ -1985,6 +1985,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();
index 36ae9f8..4e03670 100644 (file)
@@ -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);
 }
index 67e77b1..85dbcf9 100644 (file)
@@ -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);
 }