From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0066.outbound.protection.outlook.com [65.55.169.66]) by dpdk.org (Postfix) with ESMTP id 6BABA3990 for ; Sun, 29 May 2016 18:54:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=xNCebOe6sVFD9M2GDbTk4tVBWT4m+B5So4hYGtztXy8=; b=fcrbT2BMWPvYkyd7u0VZ+pby44DxqZHwaQ2HAZanRjPxuVqvu43URtaUen86EAcTlgOQ1nO0pfvViM65C4CLYwZYbLjHx3CwtlSaiJNGEnReyNumVwY3tL5AE9X29TZ9Jo5yVxm0nZE1F6tG90uSxSJjrHl3gLC+lywR7SYZtoQ= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.localdomain.localdomain (122.167.187.184) by BY1PR0701MB1722.namprd07.prod.outlook.com (10.162.111.141) with Microsoft SMTP Server (TLS) id 15.1.501.7; Sun, 29 May 2016 16:54:52 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Sun, 29 May 2016 22:24:18 +0530 Message-ID: <1464540867-13115-1-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.167.187.184] X-ClientProxiedBy: PN1PR01CA0029.INDPRD01.PROD.OUTLOOK.COM (10.164.137.36) To BY1PR0701MB1722.namprd07.prod.outlook.com (10.162.111.141) X-MS-Office365-Filtering-Correlation-Id: 751a44c5-8c3a-48be-8709-08d387e1f688 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 2:LD1HaxyLUaqi0SNTKoj6+DliIwS9/vVAZluJI25SUIjFNB99PwJop0YlDONPRLT+Tlo65c8htrw+8eW6vEWYmUWeDCCgC1UPGHHy4rDXay5RNPFOIi4FzrWk0fw8gGIUL+rObfir/WM3B70uOGuAupLZtfp0HtW0JIoFTif0QpRWfrW6B9uLFxQ1LJEUKnB/; 3:PrkD4Tu/ZJP3eB5EkJmFITtt07kT3QP0SS/DGeHgym5ld4NaaeUQ9o79nSRg5JerrFSa8r5kSuqzfUWxXbqN39FEB+jnZY2SudEASbAX5e6X/PYSFhXaUCZtBlbM2G2a; 25:OTI+pz76VQ5viZ+7HU2Oq50y1HcpONBaYJm86bqNhMesqfFzTUEqvGWR5JmFq/cuQi+Mv3jMZzKGF+Y7kI3RYZm4hCqpThP/blD4ksTJxSO/vYRXe1hD781EyNaJfYoMrwm8QXBjyp8xT2qalWVFzTlaPkjPYYA0uEHCINOon0dXkbpOW1Z9+AOCQHLbx6GFCKfZyYZKreJezNUHojV+6WwdW7LN/v/HShut1gaeKv8TvEWpK7fhJ1xmJu5GFahQ2tRV6whhu9kKS/CjyUpMw6RoNWzT+2l9lMcK4nlyxMHaywD46SHVGJAsGmvmaJq+LDEQMgRU+Fw1KjV0JJJ94o2l6Ndq5lv4TuPaQKOngDAWjxgx1CAIpFaVAeMUdPqnG8RXTc0PKktbk3GxvF61VT5DH38pDawFMs+22hZONTE= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1722; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 20:idRDJBYvqdWRzvVkBT4bV2gUSPmgnXsfa6KDXZfATYThJ0OvBvybBf0Mw2hE/0MKHnCLHzzKoIXiNlpzBmtiUdZRcue/7HIpi01P7m+BI76Z+sqWXZf8D+/r3Bur4UqCwYjteY61e8AJUn4lrOqWO4OyvP0VcaCPjOTLKf63GUL/ZZDlFovQ9RfK022FCXrsv2FD31lL+e6XwutaHl//VIp0c6Qm7zs7CWUywHwEEoGKd5/ltdBHR5TOKhfNoYY45OKE4VF7se3Q66yzNZ+RKvLsdf0LD+yz9LtqzJxqyYKXuigTyeALHbUNw7jrPtSa95Ys46lB8RSOJWE9c3SmV3yxe8gwEKruiEH+o+G5/Bp/4jLz94IX1/ozkhF2RvRgpzWztBUf8JwpeBWmIQFjdh5tP9yWu8GFNbR1PO65+Qlfa1P+xVwOn+JQh4bdZv8pmYJQnsPEScMWe7qY5DaC7CZHNb/5mgcG/yqIVC4jN4IyCWMH7Zb5/7Bjj8Qa1ub90gizLhwv128fVXmpx6ZKM40UR7sBdDSx3HQwxze35x5KqHQ0OT10gdhtvlo/Wl8ZAmTa8vXt2Z3ATg0kiSRnU6HhtAFBc0sEDWm4KvpT05E= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY1PR0701MB1722; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1722; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 4:GnCJCzWUb18Xt7qEsJK/kMTHnUQEMKOrdTY1SntCEP25CNjlJ6H0xJst98Vri0Ic0SgNLnFCRSy1qctAOWcG5C8NodUcPXz/BAZWCdq0j6ROGAeSEBnL1rl8gaPcGdgwOW3YxBr/u71/PfNOvIYYruE7FEwdZEleI+8n6r8N5uIiI9uKByCeuHqJ7avLaFSIXGG67aOXs8Nrcja/xROnDEzzD5FBIWr9AYrxFL5lPXQGq7JzCEqfnnda9iFylz+4G3bdvt339zztjBNNl0lpLzc1YM8jIHh4eWFSpPxeK5eJ2nxz8AKrIrkhLCv+pYF1ZIj4Yn0xMZCwwCdaZ63NSmvoLD1IuMHT/gbcAPord3XRfQeICLkaXHV1wmThq5xC X-Forefront-PRVS: 0957AD37A0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(33646002)(42186005)(50466002)(92566002)(50226002)(229853001)(2351001)(5003940100001)(189998001)(2950100001)(110136002)(77096005)(36756003)(47776003)(5004730100002)(48376002)(575784001)(2906002)(586003)(8676002)(5008740100001)(19580395003)(66066001)(4326007)(76176999)(81166006)(3846002)(6116002)(50986999)(19580405001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1722; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 23:8G3P+DI5G7vdrjM0/lE8KIhq7g+GCsg0xYflsHwgs/F4Arav7tLnu2iJPUKv67n3RFu9gkuoB7WDOk3JxVg5HWCpcN/lpPkJY3hXnOVGQdmgXn8wK03AihNmpxkK6BHEAIceCJbOjRXcScSmUP4cuWIXQjUTx1/uiXxBUvcu7VHySpFbK2Lp2vrmwvumWsaEPAY4QjMg1z/YtNeD3svhm2iL+C3dm5jr+X+UR8NLrhwfG3f8lhmyy59y0tZSpopIHK41tBx1fivCdOFEypCkizx42d2JFG5X/ed4DULHzPcKaUcrOpneiNxuSM4oZbB+kveGlsXptpP/AH9H7k2HqKVcu+UzltI0r75KHSBEo8n1tbtuzk3ADr3BmFcFPAXU4h6aeAB7c5MBE9YzPCFujd/ZcU0h1p9N8yYM+veU4GyQY8dw3OMZWmgEhBMHtEiGoJURUHZRiRBXqQ5HbpVheDLw8RoYwBcolKA0FRXs2ThobpXHDSZE5UXWMcD9regLQWmp0wSOJterHMUfIsj+qc3j4J6WipQ3nAFwGK4kYf8nWF/idV9XayKr4n3KS1S97xk3boQYhilJXJSRaO79COvO/J9diRxehhULUJhC1oxW2Jtc0hP/af7m0gHMw6ZfSvCRPqyYs0HlTE4bKJG8XpBPkw0e9dB+uE/pbqRkAyCeEBwU291rb2SbzQ8X7hYv6OL1/hS5yRkSb0KUMlxhZChpDjdgHCjirbyOKpY5PgeK6vghIRQamEzZLYANOnq3wmGydqifXOYWUd5rh2lP1dIBtdnQJ3+tF5aGzFM8wUZ/5nsZXzAkQskkhoc2LAJASz/MSlB6dv8uUXf9l48Cfb/Y2RW5VzJh5g1SOhQMhjXhUJoEXiVvK40/NsedW9gt7b7Bedi4Vee5Qy4B1po0WQ== X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 5:OdaUmEbkmHIgUtTA4wM94sjBlWSfPqd86QCRGWUSu3AR9e/rs6tkoxL66DtT0QlxLh53ydGCFaCGmavcPX5PhFdu+wllRFnRUzrNMqFph/npiLkekW2BPjv1u6UVDnEJWtBi9YyuP+td/7wFeCOjfw==; 24:Uw1SPOR++nbcblyWBcPo+D4Elye8vq7EvbuiEvaFhZq343AopzhitFZQfWA/vx8rakjbc3Gg+M4WB16Tijh1T858Fed6UJ+UvFLHJ0aQO7E=; 7:dUmka7FocOAPElnm89jWAf2xDDKnwMjpoEP7zF0hybOjucM9akX8E9yWvXAyXZJLOOFDRa/A/zixnsXCez/Xy9MUg6uhflZ7hFpu2PfG/ZvQmtwd9CCqAgfR54bo8wz/rqDmDFO2qfFFpSasoc35/CouDskFclIIu7qifb+phdCTCHfKDieyYICD9LDTQifg SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2016 16:54:52.8060 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1722 Subject: [dpdk-dev] [PATCH v2 11/20] thunderx/nicvf: add stats support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 May 2016 16:54:59 -0000 Signed-off-by: Jerin Jacob Signed-off-by: Maciej Czekaj Signed-off-by: Kamil Rytarowski Signed-off-by: Zyta Szpak Signed-off-by: Slawomir Rosek Signed-off-by: Radoslaw Biernacki --- drivers/net/thunderx/nicvf_ethdev.c | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index b0f3f5d..817ad37 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -71,6 +71,9 @@ static int nicvf_dev_configure(struct rte_eth_dev *dev); static int nicvf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); +static void nicvf_dev_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stat); +static void nicvf_dev_stats_reset(struct rte_eth_dev *dev); static void nicvf_dev_promisc_enable(struct rte_eth_dev *dev __rte_unused); static void nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); @@ -262,6 +265,70 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs) return -ENOTSUP; } +static void +nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + uint16_t qidx; + struct nicvf_hw_rx_qstats rx_qstats; + struct nicvf_hw_tx_qstats tx_qstats; + struct nicvf_hw_stats port_stats; + struct nicvf *nic = nicvf_pmd_priv(dev); + + /* Reading per RX ring stats */ + for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++) { + if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS) + break; + + nicvf_hw_get_rx_qstats(nic, &rx_qstats, qidx); + stats->q_ibytes[qidx] = rx_qstats.q_rx_bytes; + stats->q_ipackets[qidx] = rx_qstats.q_rx_packets; + } + + /* Reading per TX ring stats */ + for (qidx = 0; qidx < dev->data->nb_tx_queues; qidx++) { + if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS) + break; + + nicvf_hw_get_tx_qstats(nic, &tx_qstats, qidx); + stats->q_obytes[qidx] = tx_qstats.q_tx_bytes; + stats->q_opackets[qidx] = tx_qstats.q_tx_packets; + } + + nicvf_hw_get_stats(nic, &port_stats); + stats->ibytes = port_stats.rx_bytes; + stats->ipackets = port_stats.rx_ucast_frames; + stats->ipackets += port_stats.rx_bcast_frames; + stats->ipackets += port_stats.rx_mcast_frames; + stats->ierrors = port_stats.rx_l2_errors; + stats->imissed = port_stats.rx_drop_red; + stats->imissed += port_stats.rx_drop_overrun; + stats->imissed += port_stats.rx_drop_bcast; + stats->imissed += port_stats.rx_drop_mcast; + stats->imissed += port_stats.rx_drop_l3_bcast; + stats->imissed += port_stats.rx_drop_l3_mcast; + + stats->obytes = port_stats.tx_bytes_ok; + stats->opackets = port_stats.tx_ucast_frames_ok; + stats->opackets += port_stats.tx_bcast_frames_ok; + stats->opackets += port_stats.tx_mcast_frames_ok; + stats->oerrors = port_stats.tx_drops; +} + +static void +nicvf_dev_stats_reset(struct rte_eth_dev *dev) +{ + int i; + uint16_t rxqs = 0, txqs = 0; + struct nicvf *nic = nicvf_pmd_priv(dev); + + for (i = 0; i < dev->data->nb_rx_queues; i++) + rxqs |= (0x3 << (i * 2)); + for (i = 0; i < dev->data->nb_tx_queues; i++) + txqs |= (0x3 << (i * 2)); + + nicvf_mbox_reset_stat_counters(nic, 0x3FFF, 0x1F, rxqs, txqs); +} + /* Promiscuous mode enabled by default in LMAC to VF 1:1 map configuration */ static void nicvf_dev_promisc_enable(struct rte_eth_dev *dev __rte_unused) @@ -868,6 +935,8 @@ nicvf_dev_configure(struct rte_eth_dev *dev) static const struct eth_dev_ops nicvf_eth_dev_ops = { .dev_configure = nicvf_dev_configure, .link_update = nicvf_dev_link_update, + .stats_get = nicvf_dev_stats_get, + .stats_reset = nicvf_dev_stats_reset, .promiscuous_enable = nicvf_dev_promisc_enable, .dev_infos_get = nicvf_dev_info_get, .mtu_set = nicvf_dev_set_mtu, -- 2.5.5