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
)));
19 char *rbuf
= (char *)ha
->fw_dump
;
21 if (ha
->fw_dump_reading
== 0)
23 if (off
> ha
->fw_dump_len
)
25 if (off
+ count
> ha
->fw_dump_len
)
26 count
= ha
->fw_dump_len
- off
;
28 memcpy(buf
, &rbuf
[off
], count
);
34 qla2x00_sysfs_write_fw_dump(struct kobject
*kobj
, char *buf
, loff_t off
,
37 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
38 struct device
, kobj
)));
44 reading
= simple_strtol(buf
, NULL
, 10);
47 if (!ha
->fw_dump_reading
)
50 qla_printk(KERN_INFO
, ha
,
51 "Firmware dump cleared on (%ld).\n", ha
->host_no
);
53 ha
->fw_dump_reading
= 0;
57 if (ha
->fw_dumped
&& !ha
->fw_dump_reading
) {
58 ha
->fw_dump_reading
= 1;
60 qla_printk(KERN_INFO
, ha
,
61 "Raw firmware dump ready for read on (%ld).\n",
66 qla2x00_alloc_fw_dump(ha
);
72 static struct bin_attribute sysfs_fw_dump_attr
= {
75 .mode
= S_IRUSR
| S_IWUSR
,
79 .read
= qla2x00_sysfs_read_fw_dump
,
80 .write
= qla2x00_sysfs_write_fw_dump
,
84 qla2x00_sysfs_read_nvram(struct kobject
*kobj
, char *buf
, loff_t off
,
87 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
88 struct device
, kobj
)));
91 if (!capable(CAP_SYS_ADMIN
) || off
!= 0)
95 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
96 ha
->isp_ops
.read_nvram(ha
, (uint8_t *)buf
, ha
->nvram_base
,
98 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
100 return ha
->nvram_size
;
104 qla2x00_sysfs_write_nvram(struct kobject
*kobj
, char *buf
, loff_t off
,
107 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
108 struct device
, kobj
)));
112 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= ha
->nvram_size
)
115 /* Checksum NVRAM. */
116 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
120 iter
= (uint32_t *)buf
;
122 for (cnt
= 0; cnt
< ((count
>> 2) - 1); cnt
++)
123 chksum
+= le32_to_cpu(*iter
++);
124 chksum
= ~chksum
+ 1;
125 *iter
= cpu_to_le32(chksum
);
130 iter
= (uint8_t *)buf
;
132 for (cnt
= 0; cnt
< count
- 1; cnt
++)
134 chksum
= ~chksum
+ 1;
139 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
140 ha
->isp_ops
.write_nvram(ha
, (uint8_t *)buf
, ha
->nvram_base
, count
);
141 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
146 static struct bin_attribute sysfs_nvram_attr
= {
149 .mode
= S_IRUSR
| S_IWUSR
,
150 .owner
= THIS_MODULE
,
153 .read
= qla2x00_sysfs_read_nvram
,
154 .write
= qla2x00_sysfs_write_nvram
,
158 qla2x00_sysfs_read_optrom(struct kobject
*kobj
, char *buf
, loff_t off
,
161 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
162 struct device
, kobj
)));
164 if (ha
->optrom_state
!= QLA_SREADING
)
166 if (off
> ha
->optrom_size
)
168 if (off
+ count
> ha
->optrom_size
)
169 count
= ha
->optrom_size
- off
;
171 memcpy(buf
, &ha
->optrom_buffer
[off
], count
);
177 qla2x00_sysfs_write_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_SWRITING
)
185 if (off
> ha
->optrom_size
)
187 if (off
+ count
> ha
->optrom_size
)
188 count
= ha
->optrom_size
- off
;
190 memcpy(&ha
->optrom_buffer
[off
], buf
, count
);
195 static struct bin_attribute sysfs_optrom_attr
= {
198 .mode
= S_IRUSR
| S_IWUSR
,
199 .owner
= THIS_MODULE
,
201 .size
= OPTROM_SIZE_24XX
,
202 .read
= qla2x00_sysfs_read_optrom
,
203 .write
= qla2x00_sysfs_write_optrom
,
207 qla2x00_sysfs_write_optrom_ctl(struct kobject
*kobj
, char *buf
, loff_t off
,
210 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
211 struct device
, kobj
)));
217 if (sscanf(buf
, "%d", &val
) != 1)
222 if (ha
->optrom_state
!= QLA_SREADING
&&
223 ha
->optrom_state
!= QLA_SWRITING
)
226 ha
->optrom_state
= QLA_SWAITING
;
227 vfree(ha
->optrom_buffer
);
228 ha
->optrom_buffer
= NULL
;
231 if (ha
->optrom_state
!= QLA_SWAITING
)
234 ha
->optrom_state
= QLA_SREADING
;
235 ha
->optrom_buffer
= (uint8_t *)vmalloc(ha
->optrom_size
);
236 if (ha
->optrom_buffer
== NULL
) {
237 qla_printk(KERN_WARNING
, ha
,
238 "Unable to allocate memory for optrom retrieval "
239 "(%x).\n", ha
->optrom_size
);
241 ha
->optrom_state
= QLA_SWAITING
;
245 memset(ha
->optrom_buffer
, 0, ha
->optrom_size
);
246 ha
->isp_ops
.read_optrom(ha
, ha
->optrom_buffer
, 0,
250 if (ha
->optrom_state
!= QLA_SWAITING
)
253 ha
->optrom_state
= QLA_SWRITING
;
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 update "
258 "(%x).\n", ha
->optrom_size
);
260 ha
->optrom_state
= QLA_SWAITING
;
263 memset(ha
->optrom_buffer
, 0, ha
->optrom_size
);
266 if (ha
->optrom_state
!= QLA_SWRITING
)
269 ha
->isp_ops
.write_optrom(ha
, ha
->optrom_buffer
, 0,
276 static struct bin_attribute sysfs_optrom_ctl_attr
= {
278 .name
= "optrom_ctl",
280 .owner
= THIS_MODULE
,
283 .write
= qla2x00_sysfs_write_optrom_ctl
,
287 qla2x00_sysfs_read_vpd(struct kobject
*kobj
, char *buf
, loff_t off
,
290 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
291 struct device
, kobj
)));
294 if (!capable(CAP_SYS_ADMIN
) || off
!= 0)
298 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
299 ha
->isp_ops
.read_nvram(ha
, (uint8_t *)buf
, ha
->vpd_base
, ha
->vpd_size
);
300 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
306 qla2x00_sysfs_write_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 || count
!= ha
->vpd_size
)
317 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
318 ha
->isp_ops
.write_nvram(ha
, (uint8_t *)buf
, ha
->vpd_base
, count
);
319 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
324 static struct bin_attribute sysfs_vpd_attr
= {
327 .mode
= S_IRUSR
| S_IWUSR
,
328 .owner
= THIS_MODULE
,
331 .read
= qla2x00_sysfs_read_vpd
,
332 .write
= qla2x00_sysfs_write_vpd
,
336 qla2x00_sysfs_read_sfp(struct kobject
*kobj
, char *buf
, loff_t off
,
339 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
340 struct device
, kobj
)));
341 uint16_t iter
, addr
, offset
;
344 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= SFP_DEV_SIZE
* 2)
348 for (iter
= 0, offset
= 0; iter
< (SFP_DEV_SIZE
* 2) / SFP_BLOCK_SIZE
;
349 iter
++, offset
+= SFP_BLOCK_SIZE
) {
351 /* Skip to next device address. */
356 rval
= qla2x00_read_sfp(ha
, ha
->sfp_data_dma
, addr
, offset
,
358 if (rval
!= QLA_SUCCESS
) {
359 qla_printk(KERN_WARNING
, ha
,
360 "Unable to read SFP data (%x/%x/%x).\n", rval
,
365 memcpy(buf
, ha
->sfp_data
, SFP_BLOCK_SIZE
);
366 buf
+= SFP_BLOCK_SIZE
;
372 static struct bin_attribute sysfs_sfp_attr
= {
375 .mode
= S_IRUSR
| S_IWUSR
,
376 .owner
= THIS_MODULE
,
378 .size
= SFP_DEV_SIZE
* 2,
379 .read
= qla2x00_sysfs_read_sfp
,
383 qla2x00_alloc_sysfs_attr(scsi_qla_host_t
*ha
)
385 struct Scsi_Host
*host
= ha
->host
;
387 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_fw_dump_attr
);
388 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_nvram_attr
);
389 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_optrom_attr
);
390 sysfs_create_bin_file(&host
->shost_gendev
.kobj
,
391 &sysfs_optrom_ctl_attr
);
392 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
393 sysfs_create_bin_file(&host
->shost_gendev
.kobj
,
395 sysfs_create_bin_file(&host
->shost_gendev
.kobj
,
401 qla2x00_free_sysfs_attr(scsi_qla_host_t
*ha
)
403 struct Scsi_Host
*host
= ha
->host
;
405 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_fw_dump_attr
);
406 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_nvram_attr
);
407 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_optrom_attr
);
408 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
,
409 &sysfs_optrom_ctl_attr
);
410 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
411 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
,
413 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
,
417 if (ha
->beacon_blink_led
== 1)
418 ha
->isp_ops
.beacon_off(ha
);
421 /* Scsi_Host attributes. */
424 qla2x00_drvr_version_show(struct class_device
*cdev
, char *buf
)
426 return snprintf(buf
, PAGE_SIZE
, "%s\n", qla2x00_version_str
);
430 qla2x00_fw_version_show(struct class_device
*cdev
, char *buf
)
432 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
435 return snprintf(buf
, PAGE_SIZE
, "%s\n",
436 ha
->isp_ops
.fw_version_str(ha
, fw_str
));
440 qla2x00_serial_num_show(struct class_device
*cdev
, char *buf
)
442 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
445 sn
= ((ha
->serial0
& 0x1f) << 16) | (ha
->serial2
<< 8) | ha
->serial1
;
446 return snprintf(buf
, PAGE_SIZE
, "%c%05d\n", 'A' + sn
/ 100000,
451 qla2x00_isp_name_show(struct class_device
*cdev
, char *buf
)
453 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
454 return snprintf(buf
, PAGE_SIZE
, "ISP%04X\n", ha
->pdev
->device
);
458 qla2x00_isp_id_show(struct class_device
*cdev
, char *buf
)
460 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
461 return snprintf(buf
, PAGE_SIZE
, "%04x %04x %04x %04x\n",
462 ha
->product_id
[0], ha
->product_id
[1], ha
->product_id
[2],
467 qla2x00_model_name_show(struct class_device
*cdev
, char *buf
)
469 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
470 return snprintf(buf
, PAGE_SIZE
, "%s\n", ha
->model_number
);
474 qla2x00_model_desc_show(struct class_device
*cdev
, char *buf
)
476 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
477 return snprintf(buf
, PAGE_SIZE
, "%s\n",
478 ha
->model_desc
? ha
->model_desc
: "");
482 qla2x00_pci_info_show(struct class_device
*cdev
, char *buf
)
484 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
487 return snprintf(buf
, PAGE_SIZE
, "%s\n",
488 ha
->isp_ops
.pci_info_str(ha
, pci_info
));
492 qla2x00_state_show(struct class_device
*cdev
, char *buf
)
494 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
497 if (atomic_read(&ha
->loop_state
) == LOOP_DOWN
||
498 atomic_read(&ha
->loop_state
) == LOOP_DEAD
)
499 len
= snprintf(buf
, PAGE_SIZE
, "Link Down\n");
500 else if (atomic_read(&ha
->loop_state
) != LOOP_READY
||
501 test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
) ||
502 test_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
))
503 len
= snprintf(buf
, PAGE_SIZE
, "Unknown Link State\n");
505 len
= snprintf(buf
, PAGE_SIZE
, "Link Up - ");
507 switch (ha
->current_topology
) {
509 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
512 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "FL_Port\n");
515 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
516 "N_Port to N_Port\n");
519 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "F_Port\n");
522 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
530 qla2x00_zio_show(struct class_device
*cdev
, char *buf
)
532 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
535 switch (ha
->zio_mode
) {
537 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Mode 6\n");
539 case QLA_ZIO_DISABLED
:
540 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
547 qla2x00_zio_store(struct class_device
*cdev
, const char *buf
, size_t count
)
549 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
553 if (!IS_ZIO_SUPPORTED(ha
))
556 if (sscanf(buf
, "%d", &val
) != 1)
560 zio_mode
= QLA_ZIO_MODE_6
;
562 zio_mode
= QLA_ZIO_DISABLED
;
564 /* Update per-hba values and queue a reset. */
565 if (zio_mode
!= QLA_ZIO_DISABLED
|| ha
->zio_mode
!= QLA_ZIO_DISABLED
) {
566 ha
->zio_mode
= zio_mode
;
567 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
573 qla2x00_zio_timer_show(struct class_device
*cdev
, char *buf
)
575 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
577 return snprintf(buf
, PAGE_SIZE
, "%d us\n", ha
->zio_timer
* 100);
581 qla2x00_zio_timer_store(struct class_device
*cdev
, const char *buf
,
584 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
588 if (sscanf(buf
, "%d", &val
) != 1)
590 if (val
> 25500 || val
< 100)
593 zio_timer
= (uint16_t)(val
/ 100);
594 ha
->zio_timer
= zio_timer
;
600 qla2x00_beacon_show(struct class_device
*cdev
, char *buf
)
602 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
605 if (ha
->beacon_blink_led
)
606 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Enabled\n");
608 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
613 qla2x00_beacon_store(struct class_device
*cdev
, const char *buf
,
616 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
620 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
623 if (test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
)) {
624 qla_printk(KERN_WARNING
, ha
,
625 "Abort ISP active -- ignoring beacon request.\n");
629 if (sscanf(buf
, "%d", &val
) != 1)
633 rval
= ha
->isp_ops
.beacon_on(ha
);
635 rval
= ha
->isp_ops
.beacon_off(ha
);
637 if (rval
!= QLA_SUCCESS
)
643 static CLASS_DEVICE_ATTR(driver_version
, S_IRUGO
, qla2x00_drvr_version_show
,
645 static CLASS_DEVICE_ATTR(fw_version
, S_IRUGO
, qla2x00_fw_version_show
, NULL
);
646 static CLASS_DEVICE_ATTR(serial_num
, S_IRUGO
, qla2x00_serial_num_show
, NULL
);
647 static CLASS_DEVICE_ATTR(isp_name
, S_IRUGO
, qla2x00_isp_name_show
, NULL
);
648 static CLASS_DEVICE_ATTR(isp_id
, S_IRUGO
, qla2x00_isp_id_show
, NULL
);
649 static CLASS_DEVICE_ATTR(model_name
, S_IRUGO
, qla2x00_model_name_show
, NULL
);
650 static CLASS_DEVICE_ATTR(model_desc
, S_IRUGO
, qla2x00_model_desc_show
, NULL
);
651 static CLASS_DEVICE_ATTR(pci_info
, S_IRUGO
, qla2x00_pci_info_show
, NULL
);
652 static CLASS_DEVICE_ATTR(state
, S_IRUGO
, qla2x00_state_show
, NULL
);
653 static CLASS_DEVICE_ATTR(zio
, S_IRUGO
| S_IWUSR
, qla2x00_zio_show
,
655 static CLASS_DEVICE_ATTR(zio_timer
, S_IRUGO
| S_IWUSR
, qla2x00_zio_timer_show
,
656 qla2x00_zio_timer_store
);
657 static CLASS_DEVICE_ATTR(beacon
, S_IRUGO
| S_IWUSR
, qla2x00_beacon_show
,
658 qla2x00_beacon_store
);
660 struct class_device_attribute
*qla2x00_host_attrs
[] = {
661 &class_device_attr_driver_version
,
662 &class_device_attr_fw_version
,
663 &class_device_attr_serial_num
,
664 &class_device_attr_isp_name
,
665 &class_device_attr_isp_id
,
666 &class_device_attr_model_name
,
667 &class_device_attr_model_desc
,
668 &class_device_attr_pci_info
,
669 &class_device_attr_state
,
670 &class_device_attr_zio
,
671 &class_device_attr_zio_timer
,
672 &class_device_attr_beacon
,
676 /* Host attributes. */
679 qla2x00_get_host_port_id(struct Scsi_Host
*shost
)
681 scsi_qla_host_t
*ha
= to_qla_host(shost
);
683 fc_host_port_id(shost
) = ha
->d_id
.b
.domain
<< 16 |
684 ha
->d_id
.b
.area
<< 8 | ha
->d_id
.b
.al_pa
;
688 qla2x00_get_host_speed(struct Scsi_Host
*shost
)
690 scsi_qla_host_t
*ha
= to_qla_host(shost
);
693 switch (ha
->link_data_rate
) {
704 fc_host_speed(shost
) = speed
;
708 qla2x00_get_host_port_type(struct Scsi_Host
*shost
)
710 scsi_qla_host_t
*ha
= to_qla_host(shost
);
711 uint32_t port_type
= FC_PORTTYPE_UNKNOWN
;
713 switch (ha
->current_topology
) {
715 port_type
= FC_PORTTYPE_LPORT
;
718 port_type
= FC_PORTTYPE_NLPORT
;
721 port_type
= FC_PORTTYPE_PTP
;
724 port_type
= FC_PORTTYPE_NPORT
;
727 fc_host_port_type(shost
) = port_type
;
731 qla2x00_get_starget_node_name(struct scsi_target
*starget
)
733 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
734 scsi_qla_host_t
*ha
= to_qla_host(host
);
738 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
739 if (starget
->id
== fcport
->os_target_id
) {
740 node_name
= wwn_to_u64(fcport
->node_name
);
745 fc_starget_node_name(starget
) = node_name
;
749 qla2x00_get_starget_port_name(struct scsi_target
*starget
)
751 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
752 scsi_qla_host_t
*ha
= to_qla_host(host
);
756 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
757 if (starget
->id
== fcport
->os_target_id
) {
758 port_name
= wwn_to_u64(fcport
->port_name
);
763 fc_starget_port_name(starget
) = port_name
;
767 qla2x00_get_starget_port_id(struct scsi_target
*starget
)
769 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
770 scsi_qla_host_t
*ha
= to_qla_host(host
);
772 uint32_t port_id
= ~0U;
774 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
775 if (starget
->id
== fcport
->os_target_id
) {
776 port_id
= fcport
->d_id
.b
.domain
<< 16 |
777 fcport
->d_id
.b
.area
<< 8 | fcport
->d_id
.b
.al_pa
;
782 fc_starget_port_id(starget
) = port_id
;
786 qla2x00_get_rport_loss_tmo(struct fc_rport
*rport
)
788 struct Scsi_Host
*host
= rport_to_shost(rport
);
789 scsi_qla_host_t
*ha
= to_qla_host(host
);
791 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
795 qla2x00_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
797 struct Scsi_Host
*host
= rport_to_shost(rport
);
798 scsi_qla_host_t
*ha
= to_qla_host(host
);
801 ha
->port_down_retry_count
= timeout
;
803 ha
->port_down_retry_count
= 1;
805 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
809 qla2x00_issue_lip(struct Scsi_Host
*shost
)
811 scsi_qla_host_t
*ha
= to_qla_host(shost
);
813 set_bit(LOOP_RESET_NEEDED
, &ha
->dpc_flags
);
817 static struct fc_host_statistics
*
818 qla2x00_get_fc_host_stats(struct Scsi_Host
*shost
)
820 scsi_qla_host_t
*ha
= to_qla_host(shost
);
823 link_stat_t stat_buf
;
824 struct fc_host_statistics
*pfc_host_stat
;
826 pfc_host_stat
= &ha
->fc_host_stat
;
827 memset(pfc_host_stat
, -1, sizeof(struct fc_host_statistics
));
829 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
830 rval
= qla24xx_get_isp_stats(ha
, (uint32_t *)&stat_buf
,
831 sizeof(stat_buf
) / 4, mb_stat
);
833 rval
= qla2x00_get_link_status(ha
, ha
->loop_id
, &stat_buf
,
837 qla_printk(KERN_WARNING
, ha
,
838 "Unable to retrieve host statistics (%d).\n", mb_stat
[0]);
839 return pfc_host_stat
;
842 pfc_host_stat
->link_failure_count
= stat_buf
.link_fail_cnt
;
843 pfc_host_stat
->loss_of_sync_count
= stat_buf
.loss_sync_cnt
;
844 pfc_host_stat
->loss_of_signal_count
= stat_buf
.loss_sig_cnt
;
845 pfc_host_stat
->prim_seq_protocol_err_count
= stat_buf
.prim_seq_err_cnt
;
846 pfc_host_stat
->invalid_tx_word_count
= stat_buf
.inval_xmit_word_cnt
;
847 pfc_host_stat
->invalid_crc_count
= stat_buf
.inval_crc_cnt
;
849 return pfc_host_stat
;
852 struct fc_function_template qla2xxx_transport_functions
= {
854 .show_host_node_name
= 1,
855 .show_host_port_name
= 1,
856 .show_host_supported_classes
= 1,
858 .get_host_port_id
= qla2x00_get_host_port_id
,
859 .show_host_port_id
= 1,
860 .get_host_speed
= qla2x00_get_host_speed
,
861 .show_host_speed
= 1,
862 .get_host_port_type
= qla2x00_get_host_port_type
,
863 .show_host_port_type
= 1,
865 .dd_fcrport_size
= sizeof(struct fc_port
*),
866 .show_rport_supported_classes
= 1,
868 .get_starget_node_name
= qla2x00_get_starget_node_name
,
869 .show_starget_node_name
= 1,
870 .get_starget_port_name
= qla2x00_get_starget_port_name
,
871 .show_starget_port_name
= 1,
872 .get_starget_port_id
= qla2x00_get_starget_port_id
,
873 .show_starget_port_id
= 1,
875 .get_rport_dev_loss_tmo
= qla2x00_get_rport_loss_tmo
,
876 .set_rport_dev_loss_tmo
= qla2x00_set_rport_loss_tmo
,
877 .show_rport_dev_loss_tmo
= 1,
879 .issue_fc_host_lip
= qla2x00_issue_lip
,
880 .get_fc_host_stats
= qla2x00_get_fc_host_stats
,
884 qla2x00_init_host_attr(scsi_qla_host_t
*ha
)
886 fc_host_node_name(ha
->host
) = wwn_to_u64(ha
->node_name
);
887 fc_host_port_name(ha
->host
) = wwn_to_u64(ha
->port_name
);
888 fc_host_supported_classes(ha
->host
) = FC_COS_CLASS3
;