2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2011 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/kthread.h>
10 #include <linux/vmalloc.h>
11 #include <linux/slab.h>
12 #include <linux/delay.h>
14 static int qla24xx_vport_disable(struct fc_vport
*, bool);
16 /* SYSFS attributes --------------------------------------------------------- */
19 qla2x00_sysfs_read_fw_dump(struct file
*filp
, struct kobject
*kobj
,
20 struct bin_attribute
*bin_attr
,
21 char *buf
, loff_t off
, size_t count
)
23 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
24 struct device
, kobj
)));
25 struct qla_hw_data
*ha
= vha
->hw
;
28 if (ha
->fw_dump_reading
== 0)
32 if (off
< ha
->md_template_size
) {
33 rval
= memory_read_from_buffer(buf
, count
,
34 &off
, ha
->md_tmplt_hdr
, ha
->md_template_size
);
37 off
-= ha
->md_template_size
;
38 rval
= memory_read_from_buffer(buf
, count
,
39 &off
, ha
->md_dump
, ha
->md_dump_size
);
42 return memory_read_from_buffer(buf
, count
, &off
, ha
->fw_dump
,
47 qla2x00_sysfs_write_fw_dump(struct file
*filp
, struct kobject
*kobj
,
48 struct bin_attribute
*bin_attr
,
49 char *buf
, loff_t off
, size_t count
)
51 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
52 struct device
, kobj
)));
53 struct qla_hw_data
*ha
= vha
->hw
;
59 reading
= simple_strtol(buf
, NULL
, 10);
62 if (!ha
->fw_dump_reading
)
65 ql_log(ql_log_info
, vha
, 0x705d,
66 "Firmware dump cleared on (%ld).\n", vha
->host_no
);
68 if (IS_QLA82XX(vha
->hw
)) {
72 ha
->fw_dump_reading
= 0;
76 if (ha
->fw_dumped
&& !ha
->fw_dump_reading
) {
77 ha
->fw_dump_reading
= 1;
79 ql_log(ql_log_info
, vha
, 0x705e,
80 "Raw firmware dump ready for read on (%ld).\n",
85 qla2x00_alloc_fw_dump(vha
);
90 qla82xx_set_reset_owner(vha
);
91 qla82xx_idc_unlock(ha
);
93 qla2x00_system_error(vha
);
98 ql_dbg(ql_dbg_user
, vha
, 0x705b,
99 "MiniDump supported with this firmware.\n");
101 ql_dbg(ql_dbg_user
, vha
, 0x709d,
102 "MiniDump not supported with this firmware.\n");
107 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
113 static struct bin_attribute sysfs_fw_dump_attr
= {
116 .mode
= S_IRUSR
| S_IWUSR
,
119 .read
= qla2x00_sysfs_read_fw_dump
,
120 .write
= qla2x00_sysfs_write_fw_dump
,
124 qla2x00_sysfs_read_nvram(struct file
*filp
, struct kobject
*kobj
,
125 struct bin_attribute
*bin_attr
,
126 char *buf
, loff_t off
, size_t count
)
128 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
129 struct device
, kobj
)));
130 struct qla_hw_data
*ha
= vha
->hw
;
132 if (!capable(CAP_SYS_ADMIN
))
135 if (IS_NOCACHE_VPD_TYPE(ha
))
136 ha
->isp_ops
->read_optrom(vha
, ha
->nvram
, ha
->flt_region_nvram
<< 2,
138 return memory_read_from_buffer(buf
, count
, &off
, ha
->nvram
,
143 qla2x00_sysfs_write_nvram(struct file
*filp
, struct kobject
*kobj
,
144 struct bin_attribute
*bin_attr
,
145 char *buf
, loff_t off
, size_t count
)
147 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
148 struct device
, kobj
)));
149 struct qla_hw_data
*ha
= vha
->hw
;
152 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= ha
->nvram_size
||
153 !ha
->isp_ops
->write_nvram
)
156 /* Checksum NVRAM. */
157 if (IS_FWI2_CAPABLE(ha
)) {
161 iter
= (uint32_t *)buf
;
163 for (cnt
= 0; cnt
< ((count
>> 2) - 1); cnt
++)
164 chksum
+= le32_to_cpu(*iter
++);
165 chksum
= ~chksum
+ 1;
166 *iter
= cpu_to_le32(chksum
);
171 iter
= (uint8_t *)buf
;
173 for (cnt
= 0; cnt
< count
- 1; cnt
++)
175 chksum
= ~chksum
+ 1;
179 if (qla2x00_wait_for_hba_online(vha
) != QLA_SUCCESS
) {
180 ql_log(ql_log_warn
, vha
, 0x705f,
181 "HBA not online, failing NVRAM update.\n");
186 ha
->isp_ops
->write_nvram(vha
, (uint8_t *)buf
, ha
->nvram_base
, count
);
187 ha
->isp_ops
->read_nvram(vha
, (uint8_t *)ha
->nvram
, ha
->nvram_base
,
190 ql_dbg(ql_dbg_user
, vha
, 0x7060,
191 "Setting ISP_ABORT_NEEDED\n");
192 /* NVRAM settings take effect immediately. */
193 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
194 qla2xxx_wake_dpc(vha
);
195 qla2x00_wait_for_chip_reset(vha
);
200 static struct bin_attribute sysfs_nvram_attr
= {
203 .mode
= S_IRUSR
| S_IWUSR
,
206 .read
= qla2x00_sysfs_read_nvram
,
207 .write
= qla2x00_sysfs_write_nvram
,
211 qla2x00_sysfs_read_optrom(struct file
*filp
, struct kobject
*kobj
,
212 struct bin_attribute
*bin_attr
,
213 char *buf
, loff_t off
, size_t count
)
215 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
216 struct device
, kobj
)));
217 struct qla_hw_data
*ha
= vha
->hw
;
219 if (ha
->optrom_state
!= QLA_SREADING
)
222 return memory_read_from_buffer(buf
, count
, &off
, ha
->optrom_buffer
,
223 ha
->optrom_region_size
);
227 qla2x00_sysfs_write_optrom(struct file
*filp
, struct kobject
*kobj
,
228 struct bin_attribute
*bin_attr
,
229 char *buf
, loff_t off
, size_t count
)
231 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
232 struct device
, kobj
)));
233 struct qla_hw_data
*ha
= vha
->hw
;
235 if (ha
->optrom_state
!= QLA_SWRITING
)
237 if (off
> ha
->optrom_region_size
)
239 if (off
+ count
> ha
->optrom_region_size
)
240 count
= ha
->optrom_region_size
- off
;
242 memcpy(&ha
->optrom_buffer
[off
], buf
, count
);
247 static struct bin_attribute sysfs_optrom_attr
= {
250 .mode
= S_IRUSR
| S_IWUSR
,
253 .read
= qla2x00_sysfs_read_optrom
,
254 .write
= qla2x00_sysfs_write_optrom
,
258 qla2x00_sysfs_write_optrom_ctl(struct file
*filp
, struct kobject
*kobj
,
259 struct bin_attribute
*bin_attr
,
260 char *buf
, loff_t off
, size_t count
)
262 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
263 struct device
, kobj
)));
264 struct qla_hw_data
*ha
= vha
->hw
;
267 uint32_t size
= ha
->optrom_size
;
273 if (unlikely(pci_channel_offline(ha
->pdev
)))
276 if (sscanf(buf
, "%d:%x:%x", &val
, &start
, &size
) < 1)
278 if (start
> ha
->optrom_size
)
283 if (ha
->optrom_state
!= QLA_SREADING
&&
284 ha
->optrom_state
!= QLA_SWRITING
)
287 ha
->optrom_state
= QLA_SWAITING
;
289 ql_dbg(ql_dbg_user
, vha
, 0x7061,
290 "Freeing flash region allocation -- 0x%x bytes.\n",
291 ha
->optrom_region_size
);
293 vfree(ha
->optrom_buffer
);
294 ha
->optrom_buffer
= NULL
;
297 if (ha
->optrom_state
!= QLA_SWAITING
)
300 ha
->optrom_region_start
= start
;
301 ha
->optrom_region_size
= start
+ size
> ha
->optrom_size
?
302 ha
->optrom_size
- start
: size
;
304 ha
->optrom_state
= QLA_SREADING
;
305 ha
->optrom_buffer
= vmalloc(ha
->optrom_region_size
);
306 if (ha
->optrom_buffer
== NULL
) {
307 ql_log(ql_log_warn
, vha
, 0x7062,
308 "Unable to allocate memory for optrom retrieval "
309 "(%x).\n", ha
->optrom_region_size
);
311 ha
->optrom_state
= QLA_SWAITING
;
315 if (qla2x00_wait_for_hba_online(vha
) != QLA_SUCCESS
) {
316 ql_log(ql_log_warn
, vha
, 0x7063,
317 "HBA not online, failing NVRAM update.\n");
321 ql_dbg(ql_dbg_user
, vha
, 0x7064,
322 "Reading flash region -- 0x%x/0x%x.\n",
323 ha
->optrom_region_start
, ha
->optrom_region_size
);
325 memset(ha
->optrom_buffer
, 0, ha
->optrom_region_size
);
326 ha
->isp_ops
->read_optrom(vha
, ha
->optrom_buffer
,
327 ha
->optrom_region_start
, ha
->optrom_region_size
);
330 if (ha
->optrom_state
!= QLA_SWAITING
)
334 * We need to be more restrictive on which FLASH regions are
335 * allowed to be updated via user-space. Regions accessible
336 * via this method include:
338 * ISP21xx/ISP22xx/ISP23xx type boards:
340 * 0x000000 -> 0x020000 -- Boot code.
342 * ISP2322/ISP24xx type boards:
344 * 0x000000 -> 0x07ffff -- Boot code.
345 * 0x080000 -> 0x0fffff -- Firmware.
347 * ISP25xx type boards:
349 * 0x000000 -> 0x07ffff -- Boot code.
350 * 0x080000 -> 0x0fffff -- Firmware.
351 * 0x120000 -> 0x12ffff -- VPD and HBA parameters.
354 if (ha
->optrom_size
== OPTROM_SIZE_2300
&& start
== 0)
356 else if (start
== (ha
->flt_region_boot
* 4) ||
357 start
== (ha
->flt_region_fw
* 4))
359 else if (IS_QLA25XX(ha
) || IS_QLA8XXX_TYPE(ha
))
362 ql_log(ql_log_warn
, vha
, 0x7065,
363 "Invalid start region 0x%x/0x%x.\n", start
, size
);
367 ha
->optrom_region_start
= start
;
368 ha
->optrom_region_size
= start
+ size
> ha
->optrom_size
?
369 ha
->optrom_size
- start
: size
;
371 ha
->optrom_state
= QLA_SWRITING
;
372 ha
->optrom_buffer
= vmalloc(ha
->optrom_region_size
);
373 if (ha
->optrom_buffer
== NULL
) {
374 ql_log(ql_log_warn
, vha
, 0x7066,
375 "Unable to allocate memory for optrom update "
376 "(%x)\n", ha
->optrom_region_size
);
378 ha
->optrom_state
= QLA_SWAITING
;
382 ql_dbg(ql_dbg_user
, vha
, 0x7067,
383 "Staging flash region write -- 0x%x/0x%x.\n",
384 ha
->optrom_region_start
, ha
->optrom_region_size
);
386 memset(ha
->optrom_buffer
, 0, ha
->optrom_region_size
);
389 if (ha
->optrom_state
!= QLA_SWRITING
)
392 if (qla2x00_wait_for_hba_online(vha
) != QLA_SUCCESS
) {
393 ql_log(ql_log_warn
, vha
, 0x7068,
394 "HBA not online, failing flash update.\n");
398 ql_dbg(ql_dbg_user
, vha
, 0x7069,
399 "Writing flash region -- 0x%x/0x%x.\n",
400 ha
->optrom_region_start
, ha
->optrom_region_size
);
402 ha
->isp_ops
->write_optrom(vha
, ha
->optrom_buffer
,
403 ha
->optrom_region_start
, ha
->optrom_region_size
);
411 static struct bin_attribute sysfs_optrom_ctl_attr
= {
413 .name
= "optrom_ctl",
417 .write
= qla2x00_sysfs_write_optrom_ctl
,
421 qla2x00_sysfs_read_vpd(struct file
*filp
, struct kobject
*kobj
,
422 struct bin_attribute
*bin_attr
,
423 char *buf
, loff_t off
, size_t count
)
425 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
426 struct device
, kobj
)));
427 struct qla_hw_data
*ha
= vha
->hw
;
429 if (unlikely(pci_channel_offline(ha
->pdev
)))
432 if (!capable(CAP_SYS_ADMIN
))
435 if (IS_NOCACHE_VPD_TYPE(ha
))
436 ha
->isp_ops
->read_optrom(vha
, ha
->vpd
, ha
->flt_region_vpd
<< 2,
438 return memory_read_from_buffer(buf
, count
, &off
, ha
->vpd
, ha
->vpd_size
);
442 qla2x00_sysfs_write_vpd(struct file
*filp
, struct kobject
*kobj
,
443 struct bin_attribute
*bin_attr
,
444 char *buf
, loff_t off
, size_t count
)
446 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
447 struct device
, kobj
)));
448 struct qla_hw_data
*ha
= vha
->hw
;
451 if (unlikely(pci_channel_offline(ha
->pdev
)))
454 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= ha
->vpd_size
||
455 !ha
->isp_ops
->write_nvram
)
458 if (qla2x00_wait_for_hba_online(vha
) != QLA_SUCCESS
) {
459 ql_log(ql_log_warn
, vha
, 0x706a,
460 "HBA not online, failing VPD update.\n");
465 ha
->isp_ops
->write_nvram(vha
, (uint8_t *)buf
, ha
->vpd_base
, count
);
466 ha
->isp_ops
->read_nvram(vha
, (uint8_t *)ha
->vpd
, ha
->vpd_base
, count
);
468 /* Update flash version information for 4Gb & above. */
469 if (!IS_FWI2_CAPABLE(ha
))
472 tmp_data
= vmalloc(256);
474 ql_log(ql_log_warn
, vha
, 0x706b,
475 "Unable to allocate memory for VPD information update.\n");
478 ha
->isp_ops
->get_flash_version(vha
, tmp_data
);
484 static struct bin_attribute sysfs_vpd_attr
= {
487 .mode
= S_IRUSR
| S_IWUSR
,
490 .read
= qla2x00_sysfs_read_vpd
,
491 .write
= qla2x00_sysfs_write_vpd
,
495 qla2x00_sysfs_read_sfp(struct file
*filp
, struct kobject
*kobj
,
496 struct bin_attribute
*bin_attr
,
497 char *buf
, loff_t off
, size_t count
)
499 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
500 struct device
, kobj
)));
501 struct qla_hw_data
*ha
= vha
->hw
;
502 uint16_t iter
, addr
, offset
;
505 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
!= SFP_DEV_SIZE
* 2)
511 ha
->sfp_data
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
,
514 ql_log(ql_log_warn
, vha
, 0x706c,
515 "Unable to allocate memory for SFP read-data.\n");
520 memset(ha
->sfp_data
, 0, SFP_BLOCK_SIZE
);
522 for (iter
= 0, offset
= 0; iter
< (SFP_DEV_SIZE
* 2) / SFP_BLOCK_SIZE
;
523 iter
++, offset
+= SFP_BLOCK_SIZE
) {
525 /* Skip to next device address. */
530 rval
= qla2x00_read_sfp(vha
, ha
->sfp_data_dma
, ha
->sfp_data
,
531 addr
, offset
, SFP_BLOCK_SIZE
, 0);
532 if (rval
!= QLA_SUCCESS
) {
533 ql_log(ql_log_warn
, vha
, 0x706d,
534 "Unable to read SFP data (%x/%x/%x).\n", rval
,
539 memcpy(buf
, ha
->sfp_data
, SFP_BLOCK_SIZE
);
540 buf
+= SFP_BLOCK_SIZE
;
546 static struct bin_attribute sysfs_sfp_attr
= {
549 .mode
= S_IRUSR
| S_IWUSR
,
551 .size
= SFP_DEV_SIZE
* 2,
552 .read
= qla2x00_sysfs_read_sfp
,
556 qla2x00_sysfs_write_reset(struct file
*filp
, struct kobject
*kobj
,
557 struct bin_attribute
*bin_attr
,
558 char *buf
, loff_t off
, size_t count
)
560 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
561 struct device
, kobj
)));
562 struct qla_hw_data
*ha
= vha
->hw
;
563 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
569 type
= simple_strtol(buf
, NULL
, 10);
572 ql_log(ql_log_info
, vha
, 0x706e,
573 "Issuing ISP reset.\n");
575 scsi_block_requests(vha
->host
);
576 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
577 if (IS_QLA82XX(ha
)) {
578 qla82xx_idc_lock(ha
);
579 qla82xx_set_reset_owner(vha
);
580 qla82xx_idc_unlock(ha
);
582 qla2xxx_wake_dpc(vha
);
583 qla2x00_wait_for_chip_reset(vha
);
584 scsi_unblock_requests(vha
->host
);
590 ql_log(ql_log_info
, vha
, 0x706f,
591 "Issuing MPI reset.\n");
593 /* Make sure FC side is not in reset */
594 qla2x00_wait_for_hba_online(vha
);
596 /* Issue MPI reset */
597 scsi_block_requests(vha
->host
);
598 if (qla81xx_restart_mpi_firmware(vha
) != QLA_SUCCESS
)
599 ql_log(ql_log_warn
, vha
, 0x7070,
600 "MPI reset failed.\n");
601 scsi_unblock_requests(vha
->host
);
604 if (!IS_QLA82XX(ha
) || vha
!= base_vha
) {
605 ql_log(ql_log_info
, vha
, 0x7071,
606 "FCoE ctx reset no supported.\n");
610 ql_log(ql_log_info
, vha
, 0x7072,
611 "Issuing FCoE ctx reset.\n");
612 set_bit(FCOE_CTX_RESET_NEEDED
, &vha
->dpc_flags
);
613 qla2xxx_wake_dpc(vha
);
614 qla2x00_wait_for_fcoe_ctx_reset(vha
);
620 static struct bin_attribute sysfs_reset_attr
= {
626 .write
= qla2x00_sysfs_write_reset
,
630 qla2x00_sysfs_write_edc(struct file
*filp
, struct kobject
*kobj
,
631 struct bin_attribute
*bin_attr
,
632 char *buf
, loff_t off
, size_t count
)
634 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
635 struct device
, kobj
)));
636 struct qla_hw_data
*ha
= vha
->hw
;
637 uint16_t dev
, adr
, opt
, len
;
640 ha
->edc_data_len
= 0;
642 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
< 8)
646 ha
->edc_data
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
,
649 ql_log(ql_log_warn
, vha
, 0x7073,
650 "Unable to allocate memory for EDC write.\n");
655 dev
= le16_to_cpup((void *)&buf
[0]);
656 adr
= le16_to_cpup((void *)&buf
[2]);
657 opt
= le16_to_cpup((void *)&buf
[4]);
658 len
= le16_to_cpup((void *)&buf
[6]);
661 if (len
== 0 || len
> DMA_POOL_SIZE
|| len
> count
- 8)
664 memcpy(ha
->edc_data
, &buf
[8], len
);
666 rval
= qla2x00_write_sfp(vha
, ha
->edc_data_dma
, ha
->edc_data
,
668 if (rval
!= QLA_SUCCESS
) {
669 ql_log(ql_log_warn
, vha
, 0x7074,
670 "Unable to write EDC (%x) %02x:%04x:%02x:%02hhx\n",
671 rval
, dev
, adr
, opt
, len
, buf
[8]);
678 static struct bin_attribute sysfs_edc_attr
= {
684 .write
= qla2x00_sysfs_write_edc
,
688 qla2x00_sysfs_write_edc_status(struct file
*filp
, struct kobject
*kobj
,
689 struct bin_attribute
*bin_attr
,
690 char *buf
, loff_t off
, size_t count
)
692 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
693 struct device
, kobj
)));
694 struct qla_hw_data
*ha
= vha
->hw
;
695 uint16_t dev
, adr
, opt
, len
;
698 ha
->edc_data_len
= 0;
700 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
< 8)
704 ha
->edc_data
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
,
707 ql_log(ql_log_warn
, vha
, 0x708c,
708 "Unable to allocate memory for EDC status.\n");
713 dev
= le16_to_cpup((void *)&buf
[0]);
714 adr
= le16_to_cpup((void *)&buf
[2]);
715 opt
= le16_to_cpup((void *)&buf
[4]);
716 len
= le16_to_cpup((void *)&buf
[6]);
719 if (len
== 0 || len
> DMA_POOL_SIZE
)
722 memset(ha
->edc_data
, 0, len
);
723 rval
= qla2x00_read_sfp(vha
, ha
->edc_data_dma
, ha
->edc_data
,
725 if (rval
!= QLA_SUCCESS
) {
726 ql_log(ql_log_info
, vha
, 0x7075,
727 "Unable to write EDC status (%x) %02x:%04x:%02x.\n",
728 rval
, dev
, adr
, opt
, len
);
732 ha
->edc_data_len
= len
;
738 qla2x00_sysfs_read_edc_status(struct file
*filp
, struct kobject
*kobj
,
739 struct bin_attribute
*bin_attr
,
740 char *buf
, loff_t off
, size_t count
)
742 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
743 struct device
, kobj
)));
744 struct qla_hw_data
*ha
= vha
->hw
;
746 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
== 0)
749 if (!ha
->edc_data
|| ha
->edc_data_len
== 0 || ha
->edc_data_len
> count
)
752 memcpy(buf
, ha
->edc_data
, ha
->edc_data_len
);
754 return ha
->edc_data_len
;
757 static struct bin_attribute sysfs_edc_status_attr
= {
759 .name
= "edc_status",
760 .mode
= S_IRUSR
| S_IWUSR
,
763 .write
= qla2x00_sysfs_write_edc_status
,
764 .read
= qla2x00_sysfs_read_edc_status
,
768 qla2x00_sysfs_read_xgmac_stats(struct file
*filp
, struct kobject
*kobj
,
769 struct bin_attribute
*bin_attr
,
770 char *buf
, loff_t off
, size_t count
)
772 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
773 struct device
, kobj
)));
774 struct qla_hw_data
*ha
= vha
->hw
;
776 uint16_t actual_size
;
778 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
> XGMAC_DATA_SIZE
)
784 ha
->xgmac_data
= dma_alloc_coherent(&ha
->pdev
->dev
, XGMAC_DATA_SIZE
,
785 &ha
->xgmac_data_dma
, GFP_KERNEL
);
786 if (!ha
->xgmac_data
) {
787 ql_log(ql_log_warn
, vha
, 0x7076,
788 "Unable to allocate memory for XGMAC read-data.\n");
794 memset(ha
->xgmac_data
, 0, XGMAC_DATA_SIZE
);
796 rval
= qla2x00_get_xgmac_stats(vha
, ha
->xgmac_data_dma
,
797 XGMAC_DATA_SIZE
, &actual_size
);
798 if (rval
!= QLA_SUCCESS
) {
799 ql_log(ql_log_warn
, vha
, 0x7077,
800 "Unable to read XGMAC data (%x).\n", rval
);
804 count
= actual_size
> count
? count
: actual_size
;
805 memcpy(buf
, ha
->xgmac_data
, count
);
810 static struct bin_attribute sysfs_xgmac_stats_attr
= {
812 .name
= "xgmac_stats",
816 .read
= qla2x00_sysfs_read_xgmac_stats
,
820 qla2x00_sysfs_read_dcbx_tlv(struct file
*filp
, struct kobject
*kobj
,
821 struct bin_attribute
*bin_attr
,
822 char *buf
, loff_t off
, size_t count
)
824 struct scsi_qla_host
*vha
= shost_priv(dev_to_shost(container_of(kobj
,
825 struct device
, kobj
)));
826 struct qla_hw_data
*ha
= vha
->hw
;
828 uint16_t actual_size
;
830 if (!capable(CAP_SYS_ADMIN
) || off
!= 0 || count
> DCBX_TLV_DATA_SIZE
)
836 ha
->dcbx_tlv
= dma_alloc_coherent(&ha
->pdev
->dev
, DCBX_TLV_DATA_SIZE
,
837 &ha
->dcbx_tlv_dma
, GFP_KERNEL
);
839 ql_log(ql_log_warn
, vha
, 0x7078,
840 "Unable to allocate memory for DCBX TLV read-data.\n");
846 memset(ha
->dcbx_tlv
, 0, DCBX_TLV_DATA_SIZE
);
848 rval
= qla2x00_get_dcbx_params(vha
, ha
->dcbx_tlv_dma
,
850 if (rval
!= QLA_SUCCESS
) {
851 ql_log(ql_log_warn
, vha
, 0x7079,
852 "Unable to read DCBX TLV (%x).\n", rval
);
856 memcpy(buf
, ha
->dcbx_tlv
, count
);
861 static struct bin_attribute sysfs_dcbx_tlv_attr
= {
867 .read
= qla2x00_sysfs_read_dcbx_tlv
,
870 static struct sysfs_entry
{
872 struct bin_attribute
*attr
;
874 } bin_file_entries
[] = {
875 { "fw_dump", &sysfs_fw_dump_attr
, },
876 { "nvram", &sysfs_nvram_attr
, },
877 { "optrom", &sysfs_optrom_attr
, },
878 { "optrom_ctl", &sysfs_optrom_ctl_attr
, },
879 { "vpd", &sysfs_vpd_attr
, 1 },
880 { "sfp", &sysfs_sfp_attr
, 1 },
881 { "reset", &sysfs_reset_attr
, },
882 { "edc", &sysfs_edc_attr
, 2 },
883 { "edc_status", &sysfs_edc_status_attr
, 2 },
884 { "xgmac_stats", &sysfs_xgmac_stats_attr
, 3 },
885 { "dcbx_tlv", &sysfs_dcbx_tlv_attr
, 3 },
890 qla2x00_alloc_sysfs_attr(scsi_qla_host_t
*vha
)
892 struct Scsi_Host
*host
= vha
->host
;
893 struct sysfs_entry
*iter
;
896 for (iter
= bin_file_entries
; iter
->name
; iter
++) {
897 if (iter
->is4GBp_only
&& !IS_FWI2_CAPABLE(vha
->hw
))
899 if (iter
->is4GBp_only
== 2 && !IS_QLA25XX(vha
->hw
))
901 if (iter
->is4GBp_only
== 3 && !(IS_QLA8XXX_TYPE(vha
->hw
)))
904 ret
= sysfs_create_bin_file(&host
->shost_gendev
.kobj
,
907 ql_log(ql_log_warn
, vha
, 0x00f3,
908 "Unable to create sysfs %s binary attribute (%d).\n",
911 ql_dbg(ql_dbg_init
, vha
, 0x00f4,
912 "Successfully created sysfs %s binary attribure.\n",
918 qla2x00_free_sysfs_attr(scsi_qla_host_t
*vha
)
920 struct Scsi_Host
*host
= vha
->host
;
921 struct sysfs_entry
*iter
;
922 struct qla_hw_data
*ha
= vha
->hw
;
924 for (iter
= bin_file_entries
; iter
->name
; iter
++) {
925 if (iter
->is4GBp_only
&& !IS_FWI2_CAPABLE(ha
))
927 if (iter
->is4GBp_only
== 2 && !IS_QLA25XX(ha
))
929 if (iter
->is4GBp_only
== 3 && !!(IS_QLA8XXX_TYPE(vha
->hw
)))
932 sysfs_remove_bin_file(&host
->shost_gendev
.kobj
,
936 if (ha
->beacon_blink_led
== 1)
937 ha
->isp_ops
->beacon_off(vha
);
940 /* Scsi_Host attributes. */
943 qla2x00_drvr_version_show(struct device
*dev
,
944 struct device_attribute
*attr
, char *buf
)
946 return snprintf(buf
, PAGE_SIZE
, "%s\n", qla2x00_version_str
);
950 qla2x00_fw_version_show(struct device
*dev
,
951 struct device_attribute
*attr
, char *buf
)
953 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
954 struct qla_hw_data
*ha
= vha
->hw
;
957 return snprintf(buf
, PAGE_SIZE
, "%s\n",
958 ha
->isp_ops
->fw_version_str(vha
, fw_str
));
962 qla2x00_serial_num_show(struct device
*dev
, struct device_attribute
*attr
,
965 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
966 struct qla_hw_data
*ha
= vha
->hw
;
969 if (IS_FWI2_CAPABLE(ha
)) {
970 qla2xxx_get_vpd_field(vha
, "SN", buf
, PAGE_SIZE
);
971 return snprintf(buf
, PAGE_SIZE
, "%s\n", buf
);
974 sn
= ((ha
->serial0
& 0x1f) << 16) | (ha
->serial2
<< 8) | ha
->serial1
;
975 return snprintf(buf
, PAGE_SIZE
, "%c%05d\n", 'A' + sn
/ 100000,
980 qla2x00_isp_name_show(struct device
*dev
, struct device_attribute
*attr
,
983 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
984 return snprintf(buf
, PAGE_SIZE
, "ISP%04X\n", vha
->hw
->pdev
->device
);
988 qla2x00_isp_id_show(struct device
*dev
, struct device_attribute
*attr
,
991 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
992 struct qla_hw_data
*ha
= vha
->hw
;
993 return snprintf(buf
, PAGE_SIZE
, "%04x %04x %04x %04x\n",
994 ha
->product_id
[0], ha
->product_id
[1], ha
->product_id
[2],
999 qla2x00_model_name_show(struct device
*dev
, struct device_attribute
*attr
,
1002 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1003 return snprintf(buf
, PAGE_SIZE
, "%s\n", vha
->hw
->model_number
);
1007 qla2x00_model_desc_show(struct device
*dev
, struct device_attribute
*attr
,
1010 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1011 return snprintf(buf
, PAGE_SIZE
, "%s\n",
1012 vha
->hw
->model_desc
? vha
->hw
->model_desc
: "");
1016 qla2x00_pci_info_show(struct device
*dev
, struct device_attribute
*attr
,
1019 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1022 return snprintf(buf
, PAGE_SIZE
, "%s\n",
1023 vha
->hw
->isp_ops
->pci_info_str(vha
, pci_info
));
1027 qla2x00_link_state_show(struct device
*dev
, struct device_attribute
*attr
,
1030 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1031 struct qla_hw_data
*ha
= vha
->hw
;
1034 if (atomic_read(&vha
->loop_state
) == LOOP_DOWN
||
1035 atomic_read(&vha
->loop_state
) == LOOP_DEAD
||
1036 vha
->device_flags
& DFLG_NO_CABLE
)
1037 len
= snprintf(buf
, PAGE_SIZE
, "Link Down\n");
1038 else if (atomic_read(&vha
->loop_state
) != LOOP_READY
||
1039 test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) ||
1040 test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
))
1041 len
= snprintf(buf
, PAGE_SIZE
, "Unknown Link State\n");
1043 len
= snprintf(buf
, PAGE_SIZE
, "Link Up - ");
1045 switch (ha
->current_topology
) {
1047 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
1050 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "FL_Port\n");
1053 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1054 "N_Port to N_Port\n");
1057 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "F_Port\n");
1060 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Loop\n");
1068 qla2x00_zio_show(struct device
*dev
, struct device_attribute
*attr
,
1071 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1074 switch (vha
->hw
->zio_mode
) {
1075 case QLA_ZIO_MODE_6
:
1076 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Mode 6\n");
1078 case QLA_ZIO_DISABLED
:
1079 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
1086 qla2x00_zio_store(struct device
*dev
, struct device_attribute
*attr
,
1087 const char *buf
, size_t count
)
1089 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1090 struct qla_hw_data
*ha
= vha
->hw
;
1094 if (!IS_ZIO_SUPPORTED(ha
))
1097 if (sscanf(buf
, "%d", &val
) != 1)
1101 zio_mode
= QLA_ZIO_MODE_6
;
1103 zio_mode
= QLA_ZIO_DISABLED
;
1105 /* Update per-hba values and queue a reset. */
1106 if (zio_mode
!= QLA_ZIO_DISABLED
|| ha
->zio_mode
!= QLA_ZIO_DISABLED
) {
1107 ha
->zio_mode
= zio_mode
;
1108 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1114 qla2x00_zio_timer_show(struct device
*dev
, struct device_attribute
*attr
,
1117 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1119 return snprintf(buf
, PAGE_SIZE
, "%d us\n", vha
->hw
->zio_timer
* 100);
1123 qla2x00_zio_timer_store(struct device
*dev
, struct device_attribute
*attr
,
1124 const char *buf
, size_t count
)
1126 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1130 if (sscanf(buf
, "%d", &val
) != 1)
1132 if (val
> 25500 || val
< 100)
1135 zio_timer
= (uint16_t)(val
/ 100);
1136 vha
->hw
->zio_timer
= zio_timer
;
1142 qla2x00_beacon_show(struct device
*dev
, struct device_attribute
*attr
,
1145 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1148 if (vha
->hw
->beacon_blink_led
)
1149 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Enabled\n");
1151 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
, "Disabled\n");
1156 qla2x00_beacon_store(struct device
*dev
, struct device_attribute
*attr
,
1157 const char *buf
, size_t count
)
1159 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1160 struct qla_hw_data
*ha
= vha
->hw
;
1164 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
1167 if (test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
)) {
1168 ql_log(ql_log_warn
, vha
, 0x707a,
1169 "Abort ISP active -- ignoring beacon request.\n");
1173 if (sscanf(buf
, "%d", &val
) != 1)
1177 rval
= ha
->isp_ops
->beacon_on(vha
);
1179 rval
= ha
->isp_ops
->beacon_off(vha
);
1181 if (rval
!= QLA_SUCCESS
)
1188 qla2x00_optrom_bios_version_show(struct device
*dev
,
1189 struct device_attribute
*attr
, char *buf
)
1191 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1192 struct qla_hw_data
*ha
= vha
->hw
;
1193 return snprintf(buf
, PAGE_SIZE
, "%d.%02d\n", ha
->bios_revision
[1],
1194 ha
->bios_revision
[0]);
1198 qla2x00_optrom_efi_version_show(struct device
*dev
,
1199 struct device_attribute
*attr
, char *buf
)
1201 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1202 struct qla_hw_data
*ha
= vha
->hw
;
1203 return snprintf(buf
, PAGE_SIZE
, "%d.%02d\n", ha
->efi_revision
[1],
1204 ha
->efi_revision
[0]);
1208 qla2x00_optrom_fcode_version_show(struct device
*dev
,
1209 struct device_attribute
*attr
, char *buf
)
1211 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1212 struct qla_hw_data
*ha
= vha
->hw
;
1213 return snprintf(buf
, PAGE_SIZE
, "%d.%02d\n", ha
->fcode_revision
[1],
1214 ha
->fcode_revision
[0]);
1218 qla2x00_optrom_fw_version_show(struct device
*dev
,
1219 struct device_attribute
*attr
, char *buf
)
1221 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1222 struct qla_hw_data
*ha
= vha
->hw
;
1223 return snprintf(buf
, PAGE_SIZE
, "%d.%02d.%02d %d\n",
1224 ha
->fw_revision
[0], ha
->fw_revision
[1], ha
->fw_revision
[2],
1225 ha
->fw_revision
[3]);
1229 qla2x00_optrom_gold_fw_version_show(struct device
*dev
,
1230 struct device_attribute
*attr
, char *buf
)
1232 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1233 struct qla_hw_data
*ha
= vha
->hw
;
1235 if (!IS_QLA81XX(ha
))
1236 return snprintf(buf
, PAGE_SIZE
, "\n");
1238 return snprintf(buf
, PAGE_SIZE
, "%d.%02d.%02d (%d)\n",
1239 ha
->gold_fw_version
[0], ha
->gold_fw_version
[1],
1240 ha
->gold_fw_version
[2], ha
->gold_fw_version
[3]);
1244 qla2x00_total_isp_aborts_show(struct device
*dev
,
1245 struct device_attribute
*attr
, char *buf
)
1247 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1248 struct qla_hw_data
*ha
= vha
->hw
;
1249 return snprintf(buf
, PAGE_SIZE
, "%d\n",
1250 ha
->qla_stats
.total_isp_aborts
);
1254 qla24xx_84xx_fw_version_show(struct device
*dev
,
1255 struct device_attribute
*attr
, char *buf
)
1257 int rval
= QLA_SUCCESS
;
1258 uint16_t status
[2] = {0, 0};
1259 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1260 struct qla_hw_data
*ha
= vha
->hw
;
1262 if (!IS_QLA84XX(ha
))
1263 return snprintf(buf
, PAGE_SIZE
, "\n");
1265 if (ha
->cs84xx
->op_fw_version
== 0)
1266 rval
= qla84xx_verify_chip(vha
, status
);
1268 if ((rval
== QLA_SUCCESS
) && (status
[0] == 0))
1269 return snprintf(buf
, PAGE_SIZE
, "%u\n",
1270 (uint32_t)ha
->cs84xx
->op_fw_version
);
1272 return snprintf(buf
, PAGE_SIZE
, "\n");
1276 qla2x00_mpi_version_show(struct device
*dev
, struct device_attribute
*attr
,
1279 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1280 struct qla_hw_data
*ha
= vha
->hw
;
1282 if (!IS_QLA81XX(ha
))
1283 return snprintf(buf
, PAGE_SIZE
, "\n");
1285 return snprintf(buf
, PAGE_SIZE
, "%d.%02d.%02d (%x)\n",
1286 ha
->mpi_version
[0], ha
->mpi_version
[1], ha
->mpi_version
[2],
1287 ha
->mpi_capabilities
);
1291 qla2x00_phy_version_show(struct device
*dev
, struct device_attribute
*attr
,
1294 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1295 struct qla_hw_data
*ha
= vha
->hw
;
1297 if (!IS_QLA81XX(ha
))
1298 return snprintf(buf
, PAGE_SIZE
, "\n");
1300 return snprintf(buf
, PAGE_SIZE
, "%d.%02d.%02d\n",
1301 ha
->phy_version
[0], ha
->phy_version
[1], ha
->phy_version
[2]);
1305 qla2x00_flash_block_size_show(struct device
*dev
,
1306 struct device_attribute
*attr
, char *buf
)
1308 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1309 struct qla_hw_data
*ha
= vha
->hw
;
1311 return snprintf(buf
, PAGE_SIZE
, "0x%x\n", ha
->fdt_block_size
);
1315 qla2x00_vlan_id_show(struct device
*dev
, struct device_attribute
*attr
,
1318 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1320 if (!IS_QLA8XXX_TYPE(vha
->hw
))
1321 return snprintf(buf
, PAGE_SIZE
, "\n");
1323 return snprintf(buf
, PAGE_SIZE
, "%d\n", vha
->fcoe_vlan_id
);
1327 qla2x00_vn_port_mac_address_show(struct device
*dev
,
1328 struct device_attribute
*attr
, char *buf
)
1330 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1332 if (!IS_QLA8XXX_TYPE(vha
->hw
))
1333 return snprintf(buf
, PAGE_SIZE
, "\n");
1335 return snprintf(buf
, PAGE_SIZE
, "%02x:%02x:%02x:%02x:%02x:%02x\n",
1336 vha
->fcoe_vn_port_mac
[5], vha
->fcoe_vn_port_mac
[4],
1337 vha
->fcoe_vn_port_mac
[3], vha
->fcoe_vn_port_mac
[2],
1338 vha
->fcoe_vn_port_mac
[1], vha
->fcoe_vn_port_mac
[0]);
1342 qla2x00_fabric_param_show(struct device
*dev
, struct device_attribute
*attr
,
1345 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1347 return snprintf(buf
, PAGE_SIZE
, "%d\n", vha
->hw
->switch_cap
);
1351 qla2x00_thermal_temp_show(struct device
*dev
,
1352 struct device_attribute
*attr
, char *buf
)
1354 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1355 int rval
= QLA_FUNCTION_FAILED
;
1356 uint16_t temp
, frac
;
1358 if (!vha
->hw
->flags
.thermal_supported
)
1359 return snprintf(buf
, PAGE_SIZE
, "\n");
1362 if (test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) ||
1363 test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
))
1364 ql_log(ql_log_warn
, vha
, 0x707b,
1365 "ISP reset active.\n");
1366 else if (!vha
->hw
->flags
.eeh_busy
)
1367 rval
= qla2x00_get_thermal_temp(vha
, &temp
, &frac
);
1368 if (rval
!= QLA_SUCCESS
)
1371 return snprintf(buf
, PAGE_SIZE
, "%d.%02d\n", temp
, frac
);
1375 qla2x00_fw_state_show(struct device
*dev
, struct device_attribute
*attr
,
1378 scsi_qla_host_t
*vha
= shost_priv(class_to_shost(dev
));
1379 int rval
= QLA_FUNCTION_FAILED
;
1382 if (test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) ||
1383 test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
))
1384 ql_log(ql_log_warn
, vha
, 0x707c,
1385 "ISP reset active.\n");
1386 else if (!vha
->hw
->flags
.eeh_busy
)
1387 rval
= qla2x00_get_firmware_state(vha
, state
);
1388 if (rval
!= QLA_SUCCESS
)
1389 memset(state
, -1, sizeof(state
));
1391 return snprintf(buf
, PAGE_SIZE
, "0x%x 0x%x 0x%x 0x%x 0x%x\n", state
[0],
1392 state
[1], state
[2], state
[3], state
[4]);
1395 static DEVICE_ATTR(driver_version
, S_IRUGO
, qla2x00_drvr_version_show
, NULL
);
1396 static DEVICE_ATTR(fw_version
, S_IRUGO
, qla2x00_fw_version_show
, NULL
);
1397 static DEVICE_ATTR(serial_num
, S_IRUGO
, qla2x00_serial_num_show
, NULL
);
1398 static DEVICE_ATTR(isp_name
, S_IRUGO
, qla2x00_isp_name_show
, NULL
);
1399 static DEVICE_ATTR(isp_id
, S_IRUGO
, qla2x00_isp_id_show
, NULL
);
1400 static DEVICE_ATTR(model_name
, S_IRUGO
, qla2x00_model_name_show
, NULL
);
1401 static DEVICE_ATTR(model_desc
, S_IRUGO
, qla2x00_model_desc_show
, NULL
);
1402 static DEVICE_ATTR(pci_info
, S_IRUGO
, qla2x00_pci_info_show
, NULL
);
1403 static DEVICE_ATTR(link_state
, S_IRUGO
, qla2x00_link_state_show
, NULL
);
1404 static DEVICE_ATTR(zio
, S_IRUGO
| S_IWUSR
, qla2x00_zio_show
, qla2x00_zio_store
);
1405 static DEVICE_ATTR(zio_timer
, S_IRUGO
| S_IWUSR
, qla2x00_zio_timer_show
,
1406 qla2x00_zio_timer_store
);
1407 static DEVICE_ATTR(beacon
, S_IRUGO
| S_IWUSR
, qla2x00_beacon_show
,
1408 qla2x00_beacon_store
);
1409 static DEVICE_ATTR(optrom_bios_version
, S_IRUGO
,
1410 qla2x00_optrom_bios_version_show
, NULL
);
1411 static DEVICE_ATTR(optrom_efi_version
, S_IRUGO
,
1412 qla2x00_optrom_efi_version_show
, NULL
);
1413 static DEVICE_ATTR(optrom_fcode_version
, S_IRUGO
,
1414 qla2x00_optrom_fcode_version_show
, NULL
);
1415 static DEVICE_ATTR(optrom_fw_version
, S_IRUGO
, qla2x00_optrom_fw_version_show
,
1417 static DEVICE_ATTR(optrom_gold_fw_version
, S_IRUGO
,
1418 qla2x00_optrom_gold_fw_version_show
, NULL
);
1419 static DEVICE_ATTR(84xx_fw_version
, S_IRUGO
, qla24xx_84xx_fw_version_show
,
1421 static DEVICE_ATTR(total_isp_aborts
, S_IRUGO
, qla2x00_total_isp_aborts_show
,
1423 static DEVICE_ATTR(mpi_version
, S_IRUGO
, qla2x00_mpi_version_show
, NULL
);
1424 static DEVICE_ATTR(phy_version
, S_IRUGO
, qla2x00_phy_version_show
, NULL
);
1425 static DEVICE_ATTR(flash_block_size
, S_IRUGO
, qla2x00_flash_block_size_show
,
1427 static DEVICE_ATTR(vlan_id
, S_IRUGO
, qla2x00_vlan_id_show
, NULL
);
1428 static DEVICE_ATTR(vn_port_mac_address
, S_IRUGO
,
1429 qla2x00_vn_port_mac_address_show
, NULL
);
1430 static DEVICE_ATTR(fabric_param
, S_IRUGO
, qla2x00_fabric_param_show
, NULL
);
1431 static DEVICE_ATTR(fw_state
, S_IRUGO
, qla2x00_fw_state_show
, NULL
);
1432 static DEVICE_ATTR(thermal_temp
, S_IRUGO
, qla2x00_thermal_temp_show
, NULL
);
1434 struct device_attribute
*qla2x00_host_attrs
[] = {
1435 &dev_attr_driver_version
,
1436 &dev_attr_fw_version
,
1437 &dev_attr_serial_num
,
1440 &dev_attr_model_name
,
1441 &dev_attr_model_desc
,
1443 &dev_attr_link_state
,
1445 &dev_attr_zio_timer
,
1447 &dev_attr_optrom_bios_version
,
1448 &dev_attr_optrom_efi_version
,
1449 &dev_attr_optrom_fcode_version
,
1450 &dev_attr_optrom_fw_version
,
1451 &dev_attr_84xx_fw_version
,
1452 &dev_attr_total_isp_aborts
,
1453 &dev_attr_mpi_version
,
1454 &dev_attr_phy_version
,
1455 &dev_attr_flash_block_size
,
1457 &dev_attr_vn_port_mac_address
,
1458 &dev_attr_fabric_param
,
1460 &dev_attr_optrom_gold_fw_version
,
1461 &dev_attr_thermal_temp
,
1465 /* Host attributes. */
1468 qla2x00_get_host_port_id(struct Scsi_Host
*shost
)
1470 scsi_qla_host_t
*vha
= shost_priv(shost
);
1472 fc_host_port_id(shost
) = vha
->d_id
.b
.domain
<< 16 |
1473 vha
->d_id
.b
.area
<< 8 | vha
->d_id
.b
.al_pa
;
1477 qla2x00_get_host_speed(struct Scsi_Host
*shost
)
1479 struct qla_hw_data
*ha
= ((struct scsi_qla_host
*)
1480 (shost_priv(shost
)))->hw
;
1481 u32 speed
= FC_PORTSPEED_UNKNOWN
;
1483 switch (ha
->link_data_rate
) {
1484 case PORT_SPEED_1GB
:
1485 speed
= FC_PORTSPEED_1GBIT
;
1487 case PORT_SPEED_2GB
:
1488 speed
= FC_PORTSPEED_2GBIT
;
1490 case PORT_SPEED_4GB
:
1491 speed
= FC_PORTSPEED_4GBIT
;
1493 case PORT_SPEED_8GB
:
1494 speed
= FC_PORTSPEED_8GBIT
;
1496 case PORT_SPEED_10GB
:
1497 speed
= FC_PORTSPEED_10GBIT
;
1500 fc_host_speed(shost
) = speed
;
1504 qla2x00_get_host_port_type(struct Scsi_Host
*shost
)
1506 scsi_qla_host_t
*vha
= shost_priv(shost
);
1507 uint32_t port_type
= FC_PORTTYPE_UNKNOWN
;
1510 fc_host_port_type(shost
) = FC_PORTTYPE_NPIV
;
1513 switch (vha
->hw
->current_topology
) {
1515 port_type
= FC_PORTTYPE_LPORT
;
1518 port_type
= FC_PORTTYPE_NLPORT
;
1521 port_type
= FC_PORTTYPE_PTP
;
1524 port_type
= FC_PORTTYPE_NPORT
;
1527 fc_host_port_type(shost
) = port_type
;
1531 qla2x00_get_starget_node_name(struct scsi_target
*starget
)
1533 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
1534 scsi_qla_host_t
*vha
= shost_priv(host
);
1538 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
) {
1539 if (fcport
->rport
&&
1540 starget
->id
== fcport
->rport
->scsi_target_id
) {
1541 node_name
= wwn_to_u64(fcport
->node_name
);
1546 fc_starget_node_name(starget
) = node_name
;
1550 qla2x00_get_starget_port_name(struct scsi_target
*starget
)
1552 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
1553 scsi_qla_host_t
*vha
= shost_priv(host
);
1557 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
) {
1558 if (fcport
->rport
&&
1559 starget
->id
== fcport
->rport
->scsi_target_id
) {
1560 port_name
= wwn_to_u64(fcport
->port_name
);
1565 fc_starget_port_name(starget
) = port_name
;
1569 qla2x00_get_starget_port_id(struct scsi_target
*starget
)
1571 struct Scsi_Host
*host
= dev_to_shost(starget
->dev
.parent
);
1572 scsi_qla_host_t
*vha
= shost_priv(host
);
1574 uint32_t port_id
= ~0U;
1576 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
) {
1577 if (fcport
->rport
&&
1578 starget
->id
== fcport
->rport
->scsi_target_id
) {
1579 port_id
= fcport
->d_id
.b
.domain
<< 16 |
1580 fcport
->d_id
.b
.area
<< 8 | fcport
->d_id
.b
.al_pa
;
1585 fc_starget_port_id(starget
) = port_id
;
1589 qla2x00_set_rport_loss_tmo(struct fc_rport
*rport
, uint32_t timeout
)
1592 rport
->dev_loss_tmo
= timeout
;
1594 rport
->dev_loss_tmo
= 1;
1598 qla2x00_dev_loss_tmo_callbk(struct fc_rport
*rport
)
1600 struct Scsi_Host
*host
= rport_to_shost(rport
);
1601 fc_port_t
*fcport
= *(fc_port_t
**)rport
->dd_data
;
1602 unsigned long flags
;
1607 /* Now that the rport has been deleted, set the fcport state to
1609 qla2x00_set_fcport_state(fcport
, FCS_DEVICE_DEAD
);
1612 * Transport has effectively 'deleted' the rport, clear
1613 * all local references.
1615 spin_lock_irqsave(host
->host_lock
, flags
);
1616 fcport
->rport
= fcport
->drport
= NULL
;
1617 *((fc_port_t
**)rport
->dd_data
) = NULL
;
1618 spin_unlock_irqrestore(host
->host_lock
, flags
);
1620 if (test_bit(ABORT_ISP_ACTIVE
, &fcport
->vha
->dpc_flags
))
1623 if (unlikely(pci_channel_offline(fcport
->vha
->hw
->pdev
))) {
1624 qla2x00_abort_all_cmds(fcport
->vha
, DID_NO_CONNECT
<< 16);
1630 qla2x00_terminate_rport_io(struct fc_rport
*rport
)
1632 fc_port_t
*fcport
= *(fc_port_t
**)rport
->dd_data
;
1637 if (test_bit(ABORT_ISP_ACTIVE
, &fcport
->vha
->dpc_flags
))
1640 if (unlikely(pci_channel_offline(fcport
->vha
->hw
->pdev
))) {
1641 qla2x00_abort_all_cmds(fcport
->vha
, DID_NO_CONNECT
<< 16);
1645 * At this point all fcport's software-states are cleared. Perform any
1646 * final cleanup of firmware resources (PCBs and XCBs).
1648 if (fcport
->loop_id
!= FC_NO_LOOP_ID
&&
1649 !test_bit(UNLOADING
, &fcport
->vha
->dpc_flags
))
1650 fcport
->vha
->hw
->isp_ops
->fabric_logout(fcport
->vha
,
1651 fcport
->loop_id
, fcport
->d_id
.b
.domain
,
1652 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
);
1656 qla2x00_issue_lip(struct Scsi_Host
*shost
)
1658 scsi_qla_host_t
*vha
= shost_priv(shost
);
1660 qla2x00_loop_reset(vha
);
1664 static struct fc_host_statistics
*
1665 qla2x00_get_fc_host_stats(struct Scsi_Host
*shost
)
1667 scsi_qla_host_t
*vha
= shost_priv(shost
);
1668 struct qla_hw_data
*ha
= vha
->hw
;
1669 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
1671 struct link_statistics
*stats
;
1672 dma_addr_t stats_dma
;
1673 struct fc_host_statistics
*pfc_host_stat
;
1675 pfc_host_stat
= &ha
->fc_host_stat
;
1676 memset(pfc_host_stat
, -1, sizeof(struct fc_host_statistics
));
1678 if (test_bit(UNLOADING
, &vha
->dpc_flags
))
1681 if (unlikely(pci_channel_offline(ha
->pdev
)))
1684 stats
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &stats_dma
);
1685 if (stats
== NULL
) {
1686 ql_log(ql_log_warn
, vha
, 0x707d,
1687 "Failed to allocate memory for stats.\n");
1690 memset(stats
, 0, DMA_POOL_SIZE
);
1692 rval
= QLA_FUNCTION_FAILED
;
1693 if (IS_FWI2_CAPABLE(ha
)) {
1694 rval
= qla24xx_get_isp_stats(base_vha
, stats
, stats_dma
);
1695 } else if (atomic_read(&base_vha
->loop_state
) == LOOP_READY
&&
1696 !test_bit(ABORT_ISP_ACTIVE
, &base_vha
->dpc_flags
) &&
1697 !test_bit(ISP_ABORT_NEEDED
, &base_vha
->dpc_flags
) &&
1699 /* Must be in a 'READY' state for statistics retrieval. */
1700 rval
= qla2x00_get_link_status(base_vha
, base_vha
->loop_id
,
1704 if (rval
!= QLA_SUCCESS
)
1707 pfc_host_stat
->link_failure_count
= stats
->link_fail_cnt
;
1708 pfc_host_stat
->loss_of_sync_count
= stats
->loss_sync_cnt
;
1709 pfc_host_stat
->loss_of_signal_count
= stats
->loss_sig_cnt
;
1710 pfc_host_stat
->prim_seq_protocol_err_count
= stats
->prim_seq_err_cnt
;
1711 pfc_host_stat
->invalid_tx_word_count
= stats
->inval_xmit_word_cnt
;
1712 pfc_host_stat
->invalid_crc_count
= stats
->inval_crc_cnt
;
1713 if (IS_FWI2_CAPABLE(ha
)) {
1714 pfc_host_stat
->lip_count
= stats
->lip_cnt
;
1715 pfc_host_stat
->tx_frames
= stats
->tx_frames
;
1716 pfc_host_stat
->rx_frames
= stats
->rx_frames
;
1717 pfc_host_stat
->dumped_frames
= stats
->dumped_frames
;
1718 pfc_host_stat
->nos_count
= stats
->nos_rcvd
;
1720 pfc_host_stat
->fcp_input_megabytes
= ha
->qla_stats
.input_bytes
>> 20;
1721 pfc_host_stat
->fcp_output_megabytes
= ha
->qla_stats
.output_bytes
>> 20;
1724 dma_pool_free(ha
->s_dma_pool
, stats
, stats_dma
);
1726 return pfc_host_stat
;
1730 qla2x00_get_host_symbolic_name(struct Scsi_Host
*shost
)
1732 scsi_qla_host_t
*vha
= shost_priv(shost
);
1734 qla2x00_get_sym_node_name(vha
, fc_host_symbolic_name(shost
));
1738 qla2x00_set_host_system_hostname(struct Scsi_Host
*shost
)
1740 scsi_qla_host_t
*vha
= shost_priv(shost
);
1742 set_bit(REGISTER_FDMI_NEEDED
, &vha
->dpc_flags
);
1746 qla2x00_get_host_fabric_name(struct Scsi_Host
*shost
)
1748 scsi_qla_host_t
*vha
= shost_priv(shost
);
1749 uint8_t node_name
[WWN_SIZE
] = { 0xFF, 0xFF, 0xFF, 0xFF, \
1750 0xFF, 0xFF, 0xFF, 0xFF};
1751 u64 fabric_name
= wwn_to_u64(node_name
);
1753 if (vha
->device_flags
& SWITCH_FOUND
)
1754 fabric_name
= wwn_to_u64(vha
->fabric_node_name
);
1756 fc_host_fabric_name(shost
) = fabric_name
;
1760 qla2x00_get_host_port_state(struct Scsi_Host
*shost
)
1762 scsi_qla_host_t
*vha
= shost_priv(shost
);
1763 struct scsi_qla_host
*base_vha
= pci_get_drvdata(vha
->hw
->pdev
);
1765 if (!base_vha
->flags
.online
) {
1766 fc_host_port_state(shost
) = FC_PORTSTATE_OFFLINE
;
1770 switch (atomic_read(&base_vha
->loop_state
)) {
1772 fc_host_port_state(shost
) = FC_PORTSTATE_DIAGNOSTICS
;
1775 if (test_bit(LOOP_RESYNC_NEEDED
, &base_vha
->dpc_flags
))
1776 fc_host_port_state(shost
) = FC_PORTSTATE_DIAGNOSTICS
;
1778 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
1781 fc_host_port_state(shost
) = FC_PORTSTATE_LINKDOWN
;
1784 fc_host_port_state(shost
) = FC_PORTSTATE_ONLINE
;
1787 fc_host_port_state(shost
) = FC_PORTSTATE_UNKNOWN
;
1793 qla24xx_vport_create(struct fc_vport
*fc_vport
, bool disable
)
1797 scsi_qla_host_t
*base_vha
= shost_priv(fc_vport
->shost
);
1798 scsi_qla_host_t
*vha
= NULL
;
1799 struct qla_hw_data
*ha
= base_vha
->hw
;
1800 uint16_t options
= 0;
1802 struct req_que
*req
= ha
->req_q_map
[0];
1804 ret
= qla24xx_vport_create_req_sanity_check(fc_vport
);
1806 ql_log(ql_log_warn
, vha
, 0x707e,
1807 "Vport sanity check failed, status %x\n", ret
);
1811 vha
= qla24xx_create_vhost(fc_vport
);
1813 ql_log(ql_log_warn
, vha
, 0x707f, "Vport create host failed.\n");
1814 return FC_VPORT_FAILED
;
1817 atomic_set(&vha
->vp_state
, VP_OFFLINE
);
1818 fc_vport_set_state(fc_vport
, FC_VPORT_DISABLED
);
1820 atomic_set(&vha
->vp_state
, VP_FAILED
);
1822 /* ready to create vport */
1823 ql_log(ql_log_info
, vha
, 0x7080,
1824 "VP entry id %d assigned.\n", vha
->vp_idx
);
1826 /* initialized vport states */
1827 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
1828 vha
->vp_err_state
= VP_ERR_PORTDWN
;
1829 vha
->vp_prev_err_state
= VP_ERR_UNKWN
;
1830 /* Check if physical ha port is Up */
1831 if (atomic_read(&base_vha
->loop_state
) == LOOP_DOWN
||
1832 atomic_read(&base_vha
->loop_state
) == LOOP_DEAD
) {
1833 /* Don't retry or attempt login of this virtual port */
1834 ql_dbg(ql_dbg_user
, vha
, 0x7081,
1835 "Vport loop state is not UP.\n");
1836 atomic_set(&vha
->loop_state
, LOOP_DEAD
);
1838 fc_vport_set_state(fc_vport
, FC_VPORT_LINKDOWN
);
1841 if (IS_T10_PI_CAPABLE(ha
) && ql2xenabledif
) {
1842 if (ha
->fw_attributes
& BIT_4
) {
1844 vha
->flags
.difdix_supported
= 1;
1845 ql_dbg(ql_dbg_user
, vha
, 0x7082,
1846 "Registered for DIF/DIX type 1 and 3 protection.\n");
1847 if (ql2xenabledif
== 1)
1848 prot
= SHOST_DIX_TYPE0_PROTECTION
;
1849 scsi_host_set_prot(vha
->host
,
1850 prot
| SHOST_DIF_TYPE1_PROTECTION
1851 | SHOST_DIF_TYPE2_PROTECTION
1852 | SHOST_DIF_TYPE3_PROTECTION
1853 | SHOST_DIX_TYPE1_PROTECTION
1854 | SHOST_DIX_TYPE2_PROTECTION
1855 | SHOST_DIX_TYPE3_PROTECTION
);
1856 scsi_host_set_guard(vha
->host
, SHOST_DIX_GUARD_CRC
);
1858 vha
->flags
.difdix_supported
= 0;
1861 if (scsi_add_host_with_dma(vha
->host
, &fc_vport
->dev
,
1863 ql_dbg(ql_dbg_user
, vha
, 0x7083,
1864 "scsi_add_host failure for VP[%d].\n", vha
->vp_idx
);
1865 goto vport_create_failed_2
;
1868 /* initialize attributes */
1869 fc_host_dev_loss_tmo(vha
->host
) = ha
->port_down_retry_count
;
1870 fc_host_node_name(vha
->host
) = wwn_to_u64(vha
->node_name
);
1871 fc_host_port_name(vha
->host
) = wwn_to_u64(vha
->port_name
);
1872 fc_host_supported_classes(vha
->host
) =
1873 fc_host_supported_classes(base_vha
->host
);
1874 fc_host_supported_speeds(vha
->host
) =
1875 fc_host_supported_speeds(base_vha
->host
);
1877 qla24xx_vport_disable(fc_vport
, disable
);
1879 if (ha
->flags
.cpu_affinity_enabled
) {
1880 req
= ha
->req_q_map
[1];
1881 ql_dbg(ql_dbg_multiq
, vha
, 0xc000,
1882 "Request queue %p attached with "
1883 "VP[%d], cpu affinity =%d\n",
1884 req
, vha
->vp_idx
, ha
->flags
.cpu_affinity_enabled
);
1886 } else if (ql2xmaxqueues
== 1 || !ha
->npiv_info
)
1888 /* Create a request queue in QoS mode for the vport */
1889 for (cnt
= 0; cnt
< ha
->nvram_npiv_size
; cnt
++) {
1890 if (memcmp(ha
->npiv_info
[cnt
].port_name
, vha
->port_name
, 8) == 0
1891 && memcmp(ha
->npiv_info
[cnt
].node_name
, vha
->node_name
,
1893 qos
= ha
->npiv_info
[cnt
].q_qos
;
1898 ret
= qla25xx_create_req_que(ha
, options
, vha
->vp_idx
, 0, 0,
1901 ql_log(ql_log_warn
, vha
, 0x7084,
1902 "Can't create request queue for VP[%d]\n",
1905 ql_dbg(ql_dbg_multiq
, vha
, 0xc001,
1906 "Request Que:%d Q0s: %d) created for VP[%d]\n",
1907 ret
, qos
, vha
->vp_idx
);
1908 ql_dbg(ql_dbg_user
, vha
, 0x7085,
1909 "Request Que:%d Q0s: %d) created for VP[%d]\n",
1910 ret
, qos
, vha
->vp_idx
);
1911 req
= ha
->req_q_map
[ret
];
1919 vport_create_failed_2
:
1920 qla24xx_disable_vp(vha
);
1921 qla24xx_deallocate_vp_id(vha
);
1922 scsi_host_put(vha
->host
);
1923 return FC_VPORT_FAILED
;
1927 qla24xx_vport_delete(struct fc_vport
*fc_vport
)
1929 scsi_qla_host_t
*vha
= fc_vport
->dd_data
;
1930 struct qla_hw_data
*ha
= vha
->hw
;
1931 uint16_t id
= vha
->vp_idx
;
1933 while (test_bit(LOOP_RESYNC_ACTIVE
, &vha
->dpc_flags
) ||
1934 test_bit(FCPORT_UPDATE_NEEDED
, &vha
->dpc_flags
))
1937 qla24xx_disable_vp(vha
);
1939 vha
->flags
.delete_progress
= 1;
1941 fc_remove_host(vha
->host
);
1943 scsi_remove_host(vha
->host
);
1945 /* Allow timer to run to drain queued items, when removing vp */
1946 qla24xx_deallocate_vp_id(vha
);
1948 if (vha
->timer_active
) {
1949 qla2x00_vp_stop_timer(vha
);
1950 ql_dbg(ql_dbg_user
, vha
, 0x7086,
1951 "Timer for the VP[%d] has stopped\n", vha
->vp_idx
);
1954 /* No pending activities shall be there on the vha now */
1955 if (ql2xextended_error_logging
& ql_dbg_user
)
1956 msleep(random32()%10); /* Just to see if something falls on
1957 * the net we have placed below */
1959 BUG_ON(atomic_read(&vha
->vref_count
));
1961 qla2x00_free_fcports(vha
);
1963 mutex_lock(&ha
->vport_lock
);
1964 ha
->cur_vport_count
--;
1965 clear_bit(vha
->vp_idx
, ha
->vp_idx_map
);
1966 mutex_unlock(&ha
->vport_lock
);
1968 if (vha
->req
->id
&& !ha
->flags
.cpu_affinity_enabled
) {
1969 if (qla25xx_delete_req_que(vha
, vha
->req
) != QLA_SUCCESS
)
1970 ql_log(ql_log_warn
, vha
, 0x7087,
1971 "Queue delete failed.\n");
1974 scsi_host_put(vha
->host
);
1975 ql_log(ql_log_info
, vha
, 0x7088, "VP[%d] deleted.\n", id
);
1980 qla24xx_vport_disable(struct fc_vport
*fc_vport
, bool disable
)
1982 scsi_qla_host_t
*vha
= fc_vport
->dd_data
;
1985 qla24xx_disable_vp(vha
);
1987 qla24xx_enable_vp(vha
);
1992 struct fc_function_template qla2xxx_transport_functions
= {
1994 .show_host_node_name
= 1,
1995 .show_host_port_name
= 1,
1996 .show_host_supported_classes
= 1,
1997 .show_host_supported_speeds
= 1,
1999 .get_host_port_id
= qla2x00_get_host_port_id
,
2000 .show_host_port_id
= 1,
2001 .get_host_speed
= qla2x00_get_host_speed
,
2002 .show_host_speed
= 1,
2003 .get_host_port_type
= qla2x00_get_host_port_type
,
2004 .show_host_port_type
= 1,
2005 .get_host_symbolic_name
= qla2x00_get_host_symbolic_name
,
2006 .show_host_symbolic_name
= 1,
2007 .set_host_system_hostname
= qla2x00_set_host_system_hostname
,
2008 .show_host_system_hostname
= 1,
2009 .get_host_fabric_name
= qla2x00_get_host_fabric_name
,
2010 .show_host_fabric_name
= 1,
2011 .get_host_port_state
= qla2x00_get_host_port_state
,
2012 .show_host_port_state
= 1,
2014 .dd_fcrport_size
= sizeof(struct fc_port
*),
2015 .show_rport_supported_classes
= 1,
2017 .get_starget_node_name
= qla2x00_get_starget_node_name
,
2018 .show_starget_node_name
= 1,
2019 .get_starget_port_name
= qla2x00_get_starget_port_name
,
2020 .show_starget_port_name
= 1,
2021 .get_starget_port_id
= qla2x00_get_starget_port_id
,
2022 .show_starget_port_id
= 1,
2024 .set_rport_dev_loss_tmo
= qla2x00_set_rport_loss_tmo
,
2025 .show_rport_dev_loss_tmo
= 1,
2027 .issue_fc_host_lip
= qla2x00_issue_lip
,
2028 .dev_loss_tmo_callbk
= qla2x00_dev_loss_tmo_callbk
,
2029 .terminate_rport_io
= qla2x00_terminate_rport_io
,
2030 .get_fc_host_stats
= qla2x00_get_fc_host_stats
,
2032 .vport_create
= qla24xx_vport_create
,
2033 .vport_disable
= qla24xx_vport_disable
,
2034 .vport_delete
= qla24xx_vport_delete
,
2035 .bsg_request
= qla24xx_bsg_request
,
2036 .bsg_timeout
= qla24xx_bsg_timeout
,
2039 struct fc_function_template qla2xxx_transport_vport_functions
= {
2041 .show_host_node_name
= 1,
2042 .show_host_port_name
= 1,
2043 .show_host_supported_classes
= 1,
2045 .get_host_port_id
= qla2x00_get_host_port_id
,
2046 .show_host_port_id
= 1,
2047 .get_host_speed
= qla2x00_get_host_speed
,
2048 .show_host_speed
= 1,
2049 .get_host_port_type
= qla2x00_get_host_port_type
,
2050 .show_host_port_type
= 1,
2051 .get_host_symbolic_name
= qla2x00_get_host_symbolic_name
,
2052 .show_host_symbolic_name
= 1,
2053 .set_host_system_hostname
= qla2x00_set_host_system_hostname
,
2054 .show_host_system_hostname
= 1,
2055 .get_host_fabric_name
= qla2x00_get_host_fabric_name
,
2056 .show_host_fabric_name
= 1,
2057 .get_host_port_state
= qla2x00_get_host_port_state
,
2058 .show_host_port_state
= 1,
2060 .dd_fcrport_size
= sizeof(struct fc_port
*),
2061 .show_rport_supported_classes
= 1,
2063 .get_starget_node_name
= qla2x00_get_starget_node_name
,
2064 .show_starget_node_name
= 1,
2065 .get_starget_port_name
= qla2x00_get_starget_port_name
,
2066 .show_starget_port_name
= 1,
2067 .get_starget_port_id
= qla2x00_get_starget_port_id
,
2068 .show_starget_port_id
= 1,
2070 .set_rport_dev_loss_tmo
= qla2x00_set_rport_loss_tmo
,
2071 .show_rport_dev_loss_tmo
= 1,
2073 .issue_fc_host_lip
= qla2x00_issue_lip
,
2074 .dev_loss_tmo_callbk
= qla2x00_dev_loss_tmo_callbk
,
2075 .terminate_rport_io
= qla2x00_terminate_rport_io
,
2076 .get_fc_host_stats
= qla2x00_get_fc_host_stats
,
2077 .bsg_request
= qla24xx_bsg_request
,
2078 .bsg_timeout
= qla24xx_bsg_timeout
,
2082 qla2x00_init_host_attr(scsi_qla_host_t
*vha
)
2084 struct qla_hw_data
*ha
= vha
->hw
;
2085 u32 speed
= FC_PORTSPEED_UNKNOWN
;
2087 fc_host_dev_loss_tmo(vha
->host
) = ha
->port_down_retry_count
;
2088 fc_host_node_name(vha
->host
) = wwn_to_u64(vha
->node_name
);
2089 fc_host_port_name(vha
->host
) = wwn_to_u64(vha
->port_name
);
2090 fc_host_supported_classes(vha
->host
) = FC_COS_CLASS3
;
2091 fc_host_max_npiv_vports(vha
->host
) = ha
->max_npiv_vports
;
2092 fc_host_npiv_vports_inuse(vha
->host
) = ha
->cur_vport_count
;
2094 if (IS_QLA8XXX_TYPE(ha
))
2095 speed
= FC_PORTSPEED_10GBIT
;
2096 else if (IS_QLA25XX(ha
))
2097 speed
= FC_PORTSPEED_8GBIT
| FC_PORTSPEED_4GBIT
|
2098 FC_PORTSPEED_2GBIT
| FC_PORTSPEED_1GBIT
;
2099 else if (IS_QLA24XX_TYPE(ha
))
2100 speed
= FC_PORTSPEED_4GBIT
| FC_PORTSPEED_2GBIT
|
2102 else if (IS_QLA23XX(ha
))
2103 speed
= FC_PORTSPEED_2GBIT
| FC_PORTSPEED_1GBIT
;
2105 speed
= FC_PORTSPEED_1GBIT
;
2106 fc_host_supported_speeds(vha
->host
) = speed
;