Skip to content

Commit eeb85c6

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Support loopback tests with VMID enabled
The VMID feature adds an extra application services header to each frame. As such, the loopback test path is updated to accommodate the extra application header. Changes include filling in APPID and WQES bit fields for XMIT_SEQUENCE64 commands, a special loopback source APPID for verifying received loopback data matches what is sent, and increasing ELS WQ size to accommodate the APPID field in loopback test mode. Signed-off-by: Justin Tee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 1af9af1 commit eeb85c6

File tree

4 files changed

+70
-4
lines changed

4 files changed

+70
-4
lines changed

drivers/scsi/lpfc/lpfc_bsg.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,6 +3208,9 @@ lpfc_bsg_diag_loopback_run(struct bsg_job *job)
32083208
cmdiocbq->num_bdes = num_bde;
32093209
cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;
32103210
cmdiocbq->cmd_flag |= LPFC_IO_LOOPBACK;
3211+
if (phba->cfg_vmid_app_header)
3212+
cmdiocbq->cmd_flag |= LPFC_IO_VMID;
3213+
32113214
cmdiocbq->vport = phba->pport;
32123215
cmdiocbq->cmd_cmpl = NULL;
32133216
cmdiocbq->bpl_dmabuf = txbmp;

drivers/scsi/lpfc/lpfc_hw.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,27 @@ struct fc_vft_header {
561561

562562
#include <uapi/scsi/fc/fc_els.h>
563563

564+
/*
565+
* Application Header
566+
*/
567+
struct fc_app_header {
568+
uint32_t dst_app_id;
569+
uint32_t src_app_id;
570+
#define LOOPBACK_SRC_APPID 0x4321
571+
uint32_t word2;
572+
uint32_t word3;
573+
};
574+
575+
/*
576+
* dfctl optional header definition
577+
*/
578+
enum lpfc_fc_dfctl {
579+
LPFC_FC_NO_DEVICE_HEADER,
580+
LPFC_FC_16B_DEVICE_HEADER,
581+
LPFC_FC_32B_DEVICE_HEADER,
582+
LPFC_FC_64B_DEVICE_HEADER,
583+
};
584+
564585
/*
565586
* Extended Link Service LS_COMMAND codes (Payload Word 0)
566587
*/

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10451,6 +10451,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
1045110451
struct lpfc_vector_map_info *cpup;
1045210452
struct lpfc_vector_map_info *eqcpup;
1045310453
struct lpfc_eq_intr_info *eqi;
10454+
u32 wqesize;
1045410455

1045510456
/*
1045610457
* Create HBA Record arrays.
@@ -10670,9 +10671,15 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
1067010671
* Create ELS Work Queues
1067110672
*/
1067210673

10673-
/* Create slow-path ELS Work Queue */
10674+
/*
10675+
* Create slow-path ELS Work Queue.
10676+
* Increase the ELS WQ size when WQEs contain an embedded cdb
10677+
*/
10678+
wqesize = (phba->fcp_embed_io) ?
10679+
LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize;
10680+
1067410681
qdesc = lpfc_sli4_queue_alloc(phba, LPFC_DEFAULT_PAGE_SIZE,
10675-
phba->sli4_hba.wq_esize,
10682+
wqesize,
1067610683
phba->sli4_hba.wq_ecount, cpu);
1067710684
if (!qdesc) {
1067810685
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11093,9 +11093,17 @@ __lpfc_sli_prep_xmit_seq64_s4(struct lpfc_iocbq *cmdiocbq,
1109311093
/* Word 9 */
1109411094
bf_set(wqe_rcvoxid, &wqe->xmit_sequence.wqe_com, ox_id);
1109511095

11096-
/* Word 12 */
11097-
if (cmdiocbq->cmd_flag & (LPFC_IO_LIBDFC | LPFC_IO_LOOPBACK))
11096+
if (cmdiocbq->cmd_flag & (LPFC_IO_LIBDFC | LPFC_IO_LOOPBACK)) {
11097+
/* Word 10 */
11098+
if (cmdiocbq->cmd_flag & LPFC_IO_VMID) {
11099+
bf_set(wqe_appid, &wqe->xmit_sequence.wqe_com, 1);
11100+
bf_set(wqe_wqes, &wqe->xmit_sequence.wqe_com, 1);
11101+
wqe->words[31] = LOOPBACK_SRC_APPID;
11102+
}
11103+
11104+
/* Word 12 */
1109811105
wqe->xmit_sequence.xmit_len = full_size;
11106+
}
1109911107
else
1110011108
wqe->xmit_sequence.xmit_len =
1110111109
wqe->xmit_sequence.bde.tus.f.bdeSize;
@@ -18434,6 +18442,7 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr)
1843418442
{
1843518443
/* make rctl_names static to save stack space */
1843618444
struct fc_vft_header *fc_vft_hdr;
18445+
struct fc_app_header *fc_app_hdr;
1843718446
uint32_t *header = (uint32_t *) fc_hdr;
1843818447

1843918448
#define FC_RCTL_MDS_DIAGS 0xF4
@@ -18489,6 +18498,32 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr)
1848918498
goto drop;
1849018499
}
1849118500

18501+
if (unlikely(phba->link_flag == LS_LOOPBACK_MODE &&
18502+
phba->cfg_vmid_app_header)) {
18503+
/* Application header is 16B device header */
18504+
if (fc_hdr->fh_df_ctl & LPFC_FC_16B_DEVICE_HEADER) {
18505+
fc_app_hdr = (struct fc_app_header *) (fc_hdr + 1);
18506+
if (be32_to_cpu(fc_app_hdr->src_app_id) !=
18507+
LOOPBACK_SRC_APPID) {
18508+
lpfc_printf_log(phba, KERN_WARNING,
18509+
LOG_ELS | LOG_LIBDFC,
18510+
"1932 Loopback src app id "
18511+
"not matched, app_id:x%x\n",
18512+
be32_to_cpu(fc_app_hdr->src_app_id));
18513+
18514+
goto drop;
18515+
}
18516+
} else {
18517+
lpfc_printf_log(phba, KERN_WARNING,
18518+
LOG_ELS | LOG_LIBDFC,
18519+
"1933 Loopback df_ctl bit not set, "
18520+
"df_ctl:x%x\n",
18521+
fc_hdr->fh_df_ctl);
18522+
18523+
goto drop;
18524+
}
18525+
}
18526+
1849218527
lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
1849318528
"2538 Received frame rctl:x%x, type:x%x, "
1849418529
"frame Data:%08x %08x %08x %08x %08x %08x %08x\n",

0 commit comments

Comments
 (0)