aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc')
-rw-r--r--drivers/scsi/lpfc/Makefile2
-rw-r--r--drivers/scsi/lpfc/lpfc.h4
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c93
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h4
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.h18
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_hw4.h45
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c233
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c32
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c131
-rw-r--r--drivers/scsi/lpfc/lpfc_sli4.h1
-rw-r--r--drivers/scsi/lpfc/lpfc_version.h2
12 files changed, 463 insertions, 104 deletions
diff --git a/drivers/scsi/lpfc/Makefile b/drivers/scsi/lpfc/Makefile
index fe5d396aca73..e2516ba8ebfa 100644
--- a/drivers/scsi/lpfc/Makefile
+++ b/drivers/scsi/lpfc/Makefile
@@ -22,7 +22,9 @@
22ccflags-$(GCOV) := -fprofile-arcs -ftest-coverage 22ccflags-$(GCOV) := -fprofile-arcs -ftest-coverage
23ccflags-$(GCOV) += -O0 23ccflags-$(GCOV) += -O0
24 24
25ifdef WARNINGS_BECOME_ERRORS
25ccflags-y += -Werror 26ccflags-y += -Werror
27endif
26 28
27obj-$(CONFIG_SCSI_LPFC) := lpfc.o 29obj-$(CONFIG_SCSI_LPFC) := lpfc.o
28 30
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index e5da6da20f8a..a65c05a8d488 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -96,6 +96,10 @@ struct lpfc_sli2_slim;
96/* queue dump line buffer size */ 96/* queue dump line buffer size */
97#define LPFC_LBUF_SZ 128 97#define LPFC_LBUF_SZ 128
98 98
99/* mailbox system shutdown options */
100#define LPFC_MBX_NO_WAIT 0
101#define LPFC_MBX_WAIT 1
102
99enum lpfc_polling_flags { 103enum lpfc_polling_flags {
100 ENABLE_FCP_RING_POLLING = 0x1, 104 ENABLE_FCP_RING_POLLING = 0x1,
101 DISABLE_FCP_RING_INT = 0x2 105 DISABLE_FCP_RING_INT = 0x2
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 5eb2bc116183..adef5bb2100e 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -3617,6 +3617,91 @@ lpfc_sriov_nr_virtfn_init(struct lpfc_hba *phba, int val)
3617static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR, 3617static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR,
3618 lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store); 3618 lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store);
3619 3619
3620/**
3621 * lpfc_fcp_imax_store
3622 *
3623 * @dev: class device that is converted into a Scsi_host.
3624 * @attr: device attribute, not used.
3625 * @buf: string with the number of fast-path FCP interrupts per second.
3626 * @count: unused variable.
3627 *
3628 * Description:
3629 * If val is in a valid range [636,651042], then set the adapter's
3630 * maximum number of fast-path FCP interrupts per second.
3631 *
3632 * Returns:
3633 * length of the buf on success if val is in range the intended mode
3634 * is supported.
3635 * -EINVAL if val out of range or intended mode is not supported.
3636 **/
3637static ssize_t
3638lpfc_fcp_imax_store(struct device *dev, struct device_attribute *attr,
3639 const char *buf, size_t count)
3640{
3641 struct Scsi_Host *shost = class_to_shost(dev);
3642 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
3643 struct lpfc_hba *phba = vport->phba;
3644 int val = 0, i;
3645
3646 /* Sanity check on user data */
3647 if (!isdigit(buf[0]))
3648 return -EINVAL;
3649 if (sscanf(buf, "%i", &val) != 1)
3650 return -EINVAL;
3651
3652 /* Value range is [636,651042] */
3653 if (val < LPFC_MIM_IMAX || val > LPFC_DMULT_CONST)
3654 return -EINVAL;
3655
3656 phba->cfg_fcp_imax = (uint32_t)val;
3657 for (i = 0; i < phba->cfg_fcp_eq_count; i += LPFC_MAX_EQ_DELAY)
3658 lpfc_modify_fcp_eq_delay(phba, i);
3659
3660 return strlen(buf);
3661}
3662
3663/*
3664# lpfc_fcp_imax: The maximum number of fast-path FCP interrupts per second
3665#
3666# Value range is [636,651042]. Default value is 10000.
3667*/
3668static int lpfc_fcp_imax = LPFC_FP_DEF_IMAX;
3669module_param(lpfc_fcp_imax, int, S_IRUGO|S_IWUSR);
3670MODULE_PARM_DESC(lpfc_fcp_imax,
3671 "Set the maximum number of fast-path FCP interrupts per second");
3672lpfc_param_show(fcp_imax)
3673
3674/**
3675 * lpfc_fcp_imax_init - Set the initial sr-iov virtual function enable
3676 * @phba: lpfc_hba pointer.
3677 * @val: link speed value.
3678 *
3679 * Description:
3680 * If val is in a valid range [636,651042], then initialize the adapter's
3681 * maximum number of fast-path FCP interrupts per second.
3682 *
3683 * Returns:
3684 * zero if val saved.
3685 * -EINVAL val out of range
3686 **/
3687static int
3688lpfc_fcp_imax_init(struct lpfc_hba *phba, int val)
3689{
3690 if (val >= LPFC_MIM_IMAX && val <= LPFC_DMULT_CONST) {
3691 phba->cfg_fcp_imax = val;
3692 return 0;
3693 }
3694
3695 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3696 "3016 fcp_imax: %d out of range, using default\n", val);
3697 phba->cfg_fcp_imax = LPFC_FP_DEF_IMAX;
3698
3699 return 0;
3700}
3701
3702static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR,
3703 lpfc_fcp_imax_show, lpfc_fcp_imax_store);
3704
3620/* 3705/*
3621# lpfc_fcp_class: Determines FC class to use for the FCP protocol. 3706# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
3622# Value range is [2,3]. Default value is 3. 3707# Value range is [2,3]. Default value is 3.
@@ -3758,14 +3843,6 @@ LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
3758 "MSI-X (2), if possible"); 3843 "MSI-X (2), if possible");
3759 3844
3760/* 3845/*
3761# lpfc_fcp_imax: Set the maximum number of fast-path FCP interrupts per second
3762#
3763# Value range is [636,651042]. Default value is 10000.
3764*/
3765LPFC_ATTR_R(fcp_imax, LPFC_FP_DEF_IMAX, LPFC_MIM_IMAX, LPFC_DMULT_CONST,
3766 "Set the maximum number of fast-path FCP interrupts per second");
3767
3768/*
3769# lpfc_fcp_wq_count: Set the number of fast-path FCP work queues 3846# lpfc_fcp_wq_count: Set the number of fast-path FCP work queues
3770# 3847#
3771# Value range is [1,31]. Default value is 4. 3848# Value range is [1,31]. Default value is 4.
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 9b2a16f3bc79..8a2a514a2553 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -183,7 +183,7 @@ int lpfc_post_buffer(struct lpfc_hba *, struct lpfc_sli_ring *, int);
183void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int); 183void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int);
184int lpfc_online(struct lpfc_hba *); 184int lpfc_online(struct lpfc_hba *);
185void lpfc_unblock_mgmt_io(struct lpfc_hba *); 185void lpfc_unblock_mgmt_io(struct lpfc_hba *);
186void lpfc_offline_prep(struct lpfc_hba *); 186void lpfc_offline_prep(struct lpfc_hba *, int);
187void lpfc_offline(struct lpfc_hba *); 187void lpfc_offline(struct lpfc_hba *);
188void lpfc_reset_hba(struct lpfc_hba *); 188void lpfc_reset_hba(struct lpfc_hba *);
189 189
@@ -273,7 +273,7 @@ int lpfc_sli_host_down(struct lpfc_vport *);
273int lpfc_sli_hba_down(struct lpfc_hba *); 273int lpfc_sli_hba_down(struct lpfc_hba *);
274int lpfc_sli_issue_mbox(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t); 274int lpfc_sli_issue_mbox(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
275int lpfc_sli_handle_mb_event(struct lpfc_hba *); 275int lpfc_sli_handle_mb_event(struct lpfc_hba *);
276void lpfc_sli_mbox_sys_shutdown(struct lpfc_hba *); 276void lpfc_sli_mbox_sys_shutdown(struct lpfc_hba *, int);
277int lpfc_sli_check_eratt(struct lpfc_hba *); 277int lpfc_sli_check_eratt(struct lpfc_hba *);
278void lpfc_sli_handle_slow_ring_event(struct lpfc_hba *, 278void lpfc_sli_handle_slow_ring_event(struct lpfc_hba *,
279 struct lpfc_sli_ring *, uint32_t); 279 struct lpfc_sli_ring *, uint32_t);
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h
index 616c400dae14..afe368fd1b98 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.h
+++ b/drivers/scsi/lpfc/lpfc_debugfs.h
@@ -395,8 +395,13 @@ lpfc_debug_dump_fcp_cq(struct lpfc_hba *phba, int fcp_wqidx)
395 for (fcp_cqidx = 0; fcp_cqidx < phba->cfg_fcp_eq_count; fcp_cqidx++) 395 for (fcp_cqidx = 0; fcp_cqidx < phba->cfg_fcp_eq_count; fcp_cqidx++)
396 if (phba->sli4_hba.fcp_cq[fcp_cqidx]->queue_id == fcp_cqid) 396 if (phba->sli4_hba.fcp_cq[fcp_cqidx]->queue_id == fcp_cqid)
397 break; 397 break;
398 if (fcp_cqidx >= phba->cfg_fcp_eq_count) 398 if (phba->intr_type == MSIX) {
399 return; 399 if (fcp_cqidx >= phba->cfg_fcp_eq_count)
400 return;
401 } else {
402 if (fcp_cqidx > 0)
403 return;
404 }
400 405
401 printk(KERN_ERR "FCP CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]:\n", 406 printk(KERN_ERR "FCP CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]:\n",
402 fcp_wqidx, phba->sli4_hba.fcp_wq[fcp_wqidx]->queue_id, 407 fcp_wqidx, phba->sli4_hba.fcp_wq[fcp_wqidx]->queue_id,
@@ -426,8 +431,13 @@ lpfc_debug_dump_fcp_eq(struct lpfc_hba *phba, int fcp_wqidx)
426 for (fcp_cqidx = 0; fcp_cqidx < phba->cfg_fcp_eq_count; fcp_cqidx++) 431 for (fcp_cqidx = 0; fcp_cqidx < phba->cfg_fcp_eq_count; fcp_cqidx++)
427 if (phba->sli4_hba.fcp_cq[fcp_cqidx]->queue_id == fcp_cqid) 432 if (phba->sli4_hba.fcp_cq[fcp_cqidx]->queue_id == fcp_cqid)
428 break; 433 break;
429 if (fcp_cqidx >= phba->cfg_fcp_eq_count) 434 if (phba->intr_type == MSIX) {
430 return; 435 if (fcp_cqidx >= phba->cfg_fcp_eq_count)
436 return;
437 } else {
438 if (fcp_cqidx > 0)
439 return;
440 }
431 441
432 if (phba->cfg_fcp_eq_count == 0) { 442 if (phba->cfg_fcp_eq_count == 0) {
433 fcp_eqidx = -1; 443 fcp_eqidx = -1;
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 5bb269e224f6..9b4f92941dce 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -530,7 +530,7 @@ lpfc_work_list_done(struct lpfc_hba *phba)
530 break; 530 break;
531 case LPFC_EVT_OFFLINE_PREP: 531 case LPFC_EVT_OFFLINE_PREP:
532 if (phba->link_state >= LPFC_LINK_DOWN) 532 if (phba->link_state >= LPFC_LINK_DOWN)
533 lpfc_offline_prep(phba); 533 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
534 *(int *)(evtp->evt_arg1) = 0; 534 *(int *)(evtp->evt_arg1) = 0;
535 complete((struct completion *)(evtp->evt_arg2)); 535 complete((struct completion *)(evtp->evt_arg2));
536 break; 536 break;
diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index f1946dfda5b4..953603a7a43c 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -874,6 +874,7 @@ struct mbox_header {
874#define LPFC_MBOX_OPCODE_MQ_CREATE 0x15 874#define LPFC_MBOX_OPCODE_MQ_CREATE 0x15
875#define LPFC_MBOX_OPCODE_GET_CNTL_ATTRIBUTES 0x20 875#define LPFC_MBOX_OPCODE_GET_CNTL_ATTRIBUTES 0x20
876#define LPFC_MBOX_OPCODE_NOP 0x21 876#define LPFC_MBOX_OPCODE_NOP 0x21
877#define LPFC_MBOX_OPCODE_MODIFY_EQ_DELAY 0x29
877#define LPFC_MBOX_OPCODE_MQ_DESTROY 0x35 878#define LPFC_MBOX_OPCODE_MQ_DESTROY 0x35
878#define LPFC_MBOX_OPCODE_CQ_DESTROY 0x36 879#define LPFC_MBOX_OPCODE_CQ_DESTROY 0x36
879#define LPFC_MBOX_OPCODE_EQ_DESTROY 0x37 880#define LPFC_MBOX_OPCODE_EQ_DESTROY 0x37
@@ -940,6 +941,13 @@ struct eq_context {
940 uint32_t reserved3; 941 uint32_t reserved3;
941}; 942};
942 943
944struct eq_delay_info {
945 uint32_t eq_id;
946 uint32_t phase;
947 uint32_t delay_multi;
948};
949#define LPFC_MAX_EQ_DELAY 8
950
943struct sgl_page_pairs { 951struct sgl_page_pairs {
944 uint32_t sgl_pg0_addr_lo; 952 uint32_t sgl_pg0_addr_lo;
945 uint32_t sgl_pg0_addr_hi; 953 uint32_t sgl_pg0_addr_hi;
@@ -1002,6 +1010,19 @@ struct lpfc_mbx_eq_create {
1002 } u; 1010 } u;
1003}; 1011};
1004 1012
1013struct lpfc_mbx_modify_eq_delay {
1014 struct mbox_header header;
1015 union {
1016 struct {
1017 uint32_t num_eq;
1018 struct eq_delay_info eq[LPFC_MAX_EQ_DELAY];
1019 } request;
1020 struct {
1021 uint32_t word0;
1022 } response;
1023 } u;
1024};
1025
1005struct lpfc_mbx_eq_destroy { 1026struct lpfc_mbx_eq_destroy {
1006 struct mbox_header header; 1027 struct mbox_header header;
1007 union { 1028 union {
@@ -2875,6 +2896,7 @@ struct lpfc_mqe {
2875 struct lpfc_mbx_mq_create mq_create; 2896 struct lpfc_mbx_mq_create mq_create;
2876 struct lpfc_mbx_mq_create_ext mq_create_ext; 2897 struct lpfc_mbx_mq_create_ext mq_create_ext;
2877 struct lpfc_mbx_eq_create eq_create; 2898 struct lpfc_mbx_eq_create eq_create;
2899 struct lpfc_mbx_modify_eq_delay eq_delay;
2878 struct lpfc_mbx_cq_create cq_create; 2900 struct lpfc_mbx_cq_create cq_create;
2879 struct lpfc_mbx_wq_create wq_create; 2901 struct lpfc_mbx_wq_create wq_create;
2880 struct lpfc_mbx_rq_create rq_create; 2902 struct lpfc_mbx_rq_create rq_create;
@@ -3084,6 +3106,28 @@ struct lpfc_acqe_fc_la {
3084#define LPFC_FC_LA_EVENT_TYPE_SHARED_LINK 0x2 3106#define LPFC_FC_LA_EVENT_TYPE_SHARED_LINK 0x2
3085}; 3107};
3086 3108
3109struct lpfc_acqe_misconfigured_event {
3110 struct {
3111 uint32_t word0;
3112#define lpfc_sli_misconfigured_port0_SHIFT 0
3113#define lpfc_sli_misconfigured_port0_MASK 0x000000FF
3114#define lpfc_sli_misconfigured_port0_WORD word0
3115#define lpfc_sli_misconfigured_port1_SHIFT 8
3116#define lpfc_sli_misconfigured_port1_MASK 0x000000FF
3117#define lpfc_sli_misconfigured_port1_WORD word0
3118#define lpfc_sli_misconfigured_port2_SHIFT 16
3119#define lpfc_sli_misconfigured_port2_MASK 0x000000FF
3120#define lpfc_sli_misconfigured_port2_WORD word0
3121#define lpfc_sli_misconfigured_port3_SHIFT 24
3122#define lpfc_sli_misconfigured_port3_MASK 0x000000FF
3123#define lpfc_sli_misconfigured_port3_WORD word0
3124 } theEvent;
3125#define LPFC_SLI_EVENT_STATUS_VALID 0x00
3126#define LPFC_SLI_EVENT_STATUS_NOT_PRESENT 0x01
3127#define LPFC_SLI_EVENT_STATUS_WRONG_TYPE 0x02
3128#define LPFC_SLI_EVENT_STATUS_UNSUPPORTED 0x03
3129};
3130
3087struct lpfc_acqe_sli { 3131struct lpfc_acqe_sli {
3088 uint32_t event_data1; 3132 uint32_t event_data1;
3089 uint32_t event_data2; 3133 uint32_t event_data2;
@@ -3094,6 +3138,7 @@ struct lpfc_acqe_sli {
3094#define LPFC_SLI_EVENT_TYPE_NORM_TEMP 0x3 3138#define LPFC_SLI_EVENT_TYPE_NORM_TEMP 0x3
3095#define LPFC_SLI_EVENT_TYPE_NVLOG_POST 0x4 3139#define LPFC_SLI_EVENT_TYPE_NVLOG_POST 0x4
3096#define LPFC_SLI_EVENT_TYPE_DIAG_DUMP 0x5 3140#define LPFC_SLI_EVENT_TYPE_DIAG_DUMP 0x5
3141#define LPFC_SLI_EVENT_TYPE_MISCONFIGURED 0x9
3097}; 3142};
3098 3143
3099/* 3144/*
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 411ed48d79da..45c15208be9f 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -73,6 +73,8 @@ static int lpfc_hba_down_post_s4(struct lpfc_hba *phba);
73static int lpfc_sli4_cq_event_pool_create(struct lpfc_hba *); 73static int lpfc_sli4_cq_event_pool_create(struct lpfc_hba *);
74static void lpfc_sli4_cq_event_pool_destroy(struct lpfc_hba *); 74static void lpfc_sli4_cq_event_pool_destroy(struct lpfc_hba *);
75static void lpfc_sli4_cq_event_release_all(struct lpfc_hba *); 75static void lpfc_sli4_cq_event_release_all(struct lpfc_hba *);
76static void lpfc_sli4_disable_intr(struct lpfc_hba *);
77static uint32_t lpfc_sli4_enable_intr(struct lpfc_hba *, uint32_t);
76 78
77static struct scsi_transport_template *lpfc_transport_template = NULL; 79static struct scsi_transport_template *lpfc_transport_template = NULL;
78static struct scsi_transport_template *lpfc_vport_transport_template = NULL; 80static struct scsi_transport_template *lpfc_vport_transport_template = NULL;
@@ -1169,7 +1171,7 @@ lpfc_offline_eratt(struct lpfc_hba *phba)
1169 spin_lock_irq(&phba->hbalock); 1171 spin_lock_irq(&phba->hbalock);
1170 psli->sli_flag &= ~LPFC_SLI_ACTIVE; 1172 psli->sli_flag &= ~LPFC_SLI_ACTIVE;
1171 spin_unlock_irq(&phba->hbalock); 1173 spin_unlock_irq(&phba->hbalock);
1172 lpfc_offline_prep(phba); 1174 lpfc_offline_prep(phba, LPFC_MBX_NO_WAIT);
1173 1175
1174 lpfc_offline(phba); 1176 lpfc_offline(phba);
1175 lpfc_reset_barrier(phba); 1177 lpfc_reset_barrier(phba);
@@ -1193,7 +1195,7 @@ lpfc_offline_eratt(struct lpfc_hba *phba)
1193static void 1195static void
1194lpfc_sli4_offline_eratt(struct lpfc_hba *phba) 1196lpfc_sli4_offline_eratt(struct lpfc_hba *phba)
1195{ 1197{
1196 lpfc_offline_prep(phba); 1198 lpfc_offline_prep(phba, LPFC_MBX_NO_WAIT);
1197 lpfc_offline(phba); 1199 lpfc_offline(phba);
1198 lpfc_sli4_brdreset(phba); 1200 lpfc_sli4_brdreset(phba);
1199 lpfc_hba_down_post(phba); 1201 lpfc_hba_down_post(phba);
@@ -1251,7 +1253,7 @@ lpfc_handle_deferred_eratt(struct lpfc_hba *phba)
1251 * There was a firmware error. Take the hba offline and then 1253 * There was a firmware error. Take the hba offline and then
1252 * attempt to restart it. 1254 * attempt to restart it.
1253 */ 1255 */
1254 lpfc_offline_prep(phba); 1256 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
1255 lpfc_offline(phba); 1257 lpfc_offline(phba);
1256 1258
1257 /* Wait for the ER1 bit to clear.*/ 1259 /* Wait for the ER1 bit to clear.*/
@@ -1372,7 +1374,7 @@ lpfc_handle_eratt_s3(struct lpfc_hba *phba)
1372 * There was a firmware error. Take the hba offline and then 1374 * There was a firmware error. Take the hba offline and then
1373 * attempt to restart it. 1375 * attempt to restart it.
1374 */ 1376 */
1375 lpfc_offline_prep(phba); 1377 lpfc_offline_prep(phba, LPFC_MBX_NO_WAIT);
1376 lpfc_offline(phba); 1378 lpfc_offline(phba);
1377 lpfc_sli_brdrestart(phba); 1379 lpfc_sli_brdrestart(phba);
1378 if (lpfc_online(phba) == 0) { /* Initialize the HBA */ 1380 if (lpfc_online(phba) == 0) { /* Initialize the HBA */
@@ -1428,6 +1430,54 @@ lpfc_handle_eratt_s3(struct lpfc_hba *phba)
1428} 1430}
1429 1431
1430/** 1432/**
1433 * lpfc_sli4_port_sta_fn_reset - The SLI4 function reset due to port status reg
1434 * @phba: pointer to lpfc hba data structure.
1435 * @mbx_action: flag for mailbox shutdown action.
1436 *
1437 * This routine is invoked to perform an SLI4 port PCI function reset in
1438 * response to port status register polling attention. It waits for port
1439 * status register (ERR, RDY, RN) bits before proceeding with function reset.
1440 * During this process, interrupt vectors are freed and later requested
1441 * for handling possible port resource change.
1442 **/
1443static int
1444lpfc_sli4_port_sta_fn_reset(struct lpfc_hba *phba, int mbx_action)
1445{
1446 int rc;
1447 uint32_t intr_mode;
1448
1449 /*
1450 * On error status condition, driver need to wait for port
1451 * ready before performing reset.
1452 */
1453 rc = lpfc_sli4_pdev_status_reg_wait(phba);
1454 if (!rc) {
1455 /* need reset: attempt for port recovery */
1456 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1457 "2887 Reset Needed: Attempting Port "
1458 "Recovery...\n");
1459 lpfc_offline_prep(phba, mbx_action);
1460 lpfc_offline(phba);
1461 /* release interrupt for possible resource change */
1462 lpfc_sli4_disable_intr(phba);
1463 lpfc_sli_brdrestart(phba);
1464 /* request and enable interrupt */
1465 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode);
1466 if (intr_mode == LPFC_INTR_ERROR) {
1467 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1468 "3175 Failed to enable interrupt\n");
1469 return -EIO;
1470 } else {
1471 phba->intr_mode = intr_mode;
1472 }
1473 rc = lpfc_online(phba);
1474 if (rc == 0)
1475 lpfc_unblock_mgmt_io(phba);
1476 }
1477 return rc;
1478}
1479
1480/**
1431 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler 1481 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1432 * @phba: pointer to lpfc hba data structure. 1482 * @phba: pointer to lpfc hba data structure.
1433 * 1483 *
@@ -1506,30 +1556,18 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba)
1506 reg_err2 == SLIPORT_ERR2_REG_FUNC_PROVISON) 1556 reg_err2 == SLIPORT_ERR2_REG_FUNC_PROVISON)
1507 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1557 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1508 "3145 Port Down: Provisioning\n"); 1558 "3145 Port Down: Provisioning\n");
1509 /* 1559
1510 * On error status condition, driver need to wait for port 1560 /* Check port status register for function reset */
1511 * ready before performing reset. 1561 rc = lpfc_sli4_port_sta_fn_reset(phba, LPFC_MBX_NO_WAIT);
1512 */ 1562 if (rc == 0) {
1513 rc = lpfc_sli4_pdev_status_reg_wait(phba); 1563 /* don't report event on forced debug dump */
1514 if (!rc) { 1564 if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 &&
1515 /* need reset: attempt for port recovery */ 1565 reg_err2 == SLIPORT_ERR2_REG_FORCED_DUMP)
1516 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1566 return;
1517 "2887 Reset Needed: Attempting Port " 1567 else
1518 "Recovery...\n"); 1568 break;
1519 lpfc_offline_prep(phba);
1520 lpfc_offline(phba);
1521 lpfc_sli_brdrestart(phba);
1522 if (lpfc_online(phba) == 0) {
1523 lpfc_unblock_mgmt_io(phba);
1524 /* don't report event on forced debug dump */
1525 if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 &&
1526 reg_err2 == SLIPORT_ERR2_REG_FORCED_DUMP)
1527 return;
1528 else
1529 break;
1530 }
1531 /* fall through for not able to recover */
1532 } 1569 }
1570 /* fall through for not able to recover */
1533 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1571 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1534 "3152 Unrecoverable error, bring the port " 1572 "3152 Unrecoverable error, bring the port "
1535 "offline\n"); 1573 "offline\n");
@@ -2494,15 +2532,19 @@ lpfc_stop_hba_timers(struct lpfc_hba *phba)
2494 * driver prepares the HBA interface for online or offline. 2532 * driver prepares the HBA interface for online or offline.
2495 **/ 2533 **/
2496static void 2534static void
2497lpfc_block_mgmt_io(struct lpfc_hba * phba) 2535lpfc_block_mgmt_io(struct lpfc_hba *phba, int mbx_action)
2498{ 2536{
2499 unsigned long iflag; 2537 unsigned long iflag;
2500 uint8_t actcmd = MBX_HEARTBEAT; 2538 uint8_t actcmd = MBX_HEARTBEAT;
2501 unsigned long timeout; 2539 unsigned long timeout;
2502 2540
2503 timeout = msecs_to_jiffies(LPFC_MBOX_TMO * 1000) + jiffies;
2504 spin_lock_irqsave(&phba->hbalock, iflag); 2541 spin_lock_irqsave(&phba->hbalock, iflag);
2505 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; 2542 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO;
2543 spin_unlock_irqrestore(&phba->hbalock, iflag);
2544 if (mbx_action == LPFC_MBX_NO_WAIT)
2545 return;
2546 timeout = msecs_to_jiffies(LPFC_MBOX_TMO * 1000) + jiffies;
2547 spin_lock_irqsave(&phba->hbalock, iflag);
2506 if (phba->sli.mbox_active) { 2548 if (phba->sli.mbox_active) {
2507 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; 2549 actcmd = phba->sli.mbox_active->u.mb.mbxCommand;
2508 /* Determine how long we might wait for the active mailbox 2550 /* Determine how long we might wait for the active mailbox
@@ -2592,7 +2634,7 @@ lpfc_online(struct lpfc_hba *phba)
2592 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, 2634 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
2593 "0458 Bring Adapter online\n"); 2635 "0458 Bring Adapter online\n");
2594 2636
2595 lpfc_block_mgmt_io(phba); 2637 lpfc_block_mgmt_io(phba, LPFC_MBX_WAIT);
2596 2638
2597 if (!lpfc_sli_queue_setup(phba)) { 2639 if (!lpfc_sli_queue_setup(phba)) {
2598 lpfc_unblock_mgmt_io(phba); 2640 lpfc_unblock_mgmt_io(phba);
@@ -2660,7 +2702,7 @@ lpfc_unblock_mgmt_io(struct lpfc_hba * phba)
2660 * queue to make it ready to be brought offline. 2702 * queue to make it ready to be brought offline.
2661 **/ 2703 **/
2662void 2704void
2663lpfc_offline_prep(struct lpfc_hba * phba) 2705lpfc_offline_prep(struct lpfc_hba *phba, int mbx_action)
2664{ 2706{
2665 struct lpfc_vport *vport = phba->pport; 2707 struct lpfc_vport *vport = phba->pport;
2666 struct lpfc_nodelist *ndlp, *next_ndlp; 2708 struct lpfc_nodelist *ndlp, *next_ndlp;
@@ -2671,7 +2713,7 @@ lpfc_offline_prep(struct lpfc_hba * phba)
2671 if (vport->fc_flag & FC_OFFLINE_MODE) 2713 if (vport->fc_flag & FC_OFFLINE_MODE)
2672 return; 2714 return;
2673 2715
2674 lpfc_block_mgmt_io(phba); 2716 lpfc_block_mgmt_io(phba, mbx_action);
2675 2717
2676 lpfc_linkdown(phba); 2718 lpfc_linkdown(phba);
2677 2719
@@ -2718,7 +2760,7 @@ lpfc_offline_prep(struct lpfc_hba * phba)
2718 } 2760 }
2719 lpfc_destroy_vport_work_array(phba, vports); 2761 lpfc_destroy_vport_work_array(phba, vports);
2720 2762
2721 lpfc_sli_mbox_sys_shutdown(phba); 2763 lpfc_sli_mbox_sys_shutdown(phba, mbx_action);
2722} 2764}
2723 2765
2724/** 2766/**
@@ -3684,12 +3726,76 @@ out_free_pmb:
3684static void 3726static void
3685lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) 3727lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli)
3686{ 3728{
3687 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 3729 char port_name;
3688 "2901 Async SLI event - Event Data1:x%08x Event Data2:" 3730 char message[80];
3689 "x%08x SLI Event Type:%d", 3731 uint8_t status;
3690 acqe_sli->event_data1, acqe_sli->event_data2, 3732 struct lpfc_acqe_misconfigured_event *misconfigured;
3691 bf_get(lpfc_trailer_type, acqe_sli)); 3733
3692 return; 3734 /* special case misconfigured event as it contains data for all ports */
3735 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
3736 LPFC_SLI_INTF_IF_TYPE_2) ||
3737 (bf_get(lpfc_trailer_type, acqe_sli) !=
3738 LPFC_SLI_EVENT_TYPE_MISCONFIGURED)) {
3739 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
3740 "2901 Async SLI event - Event Data1:x%08x Event Data2:"
3741 "x%08x SLI Event Type:%d\n",
3742 acqe_sli->event_data1, acqe_sli->event_data2,
3743 bf_get(lpfc_trailer_type, acqe_sli));
3744 return;
3745 }
3746
3747 port_name = phba->Port[0];
3748 if (port_name == 0x00)
3749 port_name = '?'; /* get port name is empty */
3750
3751 misconfigured = (struct lpfc_acqe_misconfigured_event *)
3752 &acqe_sli->event_data1;
3753
3754 /* fetch the status for this port */
3755 switch (phba->sli4_hba.lnk_info.lnk_no) {
3756 case LPFC_LINK_NUMBER_0:
3757 status = bf_get(lpfc_sli_misconfigured_port0,
3758 &misconfigured->theEvent);
3759 break;
3760 case LPFC_LINK_NUMBER_1:
3761 status = bf_get(lpfc_sli_misconfigured_port1,
3762 &misconfigured->theEvent);
3763 break;
3764 case LPFC_LINK_NUMBER_2:
3765 status = bf_get(lpfc_sli_misconfigured_port2,
3766 &misconfigured->theEvent);
3767 break;
3768 case LPFC_LINK_NUMBER_3:
3769 status = bf_get(lpfc_sli_misconfigured_port3,
3770 &misconfigured->theEvent);
3771 break;
3772 default:
3773 status = ~LPFC_SLI_EVENT_STATUS_VALID;
3774 break;
3775 }
3776
3777 switch (status) {
3778 case LPFC_SLI_EVENT_STATUS_VALID:
3779 return; /* no message if the sfp is okay */
3780 case LPFC_SLI_EVENT_STATUS_NOT_PRESENT:
3781 sprintf(message, "Not installed");
3782 break;
3783 case LPFC_SLI_EVENT_STATUS_WRONG_TYPE:
3784 sprintf(message,
3785 "Optics of two types installed");
3786 break;
3787 case LPFC_SLI_EVENT_STATUS_UNSUPPORTED:
3788 sprintf(message, "Incompatible optics");
3789 break;
3790 default:
3791 /* firmware is reporting a status we don't know about */
3792 sprintf(message, "Unknown event status x%02x", status);
3793 break;
3794 }
3795
3796 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3797 "3176 Misconfigured Physical Port - "
3798 "Port Name %c %s\n", port_name, message);
3693} 3799}
3694 3800
3695/** 3801/**
@@ -4312,7 +4418,7 @@ lpfc_reset_hba(struct lpfc_hba *phba)
4312 phba->link_state = LPFC_HBA_ERROR; 4418 phba->link_state = LPFC_HBA_ERROR;
4313 return; 4419 return;
4314 } 4420 }
4315 lpfc_offline_prep(phba); 4421 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
4316 lpfc_offline(phba); 4422 lpfc_offline(phba);
4317 lpfc_sli_brdrestart(phba); 4423 lpfc_sli_brdrestart(phba);
4318 lpfc_online(phba); 4424 lpfc_online(phba);
@@ -5514,14 +5620,45 @@ lpfc_destroy_shost(struct lpfc_hba *phba)
5514static void 5620static void
5515lpfc_setup_bg(struct lpfc_hba *phba, struct Scsi_Host *shost) 5621lpfc_setup_bg(struct lpfc_hba *phba, struct Scsi_Host *shost)
5516{ 5622{
5623 uint32_t old_mask;
5624 uint32_t old_guard;
5625
5517 int pagecnt = 10; 5626 int pagecnt = 10;
5518 if (lpfc_prot_mask && lpfc_prot_guard) { 5627 if (lpfc_prot_mask && lpfc_prot_guard) {
5519 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 5628 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
5520 "1478 Registering BlockGuard with the " 5629 "1478 Registering BlockGuard with the "
5521 "SCSI layer\n"); 5630 "SCSI layer\n");
5522 scsi_host_set_prot(shost, lpfc_prot_mask); 5631
5523 scsi_host_set_guard(shost, lpfc_prot_guard); 5632 old_mask = lpfc_prot_mask;
5633 old_guard = lpfc_prot_guard;
5634
5635 /* Only allow supported values */
5636 lpfc_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION |
5637 SHOST_DIX_TYPE0_PROTECTION |
5638 SHOST_DIX_TYPE1_PROTECTION);
5639 lpfc_prot_guard &= (SHOST_DIX_GUARD_IP | SHOST_DIX_GUARD_CRC);
5640
5641 /* DIF Type 1 protection for profiles AST1/C1 is end to end */
5642 if (lpfc_prot_mask == SHOST_DIX_TYPE1_PROTECTION)
5643 lpfc_prot_mask |= SHOST_DIF_TYPE1_PROTECTION;
5644
5645 if (lpfc_prot_mask && lpfc_prot_guard) {
5646 if ((old_mask != lpfc_prot_mask) ||
5647 (old_guard != lpfc_prot_guard))
5648 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
5649 "1475 Registering BlockGuard with the "
5650 "SCSI layer: mask %d guard %d\n",
5651 lpfc_prot_mask, lpfc_prot_guard);
5652
5653 scsi_host_set_prot(shost, lpfc_prot_mask);
5654 scsi_host_set_guard(shost, lpfc_prot_guard);
5655 } else
5656 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
5657 "1479 Not Registering BlockGuard with the SCSI "
5658 "layer, Bad protection parameters: %d %d\n",
5659 old_mask, old_guard);
5524 } 5660 }
5661
5525 if (!_dump_buf_data) { 5662 if (!_dump_buf_data) {
5526 while (pagecnt) { 5663 while (pagecnt) {
5527 spin_lock_init(&_dump_buf_lock); 5664 spin_lock_init(&_dump_buf_lock);
@@ -8859,7 +8996,7 @@ lpfc_pci_suspend_one_s3(struct pci_dev *pdev, pm_message_t msg)
8859 "0473 PCI device Power Management suspend.\n"); 8996 "0473 PCI device Power Management suspend.\n");
8860 8997
8861 /* Bring down the device */ 8998 /* Bring down the device */
8862 lpfc_offline_prep(phba); 8999 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
8863 lpfc_offline(phba); 9000 lpfc_offline(phba);
8864 kthread_stop(phba->worker_thread); 9001 kthread_stop(phba->worker_thread);
8865 9002
@@ -8985,7 +9122,7 @@ lpfc_sli_prep_dev_for_reset(struct lpfc_hba *phba)
8985 "2710 PCI channel disable preparing for reset\n"); 9122 "2710 PCI channel disable preparing for reset\n");
8986 9123
8987 /* Block any management I/Os to the device */ 9124 /* Block any management I/Os to the device */
8988 lpfc_block_mgmt_io(phba); 9125 lpfc_block_mgmt_io(phba, LPFC_MBX_WAIT);
8989 9126
8990 /* Block all SCSI devices' I/Os on the host */ 9127 /* Block all SCSI devices' I/Os on the host */
8991 lpfc_scsi_dev_block(phba); 9128 lpfc_scsi_dev_block(phba);
@@ -9129,7 +9266,7 @@ lpfc_io_slot_reset_s3(struct pci_dev *pdev)
9129 phba->intr_mode = intr_mode; 9266 phba->intr_mode = intr_mode;
9130 9267
9131 /* Take device offline, it will perform cleanup */ 9268 /* Take device offline, it will perform cleanup */
9132 lpfc_offline_prep(phba); 9269 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
9133 lpfc_offline(phba); 9270 lpfc_offline(phba);
9134 lpfc_sli_brdrestart(phba); 9271 lpfc_sli_brdrestart(phba);
9135 9272
@@ -9603,7 +9740,7 @@ lpfc_pci_suspend_one_s4(struct pci_dev *pdev, pm_message_t msg)
9603 "2843 PCI device Power Management suspend.\n"); 9740 "2843 PCI device Power Management suspend.\n");
9604 9741
9605 /* Bring down the device */ 9742 /* Bring down the device */
9606 lpfc_offline_prep(phba); 9743 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
9607 lpfc_offline(phba); 9744 lpfc_offline(phba);
9608 kthread_stop(phba->worker_thread); 9745 kthread_stop(phba->worker_thread);
9609 9746
@@ -9729,7 +9866,7 @@ lpfc_sli4_prep_dev_for_reset(struct lpfc_hba *phba)
9729 "2826 PCI channel disable preparing for reset\n"); 9866 "2826 PCI channel disable preparing for reset\n");
9730 9867
9731 /* Block any management I/Os to the device */ 9868 /* Block any management I/Os to the device */
9732 lpfc_block_mgmt_io(phba); 9869 lpfc_block_mgmt_io(phba, LPFC_MBX_NO_WAIT);
9733 9870
9734 /* Block all SCSI devices' I/Os on the host */ 9871 /* Block all SCSI devices' I/Os on the host */
9735 lpfc_scsi_dev_block(phba); 9872 lpfc_scsi_dev_block(phba);
@@ -9902,7 +10039,7 @@ lpfc_io_resume_s4(struct pci_dev *pdev)
9902 */ 10039 */
9903 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { 10040 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) {
9904 /* Perform device reset */ 10041 /* Perform device reset */
9905 lpfc_offline_prep(phba); 10042 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
9906 lpfc_offline(phba); 10043 lpfc_offline(phba);
9907 lpfc_sli_brdrestart(phba); 10044 lpfc_sli_brdrestart(phba);
9908 /* Bring the device back online */ 10045 /* Bring the device back online */
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 66e09069f281..925975d2d765 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -4275,10 +4275,8 @@ lpfc_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
4275 * Catch race where our node has transitioned, but the 4275 * Catch race where our node has transitioned, but the
4276 * transport is still transitioning. 4276 * transport is still transitioning.
4277 */ 4277 */
4278 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { 4278 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
4279 cmnd->result = ScsiResult(DID_IMM_RETRY, 0); 4279 goto out_tgt_busy;
4280 goto out_fail_command;
4281 }
4282 if (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) 4280 if (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth)
4283 goto out_tgt_busy; 4281 goto out_tgt_busy;
4284 4282
@@ -4412,12 +4410,12 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
4412 struct lpfc_iocbq *abtsiocb; 4410 struct lpfc_iocbq *abtsiocb;
4413 struct lpfc_scsi_buf *lpfc_cmd; 4411 struct lpfc_scsi_buf *lpfc_cmd;
4414 IOCB_t *cmd, *icmd; 4412 IOCB_t *cmd, *icmd;
4415 int ret = SUCCESS; 4413 int ret = SUCCESS, status = 0;
4416 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq); 4414 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq);
4417 4415
4418 ret = fc_block_scsi_eh(cmnd); 4416 status = fc_block_scsi_eh(cmnd);
4419 if (ret) 4417 if (status)
4420 return ret; 4418 return status;
4421 4419
4422 spin_lock_irq(&phba->hbalock); 4420 spin_lock_irq(&phba->hbalock);
4423 /* driver queued commands are in process of being flushed */ 4421 /* driver queued commands are in process of being flushed */
@@ -4435,7 +4433,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
4435 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, 4433 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
4436 "2873 SCSI Layer I/O Abort Request IO CMPL Status " 4434 "2873 SCSI Layer I/O Abort Request IO CMPL Status "
4437 "x%x ID %d LUN %d\n", 4435 "x%x ID %d LUN %d\n",
4438 ret, cmnd->device->id, cmnd->device->lun); 4436 SUCCESS, cmnd->device->id, cmnd->device->lun);
4439 return SUCCESS; 4437 return SUCCESS;
4440 } 4438 }
4441 4439
@@ -4762,7 +4760,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
4762 unsigned tgt_id = cmnd->device->id; 4760 unsigned tgt_id = cmnd->device->id;
4763 unsigned int lun_id = cmnd->device->lun; 4761 unsigned int lun_id = cmnd->device->lun;
4764 struct lpfc_scsi_event_header scsi_event; 4762 struct lpfc_scsi_event_header scsi_event;
4765 int status; 4763 int status, ret = SUCCESS;
4766 4764
4767 if (!rdata) { 4765 if (!rdata) {
4768 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, 4766 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
@@ -4803,9 +4801,9 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
4803 * So, continue on. 4801 * So, continue on.
4804 * We will report success if all the i/o aborts successfully. 4802 * We will report success if all the i/o aborts successfully.
4805 */ 4803 */
4806 status = lpfc_reset_flush_io_context(vport, tgt_id, lun_id, 4804 ret = lpfc_reset_flush_io_context(vport, tgt_id, lun_id,
4807 LPFC_CTX_LUN); 4805 LPFC_CTX_LUN);
4808 return status; 4806 return ret;
4809} 4807}
4810 4808
4811/** 4809/**
@@ -4829,7 +4827,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
4829 unsigned tgt_id = cmnd->device->id; 4827 unsigned tgt_id = cmnd->device->id;
4830 unsigned int lun_id = cmnd->device->lun; 4828 unsigned int lun_id = cmnd->device->lun;
4831 struct lpfc_scsi_event_header scsi_event; 4829 struct lpfc_scsi_event_header scsi_event;
4832 int status; 4830 int status, ret = SUCCESS;
4833 4831
4834 if (!rdata) { 4832 if (!rdata) {
4835 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, 4833 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
@@ -4870,9 +4868,9 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
4870 * So, continue on. 4868 * So, continue on.
4871 * We will report success if all the i/o aborts successfully. 4869 * We will report success if all the i/o aborts successfully.
4872 */ 4870 */
4873 status = lpfc_reset_flush_io_context(vport, tgt_id, lun_id, 4871 ret = lpfc_reset_flush_io_context(vport, tgt_id, lun_id,
4874 LPFC_CTX_TGT); 4872 LPFC_CTX_TGT);
4875 return status; 4873 return ret;
4876} 4874}
4877 4875
4878/** 4876/**
@@ -4982,7 +4980,7 @@ lpfc_host_reset_handler(struct scsi_cmnd *cmnd)
4982 struct lpfc_hba *phba = vport->phba; 4980 struct lpfc_hba *phba = vport->phba;
4983 int rc, ret = SUCCESS; 4981 int rc, ret = SUCCESS;
4984 4982
4985 lpfc_offline_prep(phba); 4983 lpfc_offline_prep(phba, LPFC_MBX_WAIT);
4986 lpfc_offline(phba); 4984 lpfc_offline(phba);
4987 rc = lpfc_sli_brdrestart(phba); 4985 rc = lpfc_sli_brdrestart(phba);
4988 if (rc) 4986 if (rc)
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index b4720a109817..9cbd20b1328b 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -8984,7 +8984,7 @@ lpfc_sli_hba_down(struct lpfc_hba *phba)
8984 int i; 8984 int i;
8985 8985
8986 /* Shutdown the mailbox command sub-system */ 8986 /* Shutdown the mailbox command sub-system */
8987 lpfc_sli_mbox_sys_shutdown(phba); 8987 lpfc_sli_mbox_sys_shutdown(phba, LPFC_MBX_WAIT);
8988 8988
8989 lpfc_hba_down_prep(phba); 8989 lpfc_hba_down_prep(phba);
8990 8990
@@ -9996,11 +9996,17 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq,
9996 * sub-system flush routine to gracefully bring down mailbox sub-system. 9996 * sub-system flush routine to gracefully bring down mailbox sub-system.
9997 **/ 9997 **/
9998void 9998void
9999lpfc_sli_mbox_sys_shutdown(struct lpfc_hba *phba) 9999lpfc_sli_mbox_sys_shutdown(struct lpfc_hba *phba, int mbx_action)
10000{ 10000{
10001 struct lpfc_sli *psli = &phba->sli; 10001 struct lpfc_sli *psli = &phba->sli;
10002 unsigned long timeout; 10002 unsigned long timeout;
10003 10003
10004 if (mbx_action == LPFC_MBX_NO_WAIT) {
10005 /* delay 100ms for port state */
10006 msleep(100);
10007 lpfc_sli_mbox_sys_flush(phba);
10008 return;
10009 }
10004 timeout = msecs_to_jiffies(LPFC_MBOX_TMO * 1000) + jiffies; 10010 timeout = msecs_to_jiffies(LPFC_MBOX_TMO * 1000) + jiffies;
10005 10011
10006 spin_lock_irq(&phba->hbalock); 10012 spin_lock_irq(&phba->hbalock);
@@ -12042,6 +12048,83 @@ out_fail:
12042} 12048}
12043 12049
12044/** 12050/**
12051 * lpfc_modify_fcp_eq_delay - Modify Delay Multiplier on FCP EQs
12052 * @phba: HBA structure that indicates port to create a queue on.
12053 * @startq: The starting FCP EQ to modify
12054 *
12055 * This function sends an MODIFY_EQ_DELAY mailbox command to the HBA.
12056 *
12057 * The @phba struct is used to send mailbox command to HBA. The @startq
12058 * is used to get the starting FCP EQ to change.
12059 * This function is asynchronous and will wait for the mailbox
12060 * command to finish before continuing.
12061 *
12062 * On success this function will return a zero. If unable to allocate enough
12063 * memory this function will return -ENOMEM. If the queue create mailbox command
12064 * fails this function will return -ENXIO.
12065 **/
12066uint32_t
12067lpfc_modify_fcp_eq_delay(struct lpfc_hba *phba, uint16_t startq)
12068{
12069 struct lpfc_mbx_modify_eq_delay *eq_delay;
12070 LPFC_MBOXQ_t *mbox;
12071 struct lpfc_queue *eq;
12072 int cnt, rc, length, status = 0;
12073 uint32_t shdr_status, shdr_add_status;
12074 int fcp_eqidx;
12075 union lpfc_sli4_cfg_shdr *shdr;
12076 uint16_t dmult;
12077
12078 if (startq >= phba->cfg_fcp_eq_count)
12079 return 0;
12080
12081 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
12082 if (!mbox)
12083 return -ENOMEM;
12084 length = (sizeof(struct lpfc_mbx_modify_eq_delay) -
12085 sizeof(struct lpfc_sli4_cfg_mhdr));
12086 lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_COMMON,
12087 LPFC_MBOX_OPCODE_MODIFY_EQ_DELAY,
12088 length, LPFC_SLI4_MBX_EMBED);
12089 eq_delay = &mbox->u.mqe.un.eq_delay;
12090
12091 /* Calculate delay multiper from maximum interrupt per second */
12092 dmult = LPFC_DMULT_CONST/phba->cfg_fcp_imax - 1;
12093
12094 cnt = 0;
12095 for (fcp_eqidx = startq; fcp_eqidx < phba->cfg_fcp_eq_count;
12096 fcp_eqidx++) {
12097 eq = phba->sli4_hba.fp_eq[fcp_eqidx];
12098 if (!eq)
12099 continue;
12100 eq_delay->u.request.eq[cnt].eq_id = eq->queue_id;
12101 eq_delay->u.request.eq[cnt].phase = 0;
12102 eq_delay->u.request.eq[cnt].delay_multi = dmult;
12103 cnt++;
12104 if (cnt >= LPFC_MAX_EQ_DELAY)
12105 break;
12106 }
12107 eq_delay->u.request.num_eq = cnt;
12108
12109 mbox->vport = phba->pport;
12110 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
12111 mbox->context1 = NULL;
12112 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
12113 shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr;
12114 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response);
12115 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response);
12116 if (shdr_status || shdr_add_status || rc) {
12117 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
12118 "2512 MODIFY_EQ_DELAY mailbox failed with "
12119 "status x%x add_status x%x, mbx status x%x\n",
12120 shdr_status, shdr_add_status, rc);
12121 status = -ENXIO;
12122 }
12123 mempool_free(mbox, phba->mbox_mem_pool);
12124 return status;
12125}
12126
12127/**
12045 * lpfc_eq_create - Create an Event Queue on the HBA 12128 * lpfc_eq_create - Create an Event Queue on the HBA
12046 * @phba: HBA structure that indicates port to create a queue on. 12129 * @phba: HBA structure that indicates port to create a queue on.
12047 * @eq: The queue structure to use to create the event queue. 12130 * @eq: The queue structure to use to create the event queue.
@@ -12228,8 +12311,10 @@ lpfc_cq_create(struct lpfc_hba *phba, struct lpfc_queue *cq,
12228 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 12311 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
12229 "0361 Unsupported CQ count. (%d)\n", 12312 "0361 Unsupported CQ count. (%d)\n",
12230 cq->entry_count); 12313 cq->entry_count);
12231 if (cq->entry_count < 256) 12314 if (cq->entry_count < 256) {
12232 return -EINVAL; 12315 status = -EINVAL;
12316 goto out;
12317 }
12233 /* otherwise default to smallest count (drop through) */ 12318 /* otherwise default to smallest count (drop through) */
12234 case 256: 12319 case 256:
12235 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, 12320 bf_set(lpfc_cq_context_count, &cq_create->u.request.context,
@@ -12420,8 +12505,10 @@ lpfc_mq_create(struct lpfc_hba *phba, struct lpfc_queue *mq,
12420 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 12505 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
12421 "0362 Unsupported MQ count. (%d)\n", 12506 "0362 Unsupported MQ count. (%d)\n",
12422 mq->entry_count); 12507 mq->entry_count);
12423 if (mq->entry_count < 16) 12508 if (mq->entry_count < 16) {
12424 return -EINVAL; 12509 status = -EINVAL;
12510 goto out;
12511 }
12425 /* otherwise default to smallest count (drop through) */ 12512 /* otherwise default to smallest count (drop through) */
12426 case 16: 12513 case 16:
12427 bf_set(lpfc_mq_context_ring_size, 12514 bf_set(lpfc_mq_context_ring_size,
@@ -12710,8 +12797,10 @@ lpfc_rq_create(struct lpfc_hba *phba, struct lpfc_queue *hrq,
12710 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 12797 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
12711 "2535 Unsupported RQ count. (%d)\n", 12798 "2535 Unsupported RQ count. (%d)\n",
12712 hrq->entry_count); 12799 hrq->entry_count);
12713 if (hrq->entry_count < 512) 12800 if (hrq->entry_count < 512) {
12714 return -EINVAL; 12801 status = -EINVAL;
12802 goto out;
12803 }
12715 /* otherwise default to smallest count (drop through) */ 12804 /* otherwise default to smallest count (drop through) */
12716 case 512: 12805 case 512:
12717 bf_set(lpfc_rq_context_rqe_count, 12806 bf_set(lpfc_rq_context_rqe_count,
@@ -12791,8 +12880,10 @@ lpfc_rq_create(struct lpfc_hba *phba, struct lpfc_queue *hrq,
12791 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 12880 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
12792 "2536 Unsupported RQ count. (%d)\n", 12881 "2536 Unsupported RQ count. (%d)\n",
12793 drq->entry_count); 12882 drq->entry_count);
12794 if (drq->entry_count < 512) 12883 if (drq->entry_count < 512) {
12795 return -EINVAL; 12884 status = -EINVAL;
12885 goto out;
12886 }
12796 /* otherwise default to smallest count (drop through) */ 12887 /* otherwise default to smallest count (drop through) */
12797 case 512: 12888 case 512:
12798 bf_set(lpfc_rq_context_rqe_count, 12889 bf_set(lpfc_rq_context_rqe_count,
@@ -15855,24 +15946,18 @@ lpfc_drain_txq(struct lpfc_hba *phba)
15855 spin_lock_irqsave(&phba->hbalock, iflags); 15946 spin_lock_irqsave(&phba->hbalock, iflags);
15856 15947
15857 piocbq = lpfc_sli_ringtx_get(phba, pring); 15948 piocbq = lpfc_sli_ringtx_get(phba, pring);
15949 if (!piocbq) {
15950 spin_unlock_irqrestore(&phba->hbalock, iflags);
15951 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
15952 "2823 txq empty and txq_cnt is %d\n ",
15953 pring->txq_cnt);
15954 break;
15955 }
15858 sglq = __lpfc_sli_get_sglq(phba, piocbq); 15956 sglq = __lpfc_sli_get_sglq(phba, piocbq);
15859 if (!sglq) { 15957 if (!sglq) {
15860 __lpfc_sli_ringtx_put(phba, pring, piocbq); 15958 __lpfc_sli_ringtx_put(phba, pring, piocbq);
15861 spin_unlock_irqrestore(&phba->hbalock, iflags); 15959 spin_unlock_irqrestore(&phba->hbalock, iflags);
15862 break; 15960 break;
15863 } else {
15864 if (!piocbq) {
15865 /* The txq_cnt out of sync. This should
15866 * never happen
15867 */
15868 sglq = __lpfc_clear_active_sglq(phba,
15869 sglq->sli4_lxritag);
15870 spin_unlock_irqrestore(&phba->hbalock, iflags);
15871 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
15872 "2823 txq empty and txq_cnt is %d\n ",
15873 pring->txq_cnt);
15874 break;
15875 }
15876 } 15961 }
15877 15962
15878 /* The xri and iocb resources secured, 15963 /* The xri and iocb resources secured,
diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h
index a4a77080091b..ec756118c5c1 100644
--- a/drivers/scsi/lpfc/lpfc_sli4.h
+++ b/drivers/scsi/lpfc/lpfc_sli4.h
@@ -598,6 +598,7 @@ struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t,
598 uint32_t); 598 uint32_t);
599void lpfc_sli4_queue_free(struct lpfc_queue *); 599void lpfc_sli4_queue_free(struct lpfc_queue *);
600uint32_t lpfc_eq_create(struct lpfc_hba *, struct lpfc_queue *, uint16_t); 600uint32_t lpfc_eq_create(struct lpfc_hba *, struct lpfc_queue *, uint16_t);
601uint32_t lpfc_modify_fcp_eq_delay(struct lpfc_hba *, uint16_t);
601uint32_t lpfc_cq_create(struct lpfc_hba *, struct lpfc_queue *, 602uint32_t lpfc_cq_create(struct lpfc_hba *, struct lpfc_queue *,
602 struct lpfc_queue *, uint32_t, uint32_t); 603 struct lpfc_queue *, uint32_t, uint32_t);
603int32_t lpfc_mq_create(struct lpfc_hba *, struct lpfc_queue *, 604int32_t lpfc_mq_create(struct lpfc_hba *, struct lpfc_queue *,
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index 59c57a409981..4704e5b5088e 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.31" 21#define LPFC_DRIVER_VERSION "8.3.32"
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"