Add mlx5_fp_debug_enabled() function which:

- returns true if RTE_LIBRTE_MLX5_DEBUG is defined,
- returns false otherwise.

This allows for conditional execution of code meant to be executed only
when mlx5 debug mode is enabled, without adding conditional compilation
guards inside source code.
When mlx5 debug mode is disabled, any code running if
mlx5_fp_debug_enabled() returns true will be removed by optimizing
compiler due to dead code elimination.

Signed-off-by: Dariusz Sosnowski <dsosnow...@nvidia.com>
Acked-by: Ori Kam <or...@nvidia.com>
---
 drivers/common/mlx5/mlx5_common.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/common/mlx5/mlx5_common.h 
b/drivers/common/mlx5/mlx5_common.h
index 14c70edbef..1abd1e8239 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -109,6 +109,19 @@ pmd_drv_log_basename(const char *s)
 
 #endif /* RTE_LIBRTE_MLX5_DEBUG */
 
+/**
+ * Returns true if debug mode is enabled for fast path operations.
+ */
+static inline bool
+mlx5_fp_debug_enabled(void)
+{
+#ifdef RTE_LIBRTE_MLX5_DEBUG
+       return true;
+#else
+       return false;
+#endif
+}
+
 /* Allocate a buffer on the stack and fill it with a printf format string. */
 #define MKSTR(name, ...) \
        int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \
-- 
2.39.2

Reply via email to