From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0058.outbound.protection.outlook.com [104.47.32.58]) by dpdk.org (Postfix) with ESMTP id 7E2351B436 for ; Tue, 9 Oct 2018 11:31:51 +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=txPMCKIZu6HqaoECmZDs/fIYm53HOHS0UVcd05XnLeI=; b=dg6gtITfp4OJ/LrhYHJ5r7kslKPTkAzzop4+oUvUx+AXYCfnCU6lcjt2gZnvhS2yg04fuUovQQZRV9yEJUyhek51dd2cvyAEZz9NXSzz3UGfemAn91RuhcZczeOCEul3F4ZrJ/Zm7JyWlNelJvqKbj2DSpdlmevWiBxk2lsZ4KM= Received: from BLUPR0701MB1651.namprd07.prod.outlook.com (10.163.84.21) by BLUPR0701MB1650.namprd07.prod.outlook.com (10.163.84.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.23; Tue, 9 Oct 2018 09:31:49 +0000 Received: from BLUPR0701MB1651.namprd07.prod.outlook.com ([fe80::7c97:1527:4c0:8b46]) by BLUPR0701MB1651.namprd07.prod.outlook.com ([fe80::7c97:1527:4c0:8b46%3]) with mapi id 15.20.1207.024; Tue, 9 Oct 2018 09:31:49 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" , Pavel Belous Thread-Topic: [PATCH v4 12/22] net/atlantic: device statistics, xstats Thread-Index: AQHUX7LnUvTyU2MRwUeXVfVNW0Taaw== Date: Tue, 9 Oct 2018 09:31:49 +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: AM0PR01CA0028.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::41) To BLUPR0701MB1651.namprd07.prod.outlook.com (2a01:111:e400:58c6::21) 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; BLUPR0701MB1650; 6:B+wYAivP2ACMlvgS9LJ8HbtIZlBhrwpl1w86fdGOO9If6Ctjp9+b0evcL51zUlgOMg+sMYtM7x9Jat4KyE5/AD7iDDCXBkaHKhOnugjNf+2QutsQXfUCn6hVnsqy7222gqFKxEN0YkR/G3aVsHb9y/cQUePKXEyRzYDFwZuP++NiJpcQGzfKDcpHoG171xiboDFVzmS5jCu6WAbTl58uDDPhRWOuS6pZGf6LwaoA4HmrvZyTy26aqiAG+xc/s/wTncPuVfESMdX+EG4fLjeGRI1dGIkSm/lRbw7tQnXBUzWNNdTo0H2OAFWFUTdPcrGxbRSDT/zoe6Xu5gBq/1THYxHeartEpjQtAmBn64fBjQshkXaMW9A93MEOBQN8KIOXv+STEZsb1CbyrzyDJCFT5zUC+qpI7wDxxrzGEQ/ql9X2zXXrAwRe30WkFCfP0sNR6l00/LfRVgek3Rjoy8HxfA==; 5:AedOoJBbRuufR9I/XiL/DDWqCWZ7mtOHT//HhvxTLyilmnmX4KfPhGoZBmFFyIFJtlwcn3wgHqSwBnX3God6ovLoedztOjtlZzma5lj/9LJ0OpjKRDjXRd+SFplOCWhtcap2oULSvUed4d9kM5Rd9ffq7Rw0qXU6aQLbJlshTts=; 7:ey9CsGm8zkgDJuG/pciL6APliLs/Qz0po1VbXaNEJxqqd/E8xwZrRuNRdp0bL0YoVBrdGCNKfiB7KIVaeexc/ZsGOCm4hLNTdQctX12xHgyUEe/8HEwuE/VR4nxD2SUZh+ZNgHZdBm9U/sjQS7XABinonObmuM6rrMjermscKS3XLvUYVP3cnLrl5JtUt0NlFIrtxf7KiJmUgMQ3G9OcyZBrlW9CA/5GJJqUDCHhNEQ8RKY6HCMxQOBZYGo1aiaV x-ms-office365-filtering-correlation-id: bab6af13-84f0-4d71-6e88-08d62dca09e3 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1650; x-ms-traffictypediagnostic: BLUPR0701MB1650: 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)(10201501046)(3231355)(944501410)(52105095)(93006095)(93001095)(3002001)(149066)(150057)(6041310)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(201708071742011)(7699051); SRVR:BLUPR0701MB1650; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1650; x-forefront-prvs: 08200063E9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39850400004)(346002)(376002)(396003)(136003)(189003)(199004)(81156014)(5640700003)(6116002)(71200400001)(105586002)(68736007)(316002)(3846002)(107886003)(71190400001)(26005)(118296001)(2616005)(5250100002)(25786009)(4326008)(102836004)(44832011)(446003)(476003)(11346002)(186003)(2906002)(106356001)(97736004)(2501003)(2351001)(486006)(478600001)(99286004)(53936002)(386003)(1730700003)(5660300001)(6506007)(36756003)(66066001)(54906003)(305945005)(256004)(14444005)(86362001)(575784001)(7736002)(2900100001)(76176011)(8936002)(52116002)(8676002)(6486002)(72206003)(6436002)(14454004)(81166006)(6512007)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1650; H:BLUPR0701MB1651.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: wFx35Dq9apL4fhpoyM7CYwTu3poCumnD3E71dzEZCZwNuyrdBi0uLDir6mwxHnkGLTlGnLJ2sGwoYKfn815uiQ/QP0DOftvr0xJ51ns5upx5AX9+Z6CZjjTgRYFbINwj0wf/QZSLRuHUlWC7SQ7sU8PXHi45n7bRmOE8cvqPp+mxKu8Hk4QXbX7O4nh4zzXDjRZY/VYBloWY8qrX/kPgpWl8/Ex6k1Hy3Cr8wp2pVa2zU0hu6amo4fT8aXGnCd+qlfH5ZbaLE+8doPxOYqmDSO3JUBUxUFdEpHubrWtTXA5My4HjWi5ZsOo2pioaI8ij8v2/wS9fIF/iMEmDtOyFG0Ids1lWYlr/8ujgukUYSGo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bab6af13-84f0-4d71-6e88-08d62dca09e3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Oct 2018 09:31:49.6330 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1650 Subject: [dpdk-dev] [PATCH v4 12/22] net/atlantic: device statistics, xstats 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: Tue, 09 Oct 2018 09:31:52 -0000 From: Pavel Belous Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- drivers/net/atlantic/atl_ethdev.c | 154 ++++++++++++++++++++++++++++++++++= ++++ drivers/net/atlantic/atl_ethdev.h | 1 + drivers/net/atlantic/atl_rxtx.c | 11 ++- drivers/net/atlantic/atl_types.h | 41 ++++++++++ 4 files changed, 206 insertions(+), 1 deletion(-) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_e= thdev.c index 89e23be50ec9..30a800da0209 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -24,6 +24,24 @@ 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); =20 +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 void atl_dev_xstats_reset(struct rte_eth_dev *dev); + +static int atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev, + uint16_t queue_id, + uint8_t stat_idx, + uint8_t is_rx); + static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); =20 @@ -116,6 +134,33 @@ static const struct rte_eth_desc_lim tx_desc_lim =3D { .nb_mtu_seg_max =3D ATL_TX_MAX_SEG, }; =20 +#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[] =3D { + 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 =3D { .dev_configure =3D atl_dev_configure, .dev_start =3D atl_dev_start, @@ -128,6 +173,14 @@ static const struct eth_dev_ops atl_eth_dev_ops =3D { /* Link */ .link_update =3D atl_dev_link_update, =20 + /* Stats */ + .stats_get =3D atl_dev_stats_get, + .xstats_get =3D atl_dev_xstats_get, + .xstats_get_names =3D atl_dev_xstats_get_names, + .stats_reset =3D atl_dev_stats_reset, + .xstats_reset =3D atl_dev_xstats_reset, + .queue_stats_mapping_set =3D atl_dev_queue_stats_mapping_set, + .fw_version_get =3D atl_fw_version_get, .dev_infos_get =3D atl_dev_info_get, .dev_supported_ptypes_get =3D atl_dev_supported_ptypes_get, @@ -289,6 +342,9 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) (u8 *)ð_dev->data->mac_addrs[0]) !=3D 0) return -EINVAL; =20 + /* Reset the hw statistics */ + atl_dev_stats_reset(eth_dev); + rte_intr_callback_register(intr_handle, atl_dev_interrupt_handler, eth_dev); =20 @@ -613,6 +669,104 @@ atl_dev_reset(struct rte_eth_dev *dev) return ret; } =20 + +static int +atl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct atl_adapter *adapter =3D + (struct atl_adapter *)dev->data->dev_private; + struct aq_hw_s *hw =3D &adapter->hw; + struct atl_sw_stats *swstats =3D &adapter->sw_stats; + unsigned int i; + + hw->aq_fw_ops->update_stats(hw); + + /* Fill out the rte_eth_stats statistics structure */ + stats->ipackets =3D hw->curr_stats.dma_pkt_rc; + stats->ibytes =3D hw->curr_stats.dma_oct_rc; + stats->imissed =3D hw->curr_stats.dpc; + stats->ierrors =3D hw->curr_stats.erpt; + + stats->opackets =3D hw->curr_stats.dma_pkt_tc; + stats->obytes =3D hw->curr_stats.dma_oct_tc; + stats->oerrors =3D 0; + + stats->rx_nombuf =3D swstats->rx_nombuf; + + for (i =3D 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { + stats->q_ipackets[i] =3D swstats->q_ipackets[i]; + stats->q_opackets[i] =3D swstats->q_opackets[i]; + stats->q_ibytes[i] =3D swstats->q_ibytes[i]; + stats->q_obytes[i] =3D swstats->q_obytes[i]; + stats->q_errors[i] =3D swstats->q_errors[i]; + } + return 0; +} + +static void +atl_dev_stats_reset(struct rte_eth_dev *dev) +{ + struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + hw->aq_fw_ops->update_stats(hw); + + /* Reset software totals */ + memset(&hw->curr_stats, 0, sizeof(hw->curr_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 =3D 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 =3D + (struct atl_adapter *)dev->data->dev_private; + struct aq_hw_s *hw =3D &adapter->hw; + unsigned int i; + + if (!stats) + return 0; + + for (i =3D 0; i < n && i < RTE_DIM(atl_xstats_tbl); i++) { + stats[i].id =3D i; + stats[i].value =3D *(u64 *)((uint8_t *)&hw->curr_stats + + atl_xstats_tbl[i].offset); + } + + return n; +} + +static void +atl_dev_xstats_reset(struct rte_eth_dev *dev __rte_unused) +{ +} + +static int +atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev __rte_unused, + uint16_t queue_id __rte_unused, + uint8_t stat_idx __rte_unused, + uint8_t is_rx __rte_unused) +{ + /* The mapping is hardcoded: queue 0 -> stat 0, etc */ + return 0; +} + static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_si= ze) { diff --git a/drivers/net/atlantic/atl_ethdev.h b/drivers/net/atlantic/atl_e= thdev.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; }; =20 diff --git a/drivers/net/atlantic/atl_rxtx.c b/drivers/net/atlantic/atl_rxt= x.c index 4bacea198766..e9be6d85e647 100644 --- a/drivers/net/atlantic/atl_rxtx.c +++ b/drivers/net/atlantic/atl_rxtx.c @@ -855,7 +855,8 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts= , uint16_t nb_pkts) "queue_id=3D%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; } =20 nb_hold++; @@ -938,6 +939,9 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts= , uint16_t nb_pkts) * of returned packets. */ rx_pkts[nb_rx++] =3D rx_mbuf_first; + adapter->sw_stats.q_ipackets[rxq->queue_id]++; + adapter->sw_stats.q_ibytes[rxq->queue_id] +=3D + rx_mbuf_first->pkt_len; =20 PMD_RX_LOG(ERR, "add mbuf segs=3D%d pkt_len=3D%d", rx_mbuf_first->nb_segs, @@ -1083,6 +1087,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 =3D + ATL_DEV_TO_ADAPTER(&rte_eth_devices[txq->port_id]); uint32_t pay_len =3D 0; int tail =3D 0; struct atl_tx_entry *tx_entry; @@ -1163,6 +1169,9 @@ atl_xmit_pkt(struct aq_hw_s *hw, struct atl_tx_queue = *txq, txq->tx_tail =3D tail; =20 txq->tx_free -=3D desc_count; + + adapter->sw_stats.q_opackets[txq->queue_id]++; + adapter->sw_stats.q_obytes[txq->queue_id] +=3D pay_len; } =20 uint16_t diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_ty= pes.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); }; =20 +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 --=20 2.7.4