aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-10-28 19:44:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-28 19:44:18 -0400
commitec7ae517537ae5c7b0b2cd7f562dfa3e7a05b954 (patch)
treee6b0c64a51a7c0aa0efd09d4f7a80872e3b1657a /drivers/scsi/lpfc
parent97d2eb13a019ec09cc1a7ea2d3705c0b117b3c0d (diff)
parent590134fa78fbdbe5fea78c7ae0b2c3364bc9572f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (204 commits) [SCSI] qla4xxx: export address/port of connection (fix udev disk names) [SCSI] ipr: Fix BUG on adapter dump timeout [SCSI] megaraid_sas: Fix instance access in megasas_reset_timer [SCSI] hpsa: change confusing message to be more clear [SCSI] iscsi class: fix vlan configuration [SCSI] qla4xxx: fix data alignment and use nl helpers [SCSI] iscsi class: fix link local mispelling [SCSI] iscsi class: Replace iscsi_get_next_target_id with IDA [SCSI] aacraid: use lower snprintf() limit [SCSI] lpfc 8.3.27: Change driver version to 8.3.27 [SCSI] lpfc 8.3.27: T10 additions for SLI4 [SCSI] lpfc 8.3.27: Fix queue allocation failure recovery [SCSI] lpfc 8.3.27: Change algorithm for getting physical port name [SCSI] lpfc 8.3.27: Changed worst case mailbox timeout [SCSI] lpfc 8.3.27: Miscellanous logic and interface fixes [SCSI] megaraid_sas: Changelog and version update [SCSI] megaraid_sas: Add driver workaround for PERC5/1068 kdump kernel panic [SCSI] megaraid_sas: Add multiple MSI-X vector/multiple reply queue support [SCSI] megaraid_sas: Add support for MegaRAID 9360/9380 12GB/s controllers [SCSI] megaraid_sas: Clear FUSION_IN_RESET before enabling interrupts ...
Diffstat (limited to 'drivers/scsi/lpfc')
-rw-r--r--drivers/scsi/lpfc/lpfc.h20
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c79
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h4
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c181
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c33
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c7
-rw-r--r--drivers/scsi/lpfc/lpfc_hw4.h300
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c287
-rw-r--r--drivers/scsi/lpfc/lpfc_logmsg.h1
-rw-r--r--drivers/scsi/lpfc/lpfc_mbox.c80
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c244
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c460
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.h18
-rw-r--r--drivers/scsi/lpfc/lpfc_sli4.h23
-rw-r--r--drivers/scsi/lpfc/lpfc_version.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_vport.c16
17 files changed, 1412 insertions, 346 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index c088a36d1f3..bb4c8e0584e 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -846,8 +846,24 @@ struct lpfc_hba {
846 struct dentry *debug_hbqinfo; 846 struct dentry *debug_hbqinfo;
847 struct dentry *debug_dumpHostSlim; 847 struct dentry *debug_dumpHostSlim;
848 struct dentry *debug_dumpHBASlim; 848 struct dentry *debug_dumpHBASlim;
849 struct dentry *debug_dumpData; /* BlockGuard BPL*/ 849 struct dentry *debug_dumpData; /* BlockGuard BPL */
850 struct dentry *debug_dumpDif; /* BlockGuard BPL*/ 850 struct dentry *debug_dumpDif; /* BlockGuard BPL */
851 struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
852 struct dentry *debug_writeGuard; /* inject write guard_tag errors */
853 struct dentry *debug_writeApp; /* inject write app_tag errors */
854 struct dentry *debug_writeRef; /* inject write ref_tag errors */
855 struct dentry *debug_readApp; /* inject read app_tag errors */
856 struct dentry *debug_readRef; /* inject read ref_tag errors */
857
858 /* T10 DIF error injection */
859 uint32_t lpfc_injerr_wgrd_cnt;
860 uint32_t lpfc_injerr_wapp_cnt;
861 uint32_t lpfc_injerr_wref_cnt;
862 uint32_t lpfc_injerr_rapp_cnt;
863 uint32_t lpfc_injerr_rref_cnt;
864 sector_t lpfc_injerr_lba;
865#define LPFC_INJERR_LBA_OFF (sector_t)0xffffffffffffffff
866
851 struct dentry *debug_slow_ring_trc; 867 struct dentry *debug_slow_ring_trc;
852 struct lpfc_debugfs_trc *slow_ring_trc; 868 struct lpfc_debugfs_trc *slow_ring_trc;
853 atomic_t slow_ring_trc_cnt; 869 atomic_t slow_ring_trc_cnt;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 2542f1f8bf8..4b0333ee2d9 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -52,6 +52,13 @@
52#define LPFC_MIN_DEVLOSS_TMO 1 52#define LPFC_MIN_DEVLOSS_TMO 1
53#define LPFC_MAX_DEVLOSS_TMO 255 53#define LPFC_MAX_DEVLOSS_TMO 255
54 54
55/*
56 * Write key size should be multiple of 4. If write key is changed
57 * make sure that library write key is also changed.
58 */
59#define LPFC_REG_WRITE_KEY_SIZE 4
60#define LPFC_REG_WRITE_KEY "EMLX"
61
55/** 62/**
56 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules 63 * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules
57 * @incr: integer to convert. 64 * @incr: integer to convert.
@@ -693,7 +700,7 @@ lpfc_selective_reset(struct lpfc_hba *phba)
693 int rc; 700 int rc;
694 701
695 if (!phba->cfg_enable_hba_reset) 702 if (!phba->cfg_enable_hba_reset)
696 return -EIO; 703 return -EACCES;
697 704
698 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 705 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
699 706
@@ -742,9 +749,11 @@ lpfc_issue_reset(struct device *dev, struct device_attribute *attr,
742 struct Scsi_Host *shost = class_to_shost(dev); 749 struct Scsi_Host *shost = class_to_shost(dev);
743 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 750 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
744 struct lpfc_hba *phba = vport->phba; 751 struct lpfc_hba *phba = vport->phba;
745
746 int status = -EINVAL; 752 int status = -EINVAL;
747 753
754 if (!phba->cfg_enable_hba_reset)
755 return -EACCES;
756
748 if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) 757 if (strncmp(buf, "selective", sizeof("selective") - 1) == 0)
749 status = phba->lpfc_selective_reset(phba); 758 status = phba->lpfc_selective_reset(phba);
750 759
@@ -765,16 +774,21 @@ lpfc_issue_reset(struct device *dev, struct device_attribute *attr,
765 * Returns: 774 * Returns:
766 * zero for success 775 * zero for success
767 **/ 776 **/
768static int 777int
769lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) 778lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba)
770{ 779{
771 struct lpfc_register portstat_reg; 780 struct lpfc_register portstat_reg = {0};
772 int i; 781 int i;
773 782
774 783 msleep(100);
775 lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, 784 lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
776 &portstat_reg.word0); 785 &portstat_reg.word0);
777 786
787 /* verify if privilaged for the request operation */
788 if (!bf_get(lpfc_sliport_status_rn, &portstat_reg) &&
789 !bf_get(lpfc_sliport_status_err, &portstat_reg))
790 return -EPERM;
791
778 /* wait for the SLI port firmware ready after firmware reset */ 792 /* wait for the SLI port firmware ready after firmware reset */
779 for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { 793 for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) {
780 msleep(10); 794 msleep(10);
@@ -816,16 +830,13 @@ lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
816 int rc; 830 int rc;
817 831
818 if (!phba->cfg_enable_hba_reset) 832 if (!phba->cfg_enable_hba_reset)
819 return -EIO; 833 return -EACCES;
820 834
821 if ((phba->sli_rev < LPFC_SLI_REV4) || 835 if ((phba->sli_rev < LPFC_SLI_REV4) ||
822 (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != 836 (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
823 LPFC_SLI_INTF_IF_TYPE_2)) 837 LPFC_SLI_INTF_IF_TYPE_2))
824 return -EPERM; 838 return -EPERM;
825 839
826 if (!pdev->is_physfn)
827 return -EPERM;
828
829 /* Disable SR-IOV virtual functions if enabled */ 840 /* Disable SR-IOV virtual functions if enabled */
830 if (phba->cfg_sriov_nr_virtfn) { 841 if (phba->cfg_sriov_nr_virtfn) {
831 pci_disable_sriov(pdev); 842 pci_disable_sriov(pdev);
@@ -858,7 +869,7 @@ lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode)
858 rc = lpfc_sli4_pdev_status_reg_wait(phba); 869 rc = lpfc_sli4_pdev_status_reg_wait(phba);
859 870
860 if (rc) 871 if (rc)
861 return -EIO; 872 return rc;
862 873
863 init_completion(&online_compl); 874 init_completion(&online_compl);
864 rc = lpfc_workq_post_event(phba, &status, &online_compl, 875 rc = lpfc_workq_post_event(phba, &status, &online_compl,
@@ -984,7 +995,7 @@ lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
984 if (!status) 995 if (!status)
985 return strlen(buf); 996 return strlen(buf);
986 else 997 else
987 return -EIO; 998 return status;
988} 999}
989 1000
990/** 1001/**
@@ -3885,18 +3896,23 @@ sysfs_ctlreg_write(struct file *filp, struct kobject *kobj,
3885 if ((off + count) > FF_REG_AREA_SIZE) 3896 if ((off + count) > FF_REG_AREA_SIZE)
3886 return -ERANGE; 3897 return -ERANGE;
3887 3898
3888 if (count == 0) return 0; 3899 if (count <= LPFC_REG_WRITE_KEY_SIZE)
3900 return 0;
3889 3901
3890 if (off % 4 || count % 4 || (unsigned long)buf % 4) 3902 if (off % 4 || count % 4 || (unsigned long)buf % 4)
3891 return -EINVAL; 3903 return -EINVAL;
3892 3904
3893 if (!(vport->fc_flag & FC_OFFLINE_MODE)) { 3905 /* This is to protect HBA registers from accidental writes. */
3906 if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE))
3907 return -EINVAL;
3908
3909 if (!(vport->fc_flag & FC_OFFLINE_MODE))
3894 return -EPERM; 3910 return -EPERM;
3895 }
3896 3911
3897 spin_lock_irq(&phba->hbalock); 3912 spin_lock_irq(&phba->hbalock);
3898 for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) 3913 for (buf_off = 0; buf_off < count - LPFC_REG_WRITE_KEY_SIZE;
3899 writel(*((uint32_t *)(buf + buf_off)), 3914 buf_off += sizeof(uint32_t))
3915 writel(*((uint32_t *)(buf + buf_off + LPFC_REG_WRITE_KEY_SIZE)),
3900 phba->ctrl_regs_memmap_p + off + buf_off); 3916 phba->ctrl_regs_memmap_p + off + buf_off);
3901 3917
3902 spin_unlock_irq(&phba->hbalock); 3918 spin_unlock_irq(&phba->hbalock);
@@ -4097,8 +4113,10 @@ sysfs_mbox_read(struct file *filp, struct kobject *kobj,
4097 struct Scsi_Host *shost = class_to_shost(dev); 4113 struct Scsi_Host *shost = class_to_shost(dev);
4098 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 4114 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
4099 struct lpfc_hba *phba = vport->phba; 4115 struct lpfc_hba *phba = vport->phba;
4100 int rc; 4116 LPFC_MBOXQ_t *mboxq;
4101 MAILBOX_t *pmb; 4117 MAILBOX_t *pmb;
4118 uint32_t mbox_tmo;
4119 int rc;
4102 4120
4103 if (off > MAILBOX_CMD_SIZE) 4121 if (off > MAILBOX_CMD_SIZE)
4104 return -ERANGE; 4122 return -ERANGE;
@@ -4123,7 +4141,8 @@ sysfs_mbox_read(struct file *filp, struct kobject *kobj,
4123 if (off == 0 && 4141 if (off == 0 &&
4124 phba->sysfs_mbox.state == SMBOX_WRITING && 4142 phba->sysfs_mbox.state == SMBOX_WRITING &&
4125 phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) { 4143 phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) {
4126 pmb = &phba->sysfs_mbox.mbox->u.mb; 4144 mboxq = (LPFC_MBOXQ_t *)&phba->sysfs_mbox.mbox;
4145 pmb = &mboxq->u.mb;
4127 switch (pmb->mbxCommand) { 4146 switch (pmb->mbxCommand) {
4128 /* Offline only */ 4147 /* Offline only */
4129 case MBX_INIT_LINK: 4148 case MBX_INIT_LINK:
@@ -4233,9 +4252,8 @@ sysfs_mbox_read(struct file *filp, struct kobject *kobj,
4233 4252
4234 } else { 4253 } else {
4235 spin_unlock_irq(&phba->hbalock); 4254 spin_unlock_irq(&phba->hbalock);
4236 rc = lpfc_sli_issue_mbox_wait (phba, 4255 mbox_tmo = lpfc_mbox_tmo_val(phba, mboxq);
4237 phba->sysfs_mbox.mbox, 4256 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo);
4238 lpfc_mbox_tmo_val(phba, pmb->mbxCommand) * HZ);
4239 spin_lock_irq(&phba->hbalock); 4257 spin_lock_irq(&phba->hbalock);
4240 } 4258 }
4241 4259
@@ -4480,9 +4498,10 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost)
4480 4498
4481 spin_lock_irq(shost->host_lock); 4499 spin_lock_irq(shost->host_lock);
4482 4500
4483 if ((vport->fc_flag & FC_FABRIC) || 4501 if ((vport->port_state > LPFC_FLOGI) &&
4484 ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && 4502 ((vport->fc_flag & FC_FABRIC) ||
4485 (vport->fc_flag & FC_PUBLIC_LOOP))) 4503 ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) &&
4504 (vport->fc_flag & FC_PUBLIC_LOOP))))
4486 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); 4505 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
4487 else 4506 else
4488 /* fabric is local port if there is no F/FL_Port */ 4507 /* fabric is local port if there is no F/FL_Port */
@@ -4555,9 +4574,17 @@ lpfc_get_stats(struct Scsi_Host *shost)
4555 memset(hs, 0, sizeof (struct fc_host_statistics)); 4574 memset(hs, 0, sizeof (struct fc_host_statistics));
4556 4575
4557 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; 4576 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
4558 hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256); 4577 /*
4578 * The MBX_READ_STATUS returns tx_k_bytes which has to
4579 * converted to words
4580 */
4581 hs->tx_words = (uint64_t)
4582 ((uint64_t)pmb->un.varRdStatus.xmitByteCnt
4583 * (uint64_t)256);
4559 hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; 4584 hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
4560 hs->rx_words = (pmb->un.varRdStatus.rcvByteCnt * 256); 4585 hs->rx_words = (uint64_t)
4586 ((uint64_t)pmb->un.varRdStatus.rcvByteCnt
4587 * (uint64_t)256);
4561 4588
4562 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); 4589 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
4563 pmb->mbxCommand = MBX_READ_LNK_STAT; 4590 pmb->mbxCommand = MBX_READ_LNK_STAT;
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index a6db6aef133..60f95347bab 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -209,7 +209,7 @@ void __lpfc_mbox_cmpl_put(struct lpfc_hba *, LPFC_MBOXQ_t *);
209void lpfc_mbox_cmpl_put(struct lpfc_hba *, LPFC_MBOXQ_t *); 209void lpfc_mbox_cmpl_put(struct lpfc_hba *, LPFC_MBOXQ_t *);
210int lpfc_mbox_cmd_check(struct lpfc_hba *, LPFC_MBOXQ_t *); 210int lpfc_mbox_cmd_check(struct lpfc_hba *, LPFC_MBOXQ_t *);
211int lpfc_mbox_dev_check(struct lpfc_hba *); 211int lpfc_mbox_dev_check(struct lpfc_hba *);
212int lpfc_mbox_tmo_val(struct lpfc_hba *, int); 212int lpfc_mbox_tmo_val(struct lpfc_hba *, LPFC_MBOXQ_t *);
213void lpfc_init_vfi(struct lpfcMboxq *, struct lpfc_vport *); 213void lpfc_init_vfi(struct lpfcMboxq *, struct lpfc_vport *);
214void lpfc_reg_vfi(struct lpfcMboxq *, struct lpfc_vport *, dma_addr_t); 214void lpfc_reg_vfi(struct lpfcMboxq *, struct lpfc_vport *, dma_addr_t);
215void lpfc_init_vpi(struct lpfc_hba *, struct lpfcMboxq *, uint16_t); 215void lpfc_init_vpi(struct lpfc_hba *, struct lpfcMboxq *, uint16_t);
@@ -451,3 +451,5 @@ int lpfc_wr_object(struct lpfc_hba *, struct list_head *, uint32_t, uint32_t *);
451/* functions to support SR-IOV */ 451/* functions to support SR-IOV */
452int lpfc_sli_probe_sriov_nr_virtfn(struct lpfc_hba *, int); 452int lpfc_sli_probe_sriov_nr_virtfn(struct lpfc_hba *, int);
453uint16_t lpfc_sli_sriov_nr_virtfn_get(struct lpfc_hba *); 453uint16_t lpfc_sli_sriov_nr_virtfn_get(struct lpfc_hba *);
454int lpfc_sli4_queue_create(struct lpfc_hba *);
455void lpfc_sli4_queue_destroy(struct lpfc_hba *);
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 779b88e1469..707081d0a22 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1856,6 +1856,9 @@ lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag)
1856 case 2: 1856 case 2:
1857 c = 'B'; 1857 c = 'B';
1858 break; 1858 break;
1859 case 3:
1860 c = 'X';
1861 break;
1859 default: 1862 default:
1860 c = 0; 1863 c = 0;
1861 break; 1864 break;
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index a0424dd90e4..2cd844f7058 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -996,6 +996,85 @@ lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf,
996 return nbytes; 996 return nbytes;
997} 997}
998 998
999static int
1000lpfc_debugfs_dif_err_open(struct inode *inode, struct file *file)
1001{
1002 file->private_data = inode->i_private;
1003 return 0;
1004}
1005
1006static ssize_t
1007lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
1008 size_t nbytes, loff_t *ppos)
1009{
1010 struct dentry *dent = file->f_dentry;
1011 struct lpfc_hba *phba = file->private_data;
1012 char cbuf[16];
1013 int cnt = 0;
1014
1015 if (dent == phba->debug_writeGuard)
1016 cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wgrd_cnt);
1017 else if (dent == phba->debug_writeApp)
1018 cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wapp_cnt);
1019 else if (dent == phba->debug_writeRef)
1020 cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wref_cnt);
1021 else if (dent == phba->debug_readApp)
1022 cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_rapp_cnt);
1023 else if (dent == phba->debug_readRef)
1024 cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_rref_cnt);
1025 else if (dent == phba->debug_InjErrLBA)
1026 cnt = snprintf(cbuf, 16, "0x%lx\n",
1027 (unsigned long) phba->lpfc_injerr_lba);
1028 else
1029 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1030 "0547 Unknown debugfs error injection entry\n");
1031
1032 return simple_read_from_buffer(buf, nbytes, ppos, &cbuf, cnt);
1033}
1034
1035static ssize_t
1036lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
1037 size_t nbytes, loff_t *ppos)
1038{
1039 struct dentry *dent = file->f_dentry;
1040 struct lpfc_hba *phba = file->private_data;
1041 char dstbuf[32];
1042 unsigned long tmp;
1043 int size;
1044
1045 memset(dstbuf, 0, 32);
1046 size = (nbytes < 32) ? nbytes : 32;
1047 if (copy_from_user(dstbuf, buf, size))
1048 return 0;
1049
1050 if (strict_strtoul(dstbuf, 0, &tmp))
1051 return 0;
1052
1053 if (dent == phba->debug_writeGuard)
1054 phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp;
1055 else if (dent == phba->debug_writeApp)
1056 phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp;
1057 else if (dent == phba->debug_writeRef)
1058 phba->lpfc_injerr_wref_cnt = (uint32_t)tmp;
1059 else if (dent == phba->debug_readApp)
1060 phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp;
1061 else if (dent == phba->debug_readRef)
1062 phba->lpfc_injerr_rref_cnt = (uint32_t)tmp;
1063 else if (dent == phba->debug_InjErrLBA)
1064 phba->lpfc_injerr_lba = (sector_t)tmp;
1065 else
1066 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1067 "0548 Unknown debugfs error injection entry\n");
1068
1069 return nbytes;
1070}
1071
1072static int
1073lpfc_debugfs_dif_err_release(struct inode *inode, struct file *file)
1074{
1075 return 0;
1076}
1077
999/** 1078/**
1000 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file 1079 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
1001 * @inode: The inode pointer that contains a vport pointer. 1080 * @inode: The inode pointer that contains a vport pointer.
@@ -3380,6 +3459,16 @@ static const struct file_operations lpfc_debugfs_op_dumpDif = {
3380 .release = lpfc_debugfs_dumpDataDif_release, 3459 .release = lpfc_debugfs_dumpDataDif_release,
3381}; 3460};
3382 3461
3462#undef lpfc_debugfs_op_dif_err
3463static const struct file_operations lpfc_debugfs_op_dif_err = {
3464 .owner = THIS_MODULE,
3465 .open = lpfc_debugfs_dif_err_open,
3466 .llseek = lpfc_debugfs_lseek,
3467 .read = lpfc_debugfs_dif_err_read,
3468 .write = lpfc_debugfs_dif_err_write,
3469 .release = lpfc_debugfs_dif_err_release,
3470};
3471
3383#undef lpfc_debugfs_op_slow_ring_trc 3472#undef lpfc_debugfs_op_slow_ring_trc
3384static const struct file_operations lpfc_debugfs_op_slow_ring_trc = { 3473static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
3385 .owner = THIS_MODULE, 3474 .owner = THIS_MODULE,
@@ -3788,6 +3877,74 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
3788 goto debug_failed; 3877 goto debug_failed;
3789 } 3878 }
3790 3879
3880 /* Setup DIF Error Injections */
3881 snprintf(name, sizeof(name), "InjErrLBA");
3882 phba->debug_InjErrLBA =
3883 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
3884 phba->hba_debugfs_root,
3885 phba, &lpfc_debugfs_op_dif_err);
3886 if (!phba->debug_InjErrLBA) {
3887 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3888 "0807 Cannot create debugfs InjErrLBA\n");
3889 goto debug_failed;
3890 }
3891 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
3892
3893 snprintf(name, sizeof(name), "writeGuardInjErr");
3894 phba->debug_writeGuard =
3895 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
3896 phba->hba_debugfs_root,
3897 phba, &lpfc_debugfs_op_dif_err);
3898 if (!phba->debug_writeGuard) {
3899 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3900 "0802 Cannot create debugfs writeGuard\n");
3901 goto debug_failed;
3902 }
3903
3904 snprintf(name, sizeof(name), "writeAppInjErr");
3905 phba->debug_writeApp =
3906 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
3907 phba->hba_debugfs_root,
3908 phba, &lpfc_debugfs_op_dif_err);
3909 if (!phba->debug_writeApp) {
3910 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3911 "0803 Cannot create debugfs writeApp\n");
3912 goto debug_failed;
3913 }
3914
3915 snprintf(name, sizeof(name), "writeRefInjErr");
3916 phba->debug_writeRef =
3917 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
3918 phba->hba_debugfs_root,
3919 phba, &lpfc_debugfs_op_dif_err);
3920 if (!phba->debug_writeRef) {
3921 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3922 "0804 Cannot create debugfs writeRef\n");
3923 goto debug_failed;
3924 }
3925
3926 snprintf(name, sizeof(name), "readAppInjErr");
3927 phba->debug_readApp =
3928 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
3929 phba->hba_debugfs_root,
3930 phba, &lpfc_debugfs_op_dif_err);
3931 if (!phba->debug_readApp) {
3932 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3933 "0805 Cannot create debugfs readApp\n");
3934 goto debug_failed;
3935 }
3936
3937 snprintf(name, sizeof(name), "readRefInjErr");
3938 phba->debug_readRef =
3939 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
3940 phba->hba_debugfs_root,
3941 phba, &lpfc_debugfs_op_dif_err);
3942 if (!phba->debug_readRef) {
3943 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3944 "0806 Cannot create debugfs readApp\n");
3945 goto debug_failed;
3946 }
3947
3791 /* Setup slow ring trace */ 3948 /* Setup slow ring trace */
3792 if (lpfc_debugfs_max_slow_ring_trc) { 3949 if (lpfc_debugfs_max_slow_ring_trc) {
3793 num = lpfc_debugfs_max_slow_ring_trc - 1; 3950 num = lpfc_debugfs_max_slow_ring_trc - 1;
@@ -4090,6 +4247,30 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
4090 debugfs_remove(phba->debug_dumpDif); /* dumpDif */ 4247 debugfs_remove(phba->debug_dumpDif); /* dumpDif */
4091 phba->debug_dumpDif = NULL; 4248 phba->debug_dumpDif = NULL;
4092 } 4249 }
4250 if (phba->debug_InjErrLBA) {
4251 debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */
4252 phba->debug_InjErrLBA = NULL;
4253 }
4254 if (phba->debug_writeGuard) {
4255 debugfs_remove(phba->debug_writeGuard); /* writeGuard */
4256 phba->debug_writeGuard = NULL;
4257 }
4258 if (phba->debug_writeApp) {
4259 debugfs_remove(phba->debug_writeApp); /* writeApp */
4260 phba->debug_writeApp = NULL;
4261 }
4262 if (phba->debug_writeRef) {
4263 debugfs_remove(phba->debug_writeRef); /* writeRef */
4264 phba->debug_writeRef = NULL;
4265 }
4266 if (phba->debug_readApp) {
4267 debugfs_remove(phba->debug_readApp); /* readApp */
4268 phba->debug_readApp = NULL;
4269 }
4270 if (phba->debug_readRef) {
4271 debugfs_remove(phba->debug_readRef); /* readRef */
4272 phba->debug_readRef = NULL;
4273 }
4093 4274
4094 if (phba->slow_ring_trc) { 4275 if (phba->slow_ring_trc) {
4095 kfree(phba->slow_ring_trc); 4276 kfree(phba->slow_ring_trc);
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 023da0e00d3..445826a4c98 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -3386,7 +3386,14 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3386 cmdiocb->context1 = NULL; 3386 cmdiocb->context1 = NULL;
3387 } 3387 }
3388 } 3388 }
3389
3390 /*
3391 * The driver received a LOGO from the rport and has ACK'd it.
3392 * At this point, the driver is done so release the IOCB and
3393 * remove the ndlp reference.
3394 */
3389 lpfc_els_free_iocb(phba, cmdiocb); 3395 lpfc_els_free_iocb(phba, cmdiocb);
3396 lpfc_nlp_put(ndlp);
3390 return; 3397 return;
3391} 3398}
3392 3399
@@ -4082,9 +4089,6 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format,
4082 4089
4083 phba->fc_stat.elsXmitACC++; 4090 phba->fc_stat.elsXmitACC++;
4084 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 4091 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
4085 lpfc_nlp_put(ndlp);
4086 elsiocb->context1 = NULL; /* Don't need ndlp for cmpl,
4087 * it could be freed */
4088 4092
4089 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); 4093 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
4090 if (rc == IOCB_ERROR) { 4094 if (rc == IOCB_ERROR) {
@@ -4166,6 +4170,11 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data,
4166 psli = &phba->sli; 4170 psli = &phba->sli;
4167 cmdsize = oldiocb->iocb.unsli3.rcvsli3.acc_len; 4171 cmdsize = oldiocb->iocb.unsli3.rcvsli3.acc_len;
4168 4172
4173 /* The accumulated length can exceed the BPL_SIZE. For
4174 * now, use this as the limit
4175 */
4176 if (cmdsize > LPFC_BPL_SIZE)
4177 cmdsize = LPFC_BPL_SIZE;
4169 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, 4178 elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp,
4170 ndlp->nlp_DID, ELS_CMD_ACC); 4179 ndlp->nlp_DID, ELS_CMD_ACC);
4171 if (!elsiocb) 4180 if (!elsiocb)
@@ -4189,9 +4198,6 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data,
4189 4198
4190 phba->fc_stat.elsXmitACC++; 4199 phba->fc_stat.elsXmitACC++;
4191 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 4200 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
4192 lpfc_nlp_put(ndlp);
4193 elsiocb->context1 = NULL; /* Don't need ndlp for cmpl,
4194 * it could be freed */
4195 4201
4196 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); 4202 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
4197 if (rc == IOCB_ERROR) { 4203 if (rc == IOCB_ERROR) {
@@ -7258,16 +7264,11 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
7258 icmd->un.elsreq64.myID = 0; 7264 icmd->un.elsreq64.myID = 0;
7259 icmd->un.elsreq64.fl = 1; 7265 icmd->un.elsreq64.fl = 1;
7260 7266
7261 if ((phba->sli_rev == LPFC_SLI_REV4) && 7267 /*
7262 (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == 7268 * SLI3 ports require a different context type value than SLI4.
7263 LPFC_SLI_INTF_IF_TYPE_0)) { 7269 * Catch SLI3 ports here and override the prep.
7264 /* FDISC needs to be 1 for WQE VPI */ 7270 */
7265 elsiocb->iocb.ulpCt_h = (SLI4_CT_VPI >> 1) & 1; 7271 if (phba->sli_rev == LPFC_SLI_REV3) {
7266 elsiocb->iocb.ulpCt_l = SLI4_CT_VPI & 1 ;
7267 /* Set the ulpContext to the vpi */
7268 elsiocb->iocb.ulpContext = phba->vpi_ids[vport->vpi];
7269 } else {
7270 /* For FDISC, Let FDISC rsp set the NPortID for this VPI */
7271 icmd->ulpCt_h = 1; 7272 icmd->ulpCt_h = 1;
7272 icmd->ulpCt_l = 0; 7273 icmd->ulpCt_l = 0;
7273 } 7274 }
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 0b47adf9fee..091f68e5cb7 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1412,7 +1412,7 @@ lpfc_register_fcf(struct lpfc_hba *phba)
1412 if (phba->pport->port_state != LPFC_FLOGI) { 1412 if (phba->pport->port_state != LPFC_FLOGI) {
1413 phba->hba_flag |= FCF_RR_INPROG; 1413 phba->hba_flag |= FCF_RR_INPROG;
1414 spin_unlock_irq(&phba->hbalock); 1414 spin_unlock_irq(&phba->hbalock);
1415 lpfc_issue_init_vfi(phba->pport); 1415 lpfc_initial_flogi(phba->pport);
1416 return; 1416 return;
1417 } 1417 }
1418 spin_unlock_irq(&phba->hbalock); 1418 spin_unlock_irq(&phba->hbalock);
@@ -2646,7 +2646,9 @@ lpfc_init_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2646{ 2646{
2647 struct lpfc_vport *vport = mboxq->vport; 2647 struct lpfc_vport *vport = mboxq->vport;
2648 2648
2649 if (mboxq->u.mb.mbxStatus && (mboxq->u.mb.mbxStatus != 0x4002)) { 2649 /* VFI not supported on interface type 0, just do the flogi */
2650 if (mboxq->u.mb.mbxStatus && (bf_get(lpfc_sli_intf_if_type,
2651 &phba->sli4_hba.sli_intf) != LPFC_SLI_INTF_IF_TYPE_0)) {
2650 lpfc_printf_vlog(vport, KERN_ERR, 2652 lpfc_printf_vlog(vport, KERN_ERR,
2651 LOG_MBOX, 2653 LOG_MBOX,
2652 "2891 Init VFI mailbox failed 0x%x\n", 2654 "2891 Init VFI mailbox failed 0x%x\n",
@@ -2655,6 +2657,7 @@ lpfc_init_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
2655 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 2657 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
2656 return; 2658 return;
2657 } 2659 }
2660
2658 lpfc_initial_flogi(vport); 2661 lpfc_initial_flogi(vport);
2659 mempool_free(mboxq, phba->mbox_mem_pool); 2662 mempool_free(mboxq, phba->mbox_mem_pool);
2660 return; 2663 return;
diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index 7f8003b5181..98d21521f53 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -41,6 +41,8 @@
41 * Or clear that bit field: 41 * Or clear that bit field:
42 * bf_set(example_bit_field, &t1, 0); 42 * bf_set(example_bit_field, &t1, 0);
43 */ 43 */
44#define bf_get_be32(name, ptr) \
45 ((be32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
44#define bf_get_le32(name, ptr) \ 46#define bf_get_le32(name, ptr) \
45 ((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK) 47 ((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
46#define bf_get(name, ptr) \ 48#define bf_get(name, ptr) \
@@ -678,7 +680,6 @@ struct lpfc_register {
678#define lpfc_rq_doorbell_num_posted_SHIFT 16 680#define lpfc_rq_doorbell_num_posted_SHIFT 16
679#define lpfc_rq_doorbell_num_posted_MASK 0x3FFF 681#define lpfc_rq_doorbell_num_posted_MASK 0x3FFF
680#define lpfc_rq_doorbell_num_posted_WORD word0 682#define lpfc_rq_doorbell_num_posted_WORD word0
681#define LPFC_RQ_POST_BATCH 8 /* RQEs to post at one time */
682#define lpfc_rq_doorbell_id_SHIFT 0 683#define lpfc_rq_doorbell_id_SHIFT 0
683#define lpfc_rq_doorbell_id_MASK 0xFFFF 684#define lpfc_rq_doorbell_id_MASK 0xFFFF
684#define lpfc_rq_doorbell_id_WORD word0 685#define lpfc_rq_doorbell_id_WORD word0
@@ -784,6 +785,8 @@ union lpfc_sli4_cfg_shdr {
784#define LPFC_Q_CREATE_VERSION_2 2 785#define LPFC_Q_CREATE_VERSION_2 2
785#define LPFC_Q_CREATE_VERSION_1 1 786#define LPFC_Q_CREATE_VERSION_1 1
786#define LPFC_Q_CREATE_VERSION_0 0 787#define LPFC_Q_CREATE_VERSION_0 0
788#define LPFC_OPCODE_VERSION_0 0
789#define LPFC_OPCODE_VERSION_1 1
787 } request; 790 } request;
788 struct { 791 struct {
789 uint32_t word6; 792 uint32_t word6;
@@ -825,6 +828,7 @@ struct mbox_header {
825#define LPFC_EXTENT_VERSION_DEFAULT 0 828#define LPFC_EXTENT_VERSION_DEFAULT 0
826 829
827/* Subsystem Definitions */ 830/* Subsystem Definitions */
831#define LPFC_MBOX_SUBSYSTEM_NA 0x0
828#define LPFC_MBOX_SUBSYSTEM_COMMON 0x1 832#define LPFC_MBOX_SUBSYSTEM_COMMON 0x1
829#define LPFC_MBOX_SUBSYSTEM_FCOE 0xC 833#define LPFC_MBOX_SUBSYSTEM_FCOE 0xC
830 834
@@ -835,25 +839,34 @@ struct mbox_header {
835#define HOST_ENDIAN_HIGH_WORD1 0xFF7856FF 839#define HOST_ENDIAN_HIGH_WORD1 0xFF7856FF
836 840
837/* Common Opcodes */ 841/* Common Opcodes */
838#define LPFC_MBOX_OPCODE_CQ_CREATE 0x0C 842#define LPFC_MBOX_OPCODE_NA 0x00
839#define LPFC_MBOX_OPCODE_EQ_CREATE 0x0D 843#define LPFC_MBOX_OPCODE_CQ_CREATE 0x0C
840#define LPFC_MBOX_OPCODE_MQ_CREATE 0x15 844#define LPFC_MBOX_OPCODE_EQ_CREATE 0x0D
841#define LPFC_MBOX_OPCODE_GET_CNTL_ATTRIBUTES 0x20 845#define LPFC_MBOX_OPCODE_MQ_CREATE 0x15
842#define LPFC_MBOX_OPCODE_NOP 0x21 846#define LPFC_MBOX_OPCODE_GET_CNTL_ATTRIBUTES 0x20
843#define LPFC_MBOX_OPCODE_MQ_DESTROY 0x35 847#define LPFC_MBOX_OPCODE_NOP 0x21
844#define LPFC_MBOX_OPCODE_CQ_DESTROY 0x36 848#define LPFC_MBOX_OPCODE_MQ_DESTROY 0x35
845#define LPFC_MBOX_OPCODE_EQ_DESTROY 0x37 849#define LPFC_MBOX_OPCODE_CQ_DESTROY 0x36
846#define LPFC_MBOX_OPCODE_QUERY_FW_CFG 0x3A 850#define LPFC_MBOX_OPCODE_EQ_DESTROY 0x37
847#define LPFC_MBOX_OPCODE_FUNCTION_RESET 0x3D 851#define LPFC_MBOX_OPCODE_QUERY_FW_CFG 0x3A
848#define LPFC_MBOX_OPCODE_MQ_CREATE_EXT 0x5A 852#define LPFC_MBOX_OPCODE_FUNCTION_RESET 0x3D
849#define LPFC_MBOX_OPCODE_GET_RSRC_EXTENT_INFO 0x9A 853#define LPFC_MBOX_OPCODE_GET_PORT_NAME 0x4D
850#define LPFC_MBOX_OPCODE_GET_ALLOC_RSRC_EXTENT 0x9B 854#define LPFC_MBOX_OPCODE_MQ_CREATE_EXT 0x5A
851#define LPFC_MBOX_OPCODE_ALLOC_RSRC_EXTENT 0x9C 855#define LPFC_MBOX_OPCODE_GET_RSRC_EXTENT_INFO 0x9A
852#define LPFC_MBOX_OPCODE_DEALLOC_RSRC_EXTENT 0x9D 856#define LPFC_MBOX_OPCODE_GET_ALLOC_RSRC_EXTENT 0x9B
853#define LPFC_MBOX_OPCODE_GET_FUNCTION_CONFIG 0xA0 857#define LPFC_MBOX_OPCODE_ALLOC_RSRC_EXTENT 0x9C
854#define LPFC_MBOX_OPCODE_GET_PROFILE_CONFIG 0xA4 858#define LPFC_MBOX_OPCODE_DEALLOC_RSRC_EXTENT 0x9D
855#define LPFC_MBOX_OPCODE_WRITE_OBJECT 0xAC 859#define LPFC_MBOX_OPCODE_GET_FUNCTION_CONFIG 0xA0
856#define LPFC_MBOX_OPCODE_GET_SLI4_PARAMETERS 0xB5 860#define LPFC_MBOX_OPCODE_GET_PROFILE_CONFIG 0xA4
861#define LPFC_MBOX_OPCODE_SET_PROFILE_CONFIG 0xA5
862#define LPFC_MBOX_OPCODE_GET_PROFILE_LIST 0xA6
863#define LPFC_MBOX_OPCODE_SET_ACT_PROFILE 0xA8
864#define LPFC_MBOX_OPCODE_GET_FACTORY_PROFILE_CONFIG 0xA9
865#define LPFC_MBOX_OPCODE_READ_OBJECT 0xAB
866#define LPFC_MBOX_OPCODE_WRITE_OBJECT 0xAC
867#define LPFC_MBOX_OPCODE_READ_OBJECT_LIST 0xAD
868#define LPFC_MBOX_OPCODE_DELETE_OBJECT 0xAE
869#define LPFC_MBOX_OPCODE_GET_SLI4_PARAMETERS 0xB5
857 870
858/* FCoE Opcodes */ 871/* FCoE Opcodes */
859#define LPFC_MBOX_OPCODE_FCOE_WQ_CREATE 0x01 872#define LPFC_MBOX_OPCODE_FCOE_WQ_CREATE 0x01
@@ -867,6 +880,7 @@ struct mbox_header {
867#define LPFC_MBOX_OPCODE_FCOE_DELETE_FCF 0x0A 880#define LPFC_MBOX_OPCODE_FCOE_DELETE_FCF 0x0A
868#define LPFC_MBOX_OPCODE_FCOE_POST_HDR_TEMPLATE 0x0B 881#define LPFC_MBOX_OPCODE_FCOE_POST_HDR_TEMPLATE 0x0B
869#define LPFC_MBOX_OPCODE_FCOE_REDISCOVER_FCF 0x10 882#define LPFC_MBOX_OPCODE_FCOE_REDISCOVER_FCF 0x10
883#define LPFC_MBOX_OPCODE_FCOE_SET_FCLINK_SETTINGS 0x21
870#define LPFC_MBOX_OPCODE_FCOE_LINK_DIAG_STATE 0x22 884#define LPFC_MBOX_OPCODE_FCOE_LINK_DIAG_STATE 0x22
871#define LPFC_MBOX_OPCODE_FCOE_LINK_DIAG_LOOPBACK 0x23 885#define LPFC_MBOX_OPCODE_FCOE_LINK_DIAG_LOOPBACK 0x23
872 886
@@ -1470,16 +1484,81 @@ struct sli4_sge { /* SLI-4 */
1470 uint32_t addr_lo; 1484 uint32_t addr_lo;
1471 1485
1472 uint32_t word2; 1486 uint32_t word2;
1473#define lpfc_sli4_sge_offset_SHIFT 0 /* Offset of buffer - Not used*/ 1487#define lpfc_sli4_sge_offset_SHIFT 0
1474#define lpfc_sli4_sge_offset_MASK 0x1FFFFFFF 1488#define lpfc_sli4_sge_offset_MASK 0x07FFFFFF
1475#define lpfc_sli4_sge_offset_WORD word2 1489#define lpfc_sli4_sge_offset_WORD word2
1476#define lpfc_sli4_sge_last_SHIFT 31 /* Last SEG in the SGL sets 1490#define lpfc_sli4_sge_type_SHIFT 27
1477 this flag !! */ 1491#define lpfc_sli4_sge_type_MASK 0x0000000F
1492#define lpfc_sli4_sge_type_WORD word2
1493#define LPFC_SGE_TYPE_DATA 0x0
1494#define LPFC_SGE_TYPE_DIF 0x4
1495#define LPFC_SGE_TYPE_LSP 0x5
1496#define LPFC_SGE_TYPE_PEDIF 0x6
1497#define LPFC_SGE_TYPE_PESEED 0x7
1498#define LPFC_SGE_TYPE_DISEED 0x8
1499#define LPFC_SGE_TYPE_ENC 0x9
1500#define LPFC_SGE_TYPE_ATM 0xA
1501#define LPFC_SGE_TYPE_SKIP 0xC
1502#define lpfc_sli4_sge_last_SHIFT 31 /* Last SEG in the SGL sets it */
1478#define lpfc_sli4_sge_last_MASK 0x00000001 1503#define lpfc_sli4_sge_last_MASK 0x00000001
1479#define lpfc_sli4_sge_last_WORD word2 1504#define lpfc_sli4_sge_last_WORD word2
1480 uint32_t sge_len; 1505 uint32_t sge_len;
1481}; 1506};
1482 1507
1508struct sli4_sge_diseed { /* SLI-4 */
1509 uint32_t ref_tag;
1510 uint32_t ref_tag_tran;
1511
1512 uint32_t word2;
1513#define lpfc_sli4_sge_dif_apptran_SHIFT 0
1514#define lpfc_sli4_sge_dif_apptran_MASK 0x0000FFFF
1515#define lpfc_sli4_sge_dif_apptran_WORD word2
1516#define lpfc_sli4_sge_dif_af_SHIFT 24
1517#define lpfc_sli4_sge_dif_af_MASK 0x00000001
1518#define lpfc_sli4_sge_dif_af_WORD word2
1519#define lpfc_sli4_sge_dif_na_SHIFT 25
1520#define lpfc_sli4_sge_dif_na_MASK 0x00000001
1521#define lpfc_sli4_sge_dif_na_WORD word2
1522#define lpfc_sli4_sge_dif_hi_SHIFT 26
1523#define lpfc_sli4_sge_dif_hi_MASK 0x00000001
1524#define lpfc_sli4_sge_dif_hi_WORD word2
1525#define lpfc_sli4_sge_dif_type_SHIFT 27
1526#define lpfc_sli4_sge_dif_type_MASK 0x0000000F
1527#define lpfc_sli4_sge_dif_type_WORD word2
1528#define lpfc_sli4_sge_dif_last_SHIFT 31 /* Last SEG in the SGL sets it */
1529#define lpfc_sli4_sge_dif_last_MASK 0x00000001
1530#define lpfc_sli4_sge_dif_last_WORD word2
1531 uint32_t word3;
1532#define lpfc_sli4_sge_dif_apptag_SHIFT 0
1533#define lpfc_sli4_sge_dif_apptag_MASK 0x0000FFFF
1534#define lpfc_sli4_sge_dif_apptag_WORD word3
1535#define lpfc_sli4_sge_dif_bs_SHIFT 16
1536#define lpfc_sli4_sge_dif_bs_MASK 0x00000007
1537#define lpfc_sli4_sge_dif_bs_WORD word3
1538#define lpfc_sli4_sge_dif_ai_SHIFT 19
1539#define lpfc_sli4_sge_dif_ai_MASK 0x00000001
1540#define lpfc_sli4_sge_dif_ai_WORD word3
1541#define lpfc_sli4_sge_dif_me_SHIFT 20
1542#define lpfc_sli4_sge_dif_me_MASK 0x00000001
1543#define lpfc_sli4_sge_dif_me_WORD word3
1544#define lpfc_sli4_sge_dif_re_SHIFT 21
1545#define lpfc_sli4_sge_dif_re_MASK 0x00000001
1546#define lpfc_sli4_sge_dif_re_WORD word3
1547#define lpfc_sli4_sge_dif_ce_SHIFT 22
1548#define lpfc_sli4_sge_dif_ce_MASK 0x00000001
1549#define lpfc_sli4_sge_dif_ce_WORD word3
1550#define lpfc_sli4_sge_dif_nr_SHIFT 23
1551#define lpfc_sli4_sge_dif_nr_MASK 0x00000001
1552#define lpfc_sli4_sge_dif_nr_WORD word3
1553#define lpfc_sli4_sge_dif_oprx_SHIFT 24
1554#define lpfc_sli4_sge_dif_oprx_MASK 0x0000000F
1555#define lpfc_sli4_sge_dif_oprx_WORD word3
1556#define lpfc_sli4_sge_dif_optx_SHIFT 28
1557#define lpfc_sli4_sge_dif_optx_MASK 0x0000000F
1558#define lpfc_sli4_sge_dif_optx_WORD word3
1559/* optx and oprx use BG_OP_IN defines in lpfc_hw.h */
1560};
1561
1483struct fcf_record { 1562struct fcf_record {
1484 uint32_t max_rcv_size; 1563 uint32_t max_rcv_size;
1485 uint32_t fka_adv_period; 1564 uint32_t fka_adv_period;
@@ -2019,6 +2098,15 @@ struct lpfc_mbx_read_config {
2019#define lpfc_mbx_rd_conf_extnts_inuse_MASK 0x00000001 2098#define lpfc_mbx_rd_conf_extnts_inuse_MASK 0x00000001
2020#define lpfc_mbx_rd_conf_extnts_inuse_WORD word1 2099#define lpfc_mbx_rd_conf_extnts_inuse_WORD word1
2021 uint32_t word2; 2100 uint32_t word2;
2101#define lpfc_mbx_rd_conf_lnk_numb_SHIFT 0
2102#define lpfc_mbx_rd_conf_lnk_numb_MASK 0x0000003F
2103#define lpfc_mbx_rd_conf_lnk_numb_WORD word2
2104#define lpfc_mbx_rd_conf_lnk_type_SHIFT 6
2105#define lpfc_mbx_rd_conf_lnk_type_MASK 0x00000003
2106#define lpfc_mbx_rd_conf_lnk_type_WORD word2
2107#define lpfc_mbx_rd_conf_lnk_ldv_SHIFT 8
2108#define lpfc_mbx_rd_conf_lnk_ldv_MASK 0x00000001
2109#define lpfc_mbx_rd_conf_lnk_ldv_WORD word2
2022#define lpfc_mbx_rd_conf_topology_SHIFT 24 2110#define lpfc_mbx_rd_conf_topology_SHIFT 24
2023#define lpfc_mbx_rd_conf_topology_MASK 0x000000FF 2111#define lpfc_mbx_rd_conf_topology_MASK 0x000000FF
2024#define lpfc_mbx_rd_conf_topology_WORD word2 2112#define lpfc_mbx_rd_conf_topology_WORD word2
@@ -2552,8 +2640,152 @@ struct lpfc_mbx_get_prof_cfg {
2552 } u; 2640 } u;
2553}; 2641};
2554 2642
2643struct lpfc_controller_attribute {
2644 uint32_t version_string[8];
2645 uint32_t manufacturer_name[8];
2646 uint32_t supported_modes;
2647 uint32_t word17;
2648#define lpfc_cntl_attr_eprom_ver_lo_SHIFT 0
2649#define lpfc_cntl_attr_eprom_ver_lo_MASK 0x000000ff
2650#define lpfc_cntl_attr_eprom_ver_lo_WORD word17
2651#define lpfc_cntl_attr_eprom_ver_hi_SHIFT 8
2652#define lpfc_cntl_attr_eprom_ver_hi_MASK 0x000000ff
2653#define lpfc_cntl_attr_eprom_ver_hi_WORD word17
2654 uint32_t mbx_da_struct_ver;
2655 uint32_t ep_fw_da_struct_ver;
2656 uint32_t ncsi_ver_str[3];
2657 uint32_t dflt_ext_timeout;
2658 uint32_t model_number[8];
2659 uint32_t description[16];
2660 uint32_t serial_number[8];
2661 uint32_t ip_ver_str[8];
2662 uint32_t fw_ver_str[8];
2663 uint32_t bios_ver_str[8];
2664 uint32_t redboot_ver_str[8];
2665 uint32_t driver_ver_str[8];
2666 uint32_t flash_fw_ver_str[8];
2667 uint32_t functionality;
2668 uint32_t word105;
2669#define lpfc_cntl_attr_max_cbd_len_SHIFT 0
2670#define lpfc_cntl_attr_max_cbd_len_MASK 0x0000ffff
2671#define lpfc_cntl_attr_max_cbd_len_WORD word105
2672#define lpfc_cntl_attr_asic_rev_SHIFT 16
2673#define lpfc_cntl_attr_asic_rev_MASK 0x000000ff
2674#define lpfc_cntl_attr_asic_rev_WORD word105
2675#define lpfc_cntl_attr_gen_guid0_SHIFT 24
2676#define lpfc_cntl_attr_gen_guid0_MASK 0x000000ff
2677#define lpfc_cntl_attr_gen_guid0_WORD word105
2678 uint32_t gen_guid1_12[3];
2679 uint32_t word109;
2680#define lpfc_cntl_attr_gen_guid13_14_SHIFT 0
2681#define lpfc_cntl_attr_gen_guid13_14_MASK 0x0000ffff
2682#define lpfc_cntl_attr_gen_guid13_14_WORD word109
2683#define lpfc_cntl_attr_gen_guid15_SHIFT 16
2684#define lpfc_cntl_attr_gen_guid15_MASK 0x000000ff
2685#define lpfc_cntl_attr_gen_guid15_WORD word109
2686#define lpfc_cntl_attr_hba_port_cnt_SHIFT 24
2687#define lpfc_cntl_attr_hba_port_cnt_MASK 0x000000ff
2688#define lpfc_cntl_attr_hba_port_cnt_WORD word109
2689 uint32_t word110;
2690#define lpfc_cntl_attr_dflt_lnk_tmo_SHIFT 0
2691#define lpfc_cntl_attr_dflt_lnk_tmo_MASK 0x0000ffff
2692#define lpfc_cntl_attr_dflt_lnk_tmo_WORD word110
2693#define lpfc_cntl_attr_multi_func_dev_SHIFT 24
2694#define lpfc_cntl_attr_multi_func_dev_MASK 0x000000ff
2695#define lpfc_cntl_attr_multi_func_dev_WORD word110
2696 uint32_t word111;
2697#define lpfc_cntl_attr_cache_valid_SHIFT 0
2698#define lpfc_cntl_attr_cache_valid_MASK 0x000000ff
2699#define lpfc_cntl_attr_cache_valid_WORD word111
2700#define lpfc_cntl_attr_hba_status_SHIFT 8
2701#define lpfc_cntl_attr_hba_status_MASK 0x000000ff
2702#define lpfc_cntl_attr_hba_status_WORD word111
2703#define lpfc_cntl_attr_max_domain_SHIFT 16
2704#define lpfc_cntl_attr_max_domain_MASK 0x000000ff
2705#define lpfc_cntl_attr_max_domain_WORD word111
2706#define lpfc_cntl_attr_lnk_numb_SHIFT 24
2707#define lpfc_cntl_attr_lnk_numb_MASK 0x0000003f
2708#define lpfc_cntl_attr_lnk_numb_WORD word111
2709#define lpfc_cntl_attr_lnk_type_SHIFT 30
2710#define lpfc_cntl_attr_lnk_type_MASK 0x00000003
2711#define lpfc_cntl_attr_lnk_type_WORD word111
2712 uint32_t fw_post_status;
2713 uint32_t hba_mtu[8];
2714 uint32_t word121;
2715 uint32_t reserved1[3];
2716 uint32_t word125;
2717#define lpfc_cntl_attr_pci_vendor_id_SHIFT 0
2718#define lpfc_cntl_attr_pci_vendor_id_MASK 0x0000ffff
2719#define lpfc_cntl_attr_pci_vendor_id_WORD word125
2720#define lpfc_cntl_attr_pci_device_id_SHIFT 16
2721#define lpfc_cntl_attr_pci_device_id_MASK 0x0000ffff
2722#define lpfc_cntl_attr_pci_device_id_WORD word125
2723 uint32_t word126;
2724#define lpfc_cntl_attr_pci_subvdr_id_SHIFT 0
2725#define lpfc_cntl_attr_pci_subvdr_id_MASK 0x0000ffff
2726#define lpfc_cntl_attr_pci_subvdr_id_WORD word126
2727#define lpfc_cntl_attr_pci_subsys_id_SHIFT 16
2728#define lpfc_cntl_attr_pci_subsys_id_MASK 0x0000ffff
2729#define lpfc_cntl_attr_pci_subsys_id_WORD word126
2730 uint32_t word127;
2731#define lpfc_cntl_attr_pci_bus_num_SHIFT 0
2732#define lpfc_cntl_attr_pci_bus_num_MASK 0x000000ff
2733#define lpfc_cntl_attr_pci_bus_num_WORD word127
2734#define lpfc_cntl_attr_pci_dev_num_SHIFT 8
2735#define lpfc_cntl_attr_pci_dev_num_MASK 0x000000ff
2736#define lpfc_cntl_attr_pci_dev_num_WORD word127
2737#define lpfc_cntl_attr_pci_fnc_num_SHIFT 16
2738#define lpfc_cntl_attr_pci_fnc_num_MASK 0x000000ff
2739#define lpfc_cntl_attr_pci_fnc_num_WORD word127
2740#define lpfc_cntl_attr_inf_type_SHIFT 24
2741#define lpfc_cntl_attr_inf_type_MASK 0x000000ff
2742#define lpfc_cntl_attr_inf_type_WORD word127
2743 uint32_t unique_id[2];
2744 uint32_t word130;
2745#define lpfc_cntl_attr_num_netfil_SHIFT 0
2746#define lpfc_cntl_attr_num_netfil_MASK 0x000000ff
2747#define lpfc_cntl_attr_num_netfil_WORD word130
2748 uint32_t reserved2[4];
2749};
2750
2751struct lpfc_mbx_get_cntl_attributes {
2752 union lpfc_sli4_cfg_shdr cfg_shdr;
2753 struct lpfc_controller_attribute cntl_attr;
2754};
2755
2756struct lpfc_mbx_get_port_name {
2757 struct mbox_header header;
2758 union {
2759 struct {
2760 uint32_t word4;
2761#define lpfc_mbx_get_port_name_lnk_type_SHIFT 0
2762#define lpfc_mbx_get_port_name_lnk_type_MASK 0x00000003
2763#define lpfc_mbx_get_port_name_lnk_type_WORD word4
2764 } request;
2765 struct {
2766 uint32_t word4;
2767#define lpfc_mbx_get_port_name_name0_SHIFT 0
2768#define lpfc_mbx_get_port_name_name0_MASK 0x000000FF
2769#define lpfc_mbx_get_port_name_name0_WORD word4
2770#define lpfc_mbx_get_port_name_name1_SHIFT 8
2771#define lpfc_mbx_get_port_name_name1_MASK 0x000000FF
2772#define lpfc_mbx_get_port_name_name1_WORD word4
2773#define lpfc_mbx_get_port_name_name2_SHIFT 16
2774#define lpfc_mbx_get_port_name_name2_MASK 0x000000FF
2775#define lpfc_mbx_get_port_name_name2_WORD word4
2776#define lpfc_mbx_get_port_name_name3_SHIFT 24
2777#define lpfc_mbx_get_port_name_name3_MASK 0x000000FF
2778#define lpfc_mbx_get_port_name_name3_WORD word4
2779#define LPFC_LINK_NUMBER_0 0
2780#define LPFC_LINK_NUMBER_1 1
2781#define LPFC_LINK_NUMBER_2 2
2782#define LPFC_LINK_NUMBER_3 3
2783 } response;
2784 } u;
2785};
2786
2555/* Mailbox Completion Queue Error Messages */ 2787/* Mailbox Completion Queue Error Messages */
2556#define MB_CQE_STATUS_SUCCESS 0x0 2788#define MB_CQE_STATUS_SUCCESS 0x0
2557#define MB_CQE_STATUS_INSUFFICIENT_PRIVILEGES 0x1 2789#define MB_CQE_STATUS_INSUFFICIENT_PRIVILEGES 0x1
2558#define MB_CQE_STATUS_INVALID_PARAMETER 0x2 2790#define MB_CQE_STATUS_INVALID_PARAMETER 0x2
2559#define MB_CQE_STATUS_INSUFFICIENT_RESOURCES 0x3 2791#define MB_CQE_STATUS_INSUFFICIENT_RESOURCES 0x3
@@ -2637,8 +2869,9 @@ struct lpfc_mqe {
2637 struct lpfc_mbx_run_link_diag_test link_diag_test; 2869 struct lpfc_mbx_run_link_diag_test link_diag_test;
2638 struct lpfc_mbx_get_func_cfg get_func_cfg; 2870 struct lpfc_mbx_get_func_cfg get_func_cfg;
2639 struct lpfc_mbx_get_prof_cfg get_prof_cfg; 2871 struct lpfc_mbx_get_prof_cfg get_prof_cfg;
2640 struct lpfc_mbx_nop nop;
2641 struct lpfc_mbx_wr_object wr_object; 2872 struct lpfc_mbx_wr_object wr_object;
2873 struct lpfc_mbx_get_port_name get_port_name;
2874 struct lpfc_mbx_nop nop;
2642 } un; 2875 } un;
2643}; 2876};
2644 2877
@@ -2855,6 +3088,9 @@ struct wqe_common {
2855#define wqe_ctxt_tag_MASK 0x0000FFFF 3088#define wqe_ctxt_tag_MASK 0x0000FFFF
2856#define wqe_ctxt_tag_WORD word6 3089#define wqe_ctxt_tag_WORD word6
2857 uint32_t word7; 3090 uint32_t word7;
3091#define wqe_dif_SHIFT 0
3092#define wqe_dif_MASK 0x00000003
3093#define wqe_dif_WORD word7
2858#define wqe_ct_SHIFT 2 3094#define wqe_ct_SHIFT 2
2859#define wqe_ct_MASK 0x00000003 3095#define wqe_ct_MASK 0x00000003
2860#define wqe_ct_WORD word7 3096#define wqe_ct_WORD word7
@@ -2867,12 +3103,21 @@ struct wqe_common {
2867#define wqe_class_SHIFT 16 3103#define wqe_class_SHIFT 16
2868#define wqe_class_MASK 0x00000007 3104#define wqe_class_MASK 0x00000007
2869#define wqe_class_WORD word7 3105#define wqe_class_WORD word7
3106#define wqe_ar_SHIFT 19
3107#define wqe_ar_MASK 0x00000001
3108#define wqe_ar_WORD word7
3109#define wqe_ag_SHIFT wqe_ar_SHIFT
3110#define wqe_ag_MASK wqe_ar_MASK
3111#define wqe_ag_WORD wqe_ar_WORD
2870#define wqe_pu_SHIFT 20 3112#define wqe_pu_SHIFT 20
2871#define wqe_pu_MASK 0x00000003 3113#define wqe_pu_MASK 0x00000003
2872#define wqe_pu_WORD word7 3114#define wqe_pu_WORD word7
2873#define wqe_erp_SHIFT 22 3115#define wqe_erp_SHIFT 22
2874#define wqe_erp_MASK 0x00000001 3116#define wqe_erp_MASK 0x00000001
2875#define wqe_erp_WORD word7 3117#define wqe_erp_WORD word7
3118#define wqe_conf_SHIFT wqe_erp_SHIFT
3119#define wqe_conf_MASK wqe_erp_MASK
3120#define wqe_conf_WORD wqe_erp_WORD
2876#define wqe_lnk_SHIFT 23 3121#define wqe_lnk_SHIFT 23
2877#define wqe_lnk_MASK 0x00000001 3122#define wqe_lnk_MASK 0x00000001
2878#define wqe_lnk_WORD word7 3123#define wqe_lnk_WORD word7
@@ -2931,6 +3176,9 @@ struct wqe_common {
2931#define wqe_xc_SHIFT 21 3176#define wqe_xc_SHIFT 21
2932#define wqe_xc_MASK 0x00000001 3177#define wqe_xc_MASK 0x00000001
2933#define wqe_xc_WORD word10 3178#define wqe_xc_WORD word10
3179#define wqe_sr_SHIFT 22
3180#define wqe_sr_MASK 0x00000001
3181#define wqe_sr_WORD word10
2934#define wqe_ccpe_SHIFT 23 3182#define wqe_ccpe_SHIFT 23
2935#define wqe_ccpe_MASK 0x00000001 3183#define wqe_ccpe_MASK 0x00000001
2936#define wqe_ccpe_WORD word10 3184#define wqe_ccpe_WORD word10
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index a3c820083c3..907c94b9245 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -58,8 +58,7 @@ spinlock_t _dump_buf_lock;
58 58
59static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *); 59static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *);
60static int lpfc_post_rcv_buf(struct lpfc_hba *); 60static int lpfc_post_rcv_buf(struct lpfc_hba *);
61static int lpfc_sli4_queue_create(struct lpfc_hba *); 61static int lpfc_sli4_queue_verify(struct lpfc_hba *);
62static void lpfc_sli4_queue_destroy(struct lpfc_hba *);
63static int lpfc_create_bootstrap_mbox(struct lpfc_hba *); 62static int lpfc_create_bootstrap_mbox(struct lpfc_hba *);
64static int lpfc_setup_endian_order(struct lpfc_hba *); 63static int lpfc_setup_endian_order(struct lpfc_hba *);
65static int lpfc_sli4_read_config(struct lpfc_hba *); 64static int lpfc_sli4_read_config(struct lpfc_hba *);
@@ -1438,6 +1437,7 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba)
1438 struct Scsi_Host *shost; 1437 struct Scsi_Host *shost;
1439 uint32_t if_type; 1438 uint32_t if_type;
1440 struct lpfc_register portstat_reg; 1439 struct lpfc_register portstat_reg;
1440 int rc;
1441 1441
1442 /* If the pci channel is offline, ignore possible errors, since 1442 /* If the pci channel is offline, ignore possible errors, since
1443 * we cannot communicate with the pci card anyway. 1443 * we cannot communicate with the pci card anyway.
@@ -1480,16 +1480,24 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba)
1480 lpfc_sli4_offline_eratt(phba); 1480 lpfc_sli4_offline_eratt(phba);
1481 return; 1481 return;
1482 } 1482 }
1483 if (bf_get(lpfc_sliport_status_rn, &portstat_reg)) { 1483 /*
1484 /* 1484 * On error status condition, driver need to wait for port
1485 * TODO: Attempt port recovery via a port reset. 1485 * ready before performing reset.
1486 * When fully implemented, the driver should 1486 */
1487 * attempt to recover the port here and return. 1487 rc = lpfc_sli4_pdev_status_reg_wait(phba);
1488 * For now, log an error and take the port offline. 1488 if (!rc) {
1489 */ 1489 /* need reset: attempt for port recovery */
1490 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1490 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1491 "2887 Port Error: Attempting " 1491 "2887 Port Error: Attempting "
1492 "Port Recovery\n"); 1492 "Port Recovery\n");
1493 lpfc_offline_prep(phba);
1494 lpfc_offline(phba);
1495 lpfc_sli_brdrestart(phba);
1496 if (lpfc_online(phba) == 0) {
1497 lpfc_unblock_mgmt_io(phba);
1498 return;
1499 }
1500 /* fall through for not able to recover */
1493 } 1501 }
1494 lpfc_sli4_offline_eratt(phba); 1502 lpfc_sli4_offline_eratt(phba);
1495 break; 1503 break;
@@ -1724,11 +1732,20 @@ lpfc_parse_vpd(struct lpfc_hba *phba, uint8_t *vpd, int len)
1724 j = 0; 1732 j = 0;
1725 Length -= (3+i); 1733 Length -= (3+i);
1726 while(i--) { 1734 while(i--) {
1727 phba->Port[j++] = vpd[index++]; 1735 if ((phba->sli_rev == LPFC_SLI_REV4) &&
1728 if (j == 19) 1736 (phba->sli4_hba.pport_name_sta ==
1729 break; 1737 LPFC_SLI4_PPNAME_GET)) {
1738 j++;
1739 index++;
1740 } else
1741 phba->Port[j++] = vpd[index++];
1742 if (j == 19)
1743 break;
1730 } 1744 }
1731 phba->Port[j] = 0; 1745 if ((phba->sli_rev != LPFC_SLI_REV4) ||
1746 (phba->sli4_hba.pport_name_sta ==
1747 LPFC_SLI4_PPNAME_NON))
1748 phba->Port[j] = 0;
1732 continue; 1749 continue;
1733 } 1750 }
1734 else { 1751 else {
@@ -1958,7 +1975,7 @@ lpfc_get_hba_model_desc(struct lpfc_hba *phba, uint8_t *mdp, uint8_t *descp)
1958 case PCI_DEVICE_ID_LANCER_FCOE: 1975 case PCI_DEVICE_ID_LANCER_FCOE:
1959 case PCI_DEVICE_ID_LANCER_FCOE_VF: 1976 case PCI_DEVICE_ID_LANCER_FCOE_VF:
1960 oneConnect = 1; 1977 oneConnect = 1;
1961 m = (typeof(m)){"OCe50100", "PCIe", "FCoE"}; 1978 m = (typeof(m)){"OCe15100", "PCIe", "FCoE"};
1962 break; 1979 break;
1963 default: 1980 default:
1964 m = (typeof(m)){"Unknown", "", ""}; 1981 m = (typeof(m)){"Unknown", "", ""};
@@ -2432,17 +2449,19 @@ lpfc_block_mgmt_io(struct lpfc_hba * phba)
2432 uint8_t actcmd = MBX_HEARTBEAT; 2449 uint8_t actcmd = MBX_HEARTBEAT;
2433 unsigned long timeout; 2450 unsigned long timeout;
2434 2451
2435 2452 timeout = msecs_to_jiffies(LPFC_MBOX_TMO * 1000) + jiffies;
2436 spin_lock_irqsave(&phba->hbalock, iflag); 2453 spin_lock_irqsave(&phba->hbalock, iflag);
2437 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; 2454 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO;
2438 if (phba->sli.mbox_active) 2455 if (phba->sli.mbox_active) {
2439 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; 2456 actcmd = phba->sli.mbox_active->u.mb.mbxCommand;
2457 /* Determine how long we might wait for the active mailbox
2458 * command to be gracefully completed by firmware.
2459 */
2460 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
2461 phba->sli.mbox_active) * 1000) + jiffies;
2462 }
2440 spin_unlock_irqrestore(&phba->hbalock, iflag); 2463 spin_unlock_irqrestore(&phba->hbalock, iflag);
2441 /* Determine how long we might wait for the active mailbox 2464
2442 * command to be gracefully completed by firmware.
2443 */
2444 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, actcmd) * 1000) +
2445 jiffies;
2446 /* Wait for the outstnading mailbox command to complete */ 2465 /* Wait for the outstnading mailbox command to complete */
2447 while (phba->sli.mbox_active) { 2466 while (phba->sli.mbox_active) {
2448 /* Check active mailbox complete status every 2ms */ 2467 /* Check active mailbox complete status every 2ms */
@@ -3949,7 +3968,7 @@ static int
3949lpfc_enable_pci_dev(struct lpfc_hba *phba) 3968lpfc_enable_pci_dev(struct lpfc_hba *phba)
3950{ 3969{
3951 struct pci_dev *pdev; 3970 struct pci_dev *pdev;
3952 int bars; 3971 int bars = 0;
3953 3972
3954 /* Obtain PCI device reference */ 3973 /* Obtain PCI device reference */
3955 if (!phba->pcidev) 3974 if (!phba->pcidev)
@@ -3978,6 +3997,8 @@ lpfc_enable_pci_dev(struct lpfc_hba *phba)
3978out_disable_device: 3997out_disable_device:
3979 pci_disable_device(pdev); 3998 pci_disable_device(pdev);
3980out_error: 3999out_error:
4000 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4001 "1401 Failed to enable pci device, bars:x%x\n", bars);
3981 return -ENODEV; 4002 return -ENODEV;
3982} 4003}
3983 4004
@@ -4051,9 +4072,6 @@ lpfc_sli_sriov_nr_virtfn_get(struct lpfc_hba *phba)
4051 uint16_t nr_virtfn; 4072 uint16_t nr_virtfn;
4052 int pos; 4073 int pos;
4053 4074
4054 if (!pdev->is_physfn)
4055 return 0;
4056
4057 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV); 4075 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV);
4058 if (pos == 0) 4076 if (pos == 0)
4059 return 0; 4077 return 0;
@@ -4474,15 +4492,15 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
4474 } 4492 }
4475 } 4493 }
4476 mempool_free(mboxq, phba->mbox_mem_pool); 4494 mempool_free(mboxq, phba->mbox_mem_pool);
4477 /* Create all the SLI4 queues */ 4495 /* Verify all the SLI4 queues */
4478 rc = lpfc_sli4_queue_create(phba); 4496 rc = lpfc_sli4_queue_verify(phba);
4479 if (rc) 4497 if (rc)
4480 goto out_free_bsmbx; 4498 goto out_free_bsmbx;
4481 4499
4482 /* Create driver internal CQE event pool */ 4500 /* Create driver internal CQE event pool */
4483 rc = lpfc_sli4_cq_event_pool_create(phba); 4501 rc = lpfc_sli4_cq_event_pool_create(phba);
4484 if (rc) 4502 if (rc)
4485 goto out_destroy_queue; 4503 goto out_free_bsmbx;
4486 4504
4487 /* Initialize and populate the iocb list per host */ 4505 /* Initialize and populate the iocb list per host */
4488 rc = lpfc_init_sgl_list(phba); 4506 rc = lpfc_init_sgl_list(phba);
@@ -4516,14 +4534,21 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
4516 goto out_remove_rpi_hdrs; 4534 goto out_remove_rpi_hdrs;
4517 } 4535 }
4518 4536
4519 phba->sli4_hba.fcp_eq_hdl = kzalloc((sizeof(struct lpfc_fcp_eq_hdl) * 4537 /*
4538 * The cfg_fcp_eq_count can be zero whenever there is exactly one
4539 * interrupt vector. This is not an error
4540 */
4541 if (phba->cfg_fcp_eq_count) {
4542 phba->sli4_hba.fcp_eq_hdl =
4543 kzalloc((sizeof(struct lpfc_fcp_eq_hdl) *
4520 phba->cfg_fcp_eq_count), GFP_KERNEL); 4544 phba->cfg_fcp_eq_count), GFP_KERNEL);
4521 if (!phba->sli4_hba.fcp_eq_hdl) { 4545 if (!phba->sli4_hba.fcp_eq_hdl) {
4522 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 4546 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
4523 "2572 Failed allocate memory for fast-path " 4547 "2572 Failed allocate memory for "
4524 "per-EQ handle array\n"); 4548 "fast-path per-EQ handle array\n");
4525 rc = -ENOMEM; 4549 rc = -ENOMEM;
4526 goto out_free_fcf_rr_bmask; 4550 goto out_free_fcf_rr_bmask;
4551 }
4527 } 4552 }
4528 4553
4529 phba->sli4_hba.msix_entries = kzalloc((sizeof(struct msix_entry) * 4554 phba->sli4_hba.msix_entries = kzalloc((sizeof(struct msix_entry) *
@@ -4567,8 +4592,6 @@ out_free_sgl_list:
4567 lpfc_free_sgl_list(phba); 4592 lpfc_free_sgl_list(phba);
4568out_destroy_cq_event_pool: 4593out_destroy_cq_event_pool:
4569 lpfc_sli4_cq_event_pool_destroy(phba); 4594 lpfc_sli4_cq_event_pool_destroy(phba);
4570out_destroy_queue:
4571 lpfc_sli4_queue_destroy(phba);
4572out_free_bsmbx: 4595out_free_bsmbx:
4573 lpfc_destroy_bootstrap_mbox(phba); 4596 lpfc_destroy_bootstrap_mbox(phba);
4574out_free_mem: 4597out_free_mem:
@@ -4608,9 +4631,6 @@ lpfc_sli4_driver_resource_unset(struct lpfc_hba *phba)
4608 /* Free the SCSI sgl management array */ 4631 /* Free the SCSI sgl management array */
4609 kfree(phba->sli4_hba.lpfc_scsi_psb_array); 4632 kfree(phba->sli4_hba.lpfc_scsi_psb_array);
4610 4633
4611 /* Free the SLI4 queues */
4612 lpfc_sli4_queue_destroy(phba);
4613
4614 /* Free the completion queue EQ event pool */ 4634 /* Free the completion queue EQ event pool */
4615 lpfc_sli4_cq_event_release_all(phba); 4635 lpfc_sli4_cq_event_release_all(phba);
4616 lpfc_sli4_cq_event_pool_destroy(phba); 4636 lpfc_sli4_cq_event_pool_destroy(phba);
@@ -6139,24 +6159,21 @@ lpfc_setup_endian_order(struct lpfc_hba *phba)
6139} 6159}
6140 6160
6141/** 6161/**
6142 * lpfc_sli4_queue_create - Create all the SLI4 queues 6162 * lpfc_sli4_queue_verify - Verify and update EQ and CQ counts
6143 * @phba: pointer to lpfc hba data structure. 6163 * @phba: pointer to lpfc hba data structure.
6144 * 6164 *
6145 * This routine is invoked to allocate all the SLI4 queues for the FCoE HBA 6165 * This routine is invoked to check the user settable queue counts for EQs and
6146 * operation. For each SLI4 queue type, the parameters such as queue entry 6166 * CQs. after this routine is called the counts will be set to valid values that
6147 * count (queue depth) shall be taken from the module parameter. For now, 6167 * adhere to the constraints of the system's interrupt vectors and the port's
6148 * we just use some constant number as place holder. 6168 * queue resources.
6149 * 6169 *
6150 * Return codes 6170 * Return codes
6151 * 0 - successful 6171 * 0 - successful
6152 * -ENOMEM - No available memory 6172 * -ENOMEM - No available memory
6153 * -EIO - The mailbox failed to complete successfully.
6154 **/ 6173 **/
6155static int 6174static int
6156lpfc_sli4_queue_create(struct lpfc_hba *phba) 6175lpfc_sli4_queue_verify(struct lpfc_hba *phba)
6157{ 6176{
6158 struct lpfc_queue *qdesc;
6159 int fcp_eqidx, fcp_cqidx, fcp_wqidx;
6160 int cfg_fcp_wq_count; 6177 int cfg_fcp_wq_count;
6161 int cfg_fcp_eq_count; 6178 int cfg_fcp_eq_count;
6162 6179
@@ -6229,14 +6246,43 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
6229 /* The overall number of event queues used */ 6246 /* The overall number of event queues used */
6230 phba->sli4_hba.cfg_eqn = phba->cfg_fcp_eq_count + LPFC_SP_EQN_DEF; 6247 phba->sli4_hba.cfg_eqn = phba->cfg_fcp_eq_count + LPFC_SP_EQN_DEF;
6231 6248
6232 /*
6233 * Create Event Queues (EQs)
6234 */
6235
6236 /* Get EQ depth from module parameter, fake the default for now */ 6249 /* Get EQ depth from module parameter, fake the default for now */
6237 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; 6250 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B;
6238 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; 6251 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT;
6239 6252
6253 /* Get CQ depth from module parameter, fake the default for now */
6254 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE;
6255 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT;
6256
6257 return 0;
6258out_error:
6259 return -ENOMEM;
6260}
6261
6262/**
6263 * lpfc_sli4_queue_create - Create all the SLI4 queues
6264 * @phba: pointer to lpfc hba data structure.
6265 *
6266 * This routine is invoked to allocate all the SLI4 queues for the FCoE HBA
6267 * operation. For each SLI4 queue type, the parameters such as queue entry
6268 * count (queue depth) shall be taken from the module parameter. For now,
6269 * we just use some constant number as place holder.
6270 *
6271 * Return codes
6272 * 0 - sucessful
6273 * -ENOMEM - No availble memory
6274 * -EIO - The mailbox failed to complete successfully.
6275 **/
6276int
6277lpfc_sli4_queue_create(struct lpfc_hba *phba)
6278{
6279 struct lpfc_queue *qdesc;
6280 int fcp_eqidx, fcp_cqidx, fcp_wqidx;
6281
6282 /*
6283 * Create Event Queues (EQs)
6284 */
6285
6240 /* Create slow path event queue */ 6286 /* Create slow path event queue */
6241 qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.eq_esize, 6287 qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.eq_esize,
6242 phba->sli4_hba.eq_ecount); 6288 phba->sli4_hba.eq_ecount);
@@ -6247,14 +6293,20 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
6247 } 6293 }
6248 phba->sli4_hba.sp_eq = qdesc; 6294 phba->sli4_hba.sp_eq = qdesc;
6249 6295
6250 /* Create fast-path FCP Event Queue(s) */ 6296 /*
6251 phba->sli4_hba.fp_eq = kzalloc((sizeof(struct lpfc_queue *) * 6297 * Create fast-path FCP Event Queue(s). The cfg_fcp_eq_count can be
6252 phba->cfg_fcp_eq_count), GFP_KERNEL); 6298 * zero whenever there is exactly one interrupt vector. This is not
6253 if (!phba->sli4_hba.fp_eq) { 6299 * an error.
6254 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 6300 */
6255 "2576 Failed allocate memory for fast-path " 6301 if (phba->cfg_fcp_eq_count) {
6256 "EQ record array\n"); 6302 phba->sli4_hba.fp_eq = kzalloc((sizeof(struct lpfc_queue *) *
6257 goto out_free_sp_eq; 6303 phba->cfg_fcp_eq_count), GFP_KERNEL);
6304 if (!phba->sli4_hba.fp_eq) {
6305 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
6306 "2576 Failed allocate memory for "
6307 "fast-path EQ record array\n");
6308 goto out_free_sp_eq;
6309 }
6258 } 6310 }
6259 for (fcp_eqidx = 0; fcp_eqidx < phba->cfg_fcp_eq_count; fcp_eqidx++) { 6311 for (fcp_eqidx = 0; fcp_eqidx < phba->cfg_fcp_eq_count; fcp_eqidx++) {
6260 qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.eq_esize, 6312 qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.eq_esize,
@@ -6271,10 +6323,6 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
6271 * Create Complete Queues (CQs) 6323 * Create Complete Queues (CQs)
6272 */ 6324 */
6273 6325
6274 /* Get CQ depth from module parameter, fake the default for now */
6275 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE;
6276 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT;
6277
6278 /* Create slow-path Mailbox Command Complete Queue */ 6326 /* Create slow-path Mailbox Command Complete Queue */
6279 qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.cq_esize, 6327 qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.cq_esize,
6280 phba->sli4_hba.cq_ecount); 6328 phba->sli4_hba.cq_ecount);
@@ -6296,16 +6344,25 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
6296 phba->sli4_hba.els_cq = qdesc; 6344 phba->sli4_hba.els_cq = qdesc;
6297 6345
6298 6346
6299 /* Create fast-path FCP Completion Queue(s), one-to-one with EQs */ 6347 /*
6300 phba->sli4_hba.fcp_cq = kzalloc((sizeof(struct lpfc_queue *) * 6348 * Create fast-path FCP Completion Queue(s), one-to-one with FCP EQs.
6301 phba->cfg_fcp_eq_count), GFP_KERNEL); 6349 * If there are no FCP EQs then create exactly one FCP CQ.
6350 */
6351 if (phba->cfg_fcp_eq_count)
6352 phba->sli4_hba.fcp_cq = kzalloc((sizeof(struct lpfc_queue *) *
6353 phba->cfg_fcp_eq_count),
6354 GFP_KERNEL);
6355 else
6356 phba->sli4_hba.fcp_cq = kzalloc(sizeof(struct lpfc_queue *),
6357 GFP_KERNEL);
6302 if (!phba->sli4_hba.fcp_cq) { 6358 if (!phba->sli4_hba.fcp_cq) {
6303 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 6359 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
6304 "2577 Failed allocate memory for fast-path " 6360 "2577 Failed allocate memory for fast-path "
6305 "CQ record array\n"); 6361 "CQ record array\n");
6306 goto out_free_els_cq; 6362 goto out_free_els_cq;
6307 } 6363 }
6308 for (fcp_cqidx = 0; fcp_cqidx < phba->cfg_fcp_eq_count; fcp_cqidx++) { 6364 fcp_cqidx = 0;
6365 do {
6309 qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.cq_esize, 6366 qdesc = lpfc_sli4_queue_alloc(phba, phba->sli4_hba.cq_esize,
6310 phba->sli4_hba.cq_ecount); 6367 phba->sli4_hba.cq_ecount);
6311 if (!qdesc) { 6368 if (!qdesc) {
@@ -6315,7 +6372,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
6315 goto out_free_fcp_cq; 6372 goto out_free_fcp_cq;
6316 } 6373 }
6317 phba->sli4_hba.fcp_cq[fcp_cqidx] = qdesc; 6374 phba->sli4_hba.fcp_cq[fcp_cqidx] = qdesc;
6318 } 6375 } while (++fcp_cqidx < phba->cfg_fcp_eq_count);
6319 6376
6320 /* Create Mailbox Command Queue */ 6377 /* Create Mailbox Command Queue */
6321 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; 6378 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE;
@@ -6447,7 +6504,7 @@ out_error:
6447 * -ENOMEM - No available memory 6504 * -ENOMEM - No available memory
6448 * -EIO - The mailbox failed to complete successfully. 6505 * -EIO - The mailbox failed to complete successfully.
6449 **/ 6506 **/
6450static void 6507void
6451lpfc_sli4_queue_destroy(struct lpfc_hba *phba) 6508lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
6452{ 6509{
6453 int fcp_qidx; 6510 int fcp_qidx;
@@ -6723,6 +6780,10 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba)
6723 "0540 Receive Queue not allocated\n"); 6780 "0540 Receive Queue not allocated\n");
6724 goto out_destroy_fcp_wq; 6781 goto out_destroy_fcp_wq;
6725 } 6782 }
6783
6784 lpfc_rq_adjust_repost(phba, phba->sli4_hba.hdr_rq, LPFC_ELS_HBQ);
6785 lpfc_rq_adjust_repost(phba, phba->sli4_hba.dat_rq, LPFC_ELS_HBQ);
6786
6726 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, 6787 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq,
6727 phba->sli4_hba.els_cq, LPFC_USOL); 6788 phba->sli4_hba.els_cq, LPFC_USOL);
6728 if (rc) { 6789 if (rc) {
@@ -6731,6 +6792,7 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba)
6731 "rc = 0x%x\n", rc); 6792 "rc = 0x%x\n", rc);
6732 goto out_destroy_fcp_wq; 6793 goto out_destroy_fcp_wq;
6733 } 6794 }
6795
6734 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 6796 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
6735 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " 6797 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d "
6736 "parent cq-id=%d\n", 6798 "parent cq-id=%d\n",
@@ -6790,8 +6852,10 @@ lpfc_sli4_queue_unset(struct lpfc_hba *phba)
6790 /* Unset ELS complete queue */ 6852 /* Unset ELS complete queue */
6791 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); 6853 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq);
6792 /* Unset FCP response complete queue */ 6854 /* Unset FCP response complete queue */
6793 for (fcp_qidx = 0; fcp_qidx < phba->cfg_fcp_eq_count; fcp_qidx++) 6855 fcp_qidx = 0;
6856 do {
6794 lpfc_cq_destroy(phba, phba->sli4_hba.fcp_cq[fcp_qidx]); 6857 lpfc_cq_destroy(phba, phba->sli4_hba.fcp_cq[fcp_qidx]);
6858 } while (++fcp_qidx < phba->cfg_fcp_eq_count);
6795 /* Unset fast-path event queue */ 6859 /* Unset fast-path event queue */
6796 for (fcp_qidx = 0; fcp_qidx < phba->cfg_fcp_eq_count; fcp_qidx++) 6860 for (fcp_qidx = 0; fcp_qidx < phba->cfg_fcp_eq_count; fcp_qidx++)
6797 lpfc_eq_destroy(phba, phba->sli4_hba.fp_eq[fcp_qidx]); 6861 lpfc_eq_destroy(phba, phba->sli4_hba.fp_eq[fcp_qidx]);
@@ -7040,10 +7104,11 @@ lpfc_pci_function_reset(struct lpfc_hba *phba)
7040 * the loop again. 7104 * the loop again.
7041 */ 7105 */
7042 for (rdy_chk = 0; rdy_chk < 1000; rdy_chk++) { 7106 for (rdy_chk = 0; rdy_chk < 1000; rdy_chk++) {
7107 msleep(10);
7043 if (lpfc_readl(phba->sli4_hba.u.if_type2. 7108 if (lpfc_readl(phba->sli4_hba.u.if_type2.
7044 STATUSregaddr, &reg_data.word0)) { 7109 STATUSregaddr, &reg_data.word0)) {
7045 rc = -ENODEV; 7110 rc = -ENODEV;
7046 break; 7111 goto out;
7047 } 7112 }
7048 if (bf_get(lpfc_sliport_status_rdy, &reg_data)) 7113 if (bf_get(lpfc_sliport_status_rdy, &reg_data))
7049 break; 7114 break;
@@ -7051,7 +7116,6 @@ lpfc_pci_function_reset(struct lpfc_hba *phba)
7051 reset_again++; 7116 reset_again++;
7052 break; 7117 break;
7053 } 7118 }
7054 msleep(10);
7055 } 7119 }
7056 7120
7057 /* 7121 /*
@@ -7065,11 +7129,6 @@ lpfc_pci_function_reset(struct lpfc_hba *phba)
7065 } 7129 }
7066 7130
7067 /* Detect any port errors. */ 7131 /* Detect any port errors. */
7068 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr,
7069 &reg_data.word0)) {
7070 rc = -ENODEV;
7071 break;
7072 }
7073 if ((bf_get(lpfc_sliport_status_err, &reg_data)) || 7132 if ((bf_get(lpfc_sliport_status_err, &reg_data)) ||
7074 (rdy_chk >= 1000)) { 7133 (rdy_chk >= 1000)) {
7075 phba->work_status[0] = readl( 7134 phba->work_status[0] = readl(
@@ -7102,6 +7161,7 @@ lpfc_pci_function_reset(struct lpfc_hba *phba)
7102 break; 7161 break;
7103 } 7162 }
7104 7163
7164out:
7105 /* Catch the not-ready port failure after a port reset. */ 7165 /* Catch the not-ready port failure after a port reset. */
7106 if (num_resets >= MAX_IF_TYPE_2_RESETS) 7166 if (num_resets >= MAX_IF_TYPE_2_RESETS)
7107 rc = -ENODEV; 7167 rc = -ENODEV;
@@ -7149,12 +7209,13 @@ lpfc_sli4_send_nop_mbox_cmds(struct lpfc_hba *phba, uint32_t cnt)
7149 lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON, 7209 lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
7150 LPFC_MBOX_OPCODE_NOP, length, LPFC_SLI4_MBX_EMBED); 7210 LPFC_MBOX_OPCODE_NOP, length, LPFC_SLI4_MBX_EMBED);
7151 7211
7152 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG);
7153 for (cmdsent = 0; cmdsent < cnt; cmdsent++) { 7212 for (cmdsent = 0; cmdsent < cnt; cmdsent++) {
7154 if (!phba->sli4_hba.intr_enable) 7213 if (!phba->sli4_hba.intr_enable)
7155 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); 7214 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
7156 else 7215 else {
7216 mbox_tmo = lpfc_mbox_tmo_val(phba, mboxq);
7157 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo); 7217 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo);
7218 }
7158 if (rc == MBX_TIMEOUT) 7219 if (rc == MBX_TIMEOUT)
7159 break; 7220 break;
7160 /* Check return status */ 7221 /* Check return status */
@@ -7974,6 +8035,7 @@ lpfc_sli4_unset_hba(struct lpfc_hba *phba)
7974 8035
7975 /* Reset SLI4 HBA FCoE function */ 8036 /* Reset SLI4 HBA FCoE function */
7976 lpfc_pci_function_reset(phba); 8037 lpfc_pci_function_reset(phba);
8038 lpfc_sli4_queue_destroy(phba);
7977 8039
7978 return; 8040 return;
7979} 8041}
@@ -8087,6 +8149,7 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba)
8087 8149
8088 /* Reset SLI4 HBA FCoE function */ 8150 /* Reset SLI4 HBA FCoE function */
8089 lpfc_pci_function_reset(phba); 8151 lpfc_pci_function_reset(phba);
8152 lpfc_sli4_queue_destroy(phba);
8090 8153
8091 /* Stop the SLI4 device port */ 8154 /* Stop the SLI4 device port */
8092 phba->pport->work_port_events = 0; 8155 phba->pport->work_port_events = 0;
@@ -8120,7 +8183,7 @@ lpfc_pc_sli4_params_get(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
8120 if (!phba->sli4_hba.intr_enable) 8183 if (!phba->sli4_hba.intr_enable)
8121 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); 8184 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
8122 else { 8185 else {
8123 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_PORT_CAPABILITIES); 8186 mbox_tmo = lpfc_mbox_tmo_val(phba, mboxq);
8124 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo); 8187 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo);
8125 } 8188 }
8126 8189
@@ -8182,6 +8245,7 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
8182 int rc; 8245 int rc;
8183 struct lpfc_mqe *mqe = &mboxq->u.mqe; 8246 struct lpfc_mqe *mqe = &mboxq->u.mqe;
8184 struct lpfc_pc_sli4_params *sli4_params; 8247 struct lpfc_pc_sli4_params *sli4_params;
8248 uint32_t mbox_tmo;
8185 int length; 8249 int length;
8186 struct lpfc_sli4_parameters *mbx_sli4_parameters; 8250 struct lpfc_sli4_parameters *mbx_sli4_parameters;
8187 8251
@@ -8200,9 +8264,10 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
8200 length, LPFC_SLI4_MBX_EMBED); 8264 length, LPFC_SLI4_MBX_EMBED);
8201 if (!phba->sli4_hba.intr_enable) 8265 if (!phba->sli4_hba.intr_enable)
8202 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); 8266 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
8203 else 8267 else {
8204 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, 8268 mbox_tmo = lpfc_mbox_tmo_val(phba, mboxq);
8205 lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG)); 8269 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo);
8270 }
8206 if (unlikely(rc)) 8271 if (unlikely(rc))
8207 return rc; 8272 return rc;
8208 sli4_params = &phba->sli4_hba.pc_sli4_params; 8273 sli4_params = &phba->sli4_hba.pc_sli4_params;
@@ -8271,11 +8336,8 @@ lpfc_pci_probe_one_s3(struct pci_dev *pdev, const struct pci_device_id *pid)
8271 8336
8272 /* Perform generic PCI device enabling operation */ 8337 /* Perform generic PCI device enabling operation */
8273 error = lpfc_enable_pci_dev(phba); 8338 error = lpfc_enable_pci_dev(phba);
8274 if (error) { 8339 if (error)
8275 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
8276 "1401 Failed to enable pci device.\n");
8277 goto out_free_phba; 8340 goto out_free_phba;
8278 }
8279 8341
8280 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ 8342 /* Set up SLI API function jump table for PCI-device group-0 HBAs */
8281 error = lpfc_api_table_setup(phba, LPFC_PCI_DEV_LP); 8343 error = lpfc_api_table_setup(phba, LPFC_PCI_DEV_LP);
@@ -8322,6 +8384,9 @@ lpfc_pci_probe_one_s3(struct pci_dev *pdev, const struct pci_device_id *pid)
8322 goto out_free_iocb_list; 8384 goto out_free_iocb_list;
8323 } 8385 }
8324 8386
8387 /* Get the default values for Model Name and Description */
8388 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc);
8389
8325 /* Create SCSI host to the physical port */ 8390 /* Create SCSI host to the physical port */
8326 error = lpfc_create_shost(phba); 8391 error = lpfc_create_shost(phba);
8327 if (error) { 8392 if (error) {
@@ -8885,16 +8950,17 @@ lpfc_write_firmware(struct lpfc_hba *phba, const struct firmware *fw)
8885 uint32_t offset = 0, temp_offset = 0; 8950 uint32_t offset = 0, temp_offset = 0;
8886 8951
8887 INIT_LIST_HEAD(&dma_buffer_list); 8952 INIT_LIST_HEAD(&dma_buffer_list);
8888 if ((image->magic_number != LPFC_GROUP_OJECT_MAGIC_NUM) || 8953 if ((be32_to_cpu(image->magic_number) != LPFC_GROUP_OJECT_MAGIC_NUM) ||
8889 (bf_get(lpfc_grp_hdr_file_type, image) != LPFC_FILE_TYPE_GROUP) || 8954 (bf_get_be32(lpfc_grp_hdr_file_type, image) !=
8890 (bf_get(lpfc_grp_hdr_id, image) != LPFC_FILE_ID_GROUP) || 8955 LPFC_FILE_TYPE_GROUP) ||
8891 (image->size != fw->size)) { 8956 (bf_get_be32(lpfc_grp_hdr_id, image) != LPFC_FILE_ID_GROUP) ||
8957 (be32_to_cpu(image->size) != fw->size)) {
8892 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 8958 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
8893 "3022 Invalid FW image found. " 8959 "3022 Invalid FW image found. "
8894 "Magic:%d Type:%x ID:%x\n", 8960 "Magic:%x Type:%x ID:%x\n",
8895 image->magic_number, 8961 be32_to_cpu(image->magic_number),
8896 bf_get(lpfc_grp_hdr_file_type, image), 8962 bf_get_be32(lpfc_grp_hdr_file_type, image),
8897 bf_get(lpfc_grp_hdr_id, image)); 8963 bf_get_be32(lpfc_grp_hdr_id, image));
8898 return -EINVAL; 8964 return -EINVAL;
8899 } 8965 }
8900 lpfc_decode_firmware_rev(phba, fwrev, 1); 8966 lpfc_decode_firmware_rev(phba, fwrev, 1);
@@ -8924,11 +8990,11 @@ lpfc_write_firmware(struct lpfc_hba *phba, const struct firmware *fw)
8924 while (offset < fw->size) { 8990 while (offset < fw->size) {
8925 temp_offset = offset; 8991 temp_offset = offset;
8926 list_for_each_entry(dmabuf, &dma_buffer_list, list) { 8992 list_for_each_entry(dmabuf, &dma_buffer_list, list) {
8927 if (offset + SLI4_PAGE_SIZE > fw->size) { 8993 if (temp_offset + SLI4_PAGE_SIZE > fw->size) {
8928 temp_offset += fw->size - offset;
8929 memcpy(dmabuf->virt, 8994 memcpy(dmabuf->virt,
8930 fw->data + temp_offset, 8995 fw->data + temp_offset,
8931 fw->size - offset); 8996 fw->size - temp_offset);
8997 temp_offset = fw->size;
8932 break; 8998 break;
8933 } 8999 }
8934 memcpy(dmabuf->virt, fw->data + temp_offset, 9000 memcpy(dmabuf->virt, fw->data + temp_offset,
@@ -8984,7 +9050,6 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid)
8984 uint32_t cfg_mode, intr_mode; 9050 uint32_t cfg_mode, intr_mode;
8985 int mcnt; 9051 int mcnt;
8986 int adjusted_fcp_eq_count; 9052 int adjusted_fcp_eq_count;
8987 int fcp_qidx;
8988 const struct firmware *fw; 9053 const struct firmware *fw;
8989 uint8_t file_name[16]; 9054 uint8_t file_name[16];
8990 9055
@@ -8995,11 +9060,8 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid)
8995 9060
8996 /* Perform generic PCI device enabling operation */ 9061 /* Perform generic PCI device enabling operation */
8997 error = lpfc_enable_pci_dev(phba); 9062 error = lpfc_enable_pci_dev(phba);
8998 if (error) { 9063 if (error)
8999 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
9000 "1409 Failed to enable pci device.\n");
9001 goto out_free_phba; 9064 goto out_free_phba;
9002 }
9003 9065
9004 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ 9066 /* Set up SLI API function jump table for PCI-device group-1 HBAs */
9005 error = lpfc_api_table_setup(phba, LPFC_PCI_DEV_OC); 9067 error = lpfc_api_table_setup(phba, LPFC_PCI_DEV_OC);
@@ -9054,6 +9116,9 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid)
9054 goto out_free_iocb_list; 9116 goto out_free_iocb_list;
9055 } 9117 }
9056 9118
9119 /* Get the default values for Model Name and Description */
9120 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc);
9121
9057 /* Create SCSI host to the physical port */ 9122 /* Create SCSI host to the physical port */
9058 error = lpfc_create_shost(phba); 9123 error = lpfc_create_shost(phba);
9059 if (error) { 9124 if (error) {
@@ -9093,16 +9158,6 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid)
9093 adjusted_fcp_eq_count = phba->sli4_hba.msix_vec_nr - 1; 9158 adjusted_fcp_eq_count = phba->sli4_hba.msix_vec_nr - 1;
9094 else 9159 else
9095 adjusted_fcp_eq_count = phba->cfg_fcp_eq_count; 9160 adjusted_fcp_eq_count = phba->cfg_fcp_eq_count;
9096 /* Free unused EQs */
9097 for (fcp_qidx = adjusted_fcp_eq_count;
9098 fcp_qidx < phba->cfg_fcp_eq_count;
9099 fcp_qidx++) {
9100 lpfc_sli4_queue_free(phba->sli4_hba.fp_eq[fcp_qidx]);
9101 /* do not delete the first fcp_cq */
9102 if (fcp_qidx)
9103 lpfc_sli4_queue_free(
9104 phba->sli4_hba.fcp_cq[fcp_qidx]);
9105 }
9106 phba->cfg_fcp_eq_count = adjusted_fcp_eq_count; 9161 phba->cfg_fcp_eq_count = adjusted_fcp_eq_count;
9107 /* Set up SLI-4 HBA */ 9162 /* Set up SLI-4 HBA */
9108 if (lpfc_sli4_hba_setup(phba)) { 9163 if (lpfc_sli4_hba_setup(phba)) {
@@ -9285,6 +9340,7 @@ lpfc_pci_suspend_one_s4(struct pci_dev *pdev, pm_message_t msg)
9285 9340
9286 /* Disable interrupt from device */ 9341 /* Disable interrupt from device */
9287 lpfc_sli4_disable_intr(phba); 9342 lpfc_sli4_disable_intr(phba);
9343 lpfc_sli4_queue_destroy(phba);
9288 9344
9289 /* Save device state to PCI config space */ 9345 /* Save device state to PCI config space */
9290 pci_save_state(pdev); 9346 pci_save_state(pdev);
@@ -9414,6 +9470,7 @@ lpfc_sli4_prep_dev_for_reset(struct lpfc_hba *phba)
9414 9470
9415 /* Disable interrupt and pci device */ 9471 /* Disable interrupt and pci device */
9416 lpfc_sli4_disable_intr(phba); 9472 lpfc_sli4_disable_intr(phba);
9473 lpfc_sli4_queue_destroy(phba);
9417 pci_disable_device(phba->pcidev); 9474 pci_disable_device(phba->pcidev);
9418 9475
9419 /* Flush all driver's outstanding SCSI I/Os as we are to reset */ 9476 /* Flush all driver's outstanding SCSI I/Os as we are to reset */
diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h
index e3b790e5915..baf53e6c2bd 100644
--- a/drivers/scsi/lpfc/lpfc_logmsg.h
+++ b/drivers/scsi/lpfc/lpfc_logmsg.h
@@ -36,6 +36,7 @@
36#define LOG_SECURITY 0x00008000 /* Security events */ 36#define LOG_SECURITY 0x00008000 /* Security events */
37#define LOG_EVENT 0x00010000 /* CT,TEMP,DUMP, logging */ 37#define LOG_EVENT 0x00010000 /* CT,TEMP,DUMP, logging */
38#define LOG_FIP 0x00020000 /* FIP events */ 38#define LOG_FIP 0x00020000 /* FIP events */
39#define LOG_FCP_UNDER 0x00040000 /* FCP underruns errors */
39#define LOG_ALL_MSG 0xffffffff /* LOG all messages */ 40#define LOG_ALL_MSG 0xffffffff /* LOG all messages */
40 41
41#define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \ 42#define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
index 83450cc5c4d..2ebc7d2540c 100644
--- a/drivers/scsi/lpfc/lpfc_mbox.c
+++ b/drivers/scsi/lpfc/lpfc_mbox.c
@@ -1598,9 +1598,12 @@ lpfc_mbox_dev_check(struct lpfc_hba *phba)
1598 * Timeout value to be used for the given mailbox command 1598 * Timeout value to be used for the given mailbox command
1599 **/ 1599 **/
1600int 1600int
1601lpfc_mbox_tmo_val(struct lpfc_hba *phba, int cmd) 1601lpfc_mbox_tmo_val(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
1602{ 1602{
1603 switch (cmd) { 1603 MAILBOX_t *mbox = &mboxq->u.mb;
1604 uint8_t subsys, opcode;
1605
1606 switch (mbox->mbxCommand) {
1604 case MBX_WRITE_NV: /* 0x03 */ 1607 case MBX_WRITE_NV: /* 0x03 */
1605 case MBX_UPDATE_CFG: /* 0x1B */ 1608 case MBX_UPDATE_CFG: /* 0x1B */
1606 case MBX_DOWN_LOAD: /* 0x1C */ 1609 case MBX_DOWN_LOAD: /* 0x1C */
@@ -1610,6 +1613,28 @@ lpfc_mbox_tmo_val(struct lpfc_hba *phba, int cmd)
1610 case MBX_LOAD_EXP_ROM: /* 0x9C */ 1613 case MBX_LOAD_EXP_ROM: /* 0x9C */
1611 return LPFC_MBOX_TMO_FLASH_CMD; 1614 return LPFC_MBOX_TMO_FLASH_CMD;
1612 case MBX_SLI4_CONFIG: /* 0x9b */ 1615 case MBX_SLI4_CONFIG: /* 0x9b */
1616 subsys = lpfc_sli_config_mbox_subsys_get(phba, mboxq);
1617 opcode = lpfc_sli_config_mbox_opcode_get(phba, mboxq);
1618 if (subsys == LPFC_MBOX_SUBSYSTEM_COMMON) {
1619 switch (opcode) {
1620 case LPFC_MBOX_OPCODE_READ_OBJECT:
1621 case LPFC_MBOX_OPCODE_WRITE_OBJECT:
1622 case LPFC_MBOX_OPCODE_READ_OBJECT_LIST:
1623 case LPFC_MBOX_OPCODE_DELETE_OBJECT:
1624 case LPFC_MBOX_OPCODE_GET_FUNCTION_CONFIG:
1625 case LPFC_MBOX_OPCODE_GET_PROFILE_LIST:
1626 case LPFC_MBOX_OPCODE_SET_ACT_PROFILE:
1627 case LPFC_MBOX_OPCODE_SET_PROFILE_CONFIG:
1628 case LPFC_MBOX_OPCODE_GET_FACTORY_PROFILE_CONFIG:
1629 return LPFC_MBOX_SLI4_CONFIG_EXTENDED_TMO;
1630 }
1631 }
1632 if (subsys == LPFC_MBOX_SUBSYSTEM_FCOE) {
1633 switch (opcode) {
1634 case LPFC_MBOX_OPCODE_FCOE_SET_FCLINK_SETTINGS:
1635 return LPFC_MBOX_SLI4_CONFIG_EXTENDED_TMO;
1636 }
1637 }
1613 return LPFC_MBOX_SLI4_CONFIG_TMO; 1638 return LPFC_MBOX_SLI4_CONFIG_TMO;
1614 } 1639 }
1615 return LPFC_MBOX_TMO; 1640 return LPFC_MBOX_TMO;
@@ -1859,7 +1884,7 @@ lpfc_sli4_mbox_rsrc_extent(struct lpfc_hba *phba, struct lpfcMboxq *mbox,
1859 } 1884 }
1860 1885
1861 /* Complete the initialization for the particular Opcode. */ 1886 /* Complete the initialization for the particular Opcode. */
1862 opcode = lpfc_sli4_mbox_opcode_get(phba, mbox); 1887 opcode = lpfc_sli_config_mbox_opcode_get(phba, mbox);
1863 switch (opcode) { 1888 switch (opcode) {
1864 case LPFC_MBOX_OPCODE_ALLOC_RSRC_EXTENT: 1889 case LPFC_MBOX_OPCODE_ALLOC_RSRC_EXTENT:
1865 if (emb == LPFC_SLI4_MBX_EMBED) 1890 if (emb == LPFC_SLI4_MBX_EMBED)
@@ -1886,23 +1911,56 @@ lpfc_sli4_mbox_rsrc_extent(struct lpfc_hba *phba, struct lpfcMboxq *mbox,
1886} 1911}
1887 1912
1888/** 1913/**
1889 * lpfc_sli4_mbox_opcode_get - Get the opcode from a sli4 mailbox command 1914 * lpfc_sli_config_mbox_subsys_get - Get subsystem from a sli_config mbox cmd
1890 * @phba: pointer to lpfc hba data structure. 1915 * @phba: pointer to lpfc hba data structure.
1891 * @mbox: pointer to lpfc mbox command. 1916 * @mbox: pointer to lpfc mbox command queue entry.
1917 *
1918 * This routine gets the subsystem from a SLI4 specific SLI_CONFIG mailbox
1919 * command. If the mailbox command is not MBX_SLI4_CONFIG (0x9B) or if the
1920 * sub-header is not present, subsystem LPFC_MBOX_SUBSYSTEM_NA (0x0) shall
1921 * be returned.
1922 **/
1923uint8_t
1924lpfc_sli_config_mbox_subsys_get(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
1925{
1926 struct lpfc_mbx_sli4_config *sli4_cfg;
1927 union lpfc_sli4_cfg_shdr *cfg_shdr;
1928
1929 if (mbox->u.mb.mbxCommand != MBX_SLI4_CONFIG)
1930 return LPFC_MBOX_SUBSYSTEM_NA;
1931 sli4_cfg = &mbox->u.mqe.un.sli4_config;
1932
1933 /* For embedded mbox command, get opcode from embedded sub-header*/
1934 if (bf_get(lpfc_mbox_hdr_emb, &sli4_cfg->header.cfg_mhdr)) {
1935 cfg_shdr = &mbox->u.mqe.un.sli4_config.header.cfg_shdr;
1936 return bf_get(lpfc_mbox_hdr_subsystem, &cfg_shdr->request);
1937 }
1938
1939 /* For non-embedded mbox command, get opcode from first dma page */
1940 if (unlikely(!mbox->sge_array))
1941 return LPFC_MBOX_SUBSYSTEM_NA;
1942 cfg_shdr = (union lpfc_sli4_cfg_shdr *)mbox->sge_array->addr[0];
1943 return bf_get(lpfc_mbox_hdr_subsystem, &cfg_shdr->request);
1944}
1945
1946/**
1947 * lpfc_sli_config_mbox_opcode_get - Get opcode from a sli_config mbox cmd
1948 * @phba: pointer to lpfc hba data structure.
1949 * @mbox: pointer to lpfc mbox command queue entry.
1892 * 1950 *
1893 * This routine gets the opcode from a SLI4 specific mailbox command for 1951 * This routine gets the opcode from a SLI4 specific SLI_CONFIG mailbox
1894 * sending IOCTL command. If the mailbox command is not MBX_SLI4_CONFIG 1952 * command. If the mailbox command is not MBX_SLI4_CONFIG (0x9B) or if
1895 * (0x9B) or if the IOCTL sub-header is not present, opcode 0x0 shall be 1953 * the sub-header is not present, opcode LPFC_MBOX_OPCODE_NA (0x0) be
1896 * returned. 1954 * returned.
1897 **/ 1955 **/
1898uint8_t 1956uint8_t
1899lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox) 1957lpfc_sli_config_mbox_opcode_get(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
1900{ 1958{
1901 struct lpfc_mbx_sli4_config *sli4_cfg; 1959 struct lpfc_mbx_sli4_config *sli4_cfg;
1902 union lpfc_sli4_cfg_shdr *cfg_shdr; 1960 union lpfc_sli4_cfg_shdr *cfg_shdr;
1903 1961
1904 if (mbox->u.mb.mbxCommand != MBX_SLI4_CONFIG) 1962 if (mbox->u.mb.mbxCommand != MBX_SLI4_CONFIG)
1905 return 0; 1963 return LPFC_MBOX_OPCODE_NA;
1906 sli4_cfg = &mbox->u.mqe.un.sli4_config; 1964 sli4_cfg = &mbox->u.mqe.un.sli4_config;
1907 1965
1908 /* For embedded mbox command, get opcode from embedded sub-header*/ 1966 /* For embedded mbox command, get opcode from embedded sub-header*/
@@ -1913,7 +1971,7 @@ lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
1913 1971
1914 /* For non-embedded mbox command, get opcode from first dma page */ 1972 /* For non-embedded mbox command, get opcode from first dma page */
1915 if (unlikely(!mbox->sge_array)) 1973 if (unlikely(!mbox->sge_array))
1916 return 0; 1974 return LPFC_MBOX_OPCODE_NA;
1917 cfg_shdr = (union lpfc_sli4_cfg_shdr *)mbox->sge_array->addr[0]; 1975 cfg_shdr = (union lpfc_sli4_cfg_shdr *)mbox->sge_array->addr[0];
1918 return bf_get(lpfc_mbox_hdr_opcode, &cfg_shdr->request); 1976 return bf_get(lpfc_mbox_hdr_opcode, &cfg_shdr->request);
1919} 1977}
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index eadd241eeff..5b8790b3cf4 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -58,6 +58,13 @@ static char *dif_op_str[] = {
58 "SCSI_PROT_READ_PASS", 58 "SCSI_PROT_READ_PASS",
59 "SCSI_PROT_WRITE_PASS", 59 "SCSI_PROT_WRITE_PASS",
60}; 60};
61
62struct scsi_dif_tuple {
63 __be16 guard_tag; /* Checksum */
64 __be16 app_tag; /* Opaque storage */
65 __be32 ref_tag; /* Target LBA or indirect LBA */
66};
67
61static void 68static void
62lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb); 69lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb);
63static void 70static void
@@ -1263,6 +1270,174 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1263 return 0; 1270 return 0;
1264} 1271}
1265 1272
1273static inline unsigned
1274lpfc_cmd_blksize(struct scsi_cmnd *sc)
1275{
1276 return sc->device->sector_size;
1277}
1278
1279#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1280/*
1281 * Given a scsi cmnd, determine the BlockGuard tags to be used with it
1282 * @sc: The SCSI command to examine
1283 * @reftag: (out) BlockGuard reference tag for transmitted data
1284 * @apptag: (out) BlockGuard application tag for transmitted data
1285 * @new_guard (in) Value to replace CRC with if needed
1286 *
1287 * Returns (1) if error injection was performed, (0) otherwise
1288 */
1289static int
1290lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1291 uint32_t *reftag, uint16_t *apptag, uint32_t new_guard)
1292{
1293 struct scatterlist *sgpe; /* s/g prot entry */
1294 struct scatterlist *sgde; /* s/g data entry */
1295 struct scsi_dif_tuple *src;
1296 uint32_t op = scsi_get_prot_op(sc);
1297 uint32_t blksize;
1298 uint32_t numblks;
1299 sector_t lba;
1300 int rc = 0;
1301
1302 if (op == SCSI_PROT_NORMAL)
1303 return 0;
1304
1305 lba = scsi_get_lba(sc);
1306 if (phba->lpfc_injerr_lba != LPFC_INJERR_LBA_OFF) {
1307 blksize = lpfc_cmd_blksize(sc);
1308 numblks = (scsi_bufflen(sc) + blksize - 1) / blksize;
1309
1310 /* Make sure we have the right LBA if one is specified */
1311 if ((phba->lpfc_injerr_lba < lba) ||
1312 (phba->lpfc_injerr_lba >= (lba + numblks)))
1313 return 0;
1314 }
1315
1316 sgpe = scsi_prot_sglist(sc);
1317 sgde = scsi_sglist(sc);
1318
1319 /* Should we change the Reference Tag */
1320 if (reftag) {
1321 /*
1322 * If we are SCSI_PROT_WRITE_STRIP, the protection data is
1323 * being stripped from the wire, thus it doesn't matter.
1324 */
1325 if ((op == SCSI_PROT_WRITE_PASS) ||
1326 (op == SCSI_PROT_WRITE_INSERT)) {
1327 if (phba->lpfc_injerr_wref_cnt) {
1328
1329 /* DEADBEEF will be the reftag on the wire */
1330 *reftag = 0xDEADBEEF;
1331 phba->lpfc_injerr_wref_cnt--;
1332 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
1333 rc = 1;
1334
1335 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1336 "9081 BLKGRD: Injecting reftag error: "
1337 "write lba x%lx\n", (unsigned long)lba);
1338 }
1339 } else {
1340 if (phba->lpfc_injerr_rref_cnt) {
1341 *reftag = 0xDEADBEEF;
1342 phba->lpfc_injerr_rref_cnt--;
1343 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
1344 rc = 1;
1345
1346 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1347 "9076 BLKGRD: Injecting reftag error: "
1348 "read lba x%lx\n", (unsigned long)lba);
1349 }
1350 }
1351 }
1352
1353 /* Should we change the Application Tag */
1354 if (apptag) {
1355 /*
1356 * If we are SCSI_PROT_WRITE_STRIP, the protection data is
1357 * being stripped from the wire, thus it doesn't matter.
1358 */
1359 if ((op == SCSI_PROT_WRITE_PASS) ||
1360 (op == SCSI_PROT_WRITE_INSERT)) {
1361 if (phba->lpfc_injerr_wapp_cnt) {
1362
1363 /* DEAD will be the apptag on the wire */
1364 *apptag = 0xDEAD;
1365 phba->lpfc_injerr_wapp_cnt--;
1366 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
1367 rc = 1;
1368
1369 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1370 "9077 BLKGRD: Injecting apptag error: "
1371 "write lba x%lx\n", (unsigned long)lba);
1372 }
1373 } else {
1374 if (phba->lpfc_injerr_rapp_cnt) {
1375 *apptag = 0xDEAD;
1376 phba->lpfc_injerr_rapp_cnt--;
1377 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
1378 rc = 1;
1379
1380 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1381 "9078 BLKGRD: Injecting apptag error: "
1382 "read lba x%lx\n", (unsigned long)lba);
1383 }
1384 }
1385 }
1386
1387 /* Should we change the Guard Tag */
1388
1389 /*
1390 * If we are SCSI_PROT_WRITE_INSERT, the protection data is
1391 * being on the wire is being fully generated on the HBA.
1392 * The host cannot change it or force an error.
1393 */
1394 if (((op == SCSI_PROT_WRITE_STRIP) ||
1395 (op == SCSI_PROT_WRITE_PASS)) &&
1396 phba->lpfc_injerr_wgrd_cnt) {
1397 if (sgpe) {
1398 src = (struct scsi_dif_tuple *)sg_virt(sgpe);
1399 /*
1400 * Just inject an error in the first
1401 * prot block.
1402 */
1403 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1404 "9079 BLKGRD: Injecting guard error: "
1405 "write lba x%lx oldGuard x%x refTag x%x\n",
1406 (unsigned long)lba, src->guard_tag,
1407 src->ref_tag);
1408
1409 src->guard_tag = (uint16_t)new_guard;
1410 phba->lpfc_injerr_wgrd_cnt--;
1411 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
1412 rc = 1;
1413
1414 } else {
1415 blksize = lpfc_cmd_blksize(sc);
1416 /*
1417 * Jump past the first data block
1418 * and inject an error in the
1419 * prot data. The prot data is already
1420 * embedded after the regular data.
1421 */
1422 src = (struct scsi_dif_tuple *)
1423 (sg_virt(sgde) + blksize);
1424
1425 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1426 "9080 BLKGRD: Injecting guard error: "
1427 "write lba x%lx oldGuard x%x refTag x%x\n",
1428 (unsigned long)lba, src->guard_tag,
1429 src->ref_tag);
1430
1431 src->guard_tag = (uint16_t)new_guard;
1432 phba->lpfc_injerr_wgrd_cnt--;
1433 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
1434 rc = 1;
1435 }
1436 }
1437 return rc;
1438}
1439#endif
1440
1266/* 1441/*
1267 * Given a scsi cmnd, determine the BlockGuard opcodes to be used with it 1442 * Given a scsi cmnd, determine the BlockGuard opcodes to be used with it
1268 * @sc: The SCSI command to examine 1443 * @sc: The SCSI command to examine
@@ -1341,18 +1516,6 @@ lpfc_sc_to_bg_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1341 return ret; 1516 return ret;
1342} 1517}
1343 1518
1344struct scsi_dif_tuple {
1345 __be16 guard_tag; /* Checksum */
1346 __be16 app_tag; /* Opaque storage */
1347 __be32 ref_tag; /* Target LBA or indirect LBA */
1348};
1349
1350static inline unsigned
1351lpfc_cmd_blksize(struct scsi_cmnd *sc)
1352{
1353 return sc->device->sector_size;
1354}
1355
1356/* 1519/*
1357 * This function sets up buffer list for protection groups of 1520 * This function sets up buffer list for protection groups of
1358 * type LPFC_PG_TYPE_NO_DIF 1521 * type LPFC_PG_TYPE_NO_DIF
@@ -1401,6 +1564,11 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1401 blksize = lpfc_cmd_blksize(sc); 1564 blksize = lpfc_cmd_blksize(sc);
1402 reftag = scsi_get_lba(sc) & 0xffffffff; 1565 reftag = scsi_get_lba(sc) & 0xffffffff;
1403 1566
1567#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1568 /* reftag is the only error we can inject here */
1569 lpfc_bg_err_inject(phba, sc, &reftag, 0, 0);
1570#endif
1571
1404 /* setup PDE5 with what we have */ 1572 /* setup PDE5 with what we have */
1405 pde5 = (struct lpfc_pde5 *) bpl; 1573 pde5 = (struct lpfc_pde5 *) bpl;
1406 memset(pde5, 0, sizeof(struct lpfc_pde5)); 1574 memset(pde5, 0, sizeof(struct lpfc_pde5));
@@ -1532,6 +1700,11 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1532 blksize = lpfc_cmd_blksize(sc); 1700 blksize = lpfc_cmd_blksize(sc);
1533 reftag = scsi_get_lba(sc) & 0xffffffff; 1701 reftag = scsi_get_lba(sc) & 0xffffffff;
1534 1702
1703#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1704 /* reftag / guard tag are the only errors we can inject here */
1705 lpfc_bg_err_inject(phba, sc, &reftag, 0, 0xDEAD);
1706#endif
1707
1535 split_offset = 0; 1708 split_offset = 0;
1536 do { 1709 do {
1537 /* setup PDE5 with what we have */ 1710 /* setup PDE5 with what we have */
@@ -1671,7 +1844,6 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1671 } 1844 }
1672 1845
1673 } while (!alldone); 1846 } while (!alldone);
1674
1675out: 1847out:
1676 1848
1677 return num_bde; 1849 return num_bde;
@@ -2075,6 +2247,7 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
2075 else 2247 else
2076 bf_set(lpfc_sli4_sge_last, sgl, 0); 2248 bf_set(lpfc_sli4_sge_last, sgl, 0);
2077 bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); 2249 bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
2250 bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA);
2078 sgl->word2 = cpu_to_le32(sgl->word2); 2251 sgl->word2 = cpu_to_le32(sgl->word2);
2079 sgl->sge_len = cpu_to_le32(dma_len); 2252 sgl->sge_len = cpu_to_le32(dma_len);
2080 dma_offset += dma_len; 2253 dma_offset += dma_len;
@@ -2325,8 +2498,9 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
2325 } 2498 }
2326 lp = (uint32_t *)cmnd->sense_buffer; 2499 lp = (uint32_t *)cmnd->sense_buffer;
2327 2500
2328 if (!scsi_status && (resp_info & RESID_UNDER)) 2501 if (!scsi_status && (resp_info & RESID_UNDER) &&
2329 logit = LOG_FCP; 2502 vport->cfg_log_verbose & LOG_FCP_UNDER)
2503 logit = LOG_FCP_UNDER;
2330 2504
2331 lpfc_printf_vlog(vport, KERN_WARNING, logit, 2505 lpfc_printf_vlog(vport, KERN_WARNING, logit,
2332 "9024 FCP command x%x failed: x%x SNS x%x x%x " 2506 "9024 FCP command x%x failed: x%x SNS x%x x%x "
@@ -2342,7 +2516,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
2342 if (resp_info & RESID_UNDER) { 2516 if (resp_info & RESID_UNDER) {
2343 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId)); 2517 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId));
2344 2518
2345 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, 2519 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP_UNDER,
2346 "9025 FCP Read Underrun, expected %d, " 2520 "9025 FCP Read Underrun, expected %d, "
2347 "residual %d Data: x%x x%x x%x\n", 2521 "residual %d Data: x%x x%x x%x\n",
2348 be32_to_cpu(fcpcmd->fcpDl), 2522 be32_to_cpu(fcpcmd->fcpDl),
@@ -2449,6 +2623,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2449 struct lpfc_fast_path_event *fast_path_evt; 2623 struct lpfc_fast_path_event *fast_path_evt;
2450 struct Scsi_Host *shost; 2624 struct Scsi_Host *shost;
2451 uint32_t queue_depth, scsi_id; 2625 uint32_t queue_depth, scsi_id;
2626 uint32_t logit = LOG_FCP;
2452 2627
2453 /* Sanity check on return of outstanding command */ 2628 /* Sanity check on return of outstanding command */
2454 if (!(lpfc_cmd->pCmd)) 2629 if (!(lpfc_cmd->pCmd))
@@ -2470,16 +2645,22 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2470 lpfc_cmd->status = IOSTAT_DRIVER_REJECT; 2645 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
2471 else if (lpfc_cmd->status >= IOSTAT_CNT) 2646 else if (lpfc_cmd->status >= IOSTAT_CNT)
2472 lpfc_cmd->status = IOSTAT_DEFAULT; 2647 lpfc_cmd->status = IOSTAT_DEFAULT;
2473 2648 if (lpfc_cmd->status == IOSTAT_FCP_RSP_ERROR
2474 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, 2649 && !lpfc_cmd->fcp_rsp->rspStatus3
2475 "9030 FCP cmd x%x failed <%d/%d> " 2650 && (lpfc_cmd->fcp_rsp->rspStatus2 & RESID_UNDER)
2476 "status: x%x result: x%x Data: x%x x%x\n", 2651 && !(phba->cfg_log_verbose & LOG_FCP_UNDER))
2477 cmd->cmnd[0], 2652 logit = 0;
2478 cmd->device ? cmd->device->id : 0xffff, 2653 else
2479 cmd->device ? cmd->device->lun : 0xffff, 2654 logit = LOG_FCP | LOG_FCP_UNDER;
2480 lpfc_cmd->status, lpfc_cmd->result, 2655 lpfc_printf_vlog(vport, KERN_WARNING, logit,
2481 pIocbOut->iocb.ulpContext, 2656 "9030 FCP cmd x%x failed <%d/%d> "
2482 lpfc_cmd->cur_iocbq.iocb.ulpIoTag); 2657 "status: x%x result: x%x Data: x%x x%x\n",
2658 cmd->cmnd[0],
2659 cmd->device ? cmd->device->id : 0xffff,
2660 cmd->device ? cmd->device->lun : 0xffff,
2661 lpfc_cmd->status, lpfc_cmd->result,
2662 pIocbOut->iocb.ulpContext,
2663 lpfc_cmd->cur_iocbq.iocb.ulpIoTag);
2483 2664
2484 switch (lpfc_cmd->status) { 2665 switch (lpfc_cmd->status) {
2485 case IOSTAT_FCP_RSP_ERROR: 2666 case IOSTAT_FCP_RSP_ERROR:
@@ -3056,8 +3237,9 @@ lpfc_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
3056 } 3237 }
3057 ndlp = rdata->pnode; 3238 ndlp = rdata->pnode;
3058 3239
3059 if (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED) && 3240 if ((scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) &&
3060 scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { 3241 (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED) ||
3242 (phba->sli_rev == LPFC_SLI_REV4))) {
3061 3243
3062 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 3244 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
3063 "9058 BLKGRD: ERROR: rcvd protected cmd:%02x" 3245 "9058 BLKGRD: ERROR: rcvd protected cmd:%02x"
@@ -3691,9 +3873,9 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
3691 fc_host_post_vendor_event(shost, fc_get_event_number(), 3873 fc_host_post_vendor_event(shost, fc_get_event_number(),
3692 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID); 3874 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
3693 3875
3694 ret = fc_block_scsi_eh(cmnd); 3876 status = fc_block_scsi_eh(cmnd);
3695 if (ret) 3877 if (status)
3696 return ret; 3878 return status;
3697 3879
3698 /* 3880 /*
3699 * Since the driver manages a single bus device, reset all 3881 * Since the driver manages a single bus device, reset all
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 8b799f047a9..4d4104f38c9 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -379,10 +379,10 @@ lpfc_sli4_rq_put(struct lpfc_queue *hq, struct lpfc_queue *dq,
379 dq->host_index = ((dq->host_index + 1) % dq->entry_count); 379 dq->host_index = ((dq->host_index + 1) % dq->entry_count);
380 380
381 /* Ring The Header Receive Queue Doorbell */ 381 /* Ring The Header Receive Queue Doorbell */
382 if (!(hq->host_index % LPFC_RQ_POST_BATCH)) { 382 if (!(hq->host_index % hq->entry_repost)) {
383 doorbell.word0 = 0; 383 doorbell.word0 = 0;
384 bf_set(lpfc_rq_doorbell_num_posted, &doorbell, 384 bf_set(lpfc_rq_doorbell_num_posted, &doorbell,
385 LPFC_RQ_POST_BATCH); 385 hq->entry_repost);
386 bf_set(lpfc_rq_doorbell_id, &doorbell, hq->queue_id); 386 bf_set(lpfc_rq_doorbell_id, &doorbell, hq->queue_id);
387 writel(doorbell.word0, hq->phba->sli4_hba.RQDBregaddr); 387 writel(doorbell.word0, hq->phba->sli4_hba.RQDBregaddr);
388 } 388 }
@@ -1864,7 +1864,7 @@ lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno)
1864{ 1864{
1865 if (phba->sli_rev == LPFC_SLI_REV4) 1865 if (phba->sli_rev == LPFC_SLI_REV4)
1866 return lpfc_sli_hbqbuf_fill_hbqs(phba, qno, 1866 return lpfc_sli_hbqbuf_fill_hbqs(phba, qno,
1867 lpfc_hbq_defs[qno]->entry_count); 1867 lpfc_hbq_defs[qno]->entry_count);
1868 else 1868 else
1869 return lpfc_sli_hbqbuf_fill_hbqs(phba, qno, 1869 return lpfc_sli_hbqbuf_fill_hbqs(phba, qno,
1870 lpfc_hbq_defs[qno]->init_count); 1870 lpfc_hbq_defs[qno]->init_count);
@@ -2200,10 +2200,13 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba)
2200 /* Unknown mailbox command compl */ 2200 /* Unknown mailbox command compl */
2201 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 2201 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
2202 "(%d):0323 Unknown Mailbox command " 2202 "(%d):0323 Unknown Mailbox command "
2203 "x%x (x%x) Cmpl\n", 2203 "x%x (x%x/x%x) Cmpl\n",
2204 pmb->vport ? pmb->vport->vpi : 0, 2204 pmb->vport ? pmb->vport->vpi : 0,
2205 pmbox->mbxCommand, 2205 pmbox->mbxCommand,
2206 lpfc_sli4_mbox_opcode_get(phba, pmb)); 2206 lpfc_sli_config_mbox_subsys_get(phba,
2207 pmb),
2208 lpfc_sli_config_mbox_opcode_get(phba,
2209 pmb));
2207 phba->link_state = LPFC_HBA_ERROR; 2210 phba->link_state = LPFC_HBA_ERROR;
2208 phba->work_hs = HS_FFER3; 2211 phba->work_hs = HS_FFER3;
2209 lpfc_handle_eratt(phba); 2212 lpfc_handle_eratt(phba);
@@ -2215,17 +2218,19 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba)
2215 if (pmbox->mbxStatus == MBXERR_NO_RESOURCES) { 2218 if (pmbox->mbxStatus == MBXERR_NO_RESOURCES) {
2216 /* Mbox cmd cmpl error - RETRYing */ 2219 /* Mbox cmd cmpl error - RETRYing */
2217 lpfc_printf_log(phba, KERN_INFO, 2220 lpfc_printf_log(phba, KERN_INFO,
2218 LOG_MBOX | LOG_SLI, 2221 LOG_MBOX | LOG_SLI,
2219 "(%d):0305 Mbox cmd cmpl " 2222 "(%d):0305 Mbox cmd cmpl "
2220 "error - RETRYing Data: x%x " 2223 "error - RETRYing Data: x%x "
2221 "(x%x) x%x x%x x%x\n", 2224 "(x%x/x%x) x%x x%x x%x\n",
2222 pmb->vport ? pmb->vport->vpi :0, 2225 pmb->vport ? pmb->vport->vpi : 0,
2223 pmbox->mbxCommand, 2226 pmbox->mbxCommand,
2224 lpfc_sli4_mbox_opcode_get(phba, 2227 lpfc_sli_config_mbox_subsys_get(phba,
2225 pmb), 2228 pmb),
2226 pmbox->mbxStatus, 2229 lpfc_sli_config_mbox_opcode_get(phba,
2227 pmbox->un.varWords[0], 2230 pmb),
2228 pmb->vport->port_state); 2231 pmbox->mbxStatus,
2232 pmbox->un.varWords[0],
2233 pmb->vport->port_state);
2229 pmbox->mbxStatus = 0; 2234 pmbox->mbxStatus = 0;
2230 pmbox->mbxOwner = OWN_HOST; 2235 pmbox->mbxOwner = OWN_HOST;
2231 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); 2236 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
@@ -2236,11 +2241,12 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba)
2236 2241
2237 /* Mailbox cmd <cmd> Cmpl <cmpl> */ 2242 /* Mailbox cmd <cmd> Cmpl <cmpl> */
2238 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 2243 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
2239 "(%d):0307 Mailbox cmd x%x (x%x) Cmpl x%p " 2244 "(%d):0307 Mailbox cmd x%x (x%x/x%x) Cmpl x%p "
2240 "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x\n", 2245 "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x\n",
2241 pmb->vport ? pmb->vport->vpi : 0, 2246 pmb->vport ? pmb->vport->vpi : 0,
2242 pmbox->mbxCommand, 2247 pmbox->mbxCommand,
2243 lpfc_sli4_mbox_opcode_get(phba, pmb), 2248 lpfc_sli_config_mbox_subsys_get(phba, pmb),
2249 lpfc_sli_config_mbox_opcode_get(phba, pmb),
2244 pmb->mbox_cmpl, 2250 pmb->mbox_cmpl,
2245 *((uint32_t *) pmbox), 2251 *((uint32_t *) pmbox),
2246 pmbox->un.varWords[0], 2252 pmbox->un.varWords[0],
@@ -4686,6 +4692,175 @@ lpfc_sli4_read_rev(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
4686} 4692}
4687 4693
4688/** 4694/**
4695 * lpfc_sli4_retrieve_pport_name - Retrieve SLI4 device physical port name
4696 * @phba: pointer to lpfc hba data structure.
4697 *
4698 * This routine retrieves SLI4 device physical port name this PCI function
4699 * is attached to.
4700 *
4701 * Return codes
4702 * 0 - sucessful
4703 * otherwise - failed to retrieve physical port name
4704 **/
4705static int
4706lpfc_sli4_retrieve_pport_name(struct lpfc_hba *phba)
4707{
4708 LPFC_MBOXQ_t *mboxq;
4709 struct lpfc_mbx_read_config *rd_config;
4710 struct lpfc_mbx_get_cntl_attributes *mbx_cntl_attr;
4711 struct lpfc_controller_attribute *cntl_attr;
4712 struct lpfc_mbx_get_port_name *get_port_name;
4713 void *virtaddr = NULL;
4714 uint32_t alloclen, reqlen;
4715 uint32_t shdr_status, shdr_add_status;
4716 union lpfc_sli4_cfg_shdr *shdr;
4717 char cport_name = 0;
4718 int rc;
4719
4720 /* We assume nothing at this point */
4721 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_INVAL;
4722 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_NON;
4723
4724 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4725 if (!mboxq)
4726 return -ENOMEM;
4727
4728 /* obtain link type and link number via READ_CONFIG */
4729 lpfc_read_config(phba, mboxq);
4730 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
4731 if (rc == MBX_SUCCESS) {
4732 rd_config = &mboxq->u.mqe.un.rd_config;
4733 if (bf_get(lpfc_mbx_rd_conf_lnk_ldv, rd_config)) {
4734 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL;
4735 phba->sli4_hba.lnk_info.lnk_tp =
4736 bf_get(lpfc_mbx_rd_conf_lnk_type, rd_config);
4737 phba->sli4_hba.lnk_info.lnk_no =
4738 bf_get(lpfc_mbx_rd_conf_lnk_numb, rd_config);
4739 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
4740 "3081 lnk_type:%d, lnk_numb:%d\n",
4741 phba->sli4_hba.lnk_info.lnk_tp,
4742 phba->sli4_hba.lnk_info.lnk_no);
4743 goto retrieve_ppname;
4744 } else
4745 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
4746 "3082 Mailbox (x%x) returned ldv:x0\n",
4747 bf_get(lpfc_mqe_command,
4748 &mboxq->u.mqe));
4749 } else
4750 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
4751 "3083 Mailbox (x%x) failed, status:x%x\n",
4752 bf_get(lpfc_mqe_command, &mboxq->u.mqe),
4753 bf_get(lpfc_mqe_status, &mboxq->u.mqe));
4754
4755 /* obtain link type and link number via COMMON_GET_CNTL_ATTRIBUTES */
4756 reqlen = sizeof(struct lpfc_mbx_get_cntl_attributes);
4757 alloclen = lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
4758 LPFC_MBOX_OPCODE_GET_CNTL_ATTRIBUTES, reqlen,
4759 LPFC_SLI4_MBX_NEMBED);
4760 if (alloclen < reqlen) {
4761 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
4762 "3084 Allocated DMA memory size (%d) is "
4763 "less than the requested DMA memory size "
4764 "(%d)\n", alloclen, reqlen);
4765 rc = -ENOMEM;
4766 goto out_free_mboxq;
4767 }
4768 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
4769 virtaddr = mboxq->sge_array->addr[0];
4770 mbx_cntl_attr = (struct lpfc_mbx_get_cntl_attributes *)virtaddr;
4771 shdr = &mbx_cntl_attr->cfg_shdr;
4772 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
4773 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response);
4774 if (shdr_status || shdr_add_status || rc) {
4775 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
4776 "3085 Mailbox x%x (x%x/x%x) failed, "
4777 "rc:x%x, status:x%x, add_status:x%x\n",
4778 bf_get(lpfc_mqe_command, &mboxq->u.mqe),
4779 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
4780 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
4781 rc, shdr_status, shdr_add_status);
4782 rc = -ENXIO;
4783 goto out_free_mboxq;
4784 }
4785 cntl_attr = &mbx_cntl_attr->cntl_attr;
4786 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL;
4787 phba->sli4_hba.lnk_info.lnk_tp =
4788 bf_get(lpfc_cntl_attr_lnk_type, cntl_attr);
4789 phba->sli4_hba.lnk_info.lnk_no =
4790 bf_get(lpfc_cntl_attr_lnk_numb, cntl_attr);
4791 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
4792 "3086 lnk_type:%d, lnk_numb:%d\n",
4793 phba->sli4_hba.lnk_info.lnk_tp,
4794 phba->sli4_hba.lnk_info.lnk_no);
4795
4796retrieve_ppname:
4797 lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
4798 LPFC_MBOX_OPCODE_GET_PORT_NAME,
4799 sizeof(struct lpfc_mbx_get_port_name) -
4800 sizeof(struct lpfc_sli4_cfg_mhdr),
4801 LPFC_SLI4_MBX_EMBED);
4802 get_port_name = &mboxq->u.mqe.un.get_port_name;
4803 shdr = (union lpfc_sli4_cfg_shdr *)&get_port_name->header.cfg_shdr;
4804 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_OPCODE_VERSION_1);
4805 bf_set(lpfc_mbx_get_port_name_lnk_type, &get_port_name->u.request,
4806 phba->sli4_hba.lnk_info.lnk_tp);
4807 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
4808 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
4809 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response);
4810 if (shdr_status || shdr_add_status || rc) {
4811 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
4812 "3087 Mailbox x%x (x%x/x%x) failed: "
4813 "rc:x%x, status:x%x, add_status:x%x\n",
4814 bf_get(lpfc_mqe_command, &mboxq->u.mqe),
4815 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
4816 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
4817 rc, shdr_status, shdr_add_status);
4818 rc = -ENXIO;
4819 goto out_free_mboxq;
4820 }
4821 switch (phba->sli4_hba.lnk_info.lnk_no) {
4822 case LPFC_LINK_NUMBER_0:
4823 cport_name = bf_get(lpfc_mbx_get_port_name_name0,
4824 &get_port_name->u.response);
4825 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET;
4826 break;
4827 case LPFC_LINK_NUMBER_1:
4828 cport_name = bf_get(lpfc_mbx_get_port_name_name1,
4829 &get_port_name->u.response);
4830 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET;
4831 break;
4832 case LPFC_LINK_NUMBER_2:
4833 cport_name = bf_get(lpfc_mbx_get_port_name_name2,
4834 &get_port_name->u.response);
4835 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET;
4836 break;
4837 case LPFC_LINK_NUMBER_3:
4838 cport_name = bf_get(lpfc_mbx_get_port_name_name3,
4839 &get_port_name->u.response);
4840 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET;
4841 break;
4842 default:
4843 break;
4844 }
4845
4846 if (phba->sli4_hba.pport_name_sta == LPFC_SLI4_PPNAME_GET) {
4847 phba->Port[0] = cport_name;
4848 phba->Port[1] = '\0';
4849 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
4850 "3091 SLI get port name: %s\n", phba->Port);
4851 }
4852
4853out_free_mboxq:
4854 if (rc != MBX_TIMEOUT) {
4855 if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG)
4856 lpfc_sli4_mbox_cmd_free(phba, mboxq);
4857 else
4858 mempool_free(mboxq, phba->mbox_mem_pool);
4859 }
4860 return rc;
4861}
4862
4863/**
4689 * lpfc_sli4_arm_cqeq_intr - Arm sli-4 device completion and event queues 4864 * lpfc_sli4_arm_cqeq_intr - Arm sli-4 device completion and event queues
4690 * @phba: pointer to lpfc hba data structure. 4865 * @phba: pointer to lpfc hba data structure.
4691 * 4866 *
@@ -4754,7 +4929,7 @@ lpfc_sli4_get_avail_extnt_rsrc(struct lpfc_hba *phba, uint16_t type,
4754 if (!phba->sli4_hba.intr_enable) 4929 if (!phba->sli4_hba.intr_enable)
4755 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 4930 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
4756 else { 4931 else {
4757 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 4932 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
4758 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 4933 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
4759 } 4934 }
4760 if (unlikely(rc)) { 4935 if (unlikely(rc)) {
@@ -4911,7 +5086,7 @@ lpfc_sli4_cfg_post_extnts(struct lpfc_hba *phba, uint16_t *extnt_cnt,
4911 if (!phba->sli4_hba.intr_enable) 5086 if (!phba->sli4_hba.intr_enable)
4912 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 5087 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
4913 else { 5088 else {
4914 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 5089 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
4915 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 5090 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
4916 } 5091 }
4917 5092
@@ -5194,7 +5369,7 @@ lpfc_sli4_dealloc_extent(struct lpfc_hba *phba, uint16_t type)
5194 if (!phba->sli4_hba.intr_enable) 5369 if (!phba->sli4_hba.intr_enable)
5195 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 5370 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
5196 else { 5371 else {
5197 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox_tmo); 5372 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
5198 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 5373 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
5199 } 5374 }
5200 if (unlikely(rc)) { 5375 if (unlikely(rc)) {
@@ -5619,7 +5794,7 @@ lpfc_sli4_get_allocated_extnts(struct lpfc_hba *phba, uint16_t type,
5619 if (!phba->sli4_hba.intr_enable) 5794 if (!phba->sli4_hba.intr_enable)
5620 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 5795 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
5621 else { 5796 else {
5622 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 5797 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
5623 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 5798 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
5624 } 5799 }
5625 5800
@@ -5748,6 +5923,17 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
5748 kfree(vpd); 5923 kfree(vpd);
5749 goto out_free_mbox; 5924 goto out_free_mbox;
5750 } 5925 }
5926
5927 /*
5928 * Retrieve sli4 device physical port name, failure of doing it
5929 * is considered as non-fatal.
5930 */
5931 rc = lpfc_sli4_retrieve_pport_name(phba);
5932 if (!rc)
5933 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
5934 "3080 Successful retrieving SLI4 device "
5935 "physical port name: %s.\n", phba->Port);
5936
5751 /* 5937 /*
5752 * Evaluate the read rev and vpd data. Populate the driver 5938 * Evaluate the read rev and vpd data. Populate the driver
5753 * state with the results. If this routine fails, the failure 5939 * state with the results. If this routine fails, the failure
@@ -5818,9 +6004,13 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
5818 * then turn off the global config parameters to disable the 6004 * then turn off the global config parameters to disable the
5819 * feature in the driver. This is not a fatal error. 6005 * feature in the driver. This is not a fatal error.
5820 */ 6006 */
5821 if ((phba->cfg_enable_bg) && 6007 phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED;
5822 !(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) 6008 if (phba->cfg_enable_bg) {
5823 ftr_rsp++; 6009 if (bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))
6010 phba->sli3_options |= LPFC_SLI3_BG_ENABLED;
6011 else
6012 ftr_rsp++;
6013 }
5824 6014
5825 if (phba->max_vpi && phba->cfg_enable_npiv && 6015 if (phba->max_vpi && phba->cfg_enable_npiv &&
5826 !(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) 6016 !(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs)))
@@ -5937,12 +6127,20 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
5937 goto out_free_mbox; 6127 goto out_free_mbox;
5938 } 6128 }
5939 6129
6130 /* Create all the SLI4 queues */
6131 rc = lpfc_sli4_queue_create(phba);
6132 if (rc) {
6133 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
6134 "3089 Failed to allocate queues\n");
6135 rc = -ENODEV;
6136 goto out_stop_timers;
6137 }
5940 /* Set up all the queues to the device */ 6138 /* Set up all the queues to the device */
5941 rc = lpfc_sli4_queue_setup(phba); 6139 rc = lpfc_sli4_queue_setup(phba);
5942 if (unlikely(rc)) { 6140 if (unlikely(rc)) {
5943 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 6141 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
5944 "0381 Error %d during queue setup.\n ", rc); 6142 "0381 Error %d during queue setup.\n ", rc);
5945 goto out_stop_timers; 6143 goto out_destroy_queue;
5946 } 6144 }
5947 6145
5948 /* Arm the CQs and then EQs on device */ 6146 /* Arm the CQs and then EQs on device */
@@ -6015,15 +6213,20 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
6015 spin_lock_irq(&phba->hbalock); 6213 spin_lock_irq(&phba->hbalock);
6016 phba->link_state = LPFC_LINK_DOWN; 6214 phba->link_state = LPFC_LINK_DOWN;
6017 spin_unlock_irq(&phba->hbalock); 6215 spin_unlock_irq(&phba->hbalock);
6018 if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) 6216 if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) {
6019 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); 6217 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT);
6218 if (rc)
6219 goto out_unset_queue;
6220 }
6221 mempool_free(mboxq, phba->mbox_mem_pool);
6222 return rc;
6020out_unset_queue: 6223out_unset_queue:
6021 /* Unset all the queues set up in this routine when error out */ 6224 /* Unset all the queues set up in this routine when error out */
6022 if (rc) 6225 lpfc_sli4_queue_unset(phba);
6023 lpfc_sli4_queue_unset(phba); 6226out_destroy_queue:
6227 lpfc_sli4_queue_destroy(phba);
6024out_stop_timers: 6228out_stop_timers:
6025 if (rc) 6229 lpfc_stop_hba_timers(phba);
6026 lpfc_stop_hba_timers(phba);
6027out_free_mbox: 6230out_free_mbox:
6028 mempool_free(mboxq, phba->mbox_mem_pool); 6231 mempool_free(mboxq, phba->mbox_mem_pool);
6029 return rc; 6232 return rc;
@@ -6318,7 +6521,7 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
6318 } 6521 }
6319 /* timeout active mbox command */ 6522 /* timeout active mbox command */
6320 mod_timer(&psli->mbox_tmo, (jiffies + 6523 mod_timer(&psli->mbox_tmo, (jiffies +
6321 (HZ * lpfc_mbox_tmo_val(phba, mb->mbxCommand)))); 6524 (HZ * lpfc_mbox_tmo_val(phba, pmbox))));
6322 } 6525 }
6323 6526
6324 /* Mailbox cmd <cmd> issue */ 6527 /* Mailbox cmd <cmd> issue */
@@ -6442,9 +6645,8 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
6442 drvr_flag); 6645 drvr_flag);
6443 goto out_not_finished; 6646 goto out_not_finished;
6444 } 6647 }
6445 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, 6648 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, pmbox) *
6446 mb->mbxCommand) * 6649 1000) + jiffies;
6447 1000) + jiffies;
6448 i = 0; 6650 i = 0;
6449 /* Wait for command to complete */ 6651 /* Wait for command to complete */
6450 while (((word0 & OWN_CHIP) == OWN_CHIP) || 6652 while (((word0 & OWN_CHIP) == OWN_CHIP) ||
@@ -6555,21 +6757,21 @@ static int
6555lpfc_sli4_async_mbox_block(struct lpfc_hba *phba) 6757lpfc_sli4_async_mbox_block(struct lpfc_hba *phba)
6556{ 6758{
6557 struct lpfc_sli *psli = &phba->sli; 6759 struct lpfc_sli *psli = &phba->sli;
6558 uint8_t actcmd = MBX_HEARTBEAT;
6559 int rc = 0; 6760 int rc = 0;
6560 unsigned long timeout; 6761 unsigned long timeout = 0;
6561 6762
6562 /* Mark the asynchronous mailbox command posting as blocked */ 6763 /* Mark the asynchronous mailbox command posting as blocked */
6563 spin_lock_irq(&phba->hbalock); 6764 spin_lock_irq(&phba->hbalock);
6564 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; 6765 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK;
6565 if (phba->sli.mbox_active)
6566 actcmd = phba->sli.mbox_active->u.mb.mbxCommand;
6567 spin_unlock_irq(&phba->hbalock);
6568 /* Determine how long we might wait for the active mailbox 6766 /* Determine how long we might wait for the active mailbox
6569 * command to be gracefully completed by firmware. 6767 * command to be gracefully completed by firmware.
6570 */ 6768 */
6571 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, actcmd) * 1000) + 6769 if (phba->sli.mbox_active)
6572 jiffies; 6770 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
6771 phba->sli.mbox_active) *
6772 1000) + jiffies;
6773 spin_unlock_irq(&phba->hbalock);
6774
6573 /* Wait for the outstnading mailbox command to complete */ 6775 /* Wait for the outstnading mailbox command to complete */
6574 while (phba->sli.mbox_active) { 6776 while (phba->sli.mbox_active) {
6575 /* Check active mailbox complete status every 2ms */ 6777 /* Check active mailbox complete status every 2ms */
@@ -6664,11 +6866,12 @@ lpfc_sli4_post_sync_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
6664 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { 6866 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) {
6665 spin_unlock_irqrestore(&phba->hbalock, iflag); 6867 spin_unlock_irqrestore(&phba->hbalock, iflag);
6666 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 6868 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
6667 "(%d):2532 Mailbox command x%x (x%x) " 6869 "(%d):2532 Mailbox command x%x (x%x/x%x) "
6668 "cannot issue Data: x%x x%x\n", 6870 "cannot issue Data: x%x x%x\n",
6669 mboxq->vport ? mboxq->vport->vpi : 0, 6871 mboxq->vport ? mboxq->vport->vpi : 0,
6670 mboxq->u.mb.mbxCommand, 6872 mboxq->u.mb.mbxCommand,
6671 lpfc_sli4_mbox_opcode_get(phba, mboxq), 6873 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
6874 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
6672 psli->sli_flag, MBX_POLL); 6875 psli->sli_flag, MBX_POLL);
6673 return MBXERR_ERROR; 6876 return MBXERR_ERROR;
6674 } 6877 }
@@ -6691,7 +6894,7 @@ lpfc_sli4_post_sync_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
6691 dma_address = &phba->sli4_hba.bmbx.dma_address; 6894 dma_address = &phba->sli4_hba.bmbx.dma_address;
6692 writel(dma_address->addr_hi, phba->sli4_hba.BMBXregaddr); 6895 writel(dma_address->addr_hi, phba->sli4_hba.BMBXregaddr);
6693 6896
6694 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, mbx_cmnd) 6897 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, mboxq)
6695 * 1000) + jiffies; 6898 * 1000) + jiffies;
6696 do { 6899 do {
6697 bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr); 6900 bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr);
@@ -6707,7 +6910,7 @@ lpfc_sli4_post_sync_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
6707 6910
6708 /* Post the low mailbox dma address to the port. */ 6911 /* Post the low mailbox dma address to the port. */
6709 writel(dma_address->addr_lo, phba->sli4_hba.BMBXregaddr); 6912 writel(dma_address->addr_lo, phba->sli4_hba.BMBXregaddr);
6710 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, mbx_cmnd) 6913 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, mboxq)
6711 * 1000) + jiffies; 6914 * 1000) + jiffies;
6712 do { 6915 do {
6713 bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr); 6916 bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr);
@@ -6746,11 +6949,12 @@ lpfc_sli4_post_sync_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
6746 lpfc_sli4_swap_str(phba, mboxq); 6949 lpfc_sli4_swap_str(phba, mboxq);
6747 6950
6748 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 6951 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
6749 "(%d):0356 Mailbox cmd x%x (x%x) Status x%x " 6952 "(%d):0356 Mailbox cmd x%x (x%x/x%x) Status x%x "
6750 "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x x%x x%x" 6953 "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x x%x x%x"
6751 " x%x x%x CQ: x%x x%x x%x x%x\n", 6954 " x%x x%x CQ: x%x x%x x%x x%x\n",
6752 mboxq->vport ? mboxq->vport->vpi : 0, 6955 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd,
6753 mbx_cmnd, lpfc_sli4_mbox_opcode_get(phba, mboxq), 6956 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
6957 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
6754 bf_get(lpfc_mqe_status, mb), 6958 bf_get(lpfc_mqe_status, mb),
6755 mb->un.mb_words[0], mb->un.mb_words[1], 6959 mb->un.mb_words[0], mb->un.mb_words[1],
6756 mb->un.mb_words[2], mb->un.mb_words[3], 6960 mb->un.mb_words[2], mb->un.mb_words[3],
@@ -6796,11 +7000,12 @@ lpfc_sli_issue_mbox_s4(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
6796 rc = lpfc_mbox_dev_check(phba); 7000 rc = lpfc_mbox_dev_check(phba);
6797 if (unlikely(rc)) { 7001 if (unlikely(rc)) {
6798 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 7002 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
6799 "(%d):2544 Mailbox command x%x (x%x) " 7003 "(%d):2544 Mailbox command x%x (x%x/x%x) "
6800 "cannot issue Data: x%x x%x\n", 7004 "cannot issue Data: x%x x%x\n",
6801 mboxq->vport ? mboxq->vport->vpi : 0, 7005 mboxq->vport ? mboxq->vport->vpi : 0,
6802 mboxq->u.mb.mbxCommand, 7006 mboxq->u.mb.mbxCommand,
6803 lpfc_sli4_mbox_opcode_get(phba, mboxq), 7007 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
7008 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
6804 psli->sli_flag, flag); 7009 psli->sli_flag, flag);
6805 goto out_not_finished; 7010 goto out_not_finished;
6806 } 7011 }
@@ -6814,20 +7019,25 @@ lpfc_sli_issue_mbox_s4(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
6814 if (rc != MBX_SUCCESS) 7019 if (rc != MBX_SUCCESS)
6815 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | LOG_SLI, 7020 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | LOG_SLI,
6816 "(%d):2541 Mailbox command x%x " 7021 "(%d):2541 Mailbox command x%x "
6817 "(x%x) cannot issue Data: x%x x%x\n", 7022 "(x%x/x%x) cannot issue Data: "
7023 "x%x x%x\n",
6818 mboxq->vport ? mboxq->vport->vpi : 0, 7024 mboxq->vport ? mboxq->vport->vpi : 0,
6819 mboxq->u.mb.mbxCommand, 7025 mboxq->u.mb.mbxCommand,
6820 lpfc_sli4_mbox_opcode_get(phba, mboxq), 7026 lpfc_sli_config_mbox_subsys_get(phba,
7027 mboxq),
7028 lpfc_sli_config_mbox_opcode_get(phba,
7029 mboxq),
6821 psli->sli_flag, flag); 7030 psli->sli_flag, flag);
6822 return rc; 7031 return rc;
6823 } else if (flag == MBX_POLL) { 7032 } else if (flag == MBX_POLL) {
6824 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | LOG_SLI, 7033 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | LOG_SLI,
6825 "(%d):2542 Try to issue mailbox command " 7034 "(%d):2542 Try to issue mailbox command "
6826 "x%x (x%x) synchronously ahead of async" 7035 "x%x (x%x/x%x) synchronously ahead of async"
6827 "mailbox command queue: x%x x%x\n", 7036 "mailbox command queue: x%x x%x\n",
6828 mboxq->vport ? mboxq->vport->vpi : 0, 7037 mboxq->vport ? mboxq->vport->vpi : 0,
6829 mboxq->u.mb.mbxCommand, 7038 mboxq->u.mb.mbxCommand,
6830 lpfc_sli4_mbox_opcode_get(phba, mboxq), 7039 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
7040 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
6831 psli->sli_flag, flag); 7041 psli->sli_flag, flag);
6832 /* Try to block the asynchronous mailbox posting */ 7042 /* Try to block the asynchronous mailbox posting */
6833 rc = lpfc_sli4_async_mbox_block(phba); 7043 rc = lpfc_sli4_async_mbox_block(phba);
@@ -6836,16 +7046,18 @@ lpfc_sli_issue_mbox_s4(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
6836 rc = lpfc_sli4_post_sync_mbox(phba, mboxq); 7046 rc = lpfc_sli4_post_sync_mbox(phba, mboxq);
6837 if (rc != MBX_SUCCESS) 7047 if (rc != MBX_SUCCESS)
6838 lpfc_printf_log(phba, KERN_ERR, 7048 lpfc_printf_log(phba, KERN_ERR,
6839 LOG_MBOX | LOG_SLI, 7049 LOG_MBOX | LOG_SLI,
6840 "(%d):2597 Mailbox command " 7050 "(%d):2597 Mailbox command "
6841 "x%x (x%x) cannot issue " 7051 "x%x (x%x/x%x) cannot issue "
6842 "Data: x%x x%x\n", 7052 "Data: x%x x%x\n",
6843 mboxq->vport ? 7053 mboxq->vport ?
6844 mboxq->vport->vpi : 0, 7054 mboxq->vport->vpi : 0,
6845 mboxq->u.mb.mbxCommand, 7055 mboxq->u.mb.mbxCommand,
6846 lpfc_sli4_mbox_opcode_get(phba, 7056 lpfc_sli_config_mbox_subsys_get(phba,
6847 mboxq), 7057 mboxq),
6848 psli->sli_flag, flag); 7058 lpfc_sli_config_mbox_opcode_get(phba,
7059 mboxq),
7060 psli->sli_flag, flag);
6849 /* Unblock the async mailbox posting afterward */ 7061 /* Unblock the async mailbox posting afterward */
6850 lpfc_sli4_async_mbox_unblock(phba); 7062 lpfc_sli4_async_mbox_unblock(phba);
6851 } 7063 }
@@ -6856,11 +7068,12 @@ lpfc_sli_issue_mbox_s4(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
6856 rc = lpfc_mbox_cmd_check(phba, mboxq); 7068 rc = lpfc_mbox_cmd_check(phba, mboxq);
6857 if (rc) { 7069 if (rc) {
6858 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 7070 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
6859 "(%d):2543 Mailbox command x%x (x%x) " 7071 "(%d):2543 Mailbox command x%x (x%x/x%x) "
6860 "cannot issue Data: x%x x%x\n", 7072 "cannot issue Data: x%x x%x\n",
6861 mboxq->vport ? mboxq->vport->vpi : 0, 7073 mboxq->vport ? mboxq->vport->vpi : 0,
6862 mboxq->u.mb.mbxCommand, 7074 mboxq->u.mb.mbxCommand,
6863 lpfc_sli4_mbox_opcode_get(phba, mboxq), 7075 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
7076 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
6864 psli->sli_flag, flag); 7077 psli->sli_flag, flag);
6865 goto out_not_finished; 7078 goto out_not_finished;
6866 } 7079 }
@@ -6872,10 +7085,11 @@ lpfc_sli_issue_mbox_s4(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
6872 spin_unlock_irqrestore(&phba->hbalock, iflags); 7085 spin_unlock_irqrestore(&phba->hbalock, iflags);
6873 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 7086 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
6874 "(%d):0354 Mbox cmd issue - Enqueue Data: " 7087 "(%d):0354 Mbox cmd issue - Enqueue Data: "
6875 "x%x (x%x) x%x x%x x%x\n", 7088 "x%x (x%x/x%x) x%x x%x x%x\n",
6876 mboxq->vport ? mboxq->vport->vpi : 0xffffff, 7089 mboxq->vport ? mboxq->vport->vpi : 0xffffff,
6877 bf_get(lpfc_mqe_command, &mboxq->u.mqe), 7090 bf_get(lpfc_mqe_command, &mboxq->u.mqe),
6878 lpfc_sli4_mbox_opcode_get(phba, mboxq), 7091 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
7092 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
6879 phba->pport->port_state, 7093 phba->pport->port_state,
6880 psli->sli_flag, MBX_NOWAIT); 7094 psli->sli_flag, MBX_NOWAIT);
6881 /* Wake up worker thread to transport mailbox command from head */ 7095 /* Wake up worker thread to transport mailbox command from head */
@@ -6952,13 +7166,14 @@ lpfc_sli4_post_async_mbox(struct lpfc_hba *phba)
6952 7166
6953 /* Start timer for the mbox_tmo and log some mailbox post messages */ 7167 /* Start timer for the mbox_tmo and log some mailbox post messages */
6954 mod_timer(&psli->mbox_tmo, (jiffies + 7168 mod_timer(&psli->mbox_tmo, (jiffies +
6955 (HZ * lpfc_mbox_tmo_val(phba, mbx_cmnd)))); 7169 (HZ * lpfc_mbox_tmo_val(phba, mboxq))));
6956 7170
6957 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 7171 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
6958 "(%d):0355 Mailbox cmd x%x (x%x) issue Data: " 7172 "(%d):0355 Mailbox cmd x%x (x%x/x%x) issue Data: "
6959 "x%x x%x\n", 7173 "x%x x%x\n",
6960 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, 7174 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd,
6961 lpfc_sli4_mbox_opcode_get(phba, mboxq), 7175 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
7176 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
6962 phba->pport->port_state, psli->sli_flag); 7177 phba->pport->port_state, psli->sli_flag);
6963 7178
6964 if (mbx_cmnd != MBX_HEARTBEAT) { 7179 if (mbx_cmnd != MBX_HEARTBEAT) {
@@ -6982,11 +7197,12 @@ lpfc_sli4_post_async_mbox(struct lpfc_hba *phba)
6982 rc = lpfc_sli4_mq_put(phba->sli4_hba.mbx_wq, mqe); 7197 rc = lpfc_sli4_mq_put(phba->sli4_hba.mbx_wq, mqe);
6983 if (rc != MBX_SUCCESS) { 7198 if (rc != MBX_SUCCESS) {
6984 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 7199 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
6985 "(%d):2533 Mailbox command x%x (x%x) " 7200 "(%d):2533 Mailbox command x%x (x%x/x%x) "
6986 "cannot issue Data: x%x x%x\n", 7201 "cannot issue Data: x%x x%x\n",
6987 mboxq->vport ? mboxq->vport->vpi : 0, 7202 mboxq->vport ? mboxq->vport->vpi : 0,
6988 mboxq->u.mb.mbxCommand, 7203 mboxq->u.mb.mbxCommand,
6989 lpfc_sli4_mbox_opcode_get(phba, mboxq), 7204 lpfc_sli_config_mbox_subsys_get(phba, mboxq),
7205 lpfc_sli_config_mbox_opcode_get(phba, mboxq),
6990 psli->sli_flag, MBX_NOWAIT); 7206 psli->sli_flag, MBX_NOWAIT);
6991 goto out_not_finished; 7207 goto out_not_finished;
6992 } 7208 }
@@ -7322,6 +7538,8 @@ lpfc_sli4_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
7322 if (inbound == 1) 7538 if (inbound == 1)
7323 offset = 0; 7539 offset = 0;
7324 bf_set(lpfc_sli4_sge_offset, sgl, offset); 7540 bf_set(lpfc_sli4_sge_offset, sgl, offset);
7541 bf_set(lpfc_sli4_sge_type, sgl,
7542 LPFC_SGE_TYPE_DATA);
7325 offset += bde.tus.f.bdeSize; 7543 offset += bde.tus.f.bdeSize;
7326 } 7544 }
7327 sgl->word2 = cpu_to_le32(sgl->word2); 7545 sgl->word2 = cpu_to_le32(sgl->word2);
@@ -9359,7 +9577,6 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq,
9359 9577
9360 /* now issue the command */ 9578 /* now issue the command */
9361 retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT); 9579 retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
9362
9363 if (retval == MBX_BUSY || retval == MBX_SUCCESS) { 9580 if (retval == MBX_BUSY || retval == MBX_SUCCESS) {
9364 wait_event_interruptible_timeout(done_q, 9581 wait_event_interruptible_timeout(done_q,
9365 pmboxq->mbox_flag & LPFC_MBX_WAKE, 9582 pmboxq->mbox_flag & LPFC_MBX_WAKE,
@@ -9403,23 +9620,24 @@ void
9403lpfc_sli_mbox_sys_shutdown(struct lpfc_hba *phba) 9620lpfc_sli_mbox_sys_shutdown(struct lpfc_hba *phba)
9404{ 9621{
9405 struct lpfc_sli *psli = &phba->sli; 9622 struct lpfc_sli *psli = &phba->sli;
9406 uint8_t actcmd = MBX_HEARTBEAT;
9407 unsigned long timeout; 9623 unsigned long timeout;
9408 9624
9625 timeout = msecs_to_jiffies(LPFC_MBOX_TMO * 1000) + jiffies;
9409 spin_lock_irq(&phba->hbalock); 9626 spin_lock_irq(&phba->hbalock);
9410 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; 9627 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK;
9411 spin_unlock_irq(&phba->hbalock); 9628 spin_unlock_irq(&phba->hbalock);
9412 9629
9413 if (psli->sli_flag & LPFC_SLI_ACTIVE) { 9630 if (psli->sli_flag & LPFC_SLI_ACTIVE) {
9414 spin_lock_irq(&phba->hbalock); 9631 spin_lock_irq(&phba->hbalock);
9415 if (phba->sli.mbox_active)
9416 actcmd = phba->sli.mbox_active->u.mb.mbxCommand;
9417 spin_unlock_irq(&phba->hbalock);
9418 /* Determine how long we might wait for the active mailbox 9632 /* Determine how long we might wait for the active mailbox
9419 * command to be gracefully completed by firmware. 9633 * command to be gracefully completed by firmware.
9420 */ 9634 */
9421 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, actcmd) * 9635 if (phba->sli.mbox_active)
9422 1000) + jiffies; 9636 timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba,
9637 phba->sli.mbox_active) *
9638 1000) + jiffies;
9639 spin_unlock_irq(&phba->hbalock);
9640
9423 while (phba->sli.mbox_active) { 9641 while (phba->sli.mbox_active) {
9424 /* Check active mailbox complete status every 2ms */ 9642 /* Check active mailbox complete status every 2ms */
9425 msleep(2); 9643 msleep(2);
@@ -10415,12 +10633,17 @@ lpfc_sli4_sp_handle_mbox_event(struct lpfc_hba *phba, struct lpfc_mcqe *mcqe)
10415 /* Move mbox data to caller's mailbox region, do endian swapping */ 10633 /* Move mbox data to caller's mailbox region, do endian swapping */
10416 if (pmb->mbox_cmpl && mbox) 10634 if (pmb->mbox_cmpl && mbox)
10417 lpfc_sli_pcimem_bcopy(mbox, mqe, sizeof(struct lpfc_mqe)); 10635 lpfc_sli_pcimem_bcopy(mbox, mqe, sizeof(struct lpfc_mqe));
10418 /* Set the mailbox status with SLI4 range 0x4000 */
10419 mcqe_status = bf_get(lpfc_mcqe_status, mcqe);
10420 if (mcqe_status != MB_CQE_STATUS_SUCCESS)
10421 bf_set(lpfc_mqe_status, mqe,
10422 (LPFC_MBX_ERROR_RANGE | mcqe_status));
10423 10636
10637 /*
10638 * For mcqe errors, conditionally move a modified error code to
10639 * the mbox so that the error will not be missed.
10640 */
10641 mcqe_status = bf_get(lpfc_mcqe_status, mcqe);
10642 if (mcqe_status != MB_CQE_STATUS_SUCCESS) {
10643 if (bf_get(lpfc_mqe_status, mqe) == MBX_SUCCESS)
10644 bf_set(lpfc_mqe_status, mqe,
10645 (LPFC_MBX_ERROR_RANGE | mcqe_status));
10646 }
10424 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { 10647 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) {
10425 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; 10648 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG;
10426 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_MBOX_VPORT, 10649 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_MBOX_VPORT,
@@ -10796,7 +11019,7 @@ lpfc_sli4_sp_handle_eqe(struct lpfc_hba *phba, struct lpfc_eqe *eqe)
10796 case LPFC_MCQ: 11019 case LPFC_MCQ:
10797 while ((cqe = lpfc_sli4_cq_get(cq))) { 11020 while ((cqe = lpfc_sli4_cq_get(cq))) {
10798 workposted |= lpfc_sli4_sp_handle_mcqe(phba, cqe); 11021 workposted |= lpfc_sli4_sp_handle_mcqe(phba, cqe);
10799 if (!(++ecount % LPFC_GET_QE_REL_INT)) 11022 if (!(++ecount % cq->entry_repost))
10800 lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM); 11023 lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM);
10801 } 11024 }
10802 break; 11025 break;
@@ -10808,7 +11031,7 @@ lpfc_sli4_sp_handle_eqe(struct lpfc_hba *phba, struct lpfc_eqe *eqe)
10808 else 11031 else
10809 workposted |= lpfc_sli4_sp_handle_cqe(phba, cq, 11032 workposted |= lpfc_sli4_sp_handle_cqe(phba, cq,
10810 cqe); 11033 cqe);
10811 if (!(++ecount % LPFC_GET_QE_REL_INT)) 11034 if (!(++ecount % cq->entry_repost))
10812 lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM); 11035 lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM);
10813 } 11036 }
10814 break; 11037 break;
@@ -11040,7 +11263,7 @@ lpfc_sli4_fp_handle_eqe(struct lpfc_hba *phba, struct lpfc_eqe *eqe,
11040 /* Process all the entries to the CQ */ 11263 /* Process all the entries to the CQ */
11041 while ((cqe = lpfc_sli4_cq_get(cq))) { 11264 while ((cqe = lpfc_sli4_cq_get(cq))) {
11042 workposted |= lpfc_sli4_fp_handle_wcqe(phba, cq, cqe); 11265 workposted |= lpfc_sli4_fp_handle_wcqe(phba, cq, cqe);
11043 if (!(++ecount % LPFC_GET_QE_REL_INT)) 11266 if (!(++ecount % cq->entry_repost))
11044 lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM); 11267 lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM);
11045 } 11268 }
11046 11269
@@ -11110,6 +11333,8 @@ lpfc_sli4_sp_intr_handler(int irq, void *dev_id)
11110 11333
11111 /* Get to the EQ struct associated with this vector */ 11334 /* Get to the EQ struct associated with this vector */
11112 speq = phba->sli4_hba.sp_eq; 11335 speq = phba->sli4_hba.sp_eq;
11336 if (unlikely(!speq))
11337 return IRQ_NONE;
11113 11338
11114 /* Check device state for handling interrupt */ 11339 /* Check device state for handling interrupt */
11115 if (unlikely(lpfc_intr_state_check(phba))) { 11340 if (unlikely(lpfc_intr_state_check(phba))) {
@@ -11127,7 +11352,7 @@ lpfc_sli4_sp_intr_handler(int irq, void *dev_id)
11127 */ 11352 */
11128 while ((eqe = lpfc_sli4_eq_get(speq))) { 11353 while ((eqe = lpfc_sli4_eq_get(speq))) {
11129 lpfc_sli4_sp_handle_eqe(phba, eqe); 11354 lpfc_sli4_sp_handle_eqe(phba, eqe);
11130 if (!(++ecount % LPFC_GET_QE_REL_INT)) 11355 if (!(++ecount % speq->entry_repost))
11131 lpfc_sli4_eq_release(speq, LPFC_QUEUE_NOARM); 11356 lpfc_sli4_eq_release(speq, LPFC_QUEUE_NOARM);
11132 } 11357 }
11133 11358
@@ -11187,6 +11412,8 @@ lpfc_sli4_fp_intr_handler(int irq, void *dev_id)
11187 11412
11188 if (unlikely(!phba)) 11413 if (unlikely(!phba))
11189 return IRQ_NONE; 11414 return IRQ_NONE;
11415 if (unlikely(!phba->sli4_hba.fp_eq))
11416 return IRQ_NONE;
11190 11417
11191 /* Get to the EQ struct associated with this vector */ 11418 /* Get to the EQ struct associated with this vector */
11192 fpeq = phba->sli4_hba.fp_eq[fcp_eqidx]; 11419 fpeq = phba->sli4_hba.fp_eq[fcp_eqidx];
@@ -11207,7 +11434,7 @@ lpfc_sli4_fp_intr_handler(int irq, void *dev_id)
11207 */ 11434 */
11208 while ((eqe = lpfc_sli4_eq_get(fpeq))) { 11435 while ((eqe = lpfc_sli4_eq_get(fpeq))) {
11209 lpfc_sli4_fp_handle_eqe(phba, eqe, fcp_eqidx); 11436 lpfc_sli4_fp_handle_eqe(phba, eqe, fcp_eqidx);
11210 if (!(++ecount % LPFC_GET_QE_REL_INT)) 11437 if (!(++ecount % fpeq->entry_repost))
11211 lpfc_sli4_eq_release(fpeq, LPFC_QUEUE_NOARM); 11438 lpfc_sli4_eq_release(fpeq, LPFC_QUEUE_NOARM);
11212 } 11439 }
11213 11440
@@ -11359,6 +11586,15 @@ lpfc_sli4_queue_alloc(struct lpfc_hba *phba, uint32_t entry_size,
11359 } 11586 }
11360 queue->entry_size = entry_size; 11587 queue->entry_size = entry_size;
11361 queue->entry_count = entry_count; 11588 queue->entry_count = entry_count;
11589
11590 /*
11591 * entry_repost is calculated based on the number of entries in the
11592 * queue. This works out except for RQs. If buffers are NOT initially
11593 * posted for every RQE, entry_repost should be adjusted accordingly.
11594 */
11595 queue->entry_repost = (entry_count >> 3);
11596 if (queue->entry_repost < LPFC_QUEUE_MIN_REPOST)
11597 queue->entry_repost = LPFC_QUEUE_MIN_REPOST;
11362 queue->phba = phba; 11598 queue->phba = phba;
11363 11599
11364 return queue; 11600 return queue;
@@ -11924,6 +12160,31 @@ out:
11924} 12160}
11925 12161
11926/** 12162/**
12163 * lpfc_rq_adjust_repost - Adjust entry_repost for an RQ
12164 * @phba: HBA structure that indicates port to create a queue on.
12165 * @rq: The queue structure to use for the receive queue.
12166 * @qno: The associated HBQ number
12167 *
12168 *
12169 * For SLI4 we need to adjust the RQ repost value based on
12170 * the number of buffers that are initially posted to the RQ.
12171 */
12172void
12173lpfc_rq_adjust_repost(struct lpfc_hba *phba, struct lpfc_queue *rq, int qno)
12174{
12175 uint32_t cnt;
12176
12177 cnt = lpfc_hbq_defs[qno]->entry_count;
12178
12179 /* Recalc repost for RQs based on buffers initially posted */
12180 cnt = (cnt >> 3);
12181 if (cnt < LPFC_QUEUE_MIN_REPOST)
12182 cnt = LPFC_QUEUE_MIN_REPOST;
12183
12184 rq->entry_repost = cnt;
12185}
12186
12187/**
11927 * lpfc_rq_create - Create a Receive Queue on the HBA 12188 * lpfc_rq_create - Create a Receive Queue on the HBA
11928 * @phba: HBA structure that indicates port to create a queue on. 12189 * @phba: HBA structure that indicates port to create a queue on.
11929 * @hrq: The queue structure to use to create the header receive queue. 12190 * @hrq: The queue structure to use to create the header receive queue.
@@ -12489,7 +12750,7 @@ lpfc_sli4_post_sgl(struct lpfc_hba *phba,
12489 if (!phba->sli4_hba.intr_enable) 12750 if (!phba->sli4_hba.intr_enable)
12490 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 12751 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
12491 else { 12752 else {
12492 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 12753 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
12493 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 12754 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
12494 } 12755 }
12495 /* The IOCTL status is embedded in the mailbox subheader. */ 12756 /* The IOCTL status is embedded in the mailbox subheader. */
@@ -12704,7 +12965,7 @@ lpfc_sli4_post_els_sgl_list(struct lpfc_hba *phba)
12704 if (!phba->sli4_hba.intr_enable) 12965 if (!phba->sli4_hba.intr_enable)
12705 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 12966 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
12706 else { 12967 else {
12707 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 12968 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
12708 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 12969 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
12709 } 12970 }
12710 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr; 12971 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr;
@@ -12867,7 +13128,7 @@ lpfc_sli4_post_els_sgl_list_ext(struct lpfc_hba *phba)
12867 if (!phba->sli4_hba.intr_enable) 13128 if (!phba->sli4_hba.intr_enable)
12868 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 13129 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
12869 else { 13130 else {
12870 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 13131 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
12871 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 13132 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
12872 } 13133 }
12873 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr; 13134 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr;
@@ -12991,7 +13252,7 @@ lpfc_sli4_post_scsi_sgl_block(struct lpfc_hba *phba, struct list_head *sblist,
12991 if (!phba->sli4_hba.intr_enable) 13252 if (!phba->sli4_hba.intr_enable)
12992 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 13253 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
12993 else { 13254 else {
12994 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 13255 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
12995 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 13256 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
12996 } 13257 }
12997 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr; 13258 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr;
@@ -13147,7 +13408,7 @@ lpfc_sli4_post_scsi_sgl_blk_ext(struct lpfc_hba *phba, struct list_head *sblist,
13147 if (!phba->sli4_hba.intr_enable) 13408 if (!phba->sli4_hba.intr_enable)
13148 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 13409 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
13149 else { 13410 else {
13150 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 13411 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
13151 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 13412 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
13152 } 13413 }
13153 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr; 13414 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr;
@@ -13296,7 +13557,8 @@ lpfc_fc_frame_to_vport(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr,
13296 uint32_t did = (fc_hdr->fh_d_id[0] << 16 | 13557 uint32_t did = (fc_hdr->fh_d_id[0] << 16 |
13297 fc_hdr->fh_d_id[1] << 8 | 13558 fc_hdr->fh_d_id[1] << 8 |
13298 fc_hdr->fh_d_id[2]); 13559 fc_hdr->fh_d_id[2]);
13299 13560 if (did == Fabric_DID)
13561 return phba->pport;
13300 vports = lpfc_create_vport_work_array(phba); 13562 vports = lpfc_create_vport_work_array(phba);
13301 if (vports != NULL) 13563 if (vports != NULL)
13302 for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { 13564 for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) {
@@ -14312,7 +14574,7 @@ lpfc_sli4_init_vpi(struct lpfc_vport *vport)
14312 if (!mboxq) 14574 if (!mboxq)
14313 return -ENOMEM; 14575 return -ENOMEM;
14314 lpfc_init_vpi(phba, mboxq, vport->vpi); 14576 lpfc_init_vpi(phba, mboxq, vport->vpi);
14315 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_INIT_VPI); 14577 mbox_tmo = lpfc_mbox_tmo_val(phba, mboxq);
14316 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo); 14578 rc = lpfc_sli_issue_mbox_wait(phba, mboxq, mbox_tmo);
14317 if (rc != MBX_SUCCESS) { 14579 if (rc != MBX_SUCCESS) {
14318 lpfc_printf_vlog(vport, KERN_ERR, LOG_SLI, 14580 lpfc_printf_vlog(vport, KERN_ERR, LOG_SLI,
@@ -15188,7 +15450,7 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list,
15188 if (!phba->sli4_hba.intr_enable) 15450 if (!phba->sli4_hba.intr_enable)
15189 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); 15451 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
15190 else { 15452 else {
15191 mbox_tmo = lpfc_mbox_tmo_val(phba, MBX_SLI4_CONFIG); 15453 mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
15192 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo); 15454 rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
15193 } 15455 }
15194 /* The IOCTL status is embedded in the mailbox subheader. */ 15456 /* The IOCTL status is embedded in the mailbox subheader. */
diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h
index a0075b0af14..29c13b63e32 100644
--- a/drivers/scsi/lpfc/lpfc_sli.h
+++ b/drivers/scsi/lpfc/lpfc_sli.h
@@ -293,13 +293,11 @@ struct lpfc_sli {
293 struct lpfc_lnk_stat lnk_stat_offsets; 293 struct lpfc_lnk_stat lnk_stat_offsets;
294}; 294};
295 295
296#define LPFC_MBOX_TMO 30 /* Sec tmo for outstanding mbox 296/* Timeout for normal outstanding mbox command (Seconds) */
297 command */ 297#define LPFC_MBOX_TMO 30
298#define LPFC_MBOX_SLI4_CONFIG_TMO 60 /* Sec tmo for outstanding mbox 298/* Timeout for non-flash-based outstanding sli_config mbox command (Seconds) */
299 command */ 299#define LPFC_MBOX_SLI4_CONFIG_TMO 60
300#define LPFC_MBOX_TMO_FLASH_CMD 300 /* Sec tmo for outstanding FLASH write 300/* Timeout for flash-based outstanding sli_config mbox command (Seconds) */
301 * or erase cmds. This is especially 301#define LPFC_MBOX_SLI4_CONFIG_EXTENDED_TMO 300
302 * long because of the potential of 302/* Timeout for other flash-based outstanding mbox command (Seconds) */
303 * multiple flash erases that can be 303#define LPFC_MBOX_TMO_FLASH_CMD 300
304 * spawned.
305 */
diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h
index 19bb87ae859..d5cffd8af34 100644
--- a/drivers/scsi/lpfc/lpfc_sli4.h
+++ b/drivers/scsi/lpfc/lpfc_sli4.h
@@ -23,7 +23,6 @@
23#define LPFC_XRI_EXCH_BUSY_WAIT_T1 10 23#define LPFC_XRI_EXCH_BUSY_WAIT_T1 10
24#define LPFC_XRI_EXCH_BUSY_WAIT_T2 30000 24#define LPFC_XRI_EXCH_BUSY_WAIT_T2 30000
25#define LPFC_RELEASE_NOTIFICATION_INTERVAL 32 25#define LPFC_RELEASE_NOTIFICATION_INTERVAL 32
26#define LPFC_GET_QE_REL_INT 32
27#define LPFC_RPI_LOW_WATER_MARK 10 26#define LPFC_RPI_LOW_WATER_MARK 10
28 27
29#define LPFC_UNREG_FCF 1 28#define LPFC_UNREG_FCF 1
@@ -126,6 +125,8 @@ struct lpfc_queue {
126 struct list_head child_list; 125 struct list_head child_list;
127 uint32_t entry_count; /* Number of entries to support on the queue */ 126 uint32_t entry_count; /* Number of entries to support on the queue */
128 uint32_t entry_size; /* Size of each queue entry. */ 127 uint32_t entry_size; /* Size of each queue entry. */
128 uint32_t entry_repost; /* Count of entries before doorbell is rung */
129#define LPFC_QUEUE_MIN_REPOST 8
129 uint32_t queue_id; /* Queue ID assigned by the hardware */ 130 uint32_t queue_id; /* Queue ID assigned by the hardware */
130 uint32_t assoc_qid; /* Queue ID associated with, for CQ/WQ/MQ */ 131 uint32_t assoc_qid; /* Queue ID associated with, for CQ/WQ/MQ */
131 struct list_head page_list; 132 struct list_head page_list;
@@ -388,6 +389,16 @@ struct lpfc_iov {
388 uint32_t vf_number; 389 uint32_t vf_number;
389}; 390};
390 391
392struct lpfc_sli4_lnk_info {
393 uint8_t lnk_dv;
394#define LPFC_LNK_DAT_INVAL 0
395#define LPFC_LNK_DAT_VAL 1
396 uint8_t lnk_tp;
397#define LPFC_LNK_GE 0x0 /* FCoE */
398#define LPFC_LNK_FC 0x1 /* FC */
399 uint8_t lnk_no;
400};
401
391/* SLI4 HBA data structure entries */ 402/* SLI4 HBA data structure entries */
392struct lpfc_sli4_hba { 403struct lpfc_sli4_hba {
393 void __iomem *conf_regs_memmap_p; /* Kernel memory mapped address for 404 void __iomem *conf_regs_memmap_p; /* Kernel memory mapped address for
@@ -503,6 +514,10 @@ struct lpfc_sli4_hba {
503 struct list_head sp_els_xri_aborted_work_queue; 514 struct list_head sp_els_xri_aborted_work_queue;
504 struct list_head sp_unsol_work_queue; 515 struct list_head sp_unsol_work_queue;
505 struct lpfc_sli4_link link_state; 516 struct lpfc_sli4_link link_state;
517 struct lpfc_sli4_lnk_info lnk_info;
518 uint32_t pport_name_sta;
519#define LPFC_SLI4_PPNAME_NON 0
520#define LPFC_SLI4_PPNAME_GET 1
506 struct lpfc_iov iov; 521 struct lpfc_iov iov;
507 spinlock_t abts_scsi_buf_list_lock; /* list of aborted SCSI IOs */ 522 spinlock_t abts_scsi_buf_list_lock; /* list of aborted SCSI IOs */
508 spinlock_t abts_sgl_list_lock; /* list of aborted els IOs */ 523 spinlock_t abts_sgl_list_lock; /* list of aborted els IOs */
@@ -553,6 +568,7 @@ struct lpfc_rsrc_blks {
553 * SLI4 specific function prototypes 568 * SLI4 specific function prototypes
554 */ 569 */
555int lpfc_pci_function_reset(struct lpfc_hba *); 570int lpfc_pci_function_reset(struct lpfc_hba *);
571int lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *);
556int lpfc_sli4_hba_setup(struct lpfc_hba *); 572int lpfc_sli4_hba_setup(struct lpfc_hba *);
557int lpfc_sli4_config(struct lpfc_hba *, struct lpfcMboxq *, uint8_t, 573int lpfc_sli4_config(struct lpfc_hba *, struct lpfcMboxq *, uint8_t,
558 uint8_t, uint32_t, bool); 574 uint8_t, uint32_t, bool);
@@ -576,6 +592,7 @@ uint32_t lpfc_wq_create(struct lpfc_hba *, struct lpfc_queue *,
576 struct lpfc_queue *, uint32_t); 592 struct lpfc_queue *, uint32_t);
577uint32_t lpfc_rq_create(struct lpfc_hba *, struct lpfc_queue *, 593uint32_t lpfc_rq_create(struct lpfc_hba *, struct lpfc_queue *,
578 struct lpfc_queue *, struct lpfc_queue *, uint32_t); 594 struct lpfc_queue *, struct lpfc_queue *, uint32_t);
595void lpfc_rq_adjust_repost(struct lpfc_hba *, struct lpfc_queue *, int);
579uint32_t lpfc_eq_destroy(struct lpfc_hba *, struct lpfc_queue *); 596uint32_t lpfc_eq_destroy(struct lpfc_hba *, struct lpfc_queue *);
580uint32_t lpfc_cq_destroy(struct lpfc_hba *, struct lpfc_queue *); 597uint32_t lpfc_cq_destroy(struct lpfc_hba *, struct lpfc_queue *);
581uint32_t lpfc_mq_destroy(struct lpfc_hba *, struct lpfc_queue *); 598uint32_t lpfc_mq_destroy(struct lpfc_hba *, struct lpfc_queue *);
@@ -632,5 +649,5 @@ void lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
632void lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *); 649void lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
633int lpfc_sli4_unregister_fcf(struct lpfc_hba *); 650int lpfc_sli4_unregister_fcf(struct lpfc_hba *);
634int lpfc_sli4_post_status_check(struct lpfc_hba *); 651int lpfc_sli4_post_status_check(struct lpfc_hba *);
635uint8_t lpfc_sli4_mbox_opcode_get(struct lpfc_hba *, struct lpfcMboxq *); 652uint8_t lpfc_sli_config_mbox_subsys_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
636 653uint8_t lpfc_sli_config_mbox_opcode_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index c1e0ae94d9f..b0630e37f1e 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -18,7 +18,7 @@
18 * included with this package. * 18 * included with this package. *
19 *******************************************************************/ 19 *******************************************************************/
20 20
21#define LPFC_DRIVER_VERSION "8.3.25" 21#define LPFC_DRIVER_VERSION "8.3.27"
22#define LPFC_DRIVER_NAME "lpfc" 22#define LPFC_DRIVER_NAME "lpfc"
23#define LPFC_SP_DRIVER_HANDLER_NAME "lpfc:sp" 23#define LPFC_SP_DRIVER_HANDLER_NAME "lpfc:sp"
24#define LPFC_FP_DRIVER_HANDLER_NAME "lpfc:fp" 24#define LPFC_FP_DRIVER_HANDLER_NAME "lpfc:fp"
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c
index 1feb551a57b..cff6ca67415 100644
--- a/drivers/scsi/lpfc/lpfc_vport.c
+++ b/drivers/scsi/lpfc/lpfc_vport.c
@@ -692,13 +692,14 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
692 /* Indicate free memory when release */ 692 /* Indicate free memory when release */
693 NLP_SET_FREE_REQ(ndlp); 693 NLP_SET_FREE_REQ(ndlp);
694 } else { 694 } else {
695 if (!NLP_CHK_NODE_ACT(ndlp)) 695 if (!NLP_CHK_NODE_ACT(ndlp)) {
696 ndlp = lpfc_enable_node(vport, ndlp, 696 ndlp = lpfc_enable_node(vport, ndlp,
697 NLP_STE_UNUSED_NODE); 697 NLP_STE_UNUSED_NODE);
698 if (!ndlp) 698 if (!ndlp)
699 goto skip_logo; 699 goto skip_logo;
700 }
700 701
701 /* Remove ndlp from vport npld list */ 702 /* Remove ndlp from vport list */
702 lpfc_dequeue_node(vport, ndlp); 703 lpfc_dequeue_node(vport, ndlp);
703 spin_lock_irq(&phba->ndlp_lock); 704 spin_lock_irq(&phba->ndlp_lock);
704 if (!NLP_CHK_FREE_REQ(ndlp)) 705 if (!NLP_CHK_FREE_REQ(ndlp))
@@ -711,8 +712,17 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
711 } 712 }
712 spin_unlock_irq(&phba->ndlp_lock); 713 spin_unlock_irq(&phba->ndlp_lock);
713 } 714 }
714 if (!(vport->vpi_state & LPFC_VPI_REGISTERED)) 715
716 /*
717 * If the vpi is not registered, then a valid FDISC doesn't
718 * exist and there is no need for a ELS LOGO. Just cleanup
719 * the ndlp.
720 */
721 if (!(vport->vpi_state & LPFC_VPI_REGISTERED)) {
722 lpfc_nlp_put(ndlp);
715 goto skip_logo; 723 goto skip_logo;
724 }
725
716 vport->unreg_vpi_cmpl = VPORT_INVAL; 726 vport->unreg_vpi_cmpl = VPORT_INVAL;
717 timeout = msecs_to_jiffies(phba->fc_ratov * 2000); 727 timeout = msecs_to_jiffies(phba->fc_ratov * 2000);
718 if (!lpfc_issue_els_npiv_logo(vport, ndlp)) 728 if (!lpfc_issue_els_npiv_logo(vport, ndlp))