2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/vmalloc.h>
11 /* SYSFS attributes --------------------------------------------------------- */
14 qla2x00_sysfs_read_fw_dump(struct kobject
*kobj
, char *buf
, loff_t off
,
17 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
18 struct device
, kobj
)));
20 if (ha
->fw_dump_reading
== 0)
22 if (off
> ha
->fw_dump_buffer_len
)
24 if (off
+ count
> ha
->fw_dump_buffer_len
)
25 count
= ha
->fw_dump_buffer_len
- off
;
27 memcpy(buf
, &ha
->fw_dump_buffer
[off
], count
);
33 qla2x00_sysfs_write_fw_dump(struct kobject
*kobj
, char *buf
, loff_t off
,
36 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
37 struct device
, kobj
)));
44 reading
= simple_strtol(buf
, NULL
, 10);
47 if (ha
->fw_dump_reading
== 1) {
48 qla_printk(KERN_INFO
, ha
,
49 "Firmware dump cleared on (%ld).\n",
52 vfree(ha
->fw_dump_buffer
);
53 if (!IS_QLA24XX(ha
) && !IS_QLA54XX(ha
))
54 free_pages((unsigned long)ha
->fw_dump
,
57 ha
->fw_dump_reading
= 0;
58 ha
->fw_dump_buffer
= NULL
;
64 if ((ha
->fw_dump
|| ha
->fw_dumped
) && !ha
->fw_dump_reading
) {
65 ha
->fw_dump_reading
= 1;
67 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
))
68 dump_size
= FW_DUMP_SIZE_24XX
;
70 dump_size
= FW_DUMP_SIZE_1M
;
71 if (ha
->fw_memory_size
< 0x20000)
72 dump_size
= FW_DUMP_SIZE_128K
;
73 else if (ha
->fw_memory_size
< 0x80000)
74 dump_size
= FW_DUMP_SIZE_512K
;
76 ha
->fw_dump_buffer
= (char *)vmalloc(dump_size
);
77 if (ha
->fw_dump_buffer
== NULL
) {
78 qla_printk(KERN_WARNING
, ha
,
79 "Unable to allocate memory for firmware "
80 "dump buffer (%d).\n", dump_size
);
82 ha
->fw_dump_reading
= 0;
85 qla_printk(KERN_INFO
, ha
,
86 "Firmware dump ready for read on (%ld).\n",
88 memset(ha
->fw_dump_buffer
, 0, dump_size
);
89 ha
->isp_ops
.ascii_fw_dump(ha
);
90 ha
->fw_dump_buffer_len
= strlen(ha
->fw_dump_buffer
);
97 static struct bin_attribute sysfs_fw_dump_attr
= {
100 .mode
= S_IRUSR
| S_IWUSR
,
101 .owner
= THIS_MODULE
,
104 .read
= qla2x00_sysfs_read_fw_dump
,
105 .write
= qla2x00_sysfs_write_fw_dump
,
109 qla2x00_sysfs_read_nvram(struct kobject
*kobj
, char *buf
, loff_t off
,
112 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
113 struct device
, kobj
)));
116 if (!capable(CAP_SYS_ADMIN
) || off
!= 0)
120 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
121 ha
->isp_ops
.read_nvram(ha
, (uint8_t *)buf
, ha
->nvram_base
,
123 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
125 return ha
->nvram_size
;
129 qla2x00_sysfs_write_nvram(struct kobject
*kobj
, char *buf
, loff_t off
,
132 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
133 struct device
, kobj
)));
137 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= ha
->nvram_size
)
140 /* Checksum NVRAM. */
141 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
145 iter
= (uint32_t *)buf
;
147 for (cnt
= 0; cnt
< ((count
>> 2) - 1); cnt
++)
148 chksum
+= le32_to_cpu(*iter
++);
149 chksum
= ~chksum
+ 1;
150 *iter
= cpu_to_le32(chksum
);
155 iter
= (uint8_t *)buf
;
157 for (cnt
= 0; cnt
< count
- 1; cnt
++)
159 chksum
= ~chksum
+ 1;
164 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
165 ha
->isp_ops
.write_nvram(ha
, (uint8_t *)buf
, ha
->nvram_base
, count
);
166 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
171 static struct bin_attribute sysfs_nvram_attr
= {
174 .mode
= S_IRUSR
| S_IWUSR
,
175 .owner
= THIS_MODULE
,
178 .read
= qla2x00_sysfs_read_nvram
,
179 .write
= qla2x00_sysfs_write_nvram
,
183 qla2x00_sysfs_read_optrom(struct kobject
*kobj
, char *buf
, loff_t off
,
186 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
187 struct device
, kobj
)));
189 if (ha
->optrom_state
!= QLA_SREADING
)
191 if (off
> ha
->optrom_size
)
193 if (off
+ count
> ha
->optrom_size
)
194 count
= ha
->optrom_size
- off
;
196 memcpy(buf
, &ha
->optrom_buffer
[off
], count
);
202 qla2x00_sysfs_write_optrom(struct kobject
*kobj
, char *buf
, loff_t off
,
205 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
206 struct device
, kobj
)));
208 if (ha
->optrom_state
!= QLA_SWRITING
)
210 if (off
> ha
->optrom_size
)
212 if (off
+ count
> ha
->optrom_size
)
213 count
= ha
->optrom_size
- off
;
215 memcpy(&ha
->optrom_buffer
[off
], buf
, count
);
220 static struct bin_attribute sysfs_optrom_attr
= {
223 .mode
= S_IRUSR
| S_IWUSR
,
224 .owner
= THIS_MODULE
,
226 .size
= OPTROM_SIZE_24XX
,
227 .read
= qla2x00_sysfs_read_optrom
,
228 .write
= qla2x00_sysfs_write_optrom
,
232 qla2x00_sysfs_write_optrom_ctl(struct kobject
*kobj
, char *buf
, loff_t off
,
235 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
236 struct device
, kobj
)));
242 if (sscanf(buf
, "%d", &val
) != 1)
247 if (ha
->optrom_state
!= QLA_SREADING
&&
248 ha
->optrom_state
!= QLA_SWRITING
)
251 ha
->optrom_state
= QLA_SWAITING
;
252 vfree(ha
->optrom_buffer
);
253 ha
->optrom_buffer
= NULL
;
256 if (ha
->optrom_state
!= QLA_SWAITING
)
259 ha
->optrom_state
= QLA_SREADING
;
260 ha
->optrom_buffer
= (uint8_t *)vmalloc(ha
->optrom_size
);
261 if (ha
->optrom_buffer
== NULL
) {
262 qla_printk(KERN_WARNING
, ha
,
263 "Unable to allocate memory for optrom retrieval "
264 "(%x).\n", ha
->optrom_size
);
266 ha
->optrom_state
= QLA_SWAITING
;
270 memset(ha
->optrom_buffer
, 0, ha
->optrom_size
);
271 ha
->isp_ops
.read_optrom(ha
, ha
->optrom_buffer
, 0,
275 if (ha
->optrom_state
!= QLA_SWAITING
)
278 ha
->optrom_state
= QLA_SWRITING
;
279 ha
->optrom_buffer
= (uint8_t *)vmalloc(ha
->optrom_size
);
280 if (ha
->optrom_buffer
== NULL
) {
281 qla_printk(KERN_WARNING
, ha
,
282 "Unable to allocate memory for optrom update "
283 "(%x).\n", ha
->optrom_size
);
285 ha
->optrom_state
= QLA_SWAITING
;
288 memset(ha
->optrom_buffer
, 0, ha
->optrom_size
);
291 if (ha
->optrom_state
!= QLA_SWRITING
)
294 ha
->isp_ops
.write_optrom(ha
, ha
->optrom_buffer
, 0,
301 static struct bin_attribute sysfs_optrom_ctl_attr
= {
303 .name
= "optrom_ctl",
305 .owner
= THIS_MODULE
,
308 .write
= qla2x00_sysfs_write_optrom_ctl
,
312 qla2x00_sysfs_read_vpd(struct kobject
*kobj
, char *buf
, loff_t off
,
315 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
316 struct device
, kobj
)));
319 if (!capable(CAP_SYS_ADMIN
) || off
!= 0)
322 if (!IS_QLA24XX(ha
) && !IS_QLA54XX(ha
))
326 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
327 ha
->isp_ops
.read_nvram(ha
, (uint8_t *)buf
, ha
->vpd_base
, ha
->vpd_size
);
328 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
334 qla2x00_sysfs_write_vpd(struct kobject
*kobj
, char *buf
, loff_t off
,
337 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
338 struct device
, kobj
)));
341 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= ha
->vpd_size
)
344 if (!IS_QLA24XX(ha
) && !IS_QLA54XX(ha
))
348 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
349 ha
->isp_ops
.write_nvram(ha
, (uint8_t *)buf
, ha
->vpd_base
, count
);
350 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
355 static struct bin_attribute sysfs_vpd_attr
= {
358 .mode
= S_IRUSR
| S_IWUSR
,
359 .owner
= THIS_MODULE
,
362 .read
= qla2x00_sysfs_read_vpd
,
363 .write
= qla2x00_sysfs_write_vpd
,
367 qla2x00_alloc_sysfs_attr(scsi_qla_host_t
*ha
)
369 struct Scsi_Host
*host
= ha
->host
;
371 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_fw_dump_attr
);
372 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_nvram_attr
);
373 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_optrom_attr
);
374 sysfs_create_bin_file(&host
->shost_gendev
.kobj
,
375 &sysfs_optrom_ctl_attr
);
376 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_vpd_attr
);
380 qla2x00_free_sysfs_attr(scsi_qla_host_t
*ha
)
382 struct Scsi_Host
*host
= ha
->host
;
384 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_fw_dump_attr
);
385 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_nvram_attr
);
386 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_optrom_attr
);
387 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
,
388 &sysfs_optrom_ctl_attr
);
389 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_vpd_attr
);
391 if (ha
->beacon_blink_led
== 1)
392 ha
->isp_ops
.beacon_off(ha
);
395 /* Scsi_Host attributes. */
398 qla2x00_drvr_version_show(struct class_device
*cdev
, char *buf
)
400 return snprintf(buf
, PAGE_SIZE
, "%s\n", qla2x00_version_str
);
404 qla2x00_fw_version_show(struct class_device
*cdev
, char *buf
)
406 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
409 return snprintf(buf
, PAGE_SIZE
, "%s\n",
410 ha
->isp_ops
.fw_version_str(ha
, fw_str
));
414 qla2x00_serial_num_show(struct class_device
*cdev
, char *buf
)
416 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
419 sn
= ((ha
->serial0
& 0x1f) << 16) | (ha
->serial2
<< 8) | ha
->serial1
;
420 return snprintf(buf
, PAGE_SIZE
, "%c%05d\n", 'A' + sn
/ 100000,
425 qla2x00_isp_name_show(struct class_device
*cdev
, char *buf
)
427 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
428 return snprintf(buf
, PAGE_SIZE
, "ISP%04X\n", ha
->pdev
->device
);
432 qla2x00_isp_id_show(struct class_device
*cdev
, char *buf
)
434 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
435 return snprintf(buf
, PAGE_SIZE
, "%04x %04x %04x %04x\n",
436 ha
->product_id
[0], ha
->product_id
[1], ha
->product_id
[2],
441 qla2x00_model_name_show(struct class_device
*cdev
, char *buf
)
443 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
444 return snprintf(buf
, PAGE_SIZE
, "%s\n", ha
->model_number
);
448 qla2x00_model_desc_show(struct class_device
*cdev
, char *buf
)
450 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
451 return snprintf(buf
, PAGE_SIZE
, "%s\n",
452 ha
->model_desc
? ha
->model_desc
: "");
456 qla2x00_pci_info_show(struct class_device
*cdev
, char *buf
)
458 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
461 return snprintf(buf
, PAGE_SIZE
, "%s\n",
462 ha
->isp_ops
.pci_info_str(ha
, pci_info
));
466 qla2x00_state_show(struct class_device
*cdev
, char *buf
)
468 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
471 if (atomic_read(&ha
->loop_state
) == LOOP_DOWN
||
472 atomic_read(&ha
->loop_state
) == LOOP_DEAD
)
473 len
= snprintf(buf
, PAGE_SIZE
, "Link Down\n");
474 else if (atomic_read(&ha
->loop_state
) != LOOP_READY
||
475 test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
) ||
476 test_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
))
477 len
= snprintf(buf
, PAGE_SIZE
, "Unknown Link State\n");
479 len
= snprintf(buf
, PAGE_SIZE
, "Link Up - ");
481 switch (ha
->current_topology
) {
483 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
486 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "FL_Port\n");
489 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
490 "N_Port to N_Port\n");
493 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "F_Port\n");
496 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
504 qla2x00_zio_show(struct class_device
*cdev
, char *buf
)
506 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
509 switch (ha
->zio_mode
) {
511 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Mode 6\n");
513 case QLA_ZIO_DISABLED
:
514 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
521 qla2x00_zio_store(struct class_device
*cdev
, const char *buf
, size_t count
)
523 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
527 if (!IS_ZIO_SUPPORTED(ha
))
530 if (sscanf(buf
, "%d", &val
) != 1)
534 zio_mode
= QLA_ZIO_MODE_6
;
536 zio_mode
= QLA_ZIO_DISABLED
;
538 /* Update per-hba values and queue a reset. */
539 if (zio_mode
!= QLA_ZIO_DISABLED
|| ha
->zio_mode
!= QLA_ZIO_DISABLED
) {
540 ha
->zio_mode
= zio_mode
;
541 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
547 qla2x00_zio_timer_show(struct class_device
*cdev
, char *buf
)
549 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
551 return snprintf(buf
, PAGE_SIZE
, "%d us\n", ha
->zio_timer
* 100);
555 qla2x00_zio_timer_store(struct class_device
*cdev
, const char *buf
,
558 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
562 if (sscanf(buf
, "%d", &val
) != 1)
564 if (val
> 25500 || val
< 100)
567 zio_timer
= (uint16_t)(val
/ 100);
568 ha
->zio_timer
= zio_timer
;
574 qla2x00_beacon_show(struct class_device
*cdev
, char *buf
)
576 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
579 if (ha
->beacon_blink_led
)
580 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Enabled\n");
582 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
587 qla2x00_beacon_store(struct class_device
*cdev
, const char *buf
,
590 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
594 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
597 if (test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
)) {
598 qla_printk(KERN_WARNING
, ha
,
599 "Abort ISP active -- ignoring beacon request.\n");
603 if (sscanf(buf
, "%d", &val
) != 1)
607 rval
= ha
->isp_ops
.beacon_on(ha
);
609 rval
= ha
->isp_ops
.beacon_off(ha
);
611 if (rval
!= QLA_SUCCESS
)
617 static CLASS_DEVICE_ATTR(driver_version
, S_IRUGO
, qla2x00_drvr_version_show
,
619 static CLASS_DEVICE_ATTR(fw_version
, S_IRUGO
, qla2x00_fw_version_show
, NULL
);
620 static CLASS_DEVICE_ATTR(serial_num
, S_IRUGO
, qla2x00_serial_num_show
, NULL
);
621 static CLASS_DEVICE_ATTR(isp_name
, S_IRUGO
, qla2x00_isp_name_show
, NULL
);
622 static CLASS_DEVICE_ATTR(isp_id
, S_IRUGO
, qla2x00_isp_id_show
, NULL
);
623 static CLASS_DEVICE_ATTR(model_name
, S_IRUGO
, qla2x00_model_name_show
, NULL
);
624 static CLASS_DEVICE_ATTR(model_desc
, S_IRUGO
, qla2x00_model_desc_show
, NULL
);
625 static CLASS_DEVICE_ATTR(pci_info
, S_IRUGO
, qla2x00_pci_info_show
, NULL
);
626 static CLASS_DEVICE_ATTR(state
, S_IRUGO
, qla2x00_state_show
, NULL
);
627 static CLASS_DEVICE_ATTR(zio
, S_IRUGO
| S_IWUSR
, qla2x00_zio_show
,
629 static CLASS_DEVICE_ATTR(zio_timer
, S_IRUGO
| S_IWUSR
, qla2x00_zio_timer_show
,
630 qla2x00_zio_timer_store
);
631 static CLASS_DEVICE_ATTR(beacon
, S_IRUGO
| S_IWUSR
, qla2x00_beacon_show
,
632 qla2x00_beacon_store
);
634 struct class_device_attribute
*qla2x00_host_attrs
[] = {
635 &class_device_attr_driver_version
,
636 &class_device_attr_fw_version
,
637 &class_device_attr_serial_num
,
638 &class_device_attr_isp_name
,
639 &class_device_attr_isp_id
,
640 &class_device_attr_model_name
,
641 &class_device_attr_model_desc
,
642 &class_device_attr_pci_info
,
643 &class_device_attr_state
,
644 &class_device_attr_zio
,
645 &class_device_attr_zio_timer
,
646 &class_device_attr_beacon
,
650 /* Host attributes. */
653 qla2x00_get_host_port_id(struct Scsi_Host
*shost
)
655 scsi_qla_host_t
*ha
= to_qla_host(shost
);
657 fc_host_port_id(shost
) = ha
->d_id
.b
.domain
<< 16 |
658 ha
->d_id
.b
.area
<< 8 | ha
->d_id
.b
.al_pa
;
662 qla2x00_get_host_speed(struct Scsi_Host
*shost
)
664 scsi_qla_host_t
*ha
= to_qla_host(shost
);
667 switch (ha
->link_data_rate
) {
678 fc_host_speed(shost
) = speed
;
682 qla2x00_get_host_port_type(struct Scsi_Host
*shost
)
684 scsi_qla_host_t
*ha
= to_qla_host(shost
);
685 uint32_t port_type
= FC_PORTTYPE_UNKNOWN
;
687 switch (ha
->current_topology
) {
689 port_type
= FC_PORTTYPE_LPORT
;
692 port_type
= FC_PORTTYPE_NLPORT
;
695 port_type
= FC_PORTTYPE_PTP
;
698 port_type
= FC_PORTTYPE_NPORT
;
701 fc_host_port_type(shost
) = port_type
;
705 qla2x00_get_starget_node_name(struct scsi_target
*starget
)
707 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
708 scsi_qla_host_t
*ha
= to_qla_host(host
);
712 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
713 if (starget
->id
== fcport
->os_target_id
) {
714 node_name
= wwn_to_u64(fcport
->node_name
);
719 fc_starget_node_name(starget
) = node_name
;
723 qla2x00_get_starget_port_name(struct scsi_target
*starget
)
725 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
726 scsi_qla_host_t
*ha
= to_qla_host(host
);
730 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
731 if (starget
->id
== fcport
->os_target_id
) {
732 port_name
= wwn_to_u64(fcport
->port_name
);
737 fc_starget_port_name(starget
) = port_name
;
741 qla2x00_get_starget_port_id(struct scsi_target
*starget
)
743 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
744 scsi_qla_host_t
*ha
= to_qla_host(host
);
746 uint32_t port_id
= ~0U;
748 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
749 if (starget
->id
== fcport
->os_target_id
) {
750 port_id
= fcport
->d_id
.b
.domain
<< 16 |
751 fcport
->d_id
.b
.area
<< 8 | fcport
->d_id
.b
.al_pa
;
756 fc_starget_port_id(starget
) = port_id
;
760 qla2x00_get_rport_loss_tmo(struct fc_rport
*rport
)
762 struct Scsi_Host
*host
= rport_to_shost(rport
);
763 scsi_qla_host_t
*ha
= to_qla_host(host
);
765 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
769 qla2x00_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
771 struct Scsi_Host
*host
= rport_to_shost(rport
);
772 scsi_qla_host_t
*ha
= to_qla_host(host
);
775 ha
->port_down_retry_count
= timeout
;
777 ha
->port_down_retry_count
= 1;
779 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
783 qla2x00_issue_lip(struct Scsi_Host
*shost
)
785 scsi_qla_host_t
*ha
= to_qla_host(shost
);
787 set_bit(LOOP_RESET_NEEDED
, &ha
->dpc_flags
);
791 static struct fc_host_statistics
*
792 qla2x00_get_fc_host_stats(struct Scsi_Host
*shost
)
794 scsi_qla_host_t
*ha
= to_qla_host(shost
);
797 link_stat_t stat_buf
;
798 struct fc_host_statistics
*pfc_host_stat
;
800 pfc_host_stat
= &ha
->fc_host_stat
;
801 memset(pfc_host_stat
, -1, sizeof(struct fc_host_statistics
));
803 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
804 rval
= qla24xx_get_isp_stats(ha
, (uint32_t *)&stat_buf
,
805 sizeof(stat_buf
) / 4, mb_stat
);
807 rval
= qla2x00_get_link_status(ha
, ha
->loop_id
, &stat_buf
,
811 qla_printk(KERN_WARNING
, ha
,
812 "Unable to retrieve host statistics (%d).\n", mb_stat
[0]);
813 return pfc_host_stat
;
816 pfc_host_stat
->link_failure_count
= stat_buf
.link_fail_cnt
;
817 pfc_host_stat
->loss_of_sync_count
= stat_buf
.loss_sync_cnt
;
818 pfc_host_stat
->loss_of_signal_count
= stat_buf
.loss_sig_cnt
;
819 pfc_host_stat
->prim_seq_protocol_err_count
= stat_buf
.prim_seq_err_cnt
;
820 pfc_host_stat
->invalid_tx_word_count
= stat_buf
.inval_xmit_word_cnt
;
821 pfc_host_stat
->invalid_crc_count
= stat_buf
.inval_crc_cnt
;
823 return pfc_host_stat
;
826 struct fc_function_template qla2xxx_transport_functions
= {
828 .show_host_node_name
= 1,
829 .show_host_port_name
= 1,
830 .show_host_supported_classes
= 1,
832 .get_host_port_id
= qla2x00_get_host_port_id
,
833 .show_host_port_id
= 1,
834 .get_host_speed
= qla2x00_get_host_speed
,
835 .show_host_speed
= 1,
836 .get_host_port_type
= qla2x00_get_host_port_type
,
837 .show_host_port_type
= 1,
839 .dd_fcrport_size
= sizeof(struct fc_port
*),
840 .show_rport_supported_classes
= 1,
842 .get_starget_node_name
= qla2x00_get_starget_node_name
,
843 .show_starget_node_name
= 1,
844 .get_starget_port_name
= qla2x00_get_starget_port_name
,
845 .show_starget_port_name
= 1,
846 .get_starget_port_id
= qla2x00_get_starget_port_id
,
847 .show_starget_port_id
= 1,
849 .get_rport_dev_loss_tmo
= qla2x00_get_rport_loss_tmo
,
850 .set_rport_dev_loss_tmo
= qla2x00_set_rport_loss_tmo
,
851 .show_rport_dev_loss_tmo
= 1,
853 .issue_fc_host_lip
= qla2x00_issue_lip
,
854 .get_fc_host_stats
= qla2x00_get_fc_host_stats
,
858 qla2x00_init_host_attr(scsi_qla_host_t
*ha
)
860 fc_host_node_name(ha
->host
) = wwn_to_u64(ha
->node_name
);
861 fc_host_port_name(ha
->host
) = wwn_to_u64(ha
->port_name
);
862 fc_host_supported_classes(ha
->host
) = FC_COS_CLASS3
;