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.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 7fb0ba4cbfa7..8675aa20642a 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -1471,13 +1471,12 @@ send_mgmt_rsp_exit:
1471/** 1471/**
1472 * lpfc_bsg_diag_mode_enter - process preparing into device diag loopback mode 1472 * lpfc_bsg_diag_mode_enter - process preparing into device diag loopback mode
1473 * @phba: Pointer to HBA context object. 1473 * @phba: Pointer to HBA context object.
1474 * @job: LPFC_BSG_VENDOR_DIAG_MODE
1475 * 1474 *
1476 * This function is responsible for preparing driver for diag loopback 1475 * This function is responsible for preparing driver for diag loopback
1477 * on device. 1476 * on device.
1478 */ 1477 */
1479static int 1478static int
1480lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba, struct fc_bsg_job *job) 1479lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba)
1481{ 1480{
1482 struct lpfc_vport **vports; 1481 struct lpfc_vport **vports;
1483 struct Scsi_Host *shost; 1482 struct Scsi_Host *shost;
@@ -1521,7 +1520,6 @@ lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba, struct fc_bsg_job *job)
1521/** 1520/**
1522 * lpfc_bsg_diag_mode_exit - exit process from device diag loopback mode 1521 * lpfc_bsg_diag_mode_exit - exit process from device diag loopback mode
1523 * @phba: Pointer to HBA context object. 1522 * @phba: Pointer to HBA context object.
1524 * @job: LPFC_BSG_VENDOR_DIAG_MODE
1525 * 1523 *
1526 * This function is responsible for driver exit processing of setting up 1524 * This function is responsible for driver exit processing of setting up
1527 * diag loopback mode on device. 1525 * diag loopback mode on device.
@@ -1586,7 +1584,7 @@ lpfc_sli3_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
1586 goto job_error; 1584 goto job_error;
1587 } 1585 }
1588 1586
1589 rc = lpfc_bsg_diag_mode_enter(phba, job); 1587 rc = lpfc_bsg_diag_mode_enter(phba);
1590 if (rc) 1588 if (rc)
1591 goto job_error; 1589 goto job_error;
1592 1590
@@ -1758,7 +1756,7 @@ lpfc_sli4_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
1758 goto job_error; 1756 goto job_error;
1759 } 1757 }
1760 1758
1761 rc = lpfc_bsg_diag_mode_enter(phba, job); 1759 rc = lpfc_bsg_diag_mode_enter(phba);
1762 if (rc) 1760 if (rc)
1763 goto job_error; 1761 goto job_error;
1764 1762
@@ -1982,7 +1980,7 @@ lpfc_sli4_bsg_link_diag_test(struct fc_bsg_job *job)
1982 goto job_error; 1980 goto job_error;
1983 } 1981 }
1984 1982
1985 rc = lpfc_bsg_diag_mode_enter(phba, job); 1983 rc = lpfc_bsg_diag_mode_enter(phba);
1986 if (rc) 1984 if (rc)
1987 goto job_error; 1985 goto job_error;
1988 1986
@@ -3511,7 +3509,7 @@ lpfc_bsg_sli_cfg_read_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
3511 lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC, 3509 lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
3512 "2947 Issued SLI_CONFIG ext-buffer " 3510 "2947 Issued SLI_CONFIG ext-buffer "
3513 "maibox command, rc:x%x\n", rc); 3511 "maibox command, rc:x%x\n", rc);
3514 return 1; 3512 return SLI_CONFIG_HANDLED;
3515 } 3513 }
3516 lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC, 3514 lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
3517 "2948 Failed to issue SLI_CONFIG ext-buffer " 3515 "2948 Failed to issue SLI_CONFIG ext-buffer "
@@ -3549,7 +3547,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
3549 LPFC_MBOXQ_t *pmboxq = NULL; 3547 LPFC_MBOXQ_t *pmboxq = NULL;
3550 MAILBOX_t *pmb; 3548 MAILBOX_t *pmb;
3551 uint8_t *mbx; 3549 uint8_t *mbx;
3552 int rc = 0, i; 3550 int rc = SLI_CONFIG_NOT_HANDLED, i;
3553 3551
3554 mbox_req = 3552 mbox_req =
3555 (struct dfc_mbox_req *)job->request->rqst_data.h_vendor.vendor_cmd; 3553 (struct dfc_mbox_req *)job->request->rqst_data.h_vendor.vendor_cmd;
@@ -3660,7 +3658,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
3660 lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC, 3658 lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
3661 "2955 Issued SLI_CONFIG ext-buffer " 3659 "2955 Issued SLI_CONFIG ext-buffer "
3662 "maibox command, rc:x%x\n", rc); 3660 "maibox command, rc:x%x\n", rc);
3663 return 1; 3661 return SLI_CONFIG_HANDLED;
3664 } 3662 }
3665 lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC, 3663 lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
3666 "2956 Failed to issue SLI_CONFIG ext-buffer " 3664 "2956 Failed to issue SLI_CONFIG ext-buffer "
@@ -3668,6 +3666,11 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
3668 rc = -EPIPE; 3666 rc = -EPIPE;
3669 } 3667 }
3670 3668
3669 /* wait for additoinal external buffers */
3670 job->reply->result = 0;
3671 job->job_done(job);
3672 return SLI_CONFIG_HANDLED;
3673
3671job_error: 3674job_error:
3672 if (pmboxq) 3675 if (pmboxq)
3673 mempool_free(pmboxq, phba->mbox_mem_pool); 3676 mempool_free(pmboxq, phba->mbox_mem_pool);
@@ -3959,7 +3962,7 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct fc_bsg_job *job,
3959 lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC, 3962 lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
3960 "2969 Issued SLI_CONFIG ext-buffer " 3963 "2969 Issued SLI_CONFIG ext-buffer "
3961 "maibox command, rc:x%x\n", rc); 3964 "maibox command, rc:x%x\n", rc);
3962 return 1; 3965 return SLI_CONFIG_HANDLED;
3963 } 3966 }
3964 lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC, 3967 lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
3965 "2970 Failed to issue SLI_CONFIG ext-buffer " 3968 "2970 Failed to issue SLI_CONFIG ext-buffer "
@@ -4039,14 +4042,14 @@ lpfc_bsg_handle_sli_cfg_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
4039 struct lpfc_dmabuf *dmabuf) 4042 struct lpfc_dmabuf *dmabuf)
4040{ 4043{
4041 struct dfc_mbox_req *mbox_req; 4044 struct dfc_mbox_req *mbox_req;
4042 int rc; 4045 int rc = SLI_CONFIG_NOT_HANDLED;
4043 4046
4044 mbox_req = 4047 mbox_req =
4045 (struct dfc_mbox_req *)job->request->rqst_data.h_vendor.vendor_cmd; 4048 (struct dfc_mbox_req *)job->request->rqst_data.h_vendor.vendor_cmd;
4046 4049
4047 /* mbox command with/without single external buffer */ 4050 /* mbox command with/without single external buffer */
4048 if (mbox_req->extMboxTag == 0 && mbox_req->extSeqNum == 0) 4051 if (mbox_req->extMboxTag == 0 && mbox_req->extSeqNum == 0)
4049 return SLI_CONFIG_NOT_HANDLED; 4052 return rc;
4050 4053
4051 /* mbox command and first external buffer */ 4054 /* mbox command and first external buffer */
4052 if (phba->mbox_ext_buf_ctx.state == LPFC_BSG_MBOX_IDLE) { 4055 if (phba->mbox_ext_buf_ctx.state == LPFC_BSG_MBOX_IDLE) {
@@ -4249,7 +4252,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
4249 * mailbox extension size 4252 * mailbox extension size
4250 */ 4253 */
4251 if ((transmit_length > receive_length) || 4254 if ((transmit_length > receive_length) ||
4252 (transmit_length > MAILBOX_EXT_SIZE)) { 4255 (transmit_length > BSG_MBOX_SIZE - sizeof(MAILBOX_t))) {
4253 rc = -ERANGE; 4256 rc = -ERANGE;
4254 goto job_done; 4257 goto job_done;
4255 } 4258 }
@@ -4272,7 +4275,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
4272 /* receive length cannot be greater than mailbox 4275 /* receive length cannot be greater than mailbox
4273 * extension size 4276 * extension size
4274 */ 4277 */
4275 if (receive_length > MAILBOX_EXT_SIZE) { 4278 if (receive_length > BSG_MBOX_SIZE - sizeof(MAILBOX_t)) {
4276 rc = -ERANGE; 4279 rc = -ERANGE;
4277 goto job_done; 4280 goto job_done;
4278 } 4281 }
@@ -4306,7 +4309,8 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
4306 bde = (struct ulp_bde64 *)&pmb->un.varWords[4]; 4309 bde = (struct ulp_bde64 *)&pmb->un.varWords[4];
4307 4310
4308 /* bde size cannot be greater than mailbox ext size */ 4311 /* bde size cannot be greater than mailbox ext size */
4309 if (bde->tus.f.bdeSize > MAILBOX_EXT_SIZE) { 4312 if (bde->tus.f.bdeSize >
4313 BSG_MBOX_SIZE - sizeof(MAILBOX_t)) {
4310 rc = -ERANGE; 4314 rc = -ERANGE;
4311 goto job_done; 4315 goto job_done;
4312 } 4316 }
@@ -4332,7 +4336,8 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
4332 * mailbox extension size 4336 * mailbox extension size
4333 */ 4337 */
4334 if ((receive_length == 0) || 4338 if ((receive_length == 0) ||
4335 (receive_length > MAILBOX_EXT_SIZE)) { 4339 (receive_length >
4340 BSG_MBOX_SIZE - sizeof(MAILBOX_t))) {
4336 rc = -ERANGE; 4341 rc = -ERANGE;
4337 goto job_done; 4342 goto job_done;
4338 } 4343 }