Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753171AbcLFJgA (ORCPT ); Tue, 6 Dec 2016 04:36:00 -0500 Received: from mail-bl2nam02on0049.outbound.protection.outlook.com ([104.47.38.49]:38592 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751752AbcLFJfG (ORCPT ); Tue, 6 Dec 2016 04:35:06 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=fail action=none header.from=nxp.com; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:849;Count:10 From: Ioana Radulescu To: CC: , , , , , , , , Subject: [PATCH 5/8] staging: fsl-dpaa2/eth: Add driver specific stats Date: Tue, 6 Dec 2016 03:34:39 -0600 Message-ID: <20161206093442.11362-6-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161206093442.11362-1-ruxandra.radulescu@nxp.com> References: <20161206093442.11362-1-ruxandra.radulescu@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131254904841641763;(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)(7916002)(2980300002)(1109001)(1110001)(336004)(339900001)(199003)(189002)(97736004)(8676002)(39400400001)(39410400001)(39450400002)(77096006)(39380400001)(39060400001)(38730400001)(7416002)(5660300001)(33646002)(81156014)(8936002)(81166006)(626004)(86362001)(5003940100001)(50226002)(85426001)(39860400001)(39840400001)(39850400001)(47776003)(104016004)(68736007)(50986999)(36756003)(48376002)(4326007)(106466001)(2906002)(1076002)(189998001)(92566002)(2351001)(356003)(305945005)(76176999)(8666005)(7846002)(105606002)(50466002)(6666003)(6916009)(110136003)(2950100002)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2478;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD005;1:WGK6u6EA7mEzy7l38tN/57banPsrzM3RB1H9yWHrW9sVruTm9tqjhMZ1G19LljTXVhs5Yhv6Fpown4lsSNns0LVYX9asuH0LseHWTqXNHdrzj2MM5WE+8picYS+Z5kJSNoiDteYI0Nnw3HtfRs/5q+C55zYtDdJcKbCmKeK1lIXOXufcgXGOfSE7uGAje87BeFtMf2yW5npEB6SFhzBwug9meOxNxjJgHhJWjNsHt68u3fZ9Oqx8unxsS5CgbSw2OofX9f8HIRtzPz1TeYKyIL/58/233b4k/ASuep/fTgYAcuPe8LYEMt2hn8qglzwhwzRqyoxmBP0TGaetsbSgvLixTt+A5GmJudzNLK4FcvpuSk6i9r4XqL+SYVCABUqWiSl1IOv6RP+pmcuB9/lhrOCM6IZ7nzLg7psIymwbp1NZgnxnuiFJ9NrbFrFgstHm+bMEPLhwuxB+wiN/VQSMb0JYMPE6SDouPS1Lq2yiRvsCn5en9KEcZsxXMHBIAYqpECMiCmJgK2thQuf0SwCq0AZkNGzhho49rTZFifnFW9idDT6rhMesQajNu3KWA7VQH86OkaBNGaWnb2iHgmSA7FKmkYduArj3X8nOOrb03ip7RiO1ztTnQs3auN/UBnwJ MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 48f97705-e978-4987-141b-08d41dbb1c81 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR03MB2478; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;3:nFb/AuHe3Cu70d5zV/RHfvKhu3Don8qriNlSGAB12t4aXLJ8OiIxUfwLlFtp+c3fQhbRffPOsU2ndzYSFnB24QOlJjBkoJK9NxKpo1n0+OysUiooG1XDx90EQnZ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TUGPwU0ENhmhfHAqFNGFH4wWQ3drrtKx8gdhg= X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;31:EbSPZJ4FwaiEuzYHi+Qs1oH/BCCHcApX7jt4N/LXC7UsazhXsg5+zI0i9SGzizJO351vXibJqjSVGjOHMQLSnQL3a10yZQYLSCpoSjL9q8Q1XjlJRyAsFGEAN9mhM7JRm6isClsgQ4UAU1oZyxXVjGuhsLpVgL7OFTvbQdrllI8fdFIzyuIVWRZj/13O/ShAVd2gnACPRUywQrWyeXRQnIA0tFrxw9Wxs17krOokqmi5jPoyS1MycGU//cFZ6Y0klMlfwTRCtyNj89UxRVN9spA5SW44uslPylu6bA8jSwI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095060)(601004)(2401047)(13017025)(13015025)(13024025)(13018025)(13023025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123556025)(20161123561025)(20161123563025)(20161123565025)(20161123559025);SRVR:MWHPR03MB2478;BCL:0;PCL:0;RULEID:(400006);SRVR:MWHPR03MB2478; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;4:8nY1a1SFexqkh01MWUumJFDO11lRxdDOxgb8JkCkT9+olLKbq75WoSam2dSOSTaBOqiQQWFpNUn4JfPdAHvriGfMZTz4ZT8HXB7PIeGLDxogYFrYNyExh9iYN2T8Ocy9fqV0LYL0NkAIXNVwG/KJNh1TafG5snQMCUustGT2oL36pRp3pusyzaaw2JCM5xQ72s41/9PvdRju2ClGmI+GaWVFq7H2Pt2rR5ihWChHrPbS2OTE5r+PwTXLtz1NswO9ej8GxNacgTU0whQgCMcDSxhuviWnmFybLuqBJ/i88ATSk2clNSca3pR83GesUnUdDuQF8L0x/EgIu9qhiuf7wpYQ0DtJ3oTf/qnL52NcQdloO64QnLoFmPp+lzEPadlTszMdVhKKpTvNczbhL77Hjqohw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ek=3D?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;6:2i4DLemqfcMYwFWscvFWWxobdC3oreJNNUmrHtJJQPyh7tlwQlkH64axxZ1UJlIVGtAKazoDFz1KAX3cvwlOYoQ1BByNSfYHK5CKZmMC6M6pj8r7pkEKdX1NJSbHSk0nY/Ko748ar5OcR8vbTDwX5xa3YFfNLLd5wb/JfHhBmtgboZrdmwTAM/ze2uIhiM+fxH7liLGvBVygwPCjQtvveVBr7XUTRUpo+thOA+1u9kC6wcvyZV0M9+/emQdONSvKqoBTHtqYNLxAo6dYCQXPRslG1PeKmBEiDF7CgCaNEVlcalY4vW3Jq3wSAKxyK8qQ3DwMxpJouwwJy4fB/JeaxsZGHIWh6CkBOD/vlQ0ivhPwuBazP1UoALg4MGa/zx+MwKj+SR2YY+QlnHRBt4JJAn+mzJktW/pzHGRA2nrm1tvWb4VLgmfuVvXc+Pme93NH;5:/rRT8boVztM5XvlSYlwV7jO4e2RJyPW/XTp7NyiyFuMDEmWuz71OB6KvDAPkY4/5yP/NnF0SRBq7QQObIu9rdty+hJo8FOno0BQaN1FRCbm/V68q8lxp4imJFqvovVhAVDUiENroE6++WVZs0DUuNRnV7BayM2VQjs3+u1lrw9rmmYTPKR1tNzgOtEePkKIZ;24:r2XGU0SIfwrfhSKlf5gGtE6PP/s8GsJhwZ9j81lnIsA9hBTg8Sf4d0arTF1tOaBLo/04KHshe080kg12u3LtBGJ13gSYdcBjNqh2WHktlmA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;7:H4pKJR8CCq+QXw1qB9cv+YGArPSD813YoDU/9aJkeDty2UsXZUix6nExnlyGOJ+5pz8u2VeOsxTidGr2Z31I0iNHgBVIeSs1fXQi08K5VvdDwTFLKhyU0eVCgAznTqGTukoNevCNg6JeRg0rIgPT4mtaw6Fm7bJGuX+LwevcY/1Z35U5XHmnsuX/q5kPFwmPLiuLv/4swlJqAjo4DjkrXNQqxbZanWtg6id/LlUZ3Hy4lQcb0W6SqZvkrSNuu2Z6SYolMF/bcjqlxho0cQveiSoJYn981sYJ6wddt3FvxTKRPcEBeTLHT0sDYUDDdZXFFSggMN+veD5CGyXIq194eaweqHB3d/X02G3BigOySpXO7+XALSI++Z79ShmBkFHIMU76VL74957WQd5JVuK1/XR2ryPOXjHuqtlH6A8QuY3fO8zGXwm2ivZxbYY9FiXQNa60aJDbxeOzApTcFudSzw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2016 09:34:43.8677 (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: MWHPR03MB2478 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10230 Lines: 331 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 --- 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 cfa1d36..9033b70 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -207,6 +207,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; @@ -218,6 +219,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); @@ -226,6 +228,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; @@ -290,6 +294,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++; @@ -531,11 +536,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; @@ -564,10 +571,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; @@ -584,6 +595,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 */ @@ -609,8 +621,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)) { @@ -815,13 +832,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; } @@ -869,6 +892,8 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int budget) } while (err == -EBUSY); } + ch->stats.frames += cleaned; + return cleaned; } @@ -1330,6 +1355,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); } @@ -2351,6 +2380,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) @@ -2392,6 +2427,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); @@ -2430,6 +2467,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 b757a99..c330927 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -195,6 +195,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 @@ -222,6 +254,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 { @@ -234,6 +267,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 { @@ -273,6 +307,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 09cc2c7..00ef665 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c @@ -55,6 +55,23 @@ #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) { @@ -146,6 +163,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; } } @@ -154,7 +175,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; } @@ -170,9 +191,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++) { @@ -196,6 +222,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, -- 1.7.3.4