ipath_sysfs.c 30 KB

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