aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_bsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_bsg.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_bsg.c65
1 files changed, 24 insertions, 41 deletions
diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 7260c3af555a..0dd43bb91618 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -162,7 +162,6 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba,
162 struct lpfc_iocbq *cmdiocbq, 162 struct lpfc_iocbq *cmdiocbq,
163 struct lpfc_iocbq *rspiocbq) 163 struct lpfc_iocbq *rspiocbq)
164{ 164{
165 unsigned long iflags;
166 struct bsg_job_data *dd_data; 165 struct bsg_job_data *dd_data;
167 struct fc_bsg_job *job; 166 struct fc_bsg_job *job;
168 IOCB_t *rsp; 167 IOCB_t *rsp;
@@ -173,9 +172,10 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba,
173 int rc = 0; 172 int rc = 0;
174 173
175 spin_lock_irqsave(&phba->ct_ev_lock, flags); 174 spin_lock_irqsave(&phba->ct_ev_lock, flags);
176 dd_data = cmdiocbq->context1; 175 dd_data = cmdiocbq->context2;
177 if (!dd_data) { 176 if (!dd_data) {
178 spin_unlock_irqrestore(&phba->ct_ev_lock, flags); 177 spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
178 lpfc_sli_release_iocbq(phba, cmdiocbq);
179 return; 179 return;
180 } 180 }
181 181
@@ -183,17 +183,9 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba,
183 job = iocb->set_job; 183 job = iocb->set_job;
184 job->dd_data = NULL; /* so timeout handler does not reply */ 184 job->dd_data = NULL; /* so timeout handler does not reply */
185 185
186 spin_lock_irqsave(&phba->hbalock, iflags);
187 cmdiocbq->iocb_flag |= LPFC_IO_WAKE;
188 if (cmdiocbq->context2 && rspiocbq)
189 memcpy(&((struct lpfc_iocbq *)cmdiocbq->context2)->iocb,
190 &rspiocbq->iocb, sizeof(IOCB_t));
191 spin_unlock_irqrestore(&phba->hbalock, iflags);
192
193 bmp = iocb->bmp; 186 bmp = iocb->bmp;
194 rspiocbq = iocb->rspiocbq;
195 rsp = &rspiocbq->iocb; 187 rsp = &rspiocbq->iocb;
196 ndlp = iocb->ndlp; 188 ndlp = cmdiocbq->context1;
197 189
198 pci_unmap_sg(phba->pcidev, job->request_payload.sg_list, 190 pci_unmap_sg(phba->pcidev, job->request_payload.sg_list,
199 job->request_payload.sg_cnt, DMA_TO_DEVICE); 191 job->request_payload.sg_cnt, DMA_TO_DEVICE);
@@ -220,7 +212,6 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba,
220 rsp->un.genreq64.bdl.bdeSize; 212 rsp->un.genreq64.bdl.bdeSize;
221 213
222 lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 214 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
223 lpfc_sli_release_iocbq(phba, rspiocbq);
224 lpfc_sli_release_iocbq(phba, cmdiocbq); 215 lpfc_sli_release_iocbq(phba, cmdiocbq);
225 lpfc_nlp_put(ndlp); 216 lpfc_nlp_put(ndlp);
226 kfree(bmp); 217 kfree(bmp);
@@ -247,9 +238,7 @@ lpfc_bsg_send_mgmt_cmd(struct fc_bsg_job *job)
247 struct ulp_bde64 *bpl = NULL; 238 struct ulp_bde64 *bpl = NULL;
248 uint32_t timeout; 239 uint32_t timeout;
249 struct lpfc_iocbq *cmdiocbq = NULL; 240 struct lpfc_iocbq *cmdiocbq = NULL;
250 struct lpfc_iocbq *rspiocbq = NULL;
251 IOCB_t *cmd; 241 IOCB_t *cmd;
252 IOCB_t *rsp;
253 struct lpfc_dmabuf *bmp = NULL; 242 struct lpfc_dmabuf *bmp = NULL;
254 int request_nseg; 243 int request_nseg;
255 int reply_nseg; 244 int reply_nseg;
@@ -296,17 +285,10 @@ lpfc_bsg_send_mgmt_cmd(struct fc_bsg_job *job)
296 } 285 }
297 286
298 cmd = &cmdiocbq->iocb; 287 cmd = &cmdiocbq->iocb;
299 rspiocbq = lpfc_sli_get_iocbq(phba);
300 if (!rspiocbq) {
301 rc = -ENOMEM;
302 goto free_cmdiocbq;
303 }
304
305 rsp = &rspiocbq->iocb;
306 bmp->virt = lpfc_mbuf_alloc(phba, 0, &bmp->phys); 288 bmp->virt = lpfc_mbuf_alloc(phba, 0, &bmp->phys);
307 if (!bmp->virt) { 289 if (!bmp->virt) {
308 rc = -ENOMEM; 290 rc = -ENOMEM;
309 goto free_rspiocbq; 291 goto free_cmdiocbq;
310 } 292 }
311 293
312 INIT_LIST_HEAD(&bmp->list); 294 INIT_LIST_HEAD(&bmp->list);
@@ -358,14 +340,12 @@ lpfc_bsg_send_mgmt_cmd(struct fc_bsg_job *job)
358 cmd->ulpTimeout = timeout; 340 cmd->ulpTimeout = timeout;
359 341
360 cmdiocbq->iocb_cmpl = lpfc_bsg_send_mgmt_cmd_cmp; 342 cmdiocbq->iocb_cmpl = lpfc_bsg_send_mgmt_cmd_cmp;
361 cmdiocbq->context1 = dd_data; 343 cmdiocbq->context1 = ndlp;
362 cmdiocbq->context2 = rspiocbq; 344 cmdiocbq->context2 = dd_data;
363 dd_data->type = TYPE_IOCB; 345 dd_data->type = TYPE_IOCB;
364 dd_data->context_un.iocb.cmdiocbq = cmdiocbq; 346 dd_data->context_un.iocb.cmdiocbq = cmdiocbq;
365 dd_data->context_un.iocb.rspiocbq = rspiocbq;
366 dd_data->context_un.iocb.set_job = job; 347 dd_data->context_un.iocb.set_job = job;
367 dd_data->context_un.iocb.bmp = bmp; 348 dd_data->context_un.iocb.bmp = bmp;
368 dd_data->context_un.iocb.ndlp = ndlp;
369 349
370 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { 350 if (phba->cfg_poll & DISABLE_FCP_RING_INT) {
371 creg_val = readl(phba->HCregaddr); 351 creg_val = readl(phba->HCregaddr);
@@ -391,8 +371,6 @@ lpfc_bsg_send_mgmt_cmd(struct fc_bsg_job *job)
391 371
392 lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 372 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
393 373
394free_rspiocbq:
395 lpfc_sli_release_iocbq(phba, rspiocbq);
396free_cmdiocbq: 374free_cmdiocbq:
397 lpfc_sli_release_iocbq(phba, cmdiocbq); 375 lpfc_sli_release_iocbq(phba, cmdiocbq);
398free_bmp: 376free_bmp:
@@ -1220,7 +1198,7 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba,
1220 int rc = 0; 1198 int rc = 0;
1221 1199
1222 spin_lock_irqsave(&phba->ct_ev_lock, flags); 1200 spin_lock_irqsave(&phba->ct_ev_lock, flags);
1223 dd_data = cmdiocbq->context1; 1201 dd_data = cmdiocbq->context2;
1224 /* normal completion and timeout crossed paths, already done */ 1202 /* normal completion and timeout crossed paths, already done */
1225 if (!dd_data) { 1203 if (!dd_data) {
1226 spin_unlock_irqrestore(&phba->ct_ev_lock, flags); 1204 spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
@@ -1369,8 +1347,8 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
1369 ctiocb->context3 = bmp; 1347 ctiocb->context3 = bmp;
1370 1348
1371 ctiocb->iocb_cmpl = lpfc_issue_ct_rsp_cmp; 1349 ctiocb->iocb_cmpl = lpfc_issue_ct_rsp_cmp;
1372 ctiocb->context1 = dd_data; 1350 ctiocb->context2 = dd_data;
1373 ctiocb->context2 = NULL; 1351 ctiocb->context1 = ndlp;
1374 dd_data->type = TYPE_IOCB; 1352 dd_data->type = TYPE_IOCB;
1375 dd_data->context_un.iocb.cmdiocbq = ctiocb; 1353 dd_data->context_un.iocb.cmdiocbq = ctiocb;
1376 dd_data->context_un.iocb.rspiocbq = NULL; 1354 dd_data->context_un.iocb.rspiocbq = NULL;
@@ -1641,7 +1619,7 @@ job_error:
1641 * This function obtains a remote port login id so the diag loopback test 1619 * This function obtains a remote port login id so the diag loopback test
1642 * can send and receive its own unsolicited CT command. 1620 * can send and receive its own unsolicited CT command.
1643 **/ 1621 **/
1644static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t * rpi) 1622static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t *rpi)
1645{ 1623{
1646 LPFC_MBOXQ_t *mbox; 1624 LPFC_MBOXQ_t *mbox;
1647 struct lpfc_dmabuf *dmabuff; 1625 struct lpfc_dmabuf *dmabuff;
@@ -1651,10 +1629,14 @@ static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t * rpi)
1651 if (!mbox) 1629 if (!mbox)
1652 return -ENOMEM; 1630 return -ENOMEM;
1653 1631
1632 if (phba->sli_rev == LPFC_SLI_REV4)
1633 *rpi = lpfc_sli4_alloc_rpi(phba);
1654 status = lpfc_reg_rpi(phba, 0, phba->pport->fc_myDID, 1634 status = lpfc_reg_rpi(phba, 0, phba->pport->fc_myDID,
1655 (uint8_t *)&phba->pport->fc_sparam, mbox, 0); 1635 (uint8_t *)&phba->pport->fc_sparam, mbox, *rpi);
1656 if (status) { 1636 if (status) {
1657 mempool_free(mbox, phba->mbox_mem_pool); 1637 mempool_free(mbox, phba->mbox_mem_pool);
1638 if (phba->sli_rev == LPFC_SLI_REV4)
1639 lpfc_sli4_free_rpi(phba, *rpi);
1658 return -ENOMEM; 1640 return -ENOMEM;
1659 } 1641 }
1660 1642
@@ -1668,6 +1650,8 @@ static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t * rpi)
1668 kfree(dmabuff); 1650 kfree(dmabuff);
1669 if (status != MBX_TIMEOUT) 1651 if (status != MBX_TIMEOUT)
1670 mempool_free(mbox, phba->mbox_mem_pool); 1652 mempool_free(mbox, phba->mbox_mem_pool);
1653 if (phba->sli_rev == LPFC_SLI_REV4)
1654 lpfc_sli4_free_rpi(phba, *rpi);
1671 return -ENODEV; 1655 return -ENODEV;
1672 } 1656 }
1673 1657
@@ -1704,8 +1688,9 @@ static int lpfcdiag_loop_self_unreg(struct lpfc_hba *phba, uint16_t rpi)
1704 mempool_free(mbox, phba->mbox_mem_pool); 1688 mempool_free(mbox, phba->mbox_mem_pool);
1705 return -EIO; 1689 return -EIO;
1706 } 1690 }
1707
1708 mempool_free(mbox, phba->mbox_mem_pool); 1691 mempool_free(mbox, phba->mbox_mem_pool);
1692 if (phba->sli_rev == LPFC_SLI_REV4)
1693 lpfc_sli4_free_rpi(phba, rpi);
1709 return 0; 1694 return 0;
1710} 1695}
1711 1696
@@ -2102,7 +2087,7 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
2102 uint32_t size; 2087 uint32_t size;
2103 uint32_t full_size; 2088 uint32_t full_size;
2104 size_t segment_len = 0, segment_offset = 0, current_offset = 0; 2089 size_t segment_len = 0, segment_offset = 0, current_offset = 0;
2105 uint16_t rpi; 2090 uint16_t rpi = 0;
2106 struct lpfc_iocbq *cmdiocbq, *rspiocbq; 2091 struct lpfc_iocbq *cmdiocbq, *rspiocbq;
2107 IOCB_t *cmd, *rsp; 2092 IOCB_t *cmd, *rsp;
2108 struct lpfc_sli_ct_request *ctreq; 2093 struct lpfc_sli_ct_request *ctreq;
@@ -2162,7 +2147,7 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
2162 goto loopback_test_exit; 2147 goto loopback_test_exit;
2163 } 2148 }
2164 2149
2165 if (size >= BUF_SZ_4K) { 2150 if (full_size >= BUF_SZ_4K) {
2166 /* 2151 /*
2167 * Allocate memory for ioctl data. If buffer is bigger than 64k, 2152 * Allocate memory for ioctl data. If buffer is bigger than 64k,
2168 * then we allocate 64k and re-use that buffer over and over to 2153 * then we allocate 64k and re-use that buffer over and over to
@@ -2171,7 +2156,7 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
2171 * problem with GET_FCPTARGETMAPPING... 2156 * problem with GET_FCPTARGETMAPPING...
2172 */ 2157 */
2173 if (size <= (64 * 1024)) 2158 if (size <= (64 * 1024))
2174 total_mem = size; 2159 total_mem = full_size;
2175 else 2160 else
2176 total_mem = 64 * 1024; 2161 total_mem = 64 * 1024;
2177 } else 2162 } else
@@ -2189,7 +2174,6 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
2189 sg_copy_to_buffer(job->request_payload.sg_list, 2174 sg_copy_to_buffer(job->request_payload.sg_list,
2190 job->request_payload.sg_cnt, 2175 job->request_payload.sg_cnt,
2191 ptr, size); 2176 ptr, size);
2192
2193 rc = lpfcdiag_loop_self_reg(phba, &rpi); 2177 rc = lpfcdiag_loop_self_reg(phba, &rpi);
2194 if (rc) 2178 if (rc)
2195 goto loopback_test_exit; 2179 goto loopback_test_exit;
@@ -2601,12 +2585,11 @@ static int lpfc_bsg_check_cmd_access(struct lpfc_hba *phba,
2601 phba->wait_4_mlo_maint_flg = 1; 2585 phba->wait_4_mlo_maint_flg = 1;
2602 } else if (mb->un.varWords[0] == SETVAR_MLORST) { 2586 } else if (mb->un.varWords[0] == SETVAR_MLORST) {
2603 phba->link_flag &= ~LS_LOOPBACK_MODE; 2587 phba->link_flag &= ~LS_LOOPBACK_MODE;
2604 phba->fc_topology = TOPOLOGY_PT_PT; 2588 phba->fc_topology = LPFC_TOPOLOGY_PT_PT;
2605 } 2589 }
2606 break; 2590 break;
2607 case MBX_READ_SPARM64: 2591 case MBX_READ_SPARM64:
2608 case MBX_READ_LA: 2592 case MBX_READ_TOPOLOGY:
2609 case MBX_READ_LA64:
2610 case MBX_REG_LOGIN: 2593 case MBX_REG_LOGIN:
2611 case MBX_REG_LOGIN64: 2594 case MBX_REG_LOGIN64:
2612 case MBX_CONFIG_PORT: 2595 case MBX_CONFIG_PORT: