From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0077.outbound.protection.outlook.com [65.55.169.77]) by dpdk.org (Postfix) with ESMTP id E09465A30 for ; Sat, 7 May 2016 17:18:42 +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=JP9486H/HD5VJ0E7abztQ4ey4mjvx5YiKMxxU3swznc=; b=gjA9ou90MuRvqfVEyGegVT3Jhe54wugPnApOre7yfbL1CFfqQDwlbtRCFq3AVmpei92tED0Lz4YjfQQFk+C5jpnjm1CdBVSpTGfvEdugo8KEClZnfbTpA78ekj5llJ4vFMa5wWNdaocWih6W2JkBmKJ9sd7HxHR/pXaev/bVFMY= 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.10.92) by BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) with Microsoft SMTP Server (TLS) id 15.1.492.11; Sat, 7 May 2016 15:18:31 +0000 From: Jerin Jacob To: CC: , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Sat, 7 May 2016 20:46:29 +0530 Message-ID: <1462634198-2289-12-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 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.10.92] X-ClientProxiedBy: PN1PR01CA0050.INDPRD01.PROD.OUTLOOK.COM (10.164.136.150) To BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) X-MS-Office365-Filtering-Correlation-Id: 645eb1f9-6098-45ec-be53-08d3768adc31 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:XTiUVLqZ59iCoKBjAQYSktKlGbkYycdW0b1jqlZeN7KG72DsgT2C5tbsoG4Q7GYGd/Slj6Uhzhc7z0GF3I7F5L250u5bf0hTCrySgksu4M+Uf8ty5Ay5DLMdmtNh9nTO3cpXEUSL7H7TidOtwXnSOFEjyAdUTwi3iqzTtxX5fqqrTOi+5IKy7zF6gtW6j0Ye; 3:2G3nZDtiBJGAQ6hm3/fKdnbGxq1gpDhH/8JnpEb/d1wkYsCIivZLILCGyxjTg6Ahx1rov+4j3b9yVBthe/VtTQxxns5KVUwkoIqNkScxoWnEXc4OfrZRyg9awtQ3fbsv X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 25:tmD8rnQX6oYaHe2yJGf1IpkG3hFDifRzVYJDI+50Kaqlx23F2a2FLZxuQko359zT5MK3RqNBxSYhARs6tlv4O6I9kaqJjzbz17/UJtQ0DQUf60CdiJXIEoe9GC8XWX1M6v/oD5VX3MrlQD7fm+tV8SeKnCChpmzbmuKk+TDuqreSWDkJazgmDsAL8ixhk3SflfoDCI0bamM6YqhHCks99DB3TCM0fvXKVJNt6JMov9gQUvO7iFrBhyK7+bdGPG++OfAObFnK40QmJwDJssYEzqORKwX/Q1nbLHvKKWIyB7I2KvMyIs20AhlMZwT2yYeCDPXFpKvFu14UAS1tKTau4UbmCcL4mBZV7DsbcRBZ0aragHZxxoTOb9/bFnDhxwWYYDfJOYCOgj0CKWnSE4YovVn4l9w68H5RVLroyZ33dRhnTV3V1UFmaWOBJ6BAebqhAorgtRnAmGSptMvgyfJv5YxJK+u8fFJH+t9wDA9+KVWVzNjAMccvRVe20cTvm075udZ+8+U4ehLho3+53EdqpzaSyojlP+BrJ7GqHTjl00MrCf/ifgv9EwHy/9xSXv1eYpPXTureYCqC/rAvY1CSz7SjUCyD1Fq7XOw5K+N50IfcUHsDmnL22/whRrNrnEIDv717SzxZuPQ7nH5lMnx8Z0Kvk4ZR7YBKnM2GWTYSkVDp9+eXfNjjUsd7nf8xh3i1lj3Rbkef6VWPXFr44385fQRgm3SO+etQzlXUfDwxdZ8= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:LWbSx7jNa3SgDSulFnpoqqoV9KdvN/o9mdfyP7o1f8Cfs6vHnfF+GMXETG23/0mnIjFjfGQo5UM8uPga9vvYfm31+AX66FEbGL/D4sE2hf59TtHrLPls+iO3y27MYuN1JVKXNveOaXflma+tCFSzD6ARmlmXiqpaLk8efBFfOirq4BSLIXLXX/44/OcD5k9/n7/tbYncAPZ4zkKoTpks+Ger+x/tbZAYI/sjnltBTuAR2rwVeeo2DjlbDpWIrzgdZkalypeXwBJym8LtuWtLdNSd1mcM/SI9SphCUXPolBEOeYIVn47dfxjtK+PELLsRyWZnWfFPmi8wcWQ2bD77j9Klu4zjzl4h1fbP+FuUt289ZKVz6IbvhwRDDv3ZLG9Z4Obg/cbVvOAncS4p7CLbRoI0+TAYereHZ+tJNvp2vfil/JGpdnF3f9WtDUAa3AIfN/C57PHyf2sL8V2nSrcQoM1vGgkmyHz/Fh8HXaiG1C9c4uZBKRektTUqvM1S7+IHQc7Uai/hn2IcognI/6HWtF6KPKotPy2qUPRW0njRNaS/HPvkxR/U84cQuta2/thxQRLVstymn0PL+W9pBpYY1/3t57BFhO5s5/EEyabkrDM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN3PR0701MB1718; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 4:XnCPlNPjupe055rVUSC6yNgXiIcIVqKo3dWwkTFahhqcPOsaK5yPEQfA5NvsSF56ZnaA9gyCImiOulWWhyYYCswsggTI7gqtaxTiyDIf0g0cr8L+rgZLEDw7kxx/ZBkxfyzBCVC8YVvEpbrXXQwhFJg4eEYHyBhFavNrjxUqyG94gq6NG4R2hLM7ZvMbu5edQF5wQMlXEKBFPa9Xi0N0R6pVeoHP+zD7c1UrrTRNxlVCn5m9OPY4ODN5FeBIMVv3uYWUzQWFpa8IAmBIn/jcD32GZQA+Lrq4+jcrGZxUzYmTj4ScQ3ee1tv+gc0UWJMQFbpoTxAClcwy3r+BDU583H8faBZ7xmUMfgAQ6+c9nmkopPZtnAvnBMb4yCrJnCMU X-Forefront-PRVS: 09352FD734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(50226002)(77096005)(2950100001)(48376002)(81166005)(50466002)(66066001)(47776003)(92566002)(5003940100001)(4326007)(2906002)(110136002)(50986999)(2351001)(33646002)(586003)(3846002)(6116002)(229853001)(5004730100002)(76176999)(19580395003)(19580405001)(189998001)(5008740100001)(42186005)(36756003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1718; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 23:gl45wkaifwXlZaUTxBMtKnPOPKaVhSryu8whIDMpptsHhCrDFvYEXUZpjgLmgl8xa5Xe3AuFxNTewMQFqHcrjwen3ByhceWBsC/q/vzz2nXOtzp0Akp4o9dJ+n/9ni2QLjI4Wz+gh2d+yGRxz7byNAlzXh0tFzFSABf8WF3z20DcNt9x/5jFSKAIt9GHEK/UdU0ShFuIgb7bkOn1XNZHuCe8SIPZUWjyhitwAUp2Xi2u3KAjegyMhRikFy746+srW1/yODJhe+ohwvDBXItDygoG0TDxsoWLnQ6ExA2hwsahpUG04q1VxQrZb2gn0dT9soVCU5jwVh9fVoQNVkizNvsINQ2t0HbpSWmJd494Qjbv7Q6JsmTQgs48YFgRGWEIUemKXMECyT7HrXiIhyfp5WKdkIP56aAG/1rc/FZtsglrBKycBfVhTW652ZQ811w+qSZHxiHTHUewqRAYznid/LFTYBl09E8GJz/jY4b2Pa2b5+bderG1UiipBRvXRFpwnKdQjwUSSljZgIpu28Pb537D9qA0wPOEBUw8Y13iG8ngxMMyik0AobG/dASvXbIGAyYI0lXiSFGUe7YGpETuaP8jCK12GIWWF3pzEdHGSXJbsrcFYJITtKqbNEnN0yEH80tg9pUVLBKTjat2qkSzSM6ORqSWJk+NfrPyvVXscy4yw5Yx6/XGFcX3bAZLBT0Q5qKiAaRlRy0XuJMqXq0BYklGHWmhQH8ciOdjlW8nNf3QuX88gVx0wndYWVne/WugCuEv772tdEygrGipf+QmGjr/IvG96OI68ioI6JfGKxfmaSeTBuG2tLE7prgkLQYDWCs4NcCBFG7ukQpdYT8guoeOgznf8pEUojA6rF3pGnOep2straqFmeV+uVAxwgYB X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 5:SwYO3XwSoG3WKBCOcX3SwxThmLx2I+eG9AXsgr+LuE7eFjWf/bghdoDFLzj5pqbS70nn6JK+Hez5DXnpIFoUOCbGX8BTxuHnoUQUvyUpOedOHp4oMYb5NcBTxFHeY1eIcqctxAM4iWzE7JRmYtaZxw==; 24:asGVnk+KeNXQ6YLc9mp8FIu3MR3qHwHYcfUyJWt7hk8c6p/3WX7urpaxaBxMMN4X8J3qMZo2G/rcVSXZi80GbUsIL9nrlYmixf/Xlz0iups=; 7:PYQvCMEj7/fP3wjquptpyZ87+0ookHBlE6g+oqvMG4em2esVgs2cKd4ucu+zPH24tXcZHRHDI4a1leU/ercvvl4PWnJXhsVfV2F82hBbkfUWSlt8+o1XCzWlYwfCNnxVMGz4/flEt6e1uX8ldGwsVWmJkvZheiH+saM8JSzJb8WC4Q/Amp76ObkotbjieO3l SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2016 15:18:31.0401 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH 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: Sat, 07 May 2016 15:18:43 -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 b1a0077..23325d6 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.1.0