From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 1D2A07CFA for ; Mon, 5 Mar 2018 13:21:46 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id q83so15442144wme.5 for ; Mon, 05 Mar 2018 04:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=kXm7zxcRvWIdkgg1jrSW+d8bK5nSmvQit+mf1R6BwXQ=; b=zWwX3LhuLP1e0q3KHKXQ/2PWYm9WK8cFfFnMXxpGnYFtq9xNQDlaGKDycgp8UqlILR t3TbS8vQUaIrZ/cPIaKEgRiTLbE5/Ax3/kqaJtVpSBpj1uLJQSdaoiq5BoWeZI9HusJr ZT/nJ9h4GehLMzO+evpV2TDIhZ3UIKUV1SWxHnP32G4SlBXF5mm2TamK3r8IhTNEhJUN kSNgPfhXHHk23Om5Rb/ywMvWCBc6NCorHVa43Ex/KWCwYPH0WHDU9CfvTuLRFifED4Vp l9Wb7n4GNFiQNgSGDjpDUrkQ7CZTO2FReExSp1T8Om1pb9PHPEdHO+BKAjoUDvWpuJZe tRjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=kXm7zxcRvWIdkgg1jrSW+d8bK5nSmvQit+mf1R6BwXQ=; b=cpTI5Eeu0e6EWIg1eFf8ZwYLYMed7gLQCXADWJ6NhyjAbL+nXIAHztNQ8F6Kc+bG0X BM376N5RPxmmipKwmL48Tp7BL5cgdF3ju1xG1GHFWIAQ5fwXtGR6LzFbH2X2cOeGqRXx YjTLVjGCfGybGBvPdv7QWyIsC93gMMLPaZpAv8WT8xsqKaIZIZROPd/0ZSfY24O7uQC+ zpEKJGa09fnMcXmiuhFjWGdmu/3OiKqIuM5wobzLqBjL5uNlMPE4eG2WsN75PtFdjLW2 dq48y+F+a3hX+tYUTw2hDdFcJNMNbc7TdcsDTVlzBqhQ7sD8HHrzqZCZ7LiXn+ZQ3uX1 oBVQ== X-Gm-Message-State: AElRT7Gjd9DJcu4LFM03+kHT+qCEVUcDcqG4sQPh54M5CnF6PaKA39pB hvjZCJ9TK1os0BjAS40ZnRurlA8GMQ== X-Google-Smtp-Source: AG47ELvzuGF+IcgQJwY7kt+1v/FCzRGJFv/O+d+C4rUHXGLNfERdxdiUy6Ypw6LiwftqBTY7kk3Pew== X-Received: by 10.28.166.206 with SMTP id p197mr7487885wme.81.1520252505448; Mon, 05 Mar 2018 04:21:45 -0800 (PST) Received: from laranjeiro-vm.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id w31sm13828232wrc.49.2018.03.05.04.21.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 04:21:44 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil , Yongseok Koh Date: Mon, 5 Mar 2018 13:21:05 +0100 Message-Id: <5e04823bca50a6b2924379377f4c331ff92cc62f.1520252354.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 09/10] net/mlx5: change non failing function return values X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Mar 2018 12:21:46 -0000 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 2cb463b62..86310404a 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 fe60dd132..5c4e68736 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 a3b08a1a3..8e7693df2 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 b8f610df3..8db25cff1 100644 --- a/drivers/net/mlx5/mlx5_socket.c +++ b/drivers/net/mlx5/mlx5_socket.c @@ -82,11 +82,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; @@ -95,7 +92,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 07226b864..a3ccebdd6 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 54ed972d7..a5e2c7fa7 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; } /** @@ -824,7 +824,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) @@ -839,13 +839,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]); @@ -862,7 +857,7 @@ mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx) (*priv->txqs)[idx] = NULL; return 0; } - return EBUSY; + return 1; } /** -- 2.11.0