From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 9AB9D1B70E for ; Wed, 9 May 2018 17:29:13 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from shahafs@mellanox.com) with ESMTPS (AES256-SHA encrypted); 9 May 2018 18:06:12 +0300 Received: from unicorn01.mtl.labs.mlnx. (unicorn01.mtl.labs.mlnx [10.7.12.62]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w49F4SrQ008373; Wed, 9 May 2018 18:04:29 +0300 From: Shahaf Shuler To: bluca@debian.org Cc: stable@dpdk.org, nelio.laranjeiro@6wind.com, adrien.mazarguil@6wind.com, yskoh@mellanox.com Date: Wed, 9 May 2018 18:04:01 +0300 Message-Id: <881ade52b534653b4241338408b1d7e3587304ed.1525878118.git.shahafs@mellanox.com> X-Mailer: git-send-email 2.12.0 MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v2 09/20] net/mlx5: change non failing function return values X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 May 2018 15:29:13 -0000 From: NĂ©lio Laranjeiro [ upstream commit 925061b58b487fba57f55847b1447417fed715fb ] These functions return int although they are not supposed to fail, resulting in unnecessary checks in their callers. Some are returning error where is should be a boolean. Signed-off-by: Nelio Laranjeiro Acked-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_mr.c | 4 ++-- drivers/net/mlx5/mlx5_rxq.c | 25 ++++++++++--------------- drivers/net/mlx5/mlx5_socket.c | 6 +----- drivers/net/mlx5/mlx5_trigger.c | 6 +----- drivers/net/mlx5/mlx5_txq.c | 17 ++++++----------- 6 files changed, 22 insertions(+), 40 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 2cb463b622..86310404a0 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -242,7 +242,7 @@ int mlx5_vlan_offload_set(struct rte_eth_dev *dev, int mask); int mlx5_dev_start(struct rte_eth_dev *dev); void mlx5_dev_stop(struct rte_eth_dev *dev); int mlx5_traffic_enable(struct rte_eth_dev *dev); -int mlx5_traffic_disable(struct rte_eth_dev *dev); +void mlx5_traffic_disable(struct rte_eth_dev *dev); int mlx5_traffic_restart(struct rte_eth_dev *dev); /* mlx5_flow.c */ @@ -287,7 +287,7 @@ void mlx5_flow_delete_drop_queue(struct rte_eth_dev *dev); /* mlx5_socket.c */ int mlx5_socket_init(struct rte_eth_dev *priv); -int mlx5_socket_uninit(struct rte_eth_dev *priv); +void mlx5_socket_uninit(struct rte_eth_dev *priv); void mlx5_socket_handle(struct rte_eth_dev *priv); int mlx5_socket_connect(struct rte_eth_dev *priv); diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index fe60dd1329..5c4e687369 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -307,7 +307,7 @@ mlx5_mr_get(struct rte_eth_dev *dev, struct rte_mempool *mp) * Pointer to memory region to release. * * @return - * 0 on success, errno on failure. + * 1 while a reference on it exists, 0 when freed. */ int mlx5_mr_release(struct mlx5_mr *mr) @@ -321,7 +321,7 @@ mlx5_mr_release(struct mlx5_mr *mr) rte_free(mr); return 0; } - return EBUSY; + return 1; } /** diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index a3b08a1a3b..8e7693df2f 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -840,7 +840,7 @@ mlx5_rxq_ibv_get(struct rte_eth_dev *dev, uint16_t idx) * Verbs Rx queue object. * * @return - * 0 on success, errno value on failure. + * 1 while a reference on it exists, 0 when freed. */ int mlx5_rxq_ibv_release(struct mlx5_rxq_ibv *rxq_ibv) @@ -867,7 +867,7 @@ mlx5_rxq_ibv_release(struct mlx5_rxq_ibv *rxq_ibv) rte_free(rxq_ibv); return 0; } - return EBUSY; + return 1; } /** @@ -1074,7 +1074,7 @@ mlx5_rxq_get(struct rte_eth_dev *dev, uint16_t idx) * TX queue index. * * @return - * 0 on success, errno value on failure. + * 1 while a reference on it exists, 0 when freed. */ int mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx) @@ -1086,13 +1086,8 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx) return 0; rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); assert(rxq_ctrl->priv); - if (rxq_ctrl->ibv) { - int ret; - - ret = mlx5_rxq_ibv_release(rxq_ctrl->ibv); - if (!ret) - rxq_ctrl->ibv = NULL; - } + if (rxq_ctrl->ibv && !mlx5_rxq_ibv_release(rxq_ctrl->ibv)) + rxq_ctrl->ibv = NULL; DEBUG("%p: Rx queue %p: refcnt %d", (void *)dev, (void *)rxq_ctrl, rte_atomic32_read(&rxq_ctrl->refcnt)); if (rte_atomic32_dec_and_test(&rxq_ctrl->refcnt)) { @@ -1101,7 +1096,7 @@ mlx5_rxq_release(struct rte_eth_dev *dev, uint16_t idx) (*priv->rxqs)[idx] = NULL; return 0; } - return EBUSY; + return 1; } /** @@ -1261,7 +1256,7 @@ mlx5_ind_table_ibv_get(struct rte_eth_dev *dev, uint16_t queues[], * Indirection table to release. * * @return - * 0 on success, errno value on failure. + * 1 while a reference on it exists, 0 when freed. */ int mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, @@ -1281,7 +1276,7 @@ mlx5_ind_table_ibv_release(struct rte_eth_dev *dev, rte_free(ind_tbl); return 0; } - return EBUSY; + return 1; } /** @@ -1439,7 +1434,7 @@ mlx5_hrxq_get(struct rte_eth_dev *dev, uint8_t *rss_key, uint8_t rss_key_len, * Pointer to Hash Rx queue to release. * * @return - * 0 on success, errno value on failure. + * 1 while a reference on it exists, 0 when freed. */ int mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq) @@ -1454,7 +1449,7 @@ mlx5_hrxq_release(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq) return 0; } claim_nonzero(mlx5_ind_table_ibv_release(dev, hrxq->ind_table)); - return EBUSY; + return 1; } /** diff --git a/drivers/net/mlx5/mlx5_socket.c b/drivers/net/mlx5/mlx5_socket.c index d5071470f7..3b9574d8ae 100644 --- a/drivers/net/mlx5/mlx5_socket.c +++ b/drivers/net/mlx5/mlx5_socket.c @@ -79,11 +79,8 @@ mlx5_socket_init(struct rte_eth_dev *dev) * * @param[in] dev * Pointer to Ethernet device. - * - * @return - * 0 on success, errno value on failure. */ -int +void mlx5_socket_uninit(struct rte_eth_dev *dev) { struct priv *priv = dev->data->dev_private; @@ -92,7 +89,6 @@ mlx5_socket_uninit(struct rte_eth_dev *dev) claim_zero(close(priv->primary_socket)); priv->primary_socket = 0; claim_zero(remove(path)); - return 0; } /** diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 07226b8641..a3ccebdd66 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -363,17 +363,13 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device private data. - * - * @return - * 0 on success. */ -int +void mlx5_traffic_disable(struct rte_eth_dev *dev) { struct priv *priv = dev->data->dev_private; mlx5_flow_list_flush(dev, &priv->ctrl_flows); - return 0; } /** diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 81f2e81ca3..85f8da34b9 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -572,7 +572,7 @@ mlx5_txq_ibv_get(struct rte_eth_dev *dev, uint16_t idx) * Verbs Tx queue object. * * @return - * 0 on success, errno on failure. + * 1 while a reference on it exists, 0 when freed. */ int mlx5_txq_ibv_release(struct mlx5_txq_ibv *txq_ibv) @@ -587,7 +587,7 @@ mlx5_txq_ibv_release(struct mlx5_txq_ibv *txq_ibv) rte_free(txq_ibv); return 0; } - return EBUSY; + return 1; } /** @@ -826,7 +826,7 @@ mlx5_txq_get(struct rte_eth_dev *dev, uint16_t idx) * TX queue index. * * @return - * 0 on success, errno on failure. + * 1 while a reference on it exists, 0 when freed. */ int mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx) @@ -841,13 +841,8 @@ mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx) txq = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq); DEBUG("%p: Tx queue %p: refcnt %d", (void *)dev, (void *)txq, rte_atomic32_read(&txq->refcnt)); - if (txq->ibv) { - int ret; - - ret = mlx5_txq_ibv_release(txq->ibv); - if (!ret) - txq->ibv = NULL; - } + if (txq->ibv && !mlx5_txq_ibv_release(txq->ibv)) + txq->ibv = NULL; for (i = 0; i != MLX5_PMD_TX_MP_CACHE; ++i) { if (txq->txq.mp2mr[i]) { mlx5_mr_release(txq->txq.mp2mr[i]); @@ -864,7 +859,7 @@ mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx) (*priv->txqs)[idx] = NULL; return 0; } - return EBUSY; + return 1; } /** -- 2.12.0