Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753922AbbKBQtq (ORCPT ); Mon, 2 Nov 2015 11:49:46 -0500 Received: from mail-bn1on0117.outbound.protection.outlook.com ([157.56.110.117]:39264 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753263AbbKBQtV (ORCPT ); Mon, 2 Nov 2015 11:49:21 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; From: Madalin Bucur To: CC: , , , , , , , , , , , Madalin Bucur Subject: [net-next v4 7/8] dpaa_eth: add sysfs exports Date: Mon, 2 Nov 2015 19:31:39 +0200 Message-ID: <1446485500-9782-8-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1446485500-9782-1-git-send-email-madalin.bucur@freescale.com> References: <1446485500-9782-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC009;1:JAfZzBfJqEh7/cLvzDWai5SQ/AnG6w0MLcOXkDCUypyrxsqf5mnUY/7Z78xhWBeEMAaSOyKnQiQOc3Mzou2EWmamrFn0Y7gaD5cM6lvM5gx91amuuMatihvGj1srnN+GKtBk+Gkk4D0NhMc3aA7ZHoWV9MFLLVsz6Nw0bk/MEEVIvCLLZQR1U6tPwwsrII8kZsM14Jied426aoD3EyZ39ss6PKGMwLoBGTy4o8mK5YHSEp06L/ScLWzLXJ7Tg2Jz9zo6P22YXhSNvvYkmajNs6KwwXBh2bAp9cdvjGBi0PsAofWuy4coaVDkcxeDp1IFcovSzNiJJZXAxrPFDVmRDs4J76TlR+1B2kX8omvQDqhgk7Qfk0PCCqLp+zee/mDFotGj9FsE84aU3mqKHD1WGw== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(50466002)(33646002)(2950100001)(4001430100002)(87936001)(19580395003)(5008740100001)(105606002)(81156007)(5003940100001)(229853001)(189998001)(97736004)(106466001)(86362001)(85426001)(47776003)(49486002)(48376002)(107886002)(5007970100001)(2351001)(19580405001)(11100500001)(110136002)(50226001)(36756003)(76176999)(50986999)(53806999)(104016004)(6806005)(5001960100002)(43066003)(77096005)(2004002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB508;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;2:fQKM/2C4r1E1vsVKfYUlzpRQ/Oy1j/1T+a94SE/sw84rz77qFjpN5Dho03TlW09khV9aqqKcSZ+6+OkPywNnwpDaWiyDX0RQ+VVc8IVhhd1UYS4QGGp4s6mMoIkb7rIsoe54LFEoV33qNI51I0+Dek/vdqsay99QOii9agKHr9A=;3:usantiAR0PmG3pbZLYkOgYk2C0k6hS4Evtk6uq0Fgl/8cW79LJu5goAOQ3mc3rI6R3GF9kNUJ74Kks/GfYv5aAN7NGdREYL35kJp/Cle8aLksN4pb/CfWzLv79rCY3QvLYSp/kCgnSlICut293zi1fUYXSixtBmIvgX7IWlPiotK57z3RxoBcc8nCyuTb0/91yLCLNunX9GaQrNy8LQwXHHco9LWqUfyh8iXV5ZGdXw=;25:V4zU5eWVajXQrIVg4WkPWZxSAqTp43jtXHemgWrt3ZguYqCVzmzxCld5DRILlo1YWabDB1tqZoSf0BWZaP6JwjTLpwk0snO2BuRzUtcYKKuNpd321AnVfKXMoD78PCXWbGlfvucxikYlnd2eJQABCSaIG8qVqduhGV3GjpRJjRcX/QifTX3bwR7VsVWiYv1UqySwJ6lJbmf7FdCpOiVgGNQCKABhuFxuixHzXdVuufHZGnBl62WuANnnTJQysDRY6Lyk5JrC0F/0REC62vyqYw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB508; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;20:UAYUs7P5XYnsJh/GpBRS7oLoiG409pqAZM5XidzlVk8jf/Y4yWrVzgRcuhHYKlrxzGsoxYKha3OrhcaWwkIxu+ltRpX4anUazcCpKFe16z2gZOeQNfdjIHpsFfO3/kwp9T/57e6+HDsNNcISsjSuT0e6aGFlawtnhMYW18ZZg91eEl6q6cEAod4fyfQP3CivcRKSNuq+mjqY7obm1hGVawRzn+3ddTt+wGOd5rU3A4U0xRkbEIostMhN6u3NE/xh+YSxs+Ef/zTaDAuvK8pajl+OxDcBHf7q6KQj6UvuipHDt+8JkIlh41WE4r0PeZrSTmkmkql49CPM4NnZOw7ordgZcRwgW/gqaVRDrqBf5JM=;4:mAyaWZRn/jHAN1NOfj/TpuN2I/RgQGr3n6Zr6E9VY8Vax+y5Ce1NSQQ7uDTa3hrRWuBYDRoXlillXmq2Yb9Rei7i8rx1v8TVbp1YfpFeffh36a1nnDenaUgw10TGgnVwWG4S8F6m2YIpBW6qJU1QYXTamxQoDr7+ZSxC/MXPGvg9R4pAYLqgagIYAV+CXrETBuIT3fQi5VBN1PItyHER4HdxdlZ25aM53ipoQI32bGvW5Q3LAgb5aEUSjsz+28m3q1Ie1dx7ZeIRj3L9KWZnt6dI50VVwAuZU1urqmVOTyUXs4EDxcsEpwZqaOuyNzLDuATwN7BKSLWlC25hLM8MRhLpa/xI6WR7uB2tfG/82snBkC3f/Qmsx3F4A9MeMd65 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001);SRVR:BY2PR03MB508;BCL:0;PCL:0;RULEID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k1+amu1VGYSF7c58MEQk?= =?us-ascii?Q?knPxhQ4jiEQYJpLG4/eTRCcrr0zrPjUWggbnmsZMcAIULRsV3XYe9mPxXxAU?= =?us-ascii?Q?gn2/TO4P54kAfiCafK7lV3Y/W+/oUnrma/E2xn2lD9W1WM7cchjsUzgugmGx?= =?us-ascii?Q?HiDmnQeQZCagj3xLqr4VNwQiuI/QKpNOtUY9B0gbZsvvp/sdPpy0huOTm72o?= =?us-ascii?Q?QOE+3Z6+rQ3oREOFjGrt573GO43qWm13oMZ5kioJMbnkj7AUiFFn/MVFVwKu?= =?us-ascii?Q?3sre5mq8Mv9vp6asDgyqgMQzCnBP4oRcXtc1MT5oLpUozCbk5paOsa8+gjhs?= =?us-ascii?Q?NZ3Xfe2VjoEdjk850iF53tITGzddLQ?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;5:rX4vH5sUby+91cxY3cmKJwlPmfGywdGLtoPwKxbvxwUNzFwunScaaVL7bP13ImM9/ED01T9N1Fc7qCRL3AghJnrnuN6p6lMky6lTB8TEx3EAEJNQsOtU5KzixwsJ5sjpK0ULGf/LMciGb6DRsiVgFQ==;24:opPW0F5kKtRT7UGvzEZURcdUDmxAigZuF2PpuBSyyZRPIBCmeFCTirOjVPAaKOh6cwhcM5puSghazM+SPmwRkPK0b7e3TLxUNEt05NPfR94=;20:XNv26+YbvmHssB6fmM1Kn2owJEfBdneWYY1i8DfV+79hl+qfQAeBqxBtSH/MQVTUdEQ1r2LDayG/yXAetbDloA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2015 16:34:13.4281 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB508 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8151 Lines: 243 Export Frame Queue and Buffer Pool IDs through sysfs. Signed-off-by: Madalin Bucur --- drivers/net/ethernet/freescale/dpaa/Makefile | 2 +- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 + drivers/net/ethernet/freescale/dpaa/dpaa_eth.h | 3 + .../net/ethernet/freescale/dpaa/dpaa_eth_common.c | 2 + .../net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c | 167 +++++++++++++++++++++ 5 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c diff --git a/drivers/net/ethernet/freescale/dpaa/Makefile b/drivers/net/ethernet/freescale/dpaa/Makefile index 9b75d52..141ade4 100644 --- a/drivers/net/ethernet/freescale/dpaa/Makefile +++ b/drivers/net/ethernet/freescale/dpaa/Makefile @@ -8,4 +8,4 @@ ccflags-y += -I$(FMAN) obj-$(CONFIG_FSL_DPAA_ETH) += fsl_dpa.o -fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o dpaa_ethtool.o +fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o dpaa_ethtool.o dpaa_eth_sysfs.o diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 0b3332a..3cd03f5 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -756,6 +756,8 @@ dpaa_eth_priv_probe(struct platform_device *pdev) if (err < 0) goto netdev_init_failed; + dpaa_eth_sysfs_init(&net_dev->dev); + pr_info("Probed interface %s\n", net_dev->name); return 0; diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h index ccaadd9..cdc7595 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h @@ -371,6 +371,9 @@ static inline u16 dpa_get_headroom(struct dpa_buffer_layout_s *bl) return bl->data_align ? ALIGN(headroom, bl->data_align) : headroom; } +void dpaa_eth_sysfs_remove(struct device *dev); +void dpaa_eth_sysfs_init(struct device *dev); + void dpa_private_napi_del(struct net_device *net_dev); static inline void clear_fd(struct qm_fd *fd) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c index 4947cb9..2cf4565 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c @@ -299,6 +299,8 @@ int dpa_remove(struct platform_device *pdev) priv = netdev_priv(net_dev); + dpaa_eth_sysfs_remove(dev); + dev_set_drvdata(dev, NULL); unregister_netdev(net_dev); diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c new file mode 100644 index 0000000..a6c71b1 --- /dev/null +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c @@ -0,0 +1,167 @@ +/* Copyright 2008-2015 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include "dpaa_eth.h" +#include "mac.h" + +static ssize_t dpaa_eth_show_addr(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct dpa_priv_s *priv = netdev_priv(to_net_dev(dev)); + struct mac_device *mac_dev = priv->mac_dev; + + if (mac_dev) + return sprintf(buf, "%llx", + (unsigned long long)mac_dev->res->start); + else + return sprintf(buf, "none"); +} + +static ssize_t dpaa_eth_show_fqids(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct dpa_priv_s *priv = netdev_priv(to_net_dev(dev)); + ssize_t bytes = 0; + int i = 0; + char *str; + struct dpa_fq *fq; + struct dpa_fq *tmp; + struct dpa_fq *prev = NULL; + u32 first_fqid = 0; + u32 last_fqid = 0; + char *prevstr = NULL; + + list_for_each_entry_safe(fq, tmp, &priv->dpa_fq_list, list) { + switch (fq->fq_type) { + case FQ_TYPE_RX_DEFAULT: + str = "Rx default"; + break; + case FQ_TYPE_RX_ERROR: + str = "Rx error"; + break; + case FQ_TYPE_TX_CONFIRM: + str = "Tx default confirmation"; + break; + case FQ_TYPE_TX_CONF_MQ: + str = "Tx confirmation (mq)"; + break; + case FQ_TYPE_TX_ERROR: + str = "Tx error"; + break; + case FQ_TYPE_TX: + str = "Tx"; + break; + default: + str = "Unknown"; + } + + if (prev && (abs(fq->fqid - prev->fqid) != 1 || + str != prevstr)) { + if (last_fqid == first_fqid) + bytes += sprintf(buf + bytes, + "%s: %d\n", prevstr, prev->fqid); + else + bytes += sprintf(buf + bytes, + "%s: %d - %d\n", prevstr, + first_fqid, last_fqid); + } + + if (prev && abs(fq->fqid - prev->fqid) == 1 && + str == prevstr) { + last_fqid = fq->fqid; + } else { + first_fqid = fq->fqid; + last_fqid = fq->fqid; + } + + prev = fq; + prevstr = str; + i++; + } + + if (prev) { + if (last_fqid == first_fqid) + bytes += sprintf(buf + bytes, "%s: %d\n", prevstr, + prev->fqid); + else + bytes += sprintf(buf + bytes, "%s: %d - %d\n", prevstr, + first_fqid, last_fqid); + } + + return bytes; +} + +static ssize_t dpaa_eth_show_bpids(struct device *dev, + struct device_attribute *attr, char *buf) +{ + ssize_t bytes = 0; + struct dpa_priv_s *priv = netdev_priv(to_net_dev(dev)); + struct dpa_bp *dpa_bp = priv->dpa_bp; + int i = 0; + + for (i = 0; i < priv->bp_count; i++) + bytes += snprintf(buf + bytes, PAGE_SIZE - bytes, "%u\n", + dpa_bp[i].bpid); + + return bytes; +} + +static struct device_attribute dpaa_eth_attrs[] = { + __ATTR(device_addr, S_IRUGO, dpaa_eth_show_addr, NULL), + __ATTR(fqids, S_IRUGO, dpaa_eth_show_fqids, NULL), + __ATTR(bpids, S_IRUGO, dpaa_eth_show_bpids, NULL), +}; + +void dpaa_eth_sysfs_init(struct device *dev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(dpaa_eth_attrs); i++) + if (device_create_file(dev, &dpaa_eth_attrs[i])) { + dev_err(dev, "Error creating sysfs file\n"); + while (i > 0) + device_remove_file(dev, &dpaa_eth_attrs[--i]); + return; + } +} + +void dpaa_eth_sysfs_remove(struct device *dev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(dpaa_eth_attrs); i++) + device_remove_file(dev, &dpaa_eth_attrs[i]); +} -- 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/