aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_sli.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_sli.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c704
1 files changed, 502 insertions, 202 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 4d4104f38c9..23a27592388 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -89,15 +89,20 @@ lpfc_get_iocb_from_iocbq(struct lpfc_iocbq *iocbq)
89static uint32_t 89static uint32_t
90lpfc_sli4_wq_put(struct lpfc_queue *q, union lpfc_wqe *wqe) 90lpfc_sli4_wq_put(struct lpfc_queue *q, union lpfc_wqe *wqe)
91{ 91{
92 union lpfc_wqe *temp_wqe = q->qe[q->host_index].wqe; 92 union lpfc_wqe *temp_wqe;
93 struct lpfc_register doorbell; 93 struct lpfc_register doorbell;
94 uint32_t host_index; 94 uint32_t host_index;
95 95
96 /* sanity check on queue memory */
97 if (unlikely(!q))
98 return -ENOMEM;
99 temp_wqe = q->qe[q->host_index].wqe;
100
96 /* If the host has not yet processed the next entry then we are done */ 101 /* If the host has not yet processed the next entry then we are done */
97 if (((q->host_index + 1) % q->entry_count) == q->hba_index) 102 if (((q->host_index + 1) % q->entry_count) == q->hba_index)
98 return -ENOMEM; 103 return -ENOMEM;
99 /* set consumption flag every once in a while */ 104 /* set consumption flag every once in a while */
100 if (!((q->host_index + 1) % LPFC_RELEASE_NOTIFICATION_INTERVAL)) 105 if (!((q->host_index + 1) % q->entry_repost))
101 bf_set(wqe_wqec, &wqe->generic.wqe_com, 1); 106 bf_set(wqe_wqec, &wqe->generic.wqe_com, 1);
102 if (q->phba->sli3_options & LPFC_SLI4_PHWQ_ENABLED) 107 if (q->phba->sli3_options & LPFC_SLI4_PHWQ_ENABLED)
103 bf_set(wqe_wqid, &wqe->generic.wqe_com, q->queue_id); 108 bf_set(wqe_wqid, &wqe->generic.wqe_com, q->queue_id);
@@ -134,6 +139,10 @@ lpfc_sli4_wq_release(struct lpfc_queue *q, uint32_t index)
134{ 139{
135 uint32_t released = 0; 140 uint32_t released = 0;
136 141
142 /* sanity check on queue memory */
143 if (unlikely(!q))
144 return 0;
145
137 if (q->hba_index == index) 146 if (q->hba_index == index)
138 return 0; 147 return 0;
139 do { 148 do {
@@ -158,10 +167,15 @@ lpfc_sli4_wq_release(struct lpfc_queue *q, uint32_t index)
158static uint32_t 167static uint32_t
159lpfc_sli4_mq_put(struct lpfc_queue *q, struct lpfc_mqe *mqe) 168lpfc_sli4_mq_put(struct lpfc_queue *q, struct lpfc_mqe *mqe)
160{ 169{
161 struct lpfc_mqe *temp_mqe = q->qe[q->host_index].mqe; 170 struct lpfc_mqe *temp_mqe;
162 struct lpfc_register doorbell; 171 struct lpfc_register doorbell;
163 uint32_t host_index; 172 uint32_t host_index;
164 173
174 /* sanity check on queue memory */
175 if (unlikely(!q))
176 return -ENOMEM;
177 temp_mqe = q->qe[q->host_index].mqe;
178
165 /* If the host has not yet processed the next entry then we are done */ 179 /* If the host has not yet processed the next entry then we are done */
166 if (((q->host_index + 1) % q->entry_count) == q->hba_index) 180 if (((q->host_index + 1) % q->entry_count) == q->hba_index)
167 return -ENOMEM; 181 return -ENOMEM;
@@ -195,6 +209,10 @@ lpfc_sli4_mq_put(struct lpfc_queue *q, struct lpfc_mqe *mqe)
195static uint32_t 209static uint32_t
196lpfc_sli4_mq_release(struct lpfc_queue *q) 210lpfc_sli4_mq_release(struct lpfc_queue *q)
197{ 211{
212 /* sanity check on queue memory */
213 if (unlikely(!q))
214 return 0;
215
198 /* Clear the mailbox pointer for completion */ 216 /* Clear the mailbox pointer for completion */
199 q->phba->mbox = NULL; 217 q->phba->mbox = NULL;
200 q->hba_index = ((q->hba_index + 1) % q->entry_count); 218 q->hba_index = ((q->hba_index + 1) % q->entry_count);
@@ -213,7 +231,12 @@ lpfc_sli4_mq_release(struct lpfc_queue *q)
213static struct lpfc_eqe * 231static struct lpfc_eqe *
214lpfc_sli4_eq_get(struct lpfc_queue *q) 232lpfc_sli4_eq_get(struct lpfc_queue *q)
215{ 233{
216 struct lpfc_eqe *eqe = q->qe[q->hba_index].eqe; 234 struct lpfc_eqe *eqe;
235
236 /* sanity check on queue memory */
237 if (unlikely(!q))
238 return NULL;
239 eqe = q->qe[q->hba_index].eqe;
217 240
218 /* If the next EQE is not valid then we are done */ 241 /* If the next EQE is not valid then we are done */
219 if (!bf_get_le32(lpfc_eqe_valid, eqe)) 242 if (!bf_get_le32(lpfc_eqe_valid, eqe))
@@ -248,6 +271,10 @@ lpfc_sli4_eq_release(struct lpfc_queue *q, bool arm)
248 struct lpfc_eqe *temp_eqe; 271 struct lpfc_eqe *temp_eqe;
249 struct lpfc_register doorbell; 272 struct lpfc_register doorbell;
250 273
274 /* sanity check on queue memory */
275 if (unlikely(!q))
276 return 0;
277
251 /* while there are valid entries */ 278 /* while there are valid entries */
252 while (q->hba_index != q->host_index) { 279 while (q->hba_index != q->host_index) {
253 temp_eqe = q->qe[q->host_index].eqe; 280 temp_eqe = q->qe[q->host_index].eqe;
@@ -288,6 +315,10 @@ lpfc_sli4_cq_get(struct lpfc_queue *q)
288{ 315{
289 struct lpfc_cqe *cqe; 316 struct lpfc_cqe *cqe;
290 317
318 /* sanity check on queue memory */
319 if (unlikely(!q))
320 return NULL;
321
291 /* If the next CQE is not valid then we are done */ 322 /* If the next CQE is not valid then we are done */
292 if (!bf_get_le32(lpfc_cqe_valid, q->qe[q->hba_index].cqe)) 323 if (!bf_get_le32(lpfc_cqe_valid, q->qe[q->hba_index].cqe))
293 return NULL; 324 return NULL;
@@ -322,6 +353,9 @@ lpfc_sli4_cq_release(struct lpfc_queue *q, bool arm)
322 struct lpfc_cqe *temp_qe; 353 struct lpfc_cqe *temp_qe;
323 struct lpfc_register doorbell; 354 struct lpfc_register doorbell;
324 355
356 /* sanity check on queue memory */
357 if (unlikely(!q))
358 return 0;
325 /* while there are valid entries */ 359 /* while there are valid entries */
326 while (q->hba_index != q->host_index) { 360 while (q->hba_index != q->host_index) {
327 temp_qe = q->qe[q->host_index].cqe; 361 temp_qe = q->qe[q->host_index].cqe;
@@ -359,11 +393,17 @@ static int
359lpfc_sli4_rq_put(struct lpfc_queue *hq, struct lpfc_queue *dq, 393lpfc_sli4_rq_put(struct lpfc_queue *hq, struct lpfc_queue *dq,
360 struct lpfc_rqe *hrqe, struct lpfc_rqe *drqe) 394 struct lpfc_rqe *hrqe, struct lpfc_rqe *drqe)
361{ 395{
362 struct lpfc_rqe *temp_hrqe = hq->qe[hq->host_index].rqe; 396 struct lpfc_rqe *temp_hrqe;
363 struct lpfc_rqe *temp_drqe = dq->qe[dq->host_index].rqe; 397 struct lpfc_rqe *temp_drqe;
364 struct lpfc_register doorbell; 398 struct lpfc_register doorbell;
365 int put_index = hq->host_index; 399 int put_index = hq->host_index;
366 400
401 /* sanity check on queue memory */
402 if (unlikely(!hq) || unlikely(!dq))
403 return -ENOMEM;
404 temp_hrqe = hq->qe[hq->host_index].rqe;
405 temp_drqe = dq->qe[dq->host_index].rqe;
406
367 if (hq->type != LPFC_HRQ || dq->type != LPFC_DRQ) 407 if (hq->type != LPFC_HRQ || dq->type != LPFC_DRQ)
368 return -EINVAL; 408 return -EINVAL;
369 if (hq->host_index != dq->host_index) 409 if (hq->host_index != dq->host_index)
@@ -402,6 +442,10 @@ lpfc_sli4_rq_put(struct lpfc_queue *hq, struct lpfc_queue *dq,
402static uint32_t 442static uint32_t
403lpfc_sli4_rq_release(struct lpfc_queue *hq, struct lpfc_queue *dq) 443lpfc_sli4_rq_release(struct lpfc_queue *hq, struct lpfc_queue *dq)
404{ 444{
445 /* sanity check on queue memory */
446 if (unlikely(!hq) || unlikely(!dq))
447 return 0;
448
405 if ((hq->type != LPFC_HRQ) || (dq->type != LPFC_DRQ)) 449 if ((hq->type != LPFC_HRQ) || (dq->type != LPFC_DRQ))
406 return 0; 450 return 0;
407 hq->hba_index = ((hq->hba_index + 1) % hq->entry_count); 451 hq->hba_index = ((hq->hba_index + 1) % hq->entry_count);
@@ -3575,8 +3619,8 @@ lpfc_sli_brdready(struct lpfc_hba *phba, uint32_t mask)
3575 * lpfc_reset_barrier - Make HBA ready for HBA reset 3619 * lpfc_reset_barrier - Make HBA ready for HBA reset
3576 * @phba: Pointer to HBA context object. 3620 * @phba: Pointer to HBA context object.
3577 * 3621 *
3578 * This function is called before resetting an HBA. This 3622 * This function is called before resetting an HBA. This function is called
3579 * function requests HBA to quiesce DMAs before a reset. 3623 * with hbalock held and requests HBA to quiesce DMAs before a reset.
3580 **/ 3624 **/
3581void lpfc_reset_barrier(struct lpfc_hba *phba) 3625void lpfc_reset_barrier(struct lpfc_hba *phba)
3582{ 3626{
@@ -3851,7 +3895,6 @@ lpfc_sli4_brdreset(struct lpfc_hba *phba)
3851{ 3895{
3852 struct lpfc_sli *psli = &phba->sli; 3896 struct lpfc_sli *psli = &phba->sli;
3853 uint16_t cfg_value; 3897 uint16_t cfg_value;
3854 uint8_t qindx;
3855 3898
3856 /* Reset HBA */ 3899 /* Reset HBA */
3857 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 3900 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
@@ -3867,19 +3910,6 @@ lpfc_sli4_brdreset(struct lpfc_hba *phba)
3867 spin_lock_irq(&phba->hbalock); 3910 spin_lock_irq(&phba->hbalock);
3868 psli->sli_flag &= ~(LPFC_PROCESS_LA); 3911 psli->sli_flag &= ~(LPFC_PROCESS_LA);
3869 phba->fcf.fcf_flag = 0; 3912 phba->fcf.fcf_flag = 0;
3870 /* Clean up the child queue list for the CQs */
3871 list_del_init(&phba->sli4_hba.mbx_wq->list);
3872 list_del_init(&phba->sli4_hba.els_wq->list);
3873 list_del_init(&phba->sli4_hba.hdr_rq->list);
3874 list_del_init(&phba->sli4_hba.dat_rq->list);
3875 list_del_init(&phba->sli4_hba.mbx_cq->list);
3876 list_del_init(&phba->sli4_hba.els_cq->list);
3877 for (qindx = 0; qindx < phba->cfg_fcp_wq_count; qindx++)
3878 list_del_init(&phba->sli4_hba.fcp_wq[qindx]->list);
3879 qindx = 0;
3880 do
3881 list_del_init(&phba->sli4_hba.fcp_cq[qindx]->list);
3882 while (++qindx < phba->cfg_fcp_eq_count);
3883 spin_unlock_irq(&phba->hbalock); 3913 spin_unlock_irq(&phba->hbalock);
3884 3914
3885 /* Now physically reset the device */ 3915 /* Now physically reset the device */
@@ -3892,6 +3922,7 @@ lpfc_sli4_brdreset(struct lpfc_hba *phba)
3892 ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR))); 3922 ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR)));
3893 3923
3894 /* Perform FCoE PCI function reset */ 3924 /* Perform FCoE PCI function reset */
3925 lpfc_sli4_queue_destroy(phba);
3895 lpfc_pci_function_reset(phba); 3926 lpfc_pci_function_reset(phba);
3896 3927
3897 /* Restore PCI cmd register */ 3928 /* Restore PCI cmd register */
@@ -4339,6 +4370,11 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode)
4339 phba->sli.sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; 4370 phba->sli.sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK;
4340 spin_unlock_irq(&phba->hbalock); 4371 spin_unlock_irq(&phba->hbalock);
4341 done = 1; 4372 done = 1;
4373
4374 if ((pmb->u.mb.un.varCfgPort.casabt == 1) &&
4375 (pmb->u.mb.un.varCfgPort.gasabt == 0))
4376 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
4377 "3110 Port did not grant ASABT\n");
4342 } 4378 }
4343 } 4379 }
4344 if (!done) { 4380 if (!done) {
@@ -4551,9 +4587,9 @@ lpfc_sli_hba_setup_error:
4551 * data structure. 4587 * data structure.
4552 **/ 4588 **/
4553static int 4589static int
4554lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba, 4590lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba)
4555 LPFC_MBOXQ_t *mboxq)
4556{ 4591{
4592 LPFC_MBOXQ_t *mboxq;
4557 struct lpfc_dmabuf *mp; 4593 struct lpfc_dmabuf *mp;
4558 struct lpfc_mqe *mqe; 4594 struct lpfc_mqe *mqe;
4559 uint32_t data_length; 4595 uint32_t data_length;
@@ -4565,10 +4601,16 @@ lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba,
4565 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; 4601 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1;
4566 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; 4602 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2;
4567 4603
4568 mqe = &mboxq->u.mqe; 4604 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4569 if (lpfc_dump_fcoe_param(phba, mboxq)) 4605 if (!mboxq)
4570 return -ENOMEM; 4606 return -ENOMEM;
4571 4607
4608 mqe = &mboxq->u.mqe;
4609 if (lpfc_sli4_dump_cfg_rg23(phba, mboxq)) {
4610 rc = -ENOMEM;
4611 goto out_free_mboxq;
4612 }
4613
4572 mp = (struct lpfc_dmabuf *) mboxq->context1; 4614 mp = (struct lpfc_dmabuf *) mboxq->context1;
4573 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); 4615 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
4574 4616
@@ -4596,19 +4638,25 @@ lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba,
4596 if (rc) { 4638 if (rc) {
4597 lpfc_mbuf_free(phba, mp->virt, mp->phys); 4639 lpfc_mbuf_free(phba, mp->virt, mp->phys);
4598 kfree(mp); 4640 kfree(mp);
4599 return -EIO; 4641 rc = -EIO;
4642 goto out_free_mboxq;
4600 } 4643 }
4601 data_length = mqe->un.mb_words[5]; 4644 data_length = mqe->un.mb_words[5];
4602 if (data_length > DMP_RGN23_SIZE) { 4645 if (data_length > DMP_RGN23_SIZE) {
4603 lpfc_mbuf_free(phba, mp->virt, mp->phys); 4646 lpfc_mbuf_free(phba, mp->virt, mp->phys);
4604 kfree(mp); 4647 kfree(mp);
4605 return -EIO; 4648 rc = -EIO;
4649 goto out_free_mboxq;
4606 } 4650 }
4607 4651
4608 lpfc_parse_fcoe_conf(phba, mp->virt, data_length); 4652 lpfc_parse_fcoe_conf(phba, mp->virt, data_length);
4609 lpfc_mbuf_free(phba, mp->virt, mp->phys); 4653 lpfc_mbuf_free(phba, mp->virt, mp->phys);
4610 kfree(mp); 4654 kfree(mp);
4611 return 0; 4655 rc = 0;
4656
4657out_free_mboxq:
4658 mempool_free(mboxq, phba->mbox_mem_pool);
4659 return rc;
4612} 4660}
4613 4661
4614/** 4662/**
@@ -4706,7 +4754,6 @@ static int
4706lpfc_sli4_retrieve_pport_name(struct lpfc_hba *phba) 4754lpfc_sli4_retrieve_pport_name(struct lpfc_hba *phba)
4707{ 4755{
4708 LPFC_MBOXQ_t *mboxq; 4756 LPFC_MBOXQ_t *mboxq;
4709 struct lpfc_mbx_read_config *rd_config;
4710 struct lpfc_mbx_get_cntl_attributes *mbx_cntl_attr; 4757 struct lpfc_mbx_get_cntl_attributes *mbx_cntl_attr;
4711 struct lpfc_controller_attribute *cntl_attr; 4758 struct lpfc_controller_attribute *cntl_attr;
4712 struct lpfc_mbx_get_port_name *get_port_name; 4759 struct lpfc_mbx_get_port_name *get_port_name;
@@ -4724,33 +4771,11 @@ lpfc_sli4_retrieve_pport_name(struct lpfc_hba *phba)
4724 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 4771 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4725 if (!mboxq) 4772 if (!mboxq)
4726 return -ENOMEM; 4773 return -ENOMEM;
4727
4728 /* obtain link type and link number via READ_CONFIG */ 4774 /* obtain link type and link number via READ_CONFIG */
4729 lpfc_read_config(phba, mboxq); 4775 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_INVAL;
4730 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); 4776 lpfc_sli4_read_config(phba);
4731 if (rc == MBX_SUCCESS) { 4777 if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL)
4732 rd_config = &mboxq->u.mqe.un.rd_config; 4778 goto retrieve_ppname;
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 4779
4755 /* obtain link type and link number via COMMON_GET_CNTL_ATTRIBUTES */ 4780 /* obtain link type and link number via COMMON_GET_CNTL_ATTRIBUTES */
4756 reqlen = sizeof(struct lpfc_mbx_get_cntl_attributes); 4781 reqlen = sizeof(struct lpfc_mbx_get_cntl_attributes);
@@ -4875,14 +4900,19 @@ lpfc_sli4_arm_cqeq_intr(struct lpfc_hba *phba)
4875 lpfc_sli4_cq_release(phba->sli4_hba.mbx_cq, LPFC_QUEUE_REARM); 4900 lpfc_sli4_cq_release(phba->sli4_hba.mbx_cq, LPFC_QUEUE_REARM);
4876 lpfc_sli4_cq_release(phba->sli4_hba.els_cq, LPFC_QUEUE_REARM); 4901 lpfc_sli4_cq_release(phba->sli4_hba.els_cq, LPFC_QUEUE_REARM);
4877 fcp_eqidx = 0; 4902 fcp_eqidx = 0;
4878 do 4903 if (phba->sli4_hba.fcp_cq) {
4879 lpfc_sli4_cq_release(phba->sli4_hba.fcp_cq[fcp_eqidx], 4904 do
4880 LPFC_QUEUE_REARM); 4905 lpfc_sli4_cq_release(phba->sli4_hba.fcp_cq[fcp_eqidx],
4881 while (++fcp_eqidx < phba->cfg_fcp_eq_count); 4906 LPFC_QUEUE_REARM);
4907 while (++fcp_eqidx < phba->cfg_fcp_eq_count);
4908 }
4882 lpfc_sli4_eq_release(phba->sli4_hba.sp_eq, LPFC_QUEUE_REARM); 4909 lpfc_sli4_eq_release(phba->sli4_hba.sp_eq, LPFC_QUEUE_REARM);
4883 for (fcp_eqidx = 0; fcp_eqidx < phba->cfg_fcp_eq_count; fcp_eqidx++) 4910 if (phba->sli4_hba.fp_eq) {
4884 lpfc_sli4_eq_release(phba->sli4_hba.fp_eq[fcp_eqidx], 4911 for (fcp_eqidx = 0; fcp_eqidx < phba->cfg_fcp_eq_count;
4885 LPFC_QUEUE_REARM); 4912 fcp_eqidx++)
4913 lpfc_sli4_eq_release(phba->sli4_hba.fp_eq[fcp_eqidx],
4914 LPFC_QUEUE_REARM);
4915 }
4886} 4916}
4887 4917
4888/** 4918/**
@@ -5457,6 +5487,8 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
5457 uint16_t count, base; 5487 uint16_t count, base;
5458 unsigned long longs; 5488 unsigned long longs;
5459 5489
5490 if (!phba->sli4_hba.rpi_hdrs_in_use)
5491 phba->sli4_hba.next_rpi = phba->sli4_hba.max_cfg_param.max_rpi;
5460 if (phba->sli4_hba.extents_in_use) { 5492 if (phba->sli4_hba.extents_in_use) {
5461 /* 5493 /*
5462 * The port supports resource extents. The XRI, VPI, VFI, RPI 5494 * The port supports resource extents. The XRI, VPI, VFI, RPI
@@ -5538,9 +5570,10 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
5538 * need any action - just exit. 5570 * need any action - just exit.
5539 */ 5571 */
5540 if (bf_get(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags) == 5572 if (bf_get(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags) ==
5541 LPFC_IDX_RSRC_RDY) 5573 LPFC_IDX_RSRC_RDY) {
5542 return 0; 5574 lpfc_sli4_dealloc_resource_identifiers(phba);
5543 5575 lpfc_sli4_remove_rpis(phba);
5576 }
5544 /* RPIs. */ 5577 /* RPIs. */
5545 count = phba->sli4_hba.max_cfg_param.max_rpi; 5578 count = phba->sli4_hba.max_cfg_param.max_rpi;
5546 base = phba->sli4_hba.max_cfg_param.rpi_base; 5579 base = phba->sli4_hba.max_cfg_param.rpi_base;
@@ -5880,14 +5913,6 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
5880 if (!mboxq) 5913 if (!mboxq)
5881 return -ENOMEM; 5914 return -ENOMEM;
5882 5915
5883 /*
5884 * Continue initialization with default values even if driver failed
5885 * to read FCoE param config regions
5886 */
5887 if (lpfc_sli4_read_fcoe_params(phba, mboxq))
5888 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | LOG_INIT,
5889 "2570 Failed to read FCoE parameters\n");
5890
5891 /* Issue READ_REV to collect vpd and FW information. */ 5916 /* Issue READ_REV to collect vpd and FW information. */
5892 vpd_size = SLI4_PAGE_SIZE; 5917 vpd_size = SLI4_PAGE_SIZE;
5893 vpd = kzalloc(vpd_size, GFP_KERNEL); 5918 vpd = kzalloc(vpd_size, GFP_KERNEL);
@@ -5925,6 +5950,16 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
5925 } 5950 }
5926 5951
5927 /* 5952 /*
5953 * Continue initialization with default values even if driver failed
5954 * to read FCoE param config regions, only read parameters if the
5955 * board is FCoE
5956 */
5957 if (phba->hba_flag & HBA_FCOE_MODE &&
5958 lpfc_sli4_read_fcoe_params(phba))
5959 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | LOG_INIT,
5960 "2570 Failed to read FCoE parameters\n");
5961
5962 /*
5928 * Retrieve sli4 device physical port name, failure of doing it 5963 * Retrieve sli4 device physical port name, failure of doing it
5929 * is considered as non-fatal. 5964 * is considered as non-fatal.
5930 */ 5965 */
@@ -6044,6 +6079,8 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
6044 "rc = x%x\n", rc); 6079 "rc = x%x\n", rc);
6045 goto out_free_mbox; 6080 goto out_free_mbox;
6046 } 6081 }
6082 /* update physical xri mappings in the scsi buffers */
6083 lpfc_scsi_buf_update(phba);
6047 6084
6048 /* Read the port's service parameters. */ 6085 /* Read the port's service parameters. */
6049 rc = lpfc_read_sparam(phba, mboxq, vport->vpi); 6086 rc = lpfc_read_sparam(phba, mboxq, vport->vpi);
@@ -6205,7 +6242,11 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
6205 rc = 0; 6242 rc = 0;
6206 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi, 6243 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi,
6207 &mboxq->u.mqe.un.reg_fcfi); 6244 &mboxq->u.mqe.un.reg_fcfi);
6245
6246 /* Check if the port is configured to be disabled */
6247 lpfc_sli_read_link_ste(phba);
6208 } 6248 }
6249
6209 /* 6250 /*
6210 * The port is ready, set the host's link state to LINK_DOWN 6251 * The port is ready, set the host's link state to LINK_DOWN
6211 * in preparation for link interrupts. 6252 * in preparation for link interrupts.
@@ -6213,10 +6254,25 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
6213 spin_lock_irq(&phba->hbalock); 6254 spin_lock_irq(&phba->hbalock);
6214 phba->link_state = LPFC_LINK_DOWN; 6255 phba->link_state = LPFC_LINK_DOWN;
6215 spin_unlock_irq(&phba->hbalock); 6256 spin_unlock_irq(&phba->hbalock);
6216 if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { 6257 if (!(phba->hba_flag & HBA_FCOE_MODE) &&
6217 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); 6258 (phba->hba_flag & LINK_DISABLED)) {
6218 if (rc) 6259 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_SLI,
6260 "3103 Adapter Link is disabled.\n");
6261 lpfc_down_link(phba, mboxq);
6262 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
6263 if (rc != MBX_SUCCESS) {
6264 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_SLI,
6265 "3104 Adapter failed to issue "
6266 "DOWN_LINK mbox cmd, rc:x%x\n", rc);
6219 goto out_unset_queue; 6267 goto out_unset_queue;
6268 }
6269 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) {
6270 /* don't perform init_link on SLI4 FC port loopback test */
6271 if (!(phba->link_flag & LS_LOOPBACK_MODE)) {
6272 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT);
6273 if (rc)
6274 goto out_unset_queue;
6275 }
6220 } 6276 }
6221 mempool_free(mboxq, phba->mbox_mem_pool); 6277 mempool_free(mboxq, phba->mbox_mem_pool);
6222 return rc; 6278 return rc;
@@ -7487,6 +7543,7 @@ lpfc_sli4_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
7487 struct ulp_bde64 *bpl = NULL; 7543 struct ulp_bde64 *bpl = NULL;
7488 struct ulp_bde64 bde; 7544 struct ulp_bde64 bde;
7489 struct sli4_sge *sgl = NULL; 7545 struct sli4_sge *sgl = NULL;
7546 struct lpfc_dmabuf *dmabuf;
7490 IOCB_t *icmd; 7547 IOCB_t *icmd;
7491 int numBdes = 0; 7548 int numBdes = 0;
7492 int i = 0; 7549 int i = 0;
@@ -7505,9 +7562,12 @@ lpfc_sli4_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
7505 * have not been byteswapped yet so there is no 7562 * have not been byteswapped yet so there is no
7506 * need to swap them back. 7563 * need to swap them back.
7507 */ 7564 */
7508 bpl = (struct ulp_bde64 *) 7565 if (piocbq->context3)
7509 ((struct lpfc_dmabuf *)piocbq->context3)->virt; 7566 dmabuf = (struct lpfc_dmabuf *)piocbq->context3;
7567 else
7568 return xritag;
7510 7569
7570 bpl = (struct ulp_bde64 *)dmabuf->virt;
7511 if (!bpl) 7571 if (!bpl)
7512 return xritag; 7572 return xritag;
7513 7573
@@ -7616,6 +7676,8 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7616 int numBdes, i; 7676 int numBdes, i;
7617 struct ulp_bde64 bde; 7677 struct ulp_bde64 bde;
7618 struct lpfc_nodelist *ndlp; 7678 struct lpfc_nodelist *ndlp;
7679 uint32_t *pcmd;
7680 uint32_t if_type;
7619 7681
7620 fip = phba->hba_flag & HBA_FIP_SUPPORT; 7682 fip = phba->hba_flag & HBA_FIP_SUPPORT;
7621 /* The fcp commands will set command type */ 7683 /* The fcp commands will set command type */
@@ -7669,6 +7731,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7669 iocbq->iocb.ulpCommand); 7731 iocbq->iocb.ulpCommand);
7670 return IOCB_ERROR; 7732 return IOCB_ERROR;
7671 } 7733 }
7734
7672 wqe->els_req.payload_len = xmit_len; 7735 wqe->els_req.payload_len = xmit_len;
7673 /* Els_reguest64 has a TMO */ 7736 /* Els_reguest64 has a TMO */
7674 bf_set(wqe_tmo, &wqe->els_req.wqe_com, 7737 bf_set(wqe_tmo, &wqe->els_req.wqe_com,
@@ -7683,9 +7746,28 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7683 bf_set(wqe_ct, &wqe->els_req.wqe_com, ct); 7746 bf_set(wqe_ct, &wqe->els_req.wqe_com, ct);
7684 bf_set(wqe_pu, &wqe->els_req.wqe_com, 0); 7747 bf_set(wqe_pu, &wqe->els_req.wqe_com, 0);
7685 /* CCP CCPE PV PRI in word10 were set in the memcpy */ 7748 /* CCP CCPE PV PRI in word10 were set in the memcpy */
7686 if (command_type == ELS_COMMAND_FIP) { 7749 if (command_type == ELS_COMMAND_FIP)
7687 els_id = ((iocbq->iocb_flag & LPFC_FIP_ELS_ID_MASK) 7750 els_id = ((iocbq->iocb_flag & LPFC_FIP_ELS_ID_MASK)
7688 >> LPFC_FIP_ELS_ID_SHIFT); 7751 >> LPFC_FIP_ELS_ID_SHIFT);
7752 pcmd = (uint32_t *) (((struct lpfc_dmabuf *)
7753 iocbq->context2)->virt);
7754 if_type = bf_get(lpfc_sli_intf_if_type,
7755 &phba->sli4_hba.sli_intf);
7756 if (if_type == LPFC_SLI_INTF_IF_TYPE_2) {
7757 if (pcmd && (*pcmd == ELS_CMD_FLOGI ||
7758 *pcmd == ELS_CMD_SCR ||
7759 *pcmd == ELS_CMD_PLOGI)) {
7760 bf_set(els_req64_sp, &wqe->els_req, 1);
7761 bf_set(els_req64_sid, &wqe->els_req,
7762 iocbq->vport->fc_myDID);
7763 bf_set(wqe_ct, &wqe->els_req.wqe_com, 1);
7764 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com,
7765 phba->vpi_ids[phba->pport->vpi]);
7766 } else if (iocbq->context1) {
7767 bf_set(wqe_ct, &wqe->els_req.wqe_com, 0);
7768 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com,
7769 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
7770 }
7689 } 7771 }
7690 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com, 7772 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com,
7691 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); 7773 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
@@ -7704,6 +7786,8 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7704 /* The entire sequence is transmitted for this IOCB */ 7786 /* The entire sequence is transmitted for this IOCB */
7705 xmit_len = total_len; 7787 xmit_len = total_len;
7706 cmnd = CMD_XMIT_SEQUENCE64_CR; 7788 cmnd = CMD_XMIT_SEQUENCE64_CR;
7789 if (phba->link_flag & LS_LOOPBACK_MODE)
7790 bf_set(wqe_xo, &wqe->xmit_sequence.wge_ctl, 1);
7707 case CMD_XMIT_SEQUENCE64_CR: 7791 case CMD_XMIT_SEQUENCE64_CR:
7708 /* word3 iocb=io_tag32 wqe=reserved */ 7792 /* word3 iocb=io_tag32 wqe=reserved */
7709 wqe->xmit_sequence.rsvd3 = 0; 7793 wqe->xmit_sequence.rsvd3 = 0;
@@ -7846,6 +7930,16 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
7846 bf_set(wqe_ebde_cnt, &wqe->xmit_els_rsp.wqe_com, 0); 7930 bf_set(wqe_ebde_cnt, &wqe->xmit_els_rsp.wqe_com, 0);
7847 bf_set(wqe_rsp_temp_rpi, &wqe->xmit_els_rsp, 7931 bf_set(wqe_rsp_temp_rpi, &wqe->xmit_els_rsp,
7848 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); 7932 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
7933 pcmd = (uint32_t *) (((struct lpfc_dmabuf *)
7934 iocbq->context2)->virt);
7935 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
7936 bf_set(els_req64_sp, &wqe->els_req, 1);
7937 bf_set(els_req64_sid, &wqe->els_req,
7938 iocbq->vport->fc_myDID);
7939 bf_set(wqe_ct, &wqe->els_req.wqe_com, 1);
7940 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com,
7941 phba->vpi_ids[phba->pport->vpi]);
7942 }
7849 command_type = OTHER_COMMAND; 7943 command_type = OTHER_COMMAND;
7850 break; 7944 break;
7851 case CMD_CLOSE_XRI_CN: 7945 case CMD_CLOSE_XRI_CN:
@@ -8037,6 +8131,8 @@ __lpfc_sli_issue_iocb_s4(struct lpfc_hba *phba, uint32_t ring_number,
8037 */ 8131 */
8038 if (piocb->iocb_flag & LPFC_IO_FCP) 8132 if (piocb->iocb_flag & LPFC_IO_FCP)
8039 piocb->fcp_wqidx = lpfc_sli4_scmd_to_wqidx_distr(phba); 8133 piocb->fcp_wqidx = lpfc_sli4_scmd_to_wqidx_distr(phba);
8134 if (unlikely(!phba->sli4_hba.fcp_wq))
8135 return IOCB_ERROR;
8040 if (lpfc_sli4_wq_put(phba->sli4_hba.fcp_wq[piocb->fcp_wqidx], 8136 if (lpfc_sli4_wq_put(phba->sli4_hba.fcp_wq[piocb->fcp_wqidx],
8041 &wqe)) 8137 &wqe))
8042 return IOCB_ERROR; 8138 return IOCB_ERROR;
@@ -8173,6 +8269,137 @@ lpfc_extra_ring_setup( struct lpfc_hba *phba)
8173 return 0; 8269 return 0;
8174} 8270}
8175 8271
8272/* lpfc_sli_abts_recover_port - Recover a port that failed an ABTS.
8273 * @vport: pointer to virtual port object.
8274 * @ndlp: nodelist pointer for the impacted rport.
8275 *
8276 * The driver calls this routine in response to a XRI ABORT CQE
8277 * event from the port. In this event, the driver is required to
8278 * recover its login to the rport even though its login may be valid
8279 * from the driver's perspective. The failed ABTS notice from the
8280 * port indicates the rport is not responding.
8281 */
8282static void
8283lpfc_sli_abts_recover_port(struct lpfc_vport *vport,
8284 struct lpfc_nodelist *ndlp)
8285{
8286 struct Scsi_Host *shost;
8287 struct lpfc_hba *phba;
8288 unsigned long flags = 0;
8289
8290 shost = lpfc_shost_from_vport(vport);
8291 phba = vport->phba;
8292 if (ndlp->nlp_state != NLP_STE_MAPPED_NODE) {
8293 lpfc_printf_log(phba, KERN_INFO,
8294 LOG_SLI, "3093 No rport recovery needed. "
8295 "rport in state 0x%x\n",
8296 ndlp->nlp_state);
8297 return;
8298 }
8299 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
8300 "3094 Start rport recovery on shost id 0x%x "
8301 "fc_id 0x%06x vpi 0x%x rpi 0x%x state 0x%x "
8302 "flags 0x%x\n",
8303 shost->host_no, ndlp->nlp_DID,
8304 vport->vpi, ndlp->nlp_rpi, ndlp->nlp_state,
8305 ndlp->nlp_flag);
8306 /*
8307 * The rport is not responding. Don't attempt ADISC recovery.
8308 * Remove the FCP-2 flag to force a PLOGI.
8309 */
8310 spin_lock_irqsave(shost->host_lock, flags);
8311 ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
8312 spin_unlock_irqrestore(shost->host_lock, flags);
8313 lpfc_disc_state_machine(vport, ndlp, NULL,
8314 NLP_EVT_DEVICE_RECOVERY);
8315 lpfc_cancel_retry_delay_tmo(vport, ndlp);
8316 spin_lock_irqsave(shost->host_lock, flags);
8317 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
8318 spin_unlock_irqrestore(shost->host_lock, flags);
8319 lpfc_disc_start(vport);
8320}
8321
8322/* lpfc_sli_abts_err_handler - handle a failed ABTS request from an SLI3 port.
8323 * @phba: Pointer to HBA context object.
8324 * @iocbq: Pointer to iocb object.
8325 *
8326 * The async_event handler calls this routine when it receives
8327 * an ASYNC_STATUS_CN event from the port. The port generates
8328 * this event when an Abort Sequence request to an rport fails
8329 * twice in succession. The abort could be originated by the
8330 * driver or by the port. The ABTS could have been for an ELS
8331 * or FCP IO. The port only generates this event when an ABTS
8332 * fails to complete after one retry.
8333 */
8334static void
8335lpfc_sli_abts_err_handler(struct lpfc_hba *phba,
8336 struct lpfc_iocbq *iocbq)
8337{
8338 struct lpfc_nodelist *ndlp = NULL;
8339 uint16_t rpi = 0, vpi = 0;
8340 struct lpfc_vport *vport = NULL;
8341
8342 /* The rpi in the ulpContext is vport-sensitive. */
8343 vpi = iocbq->iocb.un.asyncstat.sub_ctxt_tag;
8344 rpi = iocbq->iocb.ulpContext;
8345
8346 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
8347 "3092 Port generated ABTS async event "
8348 "on vpi %d rpi %d status 0x%x\n",
8349 vpi, rpi, iocbq->iocb.ulpStatus);
8350
8351 vport = lpfc_find_vport_by_vpid(phba, vpi);
8352 if (!vport)
8353 goto err_exit;
8354 ndlp = lpfc_findnode_rpi(vport, rpi);
8355 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
8356 goto err_exit;
8357
8358 if (iocbq->iocb.ulpStatus == IOSTAT_LOCAL_REJECT)
8359 lpfc_sli_abts_recover_port(vport, ndlp);
8360 return;
8361
8362 err_exit:
8363 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
8364 "3095 Event Context not found, no "
8365 "action on vpi %d rpi %d status 0x%x, reason 0x%x\n",
8366 iocbq->iocb.ulpContext, iocbq->iocb.ulpStatus,
8367 vpi, rpi);
8368}
8369
8370/* lpfc_sli4_abts_err_handler - handle a failed ABTS request from an SLI4 port.
8371 * @phba: pointer to HBA context object.
8372 * @ndlp: nodelist pointer for the impacted rport.
8373 * @axri: pointer to the wcqe containing the failed exchange.
8374 *
8375 * The driver calls this routine when it receives an ABORT_XRI_FCP CQE from the
8376 * port. The port generates this event when an abort exchange request to an
8377 * rport fails twice in succession with no reply. The abort could be originated
8378 * by the driver or by the port. The ABTS could have been for an ELS or FCP IO.
8379 */
8380void
8381lpfc_sli4_abts_err_handler(struct lpfc_hba *phba,
8382 struct lpfc_nodelist *ndlp,
8383 struct sli4_wcqe_xri_aborted *axri)
8384{
8385 struct lpfc_vport *vport;
8386
8387 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
8388 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
8389 "3115 Node Context not found, driver "
8390 "ignoring abts err event\n");
8391 vport = ndlp->vport;
8392 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
8393 "3116 Port generated FCP XRI ABORT event on "
8394 "vpi %d rpi %d xri x%x status 0x%x\n",
8395 ndlp->vport->vpi, ndlp->nlp_rpi,
8396 bf_get(lpfc_wcqe_xa_xri, axri),
8397 bf_get(lpfc_wcqe_xa_status, axri));
8398
8399 if (bf_get(lpfc_wcqe_xa_status, axri) == IOSTAT_LOCAL_REJECT)
8400 lpfc_sli_abts_recover_port(vport, ndlp);
8401}
8402
8176/** 8403/**
8177 * lpfc_sli_async_event_handler - ASYNC iocb handler function 8404 * lpfc_sli_async_event_handler - ASYNC iocb handler function
8178 * @phba: Pointer to HBA context object. 8405 * @phba: Pointer to HBA context object.
@@ -8192,63 +8419,58 @@ lpfc_sli_async_event_handler(struct lpfc_hba * phba,
8192{ 8419{
8193 IOCB_t *icmd; 8420 IOCB_t *icmd;
8194 uint16_t evt_code; 8421 uint16_t evt_code;
8195 uint16_t temp;
8196 struct temp_event temp_event_data; 8422 struct temp_event temp_event_data;
8197 struct Scsi_Host *shost; 8423 struct Scsi_Host *shost;
8198 uint32_t *iocb_w; 8424 uint32_t *iocb_w;
8199 8425
8200 icmd = &iocbq->iocb; 8426 icmd = &iocbq->iocb;
8201 evt_code = icmd->un.asyncstat.evt_code; 8427 evt_code = icmd->un.asyncstat.evt_code;
8202 temp = icmd->ulpContext;
8203 8428
8204 if ((evt_code != ASYNC_TEMP_WARN) && 8429 switch (evt_code) {
8205 (evt_code != ASYNC_TEMP_SAFE)) { 8430 case ASYNC_TEMP_WARN:
8431 case ASYNC_TEMP_SAFE:
8432 temp_event_data.data = (uint32_t) icmd->ulpContext;
8433 temp_event_data.event_type = FC_REG_TEMPERATURE_EVENT;
8434 if (evt_code == ASYNC_TEMP_WARN) {
8435 temp_event_data.event_code = LPFC_THRESHOLD_TEMP;
8436 lpfc_printf_log(phba, KERN_ERR, LOG_TEMP,
8437 "0347 Adapter is very hot, please take "
8438 "corrective action. temperature : %d Celsius\n",
8439 (uint32_t) icmd->ulpContext);
8440 } else {
8441 temp_event_data.event_code = LPFC_NORMAL_TEMP;
8442 lpfc_printf_log(phba, KERN_ERR, LOG_TEMP,
8443 "0340 Adapter temperature is OK now. "
8444 "temperature : %d Celsius\n",
8445 (uint32_t) icmd->ulpContext);
8446 }
8447
8448 /* Send temperature change event to applications */
8449 shost = lpfc_shost_from_vport(phba->pport);
8450 fc_host_post_vendor_event(shost, fc_get_event_number(),
8451 sizeof(temp_event_data), (char *) &temp_event_data,
8452 LPFC_NL_VENDOR_ID);
8453 break;
8454 case ASYNC_STATUS_CN:
8455 lpfc_sli_abts_err_handler(phba, iocbq);
8456 break;
8457 default:
8206 iocb_w = (uint32_t *) icmd; 8458 iocb_w = (uint32_t *) icmd;
8207 lpfc_printf_log(phba, 8459 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
8208 KERN_ERR,
8209 LOG_SLI,
8210 "0346 Ring %d handler: unexpected ASYNC_STATUS" 8460 "0346 Ring %d handler: unexpected ASYNC_STATUS"
8211 " evt_code 0x%x\n" 8461 " evt_code 0x%x\n"
8212 "W0 0x%08x W1 0x%08x W2 0x%08x W3 0x%08x\n" 8462 "W0 0x%08x W1 0x%08x W2 0x%08x W3 0x%08x\n"
8213 "W4 0x%08x W5 0x%08x W6 0x%08x W7 0x%08x\n" 8463 "W4 0x%08x W5 0x%08x W6 0x%08x W7 0x%08x\n"
8214 "W8 0x%08x W9 0x%08x W10 0x%08x W11 0x%08x\n" 8464 "W8 0x%08x W9 0x%08x W10 0x%08x W11 0x%08x\n"
8215 "W12 0x%08x W13 0x%08x W14 0x%08x W15 0x%08x\n", 8465 "W12 0x%08x W13 0x%08x W14 0x%08x W15 0x%08x\n",
8216 pring->ringno, 8466 pring->ringno, icmd->un.asyncstat.evt_code,
8217 icmd->un.asyncstat.evt_code,
8218 iocb_w[0], iocb_w[1], iocb_w[2], iocb_w[3], 8467 iocb_w[0], iocb_w[1], iocb_w[2], iocb_w[3],
8219 iocb_w[4], iocb_w[5], iocb_w[6], iocb_w[7], 8468 iocb_w[4], iocb_w[5], iocb_w[6], iocb_w[7],
8220 iocb_w[8], iocb_w[9], iocb_w[10], iocb_w[11], 8469 iocb_w[8], iocb_w[9], iocb_w[10], iocb_w[11],
8221 iocb_w[12], iocb_w[13], iocb_w[14], iocb_w[15]); 8470 iocb_w[12], iocb_w[13], iocb_w[14], iocb_w[15]);
8222 8471
8223 return; 8472 break;
8224 }
8225 temp_event_data.data = (uint32_t)temp;
8226 temp_event_data.event_type = FC_REG_TEMPERATURE_EVENT;
8227 if (evt_code == ASYNC_TEMP_WARN) {
8228 temp_event_data.event_code = LPFC_THRESHOLD_TEMP;
8229 lpfc_printf_log(phba,
8230 KERN_ERR,
8231 LOG_TEMP,
8232 "0347 Adapter is very hot, please take "
8233 "corrective action. temperature : %d Celsius\n",
8234 temp);
8235 }
8236 if (evt_code == ASYNC_TEMP_SAFE) {
8237 temp_event_data.event_code = LPFC_NORMAL_TEMP;
8238 lpfc_printf_log(phba,
8239 KERN_ERR,
8240 LOG_TEMP,
8241 "0340 Adapter temperature is OK now. "
8242 "temperature : %d Celsius\n",
8243 temp);
8244 } 8473 }
8245
8246 /* Send temperature change event to applications */
8247 shost = lpfc_shost_from_vport(phba->pport);
8248 fc_host_post_vendor_event(shost, fc_get_event_number(),
8249 sizeof(temp_event_data), (char *) &temp_event_data,
8250 LPFC_NL_VENDOR_ID);
8251
8252} 8474}
8253 8475
8254 8476
@@ -8823,12 +9045,14 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
8823{ 9045{
8824 IOCB_t *irsp = &rspiocb->iocb; 9046 IOCB_t *irsp = &rspiocb->iocb;
8825 uint16_t abort_iotag, abort_context; 9047 uint16_t abort_iotag, abort_context;
8826 struct lpfc_iocbq *abort_iocb; 9048 struct lpfc_iocbq *abort_iocb = NULL;
8827 struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
8828
8829 abort_iocb = NULL;
8830 9049
8831 if (irsp->ulpStatus) { 9050 if (irsp->ulpStatus) {
9051
9052 /*
9053 * Assume that the port already completed and returned, or
9054 * will return the iocb. Just Log the message.
9055 */
8832 abort_context = cmdiocb->iocb.un.acxri.abortContextTag; 9056 abort_context = cmdiocb->iocb.un.acxri.abortContextTag;
8833 abort_iotag = cmdiocb->iocb.un.acxri.abortIoTag; 9057 abort_iotag = cmdiocb->iocb.un.acxri.abortIoTag;
8834 9058
@@ -8846,68 +9070,15 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
8846 */ 9070 */
8847 abort_iocb = phba->sli.iocbq_lookup[abort_context]; 9071 abort_iocb = phba->sli.iocbq_lookup[abort_context];
8848 9072
8849 /*
8850 * If the iocb is not found in Firmware queue the iocb
8851 * might have completed already. Do not free it again.
8852 */
8853 if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) {
8854 if (irsp->un.ulpWord[4] != IOERR_NO_XRI) {
8855 spin_unlock_irq(&phba->hbalock);
8856 lpfc_sli_release_iocbq(phba, cmdiocb);
8857 return;
8858 }
8859 /* For SLI4 the ulpContext field for abort IOCB
8860 * holds the iotag of the IOCB being aborted so
8861 * the local abort_context needs to be reset to
8862 * match the aborted IOCBs ulpContext.
8863 */
8864 if (abort_iocb && phba->sli_rev == LPFC_SLI_REV4)
8865 abort_context = abort_iocb->iocb.ulpContext;
8866 }
8867
8868 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS | LOG_SLI, 9073 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS | LOG_SLI,
8869 "0327 Cannot abort els iocb %p " 9074 "0327 Cannot abort els iocb %p "
8870 "with tag %x context %x, abort status %x, " 9075 "with tag %x context %x, abort status %x, "
8871 "abort code %x\n", 9076 "abort code %x\n",
8872 abort_iocb, abort_iotag, abort_context, 9077 abort_iocb, abort_iotag, abort_context,
8873 irsp->ulpStatus, irsp->un.ulpWord[4]); 9078 irsp->ulpStatus, irsp->un.ulpWord[4]);
8874 /*
8875 * make sure we have the right iocbq before taking it
8876 * off the txcmplq and try to call completion routine.
8877 */
8878 if (!abort_iocb ||
8879 abort_iocb->iocb.ulpContext != abort_context ||
8880 (abort_iocb->iocb_flag & LPFC_DRIVER_ABORTED) == 0)
8881 spin_unlock_irq(&phba->hbalock);
8882 else if (phba->sli_rev < LPFC_SLI_REV4) {
8883 /*
8884 * leave the SLI4 aborted command on the txcmplq
8885 * list and the command complete WCQE's XB bit
8886 * will tell whether the SGL (XRI) can be released
8887 * immediately or to the aborted SGL list for the
8888 * following abort XRI from the HBA.
8889 */
8890 list_del_init(&abort_iocb->list);
8891 if (abort_iocb->iocb_flag & LPFC_IO_ON_Q) {
8892 abort_iocb->iocb_flag &= ~LPFC_IO_ON_Q;
8893 pring->txcmplq_cnt--;
8894 }
8895 9079
8896 /* Firmware could still be in progress of DMAing 9080 spin_unlock_irq(&phba->hbalock);
8897 * payload, so don't free data buffer till after
8898 * a hbeat.
8899 */
8900 abort_iocb->iocb_flag |= LPFC_DELAY_MEM_FREE;
8901 abort_iocb->iocb_flag &= ~LPFC_DRIVER_ABORTED;
8902 spin_unlock_irq(&phba->hbalock);
8903
8904 abort_iocb->iocb.ulpStatus = IOSTAT_LOCAL_REJECT;
8905 abort_iocb->iocb.un.ulpWord[4] = IOERR_ABORT_REQUESTED;
8906 (abort_iocb->iocb_cmpl)(phba, abort_iocb, abort_iocb);
8907 } else
8908 spin_unlock_irq(&phba->hbalock);
8909 } 9081 }
8910
8911 lpfc_sli_release_iocbq(phba, cmdiocb); 9082 lpfc_sli_release_iocbq(phba, cmdiocb);
8912 return; 9083 return;
8913} 9084}
@@ -9258,6 +9429,14 @@ void
9258lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, 9429lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
9259 struct lpfc_iocbq *rspiocb) 9430 struct lpfc_iocbq *rspiocb)
9260{ 9431{
9432 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
9433 "3096 ABORT_XRI_CN completing on xri x%x "
9434 "original iotag x%x, abort cmd iotag x%x "
9435 "status 0x%x, reason 0x%x\n",
9436 cmdiocb->iocb.un.acxri.abortContextTag,
9437 cmdiocb->iocb.un.acxri.abortIoTag,
9438 cmdiocb->iotag, rspiocb->iocb.ulpStatus,
9439 rspiocb->iocb.un.ulpWord[4]);
9261 lpfc_sli_release_iocbq(phba, cmdiocb); 9440 lpfc_sli_release_iocbq(phba, cmdiocb);
9262 return; 9441 return;
9263} 9442}
@@ -9771,7 +9950,7 @@ lpfc_sli4_eratt_read(struct lpfc_hba *phba)
9771 phba->work_status[1] = 9950 phba->work_status[1] =
9772 readl(phba->sli4_hba.u.if_type2.ERR2regaddr); 9951 readl(phba->sli4_hba.u.if_type2.ERR2regaddr);
9773 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 9952 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
9774 "2885 Port Error Detected: " 9953 "2885 Port Status Event: "
9775 "port status reg 0x%x, " 9954 "port status reg 0x%x, "
9776 "port smphr reg 0x%x, " 9955 "port smphr reg 0x%x, "
9777 "error 1=0x%x, error 2=0x%x\n", 9956 "error 1=0x%x, error 2=0x%x\n",
@@ -10777,6 +10956,9 @@ static void
10777lpfc_sli4_sp_handle_rel_wcqe(struct lpfc_hba *phba, 10956lpfc_sli4_sp_handle_rel_wcqe(struct lpfc_hba *phba,
10778 struct lpfc_wcqe_release *wcqe) 10957 struct lpfc_wcqe_release *wcqe)
10779{ 10958{
10959 /* sanity check on queue memory */
10960 if (unlikely(!phba->sli4_hba.els_wq))
10961 return;
10780 /* Check for the slow-path ELS work queue */ 10962 /* Check for the slow-path ELS work queue */
10781 if (bf_get(lpfc_wcqe_r_wq_id, wcqe) == phba->sli4_hba.els_wq->queue_id) 10963 if (bf_get(lpfc_wcqe_r_wq_id, wcqe) == phba->sli4_hba.els_wq->queue_id)
10782 lpfc_sli4_wq_release(phba->sli4_hba.els_wq, 10964 lpfc_sli4_wq_release(phba->sli4_hba.els_wq,
@@ -10866,6 +11048,10 @@ lpfc_sli4_sp_handle_rcqe(struct lpfc_hba *phba, struct lpfc_rcqe *rcqe)
10866 uint32_t status, rq_id; 11048 uint32_t status, rq_id;
10867 unsigned long iflags; 11049 unsigned long iflags;
10868 11050
11051 /* sanity check on queue memory */
11052 if (unlikely(!hrq) || unlikely(!drq))
11053 return workposted;
11054
10869 if (bf_get(lpfc_cqe_code, rcqe) == CQE_CODE_RECEIVE_V1) 11055 if (bf_get(lpfc_cqe_code, rcqe) == CQE_CODE_RECEIVE_V1)
10870 rq_id = bf_get(lpfc_rcqe_rq_id_v1, rcqe); 11056 rq_id = bf_get(lpfc_rcqe_rq_id_v1, rcqe);
10871 else 11057 else
@@ -11000,6 +11186,9 @@ lpfc_sli4_sp_handle_eqe(struct lpfc_hba *phba, struct lpfc_eqe *eqe)
11000 11186
11001 /* Search for completion queue pointer matching this cqid */ 11187 /* Search for completion queue pointer matching this cqid */
11002 speq = phba->sli4_hba.sp_eq; 11188 speq = phba->sli4_hba.sp_eq;
11189 /* sanity check on queue memory */
11190 if (unlikely(!speq))
11191 return;
11003 list_for_each_entry(childq, &speq->child_list, list) { 11192 list_for_each_entry(childq, &speq->child_list, list) {
11004 if (childq->queue_id == cqid) { 11193 if (childq->queue_id == cqid) {
11005 cq = childq; 11194 cq = childq;
@@ -11241,12 +11430,18 @@ lpfc_sli4_fp_handle_eqe(struct lpfc_hba *phba, struct lpfc_eqe *eqe,
11241 return; 11430 return;
11242 } 11431 }
11243 11432
11433 if (unlikely(!phba->sli4_hba.fcp_cq)) {
11434 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
11435 "3146 Fast-path completion queues "
11436 "does not exist\n");
11437 return;
11438 }
11244 cq = phba->sli4_hba.fcp_cq[fcp_cqidx]; 11439 cq = phba->sli4_hba.fcp_cq[fcp_cqidx];
11245 if (unlikely(!cq)) { 11440 if (unlikely(!cq)) {
11246 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) 11441 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE)
11247 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 11442 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
11248 "0367 Fast-path completion queue " 11443 "0367 Fast-path completion queue "
11249 "does not exist\n"); 11444 "(%d) does not exist\n", fcp_cqidx);
11250 return; 11445 return;
11251 } 11446 }
11252 11447
@@ -11417,6 +11612,8 @@ lpfc_sli4_fp_intr_handler(int irq, void *dev_id)
11417 11612
11418 /* Get to the EQ struct associated with this vector */ 11613 /* Get to the EQ struct associated with this vector */
11419 fpeq = phba->sli4_hba.fp_eq[fcp_eqidx]; 11614 fpeq = phba->sli4_hba.fp_eq[fcp_eqidx];
11615 if (unlikely(!fpeq))
11616 return IRQ_NONE;
11420 11617
11421 /* Check device state for handling interrupt */ 11618 /* Check device state for handling interrupt */
11422 if (unlikely(lpfc_intr_state_check(phba))) { 11619 if (unlikely(lpfc_intr_state_check(phba))) {
@@ -11635,6 +11832,9 @@ lpfc_eq_create(struct lpfc_hba *phba, struct lpfc_queue *eq, uint16_t imax)
11635 uint16_t dmult; 11832 uint16_t dmult;
11636 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; 11833 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz;
11637 11834
11835 /* sanity check on queue memory */
11836 if (!eq)
11837 return -ENODEV;
11638 if (!phba->sli4_hba.pc_sli4_params.supported) 11838 if (!phba->sli4_hba.pc_sli4_params.supported)
11639 hw_page_size = SLI4_PAGE_SIZE; 11839 hw_page_size = SLI4_PAGE_SIZE;
11640 11840
@@ -11751,6 +11951,9 @@ lpfc_cq_create(struct lpfc_hba *phba, struct lpfc_queue *cq,
11751 union lpfc_sli4_cfg_shdr *shdr; 11951 union lpfc_sli4_cfg_shdr *shdr;
11752 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; 11952 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz;
11753 11953
11954 /* sanity check on queue memory */
11955 if (!cq || !eq)
11956 return -ENODEV;
11754 if (!phba->sli4_hba.pc_sli4_params.supported) 11957 if (!phba->sli4_hba.pc_sli4_params.supported)
11755 hw_page_size = SLI4_PAGE_SIZE; 11958 hw_page_size = SLI4_PAGE_SIZE;
11756 11959
@@ -11933,6 +12136,9 @@ lpfc_mq_create(struct lpfc_hba *phba, struct lpfc_queue *mq,
11933 union lpfc_sli4_cfg_shdr *shdr; 12136 union lpfc_sli4_cfg_shdr *shdr;
11934 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; 12137 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz;
11935 12138
12139 /* sanity check on queue memory */
12140 if (!mq || !cq)
12141 return -ENODEV;
11936 if (!phba->sli4_hba.pc_sli4_params.supported) 12142 if (!phba->sli4_hba.pc_sli4_params.supported)
11937 hw_page_size = SLI4_PAGE_SIZE; 12143 hw_page_size = SLI4_PAGE_SIZE;
11938 12144
@@ -12083,6 +12289,9 @@ lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq,
12083 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; 12289 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz;
12084 struct dma_address *page; 12290 struct dma_address *page;
12085 12291
12292 /* sanity check on queue memory */
12293 if (!wq || !cq)
12294 return -ENODEV;
12086 if (!phba->sli4_hba.pc_sli4_params.supported) 12295 if (!phba->sli4_hba.pc_sli4_params.supported)
12087 hw_page_size = SLI4_PAGE_SIZE; 12296 hw_page_size = SLI4_PAGE_SIZE;
12088 12297
@@ -12151,6 +12360,7 @@ lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq,
12151 wq->subtype = subtype; 12360 wq->subtype = subtype;
12152 wq->host_index = 0; 12361 wq->host_index = 0;
12153 wq->hba_index = 0; 12362 wq->hba_index = 0;
12363 wq->entry_repost = LPFC_RELEASE_NOTIFICATION_INTERVAL;
12154 12364
12155 /* link the wq onto the parent cq child list */ 12365 /* link the wq onto the parent cq child list */
12156 list_add_tail(&wq->list, &cq->child_list); 12366 list_add_tail(&wq->list, &cq->child_list);
@@ -12174,6 +12384,9 @@ lpfc_rq_adjust_repost(struct lpfc_hba *phba, struct lpfc_queue *rq, int qno)
12174{ 12384{
12175 uint32_t cnt; 12385 uint32_t cnt;
12176 12386
12387 /* sanity check on queue memory */
12388 if (!rq)
12389 return;
12177 cnt = lpfc_hbq_defs[qno]->entry_count; 12390 cnt = lpfc_hbq_defs[qno]->entry_count;
12178 12391
12179 /* Recalc repost for RQs based on buffers initially posted */ 12392 /* Recalc repost for RQs based on buffers initially posted */
@@ -12219,6 +12432,9 @@ lpfc_rq_create(struct lpfc_hba *phba, struct lpfc_queue *hrq,
12219 union lpfc_sli4_cfg_shdr *shdr; 12432 union lpfc_sli4_cfg_shdr *shdr;
12220 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; 12433 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz;
12221 12434
12435 /* sanity check on queue memory */
12436 if (!hrq || !drq || !cq)
12437 return -ENODEV;
12222 if (!phba->sli4_hba.pc_sli4_params.supported) 12438 if (!phba->sli4_hba.pc_sli4_params.supported)
12223 hw_page_size = SLI4_PAGE_SIZE; 12439 hw_page_size = SLI4_PAGE_SIZE;
12224 12440
@@ -12420,6 +12636,7 @@ lpfc_eq_destroy(struct lpfc_hba *phba, struct lpfc_queue *eq)
12420 uint32_t shdr_status, shdr_add_status; 12636 uint32_t shdr_status, shdr_add_status;
12421 union lpfc_sli4_cfg_shdr *shdr; 12637 union lpfc_sli4_cfg_shdr *shdr;
12422 12638
12639 /* sanity check on queue memory */
12423 if (!eq) 12640 if (!eq)
12424 return -ENODEV; 12641 return -ENODEV;
12425 mbox = mempool_alloc(eq->phba->mbox_mem_pool, GFP_KERNEL); 12642 mbox = mempool_alloc(eq->phba->mbox_mem_pool, GFP_KERNEL);
@@ -12475,6 +12692,7 @@ lpfc_cq_destroy(struct lpfc_hba *phba, struct lpfc_queue *cq)
12475 uint32_t shdr_status, shdr_add_status; 12692 uint32_t shdr_status, shdr_add_status;
12476 union lpfc_sli4_cfg_shdr *shdr; 12693 union lpfc_sli4_cfg_shdr *shdr;
12477 12694
12695 /* sanity check on queue memory */
12478 if (!cq) 12696 if (!cq)
12479 return -ENODEV; 12697 return -ENODEV;
12480 mbox = mempool_alloc(cq->phba->mbox_mem_pool, GFP_KERNEL); 12698 mbox = mempool_alloc(cq->phba->mbox_mem_pool, GFP_KERNEL);
@@ -12528,6 +12746,7 @@ lpfc_mq_destroy(struct lpfc_hba *phba, struct lpfc_queue *mq)
12528 uint32_t shdr_status, shdr_add_status; 12746 uint32_t shdr_status, shdr_add_status;
12529 union lpfc_sli4_cfg_shdr *shdr; 12747 union lpfc_sli4_cfg_shdr *shdr;
12530 12748
12749 /* sanity check on queue memory */
12531 if (!mq) 12750 if (!mq)
12532 return -ENODEV; 12751 return -ENODEV;
12533 mbox = mempool_alloc(mq->phba->mbox_mem_pool, GFP_KERNEL); 12752 mbox = mempool_alloc(mq->phba->mbox_mem_pool, GFP_KERNEL);
@@ -12581,6 +12800,7 @@ lpfc_wq_destroy(struct lpfc_hba *phba, struct lpfc_queue *wq)
12581 uint32_t shdr_status, shdr_add_status; 12800 uint32_t shdr_status, shdr_add_status;
12582 union lpfc_sli4_cfg_shdr *shdr; 12801 union lpfc_sli4_cfg_shdr *shdr;
12583 12802
12803 /* sanity check on queue memory */
12584 if (!wq) 12804 if (!wq)
12585 return -ENODEV; 12805 return -ENODEV;
12586 mbox = mempool_alloc(wq->phba->mbox_mem_pool, GFP_KERNEL); 12806 mbox = mempool_alloc(wq->phba->mbox_mem_pool, GFP_KERNEL);
@@ -12634,6 +12854,7 @@ lpfc_rq_destroy(struct lpfc_hba *phba, struct lpfc_queue *hrq,
12634 uint32_t shdr_status, shdr_add_status; 12854 uint32_t shdr_status, shdr_add_status;
12635 union lpfc_sli4_cfg_shdr *shdr; 12855 union lpfc_sli4_cfg_shdr *shdr;
12636 12856
12857 /* sanity check on queue memory */
12637 if (!hrq || !drq) 12858 if (!hrq || !drq)
12638 return -ENODEV; 12859 return -ENODEV;
12639 mbox = mempool_alloc(hrq->phba->mbox_mem_pool, GFP_KERNEL); 12860 mbox = mempool_alloc(hrq->phba->mbox_mem_pool, GFP_KERNEL);
@@ -15252,45 +15473,42 @@ lpfc_sli4_fcf_dead_failthrough(struct lpfc_hba *phba)
15252} 15473}
15253 15474
15254/** 15475/**
15255 * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled. 15476 * lpfc_sli_get_config_region23 - Get sli3 port region 23 data.
15256 * @phba: pointer to lpfc hba data structure. 15477 * @phba: pointer to lpfc hba data structure.
15478 * @rgn23_data: pointer to configure region 23 data.
15257 * 15479 *
15258 * This function read region 23 and parse TLV for port status to 15480 * This function gets SLI3 port configure region 23 data through memory dump
15259 * decide if the user disaled the port. If the TLV indicates the 15481 * mailbox command. When it successfully retrieves data, the size of the data
15260 * port is disabled, the hba_flag is set accordingly. 15482 * will be returned, otherwise, 0 will be returned.
15261 **/ 15483 **/
15262void 15484static uint32_t
15263lpfc_sli_read_link_ste(struct lpfc_hba *phba) 15485lpfc_sli_get_config_region23(struct lpfc_hba *phba, char *rgn23_data)
15264{ 15486{
15265 LPFC_MBOXQ_t *pmb = NULL; 15487 LPFC_MBOXQ_t *pmb = NULL;
15266 MAILBOX_t *mb; 15488 MAILBOX_t *mb;
15267 uint8_t *rgn23_data = NULL; 15489 uint32_t offset = 0;
15268 uint32_t offset = 0, data_size, sub_tlv_len, tlv_offset;
15269 int rc; 15490 int rc;
15270 15491
15492 if (!rgn23_data)
15493 return 0;
15494
15271 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 15495 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
15272 if (!pmb) { 15496 if (!pmb) {
15273 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 15497 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
15274 "2600 lpfc_sli_read_serdes_param failed to" 15498 "2600 failed to allocate mailbox memory\n");
15275 " allocate mailbox memory\n"); 15499 return 0;
15276 goto out;
15277 } 15500 }
15278 mb = &pmb->u.mb; 15501 mb = &pmb->u.mb;
15279 15502
15280 /* Get adapter Region 23 data */
15281 rgn23_data = kzalloc(DMP_RGN23_SIZE, GFP_KERNEL);
15282 if (!rgn23_data)
15283 goto out;
15284
15285 do { 15503 do {
15286 lpfc_dump_mem(phba, pmb, offset, DMP_REGION_23); 15504 lpfc_dump_mem(phba, pmb, offset, DMP_REGION_23);
15287 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); 15505 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
15288 15506
15289 if (rc != MBX_SUCCESS) { 15507 if (rc != MBX_SUCCESS) {
15290 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 15508 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
15291 "2601 lpfc_sli_read_link_ste failed to" 15509 "2601 failed to read config "
15292 " read config region 23 rc 0x%x Status 0x%x\n", 15510 "region 23, rc 0x%x Status 0x%x\n",
15293 rc, mb->mbxStatus); 15511 rc, mb->mbxStatus);
15294 mb->un.varDmp.word_cnt = 0; 15512 mb->un.varDmp.word_cnt = 0;
15295 } 15513 }
15296 /* 15514 /*
@@ -15303,13 +15521,96 @@ lpfc_sli_read_link_ste(struct lpfc_hba *phba)
15303 mb->un.varDmp.word_cnt = DMP_RGN23_SIZE - offset; 15521 mb->un.varDmp.word_cnt = DMP_RGN23_SIZE - offset;
15304 15522
15305 lpfc_sli_pcimem_bcopy(((uint8_t *)mb) + DMP_RSP_OFFSET, 15523 lpfc_sli_pcimem_bcopy(((uint8_t *)mb) + DMP_RSP_OFFSET,
15306 rgn23_data + offset, 15524 rgn23_data + offset,
15307 mb->un.varDmp.word_cnt); 15525 mb->un.varDmp.word_cnt);
15308 offset += mb->un.varDmp.word_cnt; 15526 offset += mb->un.varDmp.word_cnt;
15309 } while (mb->un.varDmp.word_cnt && offset < DMP_RGN23_SIZE); 15527 } while (mb->un.varDmp.word_cnt && offset < DMP_RGN23_SIZE);
15310 15528
15311 data_size = offset; 15529 mempool_free(pmb, phba->mbox_mem_pool);
15312 offset = 0; 15530 return offset;
15531}
15532
15533/**
15534 * lpfc_sli4_get_config_region23 - Get sli4 port region 23 data.
15535 * @phba: pointer to lpfc hba data structure.
15536 * @rgn23_data: pointer to configure region 23 data.
15537 *
15538 * This function gets SLI4 port configure region 23 data through memory dump
15539 * mailbox command. When it successfully retrieves data, the size of the data
15540 * will be returned, otherwise, 0 will be returned.
15541 **/
15542static uint32_t
15543lpfc_sli4_get_config_region23(struct lpfc_hba *phba, char *rgn23_data)
15544{
15545 LPFC_MBOXQ_t *mboxq = NULL;
15546 struct lpfc_dmabuf *mp = NULL;
15547 struct lpfc_mqe *mqe;
15548 uint32_t data_length = 0;
15549 int rc;
15550
15551 if (!rgn23_data)
15552 return 0;
15553
15554 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
15555 if (!mboxq) {
15556 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
15557 "3105 failed to allocate mailbox memory\n");
15558 return 0;
15559 }
15560
15561 if (lpfc_sli4_dump_cfg_rg23(phba, mboxq))
15562 goto out;
15563 mqe = &mboxq->u.mqe;
15564 mp = (struct lpfc_dmabuf *) mboxq->context1;
15565 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
15566 if (rc)
15567 goto out;
15568 data_length = mqe->un.mb_words[5];
15569 if (data_length == 0)
15570 goto out;
15571 if (data_length > DMP_RGN23_SIZE) {
15572 data_length = 0;
15573 goto out;
15574 }
15575 lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length);
15576out:
15577 mempool_free(mboxq, phba->mbox_mem_pool);
15578 if (mp) {
15579 lpfc_mbuf_free(phba, mp->virt, mp->phys);
15580 kfree(mp);
15581 }
15582 return data_length;
15583}
15584
15585/**
15586 * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
15587 * @phba: pointer to lpfc hba data structure.
15588 *
15589 * This function read region 23 and parse TLV for port status to
15590 * decide if the user disaled the port. If the TLV indicates the
15591 * port is disabled, the hba_flag is set accordingly.
15592 **/
15593void
15594lpfc_sli_read_link_ste(struct lpfc_hba *phba)
15595{
15596 uint8_t *rgn23_data = NULL;
15597 uint32_t if_type, data_size, sub_tlv_len, tlv_offset;
15598 uint32_t offset = 0;
15599
15600 /* Get adapter Region 23 data */
15601 rgn23_data = kzalloc(DMP_RGN23_SIZE, GFP_KERNEL);
15602 if (!rgn23_data)
15603 goto out;
15604
15605 if (phba->sli_rev < LPFC_SLI_REV4)
15606 data_size = lpfc_sli_get_config_region23(phba, rgn23_data);
15607 else {
15608 if_type = bf_get(lpfc_sli_intf_if_type,
15609 &phba->sli4_hba.sli_intf);
15610 if (if_type == LPFC_SLI_INTF_IF_TYPE_0)
15611 goto out;
15612 data_size = lpfc_sli4_get_config_region23(phba, rgn23_data);
15613 }
15313 15614
15314 if (!data_size) 15615 if (!data_size)
15315 goto out; 15616 goto out;
@@ -15373,9 +15674,8 @@ lpfc_sli_read_link_ste(struct lpfc_hba *phba)
15373 goto out; 15674 goto out;
15374 } 15675 }
15375 } 15676 }
15677
15376out: 15678out:
15377 if (pmb)
15378 mempool_free(pmb, phba->mbox_mem_pool);
15379 kfree(rgn23_data); 15679 kfree(rgn23_data);
15380 return; 15680 return;
15381} 15681}