[v2,1/2] ethdev: expose basic xstats for driver use

Message ID 20190626233346.4719-2-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series failsafe: add xstats |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Stephen Hemminger June 26, 2019, 11:33 p.m. UTC
  Avoid duplication by having generic basic xstats available
for use by drivers. A later patch uses this for failsafe
driver.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 lib/librte_ethdev/rte_ethdev.c           | 17 ++++++++---------
 lib/librte_ethdev/rte_ethdev_core.h      | 14 ++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  3 +++
 3 files changed, 25 insertions(+), 9 deletions(-)
  

Comments

Andrew Rybchenko July 1, 2019, 10:54 a.m. UTC | #1
On 27.06.2019 2:33, Stephen Hemminger wrote:
> Avoid duplication by having generic basic xstats available
> for use by drivers. A later patch uses this for failsafe
> driver.
>
> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>

[...]


> diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h
> index 2922d5b7cc95..91ce1880d1c6 100644
> --- a/lib/librte_ethdev/rte_ethdev_core.h
> +++ b/lib/librte_ethdev/rte_ethdev_core.h
> @@ -517,6 +517,20 @@ struct eth_dev_ops {
>   	/**< Test if a port supports specific mempool ops */
>   };
>   
> +/**
> + * @internal
> + * Get basic stats for ethdev
> + */
> +int __rte_experimental
> +rte_eth_basic_stats_count(struct rte_eth_dev *dev);
> +
> +int  __rte_experimental
> +rte_eth_basic_stats_get_names(struct rte_eth_dev *dev,
> +			      struct rte_eth_xstat_name *xstats_names);
> +
> +int __rte_experimental
> +rte_eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats);
> +
>   /**
>    * @internal
>    * Structure used to hold information about the callbacks to be called for a

It conflicts with __rte_experimenal placing patch which is on the 
mailing list.
Also I've expected to see these functions in rte_ethdev_driver.h to
avoid inclusion in rte_ethdev.h. As I understand these functions are for
rte_ethdev and drivers only.

> diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map
> index df9141825c3f..949a79800cbc 100644
> --- a/lib/librte_ethdev/rte_ethdev_version.map
> +++ b/lib/librte_ethdev/rte_ethdev_version.map
> @@ -239,6 +239,9 @@ DPDK_19.05 {
>   EXPERIMENTAL {
>   	global:
>   
> +	rte_eth_basic_stats_count;
> +	rte_eth_basic_stats_get;
> +	rte_eth_basic_stats_get_names;
>   	rte_eth_devargs_parse;
>   	rte_eth_dev_create;
>   	rte_eth_dev_destroy;
  
Stephen Hemminger July 1, 2019, 2:59 p.m. UTC | #2
On Mon, 1 Jul 2019 13:54:52 +0300
Andrew Rybchenko <arybchenko@solarflare.com> wrote:

> On 27.06.2019 2:33, Stephen Hemminger wrote:
> > Avoid duplication by having generic basic xstats available
> > for use by drivers. A later patch uses this for failsafe
> > driver.
> >
> > Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>  
> 
> [...]
> 
> 
> > diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h
> > index 2922d5b7cc95..91ce1880d1c6 100644
> > --- a/lib/librte_ethdev/rte_ethdev_core.h
> > +++ b/lib/librte_ethdev/rte_ethdev_core.h
> > @@ -517,6 +517,20 @@ struct eth_dev_ops {
> >   	/**< Test if a port supports specific mempool ops */
> >   };
> >   
> > +/**
> > + * @internal
> > + * Get basic stats for ethdev
> > + */
> > +int __rte_experimental
> > +rte_eth_basic_stats_count(struct rte_eth_dev *dev);
> > +
> > +int  __rte_experimental
> > +rte_eth_basic_stats_get_names(struct rte_eth_dev *dev,
> > +			      struct rte_eth_xstat_name *xstats_names);
> > +
> > +int __rte_experimental
> > +rte_eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats);
> > +
> >   /**
> >    * @internal
> >    * Structure used to hold information about the callbacks to be called for a  
> 
> It conflicts with __rte_experimenal placing patch which is on the 
> mailing list.
> Also I've expected to see these functions in rte_ethdev_driver.h to
> avoid inclusion in rte_ethdev.h. As I understand these functions are for
> rte_ethdev and drivers only.

Yes. Will change in V3
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8ac301608b9c..a83e9727c144 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -1996,8 +1996,8 @@  rte_eth_stats_reset(uint16_t port_id)
 	return 0;
 }
 
-static inline int
-get_xstats_basic_count(struct rte_eth_dev *dev)
+int
+rte_eth_basic_stats_count(struct rte_eth_dev *dev)
 {
 	uint16_t nb_rxqs, nb_txqs;
 	int count;
@@ -2034,7 +2034,7 @@  get_xstats_count(uint16_t port_id)
 		count = 0;
 
 
-	count += get_xstats_basic_count(dev);
+	count += rte_eth_basic_stats_count(dev);
 
 	return count;
 }
@@ -2084,7 +2084,7 @@  rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
 }
 
 /* retrieve basic stats names */
-static int
+int
 rte_eth_basic_stats_get_names(struct rte_eth_dev *dev,
 	struct rte_eth_xstat_name *xstats_names)
 {
@@ -2140,7 +2140,7 @@  rte_eth_xstats_get_names_by_id(uint16_t port_id,
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	basic_count = get_xstats_basic_count(dev);
+	basic_count = rte_eth_basic_stats_count(dev);
 	ret = get_xstats_count(port_id);
 	if (ret < 0)
 		return ret;
@@ -2268,8 +2268,7 @@  rte_eth_xstats_get_names(uint16_t port_id,
 	return cnt_used_entries;
 }
 
-
-static int
+int
 rte_eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats)
 {
 	struct rte_eth_dev *dev;
@@ -2341,7 +2340,7 @@  rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
 	expected_entries = (uint16_t)ret;
 	struct rte_eth_xstat xstats[expected_entries];
 	dev = &rte_eth_devices[port_id];
-	basic_count = get_xstats_basic_count(dev);
+	basic_count = rte_eth_basic_stats_count(dev);
 
 	/* Return max number of stats if no ids given */
 	if (!ids) {
@@ -2355,7 +2354,7 @@  rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
 		return -EINVAL;
 
 	if (ids && dev->dev_ops->xstats_get_by_id != NULL && size) {
-		unsigned int basic_count = get_xstats_basic_count(dev);
+		unsigned int basic_count = rte_eth_basic_stats_count(dev);
 		uint64_t ids_copy[size];
 
 		for (i = 0; i < size; i++) {
diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h
index 2922d5b7cc95..91ce1880d1c6 100644
--- a/lib/librte_ethdev/rte_ethdev_core.h
+++ b/lib/librte_ethdev/rte_ethdev_core.h
@@ -517,6 +517,20 @@  struct eth_dev_ops {
 	/**< Test if a port supports specific mempool ops */
 };
 
+/**
+ * @internal
+ * Get basic stats for ethdev
+ */
+int __rte_experimental
+rte_eth_basic_stats_count(struct rte_eth_dev *dev);
+
+int  __rte_experimental
+rte_eth_basic_stats_get_names(struct rte_eth_dev *dev,
+			      struct rte_eth_xstat_name *xstats_names);
+
+int __rte_experimental
+rte_eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats);
+
 /**
  * @internal
  * Structure used to hold information about the callbacks to be called for a
diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map
index df9141825c3f..949a79800cbc 100644
--- a/lib/librte_ethdev/rte_ethdev_version.map
+++ b/lib/librte_ethdev/rte_ethdev_version.map
@@ -239,6 +239,9 @@  DPDK_19.05 {
 EXPERIMENTAL {
 	global:
 
+	rte_eth_basic_stats_count;
+	rte_eth_basic_stats_get;
+	rte_eth_basic_stats_get_names;
 	rte_eth_devargs_parse;
 	rte_eth_dev_create;
 	rte_eth_dev_destroy;