doc: add deprecation notice to fix ethdev API returning void

Message ID 1563890871-26901-1-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series doc: add deprecation notice to fix ethdev API returning void |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Andrew Rybchenko July 23, 2019, 2:07 p.m. UTC
  void return value is bad for get API (like rte_eth_dev_info-get())
since caller does not know if the function does its job or not and
output value is filled in.

void return value is bad for state changing API (like
rte_eth_promiscuous_enable()) since caller should use get API
to understand if state is really changed.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 doc/guides/rel_notes/deprecation.rst | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Ferruh Yigit July 23, 2019, 2:22 p.m. UTC | #1
On 7/23/2019 3:07 PM, Andrew Rybchenko wrote:
> void return value is bad for get API (like rte_eth_dev_info-get())
> since caller does not know if the function does its job or not and
> output value is filled in.
> 
> void return value is bad for state changing API (like
> rte_eth_promiscuous_enable()) since caller should use get API
> to understand if state is really changed.
> 
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
>  doc/guides/rel_notes/deprecation.rst | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
> index 37b8592b6..79689f136 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -59,6 +59,20 @@ Deprecation Notices
>    Target release for removal of the legacy API will be defined once most
>    PMDs have switched to rte_flow.
>  
> +* ethdev: update API functions returning ``void`` to return ``int`` with
> +  negative errno values to indicate various error conditions (e.g.
> +  invalid port ID, unsupported operation, failed operation):
> +
> +  - ``rte_eth_dev_info_get``
> +  - ``rte_eth_promiscuous_enable`` and ``rte_eth_promiscuous_disable``
> +  - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable``
> +  - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
> +  - ``rte_eth_dev_stop``
> +  - ``rte_eth_dev_close``
> +  - ``rte_eth_xstats_reset``
> +  - ``rte_eth_macaddr_get``
> +  - ``rte_eth_dev_owner_delete``
> +
>  * cryptodev: support for using IV with all sizes is added, J0 still can
>    be used but only when IV length in following structs ``rte_crypto_auth_xform``,
>    ``rte_crypto_aead_xform`` is set to zero. When IV length is greater or equal
> 

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Stephen Hemminger July 23, 2019, 2:38 p.m. UTC | #2
On Tue, 23 Jul 2019 15:07:51 +0100
Andrew Rybchenko <arybchenko@solarflare.com> wrote:

> void return value is bad for get API (like rte_eth_dev_info-get())
> since caller does not know if the function does its job or not and
> output value is filled in.
> 
> void return value is bad for state changing API (like
> rte_eth_promiscuous_enable()) since caller should use get API
> to understand if state is really changed.
> 
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

In general this is a good ide, but for some API's it is hard
to think of a way it would help. For example:
void return is ok for close routines because if close() returns
an error the application really has no choice about what to do.
  
Andrew Rybchenko July 23, 2019, 2:52 p.m. UTC | #3
On 7/23/19 5:38 PM, Stephen Hemminger wrote:
> On Tue, 23 Jul 2019 15:07:51 +0100
> Andrew Rybchenko <arybchenko@solarflare.com> wrote:
> 
>> void return value is bad for get API (like rte_eth_dev_info-get())
>> since caller does not know if the function does its job or not and
>> output value is filled in.
>>
>> void return value is bad for state changing API (like
>> rte_eth_promiscuous_enable()) since caller should use get API
>> to understand if state is really changed.
>>
>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> 
> In general this is a good ide, but for some API's it is hard
> to think of a way it would help. For example:
> void return is ok for close routines because if close() returns
> an error the application really has no choice about what to do.

Yes, I agree. But application can always ignore return value.
Long-long time ago it was a surprise to me that libc close() has
non-void return value.

I intentionally provided everything which makes sense to me to
raise discussion. I was unsure in stop, close and owner delete
functions.
  
Jerin Jacob Kollanukkaran July 24, 2019, 9:17 a.m. UTC | #4
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Andrew Rybchenko
> Sent: Tuesday, July 23, 2019 7:38 PM
> To: Thomas Monjalon <thomas@monjalon.net>; Ferruh Yigit
> <ferruh.yigit@intel.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] doc: add deprecation notice to fix ethdev API
> returning void
> 
> void return value is bad for get API (like rte_eth_dev_info-get()) since caller
> does not know if the function does its job or not and output value is filled in.
> 
> void return value is bad for state changing API (like
> rte_eth_promiscuous_enable()) since caller should use get API to
> understand if state is really changed.
> 
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>

> ---
>  doc/guides/rel_notes/deprecation.rst | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/deprecation.rst
> b/doc/guides/rel_notes/deprecation.rst
> index 37b8592b6..79689f136 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -59,6 +59,20 @@ Deprecation Notices
>    Target release for removal of the legacy API will be defined once most
>    PMDs have switched to rte_flow.
> 
> +* ethdev: update API functions returning ``void`` to return ``int``
> +with
> +  negative errno values to indicate various error conditions (e.g.
> +  invalid port ID, unsupported operation, failed operation):
> +
> +  - ``rte_eth_dev_info_get``
> +  - ``rte_eth_promiscuous_enable`` and ``rte_eth_promiscuous_disable``
> +  - ``rte_eth_allmulticast_enable`` and
> + ``rte_eth_allmulticast_disable``
> +  - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
> +  - ``rte_eth_dev_stop``
> +  - ``rte_eth_dev_close``
> +  - ``rte_eth_xstats_reset``
> +  - ``rte_eth_macaddr_get``
> +  - ``rte_eth_dev_owner_delete``
> +
>  * cryptodev: support for using IV with all sizes is added, J0 still can
>    be used but only when IV length in following structs
> ``rte_crypto_auth_xform``,
>    ``rte_crypto_aead_xform`` is set to zero. When IV length is greater or equal
> --
> 2.17.1
  
Thomas Monjalon Aug. 6, 2019, 11:24 a.m. UTC | #5
23/07/2019 16:22, Ferruh Yigit:
> On 7/23/2019 3:07 PM, Andrew Rybchenko wrote:
> > void return value is bad for get API (like rte_eth_dev_info-get())
> > since caller does not know if the function does its job or not and
> > output value is filled in.
> > 
> > void return value is bad for state changing API (like
> > rte_eth_promiscuous_enable()) since caller should use get API
> > to understand if state is really changed.
> > 
> > Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> > ---
> > +* ethdev: update API functions returning ``void`` to return ``int`` with
> > +  negative errno values to indicate various error conditions (e.g.
> > +  invalid port ID, unsupported operation, failed operation):
> > +
> > +  - ``rte_eth_dev_info_get``
> > +  - ``rte_eth_promiscuous_enable`` and ``rte_eth_promiscuous_disable``
> > +  - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable``
> > +  - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
> > +  - ``rte_eth_dev_stop``
> > +  - ``rte_eth_dev_close``
> > +  - ``rte_eth_xstats_reset``
> > +  - ``rte_eth_macaddr_get``
> > +  - ``rte_eth_dev_owner_delete``
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Acked-by: Thomas Monjalon <thomas@monjalon.net>
  
Thomas Monjalon Aug. 10, 2019, 8:29 p.m. UTC | #6
06/08/2019 13:24, Thomas Monjalon:
> 23/07/2019 16:22, Ferruh Yigit:
> > On 7/23/2019 3:07 PM, Andrew Rybchenko wrote:
> > > void return value is bad for get API (like rte_eth_dev_info-get())
> > > since caller does not know if the function does its job or not and
> > > output value is filled in.
> > > 
> > > void return value is bad for state changing API (like
> > > rte_eth_promiscuous_enable()) since caller should use get API
> > > to understand if state is really changed.
> > > 
> > > Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> > Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
> Acked-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Jerin Jacob <jerinj@marvell.com>

Applied, thanks
  

Patch

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 37b8592b6..79689f136 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -59,6 +59,20 @@  Deprecation Notices
   Target release for removal of the legacy API will be defined once most
   PMDs have switched to rte_flow.
 
+* ethdev: update API functions returning ``void`` to return ``int`` with
+  negative errno values to indicate various error conditions (e.g.
+  invalid port ID, unsupported operation, failed operation):
+
+  - ``rte_eth_dev_info_get``
+  - ``rte_eth_promiscuous_enable`` and ``rte_eth_promiscuous_disable``
+  - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable``
+  - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
+  - ``rte_eth_dev_stop``
+  - ``rte_eth_dev_close``
+  - ``rte_eth_xstats_reset``
+  - ``rte_eth_macaddr_get``
+  - ``rte_eth_dev_owner_delete``
+
 * cryptodev: support for using IV with all sizes is added, J0 still can
   be used but only when IV length in following structs ``rte_crypto_auth_xform``,
   ``rte_crypto_aead_xform`` is set to zero. When IV length is greater or equal