0001
0002
0003
0004
0005
0006
0007 #ifndef __EFCT_LIO_H__
0008 #define __EFCT_LIO_H__
0009
0010 #include "efct_scsi.h"
0011 #include <target/target_core_base.h>
0012
0013 #define efct_lio_io_printf(io, fmt, ...) \
0014 efc_log_debug(io->efct, \
0015 "[%s] [%04x][i:%04x t:%04x h:%04x]" fmt,\
0016 io->node->display_name, io->instance_index, \
0017 io->init_task_tag, io->tgt_task_tag, io->hw_tag,\
0018 ##__VA_ARGS__)
0019
0020 #define efct_lio_tmfio_printf(io, fmt, ...) \
0021 efc_log_debug(io->efct, \
0022 "[%s] [%04x][i:%04x t:%04x h:%04x][f:%02x]" fmt,\
0023 io->node->display_name, io->instance_index, \
0024 io->init_task_tag, io->tgt_task_tag, io->hw_tag,\
0025 io->tgt_io.tmf, ##__VA_ARGS__)
0026
0027 #define efct_set_lio_io_state(io, value) (io->tgt_io.state |= value)
0028
0029 struct efct_lio_wq_data {
0030 struct efct *efct;
0031 void *ptr;
0032 struct work_struct work;
0033 };
0034
0035
0036 struct efct_scsi_tgt {
0037 u32 max_sge;
0038 u32 max_sgl;
0039
0040
0041
0042
0043
0044
0045
0046 atomic_t initiator_count;
0047 atomic_t ios_in_use;
0048 atomic_t io_high_watermark;
0049
0050 atomic_t watermark_hit;
0051 int watermark_min;
0052 int watermark_max;
0053
0054 struct efct_lio_nport *lio_nport;
0055 struct efct_lio_tpg *tpg;
0056
0057 struct list_head vport_list;
0058
0059 spinlock_t efct_lio_lock;
0060
0061 u64 wwnn;
0062 };
0063
0064 struct efct_scsi_tgt_nport {
0065 struct efct_lio_nport *lio_nport;
0066 };
0067
0068 struct efct_node {
0069 struct list_head list_entry;
0070 struct kref ref;
0071 void (*release)(struct kref *arg);
0072 struct efct *efct;
0073 struct efc_node *node;
0074 struct se_session *session;
0075 spinlock_t active_ios_lock;
0076 struct list_head active_ios;
0077 char display_name[EFC_NAME_LENGTH];
0078 u32 port_fc_id;
0079 u32 node_fc_id;
0080 u32 vpi;
0081 u32 rpi;
0082 u32 abort_cnt;
0083 };
0084
0085 #define EFCT_LIO_STATE_SCSI_RECV_CMD (1 << 0)
0086 #define EFCT_LIO_STATE_TGT_SUBMIT_CMD (1 << 1)
0087 #define EFCT_LIO_STATE_TFO_QUEUE_DATA_IN (1 << 2)
0088 #define EFCT_LIO_STATE_TFO_WRITE_PENDING (1 << 3)
0089 #define EFCT_LIO_STATE_TGT_EXECUTE_CMD (1 << 4)
0090 #define EFCT_LIO_STATE_SCSI_SEND_RD_DATA (1 << 5)
0091 #define EFCT_LIO_STATE_TFO_CHK_STOP_FREE (1 << 6)
0092 #define EFCT_LIO_STATE_SCSI_DATA_DONE (1 << 7)
0093 #define EFCT_LIO_STATE_TFO_QUEUE_STATUS (1 << 8)
0094 #define EFCT_LIO_STATE_SCSI_SEND_RSP (1 << 9)
0095 #define EFCT_LIO_STATE_SCSI_RSP_DONE (1 << 10)
0096 #define EFCT_LIO_STATE_TGT_GENERIC_FREE (1 << 11)
0097 #define EFCT_LIO_STATE_SCSI_RECV_TMF (1 << 12)
0098 #define EFCT_LIO_STATE_TGT_SUBMIT_TMR (1 << 13)
0099 #define EFCT_LIO_STATE_TFO_WRITE_PEND_STATUS (1 << 14)
0100 #define EFCT_LIO_STATE_TGT_GENERIC_REQ_FAILURE (1 << 15)
0101
0102 #define EFCT_LIO_STATE_TFO_ABORTED_TASK (1 << 29)
0103 #define EFCT_LIO_STATE_TFO_RELEASE_CMD (1 << 30)
0104 #define EFCT_LIO_STATE_SCSI_CMPL_CMD (1u << 31)
0105
0106 struct efct_scsi_tgt_io {
0107 struct se_cmd cmd;
0108 unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER];
0109 enum dma_data_direction ddir;
0110 int task_attr;
0111 u64 lun;
0112
0113 u32 state;
0114 u8 tmf;
0115 struct efct_io *io_to_abort;
0116 u32 seg_map_cnt;
0117 u32 seg_cnt;
0118 u32 cur_seg;
0119 enum efct_scsi_io_status err;
0120 bool aborting;
0121 bool rsp_sent;
0122 u32 transferred_len;
0123 };
0124
0125
0126 enum {
0127 SCSI_HANDLER_DATAPHASE_STARTED = 1,
0128 SCSI_HANDLER_RESP_STARTED,
0129 SCSI_HANDLER_VALIDATED_DATAPHASE_STARTED,
0130 SCSI_CMD_NOT_SUPPORTED,
0131 };
0132
0133 #define WWN_NAME_LEN 32
0134 struct efct_lio_vport {
0135 u64 wwpn;
0136 u64 npiv_wwpn;
0137 u64 npiv_wwnn;
0138 unsigned char wwpn_str[WWN_NAME_LEN];
0139 struct se_wwn vport_wwn;
0140 struct efct_lio_tpg *tpg;
0141 struct efct *efct;
0142 struct Scsi_Host *shost;
0143 struct fc_vport *fc_vport;
0144 atomic_t enable;
0145 };
0146
0147 struct efct_lio_nport {
0148 u64 wwpn;
0149 unsigned char wwpn_str[WWN_NAME_LEN];
0150 struct se_wwn nport_wwn;
0151 struct efct_lio_tpg *tpg;
0152 struct efct *efct;
0153 atomic_t enable;
0154 };
0155
0156 struct efct_lio_tpg_attrib {
0157 u32 generate_node_acls;
0158 u32 cache_dynamic_acls;
0159 u32 demo_mode_write_protect;
0160 u32 prod_mode_write_protect;
0161 u32 demo_mode_login_only;
0162 bool session_deletion_wait;
0163 };
0164
0165 struct efct_lio_tpg {
0166 struct se_portal_group tpg;
0167 struct efct_lio_nport *nport;
0168 struct efct_lio_vport *vport;
0169 struct efct_lio_tpg_attrib tpg_attrib;
0170 unsigned short tpgt;
0171 bool enabled;
0172 };
0173
0174 struct efct_lio_nacl {
0175 u64 nport_wwnn;
0176 char nport_name[WWN_NAME_LEN];
0177 struct se_session *session;
0178 struct se_node_acl se_node_acl;
0179 };
0180
0181 struct efct_lio_vport_list_t {
0182 struct list_head list_entry;
0183 struct efct_lio_vport *lio_vport;
0184 };
0185
0186 int efct_scsi_tgt_driver_init(void);
0187 int efct_scsi_tgt_driver_exit(void);
0188
0189 #endif