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 = start + 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 = start + 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 qla2x00_wait_for_hba_online(vha);
765 /* Issue MPI reset */
766 scsi_block_requests(vha->host);
767 if (qla81xx_restart_mpi_firmware(vha) != QLA_SUCCESS)
768 ql_log(ql_log_warn, vha, 0x7070,
769 "MPI reset failed.\n");
770 scsi_unblock_requests(vha->host);
774 if (!IS_P3P_TYPE(ha) || vha != base_vha) {
775 ql_log(ql_log_info, vha, 0x7071,
776 "FCoE ctx reset no supported.\n");
780 ql_log(ql_log_info, vha, 0x7072,
781 "Issuing FCoE ctx reset.\n");
782 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
783 qla2xxx_wake_dpc(vha);
784 qla2x00_wait_for_fcoe_ctx_reset(vha);
789 ql_log(ql_log_info, vha, 0x70bc,
790 "Disabling Reset by IDC control\n");
791 qla83xx_idc_lock(vha, 0);
792 __qla83xx_get_idc_control(vha, &idc_control);
793 idc_control |= QLA83XX_IDC_RESET_DISABLED;
794 __qla83xx_set_idc_control(vha, idc_control);
795 qla83xx_idc_unlock(vha, 0);
800 ql_log(ql_log_info, vha, 0x70bd,
801 "Enabling Reset by IDC control\n");
802 qla83xx_idc_lock(vha, 0);
803 __qla83xx_get_idc_control(vha, &idc_control);
804 idc_control &= ~QLA83XX_IDC_RESET_DISABLED;
805 __qla83xx_set_idc_control(vha, idc_control);
806 qla83xx_idc_unlock(vha, 0);
809 ql_dbg(ql_dbg_user, vha, 0x70e0,
810 "Updating cache versions without reset ");
812 tmp_data = vmalloc(256);
814 ql_log(ql_log_warn, vha, 0x70e1,
815 "Unable to allocate memory for VPD information update.\n");
818 ha->isp_ops->get_flash_version(vha, tmp_data);
825 static struct bin_attribute sysfs_reset_attr = {
831 .write = qla2x00_sysfs_write_reset,
835 qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct kobject *kobj,
836 struct bin_attribute *bin_attr,
837 char *buf, loff_t off, size_t count)
839 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
840 struct device, kobj)));
841 struct qla_hw_data *ha = vha->hw;
843 uint16_t actual_size;
845 if (!capable(CAP_SYS_ADMIN) || off != 0 || count > XGMAC_DATA_SIZE)
851 ha->xgmac_data = dma_alloc_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE,
852 &ha->xgmac_data_dma, GFP_KERNEL);
853 if (!ha->xgmac_data) {
854 ql_log(ql_log_warn, vha, 0x7076,
855 "Unable to allocate memory for XGMAC read-data.\n");
861 memset(ha->xgmac_data, 0, XGMAC_DATA_SIZE);
863 rval = qla2x00_get_xgmac_stats(vha, ha->xgmac_data_dma,
864 XGMAC_DATA_SIZE, &actual_size);
865 if (rval != QLA_SUCCESS) {
866 ql_log(ql_log_warn, vha, 0x7077,
867 "Unable to read XGMAC data (%x).\n", rval);
871 count = actual_size > count ? count: actual_size;
872 memcpy(buf, ha->xgmac_data, count);
877 static struct bin_attribute sysfs_xgmac_stats_attr = {
879 .name = "xgmac_stats",
883 .read = qla2x00_sysfs_read_xgmac_stats,
887 qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj,
888 struct bin_attribute *bin_attr,
889 char *buf, loff_t off, size_t count)
891 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
892 struct device, kobj)));
893 struct qla_hw_data *ha = vha->hw;
896 if (!capable(CAP_SYS_ADMIN) || off != 0 || count > DCBX_TLV_DATA_SIZE)
902 ha->dcbx_tlv = dma_alloc_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
903 &ha->dcbx_tlv_dma, GFP_KERNEL);
905 ql_log(ql_log_warn, vha, 0x7078,
906 "Unable to allocate memory for DCBX TLV read-data.\n");
911 memset(ha->dcbx_tlv, 0, DCBX_TLV_DATA_SIZE);
913 rval = qla2x00_get_dcbx_params(vha, ha->dcbx_tlv_dma,
915 if (rval != QLA_SUCCESS) {
916 ql_log(ql_log_warn, vha, 0x7079,
917 "Unable to read DCBX TLV (%x).\n", rval);
921 memcpy(buf, ha->dcbx_tlv, count);
926 static struct bin_attribute sysfs_dcbx_tlv_attr = {
932 .read = qla2x00_sysfs_read_dcbx_tlv,
935 static struct sysfs_entry {
937 struct bin_attribute *attr;
939 } bin_file_entries[] = {
940 { "fw_dump", &sysfs_fw_dump_attr, },
941 { "fw_dump_template", &sysfs_fw_dump_template_attr, 0x27 },
942 { "nvram", &sysfs_nvram_attr, },
943 { "optrom", &sysfs_optrom_attr, },
944 { "optrom_ctl", &sysfs_optrom_ctl_attr, },
945 { "vpd", &sysfs_vpd_attr, 1 },
946 { "sfp", &sysfs_sfp_attr, 1 },
947 { "reset", &sysfs_reset_attr, },
948 { "xgmac_stats", &sysfs_xgmac_stats_attr, 3 },
949 { "dcbx_tlv", &sysfs_dcbx_tlv_attr, 3 },
954 qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha)
956 struct Scsi_Host *host = vha->host;
957 struct sysfs_entry *iter;
960 for (iter = bin_file_entries; iter->name; iter++) {
961 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw))
963 if (iter->is4GBp_only == 2 && !IS_QLA25XX(vha->hw))
965 if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw)))
967 if (iter->is4GBp_only == 0x27 && !IS_QLA27XX(vha->hw))
970 ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
973 ql_log(ql_log_warn, vha, 0x00f3,
974 "Unable to create sysfs %s binary attribute (%d).\n",
977 ql_dbg(ql_dbg_init, vha, 0x00f4,
978 "Successfully created sysfs %s binary attribure.\n",
984 qla2x00_free_sysfs_attr(scsi_qla_host_t *vha, bool stop_beacon)
986 struct Scsi_Host *host = vha->host;
987 struct sysfs_entry *iter;
988 struct qla_hw_data *ha = vha->hw;
990 for (iter = bin_file_entries; iter->name; iter++) {
991 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
993 if (iter->is4GBp_only == 2 && !IS_QLA25XX(ha))
995 if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw)))
997 if (iter->is4GBp_only == 0x27 && !IS_QLA27XX(vha->hw))
1000 sysfs_remove_bin_file(&host->shost_gendev.kobj,
1004 if (stop_beacon && ha->beacon_blink_led == 1)
1005 ha->isp_ops->beacon_off(vha);
1008 /* Scsi_Host attributes. */
1011 qla2x00_drvr_version_show(struct device *dev,
1012 struct device_attribute *attr, char *buf)
1014 return scnprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str);
1018 qla2x00_fw_version_show(struct device *dev,
1019 struct device_attribute *attr, char *buf)
1021 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1022 struct qla_hw_data *ha = vha->hw;
1025 return scnprintf(buf, PAGE_SIZE, "%s\n",
1026 ha->isp_ops->fw_version_str(vha, fw_str, sizeof(fw_str)));
1030 qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr,
1033 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1034 struct qla_hw_data *ha = vha->hw;
1037 if (IS_QLAFX00(vha->hw)) {
1038 return scnprintf(buf, PAGE_SIZE, "%s\n",
1039 vha->hw->mr.serial_num);
1040 } else if (IS_FWI2_CAPABLE(ha)) {
1041 qla2xxx_get_vpd_field(vha, "SN", buf, PAGE_SIZE - 1);
1042 return strlen(strcat(buf, "\n"));
1045 sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
1046 return scnprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000,
1051 qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr,
1054 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1055 return scnprintf(buf, PAGE_SIZE, "ISP%04X\n", vha->hw->pdev->device);
1059 qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr,
1062 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1063 struct qla_hw_data *ha = vha->hw;
1065 if (IS_QLAFX00(vha->hw))
1066 return scnprintf(buf, PAGE_SIZE, "%s\n",
1067 vha->hw->mr.hw_version);
1069 return scnprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n",
1070 ha->product_id[0], ha->product_id[1], ha->product_id[2],
1075 qla2x00_model_name_show(struct device *dev, struct device_attribute *attr,
1078 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1080 return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_number);
1084 qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr,
1087 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1088 return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_desc);
1092 qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr,
1095 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1098 return scnprintf(buf, PAGE_SIZE, "%s\n",
1099 vha->hw->isp_ops->pci_info_str(vha, pci_info));
1103 qla2x00_link_state_show(struct device *dev, struct device_attribute *attr,
1106 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1107 struct qla_hw_data *ha = vha->hw;
1110 if (atomic_read(&vha->loop_state) == LOOP_DOWN ||
1111 atomic_read(&vha->loop_state) == LOOP_DEAD ||
1112 vha->device_flags & DFLG_NO_CABLE)
1113 len = scnprintf(buf, PAGE_SIZE, "Link Down\n");
1114 else if (atomic_read(&vha->loop_state) != LOOP_READY ||
1115 qla2x00_reset_active(vha))
1116 len = scnprintf(buf, PAGE_SIZE, "Unknown Link State\n");
1118 len = scnprintf(buf, PAGE_SIZE, "Link Up - ");
1120 switch (ha->current_topology) {
1122 len += scnprintf(buf + len, PAGE_SIZE-len, "Loop\n");
1125 len += scnprintf(buf + len, PAGE_SIZE-len, "FL_Port\n");
1128 len += scnprintf(buf + len, PAGE_SIZE-len,
1129 "N_Port to N_Port\n");
1132 len += scnprintf(buf + len, PAGE_SIZE-len, "F_Port\n");
1135 len += scnprintf(buf + len, PAGE_SIZE-len, "Loop\n");
1143 qla2x00_zio_show(struct device *dev, struct device_attribute *attr,
1146 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1149 switch (vha->hw->zio_mode) {
1150 case QLA_ZIO_MODE_6:
1151 len += scnprintf(buf + len, PAGE_SIZE-len, "Mode 6\n");
1153 case QLA_ZIO_DISABLED:
1154 len += scnprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
1161 qla2x00_zio_store(struct device *dev, struct device_attribute *attr,
1162 const char *buf, size_t count)
1164 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1165 struct qla_hw_data *ha = vha->hw;
1169 if (!IS_ZIO_SUPPORTED(ha))
1172 if (sscanf(buf, "%d", &val) != 1)
1176 zio_mode = QLA_ZIO_MODE_6;
1178 zio_mode = QLA_ZIO_DISABLED;
1180 /* Update per-hba values and queue a reset. */
1181 if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) {
1182 ha->zio_mode = zio_mode;
1183 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
1189 qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr,
1192 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1194 return scnprintf(buf, PAGE_SIZE, "%d us\n", vha->hw->zio_timer * 100);
1198 qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr,
1199 const char *buf, size_t count)
1201 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1205 if (sscanf(buf, "%d", &val) != 1)
1207 if (val > 25500 || val < 100)
1210 zio_timer = (uint16_t)(val / 100);
1211 vha->hw->zio_timer = zio_timer;
1217 qla2x00_beacon_show(struct device *dev, struct device_attribute *attr,
1220 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1223 if (vha->hw->beacon_blink_led)
1224 len += scnprintf(buf + len, PAGE_SIZE-len, "Enabled\n");
1226 len += scnprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
1231 qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
1232 const char *buf, size_t count)
1234 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1235 struct qla_hw_data *ha = vha->hw;
1239 if (IS_QLA2100(ha) || IS_QLA2200(ha))
1242 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) {
1243 ql_log(ql_log_warn, vha, 0x707a,
1244 "Abort ISP active -- ignoring beacon request.\n");
1248 if (sscanf(buf, "%d", &val) != 1)
1252 rval = ha->isp_ops->beacon_on(vha);
1254 rval = ha->isp_ops->beacon_off(vha);
1256 if (rval != QLA_SUCCESS)
1263 qla2x00_optrom_bios_version_show(struct device *dev,
1264 struct device_attribute *attr, char *buf)
1266 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1267 struct qla_hw_data *ha = vha->hw;
1268 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
1269 ha->bios_revision[0]);
1273 qla2x00_optrom_efi_version_show(struct device *dev,
1274 struct device_attribute *attr, char *buf)
1276 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1277 struct qla_hw_data *ha = vha->hw;
1278 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
1279 ha->efi_revision[0]);
1283 qla2x00_optrom_fcode_version_show(struct device *dev,
1284 struct device_attribute *attr, char *buf)
1286 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1287 struct qla_hw_data *ha = vha->hw;
1288 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
1289 ha->fcode_revision[0]);
1293 qla2x00_optrom_fw_version_show(struct device *dev,
1294 struct device_attribute *attr, char *buf)
1296 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1297 struct qla_hw_data *ha = vha->hw;
1298 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
1299 ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
1300 ha->fw_revision[3]);
1304 qla2x00_optrom_gold_fw_version_show(struct device *dev,
1305 struct device_attribute *attr, char *buf)
1307 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1308 struct qla_hw_data *ha = vha->hw;
1310 if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA27XX(ha))
1311 return scnprintf(buf, PAGE_SIZE, "\n");
1313 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%d)\n",
1314 ha->gold_fw_version[0], ha->gold_fw_version[1],
1315 ha->gold_fw_version[2], ha->gold_fw_version[3]);
1319 qla2x00_total_isp_aborts_show(struct device *dev,
1320 struct device_attribute *attr, char *buf)
1322 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1323 return scnprintf(buf, PAGE_SIZE, "%d\n",
1324 vha->qla_stats.total_isp_aborts);
1328 qla24xx_84xx_fw_version_show(struct device *dev,
1329 struct device_attribute *attr, char *buf)
1331 int rval = QLA_SUCCESS;
1332 uint16_t status[2] = {0, 0};
1333 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1334 struct qla_hw_data *ha = vha->hw;
1336 if (!IS_QLA84XX(ha))
1337 return scnprintf(buf, PAGE_SIZE, "\n");
1339 if (ha->cs84xx->op_fw_version == 0)
1340 rval = qla84xx_verify_chip(vha, status);
1342 if ((rval == QLA_SUCCESS) && (status[0] == 0))
1343 return scnprintf(buf, PAGE_SIZE, "%u\n",
1344 (uint32_t)ha->cs84xx->op_fw_version);
1346 return scnprintf(buf, PAGE_SIZE, "\n");
1350 qla2x00_mpi_version_show(struct device *dev, struct device_attribute *attr,
1353 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1354 struct qla_hw_data *ha = vha->hw;
1356 if (!IS_QLA81XX(ha) && !IS_QLA8031(ha) && !IS_QLA8044(ha) &&
1358 return scnprintf(buf, PAGE_SIZE, "\n");
1360 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
1361 ha->mpi_version[0], ha->mpi_version[1], ha->mpi_version[2],
1362 ha->mpi_capabilities);
1366 qla2x00_phy_version_show(struct device *dev, struct device_attribute *attr,
1369 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1370 struct qla_hw_data *ha = vha->hw;
1372 if (!IS_QLA81XX(ha) && !IS_QLA8031(ha))
1373 return scnprintf(buf, PAGE_SIZE, "\n");
1375 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
1376 ha->phy_version[0], ha->phy_version[1], ha->phy_version[2]);
1380 qla2x00_flash_block_size_show(struct device *dev,
1381 struct device_attribute *attr, char *buf)
1383 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1384 struct qla_hw_data *ha = vha->hw;
1386 return scnprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size);
1390 qla2x00_vlan_id_show(struct device *dev, struct device_attribute *attr,
1393 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1395 if (!IS_CNA_CAPABLE(vha->hw))
1396 return scnprintf(buf, PAGE_SIZE, "\n");
1398 return scnprintf(buf, PAGE_SIZE, "%d\n", vha->fcoe_vlan_id);
1402 qla2x00_vn_port_mac_address_show(struct device *dev,
1403 struct device_attribute *attr, char *buf)
1405 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1407 if (!IS_CNA_CAPABLE(vha->hw))
1408 return scnprintf(buf, PAGE_SIZE, "\n");
1410 return scnprintf(buf, PAGE_SIZE, "%pMR\n", vha->fcoe_vn_port_mac);
1414 qla2x00_fabric_param_show(struct device *dev, struct device_attribute *attr,
1417 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1419 return scnprintf(buf, PAGE_SIZE, "%d\n", vha->hw->switch_cap);
1423 qla2x00_thermal_temp_show(struct device *dev,
1424 struct device_attribute *attr, char *buf)
1426 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1429 if (qla2x00_reset_active(vha)) {
1430 ql_log(ql_log_warn, vha, 0x70dc, "ISP reset active.\n");
1434 if (vha->hw->flags.eeh_busy) {
1435 ql_log(ql_log_warn, vha, 0x70dd, "PCI EEH busy.\n");
1439 if (qla2x00_get_thermal_temp(vha, &temp) == QLA_SUCCESS)
1440 return scnprintf(buf, PAGE_SIZE, "%d\n", temp);
1443 return scnprintf(buf, PAGE_SIZE, "\n");
1447 qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
1450 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1451 int rval = QLA_FUNCTION_FAILED;
1455 if (IS_QLAFX00(vha->hw)) {
1456 pstate = qlafx00_fw_state_show(dev, attr, buf);
1457 return scnprintf(buf, PAGE_SIZE, "0x%x\n", pstate);
1460 if (qla2x00_reset_active(vha))
1461 ql_log(ql_log_warn, vha, 0x707c,
1462 "ISP reset active.\n");
1463 else if (!vha->hw->flags.eeh_busy)
1464 rval = qla2x00_get_firmware_state(vha, state);
1465 if (rval != QLA_SUCCESS)
1466 memset(state, -1, sizeof(state));
1468 return scnprintf(buf, PAGE_SIZE, "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1469 state[0], state[1], state[2], state[3], state[4], state[5]);
1473 qla2x00_diag_requests_show(struct device *dev,
1474 struct device_attribute *attr, char *buf)
1476 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1478 if (!IS_BIDI_CAPABLE(vha->hw))
1479 return scnprintf(buf, PAGE_SIZE, "\n");
1481 return scnprintf(buf, PAGE_SIZE, "%llu\n", vha->bidi_stats.io_count);
1485 qla2x00_diag_megabytes_show(struct device *dev,
1486 struct device_attribute *attr, char *buf)
1488 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1490 if (!IS_BIDI_CAPABLE(vha->hw))
1491 return scnprintf(buf, PAGE_SIZE, "\n");
1493 return scnprintf(buf, PAGE_SIZE, "%llu\n",
1494 vha->bidi_stats.transfer_bytes >> 20);
1498 qla2x00_fw_dump_size_show(struct device *dev, struct device_attribute *attr,
1501 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1502 struct qla_hw_data *ha = vha->hw;
1507 else if (IS_P3P_TYPE(ha))
1508 size = ha->md_template_size + ha->md_dump_size;
1510 size = ha->fw_dump_len;
1512 return scnprintf(buf, PAGE_SIZE, "%d\n", size);
1516 qla2x00_allow_cna_fw_dump_show(struct device *dev,
1517 struct device_attribute *attr, char *buf)
1519 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1521 if (!IS_P3P_TYPE(vha->hw))
1522 return scnprintf(buf, PAGE_SIZE, "\n");
1524 return scnprintf(buf, PAGE_SIZE, "%s\n",
1525 vha->hw->allow_cna_fw_dump ? "true" : "false");
1529 qla2x00_allow_cna_fw_dump_store(struct device *dev,
1530 struct device_attribute *attr, const char *buf, size_t count)
1532 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1535 if (!IS_P3P_TYPE(vha->hw))
1538 if (sscanf(buf, "%d", &val) != 1)
1541 vha->hw->allow_cna_fw_dump = val != 0;
1547 qla2x00_pep_version_show(struct device *dev, struct device_attribute *attr,
1550 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1551 struct qla_hw_data *ha = vha->hw;
1553 if (!IS_QLA27XX(ha))
1554 return scnprintf(buf, PAGE_SIZE, "\n");
1556 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
1557 ha->pep_version[0], ha->pep_version[1], ha->pep_version[2]);
1560 static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
1561 static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
1562 static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
1563 static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
1564 static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
1565 static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
1566 static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
1567 static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
1568 static DEVICE_ATTR(link_state, S_IRUGO, qla2x00_link_state_show, NULL);
1569 static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store);
1570 static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
1571 qla2x00_zio_timer_store);
1572 static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
1573 qla2x00_beacon_store);
1574 static DEVICE_ATTR(optrom_bios_version, S_IRUGO,
1575 qla2x00_optrom_bios_version_show, NULL);
1576 static DEVICE_ATTR(optrom_efi_version, S_IRUGO,
1577 qla2x00_optrom_efi_version_show, NULL);
1578 static DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
1579 qla2x00_optrom_fcode_version_show, NULL);
1580 static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show,
1582 static DEVICE_ATTR(optrom_gold_fw_version, S_IRUGO,
1583 qla2x00_optrom_gold_fw_version_show, NULL);
1584 static DEVICE_ATTR(84xx_fw_version, S_IRUGO, qla24xx_84xx_fw_version_show,
1586 static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show,
1588 static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL);
1589 static DEVICE_ATTR(phy_version, S_IRUGO, qla2x00_phy_version_show, NULL);
1590 static DEVICE_ATTR(flash_block_size, S_IRUGO, qla2x00_flash_block_size_show,
1592 static DEVICE_ATTR(vlan_id, S_IRUGO, qla2x00_vlan_id_show, NULL);
1593 static DEVICE_ATTR(vn_port_mac_address, S_IRUGO,
1594 qla2x00_vn_port_mac_address_show, NULL);
1595 static DEVICE_ATTR(fabric_param, S_IRUGO, qla2x00_fabric_param_show, NULL);
1596 static DEVICE_ATTR(fw_state, S_IRUGO, qla2x00_fw_state_show, NULL);
1597 static DEVICE_ATTR(thermal_temp, S_IRUGO, qla2x00_thermal_temp_show, NULL);
1598 static DEVICE_ATTR(diag_requests, S_IRUGO, qla2x00_diag_requests_show, NULL);
1599 static DEVICE_ATTR(diag_megabytes, S_IRUGO, qla2x00_diag_megabytes_show, NULL);
1600 static DEVICE_ATTR(fw_dump_size, S_IRUGO, qla2x00_fw_dump_size_show, NULL);
1601 static DEVICE_ATTR(allow_cna_fw_dump, S_IRUGO | S_IWUSR,
1602 qla2x00_allow_cna_fw_dump_show,
1603 qla2x00_allow_cna_fw_dump_store);
1604 static DEVICE_ATTR(pep_version, S_IRUGO, qla2x00_pep_version_show, NULL);
1606 struct device_attribute *qla2x00_host_attrs[] = {
1607 &dev_attr_driver_version,
1608 &dev_attr_fw_version,
1609 &dev_attr_serial_num,
1612 &dev_attr_model_name,
1613 &dev_attr_model_desc,
1615 &dev_attr_link_state,
1617 &dev_attr_zio_timer,
1619 &dev_attr_optrom_bios_version,
1620 &dev_attr_optrom_efi_version,
1621 &dev_attr_optrom_fcode_version,
1622 &dev_attr_optrom_fw_version,
1623 &dev_attr_84xx_fw_version,
1624 &dev_attr_total_isp_aborts,
1625 &dev_attr_mpi_version,
1626 &dev_attr_phy_version,
1627 &dev_attr_flash_block_size,
1629 &dev_attr_vn_port_mac_address,
1630 &dev_attr_fabric_param,
1632 &dev_attr_optrom_gold_fw_version,
1633 &dev_attr_thermal_temp,
1634 &dev_attr_diag_requests,
1635 &dev_attr_diag_megabytes,
1636 &dev_attr_fw_dump_size,
1637 &dev_attr_allow_cna_fw_dump,
1638 &dev_attr_pep_version,
1642 /* Host attributes. */
1645 qla2x00_get_host_port_id(struct Scsi_Host *shost)
1647 scsi_qla_host_t *vha = shost_priv(shost);
1649 fc_host_port_id(shost) = vha->d_id.b.domain << 16 |
1650 vha->d_id.b.area << 8 | vha->d_id.b.al_pa;
1654 qla2x00_get_host_speed(struct Scsi_Host *shost)
1656 struct qla_hw_data *ha = ((struct scsi_qla_host *)
1657 (shost_priv(shost)))->hw;
1658 u32 speed = FC_PORTSPEED_UNKNOWN;
1660 if (IS_QLAFX00(ha)) {
1661 qlafx00_get_host_speed(shost);
1665 switch (ha->link_data_rate) {
1666 case PORT_SPEED_1GB:
1667 speed = FC_PORTSPEED_1GBIT;
1669 case PORT_SPEED_2GB:
1670 speed = FC_PORTSPEED_2GBIT;
1672 case PORT_SPEED_4GB:
1673 speed = FC_PORTSPEED_4GBIT;
1675 case PORT_SPEED_8GB:
1676 speed = FC_PORTSPEED_8GBIT;
1678 case PORT_SPEED_10GB:
1679 speed = FC_PORTSPEED_10GBIT;
1681 case PORT_SPEED_16GB:
1682 speed = FC_PORTSPEED_16GBIT;
1684 case PORT_SPEED_32GB:
1685 speed = FC_PORTSPEED_32GBIT;
1688 fc_host_speed(shost) = speed;
1692 qla2x00_get_host_port_type(struct Scsi_Host *shost)
1694 scsi_qla_host_t *vha = shost_priv(shost);
1695 uint32_t port_type = FC_PORTTYPE_UNKNOWN;
1698 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
1701 switch (vha->hw->current_topology) {
1703 port_type = FC_PORTTYPE_LPORT;
1706 port_type = FC_PORTTYPE_NLPORT;
1709 port_type = FC_PORTTYPE_PTP;
1712 port_type = FC_PORTTYPE_NPORT;
1715 fc_host_port_type(shost) = port_type;
1719 qla2x00_get_starget_node_name(struct scsi_target *starget)
1721 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
1722 scsi_qla_host_t *vha = shost_priv(host);
1726 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1727 if (fcport->rport &&
1728 starget->id == fcport->rport->scsi_target_id) {
1729 node_name = wwn_to_u64(fcport->node_name);
1734 fc_starget_node_name(starget) = node_name;
1738 qla2x00_get_starget_port_name(struct scsi_target *starget)
1740 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
1741 scsi_qla_host_t *vha = shost_priv(host);
1745 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1746 if (fcport->rport &&
1747 starget->id == fcport->rport->scsi_target_id) {
1748 port_name = wwn_to_u64(fcport->port_name);
1753 fc_starget_port_name(starget) = port_name;
1757 qla2x00_get_starget_port_id(struct scsi_target *starget)
1759 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
1760 scsi_qla_host_t *vha = shost_priv(host);
1762 uint32_t port_id = ~0U;
1764 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1765 if (fcport->rport &&
1766 starget->id == fcport->rport->scsi_target_id) {
1767 port_id = fcport->d_id.b.domain << 16 |
1768 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
1773 fc_starget_port_id(starget) = port_id;
1777 qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
1780 rport->dev_loss_tmo = timeout;
1782 rport->dev_loss_tmo = 1;
1786 qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
1788 struct Scsi_Host *host = rport_to_shost(rport);
1789 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
1790 unsigned long flags;
1795 /* Now that the rport has been deleted, set the fcport state to
1797 qla2x00_set_fcport_state(fcport, FCS_DEVICE_DEAD);
1800 * Transport has effectively 'deleted' the rport, clear
1801 * all local references.
1803 spin_lock_irqsave(host->host_lock, flags);
1804 fcport->rport = fcport->drport = NULL;
1805 *((fc_port_t **)rport->dd_data) = NULL;
1806 spin_unlock_irqrestore(host->host_lock, flags);
1808 if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
1811 if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
1812 qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
1818 qla2x00_terminate_rport_io(struct fc_rport *rport)
1820 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
1825 if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
1828 if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
1829 qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
1833 * At this point all fcport's software-states are cleared. Perform any
1834 * final cleanup of firmware resources (PCBs and XCBs).
1836 if (fcport->loop_id != FC_NO_LOOP_ID) {
1837 if (IS_FWI2_CAPABLE(fcport->vha->hw))
1838 fcport->vha->hw->isp_ops->fabric_logout(fcport->vha,
1839 fcport->loop_id, fcport->d_id.b.domain,
1840 fcport->d_id.b.area, fcport->d_id.b.al_pa);
1842 qla2x00_port_logout(fcport->vha, fcport);
1847 qla2x00_issue_lip(struct Scsi_Host *shost)
1849 scsi_qla_host_t *vha = shost_priv(shost);
1851 if (IS_QLAFX00(vha->hw))
1854 qla2x00_loop_reset(vha);
1858 static struct fc_host_statistics *
1859 qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1861 scsi_qla_host_t *vha = shost_priv(shost);
1862 struct qla_hw_data *ha = vha->hw;
1863 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
1865 struct link_statistics *stats;
1866 dma_addr_t stats_dma;
1867 struct fc_host_statistics *pfc_host_stat;
1869 pfc_host_stat = &vha->fc_host_stat;
1870 memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics));
1872 if (IS_QLAFX00(vha->hw))
1875 if (test_bit(UNLOADING, &vha->dpc_flags))
1878 if (unlikely(pci_channel_offline(ha->pdev)))
1881 if (qla2x00_reset_active(vha))
1884 stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma);
1885 if (stats == NULL) {
1886 ql_log(ql_log_warn, vha, 0x707d,
1887 "Failed to allocate memory for stats.\n");
1890 memset(stats, 0, DMA_POOL_SIZE);
1892 rval = QLA_FUNCTION_FAILED;
1893 if (IS_FWI2_CAPABLE(ha)) {
1894 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma);
1895 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
1897 /* Must be in a 'READY' state for statistics retrieval. */
1898 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id,
1902 if (rval != QLA_SUCCESS)
1905 pfc_host_stat->link_failure_count = stats->link_fail_cnt;
1906 pfc_host_stat->loss_of_sync_count = stats->loss_sync_cnt;
1907 pfc_host_stat->loss_of_signal_count = stats->loss_sig_cnt;
1908 pfc_host_stat->prim_seq_protocol_err_count = stats->prim_seq_err_cnt;
1909 pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt;
1910 pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt;
1911 if (IS_FWI2_CAPABLE(ha)) {
1912 pfc_host_stat->lip_count = stats->lip_cnt;
1913 pfc_host_stat->tx_frames = stats->tx_frames;
1914 pfc_host_stat->rx_frames = stats->rx_frames;
1915 pfc_host_stat->dumped_frames = stats->discarded_frames;
1916 pfc_host_stat->nos_count = stats->nos_rcvd;
1917 pfc_host_stat->error_frames =
1918 stats->dropped_frames + stats->discarded_frames;
1919 pfc_host_stat->rx_words = vha->qla_stats.input_bytes;
1920 pfc_host_stat->tx_words = vha->qla_stats.output_bytes;
1922 pfc_host_stat->fcp_control_requests = vha->qla_stats.control_requests;
1923 pfc_host_stat->fcp_input_requests = vha->qla_stats.input_requests;
1924 pfc_host_stat->fcp_output_requests = vha->qla_stats.output_requests;
1925 pfc_host_stat->fcp_input_megabytes = vha->qla_stats.input_bytes >> 20;
1926 pfc_host_stat->fcp_output_megabytes = vha->qla_stats.output_bytes >> 20;
1927 pfc_host_stat->seconds_since_last_reset =
1928 get_jiffies_64() - vha->qla_stats.jiffies_at_last_reset;
1929 do_div(pfc_host_stat->seconds_since_last_reset, HZ);
1932 dma_pool_free(ha->s_dma_pool, stats, stats_dma);
1934 return pfc_host_stat;
1938 qla2x00_reset_host_stats(struct Scsi_Host *shost)
1940 scsi_qla_host_t *vha = shost_priv(shost);
1942 memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat));
1944 vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
1948 qla2x00_get_host_symbolic_name(struct Scsi_Host *shost)
1950 scsi_qla_host_t *vha = shost_priv(shost);
1952 qla2x00_get_sym_node_name(vha, fc_host_symbolic_name(shost),
1953 sizeof(fc_host_symbolic_name(shost)));
1957 qla2x00_set_host_system_hostname(struct Scsi_Host *shost)
1959 scsi_qla_host_t *vha = shost_priv(shost);
1961 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
1965 qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
1967 scsi_qla_host_t *vha = shost_priv(shost);
1968 uint8_t node_name[WWN_SIZE] = { 0xFF, 0xFF, 0xFF, 0xFF, \
1969 0xFF, 0xFF, 0xFF, 0xFF};
1970 u64 fabric_name = wwn_to_u64(node_name);
1972 if (vha->device_flags & SWITCH_FOUND)
1973 fabric_name = wwn_to_u64(vha->fabric_node_name);
1975 fc_host_fabric_name(shost) = fabric_name;
1979 qla2x00_get_host_port_state(struct Scsi_Host *shost)
1981 scsi_qla_host_t *vha = shost_priv(shost);
1982 struct scsi_qla_host *base_vha = pci_get_drvdata(vha->hw->pdev);
1984 if (!base_vha->flags.online) {
1985 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
1989 switch (atomic_read(&base_vha->loop_state)) {
1991 fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS;
1994 if (test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags))
1995 fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS;
1997 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
2000 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
2003 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
2006 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
2012 qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
2016 scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
2017 scsi_qla_host_t *vha = NULL;
2018 struct qla_hw_data *ha = base_vha->hw;
2019 uint16_t options = 0;
2021 struct req_que *req = ha->req_q_map[0];
2023 ret = qla24xx_vport_create_req_sanity_check(fc_vport);
2025 ql_log(ql_log_warn, vha, 0x707e,
2026 "Vport sanity check failed, status %x\n", ret);
2030 vha = qla24xx_create_vhost(fc_vport);
2032 ql_log(ql_log_warn, vha, 0x707f, "Vport create host failed.\n");
2033 return FC_VPORT_FAILED;
2036 atomic_set(&vha->vp_state, VP_OFFLINE);
2037 fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
2039 atomic_set(&vha->vp_state, VP_FAILED);
2041 /* ready to create vport */
2042 ql_log(ql_log_info, vha, 0x7080,
2043 "VP entry id %d assigned.\n", vha->vp_idx);
2045 /* initialized vport states */
2046 atomic_set(&vha->loop_state, LOOP_DOWN);
2047 vha->vp_err_state= VP_ERR_PORTDWN;
2048 vha->vp_prev_err_state= VP_ERR_UNKWN;
2049 /* Check if physical ha port is Up */
2050 if (atomic_read(&base_vha->loop_state) == LOOP_DOWN ||
2051 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
2052 /* Don't retry or attempt login of this virtual port */
2053 ql_dbg(ql_dbg_user, vha, 0x7081,
2054 "Vport loop state is not UP.\n");
2055 atomic_set(&vha->loop_state, LOOP_DEAD);
2057 fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN);
2060 if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) {
2061 if (ha->fw_attributes & BIT_4) {
2062 int prot = 0, guard;
2063 vha->flags.difdix_supported = 1;
2064 ql_dbg(ql_dbg_user, vha, 0x7082,
2065 "Registered for DIF/DIX type 1 and 3 protection.\n");
2066 if (ql2xenabledif == 1)
2067 prot = SHOST_DIX_TYPE0_PROTECTION;
2068 scsi_host_set_prot(vha->host,
2069 prot | SHOST_DIF_TYPE1_PROTECTION
2070 | SHOST_DIF_TYPE2_PROTECTION
2071 | SHOST_DIF_TYPE3_PROTECTION
2072 | SHOST_DIX_TYPE1_PROTECTION
2073 | SHOST_DIX_TYPE2_PROTECTION
2074 | SHOST_DIX_TYPE3_PROTECTION);
2076 guard = SHOST_DIX_GUARD_CRC;
2078 if (IS_PI_IPGUARD_CAPABLE(ha) &&
2079 (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha)))
2080 guard |= SHOST_DIX_GUARD_IP;
2082 scsi_host_set_guard(vha->host, guard);
2084 vha->flags.difdix_supported = 0;
2087 if (scsi_add_host_with_dma(vha->host, &fc_vport->dev,
2089 ql_dbg(ql_dbg_user, vha, 0x7083,
2090 "scsi_add_host failure for VP[%d].\n", vha->vp_idx);
2091 goto vport_create_failed_2;
2094 /* initialize attributes */
2095 fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count;
2096 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
2097 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
2098 fc_host_supported_classes(vha->host) =
2099 fc_host_supported_classes(base_vha->host);
2100 fc_host_supported_speeds(vha->host) =
2101 fc_host_supported_speeds(base_vha->host);
2103 qlt_vport_create(vha, ha);
2104 qla24xx_vport_disable(fc_vport, disable);
2106 if (ha->flags.cpu_affinity_enabled) {
2107 req = ha->req_q_map[1];
2108 ql_dbg(ql_dbg_multiq, vha, 0xc000,
2109 "Request queue %p attached with "
2110 "VP[%d], cpu affinity =%d\n",
2111 req, vha->vp_idx, ha->flags.cpu_affinity_enabled);
2113 } else if (ql2xmaxqueues == 1 || !ha->npiv_info)
2115 /* Create a request queue in QoS mode for the vport */
2116 for (cnt = 0; cnt < ha->nvram_npiv_size; cnt++) {
2117 if (memcmp(ha->npiv_info[cnt].port_name, vha->port_name, 8) == 0
2118 && memcmp(ha->npiv_info[cnt].node_name, vha->node_name,
2120 qos = ha->npiv_info[cnt].q_qos;
2126 ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, 0,
2129 ql_log(ql_log_warn, vha, 0x7084,
2130 "Can't create request queue for VP[%d]\n",
2133 ql_dbg(ql_dbg_multiq, vha, 0xc001,
2134 "Request Que:%d Q0s: %d) created for VP[%d]\n",
2135 ret, qos, vha->vp_idx);
2136 ql_dbg(ql_dbg_user, vha, 0x7085,
2137 "Request Que:%d Q0s: %d) created for VP[%d]\n",
2138 ret, qos, vha->vp_idx);
2139 req = ha->req_q_map[ret];
2147 vport_create_failed_2:
2148 qla24xx_disable_vp(vha);
2149 qla24xx_deallocate_vp_id(vha);
2150 scsi_host_put(vha->host);
2151 return FC_VPORT_FAILED;
2155 qla24xx_vport_delete(struct fc_vport *fc_vport)
2157 scsi_qla_host_t *vha = fc_vport->dd_data;
2158 struct qla_hw_data *ha = vha->hw;
2159 uint16_t id = vha->vp_idx;
2161 while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
2162 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
2165 qla24xx_disable_vp(vha);
2167 vha->flags.delete_progress = 1;
2169 qlt_remove_target(ha, vha);
2171 fc_remove_host(vha->host);
2173 scsi_remove_host(vha->host);
2175 /* Allow timer to run to drain queued items, when removing vp */
2176 qla24xx_deallocate_vp_id(vha);
2178 if (vha->timer_active) {
2179 qla2x00_vp_stop_timer(vha);
2180 ql_dbg(ql_dbg_user, vha, 0x7086,
2181 "Timer for the VP[%d] has stopped\n", vha->vp_idx);
2184 BUG_ON(atomic_read(&vha->vref_count));
2186 qla2x00_free_fcports(vha);
2188 mutex_lock(&ha->vport_lock);
2189 ha->cur_vport_count--;
2190 clear_bit(vha->vp_idx, ha->vp_idx_map);
2191 mutex_unlock(&ha->vport_lock);
2193 if (vha->req->id && !ha->flags.cpu_affinity_enabled) {
2194 if (qla25xx_delete_req_que(vha, vha->req) != QLA_SUCCESS)
2195 ql_log(ql_log_warn, vha, 0x7087,
2196 "Queue delete failed.\n");
2199 ql_log(ql_log_info, vha, 0x7088, "VP[%d] deleted.\n", id);
2200 scsi_host_put(vha->host);
2205 qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
2207 scsi_qla_host_t *vha = fc_vport->dd_data;
2210 qla24xx_disable_vp(vha);
2212 qla24xx_enable_vp(vha);
2217 struct fc_function_template qla2xxx_transport_functions = {
2219 .show_host_node_name = 1,
2220 .show_host_port_name = 1,
2221 .show_host_supported_classes = 1,
2222 .show_host_supported_speeds = 1,
2224 .get_host_port_id = qla2x00_get_host_port_id,
2225 .show_host_port_id = 1,
2226 .get_host_speed = qla2x00_get_host_speed,
2227 .show_host_speed = 1,
2228 .get_host_port_type = qla2x00_get_host_port_type,
2229 .show_host_port_type = 1,
2230 .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
2231 .show_host_symbolic_name = 1,
2232 .set_host_system_hostname = qla2x00_set_host_system_hostname,
2233 .show_host_system_hostname = 1,
2234 .get_host_fabric_name = qla2x00_get_host_fabric_name,
2235 .show_host_fabric_name = 1,
2236 .get_host_port_state = qla2x00_get_host_port_state,
2237 .show_host_port_state = 1,
2239 .dd_fcrport_size = sizeof(struct fc_port *),
2240 .show_rport_supported_classes = 1,
2242 .get_starget_node_name = qla2x00_get_starget_node_name,
2243 .show_starget_node_name = 1,
2244 .get_starget_port_name = qla2x00_get_starget_port_name,
2245 .show_starget_port_name = 1,
2246 .get_starget_port_id = qla2x00_get_starget_port_id,
2247 .show_starget_port_id = 1,
2249 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
2250 .show_rport_dev_loss_tmo = 1,
2252 .issue_fc_host_lip = qla2x00_issue_lip,
2253 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
2254 .terminate_rport_io = qla2x00_terminate_rport_io,
2255 .get_fc_host_stats = qla2x00_get_fc_host_stats,
2256 .reset_fc_host_stats = qla2x00_reset_host_stats,
2258 .vport_create = qla24xx_vport_create,
2259 .vport_disable = qla24xx_vport_disable,
2260 .vport_delete = qla24xx_vport_delete,
2261 .bsg_request = qla24xx_bsg_request,
2262 .bsg_timeout = qla24xx_bsg_timeout,
2265 struct fc_function_template qla2xxx_transport_vport_functions = {
2267 .show_host_node_name = 1,
2268 .show_host_port_name = 1,
2269 .show_host_supported_classes = 1,
2271 .get_host_port_id = qla2x00_get_host_port_id,
2272 .show_host_port_id = 1,
2273 .get_host_speed = qla2x00_get_host_speed,
2274 .show_host_speed = 1,
2275 .get_host_port_type = qla2x00_get_host_port_type,
2276 .show_host_port_type = 1,
2277 .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
2278 .show_host_symbolic_name = 1,
2279 .set_host_system_hostname = qla2x00_set_host_system_hostname,
2280 .show_host_system_hostname = 1,
2281 .get_host_fabric_name = qla2x00_get_host_fabric_name,
2282 .show_host_fabric_name = 1,
2283 .get_host_port_state = qla2x00_get_host_port_state,
2284 .show_host_port_state = 1,
2286 .dd_fcrport_size = sizeof(struct fc_port *),
2287 .show_rport_supported_classes = 1,
2289 .get_starget_node_name = qla2x00_get_starget_node_name,
2290 .show_starget_node_name = 1,
2291 .get_starget_port_name = qla2x00_get_starget_port_name,
2292 .show_starget_port_name = 1,
2293 .get_starget_port_id = qla2x00_get_starget_port_id,
2294 .show_starget_port_id = 1,
2296 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
2297 .show_rport_dev_loss_tmo = 1,
2299 .issue_fc_host_lip = qla2x00_issue_lip,
2300 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
2301 .terminate_rport_io = qla2x00_terminate_rport_io,
2302 .get_fc_host_stats = qla2x00_get_fc_host_stats,
2303 .reset_fc_host_stats = qla2x00_reset_host_stats,
2305 .bsg_request = qla24xx_bsg_request,
2306 .bsg_timeout = qla24xx_bsg_timeout,
2310 qla2x00_init_host_attr(scsi_qla_host_t *vha)
2312 struct qla_hw_data *ha = vha->hw;
2313 u32 speed = FC_PORTSPEED_UNKNOWN;
2315 fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count;
2316 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
2317 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
2318 fc_host_supported_classes(vha->host) = ha->tgt.enable_class_2 ?
2319 (FC_COS_CLASS2|FC_COS_CLASS3) : FC_COS_CLASS3;
2320 fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports;
2321 fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count;
2323 if (IS_CNA_CAPABLE(ha))
2324 speed = FC_PORTSPEED_10GBIT;
2325 else if (IS_QLA2031(ha))
2326 speed = FC_PORTSPEED_16GBIT | FC_PORTSPEED_8GBIT |
2328 else if (IS_QLA25XX(ha))
2329 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
2330 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
2331 else if (IS_QLA24XX_TYPE(ha))
2332 speed = FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT |
2334 else if (IS_QLA23XX(ha))
2335 speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
2336 else if (IS_QLAFX00(ha))
2337 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
2338 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
2339 else if (IS_QLA27XX(ha))
2340 speed = FC_PORTSPEED_32GBIT | FC_PORTSPEED_16GBIT |
2343 speed = FC_PORTSPEED_1GBIT;
2344 fc_host_supported_speeds(vha->host) = speed;