Skip to content

Commit 5613414

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: SLI path split: Introduce lpfc_prep_wqe
Introduce lpfc_prep_wqe routine. The lpfc_prep_wqe() routine is used with lpfc_sli_issue_iocb() and lpfc_sli_issue_iocb_wait(). The routine performs additional SLI-4 wqe field setting that the generic routines did not perform as they kept their actions compatible with both SLI3 and SLI4. Link: https://lore.kernel.org/r/20220225022308.16486-4-jsmart2021@gmail.com Co-developed-by: Justin Tee <justin.tee@broadcom.com> Signed-off-by: Justin Tee <justin.tee@broadcom.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 1b64aa9 commit 5613414

5 files changed

Lines changed: 200 additions & 2 deletions

File tree

drivers/scsi/lpfc/lpfc_bsg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,6 +3290,7 @@ lpfc_bsg_diag_loopback_run(struct bsg_job *job)
32903290
cmdiocbq->cmd_flag |= LPFC_IO_LOOPBACK;
32913291
cmdiocbq->vport = phba->pport;
32923292
cmdiocbq->cmd_cmpl = NULL;
3293+
32933294
iocb_stat = lpfc_sli_issue_iocb_wait(phba, LPFC_ELS_RING, cmdiocbq,
32943295
rspiocbq, (phba->fc_ratov * 2) +
32953296
LPFC_DRVR_TIMEOUT);

drivers/scsi/lpfc/lpfc_crtn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ void lpfc_els_timeout_handler(struct lpfc_vport *);
191191
struct lpfc_iocbq *lpfc_prep_els_iocb(struct lpfc_vport *, uint8_t, uint16_t,
192192
uint8_t, struct lpfc_nodelist *,
193193
uint32_t, uint32_t);
194+
void lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job);
194195
void lpfc_hb_timeout_handler(struct lpfc_hba *);
195196

196197
void lpfc_ct_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,

drivers/scsi/lpfc/lpfc_ct.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp,
659659
geniocb->context_un.ndlp = lpfc_nlp_get(ndlp);
660660
if (!geniocb->context_un.ndlp)
661661
goto out;
662+
662663
rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0);
663664

664665
if (rc == IOCB_ERROR) {

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,6 +2861,7 @@ lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
28612861
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
28622862
"Issue ADISC: did:x%x refcnt %d",
28632863
ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
2864+
28642865
rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
28652866
if (rc == IOCB_ERROR) {
28662867
lpfc_els_free_iocb(phba, elsiocb);
@@ -3085,6 +3086,7 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
30853086
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
30863087
"Issue LOGO: did:x%x refcnt %d",
30873088
ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
3089+
30883090
rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
30893091
if (rc == IOCB_ERROR) {
30903092
lpfc_els_free_iocb(phba, elsiocb);

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 195 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11251,6 +11251,8 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, uint32_t ring_number,
1125111251
int rc;
1125211252

1125311253
if (phba->sli_rev == LPFC_SLI_REV4) {
11254+
lpfc_sli_prep_wqe(phba, piocb);
11255+
1125411256
eq = phba->sli4_hba.hdwq[piocb->hba_wqidx].hba_eq;
1125511257

1125611258
pring = lpfc_sli4_calc_ring(phba, piocb);
@@ -13074,9 +13076,11 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba,
1307413076
unsigned long iflags;
1307513077
bool iocb_completed = true;
1307613078

13077-
if (phba->sli_rev >= LPFC_SLI_REV4)
13079+
if (phba->sli_rev >= LPFC_SLI_REV4) {
13080+
lpfc_sli_prep_wqe(phba, piocb);
13081+
1307813082
pring = lpfc_sli4_calc_ring(phba, piocb);
13079-
else
13083+
} else
1308013084
pring = &phba->sli.sli3_ring[ring_number];
1308113085
/*
1308213086
* If the caller has provided a response iocbq buffer, then context2
@@ -22448,3 +22452,192 @@ lpfc_free_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
2244822452

2244922453
spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags);
2245022454
}
22455+
22456+
/**
22457+
* lpfc_sli_prep_wqe - Prepare WQE for the command to be posted
22458+
* @phba: phba object
22459+
* @job: job entry of the command to be posted.
22460+
*
22461+
* Fill the common fields of the wqe for each of the command.
22462+
*
22463+
* Return codes:
22464+
* None
22465+
**/
22466+
void
22467+
lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job)
22468+
{
22469+
u8 cmnd;
22470+
u32 *pcmd;
22471+
u32 if_type = 0;
22472+
u32 fip, abort_tag;
22473+
struct lpfc_nodelist *ndlp = NULL;
22474+
union lpfc_wqe128 *wqe = &job->wqe;
22475+
struct lpfc_dmabuf *context2;
22476+
u32 els_id = LPFC_ELS_ID_DEFAULT;
22477+
u8 command_type = ELS_COMMAND_NON_FIP;
22478+
22479+
fip = phba->hba_flag & HBA_FIP_SUPPORT;
22480+
/* The fcp commands will set command type */
22481+
if (job->cmd_flag & LPFC_IO_FCP)
22482+
command_type = FCP_COMMAND;
22483+
else if (fip && (job->cmd_flag & LPFC_FIP_ELS_ID_MASK))
22484+
command_type = ELS_COMMAND_FIP;
22485+
else
22486+
command_type = ELS_COMMAND_NON_FIP;
22487+
22488+
abort_tag = job->iotag;
22489+
cmnd = bf_get(wqe_cmnd, &wqe->els_req.wqe_com);
22490+
22491+
switch (cmnd) {
22492+
case CMD_ELS_REQUEST64_WQE:
22493+
if (job->cmd_flag & LPFC_IO_LIBDFC)
22494+
ndlp = job->context_un.ndlp;
22495+
else
22496+
ndlp = (struct lpfc_nodelist *)job->context1;
22497+
22498+
/* CCP CCPE PV PRI in word10 were set in the memcpy */
22499+
if (command_type == ELS_COMMAND_FIP)
22500+
els_id = ((job->cmd_flag & LPFC_FIP_ELS_ID_MASK)
22501+
>> LPFC_FIP_ELS_ID_SHIFT);
22502+
22503+
if_type = bf_get(lpfc_sli_intf_if_type,
22504+
&phba->sli4_hba.sli_intf);
22505+
if (if_type >= LPFC_SLI_INTF_IF_TYPE_2) {
22506+
context2 = (struct lpfc_dmabuf *)job->context2;
22507+
pcmd = (u32 *)context2->virt;
22508+
if (pcmd && (*pcmd == ELS_CMD_FLOGI ||
22509+
*pcmd == ELS_CMD_SCR ||
22510+
*pcmd == ELS_CMD_RDF ||
22511+
*pcmd == ELS_CMD_EDC ||
22512+
*pcmd == ELS_CMD_RSCN_XMT ||
22513+
*pcmd == ELS_CMD_FDISC ||
22514+
*pcmd == ELS_CMD_LOGO ||
22515+
*pcmd == ELS_CMD_QFPA ||
22516+
*pcmd == ELS_CMD_UVEM ||
22517+
*pcmd == ELS_CMD_PLOGI)) {
22518+
bf_set(els_req64_sp, &wqe->els_req, 1);
22519+
bf_set(els_req64_sid, &wqe->els_req,
22520+
job->vport->fc_myDID);
22521+
22522+
if ((*pcmd == ELS_CMD_FLOGI) &&
22523+
!(phba->fc_topology ==
22524+
LPFC_TOPOLOGY_LOOP))
22525+
bf_set(els_req64_sid, &wqe->els_req, 0);
22526+
22527+
bf_set(wqe_ct, &wqe->els_req.wqe_com, 1);
22528+
bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com,
22529+
phba->vpi_ids[job->vport->vpi]);
22530+
} else if (pcmd) {
22531+
bf_set(wqe_ct, &wqe->els_req.wqe_com, 0);
22532+
bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com,
22533+
phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
22534+
}
22535+
}
22536+
22537+
bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com,
22538+
phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
22539+
22540+
bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id);
22541+
bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1);
22542+
bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ);
22543+
bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1);
22544+
bf_set(wqe_lenloc, &wqe->els_req.wqe_com, LPFC_WQE_LENLOC_NONE);
22545+
bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0);
22546+
break;
22547+
case CMD_XMIT_ELS_RSP64_WQE:
22548+
ndlp = (struct lpfc_nodelist *)job->context1;
22549+
22550+
/* word4 */
22551+
wqe->xmit_els_rsp.word4 = 0;
22552+
22553+
if_type = bf_get(lpfc_sli_intf_if_type,
22554+
&phba->sli4_hba.sli_intf);
22555+
if (if_type >= LPFC_SLI_INTF_IF_TYPE_2) {
22556+
if (job->vport->fc_flag & FC_PT2PT) {
22557+
bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1);
22558+
bf_set(els_rsp64_sid, &wqe->xmit_els_rsp,
22559+
job->vport->fc_myDID);
22560+
if (job->vport->fc_myDID == Fabric_DID) {
22561+
bf_set(wqe_els_did,
22562+
&wqe->xmit_els_rsp.wqe_dest, 0);
22563+
}
22564+
}
22565+
}
22566+
22567+
bf_set(wqe_dbde, &wqe->xmit_els_rsp.wqe_com, 1);
22568+
bf_set(wqe_iod, &wqe->xmit_els_rsp.wqe_com, LPFC_WQE_IOD_WRITE);
22569+
bf_set(wqe_qosd, &wqe->xmit_els_rsp.wqe_com, 1);
22570+
bf_set(wqe_lenloc, &wqe->xmit_els_rsp.wqe_com,
22571+
LPFC_WQE_LENLOC_WORD3);
22572+
bf_set(wqe_ebde_cnt, &wqe->xmit_els_rsp.wqe_com, 0);
22573+
22574+
if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
22575+
bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1);
22576+
bf_set(els_rsp64_sid, &wqe->xmit_els_rsp,
22577+
job->vport->fc_myDID);
22578+
bf_set(wqe_ct, &wqe->xmit_els_rsp.wqe_com, 1);
22579+
}
22580+
22581+
if (phba->sli_rev == LPFC_SLI_REV4) {
22582+
bf_set(wqe_rsp_temp_rpi, &wqe->xmit_els_rsp,
22583+
phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
22584+
22585+
if (bf_get(wqe_ct, &wqe->xmit_els_rsp.wqe_com))
22586+
bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com,
22587+
phba->vpi_ids[job->vport->vpi]);
22588+
}
22589+
command_type = OTHER_COMMAND;
22590+
break;
22591+
case CMD_GEN_REQUEST64_WQE:
22592+
/* Word 10 */
22593+
bf_set(wqe_dbde, &wqe->gen_req.wqe_com, 1);
22594+
bf_set(wqe_iod, &wqe->gen_req.wqe_com, LPFC_WQE_IOD_READ);
22595+
bf_set(wqe_qosd, &wqe->gen_req.wqe_com, 1);
22596+
bf_set(wqe_lenloc, &wqe->gen_req.wqe_com, LPFC_WQE_LENLOC_NONE);
22597+
bf_set(wqe_ebde_cnt, &wqe->gen_req.wqe_com, 0);
22598+
command_type = OTHER_COMMAND;
22599+
break;
22600+
case CMD_XMIT_SEQUENCE64_WQE:
22601+
if (phba->link_flag & LS_LOOPBACK_MODE)
22602+
bf_set(wqe_xo, &wqe->xmit_sequence.wge_ctl, 1);
22603+
22604+
wqe->xmit_sequence.rsvd3 = 0;
22605+
bf_set(wqe_pu, &wqe->xmit_sequence.wqe_com, 0);
22606+
bf_set(wqe_dbde, &wqe->xmit_sequence.wqe_com, 1);
22607+
bf_set(wqe_iod, &wqe->xmit_sequence.wqe_com,
22608+
LPFC_WQE_IOD_WRITE);
22609+
bf_set(wqe_lenloc, &wqe->xmit_sequence.wqe_com,
22610+
LPFC_WQE_LENLOC_WORD12);
22611+
bf_set(wqe_ebde_cnt, &wqe->xmit_sequence.wqe_com, 0);
22612+
command_type = OTHER_COMMAND;
22613+
break;
22614+
case CMD_XMIT_BLS_RSP64_WQE:
22615+
bf_set(xmit_bls_rsp64_seqcnthi, &wqe->xmit_bls_rsp, 0xffff);
22616+
bf_set(wqe_xmit_bls_pt, &wqe->xmit_bls_rsp.wqe_dest, 0x1);
22617+
bf_set(wqe_ct, &wqe->xmit_bls_rsp.wqe_com, 1);
22618+
bf_set(wqe_ctxt_tag, &wqe->xmit_bls_rsp.wqe_com,
22619+
phba->vpi_ids[phba->pport->vpi]);
22620+
bf_set(wqe_qosd, &wqe->xmit_bls_rsp.wqe_com, 1);
22621+
bf_set(wqe_lenloc, &wqe->xmit_bls_rsp.wqe_com,
22622+
LPFC_WQE_LENLOC_NONE);
22623+
/* Overwrite the pre-set comnd type with OTHER_COMMAND */
22624+
command_type = OTHER_COMMAND;
22625+
break;
22626+
case CMD_FCP_ICMND64_WQE: /* task mgmt commands */
22627+
case CMD_ABORT_XRI_WQE: /* abort iotag */
22628+
case CMD_SEND_FRAME: /* mds loopback */
22629+
/* cases already formatted for sli4 wqe - no chgs necessary */
22630+
return;
22631+
default:
22632+
dump_stack();
22633+
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
22634+
"6207 Invalid command 0x%x\n",
22635+
cmnd);
22636+
break;
22637+
}
22638+
22639+
wqe->generic.wqe_com.abort_tag = abort_tag;
22640+
bf_set(wqe_reqtag, &wqe->generic.wqe_com, job->iotag);
22641+
bf_set(wqe_cmd_type, &wqe->generic.wqe_com, command_type);
22642+
bf_set(wqe_cqid, &wqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT);
22643+
}

0 commit comments

Comments
 (0)