From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0043.outbound.protection.outlook.com [104.47.40.43]) by dpdk.org (Postfix) with ESMTP id 771B7FAD9 for ; Thu, 2 Mar 2017 12:40:10 +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=jJk3QWC6QiQucbwDo6Ojhcq13lfg9bNq5P/STVLkluk=; b=S9syhO5bOdYYHK3Bq+D6bKutLBlyQUlpfFRL3Rga09BFK8nigkXILQ8HzXVtVDKyXh9/UE6Kbeg1qu+H3yrQM0lRpha/fw/g1OfCp4a1D/Lo4rlZ73ZTBz/9uQ8og3gmOm6RZXZhzisrU5CwvoeegGfEpmfiXqaxxjqzUrkldN0= 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 CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Thu, 2 Mar 2017 11:40:06 +0000 From: Shijith Thotton To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Thu, 2 Mar 2017 17:02:47 +0530 Message-Id: <1488454371-3342-43-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> <1488454371-3342-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: BM1PR01CA0021.INDPRD01.PROD.OUTLOOK.COM (10.163.198.156) To CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) X-MS-Office365-Filtering-Correlation-Id: cb64778d-efb4-4f4f-f609-08d46160e14f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 3:JF4E+FFG8EXURyNM/K605jcvss6EMhQ5prw/gpiIm3MCvxPHRn7aTAxXn7UH+Q+/UjEIVEsjej0k8sFtZ3pIuD3TYUtse2N6PNRW/42ZNy5kOgSzcq9TDPJYJ1h7kS+w2Zl+wlh2KpTKUpXEkr1o0lUK3MIRyWOSlkl9vVXQNfTSLIiy2rvc6Rx/RTvCUqO7c+JSpLprgA/kDem5tHPNJuWUsHNXqdOBKGkG+r8jeGE7lLepLb4vtPx493ibAzEFSpQ83h9ahh33HlMzdkx6dw==; 25:h61uJL0cwZo2h4at/UikQYJpyZiMFusmG5aYtyHHpB1jLcVvvnHVNv0lQytnhbXt938Jsja2Otse0T/wn5DMPE2U3ClopqC98mltIc7vvUd4o3qDT59GWxYZPV0ZM5g/BKDZW3g5IHvUZMvuXu1rzQxqegVCIQxHTS8bSCqC+VQSxD4poinkAXQK3RST2SduMUGrSUZ7GoycywYtnpOrk8TxHxRmnrsXb2OKbZ5/0qmDWhZad/Gn3VioVBtkDAClwWVxfcbTI7Lqw2C6pk/TVqn9bO02shWzhjDriJtMfl8+lSgy4eASsbzVMt7eIUlI3lON/FZV0d+ClwuOZKV+msoBR+6zU08kFcqrHmP0Got8qkLzekp36IRFFNO60XV7KIwl6Khe2rQK0xRf9sclPajpKg1a0bxk/9cAwgiFlx4KvLuoszPQPP6nz9IMpBJRvpPqGDyLTpA8wvxGxbnaPA== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 31:fYRCjn9f4hIvc1BP/OQWHLDIm8wCmxLg3wEMDnAl3rW7QWSacGt9HWZIq81W1e3QMIOO3WTKwVExcfyPXN2JD39OyZNgRLQ5Eyl0eIZJYMHHP6TH+l3VTYQ9cPiasfOCtxiUySYdh2WskfG1pOwQR9vf1xCtuGWLN3dA7aIJjetvTl5XtwRh5eBQ5IelYlmlKHWDoY1y4ZFMj/o722QQTbb7t97SpYw4+l8DGfDDQ6yq9FaYcz1f4KNm1nI9bV+o; 20:wSMlXG4nw77miloRnWlc0JUvBga9YZxtlqU5+nTRh96rcMyQiRbLrv9/KUWKh2q2w7Vil+xu2CjDuYv+IzCZi0A19jMqq/bqQk6ahpWasca1oytIyljn9iHC7PAskFKNTgmXZSMkxM1oFUbUf7DQT2j0UFEUsTnbqhFtXh6NjLePsMvBlHgiiejWX+XDXCzj3L2RhA+jaigeIKsbwMlPg3T2kDfL87730YbF8V9HivmiT5xe5t/bt5S/wfFiDiPuHKnOZpUH5J9/o+bsg65XTPqTnWMhaGi2CTnxOzoHDm9rWsS6V14U+11yWVjsB0SIOj88U19ghrlsfLuzzR+naCUNHV1sGsz+0xCbjCq6j9jl5ZttHtBRDEnFM2upaxPjwqrj0hF3eX5qxv/2FtzlawXeaBcSxRG6fLKNSe5Z2P5kIk53Q2PVvMCJb81qq4jgLtOrcBbE6iTEd23sLoJUkcnT1ONBynTmrSKutjBWi5xgFchvAlQeRxRBqjcnLncYb/wu8HrEzXhkaFkiVzJno5+j4yvSSODZPDnPQf+TkDpRKIxZm5ny+J6DCJZSyq7rjLzkuyyLCjhIdJLvx2a1txqzeiL+Ok5Z2BuDXUYGk1Y= 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)(10201501046)(3002001)(6041248)(20161123558025)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148); SRVR:CY1PR07MB2277; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 4:McV0Qc7ni2hZTq97Jue031PK5NLovBkbM06eFlxWsz8fHUCasuikJ1NGR/Zo/p6i/cNJ4MVlFSpdZ/oABm/2XPiyXnHfJ0H5x/mikFqToo9RfuiTMbqWa+hvXVtxc6BJ5PdOXY7im3ISrlZPk04sLYllCrWsuKC9Pj7kjRHijGe3QMlBp6/9/XPaNiT9diMSuo8ast8GEEzxfXF8GYnuMLxmcX2mam+kg6Fik09HWZwLOrmAi7eG0SxNy9cd5grBdaYYJ/S2GkX9j15MUA3xlrOKsxkGThKluIIiTnYJuA9CghG4/EVAoMVNVJpuxt2iXGvAQYMAZM/lVQS9OqjSoTSrHFLQMmEQv0Mlb+QgUJ0k5drG08hL1rGfF0G9PqfA9OgJmB2U7rkkQGh0lj1Fv/kQXYRieXMRoisAwdHysElf00fxScoVHxo4Umjuc5J+JcB5urlnogaWyxG56mhLBb2RQsh28hT1JcB8EUX85D+h5FdY5mjNPIhJ5+qblr+KomCr8+hKvUZ+tHpFLx2rx574E30klGzg0+0R1zgynI90hTmdF3qe5SeFHAsIdAx6HBSpta8vCRZDl7+UF+NONWbv6BX6ibKrneZI4GGtN3U= X-Forefront-PRVS: 023495660C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(2950100002)(6916009)(42882006)(575784001)(5660300001)(92566002)(4720700003)(33646002)(48376002)(50226002)(6666003)(2906002)(5003940100001)(36756003)(8676002)(50466002)(81166006)(110136004)(38730400002)(4326008)(305945005)(2361001)(53936002)(2351001)(25786008)(6512007)(189998001)(54906002)(47776003)(6506006)(6486002)(66066001)(6116002)(3846002)(50986999)(76176999)(5009440100003)(42186005)(7736002)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2277; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2277;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ata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 7:DngCqe23X234YGGdq69v9tmDkAl0y0hEf7X4ZM0zkdRmNDeJH1rqeGOAVrMzVEN5Qo4ZHIuX0wUg5bYSeljtzFJLwlJLRM9H3LY2TCCQTASY6PmRTXjFjNnvvbBwoSEVvPe+kTHQ7mzCzw9AiCk81AFqTw2PbWcYQJukcLIJ/1wKZdCg+pxyYY6Kpp3MFr5l733hWrQlgK6FkOCCCcx1vMtTS7g7WYaURtHW96BjMKxacSYq6bpqjcGu+bnlDaWrq0lL0KYs2XHIH7ny6KWV5cGdNkIYCF8ZqDMIM1ikQh2dGVeQcm+6Ik3hBmvEHevbkwK0TY9BcuLQTY4nZNNJlQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 11:40:06.4700 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2277 Subject: [dpdk-dev] [PATCH v2 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: Thu, 02 Mar 2017 11:40:11 -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 --- 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 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 7f0e9f4..8459986 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, .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