[dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: add sanity checks when retrieving xstats

Ferruh Yigit ferruh.yigit at intel.com
Thu Jun 14 12:55:08 CEST 2018


On 6/14/2018 7:39 AM, Remy Horton wrote:
> 
> On 13/06/2018 16:39, Ferruh Yigit wrote:
>> On 6/7/2018 9:15 AM, David Marchand wrote:
>>> Testpmd should not expect the xstats names and values arrays to be
>>> aligned: neither the arrays sizes, nor the order in which the values are.
>>
>> As far as I can see this assumption is everywhere in API implementation:
>> xstats names and values are aligned with same order.
>> The basic stat part of the xstats, implemented in ethdev layer, seems relying on
>> same assumption. Also looks like "xstat size" and "xstat_names size" used
>> interchangeably.
>>
>> And I don't see any case that mentions xstats.id is xstats_name index.
>> cc'ed Harry, to get more information about initial intention.
>>
>> the id value in xstats struct looks like duplication, but other than that, is
>> there any downside of using array index to mach name, value pair?
>> And do we really need another layer of indirection (and complexity) to mach
>> simple name,value key pair in xstats?
> 
> When I was working on xstats one of my intentions was to allow PMDs to 
> only return a subset of values for all the keys they declare, with 
> xstats[idx].id==idx just being a coincidence that was not to be relied 
> on.

APIs exist for getting subset of values (.._by_id) but they both assume
requested ids are array index.
As you said this works fine because of xstats[idx].id==idx

struct rte_eth_xstat_name { char name[]; }
struct rte_eth_xstat { uint64_t id; uint64_t value; }

These two structs are for basic key-value match.
But one has the "id" field, but other doesn't. If we use "id" as match, this
will be the index of xstat_name[]. This is extra complexity, and xstats is
already unnecessarily complex.

I am for documenting that "xstat_name" and "xstat" are aligned, both in size and
order, and array indexes are ids, clearly in API doc and continue with existing
implementation. What do you think?

> Since then there appears to have been several instances of rework, 
> so no idea if this coincidence becoming an assumption was intentional or 
> an oversight.
> 
> ..Remy
> 



More information about the dev mailing list