aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/qib/qib_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/qib/qib_sysfs.c')
-rw-r--r--drivers/infiniband/hw/qib/qib_sysfs.c691
1 files changed, 691 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c
new file mode 100644
index 000000000000..dab4d9f4a2cc
--- /dev/null
+++ b/drivers/infiniband/hw/qib/qib_sysfs.c
@@ -0,0 +1,691 @@
1/*
2 * Copyright (c) 2006, 2007, 2008, 2009 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
35#include "qib.h"
36
37/**
38 * qib_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 */
44static int qib_parse_ushort(const char *str, unsigned short *valp)
45{
46 unsigned long val;
47 char *end;
48 int ret;
49
50 if (!isdigit(str[0])) {
51 ret = -EINVAL;
52 goto bail;
53 }
54
55 val = simple_strtoul(str, &end, 0);
56
57 if (val > 0xffff) {
58 ret = -EINVAL;
59 goto bail;
60 }
61
62 *valp = val;
63
64 ret = end + 1 - str;
65 if (ret == 0)
66 ret = -EINVAL;
67
68bail:
69 return ret;
70}
71
72/* start of per-port functions */
73/*
74 * Get/Set heartbeat enable. OR of 1=enabled, 2=auto
75 */
76static ssize_t show_hrtbt_enb(struct qib_pportdata *ppd, char *buf)
77{
78 struct qib_devdata *dd = ppd->dd;
79 int ret;
80
81 ret = dd->f_get_ib_cfg(ppd, QIB_IB_CFG_HRTBT);
82 ret = scnprintf(buf, PAGE_SIZE, "%d\n", ret);
83 return ret;
84}
85
86static ssize_t store_hrtbt_enb(struct qib_pportdata *ppd, const char *buf,
87 size_t count)
88{
89 struct qib_devdata *dd = ppd->dd;
90 int ret;
91 u16 val;
92
93 ret = qib_parse_ushort(buf, &val);
94
95 /*
96 * Set the "intentional" heartbeat enable per either of
97 * "Enable" and "Auto", as these are normally set together.
98 * This bit is consulted when leaving loopback mode,
99 * because entering loopback mode overrides it and automatically
100 * disables heartbeat.
101 */
102 if (ret >= 0)
103 ret = dd->f_set_ib_cfg(ppd, QIB_IB_CFG_HRTBT, val);
104 if (ret < 0)
105 qib_dev_err(dd, "attempt to set invalid Heartbeat enable\n");
106 return ret < 0 ? ret : count;
107}
108
109static ssize_t store_loopback(struct qib_pportdata *ppd, const char *buf,
110 size_t count)
111{
112 struct qib_devdata *dd = ppd->dd;
113 int ret = count, r;
114
115 r = dd->f_set_ib_loopback(ppd, buf);
116 if (r < 0)
117 ret = r;
118
119 return ret;
120}
121
122static ssize_t store_led_override(struct qib_pportdata *ppd, const char *buf,
123 size_t count)
124{
125 struct qib_devdata *dd = ppd->dd;
126 int ret;
127 u16 val;
128
129 ret = qib_parse_ushort(buf, &val);
130 if (ret > 0)
131 qib_set_led_override(ppd, val);
132 else
133 qib_dev_err(dd, "attempt to set invalid LED override\n");
134 return ret < 0 ? ret : count;
135}
136
137static ssize_t show_status(struct qib_pportdata *ppd, char *buf)
138{
139 ssize_t ret;
140
141 if (!ppd->statusp)
142 ret = -EINVAL;
143 else
144 ret = scnprintf(buf, PAGE_SIZE, "0x%llx\n",
145 (unsigned long long) *(ppd->statusp));
146 return ret;
147}
148
149/*
150 * For userland compatibility, these offsets must remain fixed.
151 * They are strings for QIB_STATUS_*
152 */
153static const char *qib_status_str[] = {
154 "Initted",
155 "",
156 "",
157 "",
158 "",
159 "Present",
160 "IB_link_up",
161 "IB_configured",
162 "",
163 "Fatal_Hardware_Error",
164 NULL,
165};
166
167static ssize_t show_status_str(struct qib_pportdata *ppd, char *buf)
168{
169 int i, any;
170 u64 s;
171 ssize_t ret;
172
173 if (!ppd->statusp) {
174 ret = -EINVAL;
175 goto bail;
176 }
177
178 s = *(ppd->statusp);
179 *buf = '\0';
180 for (any = i = 0; s && qib_status_str[i]; i++) {
181 if (s & 1) {
182 /* if overflow */
183 if (any && strlcat(buf, " ", PAGE_SIZE) >= PAGE_SIZE)
184 break;
185 if (strlcat(buf, qib_status_str[i], PAGE_SIZE) >=
186 PAGE_SIZE)
187 break;
188 any = 1;
189 }
190 s >>= 1;
191 }
192 if (any)
193 strlcat(buf, "\n", PAGE_SIZE);
194
195 ret = strlen(buf);
196
197bail:
198 return ret;
199}
200
201/* end of per-port functions */
202
203/*
204 * Start of per-port file structures and support code
205 * Because we are fitting into other infrastructure, we have to supply the
206 * full set of kobject/sysfs_ops structures and routines.
207 */
208#define QIB_PORT_ATTR(name, mode, show, store) \
209 static struct qib_port_attr qib_port_attr_##name = \
210 __ATTR(name, mode, show, store)
211
212struct qib_port_attr {
213 struct attribute attr;
214 ssize_t (*show)(struct qib_pportdata *, char *);
215 ssize_t (*store)(struct qib_pportdata *, const char *, size_t);
216};
217
218QIB_PORT_ATTR(loopback, S_IWUSR, NULL, store_loopback);
219QIB_PORT_ATTR(led_override, S_IWUSR, NULL, store_led_override);
220QIB_PORT_ATTR(hrtbt_enable, S_IWUSR | S_IRUGO, show_hrtbt_enb,
221 store_hrtbt_enb);
222QIB_PORT_ATTR(status, S_IRUGO, show_status, NULL);
223QIB_PORT_ATTR(status_str, S_IRUGO, show_status_str, NULL);
224
225static struct attribute *port_default_attributes[] = {
226 &qib_port_attr_loopback.attr,
227 &qib_port_attr_led_override.attr,
228 &qib_port_attr_hrtbt_enable.attr,
229 &qib_port_attr_status.attr,
230 &qib_port_attr_status_str.attr,
231 NULL
232};
233
234static ssize_t qib_portattr_show(struct kobject *kobj,
235 struct attribute *attr, char *buf)
236{
237 struct qib_port_attr *pattr =
238 container_of(attr, struct qib_port_attr, attr);
239 struct qib_pportdata *ppd =
240 container_of(kobj, struct qib_pportdata, pport_kobj);
241
242 return pattr->show(ppd, buf);
243}
244
245static ssize_t qib_portattr_store(struct kobject *kobj,
246 struct attribute *attr, const char *buf, size_t len)
247{
248 struct qib_port_attr *pattr =
249 container_of(attr, struct qib_port_attr, attr);
250 struct qib_pportdata *ppd =
251 container_of(kobj, struct qib_pportdata, pport_kobj);
252
253 return pattr->store(ppd, buf, len);
254}
255
256static void qib_port_release(struct kobject *kobj)
257{
258 /* nothing to do since memory is freed by qib_free_devdata() */
259}
260
261static const struct sysfs_ops qib_port_ops = {
262 .show = qib_portattr_show,
263 .store = qib_portattr_store,
264};
265
266static struct kobj_type qib_port_ktype = {
267 .release = qib_port_release,
268 .sysfs_ops = &qib_port_ops,
269 .default_attrs = port_default_attributes
270};
271
272/* Start sl2vl */
273
274#define QIB_SL2VL_ATTR(N) \
275 static struct qib_sl2vl_attr qib_sl2vl_attr_##N = { \
276 .attr = { .name = __stringify(N), .mode = 0444 }, \
277 .sl = N \
278 }
279
280struct qib_sl2vl_attr {
281 struct attribute attr;
282 int sl;
283};
284
285QIB_SL2VL_ATTR(0);
286QIB_SL2VL_ATTR(1);
287QIB_SL2VL_ATTR(2);
288QIB_SL2VL_ATTR(3);
289QIB_SL2VL_ATTR(4);
290QIB_SL2VL_ATTR(5);
291QIB_SL2VL_ATTR(6);
292QIB_SL2VL_ATTR(7);
293QIB_SL2VL_ATTR(8);
294QIB_SL2VL_ATTR(9);
295QIB_SL2VL_ATTR(10);
296QIB_SL2VL_ATTR(11);
297QIB_SL2VL_ATTR(12);
298QIB_SL2VL_ATTR(13);
299QIB_SL2VL_ATTR(14);
300QIB_SL2VL_ATTR(15);
301
302static struct attribute *sl2vl_default_attributes[] = {
303 &qib_sl2vl_attr_0.attr,
304 &qib_sl2vl_attr_1.attr,
305 &qib_sl2vl_attr_2.attr,
306 &qib_sl2vl_attr_3.attr,
307 &qib_sl2vl_attr_4.attr,
308 &qib_sl2vl_attr_5.attr,
309 &qib_sl2vl_attr_6.attr,
310 &qib_sl2vl_attr_7.attr,
311 &qib_sl2vl_attr_8.attr,
312 &qib_sl2vl_attr_9.attr,
313 &qib_sl2vl_attr_10.attr,
314 &qib_sl2vl_attr_11.attr,
315 &qib_sl2vl_attr_12.attr,
316 &qib_sl2vl_attr_13.attr,
317 &qib_sl2vl_attr_14.attr,
318 &qib_sl2vl_attr_15.attr,
319 NULL
320};
321
322static ssize_t sl2vl_attr_show(struct kobject *kobj, struct attribute *attr,
323 char *buf)
324{
325 struct qib_sl2vl_attr *sattr =
326 container_of(attr, struct qib_sl2vl_attr, attr);
327 struct qib_pportdata *ppd =
328 container_of(kobj, struct qib_pportdata, sl2vl_kobj);
329 struct qib_ibport *qibp = &ppd->ibport_data;
330
331 return sprintf(buf, "%u\n", qibp->sl_to_vl[sattr->sl]);
332}
333
334static const struct sysfs_ops qib_sl2vl_ops = {
335 .show = sl2vl_attr_show,
336};
337
338static struct kobj_type qib_sl2vl_ktype = {
339 .release = qib_port_release,
340 .sysfs_ops = &qib_sl2vl_ops,
341 .default_attrs = sl2vl_default_attributes
342};
343
344/* End sl2vl */
345
346/* Start diag_counters */
347
348#define QIB_DIAGC_ATTR(N) \
349 static struct qib_diagc_attr qib_diagc_attr_##N = { \
350 .attr = { .name = __stringify(N), .mode = 0444 }, \
351 .counter = offsetof(struct qib_ibport, n_##N) \
352 }
353
354struct qib_diagc_attr {
355 struct attribute attr;
356 size_t counter;
357};
358
359QIB_DIAGC_ATTR(rc_resends);
360QIB_DIAGC_ATTR(rc_acks);
361QIB_DIAGC_ATTR(rc_qacks);
362QIB_DIAGC_ATTR(rc_delayed_comp);
363QIB_DIAGC_ATTR(seq_naks);
364QIB_DIAGC_ATTR(rdma_seq);
365QIB_DIAGC_ATTR(rnr_naks);
366QIB_DIAGC_ATTR(other_naks);
367QIB_DIAGC_ATTR(rc_timeouts);
368QIB_DIAGC_ATTR(loop_pkts);
369QIB_DIAGC_ATTR(pkt_drops);
370QIB_DIAGC_ATTR(dmawait);
371QIB_DIAGC_ATTR(unaligned);
372QIB_DIAGC_ATTR(rc_dupreq);
373QIB_DIAGC_ATTR(rc_seqnak);
374
375static struct attribute *diagc_default_attributes[] = {
376 &qib_diagc_attr_rc_resends.attr,
377 &qib_diagc_attr_rc_acks.attr,
378 &qib_diagc_attr_rc_qacks.attr,
379 &qib_diagc_attr_rc_delayed_comp.attr,
380 &qib_diagc_attr_seq_naks.attr,
381 &qib_diagc_attr_rdma_seq.attr,
382 &qib_diagc_attr_rnr_naks.attr,
383 &qib_diagc_attr_other_naks.attr,
384 &qib_diagc_attr_rc_timeouts.attr,
385 &qib_diagc_attr_loop_pkts.attr,
386 &qib_diagc_attr_pkt_drops.attr,
387 &qib_diagc_attr_dmawait.attr,
388 &qib_diagc_attr_unaligned.attr,
389 &qib_diagc_attr_rc_dupreq.attr,
390 &qib_diagc_attr_rc_seqnak.attr,
391 NULL
392};
393
394static ssize_t diagc_attr_show(struct kobject *kobj, struct attribute *attr,
395 char *buf)
396{
397 struct qib_diagc_attr *dattr =
398 container_of(attr, struct qib_diagc_attr, attr);
399 struct qib_pportdata *ppd =
400 container_of(kobj, struct qib_pportdata, diagc_kobj);
401 struct qib_ibport *qibp = &ppd->ibport_data;
402
403 return sprintf(buf, "%u\n", *(u32 *)((char *)qibp + dattr->counter));
404}
405
406static const struct sysfs_ops qib_diagc_ops = {
407 .show = diagc_attr_show,
408};
409
410static struct kobj_type qib_diagc_ktype = {
411 .release = qib_port_release,
412 .sysfs_ops = &qib_diagc_ops,
413 .default_attrs = diagc_default_attributes
414};
415
416/* End diag_counters */
417
418/* end of per-port file structures and support code */
419
420/*
421 * Start of per-unit (or driver, in some cases, but replicated
422 * per unit) functions (these get a device *)
423 */
424static ssize_t show_rev(struct device *device, struct device_attribute *attr,
425 char *buf)
426{
427 struct qib_ibdev *dev =
428 container_of(device, struct qib_ibdev, ibdev.dev);
429
430 return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev);
431}
432
433static ssize_t show_hca(struct device *device, struct device_attribute *attr,
434 char *buf)
435{
436 struct qib_ibdev *dev =
437 container_of(device, struct qib_ibdev, ibdev.dev);
438 struct qib_devdata *dd = dd_from_dev(dev);
439 int ret;
440
441 if (!dd->boardname)
442 ret = -EINVAL;
443 else
444 ret = scnprintf(buf, PAGE_SIZE, "%s\n", dd->boardname);
445 return ret;
446}
447
448static ssize_t show_version(struct device *device,
449 struct device_attribute *attr, char *buf)
450{
451 /* The string printed here is already newline-terminated. */
452 return scnprintf(buf, PAGE_SIZE, "%s", (char *)ib_qib_version);
453}
454
455static ssize_t show_boardversion(struct device *device,
456 struct device_attribute *attr, char *buf)
457{
458 struct qib_ibdev *dev =
459 container_of(device, struct qib_ibdev, ibdev.dev);
460 struct qib_devdata *dd = dd_from_dev(dev);
461
462 /* The string printed here is already newline-terminated. */
463 return scnprintf(buf, PAGE_SIZE, "%s", dd->boardversion);
464}
465
466
467static ssize_t show_localbus_info(struct device *device,
468 struct device_attribute *attr, char *buf)
469{
470 struct qib_ibdev *dev =
471 container_of(device, struct qib_ibdev, ibdev.dev);
472 struct qib_devdata *dd = dd_from_dev(dev);
473
474 /* The string printed here is already newline-terminated. */
475 return scnprintf(buf, PAGE_SIZE, "%s", dd->lbus_info);
476}
477
478
479static ssize_t show_nctxts(struct device *device,
480 struct device_attribute *attr, char *buf)
481{
482 struct qib_ibdev *dev =
483 container_of(device, struct qib_ibdev, ibdev.dev);
484 struct qib_devdata *dd = dd_from_dev(dev);
485
486 /* Return the number of user ports (contexts) available. */
487 return scnprintf(buf, PAGE_SIZE, "%u\n", dd->cfgctxts -
488 dd->first_user_ctxt);
489}
490
491static ssize_t show_serial(struct device *device,
492 struct device_attribute *attr, char *buf)
493{
494 struct qib_ibdev *dev =
495 container_of(device, struct qib_ibdev, ibdev.dev);
496 struct qib_devdata *dd = dd_from_dev(dev);
497
498 buf[sizeof dd->serial] = '\0';
499 memcpy(buf, dd->serial, sizeof dd->serial);
500 strcat(buf, "\n");
501 return strlen(buf);
502}
503
504static ssize_t store_chip_reset(struct device *device,
505 struct device_attribute *attr, const char *buf,
506 size_t count)
507{
508 struct qib_ibdev *dev =
509 container_of(device, struct qib_ibdev, ibdev.dev);
510 struct qib_devdata *dd = dd_from_dev(dev);
511 int ret;
512
513 if (count < 5 || memcmp(buf, "reset", 5) || !dd->diag_client) {
514 ret = -EINVAL;
515 goto bail;
516 }
517
518 ret = qib_reset_device(dd->unit);
519bail:
520 return ret < 0 ? ret : count;
521}
522
523static ssize_t show_logged_errs(struct device *device,
524 struct device_attribute *attr, char *buf)
525{
526 struct qib_ibdev *dev =
527 container_of(device, struct qib_ibdev, ibdev.dev);
528 struct qib_devdata *dd = dd_from_dev(dev);
529 int idx, count;
530
531 /* force consistency with actual EEPROM */
532 if (qib_update_eeprom_log(dd) != 0)
533 return -ENXIO;
534
535 count = 0;
536 for (idx = 0; idx < QIB_EEP_LOG_CNT; ++idx) {
537 count += scnprintf(buf + count, PAGE_SIZE - count, "%d%c",
538 dd->eep_st_errs[idx],
539 idx == (QIB_EEP_LOG_CNT - 1) ? '\n' : ' ');
540 }
541
542 return count;
543}
544
545/*
546 * Dump tempsense regs. in decimal, to ease shell-scripts.
547 */
548static ssize_t show_tempsense(struct device *device,
549 struct device_attribute *attr, char *buf)
550{
551 struct qib_ibdev *dev =
552 container_of(device, struct qib_ibdev, ibdev.dev);
553 struct qib_devdata *dd = dd_from_dev(dev);
554 int ret;
555 int idx;
556 u8 regvals[8];
557
558 ret = -ENXIO;
559 for (idx = 0; idx < 8; ++idx) {
560 if (idx == 6)
561 continue;
562 ret = dd->f_tempsense_rd(dd, idx);
563 if (ret < 0)
564 break;
565 regvals[idx] = ret;
566 }
567 if (idx == 8)
568 ret = scnprintf(buf, PAGE_SIZE, "%d %d %02X %02X %d %d\n",
569 *(signed char *)(regvals),
570 *(signed char *)(regvals + 1),
571 regvals[2], regvals[3],
572 *(signed char *)(regvals + 5),
573 *(signed char *)(regvals + 7));
574 return ret;
575}
576
577/*
578 * end of per-unit (or driver, in some cases, but replicated
579 * per unit) functions
580 */
581
582/* start of per-unit file structures and support code */
583static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
584static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
585static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL);
586static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
587static DEVICE_ATTR(nctxts, S_IRUGO, show_nctxts, NULL);
588static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL);
589static DEVICE_ATTR(boardversion, S_IRUGO, show_boardversion, NULL);
590static DEVICE_ATTR(logged_errors, S_IRUGO, show_logged_errs, NULL);
591static DEVICE_ATTR(tempsense, S_IRUGO, show_tempsense, NULL);
592static DEVICE_ATTR(localbus_info, S_IRUGO, show_localbus_info, NULL);
593static DEVICE_ATTR(chip_reset, S_IWUSR, NULL, store_chip_reset);
594
595static struct device_attribute *qib_attributes[] = {
596 &dev_attr_hw_rev,
597 &dev_attr_hca_type,
598 &dev_attr_board_id,
599 &dev_attr_version,
600 &dev_attr_nctxts,
601 &dev_attr_serial,
602 &dev_attr_boardversion,
603 &dev_attr_logged_errors,
604 &dev_attr_tempsense,
605 &dev_attr_localbus_info,
606 &dev_attr_chip_reset,
607};
608
609int qib_create_port_files(struct ib_device *ibdev, u8 port_num,
610 struct kobject *kobj)
611{
612 struct qib_pportdata *ppd;
613 struct qib_devdata *dd = dd_from_ibdev(ibdev);
614 int ret;
615
616 if (!port_num || port_num > dd->num_pports) {
617 qib_dev_err(dd, "Skipping infiniband class with "
618 "invalid port %u\n", port_num);
619 ret = -ENODEV;
620 goto bail;
621 }
622 ppd = &dd->pport[port_num - 1];
623
624 ret = kobject_init_and_add(&ppd->pport_kobj, &qib_port_ktype, kobj,
625 "linkcontrol");
626 if (ret) {
627 qib_dev_err(dd, "Skipping linkcontrol sysfs info, "
628 "(err %d) port %u\n", ret, port_num);
629 goto bail;
630 }
631 kobject_uevent(&ppd->pport_kobj, KOBJ_ADD);
632
633 ret = kobject_init_and_add(&ppd->sl2vl_kobj, &qib_sl2vl_ktype, kobj,
634 "sl2vl");
635 if (ret) {
636 qib_dev_err(dd, "Skipping sl2vl sysfs info, "
637 "(err %d) port %u\n", ret, port_num);
638 goto bail_sl;
639 }
640 kobject_uevent(&ppd->sl2vl_kobj, KOBJ_ADD);
641
642 ret = kobject_init_and_add(&ppd->diagc_kobj, &qib_diagc_ktype, kobj,
643 "diag_counters");
644 if (ret) {
645 qib_dev_err(dd, "Skipping diag_counters sysfs info, "
646 "(err %d) port %u\n", ret, port_num);
647 goto bail_diagc;
648 }
649 kobject_uevent(&ppd->diagc_kobj, KOBJ_ADD);
650
651 return 0;
652
653bail_diagc:
654 kobject_put(&ppd->sl2vl_kobj);
655bail_sl:
656 kobject_put(&ppd->pport_kobj);
657bail:
658 return ret;
659}
660
661/*
662 * Register and create our files in /sys/class/infiniband.
663 */
664int qib_verbs_register_sysfs(struct qib_devdata *dd)
665{
666 struct ib_device *dev = &dd->verbs_dev.ibdev;
667 int i, ret;
668
669 for (i = 0; i < ARRAY_SIZE(qib_attributes); ++i) {
670 ret = device_create_file(&dev->dev, qib_attributes[i]);
671 if (ret)
672 return ret;
673 }
674
675 return 0;
676}
677
678/*
679 * Unregister and remove our files in /sys/class/infiniband.
680 */
681void qib_verbs_unregister_sysfs(struct qib_devdata *dd)
682{
683 struct qib_pportdata *ppd;
684 int i;
685
686 for (i = 0; i < dd->num_pports; i++) {
687 ppd = &dd->pport[i];
688 kobject_put(&ppd->pport_kobj);
689 kobject_put(&ppd->sl2vl_kobj);
690 }
691}