Commit 73208dfd authored by Anirban Chakraborty's avatar Anirban Chakraborty Committed by James Bottomley
Browse files

[SCSI] qla2xxx: add support for multi-queue adapter



Following changes have been made.
1. qla_hw_data structure holds an array for request queue pointers,
and an array for response queue pointers.
2. The base request and response queues are created by default.
3. Additional request and response queues are created at the time of vport
creation. If queue resources are exhausted during vport creation, newly
created vports use the default queue.
4. Requests are sent to the request queue that the vport was assigned
in the beginning.
5. Responses are completed on the response queue with which the request queue
is associated with.

[fixup memcpy argument reversal spotted by davej@redhat.com]
Signed-off-by: default avatarAnirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent 85b4aa49
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -1143,8 +1143,11 @@ static int
qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
{
	int	ret = 0;
	int	cnt = 0;
	uint8_t	qos = QLA_DEFAULT_QUE_QOS;
	scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
	scsi_qla_host_t *vha = NULL;
	struct qla_hw_data *ha = base_vha->hw;

	ret = qla24xx_vport_create_req_sanity_check(fc_vport);
	if (ret) {
@@ -1200,6 +1203,22 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)

	qla24xx_vport_disable(fc_vport, disable);

	/* Create a queue pair for the vport */
	if (ha->mqenable) {
		if (ha->npiv_info) {
			for (; cnt < ha->nvram_npiv_size; cnt++) {
				if (ha->npiv_info[cnt].port_name ==
					vha->port_name &&
					ha->npiv_info[cnt].node_name ==
					vha->node_name) {
					qos = ha->npiv_info[cnt].q_qos;
					break;
				}
			}
		}
		qla25xx_create_queues(vha, qos);
	}

	return 0;
vport_create_failed_2:
	qla24xx_disable_vp(vha);
@@ -1213,11 +1232,20 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
{
	scsi_qla_host_t *vha = fc_vport->dd_data;
	fc_port_t *fcport, *tfcport;
	struct qla_hw_data *ha = vha->hw;
	uint16_t id = vha->vp_idx;

	while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
	    test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
		msleep(1000);

	if (ha->mqenable) {
		if (qla25xx_delete_queues(vha, 0) != QLA_SUCCESS)
			qla_printk(KERN_WARNING, ha,
				"Queue delete failed.\n");
		vha->req_ques[0] = ha->req_q_map[0]->id;
	}

	qla24xx_disable_vp(vha);

	fc_remove_host(vha->host);
@@ -1240,7 +1268,7 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
        }

	scsi_host_put(vha->host);

	qla_printk(KERN_INFO, ha, "vport %d deleted\n", id);
	return 0;
}

+53 −14
Original line number Diff line number Diff line
@@ -23,11 +23,10 @@ qla2xxx_prep_dump(struct qla_hw_data *ha, struct qla2xxx_fw_dump *fw_dump)
}

static inline void *
qla2xxx_copy_queues(scsi_qla_host_t *vha, void *ptr)
qla2xxx_copy_queues(struct qla_hw_data *ha, void *ptr)
{
	struct req_que *req = vha->hw->req;
	struct rsp_que *rsp = vha->hw->rsp;

	struct req_que *req = ha->req_q_map[0];
	struct rsp_que *rsp = ha->rsp_q_map[0];
	/* Request queue. */
	memcpy(ptr, req->ring, req->length *
	    sizeof(request_t));
@@ -327,6 +326,7 @@ qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	unsigned long	flags;
	struct qla2300_fw_dump	*fw;
	void		*nxt;
	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

	flags = 0;

@@ -461,7 +461,7 @@ qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
		    ha->fw_memory_size - 0x11000 + 1, &nxt);

	if (rval == QLA_SUCCESS)
		qla2xxx_copy_queues(vha, nxt);
		qla2xxx_copy_queues(ha, nxt);

	if (rval != QLA_SUCCESS) {
		qla_printk(KERN_WARNING, ha,
@@ -471,7 +471,7 @@ qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	} else {
		qla_printk(KERN_INFO, ha,
		    "Firmware dump saved to temp buffer (%ld/%p).\n",
		    vha->host_no, ha->fw_dump);
		    base_vha->host_no, ha->fw_dump);
		ha->fw_dumped = 1;
	}

@@ -497,6 +497,7 @@ qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	uint16_t __iomem *dmp_reg;
	unsigned long	flags;
	struct qla2100_fw_dump	*fw;
	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

	risc_address = 0;
	mb0 = mb2 = 0;
@@ -667,7 +668,7 @@ qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	}

	if (rval == QLA_SUCCESS)
		qla2xxx_copy_queues(vha, &fw->risc_ram[cnt]);
		qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]);

	if (rval != QLA_SUCCESS) {
		qla_printk(KERN_WARNING, ha,
@@ -677,7 +678,7 @@ qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	} else {
		qla_printk(KERN_INFO, ha,
		    "Firmware dump saved to temp buffer (%ld/%p).\n",
		    vha->host_no, ha->fw_dump);
		    base_vha->host_no, ha->fw_dump);
		ha->fw_dumped = 1;
	}

@@ -701,6 +702,7 @@ qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	struct qla24xx_fw_dump *fw;
	uint32_t	ext_mem_cnt;
	void		*nxt;
	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

	risc_address = ext_mem_cnt = 0;
	flags = 0;
@@ -910,7 +912,7 @@ qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	if (rval != QLA_SUCCESS)
		goto qla24xx_fw_dump_failed_0;

	nxt = qla2xxx_copy_queues(vha, nxt);
	nxt = qla2xxx_copy_queues(ha, nxt);
	if (ha->eft)
		memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size));

@@ -923,7 +925,7 @@ qla24xx_fw_dump_failed_0:
	} else {
		qla_printk(KERN_INFO, ha,
		    "Firmware dump saved to temp buffer (%ld/%p).\n",
		    vha->host_no, ha->fw_dump);
		    base_vha->host_no, ha->fw_dump);
		ha->fw_dumped = 1;
	}

@@ -940,6 +942,7 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	uint32_t	risc_address;
	struct qla_hw_data *ha = vha->hw;
	struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
	struct device_reg_25xxmq __iomem *reg25;
	uint32_t __iomem *dmp_reg;
	uint32_t	*iter_reg;
	uint16_t __iomem *mbx_reg;
@@ -948,6 +951,11 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	uint32_t	ext_mem_cnt;
	void		*nxt;
	struct qla2xxx_fce_chain *fcec;
	struct qla2xxx_mq_chain *mq = NULL;
	uint32_t	qreg_size;
	uint8_t		req_cnt, rsp_cnt, que_cnt;
	uint32_t	que_idx;
	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

	risc_address = ext_mem_cnt = 0;
	flags = 0;
@@ -992,6 +1000,29 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
	fw->pcie_regs[1] = htonl(RD_REG_DWORD(dmp_reg++));
	fw->pcie_regs[2] = htonl(RD_REG_DWORD(dmp_reg));
	fw->pcie_regs[3] = htonl(RD_REG_DWORD(&reg->iobase_window));

	/* Multi queue registers */
	if (ha->mqenable) {
		qreg_size = sizeof(struct qla2xxx_mq_chain);
		mq = kzalloc(qreg_size, GFP_KERNEL);
		if (!mq)
			goto qla25xx_fw_dump_failed_0;
		req_cnt = find_first_zero_bit(ha->req_qid_map, ha->max_queues);
		rsp_cnt = find_first_zero_bit(ha->rsp_qid_map, ha->max_queues);
		que_cnt = req_cnt > rsp_cnt ? req_cnt : rsp_cnt;
		mq->count = htonl(que_cnt);
		mq->chain_size = htonl(qreg_size);
		mq->type = __constant_htonl(DUMP_CHAIN_MQ);
		for (cnt = 0; cnt < que_cnt; cnt++) {
			reg25 = (struct device_reg_25xxmq *) ((void *)
				ha->mqiobase + cnt * QLA_QUE_PAGE);
			que_idx = cnt * 4;
			mq->qregs[que_idx] = htonl(reg25->req_q_in);
			mq->qregs[que_idx+1] = htonl(reg25->req_q_out);
			mq->qregs[que_idx+2] = htonl(reg25->rsp_q_in);
			mq->qregs[que_idx+3] = htonl(reg25->rsp_q_out);
		}
	}
	WRT_REG_DWORD(&reg->iobase_window, 0x00);
	RD_REG_DWORD(&reg->iobase_window);

@@ -1219,7 +1250,7 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
		goto qla25xx_fw_dump_failed_0;

	/* Fibre Channel Trace Buffer. */
	nxt = qla2xxx_copy_queues(vha, nxt);
	nxt = qla2xxx_copy_queues(ha, nxt);
	if (ha->eft)
		memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size));

@@ -1229,7 +1260,14 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)

	ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT);

	if (ha->mqenable) {
		nxt = nxt + ntohl(ha->fw_dump->eft_size);
		memcpy(nxt, mq, qreg_size);
		kfree(mq);
		fcec = nxt + qreg_size;
	} else {
		fcec = nxt + ntohl(ha->fw_dump->eft_size);
	}
	fcec->type = __constant_htonl(DUMP_CHAIN_FCE | DUMP_CHAIN_LAST);
	fcec->chain_size = htonl(sizeof(struct qla2xxx_fce_chain) +
	    fce_calc_size(ha->fce_bufs));
@@ -1252,7 +1290,7 @@ qla25xx_fw_dump_failed_0:
	} else {
		qla_printk(KERN_INFO, ha,
		    "Firmware dump saved to temp buffer (%ld/%p).\n",
		    vha->host_no, ha->fw_dump);
		    base_vha->host_no, ha->fw_dump);
		ha->fw_dumped = 1;
	}

@@ -1260,7 +1298,6 @@ qla25xx_fw_dump_failed:
	if (!hardware_locked)
		spin_unlock_irqrestore(&ha->hardware_lock, flags);
}

/****************************************************************************/
/*                         Driver Debug Functions.                          */
/****************************************************************************/
@@ -1307,3 +1344,5 @@ qla2x00_dump_buffer(uint8_t * b, uint32_t size)
	if (cnt % 16)
		printk("\n");
}

+14 −1
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@
 *
 * See LICENSE.qla2xxx for copyright and licensing details.
 */

#include "qla_def.h"

/*
 * Driver debug definitions.
 */
@@ -23,6 +26,7 @@
/* #define QL_DEBUG_LEVEL_14 */ /* Output RSCN trace msgs */
/* #define QL_DEBUG_LEVEL_15 */ /* Output NPIV trace msgs */
/* #define QL_DEBUG_LEVEL_16 */ /* Output ISP84XX trace msgs */
/* #define QL_DEBUG_LEVEL_17 */ /* Output MULTI-Q trace messages */

/*
* Macros use for debugging the driver.
@@ -43,6 +47,7 @@
#define DEBUG2_11(x)	do { if (ql2xextended_error_logging) { x; } } while (0)
#define DEBUG2_13(x)	do { if (ql2xextended_error_logging) { x; } } while (0)
#define DEBUG2_16(x)	do { if (ql2xextended_error_logging) { x; } } while (0)
#define DEBUG2_17(x) 	do { if (ql2xextended_error_logging) { x; } } while (0)

#if defined(QL_DEBUG_LEVEL_3)
#define DEBUG3(x)	do {x;} while (0)
@@ -127,7 +132,6 @@
#else
#define DEBUG16(x)	do {} while (0)
#endif

/*
 * Firmware Dump structure definition
 */
@@ -266,8 +270,17 @@ struct qla2xxx_fce_chain {
	uint32_t eregs[8];
};

struct qla2xxx_mq_chain {
	uint32_t type;
	uint32_t chain_size;

	uint32_t count;
	uint32_t qregs[4 * QLA_MQ_SIZE];
};

#define DUMP_CHAIN_VARIANT	0x80000000
#define DUMP_CHAIN_FCE		0x7FFFFAF0
#define DUMP_CHAIN_MQ		0x7FFFFAF1
#define DUMP_CHAIN_LAST		0x80000000

struct qla2xxx_fw_dump {
+52 −12
Original line number Diff line number Diff line
@@ -369,9 +369,17 @@ struct device_reg_2xxx {
	} u_end;
};

struct device_reg_25xxmq {
	volatile uint32_t req_q_in;
	volatile uint32_t req_q_out;
	volatile uint32_t rsp_q_in;
	volatile uint32_t rsp_q_out;
};

typedef union {
		struct device_reg_2xxx isp;
		struct device_reg_24xx isp24;
		struct device_reg_25xxmq isp25mq;
} device_reg_t;

#define ISP_REQ_Q_IN(ha, reg) \
@@ -2037,6 +2045,7 @@ typedef struct vport_params {
#define VP_RET_CODE_NOT_FOUND		6

struct qla_hw_data;
struct req_que;

/*
 * ISP operations
@@ -2059,7 +2068,8 @@ struct isp_operations {
	void (*enable_intrs) (struct qla_hw_data *);
	void (*disable_intrs) (struct qla_hw_data *);

	int (*abort_command) (struct scsi_qla_host *, srb_t *);
	int (*abort_command) (struct scsi_qla_host *, srb_t *,
		struct req_que *);
	int (*target_reset) (struct fc_port *, unsigned int);
	int (*lun_reset) (struct fc_port *, unsigned int);
	int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
@@ -2102,16 +2112,18 @@ struct isp_operations {
#define QLA_MSIX_DEFAULT	0x00
#define QLA_MSIX_RSP_Q		0x01

#define QLA_MSIX_ENTRIES	2
#define QLA_MIDX_DEFAULT	0
#define QLA_MIDX_RSP_Q		1
#define QLA_PCI_MSIX_CONTROL	0xa2

struct scsi_qla_host;
struct rsp_que;

struct qla_msix_entry {
	int have_irq;
	uint32_t msix_vector;
	uint16_t msix_entry;
	uint32_t vector;
	uint16_t entry;
	struct rsp_que *rsp;
};

#define	WATCH_INTERVAL		1       /* number of seconds */
@@ -2162,6 +2174,23 @@ struct qla_statistics {
	uint64_t output_bytes;
};

/* Multi queue support */
#define MBC_INITIALIZE_MULTIQ 0x1f
#define QLA_QUE_PAGE 0X1000
#define QLA_MQ_SIZE 32
#define QLA_MAX_HOST_QUES 16
#define QLA_MAX_QUEUES 256
#define ISP_QUE_REG(ha, id) \
	((ha->mqenable) ? \
	((void *)(ha->mqiobase) +\
	(QLA_QUE_PAGE * id)) :\
	((void *)(ha->iobase)))
#define QLA_REQ_QUE_ID(tag) \
	((tag < QLA_MAX_QUEUES && tag > 0) ? tag : 0)
#define QLA_DEFAULT_QUE_QOS 5
#define QLA_PRECONFIG_VPORTS 32
#define QLA_MAX_VPORTS_QLA24XX	128
#define QLA_MAX_VPORTS_QLA25XX	256
/* Response queue data structure */
struct rsp_que {
	dma_addr_t  dma;
@@ -2171,9 +2200,12 @@ struct rsp_que {
	uint16_t  out_ptr;
	uint16_t  length;
	uint16_t  options;
	uint16_t  msix_vector;
	uint16_t  rid;
	uint16_t  id;
	uint16_t  vp_idx;
	struct qla_hw_data *hw;
	struct qla_msix_entry *msix;
	struct req_que *req;
};

/* Request queue data structure */
@@ -2187,10 +2219,10 @@ struct req_que {
	uint16_t  length;
	uint16_t  options;
	uint16_t  rid;
	uint16_t  id;
	uint16_t  qos;
	uint16_t  vp_idx;
	struct rsp_que *asso_que;
	/* Outstandings ISP commands. */
	struct rsp_que *rsp;
	srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
	uint32_t current_outstanding_cmd;
	int max_q_depth;
@@ -2240,8 +2272,17 @@ struct qla_hw_data {
	resource_size_t pio_address;

#define MIN_IOBASE_LEN          0x100
	struct req_que *req;
	struct rsp_que *rsp;
/* Multi queue data structs */
	device_reg_t    *mqiobase;
	uint16_t        msix_count;
	uint8_t         mqenable;
	struct req_que **req_q_map;
	struct rsp_que **rsp_q_map;
	unsigned long req_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
	unsigned long rsp_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
	uint16_t 	max_queues;
	struct qla_npiv_entry *npiv_info;
	uint16_t	nvram_npiv_size;

	uint16_t        switch_cap;
#define FLOGI_SEQ_DEL           BIT_8
@@ -2502,7 +2543,7 @@ struct qla_hw_data {
	uint16_t        zio_timer;
	struct fc_host_statistics fc_host_stat;

	struct qla_msix_entry msix_entries[QLA_MSIX_ENTRIES];
	struct qla_msix_entry *msix_entries;

	struct list_head        vp_list;        /* list of VP */
	unsigned long   vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) /
@@ -2524,7 +2565,6 @@ typedef struct scsi_qla_host {
	struct list_head list;
	struct list_head vp_fcports;	/* list of fcports */
	struct list_head work_list;

	/* Commonly used flags and state information. */
	struct Scsi_Host *host;
	unsigned long	host_no;
@@ -2640,9 +2680,9 @@ typedef struct scsi_qla_host {
#define VP_ERR_FAB_LOGOUT	4
#define VP_ERR_ADAP_NORESOURCES	5
	struct qla_hw_data *hw;
	int	req_ques[QLA_MAX_HOST_QUES];
} scsi_qla_host_t;


/*
 * Macros to help code, maintain, etc.
 */
+9 −5
Original line number Diff line number Diff line
@@ -299,7 +299,8 @@ struct init_cb_24xx {
	uint32_t response_q_address[2];
	uint32_t prio_request_q_address[2];

	uint8_t reserved_2[8];
	uint16_t msix;
	uint8_t reserved_2[6];

	uint16_t atio_q_inpointer;
	uint16_t atio_q_length;
@@ -372,8 +373,9 @@ struct init_cb_24xx {
	 * BIT 17-31 = Reserved
	 */
	uint32_t firmware_options_3;

	uint8_t  reserved_3[24];
	uint16_t qos;
	uint16_t rid;
	uint8_t  reserved_3[20];
};

/*
@@ -754,7 +756,8 @@ struct abort_entry_24xx {

	uint32_t handle_to_abort;	/* System handle to abort. */

	uint8_t reserved_1[32];
	uint16_t req_que_no;
	uint8_t reserved_1[30];

	uint8_t port_id[3];		/* PortID of destination port. */
	uint8_t vp_index;
@@ -1258,7 +1261,8 @@ struct qla_npiv_header {
struct qla_npiv_entry {
	uint16_t flags;
	uint16_t vf_id;
	uint16_t qos;
	uint8_t q_qos;
	uint8_t f_qos;
	uint16_t unused1;
	uint8_t port_name[WWN_SIZE];
	uint8_t node_name[WWN_SIZE];
Loading