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 187D2A034F; Mon, 7 Jun 2021 20:08:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 819D2411B6; Mon, 7 Jun 2021 20:05:24 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id ECBE8411E3 for ; Mon, 7 Jun 2021 20:05:22 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 157I1arA017502 for ; Mon, 7 Jun 2021 11:05:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=kzqKc192EJOZFu0LRJ7Kc4JbuWyn+Yt+ru0HkxBXT2A=; b=EdMJ+eakhYuMMxDjMkSpWEDwxSIz9ydBscMO2SYeBGBPX277OIqJocluKsgGjLiPIERt BGJvN6RBzTVqPYhkkI8vcCbgAgTEiDllAuAKI2XGu0HOHyVJz4YIGxDnDManlAtbCqaA Rxti50r/8XDUlsfvnGw3gXzp1K/7DxM4LdkFbaaiPVusC4gDqQm09A6kCpX7ftfKyFun Qdjdi9uG8/jodzxUiJIjlR8NLikOHI4maRrpdZQoMYeA/kPJvM4JYZYpr29Aj4stXsYa MX02Wdhq/dlBG8cU0DbvT407MEjrTMlaHq5wv+pv5bKrJzqA2LpeBc0fJzx/GNe6Muom HA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 391ecv2emy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 07 Jun 2021 11:05:22 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 7 Jun 2021 11:05:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 7 Jun 2021 11:05:20 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id A6C8A3F7043; Mon, 7 Jun 2021 11:05:17 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , Date: Mon, 7 Jun 2021 23:29:25 +0530 Message-ID: <20210607175943.31690-45-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210607175943.31690-1-ndabilpuram@marvell.com> References: <20210306153404.10781-1-ndabilpuram@marvell.com> <20210607175943.31690-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: 4qn9ChTc_2hJvwYQW6BXbcLPvLhsxSrV X-Proofpoint-ORIG-GUID: 4qn9ChTc_2hJvwYQW6BXbcLPvLhsxSrV X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-07_14:2021-06-04, 2021-06-07 signatures=0 Subject: [dpdk-dev] [PATCH v2 44/62] net/cnxk: add xstats apis 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" From: Satha Rao Initial implementation of xstats operations. Signed-off-by: Satha Rao --- doc/guides/nics/features/cnxk.ini | 1 + doc/guides/nics/features/cnxk_vec.ini | 1 + doc/guides/nics/features/cnxk_vf.ini | 1 + drivers/net/cnxk/cnxk_ethdev.c | 5 ++ drivers/net/cnxk/cnxk_ethdev.h | 11 +++ drivers/net/cnxk/cnxk_stats.c | 132 ++++++++++++++++++++++++++++++++++ 6 files changed, 151 insertions(+) diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index 40952a9..192c15a 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -34,6 +34,7 @@ Inner L4 checksum = Y Packet type parsing = Y Basic stats = Y Stats per queue = Y +Extended stats = Y Module EEPROM dump = Y Linux = Y ARMv8 = Y diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini index 32035bb..e990480 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -32,6 +32,7 @@ Inner L4 checksum = Y Packet type parsing = Y Basic stats = Y Stats per queue = Y +Extended stats = Y Module EEPROM dump = Y Linux = Y ARMv8 = Y diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini index 8060a68..3a4417c 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -29,6 +29,7 @@ Inner L4 checksum = Y Packet type parsing = Y Basic stats = Y Stats per queue = Y +Extended stats = Y Module EEPROM dump = Y Linux = Y ARMv8 = Y diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index f6eb9c9..aaf8719 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1170,6 +1170,11 @@ struct eth_dev_ops cnxk_eth_dev_ops = { .queue_stats_mapping_set = cnxk_nix_queue_stats_mapping, .stats_get = cnxk_nix_stats_get, .stats_reset = cnxk_nix_stats_reset, + .xstats_get = cnxk_nix_xstats_get, + .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, }; static int diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h index 5075e7c..dd05c24 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -279,6 +279,17 @@ int cnxk_nix_queue_stats_mapping(struct rte_eth_dev *dev, uint16_t queue_id, uint8_t stat_idx, uint8_t is_rx); int cnxk_nix_stats_reset(struct rte_eth_dev *dev); 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, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit); +int cnxk_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, + struct rte_eth_xstat_name *xstats_names, + const uint64_t *ids, 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); /* Lookup configuration */ const uint32_t *cnxk_nix_supported_ptypes_get(struct rte_eth_dev *eth_dev); diff --git a/drivers/net/cnxk/cnxk_stats.c b/drivers/net/cnxk/cnxk_stats.c index 24bff0b..ce9f9f4 100644 --- a/drivers/net/cnxk/cnxk_stats.c +++ b/drivers/net/cnxk/cnxk_stats.c @@ -83,3 +83,135 @@ cnxk_nix_queue_stats_mapping(struct rte_eth_dev *eth_dev, uint16_t queue_id, return 0; } + +int +cnxk_nix_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, + unsigned int n) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct roc_nix_xstat roc_xstats[n]; + int size, i; + + size = roc_nix_xstats_get(&dev->nix, roc_xstats, n); + + /* If requested array do not have space then return with count */ + if (size < 0 || size > (int)n) + return size; + + for (i = 0; i < size; i++) { + xstats[i].id = roc_xstats[i].id; + xstats[i].value = roc_xstats[i].value; + } + + return size; +} + +int +cnxk_nix_xstats_get_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]; + struct roc_nix *nix = &dev->nix; + int size, i; + + if ((int)limit < roc_nix_num_xstats_get(nix) && xstats_names == NULL) + return roc_nix_num_xstats_get(nix); + + size = roc_nix_xstats_names_get(nix, roc_xstats_name, limit); + + for (i = 0; i < size; i++) + strlcpy(xstats_names[i].name, roc_xstats_name[i].name, + sizeof(xstats_names[i].name)); + + return size; +} + +int +cnxk_nix_xstats_get_names_by_id(struct rte_eth_dev *eth_dev, + struct rte_eth_xstat_name *xstats_names, + const uint64_t *ids, unsigned int limit) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + uint32_t xstat_cnt = roc_nix_num_xstats_get(&dev->nix), i; + struct roc_nix_xstat_name xnames[xstat_cnt]; + + if (limit < xstat_cnt && ids == NULL) + return xstat_cnt; + + if (limit > xstat_cnt) + return -EINVAL; + + if (xstats_names == NULL) + return -ENOMEM; + + roc_nix_xstats_names_get(&dev->nix, xnames, limit); + + for (i = 0; i < xstat_cnt; i++) { + if (ids[i] >= xstat_cnt) + return -EINVAL; + + strlcpy(xstats_names[i].name, xnames[ids[i]].name, + sizeof(xstats_names[i].name)); + } + + return limit; +} + +int +cnxk_nix_xstats_get_by_id(struct rte_eth_dev *eth_dev, const uint64_t *ids, + uint64_t *values, unsigned int n) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + uint32_t xstat_cnt = roc_nix_num_xstats_get(&dev->nix), i; + struct roc_nix_xstat xstats[xstat_cnt]; + + if (n < xstat_cnt && ids == NULL) + return xstat_cnt; + + if (n > xstat_cnt) + return -EINVAL; + + if (values == NULL) + return -ENOMEM; + + roc_nix_xstats_get(&dev->nix, xstats, n); + + for (i = 0; i < xstat_cnt; i++) { + if (ids[i] >= xstat_cnt) + return -EINVAL; + values[i] = xstats[ids[i]].value; + } + + return n; +} + +int +cnxk_nix_xstats_reset(struct rte_eth_dev *eth_dev) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct roc_nix *nix = &dev->nix; + int rc = 0, i; + + rc = roc_nix_stats_reset(nix); + if (rc) + goto exit; + + /* Reset Rx Queues */ + for (i = 0; i < dev->nb_rxq; i++) { + rc = roc_nix_stats_queue_reset(nix, i, 1); + if (rc) + goto exit; + } + + /* Reset Tx Queues */ + for (i = 0; i < dev->nb_txq; i++) { + rc = roc_nix_stats_queue_reset(nix, i, 0); + if (rc) + goto exit; + } + +exit: + return rc; +} -- 2.8.4