[dpdk-dev] [PATCH] ethdev: fix xstats retrieve by id API

Ferruh Yigit ferruh.yigit at intel.com
Wed Oct 11 20:33:02 CEST 2017

On 10/11/2017 8:22 AM, Lee Daly wrote:
> From: Lee <lee.daly at intel.com>
> Fix xstats functions, rte_eth_xstats_get_names_by_id()
> and rte_eth_xstats_get_by_id(), in current implementation
> ethdev level reads all xstat values and filters out
> the ones requested by the application. This behavior doesn't
> benefit from PMD ops and doesn't provide the benefit the
> API was created in the first place for. APIs are also unnecessarily
> complicated. Both APIs have different returns for the same params.
> In this fix, instead of reading all the stats and finding the
> requested value, drivers can provide ops to get selected xstats.
> API no longer crashes with certain params,
> rte_eth_get_by_id returned seg fault with
> "ids = NULL && values != NULL && n<max”
> rte_eth_get_names_by_id returned seg fault with
> "ids = NULL && values != NULL && n=0”
> These now return max number of stats available, matching the other API.
> rte_eth_get_by_id returned seg fault with
> "ids != NULL && values = NULL && n<max”
> This now returns -22,(EINVAL).
> Standardized variable/parameter names between the 2 APIs.
> Overall code complexity reduced.

Fixes: 79c913a42f0e ("ethdev: retrieve xstats by ID")
Cc: kubax.kozak at intel.com

> Signed-off-by: Lee <lee.daly at intel.com>

Please use full name:
Signed-off-by: Lee Daly <lee.daly at intel.com>


> @@ -2472,7 +2472,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,
>   *   - A negative value on error (invalid port id).
>   */
>  int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
> -			     uint64_t *values, unsigned int n);
> +			     uint64_t *values, unsigned int size);

Function doxygen comment also should be updated to reflect this,
otherwise giving a warning.

>  /**
>   * Gets the ID of a statistic from its name.

Except above issues:
Reviewed-by: Ferruh Yigit <ferruh.yigit at intel.com>

Can you please send a new version addressing above issues, feel free to
keep review tag.


More information about the dev mailing list