ipath_sysfs.c 30 KB

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