Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753775AbbHEPoz (ORCPT ); Wed, 5 Aug 2015 11:44:55 -0400 Received: from mail-bl2on0102.outbound.protection.outlook.com ([65.55.169.102]:22944 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753286AbbHEPnv (ORCPT ); Wed, 5 Aug 2015 11:43:51 -0400 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; From: Madalin Bucur To: CC: , , , , , , , , , Madalin Bucur Subject: [v2 6/9] dpaa_eth: add sysfs exports Date: Wed, 5 Aug 2015 18:41:26 +0300 Message-ID: <1438789289-16304-7-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1438789289-16304-1-git-send-email-madalin.bucur@freescale.com> References: <1438789289-16304-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD023;1:f1+yxcHL7U7OYIaimOiXNgm5vEGrg380pc2D8TS06z4/ld+MPYfLupjwI42JlfkLLegn0LL/WqekVWUXhGLEYmAQuaXgFjNyHEi8Qv/j/8ESt4uPKGgXj/jH5A5MPmP5CGxaZSxoxEIW+RQytaxOhs7od/RSU55vretHXY5Ew0zyqEMGrEKc5LgSOx813BxZnyJGW97F3RGPVhHhn5tEzLda/6wmEQA3IulYBGi1ArkxZuQgshpBiuKY2L8pKSsZJ//SxPeXG4dBelLY+KTwKEFq5QJnUmBQxQjllKjbFVzySYwnZoQC+4F/ln2ewinqUwL4nLkydXB9eBlnvjFzLQ== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(50226001)(81156007)(19580395003)(36756003)(68736005)(19580405001)(77096005)(64706001)(4001540100001)(105606002)(97736004)(106466001)(5001830100001)(5001860100001)(5003940100001)(47776003)(104016003)(85426001)(229853001)(50986999)(76176999)(43066003)(2950100001)(62966003)(53806999)(48376002)(50466002)(110136002)(2351001)(77156002)(575784001)(6806004)(107886002)(46102003)(189998001)(5001960100002)(33646002)(87936001)(86362001)(2004002)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB507;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:ErrorRetry;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB507;2:fUytNPRN+a/ECnrsXpkzeZg59ICTFi+OR4khmQF6cx6+P4bZNHX6/uQNcGYyPvrXDGxxnHodu/Inl66R7HvyZqT6Az9uLaKmnJE46/l9BpkPmmEtNxdsDghBZFpwB6r8kkc2TGwT8wfv8pKUV6oBwhK0sCyxrxDH5OMzwEvGi9s=;3:GMjUb9ebqqXUqf//0WdqzEGGpPeVUtK3cxA6yXKjVVmnur59MdnFm2uGaW1aeD+bCQzZ72vO82kzuypFAgDW0kRZy9c3h5Vv2CLSYOkHNlUPmegv2hOYg6ERMNkRAObCHU60X4vgF95ZHKBaGCdy53bWgxk8JMHEC4hkHWVk2Qee/mGKtCCLm6GndB2oQt9ALTc8mG+V5YocDtIO6uID+UnZeAAa2Hq6/vsM/xIIHhA=;25:35ThrS1soxEsAOlTrvKwcUBKZ7z3rVj+jg5N6m+tfRApE1EEfpJ6ompylH0cPI/YXN2khPZztfY/38cXCKgtEvyg5BmtGz3A6ZuujWsDvRjDxhAuEI2nBbpW3J80wboZRQM/70q2wcfZS0TXULX3oug0ck99dN2YjB3eryDtFOgoP4cBd0+ylOBRCPYWFFSPAR74jJMEXFY5BZZXi0QbeSElQpJ/E81OdXgOVOhrowKjOcSyf8klsmgkXZCYIOFkq1NAQ6YJbaKRuizBK1FfEw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB507; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB507;20:ejzmU6X8eEY+7fUIVWuRdZvJGHINXjJFxGpeO8kGZXilQ99sn7cR6gSZG99e/4BROBwpH39yZdechlaRxcf8ERBKdZIE6OrdjmoY3B0bhmHoAuATESuV2yuCqZ+lnd8kXDvUdDrVERSdcv9vRwz46tmjfAaVjspPx8efHGIyuAzctygT3YR0mjQajSMYJb4fXIG0OjtG8lXiAyZU0UcEgrJ9LZJ0NptiJXrds62DEjXee+ecE6TfW7jvVpNl5A61wcqSwvZZmjns7AJHMdV9UlYz1cniNEzuzBZ08rIIaJewPXHCACwH2sS5ifM5RWt5g2bfgwRhbywD8Oi1nhRUaHmHGoRva71ua4iadLpppi8=;4:BK8VhrB9NkFFIvdVRjiBk9nP/+qfE+X5VoBklNW+rDz4iaRnm9Z1eEWlk079KV978l0uAwqixelos4pecXnBuRZXYSVs05WR1DAcugdkFQKFQb8Rv9Ge21JCfk7RTWf8A/44A4VYSm2vOjnWXJPi/poCq2LmK3EwO+ntCbJO9SLtawtEXsB4W+HpZ3odyIZ7tklYaUhAinr4c7J8v3B8I/LO2nunOIeryh6cjrCtK8dFqukF+m3//W6Un6+NFLZ5Ee3XNPBOid1NEHZPuoTzQ+8/hLyyBmb6lcqkCijkz4I= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY2PR03MB507;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB507; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB507;23:F2C/nPAOHDvT9wqVPNGTjkZRg/307MjGmNa18IyX9S?= =?us-ascii?Q?CnULVt3nps+CG+ABQ1WrH8o1bYR1U2Kzx7Op95Jbl1Zwk8ZAtsP5WA66AzJ1?= =?us-ascii?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ePmXD2U?= =?us-ascii?Q?sMY+PhbNiw9MF89kD5+zpvBH6xh92WJVC2JuIwwxQhUjZvDo6raMr1lqB0NQ?= =?us-ascii?Q?eLnvYh9JXiu8nzOYqtRHXUba/gn1ZxXJ1z2nZSgks6nEnViITxpxc0pIgJsG?= =?us-ascii?Q?NZ5NrcxHnrC9332MbrCc95Ubo/fY0C1yAQMTW+ExldkHfmBVqRqg7xjq487b?= =?us-ascii?Q?lc0Lh99aYxEuPi9I0syEsN3Ul+j+AdF8DV?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB507;5:fP08EEQzQr54ID5XQaNEQyG4o+tyDZnoqOAswvT36QFXVnAQenlbUyAQQ039XpYTH5z73pSSDjAajYvyX1VBQofIXdOmydTizg8SMNhmJ9Pvw8M9bYFBrTpJtdip3gKoNVs4ZkHYCCT/Agzc2ifWfw==;24:1H3oYrgv5YLzEownX8ygVh+p9WBuWP/b3Ytkg4WlqXF+5S5sG+lkErUIyi2SikbrWXHLoVMOzvgKjjHRTrqUkAXbjmjGMhexXxTaA3L3KvU=;20:ezvxBwamWCAal15gXfcQEsXsCqKQyYBCK4YCxXdHt/B3BlYM3VpqG4DqVUrCyLiEwTGShSnyKQUViyJuWWrqSQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 15:43:47.0850 (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: BY2PR03MB507 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8158 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 e137146..3a276d5 100644 --- a/drivers/net/ethernet/freescale/dpaa/Makefile +++ b/drivers/net/ethernet/freescale/dpaa/Makefile @@ -10,4 +10,4 @@ ccflags-y += -I$(FMAN)/flib 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 264945c..a1183f4 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -739,6 +739,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 55c1106..2a0ecf3 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h @@ -344,6 +344,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 ca6831a..1e43fe5 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c @@ -279,6 +279,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/