[dpdk-dev,v5] ethdev: add return code to rte_eth_stats_reset()

Message ID 20170901022631.19529-1-dharton@cisco.com (mailing list archive)
State Superseded, archived
Headers

Checks

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

Commit Message

David Harton Sept. 1, 2017, 2:26 a.m. UTC
  Some devices do not support reset of eth stats.  An application may
need to know not to clear shadow stats if the device cannot.

rte_eth_stats_reset is updated to provide a return code to share
whether the device supports reset or not.

Signed-off-by: David Harton <dharton@cisco.com>
---

v5:
* squashed doc patch
* moved rel_note change from ABI to API section

v4:
* commented return values

v3:
* overcame noob errors and figured out patch challenged

v2:
* fixed soft tab issue inserted while moving changes

 doc/guides/rel_notes/release_17_11.rst | 13 +++++++++++++
 lib/librte_ether/rte_ethdev.c          |  8 +++++---
 lib/librte_ether/rte_ethdev.h          |  6 +++++-
 3 files changed, 23 insertions(+), 4 deletions(-)
  

Comments

Hemant Agrawal Sept. 1, 2017, 7:47 a.m. UTC | #1
On 9/1/2017 7:56 AM, David Harton wrote:
> Some devices do not support reset of eth stats.  An application may
> need to know not to clear shadow stats if the device cannot.
>
> rte_eth_stats_reset is updated to provide a return code to share
> whether the device supports reset or not.
>
> Signed-off-by: David Harton <dharton@cisco.com>
> ---
>
> v5:
> * squashed doc patch
> * moved rel_note change from ABI to API section
>
> v4:
> * commented return values
>
> v3:
> * overcame noob errors and figured out patch challenged
>
> v2:
> * fixed soft tab issue inserted while moving changes
>
>  doc/guides/rel_notes/release_17_11.rst | 13 +++++++++++++
>  lib/librte_ether/rte_ethdev.c          |  8 +++++---
>  lib/librte_ether/rte_ethdev.h          |  6 +++++-
>  3 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst
> index 22df4fd..6282667 100644
> --- a/doc/guides/rel_notes/release_17_11.rst
> +++ b/doc/guides/rel_notes/release_17_11.rst
> @@ -110,6 +110,19 @@ API Changes
>     Also, make sure to start the actual text at the margin.
>     =========================================================
>
> +* **Modified the return type of rte_eth_stats_reset.**
> +
> +  Changed return type of ``rte_eth_stats_reset`` from ``void`` to ``int``
> +  so the caller may know whether a device supports the operation or not
> +  and if the operation was carried out.
> +
> +* **Modified the vlan_offload_set_t function prototype in the ethdev library.**
> +
> +  Changed the function prototype of ``vlan_offload_set_t``.  The return value
> +  has been changed from ``void`` to ``int`` so the caller to knows whether
> +  the backing device supports the operation or if the operation was
> +  successfully performed.
> +
>  * **Modified the vlan_offload_set_t function prototype in the ethdev library.**
>
>    Changed the function prototype of ``vlan_offload_set_t``.  The return value
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 05e52b8..f0f1775 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -1341,17 +1341,19 @@ struct rte_eth_dev *
>  	return 0;
>  }
>
> -void
> +int
>  rte_eth_stats_reset(uint8_t port_id)
>  {
>  	struct rte_eth_dev *dev;
>
> -	RTE_ETH_VALID_PORTID_OR_RET(port_id);
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>  	dev = &rte_eth_devices[port_id];
>
> -	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
> +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_reset, -ENOTSUP);
>  	(*dev->dev_ops->stats_reset)(dev);
>  	dev->data->rx_mbuf_alloc_failed = 0;
> +
> +	return 0;
>  }
>
>  static int
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 7254fd0..9110725 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -2246,8 +2246,12 @@ int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
>   *
>   * @param port_id
>   *   The port identifier of the Ethernet device.
> + * @return
> + *   - (0) if device notified to reset stats.
> + *   - (-ENOTSUP) if hardware doesn't support.
> + *   - (-ENODEV) if *port_id* invalid.
>   */
> -void rte_eth_stats_reset(uint8_t port_id);
> +int rte_eth_stats_reset(uint8_t port_id);
>
>  /**
>   * Retrieve names of extended statistics of an Ethernet device.
>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
  
Ferruh Yigit Sept. 19, 2017, 5:14 p.m. UTC | #2
On 9/1/2017 3:26 AM, David Harton wrote:
> Some devices do not support reset of eth stats.  An application may
> need to know not to clear shadow stats if the device cannot.
> 
> rte_eth_stats_reset is updated to provide a return code to share
> whether the device supports reset or not.
> 
> Signed-off-by: David Harton <dharton@cisco.com>
> ---
> 
> v5:
> * squashed doc patch
> * moved rel_note change from ABI to API section
> 
> v4:
> * commented return values
> 
> v3:
> * overcame noob errors and figured out patch challenged
> 
> v2:
> * fixed soft tab issue inserted while moving changes
> 
>  doc/guides/rel_notes/release_17_11.rst | 13 +++++++++++++
>  lib/librte_ether/rte_ethdev.c          |  8 +++++---
>  lib/librte_ether/rte_ethdev.h          |  6 +++++-
>  3 files changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst
> index 22df4fd..6282667 100644
> --- a/doc/guides/rel_notes/release_17_11.rst
> +++ b/doc/guides/rel_notes/release_17_11.rst
> @@ -110,6 +110,19 @@ API Changes
>     Also, make sure to start the actual text at the margin.
>     =========================================================
>  
> +* **Modified the return type of rte_eth_stats_reset.**
> +
> +  Changed return type of ``rte_eth_stats_reset`` from ``void`` to ``int``
> +  so the caller may know whether a device supports the operation or not
> +  and if the operation was carried out.
> +

> +* **Modified the vlan_offload_set_t function prototype in the ethdev library.**
> +
> +  Changed the function prototype of ``vlan_offload_set_t``.  The return value
> +  has been changed from ``void`` to ``int`` so the caller to knows whether
> +  the backing device supports the operation or if the operation was
> +  successfully performed.
> +

Is this addition to the document related to this patch?

>  * **Modified the vlan_offload_set_t function prototype in the ethdev library.**
>  
>    Changed the function prototype of ``vlan_offload_set_t``.  The return value
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 05e52b8..f0f1775 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -1341,17 +1341,19 @@ struct rte_eth_dev *
>  	return 0;
>  }
>  
> -void
> +int
>  rte_eth_stats_reset(uint8_t port_id)
>  {
>  	struct rte_eth_dev *dev;
>  
> -	RTE_ETH_VALID_PORTID_OR_RET(port_id);
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>  	dev = &rte_eth_devices[port_id];
>  
> -	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
> +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_reset, -ENOTSUP);
>  	(*dev->dev_ops->stats_reset)(dev);
>  	dev->data->rx_mbuf_alloc_failed = 0;
> +
> +	return 0;
>  }
>  
>  static int
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 7254fd0..9110725 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -2246,8 +2246,12 @@ int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
>   *
>   * @param port_id
>   *   The port identifier of the Ethernet device.
> + * @return
> + *   - (0) if device notified to reset stats.
> + *   - (-ENOTSUP) if hardware doesn't support.
> + *   - (-ENODEV) if *port_id* invalid.
>   */
> -void rte_eth_stats_reset(uint8_t port_id);
> +int rte_eth_stats_reset(uint8_t port_id);
>  
>  /**
>   * Retrieve names of extended statistics of an Ethernet device.
>
  
David Harton Sept. 20, 2017, 2:01 p.m. UTC | #3
> -----Original Message-----

> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]

> 

> On 9/1/2017 3:26 AM, David Harton wrote:

> > Some devices do not support reset of eth stats.  An application may

> > need to know not to clear shadow stats if the device cannot.

> >

> > rte_eth_stats_reset is updated to provide a return code to share

> > whether the device supports reset or not.

> >

> > Signed-off-by: David Harton <dharton@cisco.com>

> > ---

> >

> > v5:

> > * squashed doc patch

> > * moved rel_note change from ABI to API section

> >

> > v4:

> > * commented return values

> >

> > v3:

> > * overcame noob errors and figured out patch challenged

> >

> > v2:

> > * fixed soft tab issue inserted while moving changes

> >

> >  doc/guides/rel_notes/release_17_11.rst | 13 +++++++++++++

> >  lib/librte_ether/rte_ethdev.c          |  8 +++++---

> >  lib/librte_ether/rte_ethdev.h          |  6 +++++-

> >  3 files changed, 23 insertions(+), 4 deletions(-)

> >

> > diff --git a/doc/guides/rel_notes/release_17_11.rst

> > b/doc/guides/rel_notes/release_17_11.rst

> > index 22df4fd..6282667 100644

> > --- a/doc/guides/rel_notes/release_17_11.rst

> > +++ b/doc/guides/rel_notes/release_17_11.rst

> > @@ -110,6 +110,19 @@ API Changes

> >     Also, make sure to start the actual text at the margin.

> >     =========================================================

> >

> > +* **Modified the return type of rte_eth_stats_reset.**

> > +

> > +  Changed return type of ``rte_eth_stats_reset`` from ``void`` to

> > + ``int``  so the caller may know whether a device supports the

> > + operation or not  and if the operation was carried out.

> > +

> 

> > +* **Modified the vlan_offload_set_t function prototype in the ethdev

> > +library.**

> > +

> > +  Changed the function prototype of ``vlan_offload_set_t``.  The

> > + return value  has been changed from ``void`` to ``int`` so the

> > + caller to knows whether  the backing device supports the operation

> > + or if the operation was  successfully performed.

> > +

> 

> Is this addition to the document related to this patch?


Good catch.  No. :(

I must have mishandled the rebase I did to update this patch.  V6 coming.  
Would be great if you could re-ACK afterwards so this one can move.

Thanks,
Dave

> 

> >  * **Modified the vlan_offload_set_t function prototype in the ethdev

> > library.**

> >

> >    Changed the function prototype of ``vlan_offload_set_t``.  The

> > return value diff --git a/lib/librte_ether/rte_ethdev.c

> > b/lib/librte_ether/rte_ethdev.c index 05e52b8..f0f1775 100644

> > --- a/lib/librte_ether/rte_ethdev.c

> > +++ b/lib/librte_ether/rte_ethdev.c

> > @@ -1341,17 +1341,19 @@ struct rte_eth_dev *

> >  	return 0;

> >  }

> >

> > -void

> > +int

> >  rte_eth_stats_reset(uint8_t port_id)

> >  {

> >  	struct rte_eth_dev *dev;

> >

> > -	RTE_ETH_VALID_PORTID_OR_RET(port_id);

> > +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

> >  	dev = &rte_eth_devices[port_id];

> >

> > -	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);

> > +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_reset, -ENOTSUP);

> >  	(*dev->dev_ops->stats_reset)(dev);

> >  	dev->data->rx_mbuf_alloc_failed = 0;

> > +

> > +	return 0;

> >  }

> >

> >  static int

> > diff --git a/lib/librte_ether/rte_ethdev.h

> > b/lib/librte_ether/rte_ethdev.h index 7254fd0..9110725 100644

> > --- a/lib/librte_ether/rte_ethdev.h

> > +++ b/lib/librte_ether/rte_ethdev.h

> > @@ -2246,8 +2246,12 @@ int rte_eth_tx_queue_setup(uint8_t port_id,

> uint16_t tx_queue_id,

> >   *

> >   * @param port_id

> >   *   The port identifier of the Ethernet device.

> > + * @return

> > + *   - (0) if device notified to reset stats.

> > + *   - (-ENOTSUP) if hardware doesn't support.

> > + *   - (-ENODEV) if *port_id* invalid.

> >   */

> > -void rte_eth_stats_reset(uint8_t port_id);

> > +int rte_eth_stats_reset(uint8_t port_id);

> >

> >  /**

> >   * Retrieve names of extended statistics of an Ethernet device.

> >
  
Ferruh Yigit Sept. 20, 2017, 4:55 p.m. UTC | #4
On 9/20/2017 3:01 PM, David Harton (dharton) wrote:
> 
> 
>> -----Original Message-----
>> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
>>
>> On 9/1/2017 3:26 AM, David Harton wrote:
>>> Some devices do not support reset of eth stats.  An application may
>>> need to know not to clear shadow stats if the device cannot.
>>>
>>> rte_eth_stats_reset is updated to provide a return code to share
>>> whether the device supports reset or not.
>>>
>>> Signed-off-by: David Harton <dharton@cisco.com>
>>> ---
>>>
>>> v5:
>>> * squashed doc patch
>>> * moved rel_note change from ABI to API section
>>>
>>> v4:
>>> * commented return values
>>>
>>> v3:
>>> * overcame noob errors and figured out patch challenged
>>>
>>> v2:
>>> * fixed soft tab issue inserted while moving changes
>>>
>>>  doc/guides/rel_notes/release_17_11.rst | 13 +++++++++++++
>>>  lib/librte_ether/rte_ethdev.c          |  8 +++++---
>>>  lib/librte_ether/rte_ethdev.h          |  6 +++++-
>>>  3 files changed, 23 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/doc/guides/rel_notes/release_17_11.rst
>>> b/doc/guides/rel_notes/release_17_11.rst
>>> index 22df4fd..6282667 100644
>>> --- a/doc/guides/rel_notes/release_17_11.rst
>>> +++ b/doc/guides/rel_notes/release_17_11.rst
>>> @@ -110,6 +110,19 @@ API Changes
>>>     Also, make sure to start the actual text at the margin.
>>>     =========================================================
>>>
>>> +* **Modified the return type of rte_eth_stats_reset.**
>>> +
>>> +  Changed return type of ``rte_eth_stats_reset`` from ``void`` to
>>> + ``int``  so the caller may know whether a device supports the
>>> + operation or not  and if the operation was carried out.
>>> +
>>
>>> +* **Modified the vlan_offload_set_t function prototype in the ethdev
>>> +library.**
>>> +
>>> +  Changed the function prototype of ``vlan_offload_set_t``.  The
>>> + return value  has been changed from ``void`` to ``int`` so the
>>> + caller to knows whether  the backing device supports the operation
>>> + or if the operation was  successfully performed.
>>> +
>>
>> Is this addition to the document related to this patch?
> 
> Good catch.  No. :(
> 
> I must have mishandled the rebase I did to update this patch.  V6 coming.  
> Would be great if you could re-ACK afterwards so this one can move.

I think you can carry the previous Ack for this case. Since main part of
the patch that acked will not be changed...

> 
> Thanks,
> Dave

<...>
  

Patch

diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst
index 22df4fd..6282667 100644
--- a/doc/guides/rel_notes/release_17_11.rst
+++ b/doc/guides/rel_notes/release_17_11.rst
@@ -110,6 +110,19 @@  API Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* **Modified the return type of rte_eth_stats_reset.**
+
+  Changed return type of ``rte_eth_stats_reset`` from ``void`` to ``int``
+  so the caller may know whether a device supports the operation or not
+  and if the operation was carried out.
+
+* **Modified the vlan_offload_set_t function prototype in the ethdev library.**
+
+  Changed the function prototype of ``vlan_offload_set_t``.  The return value
+  has been changed from ``void`` to ``int`` so the caller to knows whether
+  the backing device supports the operation or if the operation was
+  successfully performed.
+
 * **Modified the vlan_offload_set_t function prototype in the ethdev library.**
 
   Changed the function prototype of ``vlan_offload_set_t``.  The return value
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 05e52b8..f0f1775 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1341,17 +1341,19 @@  struct rte_eth_dev *
 	return 0;
 }
 
-void
+int
 rte_eth_stats_reset(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	RTE_ETH_VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_reset, -ENOTSUP);
 	(*dev->dev_ops->stats_reset)(dev);
 	dev->data->rx_mbuf_alloc_failed = 0;
+
+	return 0;
 }
 
 static int
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 7254fd0..9110725 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2246,8 +2246,12 @@  int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
+ * @return
+ *   - (0) if device notified to reset stats.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
  */
-void rte_eth_stats_reset(uint8_t port_id);
+int rte_eth_stats_reset(uint8_t port_id);
 
 /**
  * Retrieve names of extended statistics of an Ethernet device.