DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alexander Kozyrev <akozyrev@mellanox.com>
To: dev@dpdk.org
Cc: rasland@mellanox.com, matan@mellanox.com,
	viacheslavo@mellanox.com, ferruh.yigit@intel.com,
	thomas@monjalon.net
Subject: [dpdk-dev] [PATCH v5 4/5] drivers: use mlx5 debug flag instead of NDEBUG
Date: Thu, 30 Jan 2020 18:14:39 +0200	[thread overview]
Message-ID: <1580400880-96628-5-git-send-email-akozyrev@mellanox.com> (raw)
In-Reply-To: <1580400880-96628-1-git-send-email-akozyrev@mellanox.com>

Use the RTE_LIBRTE_MLX5_DEBUG configuration flag to get rid of dependency
on the NDEBUG definition. This is a preparation step to switch
from standard assert clauses to DPDK RTE_ASSERT ones in MLX5 driver.

Signed-off-by: Alexander Kozyrev <akozyrev@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/common/mlx5/Makefile      |  2 +-
 drivers/common/mlx5/meson.build   |  4 ++--
 drivers/common/mlx5/mlx5_common.c |  2 +-
 drivers/common/mlx5/mlx5_common.h | 14 +++++++-------
 drivers/common/mlx5/mlx5_nl.c     |  2 +-
 drivers/net/mlx5/Makefile         |  4 ++--
 drivers/net/mlx5/meson.build      |  4 ++--
 drivers/net/mlx5/mlx5.c           |  4 ++--
 drivers/net/mlx5/mlx5_flow_dv.c   |  2 +-
 drivers/net/mlx5/mlx5_mr.c        |  4 ++--
 drivers/net/mlx5/mlx5_rxtx.c      |  8 ++++----
 drivers/net/mlx5/mlx5_rxtx.h      |  6 +++---
 drivers/net/mlx5/mlx5_txq.c       |  2 +-
 13 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/common/mlx5/Makefile b/drivers/common/mlx5/Makefile
index 9d4d81f..624d331 100644
--- a/drivers/common/mlx5/Makefile
+++ b/drivers/common/mlx5/Makefile
@@ -45,7 +45,7 @@ endif
 LDLIBS += -lrte_eal -lrte_pci -lrte_kvargs -lrte_net
 
 # A few warnings cannot be avoided in external headers.
-CFLAGS += -Wno-error=cast-qual -DNDEBUG -UPEDANTIC
+CFLAGS += -Wno-error=cast-qual -UPEDANTIC
 
 EXPORT_MAP := rte_common_mlx5_version.map
 
diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index fdd1e85..2b70410 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -60,9 +60,9 @@ if build
 		endif
 	endforeach
 	if get_option('buildtype').contains('debug')
-		cflags += [ '-pedantic', '-UNDEBUG', '-DPEDANTIC' ]
+		cflags += [ '-pedantic', '-DPEDANTIC' ]
 	else
-		cflags += [ '-DNDEBUG', '-UPEDANTIC' ]
+		cflags += [ '-UPEDANTIC' ]
 	endif
 	# To maintain the compatibility with the make build system
 	# mlx5_autoconf.h file is still generated.
diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 922794e..3ff0172 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -304,7 +304,7 @@ enum mlx5_class
 	}
 	mlx5_glue = *sym;
 #endif /* RTE_IBVERBS_LINK_DLOPEN */
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 	/* Glue structure must not contain any NULL pointers. */
 	{
 		unsigned int i;
diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
index d9c2d26..884ec02 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -75,10 +75,10 @@
 		RTE_FMT_TAIL(__VA_ARGS__,)))
 
 /*
- * When debugging is enabled (NDEBUG not defined), file, line and function
+ * When debugging is enabled (MLX5_DEBUG not defined), file, line and function
  * information replace the driver name (MLX5_DRIVER_NAME) in log messages.
  */
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 
 #define PMD_DRV_LOG__(level, type, name, ...) \
 	PMD_DRV_LOG___(level, type, name, "%s:%u: %s(): " __VA_ARGS__)
@@ -90,28 +90,28 @@
 		__func__, \
 		__VA_ARGS__)
 
-#else /* NDEBUG */
+#else /* RTE_LIBRTE_MLX5_DEBUG */
 #define PMD_DRV_LOG__(level, type, name, ...) \
 	PMD_DRV_LOG___(level, type, name, __VA_ARGS__)
 #define PMD_DRV_LOG_(level, type, name, s, ...) \
 	PMD_DRV_LOG__(level, type, name, s "\n", __VA_ARGS__)
 
-#endif /* NDEBUG */
+#endif /* RTE_LIBRTE_MLX5_DEBUG */
 
 /* claim_zero() does not perform any check when debugging is disabled. */
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 
 #define DEBUG(...) DRV_LOG(DEBUG, __VA_ARGS__)
 #define claim_zero(...) assert((__VA_ARGS__) == 0)
 #define claim_nonzero(...) assert((__VA_ARGS__) != 0)
 
-#else /* NDEBUG */
+#else /* RTE_LIBRTE_MLX5_DEBUG */
 
 #define DEBUG(...) (void)0
 #define claim_zero(...) (__VA_ARGS__)
 #define claim_nonzero(...) (__VA_ARGS__)
 
-#endif /* NDEBUG */
+#endif /* RTE_LIBRTE_MLX5_DEBUG */
 
 /* Allocate a buffer on the stack and fill it with a printf format string. */
 #define MKSTR(name, ...) \
diff --git a/drivers/common/mlx5/mlx5_nl.c b/drivers/common/mlx5/mlx5_nl.c
index 0d1efd2..26547f4 100644
--- a/drivers/common/mlx5/mlx5_nl.c
+++ b/drivers/common/mlx5/mlx5_nl.c
@@ -418,7 +418,7 @@ struct mlx5_nl_ifindex_data {
 				rte_errno = ENOMEM;
 				return -rte_errno;
 			}
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 			char m[18];
 
 			rte_ether_format_addr(m, 18, RTA_DATA(attribute));
diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index d26afbb..e8ba624 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -67,13 +67,13 @@ endif
 
 # User-defined CFLAGS.
 ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DEBUG),y)
-CFLAGS += -pedantic -UNDEBUG
+CFLAGS += -pedantic
 ifneq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
 CFLAGS += -DPEDANTIC
 endif
 AUTO_CONFIG_CFLAGS += -Wno-pedantic
 else
-CFLAGS += -DNDEBUG -UPEDANTIC
+CFLAGS += -UPEDANTIC
 endif
 
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build
index d45be00..d418d26 100644
--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -49,7 +49,7 @@ foreach option:cflags_options
 	endif
 endforeach
 if get_option('buildtype').contains('debug')
-	cflags += [ '-pedantic', '-UNDEBUG', '-DPEDANTIC' ]
+	cflags += [ '-pedantic', '-DPEDANTIC' ]
 else
-	cflags += [ '-DNDEBUG', '-UPEDANTIC' ]
+	cflags += [ '-UPEDANTIC' ]
 endif
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index e5fc1d3..33c0c82 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -661,7 +661,7 @@ struct mlx5_flow_id_pool *
 mlx5_free_shared_ibctx(struct mlx5_ibv_shared *sh)
 {
 	pthread_mutex_lock(&mlx5_ibv_list_mutex);
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 	/* Check the object presence in the list. */
 	struct mlx5_ibv_shared *lctx;
 
@@ -2644,7 +2644,7 @@ struct mlx5_flow_id_pool *
 		mac.addr_bytes[0], mac.addr_bytes[1],
 		mac.addr_bytes[2], mac.addr_bytes[3],
 		mac.addr_bytes[4], mac.addr_bytes[5]);
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 	{
 		char ifname[IF_NAMESIZE];
 
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f82c90e..17d6d7c 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5118,7 +5118,7 @@ struct field_modify_info modify_tcp[] = {
 	return dev_flow;
 }
 
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 /**
  * Sanity check for match mask and value. Similar to check_valid_spec() in
  * kernel driver. If unmasked bit is present in value, it returns failure.
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index b1cd9f7..764a741 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -241,7 +241,7 @@ struct mr_update_mp_data {
 void
 mlx5_mr_btree_dump(struct mlx5_mr_btree *bt __rte_unused)
 {
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 	int idx;
 	struct mlx5_mr_cache *lkp_tbl;
 
@@ -1552,7 +1552,7 @@ struct mr_update_mp_data {
 void
 mlx5_mr_dump_dev(struct mlx5_ibv_shared *sh __rte_unused)
 {
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 	struct mlx5_mr *mr;
 	int mr_n = 0;
 	int chunk_n = 0;
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 37a2084..0b94ddc 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -2185,11 +2185,11 @@ enum mlx5_txcmp_code {
 		last->cseg.flags = RTE_BE32(MLX5_COMP_ALWAYS <<
 					    MLX5_COMP_MODE_OFFSET);
 		/* Save elts_head in dedicated free on completion queue. */
-#ifdef NDEBUG
-		txq->fcqs[txq->cq_pi++ & txq->cqe_m] = head;
-#else
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 		txq->fcqs[txq->cq_pi++ & txq->cqe_m] = head |
-					(last->cseg.opcode >> 8) << 16;
+			  (last->cseg.opcode >> 8) << 16;
+#else
+		txq->fcqs[txq->cq_pi++ & txq->cqe_m] = head;
 #endif
 		/* A CQE slot must always be available. */
 		assert((txq->cq_pi - txq->cq_ci) <= txq->cqe_s);
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index f9b611a..206c5d2 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -300,10 +300,10 @@ struct mlx5_txq_data {
 	struct mlx5_mr_ctrl mr_ctrl; /* MR control descriptor. */
 	struct mlx5_wqe *wqes; /* Work queue. */
 	struct mlx5_wqe *wqes_end; /* Work queue array limit. */
-#ifdef NDEBUG
-	uint16_t *fcqs; /* Free completion queue. */
-#else
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 	uint32_t *fcqs; /* Free completion queue (debug extended). */
+#else
+	uint16_t *fcqs; /* Free completion queue. */
 #endif
 	volatile struct mlx5_cqe *cqes; /* Completion queue. */
 	volatile uint32_t *qp_db; /* Work queue doorbell. */
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 7bff769..5c91adf 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -85,7 +85,7 @@
 
 		assert(elt != NULL);
 		rte_pktmbuf_free_seg(elt);
-#ifndef NDEBUG
+#ifdef RTE_LIBRTE_MLX5_DEBUG
 		/* Poisoning. */
 		memset(&(*elts)[elts_tail & elts_m],
 		       0x77,
-- 
1.8.3.1


  parent reply	other threads:[~2020-01-30 16:15 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-23 14:25 [dpdk-dev] [PATCH 0/5] net/mlx: assert cleanup in mlx drivers Alexander Kozyrev
2020-01-23 14:25 ` [dpdk-dev] [PATCH 1/5] mk/icc: disable treatment of warnings as errors Alexander Kozyrev
2020-01-23 15:31   ` Thomas Monjalon
2020-01-23 14:25 ` [dpdk-dev] [PATCH 2/5] net/mlx4: use mlx4 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-23 14:25 ` [dpdk-dev] [PATCH 3/5] net/mlx4: introduce the mlx4 version of the assert Alexander Kozyrev
2020-01-23 15:49   ` Thomas Monjalon
2020-01-23 14:25 ` [dpdk-dev] [PATCH 4/5] net/mlx5: use mlx5 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-23 14:25 ` [dpdk-dev] [PATCH 5/5] net/mlx5: introduce the mlx5 version of the assert Alexander Kozyrev
2020-01-23 18:20 ` [dpdk-dev] [PATCH v2 0/5] net/mlx: assert cleanup in mlx drivers Alexander Kozyrev
2020-01-23 18:20   ` [dpdk-dev] [PATCH v2 1/5] mk/icc: disable treatment of warnings as errors Alexander Kozyrev
2020-01-24 16:36     ` Ferruh Yigit
2020-01-24 19:37       ` Thomas Monjalon
2020-01-27 15:37         ` Ferruh Yigit
2020-01-27 20:38           ` Thomas Monjalon
2020-01-23 18:20   ` [dpdk-dev] [PATCH v2 2/5] net/mlx4: use mlx4 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-24 16:43     ` Ferruh Yigit
2020-01-24 16:50       ` Slava Ovsiienko
2020-01-24 17:02         ` Bruce Richardson
2020-01-23 18:20   ` [dpdk-dev] [PATCH v2 3/5] net/mlx4: introduce the mlx4 version of the assert Alexander Kozyrev
2020-01-23 18:20   ` [dpdk-dev] [PATCH v2 4/5] net/mlx5: use mlx5 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-23 18:20   ` [dpdk-dev] [PATCH v2 5/5] net/mlx5: introduce the mlx5 version of the assert Alexander Kozyrev
2020-01-27 14:42 ` [dpdk-dev] [PATCH v3 0/5] net/mlx: assert cleanup in mlx drivers Alexander Kozyrev
2020-01-27 14:42   ` [dpdk-dev] [PATCH v3 1/5] mk/icc: disable treatment of warnings as errors Alexander Kozyrev
2020-01-27 14:42   ` [dpdk-dev] [PATCH v3 2/5] net/mlx4: use mlx4 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-27 14:42   ` [dpdk-dev] [PATCH v3 3/5] net/mlx4: introduce the mlx4 version of the assert Alexander Kozyrev
2020-01-27 14:42   ` [dpdk-dev] [PATCH v3 4/5] net/mlx5: use mlx5 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-27 14:42   ` [dpdk-dev] [PATCH v3 5/5] net/mlx5: introduce the mlx5 version of the assert Alexander Kozyrev
2020-01-30 14:20 ` [dpdk-dev] [PATCH v4 0/5] net/mlx: assert cleanup in mlx drivers Alexander Kozyrev
2020-01-30 14:20   ` [dpdk-dev] [PATCH v4 1/5] mk/icc: disable treatment of warnings as errors Alexander Kozyrev
2020-01-30 14:20   ` [dpdk-dev] [PATCH v4 2/5] net/mlx4: use mlx4 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-30 14:20   ` [dpdk-dev] [PATCH v4 3/5] net/mlx4: introduce the mlx4 version of the assert Alexander Kozyrev
2020-01-30 14:20   ` [dpdk-dev] [PATCH v4 4/5] drivers: use mlx5 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-30 14:20   ` [dpdk-dev] [PATCH v4 5/5] drivers: introduce the mlx5 version of the assert Alexander Kozyrev
2020-01-30 16:14 ` [dpdk-dev] [PATCH v5 0/5] net/mlx: assert cleanup in mlx drivers Alexander Kozyrev
2020-01-30 16:14   ` [dpdk-dev] [PATCH v5 1/5] mk/icc: disable treatment of warnings as errors Alexander Kozyrev
2020-01-30 16:14   ` [dpdk-dev] [PATCH v5 2/5] net/mlx4: use mlx4 debug flag instead of NDEBUG Alexander Kozyrev
2020-01-30 16:14   ` [dpdk-dev] [PATCH v5 3/5] net/mlx4: introduce the mlx4 version of the assert Alexander Kozyrev
2020-01-30 16:14   ` Alexander Kozyrev [this message]
2020-01-30 16:14   ` [dpdk-dev] [PATCH v5 5/5] drivers: introduce the mlx5 " Alexander Kozyrev
2020-01-31 10:45   ` [dpdk-dev] [PATCH v5 0/5] net/mlx: assert cleanup in mlx drivers Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1580400880-96628-5-git-send-email-akozyrev@mellanox.com \
    --to=akozyrev@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=matan@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).