ipath_sysfs.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  1. /*
  2. * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved.
  3. * Copyright (c) 2006 PathScale, Inc. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #include <linux/ctype.h>
  34. #include "ipath_kernel.h"
  35. #include "ipath_common.h"
  36. /**
  37. * ipath_parse_ushort - parse an unsigned short value in an arbitrary base
  38. * @str: the string containing the number
  39. * @valp: where to put the result
  40. *
  41. * returns the number of bytes consumed, or negative value on error
  42. */
  43. int ipath_parse_ushort(const char *str, unsigned short *valp)
  44. {
  45. unsigned long val;
  46. char *end;
  47. int ret;
  48. if (!isdigit(str[0])) {
  49. ret = -EINVAL;
  50. goto bail;
  51. }
  52. val = simple_strtoul(str, &end, 0);
  53. if (val > 0xffff) {
  54. ret = -EINVAL;
  55. goto bail;
  56. }
  57. *valp = val;
  58. ret = end + 1 - str;
  59. if (ret == 0)
  60. ret = -EINVAL;
  61. bail:
  62. return ret;
  63. }
  64. static ssize_t show_version(struct device_driver *dev, char *buf)
  65. {
  66. /* The string printed here is already newline-terminated. */
  67. return scnprintf(buf, PAGE_SIZE, "%s", ib_ipath_version);
  68. }
  69. static ssize_t show_num_units(struct device_driver *dev, char *buf)
  70. {
  71. return scnprintf(buf, PAGE_SIZE, "%d\n",
  72. ipath_count_units(NULL, NULL, NULL));
  73. }
  74. static ssize_t show_status(struct device *dev,
  75. struct device_attribute *attr,
  76. char *buf)
  77. {
  78. struct ipath_devdata *dd = dev_get_drvdata(dev);
  79. ssize_t ret;
  80. if (!dd->ipath_statusp) {
  81. ret = -EINVAL;
  82. goto bail;
  83. }
  84. ret = scnprintf(buf, PAGE_SIZE, "0x%llx\n",
  85. (unsigned long long) *(dd->ipath_statusp));
  86. bail:
  87. return ret;
  88. }
  89. static const char *ipath_status_str[] = {
  90. "Initted",
  91. "Disabled",
  92. "Admin_Disabled",
  93. "", /* This used to be the old "OIB_SMA" status. */
  94. "", /* This used to be the old "SMA" status. */
  95. "Present",
  96. "IB_link_up",
  97. "IB_configured",
  98. "NoIBcable",
  99. "Fatal_Hardware_Error",
  100. NULL,
  101. };
  102. static ssize_t show_status_str(struct device *dev,
  103. struct device_attribute *attr,
  104. char *buf)
  105. {
  106. struct ipath_devdata *dd = dev_get_drvdata(dev);
  107. int i, any;
  108. u64 s;
  109. ssize_t ret;
  110. if (!dd->ipath_statusp) {
  111. ret = -EINVAL;
  112. goto bail;
  113. }
  114. s = *(dd->ipath_statusp);
  115. *buf = '\0';
  116. for (any = i = 0; s && ipath_status_str[i]; i++) {
  117. if (s & 1) {
  118. if (any && strlcat(buf, " ", PAGE_SIZE) >=
  119. PAGE_SIZE)
  120. /* overflow */
  121. break;
  122. if (strlcat(buf, ipath_status_str[i],
  123. PAGE_SIZE) >= PAGE_SIZE)
  124. break;
  125. any = 1;
  126. }
  127. s >>= 1;
  128. }
  129. if (any)
  130. strlcat(buf, "\n", PAGE_SIZE);
  131. ret = strlen(buf);
  132. bail:
  133. return ret;
  134. }
  135. static ssize_t show_boardversion(struct device *dev,
  136. struct device_attribute *attr,
  137. char *buf)
  138. {
  139. struct ipath_devdata *dd = dev_get_drvdata(dev);
  140. /* The string printed here is already newline-terminated. */
  141. return scnprintf(buf, PAGE_SIZE, "%s", dd->ipath_boardversion);
  142. }
  143. static ssize_t show_localbus_info(struct device *dev,
  144. struct device_attribute *attr,
  145. char *buf)
  146. {
  147. struct ipath_devdata *dd = dev_get_drvdata(dev);
  148. /* The string printed here is already newline-terminated. */
  149. return scnprintf(buf, PAGE_SIZE, "%s", dd->ipath_lbus_info);
  150. }
  151. static ssize_t show_lmc(struct device *dev,
  152. struct device_attribute *attr,
  153. char *buf)
  154. {
  155. struct ipath_devdata *dd = dev_get_drvdata(dev);
  156. return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_lmc);
  157. }
  158. static ssize_t store_lmc(struct device *dev,
  159. struct device_attribute *attr,
  160. const char *buf,
  161. size_t count)
  162. {
  163. struct ipath_devdata *dd = dev_get_drvdata(dev);
  164. u16 lmc = 0;
  165. int ret;
  166. ret = ipath_parse_ushort(buf, &lmc);
  167. if (ret < 0)
  168. goto invalid;
  169. if (lmc > 7) {
  170. ret = -EINVAL;
  171. goto invalid;
  172. }
  173. ipath_set_lid(dd, dd->ipath_lid, lmc);
  174. goto bail;
  175. invalid:
  176. ipath_dev_err(dd, "attempt to set invalid LMC %u\n", lmc);
  177. bail:
  178. return ret;
  179. }
  180. static ssize_t show_lid(struct device *dev,
  181. struct device_attribute *attr,
  182. char *buf)
  183. {
  184. struct ipath_devdata *dd = dev_get_drvdata(dev);
  185. return scnprintf(buf, PAGE_SIZE, "0x%x\n", dd->ipath_lid);
  186. }
  187. static ssize_t store_lid(struct device *dev,
  188. struct device_attribute *attr,
  189. const char *buf,
  190. size_t count)
  191. {
  192. struct ipath_devdata *dd = dev_get_drvdata(dev);
  193. u16 lid = 0;
  194. int ret;
  195. ret = ipath_parse_ushort(buf, &lid);
  196. if (ret < 0)
  197. goto invalid;
  198. if (lid == 0 || lid >= IPATH_MULTICAST_LID_BASE) {
  199. ret = -EINVAL;
  200. goto invalid;
  201. }
  202. ipath_set_lid(dd, lid, dd->ipath_lmc);
  203. goto bail;
  204. invalid:
  205. ipath_dev_err(dd, "attempt to set invalid LID 0x%x\n", lid);
  206. bail:
  207. return ret;
  208. }
  209. static ssize_t show_mlid(struct device *dev,
  210. struct device_attribute *attr,
  211. char *buf)
  212. {
  213. struct ipath_devdata *dd = dev_get_drvdata(dev);
  214. return scnprintf(buf, PAGE_SIZE, "0x%x\n", dd->ipath_mlid);
  215. }
  216. static ssize_t store_mlid(struct device *dev,
  217. struct device_attribute *attr,
  218. const char *buf,
  219. size_t count)
  220. {
  221. struct ipath_devdata *dd = dev_get_drvdata(dev);
  222. u16 mlid;
  223. int ret;
  224. ret = ipath_parse_ushort(buf, &mlid);
  225. if (ret < 0 || mlid < IPATH_MULTICAST_LID_BASE)
  226. goto invalid;
  227. dd->ipath_mlid = mlid;
  228. goto bail;
  229. invalid:
  230. ipath_dev_err(dd, "attempt to set invalid MLID\n");
  231. bail:
  232. return ret;
  233. }
  234. static ssize_t show_guid(struct device *dev,
  235. struct device_attribute *attr,
  236. char *buf)
  237. {
  238. struct ipath_devdata *dd = dev_get_drvdata(dev);
  239. u8 *guid;
  240. guid = (u8 *) & (dd->ipath_guid);
  241. return scnprintf(buf, PAGE_SIZE,
  242. "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
  243. guid[0], guid[1], guid[2], guid[3],
  244. guid[4], guid[5], guid[6], guid[7]);
  245. }
  246. static ssize_t store_guid(struct device *dev,
  247. struct device_attribute *attr,
  248. const char *buf,
  249. size_t count)
  250. {
  251. struct ipath_devdata *dd = dev_get_drvdata(dev);
  252. ssize_t ret;
  253. unsigned short guid[8];
  254. __be64 new_guid;
  255. u8 *ng;
  256. int i;
  257. if (sscanf(buf, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx",
  258. &guid[0], &guid[1], &guid[2], &guid[3],
  259. &guid[4], &guid[5], &guid[6], &guid[7]) != 8)
  260. goto invalid;
  261. ng = (u8 *) &new_guid;
  262. for (i = 0; i < 8; i++) {
  263. if (guid[i] > 0xff)
  264. goto invalid;
  265. ng[i] = guid[i];
  266. }
  267. if (new_guid == 0)
  268. goto invalid;
  269. dd->ipath_guid = new_guid;
  270. dd->ipath_nguid = 1;
  271. ret = strlen(buf);
  272. goto bail;
  273. invalid:
  274. ipath_dev_err(dd, "attempt to set invalid GUID\n");
  275. ret = -EINVAL;
  276. bail:
  277. return ret;
  278. }
  279. static ssize_t show_nguid(struct device *dev,
  280. struct device_attribute *attr,
  281. char *buf)
  282. {
  283. struct ipath_devdata *dd = dev_get_drvdata(dev);
  284. return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_nguid);
  285. }
  286. static ssize_t show_nports(struct device *dev,
  287. struct device_attribute *attr,
  288. char *buf)
  289. {
  290. struct ipath_devdata *dd = dev_get_drvdata(dev);
  291. /* Return the number of user ports available. */
  292. return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_cfgports - 1);
  293. }
  294. static ssize_t show_serial(struct device *dev,
  295. struct device_attribute *attr,
  296. char *buf)
  297. {
  298. struct ipath_devdata *dd = dev_get_drvdata(dev);
  299. buf[sizeof dd->ipath_serial] = '\0';
  300. memcpy(buf, dd->ipath_serial, sizeof dd->ipath_serial);
  301. strcat(buf, "\n");
  302. return strlen(buf);
  303. }
  304. static ssize_t show_unit(struct device *dev,
  305. struct device_attribute *attr,
  306. char *buf)
  307. {
  308. struct ipath_devdata *dd = dev_get_drvdata(dev);
  309. return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_unit);
  310. }
  311. static ssize_t show_jint_max_packets(struct device *dev,
  312. struct device_attribute *attr,
  313. char *buf)
  314. {
  315. struct ipath_devdata *dd = dev_get_drvdata(dev);
  316. return scnprintf(buf, PAGE_SIZE, "%hu\n", dd->ipath_jint_max_packets);
  317. }
  318. static ssize_t store_jint_max_packets(struct device *dev,
  319. struct device_attribute *attr,
  320. const char *buf,
  321. size_t count)
  322. {
  323. struct ipath_devdata *dd = dev_get_drvdata(dev);
  324. u16 v = 0;
  325. int ret;
  326. ret = ipath_parse_ushort(buf, &v);
  327. if (ret < 0)
  328. ipath_dev_err(dd, "invalid jint_max_packets.\n");
  329. else
  330. dd->ipath_f_config_jint(dd, dd->ipath_jint_idle_ticks, v);
  331. return ret;
  332. }
  333. static ssize_t show_jint_idle_ticks(struct device *dev,
  334. struct device_attribute *attr,
  335. char *buf)
  336. {
  337. struct ipath_devdata *dd = dev_get_drvdata(dev);
  338. return scnprintf(buf, PAGE_SIZE, "%hu\n", dd->ipath_jint_idle_ticks);
  339. }
  340. static ssize_t store_jint_idle_ticks(struct device *dev,
  341. struct device_attribute *attr,
  342. const char *buf,
  343. size_t count)
  344. {
  345. struct ipath_devdata *dd = dev_get_drvdata(dev);
  346. u16 v = 0;
  347. int ret;
  348. ret = ipath_parse_ushort(buf, &v);
  349. if (ret < 0)
  350. ipath_dev_err(dd, "invalid jint_idle_ticks.\n");
  351. else
  352. dd->ipath_f_config_jint(dd, v, dd->ipath_jint_max_packets);
  353. return ret;
  354. }
  355. #define DEVICE_COUNTER(name, attr) \
  356. static ssize_t show_counter_##name(struct device *dev, \
  357. struct device_attribute *attr, \
  358. char *buf) \
  359. { \
  360. struct ipath_devdata *dd = dev_get_drvdata(dev); \
  361. return scnprintf(\
  362. buf, PAGE_SIZE, "%llu\n", (unsigned long long) \
  363. ipath_snap_cntr( \
  364. dd, offsetof(struct infinipath_counters, \
  365. attr) / sizeof(u64))); \
  366. } \
  367. static DEVICE_ATTR(name, S_IRUGO, show_counter_##name, NULL);
  368. DEVICE_COUNTER(ib_link_downeds, IBLinkDownedCnt);
  369. DEVICE_COUNTER(ib_link_err_recoveries, IBLinkErrRecoveryCnt);
  370. DEVICE_COUNTER(ib_status_changes, IBStatusChangeCnt);
  371. DEVICE_COUNTER(ib_symbol_errs, IBSymbolErrCnt);
  372. DEVICE_COUNTER(lb_flow_stalls, LBFlowStallCnt);
  373. DEVICE_COUNTER(lb_ints, LBIntCnt);
  374. DEVICE_COUNTER(rx_bad_formats, RxBadFormatCnt);
  375. DEVICE_COUNTER(rx_buf_ovfls, RxBufOvflCnt);
  376. DEVICE_COUNTER(rx_data_pkts, RxDataPktCnt);
  377. DEVICE_COUNTER(rx_dropped_pkts, RxDroppedPktCnt);
  378. DEVICE_COUNTER(rx_dwords, RxDwordCnt);
  379. DEVICE_COUNTER(rx_ebps, RxEBPCnt);
  380. DEVICE_COUNTER(rx_flow_ctrl_errs, RxFlowCtrlErrCnt);
  381. DEVICE_COUNTER(rx_flow_pkts, RxFlowPktCnt);
  382. DEVICE_COUNTER(rx_icrc_errs, RxICRCErrCnt);
  383. DEVICE_COUNTER(rx_len_errs, RxLenErrCnt);
  384. DEVICE_COUNTER(rx_link_problems, RxLinkProblemCnt);
  385. DEVICE_COUNTER(rx_lpcrc_errs, RxLPCRCErrCnt);
  386. DEVICE_COUNTER(rx_max_min_len_errs, RxMaxMinLenErrCnt);
  387. DEVICE_COUNTER(rx_p0_hdr_egr_ovfls, RxP0HdrEgrOvflCnt);
  388. DEVICE_COUNTER(rx_p1_hdr_egr_ovfls, RxP1HdrEgrOvflCnt);
  389. DEVICE_COUNTER(rx_p2_hdr_egr_ovfls, RxP2HdrEgrOvflCnt);
  390. DEVICE_COUNTER(rx_p3_hdr_egr_ovfls, RxP3HdrEgrOvflCnt);
  391. DEVICE_COUNTER(rx_p4_hdr_egr_ovfls, RxP4HdrEgrOvflCnt);
  392. DEVICE_COUNTER(rx_p5_hdr_egr_ovfls, RxP5HdrEgrOvflCnt);
  393. DEVICE_COUNTER(rx_p6_hdr_egr_ovfls, RxP6HdrEgrOvflCnt);
  394. DEVICE_COUNTER(rx_p7_hdr_egr_ovfls, RxP7HdrEgrOvflCnt);
  395. DEVICE_COUNTER(rx_p8_hdr_egr_ovfls, RxP8HdrEgrOvflCnt);
  396. DEVICE_COUNTER(rx_pkey_mismatches, RxPKeyMismatchCnt);
  397. DEVICE_COUNTER(rx_tid_full_errs, RxTIDFullErrCnt);
  398. DEVICE_COUNTER(rx_tid_valid_errs, RxTIDValidErrCnt);
  399. DEVICE_COUNTER(rx_vcrc_errs, RxVCRCErrCnt);
  400. DEVICE_COUNTER(tx_data_pkts, TxDataPktCnt);
  401. DEVICE_COUNTER(tx_dropped_pkts, TxDroppedPktCnt);
  402. DEVICE_COUNTER(tx_dwords, TxDwordCnt);
  403. DEVICE_COUNTER(tx_flow_pkts, TxFlowPktCnt);
  404. DEVICE_COUNTER(tx_flow_stalls, TxFlowStallCnt);
  405. DEVICE_COUNTER(tx_len_errs, TxLenErrCnt);
  406. DEVICE_COUNTER(tx_max_min_len_errs, TxMaxMinLenErrCnt);
  407. DEVICE_COUNTER(tx_underruns, TxUnderrunCnt);
  408. DEVICE_COUNTER(tx_unsup_vl_errs, TxUnsupVLErrCnt);
  409. static struct attribute *dev_counter_attributes[] = {
  410. &dev_attr_ib_link_downeds.attr,
  411. &dev_attr_ib_link_err_recoveries.attr,
  412. &dev_attr_ib_status_changes.attr,
  413. &dev_attr_ib_symbol_errs.attr,
  414. &dev_attr_lb_flow_stalls.attr,
  415. &dev_attr_lb_ints.attr,
  416. &dev_attr_rx_bad_formats.attr,
  417. &dev_attr_rx_buf_ovfls.attr,
  418. &dev_attr_rx_data_pkts.attr,
  419. &dev_attr_rx_dropped_pkts.attr,
  420. &dev_attr_rx_dwords.attr,
  421. &dev_attr_rx_ebps.attr,
  422. &dev_attr_rx_flow_ctrl_errs.attr,
  423. &dev_attr_rx_flow_pkts.attr,
  424. &dev_attr_rx_icrc_errs.attr,
  425. &dev_attr_rx_len_errs.attr,
  426. &dev_attr_rx_link_problems.attr,
  427. &dev_attr_rx_lpcrc_errs.attr,
  428. &dev_attr_rx_max_min_len_errs.attr,
  429. &dev_attr_rx_p0_hdr_egr_ovfls.attr,
  430. &dev_attr_rx_p1_hdr_egr_ovfls.attr,
  431. &dev_attr_rx_p2_hdr_egr_ovfls.attr,
  432. &dev_attr_rx_p3_hdr_egr_ovfls.attr,
  433. &dev_attr_rx_p4_hdr_egr_ovfls.attr,
  434. &dev_attr_rx_p5_hdr_egr_ovfls.attr,
  435. &dev_attr_rx_p6_hdr_egr_ovfls.attr,
  436. &dev_attr_rx_p7_hdr_egr_ovfls.attr,
  437. &dev_attr_rx_p8_hdr_egr_ovfls.attr,
  438. &dev_attr_rx_pkey_mismatches.attr,
  439. &dev_attr_rx_tid_full_errs.attr,
  440. &dev_attr_rx_tid_valid_errs.attr,
  441. &dev_attr_rx_vcrc_errs.attr,
  442. &dev_attr_tx_data_pkts.attr,
  443. &dev_attr_tx_dropped_pkts.attr,
  444. &dev_attr_tx_dwords.attr,
  445. &dev_attr_tx_flow_pkts.attr,
  446. &dev_attr_tx_flow_stalls.attr,
  447. &dev_attr_tx_len_errs.attr,
  448. &dev_attr_tx_max_min_len_errs.attr,
  449. &dev_attr_tx_underruns.attr,
  450. &dev_attr_tx_unsup_vl_errs.attr,
  451. NULL
  452. };
  453. static struct attribute_group dev_counter_attr_group = {
  454. .name = "counters",
  455. .attrs = dev_counter_attributes
  456. };
  457. static ssize_t store_reset(struct device *dev,
  458. struct device_attribute *attr,
  459. const char *buf,
  460. size_t count)
  461. {
  462. struct ipath_devdata *dd = dev_get_drvdata(dev);
  463. int ret;
  464. if (count < 5 || memcmp(buf, "reset", 5)) {
  465. ret = -EINVAL;
  466. goto bail;
  467. }
  468. if (dd->ipath_flags & IPATH_DISABLED) {
  469. /*
  470. * post-reset init would re-enable interrupts, etc.
  471. * so don't allow reset on disabled devices. Not
  472. * perfect error, but about the best choice.
  473. */
  474. dev_info(dev,"Unit %d is disabled, can't reset\n",
  475. dd->ipath_unit);
  476. ret = -EINVAL;
  477. }
  478. ret = ipath_reset_device(dd->ipath_unit);
  479. bail:
  480. return ret<0 ? ret : count;
  481. }
  482. static ssize_t store_link_state(struct device *dev,
  483. struct device_attribute *attr,
  484. const char *buf,
  485. size_t count)
  486. {
  487. struct ipath_devdata *dd = dev_get_drvdata(dev);
  488. int ret, r;
  489. u16 state;
  490. ret = ipath_parse_ushort(buf, &state);
  491. if (ret < 0)
  492. goto invalid;
  493. r = ipath_set_linkstate(dd, state);
  494. if (r < 0) {
  495. ret = r;
  496. goto bail;
  497. }
  498. goto bail;
  499. invalid:
  500. ipath_dev_err(dd, "attempt to set invalid link state\n");
  501. bail:
  502. return ret;
  503. }
  504. static ssize_t show_mtu(struct device *dev,
  505. struct device_attribute *attr,
  506. char *buf)
  507. {
  508. struct ipath_devdata *dd = dev_get_drvdata(dev);
  509. return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_ibmtu);
  510. }
  511. static ssize_t store_mtu(struct device *dev,
  512. struct device_attribute *attr,
  513. const char *buf,
  514. size_t count)
  515. {
  516. struct ipath_devdata *dd = dev_get_drvdata(dev);
  517. ssize_t ret;
  518. u16 mtu = 0;
  519. int r;
  520. ret = ipath_parse_ushort(buf, &mtu);
  521. if (ret < 0)
  522. goto invalid;
  523. r = ipath_set_mtu(dd, mtu);
  524. if (r < 0)
  525. ret = r;
  526. goto bail;
  527. invalid:
  528. ipath_dev_err(dd, "attempt to set invalid MTU\n");
  529. bail:
  530. return ret;
  531. }
  532. static ssize_t show_enabled(struct device *dev,
  533. struct device_attribute *attr,
  534. char *buf)
  535. {
  536. struct ipath_devdata *dd = dev_get_drvdata(dev);
  537. return scnprintf(buf, PAGE_SIZE, "%u\n",
  538. (dd->ipath_flags & IPATH_DISABLED) ? 0 : 1);
  539. }
  540. static ssize_t store_enabled(struct device *dev,
  541. struct device_attribute *attr,
  542. const char *buf,
  543. size_t count)
  544. {
  545. struct ipath_devdata *dd = dev_get_drvdata(dev);
  546. ssize_t ret;
  547. u16 enable = 0;
  548. ret = ipath_parse_ushort(buf, &enable);
  549. if (ret < 0) {
  550. ipath_dev_err(dd, "attempt to use non-numeric on enable\n");
  551. goto bail;
  552. }
  553. if (enable) {
  554. if (!(dd->ipath_flags & IPATH_DISABLED))
  555. goto bail;
  556. dev_info(dev, "Enabling unit %d\n", dd->ipath_unit);
  557. /* same as post-reset */
  558. ret = ipath_init_chip(dd, 1);
  559. if (ret)
  560. ipath_dev_err(dd, "Failed to enable unit %d\n",
  561. dd->ipath_unit);
  562. else {
  563. dd->ipath_flags &= ~IPATH_DISABLED;
  564. *dd->ipath_statusp &= ~IPATH_STATUS_ADMIN_DISABLED;
  565. }
  566. }
  567. else if (!(dd->ipath_flags & IPATH_DISABLED)) {
  568. dev_info(dev, "Disabling unit %d\n", dd->ipath_unit);
  569. ipath_shutdown_device(dd);
  570. dd->ipath_flags |= IPATH_DISABLED;
  571. *dd->ipath_statusp |= IPATH_STATUS_ADMIN_DISABLED;
  572. }
  573. bail:
  574. return ret;
  575. }
  576. static ssize_t store_rx_pol_inv(struct device *dev,
  577. struct device_attribute *attr,
  578. const char *buf,
  579. size_t count)
  580. {
  581. struct ipath_devdata *dd = dev_get_drvdata(dev);
  582. int ret, r;
  583. u16 val;
  584. ret = ipath_parse_ushort(buf, &val);
  585. if (ret < 0)
  586. goto invalid;
  587. r = ipath_set_rx_pol_inv(dd, val);
  588. if (r < 0) {
  589. ret = r;
  590. goto bail;
  591. }
  592. goto bail;
  593. invalid:
  594. ipath_dev_err(dd, "attempt to set invalid Rx Polarity invert\n");
  595. bail:
  596. return ret;
  597. }
  598. static ssize_t store_led_override(struct device *dev,
  599. struct device_attribute *attr,
  600. const char *buf,
  601. size_t count)
  602. {
  603. struct ipath_devdata *dd = dev_get_drvdata(dev);
  604. int ret;
  605. u16 val;
  606. ret = ipath_parse_ushort(buf, &val);
  607. if (ret > 0)
  608. ipath_set_led_override(dd, val);
  609. else
  610. ipath_dev_err(dd, "attempt to set invalid LED override\n");
  611. return ret;
  612. }
  613. static ssize_t show_logged_errs(struct device *dev,
  614. struct device_attribute *attr,
  615. char *buf)
  616. {
  617. struct ipath_devdata *dd = dev_get_drvdata(dev);
  618. int idx, count;
  619. /* force consistency with actual EEPROM */
  620. if (ipath_update_eeprom_log(dd) != 0)
  621. return -ENXIO;
  622. count = 0;
  623. for (idx = 0; idx < IPATH_EEP_LOG_CNT; ++idx) {
  624. count += scnprintf(buf + count, PAGE_SIZE - count, "%d%c",
  625. dd->ipath_eep_st_errs[idx],
  626. idx == (IPATH_EEP_LOG_CNT - 1) ? '\n' : ' ');
  627. }
  628. return count;
  629. }
  630. /*
  631. * New sysfs entries to control various IB config. These all turn into
  632. * accesses via ipath_f_get/set_ib_cfg.
  633. *
  634. * Get/Set heartbeat enable. Or of 1=enabled, 2=auto
  635. */
  636. static ssize_t show_hrtbt_enb(struct device *dev,
  637. struct device_attribute *attr,
  638. char *buf)
  639. {
  640. struct ipath_devdata *dd = dev_get_drvdata(dev);
  641. int ret;
  642. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_HRTBT);
  643. if (ret >= 0)
  644. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  645. return ret;
  646. }
  647. static ssize_t store_hrtbt_enb(struct device *dev,
  648. struct device_attribute *attr,
  649. const char *buf,
  650. size_t count)
  651. {
  652. struct ipath_devdata *dd = dev_get_drvdata(dev);
  653. int ret, r;
  654. u16 val;
  655. ret = ipath_parse_ushort(buf, &val);
  656. if (ret >= 0 && val > 3)
  657. ret = -EINVAL;
  658. if (ret < 0) {
  659. ipath_dev_err(dd, "attempt to set invalid Heartbeat enable\n");
  660. goto bail;
  661. }
  662. /*
  663. * Set the "intentional" heartbeat enable per either of
  664. * "Enable" and "Auto", as these are normally set together.
  665. * This bit is consulted when leaving loopback mode,
  666. * because entering loopback mode overrides it and automatically
  667. * disables heartbeat.
  668. */
  669. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_HRTBT, val);
  670. if (r < 0)
  671. ret = r;
  672. else if (val == IPATH_IB_HRTBT_OFF)
  673. dd->ipath_flags |= IPATH_NO_HRTBT;
  674. else
  675. dd->ipath_flags &= ~IPATH_NO_HRTBT;
  676. bail:
  677. return ret;
  678. }
  679. /*
  680. * Get/Set Link-widths enabled. Or of 1=1x, 2=4x (this is human/IB centric,
  681. * _not_ the particular encoding of any given chip)
  682. */
  683. static ssize_t show_lwid_enb(struct device *dev,
  684. struct device_attribute *attr,
  685. char *buf)
  686. {
  687. struct ipath_devdata *dd = dev_get_drvdata(dev);
  688. int ret;
  689. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LWID_ENB);
  690. if (ret >= 0)
  691. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  692. return ret;
  693. }
  694. static ssize_t store_lwid_enb(struct device *dev,
  695. struct device_attribute *attr,
  696. const char *buf,
  697. size_t count)
  698. {
  699. struct ipath_devdata *dd = dev_get_drvdata(dev);
  700. int ret, r;
  701. u16 val;
  702. ret = ipath_parse_ushort(buf, &val);
  703. if (ret >= 0 && (val == 0 || val > 3))
  704. ret = -EINVAL;
  705. if (ret < 0) {
  706. ipath_dev_err(dd,
  707. "attempt to set invalid Link Width (enable)\n");
  708. goto bail;
  709. }
  710. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_LWID_ENB, val);
  711. if (r < 0)
  712. ret = r;
  713. bail:
  714. return ret;
  715. }
  716. /* Get current link width */
  717. static ssize_t show_lwid(struct device *dev,
  718. struct device_attribute *attr,
  719. char *buf)
  720. {
  721. struct ipath_devdata *dd = dev_get_drvdata(dev);
  722. int ret;
  723. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LWID);
  724. if (ret >= 0)
  725. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  726. return ret;
  727. }
  728. /*
  729. * Get/Set Link-speeds enabled. Or of 1=SDR 2=DDR.
  730. */
  731. static ssize_t show_spd_enb(struct device *dev,
  732. struct device_attribute *attr,
  733. char *buf)
  734. {
  735. struct ipath_devdata *dd = dev_get_drvdata(dev);
  736. int ret;
  737. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_SPD_ENB);
  738. if (ret >= 0)
  739. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  740. return ret;
  741. }
  742. static ssize_t store_spd_enb(struct device *dev,
  743. struct device_attribute *attr,
  744. const char *buf,
  745. size_t count)
  746. {
  747. struct ipath_devdata *dd = dev_get_drvdata(dev);
  748. int ret, r;
  749. u16 val;
  750. ret = ipath_parse_ushort(buf, &val);
  751. if (ret >= 0 && (val == 0 || val > (IPATH_IB_SDR | IPATH_IB_DDR)))
  752. ret = -EINVAL;
  753. if (ret < 0) {
  754. ipath_dev_err(dd,
  755. "attempt to set invalid Link Speed (enable)\n");
  756. goto bail;
  757. }
  758. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_SPD_ENB, val);
  759. if (r < 0)
  760. ret = r;
  761. bail:
  762. return ret;
  763. }
  764. /* Get current link speed */
  765. static ssize_t show_spd(struct device *dev,
  766. struct device_attribute *attr,
  767. char *buf)
  768. {
  769. struct ipath_devdata *dd = dev_get_drvdata(dev);
  770. int ret;
  771. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_SPD);
  772. if (ret >= 0)
  773. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  774. return ret;
  775. }
  776. /*
  777. * Get/Set RX polarity-invert enable. 0=no, 1=yes.
  778. */
  779. static ssize_t show_rx_polinv_enb(struct device *dev,
  780. struct device_attribute *attr,
  781. char *buf)
  782. {
  783. struct ipath_devdata *dd = dev_get_drvdata(dev);
  784. int ret;
  785. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_RXPOL_ENB);
  786. if (ret >= 0)
  787. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  788. return ret;
  789. }
  790. static ssize_t store_rx_polinv_enb(struct device *dev,
  791. struct device_attribute *attr,
  792. const char *buf,
  793. size_t count)
  794. {
  795. struct ipath_devdata *dd = dev_get_drvdata(dev);
  796. int ret, r;
  797. u16 val;
  798. ret = ipath_parse_ushort(buf, &val);
  799. if (ret < 0 || val > 1)
  800. goto invalid;
  801. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_RXPOL_ENB, val);
  802. if (r < 0) {
  803. ret = r;
  804. goto bail;
  805. }
  806. goto bail;
  807. invalid:
  808. ipath_dev_err(dd, "attempt to set invalid Rx Polarity (enable)\n");
  809. bail:
  810. return ret;
  811. }
  812. /*
  813. * Get/Set RX lane-reversal enable. 0=no, 1=yes.
  814. */
  815. static ssize_t show_lanerev_enb(struct device *dev,
  816. struct device_attribute *attr,
  817. char *buf)
  818. {
  819. struct ipath_devdata *dd = dev_get_drvdata(dev);
  820. int ret;
  821. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LREV_ENB);
  822. if (ret >= 0)
  823. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  824. return ret;
  825. }
  826. static ssize_t store_lanerev_enb(struct device *dev,
  827. struct device_attribute *attr,
  828. const char *buf,
  829. size_t count)
  830. {
  831. struct ipath_devdata *dd = dev_get_drvdata(dev);
  832. int ret, r;
  833. u16 val;
  834. ret = ipath_parse_ushort(buf, &val);
  835. if (ret >= 0 && val > 1) {
  836. ret = -EINVAL;
  837. ipath_dev_err(dd,
  838. "attempt to set invalid Lane reversal (enable)\n");
  839. goto bail;
  840. }
  841. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_LREV_ENB, val);
  842. if (r < 0)
  843. ret = r;
  844. bail:
  845. return ret;
  846. }
  847. static DRIVER_ATTR(num_units, S_IRUGO, show_num_units, NULL);
  848. static DRIVER_ATTR(version, S_IRUGO, show_version, NULL);
  849. static struct attribute *driver_attributes[] = {
  850. &driver_attr_num_units.attr,
  851. &driver_attr_version.attr,
  852. NULL
  853. };
  854. static struct attribute_group driver_attr_group = {
  855. .attrs = driver_attributes
  856. };
  857. static ssize_t store_tempsense(struct device *dev,
  858. struct device_attribute *attr,
  859. const char *buf,
  860. size_t count)
  861. {
  862. struct ipath_devdata *dd = dev_get_drvdata(dev);
  863. int ret, stat;
  864. u16 val;
  865. ret = ipath_parse_ushort(buf, &val);
  866. if (ret <= 0) {
  867. ipath_dev_err(dd, "attempt to set invalid tempsense config\n");
  868. goto bail;
  869. }
  870. /* If anything but the highest limit, enable T_CRIT_A "interrupt" */
  871. stat = ipath_tempsense_write(dd, 9, (val == 0x7f7f) ? 0x80 : 0);
  872. if (stat) {
  873. ipath_dev_err(dd, "Unable to set tempsense config\n");
  874. ret = -1;
  875. goto bail;
  876. }
  877. stat = ipath_tempsense_write(dd, 0xB, (u8) (val & 0xFF));
  878. if (stat) {
  879. ipath_dev_err(dd, "Unable to set local Tcrit\n");
  880. ret = -1;
  881. goto bail;
  882. }
  883. stat = ipath_tempsense_write(dd, 0xD, (u8) (val >> 8));
  884. if (stat) {
  885. ipath_dev_err(dd, "Unable to set remote Tcrit\n");
  886. ret = -1;
  887. goto bail;
  888. }
  889. bail:
  890. return ret;
  891. }
  892. /*
  893. * dump tempsense regs. in decimal, to ease shell-scripts.
  894. */
  895. static ssize_t show_tempsense(struct device *dev,
  896. struct device_attribute *attr,
  897. char *buf)
  898. {
  899. struct ipath_devdata *dd = dev_get_drvdata(dev);
  900. int ret;
  901. int idx;
  902. u8 regvals[8];
  903. ret = -ENXIO;
  904. for (idx = 0; idx < 8; ++idx) {
  905. if (idx == 6)
  906. continue;
  907. ret = ipath_tempsense_read(dd, idx);
  908. if (ret < 0)
  909. break;
  910. regvals[idx] = ret;
  911. }
  912. if (idx == 8)
  913. ret = scnprintf(buf, PAGE_SIZE, "%d %d %02X %02X %d %d\n",
  914. *(signed char *)(regvals),
  915. *(signed char *)(regvals + 1),
  916. regvals[2], regvals[3],
  917. *(signed char *)(regvals + 5),
  918. *(signed char *)(regvals + 7));
  919. return ret;
  920. }
  921. struct attribute_group *ipath_driver_attr_groups[] = {
  922. &driver_attr_group,
  923. NULL,
  924. };
  925. static DEVICE_ATTR(guid, S_IWUSR | S_IRUGO, show_guid, store_guid);
  926. static DEVICE_ATTR(lmc, S_IWUSR | S_IRUGO, show_lmc, store_lmc);
  927. static DEVICE_ATTR(lid, S_IWUSR | S_IRUGO, show_lid, store_lid);
  928. static DEVICE_ATTR(link_state, S_IWUSR, NULL, store_link_state);
  929. static DEVICE_ATTR(mlid, S_IWUSR | S_IRUGO, show_mlid, store_mlid);
  930. static DEVICE_ATTR(mtu, S_IWUSR | S_IRUGO, show_mtu, store_mtu);
  931. static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO, show_enabled, store_enabled);
  932. static DEVICE_ATTR(nguid, S_IRUGO, show_nguid, NULL);
  933. static DEVICE_ATTR(nports, S_IRUGO, show_nports, NULL);
  934. static DEVICE_ATTR(reset, S_IWUSR, NULL, store_reset);
  935. static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL);
  936. static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
  937. static DEVICE_ATTR(status_str, S_IRUGO, show_status_str, NULL);
  938. static DEVICE_ATTR(boardversion, S_IRUGO, show_boardversion, NULL);
  939. static DEVICE_ATTR(unit, S_IRUGO, show_unit, NULL);
  940. static DEVICE_ATTR(rx_pol_inv, S_IWUSR, NULL, store_rx_pol_inv);
  941. static DEVICE_ATTR(led_override, S_IWUSR, NULL, store_led_override);
  942. static DEVICE_ATTR(logged_errors, S_IRUGO, show_logged_errs, NULL);
  943. static DEVICE_ATTR(localbus_info, S_IRUGO, show_localbus_info, NULL);
  944. static DEVICE_ATTR(jint_max_packets, S_IWUSR | S_IRUGO,
  945. show_jint_max_packets, store_jint_max_packets);
  946. static DEVICE_ATTR(jint_idle_ticks, S_IWUSR | S_IRUGO,
  947. show_jint_idle_ticks, store_jint_idle_ticks);
  948. static DEVICE_ATTR(tempsense, S_IWUSR | S_IRUGO,
  949. show_tempsense, store_tempsense);
  950. static struct attribute *dev_attributes[] = {
  951. &dev_attr_guid.attr,
  952. &dev_attr_lmc.attr,
  953. &dev_attr_lid.attr,
  954. &dev_attr_link_state.attr,
  955. &dev_attr_mlid.attr,
  956. &dev_attr_mtu.attr,
  957. &dev_attr_nguid.attr,
  958. &dev_attr_nports.attr,
  959. &dev_attr_serial.attr,
  960. &dev_attr_status.attr,
  961. &dev_attr_status_str.attr,
  962. &dev_attr_boardversion.attr,
  963. &dev_attr_unit.attr,
  964. &dev_attr_enabled.attr,
  965. &dev_attr_rx_pol_inv.attr,
  966. &dev_attr_led_override.attr,
  967. &dev_attr_logged_errors.attr,
  968. &dev_attr_tempsense.attr,
  969. &dev_attr_localbus_info.attr,
  970. NULL
  971. };
  972. static struct attribute_group dev_attr_group = {
  973. .attrs = dev_attributes
  974. };
  975. static DEVICE_ATTR(hrtbt_enable, S_IWUSR | S_IRUGO, show_hrtbt_enb,
  976. store_hrtbt_enb);
  977. static DEVICE_ATTR(link_width_enable, S_IWUSR | S_IRUGO, show_lwid_enb,
  978. store_lwid_enb);
  979. static DEVICE_ATTR(link_width, S_IRUGO, show_lwid, NULL);
  980. static DEVICE_ATTR(link_speed_enable, S_IWUSR | S_IRUGO, show_spd_enb,
  981. store_spd_enb);
  982. static DEVICE_ATTR(link_speed, S_IRUGO, show_spd, NULL);
  983. static DEVICE_ATTR(rx_pol_inv_enable, S_IWUSR | S_IRUGO, show_rx_polinv_enb,
  984. store_rx_polinv_enb);
  985. static DEVICE_ATTR(rx_lane_rev_enable, S_IWUSR | S_IRUGO, show_lanerev_enb,
  986. store_lanerev_enb);
  987. static struct attribute *dev_ibcfg_attributes[] = {
  988. &dev_attr_hrtbt_enable.attr,
  989. &dev_attr_link_width_enable.attr,
  990. &dev_attr_link_width.attr,
  991. &dev_attr_link_speed_enable.attr,
  992. &dev_attr_link_speed.attr,
  993. &dev_attr_rx_pol_inv_enable.attr,
  994. &dev_attr_rx_lane_rev_enable.attr,
  995. NULL
  996. };
  997. static struct attribute_group dev_ibcfg_attr_group = {
  998. .attrs = dev_ibcfg_attributes
  999. };
  1000. /**
  1001. * ipath_expose_reset - create a device reset file
  1002. * @dev: the device structure
  1003. *
  1004. * Only expose a file that lets us reset the device after someone
  1005. * enters diag mode. A device reset is quite likely to crash the
  1006. * machine entirely, so we don't want to normally make it
  1007. * available.
  1008. *
  1009. * Called with ipath_mutex held.
  1010. */
  1011. int ipath_expose_reset(struct device *dev)
  1012. {
  1013. static int exposed;
  1014. int ret;
  1015. if (!exposed) {
  1016. ret = device_create_file(dev, &dev_attr_reset);
  1017. exposed = 1;
  1018. }
  1019. else
  1020. ret = 0;
  1021. return ret;
  1022. }
  1023. int ipath_device_create_group(struct device *dev, struct ipath_devdata *dd)
  1024. {
  1025. int ret;
  1026. ret = sysfs_create_group(&dev->kobj, &dev_attr_group);
  1027. if (ret)
  1028. goto bail;
  1029. ret = sysfs_create_group(&dev->kobj, &dev_counter_attr_group);
  1030. if (ret)
  1031. goto bail_attrs;
  1032. if (dd->ipath_flags & IPATH_HAS_MULT_IB_SPEED) {
  1033. ret = device_create_file(dev, &dev_attr_jint_idle_ticks);
  1034. if (ret)
  1035. goto bail_counter;
  1036. ret = device_create_file(dev, &dev_attr_jint_max_packets);
  1037. if (ret)
  1038. goto bail_idle;
  1039. ret = sysfs_create_group(&dev->kobj, &dev_ibcfg_attr_group);
  1040. if (ret)
  1041. goto bail_max;
  1042. }
  1043. return 0;
  1044. bail_max:
  1045. device_remove_file(dev, &dev_attr_jint_max_packets);
  1046. bail_idle:
  1047. device_remove_file(dev, &dev_attr_jint_idle_ticks);
  1048. bail_counter:
  1049. sysfs_remove_group(&dev->kobj, &dev_counter_attr_group);
  1050. bail_attrs:
  1051. sysfs_remove_group(&dev->kobj, &dev_attr_group);
  1052. bail:
  1053. return ret;
  1054. }
  1055. void ipath_device_remove_group(struct device *dev, struct ipath_devdata *dd)
  1056. {
  1057. sysfs_remove_group(&dev->kobj, &dev_counter_attr_group);
  1058. if (dd->ipath_flags & IPATH_HAS_MULT_IB_SPEED) {
  1059. sysfs_remove_group(&dev->kobj, &dev_ibcfg_attr_group);
  1060. device_remove_file(dev, &dev_attr_jint_idle_ticks);
  1061. device_remove_file(dev, &dev_attr_jint_max_packets);
  1062. }
  1063. sysfs_remove_group(&dev->kobj, &dev_attr_group);
  1064. device_remove_file(dev, &dev_attr_reset);
  1065. }