Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760042AbbLCLLw (ORCPT ); Thu, 3 Dec 2015 06:11:52 -0500 Received: from mail-bn1on0092.outbound.protection.outlook.com ([157.56.110.92]:24612 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1760018AbbLCLLq (ORCPT ); Thu, 3 Dec 2015 06:11:46 -0500 Authentication-Results: spf=none (sender IP is 192.88.168.50) smtp.helo=tx30smr01.am.freescale.net; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=; From: <> To: CC: , , , , , , , , , , Madalin Bucur Subject: [net-next v5 7/8] dpaa_eth: add sysfs exports Date: Thu, 3 Dec 2015 14:09:05 +0200 Message-ID: <1449144546-25438-8-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1449144546-25438-1-git-send-email-madalin.bucur@freescale.com> References: <1449144546-25438-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Matching-Connectors: 130936147032265650;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD037;1:zR7AyXBOfSzsKv+JiPDq7/RfHlEnwhIH+FvumMPSJZQGncZcqsAJUMvylmN3afzByxXbO19gpp/UvTXd2e3F+guAQv9dItm6C1n9uBlLHd6wJgGQ7M9a/jjGSGMmD4v3sZLUhJSTOkocsl/mwe0RdsZb7tzdylekIll2bNOXbCKgdTKSXvBF8WaoLafEU7Qwt0XtSmWcvIi2cEgModQPq1bRQSdQmQVFLz8E2uAqPGv/OpBREGad/TVCwbStZmsIrSU/RA9gTY9EthQD2fa9rPQrar/2rOcVKg4ha3iRyTzeCREMgSnWQg6bg0PaIIJM/XFuwYVFB9oDnzLGGrQvZ3JrmgxZCRBiJwgk9wzLOlq1MavZcL/Ts+NPF2v6cd3dx1yd3QGZrI+dBco2BI4AkNkp+rJOhtYvLyO29s+gwyL5jSgUzOXjJlGjtt12EKxbLmyWS6QpcPa63M/pCOj4USVGssdWiwBZcKnC1K9XFJk= X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2970300002)(428002)(189002)(199003)(5001960100002)(5003940100001)(78992003)(43066003)(101416001)(110136002)(53806999)(50986999)(107886002)(76176999)(189998001)(77096005)(2950100001)(960300001)(97736004)(81156007)(50226001)(106466001)(105586002)(5005630100001)(33646002)(586003)(2351001)(50466002)(229853001)(6806005)(575784001)(104016004)(19580405001)(11100500001)(48376002)(87936001)(4001430100002)(36756003)(49486002)(5008740100001)(1096002)(1220700001)(47776003)(19580395003)(60522002)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR0301MB2123;H:tx30smr01.am.freescale.net;FPR:;SPF:None;PTR:InfoDomainNonexistent;MX:0;A:0;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB2123;2:OLBDrTlKRY21xYVtlaDf9J+1AFn1S0xjSCu3XFWJdegJP0U31r51mVdCxcNX8oARttQNvhgBljhLyeh/zOilwH5rTotaHH6Qhw0zm1u3DV8hY72cl1L8Uog5NxzyNFpmIMyuP4aReHuC2C8ELejgjQ==;3:DkS90zULhZXQZnNoEECpU9NGsCtbyraYouPc1Y9UQbcSqU+cbqAgDopd6ZMXtZvkqdiXHXLwxPITkofqF8B9qo8KHVPCB0D/UfrBGoa+EGzyqtLkA3c63HfBCz0munbjtKPhoTlLkgsRbI1ty22cLVYk1ixQO9qx3BgEQR6aPX2G29o9/TcW5BFjKsmzmv3awoHwVnHANapVu0YUok9Utm90na0YzcnZHeuqJZUTFQE=;25:OupYjTYFW39tHyo7+ySfB4k2RH+9SUAza7TsVOZvS60+ydlJMzTvy9SmADZee7TglTxLEU3hkXnIql/JyPnqSM4RiPmJLXvcDIy9rXggSrkV00A3XqRI2cZee4p7bYqRKKcG1Ue0ynt/j1qA7NYjUYz9mH6Y7P5LquU0wFU0JG93fqwiSSgZijaRkjyj/3Pac+ZxduNJUeVp6MF2FklbUt2k+RsjvJsRHDQSHdlf9qt/SarwG+byck+17B4m2wbhS7+Nf4cqPrMpjBLIv6AYmg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB2123; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(10201501046)(3002001);SRVR:CY1PR0301MB2123;BCL:0;PCL:0;RULEID:(400006);SRVR:CY1PR0301MB2123; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB2123;4:kkkvkHNFGyAEvaIuTl1qSVxg0XMF1/HMUMETwrxspvYynyU4oSEmaiVG0Njf//D2pixnzzfRwKBMLn6qGODhipxg0HWfwkECmp2BSEMKHllMGPGf1f4wtNZ39Jeqmk3e3mVniO6l+fZQ8FGVpevxotyDzk/1U202tJvpRXMj85nU9ZKuojAdCiNAfB8ennW+xaMm/Yb8+fglKrTFIJWbEWAU++TZ+w4NhDZlrHKPhqqZ/5CF6AVlEY6Zo4i0aQ3EJ2DD9Cuq658yJFWl+49igjYqk6Gh8xJqpmovRKctkbzptTgblz/GBtOMRKh8rPeu3NoHiFJB1bmYuGA1jYwG23x2H9G+pJZyrUM5M3uMkofb2A8SHe3ZLPPDL432neDzqKXTSjPSuO8hYyoyvF/f33x4u+aV/bai5h7CBbsSI1iwJs8N3M6WWCFL4Z16c1im X-Forefront-PRVS: 077929D941 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0301MB2123;23:k8ykTq65S4E2AzyJav9IhPJ47kSaqowM1zZdE6Z?= =?us-ascii?Q?JzS89iO34Hsz53vrgi2ymPVueAcktnX5W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ii?Q?yVNf2kIxZ7z9+mT/X8WF8BV7WrpuEO9dTWzYT4iN3EgwVpnbfE7mWN33R8/6?= =?us-ascii?Q?BS3b4b7Jqzb9DMq5pRY8i8G9hknETeO7bzM1uy53Lb2OnndtEx3lSo7GR39q?= =?us-ascii?Q?37vSuF+MzSDT6DPkOGfdIgRIvppH0gZMyoq15eRywqJujDl1Iy5mUtc6AlPB?= =?us-ascii?Q?blgpuTraaqIRuxeYTvWDFM0ACiGYWHfIJycCqlYjPQdVgZDa4lc9yUkzZUgm?= =?us-ascii?Q?exZdZQ+NyXn0rP8xykiy7BruVMfYbZzlaGo3gbsf1dyGInLyPI1/YM9yTJQ?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB2123;5:jH5PA4U67K7u06UNbYjIshSxYgzjqEgXjMWXIyJD0FL1N+y/XTJtL8s49gNaTW3oLSmD+xJYHCiQaBsWSCHL0ert5OeHLkwc7ivnamsoHt567XQzy7Z5ggfNoGq0dLLmY848JzKYHS6pLq6lrqWzrjZOIkhH6jQPa9t9Eexdz8I=;24:gub8YScQRhOx0VjPVBcKQUZkiOLTQLlCx3dCIvQm5pV77DJxMD1GwMDGeI2CgJUPeWX4ZaPhfKHfonCrv8BtFVVUTWHHUUTQEe+yw3NM8II= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2015 11:11:43.0549 (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: CY1PR0301MB2123 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8211 Lines: 245 From: Madalin Bucur 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 f71a0d2..7d4d21a 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -691,6 +691,8 @@ static int dpaa_eth_probe(struct platform_device *pdev) if (err < 0) goto netdev_init_failed; + dpaa_eth_sysfs_init(&net_dev->dev); + netif_info(priv, probe, net_dev, "Probed interface %s\n", net_dev->name); diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h index 076d66a..9651e24 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h @@ -356,6 +356,9 @@ static inline u16 dpa_get_headroom(struct dpa_buffer_layout *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_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 2a7cff2..3003832 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c @@ -330,6 +330,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..56588e0 --- /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 *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 *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 *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/