13
13
#include <linux/mutex.h>
14
14
#include <linux/kobject.h>
15
15
#include <linux/slab.h>
16
+ #include <linux/blk-mq-pci.h>
16
17
#include <scsi/scsi_tcq.h>
17
18
#include <scsi/scsicam.h>
18
19
#include <scsi/scsi_transport.h>
@@ -254,6 +255,7 @@ static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
254
255
static void qla2x00_clear_drv_active (struct qla_hw_data * );
255
256
static void qla2x00_free_device (scsi_qla_host_t * );
256
257
static void qla83xx_disable_laser (scsi_qla_host_t * vha );
258
+ static int qla2xxx_map_queues (struct Scsi_Host * shost );
257
259
258
260
struct scsi_host_template qla2xxx_driver_template = {
259
261
.module = THIS_MODULE ,
@@ -273,6 +275,7 @@ struct scsi_host_template qla2xxx_driver_template = {
273
275
.scan_finished = qla2xxx_scan_finished ,
274
276
.scan_start = qla2xxx_scan_start ,
275
277
.change_queue_depth = scsi_change_queue_depth ,
278
+ .map_queues = qla2xxx_map_queues ,
276
279
.this_id = -1 ,
277
280
.cmd_per_lun = 3 ,
278
281
.use_clustering = ENABLE_CLUSTERING ,
@@ -738,16 +741,26 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
738
741
struct scsi_qla_host * base_vha = pci_get_drvdata (ha -> pdev );
739
742
srb_t * sp ;
740
743
int rval ;
741
- struct qla_qpair * qpair ;
744
+ struct qla_qpair * qpair = NULL ;
745
+ uint32_t tag ;
746
+ uint16_t hwq ;
742
747
743
748
if (unlikely (test_bit (UNLOADING , & base_vha -> dpc_flags ))) {
744
749
cmd -> result = DID_NO_CONNECT << 16 ;
745
750
goto qc24_fail_command ;
746
751
}
747
752
748
- if (vha -> vp_idx && vha -> qpair ) {
749
- qpair = vha -> qpair ;
750
- return qla2xxx_mqueuecommand (host , cmd , qpair );
753
+ if (ha -> mqenable ) {
754
+ if (shost_use_blk_mq (vha -> host )) {
755
+ tag = blk_mq_unique_tag (cmd -> request );
756
+ hwq = blk_mq_unique_tag_to_hwq (tag );
757
+ qpair = ha -> queue_pair_map [hwq ];
758
+ } else if (vha -> vp_idx && vha -> qpair ) {
759
+ qpair = vha -> qpair ;
760
+ }
761
+
762
+ if (qpair )
763
+ return qla2xxx_mqueuecommand (host , cmd , qpair );
751
764
}
752
765
753
766
if (ha -> flags .eeh_busy ) {
@@ -2509,6 +2522,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2509
2522
uint16_t req_length = 0 , rsp_length = 0 ;
2510
2523
struct req_que * req = NULL ;
2511
2524
struct rsp_que * rsp = NULL ;
2525
+ int i ;
2512
2526
2513
2527
bars = pci_select_bars (pdev , IORESOURCE_MEM | IORESOURCE_IO );
2514
2528
sht = & qla2xxx_driver_template ;
@@ -2874,6 +2888,16 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2874
2888
goto probe_init_failed ;
2875
2889
}
2876
2890
2891
+ if (ha -> mqenable && shost_use_blk_mq (host )) {
2892
+ /* number of hardware queues supported by blk/scsi-mq*/
2893
+ host -> nr_hw_queues = ha -> max_qpairs ;
2894
+
2895
+ ql_dbg (ql_dbg_init , base_vha , 0x0192 ,
2896
+ "blk/scsi-mq enabled, HW queues = %d.\n" , host -> nr_hw_queues );
2897
+ } else
2898
+ ql_dbg (ql_dbg_init , base_vha , 0x0193 ,
2899
+ "blk/scsi-mq disabled.\n" );
2900
+
2877
2901
qlt_probe_one_stage1 (base_vha , ha );
2878
2902
2879
2903
pci_save_state (pdev );
@@ -2965,8 +2989,14 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2965
2989
host -> can_queue , base_vha -> req ,
2966
2990
base_vha -> mgmt_svr_loop_id , host -> sg_tablesize );
2967
2991
2968
- if (ha -> mqenable )
2992
+ if (ha -> mqenable ) {
2969
2993
ha -> wq = alloc_workqueue ("qla2xxx_wq" , WQ_MEM_RECLAIM , 1 );
2994
+ /* Create start of day qpairs for Block MQ */
2995
+ if (shost_use_blk_mq (host )) {
2996
+ for (i = 0 ; i < ha -> max_qpairs ; i ++ )
2997
+ qla2xxx_create_qpair (base_vha , 5 , 0 );
2998
+ }
2999
+ }
2970
3000
2971
3001
if (ha -> flags .running_gold_fw )
2972
3002
goto skip_dpc ;
@@ -6109,6 +6139,13 @@ qla83xx_disable_laser(scsi_qla_host_t *vha)
6109
6139
qla83xx_wr_reg (vha , reg , data );
6110
6140
}
6111
6141
6142
+ static int qla2xxx_map_queues (struct Scsi_Host * shost )
6143
+ {
6144
+ scsi_qla_host_t * vha = (scsi_qla_host_t * )shost -> hostdata ;
6145
+
6146
+ return blk_mq_pci_map_queues (& shost -> tag_set , vha -> hw -> pdev );
6147
+ }
6148
+
6112
6149
static const struct pci_error_handlers qla2xxx_err_handler = {
6113
6150
.error_detected = qla2xxx_pci_error_detected ,
6114
6151
.mmio_enabled = qla2xxx_pci_mmio_enabled ,
0 commit comments