Skip to content

Commit d745952

Browse files
Michael Hernandezmartinkpetersen
authored andcommitted
scsi: qla2xxx: Add multiple queue pair functionality.
Replaced existing multiple queue functionality with framework that allows for the creation of pairs of request and response queues, either at start of day or dynamically. Queue pair creation depend on module parameter "ql2xmqsupport", which need to be enabled to create queue pair. Signed-off-by: Sawan Chandak <[email protected]> Signed-off-by: Michael Hernandez <[email protected]> Signed-off-by: Himanshu Madhani <[email protected]> Acked-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4fa1834 commit d745952

File tree

11 files changed

+1114
-335
lines changed

11 files changed

+1114
-335
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,9 +1988,9 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
19881988
scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
19891989
scsi_qla_host_t *vha = NULL;
19901990
struct qla_hw_data *ha = base_vha->hw;
1991-
uint16_t options = 0;
19921991
int cnt;
19931992
struct req_que *req = ha->req_q_map[0];
1993+
struct qla_qpair *qpair;
19941994

19951995
ret = qla24xx_vport_create_req_sanity_check(fc_vport);
19961996
if (ret) {
@@ -2075,15 +2075,9 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
20752075
qlt_vport_create(vha, ha);
20762076
qla24xx_vport_disable(fc_vport, disable);
20772077

2078-
if (ha->flags.cpu_affinity_enabled) {
2079-
req = ha->req_q_map[1];
2080-
ql_dbg(ql_dbg_multiq, vha, 0xc000,
2081-
"Request queue %p attached with "
2082-
"VP[%d], cpu affinity =%d\n",
2083-
req, vha->vp_idx, ha->flags.cpu_affinity_enabled);
2084-
goto vport_queue;
2085-
} else if (ql2xmaxqueues == 1 || !ha->npiv_info)
2078+
if (!ql2xmqsupport || !ha->npiv_info)
20862079
goto vport_queue;
2080+
20872081
/* Create a request queue in QoS mode for the vport */
20882082
for (cnt = 0; cnt < ha->nvram_npiv_size; cnt++) {
20892083
if (memcmp(ha->npiv_info[cnt].port_name, vha->port_name, 8) == 0
@@ -2095,20 +2089,20 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
20952089
}
20962090

20972091
if (qos) {
2098-
ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, 0,
2099-
qos);
2100-
if (!ret)
2092+
qpair = qla2xxx_create_qpair(vha, qos, vha->vp_idx);
2093+
if (!qpair)
21012094
ql_log(ql_log_warn, vha, 0x7084,
2102-
"Can't create request queue for VP[%d]\n",
2095+
"Can't create qpair for VP[%d]\n",
21032096
vha->vp_idx);
21042097
else {
21052098
ql_dbg(ql_dbg_multiq, vha, 0xc001,
2106-
"Request Que:%d Q0s: %d) created for VP[%d]\n",
2107-
ret, qos, vha->vp_idx);
2099+
"Queue pair: %d Qos: %d) created for VP[%d]\n",
2100+
qpair->id, qos, vha->vp_idx);
21082101
ql_dbg(ql_dbg_user, vha, 0x7085,
2109-
"Request Que:%d Q0s: %d) created for VP[%d]\n",
2110-
ret, qos, vha->vp_idx);
2111-
req = ha->req_q_map[ret];
2102+
"Queue Pair: %d Qos: %d) created for VP[%d]\n",
2103+
qpair->id, qos, vha->vp_idx);
2104+
req = qpair->req;
2105+
vha->qpair = qpair;
21122106
}
21132107
}
21142108

@@ -2162,10 +2156,10 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
21622156
clear_bit(vha->vp_idx, ha->vp_idx_map);
21632157
mutex_unlock(&ha->vport_lock);
21642158

2165-
if (vha->req->id && !ha->flags.cpu_affinity_enabled) {
2166-
if (qla25xx_delete_req_que(vha, vha->req) != QLA_SUCCESS)
2159+
if (vha->qpair->vp_idx == vha->vp_idx) {
2160+
if (qla2xxx_delete_qpair(vha, vha->qpair) != QLA_SUCCESS)
21672161
ql_log(ql_log_warn, vha, 0x7087,
2168-
"Queue delete failed.\n");
2162+
"Queue Pair delete failed.\n");
21692163
}
21702164

21712165
ql_log(ql_log_info, vha, 0x7088, "VP[%d] deleted.\n", id);

drivers/scsi/qla2xxx/qla_dbg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* ----------------------------------------------------------------------
1212
* | Level | Last Value Used | Holes |
1313
* ----------------------------------------------------------------------
14-
* | Module Init and Probe | 0x0191 | 0x0146 |
14+
* | Module Init and Probe | 0x0193 | 0x0146 |
1515
* | | | 0x015b-0x0160 |
1616
* | | | 0x016e |
1717
* | Mailbox commands | 0x1199 | 0x1193 |
@@ -58,7 +58,7 @@
5858
* | | | 0xb13a,0xb142 |
5959
* | | | 0xb13c-0xb140 |
6060
* | | | 0xb149 |
61-
* | MultiQ | 0xc00c | |
61+
* | MultiQ | 0xc010 | |
6262
* | Misc | 0xd301 | 0xd031-0xd0ff |
6363
* | | | 0xd101-0xd1fe |
6464
* | | | 0xd214-0xd2fe |

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 90 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ typedef struct srb {
401401
uint16_t type;
402402
char *name;
403403
int iocbs;
404+
struct qla_qpair *qpair;
404405
union {
405406
struct srb_iocb iocb_cmd;
406407
struct bsg_job *bsg_job;
@@ -2719,6 +2720,7 @@ struct isp_operations {
27192720

27202721
int (*get_flash_version) (struct scsi_qla_host *, void *);
27212722
int (*start_scsi) (srb_t *);
2723+
int (*start_scsi_mq) (srb_t *);
27222724
int (*abort_isp) (struct scsi_qla_host *);
27232725
int (*iospace_config)(struct qla_hw_data*);
27242726
int (*initialize_adapter)(struct scsi_qla_host *);
@@ -2730,8 +2732,9 @@ struct isp_operations {
27302732
#define QLA_MSIX_FW_MODE(m) (((m) & (BIT_7|BIT_8|BIT_9)) >> 7)
27312733
#define QLA_MSIX_FW_MODE_1(m) (QLA_MSIX_FW_MODE(m) == 1)
27322734

2733-
#define QLA_MSIX_DEFAULT 0x00
2734-
#define QLA_MSIX_RSP_Q 0x01
2735+
#define QLA_MSIX_DEFAULT 0x00
2736+
#define QLA_MSIX_RSP_Q 0x01
2737+
#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q 0x02
27352738

27362739
#define QLA_MIDX_DEFAULT 0
27372740
#define QLA_MIDX_RSP_Q 1
@@ -2745,8 +2748,10 @@ struct scsi_qla_host;
27452748

27462749
struct qla_msix_entry {
27472750
int have_irq;
2751+
int in_use;
27482752
uint32_t vector;
27492753
uint16_t entry;
2754+
char name[30];
27502755
void *handle;
27512756
struct irq_affinity_notify irq_notify;
27522757
int cpuid;
@@ -2872,7 +2877,6 @@ struct rsp_que {
28722877
struct qla_msix_entry *msix;
28732878
struct req_que *req;
28742879
srb_t *status_srb; /* status continuation entry */
2875-
struct work_struct q_work;
28762880

28772881
dma_addr_t dma_fx00;
28782882
response_t *ring_fx00;
@@ -2909,6 +2913,37 @@ struct req_que {
29092913
uint8_t req_pkt[REQUEST_ENTRY_SIZE];
29102914
};
29112915

2916+
/*Queue pair data structure */
2917+
struct qla_qpair {
2918+
spinlock_t qp_lock;
2919+
atomic_t ref_count;
2920+
/* distill these fields down to 'online=0/1'
2921+
* ha->flags.eeh_busy
2922+
* ha->flags.pci_channel_io_perm_failure
2923+
* base_vha->loop_state
2924+
*/
2925+
uint32_t online:1;
2926+
/* move vha->flags.difdix_supported here */
2927+
uint32_t difdix_supported:1;
2928+
uint32_t delete_in_progress:1;
2929+
2930+
uint16_t id; /* qp number used with FW */
2931+
uint16_t num_active_cmd; /* cmds down at firmware */
2932+
cpumask_t cpu_mask; /* CPU mask for cpu affinity operation */
2933+
uint16_t vp_idx; /* vport ID */
2934+
2935+
mempool_t *srb_mempool;
2936+
2937+
/* to do: New driver: move queues to here instead of pointers */
2938+
struct req_que *req;
2939+
struct rsp_que *rsp;
2940+
struct atio_que *atio;
2941+
struct qla_msix_entry *msix; /* point to &ha->msix_entries[x] */
2942+
struct qla_hw_data *hw;
2943+
struct work_struct q_work;
2944+
struct list_head qp_list_elem; /* vha->qp_list */
2945+
};
2946+
29122947
/* Place holder for FW buffer parameters */
29132948
struct qlfc_fw {
29142949
void *fw_buf;
@@ -3004,7 +3039,6 @@ struct qla_hw_data {
30043039
uint32_t chip_reset_done :1;
30053040
uint32_t running_gold_fw :1;
30063041
uint32_t eeh_busy :1;
3007-
uint32_t cpu_affinity_enabled :1;
30083042
uint32_t disable_msix_handshake :1;
30093043
uint32_t fcp_prio_enabled :1;
30103044
uint32_t isp82xx_fw_hung:1;
@@ -3061,10 +3095,15 @@ struct qla_hw_data {
30613095
uint8_t mqenable;
30623096
struct req_que **req_q_map;
30633097
struct rsp_que **rsp_q_map;
3098+
struct qla_qpair **queue_pair_map;
30643099
unsigned long req_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
30653100
unsigned long rsp_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
3101+
unsigned long qpair_qid_map[(QLA_MAX_QUEUES / 8)
3102+
/ sizeof(unsigned long)];
30663103
uint8_t max_req_queues;
30673104
uint8_t max_rsp_queues;
3105+
uint8_t max_qpairs;
3106+
struct qla_qpair *base_qpair;
30683107
struct qla_npiv_entry *npiv_info;
30693108
uint16_t nvram_npiv_size;
30703109

@@ -3328,6 +3367,7 @@ struct qla_hw_data {
33283367

33293368
struct mutex vport_lock; /* Virtual port synchronization */
33303369
spinlock_t vport_slock; /* order is hardware_lock, then vport_slock */
3370+
struct mutex mq_lock; /* multi-queue synchronization */
33313371
struct completion mbx_cmd_comp; /* Serialize mbx access */
33323372
struct completion mbx_intr_comp; /* Used for completion notification */
33333373
struct completion dcbx_comp; /* For set port config notification */
@@ -3608,6 +3648,7 @@ typedef struct scsi_qla_host {
36083648

36093649
uint32_t fw_tgt_reported:1;
36103650
uint32_t bbcr_enable:1;
3651+
uint32_t qpairs_available:1;
36113652
} flags;
36123653

36133654
atomic_t loop_state;
@@ -3646,6 +3687,7 @@ typedef struct scsi_qla_host {
36463687
#define FX00_TARGET_SCAN 24
36473688
#define FX00_CRITEMP_RECOVERY 25
36483689
#define FX00_HOST_INFO_RESEND 26
3690+
#define QPAIR_ONLINE_CHECK_NEEDED 27
36493691

36503692
unsigned long pci_flags;
36513693
#define PFLG_DISCONNECTED 0 /* PCI device removed */
@@ -3704,10 +3746,13 @@ typedef struct scsi_qla_host {
37043746
/* List of pending PLOGI acks, protected by hw lock */
37053747
struct list_head plogi_ack_list;
37063748

3749+
struct list_head qp_list;
3750+
37073751
uint32_t vp_abort_cnt;
37083752

37093753
struct fc_vport *fc_vport; /* holds fc_vport * for each vport */
37103754
uint16_t vp_idx; /* vport ID */
3755+
struct qla_qpair *qpair; /* base qpair */
37113756

37123757
unsigned long vp_flags;
37133758
#define VP_IDX_ACQUIRED 0 /* bit no 0 */
@@ -3763,6 +3808,23 @@ struct qla_tgt_vp_map {
37633808
scsi_qla_host_t *vha;
37643809
};
37653810

3811+
struct qla2_sgx {
3812+
dma_addr_t dma_addr; /* OUT */
3813+
uint32_t dma_len; /* OUT */
3814+
3815+
uint32_t tot_bytes; /* IN */
3816+
struct scatterlist *cur_sg; /* IN */
3817+
3818+
/* for book keeping, bzero on initial invocation */
3819+
uint32_t bytes_consumed;
3820+
uint32_t num_bytes;
3821+
uint32_t tot_partial;
3822+
3823+
/* for debugging */
3824+
uint32_t num_sg;
3825+
srb_t *sp;
3826+
};
3827+
37663828
/*
37673829
* Macros to help code, maintain, etc.
37683830
*/
@@ -3775,21 +3837,34 @@ struct qla_tgt_vp_map {
37753837
(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
37763838
test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
37773839

3778-
#define QLA_VHA_MARK_BUSY(__vha, __bail) do { \
3779-
atomic_inc(&__vha->vref_count); \
3780-
mb(); \
3781-
if (__vha->flags.delete_progress) { \
3782-
atomic_dec(&__vha->vref_count); \
3783-
__bail = 1; \
3784-
} else { \
3785-
__bail = 0; \
3786-
} \
3840+
#define QLA_VHA_MARK_BUSY(__vha, __bail) do { \
3841+
atomic_inc(&__vha->vref_count); \
3842+
mb(); \
3843+
if (__vha->flags.delete_progress) { \
3844+
atomic_dec(&__vha->vref_count); \
3845+
__bail = 1; \
3846+
} else { \
3847+
__bail = 0; \
3848+
} \
37873849
} while (0)
37883850

3789-
#define QLA_VHA_MARK_NOT_BUSY(__vha) do { \
3790-
atomic_dec(&__vha->vref_count); \
3851+
#define QLA_VHA_MARK_NOT_BUSY(__vha) \
3852+
atomic_dec(&__vha->vref_count); \
3853+
3854+
#define QLA_QPAIR_MARK_BUSY(__qpair, __bail) do { \
3855+
atomic_inc(&__qpair->ref_count); \
3856+
mb(); \
3857+
if (__qpair->delete_in_progress) { \
3858+
atomic_dec(&__qpair->ref_count); \
3859+
__bail = 1; \
3860+
} else { \
3861+
__bail = 0; \
3862+
} \
37913863
} while (0)
37923864

3865+
#define QLA_QPAIR_MARK_NOT_BUSY(__qpair) \
3866+
atomic_dec(&__qpair->ref_count); \
3867+
37933868
/*
37943869
* qla2x00 local function return status codes
37953870
*/

0 commit comments

Comments
 (0)