diff options
author | Vikas Chaudhary <vikas.chaudhary@qlogic.com> | 2011-08-01 06:26:17 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-08-27 10:36:34 -0400 |
commit | 91ec7cec4acf0d6b7de34009fc49c8c3353b8035 (patch) | |
tree | 05e8ce502f3e5406b511cbeab34cf0f7ae42498d /drivers/scsi/qla4xxx | |
parent | 7c07d139cfec3172e813b468a8a173ad73bb5da9 (diff) |
[SCSI] qla4xxx: Added vendor specific sysfs attributes
Added board_id, fw_state, phy_port_cnt, phy_port_num,
iscsi_func_cnt, hba_model
Signed-off-by: Harish Zunjarrao <harish.zunjarrao@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/qla4xxx')
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_attr.c | 76 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_def.h | 4 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_init.c | 21 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_nx.c | 5 |
4 files changed, 106 insertions, 0 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_attr.c b/drivers/scsi/qla4xxx/ql4_attr.c index 864d018631c0..0b0a7d42137d 100644 --- a/drivers/scsi/qla4xxx/ql4_attr.c +++ b/drivers/scsi/qla4xxx/ql4_attr.c | |||
@@ -55,15 +55,91 @@ qla4xxx_optrom_version_show(struct device *dev, struct device_attribute *attr, | |||
55 | ha->bootload_patch, ha->bootload_build); | 55 | ha->bootload_patch, ha->bootload_build); |
56 | } | 56 | } |
57 | 57 | ||
58 | static ssize_t | ||
59 | qla4xxx_board_id_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 | return snprintf(buf, PAGE_SIZE, "0x%08X\n", ha->board_id); | ||
64 | } | ||
65 | |||
66 | static ssize_t | ||
67 | qla4xxx_fw_state_show(struct device *dev, struct device_attribute *attr, | ||
68 | char *buf) | ||
69 | { | ||
70 | struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); | ||
71 | |||
72 | qla4xxx_get_firmware_state(ha); | ||
73 | return snprintf(buf, PAGE_SIZE, "0x%08X%8X\n", ha->firmware_state, | ||
74 | ha->addl_fw_state); | ||
75 | } | ||
76 | |||
77 | static ssize_t | ||
78 | qla4xxx_phy_port_cnt_show(struct device *dev, struct device_attribute *attr, | ||
79 | char *buf) | ||
80 | { | ||
81 | struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); | ||
82 | |||
83 | if (!is_qla8022(ha)) | ||
84 | return -ENOSYS; | ||
85 | |||
86 | return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_cnt); | ||
87 | } | ||
88 | |||
89 | static ssize_t | ||
90 | qla4xxx_phy_port_num_show(struct device *dev, struct device_attribute *attr, | ||
91 | char *buf) | ||
92 | { | ||
93 | struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); | ||
94 | |||
95 | if (!is_qla8022(ha)) | ||
96 | return -ENOSYS; | ||
97 | |||
98 | return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_num); | ||
99 | } | ||
100 | |||
101 | static ssize_t | ||
102 | qla4xxx_iscsi_func_cnt_show(struct device *dev, struct device_attribute *attr, | ||
103 | char *buf) | ||
104 | { | ||
105 | struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); | ||
106 | |||
107 | if (!is_qla8022(ha)) | ||
108 | return -ENOSYS; | ||
109 | |||
110 | return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->iscsi_pci_func_cnt); | ||
111 | } | ||
112 | |||
113 | static ssize_t | ||
114 | qla4xxx_hba_model_show(struct device *dev, struct device_attribute *attr, | ||
115 | char *buf) | ||
116 | { | ||
117 | struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); | ||
118 | |||
119 | return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_name); | ||
120 | } | ||
121 | |||
58 | static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL); | 122 | static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL); |
59 | static DEVICE_ATTR(serial_num, S_IRUGO, qla4xxx_serial_num_show, NULL); | 123 | static DEVICE_ATTR(serial_num, S_IRUGO, qla4xxx_serial_num_show, NULL); |
60 | static DEVICE_ATTR(iscsi_version, S_IRUGO, qla4xxx_iscsi_version_show, NULL); | 124 | static DEVICE_ATTR(iscsi_version, S_IRUGO, qla4xxx_iscsi_version_show, NULL); |
61 | static DEVICE_ATTR(optrom_version, S_IRUGO, qla4xxx_optrom_version_show, NULL); | 125 | static DEVICE_ATTR(optrom_version, S_IRUGO, qla4xxx_optrom_version_show, NULL); |
126 | static DEVICE_ATTR(board_id, S_IRUGO, qla4xxx_board_id_show, NULL); | ||
127 | static DEVICE_ATTR(fw_state, S_IRUGO, qla4xxx_fw_state_show, NULL); | ||
128 | static DEVICE_ATTR(phy_port_cnt, S_IRUGO, qla4xxx_phy_port_cnt_show, NULL); | ||
129 | static DEVICE_ATTR(phy_port_num, S_IRUGO, qla4xxx_phy_port_num_show, NULL); | ||
130 | static DEVICE_ATTR(iscsi_func_cnt, S_IRUGO, qla4xxx_iscsi_func_cnt_show, NULL); | ||
131 | static DEVICE_ATTR(hba_model, S_IRUGO, qla4xxx_hba_model_show, NULL); | ||
62 | 132 | ||
63 | struct device_attribute *qla4xxx_host_attrs[] = { | 133 | struct device_attribute *qla4xxx_host_attrs[] = { |
64 | &dev_attr_fw_version, | 134 | &dev_attr_fw_version, |
65 | &dev_attr_serial_num, | 135 | &dev_attr_serial_num, |
66 | &dev_attr_iscsi_version, | 136 | &dev_attr_iscsi_version, |
67 | &dev_attr_optrom_version, | 137 | &dev_attr_optrom_version, |
138 | &dev_attr_board_id, | ||
139 | &dev_attr_fw_state, | ||
140 | &dev_attr_phy_port_cnt, | ||
141 | &dev_attr_phy_port_num, | ||
142 | &dev_attr_iscsi_func_cnt, | ||
143 | &dev_attr_hba_model, | ||
68 | NULL, | 144 | NULL, |
69 | }; | 145 | }; |
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h index 74c71af7cb5d..17a29ceb04e8 100644 --- a/drivers/scsi/qla4xxx/ql4_def.h +++ b/drivers/scsi/qla4xxx/ql4_def.h | |||
@@ -610,6 +610,10 @@ struct scsi_qla_host { | |||
610 | #define SYSFS_FLAG_FW_SEL_BOOT 2 | 610 | #define SYSFS_FLAG_FW_SEL_BOOT 2 |
611 | struct iscsi_boot_kset *boot_kset; | 611 | struct iscsi_boot_kset *boot_kset; |
612 | struct ql4_boot_tgt_info boot_tgt; | 612 | struct ql4_boot_tgt_info boot_tgt; |
613 | uint16_t phy_port_num; | ||
614 | uint16_t phy_port_cnt; | ||
615 | uint16_t iscsi_pci_func_cnt; | ||
616 | uint8_t model_name[16]; | ||
613 | }; | 617 | }; |
614 | 618 | ||
615 | struct ql4_task_data { | 619 | struct ql4_task_data { |
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c index 21f6f4bacd9d..b0bffe15c287 100644 --- a/drivers/scsi/qla4xxx/ql4_init.c +++ b/drivers/scsi/qla4xxx/ql4_init.c | |||
@@ -446,6 +446,21 @@ static int qla4xxx_init_firmware(struct scsi_qla_host *ha) | |||
446 | return qla4xxx_get_firmware_status(ha); | 446 | return qla4xxx_get_firmware_status(ha); |
447 | } | 447 | } |
448 | 448 | ||
449 | static void qla4xxx_set_model_info(struct scsi_qla_host *ha) | ||
450 | { | ||
451 | uint16_t board_id_string[8]; | ||
452 | int i; | ||
453 | int size = sizeof(ha->nvram->isp4022.boardIdStr); | ||
454 | int offset = offsetof(struct eeprom_data, isp4022.boardIdStr) / 2; | ||
455 | |||
456 | for (i = 0; i < (size / 2) ; i++) { | ||
457 | board_id_string[i] = rd_nvram_word(ha, offset); | ||
458 | offset += 1; | ||
459 | } | ||
460 | |||
461 | memcpy(ha->model_name, board_id_string, size); | ||
462 | } | ||
463 | |||
449 | static int qla4xxx_config_nvram(struct scsi_qla_host *ha) | 464 | static int qla4xxx_config_nvram(struct scsi_qla_host *ha) |
450 | { | 465 | { |
451 | unsigned long flags; | 466 | unsigned long flags; |
@@ -481,6 +496,12 @@ static int qla4xxx_config_nvram(struct scsi_qla_host *ha) | |||
481 | else | 496 | else |
482 | return QLA_ERROR; | 497 | return QLA_ERROR; |
483 | } | 498 | } |
499 | |||
500 | if (is_qla4022(ha) || is_qla4032(ha)) | ||
501 | qla4xxx_set_model_info(ha); | ||
502 | else | ||
503 | strcpy(ha->model_name, "QLA4010"); | ||
504 | |||
484 | DEBUG(printk("scsi%ld: %s: Setting extHwConfig to 0xFFFF%04x\n", | 505 | DEBUG(printk("scsi%ld: %s: Setting extHwConfig to 0xFFFF%04x\n", |
485 | ha->host_no, __func__, extHwConfig.Asuint32_t)); | 506 | ha->host_no, __func__, extHwConfig.Asuint32_t)); |
486 | 507 | ||
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c index 52a1063e4fd5..a539e1761f65 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.c +++ b/drivers/scsi/qla4xxx/ql4_nx.c | |||
@@ -2266,6 +2266,11 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha) | |||
2266 | min(sizeof(ha->my_mac), sizeof(sys_info->mac_addr))); | 2266 | min(sizeof(ha->my_mac), sizeof(sys_info->mac_addr))); |
2267 | memcpy(ha->serial_number, &sys_info->serial_number, | 2267 | memcpy(ha->serial_number, &sys_info->serial_number, |
2268 | min(sizeof(ha->serial_number), sizeof(sys_info->serial_number))); | 2268 | min(sizeof(ha->serial_number), sizeof(sys_info->serial_number))); |
2269 | memcpy(ha->model_name, &sys_info->board_id_str, | ||
2270 | min(sizeof(ha->model_name), sizeof(sys_info->board_id_str))); | ||
2271 | ha->phy_port_cnt = sys_info->phys_port_cnt; | ||
2272 | ha->phy_port_num = sys_info->port_num; | ||
2273 | ha->iscsi_pci_func_cnt = sys_info->iscsi_pci_func_cnt; | ||
2269 | 2274 | ||
2270 | DEBUG2(printk("scsi%ld: %s: " | 2275 | DEBUG2(printk("scsi%ld: %s: " |
2271 | "mac %02x:%02x:%02x:%02x:%02x:%02x " | 2276 | "mac %02x:%02x:%02x:%02x:%02x:%02x " |