From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0082.outbound.protection.outlook.com [104.47.41.82]) by dpdk.org (Postfix) with ESMTP id 6CEED1B21B for ; Thu, 28 Sep 2017 13:24:26 +0200 (CEST) Received: from CY1PR03CA0010.namprd03.prod.outlook.com (10.174.128.20) by MWHPR03MB2703.namprd03.prod.outlook.com (10.168.207.137) 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 11:24:25 +0000 Received: from BN1AFFO11FD035.protection.gbl (2a01:111:f400:7c10::136) by CY1PR03CA0010.outlook.office365.com (2603:10b6:600::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.8 via Frontend Transport; Thu, 28 Sep 2017 11:24: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 BN1AFFO11FD035.mail.protection.outlook.com (10.58.52.159) 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 11:24:23 +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 v8SBMpGG016035; Thu, 28 Sep 2017 04:24:21 -0700 From: Shreyansh Jain To: CC: , Date: Thu, 28 Sep 2017 17:03:44 +0530 Message-ID: <20170928113344.12248-41-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170928113344.12248-1-shreyansh.jain@nxp.com> References: <20170909112132.13936-1-shreyansh.jain@nxp.com> <20170928113344.12248-1-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131510714642514313; (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)(7966004)(336005)(346002)(376002)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(1076002)(498600001)(54906003)(50226002)(68736007)(2351001)(2906002)(106466001)(305945005)(36756003)(5003940100001)(33646002)(316002)(8656003)(5660300001)(85426001)(8936002)(16586007)(86362001)(48376002)(76176999)(50986999)(6666003)(104016004)(81166006)(50466002)(81156014)(77096006)(47776003)(53936002)(6916009)(2950100002)(105606002)(189998001)(97736004)(8676002)(356003)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2703; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD035; 1:qOhN7OSo2xZQm1DEImrDZrUFe9JmSKmbVC9k/y56qmKXd5wmVsFMEAqAFW1MsuwlhfTZa6YC08GNFjfVVng1vhc2On78ZScHVicj9qTq2JBbXKmO9W0k4Hw0B9G/ycX/ MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6ac8cd9-91e2-480e-b689-08d5066378d0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017052603199)(201703131430075)(201703131517081); SRVR:MWHPR03MB2703; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2703; 3:+AB7ea8pxoYytGAbbHXZ2ymx0SzD+RwzeVuZAW1XqC52R1bM45+3aItmqRNxGpMpKa9cc7PtIbO34ozZgKg9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CXOVn4YLeDDEi8SURdyW71WKo2FuJZlDPR9h02dF29cyvPwGJ48idsFB60zVthZP0+cPzYPQ0qhvhqX8B8AHQyqcK2qlTAaMz2mgjUWQDnl9qj0kkk5kOyIaPXc4nTdQPOQDoUfZdc6pzmtGUkI4zjvXwPY8ydze6rIabDU= 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)(8121501046)(5005006)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123561025)(20161123563025)(20161123559100)(20161123565025)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123556025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR03MB2703; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR03MB2703; X-Forefront-PRVS: 0444EB1997 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB2703; 23:9ZovL2VkpF9Rf3dKYUMF9qLncy+l5TUHRFNWbdkvj?= =?us-ascii?Q?l0RudvyJlliZJumlhgADt6wIdLBuagCX+QDyyzYrn8nPlr3Qx4xubBNVLM7j?= =?us-ascii?Q?Ma0ydM4jyV1ioL1FjvI+DMCnxHbK8FLcTv8oqb3VhsNxeSAWNZeDYoyqXLAX?= =?us-ascii?Q?7AeHIUzFzF1++nqBPl4WeZ53/ejQx6wRAPw5GxyZgEpa3q4PfovXOL1eFAD1?= =?us-ascii?Q?WpvBeawcewghPuQcd4q0ntHEQ/QsF8o1Gg0n6Ek0T+MqKgEVbwp8T/Xlneop?= =?us-ascii?Q?NwypXjKr6FothfeARCMio1ev4pjpn3uJ5RDXmu3MLazKv6N8e5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8QgGodsEta/n96k7O?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2703; 6:LIAnmpao4STiz4c7BwvRuE5ckqM1Qg7Awmxdq2r0HL/HU4V2uYVFCzCIFYMe5ZHTSbEdL7vEhpveGiFLWynzUowF8cICwOguhVl5G7iXc4gXuZDwY8RsoHnymPPZHPhsrZbRqKp+Pq4aANySn8QAJPCy4qD/K31ub3KONEvVUF2rgf3Ls18wu2Rz+zVW8MS9TcrWYDqncFKbfF5ddzsmJTJfKWp5t2ZjRp8NxaBeCWhh1tQY/zEMX6sqgB4IzHk7TgjwMesdp2wPOShKTyN2ukvCxgZmN92uuiaO2XPrb7rFHOVp+OrSUntXfY7/SQEHA7hNJCY1tdfLaMCM2ILh6A==; 5:0RlkQ0soBpHfYGSA/m2RU6w8C3zAvwclyv7W1vyNq1tbrgzncHysQoC2ZGDkLsdqD807mwxX0QqYVTJ9v9K67nLNef5vFHJqjQHVAFCf8jEYdjh8IcSRK0DdgHh/k44iqbp4byalNkKQ3OvPxNHAKQ==; 24:debEHMh+wiLcMDnwtniAzNC4U9CNoDcI95W5OthdNwCNrcT9GzTWHsbmtsREgmqpUCCD7ZSyiHPszAWt+uks6MrN/va7ZLr5yEug7DuCj8o=; 7:ztm86IsZUPF5veEg4BDsk33eABvJfOU1ekq5BtrCAfsUwuUko6LjtO7ZsZbOjjPFmzaC3n1M0Ljew4sPIJ0GUQfh4bWi6AjoXZgExNuSD6FLmzFnp8PD3hQPWG1VE41CUxTUmSdLE8WKawxHwP8IPYKZpjbcvs2Gx1xzx4VP8KloV4LsKQPgPkwJwfgR0rR8q7dbQJnYW4m4ogFV9gzH9Vh4mGaa26iPSJtPvnElE3U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2017 11:24:23.9394 (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: MWHPR03MB2703 Subject: [dpdk-dev] [PATCH v5 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 11:24: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 0002324..db4921f 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; /**