From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00064.outbound.protection.outlook.com [40.107.0.64]) by dpdk.org (Postfix) with ESMTP id 10A5F4D27 for ; Mon, 8 Apr 2019 13:22:38 +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=8e8uw61QGdbBIdOpq5sc3GieXKZ3Sf2ZpubZo7JtkIo=; b=NzZJonqnF5++0XLVsWPLXf1L+I/3Xw5H9yOvxUcPc/izKnIeJt6mQIV4rCnV1dHH1E7ypr6noWB+pzzvB3sB1rQRZObeWg+GsTYoF0o4h3JQm46RKbjbmX5/D4ypaWfkcAsjv/7iTDlJdP6moinF6j8G4sLBnCkxd7GuN0b2wAI= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6606.eurprd04.prod.outlook.com (20.179.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.13; Mon, 8 Apr 2019 11:22:36 +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.1771.016; Mon, 8 Apr 2019 11:22:36 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH 05/13] net/enetc: add statistics APIs Thread-Index: AQHU7f1ekGH5ZeWco0C1VKbwhysAkw== Date: Mon, 8 Apr 2019 11:22:36 +0000 Message-ID: <1554745507-15089-6-git-send-email-g.singh@nxp.com> References: <1554745507-15089-1-git-send-email-g.singh@nxp.com> In-Reply-To: <1554745507-15089-1-git-send-email-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 1.9.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.67] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ae2d8a60-0be6-4f8d-2f35-08d6bc14807b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6606; x-ms-traffictypediagnostic: VE1PR04MB6606: x-microsoft-antispam-prvs: x-forefront-prvs: 0001227049 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(39860400002)(396003)(136003)(199004)(189003)(76176011)(97736004)(81156014)(71200400001)(71190400001)(72206003)(3846002)(25786009)(81166006)(53936002)(2616005)(5660300002)(6116002)(8676002)(7736002)(446003)(478600001)(8936002)(11346002)(305945005)(2906002)(256004)(14444005)(66066001)(6512007)(476003)(6436002)(486006)(50226002)(2501003)(99286004)(106356001)(86362001)(110136005)(4326008)(6486002)(68736007)(105586002)(6506007)(52116002)(316002)(26005)(386003)(14454004)(186003)(36756003)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6606; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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: JF80fzSnqYJI2nXmUxuSSdOeU1xEnGs6ZE745hHvWDP6cE3fkBwBbb6+xgM24tg2x7pQ6OEw9tPSjtu3QUi3n6Ktaky+YqheWJSedxC8xBaBEbr6ZGCpnnsqmqdkXilAVdFx1alcE7AJDP+BmV2dd0CaSA7bY9iL6DNpnGTJ5gXcTZL4+XRIbnreg+xavW8+90AB5kAikF+SLOPZb10RDZqWW0bQSRrClx4VpTA5y7rEWT6kc+VnD5glBL3m7GcVn8wdLvzs27kDX+ssrnTFWm8nBYUMegAsWiQQjrmIUVaRCnyMOzwazJ8cLNAURmZHPM1UwBRKEm+5vlq6q4N0zzAylBIBSdWawvxsYP76vEqkw7lpusbNe593lhIVKctgttbF2fQzMNJNJiSynQT/7H076CTPeml7V2lQv4hYj2k= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae2d8a60-0be6-4f8d-2f35-08d6bc14807b X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2019 11:22:36.4491 (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: VE1PR04MB6606 Subject: [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs 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: , X-List-Received-Date: Mon, 08 Apr 2019 11:22:38 -0000 Add 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 | 46 ++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 74 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 =20 - Link Status - Packet type information +- Basic stats =20 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 =3D Y Link status =3D Y +Basic stats =3D Y Linux VFIO =3D Y ARMv8 =3D Y Usage doc =3D Y diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/ene= tc_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 =20 - /* 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 =20 diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_eth= dev.c index 91e9692..99c2ce7 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); =20 /* * 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 =3D enetc_dev_stop, .dev_close =3D enetc_dev_close, .link_update =3D enetc_link_update, + .stats_get =3D enetc_stats_get, + .stats_reset =3D enetc_stats_reset, .dev_infos_get =3D enetc_dev_infos_get, .rx_queue_setup =3D enetc_rx_queue_setup, .rx_queue_release =3D enetc_rx_queue_release, @@ -608,6 +613,47 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *de= v, uint16_t tx_queue_id, rte_free(rx_ring); } =20 +static +int enetc_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats) +{ + struct enetc_eth_hw *hw =3D + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; + + if (stats =3D=3D NULL) + return -1; + + memset(stats, 0, sizeof(struct rte_eth_stats)); + + /* 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 =3D enetc_port_rd(enetc_hw, ENETC_PM0_RPKT); + stats->opackets =3D enetc_port_rd(enetc_hw, ENETC_PM0_TPKT); + stats->ibytes =3D enetc_port_rd(enetc_hw, ENETC_PM0_REOCT); + stats->obytes =3D enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT); + /* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without + * truncated packets + */ + stats->imissed =3D enetc_port_rd(enetc_hw, ENETC_PM0_RDRP); + stats->ierrors =3D enetc_port_rd(enetc_hw, ENETC_PM0_RERR); + stats->oerrors =3D 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 =3D + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &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) --=20 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 47C6AA0096 for ; Mon, 8 Apr 2019 13:23:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BCE3A56A1; Mon, 8 Apr 2019 13:22:54 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00064.outbound.protection.outlook.com [40.107.0.64]) by dpdk.org (Postfix) with ESMTP id 10A5F4D27 for ; Mon, 8 Apr 2019 13:22:38 +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=8e8uw61QGdbBIdOpq5sc3GieXKZ3Sf2ZpubZo7JtkIo=; b=NzZJonqnF5++0XLVsWPLXf1L+I/3Xw5H9yOvxUcPc/izKnIeJt6mQIV4rCnV1dHH1E7ypr6noWB+pzzvB3sB1rQRZObeWg+GsTYoF0o4h3JQm46RKbjbmX5/D4ypaWfkcAsjv/7iTDlJdP6moinF6j8G4sLBnCkxd7GuN0b2wAI= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6606.eurprd04.prod.outlook.com (20.179.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.13; Mon, 8 Apr 2019 11:22:36 +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.1771.016; Mon, 8 Apr 2019 11:22:36 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH 05/13] net/enetc: add statistics APIs Thread-Index: AQHU7f1ekGH5ZeWco0C1VKbwhysAkw== Date: Mon, 8 Apr 2019 11:22:36 +0000 Message-ID: <1554745507-15089-6-git-send-email-g.singh@nxp.com> References: <1554745507-15089-1-git-send-email-g.singh@nxp.com> In-Reply-To: <1554745507-15089-1-git-send-email-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 1.9.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.67] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ae2d8a60-0be6-4f8d-2f35-08d6bc14807b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6606; x-ms-traffictypediagnostic: VE1PR04MB6606: x-microsoft-antispam-prvs: x-forefront-prvs: 0001227049 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(39860400002)(396003)(136003)(199004)(189003)(76176011)(97736004)(81156014)(71200400001)(71190400001)(72206003)(3846002)(25786009)(81166006)(53936002)(2616005)(5660300002)(6116002)(8676002)(7736002)(446003)(478600001)(8936002)(11346002)(305945005)(2906002)(256004)(14444005)(66066001)(6512007)(476003)(6436002)(486006)(50226002)(2501003)(99286004)(106356001)(86362001)(110136005)(4326008)(6486002)(68736007)(105586002)(6506007)(52116002)(316002)(26005)(386003)(14454004)(186003)(36756003)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6606; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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: JF80fzSnqYJI2nXmUxuSSdOeU1xEnGs6ZE745hHvWDP6cE3fkBwBbb6+xgM24tg2x7pQ6OEw9tPSjtu3QUi3n6Ktaky+YqheWJSedxC8xBaBEbr6ZGCpnnsqmqdkXilAVdFx1alcE7AJDP+BmV2dd0CaSA7bY9iL6DNpnGTJ5gXcTZL4+XRIbnreg+xavW8+90AB5kAikF+SLOPZb10RDZqWW0bQSRrClx4VpTA5y7rEWT6kc+VnD5glBL3m7GcVn8wdLvzs27kDX+ssrnTFWm8nBYUMegAsWiQQjrmIUVaRCnyMOzwazJ8cLNAURmZHPM1UwBRKEm+5vlq6q4N0zzAylBIBSdWawvxsYP76vEqkw7lpusbNe593lhIVKctgttbF2fQzMNJNJiSynQT/7H076CTPeml7V2lQv4hYj2k= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae2d8a60-0be6-4f8d-2f35-08d6bc14807b X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2019 11:22:36.4491 (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: VE1PR04MB6606 Subject: [dpdk-dev] [PATCH 05/13] net/enetc: add statistics APIs 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" Message-ID: <20190408112236.omX7tqHm7NR1b0SuIvt1tZxWvMSK1labdykv7jfx1og@z> Add 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 | 46 ++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 74 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 =20 - Link Status - Packet type information +- Basic stats =20 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 =3D Y Link status =3D Y +Basic stats =3D Y Linux VFIO =3D Y ARMv8 =3D Y Usage doc =3D Y diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/ene= tc_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 =20 - /* 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 =20 diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_eth= dev.c index 91e9692..99c2ce7 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); =20 /* * 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 =3D enetc_dev_stop, .dev_close =3D enetc_dev_close, .link_update =3D enetc_link_update, + .stats_get =3D enetc_stats_get, + .stats_reset =3D enetc_stats_reset, .dev_infos_get =3D enetc_dev_infos_get, .rx_queue_setup =3D enetc_rx_queue_setup, .rx_queue_release =3D enetc_rx_queue_release, @@ -608,6 +613,47 @@ static int enetc_tx_queue_setup(struct rte_eth_dev *de= v, uint16_t tx_queue_id, rte_free(rx_ring); } =20 +static +int enetc_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats) +{ + struct enetc_eth_hw *hw =3D + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; + + if (stats =3D=3D NULL) + return -1; + + memset(stats, 0, sizeof(struct rte_eth_stats)); + + /* 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 =3D enetc_port_rd(enetc_hw, ENETC_PM0_RPKT); + stats->opackets =3D enetc_port_rd(enetc_hw, ENETC_PM0_TPKT); + stats->ibytes =3D enetc_port_rd(enetc_hw, ENETC_PM0_REOCT); + stats->obytes =3D enetc_port_rd(enetc_hw, ENETC_PM0_TEOCT); + /* Dropped + Truncated packets, use ENETC_PM0_RDRNTP for without + * truncated packets + */ + stats->imissed =3D enetc_port_rd(enetc_hw, ENETC_PM0_RDRP); + stats->ierrors =3D enetc_port_rd(enetc_hw, ENETC_PM0_RERR); + stats->oerrors =3D 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 =3D + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &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) --=20 1.9.1