diff --git a/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c b/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c index 8ab6bd79a..4faae90c8 100644 --- a/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c +++ b/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c @@ -263,7 +263,7 @@ static struct scst_tgt_template sqa_scst_template = { .rdy_to_xfer_atomic = 1, #endif -#ifdef SCST_DIF_NO_CHECK_APP_TAG +#if QLA_ENABLE_PI /* diff cap for individual adapter is set during sqa_qla2xxx_add_target */ .dif_supported = 0, .hw_dif_type1_supported = 0, @@ -300,7 +300,7 @@ static struct scst_tgt_template sqa_scst_template = { #endif }; -#ifdef SCST_DIF_NO_CHECK_APP_TAG +#if QLA_ENABLE_PI static const int qla_tgt_supported_dif_block_size[]= { 512, @@ -432,7 +432,7 @@ static inline void qla_tgt_set_cmd_prot_op(struct qla_tgt_cmd *cmd, uint8_t xmit } } -#endif /* #ifdef SCST_DIF_NO_CHECK_APP_TAG */ +#endif /* QLA_ENABLE_PI */ static void sqa_qla2xxx_rel_cmd(struct qla_tgt_cmd *cmd) { @@ -454,7 +454,7 @@ static struct qla_tgt_cmd *sqa_qla2xxx_get_cmd(struct fc_port *sess) struct sqa_scst_tgt *sqa_tgt = (struct sqa_scst_tgt*)sess->vha->vha_tgt.target_lport_ptr; struct qla_tgt_cmd *cmd; - int tag; + int tag = -ENOENT; #if QLT_USE_PERCPU_IDA tag = percpu_ida_alloc(&sqa_tgt->tgt_tag_pool, TASK_RUNNING); @@ -470,7 +470,9 @@ static struct qla_tgt_cmd *sqa_qla2xxx_get_cmd(struct fc_port *sess) cmd = &((struct qla_tgt_cmd *)sqa_tgt->tgt_cmd_map)[tag]; memset(cmd, 0, sizeof(struct qla_tgt_cmd)); +#if QLT_USE_PERCPU_IDA || QLT_USE_SBITMAP cmd->se_cmd.map_tag = tag; +#endif #if QLT_USE_SBITMAP cmd->se_cmd.map_cpu = cpu; #endif @@ -1493,7 +1495,7 @@ static int sqa_init_scst_tgt(struct scsi_qla_host *vha) goto done; } -#ifdef SCST_DIF_NO_CHECK_APP_TAG +#if QLA_ENABLE_PI if (IS_T10_PI_CAPABLE(vha->hw)) { scst_tgt_set_supported_dif_block_sizes(scst_tgt, qla_tgt_supported_dif_block_size); scst_tgt_set_dif_supported(scst_tgt, true); @@ -1712,7 +1714,7 @@ static int sqa_xmit_response(struct scst_cmd *scst_cmd) cmd->lba = scst_cmd_get_lba(scst_cmd); cmd->trc_flags |= TRC_XMIT_STATUS; -#ifdef SCST_DIF_NO_CHECK_APP_TAG +#if QLA_ENABLE_PI if (scst_get_tgt_dif_actions(scst_cmd->cmd_dif_actions)) { cmd->blk_sz = scst_cmd_get_block_size(scst_cmd); cmd->prot_sg_cnt = scst_cmd->dif_sg_cnt; @@ -1799,7 +1801,7 @@ static int sqa_rdy_to_xfer(struct scst_cmd *scst_cmd) cmd->scsi_status = scst_cmd_get_status(scst_cmd); cmd->trc_flags |= TRC_XFR_RDY; -#ifdef SCST_DIF_NO_CHECK_APP_TAG +#if QLA_ENABLE_PI if (scst_get_tgt_dif_actions(scst_cmd->cmd_dif_actions)) { cmd->blk_sz = scst_cmd_get_block_size(scst_cmd); cmd->se_cmd.prot_type = scst_cmd_get_dif_prot_type(scst_cmd); diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index 20d12ac2e..25dec6479 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -146,7 +146,11 @@ extern int ql2xenabledif; extern int ql2xenablehba_err_chk; extern int ql2xtargetreset; extern int ql2xdontresethba; +#if 1 +extern uint ql2xmaxlun; +#else extern uint64_t ql2xmaxlun; +#endif extern int ql2xmdcapmask; extern int ql2xmdenable; extern int ql2xexlogins; diff --git a/qla2x00t-32gbit/qla_iocb.c b/qla2x00t-32gbit/qla_iocb.c index b00012a87..b3594a139 100644 --- a/qla2x00t-32gbit/qla_iocb.c +++ b/qla2x00t-32gbit/qla_iocb.c @@ -1092,6 +1092,7 @@ qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, uint32_t *dsd, return 0; } +#if QLA_ENABLE_PI int qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, uint32_t *cur_dsd, uint16_t tot_dsds, struct qla_tgt_cmd *tc) @@ -1603,6 +1604,7 @@ crc_queuing_error: return QLA_FUNCTION_FAILED; } +#endif /** * qla24xx_start_scsi() - Send a SCSI command to the ISP diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index baea6e8f3..d95edcce1 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -3476,7 +3476,29 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) + ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); + if (ret) { + if (ret < QLA_BASE_VECTORS) + goto msix_failed; + + ql_log(ql_log_warn, vha, 0x00c6, + "MSI-X: Failed to enable support " + "-- %d/%d\n Retry with %d vectors.\n", + ha->msix_count, ret, ret); + ha->msix_count = ret; + ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); + if (ret) { +msix_failed: + ql_log(ql_log_fatal, vha, 0x00c7, + "MSI-X: Failed to enable support, " + "giving up -- %d/%d.\n", + ha->msix_count, ret); + goto msix_out; + } + ha->max_rsp_queues = ha->msix_count - 1; + } +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) ret = pci_enable_msix_range(ha->pdev, entries, min_vecs, ha->msix_count); #elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) diff --git a/qla2x00t-32gbit/qla_nvme.h b/qla2x00t-32gbit/qla_nvme.h index 922276dc5..e09f538f7 100644 --- a/qla2x00t-32gbit/qla_nvme.h +++ b/qla2x00t-32gbit/qla_nvme.h @@ -7,7 +7,6 @@ #ifndef __QLA_NVME_H #define __QLA_NVME_H -#include #include #include #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index 12050aaa8..b38206730 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -220,8 +220,13 @@ MODULE_PARM_DESC(ql2xdontresethba, " 0 (Default) -- Reset on failure.\n" " 1 -- Do not reset on failure.\n"); +#if 1 +uint ql2xmaxlun = MAX_LUNS; +module_param(ql2xmaxlun, uint, S_IRUGO); +#else uint64_t ql2xmaxlun = MAX_LUNS; module_param(ql2xmaxlun, ullong, S_IRUGO); +#endif MODULE_PARM_DESC(ql2xmaxlun, "Defines the maximum LU number to register with the SCSI " "midlayer. Default is 65535."); @@ -925,16 +930,18 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); srb_t *sp; int rval; - struct qla_qpair *qpair = NULL; - uint32_t tag; - uint16_t hwq; if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { cmd->result = DID_NO_CONNECT << 16; goto qc24_fail_command; } +#ifdef BLK_MQ_H if (ha->mqenable) { + uint32_t tag; + uint16_t hwq; + struct qla_qpair *qpair = NULL; + tag = blk_mq_unique_tag(cmd->request); hwq = blk_mq_unique_tag_to_hwq(tag); qpair = ha->queue_pair_map[hwq]; @@ -942,6 +949,7 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) if (qpair) return qla2xxx_mqueuecommand(host, cmd, qpair); } +#endif if (ha->flags.eeh_busy) { if (ha->flags.pci_channel_io_perm_failure) { @@ -3244,6 +3252,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) goto probe_failed; } +#ifdef BLK_MQ_H if (ha->mqenable) { /* number of hardware queues supported by blk/scsi-mq*/ host->nr_hw_queues = ha->max_qpairs; @@ -3261,6 +3270,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) "blk/scsi-mq disabled.\n"); } } +#endif qlt_probe_one_stage1(base_vha, ha); diff --git a/qla2x00t-32gbit/qla_target.c b/qla2x00t-32gbit/qla_target.c index 337cfc746..25778c13b 100644 --- a/qla2x00t-32gbit/qla_target.c +++ b/qla2x00t-32gbit/qla_target.c @@ -42,6 +42,17 @@ #include "qla_def.h" #include "qla_target.h" +/* + * See also commit fb3269baf4ec ("qla2xxx: Add selective command queuing") + * # v4.5. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) || \ + defined(RHEL_MAJOR) && RHEL_MAJOR -0 >= 7 +#define HAVE_SE_CMD_CPUID 1 +#else +#define HAVE_SE_CMD_CPUID 0 +#endif + static int ql2xtgt_tape_enable; module_param(ql2xtgt_tape_enable, int, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(ql2xtgt_tape_enable, @@ -155,6 +166,7 @@ DEFINE_MUTEX(qla_tgt_mutex); LIST_HEAD(qla_tgt_glist); EXPORT_SYMBOL(qla_tgt_glist); +#if QLA_ENABLE_PI static const char *prot_op_str(u32 prot_op) { switch (prot_op) { @@ -168,6 +180,7 @@ static const char *prot_op_str(u32 prot_op) default: return "UNKNOWN"; } } +#endif /* This API intentionally takes dest as a parameter, rather than returning * int value to avoid caller forgetting to issue wmb() after the store */ @@ -2127,11 +2140,13 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha, mcmd->qpair = h->qpair; mcmd->vha = vha; +#if HAVE_SE_CMD_CPUID /* * LUN is looked up by target-core internally based on the passed * abts->exchange_addr_to_abort tag. */ mcmd->se_cmd.cpuid = h->cpuid; +#endif if (ha->tgt.tgt_ops->find_cmd_by_tag) { struct qla_tgt_cmd *abort_cmd; @@ -2140,14 +2155,20 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha, abts->exchange_addr_to_abort); if (abort_cmd && abort_cmd->qpair) { mcmd->qpair = abort_cmd->qpair; +#if HAVE_SE_CMD_CPUID mcmd->se_cmd.cpuid = abort_cmd->se_cmd.cpuid; +#endif mcmd->abort_io_attr = abort_cmd->atio.u.isp24.attr; mcmd->flags = QLA24XX_MGMT_ABORT_IO_ATTR_VALID; } } INIT_WORK(&mcmd->work, qlt_do_tmr_work); +#if HAVE_SE_CMD_CPUID queue_work_on(mcmd->se_cmd.cpuid, qla_tgt_wq, &mcmd->work); +#else + queue_work(qla_tgt_wq, &mcmd->work); +#endif return 0; } @@ -2436,6 +2457,12 @@ static int qlt_pci_map_calc_cnt(struct qla_tgt_prm *prm) prm->cmd->sg_mapped = 1; +#if !QLA_ENABLE_PI + if (prm->seg_cnt > QLA_TGT_DATASEGS_PER_CMD_24XX) + prm->req_cnt += DIV_ROUND_UP(prm->seg_cnt - + QLA_TGT_DATASEGS_PER_CMD_24XX, + QLA_TGT_DATASEGS_PER_CONT_24XX); +#else if (cmd->se_cmd.prot_op == TARGET_PROT_NORMAL) { /* * If greater than four sg entries then we need to allocate @@ -2472,6 +2499,7 @@ static int qlt_pci_map_calc_cnt(struct qla_tgt_prm *prm) prm->tot_dsds += prm->prot_seg_cnt; } } +#endif return 0; @@ -2806,7 +2834,7 @@ static int qlt_pre_xmit_response(struct qla_tgt_cmd *cmd, prm->residual = se_cmd->residual_count; ql_dbg_qp(ql_dbg_io + ql_dbg_verbose, qpair, 0x305c, "Residual underflow: %d (tag %lld, op %x, bufflen %d, rq_result %x)\n", - prm->residual, se_cmd->tag, + prm->residual, se_cmd_tag(se_cmd), se_cmd->t_task_cdb ? se_cmd->t_task_cdb[0] : 0, cmd->bufflen, prm->rq_result); prm->rq_result |= SS_RESIDUAL_UNDER; @@ -2814,7 +2842,7 @@ static int qlt_pre_xmit_response(struct qla_tgt_cmd *cmd, prm->residual = se_cmd->residual_count; ql_dbg_qp(ql_dbg_io, qpair, 0x305d, "Residual overflow: %d (tag %lld, op %x, bufflen %d, rq_result %x)\n", - prm->residual, se_cmd->tag, se_cmd->t_task_cdb ? + prm->residual, se_cmd_tag(se_cmd), se_cmd->t_task_cdb ? se_cmd->t_task_cdb[0] : 0, cmd->bufflen, prm->rq_result); prm->rq_result |= SS_RESIDUAL_OVER; } @@ -2906,6 +2934,7 @@ skip_explict_conf: /* Sense with len > 24, is it possible ??? */ } +#if QLA_ENABLE_PI static inline int qlt_hba_err_chk_enabled(struct se_cmd *se_cmd) { @@ -3245,6 +3274,7 @@ crc_queuing_error: return QLA_FUNCTION_FAILED; } +#endif /* * Callback to setup response of xmit_type of QLA_TGT_XMIT_DATA and * @@ -3307,9 +3337,11 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, if (unlikely(res)) goto out_unmap_unlock; +#if QLA_ENABLE_PI if (cmd->se_cmd.prot_op && (xmit_type & QLA_TGT_XMIT_DATA)) res = qlt_build_ctio_crc2_pkt(qpair, &prm); else +#endif res = qlt_24xx_build_ctio_pkt(qpair, &prm); if (unlikely(res != 0)) { qpair->req->cnt += full_req_cnt; @@ -3323,7 +3355,9 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, cpu_to_le16(CTIO7_FLAGS_DATA_IN | CTIO7_FLAGS_STATUS_MODE_0); +#if QLA_ENABLE_PI if (cmd->se_cmd.prot_op == TARGET_PROT_NORMAL) +#endif qlt_load_data_segments(&prm); if (prm.add_status_pkt == 0) { @@ -3448,9 +3482,11 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd) res = qlt_check_reserve_free_req(qpair, prm.req_cnt); if (res != 0) goto out_unlock_free_unmap; +#if QLA_ENABLE_PI if (cmd->se_cmd.prot_op) res = qlt_build_ctio_crc2_pkt(qpair, &prm); else +#endif res = qlt_24xx_build_ctio_pkt(qpair, &prm); if (unlikely(res != 0)) { @@ -3462,7 +3498,9 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd) pkt->u.status0.flags |= cpu_to_le16(CTIO7_FLAGS_DATA_OUT | CTIO7_FLAGS_STATUS_MODE_0); +#if QLA_ENABLE_PI if (cmd->se_cmd.prot_op == TARGET_PROT_NORMAL) +#endif qlt_load_data_segments(&prm); cmd->state = QLA_TGT_STATE_NEED_DATA; @@ -3837,7 +3875,7 @@ int qlt_abort_cmd(struct qla_tgt_cmd *cmd) ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014, "qla_target(%d): terminating exchange for aborted cmd=%p " "(se_cmd=%p, tag=%llu)", vha->vp_idx, cmd, &cmd->se_cmd, - se_cmd->tag); + se_cmd_tag(se_cmd)); spin_lock_irqsave(&cmd->cmd_lock, flags); if (cmd->aborted) { @@ -3900,6 +3938,7 @@ static int qlt_term_ctio_exchange(struct qla_qpair *qpair, void *ctio, struct qla_tgt_cmd *cmd, uint32_t status) { int term = 0; +#if QLA_ENABLE_PI struct scsi_qla_host *vha = qpair->vha; if (cmd->se_cmd.prot_op) @@ -3911,6 +3950,7 @@ static int qlt_term_ctio_exchange(struct qla_qpair *qpair, void *ctio, cmd->atio.u.isp24.exchange_addr, cmd->se_cmd.prot_op, prot_op_str(cmd->se_cmd.prot_op)); +#endif if (ctio != NULL) { struct ctio7_from_24xx *c = (struct ctio7_from_24xx *)ctio; @@ -4141,7 +4181,8 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha, } else if (cmd->aborted) { cmd->trc_flags |= TRC_CTIO_ABORTED; ql_dbg(ql_dbg_tgt_mgt, vha, 0xf01e, - "Aborted command %p (tag %lld) finished\n", cmd, se_cmd->tag); + "Aborted command %p (tag %lld) finished\n", cmd, + se_cmd_tag(se_cmd)); } else { cmd->trc_flags |= TRC_CTIO_STRANGE; ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05c, @@ -4219,7 +4260,7 @@ static void __qlt_do_work(struct qla_tgt_cmd *cmd) spin_lock_init(&cmd->cmd_lock); cdb = &atio->u.isp24.fcp_cmnd.cdb[0]; - cmd->se_cmd.tag = atio->u.isp24.exchange_addr; + se_cmd_tag(&cmd->se_cmd) = atio->u.isp24.exchange_addr; if (atio->u.isp24.fcp_cmnd.rddata && atio->u.isp24.fcp_cmnd.wrdata) { @@ -4381,7 +4422,9 @@ static void qlt_assign_qpair(struct scsi_qla_host *vha, } out: cmd->qpair = h->qpair; +#if HAVE_SE_CMD_CPUID cmd->se_cmd.cpuid = h->cpuid; +#endif } static struct qla_tgt_cmd *qlt_get_tag(scsi_qla_host_t *vha, @@ -4482,14 +4525,22 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, INIT_WORK(&cmd->work, qlt_do_work); if (vha->flags.qpairs_available) { +#if HAVE_SE_CMD_CPUID queue_work_on(cmd->se_cmd.cpuid, qla_tgt_wq, &cmd->work); +#else + queue_work(qla_tgt_wq, &cmd->work); +#endif } else if (ha->msix_count) { if (cmd->atio.u.isp24.fcp_cmnd.rddata) queue_work_on(smp_processor_id(), qla_tgt_wq, &cmd->work); else +#if HAVE_SE_CMD_CPUID queue_work_on(cmd->se_cmd.cpuid, qla_tgt_wq, &cmd->work); +#else + queue_work(qla_tgt_wq, &cmd->work); +#endif } else { queue_work(qla_tgt_wq, &cmd->work); } @@ -4527,7 +4578,9 @@ static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun, mcmd->reset_count = ha->base_qpair->chip_reset; mcmd->qpair = h->qpair; mcmd->vha = vha; +#if HAVE_SE_CMD_CPUID mcmd->se_cmd.cpuid = h->cpuid; +#endif mcmd->unpacked_lun = lun; switch (fn) { @@ -4539,7 +4592,9 @@ static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun, case QLA_TGT_CLEAR_ACA: h = qlt_find_qphint(vha, mcmd->unpacked_lun); mcmd->qpair = h->qpair; +#if HAVE_SE_CMD_CPUID mcmd->se_cmd.cpuid = h->cpuid; +#endif break; case QLA_TGT_TARGET_RESET: @@ -4552,8 +4607,12 @@ static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun, } INIT_WORK(&mcmd->work, qlt_do_tmr_work); +#if HAVE_SE_CMD_CPUID queue_work_on(mcmd->se_cmd.cpuid, qla_tgt_wq, &mcmd->work); +#else + queue_work(qla_tgt_wq, &mcmd->work); +#endif return 0; } diff --git a/qla2x00t-32gbit/qla_target.h b/qla2x00t-32gbit/qla_target.h index 6d1475efe..3414c203d 100644 --- a/qla2x00t-32gbit/qla_target.h +++ b/qla2x00t-32gbit/qla_target.h @@ -28,9 +28,35 @@ #ifndef __QLA_TARGET_H #define __QLA_TARGET_H +#include #include #include "qla_def.h" +/* See also commit ce65e5b97b19 ("target: Add DIF related base definitions") # v3.14. */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) || \ + defined(RHEL_MAJOR) && RHEL_MAJOR -0 >= 7 +#ifdef SCST_DIF_NO_CHECK_APP_TAG +#define QLA_ENABLE_PI 1 +#else +#define QLA_ENABLE_PI 0 +#endif +#else +#define QLA_ENABLE_PI 0 +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) || \ + defined(RHEL_MAJOR) && RHEL_MAJOR -0 >= 7 +/* + * See also commit 649ee05499d1 ("target: Move task tag into struct se_cmd + + * support 64-bit tags") # v4.2. + */ +#define HAVE_SE_CMD_TAG 1 +#define se_cmd_tag(c) ((c)->tag) +#else +#define HAVE_SE_CMD_TAG 0 +#define se_cmd_tag(c) (container_of((c), struct qla_tgt_cmd, se_cmd)->tag) +#endif + /* * Must be changed on any change in any initiator visible interfaces or * data in the target add-on @@ -873,6 +899,9 @@ struct qla_tgt_cmd { uint8_t cmd_type; uint8_t pad[7]; struct se_cmd se_cmd; +#if !HAVE_SE_CMD_TAG + u64 tag; +#endif struct fc_port *sess; struct qla_qpair *qpair; uint32_t reset_count;