From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: dev@dpdk.org, Yongseok Koh <yskoh@mellanox.com>
Subject: Re: [dpdk-dev] [PATCH 2/3] net/mlx5: convert return errno to negative ones
Date: Fri, 16 Feb 2018 15:26:42 +0100 [thread overview]
Message-ID: <20180216142642.GF4256@6wind.com> (raw)
In-Reply-To: <3c6d213784a58de85b30ff5053b0c35bcfd33b57.1518686930.git.nelio.laranjeiro@6wind.com>
How about reusing the title/commit log of its mlx4 counterpart:
net/mlx5: standardize on negative errno values
(see 9d14b27308a0 "net/mlx4: standardize on negative errno values")
More below.
On Thu, Feb 15, 2018 at 10:29:26AM +0100, Nelio Laranjeiro wrote:
> 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 +-
> drivers/net/mlx5/mlx5_rss.c | 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.
How about s/on \(failure\|error\)/otherwise/ here and everywhere else?
Documentation should be identical for all relevant functions.
<snip>
In mlx5_ethdev.c, priv_get_ifname() is still documented to return "0 on
success, -1 on failure and errno is set". You must get rid of the reliance
on external errno as part of this commit; you can optionally set rte_errno,
but for consistency all int-returning functions must return a valid negative
errno value, never -1.
The same applies to:
- priv_sysfs_read
- priv_sysfs_write
- priv_get_sysfs_ulong
- priv_set_sysfs_ulong
- priv_ifreq
- priv_get_num_vfs
- priv_get_mtu
- priv_get_cntr_sysfs
- priv_set_mtu
- priv_set_flags
- mlx5_link_update (lacks documentation)
- mlx5_ibv_device_to_pci_addr
- priv_dev_set_link
- mlx5_flow_item_validate
- mlx5_flow_create_* (unsure)
- priv_rx_intr_vec_enable ("negative" what?)
- mlx5_rx_intr_enable (ditto)
- mlx5_rx_intr_disable (ditto)
- check_cqe (returning a valid errno wouldn't impact performance)
- priv_read_dev_counters ("negative" what?)
- priv_ethtool_get_stats_n
- priv_xstats_get ("negative" what?)
- mlx5_stats_get (lacks documentation)
- mlx5_xstats_get ("negative" what?)
- mlx5_xstats_get_names (lacks documentation)
- priv_dev_traffic_disable (no error defined?)
- mlx5_priv_txq_ibv_releasable (lacks documentation)
- mlx5_priv_txq_ibv_verify (ditto)
- mlx5_vlan_offload_set (ditto, to be checked)
Also, some of them additionally set rte_errno while most of them do not. I'd
suggest to *always* set rte_errno in case of error then add the "...and
rte_errno is set" to documentation.
mlx4 approach to errors:
if (boom) {
rte_errno = ECRAP;
return -rte_errno;
}
Shorter, also valid but frowned upon:
if (boom)
return -(rte_errno = EBOOM);
Alternatively when calling another rte_errno-aware function:
ret = boom();
if (ret)
return ret;
--
Adrien Mazarguil
6WIND
next prev parent reply other threads:[~2018-02-16 14:26 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 ` [dpdk-dev] [PATCH 2/3] net/mlx5: convert return errno to negative ones Nelio Laranjeiro
2018-02-16 14:26 ` Adrien Mazarguil [this message]
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=20180216142642.GF4256@6wind.com \
--to=adrien.mazarguil@6wind.com \
--cc=dev@dpdk.org \
--cc=nelio.laranjeiro@6wind.com \
--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).