From patchwork Fri Oct 12 11:09:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 46707 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 C537C1B56A; Fri, 12 Oct 2018 13:09:39 +0200 (CEST) Received: from NAM05-BY2-obe.outbound.protection.outlook.com (mail-eopbgr710053.outbound.protection.outlook.com [40.107.71.53]) by dpdk.org (Postfix) with ESMTP id 9626D1B5BC for ; Fri, 12 Oct 2018 13:09:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector1-aquantia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CY4p1rRoEkqIFbyy9+UT56QTPeHNaHtEprHnLGNNzpI=; b=EZDc5bONDkxtUHh84hkLWMz+3nfZpb+o1BUKhTLP6z/UqIORuElsMtMZ/9nJjKN7tIyvGpdaiiAFXI3eg6iQndgGAp0XcQDx94DXbXWpX/0GAbumg4spFQikanHJY8lOj1HbQzIe31xiqTDburRO1dBuixtQc6iQNgV7ZnwSPaI= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1627.namprd07.prod.outlook.com (10.162.110.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.22; Fri, 12 Oct 2018 11:09:32 +0000 Received: from BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17]) by BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17%3]) with mapi id 15.20.1228.020; Fri, 12 Oct 2018 11:09:32 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" Thread-Topic: [PATCH v6 12/22] net/atlantic: implement device statistics Thread-Index: AQHUYhwMzbIIwzvxD0G9gMGzLLaG9g== Date: Fri, 12 Oct 2018 11:09:31 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5PR0701CA0008.eurprd07.prod.outlook.com (2603:10a6:203:51::18) To BY1PR0701MB1660.namprd07.prod.outlook.com (2a01:111:e400:522a::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BY1PR0701MB1627; 6:A0Ek+FkXY91TpdrSnJVndRG79n1Gj1zdvBH6O42mpXgyWfZZgI/9vjTj4WszgSWPs2tJOH3PVLbv+nXxJ1ImOyb42cqDTukik/VNGhUM2G2L2MmCTRiQRRMWGfqDO6niMfNXwHE8A7s+opsXkOP5zmr3dtYrCsSKWcWfos/2kYQYYvk1pewVlfHpZTdF95aUJhh/dFTEQ/Ox6Lt+7B5+KM58JLmH2qh5UggEBq71hyuKXPITaXo3azE+47tXlXxw4YZIcEek1KmyOWy+CCDdcgry11q30w6feJ0Y+Bjcol/Tbqo4KRqm5RAM8KLFawKiHXwKt9apyZrCwVIru050zReg/cL2HR+oJniaxUCZQIo+QZaWIT6HM1uYS5YSllaHYJtpXmq+mLmYmBPXpZ9f9u292lCw9L7nniv2MepTZ+5EXhE5q5BC5ibYzkZp9ZHHA1Rtd4ECQVOLXMbfRc5iT6wQ/X3dU2UDsLGkHGHyHx4=; 5:OarsC8ccmcR4ezvV0ikXOM+3zq0Zmjw0ftqPqQqqXOX7eYQNyYQghhF/XRf0uA7DGiD6OJRovGRLQihgenBAQW8O+2v/DuxhqNLsqphzKTf+Mh8KC0ux61ghcIsunHS/du9RqJRz1fW8a5LdSkwNMpHoyIXirGTdIPh5/Z3PGnA=; 7:cpes9ad7qM7eEZE5lTWpznSPDvdikCl8uwf0CdS+EefRrpL3p2KMK8+ZyXYnVAKsAS3cvW/ZsxFLaD+0s0paumteuamA03i75oQwzfnNKMzEYsBTadyt5j5KIpr3RXqWaZWwIkHtRDe9xaDzyOG5UHREURQNkIvjxHnD/vgjeD+iTHukRCeIGh5FGWrArycAURzCxz/pNNtKsPEczUdxl9enpAdAluSH0WlHU9UviTZZS8DWqGn23LlqrqB91pj5 x-ms-office365-filtering-correlation-id: 8581b173-afb7-41c4-d0a6-08d630332f2d x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BY1PR0701MB1627; x-ms-traffictypediagnostic: BY1PR0701MB1627: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991067); SRVR:BY1PR0701MB1627; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1627; x-forefront-prvs: 0823A5777B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(346002)(366004)(376002)(136003)(39850400004)(396003)(189003)(199004)(186003)(6116002)(486006)(5640700003)(446003)(6436002)(6512007)(53936002)(71200400001)(71190400001)(14454004)(72206003)(316002)(2351001)(44832011)(3846002)(7736002)(305945005)(2906002)(4326008)(6486002)(97736004)(26005)(2501003)(102836004)(5250100002)(11346002)(86362001)(575784001)(25786009)(476003)(2616005)(106356001)(54906003)(105586002)(256004)(14444005)(5660300001)(66066001)(81166006)(81156014)(1730700003)(8676002)(478600001)(36756003)(68736007)(6916009)(8936002)(99286004)(386003)(6506007)(118296001)(2900100001)(52116002)(76176011)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1627; H:BY1PR0701MB1660.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: xULOXtH1ou0li9S20hPG+axkcRn0KFkbmJmwSBl9YLl0i4FQ6wnX5lQPMVNQhz145avTRPPohyUvsEbS96S+CFO9FvdwKSPDacxOkQi9IdF1k9ZQV+Nhd426TgSf9fOOypck8i/nV64/8VtE+mfW7Anl+MsD5bAu1Zkm79dtakO1+uNfRh93iwgaMJtLN1gXuJ9J/l3V1XRyXrz+ddn2HU1jlgVLNc9y1CJ00fPU/iKbAsArSm7bGe1PHFEVJqZx01p4dBBJX7fj9o4Sj7ct18LJ2MAl9QIB5d5vGN/W4ZTwQd4NAQBaq/9p8uuYMrThy9XfPRvK4vrFcS09LBe/S+5LQr/UiF69qo0JU67PqY4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8581b173-afb7-41c4-d0a6-08d630332f2d X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2018 11:09:31.8425 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1627 Subject: [dpdk-dev] [PATCH v6 12/22] net/atlantic: implement device 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" From: Pavel Belous Add support for device stats, xstats and queue stats Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- doc/guides/nics/atlantic.rst | 1 + doc/guides/nics/features/atlantic.ini | 3 + drivers/net/atlantic/atl_ethdev.c | 133 ++++++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_ethdev.h | 1 + drivers/net/atlantic/atl_rxtx.c | 11 ++- drivers/net/atlantic/atl_types.h | 41 +++++++++++ 6 files changed, 189 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/atlantic.rst b/doc/guides/nics/atlantic.rst index a003ef5110c9..1108d458f836 100644 --- a/doc/guides/nics/atlantic.rst +++ b/doc/guides/nics/atlantic.rst @@ -13,6 +13,7 @@ Supported features ^^^^^^^^^^^^^^^^^^ - Base L2 features +- Port statistics - Checksum offload - Jumbo Frame upto 16K diff --git a/doc/guides/nics/features/atlantic.ini b/doc/guides/nics/features/atlantic.ini index f5650ae8f5f7..4056d4daacc8 100644 --- a/doc/guides/nics/features/atlantic.ini +++ b/doc/guides/nics/features/atlantic.ini @@ -13,6 +13,9 @@ CRC offload = Y L3 checksum offload = Y L4 checksum offload = Y Packet type parsing = Y +Basic stats = Y +Extended stats = Y +Stats per queue = Y FW version = Y Linux UIO = Y ARMv8 = Y diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index b4f2326b4b9a..b1e7e3030d57 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -24,6 +24,18 @@ static void atl_dev_close(struct rte_eth_dev *dev); static int atl_dev_reset(struct rte_eth_dev *dev); static int atl_dev_link_update(struct rte_eth_dev *dev, int wait); +static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + struct rte_eth_xstat_name *xstats_names, + unsigned int size); + +static int atl_dev_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats); + +static int atl_dev_xstats_get(struct rte_eth_dev *dev, + struct rte_eth_xstat *stats, unsigned int n); + +static void atl_dev_stats_reset(struct rte_eth_dev *dev); + static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); @@ -116,6 +128,33 @@ static const struct rte_eth_desc_lim tx_desc_lim = { .nb_mtu_seg_max = ATL_TX_MAX_SEG, }; +#define ATL_XSTATS_FIELD(name) { \ + #name, \ + offsetof(struct aq_stats_s, name) \ +} + +struct atl_xstats_tbl_s { + const char *name; + unsigned int offset; +}; + +static struct atl_xstats_tbl_s atl_xstats_tbl[] = { + ATL_XSTATS_FIELD(uprc), + ATL_XSTATS_FIELD(mprc), + ATL_XSTATS_FIELD(bprc), + ATL_XSTATS_FIELD(erpt), + ATL_XSTATS_FIELD(uptc), + ATL_XSTATS_FIELD(mptc), + ATL_XSTATS_FIELD(bptc), + ATL_XSTATS_FIELD(erpr), + ATL_XSTATS_FIELD(ubrc), + ATL_XSTATS_FIELD(ubtc), + ATL_XSTATS_FIELD(mbrc), + ATL_XSTATS_FIELD(mbtc), + ATL_XSTATS_FIELD(bbrc), + ATL_XSTATS_FIELD(bbtc), +}; + static const struct eth_dev_ops atl_eth_dev_ops = { .dev_configure = atl_dev_configure, .dev_start = atl_dev_start, @@ -128,6 +167,13 @@ static const struct eth_dev_ops atl_eth_dev_ops = { /* Link */ .link_update = atl_dev_link_update, + /* Stats */ + .stats_get = atl_dev_stats_get, + .xstats_get = atl_dev_xstats_get, + .xstats_get_names = atl_dev_xstats_get_names, + .stats_reset = atl_dev_stats_reset, + .xstats_reset = atl_dev_stats_reset, + .fw_version_get = atl_fw_version_get, .dev_infos_get = atl_dev_info_get, .dev_supported_ptypes_get = atl_dev_supported_ptypes_get, @@ -224,6 +270,9 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) eth_dev->data->mac_addrs->addr_bytes) != 0) return -EINVAL; + /* Reset the hw statistics */ + atl_dev_stats_reset(eth_dev); + rte_intr_callback_register(intr_handle, atl_dev_interrupt_handler, eth_dev); @@ -542,6 +591,90 @@ atl_dev_reset(struct rte_eth_dev *dev) return ret; } + +static int +atl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct atl_adapter *adapter = ATL_DEV_TO_ADAPTER(dev); + struct aq_hw_s *hw = &adapter->hw; + struct atl_sw_stats *swstats = &adapter->sw_stats; + unsigned int i; + + hw->aq_fw_ops->update_stats(hw); + + /* Fill out the rte_eth_stats statistics structure */ + stats->ipackets = hw->curr_stats.dma_pkt_rc; + stats->ibytes = hw->curr_stats.dma_oct_rc; + stats->imissed = hw->curr_stats.dpc; + stats->ierrors = hw->curr_stats.erpt; + + stats->opackets = hw->curr_stats.dma_pkt_tc; + stats->obytes = hw->curr_stats.dma_oct_tc; + stats->oerrors = 0; + + stats->rx_nombuf = swstats->rx_nombuf; + + for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { + stats->q_ipackets[i] = swstats->q_ipackets[i]; + stats->q_opackets[i] = swstats->q_opackets[i]; + stats->q_ibytes[i] = swstats->q_ibytes[i]; + stats->q_obytes[i] = swstats->q_obytes[i]; + stats->q_errors[i] = swstats->q_errors[i]; + } + return 0; +} + +static void +atl_dev_stats_reset(struct rte_eth_dev *dev) +{ + struct atl_adapter *adapter = ATL_DEV_TO_ADAPTER(dev); + struct aq_hw_s *hw = &adapter->hw; + + hw->aq_fw_ops->update_stats(hw); + + /* Reset software totals */ + memset(&hw->curr_stats, 0, sizeof(hw->curr_stats)); + + memset(&adapter->sw_stats, 0, sizeof(adapter->sw_stats)); +} + +static int +atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + struct rte_eth_xstat_name *xstats_names, + unsigned int size) +{ + unsigned int i; + + if (!xstats_names) + return RTE_DIM(atl_xstats_tbl); + + for (i = 0; i < size && i < RTE_DIM(atl_xstats_tbl); i++) + snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, "%s", + atl_xstats_tbl[i].name); + + return size; +} + +static int +atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, + unsigned int n) +{ + struct atl_adapter *adapter = ATL_DEV_TO_ADAPTER(dev); + struct aq_hw_s *hw = &adapter->hw; + unsigned int i; + + if (!stats) + return 0; + + for (i = 0; i < n && i < RTE_DIM(atl_xstats_tbl); i++) { + stats[i].id = i; + stats[i].value = *(u64 *)((uint8_t *)&hw->curr_stats + + atl_xstats_tbl[i].offset); + } + + return n; +} + static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size) { diff --git a/drivers/net/atlantic/atl_ethdev.h b/drivers/net/atlantic/atl_ethdev.h index 55a7e0d6188c..dc48c134b7b8 100644 --- a/drivers/net/atlantic/atl_ethdev.h +++ b/drivers/net/atlantic/atl_ethdev.h @@ -33,6 +33,7 @@ struct atl_interrupt { struct atl_adapter { struct aq_hw_s hw; struct aq_hw_cfg_s hw_cfg; + struct atl_sw_stats sw_stats; struct atl_interrupt intr; }; diff --git a/drivers/net/atlantic/atl_rxtx.c b/drivers/net/atlantic/atl_rxtx.c index 36141564f5c1..c51d24d74ed2 100644 --- a/drivers/net/atlantic/atl_rxtx.c +++ b/drivers/net/atlantic/atl_rxtx.c @@ -874,7 +874,8 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) "queue_id=%u", (unsigned int)rxq->port_id, (unsigned int)rxq->queue_id); dev->data->rx_mbuf_alloc_failed++; - goto err_stop; + adapter->sw_stats.rx_nombuf++; + goto err_stop; } nb_hold++; @@ -957,6 +958,9 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) * of returned packets. */ rx_pkts[nb_rx++] = rx_mbuf_first; + adapter->sw_stats.q_ipackets[rxq->queue_id]++; + adapter->sw_stats.q_ibytes[rxq->queue_id] += + rx_mbuf_first->pkt_len; PMD_RX_LOG(ERR, "add mbuf segs=%d pkt_len=%d", rx_mbuf_first->nb_segs, @@ -1102,6 +1106,8 @@ static inline void atl_xmit_pkt(struct aq_hw_s *hw, struct atl_tx_queue *txq, struct rte_mbuf *tx_pkt) { + struct atl_adapter *adapter = + ATL_DEV_TO_ADAPTER(&rte_eth_devices[txq->port_id]); uint32_t pay_len = 0; int tail = 0; struct atl_tx_entry *tx_entry; @@ -1182,6 +1188,9 @@ atl_xmit_pkt(struct aq_hw_s *hw, struct atl_tx_queue *txq, txq->tx_tail = tail; txq->tx_free -= desc_count; + + adapter->sw_stats.q_opackets[txq->queue_id]++; + adapter->sw_stats.q_obytes[txq->queue_id] += pay_len; } uint16_t diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h index e636464955e3..56887b14d6f8 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -140,4 +140,45 @@ struct aq_fw_ops { int (*set_eeprom)(struct aq_hw_s *self, u32 *data, u32 len); }; +struct atl_sw_stats { + u64 crcerrs; + u64 errbc; + u64 mspdc; + u64 mpctotal; + u64 mpc[8]; + u64 mlfc; + u64 mrfc; + u64 rlec; + u64 lxontxc; + u64 lxonrxc; + u64 lxofftxc; + u64 lxoffrxc; + u64 pxontxc[8]; + u64 pxonrxc[8]; + u64 pxofftxc[8]; + u64 pxoffrxc[8]; + u64 gprc; + u64 bprc; + u64 mprc; + u64 gptc; + u64 gorc; + u64 gotc; + u64 tor; + u64 tpr; + u64 tpt; + u64 mptc; + u64 bptc; + u64 xec; + u64 fccrc; + u64 ldpcec; + u64 pcrc8ec; + + u64 rx_nombuf; + u64 q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + u64 q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + u64 q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + u64 q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + u64 q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS]; +}; + #endif