| .. | .. |
|---|
| 442 | 442 | QIB_DIAGC_ATTR(unaligned); |
|---|
| 443 | 443 | QIB_DIAGC_ATTR(rc_dupreq); |
|---|
| 444 | 444 | QIB_DIAGC_ATTR(rc_seqnak); |
|---|
| 445 | +QIB_DIAGC_ATTR(rc_crwaits); |
|---|
| 445 | 446 | |
|---|
| 446 | 447 | static struct attribute *diagc_default_attributes[] = { |
|---|
| 447 | 448 | &qib_diagc_attr_rc_resends.attr, |
|---|
| .. | .. |
|---|
| 459 | 460 | &qib_diagc_attr_unaligned.attr, |
|---|
| 460 | 461 | &qib_diagc_attr_rc_dupreq.attr, |
|---|
| 461 | 462 | &qib_diagc_attr_rc_seqnak.attr, |
|---|
| 463 | + &qib_diagc_attr_rc_crwaits.attr, |
|---|
| 462 | 464 | NULL |
|---|
| 463 | 465 | }; |
|---|
| 464 | 466 | |
|---|
| .. | .. |
|---|
| 557 | 559 | * Start of per-unit (or driver, in some cases, but replicated |
|---|
| 558 | 560 | * per unit) functions (these get a device *) |
|---|
| 559 | 561 | */ |
|---|
| 560 | | -static ssize_t show_rev(struct device *device, struct device_attribute *attr, |
|---|
| 561 | | - char *buf) |
|---|
| 562 | +static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr, |
|---|
| 563 | + char *buf) |
|---|
| 562 | 564 | { |
|---|
| 563 | 565 | struct qib_ibdev *dev = |
|---|
| 564 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 566 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 565 | 567 | |
|---|
| 566 | 568 | return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev); |
|---|
| 567 | 569 | } |
|---|
| 570 | +static DEVICE_ATTR_RO(hw_rev); |
|---|
| 568 | 571 | |
|---|
| 569 | | -static ssize_t show_hca(struct device *device, struct device_attribute *attr, |
|---|
| 570 | | - char *buf) |
|---|
| 572 | +static ssize_t hca_type_show(struct device *device, |
|---|
| 573 | + struct device_attribute *attr, char *buf) |
|---|
| 571 | 574 | { |
|---|
| 572 | 575 | struct qib_ibdev *dev = |
|---|
| 573 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 576 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 574 | 577 | struct qib_devdata *dd = dd_from_dev(dev); |
|---|
| 575 | 578 | int ret; |
|---|
| 576 | 579 | |
|---|
| .. | .. |
|---|
| 580 | 583 | ret = scnprintf(buf, PAGE_SIZE, "%s\n", dd->boardname); |
|---|
| 581 | 584 | return ret; |
|---|
| 582 | 585 | } |
|---|
| 586 | +static DEVICE_ATTR_RO(hca_type); |
|---|
| 587 | +static DEVICE_ATTR(board_id, 0444, hca_type_show, NULL); |
|---|
| 583 | 588 | |
|---|
| 584 | | -static ssize_t show_version(struct device *device, |
|---|
| 589 | +static ssize_t version_show(struct device *device, |
|---|
| 585 | 590 | struct device_attribute *attr, char *buf) |
|---|
| 586 | 591 | { |
|---|
| 587 | 592 | /* The string printed here is already newline-terminated. */ |
|---|
| 588 | 593 | return scnprintf(buf, PAGE_SIZE, "%s", (char *)ib_qib_version); |
|---|
| 589 | 594 | } |
|---|
| 595 | +static DEVICE_ATTR_RO(version); |
|---|
| 590 | 596 | |
|---|
| 591 | | -static ssize_t show_boardversion(struct device *device, |
|---|
| 597 | +static ssize_t boardversion_show(struct device *device, |
|---|
| 592 | 598 | struct device_attribute *attr, char *buf) |
|---|
| 593 | 599 | { |
|---|
| 594 | 600 | struct qib_ibdev *dev = |
|---|
| 595 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 601 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 596 | 602 | struct qib_devdata *dd = dd_from_dev(dev); |
|---|
| 597 | 603 | |
|---|
| 598 | 604 | /* The string printed here is already newline-terminated. */ |
|---|
| 599 | 605 | return scnprintf(buf, PAGE_SIZE, "%s", dd->boardversion); |
|---|
| 600 | 606 | } |
|---|
| 607 | +static DEVICE_ATTR_RO(boardversion); |
|---|
| 601 | 608 | |
|---|
| 602 | | - |
|---|
| 603 | | -static ssize_t show_localbus_info(struct device *device, |
|---|
| 609 | +static ssize_t localbus_info_show(struct device *device, |
|---|
| 604 | 610 | struct device_attribute *attr, char *buf) |
|---|
| 605 | 611 | { |
|---|
| 606 | 612 | struct qib_ibdev *dev = |
|---|
| 607 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 613 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 608 | 614 | struct qib_devdata *dd = dd_from_dev(dev); |
|---|
| 609 | 615 | |
|---|
| 610 | 616 | /* The string printed here is already newline-terminated. */ |
|---|
| 611 | 617 | return scnprintf(buf, PAGE_SIZE, "%s", dd->lbus_info); |
|---|
| 612 | 618 | } |
|---|
| 619 | +static DEVICE_ATTR_RO(localbus_info); |
|---|
| 613 | 620 | |
|---|
| 614 | | - |
|---|
| 615 | | -static ssize_t show_nctxts(struct device *device, |
|---|
| 621 | +static ssize_t nctxts_show(struct device *device, |
|---|
| 616 | 622 | struct device_attribute *attr, char *buf) |
|---|
| 617 | 623 | { |
|---|
| 618 | 624 | struct qib_ibdev *dev = |
|---|
| 619 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 625 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 620 | 626 | struct qib_devdata *dd = dd_from_dev(dev); |
|---|
| 621 | 627 | |
|---|
| 622 | 628 | /* Return the number of user ports (contexts) available. */ |
|---|
| .. | .. |
|---|
| 626 | 632 | (dd->first_user_ctxt > dd->cfgctxts) ? 0 : |
|---|
| 627 | 633 | (dd->cfgctxts - dd->first_user_ctxt)); |
|---|
| 628 | 634 | } |
|---|
| 635 | +static DEVICE_ATTR_RO(nctxts); |
|---|
| 629 | 636 | |
|---|
| 630 | | -static ssize_t show_nfreectxts(struct device *device, |
|---|
| 631 | | - struct device_attribute *attr, char *buf) |
|---|
| 637 | +static ssize_t nfreectxts_show(struct device *device, |
|---|
| 638 | + struct device_attribute *attr, char *buf) |
|---|
| 632 | 639 | { |
|---|
| 633 | 640 | struct qib_ibdev *dev = |
|---|
| 634 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 641 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 635 | 642 | struct qib_devdata *dd = dd_from_dev(dev); |
|---|
| 636 | 643 | |
|---|
| 637 | 644 | /* Return the number of free user ports (contexts) available. */ |
|---|
| 638 | 645 | return scnprintf(buf, PAGE_SIZE, "%u\n", dd->freectxts); |
|---|
| 639 | 646 | } |
|---|
| 647 | +static DEVICE_ATTR_RO(nfreectxts); |
|---|
| 640 | 648 | |
|---|
| 641 | | -static ssize_t show_serial(struct device *device, |
|---|
| 649 | +static ssize_t serial_show(struct device *device, |
|---|
| 642 | 650 | struct device_attribute *attr, char *buf) |
|---|
| 643 | 651 | { |
|---|
| 644 | 652 | struct qib_ibdev *dev = |
|---|
| 645 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 653 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 646 | 654 | struct qib_devdata *dd = dd_from_dev(dev); |
|---|
| 647 | 655 | |
|---|
| 648 | 656 | buf[sizeof(dd->serial)] = '\0'; |
|---|
| .. | .. |
|---|
| 650 | 658 | strcat(buf, "\n"); |
|---|
| 651 | 659 | return strlen(buf); |
|---|
| 652 | 660 | } |
|---|
| 661 | +static DEVICE_ATTR_RO(serial); |
|---|
| 653 | 662 | |
|---|
| 654 | | -static ssize_t store_chip_reset(struct device *device, |
|---|
| 663 | +static ssize_t chip_reset_store(struct device *device, |
|---|
| 655 | 664 | struct device_attribute *attr, const char *buf, |
|---|
| 656 | 665 | size_t count) |
|---|
| 657 | 666 | { |
|---|
| 658 | 667 | struct qib_ibdev *dev = |
|---|
| 659 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 668 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 660 | 669 | struct qib_devdata *dd = dd_from_dev(dev); |
|---|
| 661 | 670 | int ret; |
|---|
| 662 | 671 | |
|---|
| .. | .. |
|---|
| 669 | 678 | bail: |
|---|
| 670 | 679 | return ret < 0 ? ret : count; |
|---|
| 671 | 680 | } |
|---|
| 681 | +static DEVICE_ATTR_WO(chip_reset); |
|---|
| 672 | 682 | |
|---|
| 673 | 683 | /* |
|---|
| 674 | 684 | * Dump tempsense regs. in decimal, to ease shell-scripts. |
|---|
| 675 | 685 | */ |
|---|
| 676 | | -static ssize_t show_tempsense(struct device *device, |
|---|
| 686 | +static ssize_t tempsense_show(struct device *device, |
|---|
| 677 | 687 | struct device_attribute *attr, char *buf) |
|---|
| 678 | 688 | { |
|---|
| 679 | 689 | struct qib_ibdev *dev = |
|---|
| 680 | | - container_of(device, struct qib_ibdev, rdi.ibdev.dev); |
|---|
| 690 | + rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev); |
|---|
| 681 | 691 | struct qib_devdata *dd = dd_from_dev(dev); |
|---|
| 682 | 692 | int ret; |
|---|
| 683 | 693 | int idx; |
|---|
| .. | .. |
|---|
| 701 | 711 | *(signed char *)(regvals + 7)); |
|---|
| 702 | 712 | return ret; |
|---|
| 703 | 713 | } |
|---|
| 714 | +static DEVICE_ATTR_RO(tempsense); |
|---|
| 704 | 715 | |
|---|
| 705 | 716 | /* |
|---|
| 706 | 717 | * end of per-unit (or driver, in some cases, but replicated |
|---|
| .. | .. |
|---|
| 708 | 719 | */ |
|---|
| 709 | 720 | |
|---|
| 710 | 721 | /* start of per-unit file structures and support code */ |
|---|
| 711 | | -static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
|---|
| 712 | | -static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
|---|
| 713 | | -static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); |
|---|
| 714 | | -static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); |
|---|
| 715 | | -static DEVICE_ATTR(nctxts, S_IRUGO, show_nctxts, NULL); |
|---|
| 716 | | -static DEVICE_ATTR(nfreectxts, S_IRUGO, show_nfreectxts, NULL); |
|---|
| 717 | | -static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL); |
|---|
| 718 | | -static DEVICE_ATTR(boardversion, S_IRUGO, show_boardversion, NULL); |
|---|
| 719 | | -static DEVICE_ATTR(tempsense, S_IRUGO, show_tempsense, NULL); |
|---|
| 720 | | -static DEVICE_ATTR(localbus_info, S_IRUGO, show_localbus_info, NULL); |
|---|
| 721 | | -static DEVICE_ATTR(chip_reset, S_IWUSR, NULL, store_chip_reset); |
|---|
| 722 | +static struct attribute *qib_attributes[] = { |
|---|
| 723 | + &dev_attr_hw_rev.attr, |
|---|
| 724 | + &dev_attr_hca_type.attr, |
|---|
| 725 | + &dev_attr_board_id.attr, |
|---|
| 726 | + &dev_attr_version.attr, |
|---|
| 727 | + &dev_attr_nctxts.attr, |
|---|
| 728 | + &dev_attr_nfreectxts.attr, |
|---|
| 729 | + &dev_attr_serial.attr, |
|---|
| 730 | + &dev_attr_boardversion.attr, |
|---|
| 731 | + &dev_attr_tempsense.attr, |
|---|
| 732 | + &dev_attr_localbus_info.attr, |
|---|
| 733 | + &dev_attr_chip_reset.attr, |
|---|
| 734 | + NULL, |
|---|
| 735 | +}; |
|---|
| 722 | 736 | |
|---|
| 723 | | -static struct device_attribute *qib_attributes[] = { |
|---|
| 724 | | - &dev_attr_hw_rev, |
|---|
| 725 | | - &dev_attr_hca_type, |
|---|
| 726 | | - &dev_attr_board_id, |
|---|
| 727 | | - &dev_attr_version, |
|---|
| 728 | | - &dev_attr_nctxts, |
|---|
| 729 | | - &dev_attr_nfreectxts, |
|---|
| 730 | | - &dev_attr_serial, |
|---|
| 731 | | - &dev_attr_boardversion, |
|---|
| 732 | | - &dev_attr_tempsense, |
|---|
| 733 | | - &dev_attr_localbus_info, |
|---|
| 734 | | - &dev_attr_chip_reset, |
|---|
| 737 | +const struct attribute_group qib_attr_group = { |
|---|
| 738 | + .attrs = qib_attributes, |
|---|
| 735 | 739 | }; |
|---|
| 736 | 740 | |
|---|
| 737 | 741 | int qib_create_port_files(struct ib_device *ibdev, u8 port_num, |
|---|
| .. | .. |
|---|
| 829 | 833 | bail_link: |
|---|
| 830 | 834 | kobject_put(&ppd->pport_kobj); |
|---|
| 831 | 835 | bail: |
|---|
| 832 | | - return ret; |
|---|
| 833 | | -} |
|---|
| 834 | | - |
|---|
| 835 | | -/* |
|---|
| 836 | | - * Register and create our files in /sys/class/infiniband. |
|---|
| 837 | | - */ |
|---|
| 838 | | -int qib_verbs_register_sysfs(struct qib_devdata *dd) |
|---|
| 839 | | -{ |
|---|
| 840 | | - struct ib_device *dev = &dd->verbs_dev.rdi.ibdev; |
|---|
| 841 | | - int i, ret; |
|---|
| 842 | | - |
|---|
| 843 | | - for (i = 0; i < ARRAY_SIZE(qib_attributes); ++i) { |
|---|
| 844 | | - ret = device_create_file(&dev->dev, qib_attributes[i]); |
|---|
| 845 | | - if (ret) |
|---|
| 846 | | - goto bail; |
|---|
| 847 | | - } |
|---|
| 848 | | - |
|---|
| 849 | | - return 0; |
|---|
| 850 | | -bail: |
|---|
| 851 | | - for (i = 0; i < ARRAY_SIZE(qib_attributes); ++i) |
|---|
| 852 | | - device_remove_file(&dev->dev, qib_attributes[i]); |
|---|
| 853 | 836 | return ret; |
|---|
| 854 | 837 | } |
|---|
| 855 | 838 | |
|---|