ql4_attr.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * QLogic iSCSI HBA Driver
  3. * Copyright (c) 2003-2011 QLogic Corporation
  4. *
  5. * See LICENSE.qla4xxx for copyright and licensing details.
  6. */
  7. #include "ql4_def.h"
  8. #include "ql4_glbl.h"
  9. #include "ql4_dbg.h"
  10. /* Scsi_Host attributes. */
  11. static ssize_t
  12. qla4xxx_fw_version_show(struct device *dev,
  13. struct device_attribute *attr, char *buf)
  14. {
  15. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  16. if (is_qla8022(ha))
  17. return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
  18. ha->firmware_version[0],
  19. ha->firmware_version[1],
  20. ha->patch_number, ha->build_number);
  21. else
  22. return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
  23. ha->firmware_version[0],
  24. ha->firmware_version[1],
  25. ha->patch_number, ha->build_number);
  26. }
  27. static ssize_t
  28. qla4xxx_serial_num_show(struct device *dev, struct device_attribute *attr,
  29. char *buf)
  30. {
  31. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  32. return snprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);
  33. }
  34. static ssize_t
  35. qla4xxx_iscsi_version_show(struct device *dev, struct device_attribute *attr,
  36. char *buf)
  37. {
  38. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  39. return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->iscsi_major,
  40. ha->iscsi_minor);
  41. }
  42. static ssize_t
  43. qla4xxx_optrom_version_show(struct device *dev, struct device_attribute *attr,
  44. char *buf)
  45. {
  46. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  47. return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
  48. ha->bootload_major, ha->bootload_minor,
  49. ha->bootload_patch, ha->bootload_build);
  50. }
  51. static ssize_t
  52. qla4xxx_board_id_show(struct device *dev, struct device_attribute *attr,
  53. char *buf)
  54. {
  55. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  56. return snprintf(buf, PAGE_SIZE, "0x%08X\n", ha->board_id);
  57. }
  58. static ssize_t
  59. qla4xxx_fw_state_show(struct device *dev, struct device_attribute *attr,
  60. char *buf)
  61. {
  62. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  63. qla4xxx_get_firmware_state(ha);
  64. return snprintf(buf, PAGE_SIZE, "0x%08X%8X\n", ha->firmware_state,
  65. ha->addl_fw_state);
  66. }
  67. static ssize_t
  68. qla4xxx_phy_port_cnt_show(struct device *dev, struct device_attribute *attr,
  69. char *buf)
  70. {
  71. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  72. if (!is_qla8022(ha))
  73. return -ENOSYS;
  74. return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_cnt);
  75. }
  76. static ssize_t
  77. qla4xxx_phy_port_num_show(struct device *dev, struct device_attribute *attr,
  78. char *buf)
  79. {
  80. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  81. if (!is_qla8022(ha))
  82. return -ENOSYS;
  83. return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_num);
  84. }
  85. static ssize_t
  86. qla4xxx_iscsi_func_cnt_show(struct device *dev, struct device_attribute *attr,
  87. char *buf)
  88. {
  89. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  90. if (!is_qla8022(ha))
  91. return -ENOSYS;
  92. return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->iscsi_pci_func_cnt);
  93. }
  94. static ssize_t
  95. qla4xxx_hba_model_show(struct device *dev, struct device_attribute *attr,
  96. char *buf)
  97. {
  98. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  99. return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_name);
  100. }
  101. static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL);
  102. static DEVICE_ATTR(serial_num, S_IRUGO, qla4xxx_serial_num_show, NULL);
  103. static DEVICE_ATTR(iscsi_version, S_IRUGO, qla4xxx_iscsi_version_show, NULL);
  104. static DEVICE_ATTR(optrom_version, S_IRUGO, qla4xxx_optrom_version_show, NULL);
  105. static DEVICE_ATTR(board_id, S_IRUGO, qla4xxx_board_id_show, NULL);
  106. static DEVICE_ATTR(fw_state, S_IRUGO, qla4xxx_fw_state_show, NULL);
  107. static DEVICE_ATTR(phy_port_cnt, S_IRUGO, qla4xxx_phy_port_cnt_show, NULL);
  108. static DEVICE_ATTR(phy_port_num, S_IRUGO, qla4xxx_phy_port_num_show, NULL);
  109. static DEVICE_ATTR(iscsi_func_cnt, S_IRUGO, qla4xxx_iscsi_func_cnt_show, NULL);
  110. static DEVICE_ATTR(hba_model, S_IRUGO, qla4xxx_hba_model_show, NULL);
  111. struct device_attribute *qla4xxx_host_attrs[] = {
  112. &dev_attr_fw_version,
  113. &dev_attr_serial_num,
  114. &dev_attr_iscsi_version,
  115. &dev_attr_optrom_version,
  116. &dev_attr_board_id,
  117. &dev_attr_fw_state,
  118. &dev_attr_phy_port_cnt,
  119. &dev_attr_phy_port_num,
  120. &dev_attr_iscsi_func_cnt,
  121. &dev_attr_hba_model,
  122. NULL,
  123. };