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_nvram(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 (!capable(CAP_SYS_ADMIN))
161 mutex_lock(&ha->optrom_mutex);
162 if (qla2x00_chip_is_down(vha)) {
163 mutex_unlock(&ha->optrom_mutex);
167 if (IS_NOCACHE_VPD_TYPE(ha))
168 ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2,
170 mutex_unlock(&ha->optrom_mutex);
172 return memory_read_from_buffer(buf, count, &off, ha->nvram,
177 qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj,
178 struct bin_attribute *bin_attr,
179 char *buf, loff_t off, size_t count)
181 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
182 struct device, kobj)));
183 struct qla_hw_data *ha = vha->hw;
186 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size ||
187 !ha->isp_ops->write_nvram)
190 /* Checksum NVRAM. */
191 if (IS_FWI2_CAPABLE(ha)) {
195 iter = (uint32_t *)buf;
197 for (cnt = 0; cnt < ((count >> 2) - 1); cnt++, iter++)
198 chksum += le32_to_cpu(*iter);
199 chksum = ~chksum + 1;
200 *iter = cpu_to_le32(chksum);
205 iter = (uint8_t *)buf;
207 for (cnt = 0; cnt < count - 1; cnt++)
209 chksum = ~chksum + 1;
213 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
214 ql_log(ql_log_warn, vha, 0x705f,
215 "HBA not online, failing NVRAM update.\n");
219 mutex_lock(&ha->optrom_mutex);
220 if (qla2x00_chip_is_down(vha)) {
221 mutex_unlock(&ha->optrom_mutex);
226 ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->nvram_base, count);
227 ha->isp_ops->read_nvram(vha, (uint8_t *)ha->nvram, ha->nvram_base,
229 mutex_unlock(&ha->optrom_mutex);
231 ql_dbg(ql_dbg_user, vha, 0x7060,
232 "Setting ISP_ABORT_NEEDED\n");
233 /* NVRAM settings take effect immediately. */
234 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
235 qla2xxx_wake_dpc(vha);
236 qla2x00_wait_for_chip_reset(vha);
241 static struct bin_attribute sysfs_nvram_attr = {
244 .mode = S_IRUSR | S_IWUSR,
247 .read = qla2x00_sysfs_read_nvram,
248 .write = qla2x00_sysfs_write_nvram,
252 qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj,
253 struct bin_attribute *bin_attr,
254 char *buf, loff_t off, size_t count)
256 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
257 struct device, kobj)));
258 struct qla_hw_data *ha = vha->hw;
261 mutex_lock(&ha->optrom_mutex);
263 if (ha->optrom_state != QLA_SREADING)
266 rval = memory_read_from_buffer(buf, count, &off, ha->optrom_buffer,
267 ha->optrom_region_size);
270 mutex_unlock(&ha->optrom_mutex);
276 qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj,
277 struct bin_attribute *bin_attr,
278 char *buf, loff_t off, size_t count)
280 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
281 struct device, kobj)));
282 struct qla_hw_data *ha = vha->hw;
284 mutex_lock(&ha->optrom_mutex);
286 if (ha->optrom_state != QLA_SWRITING) {
287 mutex_unlock(&ha->optrom_mutex);
290 if (off > ha->optrom_region_size) {
291 mutex_unlock(&ha->optrom_mutex);
294 if (off + count > ha->optrom_region_size)
295 count = ha->optrom_region_size - off;
297 memcpy(&ha->optrom_buffer[off], buf, count);
298 mutex_unlock(&ha->optrom_mutex);
303 static struct bin_attribute sysfs_optrom_attr = {
306 .mode = S_IRUSR | S_IWUSR,
309 .read = qla2x00_sysfs_read_optrom,
310 .write = qla2x00_sysfs_write_optrom,
314 qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
315 struct bin_attribute *bin_attr,
316 char *buf, loff_t off, size_t count)
318 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
319 struct device, kobj)));
320 struct qla_hw_data *ha = vha->hw;
322 uint32_t size = ha->optrom_size;
324 ssize_t rval = count;
329 if (unlikely(pci_channel_offline(ha->pdev)))
332 if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1)
334 if (start > ha->optrom_size)
336 if (size > ha->optrom_size - start)
337 size = ha->optrom_size - start;
339 mutex_lock(&ha->optrom_mutex);
340 if (qla2x00_chip_is_down(vha)) {
341 mutex_unlock(&ha->optrom_mutex);
346 if (ha->optrom_state != QLA_SREADING &&
347 ha->optrom_state != QLA_SWRITING) {
351 ha->optrom_state = QLA_SWAITING;
353 ql_dbg(ql_dbg_user, vha, 0x7061,
354 "Freeing flash region allocation -- 0x%x bytes.\n",
355 ha->optrom_region_size);
357 vfree(ha->optrom_buffer);
358 ha->optrom_buffer = NULL;
361 if (ha->optrom_state != QLA_SWAITING) {
366 ha->optrom_region_start = start;
367 ha->optrom_region_size = start + size;
369 ha->optrom_state = QLA_SREADING;
370 ha->optrom_buffer = vmalloc(ha->optrom_region_size);
371 if (ha->optrom_buffer == NULL) {
372 ql_log(ql_log_warn, vha, 0x7062,
373 "Unable to allocate memory for optrom retrieval "
374 "(%x).\n", ha->optrom_region_size);
376 ha->optrom_state = QLA_SWAITING;
381 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
382 ql_log(ql_log_warn, vha, 0x7063,
383 "HBA not online, failing NVRAM update.\n");
388 ql_dbg(ql_dbg_user, vha, 0x7064,
389 "Reading flash region -- 0x%x/0x%x.\n",
390 ha->optrom_region_start, ha->optrom_region_size);
392 memset(ha->optrom_buffer, 0, ha->optrom_region_size);
393 ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
394 ha->optrom_region_start, ha->optrom_region_size);
397 if (ha->optrom_state != QLA_SWAITING) {
403 * We need to be more restrictive on which FLASH regions are
404 * allowed to be updated via user-space. Regions accessible
405 * via this method include:
407 * ISP21xx/ISP22xx/ISP23xx type boards:
409 * 0x000000 -> 0x020000 -- Boot code.
411 * ISP2322/ISP24xx type boards:
413 * 0x000000 -> 0x07ffff -- Boot code.
414 * 0x080000 -> 0x0fffff -- Firmware.
416 * ISP25xx type boards:
418 * 0x000000 -> 0x07ffff -- Boot code.
419 * 0x080000 -> 0x0fffff -- Firmware.
420 * 0x120000 -> 0x12ffff -- VPD and HBA parameters.
423 if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0)
425 else if (start == (ha->flt_region_boot * 4) ||
426 start == (ha->flt_region_fw * 4))
428 else if (IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha)
429 || IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)
433 ql_log(ql_log_warn, vha, 0x7065,
434 "Invalid start region 0x%x/0x%x.\n", start, size);
439 ha->optrom_region_start = start;
440 ha->optrom_region_size = start + size;
442 ha->optrom_state = QLA_SWRITING;
443 ha->optrom_buffer = vmalloc(ha->optrom_region_size);
444 if (ha->optrom_buffer == NULL) {
445 ql_log(ql_log_warn, vha, 0x7066,
446 "Unable to allocate memory for optrom update "
447 "(%x)\n", ha->optrom_region_size);
449 ha->optrom_state = QLA_SWAITING;
454 ql_dbg(ql_dbg_user, vha, 0x7067,
455 "Staging flash region write -- 0x%x/0x%x.\n",
456 ha->optrom_region_start, ha->optrom_region_size);
458 memset(ha->optrom_buffer, 0, ha->optrom_region_size);
461 if (ha->optrom_state != QLA_SWRITING) {
466 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
467 ql_log(ql_log_warn, vha, 0x7068,
468 "HBA not online, failing flash update.\n");
473 ql_dbg(ql_dbg_user, vha, 0x7069,
474 "Writing flash region -- 0x%x/0x%x.\n",
475 ha->optrom_region_start, ha->optrom_region_size);
477 ha->isp_ops->write_optrom(vha, ha->optrom_buffer,
478 ha->optrom_region_start, ha->optrom_region_size);
485 mutex_unlock(&ha->optrom_mutex);
489 static struct bin_attribute sysfs_optrom_ctl_attr = {
491 .name = "optrom_ctl",
495 .write = qla2x00_sysfs_write_optrom_ctl,
499 qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj,
500 struct bin_attribute *bin_attr,
501 char *buf, loff_t off, size_t count)
503 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
504 struct device, kobj)));
505 struct qla_hw_data *ha = vha->hw;
508 if (unlikely(pci_channel_offline(ha->pdev)))
511 if (!capable(CAP_SYS_ADMIN))
514 if (IS_NOCACHE_VPD_TYPE(ha)) {
515 faddr = ha->flt_region_vpd << 2;
517 if (IS_QLA27XX(ha) &&
518 qla27xx_find_valid_image(vha) == QLA27XX_SECONDARY_IMAGE)
519 faddr = ha->flt_region_vpd_sec << 2;
521 mutex_lock(&ha->optrom_mutex);
522 if (qla2x00_chip_is_down(vha)) {
523 mutex_unlock(&ha->optrom_mutex);
526 ha->isp_ops->read_optrom(vha, ha->vpd, faddr,
528 mutex_unlock(&ha->optrom_mutex);
530 return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size);
534 qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj,
535 struct bin_attribute *bin_attr,
536 char *buf, loff_t off, size_t count)
538 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
539 struct device, kobj)));
540 struct qla_hw_data *ha = vha->hw;
543 if (unlikely(pci_channel_offline(ha->pdev)))
546 if (qla2x00_chip_is_down(vha))
549 if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size ||
550 !ha->isp_ops->write_nvram)
553 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
554 ql_log(ql_log_warn, vha, 0x706a,
555 "HBA not online, failing VPD update.\n");
559 mutex_lock(&ha->optrom_mutex);
560 if (qla2x00_chip_is_down(vha)) {
561 mutex_unlock(&ha->optrom_mutex);
566 ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->vpd_base, count);
567 ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->vpd_base, count);
569 /* Update flash version information for 4Gb & above. */
570 if (!IS_FWI2_CAPABLE(ha)) {
571 mutex_unlock(&ha->optrom_mutex);
575 tmp_data = vmalloc(256);
577 mutex_unlock(&ha->optrom_mutex);
578 ql_log(ql_log_warn, vha, 0x706b,
579 "Unable to allocate memory for VPD information update.\n");
582 ha->isp_ops->get_flash_version(vha, tmp_data);
585 mutex_unlock(&ha->optrom_mutex);
590 static struct bin_attribute sysfs_vpd_attr = {
593 .mode = S_IRUSR | S_IWUSR,
596 .read = qla2x00_sysfs_read_vpd,
597 .write = qla2x00_sysfs_write_vpd,
601 qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj,
602 struct bin_attribute *bin_attr,
603 char *buf, loff_t off, size_t count)
605 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
606 struct device, kobj)));
609 if (!capable(CAP_SYS_ADMIN) || off != 0 || count < SFP_DEV_SIZE)
612 mutex_lock(&vha->hw->optrom_mutex);
613 if (qla2x00_chip_is_down(vha)) {
614 mutex_unlock(&vha->hw->optrom_mutex);
618 rval = qla2x00_read_sfp_dev(vha, buf, count);
619 mutex_unlock(&vha->hw->optrom_mutex);
627 static struct bin_attribute sysfs_sfp_attr = {
630 .mode = S_IRUSR | S_IWUSR,
632 .size = SFP_DEV_SIZE,
633 .read = qla2x00_sysfs_read_sfp,
637 qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj,
638 struct bin_attribute *bin_attr,
639 char *buf, loff_t off, size_t count)
641 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
642 struct device, kobj)));
643 struct qla_hw_data *ha = vha->hw;
644 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
646 uint32_t idc_control;
647 uint8_t *tmp_data = NULL;
651 type = simple_strtol(buf, NULL, 10);
654 ql_log(ql_log_info, vha, 0x706e,
655 "Issuing ISP reset.\n");
657 scsi_block_requests(vha->host);
658 if (IS_QLA82XX(ha)) {
659 ha->flags.isp82xx_no_md_cap = 1;
660 qla82xx_idc_lock(ha);
661 qla82xx_set_reset_owner(vha);
662 qla82xx_idc_unlock(ha);
663 } else if (IS_QLA8044(ha)) {
664 qla8044_idc_lock(ha);
665 idc_control = qla8044_rd_reg(ha,
666 QLA8044_IDC_DRV_CTRL);
667 qla8044_wr_reg(ha, QLA8044_IDC_DRV_CTRL,
668 (idc_control | GRACEFUL_RESET_BIT1));
669 qla82xx_set_reset_owner(vha);
670 qla8044_idc_unlock(ha);
672 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
673 qla2xxx_wake_dpc(vha);
675 qla2x00_wait_for_chip_reset(vha);
676 scsi_unblock_requests(vha->host);
679 if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha))
682 ql_log(ql_log_info, vha, 0x706f,
683 "Issuing MPI reset.\n");
685 if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
686 uint32_t idc_control;
688 qla83xx_idc_lock(vha, 0);
689 __qla83xx_get_idc_control(vha, &idc_control);
690 idc_control |= QLA83XX_IDC_GRACEFUL_RESET;
691 __qla83xx_set_idc_control(vha, idc_control);
692 qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE,
693 QLA8XXX_DEV_NEED_RESET);
694 qla83xx_idc_audit(vha, IDC_AUDIT_TIMESTAMP);
695 qla83xx_idc_unlock(vha, 0);
698 /* Make sure FC side is not in reset */
699 qla2x00_wait_for_hba_online(vha);
701 /* Issue MPI reset */
702 scsi_block_requests(vha->host);
703 if (qla81xx_restart_mpi_firmware(vha) != QLA_SUCCESS)
704 ql_log(ql_log_warn, vha, 0x7070,
705 "MPI reset failed.\n");
706 scsi_unblock_requests(vha->host);
710 if (!IS_P3P_TYPE(ha) || vha != base_vha) {
711 ql_log(ql_log_info, vha, 0x7071,
712 "FCoE ctx reset not supported.\n");
716 ql_log(ql_log_info, vha, 0x7072,
717 "Issuing FCoE ctx reset.\n");
718 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
719 qla2xxx_wake_dpc(vha);
720 qla2x00_wait_for_fcoe_ctx_reset(vha);
725 ql_log(ql_log_info, vha, 0x70bc,
726 "Disabling Reset by IDC control\n");
727 qla83xx_idc_lock(vha, 0);
728 __qla83xx_get_idc_control(vha, &idc_control);
729 idc_control |= QLA83XX_IDC_RESET_DISABLED;
730 __qla83xx_set_idc_control(vha, idc_control);
731 qla83xx_idc_unlock(vha, 0);
736 ql_log(ql_log_info, vha, 0x70bd,
737 "Enabling Reset by IDC control\n");
738 qla83xx_idc_lock(vha, 0);
739 __qla83xx_get_idc_control(vha, &idc_control);
740 idc_control &= ~QLA83XX_IDC_RESET_DISABLED;
741 __qla83xx_set_idc_control(vha, idc_control);
742 qla83xx_idc_unlock(vha, 0);
745 ql_dbg(ql_dbg_user, vha, 0x70e0,
746 "Updating cache versions without reset ");
748 tmp_data = vmalloc(256);
750 ql_log(ql_log_warn, vha, 0x70e1,
751 "Unable to allocate memory for VPD information update.\n");
754 ha->isp_ops->get_flash_version(vha, tmp_data);
761 static struct bin_attribute sysfs_reset_attr = {
767 .write = qla2x00_sysfs_write_reset,
771 qla2x00_issue_logo(struct file *filp, struct kobject *kobj,
772 struct bin_attribute *bin_attr,
773 char *buf, loff_t off, size_t count)
775 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
776 struct device, kobj)));
780 if (!capable(CAP_SYS_ADMIN))
783 if (unlikely(pci_channel_offline(vha->hw->pdev)))
786 if (qla2x00_chip_is_down(vha))
789 type = simple_strtol(buf, NULL, 10);
791 did.b.domain = (type & 0x00ff0000) >> 16;
792 did.b.area = (type & 0x0000ff00) >> 8;
793 did.b.al_pa = (type & 0x000000ff);
795 ql_log(ql_log_info, vha, 0xd04d, "portid=%02x%02x%02x done\n",
796 did.b.domain, did.b.area, did.b.al_pa);
798 ql_log(ql_log_info, vha, 0x70e4, "%s: %d\n", __func__, type);
800 qla24xx_els_dcmd_iocb(vha, ELS_DCMD_LOGO, did);
804 static struct bin_attribute sysfs_issue_logo_attr = {
806 .name = "issue_logo",
810 .write = qla2x00_issue_logo,
814 qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct kobject *kobj,
815 struct bin_attribute *bin_attr,
816 char *buf, loff_t off, size_t count)
818 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
819 struct device, kobj)));
820 struct qla_hw_data *ha = vha->hw;
822 uint16_t actual_size;
824 if (!capable(CAP_SYS_ADMIN) || off != 0 || count > XGMAC_DATA_SIZE)
827 if (unlikely(pci_channel_offline(ha->pdev)))
829 mutex_lock(&vha->hw->optrom_mutex);
830 if (qla2x00_chip_is_down(vha)) {
831 mutex_unlock(&vha->hw->optrom_mutex);
838 ha->xgmac_data = dma_alloc_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE,
839 &ha->xgmac_data_dma, GFP_KERNEL);
840 if (!ha->xgmac_data) {
841 mutex_unlock(&vha->hw->optrom_mutex);
842 ql_log(ql_log_warn, vha, 0x7076,
843 "Unable to allocate memory for XGMAC read-data.\n");
849 memset(ha->xgmac_data, 0, XGMAC_DATA_SIZE);
851 rval = qla2x00_get_xgmac_stats(vha, ha->xgmac_data_dma,
852 XGMAC_DATA_SIZE, &actual_size);
854 mutex_unlock(&vha->hw->optrom_mutex);
855 if (rval != QLA_SUCCESS) {
856 ql_log(ql_log_warn, vha, 0x7077,
857 "Unable to read XGMAC data (%x).\n", rval);
861 count = actual_size > count ? count: actual_size;
862 memcpy(buf, ha->xgmac_data, count);
867 static struct bin_attribute sysfs_xgmac_stats_attr = {
869 .name = "xgmac_stats",
873 .read = qla2x00_sysfs_read_xgmac_stats,
877 qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj,
878 struct bin_attribute *bin_attr,
879 char *buf, loff_t off, size_t count)
881 struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
882 struct device, kobj)));
883 struct qla_hw_data *ha = vha->hw;
886 if (!capable(CAP_SYS_ADMIN) || off != 0 || count > DCBX_TLV_DATA_SIZE)
891 mutex_lock(&vha->hw->optrom_mutex);
892 if (qla2x00_chip_is_down(vha)) {
893 mutex_unlock(&vha->hw->optrom_mutex);
897 ha->dcbx_tlv = dma_alloc_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
898 &ha->dcbx_tlv_dma, GFP_KERNEL);
900 mutex_unlock(&vha->hw->optrom_mutex);
901 ql_log(ql_log_warn, vha, 0x7078,
902 "Unable to allocate memory for DCBX TLV read-data.\n");
907 memset(ha->dcbx_tlv, 0, DCBX_TLV_DATA_SIZE);
909 rval = qla2x00_get_dcbx_params(vha, ha->dcbx_tlv_dma,
912 mutex_unlock(&vha->hw->optrom_mutex);
914 if (rval != QLA_SUCCESS) {
915 ql_log(ql_log_warn, vha, 0x7079,
916 "Unable to read DCBX TLV (%x).\n", rval);
920 memcpy(buf, ha->dcbx_tlv, count);
925 static struct bin_attribute sysfs_dcbx_tlv_attr = {
931 .read = qla2x00_sysfs_read_dcbx_tlv,
934 static struct sysfs_entry {
936 struct bin_attribute *attr;
938 } bin_file_entries[] = {
939 { "fw_dump", &sysfs_fw_dump_attr, },
940 { "nvram", &sysfs_nvram_attr, },
941 { "optrom", &sysfs_optrom_attr, },
942 { "optrom_ctl", &sysfs_optrom_ctl_attr, },
943 { "vpd", &sysfs_vpd_attr, 1 },
944 { "sfp", &sysfs_sfp_attr, 1 },
945 { "reset", &sysfs_reset_attr, },
946 { "issue_logo", &sysfs_issue_logo_attr, },
947 { "xgmac_stats", &sysfs_xgmac_stats_attr, 3 },
948 { "dcbx_tlv", &sysfs_dcbx_tlv_attr, 3 },
953 qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha)
955 struct Scsi_Host *host = vha->host;
956 struct sysfs_entry *iter;
959 for (iter = bin_file_entries; iter->name; iter++) {
960 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw))
962 if (iter->is4GBp_only == 2 && !IS_QLA25XX(vha->hw))
964 if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw)))
967 ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
970 ql_log(ql_log_warn, vha, 0x00f3,
971 "Unable to create sysfs %s binary attribute (%d).\n",
974 ql_dbg(ql_dbg_init, vha, 0x00f4,
975 "Successfully created sysfs %s binary attribute.\n",
981 qla2x00_free_sysfs_attr(scsi_qla_host_t *vha, bool stop_beacon)
983 struct Scsi_Host *host = vha->host;
984 struct sysfs_entry *iter;
985 struct qla_hw_data *ha = vha->hw;
987 for (iter = bin_file_entries; iter->name; iter++) {
988 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
990 if (iter->is4GBp_only == 2 && !IS_QLA25XX(ha))
992 if (iter->is4GBp_only == 3 && !(IS_CNA_CAPABLE(vha->hw)))
994 if (iter->is4GBp_only == 0x27 && !IS_QLA27XX(vha->hw))
997 sysfs_remove_bin_file(&host->shost_gendev.kobj,
1001 if (stop_beacon && ha->beacon_blink_led == 1)
1002 ha->isp_ops->beacon_off(vha);
1005 /* Scsi_Host attributes. */
1008 qla2x00_driver_version_show(struct device *dev,
1009 struct device_attribute *attr, char *buf)
1011 return scnprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str);
1015 qla2x00_fw_version_show(struct device *dev,
1016 struct device_attribute *attr, char *buf)
1018 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1019 struct qla_hw_data *ha = vha->hw;
1022 return scnprintf(buf, PAGE_SIZE, "%s\n",
1023 ha->isp_ops->fw_version_str(vha, fw_str, sizeof(fw_str)));
1027 qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr,
1030 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1031 struct qla_hw_data *ha = vha->hw;
1034 if (IS_QLAFX00(vha->hw)) {
1035 return scnprintf(buf, PAGE_SIZE, "%s\n",
1036 vha->hw->mr.serial_num);
1037 } else if (IS_FWI2_CAPABLE(ha)) {
1038 qla2xxx_get_vpd_field(vha, "SN", buf, PAGE_SIZE - 1);
1039 return strlen(strcat(buf, "\n"));
1042 sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
1043 return scnprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000,
1048 qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr,
1051 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1052 return scnprintf(buf, PAGE_SIZE, "ISP%04X\n", vha->hw->pdev->device);
1056 qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr,
1059 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1060 struct qla_hw_data *ha = vha->hw;
1062 if (IS_QLAFX00(vha->hw))
1063 return scnprintf(buf, PAGE_SIZE, "%s\n",
1064 vha->hw->mr.hw_version);
1066 return scnprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n",
1067 ha->product_id[0], ha->product_id[1], ha->product_id[2],
1072 qla2x00_model_name_show(struct device *dev, struct device_attribute *attr,
1075 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1077 return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_number);
1081 qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr,
1084 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1085 return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_desc);
1089 qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr,
1092 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1095 return scnprintf(buf, PAGE_SIZE, "%s\n",
1096 vha->hw->isp_ops->pci_info_str(vha, pci_info));
1100 qla2x00_link_state_show(struct device *dev, struct device_attribute *attr,
1103 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1104 struct qla_hw_data *ha = vha->hw;
1107 if (atomic_read(&vha->loop_state) == LOOP_DOWN ||
1108 atomic_read(&vha->loop_state) == LOOP_DEAD ||
1109 vha->device_flags & DFLG_NO_CABLE)
1110 len = scnprintf(buf, PAGE_SIZE, "Link Down\n");
1111 else if (atomic_read(&vha->loop_state) != LOOP_READY ||
1112 qla2x00_chip_is_down(vha))
1113 len = scnprintf(buf, PAGE_SIZE, "Unknown Link State\n");
1115 len = scnprintf(buf, PAGE_SIZE, "Link Up - ");
1117 switch (ha->current_topology) {
1119 len += scnprintf(buf + len, PAGE_SIZE-len, "Loop\n");
1122 len += scnprintf(buf + len, PAGE_SIZE-len, "FL_Port\n");
1125 len += scnprintf(buf + len, PAGE_SIZE-len,
1126 "N_Port to N_Port\n");
1129 len += scnprintf(buf + len, PAGE_SIZE-len, "F_Port\n");
1132 len += scnprintf(buf + len, PAGE_SIZE-len, "Loop\n");
1140 qla2x00_zio_show(struct device *dev, struct device_attribute *attr,
1143 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1146 switch (vha->hw->zio_mode) {
1147 case QLA_ZIO_MODE_6:
1148 len += scnprintf(buf + len, PAGE_SIZE-len, "Mode 6\n");
1150 case QLA_ZIO_DISABLED:
1151 len += scnprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
1158 qla2x00_zio_store(struct device *dev, struct device_attribute *attr,
1159 const char *buf, size_t count)
1161 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1162 struct qla_hw_data *ha = vha->hw;
1166 if (!IS_ZIO_SUPPORTED(ha))
1169 if (sscanf(buf, "%d", &val) != 1)
1173 zio_mode = QLA_ZIO_MODE_6;
1175 zio_mode = QLA_ZIO_DISABLED;
1177 /* Update per-hba values and queue a reset. */
1178 if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) {
1179 ha->zio_mode = zio_mode;
1180 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
1186 qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr,
1189 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1191 return scnprintf(buf, PAGE_SIZE, "%d us\n", vha->hw->zio_timer * 100);
1195 qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr,
1196 const char *buf, size_t count)
1198 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1202 if (sscanf(buf, "%d", &val) != 1)
1204 if (val > 25500 || val < 100)
1207 zio_timer = (uint16_t)(val / 100);
1208 vha->hw->zio_timer = zio_timer;
1214 qla_zio_threshold_show(struct device *dev, struct device_attribute *attr,
1217 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1219 return scnprintf(buf, PAGE_SIZE, "%d exchanges\n",
1220 vha->hw->last_zio_threshold);
1224 qla_zio_threshold_store(struct device *dev, struct device_attribute *attr,
1225 const char *buf, size_t count)
1227 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1230 if (vha->hw->zio_mode != QLA_ZIO_MODE_6)
1232 if (sscanf(buf, "%d", &val) != 1)
1234 if (val < 0 || val > 256)
1237 atomic_set(&vha->hw->zio_threshold, val);
1242 qla2x00_beacon_show(struct device *dev, struct device_attribute *attr,
1245 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1248 if (vha->hw->beacon_blink_led)
1249 len += scnprintf(buf + len, PAGE_SIZE-len, "Enabled\n");
1251 len += scnprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
1256 qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
1257 const char *buf, size_t count)
1259 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1260 struct qla_hw_data *ha = vha->hw;
1264 if (IS_QLA2100(ha) || IS_QLA2200(ha))
1267 if (sscanf(buf, "%d", &val) != 1)
1270 mutex_lock(&vha->hw->optrom_mutex);
1271 if (qla2x00_chip_is_down(vha)) {
1272 mutex_unlock(&vha->hw->optrom_mutex);
1273 ql_log(ql_log_warn, vha, 0x707a,
1274 "Abort ISP active -- ignoring beacon request.\n");
1279 rval = ha->isp_ops->beacon_on(vha);
1281 rval = ha->isp_ops->beacon_off(vha);
1283 if (rval != QLA_SUCCESS)
1286 mutex_unlock(&vha->hw->optrom_mutex);
1292 qla2x00_optrom_bios_version_show(struct device *dev,
1293 struct device_attribute *attr, char *buf)
1295 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1296 struct qla_hw_data *ha = vha->hw;
1297 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
1298 ha->bios_revision[0]);
1302 qla2x00_optrom_efi_version_show(struct device *dev,
1303 struct device_attribute *attr, char *buf)
1305 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1306 struct qla_hw_data *ha = vha->hw;
1307 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
1308 ha->efi_revision[0]);
1312 qla2x00_optrom_fcode_version_show(struct device *dev,
1313 struct device_attribute *attr, char *buf)
1315 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1316 struct qla_hw_data *ha = vha->hw;
1317 return scnprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
1318 ha->fcode_revision[0]);
1322 qla2x00_optrom_fw_version_show(struct device *dev,
1323 struct device_attribute *attr, char *buf)
1325 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1326 struct qla_hw_data *ha = vha->hw;
1327 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
1328 ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
1329 ha->fw_revision[3]);
1333 qla2x00_optrom_gold_fw_version_show(struct device *dev,
1334 struct device_attribute *attr, char *buf)
1336 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1337 struct qla_hw_data *ha = vha->hw;
1339 if (!IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA27XX(ha))
1340 return scnprintf(buf, PAGE_SIZE, "\n");
1342 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%d)\n",
1343 ha->gold_fw_version[0], ha->gold_fw_version[1],
1344 ha->gold_fw_version[2], ha->gold_fw_version[3]);
1348 qla2x00_total_isp_aborts_show(struct device *dev,
1349 struct device_attribute *attr, char *buf)
1351 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1352 return scnprintf(buf, PAGE_SIZE, "%d\n",
1353 vha->qla_stats.total_isp_aborts);
1357 qla24xx_84xx_fw_version_show(struct device *dev,
1358 struct device_attribute *attr, char *buf)
1360 int rval = QLA_SUCCESS;
1361 uint16_t status[2] = {0, 0};
1362 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1363 struct qla_hw_data *ha = vha->hw;
1365 if (!IS_QLA84XX(ha))
1366 return scnprintf(buf, PAGE_SIZE, "\n");
1368 if (ha->cs84xx->op_fw_version == 0)
1369 rval = qla84xx_verify_chip(vha, status);
1371 if ((rval == QLA_SUCCESS) && (status[0] == 0))
1372 return scnprintf(buf, PAGE_SIZE, "%u\n",
1373 (uint32_t)ha->cs84xx->op_fw_version);
1375 return scnprintf(buf, PAGE_SIZE, "\n");
1379 qla2x00_mpi_version_show(struct device *dev, struct device_attribute *attr,
1382 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1383 struct qla_hw_data *ha = vha->hw;
1385 if (!IS_QLA81XX(ha) && !IS_QLA8031(ha) && !IS_QLA8044(ha) &&
1387 return scnprintf(buf, PAGE_SIZE, "\n");
1389 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
1390 ha->mpi_version[0], ha->mpi_version[1], ha->mpi_version[2],
1391 ha->mpi_capabilities);
1395 qla2x00_phy_version_show(struct device *dev, struct device_attribute *attr,
1398 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1399 struct qla_hw_data *ha = vha->hw;
1401 if (!IS_QLA81XX(ha) && !IS_QLA8031(ha))
1402 return scnprintf(buf, PAGE_SIZE, "\n");
1404 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
1405 ha->phy_version[0], ha->phy_version[1], ha->phy_version[2]);
1409 qla2x00_flash_block_size_show(struct device *dev,
1410 struct device_attribute *attr, char *buf)
1412 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1413 struct qla_hw_data *ha = vha->hw;
1415 return scnprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size);
1419 qla2x00_vlan_id_show(struct device *dev, struct device_attribute *attr,
1422 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1424 if (!IS_CNA_CAPABLE(vha->hw))
1425 return scnprintf(buf, PAGE_SIZE, "\n");
1427 return scnprintf(buf, PAGE_SIZE, "%d\n", vha->fcoe_vlan_id);
1431 qla2x00_vn_port_mac_address_show(struct device *dev,
1432 struct device_attribute *attr, char *buf)
1434 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1436 if (!IS_CNA_CAPABLE(vha->hw))
1437 return scnprintf(buf, PAGE_SIZE, "\n");
1439 return scnprintf(buf, PAGE_SIZE, "%pMR\n", vha->fcoe_vn_port_mac);
1443 qla2x00_fabric_param_show(struct device *dev, struct device_attribute *attr,
1446 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1448 return scnprintf(buf, PAGE_SIZE, "%d\n", vha->hw->switch_cap);
1452 qla2x00_thermal_temp_show(struct device *dev,
1453 struct device_attribute *attr, char *buf)
1455 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1459 mutex_lock(&vha->hw->optrom_mutex);
1460 if (qla2x00_chip_is_down(vha)) {
1461 mutex_unlock(&vha->hw->optrom_mutex);
1462 ql_log(ql_log_warn, vha, 0x70dc, "ISP reset active.\n");
1466 if (vha->hw->flags.eeh_busy) {
1467 mutex_unlock(&vha->hw->optrom_mutex);
1468 ql_log(ql_log_warn, vha, 0x70dd, "PCI EEH busy.\n");
1472 rc = qla2x00_get_thermal_temp(vha, &temp);
1473 mutex_unlock(&vha->hw->optrom_mutex);
1474 if (rc == QLA_SUCCESS)
1475 return scnprintf(buf, PAGE_SIZE, "%d\n", temp);
1478 return scnprintf(buf, PAGE_SIZE, "\n");
1482 qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
1485 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1486 int rval = QLA_FUNCTION_FAILED;
1490 if (IS_QLAFX00(vha->hw)) {
1491 pstate = qlafx00_fw_state_show(dev, attr, buf);
1492 return scnprintf(buf, PAGE_SIZE, "0x%x\n", pstate);
1495 mutex_lock(&vha->hw->optrom_mutex);
1496 if (qla2x00_chip_is_down(vha)) {
1497 mutex_unlock(&vha->hw->optrom_mutex);
1498 ql_log(ql_log_warn, vha, 0x707c,
1499 "ISP reset active.\n");
1501 } else if (vha->hw->flags.eeh_busy) {
1502 mutex_unlock(&vha->hw->optrom_mutex);
1506 rval = qla2x00_get_firmware_state(vha, state);
1507 mutex_unlock(&vha->hw->optrom_mutex);
1509 if (rval != QLA_SUCCESS) {
1510 memset(state, -1, sizeof(state));
1511 rval = qla2x00_get_firmware_state(vha, state);
1514 return scnprintf(buf, PAGE_SIZE, "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1515 state[0], state[1], state[2], state[3], state[4], state[5]);
1519 qla2x00_diag_requests_show(struct device *dev,
1520 struct device_attribute *attr, char *buf)
1522 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1524 if (!IS_BIDI_CAPABLE(vha->hw))
1525 return scnprintf(buf, PAGE_SIZE, "\n");
1527 return scnprintf(buf, PAGE_SIZE, "%llu\n", vha->bidi_stats.io_count);
1531 qla2x00_diag_megabytes_show(struct device *dev,
1532 struct device_attribute *attr, char *buf)
1534 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1536 if (!IS_BIDI_CAPABLE(vha->hw))
1537 return scnprintf(buf, PAGE_SIZE, "\n");
1539 return scnprintf(buf, PAGE_SIZE, "%llu\n",
1540 vha->bidi_stats.transfer_bytes >> 20);
1544 qla2x00_fw_dump_size_show(struct device *dev, struct device_attribute *attr,
1547 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1548 struct qla_hw_data *ha = vha->hw;
1553 else if (IS_P3P_TYPE(ha))
1554 size = ha->md_template_size + ha->md_dump_size;
1556 size = ha->fw_dump_len;
1558 return scnprintf(buf, PAGE_SIZE, "%d\n", size);
1562 qla2x00_allow_cna_fw_dump_show(struct device *dev,
1563 struct device_attribute *attr, char *buf)
1565 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1567 if (!IS_P3P_TYPE(vha->hw))
1568 return scnprintf(buf, PAGE_SIZE, "\n");
1570 return scnprintf(buf, PAGE_SIZE, "%s\n",
1571 vha->hw->allow_cna_fw_dump ? "true" : "false");
1575 qla2x00_allow_cna_fw_dump_store(struct device *dev,
1576 struct device_attribute *attr, const char *buf, size_t count)
1578 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1581 if (!IS_P3P_TYPE(vha->hw))
1584 if (sscanf(buf, "%d", &val) != 1)
1587 vha->hw->allow_cna_fw_dump = val != 0;
1593 qla2x00_pep_version_show(struct device *dev, struct device_attribute *attr,
1596 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1597 struct qla_hw_data *ha = vha->hw;
1599 if (!IS_QLA27XX(ha))
1600 return scnprintf(buf, PAGE_SIZE, "\n");
1602 return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
1603 ha->pep_version[0], ha->pep_version[1], ha->pep_version[2]);
1607 qla2x00_min_link_speed_show(struct device *dev, struct device_attribute *attr,
1610 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1611 struct qla_hw_data *ha = vha->hw;
1613 if (!IS_QLA27XX(ha))
1614 return scnprintf(buf, PAGE_SIZE, "\n");
1616 return scnprintf(buf, PAGE_SIZE, "%s\n",
1617 ha->min_link_speed == 5 ? "32Gps" :
1618 ha->min_link_speed == 4 ? "16Gps" :
1619 ha->min_link_speed == 3 ? "8Gps" :
1620 ha->min_link_speed == 2 ? "4Gps" :
1621 ha->min_link_speed != 0 ? "unknown" : "");
1625 qla2x00_max_speed_sup_show(struct device *dev, struct device_attribute *attr,
1628 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1629 struct qla_hw_data *ha = vha->hw;
1631 if (!IS_QLA27XX(ha))
1632 return scnprintf(buf, PAGE_SIZE, "\n");
1634 return scnprintf(buf, PAGE_SIZE, "%s\n",
1635 ha->max_speed_sup ? "32Gps" : "16Gps");
1639 qla2x00_port_speed_store(struct device *dev, struct device_attribute *attr,
1640 const char *buf, size_t count)
1642 struct scsi_qla_host *vha = shost_priv(dev_to_shost(dev));
1645 int mode = QLA_SET_DATA_RATE_LR;
1646 struct qla_hw_data *ha = vha->hw;
1648 if (!IS_QLA27XX(vha->hw)) {
1649 ql_log(ql_log_warn, vha, 0x70d8,
1650 "Speed setting not supported \n");
1654 rval = kstrtol(buf, 10, &type);
1656 if (type == 40 || type == 80 || type == 160 ||
1658 ql_dbg(ql_dbg_user, vha, 0x70d9,
1659 "Setting will be affected after a loss of sync\n");
1661 mode = QLA_SET_DATA_RATE_NOLR;
1664 oldspeed = ha->set_data_rate;
1668 ha->set_data_rate = PORT_SPEED_AUTO;
1671 ha->set_data_rate = PORT_SPEED_4GB;
1674 ha->set_data_rate = PORT_SPEED_8GB;
1677 ha->set_data_rate = PORT_SPEED_16GB;
1680 ha->set_data_rate = PORT_SPEED_32GB;
1683 ql_log(ql_log_warn, vha, 0x1199,
1684 "Unrecognized speed setting:%lx. Setting Autoneg\n",
1686 ha->set_data_rate = PORT_SPEED_AUTO;
1689 if (qla2x00_chip_is_down(vha) || (oldspeed == ha->set_data_rate))
1692 ql_log(ql_log_info, vha, 0x70da,
1693 "Setting speed to %lx Gbps \n", type);
1695 rval = qla2x00_set_data_rate(vha, mode);
1696 if (rval != QLA_SUCCESS)
1703 qla2x00_port_speed_show(struct device *dev, struct device_attribute *attr,
1706 struct scsi_qla_host *vha = shost_priv(dev_to_shost(dev));
1707 struct qla_hw_data *ha = vha->hw;
1709 char *spd[7] = {"0", "0", "0", "4", "8", "16", "32"};
1711 rval = qla2x00_get_data_rate(vha);
1712 if (rval != QLA_SUCCESS) {
1713 ql_log(ql_log_warn, vha, 0x70db,
1714 "Unable to get port speed rval:%zd\n", rval);
1718 ql_log(ql_log_info, vha, 0x70d6,
1719 "port speed:%d\n", ha->link_data_rate);
1721 return scnprintf(buf, PAGE_SIZE, "%s\n", spd[ha->link_data_rate]);
1727 qlini_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
1729 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
1732 len += scnprintf(buf + len, PAGE_SIZE-len,
1733 "Supported options: enabled | disabled | dual | exclusive\n");
1736 len += scnprintf(buf + len, PAGE_SIZE-len, "Current selection: ");
1738 switch (vha->qlini_mode) {
1739 case QLA2XXX_INI_MODE_EXCLUSIVE:
1740 len += scnprintf(buf + len, PAGE_SIZE-len,
1741 QLA2XXX_INI_MODE_STR_EXCLUSIVE);
1743 case QLA2XXX_INI_MODE_DISABLED:
1744 len += scnprintf(buf + len, PAGE_SIZE-len,
1745 QLA2XXX_INI_MODE_STR_DISABLED);
1747 case QLA2XXX_INI_MODE_ENABLED:
1748 len += scnprintf(buf + len, PAGE_SIZE-len,
1749 QLA2XXX_INI_MODE_STR_ENABLED);
1751 case QLA2XXX_INI_MODE_DUAL:
1752 len += scnprintf(buf + len, PAGE_SIZE-len,
1753 QLA2XXX_INI_MODE_STR_DUAL);
1756 len += scnprintf(buf + len, PAGE_SIZE-len, "\n");
1761 static char *mode_to_str[] = {
1768 #define NEED_EXCH_OFFLOAD(_exchg) ((_exchg) > FW_DEF_EXCHANGES_CNT)
1769 static int qla_set_ini_mode(scsi_qla_host_t *vha, int op)
1775 MODE_CHANGE_NO_ACTION,
1776 TARGET_STILL_ACTIVE,
1778 int action = NO_ACTION;
1780 u8 eo_toggle = 0; /* exchange offload flipped */
1782 switch (vha->qlini_mode) {
1783 case QLA2XXX_INI_MODE_DISABLED:
1785 case QLA2XXX_INI_MODE_DISABLED:
1786 if (qla_tgt_mode_enabled(vha)) {
1787 if (NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld) !=
1788 vha->hw->flags.exchoffld_enabled)
1790 if (((vha->ql2xexchoffld !=
1791 vha->u_ql2xexchoffld) &&
1792 NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld)) ||
1795 * The number of exchange to be offload
1796 * was tweaked or offload option was
1799 action = MODE_CHANGE_ACCEPT;
1801 action = MODE_CHANGE_NO_ACTION;
1804 action = MODE_CHANGE_NO_ACTION;
1807 case QLA2XXX_INI_MODE_EXCLUSIVE:
1808 if (qla_tgt_mode_enabled(vha)) {
1809 if (NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld) !=
1810 vha->hw->flags.exchoffld_enabled)
1812 if (((vha->ql2xexchoffld !=
1813 vha->u_ql2xexchoffld) &&
1814 NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld)) ||
1817 * The number of exchange to be offload
1818 * was tweaked or offload option was
1821 action = MODE_CHANGE_ACCEPT;
1823 action = MODE_CHANGE_NO_ACTION;
1826 action = MODE_CHANGE_ACCEPT;
1829 case QLA2XXX_INI_MODE_DUAL:
1830 action = MODE_CHANGE_ACCEPT;
1831 /* active_mode is target only, reset it to dual */
1832 if (qla_tgt_mode_enabled(vha)) {
1834 action = MODE_CHANGE_ACCEPT;
1836 action = MODE_CHANGE_NO_ACTION;
1840 case QLA2XXX_INI_MODE_ENABLED:
1841 if (qla_tgt_mode_enabled(vha))
1842 action = TARGET_STILL_ACTIVE;
1844 action = MODE_CHANGE_ACCEPT;
1851 case QLA2XXX_INI_MODE_EXCLUSIVE:
1853 case QLA2XXX_INI_MODE_EXCLUSIVE:
1854 if (qla_tgt_mode_enabled(vha)) {
1855 if (NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld) !=
1856 vha->hw->flags.exchoffld_enabled)
1858 if (((vha->ql2xexchoffld !=
1859 vha->u_ql2xexchoffld) &&
1860 NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld)) ||
1863 * The number of exchange to be offload
1864 * was tweaked or offload option was
1867 action = MODE_CHANGE_ACCEPT;
1875 case QLA2XXX_INI_MODE_DISABLED:
1876 if (qla_tgt_mode_enabled(vha)) {
1877 if (NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld) !=
1878 vha->hw->flags.exchoffld_enabled)
1880 if (((vha->ql2xexchoffld !=
1881 vha->u_ql2xexchoffld) &&
1882 NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld)) ||
1884 action = MODE_CHANGE_ACCEPT;
1886 action = MODE_CHANGE_NO_ACTION;
1888 action = MODE_CHANGE_NO_ACTION;
1891 case QLA2XXX_INI_MODE_DUAL: /* exclusive -> dual */
1892 if (qla_tgt_mode_enabled(vha)) {
1893 action = MODE_CHANGE_ACCEPT;
1896 action = MODE_CHANGE_ACCEPT;
1899 case QLA2XXX_INI_MODE_ENABLED:
1900 if (qla_tgt_mode_enabled(vha))
1901 action = TARGET_STILL_ACTIVE;
1903 if (vha->hw->flags.fw_started)
1904 action = MODE_CHANGE_NO_ACTION;
1906 action = MODE_CHANGE_ACCEPT;
1912 case QLA2XXX_INI_MODE_ENABLED:
1914 case QLA2XXX_INI_MODE_ENABLED:
1915 if (NEED_EXCH_OFFLOAD(vha->u_ql2xiniexchg) !=
1916 vha->hw->flags.exchoffld_enabled)
1918 if (((vha->ql2xiniexchg != vha->u_ql2xiniexchg) &&
1919 NEED_EXCH_OFFLOAD(vha->u_ql2xiniexchg)) ||
1921 action = MODE_CHANGE_ACCEPT;
1925 case QLA2XXX_INI_MODE_DUAL:
1926 case QLA2XXX_INI_MODE_DISABLED:
1927 action = MODE_CHANGE_ACCEPT;
1930 action = MODE_CHANGE_NO_ACTION;
1935 case QLA2XXX_INI_MODE_DUAL:
1937 case QLA2XXX_INI_MODE_DUAL:
1938 if (qla_tgt_mode_enabled(vha) ||
1939 qla_dual_mode_enabled(vha)) {
1940 if (NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld +
1941 vha->u_ql2xiniexchg) !=
1942 vha->hw->flags.exchoffld_enabled)
1945 if ((((vha->ql2xexchoffld +
1946 vha->ql2xiniexchg) !=
1947 (vha->u_ql2xiniexchg +
1948 vha->u_ql2xexchoffld)) &&
1949 NEED_EXCH_OFFLOAD(vha->u_ql2xiniexchg +
1950 vha->u_ql2xexchoffld)) || eo_toggle)
1951 action = MODE_CHANGE_ACCEPT;
1955 if (NEED_EXCH_OFFLOAD(vha->u_ql2xexchoffld +
1956 vha->u_ql2xiniexchg) !=
1957 vha->hw->flags.exchoffld_enabled)
1960 if ((((vha->ql2xexchoffld + vha->ql2xiniexchg)
1961 != (vha->u_ql2xiniexchg +
1962 vha->u_ql2xexchoffld)) &&
1963 NEED_EXCH_OFFLOAD(vha->u_ql2xiniexchg +
1964 vha->u_ql2xexchoffld)) || eo_toggle)
1965 action = MODE_CHANGE_NO_ACTION;
1971 case QLA2XXX_INI_MODE_DISABLED:
1972 if (qla_tgt_mode_enabled(vha) ||
1973 qla_dual_mode_enabled(vha)) {
1974 /* turning off initiator mode */
1976 action = MODE_CHANGE_ACCEPT;
1978 action = MODE_CHANGE_NO_ACTION;
1982 case QLA2XXX_INI_MODE_EXCLUSIVE:
1983 if (qla_tgt_mode_enabled(vha) ||
1984 qla_dual_mode_enabled(vha)) {
1986 action = MODE_CHANGE_ACCEPT;
1988 action = MODE_CHANGE_ACCEPT;
1992 case QLA2XXX_INI_MODE_ENABLED:
1993 if (qla_tgt_mode_enabled(vha) ||
1994 qla_dual_mode_enabled(vha)) {
1995 action = TARGET_STILL_ACTIVE;
1997 action = MODE_CHANGE_ACCEPT;
2004 case MODE_CHANGE_ACCEPT:
2005 ql_log(ql_log_warn, vha, 0xffff,
2006 "Mode change accepted. From %s to %s, Tgt exchg %d|%d. ini exchg %d|%d\n",
2007 mode_to_str[vha->qlini_mode], mode_to_str[op],
2008 vha->ql2xexchoffld, vha->u_ql2xexchoffld,
2009 vha->ql2xiniexchg, vha->u_ql2xiniexchg);
2011 vha->qlini_mode = op;
2012 vha->ql2xexchoffld = vha->u_ql2xexchoffld;
2013 vha->ql2xiniexchg = vha->u_ql2xiniexchg;
2016 vha->flags.online = 1;
2017 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
2020 case MODE_CHANGE_NO_ACTION:
2021 ql_log(ql_log_warn, vha, 0xffff,
2022 "Mode is set. No action taken. From %s to %s, Tgt exchg %d|%d. ini exchg %d|%d\n",
2023 mode_to_str[vha->qlini_mode], mode_to_str[op],
2024 vha->ql2xexchoffld, vha->u_ql2xexchoffld,
2025 vha->ql2xiniexchg, vha->u_ql2xiniexchg);
2026 vha->qlini_mode = op;
2027 vha->ql2xexchoffld = vha->u_ql2xexchoffld;
2028 vha->ql2xiniexchg = vha->u_ql2xiniexchg;
2031 case TARGET_STILL_ACTIVE:
2032 ql_log(ql_log_warn, vha, 0xffff,
2033 "Target Mode is active. Unable to change Mode.\n");
2038 ql_log(ql_log_warn, vha, 0xffff,
2039 "Mode unchange. No action taken. %d|%d pct %d|%d.\n",
2040 vha->qlini_mode, op,
2041 vha->ql2xexchoffld, vha->u_ql2xexchoffld);
2049 qlini_mode_store(struct device *dev, struct device_attribute *attr,
2050 const char *buf, size_t count)
2052 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
2058 if (strncasecmp(QLA2XXX_INI_MODE_STR_EXCLUSIVE, buf,
2059 strlen(QLA2XXX_INI_MODE_STR_EXCLUSIVE)) == 0)
2060 ini = QLA2XXX_INI_MODE_EXCLUSIVE;
2061 else if (strncasecmp(QLA2XXX_INI_MODE_STR_DISABLED, buf,
2062 strlen(QLA2XXX_INI_MODE_STR_DISABLED)) == 0)
2063 ini = QLA2XXX_INI_MODE_DISABLED;
2064 else if (strncasecmp(QLA2XXX_INI_MODE_STR_ENABLED, buf,
2065 strlen(QLA2XXX_INI_MODE_STR_ENABLED)) == 0)
2066 ini = QLA2XXX_INI_MODE_ENABLED;
2067 else if (strncasecmp(QLA2XXX_INI_MODE_STR_DUAL, buf,
2068 strlen(QLA2XXX_INI_MODE_STR_DUAL)) == 0)
2069 ini = QLA2XXX_INI_MODE_DUAL;
2073 qla_set_ini_mode(vha, ini);
2078 ql2xexchoffld_show(struct device *dev, struct device_attribute *attr,
2081 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
2084 len += scnprintf(buf + len, PAGE_SIZE-len,
2085 "target exchange: new %d : current: %d\n\n",
2086 vha->u_ql2xexchoffld, vha->ql2xexchoffld);
2088 len += scnprintf(buf + len, PAGE_SIZE-len,
2089 "Please (re)set operating mode via \"/sys/class/scsi_host/host%ld/qlini_mode\" to load new setting.\n",
2096 ql2xexchoffld_store(struct device *dev, struct device_attribute *attr,
2097 const char *buf, size_t count)
2099 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
2102 if (sscanf(buf, "%d", &val) != 1)
2105 if (val > FW_MAX_EXCHANGES_CNT)
2106 val = FW_MAX_EXCHANGES_CNT;
2110 vha->u_ql2xexchoffld = val;
2115 ql2xiniexchg_show(struct device *dev, struct device_attribute *attr,
2118 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
2121 len += scnprintf(buf + len, PAGE_SIZE-len,
2122 "target exchange: new %d : current: %d\n\n",
2123 vha->u_ql2xiniexchg, vha->ql2xiniexchg);
2125 len += scnprintf(buf + len, PAGE_SIZE-len,
2126 "Please (re)set operating mode via \"/sys/class/scsi_host/host%ld/qlini_mode\" to load new setting.\n",
2133 ql2xiniexchg_store(struct device *dev, struct device_attribute *attr,
2134 const char *buf, size_t count)
2136 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
2139 if (sscanf(buf, "%d", &val) != 1)
2142 if (val > FW_MAX_EXCHANGES_CNT)
2143 val = FW_MAX_EXCHANGES_CNT;
2147 vha->u_ql2xiniexchg = val;
2152 qla2x00_dif_bundle_statistics_show(struct device *dev,
2153 struct device_attribute *attr, char *buf)
2155 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
2156 struct qla_hw_data *ha = vha->hw;
2158 return scnprintf(buf, PAGE_SIZE,
2159 "cross=%llu read=%llu write=%llu kalloc=%llu dma_alloc=%llu unusable=%u\n",
2160 ha->dif_bundle_crossed_pages, ha->dif_bundle_reads,
2161 ha->dif_bundle_writes, ha->dif_bundle_kallocs,
2162 ha->dif_bundle_dma_allocs, ha->pool.unusable.count);
2165 static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_driver_version_show, NULL);
2166 static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
2167 static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
2168 static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
2169 static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
2170 static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
2171 static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
2172 static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
2173 static DEVICE_ATTR(link_state, S_IRUGO, qla2x00_link_state_show, NULL);
2174 static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store);
2175 static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
2176 qla2x00_zio_timer_store);
2177 static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
2178 qla2x00_beacon_store);
2179 static DEVICE_ATTR(optrom_bios_version, S_IRUGO,
2180 qla2x00_optrom_bios_version_show, NULL);
2181 static DEVICE_ATTR(optrom_efi_version, S_IRUGO,
2182 qla2x00_optrom_efi_version_show, NULL);
2183 static DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
2184 qla2x00_optrom_fcode_version_show, NULL);
2185 static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show,
2187 static DEVICE_ATTR(optrom_gold_fw_version, S_IRUGO,
2188 qla2x00_optrom_gold_fw_version_show, NULL);
2189 static DEVICE_ATTR(84xx_fw_version, S_IRUGO, qla24xx_84xx_fw_version_show,
2191 static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show,
2193 static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL);
2194 static DEVICE_ATTR(phy_version, S_IRUGO, qla2x00_phy_version_show, NULL);
2195 static DEVICE_ATTR(flash_block_size, S_IRUGO, qla2x00_flash_block_size_show,
2197 static DEVICE_ATTR(vlan_id, S_IRUGO, qla2x00_vlan_id_show, NULL);
2198 static DEVICE_ATTR(vn_port_mac_address, S_IRUGO,
2199 qla2x00_vn_port_mac_address_show, NULL);
2200 static DEVICE_ATTR(fabric_param, S_IRUGO, qla2x00_fabric_param_show, NULL);
2201 static DEVICE_ATTR(fw_state, S_IRUGO, qla2x00_fw_state_show, NULL);
2202 static DEVICE_ATTR(thermal_temp, S_IRUGO, qla2x00_thermal_temp_show, NULL);
2203 static DEVICE_ATTR(diag_requests, S_IRUGO, qla2x00_diag_requests_show, NULL);
2204 static DEVICE_ATTR(diag_megabytes, S_IRUGO, qla2x00_diag_megabytes_show, NULL);
2205 static DEVICE_ATTR(fw_dump_size, S_IRUGO, qla2x00_fw_dump_size_show, NULL);
2206 static DEVICE_ATTR(allow_cna_fw_dump, S_IRUGO | S_IWUSR,
2207 qla2x00_allow_cna_fw_dump_show,
2208 qla2x00_allow_cna_fw_dump_store);
2209 static DEVICE_ATTR(pep_version, S_IRUGO, qla2x00_pep_version_show, NULL);
2210 static DEVICE_ATTR(min_link_speed, S_IRUGO, qla2x00_min_link_speed_show, NULL);
2211 static DEVICE_ATTR(max_speed_sup, S_IRUGO, qla2x00_max_speed_sup_show, NULL);
2212 static DEVICE_ATTR(zio_threshold, 0644,
2213 qla_zio_threshold_show,
2214 qla_zio_threshold_store);
2215 static DEVICE_ATTR_RW(qlini_mode);
2216 static DEVICE_ATTR_RW(ql2xexchoffld);
2217 static DEVICE_ATTR_RW(ql2xiniexchg);
2218 static DEVICE_ATTR(dif_bundle_statistics, 0444,
2219 qla2x00_dif_bundle_statistics_show, NULL);
2220 static DEVICE_ATTR(port_speed, 0644, qla2x00_port_speed_show,
2221 qla2x00_port_speed_store);
2224 struct device_attribute *qla2x00_host_attrs[] = {
2225 &dev_attr_driver_version,
2226 &dev_attr_fw_version,
2227 &dev_attr_serial_num,
2230 &dev_attr_model_name,
2231 &dev_attr_model_desc,
2233 &dev_attr_link_state,
2235 &dev_attr_zio_timer,
2237 &dev_attr_optrom_bios_version,
2238 &dev_attr_optrom_efi_version,
2239 &dev_attr_optrom_fcode_version,
2240 &dev_attr_optrom_fw_version,
2241 &dev_attr_84xx_fw_version,
2242 &dev_attr_total_isp_aborts,
2243 &dev_attr_mpi_version,
2244 &dev_attr_phy_version,
2245 &dev_attr_flash_block_size,
2247 &dev_attr_vn_port_mac_address,
2248 &dev_attr_fabric_param,
2250 &dev_attr_optrom_gold_fw_version,
2251 &dev_attr_thermal_temp,
2252 &dev_attr_diag_requests,
2253 &dev_attr_diag_megabytes,
2254 &dev_attr_fw_dump_size,
2255 &dev_attr_allow_cna_fw_dump,
2256 &dev_attr_pep_version,
2257 &dev_attr_min_link_speed,
2258 &dev_attr_max_speed_sup,
2259 &dev_attr_zio_threshold,
2260 &dev_attr_dif_bundle_statistics,
2261 &dev_attr_port_speed,
2262 NULL, /* reserve for qlini_mode */
2263 NULL, /* reserve for ql2xiniexchg */
2264 NULL, /* reserve for ql2xexchoffld */
2268 void qla_insert_tgt_attrs(void)
2270 struct device_attribute **attr;
2272 /* advance to empty slot */
2273 for (attr = &qla2x00_host_attrs[0]; *attr; ++attr)
2276 *attr = &dev_attr_qlini_mode;
2278 *attr = &dev_attr_ql2xiniexchg;
2280 *attr = &dev_attr_ql2xexchoffld;
2283 /* Host attributes. */
2286 qla2x00_get_host_port_id(struct Scsi_Host *shost)
2288 scsi_qla_host_t *vha = shost_priv(shost);
2290 fc_host_port_id(shost) = vha->d_id.b.domain << 16 |
2291 vha->d_id.b.area << 8 | vha->d_id.b.al_pa;
2295 qla2x00_get_host_speed(struct Scsi_Host *shost)
2297 struct qla_hw_data *ha = ((struct scsi_qla_host *)
2298 (shost_priv(shost)))->hw;
2299 u32 speed = FC_PORTSPEED_UNKNOWN;
2301 if (IS_QLAFX00(ha)) {
2302 qlafx00_get_host_speed(shost);
2306 switch (ha->link_data_rate) {
2307 case PORT_SPEED_1GB:
2308 speed = FC_PORTSPEED_1GBIT;
2310 case PORT_SPEED_2GB:
2311 speed = FC_PORTSPEED_2GBIT;
2313 case PORT_SPEED_4GB:
2314 speed = FC_PORTSPEED_4GBIT;
2316 case PORT_SPEED_8GB:
2317 speed = FC_PORTSPEED_8GBIT;
2319 case PORT_SPEED_10GB:
2320 speed = FC_PORTSPEED_10GBIT;
2322 case PORT_SPEED_16GB:
2323 speed = FC_PORTSPEED_16GBIT;
2325 case PORT_SPEED_32GB:
2326 speed = FC_PORTSPEED_32GBIT;
2329 fc_host_speed(shost) = speed;
2333 qla2x00_get_host_port_type(struct Scsi_Host *shost)
2335 scsi_qla_host_t *vha = shost_priv(shost);
2336 uint32_t port_type = FC_PORTTYPE_UNKNOWN;
2339 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
2342 switch (vha->hw->current_topology) {
2344 port_type = FC_PORTTYPE_LPORT;
2347 port_type = FC_PORTTYPE_NLPORT;
2350 port_type = FC_PORTTYPE_PTP;
2353 port_type = FC_PORTTYPE_NPORT;
2356 fc_host_port_type(shost) = port_type;
2360 qla2x00_get_starget_node_name(struct scsi_target *starget)
2362 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
2363 scsi_qla_host_t *vha = shost_priv(host);
2367 list_for_each_entry(fcport, &vha->vp_fcports, list) {
2368 if (fcport->rport &&
2369 starget->id == fcport->rport->scsi_target_id) {
2370 node_name = wwn_to_u64(fcport->node_name);
2375 fc_starget_node_name(starget) = node_name;
2379 qla2x00_get_starget_port_name(struct scsi_target *starget)
2381 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
2382 scsi_qla_host_t *vha = shost_priv(host);
2386 list_for_each_entry(fcport, &vha->vp_fcports, list) {
2387 if (fcport->rport &&
2388 starget->id == fcport->rport->scsi_target_id) {
2389 port_name = wwn_to_u64(fcport->port_name);
2394 fc_starget_port_name(starget) = port_name;
2398 qla2x00_get_starget_port_id(struct scsi_target *starget)
2400 struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
2401 scsi_qla_host_t *vha = shost_priv(host);
2403 uint32_t port_id = ~0U;
2405 list_for_each_entry(fcport, &vha->vp_fcports, list) {
2406 if (fcport->rport &&
2407 starget->id == fcport->rport->scsi_target_id) {
2408 port_id = fcport->d_id.b.domain << 16 |
2409 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
2414 fc_starget_port_id(starget) = port_id;
2418 qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
2421 rport->dev_loss_tmo = timeout;
2423 rport->dev_loss_tmo = 1;
2427 qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
2429 struct Scsi_Host *host = rport_to_shost(rport);
2430 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
2431 unsigned long flags;
2436 /* Now that the rport has been deleted, set the fcport state to
2438 qla2x00_set_fcport_state(fcport, FCS_DEVICE_DEAD);
2441 * Transport has effectively 'deleted' the rport, clear
2442 * all local references.
2444 spin_lock_irqsave(host->host_lock, flags);
2445 fcport->rport = fcport->drport = NULL;
2446 *((fc_port_t **)rport->dd_data) = NULL;
2447 spin_unlock_irqrestore(host->host_lock, flags);
2449 if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
2452 if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
2453 qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
2459 qla2x00_terminate_rport_io(struct fc_rport *rport)
2461 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
2466 if (test_bit(UNLOADING, &fcport->vha->dpc_flags))
2469 if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
2472 if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
2473 qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
2477 * At this point all fcport's software-states are cleared. Perform any
2478 * final cleanup of firmware resources (PCBs and XCBs).
2480 if (fcport->loop_id != FC_NO_LOOP_ID) {
2481 if (IS_FWI2_CAPABLE(fcport->vha->hw))
2482 fcport->vha->hw->isp_ops->fabric_logout(fcport->vha,
2483 fcport->loop_id, fcport->d_id.b.domain,
2484 fcport->d_id.b.area, fcport->d_id.b.al_pa);
2486 qla2x00_port_logout(fcport->vha, fcport);
2491 qla2x00_issue_lip(struct Scsi_Host *shost)
2493 scsi_qla_host_t *vha = shost_priv(shost);
2495 if (IS_QLAFX00(vha->hw))
2498 qla2x00_loop_reset(vha);
2502 static struct fc_host_statistics *
2503 qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
2505 scsi_qla_host_t *vha = shost_priv(shost);
2506 struct qla_hw_data *ha = vha->hw;
2507 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
2509 struct link_statistics *stats;
2510 dma_addr_t stats_dma;
2511 struct fc_host_statistics *p = &vha->fc_host_stat;
2513 memset(p, -1, sizeof(*p));
2515 if (IS_QLAFX00(vha->hw))
2518 if (test_bit(UNLOADING, &vha->dpc_flags))
2521 if (unlikely(pci_channel_offline(ha->pdev)))
2524 if (qla2x00_chip_is_down(vha))
2527 stats = dma_alloc_coherent(&ha->pdev->dev, sizeof(*stats), &stats_dma,
2530 ql_log(ql_log_warn, vha, 0x707d,
2531 "Failed to allocate memory for stats.\n");
2535 rval = QLA_FUNCTION_FAILED;
2536 if (IS_FWI2_CAPABLE(ha)) {
2537 rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, 0);
2538 } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
2540 /* Must be in a 'READY' state for statistics retrieval. */
2541 rval = qla2x00_get_link_status(base_vha, base_vha->loop_id,
2545 if (rval != QLA_SUCCESS)
2548 p->link_failure_count = stats->link_fail_cnt;
2549 p->loss_of_sync_count = stats->loss_sync_cnt;
2550 p->loss_of_signal_count = stats->loss_sig_cnt;
2551 p->prim_seq_protocol_err_count = stats->prim_seq_err_cnt;
2552 p->invalid_tx_word_count = stats->inval_xmit_word_cnt;
2553 p->invalid_crc_count = stats->inval_crc_cnt;
2554 if (IS_FWI2_CAPABLE(ha)) {
2555 p->lip_count = stats->lip_cnt;
2556 p->tx_frames = stats->tx_frames;
2557 p->rx_frames = stats->rx_frames;
2558 p->dumped_frames = stats->discarded_frames;
2559 p->nos_count = stats->nos_rcvd;
2561 stats->dropped_frames + stats->discarded_frames;
2562 p->rx_words = vha->qla_stats.input_bytes;
2563 p->tx_words = vha->qla_stats.output_bytes;
2565 p->fcp_control_requests = vha->qla_stats.control_requests;
2566 p->fcp_input_requests = vha->qla_stats.input_requests;
2567 p->fcp_output_requests = vha->qla_stats.output_requests;
2568 p->fcp_input_megabytes = vha->qla_stats.input_bytes >> 20;
2569 p->fcp_output_megabytes = vha->qla_stats.output_bytes >> 20;
2570 p->seconds_since_last_reset =
2571 get_jiffies_64() - vha->qla_stats.jiffies_at_last_reset;
2572 do_div(p->seconds_since_last_reset, HZ);
2575 dma_free_coherent(&ha->pdev->dev, sizeof(struct link_statistics),
2582 qla2x00_reset_host_stats(struct Scsi_Host *shost)
2584 scsi_qla_host_t *vha = shost_priv(shost);
2585 struct qla_hw_data *ha = vha->hw;
2586 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
2587 struct link_statistics *stats;
2588 dma_addr_t stats_dma;
2590 memset(&vha->qla_stats, 0, sizeof(vha->qla_stats));
2591 memset(&vha->fc_host_stat, 0, sizeof(vha->fc_host_stat));
2593 vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
2595 if (IS_FWI2_CAPABLE(ha)) {
2596 stats = dma_alloc_coherent(&ha->pdev->dev,
2597 sizeof(*stats), &stats_dma, GFP_KERNEL);
2599 ql_log(ql_log_warn, vha, 0x70d7,
2600 "Failed to allocate memory for stats.\n");
2604 /* reset firmware statistics */
2605 qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
2607 dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
2613 qla2x00_get_host_symbolic_name(struct Scsi_Host *shost)
2615 scsi_qla_host_t *vha = shost_priv(shost);
2617 qla2x00_get_sym_node_name(vha, fc_host_symbolic_name(shost),
2618 sizeof(fc_host_symbolic_name(shost)));
2622 qla2x00_set_host_system_hostname(struct Scsi_Host *shost)
2624 scsi_qla_host_t *vha = shost_priv(shost);
2626 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
2630 qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
2632 scsi_qla_host_t *vha = shost_priv(shost);
2633 uint8_t node_name[WWN_SIZE] = { 0xFF, 0xFF, 0xFF, 0xFF, \
2634 0xFF, 0xFF, 0xFF, 0xFF};
2635 u64 fabric_name = wwn_to_u64(node_name);
2637 if (vha->device_flags & SWITCH_FOUND)
2638 fabric_name = wwn_to_u64(vha->fabric_node_name);
2640 fc_host_fabric_name(shost) = fabric_name;
2644 qla2x00_get_host_port_state(struct Scsi_Host *shost)
2646 scsi_qla_host_t *vha = shost_priv(shost);
2647 struct scsi_qla_host *base_vha = pci_get_drvdata(vha->hw->pdev);
2649 if (!base_vha->flags.online) {
2650 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
2654 switch (atomic_read(&base_vha->loop_state)) {
2656 fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS;
2659 if (test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags))
2660 fc_host_port_state(shost) = FC_PORTSTATE_DIAGNOSTICS;
2662 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
2665 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
2668 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
2671 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
2677 qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
2681 scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
2682 scsi_qla_host_t *vha = NULL;
2683 struct qla_hw_data *ha = base_vha->hw;
2685 struct req_que *req = ha->req_q_map[0];
2686 struct qla_qpair *qpair;
2688 ret = qla24xx_vport_create_req_sanity_check(fc_vport);
2690 ql_log(ql_log_warn, vha, 0x707e,
2691 "Vport sanity check failed, status %x\n", ret);
2695 vha = qla24xx_create_vhost(fc_vport);
2697 ql_log(ql_log_warn, vha, 0x707f, "Vport create host failed.\n");
2698 return FC_VPORT_FAILED;
2701 atomic_set(&vha->vp_state, VP_OFFLINE);
2702 fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
2704 atomic_set(&vha->vp_state, VP_FAILED);
2706 /* ready to create vport */
2707 ql_log(ql_log_info, vha, 0x7080,
2708 "VP entry id %d assigned.\n", vha->vp_idx);
2710 /* initialized vport states */
2711 atomic_set(&vha->loop_state, LOOP_DOWN);
2712 vha->vp_err_state= VP_ERR_PORTDWN;
2713 vha->vp_prev_err_state= VP_ERR_UNKWN;
2714 /* Check if physical ha port is Up */
2715 if (atomic_read(&base_vha->loop_state) == LOOP_DOWN ||
2716 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
2717 /* Don't retry or attempt login of this virtual port */
2718 ql_dbg(ql_dbg_user, vha, 0x7081,
2719 "Vport loop state is not UP.\n");
2720 atomic_set(&vha->loop_state, LOOP_DEAD);
2722 fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN);
2725 if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) {
2726 if (ha->fw_attributes & BIT_4) {
2727 int prot = 0, guard;
2728 vha->flags.difdix_supported = 1;
2729 ql_dbg(ql_dbg_user, vha, 0x7082,
2730 "Registered for DIF/DIX type 1 and 3 protection.\n");
2731 if (ql2xenabledif == 1)
2732 prot = SHOST_DIX_TYPE0_PROTECTION;
2733 scsi_host_set_prot(vha->host,
2734 prot | SHOST_DIF_TYPE1_PROTECTION
2735 | SHOST_DIF_TYPE2_PROTECTION
2736 | SHOST_DIF_TYPE3_PROTECTION
2737 | SHOST_DIX_TYPE1_PROTECTION
2738 | SHOST_DIX_TYPE2_PROTECTION
2739 | SHOST_DIX_TYPE3_PROTECTION);
2741 guard = SHOST_DIX_GUARD_CRC;
2743 if (IS_PI_IPGUARD_CAPABLE(ha) &&
2744 (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha)))
2745 guard |= SHOST_DIX_GUARD_IP;
2747 scsi_host_set_guard(vha->host, guard);
2749 vha->flags.difdix_supported = 0;
2752 if (scsi_add_host_with_dma(vha->host, &fc_vport->dev,
2754 ql_dbg(ql_dbg_user, vha, 0x7083,
2755 "scsi_add_host failure for VP[%d].\n", vha->vp_idx);
2756 goto vport_create_failed_2;
2759 /* initialize attributes */
2760 fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count;
2761 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
2762 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
2763 fc_host_supported_classes(vha->host) =
2764 fc_host_supported_classes(base_vha->host);
2765 fc_host_supported_speeds(vha->host) =
2766 fc_host_supported_speeds(base_vha->host);
2768 qlt_vport_create(vha, ha);
2769 qla24xx_vport_disable(fc_vport, disable);
2771 if (!ql2xmqsupport || !ha->npiv_info)
2774 /* Create a request queue in QoS mode for the vport */
2775 for (cnt = 0; cnt < ha->nvram_npiv_size; cnt++) {
2776 if (memcmp(ha->npiv_info[cnt].port_name, vha->port_name, 8) == 0
2777 && memcmp(ha->npiv_info[cnt].node_name, vha->node_name,
2779 qos = ha->npiv_info[cnt].q_qos;
2785 qpair = qla2xxx_create_qpair(vha, qos, vha->vp_idx, true);
2787 ql_log(ql_log_warn, vha, 0x7084,
2788 "Can't create qpair for VP[%d]\n",
2791 ql_dbg(ql_dbg_multiq, vha, 0xc001,
2792 "Queue pair: %d Qos: %d) created for VP[%d]\n",
2793 qpair->id, qos, vha->vp_idx);
2794 ql_dbg(ql_dbg_user, vha, 0x7085,
2795 "Queue Pair: %d Qos: %d) created for VP[%d]\n",
2796 qpair->id, qos, vha->vp_idx);
2806 vport_create_failed_2:
2807 qla24xx_disable_vp(vha);
2808 qla24xx_deallocate_vp_id(vha);
2809 scsi_host_put(vha->host);
2810 return FC_VPORT_FAILED;
2814 qla24xx_vport_delete(struct fc_vport *fc_vport)
2816 scsi_qla_host_t *vha = fc_vport->dd_data;
2817 struct qla_hw_data *ha = vha->hw;
2818 uint16_t id = vha->vp_idx;
2820 while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
2821 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
2824 qla_nvme_delete(vha);
2826 qla24xx_disable_vp(vha);
2827 qla2x00_wait_for_sess_deletion(vha);
2829 vha->flags.delete_progress = 1;
2831 qlt_remove_target(ha, vha);
2833 fc_remove_host(vha->host);
2835 scsi_remove_host(vha->host);
2837 /* Allow timer to run to drain queued items, when removing vp */
2838 qla24xx_deallocate_vp_id(vha);
2840 if (vha->timer_active) {
2841 qla2x00_vp_stop_timer(vha);
2842 ql_dbg(ql_dbg_user, vha, 0x7086,
2843 "Timer for the VP[%d] has stopped\n", vha->vp_idx);
2846 qla2x00_free_fcports(vha);
2848 mutex_lock(&ha->vport_lock);
2849 ha->cur_vport_count--;
2850 clear_bit(vha->vp_idx, ha->vp_idx_map);
2851 mutex_unlock(&ha->vport_lock);
2853 dma_free_coherent(&ha->pdev->dev, vha->gnl.size, vha->gnl.l,
2858 if (vha->qpair && vha->qpair->vp_idx == vha->vp_idx) {
2859 if (qla2xxx_delete_qpair(vha, vha->qpair) != QLA_SUCCESS)
2860 ql_log(ql_log_warn, vha, 0x7087,
2861 "Queue Pair delete failed.\n");
2864 ql_log(ql_log_info, vha, 0x7088, "VP[%d] deleted.\n", id);
2865 scsi_host_put(vha->host);
2870 qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
2872 scsi_qla_host_t *vha = fc_vport->dd_data;
2875 qla24xx_disable_vp(vha);
2877 qla24xx_enable_vp(vha);
2882 struct fc_function_template qla2xxx_transport_functions = {
2884 .show_host_node_name = 1,
2885 .show_host_port_name = 1,
2886 .show_host_supported_classes = 1,
2887 .show_host_supported_speeds = 1,
2889 .get_host_port_id = qla2x00_get_host_port_id,
2890 .show_host_port_id = 1,
2891 .get_host_speed = qla2x00_get_host_speed,
2892 .show_host_speed = 1,
2893 .get_host_port_type = qla2x00_get_host_port_type,
2894 .show_host_port_type = 1,
2895 .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
2896 .show_host_symbolic_name = 1,
2897 .set_host_system_hostname = qla2x00_set_host_system_hostname,
2898 .show_host_system_hostname = 1,
2899 .get_host_fabric_name = qla2x00_get_host_fabric_name,
2900 .show_host_fabric_name = 1,
2901 .get_host_port_state = qla2x00_get_host_port_state,
2902 .show_host_port_state = 1,
2904 .dd_fcrport_size = sizeof(struct fc_port *),
2905 .show_rport_supported_classes = 1,
2907 .get_starget_node_name = qla2x00_get_starget_node_name,
2908 .show_starget_node_name = 1,
2909 .get_starget_port_name = qla2x00_get_starget_port_name,
2910 .show_starget_port_name = 1,
2911 .get_starget_port_id = qla2x00_get_starget_port_id,
2912 .show_starget_port_id = 1,
2914 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
2915 .show_rport_dev_loss_tmo = 1,
2917 .issue_fc_host_lip = qla2x00_issue_lip,
2918 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
2919 .terminate_rport_io = qla2x00_terminate_rport_io,
2920 .get_fc_host_stats = qla2x00_get_fc_host_stats,
2921 .reset_fc_host_stats = qla2x00_reset_host_stats,
2923 .vport_create = qla24xx_vport_create,
2924 .vport_disable = qla24xx_vport_disable,
2925 .vport_delete = qla24xx_vport_delete,
2926 .bsg_request = qla24xx_bsg_request,
2927 .bsg_timeout = qla24xx_bsg_timeout,
2930 struct fc_function_template qla2xxx_transport_vport_functions = {
2932 .show_host_node_name = 1,
2933 .show_host_port_name = 1,
2934 .show_host_supported_classes = 1,
2936 .get_host_port_id = qla2x00_get_host_port_id,
2937 .show_host_port_id = 1,
2938 .get_host_speed = qla2x00_get_host_speed,
2939 .show_host_speed = 1,
2940 .get_host_port_type = qla2x00_get_host_port_type,
2941 .show_host_port_type = 1,
2942 .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
2943 .show_host_symbolic_name = 1,
2944 .set_host_system_hostname = qla2x00_set_host_system_hostname,
2945 .show_host_system_hostname = 1,
2946 .get_host_fabric_name = qla2x00_get_host_fabric_name,
2947 .show_host_fabric_name = 1,
2948 .get_host_port_state = qla2x00_get_host_port_state,
2949 .show_host_port_state = 1,
2951 .dd_fcrport_size = sizeof(struct fc_port *),
2952 .show_rport_supported_classes = 1,
2954 .get_starget_node_name = qla2x00_get_starget_node_name,
2955 .show_starget_node_name = 1,
2956 .get_starget_port_name = qla2x00_get_starget_port_name,
2957 .show_starget_port_name = 1,
2958 .get_starget_port_id = qla2x00_get_starget_port_id,
2959 .show_starget_port_id = 1,
2961 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
2962 .show_rport_dev_loss_tmo = 1,
2964 .issue_fc_host_lip = qla2x00_issue_lip,
2965 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
2966 .terminate_rport_io = qla2x00_terminate_rport_io,
2967 .get_fc_host_stats = qla2x00_get_fc_host_stats,
2968 .reset_fc_host_stats = qla2x00_reset_host_stats,
2970 .bsg_request = qla24xx_bsg_request,
2971 .bsg_timeout = qla24xx_bsg_timeout,
2975 qla2x00_init_host_attr(scsi_qla_host_t *vha)
2977 struct qla_hw_data *ha = vha->hw;
2978 u32 speed = FC_PORTSPEED_UNKNOWN;
2980 fc_host_dev_loss_tmo(vha->host) = ha->port_down_retry_count;
2981 fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
2982 fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
2983 fc_host_supported_classes(vha->host) = ha->base_qpair->enable_class_2 ?
2984 (FC_COS_CLASS2|FC_COS_CLASS3) : FC_COS_CLASS3;
2985 fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports;
2986 fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count;
2988 if (IS_CNA_CAPABLE(ha))
2989 speed = FC_PORTSPEED_10GBIT;
2990 else if (IS_QLA2031(ha))
2991 speed = FC_PORTSPEED_16GBIT | FC_PORTSPEED_8GBIT |
2993 else if (IS_QLA25XX(ha))
2994 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
2995 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
2996 else if (IS_QLA24XX_TYPE(ha))
2997 speed = FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT |
2999 else if (IS_QLA23XX(ha))
3000 speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
3001 else if (IS_QLAFX00(ha))
3002 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
3003 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
3004 else if (IS_QLA27XX(ha))
3005 speed = FC_PORTSPEED_32GBIT | FC_PORTSPEED_16GBIT |
3008 speed = FC_PORTSPEED_1GBIT;
3009 fc_host_supported_speeds(vha->host) = speed;