From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0058.outbound.protection.outlook.com [104.47.38.58]) by dpdk.org (Postfix) with ESMTP id CD71F29AC for ; Thu, 28 Sep 2017 14:20:26 +0200 (CEST) Received: from MWHPR03CA0055.namprd03.prod.outlook.com (10.174.173.172) by MWHPR03MB2702.namprd03.prod.outlook.com (10.168.207.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Thu, 28 Sep 2017 12:20:25 +0000 Received: from BN1BFFO11FD042.protection.gbl (2a01:111:f400:7c10::1:190) by MWHPR03CA0055.outlook.office365.com (2603:10b6:301:3b::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11 via Frontend Transport; Thu, 28 Sep 2017 12:20:24 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD042.mail.protection.outlook.com (10.58.144.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.56.11 via Frontend Transport; Thu, 28 Sep 2017 12:20:24 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.39]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v8SCJ72X008785; Thu, 28 Sep 2017 05:20:22 -0700 From: Shreyansh Jain To: CC: , Date: Thu, 28 Sep 2017 18:00:00 +0530 Message-ID: <20170928123000.1711-41-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170928123000.1711-1-shreyansh.jain@nxp.com> References: <20170928113344.12248-1-shreyansh.jain@nxp.com> <20170928123000.1711-1-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131510748246590760; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7966004)(376002)(346002)(39860400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(498600001)(68736007)(5003940100001)(8656003)(85426001)(54906003)(16586007)(4326008)(316002)(104016004)(86362001)(5660300001)(50986999)(76176999)(8676002)(33646002)(6666003)(50226002)(356003)(47776003)(189998001)(97736004)(81156014)(305945005)(53936002)(6916009)(2950100002)(8936002)(50466002)(81166006)(48376002)(36756003)(77096006)(105606002)(2906002)(1076002)(106466001)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2702; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD042; 1:v2kXAAILTHuraEUzGIX3BDPs+pws0qJqLhQUjr3fTrn/NLpi0sv8ZwkwDAeNdeun6EvHQJV9d/Fb2dOr8ai49Bip4GkombYHXxHrmukljcBAlGlYVUjzKCGRYbAcAOMt MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6832e2bd-7a24-4e01-4528-08d5066b4bd9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017052603199)(201703131430075)(201703131517081); SRVR:MWHPR03MB2702; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2702; 3:AMvIjNeg1tlYcEkJFCMQy8B/wux3YQOo3s+3eDRjFbFA9dOkYRPVc33k0GpUOQsGW6pPp0ntHh/F64GA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FDuZZEMxAqnyc2iApBWnXzb9L/x6D6JS0dxkfr6ocuzMne70aHgsRfB19QtBSu6agf5Frz0r3t3cq0/+s03h2XXcvGeAlIYWk2r+Vuyg5Lwwtz1M/myQhA3gXM57UdVJy6VFuFT0oy2R9kzGu1C6NMKJdhw8UfNpLEKf5iGRnt4PChT8EkR6L7RIg= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6096035)(20161123556025)(20161123565025)(20161123563025)(20161123559100)(20161123561025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR03MB2702; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR03MB2702; X-Forefront-PRVS: 0444EB1997 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB2702; 23:9Uy/TI+6kisR4wVI+hRrHssYosEYzDE5n4bEfvnP2?= =?us-ascii?Q?xI5RKx15uipuSH7zRPZvzTKtdbyvhAuTywNMg3DPsKo9znFg59xAbmH9ZPRs?= =?us-ascii?Q?T3u2oyX5jb0x3iG1J8kntBgn87USqu8Aqe0QMnWU/MPJzu/SOIoGqZ+PqwR5?= =?us-ascii?Q?x+43015Bs5cMME/VtIksT95JdIL+J0LksEg8XJbx+kLN42rA8EJS8tvSbpxE?= =?us-ascii?Q?rverJH5fbQ6Ksc1AmplaoDk+F+h0DIuZDe+Mi/Dm3MhFpJexuB5UDIjfdfzy?= =?us-ascii?Q?ia/Vwc0f7JMhkI6vdUzYDMgNG3Mc1Y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fu9zU/oxNAjTW93KGwDO0O458fw5aiofKA?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2702; 6:r3PQwiRe6w+AzCvJZrKlZXtJiKfLXY2G4Fb635vTA/P/GOrafeA0bkuwMs7yDGTDdi9/nBkRzJnS+yuWgd6jrTADvFqOisxk4Pxak+2JLOGJMLVmPvvB5uXXpOkP3VpD0f5aMgZI0ZnhfiMgsQMoFF2MX9evj6Th5Xmj3GOvA3NqgsdoSVnA/bcGF5lw3lulJtHQ2lWoagjq6J2UzRHNUZRaxPNpwGwqqnD16UZQBHYTmaWo/S6bmFyHbqQqcqpXxnu0aEAe27dpAV7PU8oWcVQ1UY3+q+xe6HzWH/9DOt0c0kgomIZyAg1gJbGvOzlJ3ulq8gdSwmJw+9PpVbzzZQ==; 5:kA57LvzBBc0HuXixXXm0EejYbXPWBtjHlOWVrygJEdrAUzk1XCmXyb8TdB/Ef2o7cW1I/I/gVlSVBTJwcZJqSfYiFEXuvNn9Gghq399ScUx2IZe9mRs7DEy2UsnNs1UZAU67FqstZdSy3u7+rbwwQg==; 24:vQZNSCXwThMohcju4G7eVJdxizcrObdVvV6CtZMKt7mIsJOW5HE0PinhWpDkPg+68R+xXWs2oTPE0BHuSYYQ/qWjrA5xUVePl9QPhBmgoGs=; 7:MGtuza1DH4trkhW7pqCETe+0jf0kVNZANi401rprIKb3x1UjNH6bl2e62hBl3jVGoum83WiC2opPpvzXyopkzrESAGQSQV/I5BcIpK/d8w5fQARh8IXU5h7g5hzYqS60XHF/es5iHPpcQdh4lT0hxU9nqyA9HHqvfjuKZCBb5O6FrnzyGGrXUJo9Yw7OvGwIP2+2J9okSQ+jnYxJl0w2a6d0xbwXs77mlqa7zwxTsHw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2017 12:20:24.4718 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2702 Subject: [dpdk-dev] [PATCH v6 40/40] net/dpaa: support extended statistics 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, 28 Sep 2017 12:20:27 -0000 From: Hemant Agrawal Signed-off-by: Hemant Agrawal --- doc/guides/nics/features/dpaa.ini | 1 + drivers/net/dpaa/dpaa_ethdev.c | 143 ++++++++++++++++++++++++++++++++++++++ drivers/net/dpaa/dpaa_ethdev.h | 40 +++++++++++ 3 files changed, 184 insertions(+) diff --git a/doc/guides/nics/features/dpaa.ini b/doc/guides/nics/features/dpaa.ini index 09b9bd9..24cfd85 100644 --- a/doc/guides/nics/features/dpaa.ini +++ b/doc/guides/nics/features/dpaa.ini @@ -18,6 +18,7 @@ L3 checksum offload = Y L4 checksum offload = Y Packet type parsing = Y Basic stats = Y +Extended stats = Y FW version = Y ARMv8 = Y Usage doc = Y diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 8e51fe6..8dad97e 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -75,6 +75,40 @@ /* Keep track of whether QMAN and BMAN have been globally initialized */ static int is_global_init; +struct rte_dpaa_xstats_name_off { + char name[RTE_ETH_XSTATS_NAME_SIZE]; + uint32_t offset; +}; + +static const struct rte_dpaa_xstats_name_off dpaa_xstats_strings[] = { + {"rx_align_err", + offsetof(struct dpaa_if_stats, raln)}, + {"rx_valid_pause", + offsetof(struct dpaa_if_stats, rxpf)}, + {"rx_fcs_err", + offsetof(struct dpaa_if_stats, rfcs)}, + {"rx_vlan_frame", + offsetof(struct dpaa_if_stats, rvlan)}, + {"rx_frame_err", + offsetof(struct dpaa_if_stats, rerr)}, + {"rx_drop_err", + offsetof(struct dpaa_if_stats, rdrp)}, + {"rx_undersized", + offsetof(struct dpaa_if_stats, rund)}, + {"rx_oversize_err", + offsetof(struct dpaa_if_stats, rovr)}, + {"rx_fragment_pkt", + offsetof(struct dpaa_if_stats, rfrg)}, + {"tx_valid_pause", + offsetof(struct dpaa_if_stats, txpf)}, + {"tx_fcs_err", + offsetof(struct dpaa_if_stats, terr)}, + {"tx_vlan_frame", + offsetof(struct dpaa_if_stats, tvlan)}, + {"rx_undersized", + offsetof(struct dpaa_if_stats, tund)}, +}; + static int dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) { @@ -268,6 +302,110 @@ static void dpaa_eth_stats_reset(struct rte_eth_dev *dev) fman_if_stats_reset(dpaa_intf->fif); } +static int +dpaa_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + unsigned int n) +{ + struct dpaa_if *dpaa_intf = dev->data->dev_private; + unsigned int i = 0, num = RTE_DIM(dpaa_xstats_strings); + uint64_t values[sizeof(struct dpaa_if_stats) / 8]; + + if (xstats == NULL) + return 0; + + if (n < num) + return num; + + fman_if_stats_get_all(dpaa_intf->fif, values, + sizeof(struct dpaa_if_stats) / 8); + + for (i = 0; i < num; i++) { + xstats[i].id = i; + xstats[i].value = values[dpaa_xstats_strings[i].offset / 8]; + } + return i; +} + +static int +dpaa_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ + unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings); + + if (xstats_names != NULL) + for (i = 0; i < stat_cnt; i++) + snprintf(xstats_names[i].name, + sizeof(xstats_names[i].name), + "%s", + dpaa_xstats_strings[i].name); + + return stat_cnt; +} + +static int +dpaa_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + uint64_t *values, unsigned int n) +{ + unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings); + uint64_t values_copy[sizeof(struct dpaa_if_stats) / 8]; + + if (!ids) { + struct dpaa_if *dpaa_intf = dev->data->dev_private; + + if (n < stat_cnt) + return stat_cnt; + + if (!values) + return 0; + + fman_if_stats_get_all(dpaa_intf->fif, values_copy, + sizeof(struct dpaa_if_stats)); + + for (i = 0; i < stat_cnt; i++) + values[i] = + values_copy[dpaa_xstats_strings[i].offset / 8]; + + return stat_cnt; + } + + dpaa_xstats_get_by_id(dev, NULL, values_copy, stat_cnt); + + for (i = 0; i < n; i++) { + if (ids[i] >= stat_cnt) { + DPAA_PMD_ERR("id value isn't valid"); + return -1; + } + values[i] = values_copy[ids[i]]; + } + return n; +} + +static int +dpaa_xstats_get_names_by_id( + struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + const uint64_t *ids, + unsigned int limit) +{ + unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings); + struct rte_eth_xstat_name xstats_names_copy[stat_cnt]; + + if (!ids) + return dpaa_xstats_get_names(dev, xstats_names, limit); + + dpaa_xstats_get_names(dev, xstats_names_copy, limit); + + for (i = 0; i < limit; i++) { + if (ids[i] >= stat_cnt) { + DPAA_PMD_ERR("id value isn't valid"); + return -1; + } + strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name); + } + return limit; +} + static void dpaa_eth_promiscuous_enable(struct rte_eth_dev *dev) { struct dpaa_if *dpaa_intf = dev->data->dev_private; @@ -535,6 +673,11 @@ static struct eth_dev_ops dpaa_devops = { .link_update = dpaa_eth_link_update, .stats_get = dpaa_eth_stats_get, + .xstats_get = dpaa_dev_xstats_get, + .xstats_get_by_id = dpaa_xstats_get_by_id, + .xstats_get_names_by_id = dpaa_xstats_get_names_by_id, + .xstats_get_names = dpaa_xstats_get_names, + .xstats_reset = dpaa_eth_stats_reset, .stats_reset = dpaa_eth_stats_reset, .promiscuous_enable = dpaa_eth_promiscuous_enable, .promiscuous_disable = dpaa_eth_promiscuous_disable, diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h index a980262..5457d61 100644 --- a/drivers/net/dpaa/dpaa_ethdev.h +++ b/drivers/net/dpaa/dpaa_ethdev.h @@ -139,4 +139,44 @@ struct dpaa_if { struct rte_eth_fc_conf *fc_conf; }; +struct dpaa_if_stats { + /* Rx Statistics Counter */ + uint64_t reoct; /**