Skip to content

Commit e326d22

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Enable Target Multi Queue
Enable Multi Queue for Target mode. At Initiator LUN scan time, each LUN is assign to a QPair. Each QPair is affinitize to certain CPU. When new cmd arrives from the wire, the lunid is used to search for qpair. The qpair's affinitized cpuid will be used to queue up the work element. Signed-off-by: Quinn Tran <quinn.tran@cavium.com> Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 82de802 commit e326d22

File tree

7 files changed

+240
-38
lines changed

7 files changed

+240
-38
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3245,7 +3245,7 @@ struct req_que {
32453245
struct qla_qpair {
32463246
spinlock_t qp_lock;
32473247
atomic_t ref_count;
3248-
3248+
uint32_t lun_cnt;
32493249
/*
32503250
* For qpair 0, qp_lock_ptr will point at hardware_lock due to
32513251
* legacy code. For other Qpair(s), it will point at qp_lock.
@@ -3275,6 +3275,7 @@ struct qla_qpair {
32753275
struct qla_hw_data *hw;
32763276
struct work_struct q_work;
32773277
struct list_head qp_list_elem; /* vha->qp_list */
3278+
struct list_head hints_list;
32783279
uint16_t cpuid;
32793280
};
32803281

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7623,6 +7623,7 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
76237623
ha->queue_pair_map[qpair_id] = qpair;
76247624
qpair->id = qpair_id;
76257625
qpair->vp_idx = vp_idx;
7626+
INIT_LIST_HEAD(&qpair->hints_list);
76267627

76277628
for (i = 0; i < ha->msix_count; i++) {
76287629
msix = &ha->msix_entries[i];
@@ -7666,6 +7667,8 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
76667667
qpair->req = ha->req_q_map[req_id];
76677668
qpair->rsp->req = qpair->req;
76687669
qpair->rsp->qpair = qpair;
7670+
/* init qpair to this cpu. Will adjust at run time. */
7671+
qla_cpu_update(qpair, smp_processor_id());
76697672

76707673
if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) {
76717674
if (ha->fw_attributes & BIT_4)

drivers/scsi/qla2xxx/qla_inline.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,31 @@ qla_is_exch_offld_enabled(struct scsi_qla_host *vha)
324324
else
325325
return false;
326326
}
327+
328+
static inline void
329+
qla_cpu_update(struct qla_qpair *qpair, uint16_t cpuid)
330+
{
331+
qpair->cpuid = cpuid;
332+
333+
if (!list_empty(&qpair->hints_list)) {
334+
struct qla_qpair_hint *h;
335+
336+
list_for_each_entry(h, &qpair->hints_list, hint_elem)
337+
h->cpuid = qpair->cpuid;
338+
}
339+
}
340+
341+
static inline struct qla_qpair_hint *
342+
qla_qpair_to_hint(struct qla_tgt *tgt, struct qla_qpair *qpair)
343+
{
344+
struct qla_qpair_hint *h;
345+
u16 i;
346+
347+
for (i = 0; i < tgt->ha->max_qpairs + 1; i++) {
348+
h = &tgt->qphints[i];
349+
if (h->qpair == qpair)
350+
return h;
351+
}
352+
353+
return NULL;
354+
}

drivers/scsi/qla2xxx/qla_isr.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/delay.h>
1111
#include <linux/slab.h>
12+
#include <linux/cpu.h>
1213
#include <linux/t10-pi.h>
1314
#include <scsi/scsi_tcq.h>
1415
#include <scsi/scsi_bsg_fc.h>
@@ -2761,6 +2762,9 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
27612762
if (!ha->flags.fw_started)
27622763
return;
27632764

2765+
if (rsp->qpair->cpuid != smp_processor_id())
2766+
qla_cpu_update(rsp->qpair, smp_processor_id());
2767+
27642768
while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) {
27652769
pkt = (struct sts_entry_24xx *)rsp->ring_ptr;
27662770

@@ -3196,10 +3200,10 @@ struct qla_init_msix_entry {
31963200
};
31973201

31983202
static const struct qla_init_msix_entry msix_entries[] = {
3199-
{ "qla2xxx (default)", qla24xx_msix_default },
3200-
{ "qla2xxx (rsp_q)", qla24xx_msix_rsp_q },
3201-
{ "qla2xxx (atio_q)", qla83xx_msix_atio_q },
3202-
{ "qla2xxx (qpair_multiq)", qla2xxx_msix_rsp_q },
3203+
{ "default", qla24xx_msix_default },
3204+
{ "rsp_q", qla24xx_msix_rsp_q },
3205+
{ "atio_q", qla83xx_msix_atio_q },
3206+
{ "qpair_multiq", qla2xxx_msix_rsp_q },
32033207
};
32043208

32053209
static const struct qla_init_msix_entry qla82xx_msix_entries[] = {
@@ -3279,15 +3283,15 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
32793283
qentry->handle = rsp;
32803284
rsp->msix = qentry;
32813285
scnprintf(qentry->name, sizeof(qentry->name),
3282-
"%s", msix_entries[i].name);
3286+
"qla2xxx%lu_%s", vha->host_no, msix_entries[i].name);
32833287
if (IS_P3P_TYPE(ha))
32843288
ret = request_irq(qentry->vector,
32853289
qla82xx_msix_entries[i].handler,
32863290
0, qla82xx_msix_entries[i].name, rsp);
32873291
else
32883292
ret = request_irq(qentry->vector,
32893293
msix_entries[i].handler,
3290-
0, msix_entries[i].name, rsp);
3294+
0, qentry->name, rsp);
32913295
if (ret)
32923296
goto msix_register_fail;
32933297
qentry->have_irq = 1;
@@ -3303,11 +3307,12 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
33033307
rsp->msix = qentry;
33043308
qentry->handle = rsp;
33053309
scnprintf(qentry->name, sizeof(qentry->name),
3306-
"%s", msix_entries[QLA_ATIO_VECTOR].name);
3310+
"qla2xxx%lu_%s", vha->host_no,
3311+
msix_entries[QLA_ATIO_VECTOR].name);
33073312
qentry->in_use = 1;
33083313
ret = request_irq(qentry->vector,
33093314
msix_entries[QLA_ATIO_VECTOR].handler,
3310-
0, msix_entries[QLA_ATIO_VECTOR].name, rsp);
3315+
0, qentry->name, rsp);
33113316
qentry->have_irq = 1;
33123317
}
33133318

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,23 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
371371
goto fail_rsp_map;
372372
}
373373

374+
ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL);
375+
if (ha->base_qpair == NULL) {
376+
ql_log(ql_log_warn, vha, 0x00e0,
377+
"Failed to allocate base queue pair memory.\n");
378+
goto fail_base_qpair;
379+
}
380+
381+
rsp->qpair = ha->base_qpair;
382+
rsp->req = req;
383+
ha->base_qpair->req = req;
384+
ha->base_qpair->rsp = rsp;
385+
ha->base_qpair->vha = vha;
386+
ha->base_qpair->qp_lock_ptr = &ha->hardware_lock;
387+
ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q];
388+
INIT_LIST_HEAD(&ha->base_qpair->hints_list);
389+
qla_cpu_update(rsp->qpair, smp_processor_id());
390+
374391
if (ql2xmqsupport && ha->max_qpairs) {
375392
ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *),
376393
GFP_KERNEL);
@@ -379,23 +396,8 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
379396
"Unable to allocate memory for queue pair ptrs.\n");
380397
goto fail_qpair_map;
381398
}
382-
ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL);
383-
if (ha->base_qpair == NULL) {
384-
ql_log(ql_log_warn, vha, 0x00e0,
385-
"Failed to allocate base queue pair memory.\n");
386-
goto fail_base_qpair;
387-
}
388-
ha->base_qpair->req = req;
389-
ha->base_qpair->rsp = rsp;
390399
}
391400

392-
rsp->qpair = ha->base_qpair;
393-
rsp->req = req;
394-
ha->base_qpair->vha = vha;
395-
ha->base_qpair->qp_lock_ptr = &ha->hardware_lock;
396-
ha->queue_pair_map[0] = ha->base_qpair;
397-
set_bit(0, ha->qpair_qid_map);
398-
399401
/*
400402
* Make sure we record at least the request and response queue zero in
401403
* case we need to free them if part of the probe fails.
@@ -2009,7 +2011,7 @@ qla83xx_iospace_config(struct qla_hw_data *ha)
20092011
/* Read MSIX vector size of the board */
20102012
pci_read_config_word(ha->pdev,
20112013
QLA_83XX_PCI_MSIX_CONTROL, &msix);
2012-
ha->msix_count = msix + 1;
2014+
ha->msix_count = (msix & PCI_MSIX_FLAGS_QSIZE) + 1;
20132015
/*
20142016
* By default, driver uses at least two msix vectors
20152017
* (default & rspq)
@@ -3125,12 +3127,26 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
31253127
host->can_queue, base_vha->req,
31263128
base_vha->mgmt_svr_loop_id, host->sg_tablesize);
31273129

3128-
if (ha->mqenable && qla_ini_mode_enabled(base_vha)) {
3130+
if (ha->mqenable) {
3131+
bool mq = false;
3132+
bool startit = false;
31293133
ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1);
3130-
/* Create start of day qpairs for Block MQ */
3131-
if (shost_use_blk_mq(host)) {
3134+
3135+
if (QLA_TGT_MODE_ENABLED()) {
3136+
mq = true;
3137+
startit = false;
3138+
}
3139+
3140+
if ((ql2x_ini_mode == QLA2XXX_INI_MODE_ENABLED) &&
3141+
shost_use_blk_mq(host)) {
3142+
mq = true;
3143+
startit = true;
3144+
}
3145+
3146+
if (mq) {
3147+
/* Create start of day qpairs for Block MQ */
31323148
for (i = 0; i < ha->max_qpairs; i++)
3133-
qla2xxx_create_qpair(base_vha, 5, 0, true);
3149+
qla2xxx_create_qpair(base_vha, 5, 0, startit);
31343150
}
31353151
}
31363152

0 commit comments

Comments
 (0)