ipath_sysfs.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  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. }
  481. ret = ipath_reset_device(dd->ipath_unit);
  482. bail:
  483. return ret<0 ? ret : count;
  484. }
  485. static ssize_t store_link_state(struct device *dev,
  486. struct device_attribute *attr,
  487. const char *buf,
  488. size_t count)
  489. {
  490. struct ipath_devdata *dd = dev_get_drvdata(dev);
  491. int ret, r;
  492. u16 state;
  493. ret = ipath_parse_ushort(buf, &state);
  494. if (ret < 0)
  495. goto invalid;
  496. r = ipath_set_linkstate(dd, state);
  497. if (r < 0) {
  498. ret = r;
  499. goto bail;
  500. }
  501. goto bail;
  502. invalid:
  503. ipath_dev_err(dd, "attempt to set invalid link state\n");
  504. bail:
  505. return ret;
  506. }
  507. static ssize_t show_mtu(struct device *dev,
  508. struct device_attribute *attr,
  509. char *buf)
  510. {
  511. struct ipath_devdata *dd = dev_get_drvdata(dev);
  512. return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_ibmtu);
  513. }
  514. static ssize_t store_mtu(struct device *dev,
  515. struct device_attribute *attr,
  516. const char *buf,
  517. size_t count)
  518. {
  519. struct ipath_devdata *dd = dev_get_drvdata(dev);
  520. ssize_t ret;
  521. u16 mtu = 0;
  522. int r;
  523. ret = ipath_parse_ushort(buf, &mtu);
  524. if (ret < 0)
  525. goto invalid;
  526. r = ipath_set_mtu(dd, mtu);
  527. if (r < 0)
  528. ret = r;
  529. goto bail;
  530. invalid:
  531. ipath_dev_err(dd, "attempt to set invalid MTU\n");
  532. bail:
  533. return ret;
  534. }
  535. static ssize_t show_enabled(struct device *dev,
  536. struct device_attribute *attr,
  537. char *buf)
  538. {
  539. struct ipath_devdata *dd = dev_get_drvdata(dev);
  540. return scnprintf(buf, PAGE_SIZE, "%u\n",
  541. (dd->ipath_flags & IPATH_DISABLED) ? 0 : 1);
  542. }
  543. static ssize_t store_enabled(struct device *dev,
  544. struct device_attribute *attr,
  545. const char *buf,
  546. size_t count)
  547. {
  548. struct ipath_devdata *dd = dev_get_drvdata(dev);
  549. ssize_t ret;
  550. u16 enable = 0;
  551. ret = ipath_parse_ushort(buf, &enable);
  552. if (ret < 0) {
  553. ipath_dev_err(dd, "attempt to use non-numeric on enable\n");
  554. goto bail;
  555. }
  556. if (enable) {
  557. if (!(dd->ipath_flags & IPATH_DISABLED))
  558. goto bail;
  559. dev_info(dev, "Enabling unit %d\n", dd->ipath_unit);
  560. /* same as post-reset */
  561. ret = ipath_init_chip(dd, 1);
  562. if (ret)
  563. ipath_dev_err(dd, "Failed to enable unit %d\n",
  564. dd->ipath_unit);
  565. else {
  566. dd->ipath_flags &= ~IPATH_DISABLED;
  567. *dd->ipath_statusp &= ~IPATH_STATUS_ADMIN_DISABLED;
  568. }
  569. }
  570. else if (!(dd->ipath_flags & IPATH_DISABLED)) {
  571. dev_info(dev, "Disabling unit %d\n", dd->ipath_unit);
  572. ipath_shutdown_device(dd);
  573. dd->ipath_flags |= IPATH_DISABLED;
  574. *dd->ipath_statusp |= IPATH_STATUS_ADMIN_DISABLED;
  575. }
  576. bail:
  577. return ret;
  578. }
  579. static ssize_t store_rx_pol_inv(struct device *dev,
  580. struct device_attribute *attr,
  581. const char *buf,
  582. size_t count)
  583. {
  584. struct ipath_devdata *dd = dev_get_drvdata(dev);
  585. int ret, r;
  586. u16 val;
  587. ret = ipath_parse_ushort(buf, &val);
  588. if (ret < 0)
  589. goto invalid;
  590. r = ipath_set_rx_pol_inv(dd, val);
  591. if (r < 0) {
  592. ret = r;
  593. goto bail;
  594. }
  595. goto bail;
  596. invalid:
  597. ipath_dev_err(dd, "attempt to set invalid Rx Polarity invert\n");
  598. bail:
  599. return ret;
  600. }
  601. static ssize_t store_led_override(struct device *dev,
  602. struct device_attribute *attr,
  603. const char *buf,
  604. size_t count)
  605. {
  606. struct ipath_devdata *dd = dev_get_drvdata(dev);
  607. int ret;
  608. u16 val;
  609. ret = ipath_parse_ushort(buf, &val);
  610. if (ret > 0)
  611. ipath_set_led_override(dd, val);
  612. else
  613. ipath_dev_err(dd, "attempt to set invalid LED override\n");
  614. return ret;
  615. }
  616. static ssize_t show_logged_errs(struct device *dev,
  617. struct device_attribute *attr,
  618. char *buf)
  619. {
  620. struct ipath_devdata *dd = dev_get_drvdata(dev);
  621. int idx, count;
  622. /* force consistency with actual EEPROM */
  623. if (ipath_update_eeprom_log(dd) != 0)
  624. return -ENXIO;
  625. count = 0;
  626. for (idx = 0; idx < IPATH_EEP_LOG_CNT; ++idx) {
  627. count += scnprintf(buf + count, PAGE_SIZE - count, "%d%c",
  628. dd->ipath_eep_st_errs[idx],
  629. idx == (IPATH_EEP_LOG_CNT - 1) ? '\n' : ' ');
  630. }
  631. return count;
  632. }
  633. /*
  634. * New sysfs entries to control various IB config. These all turn into
  635. * accesses via ipath_f_get/set_ib_cfg.
  636. *
  637. * Get/Set heartbeat enable. Or of 1=enabled, 2=auto
  638. */
  639. static ssize_t show_hrtbt_enb(struct device *dev,
  640. struct device_attribute *attr,
  641. char *buf)
  642. {
  643. struct ipath_devdata *dd = dev_get_drvdata(dev);
  644. int ret;
  645. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_HRTBT);
  646. if (ret >= 0)
  647. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  648. return ret;
  649. }
  650. static ssize_t store_hrtbt_enb(struct device *dev,
  651. struct device_attribute *attr,
  652. const char *buf,
  653. size_t count)
  654. {
  655. struct ipath_devdata *dd = dev_get_drvdata(dev);
  656. int ret, r;
  657. u16 val;
  658. ret = ipath_parse_ushort(buf, &val);
  659. if (ret >= 0 && val > 3)
  660. ret = -EINVAL;
  661. if (ret < 0) {
  662. ipath_dev_err(dd, "attempt to set invalid Heartbeat enable\n");
  663. goto bail;
  664. }
  665. /*
  666. * Set the "intentional" heartbeat enable per either of
  667. * "Enable" and "Auto", as these are normally set together.
  668. * This bit is consulted when leaving loopback mode,
  669. * because entering loopback mode overrides it and automatically
  670. * disables heartbeat.
  671. */
  672. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_HRTBT, val);
  673. if (r < 0)
  674. ret = r;
  675. else if (val == IPATH_IB_HRTBT_OFF)
  676. dd->ipath_flags |= IPATH_NO_HRTBT;
  677. else
  678. dd->ipath_flags &= ~IPATH_NO_HRTBT;
  679. bail:
  680. return ret;
  681. }
  682. /*
  683. * Get/Set Link-widths enabled. Or of 1=1x, 2=4x (this is human/IB centric,
  684. * _not_ the particular encoding of any given chip)
  685. */
  686. static ssize_t show_lwid_enb(struct device *dev,
  687. struct device_attribute *attr,
  688. char *buf)
  689. {
  690. struct ipath_devdata *dd = dev_get_drvdata(dev);
  691. int ret;
  692. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LWID_ENB);
  693. if (ret >= 0)
  694. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  695. return ret;
  696. }
  697. static ssize_t store_lwid_enb(struct device *dev,
  698. struct device_attribute *attr,
  699. const char *buf,
  700. size_t count)
  701. {
  702. struct ipath_devdata *dd = dev_get_drvdata(dev);
  703. int ret, r;
  704. u16 val;
  705. ret = ipath_parse_ushort(buf, &val);
  706. if (ret >= 0 && (val == 0 || val > 3))
  707. ret = -EINVAL;
  708. if (ret < 0) {
  709. ipath_dev_err(dd,
  710. "attempt to set invalid Link Width (enable)\n");
  711. goto bail;
  712. }
  713. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_LWID_ENB, val);
  714. if (r < 0)
  715. ret = r;
  716. bail:
  717. return ret;
  718. }
  719. /* Get current link width */
  720. static ssize_t show_lwid(struct device *dev,
  721. struct device_attribute *attr,
  722. char *buf)
  723. {
  724. struct ipath_devdata *dd = dev_get_drvdata(dev);
  725. int ret;
  726. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LWID);
  727. if (ret >= 0)
  728. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  729. return ret;
  730. }
  731. /*
  732. * Get/Set Link-speeds enabled. Or of 1=SDR 2=DDR.
  733. */
  734. static ssize_t show_spd_enb(struct device *dev,
  735. struct device_attribute *attr,
  736. char *buf)
  737. {
  738. struct ipath_devdata *dd = dev_get_drvdata(dev);
  739. int ret;
  740. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_SPD_ENB);
  741. if (ret >= 0)
  742. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  743. return ret;
  744. }
  745. static ssize_t store_spd_enb(struct device *dev,
  746. struct device_attribute *attr,
  747. const char *buf,
  748. size_t count)
  749. {
  750. struct ipath_devdata *dd = dev_get_drvdata(dev);
  751. int ret, r;
  752. u16 val;
  753. ret = ipath_parse_ushort(buf, &val);
  754. if (ret >= 0 && (val == 0 || val > (IPATH_IB_SDR | IPATH_IB_DDR)))
  755. ret = -EINVAL;
  756. if (ret < 0) {
  757. ipath_dev_err(dd,
  758. "attempt to set invalid Link Speed (enable)\n");
  759. goto bail;
  760. }
  761. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_SPD_ENB, val);
  762. if (r < 0)
  763. ret = r;
  764. bail:
  765. return ret;
  766. }
  767. /* Get current link speed */
  768. static ssize_t show_spd(struct device *dev,
  769. struct device_attribute *attr,
  770. char *buf)
  771. {
  772. struct ipath_devdata *dd = dev_get_drvdata(dev);
  773. int ret;
  774. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_SPD);
  775. if (ret >= 0)
  776. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  777. return ret;
  778. }
  779. /*
  780. * Get/Set RX polarity-invert enable. 0=no, 1=yes.
  781. */
  782. static ssize_t show_rx_polinv_enb(struct device *dev,
  783. struct device_attribute *attr,
  784. char *buf)
  785. {
  786. struct ipath_devdata *dd = dev_get_drvdata(dev);
  787. int ret;
  788. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_RXPOL_ENB);
  789. if (ret >= 0)
  790. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  791. return ret;
  792. }
  793. static ssize_t store_rx_polinv_enb(struct device *dev,
  794. struct device_attribute *attr,
  795. const char *buf,
  796. size_t count)
  797. {
  798. struct ipath_devdata *dd = dev_get_drvdata(dev);
  799. int ret, r;
  800. u16 val;
  801. ret = ipath_parse_ushort(buf, &val);
  802. if (ret >= 0 && val > 1) {
  803. ipath_dev_err(dd,
  804. "attempt to set invalid Rx Polarity (enable)\n");
  805. ret = -EINVAL;
  806. goto bail;
  807. }
  808. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_RXPOL_ENB, val);
  809. if (r < 0)
  810. ret = r;
  811. bail:
  812. return ret;
  813. }
  814. /*
  815. * Get/Set RX lane-reversal enable. 0=no, 1=yes.
  816. */
  817. static ssize_t show_lanerev_enb(struct device *dev,
  818. struct device_attribute *attr,
  819. char *buf)
  820. {
  821. struct ipath_devdata *dd = dev_get_drvdata(dev);
  822. int ret;
  823. ret = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LREV_ENB);
  824. if (ret >= 0)
  825. ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  826. return ret;
  827. }
  828. static ssize_t store_lanerev_enb(struct device *dev,
  829. struct device_attribute *attr,
  830. const char *buf,
  831. size_t count)
  832. {
  833. struct ipath_devdata *dd = dev_get_drvdata(dev);
  834. int ret, r;
  835. u16 val;
  836. ret = ipath_parse_ushort(buf, &val);
  837. if (ret >= 0 && val > 1) {
  838. ret = -EINVAL;
  839. ipath_dev_err(dd,
  840. "attempt to set invalid Lane reversal (enable)\n");
  841. goto bail;
  842. }
  843. r = dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_LREV_ENB, val);
  844. if (r < 0)
  845. ret = r;
  846. bail:
  847. return ret;
  848. }
  849. static DRIVER_ATTR(num_units, S_IRUGO, show_num_units, NULL);
  850. static DRIVER_ATTR(version, S_IRUGO, show_version, NULL);
  851. static struct attribute *driver_attributes[] = {
  852. &driver_attr_num_units.attr,
  853. &driver_attr_version.attr,
  854. NULL
  855. };
  856. static struct attribute_group driver_attr_group = {
  857. .attrs = driver_attributes
  858. };
  859. static ssize_t store_tempsense(struct device *dev,
  860. struct device_attribute *attr,
  861. const char *buf,
  862. size_t count)
  863. {
  864. struct ipath_devdata *dd = dev_get_drvdata(dev);
  865. int ret, stat;
  866. u16 val;
  867. ret = ipath_parse_ushort(buf, &val);
  868. if (ret <= 0) {
  869. ipath_dev_err(dd, "attempt to set invalid tempsense config\n");
  870. goto bail;
  871. }
  872. /* If anything but the highest limit, enable T_CRIT_A "interrupt" */
  873. stat = ipath_tempsense_write(dd, 9, (val == 0x7f7f) ? 0x80 : 0);
  874. if (stat) {
  875. ipath_dev_err(dd, "Unable to set tempsense config\n");
  876. ret = -1;
  877. goto bail;
  878. }
  879. stat = ipath_tempsense_write(dd, 0xB, (u8) (val & 0xFF));
  880. if (stat) {
  881. ipath_dev_err(dd, "Unable to set local Tcrit\n");
  882. ret = -1;
  883. goto bail;
  884. }
  885. stat = ipath_tempsense_write(dd, 0xD, (u8) (val >> 8));
  886. if (stat) {
  887. ipath_dev_err(dd, "Unable to set remote Tcrit\n");
  888. ret = -1;
  889. goto bail;
  890. }
  891. bail:
  892. return ret;
  893. }
  894. /*
  895. * dump tempsense regs. in decimal, to ease shell-scripts.
  896. */
  897. static ssize_t show_tempsense(struct device *dev,
  898. struct device_attribute *attr,
  899. char *buf)
  900. {
  901. struct ipath_devdata *dd = dev_get_drvdata(dev);
  902. int ret;
  903. int idx;
  904. u8 regvals[8];
  905. ret = -ENXIO;
  906. for (idx = 0; idx < 8; ++idx) {
  907. if (idx == 6)
  908. continue;
  909. ret = ipath_tempsense_read(dd, idx);
  910. if (ret < 0)
  911. break;
  912. regvals[idx] = ret;
  913. }
  914. if (idx == 8)
  915. ret = scnprintf(buf, PAGE_SIZE, "%d %d %02X %02X %d %d\n",
  916. *(signed char *)(regvals),
  917. *(signed char *)(regvals + 1),
  918. regvals[2], regvals[3],
  919. *(signed char *)(regvals + 5),
  920. *(signed char *)(regvals + 7));
  921. return ret;
  922. }
  923. struct attribute_group *ipath_driver_attr_groups[] = {
  924. &driver_attr_group,
  925. NULL,
  926. };
  927. static DEVICE_ATTR(guid, S_IWUSR | S_IRUGO, show_guid, store_guid);
  928. static DEVICE_ATTR(lmc, S_IWUSR | S_IRUGO, show_lmc, store_lmc);
  929. static DEVICE_ATTR(lid, S_IWUSR | S_IRUGO, show_lid, store_lid);
  930. static DEVICE_ATTR(link_state, S_IWUSR, NULL, store_link_state);
  931. static DEVICE_ATTR(mlid, S_IWUSR | S_IRUGO, show_mlid, store_mlid);
  932. static DEVICE_ATTR(mtu, S_IWUSR | S_IRUGO, show_mtu, store_mtu);
  933. static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO, show_enabled, store_enabled);
  934. static DEVICE_ATTR(nguid, S_IRUGO, show_nguid, NULL);
  935. static DEVICE_ATTR(nports, S_IRUGO, show_nports, NULL);
  936. static DEVICE_ATTR(reset, S_IWUSR, NULL, store_reset);
  937. static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL);
  938. static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
  939. static DEVICE_ATTR(status_str, S_IRUGO, show_status_str, NULL);
  940. static DEVICE_ATTR(boardversion, S_IRUGO, show_boardversion, NULL);
  941. static DEVICE_ATTR(unit, S_IRUGO, show_unit, NULL);
  942. static DEVICE_ATTR(rx_pol_inv, S_IWUSR, NULL, store_rx_pol_inv);
  943. static DEVICE_ATTR(led_override, S_IWUSR, NULL, store_led_override);
  944. static DEVICE_ATTR(logged_errors, S_IRUGO, show_logged_errs, NULL);
  945. static DEVICE_ATTR(localbus_info, S_IRUGO, show_localbus_info, NULL);
  946. static DEVICE_ATTR(jint_max_packets, S_IWUSR | S_IRUGO,
  947. show_jint_max_packets, store_jint_max_packets);
  948. static DEVICE_ATTR(jint_idle_ticks, S_IWUSR | S_IRUGO,
  949. show_jint_idle_ticks, store_jint_idle_ticks);
  950. static DEVICE_ATTR(tempsense, S_IWUSR | S_IRUGO,
  951. show_tempsense, store_tempsense);
  952. static struct attribute *dev_attributes[] = {
  953. &dev_attr_guid.attr,
  954. &dev_attr_lmc.attr,
  955. &dev_attr_lid.attr,
  956. &dev_attr_link_state.attr,
  957. &dev_attr_mlid.attr,
  958. &dev_attr_mtu.attr,
  959. &dev_attr_nguid.attr,
  960. &dev_attr_nports.attr,
  961. &dev_attr_serial.attr,
  962. &dev_attr_status.attr,
  963. &dev_attr_status_str.attr,
  964. &dev_attr_boardversion.attr,
  965. &dev_attr_unit.attr,
  966. &dev_attr_enabled.attr,
  967. &dev_attr_rx_pol_inv.attr,
  968. &dev_attr_led_override.attr,
  969. &dev_attr_logged_errors.attr,
  970. &dev_attr_tempsense.attr,
  971. &dev_attr_localbus_info.attr,
  972. NULL
  973. };
  974. static struct attribute_group dev_attr_group = {
  975. .attrs = dev_attributes
  976. };
  977. static DEVICE_ATTR(hrtbt_enable, S_IWUSR | S_IRUGO, show_hrtbt_enb,
  978. store_hrtbt_enb);
  979. static DEVICE_ATTR(link_width_enable, S_IWUSR | S_IRUGO, show_lwid_enb,
  980. store_lwid_enb);
  981. static DEVICE_ATTR(link_width, S_IRUGO, show_lwid, NULL);
  982. static DEVICE_ATTR(link_speed_enable, S_IWUSR | S_IRUGO, show_spd_enb,
  983. store_spd_enb);
  984. static DEVICE_ATTR(link_speed, S_IRUGO, show_spd, NULL);
  985. static DEVICE_ATTR(rx_pol_inv_enable, S_IWUSR | S_IRUGO, show_rx_polinv_enb,
  986. store_rx_polinv_enb);
  987. static DEVICE_ATTR(rx_lane_rev_enable, S_IWUSR | S_IRUGO, show_lanerev_enb,
  988. store_lanerev_enb);
  989. static struct attribute *dev_ibcfg_attributes[] = {
  990. &dev_attr_hrtbt_enable.attr,
  991. &dev_attr_link_width_enable.attr,
  992. &dev_attr_link_width.attr,
  993. &dev_attr_link_speed_enable.attr,
  994. &dev_attr_link_speed.attr,
  995. &dev_attr_rx_pol_inv_enable.attr,
  996. &dev_attr_rx_lane_rev_enable.attr,
  997. NULL
  998. };
  999. static struct attribute_group dev_ibcfg_attr_group = {
  1000. .attrs = dev_ibcfg_attributes
  1001. };
  1002. /**
  1003. * ipath_expose_reset - create a device reset file
  1004. * @dev: the device structure
  1005. *
  1006. * Only expose a file that lets us reset the device after someone
  1007. * enters diag mode. A device reset is quite likely to crash the
  1008. * machine entirely, so we don't want to normally make it
  1009. * available.
  1010. *
  1011. * Called with ipath_mutex held.
  1012. */
  1013. int ipath_expose_reset(struct device *dev)
  1014. {
  1015. static int exposed;
  1016. int ret;
  1017. if (!exposed) {
  1018. ret = device_create_file(dev, &dev_attr_reset);
  1019. exposed = 1;
  1020. }
  1021. else
  1022. ret = 0;
  1023. return ret;
  1024. }
  1025. int ipath_device_create_group(struct device *dev, struct ipath_devdata *dd)
  1026. {
  1027. int ret;
  1028. ret = sysfs_create_group(&dev->kobj, &dev_attr_group);
  1029. if (ret)
  1030. goto bail;
  1031. ret = sysfs_create_group(&dev->kobj, &dev_counter_attr_group);
  1032. if (ret)
  1033. goto bail_attrs;
  1034. if (dd->ipath_flags & IPATH_HAS_MULT_IB_SPEED) {
  1035. ret = device_create_file(dev, &dev_attr_jint_idle_ticks);
  1036. if (ret)
  1037. goto bail_counter;
  1038. ret = device_create_file(dev, &dev_attr_jint_max_packets);
  1039. if (ret)
  1040. goto bail_idle;
  1041. ret = sysfs_create_group(&dev->kobj, &dev_ibcfg_attr_group);
  1042. if (ret)
  1043. goto bail_max;
  1044. }
  1045. return 0;
  1046. bail_max:
  1047. device_remove_file(dev, &dev_attr_jint_max_packets);
  1048. bail_idle:
  1049. device_remove_file(dev, &dev_attr_jint_idle_ticks);
  1050. bail_counter:
  1051. sysfs_remove_group(&dev->kobj, &dev_counter_attr_group);
  1052. bail_attrs:
  1053. sysfs_remove_group(&dev->kobj, &dev_attr_group);
  1054. bail:
  1055. return ret;
  1056. }
  1057. void ipath_device_remove_group(struct device *dev, struct ipath_devdata *dd)
  1058. {
  1059. sysfs_remove_group(&dev->kobj, &dev_counter_attr_group);
  1060. if (dd->ipath_flags & IPATH_HAS_MULT_IB_SPEED) {
  1061. sysfs_remove_group(&dev->kobj, &dev_ibcfg_attr_group);
  1062. device_remove_file(dev, &dev_attr_jint_idle_ticks);
  1063. device_remove_file(dev, &dev_attr_jint_max_packets);
  1064. }
  1065. sysfs_remove_group(&dev->kobj, &dev_attr_group);
  1066. device_remove_file(dev, &dev_attr_reset);
  1067. }