From c66ae1850e00b1d426fe0cdcf31329a87726708a Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Mon, 6 Sep 2010 21:45:48 +0000 Subject: [PATCH] - get_transport_version() function changed to get target on entry - transport versions propageted to user space handlers git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2061 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- doc/scst_user_spec.txt | 8 ++++++++ iscsi-scst/kernel/iscsi.c | 2 +- mvsas_tgt/mv_tgt.c | 4 ++-- qla2x00t/qla2x00-target/qla2x00t.c | 8 ++++---- qla_isp/linux/isp_scst.c | 2 +- scst/include/scst.h | 10 ++-------- scst/include/scst_user.h | 2 ++ scst/src/dev_handlers/scst_user.c | 8 ++++++++ scst/src/dev_handlers/scst_vdisk.c | 4 ++-- scst_local/scst_local.c | 10 ++++------ srpt/src/ib_srpt.c | 2 +- 11 files changed, 35 insertions(+), 25 deletions(-) diff --git a/doc/scst_user_spec.txt b/doc/scst_user_spec.txt index 272b88385..dc41631cc 100644 --- a/doc/scst_user_spec.txt +++ b/doc/scst_user_spec.txt @@ -312,6 +312,8 @@ struct scst_user_sess uint64_t lun; uint16_t threads_num; uint8_t rd_only; + uint16_t scsi_transport_version; + uint16_t phys_transport_version; char initiator_name[SCST_MAX_NAME]; char target_name[SCST_MAX_NAME]; }, @@ -327,6 +329,12 @@ where: - rd_only - if true, this device is read only in this session + - scsi_transport_version - version descriptor value for SCSI transport + of this session + + - phys_transport_version - version descriptor value for physical transport + of this session + - initiator_name - name of the remote initiator, which initiated this session diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index a0701841f..6b5523f2a 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -3746,7 +3746,7 @@ static struct scst_trace_log iscsi_local_trace_tbl[] = { #define ISCSI_TRACE_TBL_HELP ", d_write, conn, conn_dbg, iov, pdu, net_page" #endif -static uint16_t iscsi_get_scsi_transport_version(struct scst_cmd *scst_cmd) +static uint16_t iscsi_get_scsi_transport_version(struct scst_tgt *scst_tgt) { return 0x0960; /* iSCSI */ } diff --git a/mvsas_tgt/mv_tgt.c b/mvsas_tgt/mv_tgt.c index ca885e699..858e94b4e 100644 --- a/mvsas_tgt/mv_tgt.c +++ b/mvsas_tgt/mv_tgt.c @@ -66,7 +66,7 @@ static void mvst_host_action(struct mvs_info *mvi, enum mvst_tgt_host_action_t action, u8 phyid); static int mvst_start_sas_target(struct mvs_info *mvi, u8 id); static int mvst_restart_free_list(struct mvs_info *mvi, u8 slot_id); -static uint16_t mvst_get_scsi_transport_version(struct scst_cmd *scst_cmd); +static uint16_t mvst_get_scsi_transport_version(struct scst_tgt *scst_tgt); struct kmem_cache *mvst_cmd_cachep; struct mvst_msg_queue tgt_msg_queue; @@ -96,7 +96,7 @@ struct scst_tgt_template tgt_template = { * Functions */ -static uint16_t mvst_get_scsi_transport_version(struct scst_cmd *scst_cmd) +static uint16_t mvst_get_scsi_transport_version(struct scst_tgt *scst_tgt) { return 0x0BE0; /* SAS */ } diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index 339ac5a78..104aac431 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -96,8 +96,8 @@ static int q2t_cut_cmd_data_head(struct q2t_cmd *cmd, unsigned int offset); static void q2t_clear_tgt_db(struct q2t_tgt *tgt, bool local_only); static void q2t_on_hw_pending_cmd_timeout(struct scst_cmd *scst_cmd); static int q2t_unreg_sess(struct q2t_sess *sess); -static uint16_t q2t_get_scsi_transport_version(struct scst_cmd *scst_cmd); -static uint16_t q2t_get_phys_transport_version(struct scst_cmd *scst_cmd); +static uint16_t q2t_get_scsi_transport_version(struct scst_tgt *scst_tgt); +static uint16_t q2t_get_phys_transport_version(struct scst_tgt *scst_tgt); #ifndef CONFIG_SCST_PROC @@ -5507,13 +5507,13 @@ static void q2t_proc_log_entry_clean(struct scst_tgt_template *templ) #endif /* CONFIG_SCST_PROC */ -static uint16_t q2t_get_scsi_transport_version(struct scst_cmd *scst_cmd) +static uint16_t q2t_get_scsi_transport_version(struct scst_tgt *scst_tgt) { /* FCP-2 (speculative, there's no info what FW supports) */ return 0x0900; } -static uint16_t q2t_get_phys_transport_version(struct scst_cmd *scst_cmd) +static uint16_t q2t_get_phys_transport_version(struct scst_tgt *scst_tgt) { return 0x0DA0; /* FC-FS */ } diff --git a/qla_isp/linux/isp_scst.c b/qla_isp/linux/isp_scst.c index 0003c9cd4..5d2c60a13 100644 --- a/qla_isp/linux/isp_scst.c +++ b/qla_isp/linux/isp_scst.c @@ -1581,7 +1581,7 @@ out: return (res); } -static uint16_t isp_get_scsi_transport_version(struct scst_cmd *scst_cmd) +static uint16_t isp_get_scsi_transport_version(struct scst_tgt *scst_tgt) { return 0x0900; /* FCP-2 */ } diff --git a/scst/include/scst.h b/scst/include/scst.h index ee1c2723f..4064966f9 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -890,7 +890,7 @@ struct scst_tgt_template { * * OPTIONAL */ - uint16_t (*get_phys_transport_version) (struct scst_cmd *cmd); + uint16_t (*get_phys_transport_version) (struct scst_tgt *tgt); /* * Should return SCSI transport version. Used in the corresponding @@ -898,7 +898,7 @@ struct scst_tgt_template { * * OPTIONAL */ - uint16_t (*get_scsi_transport_version) (struct scst_cmd *cmd); + uint16_t (*get_scsi_transport_version) (struct scst_tgt *tgt); /* * Name of the template. Must be unique to identify @@ -2763,12 +2763,6 @@ static inline void scst_cmd_set_ext_cdb(struct scst_cmd *cmd, cmd->ext_cdb_len = ext_cdb_len; } -/* Returns cmd's target */ -static inline struct scst_tgt *scst_cmd_get_tgt(struct scst_cmd *cmd) -{ - return cmd->tgt; -} - /* Returns cmd's session */ static inline struct scst_session *scst_cmd_get_session(struct scst_cmd *cmd) { diff --git a/scst/include/scst_user.h b/scst/include/scst_user.h index d51853481..d4a743e5b 100644 --- a/scst/include/scst_user.h +++ b/scst/include/scst_user.h @@ -107,6 +107,8 @@ struct scst_user_sess { aligned_u64 lun; uint16_t threads_num; uint8_t rd_only; + uint16_t scsi_transport_version; + uint16_t phys_transport_version; char initiator_name[SCST_MAX_EXTERNAL_NAME]; char target_name[SCST_MAX_EXTERNAL_NAME]; }; diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 5b9b1c2d7..53ed9131c 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -2589,6 +2589,8 @@ static int dev_user_attach_tgt(struct scst_tgt_dev *tgt_dev) int res = 0, rc; struct scst_user_cmd *ucmd; DECLARE_COMPLETION_ONSTACK(cmpl); + struct scst_tgt_template *tgtt = tgt_dev->sess->tgt->tgtt; + struct scst_tgt *tgt = tgt_dev->sess->tgt; TRACE_ENTRY(); @@ -2618,6 +2620,12 @@ static int dev_user_attach_tgt(struct scst_tgt_dev *tgt_dev) ucmd->user_cmd.sess.lun = (uint64_t)tgt_dev->lun; ucmd->user_cmd.sess.threads_num = tgt_dev->sess->tgt->tgtt->threads_num; ucmd->user_cmd.sess.rd_only = tgt_dev->acg_dev->rd_only; + if (tgtt->get_phys_transport_version != NULL) + ucmd->user_cmd.sess.phys_transport_version = + tgtt->get_phys_transport_version(tgt); + if (tgtt->get_scsi_transport_version != NULL) + ucmd->user_cmd.sess.scsi_transport_version = + tgtt->get_scsi_transport_version(tgt); strlcpy(ucmd->user_cmd.sess.initiator_name, tgt_dev->sess->initiator_name, sizeof(ucmd->user_cmd.sess.initiator_name)-1); diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 61b79fde6..d2f1c039e 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1447,7 +1447,7 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) /* Physical transport */ if (cmd->tgtt->get_phys_transport_version != NULL) { - uint16_t v = cmd->tgtt->get_phys_transport_version(cmd); + uint16_t v = cmd->tgtt->get_phys_transport_version(cmd->tgt); if (v != 0) { *((uint16_t *)&buf[58 + num]) = cpu_to_be16(v); num += 2; @@ -1457,7 +1457,7 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) /* SCSI transport */ if (cmd->tgtt->get_scsi_transport_version != NULL) { *((uint16_t *)&buf[58 + num]) = - cpu_to_be16(cmd->tgtt->get_scsi_transport_version(cmd)); + cpu_to_be16(cmd->tgtt->get_scsi_transport_version(cmd->tgt)); num += 2; } diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index a59c11d94..14dec4574 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1674,12 +1674,11 @@ static const struct attribute *scst_local_sess_attrs[] = { #endif /* CONFIG_SCST_PROC */ -static uint16_t scst_local_get_scsi_transport_version(struct scst_cmd *scst_cmd) +static uint16_t scst_local_get_scsi_transport_version(struct scst_tgt *scst_tgt) { struct scst_local_host_info *host; - host = (struct scst_local_host_info *)scst_tgt_get_tgt_priv( - scst_cmd_get_tgt(scst_cmd)); + host = (struct scst_local_host_info *)scst_tgt_get_tgt_priv(scst_tgt); if (host->scsi_transport_version == 0) return 0x0BE0; /* SAS */ @@ -1687,12 +1686,11 @@ static uint16_t scst_local_get_scsi_transport_version(struct scst_cmd *scst_cmd) return host->scsi_transport_version; } -static uint16_t scst_local_get_phys_transport_version(struct scst_cmd *scst_cmd) +static uint16_t scst_local_get_phys_transport_version(struct scst_tgt *scst_tgt) { struct scst_local_host_info *host; - host = (struct scst_local_host_info *)scst_tgt_get_tgt_priv( - scst_cmd_get_tgt(scst_cmd)); + host = (struct scst_local_host_info *)scst_tgt_get_tgt_priv(scst_tgt); return host->phys_transport_version; } diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 8763e2c2d..a57c62425 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3495,7 +3495,7 @@ static int srpt_release(struct scst_tgt *scst_tgt) return 0; } -static uint16_t srpt_get_scsi_transport_version(struct scst_cmd *scst_cmd) +static uint16_t srpt_get_scsi_transport_version(struct scst_tgt *scst_tgt) { return 0x0940; /* SRP */ }