2 * Copyright (c) 2012 Intel Corporation. All rights reserved.
3 * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
4 * Copyright (c) 2006 PathScale, Inc. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 #include <linux/ctype.h>
39 /* start of per-port functions */
41 * Get/Set heartbeat enable. OR of 1=enabled, 2=auto
43 static ssize_t
show_hrtbt_enb(struct qib_pportdata
*ppd
, char *buf
)
45 struct qib_devdata
*dd
= ppd
->dd
;
48 ret
= dd
->f_get_ib_cfg(ppd
, QIB_IB_CFG_HRTBT
);
49 ret
= scnprintf(buf
, PAGE_SIZE
, "%d\n", ret
);
53 static ssize_t
store_hrtbt_enb(struct qib_pportdata
*ppd
, const char *buf
,
56 struct qib_devdata
*dd
= ppd
->dd
;
60 ret
= kstrtou16(buf
, 0, &val
);
62 qib_dev_err(dd
, "attempt to set invalid Heartbeat enable\n");
67 * Set the "intentional" heartbeat enable per either of
68 * "Enable" and "Auto", as these are normally set together.
69 * This bit is consulted when leaving loopback mode,
70 * because entering loopback mode overrides it and automatically
73 ret
= dd
->f_set_ib_cfg(ppd
, QIB_IB_CFG_HRTBT
, val
);
74 return ret
< 0 ? ret
: count
;
77 static ssize_t
store_loopback(struct qib_pportdata
*ppd
, const char *buf
,
80 struct qib_devdata
*dd
= ppd
->dd
;
83 r
= dd
->f_set_ib_loopback(ppd
, buf
);
90 static ssize_t
store_led_override(struct qib_pportdata
*ppd
, const char *buf
,
93 struct qib_devdata
*dd
= ppd
->dd
;
97 ret
= kstrtou16(buf
, 0, &val
);
99 qib_dev_err(dd
, "attempt to set invalid LED override\n");
103 qib_set_led_override(ppd
, val
);
107 static ssize_t
show_status(struct qib_pportdata
*ppd
, char *buf
)
114 ret
= scnprintf(buf
, PAGE_SIZE
, "0x%llx\n",
115 (unsigned long long) *(ppd
->statusp
));
120 * For userland compatibility, these offsets must remain fixed.
121 * They are strings for QIB_STATUS_*
123 static const char * const qib_status_str
[] = {
133 "Fatal_Hardware_Error",
137 static ssize_t
show_status_str(struct qib_pportdata
*ppd
, char *buf
)
150 for (any
= i
= 0; s
&& qib_status_str
[i
]; i
++) {
153 if (any
&& strlcat(buf
, " ", PAGE_SIZE
) >= PAGE_SIZE
)
155 if (strlcat(buf
, qib_status_str
[i
], PAGE_SIZE
) >=
163 strlcat(buf
, "\n", PAGE_SIZE
);
171 /* end of per-port functions */
174 * Start of per-port file structures and support code
175 * Because we are fitting into other infrastructure, we have to supply the
176 * full set of kobject/sysfs_ops structures and routines.
178 #define QIB_PORT_ATTR(name, mode, show, store) \
179 static struct qib_port_attr qib_port_attr_##name = \
180 __ATTR(name, mode, show, store)
182 struct qib_port_attr
{
183 struct attribute attr
;
184 ssize_t (*show
)(struct qib_pportdata
*, char *);
185 ssize_t (*store
)(struct qib_pportdata
*, const char *, size_t);
188 QIB_PORT_ATTR(loopback
, S_IWUSR
, NULL
, store_loopback
);
189 QIB_PORT_ATTR(led_override
, S_IWUSR
, NULL
, store_led_override
);
190 QIB_PORT_ATTR(hrtbt_enable
, S_IWUSR
| S_IRUGO
, show_hrtbt_enb
,
192 QIB_PORT_ATTR(status
, S_IRUGO
, show_status
, NULL
);
193 QIB_PORT_ATTR(status_str
, S_IRUGO
, show_status_str
, NULL
);
195 static struct attribute
*port_default_attributes
[] = {
196 &qib_port_attr_loopback
.attr
,
197 &qib_port_attr_led_override
.attr
,
198 &qib_port_attr_hrtbt_enable
.attr
,
199 &qib_port_attr_status
.attr
,
200 &qib_port_attr_status_str
.attr
,
205 * Start of per-port congestion control structures and support code
209 * Congestion control table size followed by table entries
211 static ssize_t
read_cc_table_bin(struct file
*filp
, struct kobject
*kobj
,
212 struct bin_attribute
*bin_attr
,
213 char *buf
, loff_t pos
, size_t count
)
216 struct qib_pportdata
*ppd
=
217 container_of(kobj
, struct qib_pportdata
, pport_cc_kobj
);
219 if (!qib_cc_table_size
|| !ppd
->ccti_entries_shadow
)
222 ret
= ppd
->total_cct_entry
* sizeof(struct ib_cc_table_entry_shadow
)
228 if (count
> ret
- pos
)
234 spin_lock(&ppd
->cc_shadow_lock
);
235 memcpy(buf
, ppd
->ccti_entries_shadow
, count
);
236 spin_unlock(&ppd
->cc_shadow_lock
);
241 static void qib_port_release(struct kobject
*kobj
)
243 /* nothing to do since memory is freed by qib_free_devdata() */
246 static struct kobj_type qib_port_cc_ktype
= {
247 .release
= qib_port_release
,
250 static const struct bin_attribute cc_table_bin_attr
= {
251 .attr
= {.name
= "cc_table_bin", .mode
= 0444},
252 .read
= read_cc_table_bin
,
257 * Congestion settings: port control, control map and an array of 16
258 * entries for the congestion entries - increase, timer, event log
259 * trigger threshold and the minimum injection rate delay.
261 static ssize_t
read_cc_setting_bin(struct file
*filp
, struct kobject
*kobj
,
262 struct bin_attribute
*bin_attr
,
263 char *buf
, loff_t pos
, size_t count
)
266 struct qib_pportdata
*ppd
=
267 container_of(kobj
, struct qib_pportdata
, pport_cc_kobj
);
269 if (!qib_cc_table_size
|| !ppd
->congestion_entries_shadow
)
272 ret
= sizeof(struct ib_cc_congestion_setting_attr_shadow
);
276 if (count
> ret
- pos
)
282 spin_lock(&ppd
->cc_shadow_lock
);
283 memcpy(buf
, ppd
->congestion_entries_shadow
, count
);
284 spin_unlock(&ppd
->cc_shadow_lock
);
289 static const struct bin_attribute cc_setting_bin_attr
= {
290 .attr
= {.name
= "cc_settings_bin", .mode
= 0444},
291 .read
= read_cc_setting_bin
,
296 static ssize_t
qib_portattr_show(struct kobject
*kobj
,
297 struct attribute
*attr
, char *buf
)
299 struct qib_port_attr
*pattr
=
300 container_of(attr
, struct qib_port_attr
, attr
);
301 struct qib_pportdata
*ppd
=
302 container_of(kobj
, struct qib_pportdata
, pport_kobj
);
304 return pattr
->show(ppd
, buf
);
307 static ssize_t
qib_portattr_store(struct kobject
*kobj
,
308 struct attribute
*attr
, const char *buf
, size_t len
)
310 struct qib_port_attr
*pattr
=
311 container_of(attr
, struct qib_port_attr
, attr
);
312 struct qib_pportdata
*ppd
=
313 container_of(kobj
, struct qib_pportdata
, pport_kobj
);
315 return pattr
->store(ppd
, buf
, len
);
319 static const struct sysfs_ops qib_port_ops
= {
320 .show
= qib_portattr_show
,
321 .store
= qib_portattr_store
,
324 static struct kobj_type qib_port_ktype
= {
325 .release
= qib_port_release
,
326 .sysfs_ops
= &qib_port_ops
,
327 .default_attrs
= port_default_attributes
332 #define QIB_SL2VL_ATTR(N) \
333 static struct qib_sl2vl_attr qib_sl2vl_attr_##N = { \
334 .attr = { .name = __stringify(N), .mode = 0444 }, \
338 struct qib_sl2vl_attr
{
339 struct attribute attr
;
360 static struct attribute
*sl2vl_default_attributes
[] = {
361 &qib_sl2vl_attr_0
.attr
,
362 &qib_sl2vl_attr_1
.attr
,
363 &qib_sl2vl_attr_2
.attr
,
364 &qib_sl2vl_attr_3
.attr
,
365 &qib_sl2vl_attr_4
.attr
,
366 &qib_sl2vl_attr_5
.attr
,
367 &qib_sl2vl_attr_6
.attr
,
368 &qib_sl2vl_attr_7
.attr
,
369 &qib_sl2vl_attr_8
.attr
,
370 &qib_sl2vl_attr_9
.attr
,
371 &qib_sl2vl_attr_10
.attr
,
372 &qib_sl2vl_attr_11
.attr
,
373 &qib_sl2vl_attr_12
.attr
,
374 &qib_sl2vl_attr_13
.attr
,
375 &qib_sl2vl_attr_14
.attr
,
376 &qib_sl2vl_attr_15
.attr
,
380 static ssize_t
sl2vl_attr_show(struct kobject
*kobj
, struct attribute
*attr
,
383 struct qib_sl2vl_attr
*sattr
=
384 container_of(attr
, struct qib_sl2vl_attr
, attr
);
385 struct qib_pportdata
*ppd
=
386 container_of(kobj
, struct qib_pportdata
, sl2vl_kobj
);
387 struct qib_ibport
*qibp
= &ppd
->ibport_data
;
389 return sprintf(buf
, "%u\n", qibp
->sl_to_vl
[sattr
->sl
]);
392 static const struct sysfs_ops qib_sl2vl_ops
= {
393 .show
= sl2vl_attr_show
,
396 static struct kobj_type qib_sl2vl_ktype
= {
397 .release
= qib_port_release
,
398 .sysfs_ops
= &qib_sl2vl_ops
,
399 .default_attrs
= sl2vl_default_attributes
404 /* Start diag_counters */
406 #define QIB_DIAGC_ATTR(N) \
407 static struct qib_diagc_attr qib_diagc_attr_##N = { \
408 .attr = { .name = __stringify(N), .mode = 0664 }, \
409 .counter = offsetof(struct qib_ibport, rvp.n_##N) \
412 #define QIB_DIAGC_ATTR_PER_CPU(N) \
413 static struct qib_diagc_attr qib_diagc_attr_##N = { \
414 .attr = { .name = __stringify(N), .mode = 0664 }, \
415 .counter = offsetof(struct qib_ibport, rvp.z_##N) \
418 struct qib_diagc_attr
{
419 struct attribute attr
;
423 QIB_DIAGC_ATTR_PER_CPU(rc_acks
);
424 QIB_DIAGC_ATTR_PER_CPU(rc_qacks
);
425 QIB_DIAGC_ATTR_PER_CPU(rc_delayed_comp
);
427 QIB_DIAGC_ATTR(rc_resends
);
428 QIB_DIAGC_ATTR(seq_naks
);
429 QIB_DIAGC_ATTR(rdma_seq
);
430 QIB_DIAGC_ATTR(rnr_naks
);
431 QIB_DIAGC_ATTR(other_naks
);
432 QIB_DIAGC_ATTR(rc_timeouts
);
433 QIB_DIAGC_ATTR(loop_pkts
);
434 QIB_DIAGC_ATTR(pkt_drops
);
435 QIB_DIAGC_ATTR(dmawait
);
436 QIB_DIAGC_ATTR(unaligned
);
437 QIB_DIAGC_ATTR(rc_dupreq
);
438 QIB_DIAGC_ATTR(rc_seqnak
);
440 static struct attribute
*diagc_default_attributes
[] = {
441 &qib_diagc_attr_rc_resends
.attr
,
442 &qib_diagc_attr_rc_acks
.attr
,
443 &qib_diagc_attr_rc_qacks
.attr
,
444 &qib_diagc_attr_rc_delayed_comp
.attr
,
445 &qib_diagc_attr_seq_naks
.attr
,
446 &qib_diagc_attr_rdma_seq
.attr
,
447 &qib_diagc_attr_rnr_naks
.attr
,
448 &qib_diagc_attr_other_naks
.attr
,
449 &qib_diagc_attr_rc_timeouts
.attr
,
450 &qib_diagc_attr_loop_pkts
.attr
,
451 &qib_diagc_attr_pkt_drops
.attr
,
452 &qib_diagc_attr_dmawait
.attr
,
453 &qib_diagc_attr_unaligned
.attr
,
454 &qib_diagc_attr_rc_dupreq
.attr
,
455 &qib_diagc_attr_rc_seqnak
.attr
,
459 static u64
get_all_cpu_total(u64 __percpu
*cntr
)
464 for_each_possible_cpu(cpu
)
465 counter
+= *per_cpu_ptr(cntr
, cpu
);
469 #define def_write_per_cpu(cntr) \
470 static void write_per_cpu_##cntr(struct qib_pportdata *ppd, u32 data) \
472 struct qib_devdata *dd = ppd->dd; \
473 struct qib_ibport *qibp = &ppd->ibport_data; \
474 /* A write can only zero the counter */ \
476 qibp->rvp.z_##cntr = get_all_cpu_total(qibp->rvp.cntr); \
478 qib_dev_err(dd, "Per CPU cntrs can only be zeroed"); \
481 def_write_per_cpu(rc_acks
)
482 def_write_per_cpu(rc_qacks
)
483 def_write_per_cpu(rc_delayed_comp
)
485 #define READ_PER_CPU_CNTR(cntr) (get_all_cpu_total(qibp->rvp.cntr) - \
488 static ssize_t
diagc_attr_show(struct kobject
*kobj
, struct attribute
*attr
,
491 struct qib_diagc_attr
*dattr
=
492 container_of(attr
, struct qib_diagc_attr
, attr
);
493 struct qib_pportdata
*ppd
=
494 container_of(kobj
, struct qib_pportdata
, diagc_kobj
);
495 struct qib_ibport
*qibp
= &ppd
->ibport_data
;
497 if (!strncmp(dattr
->attr
.name
, "rc_acks", 7))
498 return sprintf(buf
, "%llu\n", READ_PER_CPU_CNTR(rc_acks
));
499 else if (!strncmp(dattr
->attr
.name
, "rc_qacks", 8))
500 return sprintf(buf
, "%llu\n", READ_PER_CPU_CNTR(rc_qacks
));
501 else if (!strncmp(dattr
->attr
.name
, "rc_delayed_comp", 15))
502 return sprintf(buf
, "%llu\n",
503 READ_PER_CPU_CNTR(rc_delayed_comp
));
505 return sprintf(buf
, "%u\n",
506 *(u32
*)((char *)qibp
+ dattr
->counter
));
509 static ssize_t
diagc_attr_store(struct kobject
*kobj
, struct attribute
*attr
,
510 const char *buf
, size_t size
)
512 struct qib_diagc_attr
*dattr
=
513 container_of(attr
, struct qib_diagc_attr
, attr
);
514 struct qib_pportdata
*ppd
=
515 container_of(kobj
, struct qib_pportdata
, diagc_kobj
);
516 struct qib_ibport
*qibp
= &ppd
->ibport_data
;
520 ret
= kstrtou32(buf
, 0, &val
);
524 if (!strncmp(dattr
->attr
.name
, "rc_acks", 7))
525 write_per_cpu_rc_acks(ppd
, val
);
526 else if (!strncmp(dattr
->attr
.name
, "rc_qacks", 8))
527 write_per_cpu_rc_qacks(ppd
, val
);
528 else if (!strncmp(dattr
->attr
.name
, "rc_delayed_comp", 15))
529 write_per_cpu_rc_delayed_comp(ppd
, val
);
531 *(u32
*)((char *)qibp
+ dattr
->counter
) = val
;
535 static const struct sysfs_ops qib_diagc_ops
= {
536 .show
= diagc_attr_show
,
537 .store
= diagc_attr_store
,
540 static struct kobj_type qib_diagc_ktype
= {
541 .release
= qib_port_release
,
542 .sysfs_ops
= &qib_diagc_ops
,
543 .default_attrs
= diagc_default_attributes
546 /* End diag_counters */
548 /* end of per-port file structures and support code */
551 * Start of per-unit (or driver, in some cases, but replicated
552 * per unit) functions (these get a device *)
554 static ssize_t
show_rev(struct device
*device
, struct device_attribute
*attr
,
557 struct qib_ibdev
*dev
=
558 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
560 return sprintf(buf
, "%x\n", dd_from_dev(dev
)->minrev
);
563 static ssize_t
show_hca(struct device
*device
, struct device_attribute
*attr
,
566 struct qib_ibdev
*dev
=
567 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
568 struct qib_devdata
*dd
= dd_from_dev(dev
);
574 ret
= scnprintf(buf
, PAGE_SIZE
, "%s\n", dd
->boardname
);
578 static ssize_t
show_version(struct device
*device
,
579 struct device_attribute
*attr
, char *buf
)
581 /* The string printed here is already newline-terminated. */
582 return scnprintf(buf
, PAGE_SIZE
, "%s", (char *)ib_qib_version
);
585 static ssize_t
show_boardversion(struct device
*device
,
586 struct device_attribute
*attr
, char *buf
)
588 struct qib_ibdev
*dev
=
589 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
590 struct qib_devdata
*dd
= dd_from_dev(dev
);
592 /* The string printed here is already newline-terminated. */
593 return scnprintf(buf
, PAGE_SIZE
, "%s", dd
->boardversion
);
597 static ssize_t
show_localbus_info(struct device
*device
,
598 struct device_attribute
*attr
, char *buf
)
600 struct qib_ibdev
*dev
=
601 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
602 struct qib_devdata
*dd
= dd_from_dev(dev
);
604 /* The string printed here is already newline-terminated. */
605 return scnprintf(buf
, PAGE_SIZE
, "%s", dd
->lbus_info
);
609 static ssize_t
show_nctxts(struct device
*device
,
610 struct device_attribute
*attr
, char *buf
)
612 struct qib_ibdev
*dev
=
613 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
614 struct qib_devdata
*dd
= dd_from_dev(dev
);
616 /* Return the number of user ports (contexts) available. */
617 /* The calculation below deals with a special case where
618 * cfgctxts is set to 1 on a single-port board. */
619 return scnprintf(buf
, PAGE_SIZE
, "%u\n",
620 (dd
->first_user_ctxt
> dd
->cfgctxts
) ? 0 :
621 (dd
->cfgctxts
- dd
->first_user_ctxt
));
624 static ssize_t
show_nfreectxts(struct device
*device
,
625 struct device_attribute
*attr
, char *buf
)
627 struct qib_ibdev
*dev
=
628 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
629 struct qib_devdata
*dd
= dd_from_dev(dev
);
631 /* Return the number of free user ports (contexts) available. */
632 return scnprintf(buf
, PAGE_SIZE
, "%u\n", dd
->freectxts
);
635 static ssize_t
show_serial(struct device
*device
,
636 struct device_attribute
*attr
, char *buf
)
638 struct qib_ibdev
*dev
=
639 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
640 struct qib_devdata
*dd
= dd_from_dev(dev
);
642 buf
[sizeof(dd
->serial
)] = '\0';
643 memcpy(buf
, dd
->serial
, sizeof(dd
->serial
));
648 static ssize_t
store_chip_reset(struct device
*device
,
649 struct device_attribute
*attr
, const char *buf
,
652 struct qib_ibdev
*dev
=
653 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
654 struct qib_devdata
*dd
= dd_from_dev(dev
);
657 if (count
< 5 || memcmp(buf
, "reset", 5) || !dd
->diag_client
) {
662 ret
= qib_reset_device(dd
->unit
);
664 return ret
< 0 ? ret
: count
;
668 * Dump tempsense regs. in decimal, to ease shell-scripts.
670 static ssize_t
show_tempsense(struct device
*device
,
671 struct device_attribute
*attr
, char *buf
)
673 struct qib_ibdev
*dev
=
674 container_of(device
, struct qib_ibdev
, rdi
.ibdev
.dev
);
675 struct qib_devdata
*dd
= dd_from_dev(dev
);
681 for (idx
= 0; idx
< 8; ++idx
) {
684 ret
= dd
->f_tempsense_rd(dd
, idx
);
690 ret
= scnprintf(buf
, PAGE_SIZE
, "%d %d %02X %02X %d %d\n",
691 *(signed char *)(regvals
),
692 *(signed char *)(regvals
+ 1),
693 regvals
[2], regvals
[3],
694 *(signed char *)(regvals
+ 5),
695 *(signed char *)(regvals
+ 7));
700 * end of per-unit (or driver, in some cases, but replicated
701 * per unit) functions
704 /* start of per-unit file structures and support code */
705 static DEVICE_ATTR(hw_rev
, S_IRUGO
, show_rev
, NULL
);
706 static DEVICE_ATTR(hca_type
, S_IRUGO
, show_hca
, NULL
);
707 static DEVICE_ATTR(board_id
, S_IRUGO
, show_hca
, NULL
);
708 static DEVICE_ATTR(version
, S_IRUGO
, show_version
, NULL
);
709 static DEVICE_ATTR(nctxts
, S_IRUGO
, show_nctxts
, NULL
);
710 static DEVICE_ATTR(nfreectxts
, S_IRUGO
, show_nfreectxts
, NULL
);
711 static DEVICE_ATTR(serial
, S_IRUGO
, show_serial
, NULL
);
712 static DEVICE_ATTR(boardversion
, S_IRUGO
, show_boardversion
, NULL
);
713 static DEVICE_ATTR(tempsense
, S_IRUGO
, show_tempsense
, NULL
);
714 static DEVICE_ATTR(localbus_info
, S_IRUGO
, show_localbus_info
, NULL
);
715 static DEVICE_ATTR(chip_reset
, S_IWUSR
, NULL
, store_chip_reset
);
717 static struct device_attribute
*qib_attributes
[] = {
723 &dev_attr_nfreectxts
,
725 &dev_attr_boardversion
,
727 &dev_attr_localbus_info
,
728 &dev_attr_chip_reset
,
731 int qib_create_port_files(struct ib_device
*ibdev
, u8 port_num
,
732 struct kobject
*kobj
)
734 struct qib_pportdata
*ppd
;
735 struct qib_devdata
*dd
= dd_from_ibdev(ibdev
);
738 if (!port_num
|| port_num
> dd
->num_pports
) {
740 "Skipping infiniband class with invalid port %u\n",
745 ppd
= &dd
->pport
[port_num
- 1];
747 ret
= kobject_init_and_add(&ppd
->pport_kobj
, &qib_port_ktype
, kobj
,
751 "Skipping linkcontrol sysfs info, (err %d) port %u\n",
755 kobject_uevent(&ppd
->pport_kobj
, KOBJ_ADD
);
757 ret
= kobject_init_and_add(&ppd
->sl2vl_kobj
, &qib_sl2vl_ktype
, kobj
,
761 "Skipping sl2vl sysfs info, (err %d) port %u\n",
765 kobject_uevent(&ppd
->sl2vl_kobj
, KOBJ_ADD
);
767 ret
= kobject_init_and_add(&ppd
->diagc_kobj
, &qib_diagc_ktype
, kobj
,
771 "Skipping diag_counters sysfs info, (err %d) port %u\n",
775 kobject_uevent(&ppd
->diagc_kobj
, KOBJ_ADD
);
777 if (!qib_cc_table_size
|| !ppd
->congestion_entries_shadow
)
780 ret
= kobject_init_and_add(&ppd
->pport_cc_kobj
, &qib_port_cc_ktype
,
784 "Skipping Congestion Control sysfs info, (err %d) port %u\n",
789 kobject_uevent(&ppd
->pport_cc_kobj
, KOBJ_ADD
);
791 ret
= sysfs_create_bin_file(&ppd
->pport_cc_kobj
,
792 &cc_setting_bin_attr
);
795 "Skipping Congestion Control setting sysfs info, (err %d) port %u\n",
800 ret
= sysfs_create_bin_file(&ppd
->pport_cc_kobj
,
804 "Skipping Congestion Control table sysfs info, (err %d) port %u\n",
806 goto bail_cc_entry_bin
;
809 qib_devinfo(dd
->pcidev
,
810 "IB%u: Congestion Control Agent enabled for port %d\n",
816 sysfs_remove_bin_file(&ppd
->pport_cc_kobj
, &cc_setting_bin_attr
);
818 kobject_put(&ppd
->pport_cc_kobj
);
820 kobject_put(&ppd
->diagc_kobj
);
822 kobject_put(&ppd
->sl2vl_kobj
);
824 kobject_put(&ppd
->pport_kobj
);
830 * Register and create our files in /sys/class/infiniband.
832 int qib_verbs_register_sysfs(struct qib_devdata
*dd
)
834 struct ib_device
*dev
= &dd
->verbs_dev
.rdi
.ibdev
;
837 for (i
= 0; i
< ARRAY_SIZE(qib_attributes
); ++i
) {
838 ret
= device_create_file(&dev
->dev
, qib_attributes
[i
]);
845 for (i
= 0; i
< ARRAY_SIZE(qib_attributes
); ++i
)
846 device_remove_file(&dev
->dev
, qib_attributes
[i
]);
851 * Unregister and remove our files in /sys/class/infiniband.
853 void qib_verbs_unregister_sysfs(struct qib_devdata
*dd
)
855 struct qib_pportdata
*ppd
;
858 for (i
= 0; i
< dd
->num_pports
; i
++) {
860 if (qib_cc_table_size
&&
861 ppd
->congestion_entries_shadow
) {
862 sysfs_remove_bin_file(&ppd
->pport_cc_kobj
,
863 &cc_setting_bin_attr
);
864 sysfs_remove_bin_file(&ppd
->pport_cc_kobj
,
866 kobject_put(&ppd
->pport_cc_kobj
);
868 kobject_put(&ppd
->sl2vl_kobj
);
869 kobject_put(&ppd
->pport_kobj
);