Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755044AbdDLQ2n (ORCPT ); Wed, 12 Apr 2017 12:28:43 -0400 Received: from mail-bn3nam01on0047.outbound.protection.outlook.com ([104.47.33.47]:3920 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754816AbdDLQ0G (ORCPT ); Wed, 12 Apr 2017 12:26:06 -0400 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; From: Ioana Radulescu To: CC: , , , , , , , , , , , Subject: [PATCH v2 6/9] staging: fsl-dpaa2/eth: Add driver specific stats Date: Wed, 12 Apr 2017 11:25:35 -0500 Message-ID: <20170412162538.25302-7-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170412162538.25302-1-ruxandra.radulescu@nxp.com> References: <20170412162538.25302-1-ruxandra.radulescu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131364879404509030;(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)(39450400003)(39410400002)(39380400002)(39400400002)(39860400002)(39850400002)(39840400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(47776003)(8656002)(50226002)(54906002)(50466002)(77096006)(33646002)(189998001)(76176999)(50986999)(8936002)(7416002)(104016004)(5003940100001)(6666003)(5660300001)(305945005)(53936002)(575784001)(2351001)(106466001)(48376002)(2950100002)(36756003)(6916009)(105606002)(1076002)(8676002)(86362001)(110136004)(38730400002)(81166006)(2906002)(356003)(4326008)(85426001)(39060400002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0301MB1283;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD026;1:DEBAcwEqXhqYUWzX5PYtn/mCPkoznXuKPJe0P7Wy95PDmBZBAFgF3qYixKigCo3XR7k4dsQv74MKyp8X3AcHMtiUmCcPpikSq0Cq3USyhJF5BS6hvNckCLr6mbJjgEjRazrIMiVqHG0/J931oFremsYVLSv1z4amy2iWPWGm+GdfaTLuVe7/bjLsweLhprHk2Dc2acdJNF4kuMepRnaHBLjTybg01IILNnG6L+3e42G6QjDBs73JNhRFbyODOmuJ9IX45JY4lGCaE4EGCfgXhoa3OiOIu9/grnC8nj54RiC0sQYe7Lb+DfFJRe4Cq0sRJvVcyfTfRWNm2ZUM/dh/1FN0ads2xqkIXbqRAj4c7kcobNsys3eJF7a4u2fLAjSDZ8U9OV7/Y3DazHDdtCgB5qXiJP6SvZXsvETjvlcLwAJyi7L4DmR0NX9zU4x0v0KICR1iyyXYzIAk3auoXZ/Yjk9t51St84liLQRpIwL6P8nRAI/U0SWIs5z6+NplF29sdJKIZRrxlgcwxaWdmxD/42b/3MHBosBhhemyuabwfgST3qE+2PBGDTjlrG+rFU7X8sQ+TFo+PaEFIf3MLz6VUrdTuzhTdQmkwnlH13y1Q04idnwIVePfqR0bFD1XPx92Bo9kRSydZCo51TdHdZTnsBfYPThiHs4X8V0Dn28hEbG0MbF2+ZaouS50S7EYD4LF8DEfOO9106sdJrcwdNN9RbNAx2/zMsYWXBMGmpKFMiU= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: af10db4c-5b92-4dbc-2766-08d481c08f55 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030255120)(201703131430075)(201703131517081);SRVR:BN3PR0301MB1283; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1283;3:qS+G3NGlot/SWSM+e11K32/EWnLzFwdKEhBhp1b64EfF7U5+4oSU2NOm1y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GOYYbFBMYJE+uYIi9t6iLTiNlpBCdWZ9M5NtECYfn0Mk0PDgRzSjlu7t4hZQyClzWcqUOf4KruiIc8vHDSUfVTqFy2czil+1J5paH0cQX0cdl5NRvP2tPjgxTFLXLx2ciOmoQZg2hw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(8121501046)(5005006)(13015025)(13017025)(13018025)(13024025)(13023025)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123561025)(20161123565025)(20161123563025)(201703131430075)(201703131448075)(201703131433075)(201703161259075)(20161123556025);SRVR:BN3PR0301MB1283;BCL:0;PCL:0;RULEID:(400006);SRVR:BN3PR0301MB1283; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1283;4:5AxrRBVDlJvC6KZRMzaa7fwsyhjXlfN8TomyFLFC6/TjiETiWrjF2xwv+BCKFZDxst6HB7g/0Os/YjtJWqiniAsKayUBq3NrzqROqB5EfKM62L0oNExOwUIaVGrdk9llmrKxgMwj7oRUJX9ncL7ok3n3m7X+JPAU0rjIiXHOWj1EHDXfwMGZPXg6hpk7BBLlzebhoCfVuK2Bk4EM2m+TRpMxJx0M50kqLWOAJ+eP8K/qKBawZ163QL9/yhHqqashdoMc+T4q42Cip5UdNo71fRTh70d/91pee22YW2/2ZrZ0H0+T9XtK1SvDQ/D9Tg9FjG+nfOXFtEck9xqD/dRldQqV6vKLmtnPi08dy+743nnwxyFEOZULHwAzz6ujHHezKbs1DDBtbYEkN1Thv+Qjs1bQQDnX27M6E6gmROG4CKQvv0nEy6RpqBnaFKjmCKzsa1CfkwGOUTJh8iQUjBvXoRIKNcy4nr8q167yBLP+L4DVFwxRpEW+TDx5xRv4JsLRGGG2C6nDMETuyUp6hybCrzVWtu1kG2ML04Ok/4zxEP68svUy4ZFUUn1Pzb+ImB+Niw99SW7FgXET4b8bGESdQSnnhyAT94cU/x1e3XPJo3RbFfV9jZX5IRnOACxfrQGsg0Hx5y4mVvvg92v0Zvhll1mYumCuGMU7XLw3Qttn869zts6yAj0i1PNi7N/yxk8/L4Rf6IQNmj0EV6T6WK9KzgPumYg6zB1mZeyU+jUZz+srzdqqUv6pHK329pYG0dQ4ydwHSllgBLWXUzaMTHRtlBdYSfPfDdfS0H6VYEDTWZps3F5ypx9EKF+lV7HTWlSrv6+u2134AFWxlgkagaANerogHUsB9ZueOPnyqStpGBrCjSVdlrn31ovE9q1IsUfvDGeEPGf1J5mI8wDG0EqvjFbhQzGvtyAATXkvf+5b5Ec= X-Forefront-PRVS: 027578BB13 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0301MB1283;23:Dy5mYlhuxrUNwZ1xkqIlVWAH59ODNyVQiwvZjLh?= =?us-ascii?Q?7wSKg8KOXl9DkJ9ztXzUIeuTesSXYjVdcON5AxWVG2y85szIpcjLXzzVNjeC?= =?us-ascii?Q?SzV0qgreRrU76X11d5RVz2H7D8dx9Mb+a36kn9txhyr6I1I2X2MP8msK0/2c?= =?us-ascii?Q?DHIjRtNu5sNS0tdv6ZzneO47nx8fhcGON/c4AzcLXRdZJlSLi8I8uwwtIZvW?= =?us-ascii?Q?1YnjmJifL17qfvUy6JQHUTS5LMJTU107/6gl2X0UPATuF2bA4BJ+D0Bq4ey7?= =?us-ascii?Q?L/dKQ/VgJ0qrqa43rr1dd13qtGcjhsfzTYZfmxc9mSVn+5IUCWgsXYa3uKXu?= =?us-ascii?Q?9XZgrge10QYk0vI2uP168qtWk7QverDpyN69hJoGU7WNyZ1UbNLIcHpj+jPA?= =?us-ascii?Q?/wBSFW0mdZej3TDbQ00bk25D256xKdHxcVE8jSRsSWdBh3DMhbMpJrvHtxmU?= =?us-ascii?Q?wot2vwr0qVAayMjadgAlx5u4E7z1H/mENyOzB+DO7CPPsOoSSt/Ns3F4kowu?= =?us-ascii?Q?5spgQLXRIpj4pV604WsE2yiDiEt7NVCugl1AIDv0suTcR51vndzd719zQNHB?= =?us-ascii?Q?WP4tt5wevPzZBBJ8pgHPwmqbxkdoFL6JKA8mRuxq7j34M7dq2vSl6szMOwD3?= =?us-ascii?Q?g/73ekGuu9TuLy0SCFb4NaVFDfMDdadjSwla/QyXlU0rOfY8uYRb/KErSvN9?= =?us-ascii?Q?8mjI8NhnpSwKB7YHiEF2SStGIUjIbC7dnicVsjuumZFPtCemF5YC3BU+oBhf?= =?us-ascii?Q?BjG+kC74hviU6djMoNi23MPHIfMPXmRDBzKKQCPC3r3n0tCJ1mub4WnpOGeK?= =?us-ascii?Q?k6NKMDnfO8A30y7xzwr3aWMfrX9iMrIvycbnENJyFksfNUpOOy1omV1CPya6?= =?us-ascii?Q?9sGCESNJfbZjxuJJXVVQ0TfwmXu8HCfgeWvgr0kIbaE6csV570560fxKQyof?= =?us-ascii?Q?K9th3FwbHlqhW+U7CsWpRSEYQPRMKqUSjzcygOErCISBIsajlz0zrL++Tfni?= =?us-ascii?Q?rYX7rkQ4E0fhvW79xsAcklU8ZtEktjPMzHop+jYaOhaYy42i3mtJ1/+34rP9?= =?us-ascii?Q?ZoWMOwvtBlTxep48eU0k7J368l+57sRahhsa8RWlvJ0+9XwGaK3RC7+zvxLj?= =?us-ascii?Q?+LMks9AmY+U+ndjrDmWSE+TojCgqSQuC2BX9I7AjligSq3J7EqfMFHUWQxjb?= =?us-ascii?Q?x9RSQe9iJPg1LRmSpj4gMWIOG3Q84w4JvfrcTbBjrPNCN85aiVy12a8lL6iL?= =?us-ascii?Q?pUhFsikVLSIDHKOL/LpT2WKAxHHdiCi1QQgsIBcQ/Oq4rI9XyCMhzm05GpY8?= =?us-ascii?Q?va6StnpcDRZc3R2mI2qDjypA=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1283;6:2WLLdy/5UrLYmCEN8qhMRNp60+y18iCfr/uxvsct2dK/VY9L968ROZjk2ivdk81vtTuRH4aDGGE1AZ9LnfIY+YHza2xDzl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xyao0zq4iu4GD/jrDniDNCFP9RfjSPzjwXJHM6ycQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2017 16:25:40.1857 (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: BN3PR0301MB1283 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10323 Lines: 333 Add custom statistics to be reported via ethtool -S. These include driver specific per-cpu statistics as well as queue and channel counters. Signed-off-by: Ioana Radulescu --- v2: no changes drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 42 ++++++++++++++++++- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 36 ++++++++++++++++ drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 49 +++++++++++++++++++++- 3 files changed, 123 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index f13f72f3dd9a..67f007bdbe79 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -208,6 +208,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, void *vaddr; struct sk_buff *skb; struct rtnl_link_stats64 *percpu_stats; + struct dpaa2_eth_drv_stats *percpu_extras; struct device *dev = priv->net_dev->dev.parent; struct dpaa2_fas *fas; u32 status = 0; @@ -219,6 +220,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, prefetch(vaddr + dpaa2_fd_get_offset(fd)); percpu_stats = this_cpu_ptr(priv->percpu_stats); + percpu_extras = this_cpu_ptr(priv->percpu_extras); if (fd_format == dpaa2_fd_single) { skb = build_linear_skb(priv, ch, fd, vaddr); @@ -227,6 +229,8 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv, vaddr + dpaa2_fd_get_offset(fd); skb = build_frag_skb(priv, ch, sgt); skb_free_frag(vaddr); + percpu_extras->rx_sg_frames++; + percpu_extras->rx_sg_bytes += dpaa2_fd_get_len(fd); } else { /* We don't support any other format */ goto err_frame_format; @@ -291,6 +295,7 @@ static int consume_frames(struct dpaa2_eth_channel *ch) fd = dpaa2_dq_fd(dq); fq = (struct dpaa2_eth_fq *)dpaa2_dq_fqd_ctx(dq); + fq->stats.frames++; fq->consume(priv, ch, fd, &ch->napi); cleaned++; @@ -532,11 +537,13 @@ static int dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) struct dpaa2_eth_priv *priv = netdev_priv(net_dev); struct dpaa2_fd fd; struct rtnl_link_stats64 *percpu_stats; + struct dpaa2_eth_drv_stats *percpu_extras; struct dpaa2_eth_fq *fq; u16 queue_mapping; int err, i; percpu_stats = this_cpu_ptr(priv->percpu_stats); + percpu_extras = this_cpu_ptr(priv->percpu_extras); if (unlikely(skb_headroom(skb) < DPAA2_ETH_NEEDED_HEADROOM(priv))) { struct sk_buff *ns; @@ -563,10 +570,14 @@ static int dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) /* Setup the FD fields */ memset(&fd, 0, sizeof(fd)); - if (skb_is_nonlinear(skb)) + if (skb_is_nonlinear(skb)) { err = build_sg_fd(priv, skb, &fd); - else + percpu_extras->tx_sg_frames++; + percpu_extras->tx_sg_bytes += skb->len; + } else { err = build_single_fd(priv, skb, &fd); + } + if (unlikely(err)) { percpu_stats->tx_dropped++; goto err_build_fd; @@ -583,6 +594,7 @@ static int dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) if (err != -EBUSY) break; } + percpu_extras->tx_portal_busy += i; if (unlikely(err < 0)) { percpu_stats->tx_errors++; /* Clean up everything, including freeing the skb */ @@ -608,8 +620,13 @@ static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv, struct napi_struct *napi __always_unused) { struct rtnl_link_stats64 *percpu_stats; + struct dpaa2_eth_drv_stats *percpu_extras; u32 status = 0; + percpu_extras = this_cpu_ptr(priv->percpu_extras); + percpu_extras->tx_conf_frames++; + percpu_extras->tx_conf_bytes += dpaa2_fd_get_len(fd); + free_tx_fd(priv, fd, &status); if (unlikely(status & DPAA2_ETH_TXCONF_ERR_MASK)) { @@ -814,13 +831,19 @@ static int refill_pool(struct dpaa2_eth_priv *priv, static int pull_channel(struct dpaa2_eth_channel *ch) { int err; + int dequeues = -1; /* Retry while portal is busy */ do { err = dpaa2_io_service_pull_channel(NULL, ch->ch_id, ch->store); + dequeues++; cpu_relax(); } while (err == -EBUSY); + ch->stats.dequeue_portal_busy += dequeues; + if (unlikely(err)) + ch->stats.pull_err++; + return err; } @@ -868,6 +891,8 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int budget) } while (err == -EBUSY); } + ch->stats.frames += cleaned; + return cleaned; } @@ -1320,6 +1345,10 @@ static void cdan_cb(struct dpaa2_io_notification_ctx *ctx) struct dpaa2_eth_channel *ch; ch = container_of(ctx, struct dpaa2_eth_channel, nctx); + + /* Update NAPI statistics */ + ch->stats.cdan++; + napi_schedule_irqoff(&ch->napi); } @@ -2345,6 +2374,12 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) err = -ENOMEM; goto err_alloc_percpu_stats; } + priv->percpu_extras = alloc_percpu(*priv->percpu_extras); + if (!priv->percpu_extras) { + dev_err(dev, "alloc_percpu(percpu_extras) failed\n"); + err = -ENOMEM; + goto err_alloc_percpu_extras; + } err = netdev_init(net_dev); if (err) @@ -2387,6 +2422,8 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev) err_csum: unregister_netdev(net_dev); err_netdev_init: + free_percpu(priv->percpu_extras); +err_alloc_percpu_extras: free_percpu(priv->percpu_stats); err_alloc_percpu_stats: del_ch_napi(priv); @@ -2425,6 +2462,7 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev) free_rings(priv); free_percpu(priv->percpu_stats); + free_percpu(priv->percpu_extras); del_ch_napi(priv); free_dpbp(priv); diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h index b30231891eef..f2b0a60795fe 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -197,6 +197,38 @@ struct dpaa2_fas { */ #define DPAA2_ETH_ENQUEUE_RETRIES 10 +/* Driver statistics, other than those in struct rtnl_link_stats64. + * These are usually collected per-CPU and aggregated by ethtool. + */ +struct dpaa2_eth_drv_stats { + __u64 tx_conf_frames; + __u64 tx_conf_bytes; + __u64 tx_sg_frames; + __u64 tx_sg_bytes; + __u64 rx_sg_frames; + __u64 rx_sg_bytes; + /* Enqueues retried due to portal busy */ + __u64 tx_portal_busy; +}; + +/* Per-FQ statistics */ +struct dpaa2_eth_fq_stats { + /* Number of frames received on this queue */ + __u64 frames; +}; + +/* Per-channel statistics */ +struct dpaa2_eth_ch_stats { + /* Volatile dequeues retried due to portal busy */ + __u64 dequeue_portal_busy; + /* Number of CDANs; useful to estimate avg NAPI len */ + __u64 cdan; + /* Number of frames received on queues from this channel */ + __u64 frames; + /* Pull errors */ + __u64 pull_err; +}; + /* Maximum number of queues associated with a DPNI */ #define DPAA2_ETH_MAX_RX_QUEUES 16 #define DPAA2_ETH_MAX_TX_QUEUES NR_CPUS @@ -224,6 +256,7 @@ struct dpaa2_eth_fq { struct dpaa2_eth_channel *, const struct dpaa2_fd *, struct napi_struct *); + struct dpaa2_eth_fq_stats stats; }; struct dpaa2_eth_channel { @@ -236,6 +269,7 @@ struct dpaa2_eth_channel { struct dpaa2_io_store *store; struct dpaa2_eth_priv *priv; int buf_count; + struct dpaa2_eth_ch_stats stats; }; struct dpaa2_eth_hash_fields { @@ -275,6 +309,8 @@ struct dpaa2_eth_priv { /* Standard statistics */ struct rtnl_link_stats64 __percpu *percpu_stats; + /* Extra stats, in addition to the ones known by the kernel */ + struct dpaa2_eth_drv_stats __percpu *percpu_extras; u16 mc_token; diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c index 4378956a5527..dd0cffa908ef 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c @@ -56,6 +56,23 @@ char dpaa2_ethtool_stats[][ETH_GSTRING_LEN] = { #define DPAA2_ETH_NUM_STATS ARRAY_SIZE(dpaa2_ethtool_stats) +char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = { + /* per-cpu stats */ + "tx conf frames", + "tx conf bytes", + "tx sg frames", + "tx sg bytes", + "rx sg frames", + "rx sg bytes", + "enqueue portal busy", + /* Channel stats */ + "dequeue portal busy", + "channel pull errors", + "cdan", +}; + +#define DPAA2_ETH_NUM_EXTRA_STATS ARRAY_SIZE(dpaa2_ethtool_extras) + static void dpaa2_eth_get_drvinfo(struct net_device *net_dev, struct ethtool_drvinfo *drvinfo) { @@ -147,6 +164,10 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset, strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN); p += ETH_GSTRING_LEN; } + for (i = 0; i < DPAA2_ETH_NUM_EXTRA_STATS; i++) { + strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN); + p += ETH_GSTRING_LEN; + } break; } } @@ -155,7 +176,7 @@ static int dpaa2_eth_get_sset_count(struct net_device *net_dev, int sset) { switch (sset) { case ETH_SS_STATS: /* ethtool_get_stats(), ethtool_get_drvinfo() */ - return DPAA2_ETH_NUM_STATS; + return DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS; default: return -EOPNOTSUPP; } @@ -171,9 +192,14 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev, int j, k, err; int num_cnt; union dpni_statistics dpni_stats; + u64 cdan = 0; + u64 portal_busy = 0, pull_err = 0; struct dpaa2_eth_priv *priv = netdev_priv(net_dev); + struct dpaa2_eth_drv_stats *extras; + struct dpaa2_eth_ch_stats *ch_stats; - memset(data, 0, sizeof(u64) * DPAA2_ETH_NUM_STATS); + memset(data, 0, + sizeof(u64) * (DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS)); /* Print standard counters, from DPNI statistics */ for (j = 0; j <= 2; j++) { @@ -197,6 +223,25 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev, for (k = 0; k < num_cnt; k++) *(data + i++) = dpni_stats.raw.counter[k]; } + + /* Print per-cpu extra stats */ + for_each_online_cpu(k) { + extras = per_cpu_ptr(priv->percpu_extras, k); + for (j = 0; j < sizeof(*extras) / sizeof(__u64); j++) + *((__u64 *)data + i + j) += *((__u64 *)extras + j); + } + i += j; + + for (j = 0; j < priv->num_channels; j++) { + ch_stats = &priv->channel[j]->stats; + cdan += ch_stats->cdan; + portal_busy += ch_stats->dequeue_portal_busy; + pull_err += ch_stats->pull_err; + } + + *(data + i++) = portal_busy; + *(data + i++) = pull_err; + *(data + i++) = cdan; } static int dpaa2_eth_get_rxnfc(struct net_device *net_dev, -- 2.11.0