From: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
To: dev@dpdk.org
Cc: Adrien Mazarguil <adrien.mazarguil@6wind.com>,
Yongseok Koh <yskoh@mellanox.com>
Subject: [dpdk-dev] [PATCH 2/3] net/mlx5: convert return errno to negative ones
Date: Thu, 15 Feb 2018 10:29:26 +0100 [thread overview]
Message-ID: <3c6d213784a58de85b30ff5053b0c35bcfd33b57.1518686930.git.nelio.laranjeiro@6wind.com> (raw)
In-Reply-To: <ad54d87cd39c1ad142fe9163c51317268e4b2b46.1518686930.git.nelio.laranjeiro@6wind.com>
In-Reply-To: <ad54d87cd39c1ad142fe9163c51317268e4b2b46.1518686930.git.nelio.laranjeiro@6wind.com>
Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
---
drivers/net/mlx5/mlx5.c | 19 ++++-----
drivers/net/mlx5/mlx5_ethdev.c | 30 ++++++++------
drivers/net/mlx5/mlx5_flow.c | 92 +++++++++++++++++++++--------------------
drivers/net/mlx5/mlx5_mac.c | 7 ++--
drivers/net/mlx5/mlx5_mr.c | 4 +-
| 16 +++----
drivers/net/mlx5/mlx5_rxq.c | 20 ++++-----
drivers/net/mlx5/mlx5_socket.c | 41 ++++++++++++------
drivers/net/mlx5/mlx5_trigger.c | 27 ++++++------
drivers/net/mlx5/mlx5_txq.c | 14 +++----
drivers/net/mlx5/mlx5_vlan.c | 2 +-
11 files changed, 145 insertions(+), 127 deletions(-)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index f52edf74f..d24f2a37c 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -413,7 +413,7 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
* Device arguments structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
@@ -446,7 +446,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
mlx5_args_check, config);
if (ret != 0) {
rte_kvargs_free(kvlist);
- return ret;
+ return -EINVAL;
}
}
}
@@ -472,7 +472,7 @@ static void *uar_base;
* Pointer to private structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_uar_init_primary(struct priv *priv)
@@ -480,7 +480,6 @@ priv_uar_init_primary(struct priv *priv)
void *addr = (void *)0;
int i;
const struct rte_mem_config *mcfg;
- int ret;
if (uar_base) { /* UAR address space mapped. */
priv->uar_base = uar_base;
@@ -502,8 +501,7 @@ priv_uar_init_primary(struct priv *priv)
if (addr == MAP_FAILED) {
ERROR("Failed to reserve UAR address space, please adjust "
"MLX5_UAR_SIZE or try --base-virtaddr");
- ret = ENOMEM;
- return ret;
+ return -ENOMEM;
}
/* Accept either same addr or a new addr returned from mmap if target
* range occupied.
@@ -522,13 +520,12 @@ priv_uar_init_primary(struct priv *priv)
* Pointer to private structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_uar_init_secondary(struct priv *priv)
{
void *addr;
- int ret;
assert(priv->uar_base);
if (uar_base) { /* already reserved. */
@@ -541,15 +538,13 @@ priv_uar_init_secondary(struct priv *priv)
if (addr == MAP_FAILED) {
ERROR("UAR mmap failed: %p size: %llu",
priv->uar_base, MLX5_UAR_SIZE);
- ret = ENXIO;
- return ret;
+ return -ENXIO;
}
if (priv->uar_base != addr) {
ERROR("UAR address %p size %llu occupied, please adjust "
"MLX5_UAR_OFFSET or try EAL parameter --base-virtaddr",
priv->uar_base, MLX5_UAR_SIZE);
- ret = ENXIO;
- return ret;
+ return -ENXIO;
}
uar_base = addr; /* process local, don't reserve again */
INFO("Reserved UAR address space: %p", addr);
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index b73cb53df..12d35dcf2 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -314,7 +314,7 @@ priv_set_flags(struct priv *priv, unsigned int keep, unsigned int flags)
* Pointer to Ethernet device structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
dev_configure(struct rte_eth_dev *dev)
@@ -338,26 +338,26 @@ dev_configure(struct rte_eth_dev *dev)
ERROR("Some Tx offloads are not supported "
"requested 0x%" PRIx64 " supported 0x%" PRIx64,
tx_offloads, supp_tx_offloads);
- return ENOTSUP;
+ return -ENOTSUP;
}
if ((rx_offloads & supp_rx_offloads) != rx_offloads) {
ERROR("Some Rx offloads are not supported "
"requested 0x%" PRIx64 " supported 0x%" PRIx64,
rx_offloads, supp_rx_offloads);
- return ENOTSUP;
+ return -ENOTSUP;
}
if (use_app_rss_key &&
(dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
rss_hash_default_key_len)) {
/* MLX5 RSS only support 40bytes key. */
- return EINVAL;
+ return -EINVAL;
}
priv->rss_conf.rss_key =
rte_realloc(priv->rss_conf.rss_key,
rss_hash_default_key_len, 0);
if (!priv->rss_conf.rss_key) {
ERROR("cannot allocate RSS hash key memory (%u)", rxqs_n);
- return ENOMEM;
+ return -ENOMEM;
}
memcpy(priv->rss_conf.rss_key,
use_app_rss_key ?
@@ -375,7 +375,7 @@ dev_configure(struct rte_eth_dev *dev)
}
if (rxqs_n > priv->config.ind_table_max_size) {
ERROR("cannot handle this many RX queues (%u)", rxqs_n);
- return EINVAL;
+ return -EINVAL;
}
if (rxqs_n == priv->rxqs_n)
return 0;
@@ -389,7 +389,7 @@ dev_configure(struct rte_eth_dev *dev)
priv->config.ind_table_max_size :
rxqs_n));
if (priv_rss_reta_index_resize(priv, reta_idx_n))
- return ENOMEM;
+ return -ENOMEM;
/* When the number of RX queues is not a power of two, the remaining
* table entries are padded with reused WQs and hashes are not spread
* uniformly. */
@@ -420,7 +420,7 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
ret = dev_configure(dev);
assert(ret >= 0);
priv_unlock(priv);
- return -ret;
+ return ret;
}
/**
@@ -1199,7 +1199,7 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev)
* Nonzero for link up, otherwise link down.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, -1 on error and errno is set.
*/
static int
priv_dev_set_link(struct priv *priv, int up)
@@ -1214,7 +1214,7 @@ priv_dev_set_link(struct priv *priv, int up)
* Pointer to Ethernet device structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
mlx5_set_link_down(struct rte_eth_dev *dev)
@@ -1225,7 +1225,9 @@ mlx5_set_link_down(struct rte_eth_dev *dev)
priv_lock(priv);
err = priv_dev_set_link(priv, 0);
priv_unlock(priv);
- return err;
+ if (err == -1)
+ return errno;
+ return 0;
}
/**
@@ -1235,7 +1237,7 @@ mlx5_set_link_down(struct rte_eth_dev *dev)
* Pointer to Ethernet device structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
mlx5_set_link_up(struct rte_eth_dev *dev)
@@ -1246,7 +1248,9 @@ mlx5_set_link_up(struct rte_eth_dev *dev)
priv_lock(priv);
err = priv_dev_set_link(priv, 1);
priv_unlock(priv);
- return err;
+ if (err == -1)
+ return errno;
+ return 0;
}
/**
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 26002c4b9..2a595442e 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -460,7 +460,7 @@ struct ibv_spec_header {
* Bit-Mask size in bytes.
*
* @return
- * 0 on success.
+ * 0 on success, -1 on error.
*/
static int
mlx5_flow_item_validate(const struct rte_flow_item *item,
@@ -523,7 +523,7 @@ mlx5_flow_item_validate(const struct rte_flow_item *item,
* User RSS configuration to save.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_flow_convert_rss_conf(struct priv *priv,
@@ -538,9 +538,9 @@ priv_flow_convert_rss_conf(struct priv *priv,
(void)priv;
if (rss_conf) {
if (rss_conf->rss_hf & MLX5_RSS_HF_MASK)
- return EINVAL;
+ return -EINVAL;
if (rss_conf->rss_key_len != 40)
- return EINVAL;
+ return -EINVAL;
if (rss_conf->rss_key_len && rss_conf->rss_key) {
parser->rss_conf.rss_key_len = rss_conf->rss_key_len;
memcpy(parser->rss_key, rss_conf->rss_key,
@@ -1068,7 +1068,7 @@ priv_flow_convert(struct priv *priv,
priv_flow_convert_allocate(priv, priority,
offset, error);
if (!parser->queue[HASH_RXQ_ETH].ibv_attr)
- return ENOMEM;
+ return -ENOMEM;
parser->queue[HASH_RXQ_ETH].offset =
sizeof(struct ibv_flow_attr);
} else {
@@ -1103,7 +1103,7 @@ priv_flow_convert(struct priv *priv,
cur_item->mask),
parser);
if (ret) {
- rte_flow_error_set(error, ret,
+ rte_flow_error_set(error, -ret,
RTE_FLOW_ERROR_TYPE_ITEM,
items, "item not supported");
goto exit_free;
@@ -1147,11 +1147,11 @@ priv_flow_convert(struct priv *priv,
}
rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
NULL, "cannot allocate verbs spec attributes.");
- return ret;
+ return -rte_errno;
exit_count_error:
rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
NULL, "cannot create counter.");
- return rte_errno;
+ return -rte_errno;
}
/**
@@ -1502,6 +1502,9 @@ mlx5_flow_create_tcp(const struct rte_flow_item *item,
* Default bit-masks to use when item->mask is not provided.
* @param data[in, out]
* User structure.
+ *
+ * @return
+ * 0 on success, negative errno value on failure.
*/
static int
mlx5_flow_create_vxlan(const struct rte_flow_item *item,
@@ -1542,7 +1545,7 @@ mlx5_flow_create_vxlan(const struct rte_flow_item *item,
* To avoid such situation, VNI 0 is currently refused.
*/
if (!vxlan.val.tunnel_id)
- return EINVAL;
+ return -EINVAL;
mlx5_flow_create_copy(parser, &vxlan, size);
return 0;
}
@@ -1579,7 +1582,7 @@ mlx5_flow_create_flag_mark(struct mlx5_flow_parse *parser, uint32_t mark_id)
* Pointer to MLX5 flow parser structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
mlx5_flow_create_count(struct priv *priv __rte_unused,
@@ -1597,7 +1600,7 @@ mlx5_flow_create_count(struct priv *priv __rte_unused,
init_attr.counter_set_id = 0;
parser->cs = mlx5_glue->create_counter_set(priv->ctx, &init_attr);
if (!parser->cs)
- return EINVAL;
+ return -EINVAL;
counter.counter_set_handle = parser->cs->handle;
mlx5_flow_create_copy(parser, &counter, size);
#endif
@@ -1617,7 +1620,7 @@ mlx5_flow_create_count(struct priv *priv __rte_unused,
* Perform verbose error reporting if not NULL.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_flow_create_action_queue_drop(struct priv *priv,
@@ -1653,7 +1656,7 @@ priv_flow_create_action_queue_drop(struct priv *priv,
if (!flow->frxq[HASH_RXQ_ETH].ibv_flow) {
rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
NULL, "flow rule creation failure");
- err = ENOMEM;
+ err = -ENOMEM;
goto error;
}
return 0;
@@ -1689,7 +1692,7 @@ priv_flow_create_action_queue_drop(struct priv *priv,
* Perform verbose error reporting if not NULL.
*
* @return
- * 0 on success, a errno value otherwise and rte_errno is set.
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
*/
static int
priv_flow_create_action_queue_rss(struct priv *priv,
@@ -1729,7 +1732,7 @@ priv_flow_create_action_queue_rss(struct priv *priv,
rte_flow_error_set(error, ENOMEM,
RTE_FLOW_ERROR_TYPE_HANDLE,
NULL, "cannot create hash rxq");
- return ENOMEM;
+ return -ENOMEM;
}
}
return 0;
@@ -1748,7 +1751,7 @@ priv_flow_create_action_queue_rss(struct priv *priv,
* Perform verbose error reporting if not NULL.
*
* @return
- * 0 on success, a errno value otherwise and rte_errno is set.
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
*/
static int
priv_flow_create_action_queue(struct priv *priv,
@@ -1779,7 +1782,7 @@ priv_flow_create_action_queue(struct priv *priv,
rte_flow_error_set(error, ENOMEM,
RTE_FLOW_ERROR_TYPE_HANDLE,
NULL, "flow rule creation failure");
- err = ENOMEM;
+ err = -ENOMEM;
goto error;
}
DEBUG("%p type %d QP %p ibv_flow %p",
@@ -2038,7 +2041,7 @@ priv_flow_flush(struct priv *priv, struct mlx5_flows *list)
* Pointer to private structure.
*
* @return
- * 0 on success.
+ * 0 on success, negative errno on error.
*/
int
priv_flow_create_drop_queue(struct priv *priv)
@@ -2117,7 +2120,7 @@ priv_flow_create_drop_queue(struct priv *priv)
if (fdq)
rte_free(fdq);
priv->flow_drop_queue = NULL;
- return -1;
+ return -ENOMEM;
}
/**
@@ -2214,7 +2217,7 @@ priv_flow_stop(struct priv *priv, struct mlx5_flows *list)
* Pointer to a TAILQ flow list.
*
* @return
- * 0 on success, a errno value otherwise and rte_errno is set.
+ * 0 on success, negative errno value otherwise and rte_errno is set.
*/
int
priv_flow_start(struct priv *priv, struct mlx5_flows *list)
@@ -2233,7 +2236,7 @@ priv_flow_start(struct priv *priv, struct mlx5_flows *list)
DEBUG("Flow %p cannot be applied",
(void *)flow);
rte_errno = EINVAL;
- return rte_errno;
+ return -rte_errno;
}
DEBUG("Flow %p applied", (void *)flow);
/* Next flow. */
@@ -2260,7 +2263,7 @@ priv_flow_start(struct priv *priv, struct mlx5_flows *list)
DEBUG("Flow %p cannot be applied",
(void *)flow);
rte_errno = EINVAL;
- return rte_errno;
+ return -rte_errno;
}
flow_create:
flow->frxq[i].ibv_flow =
@@ -2270,7 +2273,7 @@ priv_flow_start(struct priv *priv, struct mlx5_flows *list)
DEBUG("Flow %p cannot be applied",
(void *)flow);
rte_errno = EINVAL;
- return rte_errno;
+ return -rte_errno;
}
DEBUG("Flow %p applied", (void *)flow);
}
@@ -2319,7 +2322,7 @@ priv_flow_verify(struct priv *priv)
* A VLAN flow mask to apply.
*
* @return
- * 0 on success.
+ * 0 on success, negative errno on error.
*/
int
mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev,
@@ -2372,7 +2375,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev,
} action_rss;
if (!priv->reta_idx_n)
- return EINVAL;
+ return -EINVAL;
for (i = 0; i != priv->reta_idx_n; ++i)
action_rss.local.queue[i] = (*priv->reta_idx)[i];
action_rss.local.rss_conf = &priv->rss_conf;
@@ -2381,7 +2384,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev,
flow = priv_flow_create(priv, &priv->ctrl_flows, &attr, items, actions,
&error);
if (!flow)
- return rte_errno;
+ return -rte_errno;
return 0;
}
@@ -2396,7 +2399,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev,
* An Ethernet flow mask to apply.
*
* @return
- * 0 on success.
+ * 0 on success, negative errno on error.
*/
int
mlx5_ctrl_flow(struct rte_eth_dev *dev,
@@ -2455,7 +2458,7 @@ mlx5_flow_flush(struct rte_eth_dev *dev,
* returned data from the counter.
*
* @return
- * 0 on success, a errno value otherwise and rte_errno is set.
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
*/
static int
priv_flow_query_count(struct ibv_counter_set *cs,
@@ -2567,7 +2570,7 @@ mlx5_flow_isolate(struct rte_eth_dev *dev,
* Generic flow parameters structure.
*
* @return
- * 0 on success, errno value on error.
+ * 0 on success, negative errno value on error.
*/
static int
priv_fdir_filter_convert(struct priv *priv,
@@ -2579,7 +2582,7 @@ priv_fdir_filter_convert(struct priv *priv,
/* Validate queue number. */
if (fdir_filter->action.rx_queue >= priv->rxqs_n) {
ERROR("invalid queue number %d", fdir_filter->action.rx_queue);
- return EINVAL;
+ return -EINVAL;
}
attributes->attr.ingress = 1;
attributes->items[0] = (struct rte_flow_item) {
@@ -2601,7 +2604,7 @@ priv_fdir_filter_convert(struct priv *priv,
break;
default:
ERROR("invalid behavior %d", fdir_filter->action.behavior);
- return ENOTSUP;
+ return -ENOTSUP;
}
attributes->queue.index = fdir_filter->action.rx_queue;
switch (fdir_filter->input.flow_type) {
@@ -2737,7 +2740,7 @@ priv_fdir_filter_convert(struct priv *priv,
default:
ERROR("invalid flow type%d",
fdir_filter->input.flow_type);
- return ENOTSUP;
+ return -ENOTSUP;
}
return 0;
}
@@ -2751,7 +2754,7 @@ priv_fdir_filter_convert(struct priv *priv,
* Flow director filter to add.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_fdir_filter_add(struct priv *priv,
@@ -2774,11 +2777,11 @@ priv_fdir_filter_add(struct priv *priv,
ret = priv_fdir_filter_convert(priv, fdir_filter, &attributes);
if (ret)
- return -ret;
+ return ret;
ret = priv_flow_convert(priv, &attributes.attr, attributes.items,
attributes.actions, &error, &parser);
if (ret)
- return -ret;
+ return ret;
flow = priv_flow_create(priv,
&priv->flows,
&attributes.attr,
@@ -2789,7 +2792,7 @@ priv_fdir_filter_add(struct priv *priv,
DEBUG("FDIR created %p", (void *)flow);
return 0;
}
- return ENOTSUP;
+ return -ENOTSUP;
}
/**
@@ -2801,7 +2804,7 @@ priv_fdir_filter_add(struct priv *priv,
* Filter to be deleted.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_fdir_filter_delete(struct priv *priv,
@@ -2821,7 +2824,7 @@ priv_fdir_filter_delete(struct priv *priv,
ret = priv_fdir_filter_convert(priv, fdir_filter, &attributes);
if (ret)
- return -ret;
+ return ret;
ret = priv_flow_convert(priv, &attributes.attr, attributes.items,
attributes.actions, &error, &parser);
if (ret)
@@ -2886,7 +2889,7 @@ priv_fdir_filter_delete(struct priv *priv,
if (parser.queue[i].ibv_attr)
rte_free(parser.queue[i].ibv_attr);
}
- return -ret;
+ return ret;
}
/**
@@ -2898,7 +2901,7 @@ priv_fdir_filter_delete(struct priv *priv,
* Filter to be updated.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_fdir_filter_update(struct priv *priv,
@@ -2961,7 +2964,7 @@ priv_fdir_info_get(struct priv *priv, struct rte_eth_fdir_info *fdir_info)
* Pointer to operation-specific structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_fdir_ctrl_func(struct priv *priv, enum rte_filter_op filter_op, void *arg)
@@ -2976,7 +2979,7 @@ priv_fdir_ctrl_func(struct priv *priv, enum rte_filter_op filter_op, void *arg)
fdir_mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
ERROR("%p: flow director mode %d not supported",
(void *)priv, fdir_mode);
- return EINVAL;
+ return -EINVAL;
}
switch (filter_op) {
case RTE_ETH_FILTER_ADD:
@@ -2997,7 +3000,7 @@ priv_fdir_ctrl_func(struct priv *priv, enum rte_filter_op filter_op, void *arg)
default:
DEBUG("%p: unknown operation %u", (void *)priv,
filter_op);
- ret = EINVAL;
+ ret = -EINVAL;
break;
}
return ret;
@@ -3039,9 +3042,10 @@ mlx5_dev_filter_ctrl(struct rte_eth_dev *dev,
priv_unlock(priv);
break;
default:
+ ret = -ENOTSUP;
ERROR("%p: filter type (%d) not supported",
(void *)dev, filter_type);
break;
}
- return -ret;
+ return ret;
}
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index e8a8d4594..afd525010 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -84,14 +84,13 @@ mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
* VMDq pool index to associate address with (ignored).
*
* @return
- * 0 on success.
+ * 0 on success, negative errno on error.
*/
int
mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
uint32_t index, uint32_t vmdq)
{
unsigned int i;
- int ret = 0;
(void)vmdq;
assert(index < MLX5_MAX_MAC_ADDRESSES);
@@ -103,12 +102,12 @@ mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
if (memcmp(&dev->data->mac_addrs[i], mac, sizeof(*mac)))
continue;
/* Address already configured elsewhere, return with error. */
- return EADDRINUSE;
+ return -EADDRINUSE;
}
dev->data->mac_addrs[index] = *mac;
if (!dev->data->promiscuous)
mlx5_traffic_restart(dev);
- return ret;
+ return 0;
}
/**
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 857dfcd83..ef267403b 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -333,7 +333,7 @@ priv_mr_get(struct priv *priv, struct rte_mempool *mp)
* Pointer to memory region to release.
*
* @return
- * 0 on success, errno on failure.
+ * 0 on success, negative errno on failure.
*/
int
priv_mr_release(struct priv *priv, struct mlx5_mr *mr)
@@ -348,7 +348,7 @@ priv_mr_release(struct priv *priv, struct mlx5_mr *mr)
rte_free(mr);
return 0;
}
- return EBUSY;
+ return -EBUSY;
}
/**
--git a/drivers/net/mlx5/mlx5_rss.c b/drivers/net/mlx5/mlx5_rss.c
index d06b0bee1..9975cb049 100644
--- a/drivers/net/mlx5/mlx5_rss.c
+++ b/drivers/net/mlx5/mlx5_rss.c
@@ -106,7 +106,7 @@ mlx5_rss_hash_conf_get(struct rte_eth_dev *dev,
* The size of the array to allocate.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
priv_rss_reta_index_resize(struct priv *priv, unsigned int reta_size)
@@ -120,7 +120,7 @@ priv_rss_reta_index_resize(struct priv *priv, unsigned int reta_size)
mem = rte_realloc(priv->reta_idx,
reta_size * sizeof((*priv->reta_idx)[0]), 0);
if (!mem)
- return ENOMEM;
+ return -ENOMEM;
priv->reta_idx = mem;
priv->reta_idx_n = reta_size;
@@ -142,7 +142,7 @@ priv_rss_reta_index_resize(struct priv *priv, unsigned int reta_size)
* Number of entries.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_dev_rss_reta_query(struct priv *priv,
@@ -153,7 +153,7 @@ priv_dev_rss_reta_query(struct priv *priv,
unsigned int i;
if (!reta_size || reta_size > priv->reta_idx_n)
- return EINVAL;
+ return -EINVAL;
/* Fill each entry of the table even if its bit is not set. */
for (idx = 0, i = 0; (i != reta_size); ++i) {
idx = i / RTE_RETA_GROUP_SIZE;
@@ -174,7 +174,7 @@ priv_dev_rss_reta_query(struct priv *priv,
* Number of entries.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
static int
priv_dev_rss_reta_update(struct priv *priv,
@@ -187,7 +187,7 @@ priv_dev_rss_reta_update(struct priv *priv,
int ret;
if (!reta_size)
- return EINVAL;
+ return -EINVAL;
ret = priv_rss_reta_index_resize(priv, reta_size);
if (ret)
return ret;
@@ -227,7 +227,7 @@ mlx5_dev_rss_reta_query(struct rte_eth_dev *dev,
priv_lock(priv);
ret = priv_dev_rss_reta_query(priv, reta_conf, reta_size);
priv_unlock(priv);
- return -ret;
+ return ret;
}
/**
@@ -258,5 +258,5 @@ mlx5_dev_rss_reta_update(struct rte_eth_dev *dev,
mlx5_dev_stop(dev);
mlx5_dev_start(dev);
}
- return -ret;
+ return ret;
}
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 238fa7e56..5be0390e4 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -61,7 +61,7 @@ const size_t rss_hash_default_key_len = sizeof(rss_hash_default_key);
* Pointer to RX queue structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl)
@@ -131,7 +131,7 @@ rxq_alloc_elts(struct mlx5_rxq_ctrl *rxq_ctrl)
}
DEBUG("%p: failed, freed everything", (void *)rxq_ctrl);
assert(ret > 0);
- return ret;
+ return -ret;
}
/**
@@ -849,7 +849,7 @@ mlx5_priv_rxq_ibv_get(struct priv *priv, uint16_t idx)
* Verbs Rx queue object.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
mlx5_priv_rxq_ibv_release(struct priv *priv, struct mlx5_rxq_ibv *rxq_ibv)
@@ -876,7 +876,7 @@ mlx5_priv_rxq_ibv_release(struct priv *priv, struct mlx5_rxq_ibv *rxq_ibv)
rte_free(rxq_ibv);
return 0;
}
- return EBUSY;
+ return -EBUSY;
}
/**
@@ -1084,7 +1084,7 @@ mlx5_priv_rxq_get(struct priv *priv, uint16_t idx)
* TX queue index.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
mlx5_priv_rxq_release(struct priv *priv, uint16_t idx)
@@ -1110,7 +1110,7 @@ mlx5_priv_rxq_release(struct priv *priv, uint16_t idx)
(*priv->rxqs)[idx] = NULL;
return 0;
}
- return EBUSY;
+ return -EBUSY;
}
/**
@@ -1266,7 +1266,7 @@ mlx5_priv_ind_table_ibv_get(struct priv *priv, uint16_t queues[],
* Indirection table to release.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
mlx5_priv_ind_table_ibv_release(struct priv *priv,
@@ -1286,7 +1286,7 @@ mlx5_priv_ind_table_ibv_release(struct priv *priv,
rte_free(ind_tbl);
return 0;
}
- return EBUSY;
+ return -EBUSY;
}
/**
@@ -1440,7 +1440,7 @@ mlx5_priv_hrxq_get(struct priv *priv, uint8_t *rss_key, uint8_t rss_key_len,
* Pointer to Hash Rx queue to release.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
mlx5_priv_hrxq_release(struct priv *priv, struct mlx5_hrxq *hrxq)
@@ -1455,7 +1455,7 @@ mlx5_priv_hrxq_release(struct priv *priv, struct mlx5_hrxq *hrxq)
return 0;
}
claim_nonzero(mlx5_priv_ind_table_ibv_release(priv, hrxq->ind_table));
- return EBUSY;
+ return -EBUSY;
}
/**
diff --git a/drivers/net/mlx5/mlx5_socket.c b/drivers/net/mlx5/mlx5_socket.c
index 61c1a4a50..e6d2c98b3 100644
--- a/drivers/net/mlx5/mlx5_socket.c
+++ b/drivers/net/mlx5/mlx5_socket.c
@@ -22,7 +22,7 @@
* Pointer to private structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
priv_socket_init(struct priv *priv)
@@ -40,40 +40,49 @@ priv_socket_init(struct priv *priv)
*/
ret = socket(AF_UNIX, SOCK_STREAM, 0);
if (ret < 0) {
+ ret = errno;
WARN("secondary process not supported: %s", strerror(errno));
- return ret;
+ return -ret;
}
priv->primary_socket = ret;
flags = fcntl(priv->primary_socket, F_GETFL, 0);
- if (flags == -1)
+ if (flags == -1) {
+ ret = errno;
goto out;
+ }
ret = fcntl(priv->primary_socket, F_SETFL, flags | O_NONBLOCK);
- if (ret < 0)
+ if (ret < 0) {
+ ret = errno;
goto out;
+ }
snprintf(sun.sun_path, sizeof(sun.sun_path), "/var/tmp/%s_%d",
MLX5_DRIVER_NAME, priv->primary_socket);
ret = stat(sun.sun_path, &file_stat);
- if (!ret)
+ if (!ret) {
+ ret = errno;
claim_zero(remove(sun.sun_path));
+ }
ret = bind(priv->primary_socket, (const struct sockaddr *)&sun,
sizeof(sun));
if (ret < 0) {
+ ret = errno;
WARN("cannot bind socket, secondary process not supported: %s",
strerror(errno));
goto close;
}
ret = listen(priv->primary_socket, 0);
if (ret < 0) {
+ ret = errno;
WARN("Secondary process not supported: %s", strerror(errno));
goto close;
}
- return ret;
+ return 0;
close:
remove(sun.sun_path);
out:
claim_zero(close(priv->primary_socket));
priv->primary_socket = 0;
- return -(ret);
+ return -ret;
}
/**
@@ -83,7 +92,7 @@ priv_socket_init(struct priv *priv)
* Pointer to private structure.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
priv_socket_uninit(struct priv *priv)
@@ -191,7 +200,7 @@ priv_socket_connect(struct priv *priv)
struct sockaddr_un sun = {
.sun_family = AF_UNIX,
};
- int socket_fd;
+ int socket_fd = -1;
int *fd = NULL;
int ret;
struct ucred *cred;
@@ -211,19 +220,22 @@ priv_socket_connect(struct priv *priv)
ret = socket(AF_UNIX, SOCK_STREAM, 0);
if (ret < 0) {
+ ret = errno;
WARN("cannot connect to primary");
- return ret;
+ goto out;
}
socket_fd = ret;
snprintf(sun.sun_path, sizeof(sun.sun_path), "/var/tmp/%s_%d",
MLX5_DRIVER_NAME, priv->primary_socket);
ret = connect(socket_fd, (const struct sockaddr *)&sun, sizeof(sun));
if (ret < 0) {
+ ret = errno;
WARN("cannot connect to primary");
goto out;
}
cmsg = CMSG_FIRSTHDR(&msg);
if (cmsg == NULL) {
+ ret = EINVAL;
DEBUG("cannot get first message");
goto out;
}
@@ -232,6 +244,7 @@ priv_socket_connect(struct priv *priv)
cmsg->cmsg_len = CMSG_LEN(sizeof(*cred));
cred = (struct ucred *)CMSG_DATA(cmsg);
if (cred == NULL) {
+ ret = EINVAL;
DEBUG("no credentials received");
goto out;
}
@@ -240,17 +253,20 @@ priv_socket_connect(struct priv *priv)
cred->gid = getgid();
ret = sendmsg(socket_fd, &msg, MSG_DONTWAIT);
if (ret < 0) {
+ ret = errno;
WARN("cannot send credentials to primary: %s",
strerror(errno));
goto out;
}
ret = recvmsg(socket_fd, &msg, MSG_WAITALL);
if (ret <= 0) {
+ ret = errno;
WARN("no message from primary: %s", strerror(errno));
goto out;
}
cmsg = CMSG_FIRSTHDR(&msg);
if (cmsg == NULL) {
+ ret = EINVAL;
WARN("No file descriptor received");
goto out;
}
@@ -262,6 +278,7 @@ priv_socket_connect(struct priv *priv)
}
ret = *fd;
out:
- close(socket_fd);
- return ret;
+ if (socket_fd > 0)
+ close(socket_fd);
+ return -ret;
}
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index a70b13d52..2918ba0e9 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -36,7 +36,7 @@ priv_txq_stop(struct priv *priv)
* Pointer to private structure.
*
* @return
- * 0 on success, errno on error.
+ * 0 on success, negative errno on error.
*/
static int
priv_txq_start(struct priv *priv)
@@ -60,12 +60,12 @@ priv_txq_start(struct priv *priv)
txq_alloc_elts(txq_ctrl);
txq_ctrl->ibv = mlx5_priv_txq_ibv_new(priv, i);
if (!txq_ctrl->ibv) {
- ret = ENOMEM;
+ ret = -ENOMEM;
goto error;
}
}
ret = priv_tx_uar_remap(priv, priv->ctx->cmd_fd);
- if (ret)
+ if (!ret)
goto error;
return ret;
error:
@@ -95,7 +95,7 @@ priv_rxq_stop(struct priv *priv)
* Pointer to private structure.
*
* @return
- * 0 on success, errno on error.
+ * 0 on success, negative errno on error.
*/
static int
priv_rxq_start(struct priv *priv)
@@ -113,14 +113,14 @@ priv_rxq_start(struct priv *priv)
goto error;
rxq_ctrl->ibv = mlx5_priv_rxq_ibv_new(priv, i);
if (!rxq_ctrl->ibv) {
- ret = ENOMEM;
+ ret = -ENOMEM;
goto error;
}
}
- return -ret;
+ return ret;
error:
priv_rxq_stop(priv);
- return -ret;
+ return ret;
}
/**
@@ -239,7 +239,7 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
* Pointer to Ethernet device structure.
*
* @return
- * 0 on success.
+ * 0 on success, negative errno on error.
*/
int
priv_dev_traffic_enable(struct priv *priv, struct rte_eth_dev *dev)
@@ -354,7 +354,7 @@ priv_dev_traffic_enable(struct priv *priv, struct rte_eth_dev *dev)
}
return 0;
error:
- return rte_errno;
+ return -rte_errno;
}
@@ -386,7 +386,7 @@ priv_dev_traffic_disable(struct priv *priv, struct rte_eth_dev *dev)
* Pointer to Ethernet device structure.
*
* @return
- * 0 on success.
+ * 0 on success, negative errno on error.
*/
int
priv_dev_traffic_restart(struct priv *priv, struct rte_eth_dev *dev)
@@ -405,15 +405,16 @@ priv_dev_traffic_restart(struct priv *priv, struct rte_eth_dev *dev)
* Pointer to Ethernet device structure.
*
* @return
- * 0 on success.
+ * 0 on success, negative errno on error.
*/
int
mlx5_traffic_restart(struct rte_eth_dev *dev)
{
struct priv *priv = dev->data->dev_private;
+ int ret;
priv_lock(priv);
- priv_dev_traffic_restart(priv, dev);
+ ret = priv_dev_traffic_restart(priv, dev);
priv_unlock(priv);
- return 0;
+ return ret;
}
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index ed1c713ea..158394168 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -271,7 +271,7 @@ mlx5_tx_queue_release(void *dpdk_txq)
* Verbs file descriptor to map UAR pages.
*
* @return
- * 0 on success, errno value on failure.
+ * 0 on success, negative errno value on failure.
*/
int
priv_tx_uar_remap(struct priv *priv, int fd)
@@ -287,7 +287,6 @@ priv_tx_uar_remap(struct priv *priv, int fd)
struct mlx5_txq_ctrl *txq_ctrl;
int already_mapped;
size_t page_size = sysconf(_SC_PAGESIZE);
- int r;
memset(pages, 0, priv->txqs_n * sizeof(uintptr_t));
/*
@@ -326,8 +325,7 @@ priv_tx_uar_remap(struct priv *priv, int fd)
/* fixed mmap have to return same address */
ERROR("call to mmap failed on UAR for txq %d\n",
i);
- r = ENXIO;
- return r;
+ return -ENXIO;
}
}
if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* save once */
@@ -575,7 +573,7 @@ mlx5_priv_txq_ibv_get(struct priv *priv, uint16_t idx)
* Verbs Tx queue object.
*
* @return
- * 0 on success, errno on failure.
+ * 0 on success, negative errno on failure.
*/
int
mlx5_priv_txq_ibv_release(struct priv *priv, struct mlx5_txq_ibv *txq_ibv)
@@ -591,7 +589,7 @@ mlx5_priv_txq_ibv_release(struct priv *priv, struct mlx5_txq_ibv *txq_ibv)
rte_free(txq_ibv);
return 0;
}
- return EBUSY;
+ return -EBUSY;
}
/**
@@ -830,7 +828,7 @@ mlx5_priv_txq_get(struct priv *priv, uint16_t idx)
* TX queue index.
*
* @return
- * 0 on success, errno on failure.
+ * 0 on success, negative errno on failure.
*/
int
mlx5_priv_txq_release(struct priv *priv, uint16_t idx)
@@ -867,7 +865,7 @@ mlx5_priv_txq_release(struct priv *priv, uint16_t idx)
(*priv->txqs)[idx] = NULL;
return 0;
}
- return EBUSY;
+ return -EBUSY;
}
/**
diff --git a/drivers/net/mlx5/mlx5_vlan.c b/drivers/net/mlx5/mlx5_vlan.c
index 75c345626..2356bc0bb 100644
--- a/drivers/net/mlx5/mlx5_vlan.c
+++ b/drivers/net/mlx5/mlx5_vlan.c
@@ -80,7 +80,7 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
++priv->vlan_filter_n;
}
if (dev->data->dev_started)
- priv_dev_traffic_restart(priv, dev);
+ ret = priv_dev_traffic_restart(priv, dev);
out:
priv_unlock(priv);
return ret;
--
2.11.0
next prev parent reply other threads:[~2018-02-15 9:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-15 9:29 [dpdk-dev] [PATCH 1/3] net/mlx5: add missing function documentation Nelio Laranjeiro
2018-02-15 9:29 ` Nelio Laranjeiro [this message]
2018-02-16 14:26 ` [dpdk-dev] [PATCH 2/3] net/mlx5: convert return errno to negative ones Adrien Mazarguil
2018-02-15 9:29 ` [dpdk-dev] [PATCH 3/3] net/mlx5: fix traffic restart function to return errors Nelio Laranjeiro
2018-02-16 14:26 ` Adrien Mazarguil
2018-02-16 14:26 ` [dpdk-dev] [PATCH 1/3] net/mlx5: add missing function documentation Adrien Mazarguil
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 00/10] net/mlx5: clean driver Nelio Laranjeiro
2018-03-05 12:20 ` [dpdk-dev] [PATCH v3 " Nelio Laranjeiro
2018-03-18 6:33 ` Shahaf Shuler
2018-03-21 17:34 ` Ferruh Yigit
2018-03-05 12:20 ` [dpdk-dev] [PATCH v3 01/10] net/mlx5: fix sriov flag Nelio Laranjeiro
2018-03-05 12:20 ` [dpdk-dev] [PATCH v3 02/10] net/mlx5: name parameters in function prototypes Nelio Laranjeiro
2018-03-05 12:20 ` [dpdk-dev] [PATCH v3 03/10] net/mlx5: mark parameters with unused attribute Nelio Laranjeiro
2018-03-05 12:21 ` [dpdk-dev] [PATCH v3 04/10] net/mlx5: normalize function prototypes Nelio Laranjeiro
2018-03-05 12:21 ` [dpdk-dev] [PATCH v3 05/10] net/mlx5: add missing function documentation Nelio Laranjeiro
2018-03-05 12:21 ` [dpdk-dev] [PATCH v3 06/10] net/mlx5: remove useless empty lines Nelio Laranjeiro
2018-03-05 12:21 ` [dpdk-dev] [PATCH v3 07/10] net/mlx5: remove control path locks Nelio Laranjeiro
2018-03-05 12:21 ` [dpdk-dev] [PATCH v3 08/10] net/mlx5: prefix all function with mlx5 Nelio Laranjeiro
2018-03-05 12:21 ` [dpdk-dev] [PATCH v3 09/10] net/mlx5: change non failing function return values Nelio Laranjeiro
2018-03-05 12:21 ` [dpdk-dev] [PATCH v3 10/10] net/mlx5: standardize on negative errno values Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 01/10] net/mlx5: fix sriov flag Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 02/10] net/mlx5: name parameters in function prototypes Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 03/10] net/mlx5: mark parameters with unused attribute Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 04/10] net/mlx5: normalize function prototypes Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 05/10] net/mlx5: add missing function documentation Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 06/10] net/mlx5: remove useless empty lines Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 07/10] net/mlx5: remove control path locks Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 08/10] net/mlx5: prefix all function with mlx5 Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 09/10] net/mlx5: change non failing function return values Nelio Laranjeiro
2018-02-28 15:12 ` [dpdk-dev] [PATCH v2 10/10] net/mlx5: standardize on negative errno values Nelio Laranjeiro
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=3c6d213784a58de85b30ff5053b0c35bcfd33b57.1518686930.git.nelio.laranjeiro@6wind.com \
--to=nelio.laranjeiro@6wind.com \
--cc=adrien.mazarguil@6wind.com \
--cc=dev@dpdk.org \
--cc=yskoh@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).