Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425645AbdD1JwK (ORCPT ); Fri, 28 Apr 2017 05:52:10 -0400 Received: from mail-sn1nam01on0040.outbound.protection.outlook.com ([104.47.32.40]:21984 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1423902AbdD1Juj (ORCPT ); Fri, 28 Apr 2017 05:50:39 -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 v3 6/9] staging: fsl-dpaa2/eth: Add driver specific stats Date: Fri, 28 Apr 2017 04:50:31 -0500 Message-ID: <20170428095034.8842-7-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170428095034.8842-1-ruxandra.radulescu@nxp.com> References: <20170428095034.8842-1-ruxandra.radulescu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131378466365987453;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(979002)(6009001)(336005)(39410400002)(39860400002)(39840400002)(39380400002)(39850400002)(39400400002)(39450400003)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(8676002)(6666003)(50226002)(48376002)(6916009)(2950100002)(81166006)(36756003)(356003)(7416002)(47776003)(8936002)(5660300001)(2906002)(76176999)(104016004)(5003940100001)(50986999)(86362001)(305945005)(33646002)(39060400002)(54906002)(575784001)(4326008)(1076002)(110136004)(38730400002)(53936002)(189998001)(85426001)(2351001)(8656002)(106466001)(105606002)(77096006)(50466002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR0301MB0600;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;MX:1;A:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD010;1:7yrqBXEUbS9hmh+6XVGmK+OjIOOMKB5bzyKG47sNtH6MXt3qyaXASKprehv/m36bWcgOHj/K+SomODFiRloOjE0r1tbZXIk7XkHmkVZcXJk/jrb7zJ6FmGnvaxJVeN16TE7tOVqa81Ii/NqojHL85stE4LnXxSHqQqYSixuU8cbvCPi6/pH5cLcb8fyEKjL6eKnbnca+mXpkqdhgmQ7f6JWTm2HF1CpR+Ttsgpa2xklpOX55xIOwFApa+ulNWlgtfSo5PxX21pLRo6VNsNLSY+T1gp5TxXM4DRis++e4EXgXjojDZbu5JSEA8ZDHG+DA7RNVF2EkEQzQgY3oPIdu8Q+MFtoYE+Aq1d0/8aE6y+1j02P992JxRGGoXzdU0ZCsW+qLyXuL//X9CxY5ezteYMsO8Tei4LXy7XaG19umdpR2AFSNOQYcL7XzI11D1j0d0WxUjhcnCe7UCgNsyxDf4wMoa2drgYueae0sGiEbXI7SDJE3auZi+0jYKmCTmdgtZ8IH5MSnpV/j2snJKRf2UbPFx8VKuOH3zqveGVewZrQz3zIzEI8aVGec/cK755n2hihVu/QMkJHDI9InNmWVuJCy+Jt3yaHa7khzH/BUAyAjfyHlB1rJdnsVt73jrXAaq7scX+BvwIOe1jV4P3H/6wbZozVw778GhJCagfU6ldfMl/8uJLK3mMH/fkRwgsu6RJWNZ4GmS8Pgfy+g0sL8ZxEpLgLBbRoTI7cSQz9LW+U= MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42fcbc07-1ba8-4529-f91e-08d48e1c0555 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:BY2PR0301MB0600; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0600;3:aaUda6IS4kJe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zdcOAK+geZvGs9h4E07QT16G0yEdPeGd41tGPg5dZSJ+mv/uYsUSzdEMin/K+Jg7b6nVnhw4t8xSTHVgLwHe6QIfAy2+XzuBs0Wh4FlQ/s9dqKaW5L4p1mLKBf4VRIRVtIVkt781QX4HnvsmUX7jVsmHGl9H0jSY57yqAHBCl4= 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)(13015025)(13024025)(8121501046)(13017025)(5005006)(13018025)(13023025)(3002001)(10201501046)(93006095)(93001095)(6055026)(6096035)(20161123563025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123565025)(20161123556025)(20161123561025);SRVR:BY2PR0301MB0600;BCL:0;PCL:0;RULEID:(400006);SRVR:BY2PR0301MB0600; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR0301MB0600;4:iPHlOwVBX7pALP2N7YirzKOWruxCIlSXyvyU7InW?= =?us-ascii?Q?YEazdrCMW656uv9ZGkxFT+Q351yrFSyqPL0zVg8FnjMHyzwT6yxJHwcqJ3VO?= =?us-ascii?Q?m+kn3jJRG74XTCK+KT5gpv14q0klvolMlk62IGdaYE9gtkAWvLHyFwG5QdCW?= =?us-ascii?Q?wJNDJWffGDtfIeO32YiWW5a2E8/BjE1yOLF2UHW4X87/rKTmUbtODm0fV/h1?= =?us-ascii?Q?T4yp4DlfkrZJsFiGoSNX5zBkkzz3Z90a/9Xn0lS1BsQsFOaVB/hWaYuAy4Tc?= =?us-ascii?Q?9rwZZ+mUAg97EKxmA4bdtk6TvTMBC2Bb+RviLIcOzX0N3qAcx1ge3C8HKiv8?= =?us-ascii?Q?3l1uStOkMU3Nl1rcE57d4C6i574RqCk/b2+ywy6f5GKA7B2/BOJiadkBbNDy?= =?us-ascii?Q?/bOwzB9NXjXCqX02FCMaN1lItuitS/VpOi2A7NcNP2xDEO9FzP9g99GX5zaw?= =?us-ascii?Q?bIuY+qBs4gfh1xO3XY4dVreURK+1VUTGxlISTAdC5iq5RalalMacsgfGWfoN?= =?us-ascii?Q?loHa5E4U/pLq2U+uuk5TnZUIc6LOIDyoOnYd/2HqOmaeDamAaMX+qsCi45OH?= =?us-ascii?Q?Jt9wYyooyz7cBFbao9ASWIt1VXkXl+d4kkOgrRv0Dg3313eeVISiKAtXYwBq?= =?us-ascii?Q?j/jsszb+nIZlDGXxgIDhMyynvQaMnDJ7K9mMxk8EtBlsiuXJDI3sce0/e2Kg?= =?us-ascii?Q?jn6hql1WDW3+F+RCVZrIDtzq1gRmDQzxainR4U+iUzCUtPPwXl2sfLPR5oW2?= =?us-ascii?Q?HyraWjd5Ji/UOAa0CkpU+FJT2bQNbL47r+HH/AnbKsds0liCfXnv1oPSdvjZ?= =?us-ascii?Q?9+/Cac2ncKqtvL2YXcWD0GCPMCeAGtZ9A4olBTvu3rcu+1Bn05tVR+XxXZXp?= =?us-ascii?Q?dS557FhTVWkz+ZpyrfDj7RLqGPWA9rSPscCMhR43wJ/G/UpAag6Jq7vfVBL4?= =?us-ascii?Q?Vn4+PLMfKA8KdGQxguYf+Bue9hSg4E1MbDsiEfPfbg=3D=3D?= X-Forefront-PRVS: 029174C036 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR0301MB0600;23:X2nQbEraLWpGCWZpdsa4w+PWSDU/0l+9rOOh4XY?= =?us-ascii?Q?/gDg+VK1MxtZ4KQkq5/nRt59kP/KyWGFamHfA4T7q7fjwNG9yJpOotfk9BO4?= =?us-ascii?Q?tAfJfArvrWv8BjNtjSdtYZMHq4yweT/CEX3URgAJjrprGodFDeYZvHqJ99HM?= =?us-ascii?Q?SF15AZZGnd6KluYMK/ROoyaAnFeoj6DEBJZBW6PZxm1Rs6MQbXvUYLzpHv0H?= =?us-ascii?Q?YeoA8J40eidCRtu8RbyYrV7aogH9hby2phOOHGRWwVRlr+OtDPzBHxV/Eb1Y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nZIa2kNE/;24:3950r+g2xqk93Q4ybxKNA3GFKBRvXnsJAzphXMbcqlYAY6+Q2Xn/ozpRZ36WfozzB2VEQs/c8ItwtXwpVGt/QcNtzR05Rg9vLD7uLLD9n3o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0600;7:4psFILfKq+B/KlE0ZW3Df0aX76hbftaTia0Fv/F/WTJg4TkWoJ1vVFePtEb1zaJIfb/ra31IHjWLCzWMbvh5OgS761024Rv1jWWysHSl95C52w7yWx+B9Xsp/fe7g9T5/kELGDFBSz4MfjvPzkqf/h15qEFDGCHd/yZKEH117iDmPfR3Cy0l6p3DgB2+a6TFSfuImORIE1R/+AouamrzIgGawzJiPUIlTbjJ59A2WXedYSYtwt1jk0MrUnpsxSqS4t6p05IFYZa7ePAFqDijuAzr07isnzYjCAS+SQHQMlHs0WRkUDVIU7emQNBRxMHyeipA4Ex/8Sk2EvMuQUBC9w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2017 09:50:36.3335 (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: BY2PR0301MB0600 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10338 Lines: 334 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 --- v3: no changes 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