diff --git a/qla2x00t-32gbit/Makefile_in-tree b/qla2x00t-32gbit/Makefile_in-tree index 6d87c9153..f86fa5a0b 100644 --- a/qla2x00t-32gbit/Makefile_in-tree +++ b/qla2x00t-32gbit/Makefile_in-tree @@ -8,6 +8,3 @@ obj-$(CONFIG_TCM_QLA2XXX) += tcm_qla2xxx.o ccflags-y += -I$(src)/../../../include/scst/ ccflags-y += $(call cc-option,-Wno-format-truncation) - -qla2x00tgt-objs := qla_tgt.o scst_qla2xxx.o -obj-$(CONFIG_SCST_QLA_TGT_ADDON) += qla2x00tgt.o diff --git a/qla2x00t-32gbit/qla2x00-target/qla_tgt.c b/qla2x00t-32gbit/qla2x00-target/qla_tgt.c index e9da15b44..a6b010830 100644 --- a/qla2x00t-32gbit/qla2x00-target/qla_tgt.c +++ b/qla2x00t-32gbit/qla2x00-target/qla_tgt.c @@ -43,13 +43,13 @@ #include #include "qla_def.h" +#include "scst_qla2xxx.h" extern struct mutex qla_tgt_mutex; extern struct list_head qla_tgt_glist; -static size_t -qlt_add_vtarget(u64 port_name, u64 node_name, u64 parent_host) +size_t qlt_add_vtarget(u64 port_name, u64 node_name, u64 parent_host) { struct Scsi_Host *shost = NULL; struct qla_tgt *tgt; @@ -89,7 +89,7 @@ qlt_add_vtarget(u64 port_name, u64 node_name, u64 parent_host) } EXPORT_SYMBOL(qlt_add_vtarget); -static size_t qlt_del_vtarget(u64 port_name) +size_t qlt_del_vtarget(u64 port_name) { struct qla_tgt *tgt, *t; scsi_qla_host_t *vha = NULL; diff --git a/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c b/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c index 6e3d7d6ee..36c9534db 100644 --- a/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c +++ b/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c @@ -309,8 +309,8 @@ static const int qla_tgt_supported_dif_block_size[]= { static inline void qla_tgt_set_cmd_prot_op(struct qla_tgt_cmd *cmd, uint8_t xmit_rsp) { - struct scst_cmd *scst_cmd = (struct scst_cmd *) cmd->se_cmd.priv; - int dir = scst_cmd_get_data_direction(cmd->se_cmd.priv); + struct scst_cmd *scst_cmd = cmd->scst_cmd; + int dir = scst_cmd_get_data_direction(scst_cmd); int action = scst_get_dif_action( scst_get_tgt_dif_actions(scst_cmd->cmd_dif_actions)); @@ -481,6 +481,8 @@ static struct qla_tgt_cmd *sqa_qla2xxx_get_cmd(struct fc_port *sess) memset(cmd, 0, sizeof(struct qla_tgt_cmd)); #if QLT_USE_PERCPU_IDA || QLT_USE_SBITMAP cmd->se_cmd.map_tag = tag; +#else + cmd->map_tag = tag; #endif #if QLT_USE_SBITMAP cmd->se_cmd.map_cpu = cpu; @@ -545,10 +547,10 @@ static int sqa_qla2xxx_handle_cmd(scsi_qla_host_t *vha, vha->host_no, vha->vp_idx, data_length, task_codes, data_dir, bidi, cmd->unpacked_lun, atio->u.isp24.fcp_cmnd.cdb[0], - atio->u.isp24.exchange_addr, cmd, cmd->se_cmd.priv); + atio->u.isp24.exchange_addr, cmd, cmd->scst_cmd); - cmd->se_cmd.priv = scst_rx_cmd(scst_sess, + cmd->scst_cmd = scst_rx_cmd(scst_sess, (uint8_t *)&atio->u.isp24.fcp_cmnd.lun, sizeof(atio->u.isp24.fcp_cmnd.lun), atio->u.isp24.fcp_cmnd.cdb, @@ -556,15 +558,15 @@ static int sqa_qla2xxx_handle_cmd(scsi_qla_host_t *vha, (atio->u.isp24.fcp_cmnd.add_cdb_len *4), SCST_ATOMIC); - if (cmd->se_cmd.priv == NULL) { + if (cmd->scst_cmd == NULL) { PRINT_ERROR("sqatgt(%ld/%d): scst_rx_cmd function failed.", vha->host_no, vha->vp_idx); res = -EFAULT; goto out; } - scst_cmd_set_tag(cmd->se_cmd.priv, atio->u.isp24.exchange_addr); - scst_cmd_set_tgt_priv(cmd->se_cmd.priv, cmd); + scst_cmd_set_tag(cmd->scst_cmd, atio->u.isp24.exchange_addr); + scst_cmd_set_tgt_priv(cmd->scst_cmd, cmd); if (atio->u.isp24.fcp_cmnd.rddata && atio->u.isp24.fcp_cmnd.wrdata) dir = SCST_DATA_BIDI; @@ -574,35 +576,34 @@ static int sqa_qla2xxx_handle_cmd(scsi_qla_host_t *vha, dir = SCST_DATA_WRITE; else dir = SCST_DATA_NONE; - scst_cmd_set_expected(cmd->se_cmd.priv, dir, data_length); + scst_cmd_set_expected(cmd->scst_cmd, dir, data_length); /* task_code fr arg list is based on TCM #define. */ switch (atio->u.isp24.fcp_cmnd.task_attr) { case ATIO_SIMPLE_QUEUE: - scst_cmd_set_queue_type(cmd->se_cmd.priv, - SCST_CMD_QUEUE_SIMPLE); + scst_cmd_set_queue_type(cmd->scst_cmd, SCST_CMD_QUEUE_SIMPLE); break; case ATIO_HEAD_OF_QUEUE: - scst_cmd_set_queue_type(cmd->se_cmd.priv, + scst_cmd_set_queue_type(cmd->scst_cmd, SCST_CMD_QUEUE_HEAD_OF_QUEUE); break; case ATIO_ORDERED_QUEUE: - scst_cmd_set_queue_type(cmd->se_cmd.priv, + scst_cmd_set_queue_type(cmd->scst_cmd, SCST_CMD_QUEUE_ORDERED); break; case ATIO_ACA_QUEUE: - scst_cmd_set_queue_type(cmd->se_cmd.priv, + scst_cmd_set_queue_type(cmd->scst_cmd, SCST_CMD_QUEUE_ACA); break; case ATIO_UNTAGGED: - scst_cmd_set_queue_type(cmd->se_cmd.priv, + scst_cmd_set_queue_type(cmd->scst_cmd, SCST_CMD_QUEUE_UNTAGGED); break; default: PRINT_ERROR("sqatgt(%ld/%d): unknown task code %x, use " "ORDERED instead.", vha->host_no, vha->vp_idx, atio->u.isp24.fcp_cmnd.task_attr); - scst_cmd_set_queue_type(cmd->se_cmd.priv, + scst_cmd_set_queue_type(cmd->scst_cmd, SCST_CMD_QUEUE_ORDERED); break; } @@ -610,10 +611,10 @@ static int sqa_qla2xxx_handle_cmd(scsi_qla_host_t *vha, TRACE(TRACE_SCSI, "sqatgt(%ld/%d): START Command=%p tag=%d, " "queue type=%x", vha->host_no, vha->vp_idx, cmd, cmd->atio.u.isp24.exchange_addr, - scst_cmd_get_queue_type(cmd->se_cmd.priv)); + scst_cmd_get_queue_type(cmd->scst_cmd)); /* we're being call by wq, so do direct */ - scst_cmd_init_done(cmd->se_cmd.priv, SCST_CONTEXT_DIRECT); + scst_cmd_init_done(cmd->scst_cmd, SCST_CONTEXT_DIRECT); out: TRACE_EXIT_RES(res); @@ -622,7 +623,7 @@ static int sqa_qla2xxx_handle_cmd(scsi_qla_host_t *vha, static void sqa_qla2xxx_handle_data(struct qla_tgt_cmd *cmd) { - struct scst_cmd *scst_cmd = (struct scst_cmd *)cmd->se_cmd.priv; + struct scst_cmd *scst_cmd = cmd->scst_cmd; int rx_status; unsigned long flags; @@ -800,7 +801,7 @@ static int sqa_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, u64 lun, static void sqa_qla2xxx_free_cmd(struct qla_tgt_cmd *cmd) { - struct scst_cmd *scst_cmd = cmd->se_cmd.priv; + struct scst_cmd *scst_cmd = cmd->scst_cmd; TRACE_ENTRY(); @@ -920,24 +921,12 @@ static void sqa_scst_session_cb(struct scst_session *scst_sess, static struct se_session *sqa_alloc_sesess(scsi_qla_host_t *vha) { struct se_session *se_sess; + /* - * The following is open coded from: - * - * target_core_transport:transport_init_session() - * * For now we simply allocate a single page to hold the session * structure. This needs to be modified to use the slab cache. */ - se_sess = kzalloc(sizeof(*se_sess), GFP_KERNEL); - if (!se_sess) - return NULL; - - INIT_LIST_HEAD(&se_sess->sess_list); - INIT_LIST_HEAD(&se_sess->sess_acl_list); - INIT_LIST_HEAD(&se_sess->sess_cmd_list); - spin_lock_init(&se_sess->sess_cmd_lock); - - return se_sess; + return kzalloc(sizeof(*se_sess), GFP_KERNEL); } static void sqa_free_sesess(struct se_session *se_sess) @@ -1694,16 +1683,14 @@ static int sqa_xmit_response(struct scst_cmd *scst_cmd) EXTRACHECKS_BUG_ON(scst_cmd_atomic(scst_cmd)); #endif if (is_send_status) { + const u8* const sense_buf = scst_cmd_get_sense_buffer(scst_cmd); u16 len = scst_cmd_get_sense_buffer_len(scst_cmd); + xmit_type |= QLA_TGT_XMIT_STATUS; - - if (QLA_TGT_SENSE_VALID(scst_cmd_get_sense_buffer(scst_cmd))) { - if (len > TRANSPORT_SENSE_BUFFER || - len == 0) + if (QLA_TGT_SENSE_VALID(sense_buf)) { + if (len > TRANSPORT_SENSE_BUFFER || len == 0) len = TRANSPORT_SENSE_BUFFER; - - memcpy(cmd->sense_buffer, - scst_cmd_get_sense_buffer(scst_cmd), len); + memcpy(cmd->sense_buffer, sense_buf, len); } } @@ -1730,7 +1717,7 @@ static int sqa_xmit_response(struct scst_cmd *scst_cmd) TRACE_DBG("cmd[%p] ulpcmd[%p] dif_actions=0x%x, cdb=0x%x, prot_sg[%p] " "prot_sg_cnt[%x], prot_type[%x] prot_op[%x]", - cmd, cmd->se_cmd.priv, scst_cmd->cmd_dif_actions, scst_cmd->cdb_buf[0], + cmd, cmd->scst_cmd, scst_cmd->cmd_dif_actions, scst_cmd->cdb_buf[0], cmd->prot_sg, cmd->prot_sg_cnt, cmd->se_cmd.prot_type, cmd->se_cmd.prot_op); @@ -1817,7 +1804,7 @@ static int sqa_rdy_to_xfer(struct scst_cmd *scst_cmd) TRACE_DBG("%s: cmd[%p] ulpcmd[%p] dif_actions=0x%x, cdb=0x%x, " "prot_sg_cnt[%x], prot_type[%x] prot_op[%x], bufflen[%x]",__func__, - cmd, cmd->se_cmd.priv, + cmd, cmd->scst_cmd, scst_cmd->cmd_dif_actions, scst_cmd->cdb_buf[0], cmd->prot_sg_cnt, cmd->se_cmd.prot_type, cmd->se_cmd.prot_op, cmd->bufflen); @@ -2342,7 +2329,7 @@ sqa_qla2xxx_chk_dif_tags(uint32_t tag) static int sqa_qla2xxx_dif_tags(struct qla_tgt_cmd *cmd, uint16_t *pfw_prot_opts) { - struct scst_cmd *scst_cmd = (struct scst_cmd *)cmd->se_cmd.priv; + struct scst_cmd *scst_cmd = cmd->scst_cmd; uint32_t t32=0; t32 = scst_get_dif_checks(scst_cmd->cmd_dif_actions); diff --git a/qla2x00t-32gbit/qla_bsg.c b/qla2x00t-32gbit/qla_bsg.c index 850ac4114..f21369148 100644 --- a/qla2x00t-32gbit/qla_bsg.c +++ b/qla2x00t-32gbit/qla_bsg.c @@ -9,9 +9,10 @@ #include #include #include -#include -#ifndef NEW_LIBFC_API +#ifdef NEW_LIBFC_API +#include +#else static inline struct Scsi_Host *fc_bsg_to_shost(struct fc_bsg_job *job) { return job->shost; diff --git a/qla2x00t-32gbit/qla_fw.h b/qla2x00t-32gbit/qla_fw.h index b61a09c2c..e4b7ae4c9 100644 --- a/qla2x00t-32gbit/qla_fw.h +++ b/qla2x00t-32gbit/qla_fw.h @@ -8,7 +8,9 @@ #define __QLA_FW_H #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0) || defined(RHEL_MAJOR) #include +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) #include #endif diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index 25dec6479..a611c093b 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -293,8 +293,6 @@ extern int qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *, srb_t *, uint32_t *, uint16_t, struct qla_tgt_cmd *); extern int qla24xx_get_one_block_sg(uint32_t, struct qla2_sgx *, uint32_t *); extern int qla24xx_configure_prot_mode(srb_t *, uint16_t *); -extern int qla24xx_build_scsi_crc_2_iocbs(srb_t *, - struct cmd_type_crc_2 *, uint16_t, uint16_t, uint16_t); /* * Global Function Prototypes in qla_mbx.c source file. diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index 0c700b140..4ca4f0023 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -17,7 +17,6 @@ #include #endif -#include #include "qla_target.h" /* diff --git a/qla2x00t-32gbit/qla_iocb.c b/qla2x00t-32gbit/qla_iocb.c index b3594a139..0920cb1f9 100644 --- a/qla2x00t-32gbit/qla_iocb.c +++ b/qla2x00t-32gbit/qla_iocb.c @@ -1396,6 +1396,8 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, *cur_dsd++ = 0; return 0; } +#endif + /** * qla24xx_build_scsi_crc_2_iocbs() - Build IOCB command utilizing Command * Type 6 IOCB types. @@ -1406,7 +1408,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, * @tot_prot_dsds: Total number of segments with protection information * @fw_prot_opts: Protection options to be passed to firmware */ -inline int +static inline int qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, uint16_t tot_dsds, uint16_t tot_prot_dsds, uint16_t fw_prot_opts) { @@ -1590,12 +1592,16 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, goto crc_queuing_error; if (bundling && tot_prot_dsds) { +#if QLA_ENABLE_PI /* Walks dif segments */ cmd_pkt->control_flags |= cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE); cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; if (qla24xx_walk_and_build_prot_sglist(ha, sp, cur_dsd, tot_prot_dsds, NULL)) goto crc_queuing_error; +#else + WARN_ON_ONCE(true); +#endif } return QLA_SUCCESS; @@ -1604,7 +1610,6 @@ 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 4d0cb6c25..8db67f9f8 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -3495,7 +3495,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) && !defined(RHEL_MAJOR) ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); if (ret) { if (ret < QLA_BASE_VECTORS) diff --git a/qla2x00t-32gbit/qla_mr.c b/qla2x00t-32gbit/qla_mr.c index 7d4caab81..2fbfd7b4b 100644 --- a/qla2x00t-32gbit/qla_mr.c +++ b/qla2x00t-32gbit/qla_mr.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index 1e647b332..0985d5a5c 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -924,9 +924,6 @@ qla2xxx_qpair_sp_compl(void *ptr, int res) cmd->scsi_done(cmd); } -/* If we are SP1 here, we need to still take and release the host_lock as SP1 - * does not have the changes necessary to avoid taking host->host_lock. - */ static int qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) { diff --git a/qla2x00t-32gbit/qla_target.c b/qla2x00t-32gbit/qla_target.c index 25778c13b..50ccb55fd 100644 --- a/qla2x00t-32gbit/qla_target.c +++ b/qla2x00t-32gbit/qla_target.c @@ -36,8 +36,6 @@ #include #include #include -#include -#include #include "qla_def.h" #include "qla_target.h" @@ -163,6 +161,7 @@ struct kmem_cache *qla_tgt_plogi_cachep; static mempool_t *qla_tgt_mgmt_cmd_mempool; static struct workqueue_struct *qla_tgt_wq; DEFINE_MUTEX(qla_tgt_mutex); +EXPORT_SYMBOL(qla_tgt_mutex); LIST_HEAD(qla_tgt_glist); EXPORT_SYMBOL(qla_tgt_glist); @@ -3528,6 +3527,7 @@ out_unlock_free_unmap: EXPORT_SYMBOL(qlt_rdy_to_xfer); +#if QLA_ENABLE_PI /* * it is assumed either hardware_lock or qpair lock is held. */ @@ -3630,6 +3630,14 @@ out: break; } } +#else +static void +qlt_handle_dif_error(struct qla_qpair *qpair, struct qla_tgt_cmd *cmd, + struct ctio_crc_from_fw *sts) +{ + WARN_ON_ONCE(true); +} +#endif /* If hardware_lock held on entry, might drop it, then reaquire */ /* This function sends the appropriate CTIO to ISP 2xxx or 24xx */ @@ -3885,10 +3893,8 @@ int qlt_abort_cmd(struct qla_tgt_cmd *cmd) * 1) XFER Rdy completion + CMD_T_ABORT * 2) TCM TMR - drain_state_list */ - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf016, - "multiple abort. %p transport_state %x, t_state %x, " - "se_cmd_flags %x\n", cmd, cmd->se_cmd.transport_state, - cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf016, "multiple abort. %p\n", + cmd); return EIO; } cmd->aborted = 1; diff --git a/qla2x00t-32gbit/qla_target.h b/qla2x00t-32gbit/qla_target.h index 8ec9d7741..874e4b24f 100644 --- a/qla2x00t-32gbit/qla_target.h +++ b/qla2x00t-32gbit/qla_target.h @@ -899,6 +899,7 @@ struct qla_tgt_cmd { uint8_t cmd_type; uint8_t pad[7]; struct se_cmd se_cmd; + struct scst_cmd *scst_cmd; #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) /* * Used if neither nor are diff --git a/scripts/kernel-functions b/scripts/kernel-functions index c5178bfe0..016389820 100644 --- a/scripts/kernel-functions +++ b/scripts/kernel-functions @@ -322,7 +322,7 @@ index d6d65537b0d9..6aad8308a0ac 100644 EOF fi case "$1" in - 2.6.3[6-9]*|3.[0-9].*|3.1[01345].*|3.17.*|3.19.*|4.[023567].*) + 2.6.3[6-9]*|3.[0-9]|3.[0-9].*|3.1[01345]|3.1[01345].*|3.17|3.17.*|3.19|3.19.*|4.[023567]|4.[023567].*) patch -p1 <<'EOF' From c6a385539175ebc603da53aafb7753d39089f32e Mon Sep 17 00:00:00 2001 From: Borislav Petkov diff --git a/scst/include/backport.h b/scst/include/backport.h index 9c636c5a5..caeaec206 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -37,6 +37,7 @@ #include /* sizeof_field() */ #include #include +#include #include /* sync_page_range() */ #include #include /* struct scsi_cmnd */ @@ -531,6 +532,25 @@ static inline struct io_context *get_task_io_context(struct task_struct *task, } #endif +/* */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0) && !defined(RHEL_MAJOR) +/* + * See also commit 2a11c8ea20bf ("kconfig: Introduce IS_ENABLED(), IS_BUILTIN() + * and IS_MODULE()") # v3.1. + */ +#define __ARG_PLACEHOLDER_1 0, +#define __take_second_arg(__ignored, val, ...) val +#define __or(x, y) ___or(x, y) +#define ___or(x, y) ____or(__ARG_PLACEHOLDER_##x, y) +#define ____or(arg1_or_junk, y) __take_second_arg(arg1_or_junk 1, y) +#define __is_defined(x) ___is_defined(x) +#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val) +#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0) +#define IS_BUILTIN(option) __is_defined(option) +#define IS_MODULE(option) __is_defined(option##_MODULE) +#define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) @@ -1456,6 +1476,22 @@ static inline void *vzalloc(unsigned long size) } #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) +/* + * See also commit d320c03830b1 ("workqueue: s/__create_workqueue()/ + * alloc_workqueue()/, and add system workqueues") # v2.6.36. + */ +static inline struct workqueue_struct *alloc_workqueue(const char *fmt, + unsigned int flags, + int max_active, ...) +{ + WARN_ON_ONCE(flags | max_active); + return create_workqueue(fmt); +} +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) || \