diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_attr.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_attr.c | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 659a5d63467d..fe0fce71adc7 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c | |||
@@ -211,6 +211,138 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha) | |||
211 | sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); | 211 | sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); |
212 | } | 212 | } |
213 | 213 | ||
214 | /* Scsi_Host attributes. */ | ||
215 | |||
216 | static ssize_t | ||
217 | qla2x00_drvr_version_show(struct class_device *cdev, char *buf) | ||
218 | { | ||
219 | return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); | ||
220 | } | ||
221 | |||
222 | static ssize_t | ||
223 | qla2x00_fw_version_show(struct class_device *cdev, char *buf) | ||
224 | { | ||
225 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | ||
226 | char fw_str[30]; | ||
227 | |||
228 | return snprintf(buf, PAGE_SIZE, "%s\n", | ||
229 | ha->isp_ops.fw_version_str(ha, fw_str)); | ||
230 | } | ||
231 | |||
232 | static ssize_t | ||
233 | qla2x00_serial_num_show(struct class_device *cdev, char *buf) | ||
234 | { | ||
235 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | ||
236 | uint32_t sn; | ||
237 | |||
238 | sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; | ||
239 | return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000, | ||
240 | sn % 100000); | ||
241 | } | ||
242 | |||
243 | static ssize_t | ||
244 | qla2x00_isp_name_show(struct class_device *cdev, char *buf) | ||
245 | { | ||
246 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | ||
247 | return snprintf(buf, PAGE_SIZE, "%s\n", ha->brd_info->isp_name); | ||
248 | } | ||
249 | |||
250 | static ssize_t | ||
251 | qla2x00_isp_id_show(struct class_device *cdev, char *buf) | ||
252 | { | ||
253 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | ||
254 | return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n", | ||
255 | ha->product_id[0], ha->product_id[1], ha->product_id[2], | ||
256 | ha->product_id[3]); | ||
257 | } | ||
258 | |||
259 | static ssize_t | ||
260 | qla2x00_model_name_show(struct class_device *cdev, char *buf) | ||
261 | { | ||
262 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | ||
263 | return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number); | ||
264 | } | ||
265 | |||
266 | static ssize_t | ||
267 | qla2x00_model_desc_show(struct class_device *cdev, char *buf) | ||
268 | { | ||
269 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | ||
270 | return snprintf(buf, PAGE_SIZE, "%s\n", | ||
271 | ha->model_desc ? ha->model_desc: ""); | ||
272 | } | ||
273 | |||
274 | static ssize_t | ||
275 | qla2x00_pci_info_show(struct class_device *cdev, char *buf) | ||
276 | { | ||
277 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | ||
278 | char pci_info[30]; | ||
279 | |||
280 | return snprintf(buf, PAGE_SIZE, "%s\n", | ||
281 | ha->isp_ops.pci_info_str(ha, pci_info)); | ||
282 | } | ||
283 | |||
284 | static ssize_t | ||
285 | qla2x00_state_show(struct class_device *cdev, char *buf) | ||
286 | { | ||
287 | scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); | ||
288 | int len = 0; | ||
289 | |||
290 | if (atomic_read(&ha->loop_state) == LOOP_DOWN || | ||
291 | atomic_read(&ha->loop_state) == LOOP_DEAD) | ||
292 | len = snprintf(buf, PAGE_SIZE, "Link Down\n"); | ||
293 | else if (atomic_read(&ha->loop_state) != LOOP_READY || | ||
294 | test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) || | ||
295 | test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) | ||
296 | len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n"); | ||
297 | else { | ||
298 | len = snprintf(buf, PAGE_SIZE, "Link Up - "); | ||
299 | |||
300 | switch (ha->current_topology) { | ||
301 | case ISP_CFG_NL: | ||
302 | len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n"); | ||
303 | break; | ||
304 | case ISP_CFG_FL: | ||
305 | len += snprintf(buf + len, PAGE_SIZE-len, "FL_Port\n"); | ||
306 | break; | ||
307 | case ISP_CFG_N: | ||
308 | len += snprintf(buf + len, PAGE_SIZE-len, | ||
309 | "N_Port to N_Port\n"); | ||
310 | break; | ||
311 | case ISP_CFG_F: | ||
312 | len += snprintf(buf + len, PAGE_SIZE-len, "F_Port\n"); | ||
313 | break; | ||
314 | default: | ||
315 | len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n"); | ||
316 | break; | ||
317 | } | ||
318 | } | ||
319 | return len; | ||
320 | } | ||
321 | |||
322 | static CLASS_DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, | ||
323 | NULL); | ||
324 | static CLASS_DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); | ||
325 | static CLASS_DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); | ||
326 | static CLASS_DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); | ||
327 | static CLASS_DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL); | ||
328 | static CLASS_DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL); | ||
329 | static CLASS_DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL); | ||
330 | static CLASS_DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL); | ||
331 | static CLASS_DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL); | ||
332 | |||
333 | struct class_device_attribute *qla2x00_host_attrs[] = { | ||
334 | &class_device_attr_driver_version, | ||
335 | &class_device_attr_fw_version, | ||
336 | &class_device_attr_serial_num, | ||
337 | &class_device_attr_isp_name, | ||
338 | &class_device_attr_isp_id, | ||
339 | &class_device_attr_model_name, | ||
340 | &class_device_attr_model_desc, | ||
341 | &class_device_attr_pci_info, | ||
342 | &class_device_attr_state, | ||
343 | NULL, | ||
344 | }; | ||
345 | |||
214 | /* Host attributes. */ | 346 | /* Host attributes. */ |
215 | 347 | ||
216 | static void | 348 | static void |
@@ -304,10 +436,13 @@ struct fc_function_template qla2xxx_transport_functions = { | |||
304 | 436 | ||
305 | .show_host_node_name = 1, | 437 | .show_host_node_name = 1, |
306 | .show_host_port_name = 1, | 438 | .show_host_port_name = 1, |
439 | .show_host_supported_classes = 1, | ||
440 | |||
307 | .get_host_port_id = qla2x00_get_host_port_id, | 441 | .get_host_port_id = qla2x00_get_host_port_id, |
308 | .show_host_port_id = 1, | 442 | .show_host_port_id = 1, |
309 | 443 | ||
310 | .dd_fcrport_size = sizeof(struct fc_port *), | 444 | .dd_fcrport_size = sizeof(struct fc_port *), |
445 | .show_rport_supported_classes = 1, | ||
311 | 446 | ||
312 | .get_starget_node_name = qla2x00_get_starget_node_name, | 447 | .get_starget_node_name = qla2x00_get_starget_node_name, |
313 | .show_starget_node_name = 1, | 448 | .show_starget_node_name = 1, |
@@ -329,4 +464,5 @@ qla2x00_init_host_attr(scsi_qla_host_t *ha) | |||
329 | be64_to_cpu(*(uint64_t *)ha->init_cb->node_name); | 464 | be64_to_cpu(*(uint64_t *)ha->init_cb->node_name); |
330 | fc_host_port_name(ha->host) = | 465 | fc_host_port_name(ha->host) = |
331 | be64_to_cpu(*(uint64_t *)ha->init_cb->port_name); | 466 | be64_to_cpu(*(uint64_t *)ha->init_cb->port_name); |
467 | fc_host_supported_classes(ha->host) = FC_COS_CLASS3; | ||
332 | } | 468 | } |