rk30/rk2928 hdmi:
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / lpfc / lpfc_bsg.c
index 7fb0ba4cbfa7048661bb616e5b8c5bdad5a09252..f46378fb802ca32429c15623beb40a63a2fcae81 100644 (file)
@@ -960,8 +960,10 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
                                                    evt_dat->immed_dat].oxid,
                                                phba->ct_ctx[
                                                    evt_dat->immed_dat].SID);
+                       phba->ct_ctx[evt_dat->immed_dat].rxid =
+                               piocbq->iocb.ulpContext;
                        phba->ct_ctx[evt_dat->immed_dat].oxid =
-                                               piocbq->iocb.ulpContext;
+                               piocbq->iocb.unsli3.rcvsli3.ox_id;
                        phba->ct_ctx[evt_dat->immed_dat].SID =
                                piocbq->iocb.un.rcvels.remoteID;
                        phba->ct_ctx[evt_dat->immed_dat].flags = UNSOL_VALID;
@@ -1312,7 +1314,8 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
                        rc = IOCB_ERROR;
                        goto issue_ct_rsp_exit;
                }
-               icmd->ulpContext = phba->ct_ctx[tag].oxid;
+               icmd->ulpContext = phba->ct_ctx[tag].rxid;
+               icmd->unsli3.rcvsli3.ox_id = phba->ct_ctx[tag].oxid;
                ndlp = lpfc_findnode_did(phba->pport, phba->ct_ctx[tag].SID);
                if (!ndlp) {
                        lpfc_printf_log(phba, KERN_WARNING, LOG_ELS,
@@ -1337,9 +1340,7 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
                        goto issue_ct_rsp_exit;
                }
 
-               icmd->un.ulpWord[3] = ndlp->nlp_rpi;
-               if (phba->sli_rev == LPFC_SLI_REV4)
-                       icmd->ulpContext =
+               icmd->un.ulpWord[3] =
                                phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
 
                /* The exchange is done, mark the entry as invalid */
@@ -1351,8 +1352,8 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct fc_bsg_job *job, uint32_t tag,
 
        /* Xmit CT response on exchange <xid> */
        lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
-                       "2722 Xmit CT response on exchange x%x Data: x%x x%x\n",
-                       icmd->ulpContext, icmd->ulpIoTag, phba->link_state);
+               "2722 Xmit CT response on exchange x%x Data: x%x x%x x%x\n",
+               icmd->ulpContext, icmd->ulpIoTag, tag, phba->link_state);
 
        ctiocb->iocb_cmpl = NULL;
        ctiocb->iocb_flag |= LPFC_IO_LIBDFC;
@@ -1471,13 +1472,12 @@ send_mgmt_rsp_exit:
 /**
  * lpfc_bsg_diag_mode_enter - process preparing into device diag loopback mode
  * @phba: Pointer to HBA context object.
- * @job: LPFC_BSG_VENDOR_DIAG_MODE
  *
  * This function is responsible for preparing driver for diag loopback
  * on device.
  */
 static int
-lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba, struct fc_bsg_job *job)
+lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba)
 {
        struct lpfc_vport **vports;
        struct Scsi_Host *shost;
@@ -1521,7 +1521,6 @@ lpfc_bsg_diag_mode_enter(struct lpfc_hba *phba, struct fc_bsg_job *job)
 /**
  * lpfc_bsg_diag_mode_exit - exit process from device diag loopback mode
  * @phba: Pointer to HBA context object.
- * @job: LPFC_BSG_VENDOR_DIAG_MODE
  *
  * This function is responsible for driver exit processing of setting up
  * diag loopback mode on device.
@@ -1586,7 +1585,7 @@ lpfc_sli3_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
                goto job_error;
        }
 
-       rc = lpfc_bsg_diag_mode_enter(phba, job);
+       rc = lpfc_bsg_diag_mode_enter(phba);
        if (rc)
                goto job_error;
 
@@ -1758,7 +1757,7 @@ lpfc_sli4_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
                goto job_error;
        }
 
-       rc = lpfc_bsg_diag_mode_enter(phba, job);
+       rc = lpfc_bsg_diag_mode_enter(phba);
        if (rc)
                goto job_error;
 
@@ -1982,7 +1981,7 @@ lpfc_sli4_bsg_link_diag_test(struct fc_bsg_job *job)
                goto job_error;
        }
 
-       rc = lpfc_bsg_diag_mode_enter(phba, job);
+       rc = lpfc_bsg_diag_mode_enter(phba);
        if (rc)
                goto job_error;
 
@@ -3511,7 +3510,7 @@ lpfc_bsg_sli_cfg_read_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
                lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
                                "2947 Issued SLI_CONFIG ext-buffer "
                                "maibox command, rc:x%x\n", rc);
-               return 1;
+               return SLI_CONFIG_HANDLED;
        }
        lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
                        "2948 Failed to issue SLI_CONFIG ext-buffer "
@@ -3549,7 +3548,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
        LPFC_MBOXQ_t *pmboxq = NULL;
        MAILBOX_t *pmb;
        uint8_t *mbx;
-       int rc = 0, i;
+       int rc = SLI_CONFIG_NOT_HANDLED, i;
 
        mbox_req =
           (struct dfc_mbox_req *)job->request->rqst_data.h_vendor.vendor_cmd;
@@ -3660,7 +3659,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
                        lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
                                        "2955 Issued SLI_CONFIG ext-buffer "
                                        "maibox command, rc:x%x\n", rc);
-                       return 1;
+                       return SLI_CONFIG_HANDLED;
                }
                lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
                                "2956 Failed to issue SLI_CONFIG ext-buffer "
@@ -3668,6 +3667,11 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
                rc = -EPIPE;
        }
 
+       /* wait for additoinal external buffers */
+       job->reply->result = 0;
+       job->job_done(job);
+       return SLI_CONFIG_HANDLED;
+
 job_error:
        if (pmboxq)
                mempool_free(pmboxq, phba->mbox_mem_pool);
@@ -3959,7 +3963,7 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct fc_bsg_job *job,
                        lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
                                        "2969 Issued SLI_CONFIG ext-buffer "
                                        "maibox command, rc:x%x\n", rc);
-                       return 1;
+                       return SLI_CONFIG_HANDLED;
                }
                lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
                                "2970 Failed to issue SLI_CONFIG ext-buffer "
@@ -4039,14 +4043,14 @@ lpfc_bsg_handle_sli_cfg_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
                            struct lpfc_dmabuf *dmabuf)
 {
        struct dfc_mbox_req *mbox_req;
-       int rc;
+       int rc = SLI_CONFIG_NOT_HANDLED;
 
        mbox_req =
           (struct dfc_mbox_req *)job->request->rqst_data.h_vendor.vendor_cmd;
 
        /* mbox command with/without single external buffer */
        if (mbox_req->extMboxTag == 0 && mbox_req->extSeqNum == 0)
-               return SLI_CONFIG_NOT_HANDLED;
+               return rc;
 
        /* mbox command and first external buffer */
        if (phba->mbox_ext_buf_ctx.state == LPFC_BSG_MBOX_IDLE) {
@@ -4249,7 +4253,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
                 * mailbox extension size
                 */
                if ((transmit_length > receive_length) ||
-                       (transmit_length > MAILBOX_EXT_SIZE)) {
+                       (transmit_length > BSG_MBOX_SIZE - sizeof(MAILBOX_t))) {
                        rc = -ERANGE;
                        goto job_done;
                }
@@ -4272,7 +4276,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
                /* receive length cannot be greater than mailbox
                 * extension size
                 */
-               if (receive_length > MAILBOX_EXT_SIZE) {
+               if (receive_length > BSG_MBOX_SIZE - sizeof(MAILBOX_t)) {
                        rc = -ERANGE;
                        goto job_done;
                }
@@ -4306,7 +4310,8 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
                        bde = (struct ulp_bde64 *)&pmb->un.varWords[4];
 
                        /* bde size cannot be greater than mailbox ext size */
-                       if (bde->tus.f.bdeSize > MAILBOX_EXT_SIZE) {
+                       if (bde->tus.f.bdeSize >
+                           BSG_MBOX_SIZE - sizeof(MAILBOX_t)) {
                                rc = -ERANGE;
                                goto job_done;
                        }
@@ -4332,7 +4337,8 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
                                 * mailbox extension size
                                 */
                                if ((receive_length == 0) ||
-                                   (receive_length > MAILBOX_EXT_SIZE)) {
+                                   (receive_length >
+                                    BSG_MBOX_SIZE - sizeof(MAILBOX_t))) {
                                        rc = -ERANGE;
                                        goto job_done;
                                }