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.c329
1 files changed, 255 insertions, 74 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 589549b2bf0e..35e3b96d4e07 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -580,10 +580,7 @@ __lpfc_sli_release_iocbq_s4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
580 else 580 else
581 sglq = __lpfc_clear_active_sglq(phba, iocbq->sli4_xritag); 581 sglq = __lpfc_clear_active_sglq(phba, iocbq->sli4_xritag);
582 if (sglq) { 582 if (sglq) {
583 if (iocbq->iocb_flag & LPFC_DRIVER_ABORTED 583 if (iocbq->iocb_flag & LPFC_EXCHANGE_BUSY) {
584 && ((iocbq->iocb.ulpStatus == IOSTAT_LOCAL_REJECT)
585 && (iocbq->iocb.un.ulpWord[4]
586 == IOERR_ABORT_REQUESTED))) {
587 spin_lock_irqsave(&phba->sli4_hba.abts_sgl_list_lock, 584 spin_lock_irqsave(&phba->sli4_hba.abts_sgl_list_lock,
588 iflag); 585 iflag);
589 list_add(&sglq->list, 586 list_add(&sglq->list,
@@ -764,10 +761,6 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd)
764 case DSSCMD_IWRITE64_CX: 761 case DSSCMD_IWRITE64_CX:
765 case DSSCMD_IREAD64_CR: 762 case DSSCMD_IREAD64_CR:
766 case DSSCMD_IREAD64_CX: 763 case DSSCMD_IREAD64_CX:
767 case DSSCMD_INVALIDATE_DEK:
768 case DSSCMD_SET_KEK:
769 case DSSCMD_GET_KEK_ID:
770 case DSSCMD_GEN_XFER:
771 type = LPFC_SOL_IOCB; 764 type = LPFC_SOL_IOCB;
772 break; 765 break;
773 case CMD_ABORT_XRI_CN: 766 case CMD_ABORT_XRI_CN:
@@ -1717,6 +1710,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1717 struct lpfc_dmabuf *mp; 1710 struct lpfc_dmabuf *mp;
1718 uint16_t rpi, vpi; 1711 uint16_t rpi, vpi;
1719 int rc; 1712 int rc;
1713 struct lpfc_vport *vport = pmb->vport;
1720 1714
1721 mp = (struct lpfc_dmabuf *) (pmb->context1); 1715 mp = (struct lpfc_dmabuf *) (pmb->context1);
1722 1716
@@ -1745,6 +1739,18 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1745 return; 1739 return;
1746 } 1740 }
1747 1741
1742 /* Unreg VPI, if the REG_VPI succeed after VLink failure */
1743 if ((pmb->u.mb.mbxCommand == MBX_REG_VPI) &&
1744 !(phba->pport->load_flag & FC_UNLOADING) &&
1745 !pmb->u.mb.mbxStatus) {
1746 lpfc_unreg_vpi(phba, pmb->u.mb.un.varRegVpi.vpi, pmb);
1747 pmb->vport = vport;
1748 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1749 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
1750 if (rc != MBX_NOT_FINISHED)
1751 return;
1752 }
1753
1748 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG) 1754 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG)
1749 lpfc_sli4_mbox_cmd_free(phba, pmb); 1755 lpfc_sli4_mbox_cmd_free(phba, pmb);
1750 else 1756 else
@@ -2228,9 +2234,15 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2228 * All other are passed to the completion callback. 2234 * All other are passed to the completion callback.
2229 */ 2235 */
2230 if (pring->ringno == LPFC_ELS_RING) { 2236 if (pring->ringno == LPFC_ELS_RING) {
2231 if (cmdiocbp->iocb_flag & LPFC_DRIVER_ABORTED) { 2237 if ((phba->sli_rev < LPFC_SLI_REV4) &&
2238 (cmdiocbp->iocb_flag &
2239 LPFC_DRIVER_ABORTED)) {
2240 spin_lock_irqsave(&phba->hbalock,
2241 iflag);
2232 cmdiocbp->iocb_flag &= 2242 cmdiocbp->iocb_flag &=
2233 ~LPFC_DRIVER_ABORTED; 2243 ~LPFC_DRIVER_ABORTED;
2244 spin_unlock_irqrestore(&phba->hbalock,
2245 iflag);
2234 saveq->iocb.ulpStatus = 2246 saveq->iocb.ulpStatus =
2235 IOSTAT_LOCAL_REJECT; 2247 IOSTAT_LOCAL_REJECT;
2236 saveq->iocb.un.ulpWord[4] = 2248 saveq->iocb.un.ulpWord[4] =
@@ -2240,7 +2252,47 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2240 * of DMAing payload, so don't free data 2252 * of DMAing payload, so don't free data
2241 * buffer till after a hbeat. 2253 * buffer till after a hbeat.
2242 */ 2254 */
2255 spin_lock_irqsave(&phba->hbalock,
2256 iflag);
2243 saveq->iocb_flag |= LPFC_DELAY_MEM_FREE; 2257 saveq->iocb_flag |= LPFC_DELAY_MEM_FREE;
2258 spin_unlock_irqrestore(&phba->hbalock,
2259 iflag);
2260 }
2261 if ((phba->sli_rev == LPFC_SLI_REV4) &&
2262 (saveq->iocb_flag & LPFC_EXCHANGE_BUSY)) {
2263 /* Set cmdiocb flag for the exchange
2264 * busy so sgl (xri) will not be
2265 * released until the abort xri is
2266 * received from hba, clear the
2267 * LPFC_DRIVER_ABORTED bit in case
2268 * it was driver initiated abort.
2269 */
2270 spin_lock_irqsave(&phba->hbalock,
2271 iflag);
2272 cmdiocbp->iocb_flag &=
2273 ~LPFC_DRIVER_ABORTED;
2274 cmdiocbp->iocb_flag |=
2275 LPFC_EXCHANGE_BUSY;
2276 spin_unlock_irqrestore(&phba->hbalock,
2277 iflag);
2278 cmdiocbp->iocb.ulpStatus =
2279 IOSTAT_LOCAL_REJECT;
2280 cmdiocbp->iocb.un.ulpWord[4] =
2281 IOERR_ABORT_REQUESTED;
2282 /*
2283 * For SLI4, irsiocb contains NO_XRI
2284 * in sli_xritag, it shall not affect
2285 * releasing sgl (xri) process.
2286 */
2287 saveq->iocb.ulpStatus =
2288 IOSTAT_LOCAL_REJECT;
2289 saveq->iocb.un.ulpWord[4] =
2290 IOERR_SLI_ABORTED;
2291 spin_lock_irqsave(&phba->hbalock,
2292 iflag);
2293 saveq->iocb_flag |= LPFC_DELAY_MEM_FREE;
2294 spin_unlock_irqrestore(&phba->hbalock,
2295 iflag);
2244 } 2296 }
2245 } 2297 }
2246 (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq); 2298 (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq);
@@ -5687,19 +5739,19 @@ lpfc_sli4_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
5687 5739
5688 for (i = 0; i < numBdes; i++) { 5740 for (i = 0; i < numBdes; i++) {
5689 /* Should already be byte swapped. */ 5741 /* Should already be byte swapped. */
5690 sgl->addr_hi = bpl->addrHigh; 5742 sgl->addr_hi = bpl->addrHigh;
5691 sgl->addr_lo = bpl->addrLow; 5743 sgl->addr_lo = bpl->addrLow;
5692 /* swap the size field back to the cpu so we 5744
5693 * can assign it to the sgl.
5694 */
5695 bde.tus.w = le32_to_cpu(bpl->tus.w);
5696 bf_set(lpfc_sli4_sge_len, sgl, bde.tus.f.bdeSize);
5697 if ((i+1) == numBdes) 5745 if ((i+1) == numBdes)
5698 bf_set(lpfc_sli4_sge_last, sgl, 1); 5746 bf_set(lpfc_sli4_sge_last, sgl, 1);
5699 else 5747 else
5700 bf_set(lpfc_sli4_sge_last, sgl, 0); 5748 bf_set(lpfc_sli4_sge_last, sgl, 0);
5701 sgl->word2 = cpu_to_le32(sgl->word2); 5749 sgl->word2 = cpu_to_le32(sgl->word2);
5702 sgl->word3 = cpu_to_le32(sgl->word3); 5750 /* swap the size field back to the cpu so we
5751 * can assign it to the sgl.
5752 */
5753 bde.tus.w = le32_to_cpu(bpl->tus.w);
5754 sgl->sge_len = cpu_to_le32(bde.tus.f.bdeSize);
5703 bpl++; 5755 bpl++;
5704 sgl++; 5756 sgl++;
5705 } 5757 }
@@ -5712,11 +5764,10 @@ lpfc_sli4_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
5712 cpu_to_le32(icmd->un.genreq64.bdl.addrHigh); 5764 cpu_to_le32(icmd->un.genreq64.bdl.addrHigh);
5713 sgl->addr_lo = 5765 sgl->addr_lo =
5714 cpu_to_le32(icmd->un.genreq64.bdl.addrLow); 5766 cpu_to_le32(icmd->un.genreq64.bdl.addrLow);
5715 bf_set(lpfc_sli4_sge_len, sgl,
5716 icmd->un.genreq64.bdl.bdeSize);
5717 bf_set(lpfc_sli4_sge_last, sgl, 1); 5767 bf_set(lpfc_sli4_sge_last, sgl, 1);
5718 sgl->word2 = cpu_to_le32(sgl->word2); 5768 sgl->word2 = cpu_to_le32(sgl->word2);
5719 sgl->word3 = cpu_to_le32(sgl->word3); 5769 sgl->sge_len =
5770 cpu_to_le32(icmd->un.genreq64.bdl.bdeSize);
5720 } 5771 }
5721 return sglq->sli4_xritag; 5772 return sglq->sli4_xritag;
5722} 5773}
@@ -5987,12 +6038,10 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
5987 else 6038 else
5988 bf_set(abort_cmd_ia, &wqe->abort_cmd, 0); 6039 bf_set(abort_cmd_ia, &wqe->abort_cmd, 0);
5989 bf_set(abort_cmd_criteria, &wqe->abort_cmd, T_XRI_TAG); 6040 bf_set(abort_cmd_criteria, &wqe->abort_cmd, T_XRI_TAG);
5990 abort_tag = iocbq->iocb.un.acxri.abortIoTag;
5991 wqe->words[5] = 0; 6041 wqe->words[5] = 0;
5992 bf_set(lpfc_wqe_gen_ct, &wqe->generic, 6042 bf_set(lpfc_wqe_gen_ct, &wqe->generic,
5993 ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l)); 6043 ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l));
5994 abort_tag = iocbq->iocb.un.acxri.abortIoTag; 6044 abort_tag = iocbq->iocb.un.acxri.abortIoTag;
5995 wqe->generic.abort_tag = abort_tag;
5996 /* 6045 /*
5997 * The abort handler will send us CMD_ABORT_XRI_CN or 6046 * The abort handler will send us CMD_ABORT_XRI_CN or
5998 * CMD_CLOSE_XRI_CN and the fw only accepts CMD_ABORT_XRI_CX 6047 * CMD_CLOSE_XRI_CN and the fw only accepts CMD_ABORT_XRI_CX
@@ -6121,15 +6170,15 @@ __lpfc_sli_issue_iocb_s4(struct lpfc_hba *phba, uint32_t ring_number,
6121 if (lpfc_sli4_iocb2wqe(phba, piocb, &wqe)) 6170 if (lpfc_sli4_iocb2wqe(phba, piocb, &wqe))
6122 return IOCB_ERROR; 6171 return IOCB_ERROR;
6123 6172
6124 if (piocb->iocb_flag & LPFC_IO_FCP) { 6173 if ((piocb->iocb_flag & LPFC_IO_FCP) ||
6174 (piocb->iocb_flag & LPFC_USE_FCPWQIDX)) {
6125 /* 6175 /*
6126 * For FCP command IOCB, get a new WQ index to distribute 6176 * For FCP command IOCB, get a new WQ index to distribute
6127 * WQE across the WQsr. On the other hand, for abort IOCB, 6177 * WQE across the WQsr. On the other hand, for abort IOCB,
6128 * it carries the same WQ index to the original command 6178 * it carries the same WQ index to the original command
6129 * IOCB. 6179 * IOCB.
6130 */ 6180 */
6131 if ((piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && 6181 if (piocb->iocb_flag & LPFC_IO_FCP)
6132 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN))
6133 piocb->fcp_wqidx = lpfc_sli4_scmd_to_wqidx_distr(phba); 6182 piocb->fcp_wqidx = lpfc_sli4_scmd_to_wqidx_distr(phba);
6134 if (lpfc_sli4_wq_put(phba->sli4_hba.fcp_wq[piocb->fcp_wqidx], 6183 if (lpfc_sli4_wq_put(phba->sli4_hba.fcp_wq[piocb->fcp_wqidx],
6135 &wqe)) 6184 &wqe))
@@ -7004,7 +7053,14 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
7004 abort_iocb->iocb.ulpContext != abort_context || 7053 abort_iocb->iocb.ulpContext != abort_context ||
7005 (abort_iocb->iocb_flag & LPFC_DRIVER_ABORTED) == 0) 7054 (abort_iocb->iocb_flag & LPFC_DRIVER_ABORTED) == 0)
7006 spin_unlock_irq(&phba->hbalock); 7055 spin_unlock_irq(&phba->hbalock);
7007 else { 7056 else if (phba->sli_rev < LPFC_SLI_REV4) {
7057 /*
7058 * leave the SLI4 aborted command on the txcmplq
7059 * list and the command complete WCQE's XB bit
7060 * will tell whether the SGL (XRI) can be released
7061 * immediately or to the aborted SGL list for the
7062 * following abort XRI from the HBA.
7063 */
7008 list_del_init(&abort_iocb->list); 7064 list_del_init(&abort_iocb->list);
7009 pring->txcmplq_cnt--; 7065 pring->txcmplq_cnt--;
7010 spin_unlock_irq(&phba->hbalock); 7066 spin_unlock_irq(&phba->hbalock);
@@ -7013,11 +7069,13 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
7013 * payload, so don't free data buffer till after 7069 * payload, so don't free data buffer till after
7014 * a hbeat. 7070 * a hbeat.
7015 */ 7071 */
7072 spin_lock_irq(&phba->hbalock);
7016 abort_iocb->iocb_flag |= LPFC_DELAY_MEM_FREE; 7073 abort_iocb->iocb_flag |= LPFC_DELAY_MEM_FREE;
7017
7018 abort_iocb->iocb_flag &= ~LPFC_DRIVER_ABORTED; 7074 abort_iocb->iocb_flag &= ~LPFC_DRIVER_ABORTED;
7075 spin_unlock_irq(&phba->hbalock);
7076
7019 abort_iocb->iocb.ulpStatus = IOSTAT_LOCAL_REJECT; 7077 abort_iocb->iocb.ulpStatus = IOSTAT_LOCAL_REJECT;
7020 abort_iocb->iocb.un.ulpWord[4] = IOERR_SLI_ABORTED; 7078 abort_iocb->iocb.un.ulpWord[4] = IOERR_ABORT_REQUESTED;
7021 (abort_iocb->iocb_cmpl)(phba, abort_iocb, abort_iocb); 7079 (abort_iocb->iocb_cmpl)(phba, abort_iocb, abort_iocb);
7022 } 7080 }
7023 } 7081 }
@@ -7106,7 +7164,7 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
7106 return 0; 7164 return 0;
7107 7165
7108 /* This signals the response to set the correct status 7166 /* This signals the response to set the correct status
7109 * before calling the completion handler. 7167 * before calling the completion handler
7110 */ 7168 */
7111 cmdiocb->iocb_flag |= LPFC_DRIVER_ABORTED; 7169 cmdiocb->iocb_flag |= LPFC_DRIVER_ABORTED;
7112 7170
@@ -7124,6 +7182,8 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
7124 7182
7125 /* ABTS WQE must go to the same WQ as the WQE to be aborted */ 7183 /* ABTS WQE must go to the same WQ as the WQE to be aborted */
7126 abtsiocbp->fcp_wqidx = cmdiocb->fcp_wqidx; 7184 abtsiocbp->fcp_wqidx = cmdiocb->fcp_wqidx;
7185 if (cmdiocb->iocb_flag & LPFC_IO_FCP)
7186 abtsiocbp->iocb_flag |= LPFC_USE_FCPWQIDX;
7127 7187
7128 if (phba->link_state >= LPFC_LINK_UP) 7188 if (phba->link_state >= LPFC_LINK_UP)
7129 iabt->ulpCommand = CMD_ABORT_XRI_CN; 7189 iabt->ulpCommand = CMD_ABORT_XRI_CN;
@@ -7330,6 +7390,8 @@ lpfc_sli_abort_iocb(struct lpfc_vport *vport, struct lpfc_sli_ring *pring,
7330 7390
7331 /* ABTS WQE must go to the same WQ as the WQE to be aborted */ 7391 /* ABTS WQE must go to the same WQ as the WQE to be aborted */
7332 abtsiocb->fcp_wqidx = iocbq->fcp_wqidx; 7392 abtsiocb->fcp_wqidx = iocbq->fcp_wqidx;
7393 if (iocbq->iocb_flag & LPFC_IO_FCP)
7394 abtsiocb->iocb_flag |= LPFC_USE_FCPWQIDX;
7333 7395
7334 if (lpfc_is_link_up(phba)) 7396 if (lpfc_is_link_up(phba))
7335 abtsiocb->iocb.ulpCommand = CMD_ABORT_XRI_CN; 7397 abtsiocb->iocb.ulpCommand = CMD_ABORT_XRI_CN;
@@ -8359,11 +8421,24 @@ void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *phba)
8359 } 8421 }
8360} 8422}
8361 8423
8424/**
8425 * lpfc_sli4_iocb_param_transfer - Transfer pIocbOut and cmpl status to pIocbIn
8426 * @phba: pointer to lpfc hba data structure
8427 * @pIocbIn: pointer to the rspiocbq
8428 * @pIocbOut: pointer to the cmdiocbq
8429 * @wcqe: pointer to the complete wcqe
8430 *
8431 * This routine transfers the fields of a command iocbq to a response iocbq
8432 * by copying all the IOCB fields from command iocbq and transferring the
8433 * completion status information from the complete wcqe.
8434 **/
8362static void 8435static void
8363lpfc_sli4_iocb_param_transfer(struct lpfc_iocbq *pIocbIn, 8436lpfc_sli4_iocb_param_transfer(struct lpfc_hba *phba,
8437 struct lpfc_iocbq *pIocbIn,
8364 struct lpfc_iocbq *pIocbOut, 8438 struct lpfc_iocbq *pIocbOut,
8365 struct lpfc_wcqe_complete *wcqe) 8439 struct lpfc_wcqe_complete *wcqe)
8366{ 8440{
8441 unsigned long iflags;
8367 size_t offset = offsetof(struct lpfc_iocbq, iocb); 8442 size_t offset = offsetof(struct lpfc_iocbq, iocb);
8368 8443
8369 memcpy((char *)pIocbIn + offset, (char *)pIocbOut + offset, 8444 memcpy((char *)pIocbIn + offset, (char *)pIocbOut + offset,
@@ -8377,8 +8452,17 @@ lpfc_sli4_iocb_param_transfer(struct lpfc_iocbq *pIocbIn,
8377 wcqe->total_data_placed; 8452 wcqe->total_data_placed;
8378 else 8453 else
8379 pIocbIn->iocb.un.ulpWord[4] = wcqe->parameter; 8454 pIocbIn->iocb.un.ulpWord[4] = wcqe->parameter;
8380 else 8455 else {
8381 pIocbIn->iocb.un.ulpWord[4] = wcqe->parameter; 8456 pIocbIn->iocb.un.ulpWord[4] = wcqe->parameter;
8457 pIocbIn->iocb.un.genreq64.bdl.bdeSize = wcqe->total_data_placed;
8458 }
8459
8460 /* Pick up HBA exchange busy condition */
8461 if (bf_get(lpfc_wcqe_c_xb, wcqe)) {
8462 spin_lock_irqsave(&phba->hbalock, iflags);
8463 pIocbIn->iocb_flag |= LPFC_EXCHANGE_BUSY;
8464 spin_unlock_irqrestore(&phba->hbalock, iflags);
8465 }
8382} 8466}
8383 8467
8384/** 8468/**
@@ -8419,7 +8503,7 @@ lpfc_sli4_els_wcqe_to_rspiocbq(struct lpfc_hba *phba,
8419 } 8503 }
8420 8504
8421 /* Fake the irspiocbq and copy necessary response information */ 8505 /* Fake the irspiocbq and copy necessary response information */
8422 lpfc_sli4_iocb_param_transfer(irspiocbq, cmdiocbq, wcqe); 8506 lpfc_sli4_iocb_param_transfer(phba, irspiocbq, cmdiocbq, wcqe);
8423 8507
8424 return irspiocbq; 8508 return irspiocbq;
8425} 8509}
@@ -8849,8 +8933,7 @@ lpfc_sli4_sp_handle_eqe(struct lpfc_hba *phba, struct lpfc_eqe *eqe)
8849 int ecount = 0; 8933 int ecount = 0;
8850 uint16_t cqid; 8934 uint16_t cqid;
8851 8935
8852 if (bf_get(lpfc_eqe_major_code, eqe) != 0 || 8936 if (bf_get(lpfc_eqe_major_code, eqe) != 0) {
8853 bf_get(lpfc_eqe_minor_code, eqe) != 0) {
8854 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 8937 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
8855 "0359 Not a valid slow-path completion " 8938 "0359 Not a valid slow-path completion "
8856 "event: majorcode=x%x, minorcode=x%x\n", 8939 "event: majorcode=x%x, minorcode=x%x\n",
@@ -8976,7 +9059,7 @@ lpfc_sli4_fp_handle_fcp_wcqe(struct lpfc_hba *phba,
8976 } 9059 }
8977 9060
8978 /* Fake the irspiocb and copy necessary response information */ 9061 /* Fake the irspiocb and copy necessary response information */
8979 lpfc_sli4_iocb_param_transfer(&irspiocbq, cmdiocbq, wcqe); 9062 lpfc_sli4_iocb_param_transfer(phba, &irspiocbq, cmdiocbq, wcqe);
8980 9063
8981 /* Pass the cmd_iocb and the rsp state to the upper layer */ 9064 /* Pass the cmd_iocb and the rsp state to the upper layer */
8982 (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, &irspiocbq); 9065 (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, &irspiocbq);
@@ -9082,8 +9165,7 @@ lpfc_sli4_fp_handle_eqe(struct lpfc_hba *phba, struct lpfc_eqe *eqe,
9082 uint16_t cqid; 9165 uint16_t cqid;
9083 int ecount = 0; 9166 int ecount = 0;
9084 9167
9085 if (unlikely(bf_get(lpfc_eqe_major_code, eqe) != 0) || 9168 if (unlikely(bf_get(lpfc_eqe_major_code, eqe) != 0)) {
9086 unlikely(bf_get(lpfc_eqe_minor_code, eqe) != 0)) {
9087 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 9169 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
9088 "0366 Not a valid fast-path completion " 9170 "0366 Not a valid fast-path completion "
9089 "event: majorcode=x%x, minorcode=x%x\n", 9171 "event: majorcode=x%x, minorcode=x%x\n",
@@ -11871,12 +11953,6 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index)
11871{ 11953{
11872 int rc = 0, error; 11954 int rc = 0, error;
11873 LPFC_MBOXQ_t *mboxq; 11955 LPFC_MBOXQ_t *mboxq;
11874 void *virt_addr;
11875 dma_addr_t phys_addr;
11876 uint8_t *bytep;
11877 struct lpfc_mbx_sge sge;
11878 uint32_t alloc_len, req_len;
11879 struct lpfc_mbx_read_fcf_tbl *read_fcf;
11880 11956
11881 phba->fcoe_eventtag_at_fcf_scan = phba->fcoe_eventtag; 11957 phba->fcoe_eventtag_at_fcf_scan = phba->fcoe_eventtag;
11882 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 11958 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -11887,43 +11963,19 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index)
11887 error = -ENOMEM; 11963 error = -ENOMEM;
11888 goto fail_fcfscan; 11964 goto fail_fcfscan;
11889 } 11965 }
11890 11966 /* Construct the read FCF record mailbox command */
11891 req_len = sizeof(struct fcf_record) + 11967 rc = lpfc_sli4_mbx_read_fcf_record(phba, mboxq, fcf_index);
11892 sizeof(union lpfc_sli4_cfg_shdr) + 2 * sizeof(uint32_t); 11968 if (rc) {
11893 11969 error = -EINVAL;
11894 /* Set up READ_FCF SLI4_CONFIG mailbox-ioctl command */
11895 alloc_len = lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_FCOE,
11896 LPFC_MBOX_OPCODE_FCOE_READ_FCF_TABLE, req_len,
11897 LPFC_SLI4_MBX_NEMBED);
11898
11899 if (alloc_len < req_len) {
11900 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
11901 "0291 Allocated DMA memory size (x%x) is "
11902 "less than the requested DMA memory "
11903 "size (x%x)\n", alloc_len, req_len);
11904 error = -ENOMEM;
11905 goto fail_fcfscan; 11970 goto fail_fcfscan;
11906 } 11971 }
11907 11972 /* Issue the mailbox command asynchronously */
11908 /* Get the first SGE entry from the non-embedded DMA memory. This
11909 * routine only uses a single SGE.
11910 */
11911 lpfc_sli4_mbx_sge_get(mboxq, 0, &sge);
11912 phys_addr = getPaddr(sge.pa_hi, sge.pa_lo);
11913 virt_addr = mboxq->sge_array->addr[0];
11914 read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr;
11915
11916 /* Set up command fields */
11917 bf_set(lpfc_mbx_read_fcf_tbl_indx, &read_fcf->u.request, fcf_index);
11918 /* Perform necessary endian conversion */
11919 bytep = virt_addr + sizeof(union lpfc_sli4_cfg_shdr);
11920 lpfc_sli_pcimem_bcopy(bytep, bytep, sizeof(uint32_t));
11921 mboxq->vport = phba->pport; 11973 mboxq->vport = phba->pport;
11922 mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_record; 11974 mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_record;
11923 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); 11975 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);
11924 if (rc == MBX_NOT_FINISHED) { 11976 if (rc == MBX_NOT_FINISHED)
11925 error = -EIO; 11977 error = -EIO;
11926 } else { 11978 else {
11927 spin_lock_irq(&phba->hbalock); 11979 spin_lock_irq(&phba->hbalock);
11928 phba->hba_flag |= FCF_DISC_INPROGRESS; 11980 phba->hba_flag |= FCF_DISC_INPROGRESS;
11929 spin_unlock_irq(&phba->hbalock); 11981 spin_unlock_irq(&phba->hbalock);
@@ -11942,6 +11994,90 @@ fail_fcfscan:
11942} 11994}
11943 11995
11944/** 11996/**
11997 * lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table
11998 * @phba: pointer to lpfc hba data structure.
11999 *
12000 * This routine is the completion routine for the rediscover FCF table mailbox
12001 * command. If the mailbox command returned failure, it will try to stop the
12002 * FCF rediscover wait timer.
12003 **/
12004void
12005lpfc_mbx_cmpl_redisc_fcf_table(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
12006{
12007 struct lpfc_mbx_redisc_fcf_tbl *redisc_fcf;
12008 uint32_t shdr_status, shdr_add_status;
12009
12010 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl;
12011
12012 shdr_status = bf_get(lpfc_mbox_hdr_status,
12013 &redisc_fcf->header.cfg_shdr.response);
12014 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status,
12015 &redisc_fcf->header.cfg_shdr.response);
12016 if (shdr_status || shdr_add_status) {
12017 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
12018 "2746 Requesting for FCF rediscovery failed "
12019 "status x%x add_status x%x\n",
12020 shdr_status, shdr_add_status);
12021 /*
12022 * Request failed, last resort to re-try current
12023 * registered FCF entry
12024 */
12025 lpfc_retry_pport_discovery(phba);
12026 } else
12027 /*
12028 * Start FCF rediscovery wait timer for pending FCF
12029 * before rescan FCF record table.
12030 */
12031 lpfc_fcf_redisc_wait_start_timer(phba);
12032
12033 mempool_free(mbox, phba->mbox_mem_pool);
12034}
12035
12036/**
12037 * lpfc_sli4_redisc_all_fcf - Request to rediscover entire FCF table by port.
12038 * @phba: pointer to lpfc hba data structure.
12039 *
12040 * This routine is invoked to request for rediscovery of the entire FCF table
12041 * by the port.
12042 **/
12043int
12044lpfc_sli4_redisc_fcf_table(struct lpfc_hba *phba)
12045{
12046 LPFC_MBOXQ_t *mbox;
12047 struct lpfc_mbx_redisc_fcf_tbl *redisc_fcf;
12048 int rc, length;
12049
12050 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
12051 if (!mbox) {
12052 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
12053 "2745 Failed to allocate mbox for "
12054 "requesting FCF rediscover.\n");
12055 return -ENOMEM;
12056 }
12057
12058 length = (sizeof(struct lpfc_mbx_redisc_fcf_tbl) -
12059 sizeof(struct lpfc_sli4_cfg_mhdr));
12060 lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_FCOE,
12061 LPFC_MBOX_OPCODE_FCOE_REDISCOVER_FCF,
12062 length, LPFC_SLI4_MBX_EMBED);
12063
12064 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl;
12065 /* Set count to 0 for invalidating the entire FCF database */
12066 bf_set(lpfc_mbx_redisc_fcf_count, redisc_fcf, 0);
12067
12068 /* Issue the mailbox command asynchronously */
12069 mbox->vport = phba->pport;
12070 mbox->mbox_cmpl = lpfc_mbx_cmpl_redisc_fcf_table;
12071 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
12072
12073 if (rc == MBX_NOT_FINISHED) {
12074 mempool_free(mbox, phba->mbox_mem_pool);
12075 return -EIO;
12076 }
12077 return 0;
12078}
12079
12080/**
11945 * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled. 12081 * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
11946 * @phba: pointer to lpfc hba data structure. 12082 * @phba: pointer to lpfc hba data structure.
11947 * 12083 *
@@ -12069,3 +12205,48 @@ out:
12069 kfree(rgn23_data); 12205 kfree(rgn23_data);
12070 return; 12206 return;
12071} 12207}
12208
12209/**
12210 * lpfc_cleanup_pending_mbox - Free up vport discovery mailbox commands.
12211 * @vport: pointer to vport data structure.
12212 *
12213 * This function iterate through the mailboxq and clean up all REG_LOGIN
12214 * and REG_VPI mailbox commands associated with the vport. This function
12215 * is called when driver want to restart discovery of the vport due to
12216 * a Clear Virtual Link event.
12217 **/
12218void
12219lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
12220{
12221 struct lpfc_hba *phba = vport->phba;
12222 LPFC_MBOXQ_t *mb, *nextmb;
12223 struct lpfc_dmabuf *mp;
12224
12225 spin_lock_irq(&phba->hbalock);
12226 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
12227 if (mb->vport != vport)
12228 continue;
12229
12230 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) &&
12231 (mb->u.mb.mbxCommand != MBX_REG_VPI))
12232 continue;
12233
12234 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
12235 mp = (struct lpfc_dmabuf *) (mb->context1);
12236 if (mp) {
12237 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
12238 kfree(mp);
12239 }
12240 }
12241 list_del(&mb->list);
12242 mempool_free(mb, phba->mbox_mem_pool);
12243 }
12244 mb = phba->sli.mbox_active;
12245 if (mb && (mb->vport == vport)) {
12246 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) ||
12247 (mb->u.mb.mbxCommand == MBX_REG_VPI))
12248 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
12249 }
12250 spin_unlock_irq(&phba->hbalock);
12251}
12252