Skip to content

Commit 8b0dff1

Browse files
James SmartJames Bottomley
authored andcommitted
lpfc: Add support for using block multi-queue
With blk-mq support in the mid-layer, lpfc can do IO steering based on the information in the request tag. This patch allows lpfc to use blk-mq if enabled. If not enabled, we fall back into the emulex-internal affinity mappings. This feature can be turned on via CONFIG_SCSI_MQ_DEFAULT or passing scsi_mod.use_blk_mq=Y as a parameter to the kernel. Signed-off-by: Dick Kennedy <[email protected]> Signed-off-by: James Smart <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 953ceed commit 8b0dff1

File tree

4 files changed

+72
-52
lines changed

4 files changed

+72
-52
lines changed

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3303,6 +3303,7 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
33033303
shost->max_lun = vport->cfg_max_luns;
33043304
shost->this_id = -1;
33053305
shost->max_cmd_len = 16;
3306+
shost->nr_hw_queues = phba->cfg_fcp_io_channel;
33063307
if (phba->sli_rev == LPFC_SLI_REV4) {
33073308
shost->dma_boundary =
33083309
phba->sli4_hba.pc_sli4_params.sge_supp_len-1;
@@ -8980,7 +8981,8 @@ lpfc_sli4_enable_msix(struct lpfc_hba *phba)
89808981
phba->cfg_fcp_io_channel = vectors;
89818982
}
89828983

8983-
lpfc_sli4_set_affinity(phba, vectors);
8984+
if (!shost_use_blk_mq(lpfc_shost_from_vport(phba->pport)))
8985+
lpfc_sli4_set_affinity(phba, vectors);
89848986
return rc;
89858987

89868988
cfg_fail_out:

drivers/scsi/lpfc/lpfc_scsi.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,6 +3845,49 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
38453845
lpfc_send_scsi_error_event(vport->phba, vport, lpfc_cmd, rsp_iocb);
38463846
}
38473847

3848+
/**
3849+
* lpfc_sli4_scmd_to_wqidx_distr - scsi command to SLI4 WQ index distribution
3850+
* @phba: Pointer to HBA context object.
3851+
*
3852+
* This routine performs a roundrobin SCSI command to SLI4 FCP WQ index
3853+
* distribution. This is called by __lpfc_sli_issue_iocb_s4() with the hbalock
3854+
* held.
3855+
* If scsi-mq is enabled, get the default block layer mapping of software queues
3856+
* to hardware queues. This information is saved in request tag.
3857+
*
3858+
* Return: index into SLI4 fast-path FCP queue index.
3859+
**/
3860+
int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
3861+
struct lpfc_scsi_buf *lpfc_cmd)
3862+
{
3863+
struct scsi_cmnd *cmnd = lpfc_cmd->pCmd;
3864+
struct lpfc_vector_map_info *cpup;
3865+
int chann, cpu;
3866+
uint32_t tag;
3867+
uint16_t hwq;
3868+
3869+
if (shost_use_blk_mq(cmnd->device->host)) {
3870+
tag = blk_mq_unique_tag(cmnd->request);
3871+
hwq = blk_mq_unique_tag_to_hwq(tag);
3872+
3873+
return hwq;
3874+
}
3875+
3876+
if (phba->cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_CPU
3877+
&& phba->cfg_fcp_io_channel > 1) {
3878+
cpu = smp_processor_id();
3879+
if (cpu < phba->sli4_hba.num_present_cpu) {
3880+
cpup = phba->sli4_hba.cpu_map;
3881+
cpup += cpu;
3882+
return cpup->channel_id;
3883+
}
3884+
}
3885+
chann = atomic_add_return(1, &phba->fcp_qidx);
3886+
chann = (chann % phba->cfg_fcp_io_channel);
3887+
return chann;
3888+
}
3889+
3890+
38483891
/**
38493892
* lpfc_scsi_cmd_iocb_cmpl - Scsi cmnd IOCB completion routine
38503893
* @phba: The Hba for which this call is being executed.

drivers/scsi/lpfc/lpfc_scsi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,6 @@ struct lpfc_scsi_buf {
184184
#define FIND_FIRST_OAS_LUN 0
185185
#define NO_MORE_OAS_LUN -1
186186
#define NOT_OAS_ENABLED_LUN NO_MORE_OAS_LUN
187+
188+
int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
189+
struct lpfc_scsi_buf *lpfc_cmd);

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8137,36 +8137,6 @@ lpfc_sli4_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
81378137
return sglq->sli4_xritag;
81388138
}
81398139

8140-
/**
8141-
* lpfc_sli4_scmd_to_wqidx_distr - scsi command to SLI4 WQ index distribution
8142-
* @phba: Pointer to HBA context object.
8143-
*
8144-
* This routine performs a roundrobin SCSI command to SLI4 FCP WQ index
8145-
* distribution. This is called by __lpfc_sli_issue_iocb_s4() with the hbalock
8146-
* held.
8147-
*
8148-
* Return: index into SLI4 fast-path FCP queue index.
8149-
**/
8150-
static inline int
8151-
lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba)
8152-
{
8153-
struct lpfc_vector_map_info *cpup;
8154-
int chann, cpu;
8155-
8156-
if (phba->cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_CPU
8157-
&& phba->cfg_fcp_io_channel > 1) {
8158-
cpu = smp_processor_id();
8159-
if (cpu < phba->sli4_hba.num_present_cpu) {
8160-
cpup = phba->sli4_hba.cpu_map;
8161-
cpup += cpu;
8162-
return cpup->channel_id;
8163-
}
8164-
}
8165-
chann = atomic_add_return(1, &phba->fcp_qidx);
8166-
chann = (chann % phba->cfg_fcp_io_channel);
8167-
return chann;
8168-
}
8169-
81708140
/**
81718141
* lpfc_sli_iocb2wqe - Convert the IOCB to a work queue entry.
81728142
* @phba: Pointer to HBA context object.
@@ -8807,27 +8777,29 @@ int
88078777
lpfc_sli_calc_ring(struct lpfc_hba *phba, uint32_t ring_number,
88088778
struct lpfc_iocbq *piocb)
88098779
{
8810-
if (phba->sli_rev == LPFC_SLI_REV4) {
8811-
if (piocb->iocb_flag & (LPFC_IO_FCP | LPFC_USE_FCPWQIDX)) {
8812-
if (!(phba->cfg_fof) ||
8813-
(!(piocb->iocb_flag & LPFC_IO_FOF))) {
8814-
if (unlikely(!phba->sli4_hba.fcp_wq))
8815-
return LPFC_HBA_ERROR;
8816-
/*
8817-
* for abort iocb fcp_wqidx should already
8818-
* be setup based on what work queue we used.
8819-
*/
8820-
if (!(piocb->iocb_flag & LPFC_USE_FCPWQIDX))
8821-
piocb->fcp_wqidx =
8822-
lpfc_sli4_scmd_to_wqidx_distr(phba);
8823-
ring_number = MAX_SLI3_CONFIGURED_RINGS +
8824-
piocb->fcp_wqidx;
8825-
} else {
8826-
if (unlikely(!phba->sli4_hba.oas_wq))
8827-
return LPFC_HBA_ERROR;
8828-
piocb->fcp_wqidx = 0;
8829-
ring_number = LPFC_FCP_OAS_RING;
8830-
}
8780+
if (phba->sli_rev < LPFC_SLI_REV4)
8781+
return ring_number;
8782+
8783+
if (piocb->iocb_flag & (LPFC_IO_FCP | LPFC_USE_FCPWQIDX)) {
8784+
if (!(phba->cfg_fof) ||
8785+
(!(piocb->iocb_flag & LPFC_IO_FOF))) {
8786+
if (unlikely(!phba->sli4_hba.fcp_wq))
8787+
return LPFC_HBA_ERROR;
8788+
/*
8789+
* for abort iocb fcp_wqidx should already
8790+
* be setup based on what work queue we used.
8791+
*/
8792+
if (!(piocb->iocb_flag & LPFC_USE_FCPWQIDX))
8793+
piocb->fcp_wqidx =
8794+
lpfc_sli4_scmd_to_wqidx_distr(phba,
8795+
piocb->context1);
8796+
ring_number = MAX_SLI3_CONFIGURED_RINGS +
8797+
piocb->fcp_wqidx;
8798+
} else {
8799+
if (unlikely(!phba->sli4_hba.oas_wq))
8800+
return LPFC_HBA_ERROR;
8801+
piocb->fcp_wqidx = 0;
8802+
ring_number = LPFC_FCP_OAS_RING;
88318803
}
88328804
}
88338805
return ring_number;

0 commit comments

Comments
 (0)