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 B25C5A0C46; Fri, 18 Jun 2021 12:44:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D825B4118A; Fri, 18 Jun 2021 12:41:06 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7CC37410FD for ; Fri, 18 Jun 2021 12:41:04 +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 15IAZv9X004568 for ; Fri, 18 Jun 2021 03:41:04 -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=QjlDBA7eT1+LtYD2JnKBZHCBhZXrFJo9VXj1+vrqkJw=; b=Cm8O1lLlSjPaPc2zuEhkOgTjfFfxN41SOBzKAG0IiuVW8s6oTiqkHFwPw/EYQAB3rjLT pVfoX0UeAft5K9phsAyBVmoD0Yy7miaB60tLVnYoClNQQ7jhCWpz0dVr6LwU2z1ocHQU cElGG9Pj4RzFtgyZXhz2hXopUr5CbBU/4+NP25cz0FeOcH2TlgSfrtEvXr1df/xTOXmw YsF/ETD3yppOdGU+ZbZj2hUTO//1pUavXrRKhjbiIvI9gzoS3/rgBBHDsbxkRs872bCt VNgUu6NzEj2n9M+y/UqArjOdUMPwP/90V1p1ottC2f1h080KQJ2OaA2vaXWmxVfXZm8N 9A== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 397udry7k9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 18 Jun 2021 03:41:03 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 18 Jun 2021 03:41:01 -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:01 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 508D75B69FB; Fri, 18 Jun 2021 03:40:47 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , , Date: Fri, 18 Jun 2021 16:07:22 +0530 Message-ID: <20210618103741.26526-44-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: PN3xdwxNvzxpNy38Vr5Sd_Gi2S0kS18C X-Proofpoint-GUID: PN3xdwxNvzxpNy38Vr5Sd_Gi2S0kS18C 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 43/62] net/cnxk: add port/queue stats 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 This patch implements regular port statistics and queue mapping set api to get queue statistics Signed-off-by: Satha Rao --- doc/guides/nics/cnxk.rst | 1 + doc/guides/nics/features/cnxk.ini | 2 + doc/guides/nics/features/cnxk_vec.ini | 2 + doc/guides/nics/features/cnxk_vf.ini | 2 + drivers/net/cnxk/cnxk_ethdev.c | 3 ++ drivers/net/cnxk/cnxk_ethdev.h | 8 ++++ drivers/net/cnxk/cnxk_stats.c | 85 +++++++++++++++++++++++++++++++++++ drivers/net/cnxk/meson.build | 3 +- 8 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 drivers/net/cnxk/cnxk_stats.c diff --git a/doc/guides/nics/cnxk.rst b/doc/guides/nics/cnxk.rst index 6678486..e875e55 100644 --- a/doc/guides/nics/cnxk.rst +++ b/doc/guides/nics/cnxk.rst @@ -25,6 +25,7 @@ Features of the CNXK Ethdev PMD are: - Receiver Side Scaling (RSS) - MAC filtering - Inner and Outer Checksum offload +- Port hardware statistics - Link state information - Link flow control - MTU update diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini index e5669f5..40952a9 100644 --- a/doc/guides/nics/features/cnxk.ini +++ b/doc/guides/nics/features/cnxk.ini @@ -32,6 +32,8 @@ L4 checksum offload = Y Inner L3 checksum = Y Inner L4 checksum = Y Packet type parsing = Y +Basic stats = Y +Stats per queue = 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 dff0c9b..32035bb 100644 --- a/doc/guides/nics/features/cnxk_vec.ini +++ b/doc/guides/nics/features/cnxk_vec.ini @@ -30,6 +30,8 @@ L4 checksum offload = Y Inner L3 checksum = Y Inner L4 checksum = Y Packet type parsing = Y +Basic stats = Y +Stats per queue = 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 b950d2f..8060a68 100644 --- a/doc/guides/nics/features/cnxk_vf.ini +++ b/doc/guides/nics/features/cnxk_vf.ini @@ -27,6 +27,8 @@ L4 checksum offload = Y Inner L3 checksum = Y Inner L4 checksum = Y Packet type parsing = Y +Basic stats = Y +Stats per queue = 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 627ac32..ecc7f13 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1184,6 +1184,9 @@ struct eth_dev_ops cnxk_eth_dev_ops = { .rx_queue_intr_enable = cnxk_nix_rx_queue_intr_enable, .rx_queue_intr_disable = cnxk_nix_rx_queue_intr_disable, .pool_ops_supported = cnxk_nix_pool_ops_supported, + .queue_stats_mapping_set = cnxk_nix_queue_stats_mapping, + .stats_get = cnxk_nix_stats_get, + .stats_reset = cnxk_nix_stats_reset, }; static int diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h index e6dac95..860cfe1 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -191,6 +191,10 @@ struct cnxk_eth_dev { /* LSO Tunnel format indices */ uint64_t lso_tun_fmt; + + /* Per queue statistics counters */ + uint32_t txq_stat_map[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + uint32_t rxq_stat_map[RTE_ETHDEV_QUEUE_STAT_CNTRS]; }; struct cnxk_eth_rxq_sp { @@ -286,6 +290,10 @@ void cnxk_nix_toggle_flag_link_cfg(struct cnxk_eth_dev *dev, bool set); void cnxk_eth_dev_link_status_cb(struct roc_nix *nix, struct roc_nix_link_info *link); int cnxk_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete); +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); /* 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 new file mode 100644 index 0000000..24bff0b --- /dev/null +++ b/drivers/net/cnxk/cnxk_stats.c @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 Marvell. + */ + +#include "cnxk_ethdev.h" + +int +cnxk_nix_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct roc_nix *nix = &dev->nix; + struct roc_nix_stats nix_stats; + int rc = 0, i; + + rc = roc_nix_stats_get(nix, &nix_stats); + if (rc) + goto exit; + + stats->opackets = nix_stats.tx_ucast; + stats->opackets += nix_stats.tx_mcast; + stats->opackets += nix_stats.tx_bcast; + stats->oerrors = nix_stats.tx_drop; + stats->obytes = nix_stats.tx_octs; + + stats->ipackets = nix_stats.rx_ucast; + stats->ipackets += nix_stats.rx_mcast; + stats->ipackets += nix_stats.rx_bcast; + stats->imissed = nix_stats.rx_drop; + stats->ibytes = nix_stats.rx_octs; + stats->ierrors = nix_stats.rx_err; + + for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { + struct roc_nix_stats_queue qstats; + uint16_t qidx; + + if (dev->txq_stat_map[i] & (1U << 31)) { + qidx = dev->txq_stat_map[i] & 0xFFFF; + rc = roc_nix_stats_queue_get(nix, qidx, 0, &qstats); + if (rc) + goto exit; + stats->q_opackets[i] = qstats.tx_pkts; + stats->q_obytes[i] = qstats.tx_octs; + stats->q_errors[i] = qstats.tx_drop_pkts; + } + + if (dev->rxq_stat_map[i] & (1U << 31)) { + qidx = dev->rxq_stat_map[i] & 0xFFFF; + rc = roc_nix_stats_queue_get(nix, qidx, 1, &qstats); + if (rc) + goto exit; + stats->q_ipackets[i] = qstats.rx_pkts; + stats->q_ibytes[i] = qstats.rx_octs; + stats->q_errors[i] += qstats.rx_drop_pkts; + } + } +exit: + return rc; +} + +int +cnxk_nix_stats_reset(struct rte_eth_dev *eth_dev) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + + return roc_nix_stats_reset(&dev->nix); +} + +int +cnxk_nix_queue_stats_mapping(struct rte_eth_dev *eth_dev, uint16_t queue_id, + uint8_t stat_idx, uint8_t is_rx) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + + if (is_rx) { + if (queue_id >= dev->nb_rxq) + return -EINVAL; + dev->rxq_stat_map[stat_idx] = ((1U << 31) | queue_id); + } else { + if (queue_id >= dev->nb_txq) + return -EINVAL; + dev->txq_stat_map[stat_idx] = ((1U << 31) | queue_id); + } + + return 0; +} diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build index 8f32dc7..7d711a2 100644 --- a/drivers/net/cnxk/meson.build +++ b/drivers/net/cnxk/meson.build @@ -12,7 +12,8 @@ sources = files('cnxk_ethdev.c', 'cnxk_ethdev_ops.c', 'cnxk_ethdev_devargs.c', 'cnxk_link.c', - 'cnxk_lookup.c') + 'cnxk_lookup.c', + 'cnxk_stats.c') # CN9K sources += files('cn9k_ethdev.c', -- 2.8.4