Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965583AbbGVQdS (ORCPT ); Wed, 22 Jul 2015 12:33:18 -0400 Received: from mail-bn1bon0148.outbound.protection.outlook.com ([157.56.111.148]:45366 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965204AbbGVQdM (ORCPT ); Wed, 22 Jul 2015 12:33:12 -0400 X-Greylist: delayed 893 seconds by postgrey-1.27 at vger.kernel.org; Wed, 22 Jul 2015 12:33:11 EDT Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Madalin Bucur To: CC: , , , , , , , , Madalin Bucur Subject: [PATCH 07/10] dpaa_eth: add sysfs exports Date: Wed, 22 Jul 2015 19:16:43 +0300 Message-ID: <1437581806-17420-7-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1437581806-17420-6-git-send-email-madalin.bucur@freescale.com> References: <1437581806-17420-1-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-2-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-3-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-4-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-5-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-6-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD053;1:jYnQXXQuYHinVDzIQALcKinfonl+u/8toG4zOnYV5s0wjrG+ZJ6OMtuCGsaOjuvBLf629rkB+VVOaD7ponkYqal15/2jYP7xy74BC9r5zjq9igRQh8LoT37PD8ZJvv+8Gpqt0Wx4iyvCe9lxCJg5ly2EyS4rBzmI5PHsyN/cHGyAVDGCHWP4+6Qku7rD9O7iVcwQIFqA9njhDd7WGviOHoxknrsae/vK7QJMdWaT3oONSZqPdEXyMlEFgnXqHL84Hj7GaEQawENVkGBFO+dwSFhJtK7+DWygkMHDhBNXuII+mSVuX/8czmnGbxmYzWD9zjbcTSvxGqldbpmH0y2e+nPlqAbwuKTGcH9AR8NqjwuBSaYhAudaHXQMFRqbKaLV3/59GNya+alxGUy5fFc3gsJT5/nbHKjLGJEeaU9HGSS1Nb5F/vMxigLCFzh1jusd X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(86362001)(33646002)(19580405001)(19580395003)(93886004)(2950100001)(6806004)(47776003)(104016003)(2351001)(229853001)(77096005)(36756003)(49486002)(105606002)(50466002)(106466001)(50226001)(48376002)(46102003)(53806999)(43066003)(77156002)(5003940100001)(76176999)(62966003)(107886002)(110136002)(5001960100002)(87936001)(50986999)(85426001)(189998001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR03MB1483;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1483;2:GYJrX8zhl8fNrviueLhb64CElrGI2WJh6TwGc00XsJvOJIMW9VtZg9N9j8ksMYm/;3:x9VkWK0R0oHlHtVrNCD4kUD9r/3Gh+/f1RPtIi1M7W/PSSZ1sWQIK/rJSLTnM1Z/L+3AgF8FrTKonMRxDA+4srkWbARH+sCQEC3F8T93V3BX0uBuDQL0XUqznt8RK6LXNA3zMo7BzgkZ5ydkmZDlKWeriVIssqRj0EO3I5SqSRy2hulvcFM7TmsJbQlLI6ySG/ZYX4Hc4BIu0saws44ph3mtgIDjdFH4DDdCDjNsgqI=;25:gDMvzEYDEdrGDZtlipEQBEuMDIG+Z8eMGZTDtSadmL9SnkAJMSWeoSFtr6UfdpSjgccqgAie13RfOJHs3+ykXFFxybYKywwzExp2Uddf7OULZFmupXYV6SDfn3MPrjksWoEMtXd8SaOXIi8jtzxs1vviLOVTZsyo8lT1YAYpccgBAs/nOMcE/DIXYZ56Wl+0MXiuNEQlT1SoYkAsmJbOCjT+8kInJbFFqFG0Sse24vahdJZbgm4CLKZKx0mW199+miiVktapfqiUSDuKmiu6MA==;20:R/CqpYJ4rkvU9UbRKTitmV0CGFGGKmakS76RgFVb0Tf7IZh4NQTxE6bBANJMkvkcZAORX0B0uMDJidhpgnh4ZAp2qJVVCCfsEExJMzv28DsYeDSSP4o+Sf8TYaqjiJxdlVCPnA6l0/mJHsI3a8cuC56WcX/eH4PIxb625fdO6q0p2Sz7bfg4vWF02bJXQqtptlPW0rDRRYZr6ZKJ7Htya6P4ImyeOzQSufCKsA0YkVt+Is+iOS+n2gOp8W7th6Sms0D1w39CPKIlSpMUDJ/e6M4yMucvf9fndRCC0ECsLLa8tZCPOBEdjdE8N8Ps5/cHwZTgr0LgCb9amxmima72T9IMVdB+NKshQ5mqh3lNZkw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1483; BY1PR03MB1483: X-MS-Exchange-Organization-RulesExecuted 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:BY1PR03MB1483;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1483; X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1483;4:WJex1sFZ4HAoWFdRvAVf/2UpYmKvSkvah/1NzcfQFc2hahJcWJeF6fhDPgYlMe5ZEGg0Xa2LGzheFGgNw3Z5IZQini76nAH+vXHq4ANFcycdCmtjdlknfdzB/8FE/0Fyq6EEdsug5HUW+IrqEHvgU5P/gmqRsXqB3GKF3Ief5iXVp8gqjINiqVMR7FJRx6G7bN5LATspIyzauVLcdYBA/M4nfYxKbo2933iKowVr9Xp9xHgkaZt1vqjP6DcgEXHkAoc4ppjxTvYTpxfckqEuYRrA29q70MbuB93Aag2HYDg= X-Forefront-PRVS: 0645BEB7AA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR03MB1483;23:j3rupQ2+0xuUY2MQq/6uiujkCi5CcK3uEvQy7ef3X?= =?us-ascii?Q?fUnT/QhH/3DjXhY4B2FZfl8Y+9iJXgolQyRxISvN4WuZ9dxmvvuc7Mu9bhCJ?= =?us-ascii?Q?WtZBbFb58Qm2ClbLOOnKG6w3xStUyEGXneZGgM1ImyS8zMQIwZqKlF4NJYP3?= =?us-ascii?Q?aOWRfvvljD08vDep0XYZVqvPUVVuI3WOyRfTiE5zk3Xk7N6P3x9DzOuyNAzz?= =?us-ascii?Q?6KOfMwvKAe6fjxaOawKODx9oPj8P281X9WFyxYaaxN9fGFy5ZPt/GFJVKZM3?= =?us-ascii?Q?ARQ5yXOeSFrCVt3oEbalxRDN0H7wPp5x5kh4KNW+HxtfGqGC4rxfKhqev09N?= =?us-ascii?Q?dk4cZcqZE9yEe96dEKBshCialFenn/vEBAyCgB0eVSGaEt3aOMSYCZaM+SR+?= =?us-ascii?Q?jU/FyEakaO2xjH73oGgrn0n0yGO3B/GXzY9HESVdBg7I0goDkrDwme9/XJNB?= =?us-ascii?Q?rPPD9V9nbRFC9GUyvotywcgco07BhdmJ1GxINvUvAVs9QmelEZTAwX44aBa0?= =?us-ascii?Q?/70tQI6tZwyidCSXS6cqQp2rOVaWjKdIknwkvZWJ9L0Mduzz6w3siKCRDmmv?= =?us-ascii?Q?24Bo019h94qVysJ3HmsDXuPNgmtVa+ZM4V+xYj/5DnZtETdt1myR6dgkDuUk?= =?us-ascii?Q?i7XnJNGl335xR7IRU7bJ27w2uBiN7wOouoETOpZbaCiDfqucIf//KRFnw8bc?= =?us-ascii?Q?G1Gj0ckWO9pBcY+p6gj26fP3AaKPzo+SBvVJ3/PK8494xgMlbPoMasJVtsK/?= =?us-ascii?Q?hPBBi8JkGJGEmJCe+RxUntaaEWA5ao602qQJ97hH4Dvp6mu4vlTIG8Edjbo9?= =?us-ascii?Q?TwZlfWZxZzUQziL+Xo7u/cZ4FcQ8eRhVKzXMfc/GoDSzTpkO27XmmqGFyNTK?= =?us-ascii?Q?0vhapk73FCBpE1t7ugtV7UhgTvThU12tV5i4GNXQbisKqjRaIsc/8v07QXpG?= =?us-ascii?Q?EOWtNr9ds1I0sgrp/wM3BYzzXH8WUd59cvkG9iJZRmuF7FAK7gIczO2FURXA?= =?us-ascii?Q?q1memtcrMQpZyAChWKuWRZ2Oa1ILJwF2n3jbmzMs5Acuw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1483;5:08FuKb8opJsQa59jHe62t/y7D/UGosivms13e9cDidRCfowva6Q8XQ8wbUwRTixZf9LOWLuFQT1fe4RMjjbSBdSenNUltYNUrxCNAGwG244GLJWWmyu8VSbGKZ1CtEWExNYJND25cqEmyypnWe7qFQ==;24:sq1jPv4cSiVsHngL1JX/iPpmbjo9boKxb2EKXu88Qn79NzPQgeozscJNvZbIqw4a8pCv9zf+HpvkYNTsUIjkhCqsaVvXxyw87fD24h2PVYY=;20:As7kGZADr07GdAz11CX6HIC3WebPgAZqxrrIimhJObkVbb7cSGCXWKdlNqM+JVZURU1ZBssphzF/J/klff8cuA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2015 16:18:16.2694 (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.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1483 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 3fbd114..dbd8a70 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -740,6 +740,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 cbe9626..7160eda 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h @@ -346,6 +346,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 aeb2baf..bcd4c4f 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c @@ -285,6 +285,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/