Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754410AbbKBQuq (ORCPT ); Mon, 2 Nov 2015 11:50:46 -0500 Received: from mail-bn1bon0132.outbound.protection.outlook.com ([157.56.111.132]:40787 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754427AbbKBQtP (ORCPT ); Mon, 2 Nov 2015 11:49:15 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; From: Madalin Bucur To: CC: , , , , , , , , , , , Madalin Bucur , Ioana Ciornei Subject: [net-next v4 6/8] dpaa_eth: add ethtool statistics Date: Mon, 2 Nov 2015 19:31:38 +0200 Message-ID: <1446485500-9782-7-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1446485500-9782-1-git-send-email-madalin.bucur@freescale.com> References: <1446485500-9782-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD008;1:VA2cU+R6MGJ4xASF+wWdvIqfO++2F5R1m83XX2+Cl1Sfc5aGUOy00u6woeiKWJmzW7SQskXyaX1Q71Ea8WN/HvzKlMVSxpfKT0U+fhqoT0ZVkQgpgEQO9U27gKcOAUxIzSiMlx15Lrq/IKxZrAIGxLXF+THngwmjGkT2sUUgPdapcGe/WWLuKbXOe10iVNceDfCtD897KXMp8APB8QxRmmNQY/1iawHaaRaXplay4shmAePsi0p1AyVtM5R4+jKHgRqu4FCjdH6BIVwtE9yL3GgiPU7Y2BkTWIP7l4TSTEClFewwX/av3tEaAATX9DZFns5lhgbYr+/GOcuk149msVFVipKB+IfHVZn8YqZkM7v33YSrvDh3L+f5GKlRuZHG4XnDr7rfYo+Iy+kwQmZbGw== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(106466001)(5008740100001)(105606002)(229853001)(81156007)(48376002)(2351001)(11100500001)(97736004)(104016004)(5007970100001)(5003940100001)(36756003)(189998001)(47776003)(87936001)(5001960100002)(50226001)(4001430100002)(49486002)(86362001)(2950100001)(33646002)(50466002)(19580405001)(6806005)(43066003)(107886002)(85426001)(110136002)(50986999)(76176999)(77096005)(53806999)(19580395003);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR03MB547;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB547;2:P3JBUCEUvBlH7wmBqUHjzl9vY+rLM0VkVDdFuAS/6ZOnp/LSDmcXKfEY627/p24jrVHf8jYfpIa+q8znnSR1YcM9oAusASwinP4l+5vqBrQXtrSpNFCuIHkF+apr/kclJTVMm0CcyeD1jWG06jYZCxuCfUo4/wWEEeooAIkaSnU=;3:jDttgl/E872UZqRplTsz3/IbTRlok/yjgmZuigoJ8Hni6yB6wD4DAjRZxjDVkSUmKHuJd7PeYV4beUva29RD1YCJ3uJfaMqoZQ6RDTYW5pXJPQ9l3H287aGt4kC0lASl/NFwu9TRM9jg9UqForsZP9epxHF8g8i8VKx9RLAdBvpjWRQfuMMT4W6Nh6gu0Kl1YTlr3K8BzQy3yT7KZMUT0VIURLnMNGFsLay6k9bJTnY=;25:EClkhqFT/4Mj6vxFAGH+3EbUZkttj9R3twoeVRcJlc/N4syt7vmLgoDxDga7TM9KeoZK0j4JeLmDWEt6dDzsVK1RFuahk0VgPnxTYCEUftLZ9eAYk6+qOX7JA7v6jtsiCbcEXRQTxy3UY3nwtLBn/mD0otkRJQQfxl9gDT0D8lB92O8NLKchctwwB/2m2tF3A/z7XwSPjJcgnVZ0liHDR5JoPizpVhrFKHO+AykbtWRrRpy9B23vk2+pOWe9ie8oDylXRsp/tC9jqiZGe1wcJg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB547; X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB547;20:lb7DB11IqZTEeHOU0yvDukbJHg48ekuUYZXcRDBrTbHWaZiyge+hHEa+ttexmS0sWowSeDTfDy8RdpefMji7OE8arbMH9WeltA4duvFIGfeei/nm4klJaJRsCbVkHVj7bM3rYoMNlCZ4c3aT2rlDUd14d7Cy+wVil7+qJidUTZ5u0VW2pz+Ct5AlwKVTF5vpJqvts7aoDSbem08+sJ05nuEHdBxlfJE+XPL9ITcD5TzByqPhxj1hieqU5JCl9Hu/q9XWqYrwKx7fedSxVS2p/7EWQKSyFuLVWD4oZfnGFR2KyeMyXQ6RKL23SD4nJAzM1vC8wWWGM7OL21znqu2EqNCg7t/BQIDV/YptfrDP3Rk=;4:lNqlAm0PN783SyjA2eOtjFvkT2i077pYYdx17xiKwdZkKu18b4NmG+gZHg0nzNTLmguDG1CMq83j7kgT1scHdQYRmqc74dzf1bsfTvpdQbI6yQ19Z5LwG3qzg6B8Z78cvGt4KRsHVR2zFWnVi9a/rWtCqQKiiECnVy9HAJDqqJT0r/W/c13PWdzfHmDKjdNxhW2qwlxkbhNWVyRerls0F18reIBVnvHy9FtYFzahho/x9Ry4YFiQF6rjU+mXgG+NoX8TkNvMRsc1QmMWS+Kg8hoPa1rntkytr3MrOeua4fL13dBjl8doLQwlUkvVHySQO40nBcpm4IYW2gHFM7HsiB7JEoz3sSm3heFeQzO5HXVKlvMjAqtGbP1Dj4Nt2+At X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(10201501046)(3002001);SRVR:BL2PR03MB547;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB547; X-Forefront-PRVS: 0748FF9A04 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2PR03MB547;23:ZLLQwFQinDQF7LvEi4I2TXnxnYSyIn2Myjzhih5oEb?= =?us-ascii?Q?2wE0uQFBIaeZ6oCtMP5E+6Cbh5MZ8SXZm8TFV/TawTT5A/yvFHHkE7lepYxo?= =?us-ascii?Q?OVZs32vz5/0BuTB53izrFQQ1C8i8nXqE/30XRvNZplV73a6IftoWDvdEwbTC?= =?us-ascii?Q?KoxXk/U8ILJq8yZ/pEGN6OD1T7y01g0stWaPwlW7oQgAeROhNQyyJCrcVVM5?= =?us-ascii?Q?w6oosJgxCKm8kHW67LphkqI/ACrLzJUqRM6JJdKXBVB1dHLgM3OSup3dwyOT?= =?us-ascii?Q?zMbZJ2TkuQAilnyNFRPJOSnWSg74bwDs9CiSoAigkxi5yk8NnMIYK+mvXmC3?= =?us-ascii?Q?5nf6DlhZl5XeQcuuXNxA2ec5H/yFT1oQxQtuL1Hm+TELWWzbZGqWOSuYW3jK?= =?us-ascii?Q?sjdKq7pYyDQYzEGTkXXQS2A97B96eBXhrEdaI8yyWJTStZGi4go2SCUlCRVU?= =?us-ascii?Q?Bks664fUeG+jcHw65p6WsjYgc/pvs82TEmkpZefhgArgjoDHpxVeauD1XCBA?= =?us-ascii?Q?vO5DqXXfodQV18VhF7cLeu3k+Zf7USCVQIlCWHLYZ1JBhzUbVTm2HkkAFyOh?= =?us-ascii?Q?ZKAci1U7IScUdBneZwXfmi4UeH7sYBsWo/J52bt41UgRccbHOeBzOYdrixNd?= =?us-ascii?Q?jbr35pb+ycxHAsLEccYqoqi+ZGmNFUQyf/jIraKUqik5ySRUHK1D6em1wwUM?= =?us-ascii?Q?Qu1o9T3gIPTg27J7OCQ4Qg38HnVsmxA43Wi720RIu2SVi/SbJj3R0KsbCSOF?= =?us-ascii?Q?d6zGwV3R0tR9BEIU8VRSVH2dk17UKSv/pNK4CapzMvzlhZRw5Gm0St5ZSCKZ?= =?us-ascii?Q?4Mc4GRxBpE/8kExmp2OSav9iQ6Yc3Q0uh1p6hdudTXMPZneL2EdsvLzQO+Wu?= =?us-ascii?Q?WFZ0ol4zjxnEe2vobUxPDuWL5RoH91lsEq+0HoRB3qMmq5JDrzvOqp2dfx0t?= =?us-ascii?Q?mwTngmyDMP+HgBTppooi3acnQomcCeCidF80zjOhlhSAgAQ4J9t8+KhT8mFj?= =?us-ascii?Q?pw42byPlpRm8iK4lEJXaHDrgM8wkpQg1DInV6Esczv3wks8wVJwfox3dlcBU?= =?us-ascii?Q?l1EWlXQkz7HEgspjo9G9NNyLmZjPKKq5EtHp01vIjyeLHhkN0oBFwQR7zvwQ?= =?us-ascii?Q?AxXjNtfVWswRe6wnga2xcIc1GD5vcH?= X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB547;5:QvmDacEo6Rs9398Eog21Eyu7b7jTQOWTwWk1Ynjj+XgFVNyO/o5Y+5+fAA9pFAVA4P7GWT0HYC+MrwdO122uDvsW3XOiSfmNvmaPQoX4QzHeNn5ulP+W/G933UxAXu3D0Lc80qJNclthYZtJbQ69qA==;24:n56v0aiVjYvbNd3UBQUtfv7NH/kWlaw1voE/tHQsYW3vRUn/dCnp1R1AUd8yNeJNShPperkzRcJpErmQd15aR2anzu9ZU61sp8/Mlx1FDew=;20:dJorrL3IADGyn49WHEH6C907gPGbulILcMnhqGX3/3QV1T1xoLfgfWrPNdc1dj8UG211XwqI+fzMiogFJCRRwg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2015 16:34:10.6991 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB547 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14323 Lines: 422 Add a series of counters to be exported through ethtool: - add detailed counters for reception errors; - add detailed counters for QMan enqueue reject events; - count the number of fragmented skbs received from the stack; - count all frames received on the Tx confirmation path; - add congestion group statistics; - count the number of interrupts for each CPU. Signed-off-by: Ioana Ciornei Signed-off-by: Madalin Bucur --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 12 ++ drivers/net/ethernet/freescale/dpaa/dpaa_eth.h | 34 ++++ .../net/ethernet/freescale/dpaa/dpaa_eth_common.c | 40 ++++- .../net/ethernet/freescale/dpaa/dpaa_eth_common.h | 2 + drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c | 1 + drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 183 +++++++++++++++++++++ 6 files changed, 270 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 894f1a7..0b3332a 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -102,6 +102,15 @@ static void _dpa_rx_error(struct net_device *net_dev, percpu_priv->stats.rx_errors++; + if (fd->status & FM_FD_ERR_DMA) + percpu_priv->rx_errors.dme++; + if (fd->status & FM_FD_ERR_PHYSICAL) + percpu_priv->rx_errors.fpe++; + if (fd->status & FM_FD_ERR_SIZE) + percpu_priv->rx_errors.fse++; + if (fd->status & FM_FD_ERR_PRS_HDR_ERR) + percpu_priv->rx_errors.phe++; + dpa_fd_release(net_dev, fd); } @@ -167,6 +176,8 @@ static void _dpa_tx_conf(struct net_device *net_dev, percpu_priv->stats.tx_errors++; } + percpu_priv->tx_confirm++; + skb = _dpa_cleanup_tx_fd(priv, fd); dev_kfree_skb(skb); @@ -302,6 +313,7 @@ static void priv_ern(struct qman_portal *portal, percpu_priv->stats.tx_dropped++; percpu_priv->stats.tx_fifo_errors++; + count_ern(percpu_priv, msg); /* If we intended this buffer to go into the pool * when the FM was done, we need to put it in diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h index 87577cf..ccaadd9 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h @@ -192,6 +192,25 @@ struct dpa_bp { void (*free_buf_cb)(void *addr); }; +struct dpa_rx_errors { + u64 dme; /* DMA Error */ + u64 fpe; /* Frame Physical Error */ + u64 fse; /* Frame Size Error */ + u64 phe; /* Header Error */ +}; + +/* Counters for QMan ERN frames - one counter per rejection code */ +struct dpa_ern_cnt { + u64 cg_tdrop; /* Congestion group taildrop */ + u64 wred; /* WRED congestion */ + u64 err_cond; /* Error condition */ + u64 early_window; /* Order restoration, frame too early */ + u64 late_window; /* Order restoration, frame too late */ + u64 fq_tdrop; /* FQ taildrop */ + u64 fq_retired; /* FQ is retired */ + u64 orp_zero; /* ORP disabled */ +}; + struct dpa_napi_portal { struct napi_struct napi; struct qman_portal *p; @@ -201,7 +220,13 @@ struct dpa_napi_portal { struct dpa_percpu_priv_s { struct net_device *net_dev; struct dpa_napi_portal *np; + u64 in_interrupt; + u64 tx_confirm; + /* fragmented (non-linear) skbuffs received from the stack */ + u64 tx_frag_skbuffs; struct rtnl_link_stats64 stats; + struct dpa_rx_errors rx_errors; + struct dpa_ern_cnt ern_cnt; }; struct dpa_priv_s { @@ -228,6 +253,14 @@ struct dpa_priv_s { * (and the same) congestion group. */ struct qman_cgr cgr; + /* If congested, when it began. Used for performance stats. */ + u32 congestion_start_jiffies; + /* Number of jiffies the Tx port was congested. */ + u32 congested_jiffies; + /* Counter for the number of times the CGR + * entered congestion state + */ + u32 cgr_congested_count; } cgr_data; /* Use a per-port CGR for ingress traffic. */ bool use_ingress_cgr; @@ -289,6 +322,7 @@ static inline int dpaa_eth_napi_schedule(struct dpa_percpu_priv_s *percpu_priv, np->p = portal; napi_schedule(&np->napi); + percpu_priv->in_interrupt++; return 1; } } diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c index 2b95696..4947cb9 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c @@ -751,10 +751,15 @@ static void dpaa_eth_cgscn(struct qman_portal *qm, struct qman_cgr *cgr, struct dpa_priv_s *priv = (struct dpa_priv_s *)container_of(cgr, struct dpa_priv_s, cgr_data.cgr); - if (congested) + if (congested) { + priv->cgr_data.congestion_start_jiffies = jiffies; netif_tx_stop_all_queues(priv->net_dev); - else + priv->cgr_data.cgr_congested_count++; + } else { + priv->cgr_data.congested_jiffies += + (jiffies - priv->cgr_data.congestion_start_jiffies); netif_tx_wake_all_queues(priv->net_dev); + } } int dpaa_eth_cgr_init(struct dpa_priv_s *priv) @@ -1252,6 +1257,37 @@ void dpa_fd_release(const struct net_device *net_dev, const struct qm_fd *fd) cpu_relax(); } +void count_ern(struct dpa_percpu_priv_s *percpu_priv, + const struct qm_mr_entry *msg) +{ + switch (msg->ern.rc & QM_MR_RC_MASK) { + case QM_MR_RC_CGR_TAILDROP: + percpu_priv->ern_cnt.cg_tdrop++; + break; + case QM_MR_RC_WRED: + percpu_priv->ern_cnt.wred++; + break; + case QM_MR_RC_ERROR: + percpu_priv->ern_cnt.err_cond++; + break; + case QM_MR_RC_ORPWINDOW_EARLY: + percpu_priv->ern_cnt.early_window++; + break; + case QM_MR_RC_ORPWINDOW_LATE: + percpu_priv->ern_cnt.late_window++; + break; + case QM_MR_RC_FQ_TAILDROP: + percpu_priv->ern_cnt.fq_tdrop++; + break; + case QM_MR_RC_ORPWINDOW_RETIRED: + percpu_priv->ern_cnt.fq_retired++; + break; + case QM_MR_RC_ORP_ZERO: + percpu_priv->ern_cnt.orp_zero++; + break; + } +} + /* Turn on HW checksum computation for this outgoing frame. * If the current protocol is not something we support in this regard * (or if the stack has already computed the SW checksum), we do nothing. diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h index 160a018..262b9b4 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h @@ -100,6 +100,8 @@ void dpaa_eth_init_ports(struct mac_device *mac_dev, struct device *dev); void dpa_release_sgt(struct qm_sg_entry *sgt); void dpa_fd_release(const struct net_device *net_dev, const struct qm_fd *fd); +void count_ern(struct dpa_percpu_priv_s *percpu_priv, + const struct qm_mr_entry *msg); int dpa_enable_tx_csum(struct dpa_priv_s *priv, struct sk_buff *skb, struct qm_fd *fd, diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c index af83ac2c..b4c2cee 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c @@ -673,6 +673,7 @@ int dpa_tx(struct sk_buff *skb, struct net_device *net_dev) likely(skb_shinfo(skb)->nr_frags < DPA_SGT_MAX_ENTRIES)) { /* Just create a S/G fd based on the skb */ err = skb_to_sg_fd(priv, skb, &fd); + percpu_priv->tx_frag_skbuffs++; } else { /* If the egress skb contains more fragments than we support * we have no choice but to linearize it ourselves. diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c index fa8ba69..356857b 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c @@ -37,6 +37,43 @@ #include "mac.h" #include "dpaa_eth_common.h" +static const char dpa_stats_percpu[][ETH_GSTRING_LEN] = { + "interrupts", + "rx packets", + "tx packets", + "tx confirm", + "tx S/G", + "tx error", + "rx error", + "bp count" +}; + +static char dpa_stats_global[][ETH_GSTRING_LEN] = { + /* dpa rx errors */ + "rx dma error", + "rx frame physical error", + "rx frame size error", + "rx header error", + + /* demultiplexing errors */ + "qman cg_tdrop", + "qman wred", + "qman error cond", + "qman early window", + "qman late window", + "qman fq tdrop", + "qman fq retired", + "qman orp disabled", + + /* congestion related stats */ + "congestion time (ms)", + "entered congestion", + "congested (0/1)" +}; + +#define DPA_STATS_PERCPU_LEN ARRAY_SIZE(dpa_stats_percpu) +#define DPA_STATS_GLOBAL_LEN ARRAY_SIZE(dpa_stats_global) + static int dpa_get_settings(struct net_device *net_dev, struct ethtool_cmd *et_cmd) { @@ -217,6 +254,149 @@ static int dpa_set_pauseparam(struct net_device *net_dev, return err; } +static int dpa_get_sset_count(struct net_device *net_dev, int type) +{ + unsigned int total_stats, num_stats; + + num_stats = num_online_cpus() + 1; + total_stats = num_stats * DPA_STATS_PERCPU_LEN + DPA_STATS_GLOBAL_LEN; + + switch (type) { + case ETH_SS_STATS: + return total_stats; + default: + return -EOPNOTSUPP; + } +} + +static void copy_stats(struct dpa_percpu_priv_s *percpu_priv, int num_cpus, + int crr_cpu, u64 bp_count, u64 *data) +{ + int num_values = num_cpus + 1; + int crr = 0; + + /* update current CPU's stats and also add them to the total values */ + data[crr * num_values + crr_cpu] = percpu_priv->in_interrupt; + data[crr++ * num_values + num_cpus] += percpu_priv->in_interrupt; + + data[crr * num_values + crr_cpu] = percpu_priv->stats.rx_packets; + data[crr++ * num_values + num_cpus] += percpu_priv->stats.rx_packets; + + data[crr * num_values + crr_cpu] = percpu_priv->stats.tx_packets; + data[crr++ * num_values + num_cpus] += percpu_priv->stats.tx_packets; + + data[crr * num_values + crr_cpu] = percpu_priv->tx_confirm; + data[crr++ * num_values + num_cpus] += percpu_priv->tx_confirm; + + data[crr * num_values + crr_cpu] = percpu_priv->tx_frag_skbuffs; + data[crr++ * num_values + num_cpus] += percpu_priv->tx_frag_skbuffs; + + data[crr * num_values + crr_cpu] = percpu_priv->stats.tx_errors; + data[crr++ * num_values + num_cpus] += percpu_priv->stats.tx_errors; + + data[crr * num_values + crr_cpu] = percpu_priv->stats.rx_errors; + data[crr++ * num_values + num_cpus] += percpu_priv->stats.rx_errors; + + data[crr * num_values + crr_cpu] = bp_count; + data[crr++ * num_values + num_cpus] += bp_count; +} + +static void dpa_get_ethtool_stats(struct net_device *net_dev, + struct ethtool_stats *stats, u64 *data) +{ + u64 bp_count, cg_time, cg_num, cg_status; + struct dpa_percpu_priv_s *percpu_priv; + struct qm_mcr_querycgr query_cgr; + struct dpa_rx_errors rx_errors; + struct dpa_ern_cnt ern_cnt; + struct dpa_priv_s *priv; + unsigned int num_cpus, offset; + struct dpa_bp *dpa_bp; + int total_stats, i; + + total_stats = dpa_get_sset_count(net_dev, ETH_SS_STATS); + priv = netdev_priv(net_dev); + dpa_bp = priv->dpa_bp; + num_cpus = num_online_cpus(); + bp_count = 0; + + memset(&rx_errors, 0, sizeof(struct dpa_rx_errors)); + memset(&ern_cnt, 0, sizeof(struct dpa_ern_cnt)); + memset(data, 0, total_stats * sizeof(u64)); + + for_each_online_cpu(i) { + percpu_priv = per_cpu_ptr(priv->percpu_priv, i); + + if (dpa_bp->percpu_count) + bp_count = *(per_cpu_ptr(dpa_bp->percpu_count, i)); + + rx_errors.dme += percpu_priv->rx_errors.dme; + rx_errors.fpe += percpu_priv->rx_errors.fpe; + rx_errors.fse += percpu_priv->rx_errors.fse; + rx_errors.phe += percpu_priv->rx_errors.phe; + + ern_cnt.cg_tdrop += percpu_priv->ern_cnt.cg_tdrop; + ern_cnt.wred += percpu_priv->ern_cnt.wred; + ern_cnt.err_cond += percpu_priv->ern_cnt.err_cond; + ern_cnt.early_window += percpu_priv->ern_cnt.early_window; + ern_cnt.late_window += percpu_priv->ern_cnt.late_window; + ern_cnt.fq_tdrop += percpu_priv->ern_cnt.fq_tdrop; + ern_cnt.fq_retired += percpu_priv->ern_cnt.fq_retired; + ern_cnt.orp_zero += percpu_priv->ern_cnt.orp_zero; + + copy_stats(percpu_priv, num_cpus, i, bp_count, data); + } + + offset = (num_cpus + 1) * DPA_STATS_PERCPU_LEN; + memcpy(data + offset, &rx_errors, sizeof(struct dpa_rx_errors)); + + offset += sizeof(struct dpa_rx_errors) / sizeof(u64); + memcpy(data + offset, &ern_cnt, sizeof(struct dpa_ern_cnt)); + + /* gather congestion related counters */ + cg_num = 0; + cg_status = 0; + cg_time = jiffies_to_msecs(priv->cgr_data.congested_jiffies); + if (qman_query_cgr(&priv->cgr_data.cgr, &query_cgr) == 0) { + cg_num = priv->cgr_data.cgr_congested_count; + cg_status = query_cgr.cgr.cs; + + /* reset congestion stats (like QMan API does */ + priv->cgr_data.congested_jiffies = 0; + priv->cgr_data.cgr_congested_count = 0; + } + + offset += sizeof(struct dpa_ern_cnt) / sizeof(u64); + data[offset++] = cg_time; + data[offset++] = cg_num; + data[offset++] = cg_status; +} + +static void dpa_get_strings(struct net_device *net_dev, u32 stringset, u8 *data) +{ + unsigned int i, j, num_cpus, size; + char string_cpu[ETH_GSTRING_LEN]; + u8 *strings; + + strings = data; + num_cpus = num_online_cpus(); + size = DPA_STATS_GLOBAL_LEN * ETH_GSTRING_LEN; + + for (i = 0; i < DPA_STATS_PERCPU_LEN; i++) { + for (j = 0; j < num_cpus; j++) { + snprintf(string_cpu, ETH_GSTRING_LEN, "%s [CPU %d]", + dpa_stats_percpu[i], j); + memcpy(strings, string_cpu, ETH_GSTRING_LEN); + strings += ETH_GSTRING_LEN; + } + snprintf(string_cpu, ETH_GSTRING_LEN, "%s [TOTAL]", + dpa_stats_percpu[i]); + memcpy(strings, string_cpu, ETH_GSTRING_LEN); + strings += ETH_GSTRING_LEN; + } + memcpy(strings, dpa_stats_global, size); +} + const struct ethtool_ops dpa_ethtool_ops = { .get_settings = dpa_get_settings, .set_settings = dpa_set_settings, @@ -227,4 +407,7 @@ const struct ethtool_ops dpa_ethtool_ops = { .get_pauseparam = dpa_get_pauseparam, .set_pauseparam = dpa_set_pauseparam, .get_link = ethtool_op_get_link, + .get_sset_count = dpa_get_sset_count, + .get_ethtool_stats = dpa_get_ethtool_stats, + .get_strings = dpa_get_strings, }; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/