|
@@ -259,6 +259,7 @@ lpfc_bsg_send_mgmt_cmd(struct fc_bsg_job *job)
|
|
struct bsg_job_data *dd_data;
|
|
struct bsg_job_data *dd_data;
|
|
uint32_t creg_val;
|
|
uint32_t creg_val;
|
|
int rc = 0;
|
|
int rc = 0;
|
|
|
|
+ int iocb_stat;
|
|
|
|
|
|
/* in case no data is transferred */
|
|
/* in case no data is transferred */
|
|
job->reply->reply_payload_rcv_len = 0;
|
|
job->reply->reply_payload_rcv_len = 0;
|
|
@@ -373,14 +374,13 @@ lpfc_bsg_send_mgmt_cmd(struct fc_bsg_job *job)
|
|
readl(phba->HCregaddr); /* flush */
|
|
readl(phba->HCregaddr); /* flush */
|
|
}
|
|
}
|
|
|
|
|
|
- rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
|
|
|
|
-
|
|
|
|
- if (rc == IOCB_SUCCESS)
|
|
|
|
|
|
+ iocb_stat = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
|
|
|
|
+ if (iocb_stat == IOCB_SUCCESS)
|
|
return 0; /* done for now */
|
|
return 0; /* done for now */
|
|
- else if (rc == IOCB_BUSY)
|
|
|
|
- rc = EAGAIN;
|
|
|
|
|
|
+ else if (iocb_stat == IOCB_BUSY)
|
|
|
|
+ rc = -EAGAIN;
|
|
else
|
|
else
|
|
- rc = EIO;
|
|
|
|
|
|
+ rc = -EIO;
|
|
|
|
|
|
|
|
|
|
/* iocb failed so cleanup */
|
|
/* iocb failed so cleanup */
|
|
@@ -631,9 +631,9 @@ lpfc_bsg_rport_els(struct fc_bsg_job *job)
|
|
if (rc == IOCB_SUCCESS)
|
|
if (rc == IOCB_SUCCESS)
|
|
return 0; /* done for now */
|
|
return 0; /* done for now */
|
|
else if (rc == IOCB_BUSY)
|
|
else if (rc == IOCB_BUSY)
|
|
- rc = EAGAIN;
|
|
|
|
|
|
+ rc = -EAGAIN;
|
|
else
|
|
else
|
|
- rc = EIO;
|
|
|
|
|
|
+ rc = -EIO;
|
|
|
|
|
|
pci_unmap_sg(phba->pcidev, job->request_payload.sg_list,
|
|
pci_unmap_sg(phba->pcidev, job->request_payload.sg_list,
|
|
job->request_payload.sg_cnt, DMA_TO_DEVICE);
|
|
job->request_payload.sg_cnt, DMA_TO_DEVICE);
|
|
@@ -1299,7 +1299,7 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
|
|
/* Allocate buffer for command iocb */
|
|
/* Allocate buffer for command iocb */
|
|
ctiocb = lpfc_sli_get_iocbq(phba);
|
|
ctiocb = lpfc_sli_get_iocbq(phba);
|
|
if (!ctiocb) {
|
|
if (!ctiocb) {
|
|
- rc = ENOMEM;
|
|
|
|
|
|
+ rc = -ENOMEM;
|
|
goto no_ctiocb;
|
|
goto no_ctiocb;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1649,17 +1649,18 @@ static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t * rpi)
|
|
|
|
|
|
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
|
|
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
|
|
if (!mbox)
|
|
if (!mbox)
|
|
- return ENOMEM;
|
|
|
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
status = lpfc_reg_rpi(phba, 0, phba->pport->fc_myDID,
|
|
status = lpfc_reg_rpi(phba, 0, phba->pport->fc_myDID,
|
|
(uint8_t *)&phba->pport->fc_sparam, mbox, 0);
|
|
(uint8_t *)&phba->pport->fc_sparam, mbox, 0);
|
|
if (status) {
|
|
if (status) {
|
|
mempool_free(mbox, phba->mbox_mem_pool);
|
|
mempool_free(mbox, phba->mbox_mem_pool);
|
|
- return ENOMEM;
|
|
|
|
|
|
+ return -ENOMEM;
|
|
}
|
|
}
|
|
|
|
|
|
dmabuff = (struct lpfc_dmabuf *) mbox->context1;
|
|
dmabuff = (struct lpfc_dmabuf *) mbox->context1;
|
|
mbox->context1 = NULL;
|
|
mbox->context1 = NULL;
|
|
|
|
+ mbox->context2 = NULL;
|
|
status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
|
|
status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
|
|
|
|
|
|
if ((status != MBX_SUCCESS) || (mbox->u.mb.mbxStatus)) {
|
|
if ((status != MBX_SUCCESS) || (mbox->u.mb.mbxStatus)) {
|
|
@@ -1667,7 +1668,7 @@ static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t * rpi)
|
|
kfree(dmabuff);
|
|
kfree(dmabuff);
|
|
if (status != MBX_TIMEOUT)
|
|
if (status != MBX_TIMEOUT)
|
|
mempool_free(mbox, phba->mbox_mem_pool);
|
|
mempool_free(mbox, phba->mbox_mem_pool);
|
|
- return ENODEV;
|
|
|
|
|
|
+ return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
*rpi = mbox->u.mb.un.varWords[0];
|
|
*rpi = mbox->u.mb.un.varWords[0];
|
|
@@ -1693,7 +1694,7 @@ static int lpfcdiag_loop_self_unreg(struct lpfc_hba *phba, uint16_t rpi)
|
|
/* Allocate mboxq structure */
|
|
/* Allocate mboxq structure */
|
|
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
|
|
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
|
|
if (mbox == NULL)
|
|
if (mbox == NULL)
|
|
- return ENOMEM;
|
|
|
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
lpfc_unreg_login(phba, 0, rpi, mbox);
|
|
lpfc_unreg_login(phba, 0, rpi, mbox);
|
|
status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
|
|
status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
|
|
@@ -1701,7 +1702,7 @@ static int lpfcdiag_loop_self_unreg(struct lpfc_hba *phba, uint16_t rpi)
|
|
if ((status != MBX_SUCCESS) || (mbox->u.mb.mbxStatus)) {
|
|
if ((status != MBX_SUCCESS) || (mbox->u.mb.mbxStatus)) {
|
|
if (status != MBX_TIMEOUT)
|
|
if (status != MBX_TIMEOUT)
|
|
mempool_free(mbox, phba->mbox_mem_pool);
|
|
mempool_free(mbox, phba->mbox_mem_pool);
|
|
- return EIO;
|
|
|
|
|
|
+ return -EIO;
|
|
}
|
|
}
|
|
|
|
|
|
mempool_free(mbox, phba->mbox_mem_pool);
|
|
mempool_free(mbox, phba->mbox_mem_pool);
|
|
@@ -1730,6 +1731,8 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
|
|
struct ulp_bde64 *bpl = NULL;
|
|
struct ulp_bde64 *bpl = NULL;
|
|
struct lpfc_sli_ct_request *ctreq = NULL;
|
|
struct lpfc_sli_ct_request *ctreq = NULL;
|
|
int ret_val = 0;
|
|
int ret_val = 0;
|
|
|
|
+ int time_left;
|
|
|
|
+ int iocb_stat;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
|
|
*txxri = 0;
|
|
*txxri = 0;
|
|
@@ -1737,7 +1740,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
|
|
evt = lpfc_bsg_event_new(FC_REG_CT_EVENT, current->pid,
|
|
evt = lpfc_bsg_event_new(FC_REG_CT_EVENT, current->pid,
|
|
SLI_CT_ELX_LOOPBACK);
|
|
SLI_CT_ELX_LOOPBACK);
|
|
if (!evt)
|
|
if (!evt)
|
|
- return ENOMEM;
|
|
|
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
spin_lock_irqsave(&phba->ct_ev_lock, flags);
|
|
spin_lock_irqsave(&phba->ct_ev_lock, flags);
|
|
list_add(&evt->node, &phba->ct_ev_waiters);
|
|
list_add(&evt->node, &phba->ct_ev_waiters);
|
|
@@ -1770,7 +1773,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
|
|
if (cmdiocbq == NULL || rspiocbq == NULL ||
|
|
if (cmdiocbq == NULL || rspiocbq == NULL ||
|
|
dmabuf == NULL || bpl == NULL || ctreq == NULL ||
|
|
dmabuf == NULL || bpl == NULL || ctreq == NULL ||
|
|
dmabuf->virt == NULL) {
|
|
dmabuf->virt == NULL) {
|
|
- ret_val = ENOMEM;
|
|
|
|
|
|
+ ret_val = -ENOMEM;
|
|
goto err_get_xri_exit;
|
|
goto err_get_xri_exit;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1806,24 +1809,24 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi,
|
|
cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC;
|
|
cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC;
|
|
cmdiocbq->vport = phba->pport;
|
|
cmdiocbq->vport = phba->pport;
|
|
|
|
|
|
- ret_val = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq,
|
|
|
|
|
|
+ iocb_stat = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq,
|
|
rspiocbq,
|
|
rspiocbq,
|
|
(phba->fc_ratov * 2)
|
|
(phba->fc_ratov * 2)
|
|
+ LPFC_DRVR_TIMEOUT);
|
|
+ LPFC_DRVR_TIMEOUT);
|
|
- if (ret_val)
|
|
|
|
|
|
+ if (iocb_stat) {
|
|
|
|
+ ret_val = -EIO;
|
|
goto err_get_xri_exit;
|
|
goto err_get_xri_exit;
|
|
-
|
|
|
|
|
|
+ }
|
|
*txxri = rsp->ulpContext;
|
|
*txxri = rsp->ulpContext;
|
|
|
|
|
|
evt->waiting = 1;
|
|
evt->waiting = 1;
|
|
evt->wait_time_stamp = jiffies;
|
|
evt->wait_time_stamp = jiffies;
|
|
- ret_val = wait_event_interruptible_timeout(
|
|
|
|
|
|
+ time_left = wait_event_interruptible_timeout(
|
|
evt->wq, !list_empty(&evt->events_to_see),
|
|
evt->wq, !list_empty(&evt->events_to_see),
|
|
((phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT) * HZ);
|
|
((phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT) * HZ);
|
|
if (list_empty(&evt->events_to_see))
|
|
if (list_empty(&evt->events_to_see))
|
|
- ret_val = (ret_val) ? EINTR : ETIMEDOUT;
|
|
|
|
|
|
+ ret_val = (time_left) ? -EINTR : -ETIMEDOUT;
|
|
else {
|
|
else {
|
|
- ret_val = IOCB_SUCCESS;
|
|
|
|
spin_lock_irqsave(&phba->ct_ev_lock, flags);
|
|
spin_lock_irqsave(&phba->ct_ev_lock, flags);
|
|
list_move(evt->events_to_see.prev, &evt->events_to_get);
|
|
list_move(evt->events_to_see.prev, &evt->events_to_get);
|
|
spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
|
|
spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
|
|
@@ -1845,7 +1848,7 @@ err_get_xri_exit:
|
|
kfree(dmabuf);
|
|
kfree(dmabuf);
|
|
}
|
|
}
|
|
|
|
|
|
- if (cmdiocbq && (ret_val != IOCB_TIMEDOUT))
|
|
|
|
|
|
+ if (cmdiocbq && (iocb_stat != IOCB_TIMEDOUT))
|
|
lpfc_sli_release_iocbq(phba, cmdiocbq);
|
|
lpfc_sli_release_iocbq(phba, cmdiocbq);
|
|
if (rspiocbq)
|
|
if (rspiocbq)
|
|
lpfc_sli_release_iocbq(phba, rspiocbq);
|
|
lpfc_sli_release_iocbq(phba, rspiocbq);
|
|
@@ -1959,6 +1962,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
|
|
uint32_t num_bde;
|
|
uint32_t num_bde;
|
|
struct lpfc_dmabufext *rxbuffer = NULL;
|
|
struct lpfc_dmabufext *rxbuffer = NULL;
|
|
int ret_val = 0;
|
|
int ret_val = 0;
|
|
|
|
+ int iocb_stat;
|
|
int i = 0;
|
|
int i = 0;
|
|
|
|
|
|
cmdiocbq = lpfc_sli_get_iocbq(phba);
|
|
cmdiocbq = lpfc_sli_get_iocbq(phba);
|
|
@@ -1973,7 +1977,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
|
|
}
|
|
}
|
|
|
|
|
|
if (!cmdiocbq || !rxbmp || !rxbpl || !rxbuffer) {
|
|
if (!cmdiocbq || !rxbmp || !rxbpl || !rxbuffer) {
|
|
- ret_val = ENOMEM;
|
|
|
|
|
|
+ ret_val = -ENOMEM;
|
|
goto err_post_rxbufs_exit;
|
|
goto err_post_rxbufs_exit;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2022,16 +2026,16 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
|
|
cmd->ulpClass = CLASS3;
|
|
cmd->ulpClass = CLASS3;
|
|
cmd->ulpContext = rxxri;
|
|
cmd->ulpContext = rxxri;
|
|
|
|
|
|
- ret_val = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
|
|
|
|
-
|
|
|
|
- if (ret_val == IOCB_ERROR) {
|
|
|
|
|
|
+ iocb_stat = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq,
|
|
|
|
+ 0);
|
|
|
|
+ if (iocb_stat == IOCB_ERROR) {
|
|
diag_cmd_data_free(phba,
|
|
diag_cmd_data_free(phba,
|
|
(struct lpfc_dmabufext *)mp[0]);
|
|
(struct lpfc_dmabufext *)mp[0]);
|
|
if (mp[1])
|
|
if (mp[1])
|
|
diag_cmd_data_free(phba,
|
|
diag_cmd_data_free(phba,
|
|
(struct lpfc_dmabufext *)mp[1]);
|
|
(struct lpfc_dmabufext *)mp[1]);
|
|
dmp = list_entry(next, struct lpfc_dmabuf, list);
|
|
dmp = list_entry(next, struct lpfc_dmabuf, list);
|
|
- ret_val = EIO;
|
|
|
|
|
|
+ ret_val = -EIO;
|
|
goto err_post_rxbufs_exit;
|
|
goto err_post_rxbufs_exit;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2045,7 +2049,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba *phba, uint16_t rxxri,
|
|
cmdiocbq = lpfc_sli_get_iocbq(phba);
|
|
cmdiocbq = lpfc_sli_get_iocbq(phba);
|
|
if (!cmdiocbq) {
|
|
if (!cmdiocbq) {
|
|
dmp = list_entry(next, struct lpfc_dmabuf, list);
|
|
dmp = list_entry(next, struct lpfc_dmabuf, list);
|
|
- ret_val = EIO;
|
|
|
|
|
|
+ ret_val = -EIO;
|
|
goto err_post_rxbufs_exit;
|
|
goto err_post_rxbufs_exit;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2111,6 +2115,8 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
|
|
uint32_t num_bde;
|
|
uint32_t num_bde;
|
|
uint8_t *ptr = NULL, *rx_databuf = NULL;
|
|
uint8_t *ptr = NULL, *rx_databuf = NULL;
|
|
int rc = 0;
|
|
int rc = 0;
|
|
|
|
+ int time_left;
|
|
|
|
+ int iocb_stat;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
void *dataout = NULL;
|
|
void *dataout = NULL;
|
|
uint32_t total_mem;
|
|
uint32_t total_mem;
|
|
@@ -2185,22 +2191,18 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
|
|
ptr, size);
|
|
ptr, size);
|
|
|
|
|
|
rc = lpfcdiag_loop_self_reg(phba, &rpi);
|
|
rc = lpfcdiag_loop_self_reg(phba, &rpi);
|
|
- if (rc) {
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
|
|
+ if (rc)
|
|
goto loopback_test_exit;
|
|
goto loopback_test_exit;
|
|
- }
|
|
|
|
|
|
|
|
rc = lpfcdiag_loop_get_xri(phba, rpi, &txxri, &rxxri);
|
|
rc = lpfcdiag_loop_get_xri(phba, rpi, &txxri, &rxxri);
|
|
if (rc) {
|
|
if (rc) {
|
|
lpfcdiag_loop_self_unreg(phba, rpi);
|
|
lpfcdiag_loop_self_unreg(phba, rpi);
|
|
- rc = -ENOMEM;
|
|
|
|
goto loopback_test_exit;
|
|
goto loopback_test_exit;
|
|
}
|
|
}
|
|
|
|
|
|
rc = lpfcdiag_loop_post_rxbufs(phba, rxxri, full_size);
|
|
rc = lpfcdiag_loop_post_rxbufs(phba, rxxri, full_size);
|
|
if (rc) {
|
|
if (rc) {
|
|
lpfcdiag_loop_self_unreg(phba, rpi);
|
|
lpfcdiag_loop_self_unreg(phba, rpi);
|
|
- rc = -ENOMEM;
|
|
|
|
goto loopback_test_exit;
|
|
goto loopback_test_exit;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2290,21 +2292,22 @@ lpfc_bsg_diag_test(struct fc_bsg_job *job)
|
|
cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC;
|
|
cmdiocbq->iocb_flag |= LPFC_IO_LIBDFC;
|
|
cmdiocbq->vport = phba->pport;
|
|
cmdiocbq->vport = phba->pport;
|
|
|
|
|
|
- rc = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq, rspiocbq,
|
|
|
|
- (phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT);
|
|
|
|
|
|
+ iocb_stat = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq,
|
|
|
|
+ rspiocbq, (phba->fc_ratov * 2) +
|
|
|
|
+ LPFC_DRVR_TIMEOUT);
|
|
|
|
|
|
- if ((rc != IOCB_SUCCESS) || (rsp->ulpStatus != IOCB_SUCCESS)) {
|
|
|
|
|
|
+ if ((iocb_stat != IOCB_SUCCESS) || (rsp->ulpStatus != IOCB_SUCCESS)) {
|
|
rc = -EIO;
|
|
rc = -EIO;
|
|
goto err_loopback_test_exit;
|
|
goto err_loopback_test_exit;
|
|
}
|
|
}
|
|
|
|
|
|
evt->waiting = 1;
|
|
evt->waiting = 1;
|
|
- rc = wait_event_interruptible_timeout(
|
|
|
|
|
|
+ time_left = wait_event_interruptible_timeout(
|
|
evt->wq, !list_empty(&evt->events_to_see),
|
|
evt->wq, !list_empty(&evt->events_to_see),
|
|
((phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT) * HZ);
|
|
((phba->fc_ratov * 2) + LPFC_DRVR_TIMEOUT) * HZ);
|
|
evt->waiting = 0;
|
|
evt->waiting = 0;
|
|
if (list_empty(&evt->events_to_see))
|
|
if (list_empty(&evt->events_to_see))
|
|
- rc = (rc) ? -EINTR : -ETIMEDOUT;
|
|
|
|
|
|
+ rc = (time_left) ? -EINTR : -ETIMEDOUT;
|
|
else {
|
|
else {
|
|
spin_lock_irqsave(&phba->ct_ev_lock, flags);
|
|
spin_lock_irqsave(&phba->ct_ev_lock, flags);
|
|
list_move(evt->events_to_see.prev, &evt->events_to_get);
|
|
list_move(evt->events_to_see.prev, &evt->events_to_get);
|