Skip to content

Commit 82de802

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Preparation for Target MQ.
In Current code, Req Q 0, RespQ 0 & hardware_lock are the main resources for sending and process completion of Target IO. These resources are now referenced behind a new qpair/"struct qla_qpair base_qpair". Main path IO handle will access those resources via the qpair pointer in preparation for Target MQ. 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 c5419e2 commit 82de802

File tree

10 files changed

+380
-297
lines changed

10 files changed

+380
-297
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,7 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
20962096
}
20972097

20982098
if (qos) {
2099-
qpair = qla2xxx_create_qpair(vha, qos, vha->vp_idx);
2099+
qpair = qla2xxx_create_qpair(vha, qos, vha->vp_idx, true);
21002100
if (!qpair)
21012101
ql_log(ql_log_warn, vha, 0x7084,
21022102
"Can't create qpair for VP[%d]\n",

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,9 @@ struct qla_tc_param {
31823182
#define QLA_PRECONFIG_VPORTS 32
31833183
#define QLA_MAX_VPORTS_QLA24XX 128
31843184
#define QLA_MAX_VPORTS_QLA25XX 256
3185+
3186+
struct qla_qpair;
3187+
31853188
/* Response queue data structure */
31863189
struct rsp_que {
31873190
dma_addr_t dma;
@@ -3201,6 +3204,7 @@ struct rsp_que {
32013204
struct qla_msix_entry *msix;
32023205
struct req_que *req;
32033206
srb_t *status_srb; /* status continuation entry */
3207+
struct qla_qpair *qpair;
32043208

32053209
dma_addr_t dma_fx00;
32063210
response_t *ring_fx00;
@@ -3241,6 +3245,14 @@ struct req_que {
32413245
struct qla_qpair {
32423246
spinlock_t qp_lock;
32433247
atomic_t ref_count;
3248+
3249+
/*
3250+
* For qpair 0, qp_lock_ptr will point at hardware_lock due to
3251+
* legacy code. For other Qpair(s), it will point at qp_lock.
3252+
*/
3253+
spinlock_t *qp_lock_ptr;
3254+
struct scsi_qla_host *vha;
3255+
32443256
/* distill these fields down to 'online=0/1'
32453257
* ha->flags.eeh_busy
32463258
* ha->flags.pci_channel_io_perm_failure
@@ -3252,10 +3264,7 @@ struct qla_qpair {
32523264
uint32_t delete_in_progress:1;
32533265

32543266
uint16_t id; /* qp number used with FW */
3255-
uint16_t num_active_cmd; /* cmds down at firmware */
3256-
cpumask_t cpu_mask; /* CPU mask for cpu affinity operation */
32573267
uint16_t vp_idx; /* vport ID */
3258-
32593268
mempool_t *srb_mempool;
32603269

32613270
/* to do: New driver: move queues to here instead of pointers */
@@ -3266,7 +3275,7 @@ struct qla_qpair {
32663275
struct qla_hw_data *hw;
32673276
struct work_struct q_work;
32683277
struct list_head qp_list_elem; /* vha->qp_list */
3269-
struct scsi_qla_host *vha;
3278+
uint16_t cpuid;
32703279
};
32713280

32723281
/* Place holder for FW buffer parameters */

drivers/scsi/qla2xxx/qla_gbl.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ struct qla_work_evt *qla2x00_alloc_work(struct scsi_qla_host *,
7777
enum qla_work_type);
7878
extern int qla24xx_async_gnl(struct scsi_qla_host *, fc_port_t *);
7979
int qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e);
80-
extern void *qla2x00_alloc_iocbs(struct scsi_qla_host *, srb_t *);
81-
extern void *qla2x00_alloc_iocbs_ready(struct scsi_qla_host *, srb_t *);
80+
extern void *qla2x00_alloc_iocbs_ready(struct qla_qpair *, srb_t *);
8281
extern int qla24xx_update_fcport_fcp_prio(scsi_qla_host_t *, fc_port_t *);
8382

8483
extern fc_port_t *
@@ -96,7 +95,7 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *, struct req_que *);
9695
extern int qla2x00_init_rings(scsi_qla_host_t *);
9796
extern uint8_t qla27xx_find_valid_image(struct scsi_qla_host *);
9897
extern struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *,
99-
int, int);
98+
int, int, bool);
10099
extern int qla2xxx_delete_qpair(struct scsi_qla_host *, struct qla_qpair *);
101100
void qla2x00_fcport_event_handler(scsi_qla_host_t *, struct event_arg *);
102101
int qla24xx_async_gpdb(struct scsi_qla_host *, fc_port_t *, u8);
@@ -255,7 +254,8 @@ extern int qla2x00_start_bidir(srb_t *, struct scsi_qla_host *, uint32_t);
255254
extern int qla2xxx_dif_start_scsi_mq(srb_t *);
256255
extern unsigned long qla2x00_get_async_timeout(struct scsi_qla_host *);
257256

258-
extern void *qla2x00_alloc_iocbs(scsi_qla_host_t *, srb_t *);
257+
extern void *qla2x00_alloc_iocbs(struct scsi_qla_host *, srb_t *);
258+
extern void *__qla2x00_alloc_iocbs(struct qla_qpair *, srb_t *);
259259
extern int qla2x00_issue_marker(scsi_qla_host_t *, int);
260260
extern int qla24xx_walk_and_build_sglist_no_difb(struct qla_hw_data *, srb_t *,
261261
uint32_t *, uint16_t, struct qla_tc_param *);
@@ -663,9 +663,9 @@ extern int qla25xx_request_irq(struct qla_hw_data *, struct qla_qpair *,
663663
extern int qla25xx_init_req_que(struct scsi_qla_host *, struct req_que *);
664664
extern int qla25xx_init_rsp_que(struct scsi_qla_host *, struct rsp_que *);
665665
extern int qla25xx_create_req_que(struct qla_hw_data *, uint16_t, uint8_t,
666-
uint16_t, int, uint8_t);
666+
uint16_t, int, uint8_t, bool);
667667
extern int qla25xx_create_rsp_que(struct qla_hw_data *, uint16_t, uint8_t,
668-
uint16_t, struct qla_qpair *);
668+
uint16_t, struct qla_qpair *, bool);
669669

670670
extern void qla2x00_init_response_q_entries(struct rsp_que *);
671671
extern int qla25xx_delete_req_que(struct scsi_qla_host *, struct req_que *);
@@ -839,7 +839,8 @@ extern int qla_get_exlogin_status(scsi_qla_host_t *, uint16_t *,
839839
extern int qla_set_exlogin_mem_cfg(scsi_qla_host_t *vha, dma_addr_t phys_addr);
840840
extern int qla_get_exchoffld_status(scsi_qla_host_t *, uint16_t *, uint16_t *);
841841
extern int qla_set_exchoffld_mem_cfg(scsi_qla_host_t *);
842-
extern void qlt_handle_abts_recv(struct scsi_qla_host *, response_t *);
842+
extern void qlt_handle_abts_recv(struct scsi_qla_host *, struct rsp_que *,
843+
response_t *);
843844

844845
int qla24xx_async_notify_ack(scsi_qla_host_t *, fc_port_t *,
845846
struct imm_ntfy_from_isp *, int);

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7578,7 +7578,8 @@ qla24xx_update_all_fcp_prio(scsi_qla_host_t *vha)
75787578
return ret;
75797579
}
75807580

7581-
struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos, int vp_idx)
7581+
struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
7582+
int vp_idx, bool startqp)
75827583
{
75837584
int rsp_id = 0;
75847585
int req_id = 0;
@@ -7605,6 +7606,8 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos, int v
76057606

76067607
qpair->hw = vha->hw;
76077608
qpair->vha = vha;
7609+
qpair->qp_lock_ptr = &qpair->qp_lock;
7610+
spin_lock_init(&qpair->qp_lock);
76087611

76097612
/* Assign available que pair id */
76107613
mutex_lock(&ha->mq_lock);
@@ -7642,7 +7645,7 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos, int v
76427645
mutex_unlock(&ha->mq_lock);
76437646

76447647
/* Create response queue first */
7645-
rsp_id = qla25xx_create_rsp_que(ha, 0, 0, 0, qpair);
7648+
rsp_id = qla25xx_create_rsp_que(ha, 0, 0, 0, qpair, startqp);
76467649
if (!rsp_id) {
76477650
ql_log(ql_log_warn, vha, 0x0185,
76487651
"Failed to create response queue.\n");
@@ -7652,7 +7655,8 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos, int v
76527655
qpair->rsp = ha->rsp_q_map[rsp_id];
76537656

76547657
/* Create request queue */
7655-
req_id = qla25xx_create_req_que(ha, 0, vp_idx, 0, rsp_id, qos);
7658+
req_id = qla25xx_create_req_que(ha, 0, vp_idx, 0, rsp_id, qos,
7659+
startqp);
76567660
if (!req_id) {
76577661
ql_log(ql_log_warn, vha, 0x0186,
76587662
"Failed to create request queue.\n");
@@ -7661,6 +7665,7 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos, int v
76617665

76627666
qpair->req = ha->req_q_map[req_id];
76637667
qpair->rsp->req = qpair->req;
7668+
qpair->rsp->qpair = qpair;
76647669

76657670
if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) {
76667671
if (ha->fw_attributes & BIT_4)

drivers/scsi/qla2xxx/qla_iocb.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,20 +2109,13 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp)
21092109
/* Generic Control-SRB manipulation functions. */
21102110

21112111
/* hardware_lock assumed to be held. */
2112-
void *
2113-
qla2x00_alloc_iocbs_ready(scsi_qla_host_t *vha, srb_t *sp)
2114-
{
2115-
if (qla2x00_reset_active(vha))
2116-
return NULL;
2117-
2118-
return qla2x00_alloc_iocbs(vha, sp);
2119-
}
21202112

21212113
void *
2122-
qla2x00_alloc_iocbs(scsi_qla_host_t *vha, srb_t *sp)
2114+
__qla2x00_alloc_iocbs(struct qla_qpair *qpair, srb_t *sp)
21232115
{
2116+
scsi_qla_host_t *vha = qpair->vha;
21242117
struct qla_hw_data *ha = vha->hw;
2125-
struct req_que *req = ha->req_q_map[0];
2118+
struct req_que *req = qpair->req;
21262119
device_reg_t *reg = ISP_QUE_REG(ha, req->id);
21272120
uint32_t index, handle;
21282121
request_t *pkt;
@@ -2200,6 +2193,23 @@ qla2x00_alloc_iocbs(scsi_qla_host_t *vha, srb_t *sp)
22002193
return pkt;
22012194
}
22022195

2196+
void *
2197+
qla2x00_alloc_iocbs_ready(struct qla_qpair *qpair, srb_t *sp)
2198+
{
2199+
scsi_qla_host_t *vha = qpair->vha;
2200+
2201+
if (qla2x00_reset_active(vha))
2202+
return NULL;
2203+
2204+
return __qla2x00_alloc_iocbs(qpair, sp);
2205+
}
2206+
2207+
void *
2208+
qla2x00_alloc_iocbs(struct scsi_qla_host *vha, srb_t *sp)
2209+
{
2210+
return __qla2x00_alloc_iocbs(vha->hw->base_qpair, sp);
2211+
}
2212+
22032213
static void
22042214
qla24xx_login_iocb(srb_t *sp, struct logio_entry_24xx *logio)
22052215
{

drivers/scsi/qla2xxx/qla_isr.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,7 +2653,8 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
26532653
int res = DID_ERROR << 16;
26542654

26552655
ql_dbg(ql_dbg_async, vha, 0x502a,
2656-
"type of error status in response: 0x%x\n", pkt->entry_status);
2656+
"iocb type %xh with error status %xh, handle %xh, rspq id %d\n",
2657+
pkt->entry_type, pkt->entry_status, pkt->handle, rsp->id);
26572658

26582659
if (que >= ha->max_req_queues || !ha->req_q_map[que])
26592660
goto fatal;
@@ -2805,7 +2806,8 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
28052806
case ABTS_RECV_24XX:
28062807
if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
28072808
/* ensure that the ATIO queue is empty */
2808-
qlt_handle_abts_recv(vha, (response_t *)pkt);
2809+
qlt_handle_abts_recv(vha, rsp,
2810+
(response_t *)pkt);
28092811
break;
28102812
} else {
28112813
/* drop through */
@@ -2814,11 +2816,12 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
28142816
case ABTS_RESP_24XX:
28152817
case CTIO_TYPE7:
28162818
case CTIO_CRC2:
2817-
qlt_response_pkt_all_vps(vha, (response_t *)pkt);
2819+
qlt_response_pkt_all_vps(vha, rsp, (response_t *)pkt);
28182820
break;
28192821
case NOTIFY_ACK_TYPE:
28202822
if (pkt->handle == QLA_TGT_SKIP_HANDLE)
2821-
qlt_response_pkt_all_vps(vha, (response_t *)pkt);
2823+
qlt_response_pkt_all_vps(vha, rsp,
2824+
(response_t *)pkt);
28222825
else
28232826
qla24xxx_nack_iocb_entry(vha, rsp->req,
28242827
(struct nack_to_isp *)pkt);

drivers/scsi/qla2xxx/qla_mid.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ qla25xx_delete_queues(struct scsi_qla_host *vha)
640640

641641
int
642642
qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
643-
uint8_t vp_idx, uint16_t rid, int rsp_que, uint8_t qos)
643+
uint8_t vp_idx, uint16_t rid, int rsp_que, uint8_t qos, bool startqp)
644644
{
645645
int ret = 0;
646646
struct req_que *req = NULL;
@@ -731,14 +731,16 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
731731
req->ring_ptr, req->ring_index, req->cnt,
732732
req->id, req->max_q_depth);
733733

734-
ret = qla25xx_init_req_que(base_vha, req);
735-
if (ret != QLA_SUCCESS) {
736-
ql_log(ql_log_fatal, base_vha, 0x00df,
737-
"%s failed.\n", __func__);
738-
mutex_lock(&ha->mq_lock);
739-
clear_bit(que_id, ha->req_qid_map);
740-
mutex_unlock(&ha->mq_lock);
741-
goto que_failed;
734+
if (startqp) {
735+
ret = qla25xx_init_req_que(base_vha, req);
736+
if (ret != QLA_SUCCESS) {
737+
ql_log(ql_log_fatal, base_vha, 0x00df,
738+
"%s failed.\n", __func__);
739+
mutex_lock(&ha->mq_lock);
740+
clear_bit(que_id, ha->req_qid_map);
741+
mutex_unlock(&ha->mq_lock);
742+
goto que_failed;
743+
}
742744
}
743745

744746
return req->id;
@@ -765,7 +767,7 @@ static void qla_do_work(struct work_struct *work)
765767
/* create response queue */
766768
int
767769
qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
768-
uint8_t vp_idx, uint16_t rid, struct qla_qpair *qpair)
770+
uint8_t vp_idx, uint16_t rid, struct qla_qpair *qpair, bool startqp)
769771
{
770772
int ret = 0;
771773
struct rsp_que *rsp = NULL;
@@ -843,14 +845,16 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
843845
if (ret)
844846
goto que_failed;
845847

846-
ret = qla25xx_init_rsp_que(base_vha, rsp);
847-
if (ret != QLA_SUCCESS) {
848-
ql_log(ql_log_fatal, base_vha, 0x00e7,
849-
"%s failed.\n", __func__);
850-
mutex_lock(&ha->mq_lock);
851-
clear_bit(que_id, ha->rsp_qid_map);
852-
mutex_unlock(&ha->mq_lock);
853-
goto que_failed;
848+
if (startqp) {
849+
ret = qla25xx_init_rsp_que(base_vha, rsp);
850+
if (ret != QLA_SUCCESS) {
851+
ql_log(ql_log_fatal, base_vha, 0x00e7,
852+
"%s failed.\n", __func__);
853+
mutex_lock(&ha->mq_lock);
854+
clear_bit(que_id, ha->rsp_qid_map);
855+
mutex_unlock(&ha->mq_lock);
856+
goto que_failed;
857+
}
854858
}
855859
rsp->req = NULL;
856860

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,13 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
389389
ha->base_qpair->rsp = rsp;
390390
}
391391

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+
392399
/*
393400
* Make sure we record at least the request and response queue zero in
394401
* case we need to free them if part of the probe fails.
@@ -399,9 +406,10 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
399406
set_bit(0, ha->req_qid_map);
400407
return 1;
401408

402-
fail_base_qpair:
403-
kfree(ha->queue_pair_map);
404409
fail_qpair_map:
410+
kfree(ha->base_qpair);
411+
ha->base_qpair = NULL;
412+
fail_base_qpair:
405413
kfree(ha->rsp_q_map);
406414
ha->rsp_q_map = NULL;
407415
fail_rsp_map:
@@ -451,6 +459,15 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
451459
int cnt;
452460
unsigned long flags;
453461

462+
if (ha->queue_pair_map) {
463+
kfree(ha->queue_pair_map);
464+
ha->queue_pair_map = NULL;
465+
}
466+
if (ha->base_qpair) {
467+
kfree(ha->base_qpair);
468+
ha->base_qpair = NULL;
469+
}
470+
454471
spin_lock_irqsave(&ha->hardware_lock, flags);
455472
for (cnt = 0; cnt < ha->max_req_queues; cnt++) {
456473
if (!test_bit(cnt, ha->req_qid_map))
@@ -3113,7 +3130,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
31133130
/* Create start of day qpairs for Block MQ */
31143131
if (shost_use_blk_mq(host)) {
31153132
for (i = 0; i < ha->max_qpairs; i++)
3116-
qla2xxx_create_qpair(base_vha, 5, 0);
3133+
qla2xxx_create_qpair(base_vha, 5, 0, true);
31173134
}
31183135
}
31193136

0 commit comments

Comments
 (0)