From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0074.outbound.protection.outlook.com [157.56.111.74]) by dpdk.org (Postfix) with ESMTP id 6AD39AA39 for ; Tue, 7 Jun 2016 18:42:05 +0200 (CEST) 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=VrveRVue7GNr3q4r9pdgxMPDlPPaPYGWvqghUcCXma0=; b=UKe3sp14MA9k/dN6Qt0Tjy59oLAWIY/Y/cAz6MLzfpq1fd04NT3qlKGnfpP4v1paMXL8MocmuXozO7YVAkbNO35W6ELH6oMS3UO8xGagVuIFjW6wyID/jf+6Va7LXkEAUfbmfTjRkcnIAz9O6mrsAV7fiqzq19NAu8R21YL0gxk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BN3PR0701MB1719.namprd07.prod.outlook.com (10.163.39.18) with Microsoft SMTP Server (TLS) id 15.1.511.8; Tue, 7 Jun 2016 16:42:01 +0000 From: Jerin Jacob To: CC: , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Tue, 7 Jun 2016 22:10:23 +0530 Message-ID: <1465317632-11471-12-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465317632-11471-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> <1465317632-11471-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR01CA0054.INDPRD01.PROD.OUTLOOK.COM (10.164.146.154) To BN3PR0701MB1719.namprd07.prod.outlook.com (10.163.39.18) X-MS-Office365-Filtering-Correlation-Id: 60d3c679-3f24-499f-23ac-08d38ef2a801 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 2:5u65nK0nDhUOolhmM7KRIyw0bEdQ/NkMnH0o2L+h3UwXp5tJrCre2WMhg3SK4QRL+djct3BKIxCTiiv09I9JeVvfLPjiGa3KfjVfItRmj/s1tQuDk5fV0gTLdLzI7gK+mjueYr9Td1YgTJJ1WGrAaKE+R3TQuEwEdvaNQyv9xUzUMkSWWGaOAUd7RCSAHfG5; 3:rG2JCqWkTUojI+Vfk0bhvwVTzylAS0RvFwSXg+63tzfp1d7FyVaAznQN6naLbomWoFr+T/X6gM5VALuXByUG5QxzM1nhbu/lpPQu7mCfQxzFixbQfItBxlPYewhlIojT; 25:Ygz+y7IBZI32WaWeN1onNioU505s8mkHDAla0/LiKWywXukw0+Vg0Jjn6VjUiIBIdVHdEkjYO3KWOtTrELUEBUWGCr2vXgbx33GzfRKebSNkpRWgSOpP0bXg3BEwxuKwURvLsRj/c5UtZBPMv3x5S0l8d52Tcig67dsxw5C5elygQgwBEArXPQ5jPhK3cwpUE0BlW+IlSxdLoukLgf4UsBR7qHyj4Bhpd4ZMjKV1gFHjNu27Z16wkF5D222R1yqw2OQy82KNXVQL3G6lNhafIq9MFP0C8On6HaZFY1rlNAik6SLrjiHfwiiTsn1cX7AAwF59booKCdlT+kPct7R/h41ynZPajYWxv9Imkbqyld3QilYBK07YSQe4WhvZawqsFn2ct2CTa0Gjf6oKMlRKMp/AXqiHZGGETGwmw1idE8s= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1719; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 20:/p+4SW+IBzFbiUsFbE0fJaL6yGjJpze2NHClyxgc5FOBMQVPkOTZOCSFqpdMpnJQ+ZEgO/Dgi4Gpx543yymsL82wrMKuC4aNuXLIEbx2iGReEJPZlbFufT0yIwsrj9i814qn2VnNm3k5vFwtLSlLZdHL2H4Xz1xMnUKhbp1ORwRuh7FDrzHyLgxxw76k4Nl6uWLe8gIAhsJdROea5w3/FP2tH+savtwQu6e8ihQXtdsyRcV7KEY/oKWqPpqajKHpxuqFPCc721ojZtSSG87HKOs92aXhihx9jaaxkmyuNmguUrErwyLQsX/S6j0YhYYtVV+1a8VP4Y0Qt18Px/CSa+lymvMTOpCJoD+K74rNfQP4pZa5LnbVGSIpw1ng2Agzc8g7YdOb5pLE1E+7dvQX6fknjTOYMSRkgvAdcz5qFJkvNO6j3RnkKyajYjds8QZLVRJM9NyJt/DcDsWIzzkATNmGkA2DUtF5SmSs+r48Iy3Nw4cegt7t45noJC94B9Ox643PxtZn3hzUS46tSY7jfvqM2gws4AkiiTtwluRCy3N2TBT6qWk6tU1f+zOLvGWxxNKFk15ncpG747OMofHtqAxMgEy9Jh6NENkwFXHye+o= 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:BN3PR0701MB1719; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1719; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 4:4x3Vuw7hi43QmYNaZ58xN3WhfQ+UQKhPAAtxJk34a4oT/NhgjmPS172dWeF3LKjna6W1AjWdV7+ykcC8HU2KZiudE6Qo5WBd0vjYuxAS1WNoCvlkWzrF4SvqTSSUpD7/tL54jkuZKGMo75AAA7/Yw+Eu7c+4d76s5kO9XtIfW1klwyC6w+UviY7ytVIdY4ngb/XlyP3nfpW0n7XFyDHNQ3WkOoFKSJ5muDv50JSGKOXeYLicSua9d0CCcQPnlagdGO6qBvDsK0NlLbUDpnPCP3A1zJ8SYHAFbLVKp+qVhVZyUwzUFYK4EifYJfMWWStYEbKs7pMOCu3qnBdUVDnpjbMqpJeZC639taNajjN7aGVOacMKOrwgMvCVMrhvpWOO X-Forefront-PRVS: 09669DB681 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(199003)(189002)(81166006)(8676002)(81156014)(47776003)(66066001)(36756003)(92566002)(2950100001)(586003)(2351001)(48376002)(76506005)(42186005)(50466002)(4326007)(77096005)(3846002)(6116002)(5003940100001)(53416004)(5004730100002)(105586002)(97736004)(2906002)(5008740100001)(106356001)(189998001)(19580395003)(69596002)(101416001)(110136002)(19580405001)(68736007)(33646002)(76176999)(50986999)(229853001)(50226002)(5009440100003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1719; H:localhost.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BN3PR0701MB1719; 23:oFfQ2YpaaZIYShtS2OYo/k/T0c0Ffcz53OHk6Dv?= =?us-ascii?Q?0SVHlWYCbSLJStI9ODdUGns4hcXq/Y24tfrgj/Pd6KY63/NuucG8BQl0AZYD?= =?us-ascii?Q?kRwMfnmW92FdBuX6gNMhv/NFOudUlzbUwRsVSMzsP2/jgkdvd/bRtkcRwdYU?= =?us-ascii?Q?LFzktSR+EBElDXAqXYppyTchJRaurhTaTi1IvDgW20gtl0IOr8PA5PRfcLDP?= =?us-ascii?Q?JXo5IVmG9vPU866J0Lp6NOPyBcCFxnGJWPCwIHXQ6fKCv7G49jdDpZYTVG8P?= =?us-ascii?Q?zId3P9gMNFba9kLTQG4v4rMmkUXztxvvQIcpM9UNPGgQpxNS5FvB6k2Uk/pX?= =?us-ascii?Q?N4yWFVYcIH0sVCD0QU5nCQyOyLjXVZQSm4oZLtTsAdn8pDIJWw1su7el2Xwh?= =?us-ascii?Q?L+smxVkJKV7bOAw0TZIQUi+gM6/Rf94eSy4ZnKS7H0CnahVKqZ/hszsp0HSB?= =?us-ascii?Q?iMZ6+uLXcpu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yrzbT5FBiYcBhYiRCwYFofX4MET1+kSc9aYxo+zsUg3s6bNqSjYYVwohWwxDvmxziq7Yl7BiCOcMmI3zkQokWOPun7U9Zq9ZIZBDZgyxo=; 7:JOwfw3pM2pJrzMnM6jHe1MEc8/oCxrng3QoVF2oMxrAA95W8hQSNb3wZEu3xr/75CcyU63rk/snNkbKtfxh+J+l+bnPDQfC7VtJy5tk7CvfwS5A4aXGtS4x3Ravd5aj6Ds5qcx7FLRpqZpOuzdHBpjS3FrqErB6ZyDcMdo0+ztlvCeLaszae6XiadjxGuTUpBe+mI4IKOBc+2h5aJ8QVhsEhzJTxiw1bOzVxRa6bdLY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2016 16:42:01.2637 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1719 Subject: [dpdk-dev] [PATCH v3 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: Tue, 07 Jun 2016 16:42:06 -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 7a931ec..35fad4c 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); @@ -240,6 +243,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) @@ -846,6 +913,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