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.laranje...@6wind.com> > Acked-by: Yongseok Koh <ys...@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