common/mlx5: remove NDEBUG

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>
This commit is contained in:
Alexander Kozyrev 2020-01-30 18:14:39 +02:00 committed by Ferruh Yigit
parent 8e08df22f0
commit 0afacb04f5
13 changed files with 29 additions and 29 deletions

@ -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

@ -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.

@ -302,7 +302,7 @@ RTE_INIT_PRIO(mlx5_glue_init, 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;

@ -75,10 +75,10 @@ pmd_drv_log_basename(const char *s)
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 @@ pmd_drv_log_basename(const char *s)
__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, ...) \

@ -417,7 +417,7 @@ mlx5_nl_mac_addr_cb(struct nlmsghdr *nh, void *arg)
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));

@ -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

@ -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

@ -661,7 +661,7 @@ static void
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 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
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];

@ -5118,7 +5118,7 @@ flow_dv_prepare(const struct rte_flow_attr *attr __rte_unused,
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.

@ -241,7 +241,7 @@ mlx5_mr_btree_free(struct mlx5_mr_btree *bt)
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 @@ mlx5_mr_update_mp(struct rte_eth_dev *dev, struct mlx5_mr_ctrl *mr_ctrl,
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;

@ -2185,11 +2185,11 @@ mlx5_tx_request_completion(struct mlx5_txq_data *restrict txq,
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);

@ -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. */

@ -85,7 +85,7 @@ txq_free_elts(struct mlx5_txq_ctrl *txq_ctrl)
assert(elt != NULL);
rte_pktmbuf_free_seg(elt);
#ifndef NDEBUG
#ifdef RTE_LIBRTE_MLX5_DEBUG
/* Poisoning. */
memset(&(*elts)[elts_tail & elts_m],
0x77,