ethdev: extract xstat basic stat count calculation
PATCH 1/3 ethdev: extract xstat basic stat count calculation
Extract into static inline function so that can be used by other functions.
--- lib/librte_ether/rte_ethdev.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
lib/librte_ether/rte_ethdev.c +19 -5
@@ -1550,6 +1550,22 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } +static inline int +get_xstats_basic_count (struct rte_eth_dev *dev) +{ +uint16_t nb_rxqs, nb_txqs; +int count; + + nb_rxqs =RTE_MIN (dev->data->nb_rx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ); + nb_txqs =RTE_MIN (dev->data->nb_tx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ); + + count =RTE_NB_STATS ; + count += nb_rxqs *RTE_NB_RXQ_STATS ; + count += nb_txqs *RTE_NB_TXQ_STATS ; + +return count; +} +static int get_xstats_count (uint16_t port_id) {
@@ -1571,11 +1587,9 @@ get_xstats_count(uint16_t port_id) }else count =0 ; - count +=RTE_NB_STATS ; - count +=RTE_MIN (dev->data->nb_rx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ) * -RTE_NB_RXQ_STATS ; - count +=RTE_MIN (dev->data->nb_tx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ) * -RTE_NB_TXQ_STATS ; + + count +=get_xstats_basic_count (dev); +return count; }
Signature · 1 line
2.13.6
PATCH 2/3 ethdev: fix xstats get by id APIS
ethdev xstat get by id APIs:rte_eth_xstats_get_names_by_id()rte_eth_xstats_get_by_id()
Works on ids calculated as "basic stats + device specific stats"
When an application asking for id less than "basic stats count", it is indeed asking basic stats nothing specific to device stats.
The dev_ops PMDs implements xstats_get_names_by_id and xstats_get_by_id works on device specific ids.
This patch adds a check if all stats requested by ids can be provided via device and if so converts ids to device specific ones.
This conversion wasn't required before commit 8c49d5f1c219, because _by_id dev_ops were always used to get whole stats instead of specific ids.
---
Cc: Ivan Malov <[email protected]>
Cc: Harry Van Haaren <[email protected]>
Cc: Lee Daly <[email protected]>
--- lib/librte_ether/rte_ethdev.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-)
lib/librte_ether/rte_ethdev.c +36 -6
@@ -1644,6 +1644,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, uint64_t *ids) {struct rte_eth_xstat_name *xstats_names_copy; +unsigned int all_ids_from_pmd =1 ;unsigned int expected_entries;struct rte_eth_dev *dev;unsigned int i;
@@ -1663,9 +1664,23 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,if (ids && !xstats_names)return -EINVAL ; -if (dev->dev_ops->xstats_get_names_by_id !=NULL ) -return (*dev->dev_ops->xstats_get_names_by_id)( - dev, xstats_names, ids, size); +if (ids && dev->dev_ops->xstats_get_names_by_id !=NULL && size >0 ) { +unsigned int basic_count =get_xstats_basic_count (dev); +uint64_t ids_copy[size]; + +for (i =0 ; i < size; i++) { +if (ids[i] < basic_count) { + all_ids_from_pmd =0 ; +break ; + } + + ids_copy[i] = ids[i] - basic_count; + } + +if (all_ids_from_pmd) +return (*dev->dev_ops->xstats_get_names_by_id)(dev, + xstats_names, ids_copy, size); + }/* Retrieve all stats */ if (!ids) {
@@ -1772,6 +1787,7 @@ int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint64_t *values, unsigned int size) { + unsigned int all_ids_from_pmd = 1;unsigned int num_xstats_filled;uint16_t expected_entries;struct rte_eth_dev *dev;
@@ -1793,9 +1809,23 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,if (ids && !values)return -EINVAL ; -if (dev->dev_ops->xstats_get_by_id !=NULL ) -return (*dev->dev_ops->xstats_get_by_id)(dev, ids, values, - size); +if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { +unsigned int basic_count =get_xstats_basic_count (dev); +uint64_t ids_copy[size]; + +for (i =0 ; i < size; i++) { +if (ids[i] < basic_count) { + all_ids_from_pmd =0 ; +break ; + } + + ids_copy[i] = ids[i] - basic_count; + } + +if (all_ids_from_pmd) +return (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, + values, size); + }/* Fill the xstats structure */ num_xstats_filled = rte_eth_xstats_get(port_id, xstats,
Signature · 1 line
2.13.6
PATCH 3/3 ethdev: fix negative return values in xstats
In reply to Ferruh YigitSome function calls in xstat functions can return negative values to indicate the error, check return values for those cases.
Coverity issue: 195028, 195026
---
Cc: Lee Daly <[email protected]>
--- lib/librte_ether/rte_ethdev.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
lib/librte_ether/rte_ethdev.c +11 -3
@@ -1648,11 +1648,16 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,unsigned int expected_entries;struct rte_eth_dev *dev;unsigned int i; +int ret;RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); - expected_entries =get_xstats_count (port_id); dev = &rte_eth_devices[port_id]; + ret =get_xstats_count (port_id); +if (ret <0 ) +return ret; + expected_entries = (unsigned int )ret; +/* Return max number of stats if no ids given */ if (!ids) {if (!xstats_names)
@@ -1792,6 +1797,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,uint16_t expected_entries;struct rte_eth_dev *dev;unsigned int i; +int ret;RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); expected_entries =get_xstats_count (port_id);
@@ -1828,8 +1834,10 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, }/* Fill the xstats structure */ - num_xstats_filled =rte_eth_xstats_get (port_id, xstats, - expected_entries); + ret =rte_eth_xstats_get (port_id, xstats, expected_entries); +if (ret <0 ) +return ret; + num_xstats_filled = (unsigned int )ret;/* Return all stats */ if (!ids) {
Signature · 1 line
2.13.6
Re: [PATCH 2/3] ethdev: fix xstats get by id APIS
In reply to Ferruh YigitQuoted 19 lines · Ferruh Yigit
ethdev xstat get by id APIs:
rte_eth_xstats_get_names_by_id()rte_eth_xstats_get_by_id()Works on ids calculated as "basic stats + device specific stats"
When an application asking for id less than "basic stats count", it is indeed asking basic stats nothing specific to device stats.
The
dev_opsPMDs implementsxstats_get_names_by_idandxstats_get_by_idworks on device specific ids.This patch adds a check if all stats requested by ids can be provided via device and if so converts ids to device specific ones.
This conversion wasn't required before commit
8c49d5f1c219, because_by_iddev_opswere always used to get whole stats instead of specific ids.
Quoted 7 lines
Fixes 8c49d5f1c219 ("ethdev: rework xstats retrieve by id")Signed-off-by Ferruh Yigit <[email protected]>---
Cc: Ivan Malov <[email protected]>
Cc: Harry Van Haaren <[email protected]>
Cc: Lee Daly <[email protected]>
The patch looks reasonable.
It solves the problem for me provided that the parts 1/3 and 3/3 are also applied.
Signature · 2 lines
Best regards, Ivan
Re: [PATCH 2/3] ethdev: fix xstats get by id APIS
In reply to Ferruh Yigit20/10/2017 02:03, Ferruh Yigit:
Quoted 12 lines
ethdev xstat get by id APIs:
rte_eth_xstats_get_names_by_id()rte_eth_xstats_get_by_id()Works on ids calculated as "basic stats + device specific stats"
When an application asking for id less than "basic stats count", it is indeed asking basic stats nothing specific to device stats.
The
dev_opsPMDs implementsxstats_get_names_by_idandxstats_get_by_idworks on device specific ids.
Quoted 8 lines
This patch adds a check if all stats requested by ids can be provided via device and if so converts ids to device specific ones.
This conversion wasn't required before commit
8c49d5f1c219, because_by_iddev_opswere always used to get whole stats instead of specific ids.Fixes 8c49d5f1c219 ("ethdev: rework xstats retrieve by id")
It would be easier to understand if starting with a statement of bug.
lib/librte_ether/rte_ethdev.c rte_eth_xstats_get_names_by_id(uint16_t port_id, · line 1647
Quoted 7 lines
lib/librte_ether/rte_ethdev.c +1
-0@@ -1644,6 +1644,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, uint64_t *ids) {struct rte_eth_xstat_name *xstats_names_copy; +unsigned int all_ids_from_pmd =1 ;
This variable would be better renamed as "no_basic_stat_requested".
lib/librte_ether/rte_ethdev.c rte_eth_xstats_get_names_by_id(uint16_t port_id, · line 1648
Quoted 1 line
lib/librte_ether/rte_ethdev.c +1
-0+ ids_copy[i] = ids[i] - basic_count;
This line may deserve a comment.
Re: [PATCH 3/3] ethdev: fix negative return values in xstats
In reply to Ferruh YigitSuggested title:
check more errors in xstats retrieval
20/10/2017 02:03, Ferruh Yigit:
Quoted 7 lines
Some function calls in xstat functions can return negative values to indicate the error, check return values for those cases.
Coverity issue: 195028, 195026
Fixes 8c49d5f1c219 ("ethdev: rework xstats retrieve by id")Signed-off-by Ferruh Yigit <[email protected]>
PATCH 2/3 ethdev: fix xstats get by id APIS
In reply to Ferruh Yigitxstats _by_id() APIs are broken because ids known by user sent directly to the PMDs.
ethdev xstat get by id APIs:rte_eth_xstats_get_names_by_id() and rte_eth_xstats_get_by_id() work on ids calculated as "basic stats + extended stats"
When an application asking for id less than "basic stats count", it is indeed asking basic stats not extended stats.
The dev_ops PMDs implements work on extended stats ids.
This patch adds a check if all requested stats are xstats and if so converts ids to xstats ids before passing them to PMDs.
This conversion wasn't required before commit 8c49d5f1c219, because _by_id dev_ops were always used to get whole stats via NULL ids.
---
Cc: Ivan Malov <[email protected]>
Cc: Harry Van Haaren <[email protected]>
Cc: Lee Daly <[email protected]>
v2:
* variable renamed, all_ids_from_pmd -> no_basic_stat_requested
* xstats id conversion commented.
--- lib/librte_ether/rte_ethdev.c | 50 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-)
lib/librte_ether/rte_ethdev.c +44 -6
@@ -1644,6 +1644,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, uint64_t *ids) {struct rte_eth_xstat_name *xstats_names_copy; +unsigned int no_basic_stat_requested =1 ;unsigned int expected_entries;struct rte_eth_dev *dev;unsigned int i;
@@ -1663,9 +1664,27 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,if (ids && !xstats_names)return -EINVAL ; -if (dev->dev_ops->xstats_get_names_by_id !=NULL ) -return (*dev->dev_ops->xstats_get_names_by_id)( - dev, xstats_names, ids, size); +if (ids && dev->dev_ops->xstats_get_names_by_id !=NULL && size >0 ) { +unsigned int basic_count =get_xstats_basic_count (dev); +uint64_t ids_copy[size]; + +for (i =0 ; i < size; i++) { +if (ids[i] < basic_count) { + no_basic_stat_requested =0 ; +break ; + } + +/* +* Convert ids to xstats ids that PMD knows. +* ids known by user are basic + extended stats. +*/ + ids_copy[i] = ids[i] - basic_count; + } + +if (no_basic_stat_requested) +return (*dev->dev_ops->xstats_get_names_by_id)(dev, + xstats_names, ids_copy, size); + }/* Retrieve all stats */ if (!ids) {
@@ -1772,6 +1791,7 @@ int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint64_t *values, unsigned int size) { + unsigned int no_basic_stat_requested = 1;unsigned int num_xstats_filled;uint16_t expected_entries;struct rte_eth_dev *dev;
@@ -1793,9 +1813,27 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,if (ids && !values)return -EINVAL ; -if (dev->dev_ops->xstats_get_by_id !=NULL ) -return (*dev->dev_ops->xstats_get_by_id)(dev, ids, values, - size); +if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { +unsigned int basic_count =get_xstats_basic_count (dev); +uint64_t ids_copy[size]; + +for (i =0 ; i < size; i++) { +if (ids[i] < basic_count) { + no_basic_stat_requested =0 ; +break ; + } + +/* +* Convert ids to xstats ids that PMD knows. +* ids known by user are basic + extended stats. +*/ + ids_copy[i] = ids[i] - basic_count; + } + +if (no_basic_stat_requested) +return (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, + values, size); + }/* Fill the xstats structure */ num_xstats_filled = rte_eth_xstats_get(port_id, xstats,
Signature · 1 line
2.13.6
PATCH 1/3 ethdev: extract xstat basic stat count calculation
In reply to Ferruh YigitExtract into static inline function so that can be used by other functions.
--- lib/librte_ether/rte_ethdev.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
lib/librte_ether/rte_ethdev.c +19 -5
@@ -1550,6 +1550,22 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } +static inline int +get_xstats_basic_count (struct rte_eth_dev *dev) +{ +uint16_t nb_rxqs, nb_txqs; +int count; + + nb_rxqs =RTE_MIN (dev->data->nb_rx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ); + nb_txqs =RTE_MIN (dev->data->nb_tx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ); + + count =RTE_NB_STATS ; + count += nb_rxqs *RTE_NB_RXQ_STATS ; + count += nb_txqs *RTE_NB_TXQ_STATS ; + +return count; +} +static int get_xstats_count (uint16_t port_id) {
@@ -1571,11 +1587,9 @@ get_xstats_count(uint16_t port_id) }else count =0 ; - count +=RTE_NB_STATS ; - count +=RTE_MIN (dev->data->nb_rx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ) * -RTE_NB_RXQ_STATS ; - count +=RTE_MIN (dev->data->nb_tx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ) * -RTE_NB_TXQ_STATS ; + + count +=get_xstats_basic_count (dev); +return count; }
Signature · 1 line
2.13.6
PATCH 3/3 ethdev: check more errors in xstats retrieval
Some function calls in xstat functions can return negative values to indicate the error, check return values for those cases.
Coverity issue: 195028, 195026
---
Cc: Lee Daly <[email protected]>
--- lib/librte_ether/rte_ethdev.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
lib/librte_ether/rte_ethdev.c +11 -3
@@ -1648,11 +1648,16 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,unsigned int expected_entries;struct rte_eth_dev *dev;unsigned int i; +int ret;RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); - expected_entries =get_xstats_count (port_id); dev = &rte_eth_devices[port_id]; + ret =get_xstats_count (port_id); +if (ret <0 ) +return ret; + expected_entries = (unsigned int )ret; +/* Return max number of stats if no ids given */ if (!ids) {if (!xstats_names)
@@ -1796,6 +1801,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,uint16_t expected_entries;struct rte_eth_dev *dev;unsigned int i; +int ret;RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); expected_entries =get_xstats_count (port_id);
@@ -1836,8 +1842,10 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, }/* Fill the xstats structure */ - num_xstats_filled =rte_eth_xstats_get (port_id, xstats, - expected_entries); + ret =rte_eth_xstats_get (port_id, xstats, expected_entries); +if (ret <0 ) +return ret; + num_xstats_filled = (unsigned int )ret;/* Return all stats */ if (!ids) {
Signature · 1 line
2.13.6
PATCH v2 1/3 ethdev: extract xstat basic stat count calculation
In reply to Ferruh YigitExtract into static inline function so that can be used by other functions.
--- lib/librte_ether/rte_ethdev.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
lib/librte_ether/rte_ethdev.c +19 -5
@@ -1550,6 +1550,22 @@ rte_eth_stats_reset(uint16_t port_id)return 0 ; } +static inline int +get_xstats_basic_count (struct rte_eth_dev *dev) +{ +uint16_t nb_rxqs, nb_txqs; +int count; + + nb_rxqs =RTE_MIN (dev->data->nb_rx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ); + nb_txqs =RTE_MIN (dev->data->nb_tx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ); + + count =RTE_NB_STATS ; + count += nb_rxqs *RTE_NB_RXQ_STATS ; + count += nb_txqs *RTE_NB_TXQ_STATS ; + +return count; +} +static int get_xstats_count (uint16_t port_id) {
@@ -1571,11 +1587,9 @@ get_xstats_count(uint16_t port_id) }else count =0 ; - count +=RTE_NB_STATS ; - count +=RTE_MIN (dev->data->nb_rx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ) * -RTE_NB_RXQ_STATS ; - count +=RTE_MIN (dev->data->nb_tx_queues,RTE_ETHDEV_QUEUE_STAT_CNTRS ) * -RTE_NB_TXQ_STATS ; + + count +=get_xstats_basic_count (dev); +return count; }
Signature · 1 line
2.13.6
PATCH v2 2/3 ethdev: fix xstats get by id APIS
xstats _by_id() APIs are broken because ids known by user sent directly to the PMDs.
ethdev xstat get by id APIs:rte_eth_xstats_get_names_by_id() and rte_eth_xstats_get_by_id() work on ids calculated as "basic stats + extended stats"
When an application asking for id less than "basic stats count", it is indeed asking basic stats not extended stats.
The dev_ops PMDs implements work on extended stats ids.
This patch adds a check if all requested stats are xstats and if so converts ids to xstats ids before passing them to PMDs.
This conversion wasn't required before commit 8c49d5f1c219, because _by_id dev_ops were always used to get whole stats via NULL ids.
---
Cc: Ivan Malov <[email protected]>
Cc: Harry Van Haaren <[email protected]>
Cc: Lee Daly <[email protected]>
v2:
* variable renamed, all_ids_from_pmd -> no_basic_stat_requested
* xstats id conversion commented.
--- lib/librte_ether/rte_ethdev.c | 50 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-)
lib/librte_ether/rte_ethdev.c +44 -6
@@ -1644,6 +1644,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, uint64_t *ids) {struct rte_eth_xstat_name *xstats_names_copy; +unsigned int no_basic_stat_requested =1 ;unsigned int expected_entries;struct rte_eth_dev *dev;unsigned int i;
@@ -1663,9 +1664,27 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,if (ids && !xstats_names)return -EINVAL ; -if (dev->dev_ops->xstats_get_names_by_id !=NULL ) -return (*dev->dev_ops->xstats_get_names_by_id)( - dev, xstats_names, ids, size); +if (ids && dev->dev_ops->xstats_get_names_by_id !=NULL && size >0 ) { +unsigned int basic_count =get_xstats_basic_count (dev); +uint64_t ids_copy[size]; + +for (i =0 ; i < size; i++) { +if (ids[i] < basic_count) { + no_basic_stat_requested =0 ; +break ; + } + +/* +* Convert ids to xstats ids that PMD knows. +* ids known by user are basic + extended stats. +*/ + ids_copy[i] = ids[i] - basic_count; + } + +if (no_basic_stat_requested) +return (*dev->dev_ops->xstats_get_names_by_id)(dev, + xstats_names, ids_copy, size); + }/* Retrieve all stats */ if (!ids) {
@@ -1772,6 +1791,7 @@ int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint64_t *values, unsigned int size) { + unsigned int no_basic_stat_requested = 1;unsigned int num_xstats_filled;uint16_t expected_entries;struct rte_eth_dev *dev;
@@ -1793,9 +1813,27 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,if (ids && !values)return -EINVAL ; -if (dev->dev_ops->xstats_get_by_id !=NULL ) -return (*dev->dev_ops->xstats_get_by_id)(dev, ids, values, - size); +if (ids && dev->dev_ops->xstats_get_by_id !=NULL && size) { +unsigned int basic_count =get_xstats_basic_count (dev); +uint64_t ids_copy[size]; + +for (i =0 ; i < size; i++) { +if (ids[i] < basic_count) { + no_basic_stat_requested =0 ; +break ; + } + +/* +* Convert ids to xstats ids that PMD knows. +* ids known by user are basic + extended stats. +*/ + ids_copy[i] = ids[i] - basic_count; + } + +if (no_basic_stat_requested) +return (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, + values, size); + }/* Fill the xstats structure */ num_xstats_filled = rte_eth_xstats_get(port_id, xstats,
Signature · 1 line
2.13.6
PATCH v2 3/3 ethdev: check more errors in xstats retrieval
In reply to Ferruh YigitSome function calls in xstat functions can return negative values to indicate the error, check return values for those cases.
Coverity issue: 195028, 195026
---
Cc: Lee Daly <[email protected]>
--- lib/librte_ether/rte_ethdev.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
lib/librte_ether/rte_ethdev.c +11 -3
@@ -1648,11 +1648,16 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,unsigned int expected_entries;struct rte_eth_dev *dev;unsigned int i; +int ret;RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); - expected_entries =get_xstats_count (port_id); dev = &rte_eth_devices[port_id]; + ret =get_xstats_count (port_id); +if (ret <0 ) +return ret; + expected_entries = (unsigned int )ret; +/* Return max number of stats if no ids given */ if (!ids) {if (!xstats_names)
@@ -1796,6 +1801,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,uint16_t expected_entries;struct rte_eth_dev *dev;unsigned int i; +int ret;RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); expected_entries =get_xstats_count (port_id);
@@ -1836,8 +1842,10 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, }/* Fill the xstats structure */ - num_xstats_filled =rte_eth_xstats_get (port_id, xstats, - expected_entries); + ret =rte_eth_xstats_get (port_id, xstats, expected_entries); +if (ret <0 ) +return ret; + num_xstats_filled = (unsigned int )ret;/* Return all stats */ if (!ids) {
Signature · 1 line
2.13.6
Re: [PATCH v2 2/3] ethdev: fix xstats get by id APIS
In reply to Ferruh Yigit24/10/2017 01:15, Ferruh Yigit:
Quoted 23 lines
xstats
_by_id()APIs are broken because ids known by user sent directly to the PMDs.ethdev xstat get by id APIs:
rte_eth_xstats_get_names_by_id()andrte_eth_xstats_get_by_id()work on ids calculated as "basic stats + extended stats"When an application asking for id less than "basic stats count", it is indeed asking basic stats not extended stats.
The
dev_opsPMDs implements work on extended stats ids.This patch adds a check if all requested stats are xstats and if so converts ids to xstats ids before passing them to PMDs.
This conversion wasn't required before commit
8c49d5f1c219, because_by_iddev_opswere always used to get whole stats via NULL ids.Fixes 8c49d5f1c219 ("ethdev: rework xstats retrieve by id")Signed-off-by Ferruh Yigit <[email protected]>Reviewed-by Ivan Malov <[email protected]>Tested-by Ivan Malov <[email protected]>
Quoted 8 lines
---
Cc: Ivan Malov <[email protected]>
Cc: Harry Van Haaren <[email protected]>
Cc: Lee Daly <[email protected]>v2:
* variable renamed,all_ids_from_pmd->no_basic_stat_requested
* xstats id conversion commented.
A lot more clear :)
Thanks
Quoted 4 lines · Ferruh Yigit
Extract into static inline function so that can be used by other functions.
Signed-off-by Ferruh Yigit <[email protected]>
Series applied to dpdk-next-net/master, thanks.