From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D58A1A0C43; Thu, 30 Sep 2021 18:03:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DBDE041148; Thu, 30 Sep 2021 18:03:32 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 2233041134 for ; Thu, 30 Sep 2021 18:03:31 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id E28987F6DF; Thu, 30 Sep 2021 19:03:30 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 43F827F6D9; Thu, 30 Sep 2021 19:02:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 43F827F6D9 Authentication-Results: shelob.oktetlabs.ru/43F827F6D9; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Igor Russkikh , Somalapuram Amaranath , Rasesh Mody , Shahed Shaikh , Ajit Khaparde , Somnath Kotur , Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Rahul Lakkireddy , Hemant Agrawal , Sachin Saxena , Haiyue Wang , Marcin Wojtas , Michal Krawczyk , Shai Brandes , Evgeny Schemeilin , Igor Chauskin , Gaetan Rivet , Qi Zhang , Xiao Wang , Ziyang Xuan , Xiaoyun Wang , Guoyang Zhou , "Min Hu (Connor)" , Yisen Zhuang , Lijun Ou , Beilei Xing , Jingjing Wu , Qiming Yang , Andrew Boyer , Rosen Xu , Shijith Thotton , Srisivasubramanian Srinivasan , Matan Azrad , Viacheslav Ovsiienko , Liron Himi , Stephen Hemminger , Long Li , Jerin Jacob , Devendra Singh Rawat , Jiawen Wu , Jian Wang , Maxime Coquelin , Chenbo Xia , Yong Wang , Thomas Monjalon , Ferruh Yigit Cc: dev@dpdk.org Date: Thu, 30 Sep 2021 19:01:56 +0300 Message-Id: <20210930160156.961041-9-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210930160156.961041-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210930160156.961041-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 5/5] ethdev: merge driver ops to get all xstats names and by ID X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" All xstats names may be retrieved passing NULL ids. If a driver does not support getting names by IDs, the callback should return -ENOTSUP on attempt to use it. If so, the request is handled on ethdev layer by getting all names and filtering out requested only. Signed-off-by: Andrew Rybchenko --- doc/guides/nics/features.rst | 2 +- drivers/net/atlantic/atl_ethdev.c | 5 ++ drivers/net/axgbe/axgbe_ethdev.c | 30 ++++----- drivers/net/bnx2x/bnx2x_ethdev.c | 4 ++ drivers/net/bnxt/bnxt_stats.c | 4 ++ drivers/net/bnxt/bnxt_stats.h | 1 + drivers/net/cnxk/cnxk_ethdev.c | 1 - drivers/net/cnxk/cnxk_ethdev.h | 5 +- drivers/net/cnxk/cnxk_stats.c | 18 +++--- drivers/net/cxgbe/cxgbe_ethdev.c | 17 ++--- drivers/net/dpaa/dpaa_ethdev.c | 13 ++-- drivers/net/dpaa2/dpaa2_ethdev.c | 13 ++-- drivers/net/e1000/igb_ethdev.c | 36 +++-------- drivers/net/ena/ena_ethdev.c | 6 +- drivers/net/failsafe/failsafe_ops.c | 5 +- drivers/net/fm10k/fm10k_ethdev.c | 4 ++ drivers/net/hinic/hinic_pmd_ethdev.c | 4 ++ drivers/net/hns3/hns3_ethdev.c | 1 - drivers/net/hns3/hns3_ethdev_vf.c | 1 - drivers/net/hns3/hns3_stats.c | 22 +++---- drivers/net/hns3/hns3_stats.h | 10 +-- drivers/net/i40e/i40e_ethdev.c | 5 ++ drivers/net/iavf/iavf_ethdev.c | 13 ++-- drivers/net/ice/ice_ethdev.c | 5 ++ drivers/net/igc/igc_ethdev.c | 10 +-- drivers/net/ionic/ionic_ethdev.c | 25 +------- drivers/net/ipn3ke/ipn3ke_representor.c | 5 +- drivers/net/ixgbe/ixgbe_ethdev.c | 71 +++------------------ drivers/net/liquidio/lio_ethdev.c | 4 ++ drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_stats.c | 7 ++- drivers/net/mvpp2/mrvl_ethdev.c | 4 ++ drivers/net/netvsc/hn_ethdev.c | 5 +- drivers/net/octeontx2/otx2_ethdev.c | 1 - drivers/net/octeontx2/otx2_ethdev.h | 5 +- drivers/net/octeontx2/otx2_stats.c | 14 ++--- drivers/net/qede/qede_ethdev.c | 4 ++ drivers/net/sfc/sfc_ethdev.c | 84 ++++++++++++------------- drivers/net/txgbe/txgbe_ethdev.c | 7 +-- drivers/net/txgbe/txgbe_ethdev_vf.c | 4 ++ drivers/net/vhost/rte_eth_vhost.c | 4 ++ drivers/net/virtio/virtio_ethdev.c | 5 ++ drivers/net/vmxnet3/vmxnet3_ethdev.c | 5 ++ lib/ethdev/ethdev_driver.h | 17 ++--- lib/ethdev/rte_ethdev.c | 17 +++-- 45 files changed, 238 insertions(+), 286 deletions(-) diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst index 4fce8cd1c9..8fef2939fb 100644 --- a/doc/guides/nics/features.rst +++ b/doc/guides/nics/features.rst @@ -708,7 +708,7 @@ Extended stats Supports Extended Statistics, changes from driver to driver. * **[implements] eth_dev_ops**: ``xstats_get``, ``xstats_reset``, ``xstats_get_names``. -* **[implements] eth_dev_ops**: ``xstats_get_by_id``, ``xstats_get_names_by_id``. +* **[implements] eth_dev_ops**: ``xstats_get_by_id``. * **[related] API**: ``rte_eth_xstats_get()``, ``rte_eth_xstats_reset()``, ``rte_eth_xstats_get_names``, ``rte_eth_xstats_get_by_id()``, ``rte_eth_xstats_get_names_by_id()``, ``rte_eth_xstats_get_id_by_name()``. diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 0ce35eb519..f55d18ae9a 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -29,6 +29,7 @@ static int atl_dev_allmulticast_disable(struct rte_eth_dev *dev); static int atl_dev_link_update(struct rte_eth_dev *dev, int wait); static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int size); @@ -1003,12 +1004,16 @@ atl_dev_xstats_get_count(struct rte_eth_dev *dev) static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int size) { unsigned int i; unsigned int count = atl_dev_xstats_get_count(dev); + if (ids != NULL) + return -ENOTSUP; + if (xstats_names) { for (i = 0; i < size && i < count; i++) { snprintf(xstats_names[i].name, diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index ebd5411fdd..6a55a211df 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -47,19 +47,14 @@ static int axgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, unsigned int n); static int -axgbe_dev_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int size); -static int axgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int n); static int -axgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - unsigned int size); +axgbe_dev_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int size); static int axgbe_dev_xstats_reset(struct rte_eth_dev *dev); static int axgbe_dev_rss_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, @@ -239,7 +234,6 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = { .xstats_get = axgbe_dev_xstats_get, .xstats_reset = axgbe_dev_xstats_reset, .xstats_get_names = axgbe_dev_xstats_get_names, - .xstats_get_names_by_id = axgbe_dev_xstats_get_names_by_id, .xstats_get_by_id = axgbe_dev_xstats_get_by_id, .reta_update = axgbe_dev_rss_reta_update, .reta_query = axgbe_dev_rss_reta_query, @@ -1022,9 +1016,9 @@ axgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, } static int -axgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int n) +axgbe_dev_xstats_get_all_names(__rte_unused struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + unsigned int n) { unsigned int i; @@ -1075,18 +1069,18 @@ axgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, } static int -axgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - unsigned int size) +axgbe_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int size) { struct rte_eth_xstat_name xstats_names_copy[AXGBE_XSTATS_COUNT]; unsigned int i; if (!ids) - return axgbe_dev_xstats_get_names(dev, xstats_names, size); + return axgbe_dev_xstats_get_all_names(dev, xstats_names, size); - axgbe_dev_xstats_get_names(dev, xstats_names_copy, size); + axgbe_dev_xstats_get_all_names(dev, xstats_names_copy, size); for (i = 0; i < size; i++) { if (ids[i] >= AXGBE_XSTATS_COUNT) { diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c index 463886f17a..b18d14d735 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -484,11 +484,15 @@ bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) static int bnx2x_get_xstats_names(__rte_unused struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit) { unsigned int i, stat_cnt = RTE_DIM(bnx2x_xstats_strings); + if (ids != NULL) + return -ENOTSUP; + if (xstats_names != NULL) for (i = 0; i < stat_cnt; i++) strlcpy(xstats_names[i].name, diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 991eafc644..aca350402b 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -845,6 +845,7 @@ int bnxt_flow_stats_cnt(struct bnxt *bp) } int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int limit) { @@ -862,6 +863,9 @@ int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, if (rc) return rc; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names != NULL) { count = 0; diff --git a/drivers/net/bnxt/bnxt_stats.h b/drivers/net/bnxt/bnxt_stats.h index 1ca9b9c594..497380ae2d 100644 --- a/drivers/net/bnxt/bnxt_stats.h +++ b/drivers/net/bnxt/bnxt_stats.h @@ -13,6 +13,7 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, struct rte_eth_stats *bnxt_stats); int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev); int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int limit); int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index 8629193d50..c208611e88 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1258,7 +1258,6 @@ struct eth_dev_ops cnxk_eth_dev_ops = { .xstats_get_names = cnxk_nix_xstats_get_names, .xstats_reset = cnxk_nix_xstats_reset, .xstats_get_by_id = cnxk_nix_xstats_get_by_id, - .xstats_get_names_by_id = cnxk_nix_xstats_get_names_by_id, .fw_version_get = cnxk_nix_fw_version_get, .rxq_info_get = cnxk_nix_rxq_info_get, .txq_info_get = cnxk_nix_txq_info_get, diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h index 946629f72e..1165482baf 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -362,12 +362,9 @@ int cnxk_nix_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); int cnxk_nix_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, unsigned int n); int cnxk_nix_xstats_get_names(struct rte_eth_dev *eth_dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit); -int cnxk_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit); int cnxk_nix_xstats_get_by_id(struct rte_eth_dev *eth_dev, const uint64_t *ids, uint64_t *values, unsigned int n); int cnxk_nix_xstats_reset(struct rte_eth_dev *eth_dev); diff --git a/drivers/net/cnxk/cnxk_stats.c b/drivers/net/cnxk/cnxk_stats.c index 4b0deac05e..ae3eef3628 100644 --- a/drivers/net/cnxk/cnxk_stats.c +++ b/drivers/net/cnxk/cnxk_stats.c @@ -162,10 +162,10 @@ cnxk_nix_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, return size; } -int -cnxk_nix_xstats_get_names(struct rte_eth_dev *eth_dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit) +static int +cnxk_nix_xstats_get_all_names(struct rte_eth_dev *eth_dev, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit) { struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); struct roc_nix_xstat_name roc_xstats_name[limit]; @@ -226,10 +226,10 @@ cnxk_nix_xstats_get_names(struct rte_eth_dev *eth_dev, } int -cnxk_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit) +cnxk_nix_xstats_get_names(struct rte_eth_dev *eth_dev, + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit) { struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); uint32_t nix_cnt = roc_nix_num_xstats_get(&dev->nix); @@ -247,7 +247,7 @@ cnxk_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, if (xstats_names == NULL) return -ENOMEM; - cnxk_nix_xstats_get_names(eth_dev, xnames, stat_cnt); + cnxk_nix_xstats_get_all_names(eth_dev, xnames, stat_cnt); for (i = 0; i < limit; i++) { if (ids[i] >= stat_cnt) diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 4929766d9a..371550069e 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -1005,10 +1005,10 @@ static int cxgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, } /* Get names of port extended statistics by ID. */ -static int cxgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xnames, - unsigned int n) +static int cxgbe_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, + struct rte_eth_xstat_name *xnames, + unsigned int n) { struct port_info *pi = dev->data->dev_private; struct rte_eth_xstat_name *xnames_copy; @@ -1048,14 +1048,6 @@ static int cxgbe_dev_xstats_get(struct rte_eth_dev *dev, return cxgbe_dev_xstats(dev, NULL, xstats, n); } -/* Get names of port extended statistics. */ -static int cxgbe_dev_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int n) -{ - return cxgbe_dev_xstats(dev, xstats_names, NULL, n); -} - /* Reset port extended statistics. */ static int cxgbe_dev_xstats_reset(struct rte_eth_dev *dev) { @@ -1620,7 +1612,6 @@ static const struct eth_dev_ops cxgbe_eth_dev_ops = { .xstats_get = cxgbe_dev_xstats_get, .xstats_get_by_id = cxgbe_dev_xstats_get_by_id, .xstats_get_names = cxgbe_dev_xstats_get_names, - .xstats_get_names_by_id = cxgbe_dev_xstats_get_names_by_id, .xstats_reset = cxgbe_dev_xstats_reset, .flow_ctrl_get = cxgbe_flow_ctrl_get, .flow_ctrl_set = cxgbe_flow_ctrl_set, diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 1f80e8d744..06e293b17f 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -758,9 +758,9 @@ dpaa_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, } static int -dpaa_xstats_get_names(__rte_unused struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit) +dpaa_xstats_get_all_names(__rte_unused struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit) { unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings); @@ -813,7 +813,7 @@ dpaa_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, } static int -dpaa_xstats_get_names_by_id( +dpaa_xstats_get_names( struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, @@ -823,9 +823,9 @@ dpaa_xstats_get_names_by_id( struct rte_eth_xstat_name xstats_names_copy[stat_cnt]; if (!ids) - return dpaa_xstats_get_names(dev, xstats_names, limit); + return dpaa_xstats_get_all_names(dev, xstats_names, limit); - dpaa_xstats_get_names(dev, xstats_names_copy, limit); + dpaa_xstats_get_all_names(dev, xstats_names_copy, limit); for (i = 0; i < limit; i++) { if (ids[i] >= stat_cnt) { @@ -1585,7 +1585,6 @@ static struct eth_dev_ops dpaa_devops = { .stats_get = dpaa_eth_stats_get, .xstats_get = dpaa_dev_xstats_get, .xstats_get_by_id = dpaa_xstats_get_by_id, - .xstats_get_names_by_id = dpaa_xstats_get_names_by_id, .xstats_get_names = dpaa_xstats_get_names, .xstats_reset = dpaa_eth_stats_reset, .stats_reset = dpaa_eth_stats_reset, diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index ea191564fc..9aaeb0bc17 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -1711,9 +1711,9 @@ dpaa2_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, } static int -dpaa2_xstats_get_names(__rte_unused struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit) +dpaa2_xstats_get_all_names(__rte_unused struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit) { unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings); @@ -1793,7 +1793,7 @@ dpaa2_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, } static int -dpaa2_xstats_get_names_by_id( +dpaa2_xstats_get_names( struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, @@ -1803,9 +1803,9 @@ dpaa2_xstats_get_names_by_id( struct rte_eth_xstat_name xstats_names_copy[stat_cnt]; if (!ids) - return dpaa2_xstats_get_names(dev, xstats_names, limit); + return dpaa2_xstats_get_all_names(dev, xstats_names, limit); - dpaa2_xstats_get_names(dev, xstats_names_copy, limit); + dpaa2_xstats_get_all_names(dev, xstats_names_copy, limit); for (i = 0; i < limit; i++) { if (ids[i] >= stat_cnt) { @@ -2413,7 +2413,6 @@ static struct eth_dev_ops dpaa2_ethdev_ops = { .stats_get = dpaa2_dev_stats_get, .xstats_get = dpaa2_dev_xstats_get, .xstats_get_by_id = dpaa2_xstats_get_by_id, - .xstats_get_names_by_id = dpaa2_xstats_get_names_by_id, .xstats_get_names = dpaa2_xstats_get_names, .stats_reset = dpaa2_dev_stats_reset, .xstats_reset = dpaa2_dev_stats_reset, diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 6510cd7ceb..8bf254a802 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -93,9 +93,6 @@ static int eth_igb_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int n); static int eth_igb_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int size); -static int eth_igb_xstats_get_names_by_id(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit); static int eth_igb_stats_reset(struct rte_eth_dev *dev); @@ -166,6 +163,7 @@ static int eth_igbvf_stats_get(struct rte_eth_dev *dev, static int eth_igbvf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); static int eth_igbvf_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned limit); static int eth_igbvf_stats_reset(struct rte_eth_dev *dev); @@ -343,7 +341,6 @@ static const struct eth_dev_ops eth_igb_ops = { .stats_get = eth_igb_stats_get, .xstats_get = eth_igb_xstats_get, .xstats_get_by_id = eth_igb_xstats_get_by_id, - .xstats_get_names_by_id = eth_igb_xstats_get_names_by_id, .xstats_get_names = eth_igb_xstats_get_names, .stats_reset = eth_igb_stats_reset, .xstats_reset = eth_igb_xstats_reset, @@ -1863,26 +1860,7 @@ eth_igb_xstats_reset(struct rte_eth_dev *dev) return 0; } -static int eth_igb_xstats_get_names(__rte_unused struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int size) -{ - unsigned i; - - if (xstats_names == NULL) - return IGB_NB_XSTATS; - - /* Note: limit checked in rte_eth_xstats_names() */ - - for (i = 0; i < IGB_NB_XSTATS; i++) { - strlcpy(xstats_names[i].name, rte_igb_stats_strings[i].name, - sizeof(xstats_names[i].name)); - } - - return IGB_NB_XSTATS; -} - -static int eth_igb_xstats_get_names_by_id(struct rte_eth_dev *dev, +static int eth_igb_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit) { @@ -1902,7 +1880,7 @@ static int eth_igb_xstats_get_names_by_id(struct rte_eth_dev *dev, } else { struct rte_eth_xstat_name xstats_names_copy[IGB_NB_XSTATS]; - eth_igb_xstats_get_names_by_id(dev, NULL, xstats_names_copy, + eth_igb_xstats_get_names(dev, NULL, xstats_names_copy, IGB_NB_XSTATS); for (i = 0; i < limit; i++) { @@ -2035,11 +2013,15 @@ igbvf_read_stats_registers(struct e1000_hw *hw, struct e1000_vf_stats *hw_stats) } static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned limit) + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned limit) { unsigned i; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names != NULL) for (i = 0; i < IGBVF_NB_XSTATS; i++) { strlcpy(xstats_names[i].name, diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 4cebf60a68..a807e50dba 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -212,7 +212,7 @@ static void ena_interrupt_handler_rte(void *cb_arg); static void ena_timer_wd_callback(struct rte_timer *timer, void *arg); static void ena_destroy_device(struct rte_eth_dev *eth_dev); static int eth_ena_dev_init(struct rte_eth_dev *eth_dev); -static int ena_xstats_get_names(struct rte_eth_dev *dev, +static int ena_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int n); static int ena_xstats_get(struct rte_eth_dev *dev, @@ -2585,12 +2585,16 @@ int ena_copy_eni_stats(struct ena_adapter *adapter) * Number of xstats names. */ static int ena_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int n) { unsigned int xstats_count = ena_xstats_calc_num(dev->data); unsigned int stat, i, count = 0; + if (ids != NULL) + return -ENOTSUP; + if (n < xstats_count || !xstats_names) return xstats_count; diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 5ff33e03e0..dae85b7677 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -990,12 +990,15 @@ __fs_xstats_get_names(struct rte_eth_dev *dev, } static int -fs_xstats_get_names(struct rte_eth_dev *dev, +fs_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit) { int ret; + if (ids != NULL) + return -ENOTSUP; + fs_lock(dev, 0); ret = __fs_xstats_get_names(dev, xstats_names, limit); fs_unlock(dev, 0); diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 3236290e40..16af1751f9 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -1232,11 +1232,15 @@ fm10k_link_update(struct rte_eth_dev *dev, } static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit) { unsigned i, q; unsigned count = 0; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names != NULL) { /* Note: limit checked in rte_eth_xstats_names() */ diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c index c01e2ec1d4..bc6f07d070 100644 --- a/drivers/net/hinic/hinic_pmd_ethdev.c +++ b/drivers/net/hinic/hinic_pmd_ethdev.c @@ -2280,6 +2280,7 @@ static void hinic_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, * Number of xstats names. */ static int hinic_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int limit) { @@ -2287,6 +2288,9 @@ static int hinic_dev_xstats_get_names(struct rte_eth_dev *dev, int count = 0; u16 i = 0, q_num; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names == NULL) return hinic_xstats_calc_num(nic_dev); diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 7d37004972..87ae92080f 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -7413,7 +7413,6 @@ static const struct eth_dev_ops hns3_eth_dev_ops = { .xstats_get_names = hns3_dev_xstats_get_names, .xstats_reset = hns3_dev_xstats_reset, .xstats_get_by_id = hns3_dev_xstats_get_by_id, - .xstats_get_names_by_id = hns3_dev_xstats_get_names_by_id, .dev_infos_get = hns3_dev_infos_get, .fw_version_get = hns3_fw_version_get, .rx_queue_setup = hns3_rx_queue_setup, diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 8d9b7979c8..d65236e003 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2905,7 +2905,6 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = { .xstats_get_names = hns3_dev_xstats_get_names, .xstats_reset = hns3_dev_xstats_reset, .xstats_get_by_id = hns3_dev_xstats_get_by_id, - .xstats_get_names_by_id = hns3_dev_xstats_get_names_by_id, .dev_infos_get = hns3vf_dev_infos_get, .fw_version_get = hns3vf_fw_version_get, .rx_queue_setup = hns3_rx_queue_setup, diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index 0fe853d626..abb2d42144 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -1189,7 +1189,7 @@ hns3_imissed_stats_name_get(struct rte_eth_dev *dev, } /* - * Retrieve names of extended statistics of an Ethernet device. + * Retrieve all names of extended statistics of an Ethernet device. * * There is an assumption that 'xstat_names' and 'xstats' arrays are matched * by array index: @@ -1212,10 +1212,10 @@ hns3_imissed_stats_name_get(struct rte_eth_dev *dev, * - A positive value lower or equal to size: success. The return value * is the number of entries filled in the stats table. */ -int -hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int size) +static int +hns3_dev_xstats_get_all_names(struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int size) { struct hns3_adapter *hns = dev->data->dev_private; int cnt_stats = hns3_xstats_calc_num(dev); @@ -1382,10 +1382,9 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, * shall not be used by the caller. */ int -hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - uint32_t size) +hns3_dev_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + uint32_t size) { const uint32_t cnt_stats = hns3_xstats_calc_num(dev); struct hns3_adapter *hns = dev->data->dev_private; @@ -1401,7 +1400,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, if (size < cnt_stats) return cnt_stats; - return hns3_dev_xstats_get_names(dev, xstats_names, cnt_stats); + return hns3_dev_xstats_get_all_names(dev, xstats_names, + cnt_stats); } len = cnt_stats * sizeof(struct rte_eth_xstat_name); @@ -1412,7 +1412,7 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, return -ENOMEM; } - (void)hns3_dev_xstats_get_names(dev, names_copy, cnt_stats); + (void)hns3_dev_xstats_get_all_names(dev, names_copy, cnt_stats); for (i = 0; i < size; i++) { if (ids[i] >= cnt_stats) { diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h index d1230f94cb..53fd1572f0 100644 --- a/drivers/net/hns3/hns3_stats.h +++ b/drivers/net/hns3/hns3_stats.h @@ -153,17 +153,13 @@ int hns3_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned int n); int hns3_dev_xstats_reset(struct rte_eth_dev *dev); -int hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int size); int hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, uint32_t size); -int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - uint32_t size); +int hns3_dev_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int size); int hns3_stats_reset(struct rte_eth_dev *dev); int hns3_tqp_stats_init(struct hns3_hw *hw); void hns3_tqp_stats_uninit(struct hns3_hw *hw); diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 7a2a8281d2..832c9bff01 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -258,6 +258,7 @@ static int i40e_dev_stats_get(struct rte_eth_dev *dev, static int i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); static int i40e_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned limit); static int i40e_dev_stats_reset(struct rte_eth_dev *dev); @@ -3567,12 +3568,16 @@ i40e_xstats_calc_num(void) } static int i40e_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit) { unsigned count = 0; unsigned i, prio; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names == NULL) return i40e_xstats_calc_num(); diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 5a5a7f59e1..a7be7abf1a 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -87,8 +87,9 @@ static int iavf_dev_stats_reset(struct rte_eth_dev *dev); static int iavf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned int n); static int iavf_dev_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit); + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit); static int iavf_dev_promiscuous_enable(struct rte_eth_dev *dev); static int iavf_dev_promiscuous_disable(struct rte_eth_dev *dev); static int iavf_dev_allmulticast_enable(struct rte_eth_dev *dev); @@ -1611,11 +1612,15 @@ iavf_dev_stats_reset(struct rte_eth_dev *dev) } static int iavf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int limit) + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) { unsigned int i; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names != NULL) for (i = 0; i < IAVF_NB_XSTATS; i++) { snprintf(xstats_names[i].name, diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index ea3b5c02aa..adeb5a00f3 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -145,6 +145,7 @@ static int ice_stats_reset(struct rte_eth_dev *dev); static int ice_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned int n); static int ice_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit); static int ice_dev_flow_ops_get(struct rte_eth_dev *dev, @@ -5420,12 +5421,16 @@ ice_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, } static int ice_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int limit) { unsigned int count = 0; unsigned int i; + if (ids != NULL) + return -ENOTSUP; + if (!xstats_names) return ice_xstats_calc_num(); diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c index be2c066111..969e515a5f 100644 --- a/drivers/net/igc/igc_ethdev.c +++ b/drivers/net/igc/igc_ethdev.c @@ -213,9 +213,6 @@ static int eth_igc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int n); static int eth_igc_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int size); -static int eth_igc_xstats_get_names_by_id(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit); static int eth_igc_xstats_reset(struct rte_eth_dev *dev); @@ -280,7 +277,6 @@ static const struct eth_dev_ops eth_igc_ops = { .stats_get = eth_igc_stats_get, .xstats_get = eth_igc_xstats_get, .xstats_get_by_id = eth_igc_xstats_get_by_id, - .xstats_get_names_by_id = eth_igc_xstats_get_names_by_id, .xstats_get_names = eth_igc_xstats_get_names, .stats_reset = eth_igc_xstats_reset, .xstats_reset = eth_igc_xstats_reset, @@ -1991,7 +1987,7 @@ eth_igc_xstats_reset(struct rte_eth_dev *dev) } static int -eth_igc_xstats_get_names(__rte_unused struct rte_eth_dev *dev, +eth_igc_xstats_get_all_names(__rte_unused struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, unsigned int size) { unsigned int i; @@ -2012,14 +2008,14 @@ eth_igc_xstats_get_names(__rte_unused struct rte_eth_dev *dev, } static int -eth_igc_xstats_get_names_by_id(struct rte_eth_dev *dev, +eth_igc_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit) { unsigned int i; if (!ids) - return eth_igc_xstats_get_names(dev, xstats_names, limit); + return eth_igc_xstats_get_all_names(dev, xstats_names, limit); for (i = 0; i < limit; i++) { if (ids[i] >= IGC_NB_XSTATS) { diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c index 344c076f30..d813e9f909 100644 --- a/drivers/net/ionic/ionic_ethdev.c +++ b/drivers/net/ionic/ionic_ethdev.c @@ -50,8 +50,6 @@ static int ionic_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int n); static int ionic_dev_xstats_reset(struct rte_eth_dev *dev); static int ionic_dev_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, unsigned int size); -static int ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit); static int ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev, @@ -119,7 +117,6 @@ static const struct eth_dev_ops ionic_eth_dev_ops = { .xstats_get_by_id = ionic_dev_xstats_get_by_id, .xstats_reset = ionic_dev_xstats_reset, .xstats_get_names = ionic_dev_xstats_get_names, - .xstats_get_names_by_id = ionic_dev_xstats_get_names_by_id, .fw_version_get = ionic_dev_fw_version_get, }; @@ -714,25 +711,7 @@ ionic_dev_stats_reset(struct rte_eth_dev *eth_dev) } static int -ionic_dev_xstats_get_names(__rte_unused struct rte_eth_dev *eth_dev, - struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int size) -{ - unsigned int i; - - if (xstats_names != NULL) { - for (i = 0; i < IONIC_NB_HW_STATS; i++) { - snprintf(xstats_names[i].name, - sizeof(xstats_names[i].name), - "%s", rte_ionic_xstats_strings[i].name); - } - } - - return IONIC_NB_HW_STATS; -} - -static int -ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, +ionic_dev_xstats_get_names(struct rte_eth_dev *eth_dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit) { @@ -751,7 +730,7 @@ ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, return IONIC_NB_HW_STATS; } - ionic_dev_xstats_get_names_by_id(eth_dev, NULL, xstats_names_copy, + ionic_dev_xstats_get_names(eth_dev, NULL, xstats_names_copy, IONIC_NB_HW_STATS); for (i = 0; i < limit; i++) { diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c index 589d9fa587..5312b955d6 100644 --- a/drivers/net/ipn3ke/ipn3ke_representor.c +++ b/drivers/net/ipn3ke/ipn3ke_representor.c @@ -2329,13 +2329,16 @@ ipn3ke_rpst_xstats_get static int ipn3ke_rpst_xstats_get_names -(__rte_unused struct rte_eth_dev *dev, +(__rte_unused struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int limit) { unsigned int count = 0; unsigned int i, prio; + if (ids != NULL) + return -ENOTSUP; + if (!xstats_names) return ipn3ke_rpst_xstats_calc_num(); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index aae8b55d83..51b86ea5ce 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -167,15 +167,12 @@ ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, static int ixgbe_dev_stats_reset(struct rte_eth_dev *dev); static int ixgbe_dev_xstats_reset(struct rte_eth_dev *dev); static int ixgbe_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int size); static int ixgbevf_dev_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, unsigned limit); -static int ixgbe_dev_xstats_get_names_by_id( - struct rte_eth_dev *dev, const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit); + struct rte_eth_xstat_name *xstats_names, unsigned limit); static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id, uint8_t stat_idx, @@ -499,7 +496,6 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = { .stats_reset = ixgbe_dev_stats_reset, .xstats_reset = ixgbe_dev_xstats_reset, .xstats_get_names = ixgbe_dev_xstats_get_names, - .xstats_get_names_by_id = ixgbe_dev_xstats_get_names_by_id, .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set, .fw_version_get = ixgbe_fw_version_get, .dev_infos_get = ixgbe_dev_info_get, @@ -3381,61 +3377,7 @@ ixgbe_xstats_calc_num(void) { (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES); } -static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int size) -{ - const unsigned cnt_stats = ixgbe_xstats_calc_num(); - unsigned stat, i, count; - - if (xstats_names != NULL) { - count = 0; - - /* Note: limit >= cnt_stats checked upstream - * in rte_eth_xstats_names() - */ - - /* Extended stats from ixgbe_hw_stats */ - for (i = 0; i < IXGBE_NB_HW_STATS; i++) { - strlcpy(xstats_names[count].name, - rte_ixgbe_stats_strings[i].name, - sizeof(xstats_names[count].name)); - count++; - } - - /* MACsec Stats */ - for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) { - strlcpy(xstats_names[count].name, - rte_ixgbe_macsec_strings[i].name, - sizeof(xstats_names[count].name)); - count++; - } - - /* RX Priority Stats */ - for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) { - for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "rx_priority%u_%s", i, - rte_ixgbe_rxq_strings[stat].name); - count++; - } - } - - /* TX Priority Stats */ - for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) { - for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), - "tx_priority%u_%s", i, - rte_ixgbe_txq_strings[stat].name); - count++; - } - } - } - return cnt_stats; -} - -static int ixgbe_dev_xstats_get_names_by_id( +static int ixgbe_dev_xstats_get_names( struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, @@ -3497,8 +3439,7 @@ static int ixgbe_dev_xstats_get_names_by_id( uint16_t size = ixgbe_xstats_calc_num(); struct rte_eth_xstat_name xstats_names_copy[size]; - ixgbe_dev_xstats_get_names_by_id(dev, NULL, xstats_names_copy, - size); + ixgbe_dev_xstats_get_names(dev, NULL, xstats_names_copy, size); for (i = 0; i < limit; i++) { if (ids[i] >= size) { @@ -3512,6 +3453,7 @@ static int ixgbe_dev_xstats_get_names_by_id( } static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned limit) { unsigned i; @@ -3519,6 +3461,9 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL) return -ENOMEM; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names != NULL) for (i = 0; i < IXGBEVF_NB_XSTATS; i++) strlcpy(xstats_names[i].name, diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index b72060a449..68b674c2a6 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -214,6 +214,7 @@ lio_dev_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, static int lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned limit __rte_unused) { @@ -226,6 +227,9 @@ lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev, return -EINVAL; } + if (ids != NULL) + return -ENOTSUP; + if (xstats_names == NULL) return LIO_NB_XSTATS; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 3581414b78..4eab2554bc 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1620,6 +1620,7 @@ int mlx5_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, unsigned int n); int mlx5_xstats_reset(struct rte_eth_dev *dev); int mlx5_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int n); diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index ae2f5668a7..d67afd6bc1 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -260,6 +260,8 @@ mlx5_xstats_reset(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. + * @param ids + * Array of xstats IDs to get names * @param[out] xstats_names * Buffer to insert names into. * @param n @@ -269,7 +271,7 @@ mlx5_xstats_reset(struct rte_eth_dev *dev) * Number of xstats names. */ int -mlx5_xstats_get_names(struct rte_eth_dev *dev, +mlx5_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int n) { unsigned int i; @@ -277,6 +279,9 @@ mlx5_xstats_get_names(struct rte_eth_dev *dev, struct mlx5_xstats_ctrl *xstats_ctrl = &priv->xstats_ctrl; unsigned int mlx5_xstats_n = xstats_ctrl->mlx5_stats_n; + if (ids != NULL) + return -ENOTSUP; + if (n >= mlx5_xstats_n && xstats_names) { for (i = 0; i != mlx5_xstats_n; ++i) { strncpy(xstats_names[i].name, diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 078aefbb8d..554aba1be9 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -1689,11 +1689,15 @@ mrvl_xstats_reset(struct rte_eth_dev *dev) */ static int mrvl_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int size) { unsigned int i; + if (ids != NULL) + return -ENOTSUP; + if (!xstats_names) return RTE_DIM(mrvl_xstats_tbl); diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 9e2a405973..4260f0b4ab 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -851,13 +851,16 @@ hn_dev_xstats_count(struct rte_eth_dev *dev) } static int -hn_dev_xstats_get_names(struct rte_eth_dev *dev, +hn_dev_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit) { unsigned int i, t, count = 0; int ret; + if (ids != NULL) + return -ENOTSUP; + if (!xstats_names) return hn_dev_xstats_count(dev); diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index 75d4cabf2e..c1fd2ad7d5 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -2338,7 +2338,6 @@ static const struct eth_dev_ops otx2_eth_dev_ops = { .xstats_get_names = otx2_nix_xstats_get_names, .xstats_reset = otx2_nix_xstats_reset, .xstats_get_by_id = otx2_nix_xstats_get_by_id, - .xstats_get_names_by_id = otx2_nix_xstats_get_names_by_id, .rxq_info_get = otx2_nix_rxq_info_get, .txq_info_get = otx2_nix_txq_info_get, .rx_burst_mode_get = otx2_rx_burst_mode_get, diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h index b1575f59a2..1eeb77c9dd 100644 --- a/drivers/net/octeontx2/otx2_ethdev.h +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -506,6 +506,7 @@ int otx2_nix_queue_stats_mapping(struct rte_eth_dev *dev, int otx2_nix_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, unsigned int n); int otx2_nix_xstats_get_names(struct rte_eth_dev *eth_dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit); int otx2_nix_xstats_reset(struct rte_eth_dev *eth_dev); @@ -513,10 +514,6 @@ int otx2_nix_xstats_reset(struct rte_eth_dev *eth_dev); int otx2_nix_xstats_get_by_id(struct rte_eth_dev *eth_dev, const uint64_t *ids, uint64_t *values, unsigned int n); -int otx2_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit); /* RSS */ void otx2_nix_rss_set_key(struct otx2_eth_dev *dev, diff --git a/drivers/net/octeontx2/otx2_stats.c b/drivers/net/octeontx2/otx2_stats.c index 3adf21608c..70bfaa3d77 100644 --- a/drivers/net/octeontx2/otx2_stats.c +++ b/drivers/net/octeontx2/otx2_stats.c @@ -200,8 +200,8 @@ otx2_nix_xstats_get(struct rte_eth_dev *eth_dev, return count; } -int -otx2_nix_xstats_get_names(struct rte_eth_dev *eth_dev, +static int +otx2_nix_xstats_get_all_names(struct rte_eth_dev *eth_dev, struct rte_eth_xstat_name *xstats_names, unsigned int limit) { @@ -239,10 +239,10 @@ otx2_nix_xstats_get_names(struct rte_eth_dev *eth_dev, } int -otx2_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - unsigned int limit) +otx2_nix_xstats_get_names(struct rte_eth_dev *eth_dev, + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit) { struct rte_eth_xstat_name xstats_names_copy[OTX2_NIX_NUM_XSTATS_REG]; uint16_t i; @@ -256,7 +256,7 @@ otx2_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, if (xstats_names == NULL) return -ENOMEM; - otx2_nix_xstats_get_names(eth_dev, xstats_names_copy, limit); + otx2_nix_xstats_get_all_names(eth_dev, xstats_names_copy, limit); for (i = 0; i < OTX2_NIX_NUM_XSTATS_REG; i++) { if (ids[i] >= OTX2_NIX_NUM_XSTATS_REG) { diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index a4304e0eff..40443b30bf 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -1718,6 +1718,7 @@ qede_get_xstats_count(struct qede_dev *qdev) { static int qede_get_xstats_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int limit) { @@ -1726,6 +1727,9 @@ qede_get_xstats_names(struct rte_eth_dev *dev, const unsigned int stat_cnt = qede_get_xstats_count(qdev); unsigned int i, qid, hw_fn, stat_idx = 0; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names == NULL) return stat_cnt; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index f212ca8ad6..d05a1fb5ca 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -763,43 +763,6 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, return nb_supported; } -static int -sfc_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - unsigned int xstats_count) -{ - struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); - struct sfc_port *port = &sa->port; - unsigned int i; - unsigned int nstats = 0; - unsigned int nb_written = 0; - int ret; - - if (unlikely(xstats_names == NULL)) - return sfc_xstats_get_nb_supported(sa); - - for (i = 0; i < EFX_MAC_NSTATS; ++i) { - if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) { - if (nstats < xstats_count) { - strlcpy(xstats_names[nstats].name, - efx_mac_stat_name(sa->nic, i), - sizeof(xstats_names[0].name)); - nb_written++; - } - nstats++; - } - } - - ret = sfc_sw_xstats_get_names(sa, xstats_names, xstats_count, - &nb_written, &nstats); - if (ret != 0) { - SFC_ASSERT(ret < 0); - return ret; - } - - return nstats; -} - static int sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int n) @@ -837,10 +800,42 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, } static int -sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, - const uint64_t *ids, - struct rte_eth_xstat_name *xstats_names, - unsigned int size) +sfc_xstats_get_all_names(struct sfc_adapter *sa, + struct rte_eth_xstat_name *xstats_names, + unsigned int xstats_count) +{ + struct sfc_port *port = &sa->port; + unsigned int i; + unsigned int nstats = 0; + unsigned int nb_written = 0; + int ret; + + for (i = 0; i < EFX_MAC_NSTATS; ++i) { + if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) { + if (nstats < xstats_count) { + strlcpy(xstats_names[nstats].name, + efx_mac_stat_name(sa->nic, i), + sizeof(xstats_names[0].name)); + nb_written++; + } + nstats++; + } + } + + ret = sfc_sw_xstats_get_names(sa, xstats_names, xstats_count, + &nb_written, &nstats); + if (ret != 0) { + SFC_ASSERT(ret < 0); + return ret; + } + + return nstats; +} + +static int +sfc_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int size) { struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); struct sfc_port *port = &sa->port; @@ -848,13 +843,15 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, unsigned int i; int ret; - if (unlikely(xstats_names == NULL && ids != NULL) || - unlikely(xstats_names != NULL && ids == NULL)) + if (unlikely(xstats_names == NULL && ids != NULL)) return -EINVAL; if (unlikely(xstats_names == NULL && ids == NULL)) return sfc_xstats_get_nb_supported(sa); + if (ids == NULL) + return sfc_xstats_get_all_names(sa, xstats_names, size); + /* * Names array could be filled in nonsequential order. Fill names with * string indicating invalid ID first. @@ -1905,7 +1902,6 @@ static const struct eth_dev_ops sfc_eth_dev_ops = { .txq_info_get = sfc_tx_queue_info_get, .fw_version_get = sfc_fw_version_get, .xstats_get_by_id = sfc_xstats_get_by_id, - .xstats_get_names_by_id = sfc_xstats_get_names_by_id, .pool_ops_supported = sfc_pool_ops_supported, }; diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index b267da462b..be6e073141 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -2424,7 +2424,7 @@ txgbe_get_offset_by_id(uint32_t id, uint32_t *offset) return -1; } -static int txgbe_dev_xstats_get_names(struct rte_eth_dev *dev, +static int txgbe_dev_xstats_get_all_names(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, unsigned int limit) { unsigned int i, count; @@ -2450,7 +2450,7 @@ static int txgbe_dev_xstats_get_names(struct rte_eth_dev *dev, return i; } -static int txgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, +static int txgbe_dev_xstats_get_names(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit) @@ -2458,7 +2458,7 @@ static int txgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, unsigned int i; if (ids == NULL) - return txgbe_dev_xstats_get_names(dev, xstats_names, limit); + return txgbe_dev_xstats_get_all_names(dev, xstats_names, limit); for (i = 0; i < limit; i++) { if (txgbe_get_name_by_id(ids[i], xstats_names[i].name, @@ -5292,7 +5292,6 @@ static const struct eth_dev_ops txgbe_eth_dev_ops = { .stats_reset = txgbe_dev_stats_reset, .xstats_reset = txgbe_dev_xstats_reset, .xstats_get_names = txgbe_dev_xstats_get_names, - .xstats_get_names_by_id = txgbe_dev_xstats_get_names_by_id, .queue_stats_mapping_set = txgbe_dev_queue_stats_mapping_set, .fw_version_get = txgbe_fw_version_get, .dev_supported_ptypes_get = txgbe_dev_supported_ptypes_get, diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c b/drivers/net/txgbe/txgbe_ethdev_vf.c index 896da8a887..cbe2f46f34 100644 --- a/drivers/net/txgbe/txgbe_ethdev_vf.c +++ b/drivers/net/txgbe/txgbe_ethdev_vf.c @@ -348,10 +348,14 @@ static struct rte_pci_driver rte_txgbevf_pmd = { }; static int txgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit) { unsigned int i; + if (ids != NULL) + return -ENOTSUP; + if (limit < TXGBEVF_NB_XSTATS && xstats_names != NULL) return -ENOMEM; diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index a202931e9a..e5d723bfd7 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -251,6 +251,7 @@ vhost_dev_xstats_reset(struct rte_eth_dev *dev) static int vhost_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int limit __rte_unused) { @@ -258,6 +259,9 @@ vhost_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, int count = 0; int nstats = VHOST_NB_XSTATS_RXPORT + VHOST_NB_XSTATS_TXPORT; + if (ids != NULL) + return -ENOTSUP; + if (!xstats_names) return nstats; for (t = 0; t < VHOST_NB_XSTATS_RXPORT; t++) { diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index b60eeb24ab..da405e0896 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -60,6 +60,7 @@ static int virtio_dev_stats_get(struct rte_eth_dev *dev, static int virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned n); static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned limit); static int virtio_dev_stats_reset(struct rte_eth_dev *dev); @@ -1045,6 +1046,7 @@ virtio_update_stats(struct rte_eth_dev *dev, struct rte_eth_stats *stats) } static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit) { @@ -1055,6 +1057,9 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, unsigned nstats = dev->data->nb_tx_queues * VIRTIO_NB_TXQ_XSTATS + dev->data->nb_rx_queues * VIRTIO_NB_RXQ_XSTATS; + if (ids != NULL) + return -ENOTSUP; + if (xstats_names != NULL) { /* Note: limit checked in rte_eth_xstats_names() */ diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 2f40ae907d..48767e6db1 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -80,6 +80,7 @@ static int vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int vmxnet3_dev_stats_reset(struct rte_eth_dev *dev); static int vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats, unsigned int n); static int vmxnet3_dev_xstats_get(struct rte_eth_dev *dev, @@ -1201,6 +1202,7 @@ vmxnet3_hw_stats_save(struct vmxnet3_hw *hw) static int vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev, + const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int n) { @@ -1209,6 +1211,9 @@ vmxnet3_dev_xstats_get_names(struct rte_eth_dev *dev, dev->data->nb_tx_queues * RTE_DIM(vmxnet3_txq_stat_strings) + dev->data->nb_rx_queues * RTE_DIM(vmxnet3_rxq_stat_strings); + if (ids != NULL) + return -ENOTSUP; + if (!xstats_names || n < nstats) return nstats; diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 6a2be98c1f..9423200d9f 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -227,10 +227,6 @@ typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev, */ typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev); -typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, unsigned int size); -/**< @internal Get names of extended stats of an Ethernet device. */ - /** * @internal * Get names of extended stats of an Ethernet device. @@ -238,13 +234,12 @@ typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev, * @param dev * ethdev handle of port. * @param ids - * IDs array to retrieve specific statistics. Can be NULL together - * with @p xstats_names to retrieve number of available statistics. - * @param ids - * IDs array to retrieve specific statistics. Must not be NULL. + * IDs array to retrieve specific statistics. Can be NULL to get names + * of all available statistics. * @param xstats_names * An rte_eth_xstat_name array of at least *size* elements to - * be filled. Must not be NULL. + * be filled. Can be NULL together with @p ids to get number of + * extended statistics. * @param size * Element count in @p ids and @p xstats_names. * @@ -253,7 +248,7 @@ typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev, * - A number of available stats if both xstats_names and ids are NULL. * - A negative value on error. */ -typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev, +typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, unsigned int size); @@ -940,8 +935,6 @@ struct eth_dev_ops { eth_xstats_get_by_id_t xstats_get_by_id; /**< Get extended device statistic values by ID. */ - eth_xstats_get_names_by_id_t xstats_get_names_by_id; - /**< Get name of extended device statistics by ID. */ eth_tm_ops_get_t tm_ops_get; /**< Get Traffic Management (TM) operations. */ diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 655d7be3b5..c951c0ba35 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -2867,7 +2867,7 @@ eth_dev_get_xstats_count(uint16_t port_id) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; if (dev->dev_ops->xstats_get_names != NULL) { - count = (*dev->dev_ops->xstats_get_names)(dev, NULL, 0); + count = (*dev->dev_ops->xstats_get_names)(dev, NULL, NULL, 0); if (count < 0) return eth_err(port_id, count); } else @@ -3005,7 +3005,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, if (ids && !xstats_names) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_names_by_id != NULL && size > 0) { + if (ids && dev->dev_ops->xstats_get_names != NULL && size > 0) { uint64_t ids_copy[size]; for (i = 0; i < size; i++) { @@ -3021,9 +3021,16 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, ids_copy[i] = ids[i] - basic_count; } - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_names_by_id)(dev, + if (no_basic_stat_requested) { + ret = (*dev->dev_ops->xstats_get_names)(dev, ids_copy, xstats_names, size); + if (ret == 0 || ret != -ENOTSUP) + return ret; + /* + * Driver does not support getting names by IDs. + * Fallback to support on ethdev layer. + */ + } } /* Retrieve all stats */ @@ -3104,7 +3111,7 @@ rte_eth_xstats_get_names(uint16_t port_id, * to end of list. */ cnt_driver_entries = (*dev->dev_ops->xstats_get_names)( - dev, + dev, NULL, xstats_names + cnt_used_entries, size - cnt_used_entries); if (cnt_driver_entries < 0) -- 2.30.2