2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2014 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
8 #include "qla_target.h"
10 #include <linux/kthread.h>
11 #include <linux/vmalloc.h>
12 #include <linux/slab.h>
13 #include <linux/delay.h>
15 static int qla24xx_vport_disable(struct fc_vport *, bool);
17 /* SYSFS attributes --------------------------------------------------------- */
20 qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj,
21 struct bin_attribute *bin_attr,
22 char *buf, loff_t off, size_t count)
24 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
25 struct device, kobj)));
26 struct qla_hw_data *ha = vha->hw;
29 if (!(ha->fw_dump_reading || ha->mctp_dump_reading))
32 if (IS_P3P_TYPE(ha)) {
33 if (off < ha->md_template_size) {
34 rval = memory_read_from_buffer(buf, count,
35 &off, ha->md_tmplt_hdr, ha->md_template_size);
38 off -= ha->md_template_size;
39 rval = memory_read_from_buffer(buf, count,
40 &off, ha->md_dump, ha->md_dump_size);
42 } else if (ha->mctp_dumped && ha->mctp_dump_reading)
43 return memory_read_from_buffer(buf, count, &off, ha->mctp_dump,
45 else if (ha->fw_dump_reading)
46 return memory_read_from_buffer(buf, count, &off, ha->fw_dump,
53 qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj,
54 struct bin_attribute *bin_attr,
55 char *buf, loff_t off, size_t count)
57 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
58 struct device, kobj)));
59 struct qla_hw_data *ha = vha->hw;
65 reading = simple_strtol(buf, NULL, 10);
68 if (!ha->fw_dump_reading)
71 ql_log(ql_log_info, vha, 0x705d,
72 "Firmware dump cleared on (%ld).\n", vha->host_no);
74 if (IS_P3P_TYPE(ha)) {
78 ha->fw_dump_reading = 0;
82 if (ha->fw_dumped && !ha->fw_dump_reading) {
83 ha->fw_dump_reading = 1;
85 ql_log(ql_log_info, vha, 0x705e,
86 "Raw firmware dump ready for read on (%ld).\n",
91 qla2x00_alloc_fw_dump(vha);
96 qla82xx_set_reset_owner(vha);
97 qla82xx_idc_unlock(ha);
98 } else if (IS_QLA8044(ha)) {
100 qla82xx_set_reset_owner(vha);
101 qla8044_idc_unlock(ha);
103 qla2x00_system_error(vha);
106 if (IS_P3P_TYPE(ha)) {
107 if (ha->md_tmplt_hdr)
108 ql_dbg(ql_dbg_user, vha, 0x705b,
109 "MiniDump supported with this firmware.\n");
111 ql_dbg(ql_dbg_user, vha, 0x709d,
112 "MiniDump not supported with this firmware.\n");
117 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
120 if (!ha->mctp_dump_reading)
122 ql_log(ql_log_info, vha, 0x70c1,
123 "MCTP dump cleared on (%ld).\n", vha->host_no);
124 ha->mctp_dump_reading = 0;
128 if (ha->mctp_dumped && !ha->mctp_dump_reading) {
129 ha->mctp_dump_reading = 1;
130 ql_log(ql_log_info, vha, 0x70c2,
131 "Raw mctp dump ready for read on (%ld).\n",
139 static struct bin_attribute sysfs_fw_dump_attr = {
142 .mode = S_IRUSR | S_IWUSR,
145 .read = qla2x00_sysfs_read_fw_dump,
146 .write = qla2x00_sysfs_write_fw_dump,
150 qla2x00_sysfs_read_fw_dump_template(struct file *filp, struct kobject *kobj,
151 struct bin_attribute *bin_attr,
152 char *buf, loff_t off, size_t count)
154 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
155 struct device, kobj)));
156 struct qla_hw_data *ha = vha->hw;
158 if (!ha->fw_dump_template || !ha->fw_dump_template_len)
161 ql_dbg(ql_dbg_user, vha, 0x70e2,
162 "chunk <- off=%llx count=%zx\n", off, count);
163 return memory_read_from_buffer(buf, count, &off,
164 ha->fw_dump_template, ha->fw_dump_template_len);
168 qla2x00_sysfs_write_fw_dump_template(struct file *filp, struct kobject *kobj,
169 struct bin_attribute *bin_attr,
170 char *buf, loff_t off, size_t count)
172 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
173 struct device, kobj)));
174 struct qla_hw_data *ha = vha->hw;
180 if (ha->fw_dump_template)
181 vfree(ha->fw_dump_template);
185 ha->fw_dump_template = NULL;
186 ha->fw_dump_template_len = 0;
188 size = qla27xx_fwdt_template_size(buf);
189 ql_dbg(ql_dbg_user, vha, 0x70d1,
190 "-> allocating fwdt (%x bytes)...\n", size);
191 ha->fw_dump_template = vmalloc(size);
192 if (!ha->fw_dump_template) {
193 ql_log(ql_log_warn, vha, 0x70d2,
194 "Failed allocate fwdt (%x bytes).\n", size);
197 ha->fw_dump_template_len = size;
200 if (off + count > ha->fw_dump_template_len) {
201 count = ha->fw_dump_template_len - off;
202 ql_dbg(ql_dbg_user, vha, 0x70d3,
203 "chunk -> truncating to %zx bytes.\n", count);
206 ql_dbg(ql_dbg_user, vha, 0x70d4,
207 "chunk -> off=%llx count=%zx\n", off, count);
208 memcpy(ha->fw_dump_template + off, buf, count);
210 if (off + count == ha->fw_dump_template_len) {
211 size = qla27xx_fwdt_calculate_dump_size(vha);
212 ql_dbg(ql_dbg_user, vha, 0x70d5,
213 "-> allocating fwdump (%x bytes)...\n", size);
214 ha->fw_dump = vmalloc(size);
216 ql_log(ql_log_warn, vha, 0x70d6,
217 "Failed allocate fwdump (%x bytes).\n", size);
220 ha->fw_dump_len = size;
225 static struct bin_attribute sysfs_fw_dump_template_attr = {
227 .name = "fw_dump_template",
228 .mode = S_IRUSR | S_IWUSR,
231 .read = qla2x00_sysfs_read_fw_dump_template,
232 .write = qla2x00_sysfs_write_fw_dump_template,
236 qla2x00_sysfs_read_nvram(struct file *filp, struct kobject *kobj,
237 struct bin_attribute *bin_attr,
238 char *buf, loff_t off, size_t count)
240 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
241 struct device, kobj)));
242 struct qla_hw_data *ha = vha->hw;
244 if (!capable(CAP_SYS_ADMIN))
247 if (IS_NOCACHE_VPD_TYPE(ha))
248 ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2,
250 return memory_read_from_buffer(buf, count, &off, ha->nvram,
255 qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj,
256 struct bin_attribute *bin_attr,
257 char *buf, loff_t off, size_t count)
259 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
260 struct device, kobj)));
261 struct qla_hw_data *ha = vha->hw;
264 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size ||
265 !ha->isp_ops->write_nvram)
268 /* Checksum NVRAM. */
269 if (IS_FWI2_CAPABLE(ha)) {
273 iter = (uint32_t *)buf;
275 for (cnt = 0; cnt < ((count >> 2) - 1); cnt++)
276 chksum += le32_to_cpu(*iter++);
277 chksum = ~chksum + 1;
278 *iter = cpu_to_le32(chksum);
283 iter = (uint8_t *)buf;
285 for (cnt = 0; cnt < count - 1; cnt++)
287 chksum = ~chksum + 1;
291 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
292 ql_log(ql_log_warn, vha, 0x705f,
293 "HBA not online, failing NVRAM update.\n");
298 ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->nvram_base, count);
299 ha->isp_ops->read_nvram(vha, (uint8_t *)ha->nvram, ha->nvram_base,
302 ql_dbg(ql_dbg_user, vha, 0x7060,
303 "Setting ISP_ABORT_NEEDED\n");
304 /* NVRAM settings take effect immediately. */
305 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
306 qla2xxx_wake_dpc(vha);
307 qla2x00_wait_for_chip_reset(vha);
312 static struct bin_attribute sysfs_nvram_attr = {
315 .mode = S_IRUSR | S_IWUSR,
318 .read = qla2x00_sysfs_read_nvram,
319 .write = qla2x00_sysfs_write_nvram,
323 qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj,
324 struct bin_attribute *bin_attr,
325 char *buf, loff_t off, size_t count)
327 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
328 struct device, kobj)));
329 struct qla_hw_data *ha = vha->hw;
332 mutex_lock(&ha->optrom_mutex);
334 if (ha->optrom_state != QLA_SREADING)
337 rval = memory_read_from_buffer(buf, count, &off, ha->optrom_buffer,
338 ha->optrom_region_size);
341 mutex_unlock(&ha->optrom_mutex);
347 qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj,
348 struct bin_attribute *bin_attr,
349 char *buf, loff_t off, size_t count)
351 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
352 struct device, kobj)));
353 struct qla_hw_data *ha = vha->hw;
355 mutex_lock(&ha->optrom_mutex);
357 if (ha->optrom_state != QLA_SWRITING) {
358 mutex_unlock(&ha->optrom_mutex);
361 if (off > ha->optrom_region_size) {
362 mutex_unlock(&ha->optrom_mutex);
365 if (off + count > ha->optrom_region_size)
366 count = ha->optrom_region_size - off;
368 memcpy(&ha->optrom_buffer[off], buf, count);
369 mutex_unlock(&ha->optrom_mutex);
374 static struct bin_attribute sysfs_optrom_attr = {
377 .mode = S_IRUSR | S_IWUSR,
380 .read = qla2x00_sysfs_read_optrom,
381 .write = qla2x00_sysfs_write_optrom,
385 qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
386 struct bin_attribute *bin_attr,
387 char *buf, loff_t off, size_t count)
389 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
390 struct device, kobj)));
391 struct qla_hw_data *ha = vha->hw;
393 uint32_t size = ha->optrom_size;
395 ssize_t rval = count;
400 if (unlikely(pci_channel_offline(ha->pdev)))
403 if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1)
405 if (start > ha->optrom_size)
407 if (size > ha->optrom_size - start)
408 size = ha->optrom_size - start;
410 mutex_lock(&ha->optrom_mutex);
413 if (ha->optrom_state != QLA_SREADING &&
414 ha->optrom_state != QLA_SWRITING) {
418 ha->optrom_state = QLA_SWAITING;
420 ql_dbg(ql_dbg_user, vha, 0x7061,
421 "Freeing flash region allocation -- 0x%x bytes.\n",
422 ha->optrom_region_size);
424 vfree(ha->optrom_buffer);
425 ha->optrom_buffer = NULL;
428 if (ha->optrom_state != QLA_SWAITING) {
433 ha->optrom_region_start = start;
434 ha->optrom_region_size = size;
436 ha->optrom_state = QLA_SREADING;
437 ha->optrom_buffer = vmalloc(ha->optrom_region_size);
438 if (ha->optrom_buffer == NULL) {
439 ql_log(ql_log_warn, vha, 0x7062,
440 "Unable to allocate memory for optrom retrieval "
441 "(%x).\n", ha->optrom_region_size);
443 ha->optrom_state = QLA_SWAITING;
448 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
449 ql_log(ql_log_warn, vha, 0x7063,
450 "HBA not online, failing NVRAM update.\n");
455 ql_dbg(ql_dbg_user, vha, 0x7064,
456 "Reading flash region -- 0x%x/0x%x.\n",
457 ha->optrom_region_start, ha->optrom_region_size);
459 memset(ha->optrom_buffer, 0, ha->optrom_region_size);
460 ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
461 ha->optrom_region_start, ha->optrom_region_size);
464 if (ha->optrom_state != QLA_SWAITING) {
470 * We need to be more restrictive on which FLASH regions are
471 * allowed to be updated via user-space. Regions accessible
472 * via this method include:
474 * ISP21xx/ISP22xx/ISP23xx type boards:
476 * 0x000000 -> 0x020000 -- Boot code.
478 * ISP2322/ISP24xx type boards:
480 * 0x000000 -> 0x07ffff -- Boot code.
481 * 0x080000 -> 0x0fffff -- Firmware.
483 * ISP25xx type boards:
485 * 0x000000 -> 0x07ffff -- Boot code.
486 * 0x080000 -> 0x0fffff -- Firmware.
487 * 0x120000 -> 0x12ffff -- VPD and HBA parameters.
490 if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0)
492 else if (start == (ha->flt_region_boot * 4) ||
493 start == (ha->flt_region_fw * 4))
495 else if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha)
496 || IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)
500 ql_log(ql_log_warn, vha, 0x7065,
501 "Invalid start region 0x%x/0x%x.\n", start, size);
506 ha->optrom_region_start = start;
507 ha->optrom_region_size = size;
509 ha->optrom_state = QLA_SWRITING;
510 ha->optrom_buffer = vmalloc(ha->optrom_region_size);
511 if (ha->optrom_buffer == NULL) {
512 ql_log(ql_log_warn, vha, 0x7066,
513 "Unable to allocate memory for optrom update "
514 "(%x)\n", ha->optrom_region_size);
516 ha->optrom_state = QLA_SWAITING;
521 ql_dbg(ql_dbg_user, vha, 0x7067,
522 "Staging flash region write -- 0x%x/0x%x.\n",
523 ha->optrom_region_start, ha->optrom_region_size);
525 memset(ha->optrom_buffer, 0, ha->optrom_region_size);
528 if (ha->optrom_state != QLA_SWRITING) {
533 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
534 ql_log(ql_log_warn, vha, 0x7068,
535 "HBA not online, failing flash update.\n");
540 ql_dbg(ql_dbg_user, vha, 0x7069,
541 "Writing flash region -- 0x%x/0x%x.\n",
542 ha->optrom_region_start, ha->optrom_region_size);
544 ha->isp_ops->write_optrom(vha, ha->optrom_buffer,
545 ha->optrom_region_start, ha->optrom_region_size);
552 mutex_unlock(&ha->optrom_mutex);
556 static struct bin_attribute sysfs_optrom_ctl_attr = {
558 .name = "optrom_ctl",
562 .write = qla2x00_sysfs_write_optrom_ctl,
566 qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj,
567 struct bin_attribute *bin_attr,
568 char *buf, loff_t off, size_t count)
570 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
571 struct device, kobj)));
572 struct qla_hw_data *ha = vha->hw;
574 if (unlikely(pci_channel_offline(ha->pdev)))
577 if (!capable(CAP_SYS_ADMIN))
580 if (IS_NOCACHE_VPD_TYPE(ha))
581 ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2,
583 return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size);
587 qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj,
588 struct bin_attribute *bin_attr,
589 char *buf, loff_t off, size_t count)
591 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
592 struct device, kobj)));
593 struct qla_hw_data *ha = vha->hw;
596 if (unlikely(pci_channel_offline(ha->pdev)))
599 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size ||
600 !ha->isp_ops->write_nvram)
603 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
604 ql_log(ql_log_warn, vha, 0x706a,
605 "HBA not online, failing VPD update.\n");
610 ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->vpd_base, count);
611 ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->vpd_base, count);
613 /* Update flash version information for 4Gb & above. */
614 if (!IS_FWI2_CAPABLE(ha))
617 tmp_data = vmalloc(256);
619 ql_log(ql_log_warn, vha, 0x706b,
620 "Unable to allocate memory for VPD information update.\n");
623 ha->isp_ops->get_flash_version(vha, tmp_data);
629 static struct bin_attribute sysfs_vpd_attr = {
632 .mode = S_IRUSR | S_IWUSR,
635 .read = qla2x00_sysfs_read_vpd,
636 .write = qla2x00_sysfs_write_vpd,
640 qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj,
641 struct bin_attribute *bin_attr,
642 char *buf, loff_t off, size_t count)
644 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
645 struct device, kobj)));
646 struct qla_hw_data *ha = vha->hw;
647 uint16_t iter, addr, offset;
650 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != SFP_DEV_SIZE * 2)
656 ha->sfp_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
659 ql_log(ql_log_warn, vha, 0x706c,
660 "Unable to allocate memory for SFP read-data.\n");
665 memset(ha->sfp_data, 0, SFP_BLOCK_SIZE);
667 for (iter = 0, offset = 0; iter < (SFP_DEV_SIZE * 2) / SFP_BLOCK_SIZE;
668 iter++, offset += SFP_BLOCK_SIZE) {
670 /* Skip to next device address. */
675 rval = qla2x00_read_sfp(vha, ha->sfp_data_dma, ha->sfp_data,
676 addr, offset, SFP_BLOCK_SIZE, BIT_1);
677 if (rval != QLA_SUCCESS) {
678 ql_log(ql_log_warn, vha, 0x706d,
679 "Unable to read SFP data (%x/%x/%x).\n", rval,
684 memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE);
685 buf += SFP_BLOCK_SIZE;
691 static struct bin_attribute sysfs_sfp_attr = {
694 .mode = S_IRUSR | S_IWUSR,
696 .size = SFP_DEV_SIZE * 2,
697 .read = qla2x00_sysfs_read_sfp,
701 qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
702 struct bin_attribute *bin_attr,
703 char *buf, loff_t off, size_t count)
705 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
706 struct device, kobj)));
707 struct qla_hw_data *ha = vha->hw;
708 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
710 uint32_t idc_control;
711 uint8_t *tmp_data = NULL;
715 type = simple_strtol(buf, NULL, 10);
718 ql_log(ql_log_info, vha, 0x706e,
719 "Issuing ISP reset.\n");
721 scsi_block_requests(vha->host);
722 if (IS_QLA82XX(ha)) {
723 ha->flags.isp82xx_no_md_cap = 1;
724 qla82xx_idc_lock(ha);
725 qla82xx_set_reset_owner(vha);
726 qla82xx_idc_unlock(ha);
727 } else if (IS_QLA8044(ha)) {
728 qla8044_idc_lock(ha);
729 idc_control = qla8044_rd_reg(ha,
730 QLA8044_IDC_DRV_CTRL);
731 qla8044_wr_reg(ha, QLA8044_IDC_DRV_CTRL,
732 (idc_control | GRACEFUL_RESET_BIT1));
733 qla82xx_set_reset_owner(vha);
734 qla8044_idc_unlock(ha);
736 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
737 qla2xxx_wake_dpc(vha);
739 qla2x00_wait_for_chip_reset(vha);
740 scsi_unblock_requests(vha->host);
743 if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha))
746 ql_log(ql_log_info, vha, 0x706f,
747 "Issuing MPI reset.\n");
749 if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
750 uint32_t idc_control;
752 qla83xx_idc_lock(vha, 0);
753 __qla83xx_get_idc_control(vha, &idc_control);
754 idc_control |= QLA83XX_IDC_GRACEFUL_RESET;
755 __qla83xx_set_idc_control(vha, idc_control);
756 qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE,
757 QLA8XXX_DEV_NEED_RESET);
758 qla83xx_idc_audit(vha, IDC_AUDIT_TIMESTAMP);
759 qla83xx_idc_unlock(vha, 0);
762 /* Make sure FC side is not in reset */
763 WARN_ON_ONCE(qla2x00_wait_for_hba_online(vha) !=
766 /* Issue MPI reset */
767 scsi_block_requests(vha->host);
768 if (qla81xx_restart_mpi_firmware(vha) != QLA_SUCCESS)
769 ql_log(ql_log_warn, vha, 0x7070,
770 "MPI reset failed.\n");
771 scsi_unblock_requests(vha->host);
775 if (!IS_P3P_TYPE(ha) || vha != base_vha) {
776 ql_log(ql_log_info, vha, 0x7071,
777 "FCoE ctx reset no supported.\n");
781 ql_log(ql_log_info, vha, 0x7072,
782 "Issuing FCoE ctx reset.\n");
783 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
784 qla2xxx_wake_dpc(vha);
785 qla2x00_wait_for_fcoe_ctx_reset(vha);
790 ql_log(ql_log_info, vha, 0x70bc,
791 "Disabling Reset by IDC control\n");
792 qla83xx_idc_lock(vha, 0);
793 __qla83xx_get_idc_control(vha, &idc_control);
794 idc_control |= QLA83XX_IDC_RESET_DISABLED;
795 __qla83xx_set_idc_control(vha, idc_control);
796 qla83xx_idc_unlock(vha, 0);
801 ql_log(ql_log_info, vha, 0x70bd,
802 "Enabling Reset by IDC control\n");
803 qla83xx_idc_lock(vha, 0);
804 __qla83xx_get_idc_control(vha, &idc_control);
805 idc_control &= ~QLA83XX_IDC_RESET_DISABLED;
806 __qla83xx_set_idc_control(vha, idc_control);
807 qla83xx_idc_unlock(vha, 0);
810 ql_dbg(ql_dbg_user, vha, 0x70e0,
811 "Updating cache versions without reset ");
813 tmp_data = vmalloc(256);
815 ql_log(ql_log_warn, vha, 0x70e1,
816 "Unable to allocate memory for VPD information update.\n");
819 ha->isp_ops->get_flash_version(vha, tmp_data);
826 static struct bin_attribute sysfs_reset_attr = {
832 .write = qla2x00_sysfs_write_reset,
836 qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct kobject *kobj,
837 struct bin_attribute *bin_attr,
838 char *buf, loff_t off, size_t count)
840 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
841 struct device, kobj)));
842 struct qla_hw_data *ha = vha->hw;
844 uint16_t actual_size;
846 if (!capable(CAP_SYS_ADMIN) || off != 0 || count > XGMAC_DATA_SIZE)
852 ha->xgmac_data = dma_alloc_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE,
853 &ha->xgmac_data_dma, GFP_KERNEL);
854 if (!ha->xgmac_data) {
855 ql_log(ql_log_warn, vha, 0x7076,
856 "Unable to allocate memory for XGMAC read-data.\n");
862 memset(ha->xgmac_data, 0, XGMAC_DATA_SIZE);
864 rval = qla2x00_get_xgmac_stats(vha, ha->xgmac_data_dma,
865 XGMAC_DATA_SIZE, &actual_size);
866 if (rval != QLA_SUCCESS) {
867 ql_log(ql_log_warn, vha, 0x7077,
868 "Unable to read XGMAC data (%x).\n", rval);
872 count = actual_size > count ? count: actual_size;
873 memcpy(buf, ha->xgmac_data, count);
878 static struct bin_attribute sysfs_xgmac_stats_attr = {
880 .name = "xgmac_stats",
884 .read = qla2x00_sysfs_read_xgmac_stats,
888 qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj,
889 struct bin_attribute *bin_attr,
890 char *buf, loff_t off, size_t count)
892 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
893 struct device, kobj)));
894 struct qla_hw_data *ha = vha->hw;
897 if (!capable(CAP_SYS_ADMIN) || off != 0 || count > DCBX_TLV_DATA_SIZE)
903 ha->dcbx_tlv = dma_alloc_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
904 &ha->dcbx_tlv_dma, GFP_KERNEL);
906 ql_log(ql_log_warn, vha, 0x7078,
907 "Unable to allocate memory for DCBX TLV read-data.\n");
912 memset(ha->dcbx_tlv, 0, DCBX_TLV_DATA_SIZE);
914 rval = qla2x00_get_dcbx_params(vha, ha->dcbx_tlv_dma,
916 if (rval != QLA_SUCCESS) {
917 ql_log(ql_log_warn, vha, 0x7079,
918 "Unable to read DCBX TLV (%x).\n", rval);
922 memcpy(buf, ha->dcbx_tlv, count);
927 static struct bin_attribute sysfs_dcbx_tlv_attr = {
933 .read = qla2x00_sysfs_read_dcbx_tlv,
936 static struct sysfs_entry {
938 struct bin_attribute *attr;
940 } bin_file_entries[] = {
941 { "fw_dump", &sysfs_fw_dump_attr, },
942 { "fw_dump_template", &sysfs_fw_dump_template_attr, 0x27 },
943 { "nvram", &sysfs_nvram_attr, },
944 { "optrom", &sysfs_optrom_attr, },
945 { "optrom_ctl", &sysfs_optrom_ctl_attr, },
946 { "vpd", &sysfs_vpd_attr, 1 },
947 { "sfp", &sysfs_sfp_attr, 1 },
948 { "reset", &sysfs_reset_attr, },
949 { "xgmac_stats", &sysfs_xgmac_stats_attr, 3 },
950 { "dcbx_tlv", &sysfs_dcbx_tlv_attr, 3 },
955 qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha)
957 struct Scsi_Host *host = vha->host;
958 struct sysfs_entry *iter;
961 for (iter = bin_file_entries; iter->name; iter++) {
962 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw))
964 if (iter->is4GBp_only == 2 && !IS_QLA25XX(vha->hw))
966 if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw)))
968 if (iter->is4GBp_only == 0x27 && !IS_QLA27XX(vha->hw))
971 ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
974 ql_log(ql_log_warn, vha, 0x00f3,
975 "Unable to create sysfs %s binary attribute (%d).\n",
978 ql_dbg(ql_dbg_init, vha, 0x00f4,
979 "Successfully created sysfs %s binary attribure.\n",
985 qla2x00_free_sysfs_attr(scsi_qla_host_t *vha, bool stop_beacon)
987 struct Scsi_Host *host = vha->host;
988 struct sysfs_entry *iter;
989 struct qla_hw_data *ha = vha->hw;
991 for (iter = bin_file_entries; iter->name; iter++) {
992 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
994 if (iter->is4GBp_only == 2 && !IS_QLA25XX(ha))
996 if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw)))
998 if (iter->is4GBp_only == 0x27 && !IS_QLA27XX(vha->hw))
1001 sysfs_remove_bin_file(&host->shost_gendev.kobj,
1005 if (stop_beacon && ha->beacon_blink_led == 1)
1006 ha->isp_ops->beacon_off(vha);
1009 /* Scsi_Host attributes. */
1012 qla2x00_drvr_version_show(struct device *dev,
1013 struct device_attribute *attr, char *buf)
1015 return scnprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str);
1019 qla2x00_fw_version_show(struct device *dev,
1020 struct device_attribute *attr, char *buf)
1022 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1023 struct qla_hw_data *ha = vha->hw;
1026 return scnprintf(buf, PAGE_SIZE, "%s\n",
1027 ha->isp_ops->fw_version_str(vha, fw_str, sizeof(fw_str)));
1031 qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr,
1034 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1035 struct qla_hw_data *ha = vha->hw;
1038 if (IS_QLAFX00(vha->hw)) {
1039 return scnprintf(buf, PAGE_SIZE, "%s\n",
1040 vha->hw->mr.serial_num);
1041 } else if (IS_FWI2_CAPABLE(ha)) {
1042 qla2xxx_get_vpd_field(vha, "SN", buf, PAGE_SIZE - 1);
1043 return strlen(strcat(buf, "\n"));
1046 sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
1047 return scnprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000,
1052 qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr,
1055 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1056 return scnprintf(buf, PAGE_SIZE, "ISP%04X\n", vha->hw->pdev->device);
1060 qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr,
1063 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1064 struct qla_hw_data *ha = vha->hw;
1066 if (IS_QLAFX00(vha->hw))
1067 return scnprintf(buf, PAGE_SIZE, "%s\n",
1068 vha->hw->mr.hw_version);
1070 return scnprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n",
1071 ha->product_id[0], ha->product_id[1], ha->product_id[2],
1076 qla2x00_model_name_show(struct device *dev, struct device_attribute *attr,
1079 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1081 return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_number);
1085 qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr,
1088 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1089 return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_desc);
1093 qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr,
1096 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1099 return scnprintf(buf, PAGE_SIZE, "%s\n",
1100 vha->hw->isp_ops->pci_info_str(vha, pci_info));
1104 qla2x00_link_state_show(struct device *dev, struct device_attribute *attr,
1107 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1108 struct qla_hw_data *ha = vha->hw;
1111 if (atomic_read(&vha->loop_state) == LOOP_DOWN ||
1112 atomic_read(&vha->loop_state) == LOOP_DEAD ||
1113 vha->device_flags & DFLG_NO_CABLE)
1114 len = scnprintf(buf, PAGE_SIZE, "Link Down\n");
1115 else if (atomic_read(&vha->loop_state) != LOOP_READY ||
1116 qla2x00_reset_active(vha))
1117 len = scnprintf(buf, PAGE_SIZE, "Unknown Link State\n");
1119 len = scnprintf(buf, PAGE_SIZE, "Link Up - ");
1121 switch (ha->current_topology) {
1123 len += scnprintf(buf + len, PAGE_SIZE-len, "Loop\n");
1126 len += scnprintf(buf + len, PAGE_SIZE-len, "FL_Port\n");
1129 len += scnprintf(buf + len, PAGE_SIZE-len,
1130 "N_Port to N_Port\n");
1133 len += scnprintf(buf + len, PAGE_SIZE-len, "F_Port\n");
1136 len += scnprintf(buf + len, PAGE_SIZE-len, "Loop\n");
1144 qla2x00_zio_show(struct device *dev, struct device_attribute *attr,
1147 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1150 switch (vha->hw->zio_mode) {
1151 case QLA_ZIO_MODE_6:
1152 len += scnprintf(buf + len, PAGE_SIZE-len, "Mode 6\n");
1154 case QLA_ZIO_DISABLED:
1155 len += scnprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
1162 qla2x00_zio_store(struct device *dev, struct device_attribute *attr,
1163 const char *buf, size_t count)
1165 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1166 struct qla_hw_data *ha = vha->hw;
1170 if (!IS_ZIO_SUPPORTED(ha))
1173 if (sscanf(buf, "%d", &val) != 1)
1177 zio_mode = QLA_ZIO_MODE_6;
1179 zio_mode = QLA_ZIO_DISABLED;
1181 /* Update per-hba values and queue a reset. */
1182 if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) {
1183 ha->zio_mode = zio_mode;
1184 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
1190 qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr,
1193 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1195 return scnprintf(buf, PAGE_SIZE, "%d us\n", vha->hw->zio_timer * 100);
1199 qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr,
1200 const char *buf, size_t count)
1202 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1206 if (sscanf(buf, "%d", &val) != 1)
1208 if (val > 25500 || val < 100)
1211 zio_timer = (uint16_t)(val / 100);
1212 vha->hw->zio_timer = zio_timer;
1218 qla2x00_beacon_show(struct device *dev, struct device_attribute *attr,
1221 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1224 if (vha->hw->beacon_blink_led)
1225 len += scnprintf(buf + len, PAGE_SIZE-len, "Enabled\n");
1227 len += scnprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
1232 qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
1233 const char *buf, size_t count)
1235 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1236 struct qla_hw_data *ha = vha->hw;
1240 if (IS_QLA2100(ha) || IS_QLA2200(ha))
1243 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) {
1244 ql_log(ql_log_warn, vha, 0x707a,
1245 "Abort ISP active -- ignoring beacon request.\n");
1249 if (sscanf(buf, "%d", &val) != 1)
1253 rval = ha->isp_ops->beacon_on(vha);
1255 rval = ha->isp_ops->beacon_off(vha);
1257 if (rval != QLA_SUCCESS)
1264 qla2x00_optrom_bios_version_show(struct device *dev,
1265 struct device_attribute *attr, char *buf)
1267 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1268 struct qla_hw_data *ha = vha->hw;
1269 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
1270 ha->bios_revision[0]);
1274 qla2x00_optrom_efi_version_show(struct device *dev,
1275 struct device_attribute *attr, char *buf)
1277 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1278 struct qla_hw_data *ha = vha->hw;
1279 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
1280 ha->efi_revision[0]);
1284 qla2x00_optrom_fcode_version_show(struct device *dev,
1285 struct device_attribute *attr, char *buf)
1287 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1288 struct qla_hw_data *ha = vha->hw;
1289 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
1290 ha->fcode_revision[0]);
1294 qla2x00_optrom_fw_version_show(struct device *dev,
1295 struct device_attribute *attr, char *buf)
1297 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1298 struct qla_hw_data *ha = vha->hw;
1299 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
1300 ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
1301 ha->fw_revision[3]);
1305 qla2x00_optrom_gold_fw_version_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 if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA27XX(ha))
1312 return scnprintf(buf, PAGE_SIZE, "\n");
1314 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%d)\n",
1315 ha->gold_fw_version[0], ha->gold_fw_version[1],
1316 ha->gold_fw_version[2], ha->gold_fw_version[3]);
1320 qla2x00_total_isp_aborts_show(struct device *dev,
1321 struct device_attribute *attr, char *buf)
1323 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1324 return scnprintf(buf, PAGE_SIZE, "%d\n",
1325 vha->qla_stats.total_isp_aborts);
1329 qla24xx_84xx_fw_version_show(struct device *dev,
1330 struct device_attribute *attr, char *buf)
1332 int rval = QLA_SUCCESS;
1333 uint16_t status[2] = {0, 0};
1334 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1335 struct qla_hw_data *ha = vha->hw;
1337 if (!IS_QLA84XX(ha))
1338 return scnprintf(buf, PAGE_SIZE, "\n");
1340 if (ha->cs84xx->op_fw_version == 0)
1341 rval = qla84xx_verify_chip(vha, status);
1343 if ((rval == QLA_SUCCESS) && (status[0] == 0))
1344 return scnprintf(buf, PAGE_SIZE, "%u\n",
1345 (uint32_t)ha->cs84xx->op_fw_version);
1347 return scnprintf(buf, PAGE_SIZE, "\n");
1351 qla2x00_mpi_version_show(struct device *dev, struct device_attribute *attr,
1354 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1355 struct qla_hw_data *ha = vha->hw;
1357 if (!IS_QLA81XX(ha) && !IS_QLA8031(ha) && !IS_QLA8044(ha) &&
1359 return scnprintf(buf, PAGE_SIZE, "\n");
1361 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
1362 ha->mpi_version[0], ha->mpi_version[1], ha->mpi_version[2],
1363 ha->mpi_capabilities);
1367 qla2x00_phy_version_show(struct device *dev, struct device_attribute *attr,
1370 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1371 struct qla_hw_data *ha = vha->hw;
1373 if (!IS_QLA81XX(ha) && !IS_QLA8031(ha))
1374 return scnprintf(buf, PAGE_SIZE, "\n");
1376 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
1377 ha->phy_version[0], ha->phy_version[1], ha->phy_version[2]);
1381 qla2x00_flash_block_size_show(struct device *dev,
1382 struct device_attribute *attr, char *buf)
1384 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1385 struct qla_hw_data *ha = vha->hw;
1387 return scnprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size);
1391 qla2x00_vlan_id_show(struct device *dev, struct device_attribute *attr,
1394 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1396 if (!IS_CNA_CAPABLE(vha->hw))
1397 return scnprintf(buf, PAGE_SIZE, "\n");
1399 return scnprintf(buf, PAGE_SIZE, "%d\n", vha->fcoe_vlan_id);
1403 qla2x00_vn_port_mac_address_show(struct device *dev,
1404 struct device_attribute *attr, char *buf)
1406 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1408 if (!IS_CNA_CAPABLE(vha->hw))
1409 return scnprintf(buf, PAGE_SIZE, "\n");
1411 return scnprintf(buf, PAGE_SIZE, "%pMR\n", vha->fcoe_vn_port_mac);
1415 qla2x00_fabric_param_show(struct device *dev, struct device_attribute *attr,
1418 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1420 return scnprintf(buf, PAGE_SIZE, "%d\n", vha->hw->switch_cap);
1424 qla2x00_thermal_temp_show(struct device *dev,
1425 struct device_attribute *attr, char *buf)
1427 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1430 if (qla2x00_reset_active(vha)) {
1431 ql_log(ql_log_warn, vha, 0x70dc, "ISP reset active.\n");
1435 if (vha->hw->flags.eeh_busy) {
1436 ql_log(ql_log_warn, vha, 0x70dd, "PCI EEH busy.\n");
1440 if (qla2x00_get_thermal_temp(vha, &temp) == QLA_SUCCESS)
1441 return scnprintf(buf, PAGE_SIZE, "%d\n", temp);
1444 return scnprintf(buf, PAGE_SIZE, "\n");
1448 qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
1451 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1452 int rval = QLA_FUNCTION_FAILED;
1456 if (IS_QLAFX00(vha->hw)) {
1457 pstate = qlafx00_fw_state_show(dev, attr, buf);
1458 return scnprintf(buf, PAGE_SIZE, "0x%x\n", pstate);
1461 if (qla2x00_reset_active(vha))
1462 ql_log(ql_log_warn, vha, 0x707c,
1463 "ISP reset active.\n");
1464 else if (!vha->hw->flags.eeh_busy)
1465 rval = qla2x00_get_firmware_state(vha, state);
1466 if (rval != QLA_SUCCESS)
1467 memset(state, -1, sizeof(state));
1469 return scnprintf(buf, PAGE_SIZE, "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1470 state[0], state[1], state[2], state[3], state[4], state[5]);
1474 qla2x00_diag_requests_show(struct device *dev,
1475 struct device_attribute *attr, char *buf)
1477 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1479 if (!IS_BIDI_CAPABLE(vha->hw))
1480 return scnprintf(buf, PAGE_SIZE, "\n");
1482 return scnprintf(buf, PAGE_SIZE, "%llu\n", vha->bidi_stats.io_count);
1486 qla2x00_diag_megabytes_show(struct device *dev,
1487 struct device_attribute *attr, char *buf)
1489 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1491 if (!IS_BIDI_CAPABLE(vha->hw))
1492 return scnprintf(buf, PAGE_SIZE, "\n");
1494 return scnprintf(buf, PAGE_SIZE, "%llu\n",
1495 vha->bidi_stats.transfer_bytes >> 20);
1499 qla2x00_fw_dump_size_show(struct device *dev, struct device_attribute *attr,
1502 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1503 struct qla_hw_data *ha = vha->hw;
1508 else if (IS_P3P_TYPE(ha))
1509 size = ha->md_template_size + ha->md_dump_size;
1511 size = ha->fw_dump_len;
1513 return scnprintf(buf, PAGE_SIZE, "%d\n", size);
1517 qla2x00_allow_cna_fw_dump_show(struct device *dev,
1518 struct device_attribute *attr, char *buf)
1520 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1522 if (!IS_P3P_TYPE(vha->hw))
1523 return scnprintf(buf, PAGE_SIZE, "\n");
1525 return scnprintf(buf, PAGE_SIZE, "%s\n",
1526 vha->hw->allow_cna_fw_dump ? "true" : "false");
1530 qla2x00_allow_cna_fw_dump_store(struct device *dev,
1531 struct device_attribute *attr, const char *buf, size_t count)
1533 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1536 if (!IS_P3P_TYPE(vha->hw))
1539 if (sscanf(buf, "%d", &val) != 1)
1542 vha->hw->allow_cna_fw_dump = val != 0;
1548 qla2x00_pep_version_show(struct device *dev, struct device_attribute *attr,
1551 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1552 struct qla_hw_data *ha = vha->hw;
1554 if (!IS_QLA27XX(ha))
1555 return scnprintf(buf, PAGE_SIZE, "\n");
1557 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
1558 ha->pep_version[0], ha->pep_version[1], ha->pep_version[2]);
1561 static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
1562 static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
1563 static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
1564 static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
1565 static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
1566 static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
1567 static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
1568 static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
1569 static DEVICE_ATTR(link_state, S_IRUGO, qla2x00_link_state_show, NULL);
1570 static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store);
1571 static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
1572 qla2x00_zio_timer_store);
1573 static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
1574 qla2x00_beacon_store);
1575 static DEVICE_ATTR(optrom_bios_version, S_IRUGO,
1576 qla2x00_optrom_bios_version_show, NULL);
1577 static DEVICE_ATTR(optrom_efi_version, S_IRUGO,
1578 qla2x00_optrom_efi_version_show, NULL);
1579 static DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
1580 qla2x00_optrom_fcode_version_show, NULL);
1581 static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show,
1583 static DEVICE_ATTR(optrom_gold_fw_version, S_IRUGO,
1584 qla2x00_optrom_gold_fw_version_show, NULL);
1585 static DEVICE_ATTR(84xx_fw_version, S_IRUGO, qla24xx_84xx_fw_version_show,
1587 static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show,
1589 static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL);
1590 static DEVICE_ATTR(phy_version, S_IRUGO, qla2x00_phy_version_show, NULL);
1591 static DEVICE_ATTR(flash_block_size, S_IRUGO, qla2x00_flash_block_size_show,
1593 static DEVICE_ATTR(vlan_id, S_IRUGO, qla2x00_vlan_id_show, NULL);
1594 static DEVICE_ATTR(vn_port_mac_address, S_IRUGO,
1595 qla2x00_vn_port_mac_address_show, NULL);
1596 static DEVICE_ATTR(fabric_param, S_IRUGO, qla2x00_fabric_param_show, NULL);
1597 static DEVICE_ATTR(fw_state, S_IRUGO, qla2x00_fw_state_show, NULL);
1598 static DEVICE_ATTR(thermal_temp, S_IRUGO, qla2x00_thermal_temp_show, NULL);
1599 static DEVICE_ATTR(diag_requests, S_IRUGO, qla2x00_diag_requests_show, NULL);
1600 static DEVICE_ATTR(diag_megabytes, S_IRUGO, qla2x00_diag_megabytes_show, NULL);
1601 static DEVICE_ATTR(fw_dump_size, S_IRUGO, qla2x00_fw_dump_size_show, NULL);
1602 static DEVICE_ATTR(allow_cna_fw_dump, S_IRUGO | S_IWUSR,
1603 qla2x00_allow_cna_fw_dump_show,
1604 qla2x00_allow_cna_fw_dump_store);
1605 static DEVICE_ATTR(pep_version, S_IRUGO, qla2x00_pep_version_show, NULL);
1607 struct device_attribute *qla2x00_host_attrs[] = {
1608 &dev_attr_driver_version,
1609 &dev_attr_fw_version,
1610 &dev_attr_serial_num,
1613 &dev_attr_model_name,
1614 &dev_attr_model_desc,
1616 &dev_attr_link_state,
1618 &dev_attr_zio_timer,
1620 &dev_attr_optrom_bios_version,
1621 &dev_attr_optrom_efi_version,
1622 &dev_attr_optrom_fcode_version,
1623 &dev_attr_optrom_fw_version,
1624 &dev_attr_84xx_fw_version,
1625 &dev_attr_total_isp_aborts,
1626 &dev_attr_mpi_version,
1627 &dev_attr_phy_version,
1628 &dev_attr_flash_block_size,
1630 &dev_attr_vn_port_mac_address,
1631 &dev_attr_fabric_param,
1633 &dev_attr_optrom_gold_fw_version,
1634 &dev_attr_thermal_temp,
1635 &dev_attr_diag_requests,
1636 &dev_attr_diag_megabytes,
1637 &dev_attr_fw_dump_size,
1638 &dev_attr_allow_cna_fw_dump,
1639 &dev_attr_pep_version,
1643 /* Host attributes. */
1646 qla2x00_get_host_port_id(struct Scsi_Host *shost)
1648 scsi_qla_host_t *vha = shost_priv(shost);
1650 fc_host_port_id(shost) = vha->d_id.b.domain << 16 |
1651 vha->d_id.b.area << 8 | vha->d_id.b.al_pa;
1655 qla2x00_get_host_speed(struct Scsi_Host *shost)
1657 struct qla_hw_data *ha = ((struct scsi_qla_host *)
1658 (shost_priv(shost)))->hw;
1659 u32 speed = FC_PORTSPEED_UNKNOWN;
1661 if (IS_QLAFX00(ha)) {
1662 qlafx00_get_host_speed(shost);
1666 switch (ha->link_data_rate) {
1667 case PORT_SPEED_1GB:
1668 speed = FC_PORTSPEED_1GBIT;
1670 case PORT_SPEED_2GB:
1671 speed = FC_PORTSPEED_2GBIT;
1673 case PORT_SPEED_4GB:
1674 speed = FC_PORTSPEED_4GBIT;
1676 case PORT_SPEED_8GB:
1677 speed = FC_PORTSPEED_8GBIT;
1679 case PORT_SPEED_10GB:
1680 speed = FC_PORTSPEED_10GBIT;
1682 case PORT_SPEED_16GB:
1683 speed = FC_PORTSPEED_16GBIT;
1685 case PORT_SPEED_32GB:
1686 speed = FC_PORTSPEED_32GBIT;
1689 fc_host_speed(shost) = speed;
1693 qla2x00_get_host_port_type(struct Scsi_Host *shost)
1695 scsi_qla_host_t *vha = shost_priv(shost);
1696 uint32_t port_type = FC_PORTTYPE_UNKNOWN;
1699 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
1702 switch (vha->hw->current_topology) {
1704 port_type = FC_PORTTYPE_LPORT;
1707 port_type = FC_PORTTYPE_NLPORT;
1710 port_type = FC_PORTTYPE_PTP;
1713 port_type = FC_PORTTYPE_NPORT;
1716 fc_host_port_type(shost) = port_type;
1720 qla2x00_get_starget_node_name(struct scsi_target *starget)
1722 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
1723 scsi_qla_host_t *vha = shost_priv(host);
1727 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1728 if (fcport->rport &&
1729 starget->id == fcport->rport->scsi_target_id) {
1730 node_name = wwn_to_u64(fcport->node_name);
1735 fc_starget_node_name(starget) = node_name;
1739 qla2x00_get_starget_port_name(struct scsi_target *starget)
1741 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
1742 scsi_qla_host_t *vha = shost_priv(host);
1746 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1747 if (fcport->rport &&
1748 starget->id == fcport->rport->scsi_target_id) {
1749 port_name = wwn_to_u64(fcport->port_name);
1754 fc_starget_port_name(starget) = port_name;
1758 qla2x00_get_starget_port_id(struct scsi_target *starget)
1760 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
1761 scsi_qla_host_t *vha = shost_priv(host);
1763 uint32_t port_id = ~0U;
1765 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1766 if (fcport->rport &&
1767 starget->id == fcport->rport->scsi_target_id) {
1768 port_id = fcport->d_id.b.domain << 16 |
1769 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
1774 fc_starget_port_id(starget) = port_id;
1778 qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
1781 rport->dev_loss_tmo = timeout;
1783 rport->dev_loss_tmo = 1;
1787 qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
1789 struct Scsi_Host *host = rport_to_shost(rport);
1790 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
1791 unsigned long flags;
1796 /* Now that the rport has been deleted, set the fcport state to
1798 qla2x00_set_fcport_state(fcport, FCS_DEVICE_DEAD);
1801 * Transport has effectively 'deleted' the rport, clear
1802 * all local references.
1804 spin_lock_irqsave(host->host_lock, flags);
1805 fcport->rport = fcport->drport = NULL;
1806 *((fc_port_t **)rport->dd_data) = NULL;
1807 spin_unlock_irqrestore(host->host_lock, flags);
1809 if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
1812 if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
1813 qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
1819 qla2x00_terminate_rport_io(struct fc_rport *rport)
1821 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
1826 if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
1829 if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
1830 qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
1834 * At this point all fcport's software-states are cleared. Perform any
1835 * final cleanup of firmware resources (PCBs and XCBs).
1837 if (fcport->loop_id != FC_NO_LOOP_ID) {
1838 if (IS_FWI2_CAPABLE(fcport->vha->hw))
1839 fcport->vha->hw->isp_ops->fabric_logout(fcport->vha,
1840 fcport->loop_id, fcport->d_id.b.domain,
1841 fcport->d_id.b.area, fcport->d_id.b.al_pa);
1843 qla2x00_port_logout(fcport->vha, fcport);
1848 qla2x00_issue_lip(struct Scsi_Host *shost)
1850 scsi_qla_host_t *vha = shost_priv(shost);
1852 if (IS_QLAFX00(vha->hw))
1855 qla2x00_loop_reset(vha);
1859 static struct fc_host_statistics *
1860 qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1862 scsi_qla_host_t *vha = shost_priv(shost);
1863 struct qla_hw_data *ha = vha->hw;
1864 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
1866 struct link_statistics *stats;
1867 dma_addr_t stats_dma;
1868 struct fc_host_statistics *pfc_host_stat;
1870 pfc_host_stat = &vha->fc_host_stat;
1871 memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics));
1873 if (IS_QLAFX00(vha->hw))
1876 if (test_bit(UNLOADING, &vha->dpc_flags))
1879 if (unlikely(pci_channel_offline(ha->pdev)))
1882 if (qla2x00_reset_active(vha))
1885 stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma);
1886 if (stats == NULL) {
1887 ql_log(ql_log_warn, vha, 0x707d,
1888 "Failed to allocate memory for stats.\n");
1891 memset(stats, 0, DMA_POOL_SIZE);
1893 rval = QLA_FUNCTION_FAILED;
1894 if (IS_FWI2_CAPABLE(ha)) {
1895 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma);
1896 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
1898 /* Must be in a 'READY' state for statistics retrieval. */
1899 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id,
1903 if (rval != QLA_SUCCESS)
1906 pfc_host_stat->link_failure_count = stats->link_fail_cnt;
1907 pfc_host_stat->loss_of_sync_count = stats->loss_sync_cnt;
1908 pfc_host_stat->loss_of_signal_count = stats->loss_sig_cnt;
1909 pfc_host_stat->prim_seq_protocol_err_count = stats->prim_seq_err_cnt;
1910 pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt;
1911 pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt;
1912 if (IS_FWI2_CAPABLE(ha)) {
1913 pfc_host_stat->lip_count = stats->lip_cnt;
1914 pfc_host_stat->tx_frames = stats->tx_frames;
1915 pfc_host_stat->rx_frames = stats->rx_frames;
1916 pfc_host_stat->dumped_frames = stats->discarded_frames;
1917 pfc_host_stat->nos_count = stats->nos_rcvd;
1918 pfc_host_stat->error_frames =
1919 stats->dropped_frames + stats->discarded_frames;
1920 pfc_host_stat->rx_words = vha->qla_stats.input_bytes;
1921 pfc_host_stat->tx_words = vha->qla_stats.output_bytes;
1923 pfc_host_stat->fcp_control_requests = vha->qla_stats.control_requests;
1924 pfc_host_stat->fcp_input_requests = vha->qla_stats.input_requests;
1925 pfc_host_stat->fcp_output_requests = vha->qla_stats.output_requests;
1926 pfc_host_stat->fcp_input_megabytes = vha->qla_stats.input_bytes >> 20;
1927 pfc_host_stat->fcp_output_megabytes = vha->qla_stats.output_bytes >> 20;
1928 pfc_host_stat->seconds_since_last_reset =
1929 get_jiffies_64() - vha->qla_stats.jiffies_at_last_reset;
1930 do_div(pfc_host_stat->seconds_since_last_reset, HZ);
1933 dma_pool_free(ha->s_dma_pool, stats, stats_dma);
1935 return pfc_host_stat;
1939 qla2x00_reset_host_stats(struct Scsi_Host *shost)
1941 scsi_qla_host_t *vha = shost_priv(shost);
1943 memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat));
1945 vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
1949 qla2x00_get_host_symbolic_name(struct Scsi_Host *shost)
1951 scsi_qla_host_t *vha = shost_priv(shost);
1953 qla2x00_get_sym_node_name(vha, fc_host_symbolic_name(shost),
1954 sizeof(fc_host_symbolic_name(shost)));
1958 qla2x00_set_host_system_hostname(struct Scsi_Host *shost)
1960 scsi_qla_host_t *vha = shost_priv(shost);
1962 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
1966 qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
1968 scsi_qla_host_t *vha = shost_priv(shost);
1969 uint8_t node_name[WWN_SIZE] = { 0xFF, 0xFF, 0xFF, 0xFF, \
1970 0xFF, 0xFF, 0xFF, 0xFF};
1971 u64 fabric_name = wwn_to_u64(node_name);
1973 if (vha->device_flags & SWITCH_FOUND)
1974 fabric_name = wwn_to_u64(vha->fabric_node_name);
1976 fc_host_fabric_name(shost) = fabric_name;
1980 qla2x00_get_host_port_state(struct Scsi_Host *shost)
1982 scsi_qla_host_t *vha = shost_priv(shost);
1983 struct scsi_qla_host *base_vha = pci_get_drvdata(vha->hw->pdev);
1985 if (!base_vha->flags.online) {
1986 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
1990 switch (atomic_read(&base_vha->loop_state)) {
1992 fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS;
1995 if (test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags))
1996 fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS;
1998 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
2001 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
2004 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
2007 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
2013 qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
2017 scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
2018 scsi_qla_host_t *vha = NULL;
2019 struct qla_hw_data *ha = base_vha->hw;
2020 uint16_t options = 0;
2022 struct req_que *req = ha->req_q_map[0];
2024 ret = qla24xx_vport_create_req_sanity_check(fc_vport);
2026 ql_log(ql_log_warn, vha, 0x707e,
2027 "Vport sanity check failed, status %x\n", ret);
2031 vha = qla24xx_create_vhost(fc_vport);
2033 ql_log(ql_log_warn, vha, 0x707f, "Vport create host failed.\n");
2034 return FC_VPORT_FAILED;
2037 atomic_set(&vha->vp_state, VP_OFFLINE);
2038 fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
2040 atomic_set(&vha->vp_state, VP_FAILED);
2042 /* ready to create vport */
2043 ql_log(ql_log_info, vha, 0x7080,
2044 "VP entry id %d assigned.\n", vha->vp_idx);
2046 /* initialized vport states */
2047 atomic_set(&vha->loop_state, LOOP_DOWN);
2048 vha->vp_err_state= VP_ERR_PORTDWN;
2049 vha->vp_prev_err_state= VP_ERR_UNKWN;
2050 /* Check if physical ha port is Up */
2051 if (atomic_read(&base_vha->loop_state) == LOOP_DOWN ||
2052 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
2053 /* Don't retry or attempt login of this virtual port */
2054 ql_dbg(ql_dbg_user, vha, 0x7081,
2055 "Vport loop state is not UP.\n");
2056 atomic_set(&vha->loop_state, LOOP_DEAD);
2058 fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN);
2061 if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) {
2062 if (ha->fw_attributes & BIT_4) {
2063 int prot = 0, guard;
2064 vha->flags.difdix_supported = 1;
2065 ql_dbg(ql_dbg_user, vha, 0x7082,
2066 "Registered for DIF/DIX type 1 and 3 protection.\n");
2067 if (ql2xenabledif == 1)
2068 prot = SHOST_DIX_TYPE0_PROTECTION;
2069 scsi_host_set_prot(vha->host,
2070 prot | SHOST_DIF_TYPE1_PROTECTION
2071 | SHOST_DIF_TYPE2_PROTECTION
2072 | SHOST_DIF_TYPE3_PROTECTION
2073 | SHOST_DIX_TYPE1_PROTECTION
2074 | SHOST_DIX_TYPE2_PROTECTION
2075 | SHOST_DIX_TYPE3_PROTECTION);
2077 guard = SHOST_DIX_GUARD_CRC;
2079 if (IS_PI_IPGUARD_CAPABLE(ha) &&
2080 (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha)))
2081 guard |= SHOST_DIX_GUARD_IP;
2083 scsi_host_set_guard(vha->host, guard);
2085 vha->flags.difdix_supported = 0;
2088 if (scsi_add_host_with_dma(vha->host, &fc_vport->dev,
2090 ql_dbg(ql_dbg_user, vha, 0x7083,
2091 "scsi_add_host failure for VP[%d].\n", vha->vp_idx);
2092 goto vport_create_failed_2;
2095 /* initialize attributes */
2096 fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count;
2097 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
2098 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
2099 fc_host_supported_classes(vha->host) =
2100 fc_host_supported_classes(base_vha->host);
2101 fc_host_supported_speeds(vha->host) =
2102 fc_host_supported_speeds(base_vha->host);
2104 qlt_vport_create(vha, ha);
2105 qla24xx_vport_disable(fc_vport, disable);
2107 if (ha->flags.cpu_affinity_enabled) {
2108 req = ha->req_q_map[1];
2109 ql_dbg(ql_dbg_multiq, vha, 0xc000,
2110 "Request queue %p attached with "
2111 "VP[%d], cpu affinity =%d\n",
2112 req, vha->vp_idx, ha->flags.cpu_affinity_enabled);
2114 } else if (ql2xmaxqueues == 1 || !ha->npiv_info)
2116 /* Create a request queue in QoS mode for the vport */
2117 for (cnt = 0; cnt < ha->nvram_npiv_size; cnt++) {
2118 if (memcmp(ha->npiv_info[cnt].port_name, vha->port_name, 8) == 0
2119 && memcmp(ha->npiv_info[cnt].node_name, vha->node_name,
2121 qos = ha->npiv_info[cnt].q_qos;
2127 ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, 0,
2130 ql_log(ql_log_warn, vha, 0x7084,
2131 "Can't create request queue for VP[%d]\n",
2134 ql_dbg(ql_dbg_multiq, vha, 0xc001,
2135 "Request Que:%d Q0s: %d) created for VP[%d]\n",
2136 ret, qos, vha->vp_idx);
2137 ql_dbg(ql_dbg_user, vha, 0x7085,
2138 "Request Que:%d Q0s: %d) created for VP[%d]\n",
2139 ret, qos, vha->vp_idx);
2140 req = ha->req_q_map[ret];
2148 vport_create_failed_2:
2149 qla24xx_disable_vp(vha);
2150 qla24xx_deallocate_vp_id(vha);
2151 scsi_host_put(vha->host);
2152 return FC_VPORT_FAILED;
2156 qla24xx_vport_delete(struct fc_vport *fc_vport)
2158 scsi_qla_host_t *vha = fc_vport->dd_data;
2159 struct qla_hw_data *ha = vha->hw;
2160 uint16_t id = vha->vp_idx;
2162 while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
2163 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
2166 qla24xx_disable_vp(vha);
2168 vha->flags.delete_progress = 1;
2170 qlt_remove_target(ha, vha);
2172 fc_remove_host(vha->host);
2174 scsi_remove_host(vha->host);
2176 /* Allow timer to run to drain queued items, when removing vp */
2177 qla24xx_deallocate_vp_id(vha);
2179 if (vha->timer_active) {
2180 qla2x00_vp_stop_timer(vha);
2181 ql_dbg(ql_dbg_user, vha, 0x7086,
2182 "Timer for the VP[%d] has stopped\n", vha->vp_idx);
2185 BUG_ON(atomic_read(&vha->vref_count));
2187 qla2x00_free_fcports(vha);
2189 mutex_lock(&ha->vport_lock);
2190 ha->cur_vport_count--;
2191 clear_bit(vha->vp_idx, ha->vp_idx_map);
2192 mutex_unlock(&ha->vport_lock);
2194 if (vha->req->id && !ha->flags.cpu_affinity_enabled) {
2195 if (qla25xx_delete_req_que(vha, vha->req) != QLA_SUCCESS)
2196 ql_log(ql_log_warn, vha, 0x7087,
2197 "Queue delete failed.\n");
2200 ql_log(ql_log_info, vha, 0x7088, "VP[%d] deleted.\n", id);
2201 scsi_host_put(vha->host);
2206 qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
2208 scsi_qla_host_t *vha = fc_vport->dd_data;
2211 qla24xx_disable_vp(vha);
2213 qla24xx_enable_vp(vha);
2218 struct fc_function_template qla2xxx_transport_functions = {
2220 .show_host_node_name = 1,
2221 .show_host_port_name = 1,
2222 .show_host_supported_classes = 1,
2223 .show_host_supported_speeds = 1,
2225 .get_host_port_id = qla2x00_get_host_port_id,
2226 .show_host_port_id = 1,
2227 .get_host_speed = qla2x00_get_host_speed,
2228 .show_host_speed = 1,
2229 .get_host_port_type = qla2x00_get_host_port_type,
2230 .show_host_port_type = 1,
2231 .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
2232 .show_host_symbolic_name = 1,
2233 .set_host_system_hostname = qla2x00_set_host_system_hostname,
2234 .show_host_system_hostname = 1,
2235 .get_host_fabric_name = qla2x00_get_host_fabric_name,
2236 .show_host_fabric_name = 1,
2237 .get_host_port_state = qla2x00_get_host_port_state,
2238 .show_host_port_state = 1,
2240 .dd_fcrport_size = sizeof(struct fc_port *),
2241 .show_rport_supported_classes = 1,
2243 .get_starget_node_name = qla2x00_get_starget_node_name,
2244 .show_starget_node_name = 1,
2245 .get_starget_port_name = qla2x00_get_starget_port_name,
2246 .show_starget_port_name = 1,
2247 .get_starget_port_id = qla2x00_get_starget_port_id,
2248 .show_starget_port_id = 1,
2250 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
2251 .show_rport_dev_loss_tmo = 1,
2253 .issue_fc_host_lip = qla2x00_issue_lip,
2254 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
2255 .terminate_rport_io = qla2x00_terminate_rport_io,
2256 .get_fc_host_stats = qla2x00_get_fc_host_stats,
2257 .reset_fc_host_stats = qla2x00_reset_host_stats,
2259 .vport_create = qla24xx_vport_create,
2260 .vport_disable = qla24xx_vport_disable,
2261 .vport_delete = qla24xx_vport_delete,
2262 .bsg_request = qla24xx_bsg_request,
2263 .bsg_timeout = qla24xx_bsg_timeout,
2266 struct fc_function_template qla2xxx_transport_vport_functions = {
2268 .show_host_node_name = 1,
2269 .show_host_port_name = 1,
2270 .show_host_supported_classes = 1,
2272 .get_host_port_id = qla2x00_get_host_port_id,
2273 .show_host_port_id = 1,
2274 .get_host_speed = qla2x00_get_host_speed,
2275 .show_host_speed = 1,
2276 .get_host_port_type = qla2x00_get_host_port_type,
2277 .show_host_port_type = 1,
2278 .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
2279 .show_host_symbolic_name = 1,
2280 .set_host_system_hostname = qla2x00_set_host_system_hostname,
2281 .show_host_system_hostname = 1,
2282 .get_host_fabric_name = qla2x00_get_host_fabric_name,
2283 .show_host_fabric_name = 1,
2284 .get_host_port_state = qla2x00_get_host_port_state,
2285 .show_host_port_state = 1,
2287 .dd_fcrport_size = sizeof(struct fc_port *),
2288 .show_rport_supported_classes = 1,
2290 .get_starget_node_name = qla2x00_get_starget_node_name,
2291 .show_starget_node_name = 1,
2292 .get_starget_port_name = qla2x00_get_starget_port_name,
2293 .show_starget_port_name = 1,
2294 .get_starget_port_id = qla2x00_get_starget_port_id,
2295 .show_starget_port_id = 1,
2297 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
2298 .show_rport_dev_loss_tmo = 1,
2300 .issue_fc_host_lip = qla2x00_issue_lip,
2301 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
2302 .terminate_rport_io = qla2x00_terminate_rport_io,
2303 .get_fc_host_stats = qla2x00_get_fc_host_stats,
2304 .reset_fc_host_stats = qla2x00_reset_host_stats,
2306 .bsg_request = qla24xx_bsg_request,
2307 .bsg_timeout = qla24xx_bsg_timeout,
2311 qla2x00_init_host_attr(scsi_qla_host_t *vha)
2313 struct qla_hw_data *ha = vha->hw;
2314 u32 speed = FC_PORTSPEED_UNKNOWN;
2316 fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count;
2317 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
2318 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
2319 fc_host_supported_classes(vha->host) = ha->tgt.enable_class_2 ?
2320 (FC_COS_CLASS2|FC_COS_CLASS3) : FC_COS_CLASS3;
2321 fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports;
2322 fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count;
2324 if (IS_CNA_CAPABLE(ha))
2325 speed = FC_PORTSPEED_10GBIT;
2326 else if (IS_QLA2031(ha))
2327 speed = FC_PORTSPEED_16GBIT | FC_PORTSPEED_8GBIT |
2329 else if (IS_QLA25XX(ha))
2330 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
2331 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
2332 else if (IS_QLA24XX_TYPE(ha))
2333 speed = FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT |
2335 else if (IS_QLA23XX(ha))
2336 speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
2337 else if (IS_QLAFX00(ha))
2338 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
2339 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
2340 else if (IS_QLA27XX(ha))
2341 speed = FC_PORTSPEED_32GBIT | FC_PORTSPEED_16GBIT |
2344 speed = FC_PORTSPEED_1GBIT;
2345 fc_host_supported_speeds(vha->host) = speed;