Skip to content

Commit 09620ee

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Add debug knob for user control workload
For Target mode, user can control the work load by placing qla2xxx's irq vector on certain CPU via the smp_affinity knob. This patch allows user to control the number of QPair's irq to be active. The irqs are allocated at driver load time until unload. The work itself is placed on the QPair based on user setting. Usage: modprobe qla2xxx qlini_mode=disabled ql2xuctrlirq=1 mount -t debugfs none /sys/kernel/debug echo 2 > /sys/kernel/debug/qla2xxx/qla2xxx_[host num]/naqp echo [cpu id] > /proc/irq/[irq id]/smp_affinity_list 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 d65237c commit 09620ee

File tree

5 files changed

+137
-4
lines changed

5 files changed

+137
-4
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3322,6 +3322,7 @@ struct qlt_hw_data {
33223322

33233323
struct dentry *dfs_tgt_sess;
33243324
struct dentry *dfs_tgt_port_database;
3325+
struct dentry *dfs_naqp;
33253326

33263327
struct list_head q_full_list;
33273328
uint32_t num_pend_cmds;
@@ -3330,7 +3331,8 @@ struct qlt_hw_data {
33303331
spinlock_t q_full_lock;
33313332
uint32_t leak_exchg_thresh_hold;
33323333
spinlock_t sess_lock;
3333-
int rspq_vector_cpuid;
3334+
int num_act_qpairs;
3335+
#define DEFAULT_NAQP 2
33343336
spinlock_t atio_lock ____cacheline_aligned;
33353337
struct btree_head32 host_map;
33363338
};
@@ -4278,6 +4280,9 @@ enum nexus_wait_type {
42784280
WAIT_LUN,
42794281
};
42804282

4283+
#define USER_CTRL_IRQ(_ha) (ql2xuctrlirq && QLA_TGT_MODE_ENABLED() && \
4284+
(IS_QLA27XX(_ha) || IS_QLA83XX(_ha)))
4285+
42814286
#include "qla_target.h"
42824287
#include "qla_gbl.h"
42834288
#include "qla_dbg.h"

drivers/scsi/qla2xxx/qla_dfs.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,81 @@ static const struct file_operations dfs_fce_ops = {
314314
.release = qla2x00_dfs_fce_release,
315315
};
316316

317+
static int
318+
qla_dfs_naqp_show(struct seq_file *s, void *unused)
319+
{
320+
struct scsi_qla_host *vha = s->private;
321+
struct qla_hw_data *ha = vha->hw;
322+
323+
seq_printf(s, "%d\n", ha->tgt.num_act_qpairs);
324+
return 0;
325+
}
326+
327+
static int
328+
qla_dfs_naqp_open(struct inode *inode, struct file *file)
329+
{
330+
struct scsi_qla_host *vha = inode->i_private;
331+
332+
return single_open(file, qla_dfs_naqp_show, vha);
333+
}
334+
335+
static ssize_t
336+
qla_dfs_naqp_write(struct file *file, const char __user *buffer,
337+
size_t count, loff_t *pos)
338+
{
339+
struct seq_file *s = file->private_data;
340+
struct scsi_qla_host *vha = s->private;
341+
struct qla_hw_data *ha = vha->hw;
342+
char *buf;
343+
int rc = 0;
344+
unsigned long num_act_qp;
345+
346+
if (!(IS_QLA27XX(ha) || IS_QLA83XX(ha))) {
347+
pr_err("host%ld: this adapter does not support Multi Q.",
348+
vha->host_no);
349+
return -EINVAL;
350+
}
351+
352+
if (!vha->flags.qpairs_available) {
353+
pr_err("host%ld: Driver is not setup with Multi Q.",
354+
vha->host_no);
355+
return -EINVAL;
356+
}
357+
buf = memdup_user_nul(buffer, count);
358+
if (IS_ERR(buf)) {
359+
pr_err("host%ld: fail to copy user buffer.",
360+
vha->host_no);
361+
return PTR_ERR(buf);
362+
}
363+
364+
num_act_qp = simple_strtoul(buf, NULL, 0);
365+
366+
if (num_act_qp >= vha->hw->max_qpairs) {
367+
pr_err("User set invalid number of qpairs %lu. Max = %d",
368+
num_act_qp, vha->hw->max_qpairs);
369+
rc = -EINVAL;
370+
goto out_free;
371+
}
372+
373+
if (num_act_qp != ha->tgt.num_act_qpairs) {
374+
ha->tgt.num_act_qpairs = num_act_qp;
375+
qlt_clr_qp_table(vha);
376+
}
377+
rc = count;
378+
out_free:
379+
kfree(buf);
380+
return rc;
381+
}
382+
383+
static const struct file_operations dfs_naqp_ops = {
384+
.open = qla_dfs_naqp_open,
385+
.read = seq_read,
386+
.llseek = seq_lseek,
387+
.release = single_release,
388+
.write = qla_dfs_naqp_write,
389+
};
390+
391+
317392
int
318393
qla2x00_dfs_setup(scsi_qla_host_t *vha)
319394
{
@@ -391,6 +466,15 @@ qla2x00_dfs_setup(scsi_qla_host_t *vha)
391466
goto out;
392467
}
393468

469+
if (IS_QLA27XX(ha) || IS_QLA83XX(ha)) {
470+
ha->tgt.dfs_naqp = debugfs_create_file("naqp",
471+
0400, ha->dfs_dir, vha, &dfs_naqp_ops);
472+
if (!ha->tgt.dfs_naqp) {
473+
ql_log(ql_log_warn, vha, 0xd011,
474+
"Unable to create debugFS naqp node.\n");
475+
goto out;
476+
}
477+
}
394478
out:
395479
return 0;
396480
}
@@ -400,6 +484,11 @@ qla2x00_dfs_remove(scsi_qla_host_t *vha)
400484
{
401485
struct qla_hw_data *ha = vha->hw;
402486

487+
if (ha->tgt.dfs_naqp) {
488+
debugfs_remove(ha->tgt.dfs_naqp);
489+
ha->tgt.dfs_naqp = NULL;
490+
}
491+
403492
if (ha->tgt.dfs_tgt_sess) {
404493
debugfs_remove(ha->tgt.dfs_tgt_sess);
405494
ha->tgt.dfs_tgt_sess = NULL;

drivers/scsi/qla2xxx/qla_gbl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ extern int ql2xexchoffld;
139139
extern int ql2xiniexchg;
140140
extern int ql2xfwholdabts;
141141
extern int ql2xmvasynctoatio;
142+
extern int ql2xuctrlirq;
142143

143144
extern int qla2x00_loop_reset(scsi_qla_host_t *);
144145
extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int);
@@ -856,5 +857,6 @@ void qla24xx_delete_sess_fn(struct work_struct *);
856857
void qlt_unknown_atio_work_fn(struct work_struct *);
857858
void qlt_update_host_map(struct scsi_qla_host *, port_id_t);
858859
void qlt_remove_target_resources(struct qla_hw_data *);
860+
void qlt_clr_qp_table(struct scsi_qla_host *vha);
859861

860862
#endif /* _QLA_GBL_H */

drivers/scsi/qla2xxx/qla_isr.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,9 +3227,14 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
32273227
min_vecs++;
32283228
}
32293229

3230-
ret = pci_alloc_irq_vectors_affinity(ha->pdev, min_vecs,
3231-
ha->msix_count, PCI_IRQ_MSIX | PCI_IRQ_AFFINITY,
3232-
&desc);
3230+
if (USER_CTRL_IRQ(ha)) {
3231+
/* user wants to control IRQ setting for target mode */
3232+
ret = pci_alloc_irq_vectors(ha->pdev, min_vecs,
3233+
ha->msix_count, PCI_IRQ_MSIX);
3234+
} else
3235+
ret = pci_alloc_irq_vectors_affinity(ha->pdev, min_vecs,
3236+
ha->msix_count, PCI_IRQ_MSIX | PCI_IRQ_AFFINITY,
3237+
&desc);
32333238

32343239
if (ret < 0) {
32353240
ql_log(ql_log_fatal, vha, 0x00c7,

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ MODULE_PARM_DESC(ql_dm_tgt_ex_pct,
6666
"the percentage of exchanges/cmds FW will allocate resources "
6767
"for Target mode.");
6868

69+
int ql2xuctrlirq = 1;
70+
module_param(ql2xuctrlirq, int, 0644);
71+
MODULE_PARM_DESC(ql2xuctrlirq,
72+
"User to control IRQ placement via smp_affinity."
73+
"Valid with qlini_mode=disabled."
74+
"1(default): enable");
75+
6976
int ql2x_ini_mode = QLA2XXX_INI_MODE_EXCLUSIVE;
7077

7178
static int temp_sam_status = SAM_STAT_BUSY;
@@ -4059,6 +4066,31 @@ static void qlt_do_work(struct work_struct *work)
40594066
__qlt_do_work(cmd);
40604067
}
40614068

4069+
void qlt_clr_qp_table(struct scsi_qla_host *vha)
4070+
{
4071+
unsigned long flags;
4072+
struct qla_hw_data *ha = vha->hw;
4073+
struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
4074+
void *node;
4075+
u64 key = 0;
4076+
4077+
ql_log(ql_log_info, vha, 0x706c,
4078+
"User update Number of Active Qpairs %d\n",
4079+
ha->tgt.num_act_qpairs);
4080+
4081+
spin_lock_irqsave(&ha->tgt.atio_lock, flags);
4082+
4083+
btree_for_each_safe64(&tgt->lun_qpair_map, key, node)
4084+
btree_remove64(&tgt->lun_qpair_map, key);
4085+
4086+
ha->base_qpair->lun_cnt = 0;
4087+
for (key = 0; key < ha->max_qpairs; key++)
4088+
if (ha->queue_pair_map[key])
4089+
ha->queue_pair_map[key]->lun_cnt = 0;
4090+
4091+
spin_unlock_irqrestore(&ha->tgt.atio_lock, flags);
4092+
}
4093+
40624094
static void qlt_assign_qpair(struct scsi_qla_host *vha,
40634095
struct qla_tgt_cmd *cmd)
40644096
{

0 commit comments

Comments
 (0)