Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760143AbbLCLQU (ORCPT ); Thu, 3 Dec 2015 06:16:20 -0500 Received: from mail-bn1on0075.outbound.protection.outlook.com ([157.56.110.75]:44832 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759051AbbLCLLn (ORCPT ); Thu, 3 Dec 2015 06:11:43 -0500 Authentication-Results: spf=none (sender IP is 192.88.168.50) smtp.helo=tx30smr01.am.freescale.net; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=; From: <> To: CC: , , , , , , , , , , Madalin Bucur , Ioana Ciornei Subject: [net-next v5 6/8] dpaa_eth: add ethtool statistics Date: Thu, 3 Dec 2015 14:09:04 +0200 Message-ID: <1449144546-25438-7-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1449144546-25438-1-git-send-email-madalin.bucur@freescale.com> References: <1449144546-25438-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Matching-Connectors: 130936147001859877;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD042;1:1iLOFqwFkPQwCUGakdsVuzHXmVdGxIUZHHVZ2NErYCsHaJ3MNI0vWZuAPqp4ph5HyRtJ1q3NMz+7dN/lVzUANSOU6swPro3Gmi3GxL/ZysMoAEEV8sRSiA7xRGxYwc2f3PnAbIqYF8XMlo0jymC5YauxRkMMPBhCF1NRNFNH8u82g77w8PZN9aawpQDtD2jDLbG/thu9sFtiW/bJ2yFd3KTp2aQJma389J7b1IMt806MVI9gPFegkiFGrbIoQ+2e9n2cph+XTYHohqK91I6ZnsGFnaIH0mIg/hLbuhE0kJ0mHP284qxEnY+YoK+MKu/l/Anj1OK+9XxhiQQAG66hMQVCYC3pDGDTrgb3+JlNybAR1jP+hHlSYE6TPEVd22/pbbHRyabBTTCRR7McsveHlImGKXGkdFDuiE2EdfpinS7tp8iowO85aHWCO9r7p/3E25JMl8lFqfc8/Hz/u0YoCrpC2+cktgQB913YWUdAt6c= X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2970300002)(428002)(199003)(189002)(960300001)(104016004)(5003940100001)(4001430100002)(106466001)(6806005)(5008740100001)(19580405001)(19580395003)(47776003)(87936001)(33646002)(49486002)(2351001)(50466002)(229853001)(189998001)(5001960100002)(110136002)(575784001)(107886002)(78992003)(5005630100001)(48376002)(586003)(43066003)(50986999)(1096002)(76176999)(36756003)(53806999)(1220700001)(97736004)(77096005)(50226001)(81156007)(105586002)(101416001)(2950100001)(60522002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0301MB0897;H:tx30smr01.am.freescale.net;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:0;MX:0;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB0897;2:5i67R+HnlkGhy6AtBENCKnje1Tcplfg5b5gZRmaX9ue4rPQ+PWAAVN/LuUUdhXwOcFZ4pT46hOLXVcUBUUYJbLu1/P79GbvTLzQZFC3Pke0/DnPFsBpq4TdgVkURGMy0hSqbpMboac79lCQtYS+93g==;3:7dodN6CR8DQegGCvjhnNXLOccFZ/q2OkfQx3BcjbpfSUS1b8RwDsvwEDmCES5eV8liCb0LTAmHvw/mx8uZjscD7Kj1K0WDRDct7xxJVsdh3c4MW1xUQ/0STnzDAPuvb5DFrNyJIQ+0O634sfvMGAZPmEjMLtsqLb05Ceoj8PM1/oK8gMwnnu590dYdawS4TPAq4TbphJNbzKxRQr53xBPX9879/zquFqdY6OHyKDcaQ=;25:+WqpxJ7yy0+gUcJunAQ2/0vdT2LpFxpG6z/KeARxHerCd3HCt2vw78csCXFtT1+Bg1c5H04eqNBZdJIV6EfTuh68Me2MVRXZng/Eku9FUOBpr2pIThmjQnX7pEsitiUmFSQHrMMkD6Xmu2fh4lo6sl5pSsG45uSpSTtKgZlY4IvRmeVUDHQed3Way4sCqBOFdtdcIpySzatxtelNwKGW67u6IIL6KHQHTjW/tGNyqbjDsuoQOKzvtKhZMdcE87xJ1px1iUR6NOlu76EGu4S8Nw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB0897; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(10201501046)(3002001);SRVR:BN3PR0301MB0897;BCL:0;PCL:0;RULEID:(400006);SRVR:BN3PR0301MB0897; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB0897;4:Xh4NT4SR7gQy8mL8IqXicLKARy6qdb273l99yDbngNawcdg9VU7VwMQVq6c4Mcn/bwpvCkemiJ/72o/O8VY6ZehQIEY7O2H8jW6EpLJAHkLqEX2Vx8m19+cmDAjBI/7PV3plx2u/BP+eHgmAwAU5YwRiRh3AYyxmRmQxsk76AsslMw4ohCKg3SeMDL4bqLlhLlHCzWZmVt/oFc5anWsxOX0rHHvoX5SN8GNITwpE8DtVATVFLt601jxUCY1XKcpZyPLxJWikiz2SAWiWx6znoCnm2zB0hYrpnzzrBTHyazMPqlr8uPZ4onzP/L79ZLrOrrPvbQG5GtvxAhtdkIH6wtzyVRSioZDTpSgXe5wwv/6jWztg/AaoZdqUEkXH2o8+7BhCrxVLQUFfKtDfMdWqVRUnSE1xfr8GlhhNxvMpLdmfcdSNp3yZgVOpH3JS4kwk X-Forefront-PRVS: 077929D941 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0301MB0897;23:yadvOTj2uWb+eRTABMCGqzwSB6luUmLImAp1yNE?= =?us-ascii?Q?fs3KTgsO+d+Q2PC7K9YlJZz9uRXsvdnbQAZKTV8ENBR5Jus8837Lk9AxPfTH?= =?us-ascii?Q?5KG9Tqx/aUfMbirTUJxNRTc52GGgSSGuA6jtk3+h+l2IrBBjf4/CtWI6hykh?= =?us-ascii?Q?h5nvu+ebBTwquJPOD9SHtUJd1vDBRX7X+0YXJ9EJ+cqtIEBuHkLIuPGKzLQe?= =?us-ascii?Q?duEk4raP5Q4HaF2nKT1v3L360Wyk9Nhd0vBSeAiXLoVZY1/PXSSkr3C1EaYq?= =?us-ascii?Q?DRDhGTVLMY7t4lllt2ON/Lkg3mqQ77s8pVDLG+KeExiMRngT55CRT0ip2XYd?= =?us-ascii?Q?nf5mEeEgf+OUk69XoTelwkdeT3IU7wKW8qZlLX5ekCYWTsqwjN8LokqmzmHS?= =?us-ascii?Q?krxyHIIC1JU/JtZdc8t9A6hiR1kvlF2wdbk+BEdwEb2W1v7SIlf2mfpZCT45?= =?us-ascii?Q?wpagaLchH3d7Zw4lUF2CgCpOqBPLD+gZlX4L7zox11x4uoZ26olW3HGHQWME?= =?us-ascii?Q?SIUM8v6Z8Viu1jmwAltniKKzqVUqrkxSbXLVfnJ1UZlc/vJ/dHEm5FVJGWeA?= =?us-ascii?Q?deoHM1Uq+xl4aCmW02zs/oGc/uADbCjdZgn+LZqmz6LBR3xdPXceR4pllLGP?= =?us-ascii?Q?ysfkBoeSJ232sfhELDqWwbRrV5TuLynZ+o9Z2+qytvaVCnxMEXfyuhIn3LG1?= =?us-ascii?Q?K3nAW2CmulbUIiHgUyzwAigmRUCaZU7I97fr8lYIaXtrVWz5FlSkO98nULys?= =?us-ascii?Q?GYksNWbokIBJuPluaDndjnczcP4CpgD0lc0rAWpZw5Xf4ueIGWOBckh1CI7L?= =?us-ascii?Q?6biooFBc01JuL6OJlnJoY1etQvOpotlIJ8BDIyGMAMnmFSr+iN282o7COata?= =?us-ascii?Q?AQh8okeEl4iKGqj12PLKOhQV+a2eSX8Xy70iqlZg/i2j5lFQsl/l22/WSt0Y?= =?us-ascii?Q?olSsZq44PRFuOCpAEr8AW0pE8Yz6idTSvz1hKRN30PjlHIvTwO4FKP+Knq8i?= =?us-ascii?Q?aqIivkOHFGHAkgL7sXugBCViV3dhkx9jt+Fi1QZ6U9ODSJg3MXOjjTBmi1Jr?= =?us-ascii?Q?X3CNnXlhE0Dai+slTt9Ws3KsiXd+JmXcn9a6ZCuHUIKHJIyBZtWg4bHJaJeT?= =?us-ascii?Q?VCP8ebGrjx6Ijw5xGNKVeUlJ9QW+dZ/Jr6JUZBDfN15G8DuNidf1vFmINqVm?= =?us-ascii?Q?mzDbirylhBp+NRdg=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB0897;5:gwGMplblttF6NOjY0sZwm0g+86PVjAvcHXe0+TnsqOWlSDreStxFOwyDSBSt/QV2538W+ZJ6OJtTzkUIzzch6Mk/4qyERJE4ChbG3S8d9p1wslm9q6x5GbvO805kwndcU4VgsEtviXi8Qkd8v9z0R9W2Vml+Rzs7iadD35bn8oA=;24:QrbUjbjVlUfh/npVrcpLRBavUeHEKT9uO3x06Dn+QdKuadQmVzzThAsnVJ88WSxdribdJ4VGABPxrJyo2EnMSjmNo4ETZs4/FprGQtJ4EzE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2015 11:11:39.9831 (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: BN3PR0301MB0897 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14383 Lines: 425 From: Madalin Bucur 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 | 184 +++++++++++++++++++++ 6 files changed, 271 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 6c16ddd..f71a0d2 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -93,6 +93,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); } @@ -158,6 +167,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); @@ -287,6 +298,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 a990c7b..076d66a 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h @@ -183,6 +183,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; @@ -192,7 +211,13 @@ struct dpa_napi_portal { struct dpa_percpu_priv { 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 { @@ -219,6 +244,14 @@ struct dpa_priv { * (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; @@ -276,6 +309,7 @@ static inline int dpaa_eth_napi_schedule(struct dpa_percpu_priv *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 656c5a8..2a7cff2 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c @@ -767,10 +767,15 @@ static void dpaa_eth_cgscn(struct qman_portal *qm, struct qman_cgr *cgr, struct dpa_priv *priv = (struct dpa_priv *)container_of(cgr, struct dpa_priv, 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 *priv) @@ -1274,6 +1279,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 *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 8564bfa..93b4717 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h @@ -99,6 +99,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 *percpu_priv, + const struct qm_mr_entry *msg); int dpa_enable_tx_csum(struct dpa_priv *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 5fbc167..436e277 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c @@ -653,6 +653,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 ebf049f..274c484 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,150 @@ 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 *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 *percpu_priv; + struct qm_mcr_querycgr query_cgr; + struct dpa_rx_errors rx_errors; + struct dpa_ern_cnt ern_cnt; + struct dpa_priv *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; + + memset(string_cpu, 0, sizeof(string_cpu)); + 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 +408,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/