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", ha
->host_no
);
51 vfree(ha
->fw_dump_buffer
);
52 ha
->fw_dump_buffer
= NULL
;
53 ha
->fw_dump_reading
= 0;
58 if (ha
->fw_dumped
&& !ha
->fw_dump_reading
) {
59 ha
->fw_dump_reading
= 1;
61 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
))
62 dump_size
= FW_DUMP_SIZE_24XX
;
64 dump_size
= FW_DUMP_SIZE_1M
;
65 if (ha
->fw_memory_size
< 0x20000)
66 dump_size
= FW_DUMP_SIZE_128K
;
67 else if (ha
->fw_memory_size
< 0x80000)
68 dump_size
= FW_DUMP_SIZE_512K
;
70 ha
->fw_dump_buffer
= (char *)vmalloc(dump_size
);
71 if (ha
->fw_dump_buffer
== NULL
) {
72 qla_printk(KERN_WARNING
, ha
,
73 "Unable to allocate memory for firmware "
74 "dump buffer (%d).\n", dump_size
);
76 ha
->fw_dump_reading
= 0;
79 qla_printk(KERN_INFO
, ha
,
80 "Firmware dump ready for read on (%ld).\n",
82 memset(ha
->fw_dump_buffer
, 0, dump_size
);
83 ha
->isp_ops
.ascii_fw_dump(ha
);
84 ha
->fw_dump_buffer_len
= strlen(ha
->fw_dump_buffer
);
91 static struct bin_attribute sysfs_fw_dump_attr
= {
94 .mode
= S_IRUSR
| S_IWUSR
,
98 .read
= qla2x00_sysfs_read_fw_dump
,
99 .write
= qla2x00_sysfs_write_fw_dump
,
103 qla2x00_sysfs_read_nvram(struct kobject
*kobj
, char *buf
, loff_t off
,
106 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
107 struct device
, kobj
)));
110 if (!capable(CAP_SYS_ADMIN
) || off
!= 0)
114 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
115 ha
->isp_ops
.read_nvram(ha
, (uint8_t *)buf
, ha
->nvram_base
,
117 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
119 return ha
->nvram_size
;
123 qla2x00_sysfs_write_nvram(struct kobject
*kobj
, char *buf
, loff_t off
,
126 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
127 struct device
, kobj
)));
131 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= ha
->nvram_size
)
134 /* Checksum NVRAM. */
135 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
139 iter
= (uint32_t *)buf
;
141 for (cnt
= 0; cnt
< ((count
>> 2) - 1); cnt
++)
142 chksum
+= le32_to_cpu(*iter
++);
143 chksum
= ~chksum
+ 1;
144 *iter
= cpu_to_le32(chksum
);
149 iter
= (uint8_t *)buf
;
151 for (cnt
= 0; cnt
< count
- 1; cnt
++)
153 chksum
= ~chksum
+ 1;
158 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
159 ha
->isp_ops
.write_nvram(ha
, (uint8_t *)buf
, ha
->nvram_base
, count
);
160 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
165 static struct bin_attribute sysfs_nvram_attr
= {
168 .mode
= S_IRUSR
| S_IWUSR
,
169 .owner
= THIS_MODULE
,
172 .read
= qla2x00_sysfs_read_nvram
,
173 .write
= qla2x00_sysfs_write_nvram
,
177 qla2x00_sysfs_read_optrom(struct kobject
*kobj
, char *buf
, loff_t off
,
180 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
181 struct device
, kobj
)));
183 if (ha
->optrom_state
!= QLA_SREADING
)
185 if (off
> ha
->optrom_size
)
187 if (off
+ count
> ha
->optrom_size
)
188 count
= ha
->optrom_size
- off
;
190 memcpy(buf
, &ha
->optrom_buffer
[off
], count
);
196 qla2x00_sysfs_write_optrom(struct kobject
*kobj
, char *buf
, loff_t off
,
199 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
200 struct device
, kobj
)));
202 if (ha
->optrom_state
!= QLA_SWRITING
)
204 if (off
> ha
->optrom_size
)
206 if (off
+ count
> ha
->optrom_size
)
207 count
= ha
->optrom_size
- off
;
209 memcpy(&ha
->optrom_buffer
[off
], buf
, count
);
214 static struct bin_attribute sysfs_optrom_attr
= {
217 .mode
= S_IRUSR
| S_IWUSR
,
218 .owner
= THIS_MODULE
,
220 .size
= OPTROM_SIZE_24XX
,
221 .read
= qla2x00_sysfs_read_optrom
,
222 .write
= qla2x00_sysfs_write_optrom
,
226 qla2x00_sysfs_write_optrom_ctl(struct kobject
*kobj
, char *buf
, loff_t off
,
229 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
230 struct device
, kobj
)));
236 if (sscanf(buf
, "%d", &val
) != 1)
241 if (ha
->optrom_state
!= QLA_SREADING
&&
242 ha
->optrom_state
!= QLA_SWRITING
)
245 ha
->optrom_state
= QLA_SWAITING
;
246 vfree(ha
->optrom_buffer
);
247 ha
->optrom_buffer
= NULL
;
250 if (ha
->optrom_state
!= QLA_SWAITING
)
253 ha
->optrom_state
= QLA_SREADING
;
254 ha
->optrom_buffer
= (uint8_t *)vmalloc(ha
->optrom_size
);
255 if (ha
->optrom_buffer
== NULL
) {
256 qla_printk(KERN_WARNING
, ha
,
257 "Unable to allocate memory for optrom retrieval "
258 "(%x).\n", ha
->optrom_size
);
260 ha
->optrom_state
= QLA_SWAITING
;
264 memset(ha
->optrom_buffer
, 0, ha
->optrom_size
);
265 ha
->isp_ops
.read_optrom(ha
, ha
->optrom_buffer
, 0,
269 if (ha
->optrom_state
!= QLA_SWAITING
)
272 ha
->optrom_state
= QLA_SWRITING
;
273 ha
->optrom_buffer
= (uint8_t *)vmalloc(ha
->optrom_size
);
274 if (ha
->optrom_buffer
== NULL
) {
275 qla_printk(KERN_WARNING
, ha
,
276 "Unable to allocate memory for optrom update "
277 "(%x).\n", ha
->optrom_size
);
279 ha
->optrom_state
= QLA_SWAITING
;
282 memset(ha
->optrom_buffer
, 0, ha
->optrom_size
);
285 if (ha
->optrom_state
!= QLA_SWRITING
)
288 ha
->isp_ops
.write_optrom(ha
, ha
->optrom_buffer
, 0,
295 static struct bin_attribute sysfs_optrom_ctl_attr
= {
297 .name
= "optrom_ctl",
299 .owner
= THIS_MODULE
,
302 .write
= qla2x00_sysfs_write_optrom_ctl
,
306 qla2x00_sysfs_read_vpd(struct kobject
*kobj
, char *buf
, loff_t off
,
309 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
310 struct device
, kobj
)));
313 if (!capable(CAP_SYS_ADMIN
) || off
!= 0)
316 if (!IS_QLA24XX(ha
) && !IS_QLA54XX(ha
))
320 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
321 ha
->isp_ops
.read_nvram(ha
, (uint8_t *)buf
, ha
->vpd_base
, ha
->vpd_size
);
322 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
328 qla2x00_sysfs_write_vpd(struct kobject
*kobj
, char *buf
, loff_t off
,
331 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
332 struct device
, kobj
)));
335 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= ha
->vpd_size
)
338 if (!IS_QLA24XX(ha
) && !IS_QLA54XX(ha
))
342 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
343 ha
->isp_ops
.write_nvram(ha
, (uint8_t *)buf
, ha
->vpd_base
, count
);
344 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
349 static struct bin_attribute sysfs_vpd_attr
= {
352 .mode
= S_IRUSR
| S_IWUSR
,
353 .owner
= THIS_MODULE
,
356 .read
= qla2x00_sysfs_read_vpd
,
357 .write
= qla2x00_sysfs_write_vpd
,
361 qla2x00_alloc_sysfs_attr(scsi_qla_host_t
*ha
)
363 struct Scsi_Host
*host
= ha
->host
;
365 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_fw_dump_attr
);
366 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_nvram_attr
);
367 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_optrom_attr
);
368 sysfs_create_bin_file(&host
->shost_gendev
.kobj
,
369 &sysfs_optrom_ctl_attr
);
370 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_vpd_attr
);
374 qla2x00_free_sysfs_attr(scsi_qla_host_t
*ha
)
376 struct Scsi_Host
*host
= ha
->host
;
378 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_fw_dump_attr
);
379 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_nvram_attr
);
380 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_optrom_attr
);
381 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
,
382 &sysfs_optrom_ctl_attr
);
383 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_vpd_attr
);
385 if (ha
->beacon_blink_led
== 1)
386 ha
->isp_ops
.beacon_off(ha
);
389 /* Scsi_Host attributes. */
392 qla2x00_drvr_version_show(struct class_device
*cdev
, char *buf
)
394 return snprintf(buf
, PAGE_SIZE
, "%s\n", qla2x00_version_str
);
398 qla2x00_fw_version_show(struct class_device
*cdev
, char *buf
)
400 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
403 return snprintf(buf
, PAGE_SIZE
, "%s\n",
404 ha
->isp_ops
.fw_version_str(ha
, fw_str
));
408 qla2x00_serial_num_show(struct class_device
*cdev
, char *buf
)
410 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
413 sn
= ((ha
->serial0
& 0x1f) << 16) | (ha
->serial2
<< 8) | ha
->serial1
;
414 return snprintf(buf
, PAGE_SIZE
, "%c%05d\n", 'A' + sn
/ 100000,
419 qla2x00_isp_name_show(struct class_device
*cdev
, char *buf
)
421 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
422 return snprintf(buf
, PAGE_SIZE
, "ISP%04X\n", ha
->pdev
->device
);
426 qla2x00_isp_id_show(struct class_device
*cdev
, char *buf
)
428 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
429 return snprintf(buf
, PAGE_SIZE
, "%04x %04x %04x %04x\n",
430 ha
->product_id
[0], ha
->product_id
[1], ha
->product_id
[2],
435 qla2x00_model_name_show(struct class_device
*cdev
, char *buf
)
437 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
438 return snprintf(buf
, PAGE_SIZE
, "%s\n", ha
->model_number
);
442 qla2x00_model_desc_show(struct class_device
*cdev
, char *buf
)
444 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
445 return snprintf(buf
, PAGE_SIZE
, "%s\n",
446 ha
->model_desc
? ha
->model_desc
: "");
450 qla2x00_pci_info_show(struct class_device
*cdev
, char *buf
)
452 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
455 return snprintf(buf
, PAGE_SIZE
, "%s\n",
456 ha
->isp_ops
.pci_info_str(ha
, pci_info
));
460 qla2x00_state_show(struct class_device
*cdev
, char *buf
)
462 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
465 if (atomic_read(&ha
->loop_state
) == LOOP_DOWN
||
466 atomic_read(&ha
->loop_state
) == LOOP_DEAD
)
467 len
= snprintf(buf
, PAGE_SIZE
, "Link Down\n");
468 else if (atomic_read(&ha
->loop_state
) != LOOP_READY
||
469 test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
) ||
470 test_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
))
471 len
= snprintf(buf
, PAGE_SIZE
, "Unknown Link State\n");
473 len
= snprintf(buf
, PAGE_SIZE
, "Link Up - ");
475 switch (ha
->current_topology
) {
477 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
480 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "FL_Port\n");
483 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
484 "N_Port to N_Port\n");
487 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "F_Port\n");
490 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
498 qla2x00_zio_show(struct class_device
*cdev
, char *buf
)
500 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
503 switch (ha
->zio_mode
) {
505 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Mode 6\n");
507 case QLA_ZIO_DISABLED
:
508 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
515 qla2x00_zio_store(struct class_device
*cdev
, const char *buf
, size_t count
)
517 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
521 if (!IS_ZIO_SUPPORTED(ha
))
524 if (sscanf(buf
, "%d", &val
) != 1)
528 zio_mode
= QLA_ZIO_MODE_6
;
530 zio_mode
= QLA_ZIO_DISABLED
;
532 /* Update per-hba values and queue a reset. */
533 if (zio_mode
!= QLA_ZIO_DISABLED
|| ha
->zio_mode
!= QLA_ZIO_DISABLED
) {
534 ha
->zio_mode
= zio_mode
;
535 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
541 qla2x00_zio_timer_show(struct class_device
*cdev
, char *buf
)
543 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
545 return snprintf(buf
, PAGE_SIZE
, "%d us\n", ha
->zio_timer
* 100);
549 qla2x00_zio_timer_store(struct class_device
*cdev
, const char *buf
,
552 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
556 if (sscanf(buf
, "%d", &val
) != 1)
558 if (val
> 25500 || val
< 100)
561 zio_timer
= (uint16_t)(val
/ 100);
562 ha
->zio_timer
= zio_timer
;
568 qla2x00_beacon_show(struct class_device
*cdev
, char *buf
)
570 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
573 if (ha
->beacon_blink_led
)
574 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Enabled\n");
576 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
581 qla2x00_beacon_store(struct class_device
*cdev
, const char *buf
,
584 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
588 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
591 if (test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
)) {
592 qla_printk(KERN_WARNING
, ha
,
593 "Abort ISP active -- ignoring beacon request.\n");
597 if (sscanf(buf
, "%d", &val
) != 1)
601 rval
= ha
->isp_ops
.beacon_on(ha
);
603 rval
= ha
->isp_ops
.beacon_off(ha
);
605 if (rval
!= QLA_SUCCESS
)
611 static CLASS_DEVICE_ATTR(driver_version
, S_IRUGO
, qla2x00_drvr_version_show
,
613 static CLASS_DEVICE_ATTR(fw_version
, S_IRUGO
, qla2x00_fw_version_show
, NULL
);
614 static CLASS_DEVICE_ATTR(serial_num
, S_IRUGO
, qla2x00_serial_num_show
, NULL
);
615 static CLASS_DEVICE_ATTR(isp_name
, S_IRUGO
, qla2x00_isp_name_show
, NULL
);
616 static CLASS_DEVICE_ATTR(isp_id
, S_IRUGO
, qla2x00_isp_id_show
, NULL
);
617 static CLASS_DEVICE_ATTR(model_name
, S_IRUGO
, qla2x00_model_name_show
, NULL
);
618 static CLASS_DEVICE_ATTR(model_desc
, S_IRUGO
, qla2x00_model_desc_show
, NULL
);
619 static CLASS_DEVICE_ATTR(pci_info
, S_IRUGO
, qla2x00_pci_info_show
, NULL
);
620 static CLASS_DEVICE_ATTR(state
, S_IRUGO
, qla2x00_state_show
, NULL
);
621 static CLASS_DEVICE_ATTR(zio
, S_IRUGO
| S_IWUSR
, qla2x00_zio_show
,
623 static CLASS_DEVICE_ATTR(zio_timer
, S_IRUGO
| S_IWUSR
, qla2x00_zio_timer_show
,
624 qla2x00_zio_timer_store
);
625 static CLASS_DEVICE_ATTR(beacon
, S_IRUGO
| S_IWUSR
, qla2x00_beacon_show
,
626 qla2x00_beacon_store
);
628 struct class_device_attribute
*qla2x00_host_attrs
[] = {
629 &class_device_attr_driver_version
,
630 &class_device_attr_fw_version
,
631 &class_device_attr_serial_num
,
632 &class_device_attr_isp_name
,
633 &class_device_attr_isp_id
,
634 &class_device_attr_model_name
,
635 &class_device_attr_model_desc
,
636 &class_device_attr_pci_info
,
637 &class_device_attr_state
,
638 &class_device_attr_zio
,
639 &class_device_attr_zio_timer
,
640 &class_device_attr_beacon
,
644 /* Host attributes. */
647 qla2x00_get_host_port_id(struct Scsi_Host
*shost
)
649 scsi_qla_host_t
*ha
= to_qla_host(shost
);
651 fc_host_port_id(shost
) = ha
->d_id
.b
.domain
<< 16 |
652 ha
->d_id
.b
.area
<< 8 | ha
->d_id
.b
.al_pa
;
656 qla2x00_get_host_speed(struct Scsi_Host
*shost
)
658 scsi_qla_host_t
*ha
= to_qla_host(shost
);
661 switch (ha
->link_data_rate
) {
672 fc_host_speed(shost
) = speed
;
676 qla2x00_get_host_port_type(struct Scsi_Host
*shost
)
678 scsi_qla_host_t
*ha
= to_qla_host(shost
);
679 uint32_t port_type
= FC_PORTTYPE_UNKNOWN
;
681 switch (ha
->current_topology
) {
683 port_type
= FC_PORTTYPE_LPORT
;
686 port_type
= FC_PORTTYPE_NLPORT
;
689 port_type
= FC_PORTTYPE_PTP
;
692 port_type
= FC_PORTTYPE_NPORT
;
695 fc_host_port_type(shost
) = port_type
;
699 qla2x00_get_starget_node_name(struct scsi_target
*starget
)
701 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
702 scsi_qla_host_t
*ha
= to_qla_host(host
);
706 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
707 if (starget
->id
== fcport
->os_target_id
) {
708 node_name
= wwn_to_u64(fcport
->node_name
);
713 fc_starget_node_name(starget
) = node_name
;
717 qla2x00_get_starget_port_name(struct scsi_target
*starget
)
719 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
720 scsi_qla_host_t
*ha
= to_qla_host(host
);
724 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
725 if (starget
->id
== fcport
->os_target_id
) {
726 port_name
= wwn_to_u64(fcport
->port_name
);
731 fc_starget_port_name(starget
) = port_name
;
735 qla2x00_get_starget_port_id(struct scsi_target
*starget
)
737 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
738 scsi_qla_host_t
*ha
= to_qla_host(host
);
740 uint32_t port_id
= ~0U;
742 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
743 if (starget
->id
== fcport
->os_target_id
) {
744 port_id
= fcport
->d_id
.b
.domain
<< 16 |
745 fcport
->d_id
.b
.area
<< 8 | fcport
->d_id
.b
.al_pa
;
750 fc_starget_port_id(starget
) = port_id
;
754 qla2x00_get_rport_loss_tmo(struct fc_rport
*rport
)
756 struct Scsi_Host
*host
= rport_to_shost(rport
);
757 scsi_qla_host_t
*ha
= to_qla_host(host
);
759 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
763 qla2x00_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
765 struct Scsi_Host
*host
= rport_to_shost(rport
);
766 scsi_qla_host_t
*ha
= to_qla_host(host
);
769 ha
->port_down_retry_count
= timeout
;
771 ha
->port_down_retry_count
= 1;
773 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
777 qla2x00_issue_lip(struct Scsi_Host
*shost
)
779 scsi_qla_host_t
*ha
= to_qla_host(shost
);
781 set_bit(LOOP_RESET_NEEDED
, &ha
->dpc_flags
);
785 static struct fc_host_statistics
*
786 qla2x00_get_fc_host_stats(struct Scsi_Host
*shost
)
788 scsi_qla_host_t
*ha
= to_qla_host(shost
);
791 link_stat_t stat_buf
;
792 struct fc_host_statistics
*pfc_host_stat
;
794 pfc_host_stat
= &ha
->fc_host_stat
;
795 memset(pfc_host_stat
, -1, sizeof(struct fc_host_statistics
));
797 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
798 rval
= qla24xx_get_isp_stats(ha
, (uint32_t *)&stat_buf
,
799 sizeof(stat_buf
) / 4, mb_stat
);
801 rval
= qla2x00_get_link_status(ha
, ha
->loop_id
, &stat_buf
,
805 qla_printk(KERN_WARNING
, ha
,
806 "Unable to retrieve host statistics (%d).\n", mb_stat
[0]);
807 return pfc_host_stat
;
810 pfc_host_stat
->link_failure_count
= stat_buf
.link_fail_cnt
;
811 pfc_host_stat
->loss_of_sync_count
= stat_buf
.loss_sync_cnt
;
812 pfc_host_stat
->loss_of_signal_count
= stat_buf
.loss_sig_cnt
;
813 pfc_host_stat
->prim_seq_protocol_err_count
= stat_buf
.prim_seq_err_cnt
;
814 pfc_host_stat
->invalid_tx_word_count
= stat_buf
.inval_xmit_word_cnt
;
815 pfc_host_stat
->invalid_crc_count
= stat_buf
.inval_crc_cnt
;
817 return pfc_host_stat
;
820 struct fc_function_template qla2xxx_transport_functions
= {
822 .show_host_node_name
= 1,
823 .show_host_port_name
= 1,
824 .show_host_supported_classes
= 1,
826 .get_host_port_id
= qla2x00_get_host_port_id
,
827 .show_host_port_id
= 1,
828 .get_host_speed
= qla2x00_get_host_speed
,
829 .show_host_speed
= 1,
830 .get_host_port_type
= qla2x00_get_host_port_type
,
831 .show_host_port_type
= 1,
833 .dd_fcrport_size
= sizeof(struct fc_port
*),
834 .show_rport_supported_classes
= 1,
836 .get_starget_node_name
= qla2x00_get_starget_node_name
,
837 .show_starget_node_name
= 1,
838 .get_starget_port_name
= qla2x00_get_starget_port_name
,
839 .show_starget_port_name
= 1,
840 .get_starget_port_id
= qla2x00_get_starget_port_id
,
841 .show_starget_port_id
= 1,
843 .get_rport_dev_loss_tmo
= qla2x00_get_rport_loss_tmo
,
844 .set_rport_dev_loss_tmo
= qla2x00_set_rport_loss_tmo
,
845 .show_rport_dev_loss_tmo
= 1,
847 .issue_fc_host_lip
= qla2x00_issue_lip
,
848 .get_fc_host_stats
= qla2x00_get_fc_host_stats
,
852 qla2x00_init_host_attr(scsi_qla_host_t
*ha
)
854 fc_host_node_name(ha
->host
) = wwn_to_u64(ha
->node_name
);
855 fc_host_port_name(ha
->host
) = wwn_to_u64(ha
->port_name
);
856 fc_host_supported_classes(ha
->host
) = FC_COS_CLASS3
;