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 C563EA0C46; Fri, 18 Jun 2021 12:44:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D55C411F1; Fri, 18 Jun 2021 12:41:09 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 51014410F5 for ; Fri, 18 Jun 2021 12:41:08 +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 15IAaS8k004719 for ; Fri, 18 Jun 2021 03:41:07 -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=2yQXTeiXi6XaiojJmpsXyyWB6RUWni4lBK6HCeC5Xss=; b=fFLMijvo7ZrIn8frEbsjdzlmQG6VJb+Vsf56QGEfIuvBU80GwBaH0eQ9XIid44RrceE4 3ked2ApOdHkU8Vfy2wIL46Zk2IcDbwDNM1Wd+liRMXzVwu3zjfoZ50lJe3Hk6QBC+4xq +YuESj2m6TB7+2ruIFHDV4s3CDJ+56EnTugfWyRS+miHEQ5txzp41rN9r/km0+TEF6J0 9EE2x/kKvbqzaqeUn4dsbfgfiknFYPQ0w2drC6T9exEcTAyl5363K6xLCEC9SO6JoiQw 1DQ4V50NpHEJL81RtE67wLhZes9nNiRmXfg8hnRegTTGBttAXxDYyqyS/2/XTa38XcUk Hg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 397udry7kd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 18 Jun 2021 03:41:07 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 18 Jun 2021 03:41:05 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Fri, 18 Jun 2021 03:41:05 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 68EE85B6A60; Fri, 18 Jun 2021 03:40:50 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , , Date: Fri, 18 Jun 2021 16:07:23 +0530 Message-ID: <20210618103741.26526-45-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210618103741.26526-1-ndabilpuram@marvell.com> References: <20210306153404.10781-1-ndabilpuram@marvell.com> <20210618103741.26526-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: 9IRWU5bnnio-o_au9fT-dyX51TP9ku_1 X-Proofpoint-GUID: 9IRWU5bnnio-o_au9fT-dyX51TP9ku_1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-18_04:2021-06-18, 2021-06-18 signatures=0 Subject: [dpdk-dev] [PATCH v3 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 | 235 ++++++++++++++++++++++++++++++++++ 6 files changed, 254 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 ecc7f13..27b92f9 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1187,6 +1187,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 860cfe1..5a0dc13 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -294,6 +294,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..19bab21 100644 --- a/drivers/net/cnxk/cnxk_stats.c +++ b/drivers/net/cnxk/cnxk_stats.c @@ -4,6 +4,9 @@ #include "cnxk_ethdev.h" +#define CNXK_NB_RXQ_STATS 5 +#define CNXK_NB_TXQ_STATS 4 + int cnxk_nix_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { @@ -83,3 +86,235 @@ 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]; + struct roc_nix *nix = &dev->nix; + int roc_size, q, idx = 0, size; + + roc_size = roc_nix_xstats_get(nix, roc_xstats, n); + + if (roc_size < 0) + return roc_size; + + /* Per Queue statistics also returned as part of xstats */ + size = roc_size + (dev->nb_rxq * CNXK_NB_RXQ_STATS) + + (dev->nb_txq * CNXK_NB_TXQ_STATS); + + /* If requested array do not have space then return with count */ + if (size > (int)n || xstats == NULL) + return size; + + for (idx = 0; idx < roc_size; idx++) { + xstats[idx].id = roc_xstats[idx].id; + xstats[idx].value = roc_xstats[idx].value; + } + for (q = 0; q < dev->nb_rxq; q++) { + struct roc_nix_stats_queue qstats; + int rc; + + rc = roc_nix_stats_queue_get(nix, q, 1, &qstats); + if (rc) + return rc; + + xstats[idx].id = idx; + xstats[idx].value = qstats.rx_pkts; + idx++; + xstats[idx].id = idx; + xstats[idx].value = qstats.rx_octs; + idx++; + xstats[idx].id = idx; + xstats[idx].value = qstats.rx_drop_pkts; + idx++; + xstats[idx].id = idx; + xstats[idx].value = qstats.rx_drop_octs; + idx++; + xstats[idx].id = idx; + xstats[idx].value = qstats.rx_error_pkts; + idx++; + } + for (q = 0; q < dev->nb_txq; q++) { + struct roc_nix_stats_queue qstats; + int rc; + + rc = roc_nix_stats_queue_get(nix, q, 0, &qstats); + if (rc) + return rc; + + xstats[idx].id = idx; + xstats[idx].value = qstats.tx_pkts; + idx++; + xstats[idx].id = idx; + xstats[idx].value = qstats.tx_octs; + idx++; + xstats[idx].id = idx; + xstats[idx].value = qstats.tx_drop_pkts; + idx++; + xstats[idx].id = idx; + xstats[idx].value = qstats.tx_drop_octs; + idx++; + } + + 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 roc_size, size, i, q; + + roc_size = roc_nix_num_xstats_get(nix); + /* Per Queue statistics also returned as part of xstats */ + size = roc_size + (dev->nb_rxq * CNXK_NB_RXQ_STATS) + + (dev->nb_txq * CNXK_NB_TXQ_STATS); + + if (xstats_names == NULL) + return size; + + if ((int)limit < size && xstats_names != NULL) + return size; + + roc_size = roc_nix_xstats_names_get(nix, roc_xstats_name, limit); + + for (i = 0; i < roc_size; i++) + rte_strscpy(xstats_names[i].name, roc_xstats_name[i].name, + sizeof(xstats_names[i].name)); + + for (q = 0; q < dev->nb_rxq; q++) { + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "rxq_%d_pkts", q); + i++; + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "rxq_%d_octs", q); + i++; + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "rxq_%d_drop_pkts", q); + i++; + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "rxq_%d_drop_octs", q); + i++; + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "rxq_%d_err_pkts", q); + i++; + } + + for (q = 0; q < dev->nb_txq; q++) { + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "txq_%d_pkts", q); + i++; + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "txq_%d_octs", q); + i++; + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "txq_%d_drop_pkts", q); + i++; + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "txq_%d_drop_octs", q); + i++; + } + + 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 nix_cnt = roc_nix_num_xstats_get(&dev->nix); + uint32_t stat_cnt = nix_cnt + (dev->nb_rxq * CNXK_NB_RXQ_STATS) + + (dev->nb_txq * CNXK_NB_TXQ_STATS); + struct rte_eth_xstat_name xnames[stat_cnt]; + uint32_t i; + + if (limit < stat_cnt && ids == NULL) + return stat_cnt; + + if (limit > stat_cnt) + return -EINVAL; + + if (xstats_names == NULL) + return -ENOMEM; + + cnxk_nix_xstats_get_names(eth_dev, xnames, stat_cnt); + + for (i = 0; i < limit; i++) { + if (ids[i] >= stat_cnt) + return -EINVAL; + + rte_strscpy(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 nix_cnt = roc_nix_num_xstats_get(&dev->nix); + uint32_t stat_cnt = nix_cnt + (dev->nb_rxq * CNXK_NB_RXQ_STATS) + + (dev->nb_txq * CNXK_NB_TXQ_STATS); + struct rte_eth_xstat xstats[stat_cnt]; + uint32_t i; + + if (n < stat_cnt && ids == NULL) + return stat_cnt; + + if (n > stat_cnt) + return -EINVAL; + + if (values == NULL) + return -ENOMEM; + + cnxk_nix_xstats_get(eth_dev, xstats, stat_cnt); + + for (i = 0; i < n; i++) { + if (ids[i] >= stat_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