From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0040.outbound.protection.outlook.com [104.47.36.40]) by dpdk.org (Postfix) with ESMTP id EF942F96D for ; Sat, 25 Mar 2017 07:29:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NNwhopJ4d9rWC6yE19UOrmKnc3NkilBRyr8XOGpVn38=; b=XlbTN9aOZyXl+ZH5gwdWkReAeMm6bIUtOO16kal+/mU5YUTWfFk+Xz17inawqzlMeGrs8OyslO1UxIyPr38txpe85hI0Ntz/NJppM0Vvqfl3HvY83zgWoVcnNpqcQe3pCnXrLiZeLFH+Tw5FZrSocQCdJKx3YMiakYdHLm8m+6U= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Sat, 25 Mar 2017 06:29:00 +0000 From: Shijith Thotton To: Ferruh Yigit Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Sat, 25 Mar 2017 11:54:53 +0530 Message-Id: <1490423097-6797-43-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0117.INDPRD01.PROD.OUTLOOK.COM (10.174.208.33) To CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) X-MS-Office365-Filtering-Correlation-Id: 1438e7a8-e7f9-47f5-f2e3-08d473483b1b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:2laMFn4/V7JgDIXckFDx2qkaFw1L6u3xvz/tgY/aVcAPq0iUpxpGm7QTvxaNWgsHRzdaNHy3vOntR5NofXz8yvW1bxI4GzT3Zr5LVeT19EyrUVBD+apDQQGjMb8lYhkC35lgxneK1HhlUqitqjxeRZtbtn28BWxsv+obEC/Dj4iZNpHQJaGlnt/r8fDOVKP258WvaDCqdEGu/CDD7Re+PgQhCQrkO2ZOkaKzg26oEQ2Ydt/r+a0S0bmP6A+aDg73sOOt+ekeAvFgjWm8YC5Abw==; 25:SFjF20WhAE6TzZ3l1ZXX6iB/jVv1k71JfmmglSFEz7krsfTl2zlBxcG7ugFUwcj5rAxsdKJKYf+7C/fF3nK/oRpYy8hgUatOIAYB5kS7UQNLJlvhGsV6trRd/z6MIRL13D2yjtazH5UiP0UUUBkkyKPxSlgVXVvKOFapeQLykSkAbs9Csf4ynrhKeNQTOCM3w+KZiANovr0c7lVEpGx4Tz9S+qSjc7FftIKc8dt5May3wa/iwpCVyy+r9CUTg+mWdYllRHrL/8tBwEBXT+WyGnRFLCtM7P9w6wzqGuJuzBwwMmVy3xDA2lmYOrq3Gv1LTDCMwv4uyihrZ2EXdU4mJdCdTMCFqAjDnGnCNQIIyo9rmt/aK9LHKKdJoRk66qrQ0tC11dg/wxdPCC3JPwLHqZZ1+ISMVHr3UXeMmd/NlGyCTz2k4+uBa8WMpywTF8iChoCQVQlHA7ofQbAvTOQqXQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:RaMArqH4cpPIc1ylfkhu3AOWDc+NlIMuhpSnFpjOdlQlUWM1V96jo1vjZy/n633KYMbqdexHrjhYnzx2EV/WdEehZN9XXRGvSW3xUQd43+sEU9WJ8NBMwP+hcnHxINy8KdpS8VawDrwz8seI4U+8GDZDgw7QvGW2HGnAOF6LFz6hsQL1UHNn0EkT65yJijkKjpFWIqfbUDLQCyQKcxDnhjkjhB2L2VvRJFZ5nHmIuD4=; 20:3LH3ZMA28YgiL4DTnlSKOh6X12w61JeZ+4l6JJijOMKI5r93VNjuow/vt8xj2PC78vAjgt9VG9MTRmasBHgcK3/xDetKarDpgbIixKkDRIheBkhh5ERiS12rN28gg8h2T859bBpbcfJY+6ACPlva90SSE0sHRRzeXdli/9///bt8Q8I3p6TmBqop0EYbVHR+dmKRsWRZHWW+ODlPrbjHDu6hT2pFJB/3+zKhkOJuTCqyCIadZz/cV0yqjGsPkgztfCVKnHjWbUQXkk8tLYg+TZIemYarL7pPSPRk0KpvbjU8XaHXmbLdcsnfneqzii0rvGRN6iwiqwx4rXn4Hp+7gTHYbxCZdhNcigHPFG9zQ2hW9SUz47R4xFtXY4BE2ZI56Bv4d5qhR8xM5HRX1ZfJovqnkujmFCSyJB2qFUj4ERpm9sW1MZxXq3U/md51/xDvd6NMKLyv84nPx1CTwETm2O19ruFyMqxkhiuulZkDETfZ9Ke493S5UoAj35gMa+NZEVw7LegKn3JKVowl0wF4sU6ymGTMrk0wQ1Ec2nC8ULkRIOtJoGaTKRUIc1clniTiEKD0/bckNNn03DSfv7w5Ylw03Uzf/HbDpm2+v35TBqk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(6072148); SRVR:CY1PR07MB2280; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 4:yhs171hCz5z14TBPijrMg5gqLTV6THDBsbjY8EWdDbT6DtIbjQY6eEYLMLmtq9uTJxvpmJcbkEhCzkwYnWCoJI/WlVRmEWaPwb+Mf3Es167E+dSfvts81Uv/8wgq6efonBZNJ714dXSBVzS0nkSleD2+6mXQNSQkN/OiqI3pkZjxbuzwN5ACw5g2VI/Pi51mJ4sualmY6ZhJUVL50kG9Y109jUFXivOjikA00eRLOF5sve1RAottX2IRpFUsv0rP8JlPob6Bja9S3o0uMczfgTg82p3vYp6RGdC5GubgovG1kFGUt+vHzQgSU2KssPu+XLRA+ADU+C04c1NOVHt06+4P1v6jHaVNJFj2hd/X0Xn7PcX5UCdQ+KufYGEMz0hYZJpvPmCoeeN4ag+Jeg0I03nSthr/PVoN0MpdarSEeRI5veUOFaoGREsB4rCLp8v2xiBsZ1Lw3p12O1VDWrs+AC0msqyYpSESL95dK/p88zXJ0SQ3EFC8GIGVEXIn6kUhTkESy03MU1JA2ReAnnEoIkzlJL0qRMSjGQIcZRHfbfHMm9kFYKaiAdJ5xwqrujoquMZpQwHDuJIWjAxMcQckJ4qX3XPvNbUHcWwCYkOW4D4= X-Forefront-PRVS: 025796F161 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39410400002)(39830400002)(2906002)(2950100002)(5003940100001)(66066001)(42882006)(6916009)(50466002)(48376002)(47776003)(42186005)(53936002)(6512007)(68736007)(5009440100003)(54906002)(50226002)(38730400002)(6486002)(6666003)(25786009)(305945005)(81166006)(7736002)(6116002)(3846002)(4326008)(8676002)(6506006)(189998001)(36756003)(50986999)(76176999)(33646002)(4720700003)(5660300001)(110136004)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2280; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2280; 23:T19078oel1Lmkh0W/aHDYRlefxwX023ZwinzUo0tx?= =?us-ascii?Q?u8BiSACgE0n6JIDSgsMkTLZwB1z/2HEEag95dnP0ioAXdrQ+OwcJpeQTmd/R?= =?us-ascii?Q?974tp58ZyJgNxbIXKft+EduVAiii5Uff9+7IjsM8Nul0VxoiB8OMO7FMMrtF?= =?us-ascii?Q?K/8Td+GieX9QFdG5OmXVQ6Nr5PFHyE1jfalluJdcLYomAKJi4L0TP4NQuVxJ?= =?us-ascii?Q?I/DjfGahHM0GO8tkWD4ltIsWyByb3KHbpOgIBVrJnDaplEJEtYLNOzcdHNkR?= =?us-ascii?Q?qg4HDvgWOWwBnibiKBDMBxIdbbL3EsqKUOnUnWd390gwGRp539+sAmvMMGM7?= =?us-ascii?Q?lbMLlRsDjJ5VLNzaee0p25p+SB61+h0R/2Px6Q1EnsMEj0QiMmNBh4g9K47C?= =?us-ascii?Q?b2/T2HT1lQz9Z1BPD3mShS5PnRSN1f+Ors2Me9OxnNH5COxCMBcHqawXZLPR?= =?us-ascii?Q?yQNwEpvZn1bLNjgEvVnhBxeTn/VMddrmmvfpAEl/opgr5GqkOInp6DTRc/Yy?= =?us-ascii?Q?w7QYK3N48pqYAkkrWpJh32cBL9rhUxWGWg9XbDOlABy/8VbxHAecGnuN47pA?= =?us-ascii?Q?678zm4NojrTaAIoUxXjISKb61Q3dtKyOgPzpjBSRHrX0xuH7z0qh3LTiCwz8?= =?us-ascii?Q?VNcZFgD/1ljKCa7WL8HjGNREp5YERS0HoSlXYy/9AWmlfYdcZdW/N/W1BTTX?= =?us-ascii?Q?6okh6p1y7q/iSN3X1bWttmjwl9GNvN77M/jq6tKfnt0D31cCJAgFMJ4XBi9h?= =?us-ascii?Q?IV+x/6Y9+Ol3yfqzZkKCH1gKsLM5vG5CLBPRojjiGnG9zaTzxZSAxfx/bZL7?= =?us-ascii?Q?FvqrlJbSLaYyOWs7GTCH/Zh77RfwB/DwlFHbQj2yjv8CvL7IOWL1by77MEMy?= =?us-ascii?Q?2/tFQhKn82A+JaERkwpAdzWMj5VThRpvXKHg78U/MnR1D1CIyenWTYgmBkmj?= =?us-ascii?Q?vQyv/GxVzcgcBN2IUu0pLhoT914+tEl0o3Ha6WZ5x7a8nX76yPJuZIltjmYa?= =?us-ascii?Q?mw4A4gLKgXLw2zmEEU69T5VVrUSz8FsAnHFsfJS6vQliRXxAtOyL0+AN6pwD?= =?us-ascii?Q?JKG1ZVHdvVF5ZhYeV+xcnZ19Rda?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:jx9Fyupkgeq5fNk3FxASMTXsL+CVCxIINpBK+w4zjQRFxIs1QvvCEIgGEi9jtsx6FdHvg2qGH6V1+ie1XZTz0cDo7Dv6yCfYx4SiH11msuSvxBV724NKR1b9L7WbTqjAl37QUfILnJr94YhQdUJJo3mtgZYx265Sb3HKtddOn+ShJdboS5sTEHSrRjGyyxM27/ZoPIR3LItQmtgaLjoxvTQJeXREw+iU8hsL/+Do0Vh1XXC06yZk0BpecXj+CUiYicMhoLp4kQsnoyxjm54RtslwuK9/YGR7AwKwo9hUxnHk0GZQ+Wj6A0Mpu4fJ6V4TjudmpRYb1T1bPVfAxXEotUC0+iniqzbP9ez+bCAwJU2ePEguYbZkAT8TsPKF1bLTFLfULeMyxoxKVBeVkdTzZg==; 5:75LrLL75BHNKEwNAh5uBeJ5pKv9URM1krbc9H4K6+pkcvwGfdOSwgE9aSNeO1+SKAH1DxUPBQHooG8EiZJjlVwdiiktISC7eSREUwqKmW2RJfqJ6eqtdrtM31wLt1ccli8lMPVCCn2JZaMH+qBm48Q==; 24:ORddWAr8O/BqLeBpSMktch+Kn3q2K7uE3ZTzx61SIf2LGonoPaHgEleLG8SjU/jwM9W3/ceFu+53/K8xWrk0i+MlMh0JHTzmUuetpfQIPY0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:xdMTFn0p6Sb7TdwazNc4NL+MCxaI2x+1d9OTqtBaJsTmqEhhQY3a7Rm+QAHfxYIhn9x1g0Q9h0648a6syDn1IYXmHcad9XOynnO3bTzgya/zB0jhFa79P78Tl0N6aM8it49akct0a2wNjwq3QllSAtbRWspYHyJfi07I0xqM5Gz8dpRLF1nDK76W/d/NhoetQ3OVhM95LLFnfP8KvsbynySise9DmUIHNY3kn+vMqlbeSIJlZEA8MGPDvyC7pjiKRvUOCsz1kSTWc4T8ipn0znR3G6w8xIPuof6/bM+Vs4shvdp5VgRqR4LnXjEJtPdek8Yt8YcDHUePrnRT5+0K/w== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:29:00.8670 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 42/46] net/liquidio: add APIs for hardware stats 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: Sat, 25 Mar 2017 06:29:05 -0000 Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- doc/guides/nics/features/liquidio.ini | 1 + drivers/net/liquidio/base/lio_hw_defs.h | 2 + drivers/net/liquidio/lio_ethdev.c | 194 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_ethdev.h | 83 ++++++++++++++ 4 files changed, 280 insertions(+) diff --git a/doc/guides/nics/features/liquidio.ini b/doc/guides/nics/features/liquidio.ini index 3195515..d6d9e92 100644 --- a/doc/guides/nics/features/liquidio.ini +++ b/doc/guides/nics/features/liquidio.ini @@ -18,6 +18,7 @@ L4 checksum offload = Y Inner L3 checksum = Y Inner L4 checksum = Y Basic stats = Y +Extended stats = Y Multiprocess aware = Y Linux UIO = Y Linux VFIO = Y diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index cc189ad..8a22d10 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -124,6 +124,7 @@ enum octeon_tag_type { #define LIO_OPCODE_NW_DATA 0x02 /* network packet data */ #define LIO_OPCODE_CMD 0x03 #define LIO_OPCODE_INFO 0x04 +#define LIO_OPCODE_PORT_STATS 0x05 #define LIO_OPCODE_IF_CFG 0x09 #define LIO_MIN_RX_BUF_SIZE 64 @@ -132,6 +133,7 @@ enum octeon_tag_type { /* NIC Command types */ #define LIO_CMD_CHANGE_DEVFLAGS 0x3 #define LIO_CMD_RX_CTL 0x4 +#define LIO_CMD_CLEAR_STATS 0x6 #define LIO_CMD_SET_RSS 0xD #define LIO_CMD_TNL_RX_CSUM_CTL 0x10 #define LIO_CMD_TNL_TX_CSUM_CTL 0x11 diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 2f3bb3d..4d0977a 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -117,6 +117,197 @@ return 0; } +/* store statistics names and its offset in stats structure */ +struct rte_lio_xstats_name_off { + char name[RTE_ETH_XSTATS_NAME_SIZE]; + unsigned int offset; +}; + +static const struct rte_lio_xstats_name_off rte_lio_stats_strings[] = { + {"rx_pkts", offsetof(struct octeon_rx_stats, total_rcvd)}, + {"rx_bytes", offsetof(struct octeon_rx_stats, bytes_rcvd)}, + {"rx_broadcast_pkts", offsetof(struct octeon_rx_stats, total_bcst)}, + {"rx_multicast_pkts", offsetof(struct octeon_rx_stats, total_mcst)}, + {"rx_flow_ctrl_pkts", offsetof(struct octeon_rx_stats, ctl_rcvd)}, + {"rx_fifo_err", offsetof(struct octeon_rx_stats, fifo_err)}, + {"rx_dmac_drop", offsetof(struct octeon_rx_stats, dmac_drop)}, + {"rx_fcs_err", offsetof(struct octeon_rx_stats, fcs_err)}, + {"rx_jabber_err", offsetof(struct octeon_rx_stats, jabber_err)}, + {"rx_l2_err", offsetof(struct octeon_rx_stats, l2_err)}, + {"rx_vxlan_pkts", offsetof(struct octeon_rx_stats, fw_rx_vxlan)}, + {"rx_vxlan_err", offsetof(struct octeon_rx_stats, fw_rx_vxlan_err)}, + {"rx_lro_pkts", offsetof(struct octeon_rx_stats, fw_lro_pkts)}, + {"tx_pkts", (offsetof(struct octeon_tx_stats, total_pkts_sent)) + + sizeof(struct octeon_rx_stats)}, + {"tx_bytes", (offsetof(struct octeon_tx_stats, total_bytes_sent)) + + sizeof(struct octeon_rx_stats)}, + {"tx_broadcast_pkts", + (offsetof(struct octeon_tx_stats, bcast_pkts_sent)) + + sizeof(struct octeon_rx_stats)}, + {"tx_multicast_pkts", + (offsetof(struct octeon_tx_stats, mcast_pkts_sent)) + + sizeof(struct octeon_rx_stats)}, + {"tx_flow_ctrl_pkts", (offsetof(struct octeon_tx_stats, ctl_sent)) + + sizeof(struct octeon_rx_stats)}, + {"tx_fifo_err", (offsetof(struct octeon_tx_stats, fifo_err)) + + sizeof(struct octeon_rx_stats)}, + {"tx_total_collisions", (offsetof(struct octeon_tx_stats, + total_collisions)) + + sizeof(struct octeon_rx_stats)}, + {"tx_tso", (offsetof(struct octeon_tx_stats, fw_tso)) + + sizeof(struct octeon_rx_stats)}, + {"tx_vxlan_pkts", (offsetof(struct octeon_tx_stats, fw_tx_vxlan)) + + sizeof(struct octeon_rx_stats)}, +}; + +#define LIO_NB_XSTATS RTE_DIM(rte_lio_stats_strings) + +/* Get hw stats of the port */ +static int +lio_dev_xstats_get(struct rte_eth_dev *eth_dev, struct rte_eth_xstat *xstats, + unsigned int n) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + uint16_t timeout = LIO_MAX_CMD_TIMEOUT; + struct octeon_link_stats *hw_stats; + struct lio_link_stats_resp *resp; + struct lio_soft_command *sc; + uint32_t resp_size; + unsigned int i; + int retval; + + if (!lio_dev->intf_open) { + lio_dev_err(lio_dev, "Port %d down\n", + lio_dev->port_id); + return -EINVAL; + } + + if (n < LIO_NB_XSTATS) + return LIO_NB_XSTATS; + + resp_size = sizeof(struct lio_link_stats_resp); + sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0); + if (sc == NULL) + return -ENOMEM; + + resp = (struct lio_link_stats_resp *)sc->virtrptr; + lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE, + LIO_OPCODE_PORT_STATS, 0, 0, 0); + + /* Setting wait time in seconds */ + sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000; + + retval = lio_send_soft_command(lio_dev, sc); + if (retval == LIO_IQ_SEND_FAILED) { + lio_dev_err(lio_dev, "failed to get port stats from firmware. status: %x\n", + retval); + goto get_stats_fail; + } + + while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) { + lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]); + lio_process_ordered_list(lio_dev); + rte_delay_ms(1); + } + + retval = resp->status; + if (retval) { + lio_dev_err(lio_dev, "failed to get port stats from firmware\n"); + goto get_stats_fail; + } + + lio_swap_8B_data((uint64_t *)(&resp->link_stats), + sizeof(struct octeon_link_stats) >> 3); + + hw_stats = &resp->link_stats; + + for (i = 0; i < LIO_NB_XSTATS; i++) { + xstats[i].id = i; + xstats[i].value = + *(uint64_t *)(((char *)hw_stats) + + rte_lio_stats_strings[i].offset); + } + + lio_free_soft_command(sc); + + return LIO_NB_XSTATS; + +get_stats_fail: + lio_free_soft_command(sc); + + return -1; +} + +static int +lio_dev_xstats_get_names(struct rte_eth_dev *eth_dev, + struct rte_eth_xstat_name *xstats_names, + unsigned limit __rte_unused) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + unsigned int i; + + if (!lio_dev->intf_open) { + lio_dev_err(lio_dev, "Port %d down\n", + lio_dev->port_id); + return -EINVAL; + } + + if (xstats_names == NULL) + return LIO_NB_XSTATS; + + /* Note: limit checked in rte_eth_xstats_names() */ + + for (i = 0; i < LIO_NB_XSTATS; i++) { + snprintf(xstats_names[i].name, sizeof(xstats_names[i].name), + "%s", rte_lio_stats_strings[i].name); + } + + return LIO_NB_XSTATS; +} + +/* Reset hw stats for the port */ +static void +lio_dev_xstats_reset(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct lio_dev_ctrl_cmd ctrl_cmd; + struct lio_ctrl_pkt ctrl_pkt; + + if (!lio_dev->intf_open) { + lio_dev_err(lio_dev, "Port %d down\n", + lio_dev->port_id); + return; + } + + /* flush added to prevent cmd failure + * incase the queue is full + */ + lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); + + memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); + memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); + + ctrl_cmd.eth_dev = eth_dev; + ctrl_cmd.cond = 0; + + ctrl_pkt.ncmd.s.cmd = LIO_CMD_CLEAR_STATS; + ctrl_pkt.ctrl_cmd = &ctrl_cmd; + + if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { + lio_dev_err(lio_dev, "Failed to send clear stats command\n"); + return; + } + + if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { + lio_dev_err(lio_dev, "Clear stats command timed out\n"); + return; + } + + /* clear stored per queue stats */ + RTE_FUNC_PTR_OR_RET(*eth_dev->dev_ops->stats_reset); + (*eth_dev->dev_ops->stats_reset)(eth_dev); +} + /* Retrieve the device statistics (# packets in/out, # bytes in/out, etc */ static void lio_dev_stats_get(struct rte_eth_dev *eth_dev, @@ -1471,7 +1662,10 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev) .allmulticast_disable = lio_dev_allmulticast_disable, .link_update = lio_dev_link_update, .stats_get = lio_dev_stats_get, + .xstats_get = lio_dev_xstats_get, + .xstats_get_names = lio_dev_xstats_get_names, .stats_reset = lio_dev_stats_reset, + .xstats_reset = lio_dev_xstats_reset, .dev_infos_get = lio_dev_info_get, .rx_queue_setup = lio_dev_rx_queue_setup, .rx_queue_release = lio_dev_rx_queue_release, diff --git a/drivers/net/liquidio/lio_ethdev.h b/drivers/net/liquidio/lio_ethdev.h index 6543061..150e9c9 100644 --- a/drivers/net/liquidio/lio_ethdev.h +++ b/drivers/net/liquidio/lio_ethdev.h @@ -62,6 +62,83 @@ struct octeon_if_cfg_info { char lio_firmware_version[LIO_FW_VERSION_LENGTH]; }; +/** Stats for each NIC port in RX direction. */ +struct octeon_rx_stats { + /* link-level stats */ + uint64_t total_rcvd; + uint64_t bytes_rcvd; + uint64_t total_bcst; + uint64_t total_mcst; + uint64_t runts; + uint64_t ctl_rcvd; + uint64_t fifo_err; /* Accounts for over/under-run of buffers */ + uint64_t dmac_drop; + uint64_t fcs_err; + uint64_t jabber_err; + uint64_t l2_err; + uint64_t frame_err; + + /* firmware stats */ + uint64_t fw_total_rcvd; + uint64_t fw_total_fwd; + uint64_t fw_total_fwd_bytes; + uint64_t fw_err_pko; + uint64_t fw_err_link; + uint64_t fw_err_drop; + uint64_t fw_rx_vxlan; + uint64_t fw_rx_vxlan_err; + + /* LRO */ + uint64_t fw_lro_pkts; /* Number of packets that are LROed */ + uint64_t fw_lro_octs; /* Number of octets that are LROed */ + uint64_t fw_total_lro; /* Number of LRO packets formed */ + uint64_t fw_lro_aborts; /* Number of times lRO of packet aborted */ + uint64_t fw_lro_aborts_port; + uint64_t fw_lro_aborts_seq; + uint64_t fw_lro_aborts_tsval; + uint64_t fw_lro_aborts_timer; + /* intrmod: packet forward rate */ + uint64_t fwd_rate; +}; + +/** Stats for each NIC port in RX direction. */ +struct octeon_tx_stats { + /* link-level stats */ + uint64_t total_pkts_sent; + uint64_t total_bytes_sent; + uint64_t mcast_pkts_sent; + uint64_t bcast_pkts_sent; + uint64_t ctl_sent; + uint64_t one_collision_sent; /* Packets sent after one collision */ + /* Packets sent after multiple collision */ + uint64_t multi_collision_sent; + /* Packets not sent due to max collisions */ + uint64_t max_collision_fail; + /* Packets not sent due to max deferrals */ + uint64_t max_deferral_fail; + /* Accounts for over/under-run of buffers */ + uint64_t fifo_err; + uint64_t runts; + uint64_t total_collisions; /* Total number of collisions detected */ + + /* firmware stats */ + uint64_t fw_total_sent; + uint64_t fw_total_fwd; + uint64_t fw_total_fwd_bytes; + uint64_t fw_err_pko; + uint64_t fw_err_link; + uint64_t fw_err_drop; + uint64_t fw_err_tso; + uint64_t fw_tso; /* number of tso requests */ + uint64_t fw_tso_fwd; /* number of packets segmented in tso */ + uint64_t fw_tx_vxlan; +}; + +struct octeon_link_stats { + struct octeon_rx_stats fromwire; + struct octeon_tx_stats fromhost; +}; + union lio_if_cfg { uint64_t if_cfg64; struct { @@ -87,6 +164,12 @@ struct lio_if_cfg_resp { uint64_t status; }; +struct lio_link_stats_resp { + uint64_t rh; + struct octeon_link_stats link_stats; + uint64_t status; +}; + struct lio_link_status_resp { uint64_t rh; struct octeon_link_info link_info; -- 1.8.3.1