From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id C19115F5B for ; Wed, 14 Mar 2018 18:21:10 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2018 10:21:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,306,1517904000"; d="scan'208";a="33850705" Received: from fyigit-mobl.ger.corp.intel.com (HELO [10.237.221.62]) ([10.237.221.62]) by FMSMGA003.fm.intel.com with ESMTP; 14 Mar 2018 10:21:08 -0700 To: Tomasz Duszynski , dev@dpdk.org Cc: mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com, jck@semihalf.com, jianbo.liu@arm.com References: <1519222460-14605-1-git-send-email-tdu@semihalf.com> <1520844132-29969-1-git-send-email-tdu@semihalf.com> <1520844132-29969-7-git-send-email-tdu@semihalf.com> From: Ferruh Yigit Message-ID: <8210985b-4898-88f1-2f90-0a69862078c1@intel.com> Date: Wed, 14 Mar 2018 17:21:07 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1520844132-29969-7-git-send-email-tdu@semihalf.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 6/8] net/mrvl: add extended statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Mar 2018 17:21:11 -0000 On 3/12/2018 8:42 AM, Tomasz Duszynski wrote: > Add extended statistics implementation. > > Signed-off-by: Natalie Samsonov > Signed-off-by: Tomasz Duszynski <...> > @@ -1674,6 +1784,94 @@ mrvl_eth_filter_ctrl(struct rte_eth_dev *dev __rte_unused, > } > } > > +/** > + * DPDK callback to get xstats by id. > + * > + * @param dev > + * Pointer to the device structure. > + * @param ids > + * Pointer to the ids table. > + * @param values > + * Pointer to the values table. > + * @param n > + * Values table size. > + * @returns > + * Number of read values, negative value otherwise. > + */ > +static int > +mrvl_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, > + uint64_t *values, unsigned int n) > +{ > + unsigned int i, num = RTE_DIM(mrvl_xstats_tbl); > + uint64_t vals[n]; > + int ret; > + > + if (!ids) { You will not get NULL ids, this case covered by ethdev layer, for both by_id() functions. > + struct rte_eth_xstat xstats[num]; > + int j; > + > + ret = mrvl_xstats_get(dev, xstats, num); > + for (j = 0; j < ret; i++) > + values[j] = xstats[j].value; > + > + return ret; > + } > + > + ret = mrvl_xstats_get_by_id(dev, NULL, vals, n); > + if (ret < 0) > + return ret; > + > + for (i = 0; i < n; i++) { > + if (ids[i] >= num) { > + RTE_LOG(ERR, PMD, "id value is not valid\n"); > + return -1; > + } > + > + values[i] = vals[ids[i]]; > + } > + > + return n; > +} > + > +/** > + * DPDK callback to get xstats names by ids. > + * > + * @param dev > + * Pointer to the device structure. > + * @param xstats_names > + * Pointer to table with xstats names. > + * @param ids > + * Pointer to table with ids. > + * @param size > + * Xstats names table size. > + * @returns > + * Number of names read, negative value otherwise. > + */ > +static int > +mrvl_xstats_get_names_by_id(struct rte_eth_dev *dev, > + struct rte_eth_xstat_name *xstats_names, > + const uint64_t *ids, unsigned int size) > +{ > + unsigned int i, num = RTE_DIM(mrvl_xstats_tbl); > + struct rte_eth_xstat_name names[num]; > + > + if (!ids) > + return mrvl_xstats_get_names(dev, xstats_names, size); > + > + mrvl_xstats_get_names(dev, names, size); > + for (i = 0; i < size; i++) { > + if (ids[i] >= num) { > + RTE_LOG(ERR, PMD, "id value is not valid"); > + return -1; > + } > + > + snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, > + "%s", names[ids[i]].name); > + } > + > + return size; > +} Specific to *_by_id() implementations, please check ethdev layer APIs for these devops, they already do same thing as you did here. These devops are to access specific ids efficiently with support of PMD, if you don't have a quick way to access to an extended stat by id, you may just left these unimplemented and abstraction layer will do the work for you, it is up to you. Thanks, ferruh