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 3BC1145BAC; Wed, 23 Oct 2024 08:25:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 738F540E2D; Wed, 23 Oct 2024 08:24:42 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id 0E79140E03 for ; Wed, 23 Oct 2024 08:24:38 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E4A6E20137E; Wed, 23 Oct 2024 08:24:37 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id AB2D520245A; Wed, 23 Oct 2024 08:24:37 +0200 (CEST) Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com [92.120.147.188]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 12A7D183DC06; Wed, 23 Oct 2024 14:24:37 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Gagandeep Singh , Sachin Saxena , Vanshika Shukla Cc: Apeksha Gupta Subject: [v2 05/12] net/enetc: Add basic statistics Date: Wed, 23 Oct 2024 11:54:26 +0530 Message-Id: <20241023062433.851218-6-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241023062433.851218-1-vanshika.shukla@nxp.com> References: <20241018072644.2379012-1-vanshika.shukla@nxp.com> <20241023062433.851218-1-vanshika.shukla@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP 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 From: Apeksha Gupta Introduces basic statistics collection for ENETC4 PMD, including: - Packet transmit/receive counts - Byte transmit/receive counts - Error counters (TX/RX drops, errors) Signed-off-by: Apeksha Gupta Signed-off-by: Gagandeep Singh --- doc/guides/nics/features/enetc4.ini | 1 + drivers/net/enetc/base/enetc4_hw.h | 7 +++++ drivers/net/enetc/base/enetc_hw.h | 5 +++- drivers/net/enetc/enetc4_ethdev.c | 42 +++++++++++++++++++++++++++++ drivers/net/enetc/enetc4_vf.c | 24 +++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/enetc4.ini b/doc/guides/nics/features/enetc4.ini index 55b3b95953..e814852d2d 100644 --- a/doc/guides/nics/features/enetc4.ini +++ b/doc/guides/nics/features/enetc4.ini @@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Basic stats = Y L3 checksum offload = Y L4 checksum offload = Y Queue start/stop = Y diff --git a/drivers/net/enetc/base/enetc4_hw.h b/drivers/net/enetc/base/enetc4_hw.h index 114d27f34b..874cdc4775 100644 --- a/drivers/net/enetc/base/enetc4_hw.h +++ b/drivers/net/enetc/base/enetc4_hw.h @@ -103,6 +103,13 @@ #define IFMODE_SGMII 5 #define PM_IF_MODE_ENA BIT(15) +/* Station interface statistics */ +#define ENETC4_SIROCT0 0x300 +#define ENETC4_SIRFRM0 0x308 +#define ENETC4_SITOCT0 0x320 +#define ENETC4_SITFRM0 0x328 +#define ENETC4_SITDFCR 0x340 + /* general register accessors */ #define enetc4_rd_reg(reg) rte_read32((void *)(reg)) #define enetc4_wr_reg(reg, val) rte_write32((val), (void *)(reg)) diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h index 3cdfe23fc0..3208d91bc5 100644 --- a/drivers/net/enetc/base/enetc_hw.h +++ b/drivers/net/enetc/base/enetc_hw.h @@ -278,7 +278,10 @@ union enetc_rx_bd { union { struct { uint16_t flags; - uint16_t error; + uint8_t error; + uint8_t resv:6; + uint8_t r:1; + uint8_t f:1; }; uint32_t lstatus; }; diff --git a/drivers/net/enetc/enetc4_ethdev.c b/drivers/net/enetc/enetc4_ethdev.c index ee66da742f..6a165f2ff2 100644 --- a/drivers/net/enetc/enetc4_ethdev.c +++ b/drivers/net/enetc/enetc4_ethdev.c @@ -473,6 +473,46 @@ enetc4_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid) rte_free(rx_ring); } +static +int enetc4_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats) +{ + struct enetc_eth_hw *hw = + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw = &hw->hw; + + /* + * Total received packets, bad + good, if we want to get counters + * of only good received packets then use ENETC4_PM_RFRM, + * ENETC4_PM_TFRM registers. + */ + stats->ipackets = enetc4_port_rd(enetc_hw, ENETC4_PM_RPKT(0)); + stats->opackets = enetc4_port_rd(enetc_hw, ENETC4_PM_TPKT(0)); + stats->ibytes = enetc4_port_rd(enetc_hw, ENETC4_PM_REOCT(0)); + stats->obytes = enetc4_port_rd(enetc_hw, ENETC4_PM_TEOCT(0)); + /* + * Dropped + Truncated packets, use ENETC4_PM_RDRNTP(0) for without + * truncated packets + */ + stats->imissed = enetc4_port_rd(enetc_hw, ENETC4_PM_RDRP(0)); + stats->ierrors = enetc4_port_rd(enetc_hw, ENETC4_PM_RERR(0)); + stats->oerrors = enetc4_port_rd(enetc_hw, ENETC4_PM_TERR(0)); + + return 0; +} + +static int +enetc4_stats_reset(struct rte_eth_dev *dev) +{ + struct enetc_eth_hw *hw = + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw = &hw->hw; + + enetc4_port_wr(enetc_hw, ENETC4_PM0_STAT_CONFIG, ENETC4_CLEAR_STATS); + + return 0; +} + int enetc4_dev_close(struct rte_eth_dev *dev) { @@ -657,6 +697,8 @@ static const struct eth_dev_ops enetc4_ops = { .dev_stop = enetc4_dev_stop, .dev_close = enetc4_dev_close, .dev_infos_get = enetc4_dev_infos_get, + .stats_get = enetc4_stats_get, + .stats_reset = enetc4_stats_reset, .rx_queue_setup = enetc4_rx_queue_setup, .rx_queue_start = enetc4_rx_queue_start, .rx_queue_stop = enetc4_rx_queue_stop, diff --git a/drivers/net/enetc/enetc4_vf.c b/drivers/net/enetc/enetc4_vf.c index 0c68229a8d..0d35fc2e1c 100644 --- a/drivers/net/enetc/enetc4_vf.c +++ b/drivers/net/enetc/enetc4_vf.c @@ -26,6 +26,29 @@ enetc4_vf_dev_start(struct rte_eth_dev *dev __rte_unused) return 0; } +static int +enetc4_vf_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats) +{ + struct enetc_eth_hw *hw = + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw = &hw->hw; + struct enetc_bdr *rx_ring; + uint8_t i; + + PMD_INIT_FUNC_TRACE(); + stats->ipackets = enetc4_rd(enetc_hw, ENETC4_SIRFRM0); + stats->opackets = enetc4_rd(enetc_hw, ENETC4_SITFRM0); + stats->ibytes = enetc4_rd(enetc_hw, ENETC4_SIROCT0); + stats->obytes = enetc4_rd(enetc_hw, ENETC4_SITOCT0); + stats->oerrors = enetc4_rd(enetc_hw, ENETC4_SITDFCR); + for (i = 0; i < dev->data->nb_rx_queues; i++) { + rx_ring = dev->data->rx_queues[i]; + stats->ierrors += rx_ring->ierrors; + } + return 0; +} + /* * The set of PCI devices this driver supports */ @@ -41,6 +64,7 @@ static const struct eth_dev_ops enetc4_vf_ops = { .dev_stop = enetc4_vf_dev_stop, .dev_close = enetc4_dev_close, .dev_infos_get = enetc4_dev_infos_get, + .stats_get = enetc4_vf_stats_get, .rx_queue_setup = enetc4_rx_queue_setup, .rx_queue_start = enetc4_rx_queue_start, .rx_queue_stop = enetc4_rx_queue_stop, -- 2.25.1