From patchwork Fri Apr 12 11:01:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 52689 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 72F931B0F8; Fri, 12 Apr 2019 13:01:37 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140049.outbound.protection.outlook.com [40.107.14.49]) by dpdk.org (Postfix) with ESMTP id 3B35169D4 for ; Fri, 12 Apr 2019 13:01:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9rGb+RUnXyk2sWepr6xgGJoTfW1WEvOV2gwNxnYRsT4=; b=vn0NCbjBvDkU0ka6CjRx8Qw804bbQ+1A/bo7P/capgi82eTkGagzw79typxnXPIAKrB4zJCRehIrhL6KkYPrkpkrK0odJTmGH5Zro6+B8MRxkhmzaCi/Ek6DnSGGkuNMyeGQuTi4Bmc0zWSDWCTOYyFlnv4xceZG+hDfoSacD0s= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6462.eurprd04.prod.outlook.com (20.179.233.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.21; Fri, 12 Apr 2019 11:01:30 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1792.016; Fri, 12 Apr 2019 11:01:30 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH v3 05/13] net/enetc: add basic statistics Thread-Index: AQHU8R8UdCBaM8zXskSUUPAGt2Qf7w== Date: Fri, 12 Apr 2019 11:01:29 +0000 Message-ID: <20190412105105.24351-6-g.singh@nxp.com> References: <1555075598-4988-1-git-send-email-g.singh@nxp.com> <20190412105105.24351-1-g.singh@nxp.com> In-Reply-To: <20190412105105.24351-1-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: TYAPR01CA0204.jpnprd01.prod.outlook.com (2603:1096:404:29::24) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 2.17.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.1.68] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f98d64b4-59f1-41ce-3082-08d6bf363723 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VE1PR04MB6462; x-ms-traffictypediagnostic: VE1PR04MB6462: x-microsoft-antispam-prvs: x-forefront-prvs: 0005B05917 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(366004)(396003)(346002)(39860400002)(189003)(199004)(14444005)(2501003)(186003)(97736004)(7736002)(3846002)(110136005)(99286004)(6116002)(102836004)(86362001)(316002)(2616005)(11346002)(476003)(6506007)(446003)(76176011)(305945005)(26005)(1076003)(106356001)(66066001)(486006)(4326008)(105586002)(386003)(478600001)(52116002)(72206003)(50226002)(5660300002)(6436002)(81156014)(6512007)(71200400001)(8936002)(71190400001)(6486002)(68736007)(53936002)(256004)(25786009)(8676002)(81166006)(36756003)(14454004)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6462; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: z0fLkbAifzhx4nGP+mmvwH65t9Rq9G2EsV/BGtDMSfcDqiBJpKBsZq/8PhKW+rwnbFek/ElIQkbFdCoKgz7v233SSEnwINPxctMM0eMJIEhcvRhF2NWW+B1g2iPhgRiNQ//hDBp+e892LXtEst4BKnRIYbQZc13/DZoOdHRNAT6UiJdl/qEyHaoat8ERoE3k+dcRQ+a70PkC53nbYMIiOrPhu7rqUNFnSZ91EyTHtk3GBoScTjSnk5XYmO6d9UkaGid1MS8+eqNZOuC4d/hnVLmLUl2se3xuCLT48c1TMhmHCQTxAzPZVOn4QNnyNncvjSGUt8Nu9DVYNmmhj8THmU8JYYEl3izjTx0w1oQG3d3dOCpKipUWVxE/W8gOTmOXpxbb5VYmbpE0IE5MkBJCBGqXC3vKbju/MOxImXK+j0A= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f98d64b4-59f1-41ce-3082-08d6bf363723 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2019 11:01:29.8479 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6462 Subject: [dpdk-dev] [PATCH v3 05/13] net/enetc: add basic statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Enable basic statistics APIs enetc_stats_get and enetc_stats_reset. Signed-off-by: Gagandeep Singh --- doc/guides/nics/enetc.rst | 1 + doc/guides/nics/features/enetc.ini | 1 + drivers/net/enetc/base/enetc_hw.h | 27 ++++++++++++++++++++++++- drivers/net/enetc/enetc_ethdev.c | 41 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst index 8038bf2..9f575d2 100644 --- a/doc/guides/nics/enetc.rst +++ b/doc/guides/nics/enetc.rst @@ -46,6 +46,7 @@ ENETC Features - Link Status - Packet type information +- Basic stats NIC Driver (PMD) ~~~~~~~~~~~~~~~~ diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/enetc.ini index 69476a2..d8bd567 100644 --- a/doc/guides/nics/features/enetc.ini +++ b/doc/guides/nics/features/enetc.ini @@ -6,6 +6,7 @@ [Features] Packet type parsing = Y Link status = Y +Basic stats = Y Linux VFIO = Y ARMv8 = Y Usage doc = Y diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h index e3738a6..3f0a2a9 100644 --- a/drivers/net/enetc/base/enetc_hw.h +++ b/drivers/net/enetc/base/enetc_hw.h @@ -115,8 +115,33 @@ #define ENETC_G_EIPBRR0 0x00bf8 #define ENETC_G_EIPBRR1 0x00bfc - /* MAC Counters */ +/* Config register to reset counters*/ +#define ENETC_PM0_STAT_CONFIG 0x080E0 +/* Receive frames counter without error */ +#define ENETC_PM0_RFRM 0x08120 +/* Receive packets counter, good + bad */ +#define ENETC_PM0_RPKT 0x08160 +/* Received octets, good + bad */ +#define ENETC_PM0_REOCT 0x08120 +/* Transmit octets, good + bad */ +#define ENETC_PM0_TEOCT 0x08200 +/* Transmit frames counter without error */ +#define ENETC_PM0_TFRM 0x08220 +/* Transmit packets counter, good + bad */ +#define ENETC_PM0_TPKT 0x08260 +/* Dropped not Truncated packets counter */ +#define ENETC_PM0_RDRNTP 0x081C8 +/* Dropped + trucated packets counter */ +#define ENETC_PM0_RDRP 0x08158 +/* Receive packets error counter */ +#define ENETC_PM0_RERR 0x08138 +/* Transmit packets error counter */ +#define ENETC_PM0_TERR 0x08238 + +/* Stats Reset Bit*/ +#define ENETC_CLEAR_STATS BIT(2) + #define ENETC_G_EPFBLPR(n) (0xd00 + 4 * (n)) #define ENETC_G_EPFBLPR1_XGMII 0x80000000 diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index 91e9692..10b2b39 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -29,6 +29,9 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, const struct rte_eth_txconf *tx_conf); static void enetc_tx_queue_release(void *txq); static const uint32_t *enetc_supported_ptypes_get(struct rte_eth_dev *dev); +static int enetc_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats); +static void enetc_stats_reset(struct rte_eth_dev *dev); /* * The set of PCI devices this driver supports @@ -46,6 +49,8 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, .dev_stop = enetc_dev_stop, .dev_close = enetc_dev_close, .link_update = enetc_link_update, + .stats_get = enetc_stats_get, + .stats_reset = enetc_stats_reset, .dev_infos_get = enetc_dev_infos_get, .rx_queue_setup = enetc_rx_queue_setup, .rx_queue_release = enetc_rx_queue_release, @@ -608,6 +613,42 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, rte_free(rx_ring); } +static +int enetc_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 ENETC_PM0_RFRM, + * ENETC_PM0_TFRM registers. + */ + stats->ipackets = enetc_port_rd(enetc_hw, ENETC_PM0_RPKT); + stats->opackets = enetc_port_rd(enetc_hw, ENETC_PM0_TPKT); + stats->ibytes = enetc_port_rd(enetc_hw, ENETC_PM0_REOCT); + stats->obytes = enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT); + /* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without + * truncated packets + */ + stats->imissed = enetc_port_rd(enetc_hw, ENETC_PM0_RDRP); + stats->ierrors = enetc_port_rd(enetc_hw, ENETC_PM0_RERR); + stats->oerrors = enetc_port_rd(enetc_hw, ENETC_PM0_TERR); + + return 0; +} + +static void +enetc_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; + + enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS); +} + static int enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev)