From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0081.outbound.protection.outlook.com [104.47.36.81]) by dpdk.org (Postfix) with ESMTP id 7EE8EF956 for ; Tue, 21 Feb 2017 10:30:31 +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=74x7E640B4CKhx7uFl2GppTW7Oy9NyoVtX3ogCsRfTg=; b=YSaxuh/OF2eGivLcym7sij39c8if20GWGqFSBZkx1aajzxzAlH4Cr5f4dz7dM/uqle02PAQ/71Fyl4IoRf0uZb3goR9nKkwf/E0ehEgrTZHEO0tBYt1OA/OjJ7vDiKrfo8BDjWIRzXpoUJ1aOJ8hTjefrxogPn3uVWLB8KGV63Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shijith.Thotton@cavium.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Tue, 21 Feb 2017 09:30:26 +0000 From: Shijith Thotton To: dev@dpdk.org Cc: Jerin Jacob , Derek Chickles , Venkat Koppula , Mallesham Jatharakonda Date: Tue, 21 Feb 2017 14:57:01 +0530 Message-Id: <1487669225-30091-47-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-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: MA1PR01CA0089.INDPRD01.PROD.OUTLOOK.COM (10.174.56.29) To SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) X-MS-Office365-Filtering-Correlation-Id: 13b7ce77-b4ce-4eba-86b1-08d45a3c4601 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 3:uNU4/O7JwGz/mLazVtcof1Vh0C5tqIy42QG6xEcQ2poyhkF7wcyZf10YSPfbc+IJy69Afedf2gA3Zuugu/ZwPOQZtppUlILCrSoeGq/OZz3NqwHpQINE4yOXX20Q7GZgdbEBBrAYTJfhoJxFAppU0YnpJ2dPitBytygz2Zui0iAcF/s9jhbQSjGPMUkFwGZsLe//wsL9lHawSYlOSs/IRryzxUcOGlN9BubciXN0SN5QEzsiy0ZdO4mbVaU7tG//uPKJxD0XQ7mvVYOsJjXZHw==; 25:RfRKHteloqFi2FHjW1OEfs/12BPCHji7+8Fo+O+KroAf4QgnhOnP5kdskDbdJOgfRbkXXFRZ56AgvVnvC8/TvtuGJpar9ZHr8+xbiMqbTF4B2UEID+T6Dcsn9XrCPelsU46jHtqC/y0vpzNKYexdZ7LD2s2BOIjbP4OrOCHtVxHCU/iNBPlQZ1dyoK/LgwzTtTYqj2sqrbXFWx9RV0BkVS+WMxPe0q8rey0Z8eFbpVbb8DklkkH7BV6PflYkMLc5NfH2dYCZsnZOboyRb2LQ5Ee4kOYk1fhEhWNaflrZ2z4azNlhozrHIquj1oS5XrhyqXB7A0beZX4LKFJE9qFgtS6M/4Bm1iyHaSYQd4J5y66e39NMGBjzPteP2xBdSQRugIdiffC4SPk1hXifWKvPK27Pg7S9QbqnuUXJy2krPPrbnNibMp1y224EWUcIQs7DkrOXK6Yu+AbFgTcZQsUjNA== X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 31:kAwunpSlteWP/EN4R6UYtUCgvALP64tQcUVZsBGsE7kt5IbC7PgLE/QXLTlwRzGkFupVIPHnTtj0bCsfhtxuwNR8cfI7HUC6dvzlJa3Mb01BPzbG1CfJilRdYO0470haMK5fPBDJYlrzWu2SUY+waIYQRbZTWw4VP/QSoFqnarKV6DkmEJY2X4RJdmfClMMAI8bAQVV7YTr+kJFfMGosgroyjYwY1nGWWCTMSoCZwD4DDEZSgy4vXDEEUGPSFGMl; 20:m5WNFieq4pdw680vaU4MwUAlRTfs+jjWy7hUPn5rZp6szf92vIITsa2naIZpwuLFpWNXo5/UtY+KuKTr6aUF7GEcgTaG03tWFNlNe8EwjabINY0VkxvZaPEqc8j/Jv6KWWA1p8tUTmh3Oxt0THCa6Y+6a5pFZFFrSHmlOvz5dwX1sHccgGgQ/kBWup3ebtny2El89RcCVJtiwOw3SZTMUlt9/Pln7NuuvDuyyUNpUYfMa1KvJxFWN74WrITmnf1goj5VEaU+9BotZxEKmTk7R8UrsbcXRmb3gARLCgP/teu0hKjTZTAfg6FoTlfLN79AktPdAiNqVErZMITSsBP0bxaDfDZ1I872hNXf5mbmCQx3OxbYPgD8e135JU2k3TJO4SnHU9xwWN8/5xchaXCy4/3fbGtbFVheZCFFEyxPHZdT3rpfczx9JxVI0xhO9xl4uB+a85xAoW0Re1lmNL4hc1WpBm3eXEqR+ctCloga6dg+ZTnYN2W2V7/o26rbgVVeDIRh66bhyqYngcAyKNa8vHoigSTVtkzaOOPsgIpeuEq5NsqORnDp9l1mXUY+92XslPT9zV8fGPqaePPHmmBQzO+QEdZGnNnB4gGfvhb1Hm4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(20161123558025)(6072148); SRVR:SN1PR07MB2285; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 4:ZgY7UQ/lM46S9ZIPeTBgTjXxWw6NMIZvay/N25bxN3ILXZl3c0peat/ydT7NdL8FfNCIwD5ztH9ilCLKOGog1FgHW200Uijn/C0/ujqYdv8zA/sY+MGD+xrYPxphEy1YmSP1fl5zThJpNSYLJYTHpCQkNraJ1H6j6uVObW1YqBvTU55Iz30LsO0HxM+qIkJO/ZjXjcqOm0P7gWiyU/s4gI7o4QXp2IdNxPydnYWQnY3MOxMRHsTXlQfl7VQtorbqH9RJdHT0oZEmxlm75I5AQSLvbCqINeP4U8gbDlCNnScaDjDXfiiV4Mfk6glZPavpLsFjSy44artMCQuBVtoAUEHtAnUenm5WjA+6Qa7VxqmNEQvYA/GQRn0+l1s25GtuXBHIKOG7dcvID4ygOyaX7mSB1jc+ltUu/dW31KQiM1q6GLV6/v3P/DuejizvQyoakKmGvY2waXKwOQcJurgf1+reW7IhAFQAFvFBMZvbd0WUAGPs3kcjsVIXH4m6raNpBmUKG6voI0LvEVPl7p57ZZjub5fS44azaQXOzc8+3tlUzeJGaEMKsMKNnwpHfuJgLqhixaLqN6Q4ZOpnjGRSbJQ1UXdJ9ZH0cQPIu1bK+QQ= X-Forefront-PRVS: 0225B0D5BC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(7916002)(39450400003)(39410400002)(39830400002)(189002)(199003)(50226002)(81166006)(42186005)(2361001)(575784001)(101416001)(81156014)(305945005)(3846002)(6116002)(5009440100003)(8676002)(105586002)(7736002)(53936002)(36756003)(110136004)(106356001)(6506006)(25786008)(38730400002)(2351001)(92566002)(48376002)(6486002)(97736004)(50466002)(5003940100001)(189998001)(68736007)(2906002)(4326007)(33646002)(76176999)(54906002)(5660300001)(6666003)(6916009)(50986999)(2950100002)(6512007)(4720700003)(42882006)(66066001)(47776003)(7099028)(110426004)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2285; H:lio357.in.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07MB2285; 23:GxHmhpdrH6fzynwWqpeqVXkdDopAT4Q1PXOx4ycaK?= =?us-ascii?Q?8OCa2xwNDR5OhZpbfoOxabS8TzaXmrbgOWmSXh23epyXdzO9hdAcN34+gSLo?= =?us-ascii?Q?Vj4TW7gYZvX010xxE+CyNriMsIuvyHyz3guKyyJETNwwP0KS93CrxTOZiDwB?= =?us-ascii?Q?Y7GiKOrCVN/CHDSOHoRzbj/edXH50e1m4vR9gRDWH8WIFvIqnQdAOOUl4ruJ?= =?us-ascii?Q?JKwF5H4zzvo34B4phcl9ujqZqp+a/Ob+Y3Bqq8z8IrMYQ+nynYuHpL8AWujP?= =?us-ascii?Q?eH7B6Kno0/2R6vP/WR0gGHNl/Z8mi18ya1WPmGcv6B/DS4VrgmpszybLBGJO?= =?us-ascii?Q?qTTavnplQwjC+m2XqfhpLIWcR5mbJRyMwyrfP3AYawF+iiTGf7VkHzMv0Iur?= =?us-ascii?Q?Dm4syIRjHOMh1W2FXBpnAeu6uTdWyPzs984++Zf9a5Z+t4WKQA0peSjBLmux?= =?us-ascii?Q?qaVJfXbs0cRGUQLD55cHrUUMZde3S61W1gPTvmoc33+W4Oomg7T6K3qZqtnI?= =?us-ascii?Q?QbgxCHPLpGgIMn4s2v3j/2eIs63lA9R3AmthUMM45PLf7ovr097oLhR+vgSg?= =?us-ascii?Q?Ypt8z9iHdsB125Xm8YY0NkjgqhR1Kxy1NEb4s/ULx7YWAqaqPCz/rRufJosC?= =?us-ascii?Q?NJzl+V1vPG6jdkjfPVGXiFjEEloZ9k3V9UiXiHC35YG42yon5MmG5ARL9OaJ?= =?us-ascii?Q?8geMgCSCg0Ap92h6lk1sb9aijgt2tARAQ+mZocsKbteou6M+mLYBdwXk6Mp1?= =?us-ascii?Q?jDE8sO4aohOMdZlBleHUHLbfwu2/a2k4uKhz8T57DZHFDjR25HMboUB9N1j3?= =?us-ascii?Q?WkwwJ7+8SiAlmkdEihrY8jY2iVJ+R/gyFKLHILRoJa69gNd9OoCnMWPLqAT7?= =?us-ascii?Q?T8MnS+WD6BmorwWoKdHR93mgG/++/WDAo8ew0zZY9879jn/u/c0HWS8r/V+v?= =?us-ascii?Q?QJezUX9K+2+PgotzM8fOKdB8RPedhi4cNN+YwajVAhCr2wUKHeYaAnB5FrcP?= =?us-ascii?Q?EokwO6hs+joB1bK5JBVzUJfJqMiiz+QE2b1e9xHH3QRjPtcM2me3XdX6kqG/?= =?us-ascii?Q?VVEDzU+E+us7Tmia0dBkxIfxyeH28XzxWjdEc7IqbNZtSRTtQF7naBqKOxzF?= =?us-ascii?Q?KbT9cA0DwBnZS7MYoP7Mw8bMVCa/yNK4wMJ/qYxPXbYwC1uax7+X5rvgVGuD?= =?us-ascii?Q?hCIITEVBWBZz5L0sl2tRpOva7wZqq6i8vabPW5HFa+RM1f8Cox3AVTq4bFIS?= =?us-ascii?Q?XvbVTYIIkga45u8Cdb9qwwZYjKMnOAmzFSZ7/ZWuw5D862mrHfD0FPflwt8S?= =?us-ascii?Q?seRYGNzvJ/uwgOGfa51ztGjf0lUTWsdIhDSCm1aSPswvnhFLbuRfdS3u/slj?= =?us-ascii?Q?hj7/+ByBPmNYFVDvRsr02ZEF8IvP01Cdpj8e36A17NtuEVY+ay86+UdXokkp?= =?us-ascii?Q?1YNa2esKVPdwSA5Ja9UFyhwC8yp3/Q=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 6:HUwG0jT2XTcEZwTdny15siFdX9SHWbLa/UeP5XjWoDriRzMpeyV048+OkJzS27K7cVxYjJ9QjYAfxCPg9ONZRlbjwYm+1y5UCR/mQtMJqmzxEfveD8Z1opS2bwWJ/Dzqb4mOshZfKdkbDnoIsHImAFTPF9Fh8OEChDwAPAVWtfDFe/q0xxZDGgZimkal2pZaUMbjvD/XAoxgpDkioRh3GIcVUdToG8+zO4GslWXxonHJoaPKteHQWAiLJIS2v5Kc5IV0K7v9p/mb/zRM+FGLSt41gh9FszULQUHTefLrU0gOj3Q0NnxWcZZZ+Vw5Ip6TLWLZ5JAjiCYPzRW0AC6GFxJpP9Mfd9OfzVAnVU8n2scBYMQUWx+Wg3+NYO99ZghoEnY6Rrc++QcwGHgDXUKPMA==; 5:/bH1f7eQUWjJ67lqMH+hta9HjUdwSyoeAP4d0/OP1CADL0KdpbMyJR4AoBhXXiFx3jzX8zRfNNA0DY4Cm/nmhackZEcm3rGGa5HVRoiI2+Tv09o4Zj/KQXjQQnRiuv1lW2kVLErsNItdj8/l2rrsGw==; 24:8Pvcwzp8hT/jkEv4ydcaQxZqB00hBZ01fHRWoBx5dTZggIqNdY2yXMLim3nQ6ZALu5n/t3n5qd7o+LM7nwCPG1nItvT75kGNU2O/WKN3LuI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 7:dCKS/NTj6pQ8opmU+NrPKIegtNUHdjEnzYAnid+3Kn9bD9Nzml3GcfxS3y7tqI6SWuPbDW5bRDz2p1tANzeZSCMV7w6wn/MefHSGGampJNL5KjiO2H6sLcwxb+Qwi7gGpCBbCcAafHneCAYb5vSz8/yCNoEahLzTKgaa0kBNoynATxf5AHlP3rEUEpoDm9HlvTkUpVPnsRsbZNCT/hgXwzLbFTm47jJSqgbpCIsJcaEifO9sfMmvHEI89pPkptM/pBbWHAUz5iqPYH1AfzVTxukEVYCtU7+YtorkBVWkQwjuIqQFcJDFHLgxXGNqt1BKxmgo1QwvkHpLd6tVIn4zVA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2017 09:30:26.5593 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2285 Subject: [dpdk-dev] [PATCH 46/50] 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: Tue, 21 Feb 2017 09:30:32 -0000 Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/base/lio_hw_defs.h | 2 + drivers/net/liquidio/lio_ethdev.c | 194 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_ethdev.h | 83 ++++++++++++++ 3 files changed, 279 insertions(+) diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index 39a3b3d..d0a8936 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 7e6277a..17448fe 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, @@ -1472,7 +1663,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, .mtu_set = lio_dev_change_vf_mtu, .rx_queue_setup = lio_dev_rx_queue_setup, 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