From patchwork Tue Jun 28 14:26:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathesh B Edara X-Patchwork-Id: 113512 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D1006A056E; Tue, 28 Jun 2022 16:27:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A46FE40691; Tue, 28 Jun 2022 16:27:14 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id AA5C9400D7 for ; Tue, 28 Jun 2022 16:27:12 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25SAHia0010854 for ; Tue, 28 Jun 2022 07:27:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=NwbZuukVDV21H3fYnIUvmafxGovfye0hMjqz1S7xpfs=; b=DxOi6tM1pdi+Amic4n5rs0tgg1suH8d6G0nl6YpmXxuX+GERfpgn7/tdWD28KVjODFd7 GBr19zY7zRN0hscv3WhV8d06xQyHZJ7CpSmdiU3SD6hci3rFAXWfWexmo6l4pFIsdRqH LUWLqsWr5ggPfzIT85jjbvvW9zl2MMnQwK9dnPyQjGmZdQQNpbwK7ov95QoezYtNfeEM 83WPgcLZt2z+qy2n6l9hvucgrd+eg92KnJzkkrmfSmoPmlKWKUvjOGkmCp3PnGWVtW8B w/LaGA0tSFO0Cwtm+1UU6ZUcd/v6B+7ZBpnVVySd3++DOtEHSRDFR7XrvTS+yuO/SLce JA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3gx1vm45vj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 28 Jun 2022 07:27:11 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 28 Jun 2022 07:27:10 -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.18 via Frontend Transport; Tue, 28 Jun 2022 07:27:09 -0700 Received: from setup-1.caveonetworks.com (unknown [10.106.27.161]) by maili.marvell.com (Postfix) with ESMTP id A2D9A3F7053; Tue, 28 Jun 2022 07:27:09 -0700 (PDT) From: Sathesh Edara To: , , , "Nalla Pradeep" , Radha Mohan Chintakuntla , Veerasenareddy Burru CC: Subject: [PATCH] net/octeontx_ep: support basic stats Date: Tue, 28 Jun 2022 07:26:55 -0700 Message-ID: <20220628142655.134851-1-sedara@marvell.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: QtCBOhL019slPxjyDvjwK1FpgxObcj1p X-Proofpoint-GUID: QtCBOhL019slPxjyDvjwK1FpgxObcj1p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-28_07,2022-06-28_01,2022-06-22_01 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 Added functionality to fetch and reset ethdev stats. Signed-off-by: Sathesh Edara --- doc/guides/nics/features/octeontx_ep.ini | 1 + drivers/net/octeontx_ep/otx_ep_ethdev.c | 52 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/doc/guides/nics/features/octeontx_ep.ini b/doc/guides/nics/features/octeontx_ep.ini index d1453f5bee..e0c469676e 100644 --- a/doc/guides/nics/features/octeontx_ep.ini +++ b/doc/guides/nics/features/octeontx_ep.ini @@ -8,4 +8,5 @@ Speed capabilities = P SR-IOV = Y Linux = Y x86-64 = Y +Basic stats = Y Usage doc = Y diff --git a/drivers/net/octeontx_ep/otx_ep_ethdev.c b/drivers/net/octeontx_ep/otx_ep_ethdev.c index 806add246b..cb45bd7a8a 100644 --- a/drivers/net/octeontx_ep/otx_ep_ethdev.c +++ b/drivers/net/octeontx_ep/otx_ep_ethdev.c @@ -337,6 +337,56 @@ otx_ep_tx_queue_release(struct rte_eth_dev *dev, uint16_t q_no) otx_ep_delete_iqs(tq->otx_ep_dev, tq->q_no); } +static int +otx_ep_dev_stats_reset(struct rte_eth_dev *dev) +{ + struct otx_ep_device *otx_epvf = OTX_EP_DEV(dev); + uint32_t i; + + for (i = 0; i < otx_epvf->nb_tx_queues; i++) + memset(&otx_epvf->instr_queue[i]->stats, 0, + sizeof(struct otx_ep_iq_stats)); + + for (i = 0; i < otx_epvf->nb_rx_queues; i++) + memset(&otx_epvf->droq[i]->stats, 0, + sizeof(struct otx_ep_droq_stats)); + + return 0; +} + +static int +otx_ep_dev_stats_get(struct rte_eth_dev *eth_dev, + struct rte_eth_stats *stats) +{ + struct otx_ep_device *otx_epvf = OTX_EP_DEV(eth_dev); + struct otx_ep_iq_stats *ostats; + struct otx_ep_droq_stats *istats; + uint32_t i; + + memset(stats, 0, sizeof(struct rte_eth_stats)); + + for (i = 0; i < otx_epvf->nb_tx_queues; i++) { + ostats = &otx_epvf->instr_queue[i]->stats; + stats->q_opackets[i] = ostats->tx_pkts; + stats->q_obytes[i] = ostats->tx_bytes; + stats->opackets += ostats->tx_pkts; + stats->obytes += ostats->tx_bytes; + stats->oerrors += ostats->instr_dropped; + } + for (i = 0; i < otx_epvf->nb_rx_queues; i++) { + istats = &otx_epvf->droq[i]->stats; + stats->q_ipackets[i] = istats->pkts_received; + stats->q_ibytes[i] = istats->bytes_received; + stats->q_errors[i] = istats->rx_err; + stats->ipackets += istats->pkts_received; + stats->ibytes += istats->bytes_received; + stats->imissed += istats->rx_alloc_failure; + stats->ierrors += istats->rx_err; + stats->rx_nombuf += istats->rx_alloc_failure; + } + return 0; +} + /* Define our ethernet definitions */ static const struct eth_dev_ops otx_ep_eth_dev_ops = { .dev_configure = otx_ep_dev_configure, @@ -347,6 +397,8 @@ static const struct eth_dev_ops otx_ep_eth_dev_ops = { .tx_queue_setup = otx_ep_tx_queue_setup, .tx_queue_release = otx_ep_tx_queue_release, .dev_infos_get = otx_ep_dev_info_get, + .stats_get = otx_ep_dev_stats_get, + .stats_reset = otx_ep_dev_stats_reset, }; static int