]> git.droids-corp.org - dpdk.git/commit
ethdev: clarify null location case in xstats get
authorChengwen Feng <fengchengwen@huawei.com>
Fri, 13 May 2022 02:53:49 +0000 (10:53 +0800)
committerAndrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Fri, 20 May 2022 14:45:25 +0000 (16:45 +0200)
commit485df8847a2c0ecf947a514f634b8180b725b827
treef0bccb2b0e22ba475f14c13aa8f5d7860f37e07a
parent2d8699ebb2a0638e8ae18fc0a83c56f984d0b270
ethdev: clarify null location case in xstats get

When xstats location is null in rte_eth_xstats_get() the return value
is not clearly specified.  Some PMDs (eg. hns3/ipn3ke/mvpp2/axgbe) return
zero while others return the required number of elements.

In this patch, special parameter combinations are restricted:
 1. highlight that xstats location may be null if and only if n is 0.
 2. amend n parameter description to specify that if n is lower than
    the required number of elements, the function returns the required
    number of elements.
 3. specify that if n is zero, the xstats must be NULL, the function
    returns the required number of elements (a duplicate which should
    help to not very attentive readers).

Add sanity check for null xstats and non-zero n case on API level to
make it unnecessary to care about it in drivers.

Fixes: ce757f5c9a4d ("ethdev: new method to retrieve extended statistics")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
lib/ethdev/rte_ethdev.c
lib/ethdev/rte_ethdev.h