From patchwork Thu Jan 28 21:26:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8154161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 15EC3BEEE5 for ; Thu, 28 Jan 2016 21:40:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BEE0201BC for ; Thu, 28 Jan 2016 21:40:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4799F201B9 for ; Thu, 28 Jan 2016 21:40:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOuH8-0008Po-Dl; Thu, 28 Jan 2016 21:38:46 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOu8A-0006BN-Pn for linux-arm-kernel@lists.infradead.org; Thu, 28 Jan 2016 21:29:32 +0000 Received: by mail-pa0-x229.google.com with SMTP id ho8so29149254pac.2 for ; Thu, 28 Jan 2016 13:29:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pLAGcbBCb893ziOWjfCvzJDZ9XDio0v4LwUBR2jf/iI=; b=PCQW1KHpnRiMmI9kvwwiPVF6YG+onrVKI2FFvc7PlxWXLVcLzDPaRrFDiMjBp5bw9J rf5WOmzMsRLLY/gaWkzQGGl6Q3xjHozckIDU3x6Nd7ivZdYIxmWavBEqq/gaC0YtDFDK X4/e4dIqvvgDIs0OJ8mLQ63W4mupaY/md8R0hr5C/Kd1+SvXg1m3x91gcNZznwPl1EWg jOYRs0pY3q2EMET4wQkLcONkEWDH3MBqc7thNT+49yvXSbPO19DkmngwEyQ/VjtH4wJt dkOTCYSLgF0RBbfXYEnd9H0EMa8poj/Xa3GfVl5jrHjKCCEgNNzXuX3i/ElFxnXWUrc9 HcjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pLAGcbBCb893ziOWjfCvzJDZ9XDio0v4LwUBR2jf/iI=; b=Is242ef4hQnU1V4l+OtSMeX78Ja6+bYvLGaALtgxUbsp3+l8OW4dqrre55vexEyV8h viLmPLenfN8QvQQXH34aPTaiHJWqTQ4xANNBO8/mfsod38BQhZoJk4UI/PXAAT6+uQ+p ZwtA+fTRq6hQ8NsE9sHq1tv7MyvJhd0ZmeVywweOnFrlzrAN4tiadEKd9VLIXF/vfqDu zTVqaZV8L8mgRI/FuGqjWM8dWwogz7RrDOLaouJKdtYH+9/Qkn3RWt/50EhfkZd7E7O4 B1VvWUiaEbzp9f/qdmUm+OcRana6NgmPHBIf4Qb1jCWcW+ijheF3PdI1ghxFfOSY2Niw Q/iQ== X-Gm-Message-State: AG10YOT0M8wDT+Fw1RNjNb1M7mpUxFHmE2nfxOZdWS/Q6TRwmZ2AN2WztWYNPvmNozvE0A== X-Received: by 10.66.90.133 with SMTP id bw5mr8023198pab.22.1454016550463; Thu, 28 Jan 2016 13:29:10 -0800 (PST) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id c90sm18583190pfd.31.2016.01.28.13.29.08 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jan 2016 13:29:09 -0800 (PST) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Subject: [PATCH net-next 37/40] net: fec: add events device file Date: Thu, 28 Jan 2016 14:26:01 -0700 Message-Id: <1454016364-30985-38-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> References: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160128_132931_053277_25F9CEEA X-CRM114-Status: GOOD ( 12.33 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fabio.estevam@freescale.com, andrew@lunn.ch, linux@arm.linux.org.uk, Troy Kisky , laci@boundarydevices.com, l.stach@pengutronix.de, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, tremyfr@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is for debug purposes. If a receive interrupt is lost, writing to this file can recover the FEC. Signed-off-by: Troy Kisky --- drivers/net/ethernet/freescale/fec_main.c | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 11968a9..00c9b7e 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3273,6 +3273,53 @@ fec_enet_get_queue_num(struct platform_device *pdev, int *num_tx, int *num_rx) } +static ssize_t fec_show_events(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct fec_enet_private *fep = netdev_priv(ndev); + int qid; + int complete_cnt[] = {0, 0, 0}; + + for (qid = 0; qid < fep->num_rx_queues; qid++) { + struct fec_enet_priv_rx_q *rxq = fep->rx_queue[qid]; + struct bufdesc *bdp = rxq->bd.cur; + + do { + unsigned status = bdp->cbd_sc; + + if (status & BD_ENET_RX_EMPTY) + break; + complete_cnt[qid]++; + bdp = fec_enet_get_nextdesc(bdp, &rxq->bd); + } while (bdp != rxq->bd.cur); + } + return sprintf(buf, "%08x %08x %08x %08x %d %d %d\n", fep->events, + fep->last_ievents, + readl(fep->hwp + FEC_IEVENT), + readl(fep->hwp + FEC_IMASK), + complete_cnt[0], complete_cnt[1], complete_cnt[2]); +} + +static ssize_t fec_set_events(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct fec_enet_private *fep = netdev_priv(ndev); + unsigned long events; + + /* Disable the RX/TX interrupt */ + writel(FEC_NAPI_IMASK, fep->hwp + FEC_IMASK); + if (!kstrtoul(buf, 16, &events)) + fep->events |= events; + napi_schedule(&fep->napi); + netif_wake_queue(fep->netdev); + return count; +} + +static DEVICE_ATTR(events, 0644, fec_show_events, fec_set_events); + static int fec_probe(struct platform_device *pdev) { @@ -3451,6 +3498,9 @@ fec_probe(struct platform_device *pdev) fec_enet_clk_enable(ndev, false); pinctrl_pm_select_sleep_state(&pdev->dev); + ret = device_create_file(&pdev->dev, &dev_attr_events); + if (ret) + dev_err(&pdev->dev, "Error creating fec sysfs file(%d)\n", ret); ret = register_netdev(ndev); if (ret) goto failed_register; @@ -3470,6 +3520,7 @@ fec_probe(struct platform_device *pdev) return 0; failed_register: + device_remove_file(&pdev->dev, &dev_attr_events); fec_enet_mii_remove(fep); failed_mii_init: failed_irq: @@ -3496,6 +3547,7 @@ fec_drv_remove(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct fec_enet_private *fep = netdev_priv(ndev); + device_remove_file(&pdev->dev, &dev_attr_events); cancel_work_sync(&fep->tx_timeout_work); fec_ptp_stop(pdev); unregister_netdev(ndev);