On 8/24/2017 5:29 PM, Ajit Khaparde wrote: > This patch adds support for xstats_get_by_id/xstats_get_names_by_id. > Signed-off-by: Ajit Khaparde <ajit.khapa...@broadcom.com>
<...> > + > +int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t > *ids, > + uint64_t *values, unsigned int limit) > +{ > + /* Account for the Tx drop pkts aka the Anti spoof counter */ > + const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) + > + RTE_DIM(bnxt_tx_stats_strings) + 1; > + struct rte_eth_xstat xstats[stat_cnt]; > + uint16_t i; > + > + bnxt_dev_xstats_get_op(dev, xstats, limit); I guess intention here is to read all xstats, so "stat_cnt" should be used instead of "limit" > + > + for (i = 0; i < limit; i++) { > + if (ids[i] >= stat_cnt) { Current xstats_get_by_id API, which is an interesting one, can call this with ids==NULL. > + RTE_LOG(ERR, PMD, "id value isn't valid"); > + return -1; > + } > + values[i] = xstats[ids[i]].value; > + } > + return limit; if limit is zero, API expects to get number of available xstats, so can't just return limit here. > +} <...>