ipath_sysfs.c revision a4dbd6740df0872cdf0a86841f75beec8381964d
13e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan/* 2e7eacd36865ae0707f5efae8e4dda421ffcd1b66Ralph Campbell * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved. 33e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * Copyright (c) 2006 PathScale, Inc. All rights reserved. 43e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * 53e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * This software is available to you under a choice of one of two 63e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * licenses. You may choose to be licensed under the terms of the GNU 73e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * General Public License (GPL) Version 2, available from the file 83e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * COPYING in the main directory of this source tree, or the 93e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * OpenIB.org BSD license below: 103e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * 113e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * Redistribution and use in source and binary forms, with or 123e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * without modification, are permitted provided that the following 133e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * conditions are met: 143e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * 153e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * - Redistributions of source code must retain the above 163e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * copyright notice, this list of conditions and the following 173e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * disclaimer. 183e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * 193e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * - Redistributions in binary form must reproduce the above 203e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * copyright notice, this list of conditions and the following 213e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * disclaimer in the documentation and/or other materials 223e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * provided with the distribution. 233e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * 243e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 253e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 263e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 273e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 283e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 293e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 303e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 313e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * SOFTWARE. 323e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan */ 333e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 343e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan#include <linux/ctype.h> 353e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 363e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan#include "ipath_kernel.h" 37bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones#include "ipath_verbs.h" 3827b678dd04a636f2c351816f4b3042c8815d4e9dBryan O'Sullivan#include "ipath_common.h" 393e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 403e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan/** 413e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * ipath_parse_ushort - parse an unsigned short value in an arbitrary base 423e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * @str: the string containing the number 433e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * @valp: where to put the result 443e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * 453e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * returns the number of bytes consumed, or negative value on error 463e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan */ 473e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanint ipath_parse_ushort(const char *str, unsigned short *valp) 483e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 493e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan unsigned long val; 503e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *end; 513e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int ret; 523e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 533e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (!isdigit(str[0])) { 543e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 553e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 563e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 573e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 583e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan val = simple_strtoul(str, &end, 0); 593e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 603e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (val > 0xffff) { 613e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 623e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 633e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 643e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 653e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan *valp = val; 663e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 673e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = end + 1 - str; 683e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (ret == 0) 693e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 703e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 713e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 723e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 733e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 743e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 753e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_version(struct device_driver *dev, char *buf) 763e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 773e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan /* The string printed here is already newline-terminated. */ 78b55f4f06c834a67f949a5219c5f97ffafa240989Bryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "%s", ib_ipath_version); 793e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 803e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 813e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_num_units(struct device_driver *dev, char *buf) 823e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 833e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "%d\n", 843e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_count_units(NULL, NULL, NULL)); 853e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 863e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 873e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_status(struct device *dev, 883e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 893e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 903e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 913e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 923e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ssize_t ret; 933e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 943e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (!dd->ipath_statusp) { 953e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 963e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 973e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 983e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 993e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = scnprintf(buf, PAGE_SIZE, "0x%llx\n", 1003e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan (unsigned long long) *(dd->ipath_statusp)); 1013e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1023e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 1033e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 1043e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 1053e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1063e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic const char *ipath_status_str[] = { 1073e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "Initted", 1083e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "Disabled", 1093e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "Admin_Disabled", 1100fd41363e0785247b7c19127318abc8b5eacc86bBryan O'Sullivan "", /* This used to be the old "OIB_SMA" status. */ 1110fd41363e0785247b7c19127318abc8b5eacc86bBryan O'Sullivan "", /* This used to be the old "SMA" status. */ 1123e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "Present", 1133e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "IB_link_up", 1143e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "IB_configured", 1153e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "NoIBcable", 1163e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "Fatal_Hardware_Error", 1173e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan NULL, 1183e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan}; 1193e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1203e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_status_str(struct device *dev, 1213e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 1223e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 1233e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 1243e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 1253e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int i, any; 1263e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan u64 s; 1273e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ssize_t ret; 1283e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1293e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (!dd->ipath_statusp) { 1303e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 1313e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 1323e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 1333e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1343e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan s = *(dd->ipath_statusp); 1353e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan *buf = '\0'; 1363e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan for (any = i = 0; s && ipath_status_str[i]; i++) { 1373e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (s & 1) { 1383e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (any && strlcat(buf, " ", PAGE_SIZE) >= 1393e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan PAGE_SIZE) 1403e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan /* overflow */ 1413e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan break; 1423e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (strlcat(buf, ipath_status_str[i], 1433e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan PAGE_SIZE) >= PAGE_SIZE) 1443e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan break; 1453e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan any = 1; 1463e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 1473e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan s >>= 1; 1483e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 1493e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (any) 1503e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan strlcat(buf, "\n", PAGE_SIZE); 1513e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1523e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = strlen(buf); 1533e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1543e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 1553e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 1563e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 1573e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1583e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_boardversion(struct device *dev, 1593e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 1603e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 1613e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 1623e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 1633e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan /* The string printed here is already newline-terminated. */ 1643e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "%s", dd->ipath_boardversion); 1653e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 1663e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1676ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jonesstatic ssize_t show_localbus_info(struct device *dev, 1686ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones struct device_attribute *attr, 1696ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones char *buf) 1706ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones{ 1716ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones struct ipath_devdata *dd = dev_get_drvdata(dev); 1726ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones /* The string printed here is already newline-terminated. */ 1736ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones return scnprintf(buf, PAGE_SIZE, "%s", dd->ipath_lbus_info); 1746ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones} 1756ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones 17615cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbellstatic ssize_t show_lmc(struct device *dev, 17715cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell struct device_attribute *attr, 17815cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell char *buf) 17915cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell{ 18015cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell struct ipath_devdata *dd = dev_get_drvdata(dev); 18115cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell 18215cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_lmc); 18315cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell} 18415cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell 18515cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbellstatic ssize_t store_lmc(struct device *dev, 18615cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell struct device_attribute *attr, 18715cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell const char *buf, 18815cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell size_t count) 18915cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell{ 19015cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell struct ipath_devdata *dd = dev_get_drvdata(dev); 19115cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell u16 lmc = 0; 19215cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell int ret; 19315cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell 19415cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell ret = ipath_parse_ushort(buf, &lmc); 19515cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell if (ret < 0) 19615cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell goto invalid; 19715cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell 19815cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell if (lmc > 7) { 19915cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell ret = -EINVAL; 20015cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell goto invalid; 20115cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell } 20215cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell 20315cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell ipath_set_lid(dd, dd->ipath_lid, lmc); 20415cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell 20515cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell goto bail; 20615cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbellinvalid: 20715cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell ipath_dev_err(dd, "attempt to set invalid LMC %u\n", lmc); 20815cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbellbail: 20915cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell return ret; 21015cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell} 21115cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell 2123e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_lid(struct device *dev, 2133e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 2143e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 2153e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 2163e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 2173e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2183e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "0x%x\n", dd->ipath_lid); 2193e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 2203e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2213e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t store_lid(struct device *dev, 2223e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 2233e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan const char *buf, 2243e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan size_t count) 2253e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 2263e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 2271eb68b990aab4c007e520acae39c74d8116693bcBryan O'Sullivan u16 lid = 0; 2283e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int ret; 2293e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2303e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = ipath_parse_ushort(buf, &lid); 2313e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (ret < 0) 2323e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto invalid; 2333e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 23427b678dd04a636f2c351816f4b3042c8815d4e9dBryan O'Sullivan if (lid == 0 || lid >= IPATH_MULTICAST_LID_BASE) { 2353e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 2363e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto invalid; 2373e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 2383e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 23915cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell ipath_set_lid(dd, lid, dd->ipath_lmc); 2403e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2413e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 2423e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivaninvalid: 2431eb68b990aab4c007e520acae39c74d8116693bcBryan O'Sullivan ipath_dev_err(dd, "attempt to set invalid LID 0x%x\n", lid); 2443e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 2453e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 2463e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 2473e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2483e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_mlid(struct device *dev, 2493e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 2503e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 2513e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 2523e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 2533e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2543e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "0x%x\n", dd->ipath_mlid); 2553e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 2563e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2573e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t store_mlid(struct device *dev, 2583e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 2593e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan const char *buf, 2603e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan size_t count) 2613e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 2623e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 2633e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan u16 mlid; 2643e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int ret; 2653e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2663e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = ipath_parse_ushort(buf, &mlid); 26727b678dd04a636f2c351816f4b3042c8815d4e9dBryan O'Sullivan if (ret < 0 || mlid < IPATH_MULTICAST_LID_BASE) 2683e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto invalid; 2693e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2703e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dd->ipath_mlid = mlid; 2713e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2723e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 2733e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivaninvalid: 2743e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_dev_err(dd, "attempt to set invalid MLID\n"); 2753e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 2763e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 2773e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 2783e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2793e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_guid(struct device *dev, 2803e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 2813e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 2823e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 2833e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 2843e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan u8 *guid; 2853e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2863e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan guid = (u8 *) & (dd->ipath_guid); 2873e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2883e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, 2893e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", 2903e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan guid[0], guid[1], guid[2], guid[3], 2913e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan guid[4], guid[5], guid[6], guid[7]); 2923e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 2933e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 2943e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t store_guid(struct device *dev, 2953e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 2963e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan const char *buf, 2973e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan size_t count) 2983e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 2993e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 3003e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ssize_t ret; 3013e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan unsigned short guid[8]; 30211b054fe1d453954449a86de178bb98274bb86efBryan O'Sullivan __be64 new_guid; 3033e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan u8 *ng; 3043e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int i; 3053e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3063e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (sscanf(buf, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", 3073e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &guid[0], &guid[1], &guid[2], &guid[3], 3083e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &guid[4], &guid[5], &guid[6], &guid[7]) != 8) 3093e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto invalid; 3103e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 31111b054fe1d453954449a86de178bb98274bb86efBryan O'Sullivan ng = (u8 *) &new_guid; 3123e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3133e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan for (i = 0; i < 8; i++) { 3143e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (guid[i] > 0xff) 3153e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto invalid; 3163e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ng[i] = guid[i]; 3173e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 3183e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 31911b054fe1d453954449a86de178bb98274bb86efBryan O'Sullivan if (new_guid == 0) 32011b054fe1d453954449a86de178bb98274bb86efBryan O'Sullivan goto invalid; 32111b054fe1d453954449a86de178bb98274bb86efBryan O'Sullivan 32211b054fe1d453954449a86de178bb98274bb86efBryan O'Sullivan dd->ipath_guid = new_guid; 3233e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dd->ipath_nguid = 1; 324bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones if (dd->verbs_dev) 325bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones dd->verbs_dev->ibdev.node_guid = new_guid; 3263e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3273e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = strlen(buf); 3283e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 3293e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3303e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivaninvalid: 3313e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_dev_err(dd, "attempt to set invalid GUID\n"); 3323e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 3333e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3343e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 3353e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 3363e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 3373e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3383e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_nguid(struct device *dev, 3393e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 3403e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 3413e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 3423e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 3433e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3443e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_nguid); 3453e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 3463e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3479929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivanstatic ssize_t show_nports(struct device *dev, 3489929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan struct device_attribute *attr, 3499929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan char *buf) 3509929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan{ 3519929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 3529929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan 3539929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan /* Return the number of user ports available. */ 3549929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_cfgports - 1); 3559929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan} 3569929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan 3573e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_serial(struct device *dev, 3583e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 3593e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 3603e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 3613e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 3623e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3633e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan buf[sizeof dd->ipath_serial] = '\0'; 3643e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan memcpy(buf, dd->ipath_serial, sizeof dd->ipath_serial); 3653e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan strcat(buf, "\n"); 3663e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return strlen(buf); 3673e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 3683e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3693e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_unit(struct device *dev, 3703e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 3713e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 3723e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 3733e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 3743e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 3753e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_unit); 3763e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 3773e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 378359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_jint_max_packets(struct device *dev, 379359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 380359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 381359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 382359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 383359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 384359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return scnprintf(buf, PAGE_SIZE, "%hu\n", dd->ipath_jint_max_packets); 385359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 386359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 387359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t store_jint_max_packets(struct device *dev, 388359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 389359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh const char *buf, 390359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh size_t count) 391359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 392359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 393359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh u16 v = 0; 394359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 395359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 396359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = ipath_parse_ushort(buf, &v); 397359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret < 0) 398359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ipath_dev_err(dd, "invalid jint_max_packets.\n"); 399359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh else 400359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh dd->ipath_f_config_jint(dd, dd->ipath_jint_idle_ticks, v); 401359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 402359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 403359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 404359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 405359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_jint_idle_ticks(struct device *dev, 406359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 407359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 408359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 409359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 410359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 411359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return scnprintf(buf, PAGE_SIZE, "%hu\n", dd->ipath_jint_idle_ticks); 412359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 413359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 414359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t store_jint_idle_ticks(struct device *dev, 415359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 416359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh const char *buf, 417359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh size_t count) 418359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 419359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 420359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh u16 v = 0; 421359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 422359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 423359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = ipath_parse_ushort(buf, &v); 424359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret < 0) 425359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ipath_dev_err(dd, "invalid jint_idle_ticks.\n"); 426359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh else 427359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh dd->ipath_f_config_jint(dd, v, dd->ipath_jint_max_packets); 428359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 429359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 430359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 431359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 4323e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan#define DEVICE_COUNTER(name, attr) \ 4333e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan static ssize_t show_counter_##name(struct device *dev, \ 4343e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, \ 4353e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) \ 4363e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan { \ 4373e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); \ 4383e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(\ 4393e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan buf, PAGE_SIZE, "%llu\n", (unsigned long long) \ 4403e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_snap_cntr( \ 4413e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dd, offsetof(struct infinipath_counters, \ 4423e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan attr) / sizeof(u64))); \ 4433e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } \ 4443e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan static DEVICE_ATTR(name, S_IRUGO, show_counter_##name, NULL); 4453e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 4463e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(ib_link_downeds, IBLinkDownedCnt); 4473e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(ib_link_err_recoveries, IBLinkErrRecoveryCnt); 4483e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(ib_status_changes, IBStatusChangeCnt); 4493e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(ib_symbol_errs, IBSymbolErrCnt); 4503e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(lb_flow_stalls, LBFlowStallCnt); 4513e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(lb_ints, LBIntCnt); 4523e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_bad_formats, RxBadFormatCnt); 4533e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_buf_ovfls, RxBufOvflCnt); 4543e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_data_pkts, RxDataPktCnt); 4553e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_dropped_pkts, RxDroppedPktCnt); 4563e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_dwords, RxDwordCnt); 4573e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_ebps, RxEBPCnt); 4583e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_flow_ctrl_errs, RxFlowCtrlErrCnt); 4593e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_flow_pkts, RxFlowPktCnt); 4603e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_icrc_errs, RxICRCErrCnt); 4613e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_len_errs, RxLenErrCnt); 4623e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_link_problems, RxLinkProblemCnt); 4633e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_lpcrc_errs, RxLPCRCErrCnt); 4643e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_max_min_len_errs, RxMaxMinLenErrCnt); 4653e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p0_hdr_egr_ovfls, RxP0HdrEgrOvflCnt); 4663e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p1_hdr_egr_ovfls, RxP1HdrEgrOvflCnt); 4673e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p2_hdr_egr_ovfls, RxP2HdrEgrOvflCnt); 4683e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p3_hdr_egr_ovfls, RxP3HdrEgrOvflCnt); 4693e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p4_hdr_egr_ovfls, RxP4HdrEgrOvflCnt); 4703e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p5_hdr_egr_ovfls, RxP5HdrEgrOvflCnt); 4713e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p6_hdr_egr_ovfls, RxP6HdrEgrOvflCnt); 4723e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p7_hdr_egr_ovfls, RxP7HdrEgrOvflCnt); 4733e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_p8_hdr_egr_ovfls, RxP8HdrEgrOvflCnt); 4743e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_pkey_mismatches, RxPKeyMismatchCnt); 4753e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_tid_full_errs, RxTIDFullErrCnt); 4763e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_tid_valid_errs, RxTIDValidErrCnt); 4773e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(rx_vcrc_errs, RxVCRCErrCnt); 4783e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_data_pkts, TxDataPktCnt); 4793e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_dropped_pkts, TxDroppedPktCnt); 4803e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_dwords, TxDwordCnt); 4813e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_flow_pkts, TxFlowPktCnt); 4823e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_flow_stalls, TxFlowStallCnt); 4833e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_len_errs, TxLenErrCnt); 4843e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_max_min_len_errs, TxMaxMinLenErrCnt); 4853e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_underruns, TxUnderrunCnt); 4863e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'SullivanDEVICE_COUNTER(tx_unsup_vl_errs, TxUnsupVLErrCnt); 4873e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 4883e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic struct attribute *dev_counter_attributes[] = { 4893e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_ib_link_downeds.attr, 4903e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_ib_link_err_recoveries.attr, 4913e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_ib_status_changes.attr, 4923e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_ib_symbol_errs.attr, 4933e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_lb_flow_stalls.attr, 4943e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_lb_ints.attr, 4953e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_bad_formats.attr, 4963e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_buf_ovfls.attr, 4973e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_data_pkts.attr, 4983e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_dropped_pkts.attr, 4993e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_dwords.attr, 5003e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_ebps.attr, 5013e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_flow_ctrl_errs.attr, 5023e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_flow_pkts.attr, 5033e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_icrc_errs.attr, 5043e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_len_errs.attr, 5053e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_link_problems.attr, 5063e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_lpcrc_errs.attr, 5073e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_max_min_len_errs.attr, 5083e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p0_hdr_egr_ovfls.attr, 5093e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p1_hdr_egr_ovfls.attr, 5103e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p2_hdr_egr_ovfls.attr, 5113e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p3_hdr_egr_ovfls.attr, 5123e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p4_hdr_egr_ovfls.attr, 5133e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p5_hdr_egr_ovfls.attr, 5143e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p6_hdr_egr_ovfls.attr, 5153e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p7_hdr_egr_ovfls.attr, 5163e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_p8_hdr_egr_ovfls.attr, 5173e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_pkey_mismatches.attr, 5183e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_tid_full_errs.attr, 5193e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_tid_valid_errs.attr, 5203e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_rx_vcrc_errs.attr, 5213e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_data_pkts.attr, 5223e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_dropped_pkts.attr, 5233e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_dwords.attr, 5243e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_flow_pkts.attr, 5253e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_flow_stalls.attr, 5263e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_len_errs.attr, 5273e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_max_min_len_errs.attr, 5283e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_underruns.attr, 5293e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_tx_unsup_vl_errs.attr, 5303e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan NULL 5313e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan}; 5323e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 5333e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic struct attribute_group dev_counter_attr_group = { 5343e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan .name = "counters", 5353e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan .attrs = dev_counter_attributes 5363e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan}; 5373e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 5383e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t store_reset(struct device *dev, 5393e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 5403e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan const char *buf, 5413e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan size_t count) 5423e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 5433e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 5443e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int ret; 5453e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 5463e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (count < 5 || memcmp(buf, "reset", 5)) { 5473e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 5483e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 5493e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 5503e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 5513e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (dd->ipath_flags & IPATH_DISABLED) { 5523e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan /* 5533e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * post-reset init would re-enable interrupts, etc. 5543e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * so don't allow reset on disabled devices. Not 5553e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * perfect error, but about the best choice. 5563e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan */ 5573e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dev_info(dev,"Unit %d is disabled, can't reset\n", 5583e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dd->ipath_unit); 5593e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = -EINVAL; 5603e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 5613e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = ipath_reset_device(dd->ipath_unit); 5623e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 5633e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret<0 ? ret : count; 5643e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 5653e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 5663e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t store_link_state(struct device *dev, 5673e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 5683e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan const char *buf, 5693e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan size_t count) 5703e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 5713e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 5723e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int ret, r; 5733e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan u16 state; 5743e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 5753e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = ipath_parse_ushort(buf, &state); 5763e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (ret < 0) 5773e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto invalid; 5783e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 57934b2aafea38efdf02cd8107a6e1057e2a297c447Bryan O'Sullivan r = ipath_set_linkstate(dd, state); 5803e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (r < 0) { 5813e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = r; 5823e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 5833e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 5843e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 5853e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 5863e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivaninvalid: 5873e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_dev_err(dd, "attempt to set invalid link state\n"); 5883e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 5893e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 5903e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 5913e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 5923e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_mtu(struct device *dev, 5933e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 5943e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 5953e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 5963e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 5973e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_ibmtu); 5983e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 5993e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6003e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t store_mtu(struct device *dev, 6013e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 6023e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan const char *buf, 6033e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan size_t count) 6043e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 6053e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 6063e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ssize_t ret; 6073e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan u16 mtu = 0; 6083e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int r; 6093e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6103e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = ipath_parse_ushort(buf, &mtu); 6113e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (ret < 0) 6123e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto invalid; 6133e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 61434b2aafea38efdf02cd8107a6e1057e2a297c447Bryan O'Sullivan r = ipath_set_mtu(dd, mtu); 6153e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (r < 0) 6163e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = r; 6173e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6183e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 6193e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivaninvalid: 6203e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_dev_err(dd, "attempt to set invalid MTU\n"); 6213e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 6223e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 6233e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 6243e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6253e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t show_enabled(struct device *dev, 6263e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 6273e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan char *buf) 6283e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 6293e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 6303e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return scnprintf(buf, PAGE_SIZE, "%u\n", 6313e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan (dd->ipath_flags & IPATH_DISABLED) ? 0 : 1); 6323e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 6333e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6343e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic ssize_t store_enabled(struct device *dev, 6353e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct device_attribute *attr, 6363e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan const char *buf, 6373e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan size_t count) 6383e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 6393e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 6403e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ssize_t ret; 6413e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan u16 enable = 0; 6423e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6433e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = ipath_parse_ushort(buf, &enable); 6443e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (ret < 0) { 6453e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_dev_err(dd, "attempt to use non-numeric on enable\n"); 6463e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 6473e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 6483e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6493e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (enable) { 6503e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (!(dd->ipath_flags & IPATH_DISABLED)) 6513e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 6523e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6533e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dev_info(dev, "Enabling unit %d\n", dd->ipath_unit); 6543e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan /* same as post-reset */ 6553e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = ipath_init_chip(dd, 1); 6563e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (ret) 6573e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_dev_err(dd, "Failed to enable unit %d\n", 6583e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dd->ipath_unit); 6593e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan else { 6603e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dd->ipath_flags &= ~IPATH_DISABLED; 6613e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan *dd->ipath_statusp &= ~IPATH_STATUS_ADMIN_DISABLED; 6623e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 6633e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 6643e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan else if (!(dd->ipath_flags & IPATH_DISABLED)) { 6653e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dev_info(dev, "Disabling unit %d\n", dd->ipath_unit); 6663e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ipath_shutdown_device(dd); 6673e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan dd->ipath_flags |= IPATH_DISABLED; 6683e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan *dd->ipath_statusp |= IPATH_STATUS_ADMIN_DISABLED; 6693e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan } 6703e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 6713e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 6723e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 6733e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 6743e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 67530fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivanstatic ssize_t store_rx_pol_inv(struct device *dev, 67630fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan struct device_attribute *attr, 67730fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan const char *buf, 67830fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan size_t count) 67930fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan{ 68030fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan struct ipath_devdata *dd = dev_get_drvdata(dev); 68130fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan int ret, r; 68230fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan u16 val; 68330fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan 68430fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan ret = ipath_parse_ushort(buf, &val); 68530fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan if (ret < 0) 68630fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan goto invalid; 68730fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan 68830fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan r = ipath_set_rx_pol_inv(dd, val); 68930fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan if (r < 0) { 69030fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan ret = r; 69130fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan goto bail; 69230fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan } 69330fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan 69430fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan goto bail; 69530fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivaninvalid: 69630fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan ipath_dev_err(dd, "attempt to set invalid Rx Polarity invert\n"); 69730fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivanbail: 69830fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan return ret; 69930fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan} 70030fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan 70182466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaughstatic ssize_t store_led_override(struct device *dev, 70282466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh struct device_attribute *attr, 70382466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh const char *buf, 70482466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh size_t count) 70582466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh{ 70682466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 70782466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh int ret; 70882466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh u16 val; 70982466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh 71082466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh ret = ipath_parse_ushort(buf, &val); 71182466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh if (ret > 0) 71282466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh ipath_set_led_override(dd, val); 71382466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh else 71482466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh ipath_dev_err(dd, "attempt to set invalid LED override\n"); 71582466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh return ret; 71682466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh} 71782466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh 718aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaughstatic ssize_t show_logged_errs(struct device *dev, 719aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh struct device_attribute *attr, 720aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh char *buf) 721aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh{ 722aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 723aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh int idx, count; 724aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh 725aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh /* force consistency with actual EEPROM */ 726aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh if (ipath_update_eeprom_log(dd) != 0) 727aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh return -ENXIO; 728aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh 729aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh count = 0; 730aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh for (idx = 0; idx < IPATH_EEP_LOG_CNT; ++idx) { 731aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh count += scnprintf(buf + count, PAGE_SIZE - count, "%d%c", 732aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh dd->ipath_eep_st_errs[idx], 733aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh idx == (IPATH_EEP_LOG_CNT - 1) ? '\n' : ' '); 734aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh } 735aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh 736aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh return count; 737aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh} 73830fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan 739359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh/* 740359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * New sysfs entries to control various IB config. These all turn into 741359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * accesses via ipath_f_get/set_ib_cfg. 742359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * 743359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * Get/Set heartbeat enable. Or of 1=enabled, 2=auto 744359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh */ 745359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_hrtbt_enb(struct device *dev, 746359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 747359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 748359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 749359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 750359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 751359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 752359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_HRTBT); 753359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0) 754359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret); 755359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 756359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 757359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 758359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t store_hrtbt_enb(struct device *dev, 759359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 760359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh const char *buf, 761359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh size_t count) 762359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 763359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 764359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret, r; 765359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh u16 val; 766359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 767359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = ipath_parse_ushort(buf, &val); 768359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0 && val > 3) 769359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = -EINVAL; 770359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret < 0) { 771359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ipath_dev_err(dd, "attempt to set invalid Heartbeat enable\n"); 772359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh goto bail; 773359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh } 774359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 775359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh /* 776359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * Set the "intentional" heartbeat enable per either of 777359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * "Enable" and "Auto", as these are normally set together. 778359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * This bit is consulted when leaving loopback mode, 779359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * because entering loopback mode overrides it and automatically 780359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * disables heartbeat. 781359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh */ 782359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_HRTBT, val); 783359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (r < 0) 784359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = r; 785359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh else if (val == IPATH_IB_HRTBT_OFF) 786359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh dd->ipath_flags |= IPATH_NO_HRTBT; 787359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh else 788359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh dd->ipath_flags &= ~IPATH_NO_HRTBT; 789359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 790359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughbail: 791359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 792359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 793359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 794359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh/* 795359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * Get/Set Link-widths enabled. Or of 1=1x, 2=4x (this is human/IB centric, 796359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * _not_ the particular encoding of any given chip) 797359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh */ 798359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_lwid_enb(struct device *dev, 799359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 800359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 801359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 802359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 803359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 804359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 805359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LWID_ENB); 806359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0) 807359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret); 808359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 809359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 810359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 811359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t store_lwid_enb(struct device *dev, 812359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 813359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh const char *buf, 814359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh size_t count) 815359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 816359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 817359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret, r; 818359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh u16 val; 819359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 820359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = ipath_parse_ushort(buf, &val); 821359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0 && (val == 0 || val > 3)) 822359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = -EINVAL; 823359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret < 0) { 824359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ipath_dev_err(dd, 825359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh "attempt to set invalid Link Width (enable)\n"); 826359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh goto bail; 827359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh } 828359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 829359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_LWID_ENB, val); 830359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (r < 0) 831359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = r; 832359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 833359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughbail: 834359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 835359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 836359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 837359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh/* Get current link width */ 838359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_lwid(struct device *dev, 839359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 840359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 841359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 842359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 843359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 844359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 845359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 846359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LWID); 847359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0) 848359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret); 849359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 850359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 851359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 852359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh/* 853359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * Get/Set Link-speeds enabled. Or of 1=SDR 2=DDR. 854359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh */ 855359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_spd_enb(struct device *dev, 856359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 857359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 858359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 859359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 860359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 861359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 862359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_SPD_ENB); 863359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0) 864359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret); 865359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 866359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 867359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 868359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t store_spd_enb(struct device *dev, 869359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 870359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh const char *buf, 871359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh size_t count) 872359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 873359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 874359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret, r; 875359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh u16 val; 876359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 877359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = ipath_parse_ushort(buf, &val); 878359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0 && (val == 0 || val > (IPATH_IB_SDR | IPATH_IB_DDR))) 879359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = -EINVAL; 880359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret < 0) { 881359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ipath_dev_err(dd, 882359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh "attempt to set invalid Link Speed (enable)\n"); 883359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh goto bail; 884359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh } 885359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 886359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_SPD_ENB, val); 887359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (r < 0) 888359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = r; 889359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 890359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughbail: 891359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 892359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 893359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 894359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh/* Get current link speed */ 895359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_spd(struct device *dev, 896359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 897359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 898359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 899359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 900359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 901359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 902359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_SPD); 903359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0) 904359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret); 905359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 906359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 907359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 908359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh/* 909359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * Get/Set RX polarity-invert enable. 0=no, 1=yes. 910359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh */ 911359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_rx_polinv_enb(struct device *dev, 912359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 913359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 914359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 915359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 916359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 917359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 918359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_RXPOL_ENB); 919359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0) 920359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret); 921359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 922359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 923359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 924359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t store_rx_polinv_enb(struct device *dev, 925359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 926359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh const char *buf, 927359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh size_t count) 928359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 929359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 930359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret, r; 931359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh u16 val; 932359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 933359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = ipath_parse_ushort(buf, &val); 934bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones if (ret >= 0 && val > 1) { 935bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones ipath_dev_err(dd, 936bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones "attempt to set invalid Rx Polarity (enable)\n"); 937bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones ret = -EINVAL; 938bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones goto bail; 939bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones } 940359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 941359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_RXPOL_ENB, val); 942bb9171448deb1f7ece27674e2e431e4f267fd453Arthur Jones if (r < 0) 943359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = r; 944359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 945359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughbail: 946359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 947359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 948d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh 949359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh/* 950359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh * Get/Set RX lane-reversal enable. 0=no, 1=yes. 951359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh */ 952359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t show_lanerev_enb(struct device *dev, 953359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 954359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh char *buf) 955359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 956359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 957359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret; 958359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 959359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LREV_ENB); 960359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0) 961359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret); 962359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 963359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 964359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 965359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic ssize_t store_lanerev_enb(struct device *dev, 966359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct device_attribute *attr, 967359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh const char *buf, 968359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh size_t count) 969359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh{ 970359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 971359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh int ret, r; 972359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh u16 val; 973359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 974359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = ipath_parse_ushort(buf, &val); 975359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret >= 0 && val > 1) { 976359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = -EINVAL; 977359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ipath_dev_err(dd, 978359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh "attempt to set invalid Lane reversal (enable)\n"); 979359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh goto bail; 980359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh } 981359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 982359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_LREV_ENB, val); 983359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (r < 0) 984359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = r; 985359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 986359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughbail: 987359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh return ret; 988359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh} 989359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 9903e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DRIVER_ATTR(num_units, S_IRUGO, show_num_units, NULL); 9913e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DRIVER_ATTR(version, S_IRUGO, show_version, NULL); 9923e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 9933e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic struct attribute *driver_attributes[] = { 9943e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &driver_attr_num_units.attr, 9953e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &driver_attr_version.attr, 9963e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan NULL 9973e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan}; 9983e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 9993e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic struct attribute_group driver_attr_group = { 10003e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan .attrs = driver_attributes 10013e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan}; 10023e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1003d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaughstatic ssize_t store_tempsense(struct device *dev, 1004d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh struct device_attribute *attr, 1005d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh const char *buf, 1006d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh size_t count) 1007d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh{ 1008d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 1009d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh int ret, stat; 1010d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh u16 val; 1011d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh 1012d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ret = ipath_parse_ushort(buf, &val); 1013d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh if (ret <= 0) { 1014d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ipath_dev_err(dd, "attempt to set invalid tempsense config\n"); 1015d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh goto bail; 1016d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh } 1017d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh /* If anything but the highest limit, enable T_CRIT_A "interrupt" */ 1018d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh stat = ipath_tempsense_write(dd, 9, (val == 0x7f7f) ? 0x80 : 0); 1019d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh if (stat) { 1020d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ipath_dev_err(dd, "Unable to set tempsense config\n"); 1021d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ret = -1; 1022d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh goto bail; 1023d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh } 1024d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh stat = ipath_tempsense_write(dd, 0xB, (u8) (val & 0xFF)); 1025d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh if (stat) { 1026d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ipath_dev_err(dd, "Unable to set local Tcrit\n"); 1027d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ret = -1; 1028d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh goto bail; 1029d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh } 1030d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh stat = ipath_tempsense_write(dd, 0xD, (u8) (val >> 8)); 1031d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh if (stat) { 1032d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ipath_dev_err(dd, "Unable to set remote Tcrit\n"); 1033d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ret = -1; 1034d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh goto bail; 1035d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh } 1036d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh 1037d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaughbail: 1038d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh return ret; 1039d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh} 1040d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh 1041d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh/* 1042d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh * dump tempsense regs. in decimal, to ease shell-scripts. 1043d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh */ 1044d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaughstatic ssize_t show_tempsense(struct device *dev, 1045d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh struct device_attribute *attr, 1046d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh char *buf) 1047d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh{ 1048d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh struct ipath_devdata *dd = dev_get_drvdata(dev); 1049d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh int ret; 1050d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh int idx; 1051d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh u8 regvals[8]; 1052d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh 1053d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ret = -ENXIO; 1054d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh for (idx = 0; idx < 8; ++idx) { 1055d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh if (idx == 6) 1056d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh continue; 1057d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ret = ipath_tempsense_read(dd, idx); 1058d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh if (ret < 0) 1059d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh break; 1060d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh regvals[idx] = ret; 1061d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh } 1062d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh if (idx == 8) 1063d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh ret = scnprintf(buf, PAGE_SIZE, "%d %d %02X %02X %d %d\n", 1064d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh *(signed char *)(regvals), 1065d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh *(signed char *)(regvals + 1), 1066d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh regvals[2], regvals[3], 1067d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh *(signed char *)(regvals + 5), 1068d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh *(signed char *)(regvals + 7)); 1069d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh return ret; 1070d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh} 1071d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh 1072a4dbd6740df0872cdf0a86841f75beec8381964dDavid Brownellconst struct attribute_group *ipath_driver_attr_groups[] = { 107323b9c1ab5baf368a32b7242bf110ef1f48700d04Greg Kroah-Hartman &driver_attr_group, 107423b9c1ab5baf368a32b7242bf110ef1f48700d04Greg Kroah-Hartman NULL, 107523b9c1ab5baf368a32b7242bf110ef1f48700d04Greg Kroah-Hartman}; 107623b9c1ab5baf368a32b7242bf110ef1f48700d04Greg Kroah-Hartman 10773e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(guid, S_IWUSR | S_IRUGO, show_guid, store_guid); 107815cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbellstatic DEVICE_ATTR(lmc, S_IWUSR | S_IRUGO, show_lmc, store_lmc); 10793e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(lid, S_IWUSR | S_IRUGO, show_lid, store_lid); 10803e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(link_state, S_IWUSR, NULL, store_link_state); 10813e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(mlid, S_IWUSR | S_IRUGO, show_mlid, store_mlid); 10823e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(mtu, S_IWUSR | S_IRUGO, show_mtu, store_mtu); 10833e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO, show_enabled, store_enabled); 10843e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(nguid, S_IRUGO, show_nguid, NULL); 10859929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivanstatic DEVICE_ATTR(nports, S_IRUGO, show_nports, NULL); 10863e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(reset, S_IWUSR, NULL, store_reset); 10873e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL); 10883e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(status, S_IRUGO, show_status, NULL); 10893e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(status_str, S_IRUGO, show_status_str, NULL); 10903e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(boardversion, S_IRUGO, show_boardversion, NULL); 10913e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic DEVICE_ATTR(unit, S_IRUGO, show_unit, NULL); 109230fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivanstatic DEVICE_ATTR(rx_pol_inv, S_IWUSR, NULL, store_rx_pol_inv); 109382466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaughstatic DEVICE_ATTR(led_override, S_IWUSR, NULL, store_led_override); 1094aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaughstatic DEVICE_ATTR(logged_errors, S_IRUGO, show_logged_errs, NULL); 10956ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jonesstatic DEVICE_ATTR(localbus_info, S_IRUGO, show_localbus_info, NULL); 1096359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(jint_max_packets, S_IWUSR | S_IRUGO, 1097359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh show_jint_max_packets, store_jint_max_packets); 1098359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(jint_idle_ticks, S_IWUSR | S_IRUGO, 1099359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh show_jint_idle_ticks, store_jint_idle_ticks); 1100d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaughstatic DEVICE_ATTR(tempsense, S_IWUSR | S_IRUGO, 1101d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh show_tempsense, store_tempsense); 11023e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 11033e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic struct attribute *dev_attributes[] = { 11043e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_guid.attr, 110515cba26f42c13ca30cbb4388f132ac0ddf4df538Ralph Campbell &dev_attr_lmc.attr, 11063e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_lid.attr, 11073e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_link_state.attr, 11083e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_mlid.attr, 11093e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_mtu.attr, 11103e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_nguid.attr, 11119929b0fb0f35f54371e9364bab809bcd753f9d3aBryan O'Sullivan &dev_attr_nports.attr, 11123e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_serial.attr, 11133e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_status.attr, 11143e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_status_str.attr, 11153e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_boardversion.attr, 11163e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_unit.attr, 11173e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan &dev_attr_enabled.attr, 111830fc5c3130bdbc7cc051a2d6054ad38360d408a8Bryan O'Sullivan &dev_attr_rx_pol_inv.attr, 111982466f00ec6ef0a5ca7ea8991c731af2ec561c7dMichael Albaugh &dev_attr_led_override.attr, 1120aecd3b5ab19624ca9644b9df9c61615282d8923fMichael Albaugh &dev_attr_logged_errors.attr, 1121d84e0b28d3a0b41fc574ea50d60522ae0fba75f4Michael Albaugh &dev_attr_tempsense.attr, 11226ca2abf4c02fb3e35247a985c2b6f5834e995033Arthur Jones &dev_attr_localbus_info.attr, 11233e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan NULL 11243e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan}; 11253e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 11263e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanstatic struct attribute_group dev_attr_group = { 11273e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan .attrs = dev_attributes 11283e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan}; 11293e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1130359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(hrtbt_enable, S_IWUSR | S_IRUGO, show_hrtbt_enb, 1131359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh store_hrtbt_enb); 1132359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(link_width_enable, S_IWUSR | S_IRUGO, show_lwid_enb, 1133359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh store_lwid_enb); 1134359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(link_width, S_IRUGO, show_lwid, NULL); 1135359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(link_speed_enable, S_IWUSR | S_IRUGO, show_spd_enb, 1136359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh store_spd_enb); 1137359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(link_speed, S_IRUGO, show_spd, NULL); 1138359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(rx_pol_inv_enable, S_IWUSR | S_IRUGO, show_rx_polinv_enb, 1139359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh store_rx_polinv_enb); 1140359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic DEVICE_ATTR(rx_lane_rev_enable, S_IWUSR | S_IRUGO, show_lanerev_enb, 1141359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh store_lanerev_enb); 1142359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 1143359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic struct attribute *dev_ibcfg_attributes[] = { 1144359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh &dev_attr_hrtbt_enable.attr, 1145359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh &dev_attr_link_width_enable.attr, 1146359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh &dev_attr_link_width.attr, 1147359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh &dev_attr_link_speed_enable.attr, 1148359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh &dev_attr_link_speed.attr, 1149359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh &dev_attr_rx_pol_inv_enable.attr, 1150359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh &dev_attr_rx_lane_rev_enable.attr, 1151359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh NULL 1152359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh}; 1153359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 1154359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughstatic struct attribute_group dev_ibcfg_attr_group = { 1155359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh .attrs = dev_ibcfg_attributes 1156359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh}; 1157359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 11583e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan/** 11593e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * ipath_expose_reset - create a device reset file 11603e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * @dev: the device structure 11613e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * 11623e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * Only expose a file that lets us reset the device after someone 11633e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * enters diag mode. A device reset is quite likely to crash the 11643e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * machine entirely, so we don't want to normally make it 11653e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan * available. 1166755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan * 1167755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan * Called with ipath_mutex held. 11683e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan */ 11693e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanint ipath_expose_reset(struct device *dev) 11703e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 1171755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan static int exposed; 1172755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan int ret; 1173755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan 1174755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan if (!exposed) { 1175755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan ret = device_create_file(dev, &dev_attr_reset); 1176755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan exposed = 1; 1177755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan } 1178755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan else 1179755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan ret = 0; 1180755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan 1181755e4ca4a9885b79a14169ab5b615920eb38a32aBryan O'Sullivan return ret; 11823e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 11833e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 11843e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanint ipath_device_create_group(struct device *dev, struct ipath_devdata *dd) 11853e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 11863e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan int ret; 11873e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 11883e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = sysfs_create_group(&dev->kobj, &dev_attr_group); 11893e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (ret) 11903e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail; 11913e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 11923e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan ret = sysfs_create_group(&dev->kobj, &dev_counter_attr_group); 11933e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan if (ret) 11943e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan goto bail_attrs; 11953e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 1196359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (dd->ipath_flags & IPATH_HAS_MULT_IB_SPEED) { 1197359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = device_create_file(dev, &dev_attr_jint_idle_ticks); 1198359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret) 1199359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh goto bail_counter; 1200359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = device_create_file(dev, &dev_attr_jint_max_packets); 1201359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret) 1202359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh goto bail_idle; 1203359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 1204359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh ret = sysfs_create_group(&dev->kobj, &dev_ibcfg_attr_group); 1205359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (ret) 1206359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh goto bail_max; 1207359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh } 1208359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 1209657c2f2cbccbac88689ac5174fc13dd3f9aece34Roland Dreier return 0; 1210657c2f2cbccbac88689ac5174fc13dd3f9aece34Roland Dreier 1211359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughbail_max: 1212359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh device_remove_file(dev, &dev_attr_jint_max_packets); 1213359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughbail_idle: 1214359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh device_remove_file(dev, &dev_attr_jint_idle_ticks); 1215359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaughbail_counter: 1216359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh sysfs_remove_group(&dev->kobj, &dev_counter_attr_group); 12173e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail_attrs: 12183e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan sysfs_remove_group(&dev->kobj, &dev_attr_group); 12193e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanbail: 12203e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan return ret; 12213e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 12223e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 12233e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivanvoid ipath_device_remove_group(struct device *dev, struct ipath_devdata *dd) 12243e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan{ 12253e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan sysfs_remove_group(&dev->kobj, &dev_counter_attr_group); 1226359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 1227359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh if (dd->ipath_flags & IPATH_HAS_MULT_IB_SPEED) { 1228359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh sysfs_remove_group(&dev->kobj, &dev_ibcfg_attr_group); 1229359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh device_remove_file(dev, &dev_attr_jint_idle_ticks); 1230359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh device_remove_file(dev, &dev_attr_jint_max_packets); 1231359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh } 1232359193ef433061515fe24d57e5bd5a1318d71bc3Michael Albaugh 12333e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan sysfs_remove_group(&dev->kobj, &dev_attr_group); 12343e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan 12353e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan device_remove_file(dev, &dev_attr_reset); 12363e9b4a5eb4ae4936feeea256c0105e078c7702cdBryan O'Sullivan} 1237