net/mlx4: improve assert control
[dpdk.git] / drivers / net / mlx4 / mlx4_mp.c
index cdb6485..eca0c20 100644 (file)
@@ -3,7 +3,6 @@
  * Copyright 2019 Mellanox Technologies, Ltd
  */
 
-#include <assert.h>
 #include <stdio.h>
 #include <time.h>
 
@@ -62,7 +61,7 @@ mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
        uint32_t lkey;
        int ret;
 
-       assert(rte_eal_process_type() == RTE_PROC_PRIMARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
        if (!rte_eth_dev_is_valid_port(param->port_id)) {
                rte_errno = ENODEV;
                ERROR("port %u invalid port ID", param->port_id);
@@ -114,7 +113,7 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
        struct rte_eth_dev *dev;
        int ret;
 
-       assert(rte_eal_process_type() == RTE_PROC_SECONDARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
        if (!rte_eth_dev_is_valid_port(param->port_id)) {
                rte_errno = ENODEV;
                ERROR("port %u invalid port ID", param->port_id);
@@ -167,7 +166,7 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx4_mp_req_type type)
        int ret;
        int i;
 
-       assert(rte_eal_process_type() == RTE_PROC_PRIMARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
        if (!mlx4_shared_data->secondary_cnt)
                return;
        if (type != MLX4_MP_REQ_START_RXTX && type != MLX4_MP_REQ_STOP_RXTX) {
@@ -249,7 +248,7 @@ mlx4_mp_req_mr_create(struct rte_eth_dev *dev, uintptr_t addr)
        struct timespec ts = {.tv_sec = MLX4_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
        int ret;
 
-       assert(rte_eal_process_type() == RTE_PROC_SECONDARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
        mp_init_msg(dev, &mp_req, MLX4_MP_REQ_CREATE_MR);
        req->args.addr = addr;
        ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
@@ -258,7 +257,7 @@ mlx4_mp_req_mr_create(struct rte_eth_dev *dev, uintptr_t addr)
                      dev->data->port_id);
                return -rte_errno;
        }
-       assert(mp_rep.nb_received == 1);
+       MLX4_ASSERT(mp_rep.nb_received == 1);
        mp_res = &mp_rep.msgs[0];
        res = (struct mlx4_mp_param *)mp_res->param;
        ret = res->result;
@@ -287,7 +286,7 @@ mlx4_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev)
        struct timespec ts = {.tv_sec = MLX4_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
        int ret;
 
-       assert(rte_eal_process_type() == RTE_PROC_SECONDARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
        mp_init_msg(dev, &mp_req, MLX4_MP_REQ_VERBS_CMD_FD);
        ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
        if (ret) {
@@ -295,7 +294,7 @@ mlx4_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev)
                      dev->data->port_id);
                return -rte_errno;
        }
-       assert(mp_rep.nb_received == 1);
+       MLX4_ASSERT(mp_rep.nb_received == 1);
        mp_res = &mp_rep.msgs[0];
        res = (struct mlx4_mp_param *)mp_res->param;
        if (res->result) {
@@ -305,7 +304,7 @@ mlx4_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev)
                ret = -rte_errno;
                goto exit;
        }
-       assert(mp_res->num_fds == 1);
+       MLX4_ASSERT(mp_res->num_fds == 1);
        ret = mp_res->fds[0];
        DEBUG("port %u command FD from primary is %d",
              dev->data->port_id, ret);
@@ -322,7 +321,7 @@ mlx4_mp_init_primary(void)
 {
        int ret;
 
-       assert(rte_eal_process_type() == RTE_PROC_PRIMARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
 
        /* primary is allowed to not support IPC */
        ret = rte_mp_action_register(MLX4_MP_NAME, mp_primary_handle);
@@ -337,7 +336,7 @@ mlx4_mp_init_primary(void)
 void
 mlx4_mp_uninit_primary(void)
 {
-       assert(rte_eal_process_type() == RTE_PROC_PRIMARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
        rte_mp_action_unregister(MLX4_MP_NAME);
 }
 
@@ -347,7 +346,7 @@ mlx4_mp_uninit_primary(void)
 int
 mlx4_mp_init_secondary(void)
 {
-       assert(rte_eal_process_type() == RTE_PROC_SECONDARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
        return rte_mp_action_register(MLX4_MP_NAME, mp_secondary_handle);
 }
 
@@ -357,6 +356,6 @@ mlx4_mp_init_secondary(void)
 void
 mlx4_mp_uninit_secondary(void)
 {
-       assert(rte_eal_process_type() == RTE_PROC_SECONDARY);
+       MLX4_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
        rte_mp_action_unregister(MLX4_MP_NAME);
 }