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)
297 if (!IS_QLA24XX(ha
) && !IS_QLA54XX(ha
))
301 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
302 ha
->isp_ops
.read_nvram(ha
, (uint8_t *)buf
, ha
->vpd_base
, ha
->vpd_size
);
303 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
309 qla2x00_sysfs_write_vpd(struct kobject
*kobj
, char *buf
, loff_t off
,
312 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
313 struct device
, kobj
)));
316 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= ha
->vpd_size
)
319 if (!IS_QLA24XX(ha
) && !IS_QLA54XX(ha
))
323 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
324 ha
->isp_ops
.write_nvram(ha
, (uint8_t *)buf
, ha
->vpd_base
, count
);
325 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
330 static struct bin_attribute sysfs_vpd_attr
= {
333 .mode
= S_IRUSR
| S_IWUSR
,
334 .owner
= THIS_MODULE
,
337 .read
= qla2x00_sysfs_read_vpd
,
338 .write
= qla2x00_sysfs_write_vpd
,
342 qla2x00_sysfs_read_sfp(struct kobject
*kobj
, char *buf
, loff_t off
,
345 struct scsi_qla_host
*ha
= to_qla_host(dev_to_shost(container_of(kobj
,
346 struct device
, kobj
)));
347 uint16_t iter
, addr
, offset
;
350 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= SFP_DEV_SIZE
* 2)
354 for (iter
= 0, offset
= 0; iter
< (SFP_DEV_SIZE
* 2) / SFP_BLOCK_SIZE
;
355 iter
++, offset
+= SFP_BLOCK_SIZE
) {
357 /* Skip to next device address. */
362 rval
= qla2x00_read_sfp(ha
, ha
->sfp_data_dma
, addr
, offset
,
364 if (rval
!= QLA_SUCCESS
) {
365 qla_printk(KERN_WARNING
, ha
,
366 "Unable to read SFP data (%x/%x/%x).\n", rval
,
371 memcpy(buf
, ha
->sfp_data
, SFP_BLOCK_SIZE
);
372 buf
+= SFP_BLOCK_SIZE
;
378 static struct bin_attribute sysfs_sfp_attr
= {
381 .mode
= S_IRUSR
| S_IWUSR
,
382 .owner
= THIS_MODULE
,
384 .size
= SFP_DEV_SIZE
* 2,
385 .read
= qla2x00_sysfs_read_sfp
,
389 qla2x00_alloc_sysfs_attr(scsi_qla_host_t
*ha
)
391 struct Scsi_Host
*host
= ha
->host
;
393 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_fw_dump_attr
);
394 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_nvram_attr
);
395 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_optrom_attr
);
396 sysfs_create_bin_file(&host
->shost_gendev
.kobj
,
397 &sysfs_optrom_ctl_attr
);
398 sysfs_create_bin_file(&host
->shost_gendev
.kobj
, &sysfs_vpd_attr
);
399 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
))
400 sysfs_create_bin_file(&host
->shost_gendev
.kobj
,
405 qla2x00_free_sysfs_attr(scsi_qla_host_t
*ha
)
407 struct Scsi_Host
*host
= ha
->host
;
409 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_fw_dump_attr
);
410 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_nvram_attr
);
411 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_optrom_attr
);
412 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
,
413 &sysfs_optrom_ctl_attr
);
414 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
, &sysfs_vpd_attr
);
415 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
))
416 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
,
419 if (ha
->beacon_blink_led
== 1)
420 ha
->isp_ops
.beacon_off(ha
);
423 /* Scsi_Host attributes. */
426 qla2x00_drvr_version_show(struct class_device
*cdev
, char *buf
)
428 return snprintf(buf
, PAGE_SIZE
, "%s\n", qla2x00_version_str
);
432 qla2x00_fw_version_show(struct class_device
*cdev
, char *buf
)
434 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
437 return snprintf(buf
, PAGE_SIZE
, "%s\n",
438 ha
->isp_ops
.fw_version_str(ha
, fw_str
));
442 qla2x00_serial_num_show(struct class_device
*cdev
, char *buf
)
444 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
447 sn
= ((ha
->serial0
& 0x1f) << 16) | (ha
->serial2
<< 8) | ha
->serial1
;
448 return snprintf(buf
, PAGE_SIZE
, "%c%05d\n", 'A' + sn
/ 100000,
453 qla2x00_isp_name_show(struct class_device
*cdev
, char *buf
)
455 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
456 return snprintf(buf
, PAGE_SIZE
, "ISP%04X\n", ha
->pdev
->device
);
460 qla2x00_isp_id_show(struct class_device
*cdev
, char *buf
)
462 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
463 return snprintf(buf
, PAGE_SIZE
, "%04x %04x %04x %04x\n",
464 ha
->product_id
[0], ha
->product_id
[1], ha
->product_id
[2],
469 qla2x00_model_name_show(struct class_device
*cdev
, char *buf
)
471 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
472 return snprintf(buf
, PAGE_SIZE
, "%s\n", ha
->model_number
);
476 qla2x00_model_desc_show(struct class_device
*cdev
, char *buf
)
478 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
479 return snprintf(buf
, PAGE_SIZE
, "%s\n",
480 ha
->model_desc
? ha
->model_desc
: "");
484 qla2x00_pci_info_show(struct class_device
*cdev
, char *buf
)
486 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
489 return snprintf(buf
, PAGE_SIZE
, "%s\n",
490 ha
->isp_ops
.pci_info_str(ha
, pci_info
));
494 qla2x00_state_show(struct class_device
*cdev
, char *buf
)
496 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
499 if (atomic_read(&ha
->loop_state
) == LOOP_DOWN
||
500 atomic_read(&ha
->loop_state
) == LOOP_DEAD
)
501 len
= snprintf(buf
, PAGE_SIZE
, "Link Down\n");
502 else if (atomic_read(&ha
->loop_state
) != LOOP_READY
||
503 test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
) ||
504 test_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
))
505 len
= snprintf(buf
, PAGE_SIZE
, "Unknown Link State\n");
507 len
= snprintf(buf
, PAGE_SIZE
, "Link Up - ");
509 switch (ha
->current_topology
) {
511 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
514 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "FL_Port\n");
517 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
518 "N_Port to N_Port\n");
521 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "F_Port\n");
524 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
532 qla2x00_zio_show(struct class_device
*cdev
, char *buf
)
534 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
537 switch (ha
->zio_mode
) {
539 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Mode 6\n");
541 case QLA_ZIO_DISABLED
:
542 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
549 qla2x00_zio_store(struct class_device
*cdev
, const char *buf
, size_t count
)
551 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
555 if (!IS_ZIO_SUPPORTED(ha
))
558 if (sscanf(buf
, "%d", &val
) != 1)
562 zio_mode
= QLA_ZIO_MODE_6
;
564 zio_mode
= QLA_ZIO_DISABLED
;
566 /* Update per-hba values and queue a reset. */
567 if (zio_mode
!= QLA_ZIO_DISABLED
|| ha
->zio_mode
!= QLA_ZIO_DISABLED
) {
568 ha
->zio_mode
= zio_mode
;
569 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
575 qla2x00_zio_timer_show(struct class_device
*cdev
, char *buf
)
577 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
579 return snprintf(buf
, PAGE_SIZE
, "%d us\n", ha
->zio_timer
* 100);
583 qla2x00_zio_timer_store(struct class_device
*cdev
, const char *buf
,
586 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
590 if (sscanf(buf
, "%d", &val
) != 1)
592 if (val
> 25500 || val
< 100)
595 zio_timer
= (uint16_t)(val
/ 100);
596 ha
->zio_timer
= zio_timer
;
602 qla2x00_beacon_show(struct class_device
*cdev
, char *buf
)
604 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
607 if (ha
->beacon_blink_led
)
608 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Enabled\n");
610 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
615 qla2x00_beacon_store(struct class_device
*cdev
, const char *buf
,
618 scsi_qla_host_t
*ha
= to_qla_host(class_to_shost(cdev
));
622 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
625 if (test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
)) {
626 qla_printk(KERN_WARNING
, ha
,
627 "Abort ISP active -- ignoring beacon request.\n");
631 if (sscanf(buf
, "%d", &val
) != 1)
635 rval
= ha
->isp_ops
.beacon_on(ha
);
637 rval
= ha
->isp_ops
.beacon_off(ha
);
639 if (rval
!= QLA_SUCCESS
)
645 static CLASS_DEVICE_ATTR(driver_version
, S_IRUGO
, qla2x00_drvr_version_show
,
647 static CLASS_DEVICE_ATTR(fw_version
, S_IRUGO
, qla2x00_fw_version_show
, NULL
);
648 static CLASS_DEVICE_ATTR(serial_num
, S_IRUGO
, qla2x00_serial_num_show
, NULL
);
649 static CLASS_DEVICE_ATTR(isp_name
, S_IRUGO
, qla2x00_isp_name_show
, NULL
);
650 static CLASS_DEVICE_ATTR(isp_id
, S_IRUGO
, qla2x00_isp_id_show
, NULL
);
651 static CLASS_DEVICE_ATTR(model_name
, S_IRUGO
, qla2x00_model_name_show
, NULL
);
652 static CLASS_DEVICE_ATTR(model_desc
, S_IRUGO
, qla2x00_model_desc_show
, NULL
);
653 static CLASS_DEVICE_ATTR(pci_info
, S_IRUGO
, qla2x00_pci_info_show
, NULL
);
654 static CLASS_DEVICE_ATTR(state
, S_IRUGO
, qla2x00_state_show
, NULL
);
655 static CLASS_DEVICE_ATTR(zio
, S_IRUGO
| S_IWUSR
, qla2x00_zio_show
,
657 static CLASS_DEVICE_ATTR(zio_timer
, S_IRUGO
| S_IWUSR
, qla2x00_zio_timer_show
,
658 qla2x00_zio_timer_store
);
659 static CLASS_DEVICE_ATTR(beacon
, S_IRUGO
| S_IWUSR
, qla2x00_beacon_show
,
660 qla2x00_beacon_store
);
662 struct class_device_attribute
*qla2x00_host_attrs
[] = {
663 &class_device_attr_driver_version
,
664 &class_device_attr_fw_version
,
665 &class_device_attr_serial_num
,
666 &class_device_attr_isp_name
,
667 &class_device_attr_isp_id
,
668 &class_device_attr_model_name
,
669 &class_device_attr_model_desc
,
670 &class_device_attr_pci_info
,
671 &class_device_attr_state
,
672 &class_device_attr_zio
,
673 &class_device_attr_zio_timer
,
674 &class_device_attr_beacon
,
678 /* Host attributes. */
681 qla2x00_get_host_port_id(struct Scsi_Host
*shost
)
683 scsi_qla_host_t
*ha
= to_qla_host(shost
);
685 fc_host_port_id(shost
) = ha
->d_id
.b
.domain
<< 16 |
686 ha
->d_id
.b
.area
<< 8 | ha
->d_id
.b
.al_pa
;
690 qla2x00_get_host_speed(struct Scsi_Host
*shost
)
692 scsi_qla_host_t
*ha
= to_qla_host(shost
);
695 switch (ha
->link_data_rate
) {
706 fc_host_speed(shost
) = speed
;
710 qla2x00_get_host_port_type(struct Scsi_Host
*shost
)
712 scsi_qla_host_t
*ha
= to_qla_host(shost
);
713 uint32_t port_type
= FC_PORTTYPE_UNKNOWN
;
715 switch (ha
->current_topology
) {
717 port_type
= FC_PORTTYPE_LPORT
;
720 port_type
= FC_PORTTYPE_NLPORT
;
723 port_type
= FC_PORTTYPE_PTP
;
726 port_type
= FC_PORTTYPE_NPORT
;
729 fc_host_port_type(shost
) = port_type
;
733 qla2x00_get_starget_node_name(struct scsi_target
*starget
)
735 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
736 scsi_qla_host_t
*ha
= to_qla_host(host
);
740 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
741 if (starget
->id
== fcport
->os_target_id
) {
742 node_name
= wwn_to_u64(fcport
->node_name
);
747 fc_starget_node_name(starget
) = node_name
;
751 qla2x00_get_starget_port_name(struct scsi_target
*starget
)
753 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
754 scsi_qla_host_t
*ha
= to_qla_host(host
);
758 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
759 if (starget
->id
== fcport
->os_target_id
) {
760 port_name
= wwn_to_u64(fcport
->port_name
);
765 fc_starget_port_name(starget
) = port_name
;
769 qla2x00_get_starget_port_id(struct scsi_target
*starget
)
771 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
772 scsi_qla_host_t
*ha
= to_qla_host(host
);
774 uint32_t port_id
= ~0U;
776 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
777 if (starget
->id
== fcport
->os_target_id
) {
778 port_id
= fcport
->d_id
.b
.domain
<< 16 |
779 fcport
->d_id
.b
.area
<< 8 | fcport
->d_id
.b
.al_pa
;
784 fc_starget_port_id(starget
) = port_id
;
788 qla2x00_get_rport_loss_tmo(struct fc_rport
*rport
)
790 struct Scsi_Host
*host
= rport_to_shost(rport
);
791 scsi_qla_host_t
*ha
= to_qla_host(host
);
793 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
797 qla2x00_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
799 struct Scsi_Host
*host
= rport_to_shost(rport
);
800 scsi_qla_host_t
*ha
= to_qla_host(host
);
803 ha
->port_down_retry_count
= timeout
;
805 ha
->port_down_retry_count
= 1;
807 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
811 qla2x00_issue_lip(struct Scsi_Host
*shost
)
813 scsi_qla_host_t
*ha
= to_qla_host(shost
);
815 set_bit(LOOP_RESET_NEEDED
, &ha
->dpc_flags
);
819 static struct fc_host_statistics
*
820 qla2x00_get_fc_host_stats(struct Scsi_Host
*shost
)
822 scsi_qla_host_t
*ha
= to_qla_host(shost
);
825 link_stat_t stat_buf
;
826 struct fc_host_statistics
*pfc_host_stat
;
828 pfc_host_stat
= &ha
->fc_host_stat
;
829 memset(pfc_host_stat
, -1, sizeof(struct fc_host_statistics
));
831 if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
832 rval
= qla24xx_get_isp_stats(ha
, (uint32_t *)&stat_buf
,
833 sizeof(stat_buf
) / 4, mb_stat
);
835 rval
= qla2x00_get_link_status(ha
, ha
->loop_id
, &stat_buf
,
839 qla_printk(KERN_WARNING
, ha
,
840 "Unable to retrieve host statistics (%d).\n", mb_stat
[0]);
841 return pfc_host_stat
;
844 pfc_host_stat
->link_failure_count
= stat_buf
.link_fail_cnt
;
845 pfc_host_stat
->loss_of_sync_count
= stat_buf
.loss_sync_cnt
;
846 pfc_host_stat
->loss_of_signal_count
= stat_buf
.loss_sig_cnt
;
847 pfc_host_stat
->prim_seq_protocol_err_count
= stat_buf
.prim_seq_err_cnt
;
848 pfc_host_stat
->invalid_tx_word_count
= stat_buf
.inval_xmit_word_cnt
;
849 pfc_host_stat
->invalid_crc_count
= stat_buf
.inval_crc_cnt
;
851 return pfc_host_stat
;
854 struct fc_function_template qla2xxx_transport_functions
= {
856 .show_host_node_name
= 1,
857 .show_host_port_name
= 1,
858 .show_host_supported_classes
= 1,
860 .get_host_port_id
= qla2x00_get_host_port_id
,
861 .show_host_port_id
= 1,
862 .get_host_speed
= qla2x00_get_host_speed
,
863 .show_host_speed
= 1,
864 .get_host_port_type
= qla2x00_get_host_port_type
,
865 .show_host_port_type
= 1,
867 .dd_fcrport_size
= sizeof(struct fc_port
*),
868 .show_rport_supported_classes
= 1,
870 .get_starget_node_name
= qla2x00_get_starget_node_name
,
871 .show_starget_node_name
= 1,
872 .get_starget_port_name
= qla2x00_get_starget_port_name
,
873 .show_starget_port_name
= 1,
874 .get_starget_port_id
= qla2x00_get_starget_port_id
,
875 .show_starget_port_id
= 1,
877 .get_rport_dev_loss_tmo
= qla2x00_get_rport_loss_tmo
,
878 .set_rport_dev_loss_tmo
= qla2x00_set_rport_loss_tmo
,
879 .show_rport_dev_loss_tmo
= 1,
881 .issue_fc_host_lip
= qla2x00_issue_lip
,
882 .get_fc_host_stats
= qla2x00_get_fc_host_stats
,
886 qla2x00_init_host_attr(scsi_qla_host_t
*ha
)
888 fc_host_node_name(ha
->host
) = wwn_to_u64(ha
->node_name
);
889 fc_host_port_name(ha
->host
) = wwn_to_u64(ha
->port_name
);
890 fc_host_supported_classes(ha
->host
) = FC_COS_CLASS3
;