[v10,06/10] common/mlx5: avoid using class constructor priority
Checks
Commit Message
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 <david.marchand@redhat.com>
Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Parav Pandit <parav@mellanox.com>
---
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(-)
@@ -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;
}
/**
@@ -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_ */
@@ -3,6 +3,7 @@ INTERNAL {
mlx5_class_get;
+ mlx5_common_init;
mlx5_common_verbs_reg_mr;
mlx5_common_verbs_dereg_mr;
@@ -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();
@@ -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);
}
@@ -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);
}