Path: blob/master/include/target/target_core_base.h
10814 views
#ifndef TARGET_CORE_BASE_H1#define TARGET_CORE_BASE_H23#include <linux/in.h>4#include <linux/configfs.h>5#include <linux/dma-mapping.h>6#include <linux/blkdev.h>7#include <scsi/scsi_cmnd.h>8#include <net/sock.h>9#include <net/tcp.h>1011#define TARGET_CORE_MOD_VERSION "v4.0.0-rc7-ml"12#define SHUTDOWN_SIGS (sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGABRT))1314/* Used by transport_generic_allocate_iovecs() */15#define TRANSPORT_IOV_DATA_BUFFER 516/* Maximum Number of LUNs per Target Portal Group */17#define TRANSPORT_MAX_LUNS_PER_TPG 25618/*19* By default we use 32-byte CDBs in TCM Core and subsystem plugin code.20*21* Note that both include/scsi/scsi_cmnd.h:MAX_COMMAND_SIZE and22* include/linux/blkdev.h:BLOCK_MAX_CDB as of v2.6.36-rc4 still use23* 16-byte CDBs by default and require an extra allocation for24* 32-byte CDBs to because of legacy issues.25*26* Within TCM Core there are no such legacy limitiations, so we go ahead27* use 32-byte CDBs by default and use include/scsi/scsi.h:scsi_command_size()28* within all TCM Core and subsystem plugin code.29*/30#define TCM_MAX_COMMAND_SIZE 3231/*32* From include/scsi/scsi_cmnd.h:SCSI_SENSE_BUFFERSIZE, currently33* defined 96, but the real limit is 252 (or 260 including the header)34*/35#define TRANSPORT_SENSE_BUFFER SCSI_SENSE_BUFFERSIZE36/* Used by transport_send_check_condition_and_sense() */37#define SPC_SENSE_KEY_OFFSET 238#define SPC_ASC_KEY_OFFSET 1239#define SPC_ASCQ_KEY_OFFSET 1340#define TRANSPORT_IQN_LEN 22441/* Used by target_core_store_alua_lu_gp() and target_core_alua_lu_gp_show_attr_members() */42#define LU_GROUP_NAME_BUF 25643/* Used by core_alua_store_tg_pt_gp_info() and target_core_alua_tg_pt_gp_show_attr_members() */44#define TG_PT_GROUP_NAME_BUF 25645/* Used to parse VPD into struct t10_vpd */46#define VPD_TMP_BUF_SIZE 12847/* Used by transport_generic_cmd_sequencer() */48#define READ_BLOCK_LEN 649#define READ_CAP_LEN 850#define READ_POSITION_LEN 2051#define INQUIRY_LEN 3652/* Used by transport_get_inquiry_vpd_serial() */53#define INQUIRY_VPD_SERIAL_LEN 25454/* Used by transport_get_inquiry_vpd_device_ident() */55#define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 2545657/* struct se_hba->hba_flags */58enum hba_flags_table {59HBA_FLAGS_INTERNAL_USE = 0x01,60HBA_FLAGS_PSCSI_MODE = 0x02,61};6263/* struct se_lun->lun_status */64enum transport_lun_status_table {65TRANSPORT_LUN_STATUS_FREE = 0,66TRANSPORT_LUN_STATUS_ACTIVE = 1,67};6869/* struct se_portal_group->se_tpg_type */70enum transport_tpg_type_table {71TRANSPORT_TPG_TYPE_NORMAL = 0,72TRANSPORT_TPG_TYPE_DISCOVERY = 1,73};7475/* Used for generate timer flags */76enum timer_flags_table {77TF_RUNNING = 0x01,78TF_STOP = 0x02,79};8081/* Special transport agnostic struct se_cmd->t_states */82enum transport_state_table {83TRANSPORT_NO_STATE = 0,84TRANSPORT_NEW_CMD = 1,85TRANSPORT_DEFERRED_CMD = 2,86TRANSPORT_WRITE_PENDING = 3,87TRANSPORT_PROCESS_WRITE = 4,88TRANSPORT_PROCESSING = 5,89TRANSPORT_COMPLETE_OK = 6,90TRANSPORT_COMPLETE_FAILURE = 7,91TRANSPORT_COMPLETE_TIMEOUT = 8,92TRANSPORT_PROCESS_TMR = 9,93TRANSPORT_TMR_COMPLETE = 10,94TRANSPORT_ISTATE_PROCESSING = 11,95TRANSPORT_ISTATE_PROCESSED = 12,96TRANSPORT_KILL = 13,97TRANSPORT_REMOVE = 14,98TRANSPORT_FREE = 15,99TRANSPORT_NEW_CMD_MAP = 16,100TRANSPORT_FREE_CMD_INTR = 17,101};102103/* Used for struct se_cmd->se_cmd_flags */104enum se_cmd_flags_table {105SCF_SUPPORTED_SAM_OPCODE = 0x00000001,106SCF_TRANSPORT_TASK_SENSE = 0x00000002,107SCF_EMULATED_TASK_SENSE = 0x00000004,108SCF_SCSI_DATA_SG_IO_CDB = 0x00000008,109SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010,110SCF_SCSI_CONTROL_NONSG_IO_CDB = 0x00000020,111SCF_SCSI_NON_DATA_CDB = 0x00000040,112SCF_SCSI_CDB_EXCEPTION = 0x00000080,113SCF_SCSI_RESERVATION_CONFLICT = 0x00000100,114SCF_CMD_PASSTHROUGH_NOALLOC = 0x00000200,115SCF_SE_CMD_FAILED = 0x00000400,116SCF_SE_LUN_CMD = 0x00000800,117SCF_SE_ALLOW_EOO = 0x00001000,118SCF_SE_DISABLE_ONLINE_CHECK = 0x00002000,119SCF_SENT_CHECK_CONDITION = 0x00004000,120SCF_OVERFLOW_BIT = 0x00008000,121SCF_UNDERFLOW_BIT = 0x00010000,122SCF_SENT_DELAYED_TAS = 0x00020000,123SCF_ALUA_NON_OPTIMIZED = 0x00040000,124SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000,125SCF_PASSTHROUGH_SG_TO_MEM = 0x00100000,126SCF_PASSTHROUGH_CONTIG_TO_SG = 0x00200000,127SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00400000,128SCF_EMULATE_SYNC_CACHE = 0x00800000,129SCF_EMULATE_CDB_ASYNC = 0x01000000,130SCF_EMULATE_SYNC_UNMAP = 0x02000000131};132133/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */134enum transport_lunflags_table {135TRANSPORT_LUNFLAGS_NO_ACCESS = 0x00,136TRANSPORT_LUNFLAGS_INITIATOR_ACCESS = 0x01,137TRANSPORT_LUNFLAGS_READ_ONLY = 0x02,138TRANSPORT_LUNFLAGS_READ_WRITE = 0x04,139};140141/* struct se_device->dev_status */142enum transport_device_status_table {143TRANSPORT_DEVICE_ACTIVATED = 0x01,144TRANSPORT_DEVICE_DEACTIVATED = 0x02,145TRANSPORT_DEVICE_QUEUE_FULL = 0x04,146TRANSPORT_DEVICE_SHUTDOWN = 0x08,147TRANSPORT_DEVICE_OFFLINE_ACTIVATED = 0x10,148TRANSPORT_DEVICE_OFFLINE_DEACTIVATED = 0x20,149};150151/*152* Used by transport_send_check_condition_and_sense() and se_cmd->scsi_sense_reason153* to signal which ASC/ASCQ sense payload should be built.154*/155enum tcm_sense_reason_table {156TCM_NON_EXISTENT_LUN = 0x01,157TCM_UNSUPPORTED_SCSI_OPCODE = 0x02,158TCM_INCORRECT_AMOUNT_OF_DATA = 0x03,159TCM_UNEXPECTED_UNSOLICITED_DATA = 0x04,160TCM_SERVICE_CRC_ERROR = 0x05,161TCM_SNACK_REJECTED = 0x06,162TCM_SECTOR_COUNT_TOO_MANY = 0x07,163TCM_INVALID_CDB_FIELD = 0x08,164TCM_INVALID_PARAMETER_LIST = 0x09,165TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE = 0x0a,166TCM_UNKNOWN_MODE_PAGE = 0x0b,167TCM_WRITE_PROTECTED = 0x0c,168TCM_CHECK_CONDITION_ABORT_CMD = 0x0d,169TCM_CHECK_CONDITION_UNIT_ATTENTION = 0x0e,170TCM_CHECK_CONDITION_NOT_READY = 0x0f,171};172173struct se_obj {174atomic_t obj_access_count;175} ____cacheline_aligned;176177/*178* Used by TCM Core internally to signal if ALUA emulation is enabled or179* disabled, or running in with TCM/pSCSI passthrough mode180*/181typedef enum {182SPC_ALUA_PASSTHROUGH,183SPC2_ALUA_DISABLED,184SPC3_ALUA_EMULATED185} t10_alua_index_t;186187/*188* Used by TCM Core internally to signal if SAM Task Attribute emulation189* is enabled or disabled, or running in with TCM/pSCSI passthrough mode190*/191typedef enum {192SAM_TASK_ATTR_PASSTHROUGH,193SAM_TASK_ATTR_UNTAGGED,194SAM_TASK_ATTR_EMULATED195} t10_task_attr_index_t;196197/*198* Used for target SCSI statistics199*/200typedef enum {201SCSI_INST_INDEX,202SCSI_DEVICE_INDEX,203SCSI_AUTH_INTR_INDEX,204SCSI_INDEX_TYPE_MAX205} scsi_index_t;206207struct scsi_index_table {208spinlock_t lock;209u32 scsi_mib_index[SCSI_INDEX_TYPE_MAX];210} ____cacheline_aligned;211212struct se_cmd;213214struct t10_alua {215t10_alua_index_t alua_type;216/* ALUA Target Port Group ID */217u16 alua_tg_pt_gps_counter;218u32 alua_tg_pt_gps_count;219spinlock_t tg_pt_gps_lock;220struct se_subsystem_dev *t10_sub_dev;221/* Used for default ALUA Target Port Group */222struct t10_alua_tg_pt_gp *default_tg_pt_gp;223/* Used for default ALUA Target Port Group ConfigFS group */224struct config_group alua_tg_pt_gps_group;225int (*alua_state_check)(struct se_cmd *, unsigned char *, u8 *);226struct list_head tg_pt_gps_list;227} ____cacheline_aligned;228229struct t10_alua_lu_gp {230u16 lu_gp_id;231int lu_gp_valid_id;232u32 lu_gp_members;233atomic_t lu_gp_shutdown;234atomic_t lu_gp_ref_cnt;235spinlock_t lu_gp_lock;236struct config_group lu_gp_group;237struct list_head lu_gp_list;238struct list_head lu_gp_mem_list;239} ____cacheline_aligned;240241struct t10_alua_lu_gp_member {242bool lu_gp_assoc;243atomic_t lu_gp_mem_ref_cnt;244spinlock_t lu_gp_mem_lock;245struct t10_alua_lu_gp *lu_gp;246struct se_device *lu_gp_mem_dev;247struct list_head lu_gp_mem_list;248} ____cacheline_aligned;249250struct t10_alua_tg_pt_gp {251u16 tg_pt_gp_id;252int tg_pt_gp_valid_id;253int tg_pt_gp_alua_access_status;254int tg_pt_gp_alua_access_type;255int tg_pt_gp_nonop_delay_msecs;256int tg_pt_gp_trans_delay_msecs;257int tg_pt_gp_pref;258int tg_pt_gp_write_metadata;259/* Used by struct t10_alua_tg_pt_gp->tg_pt_gp_md_buf_len */260#define ALUA_MD_BUF_LEN 1024261u32 tg_pt_gp_md_buf_len;262u32 tg_pt_gp_members;263atomic_t tg_pt_gp_alua_access_state;264atomic_t tg_pt_gp_ref_cnt;265spinlock_t tg_pt_gp_lock;266struct mutex tg_pt_gp_md_mutex;267struct se_subsystem_dev *tg_pt_gp_su_dev;268struct config_group tg_pt_gp_group;269struct list_head tg_pt_gp_list;270struct list_head tg_pt_gp_mem_list;271} ____cacheline_aligned;272273struct t10_alua_tg_pt_gp_member {274bool tg_pt_gp_assoc;275atomic_t tg_pt_gp_mem_ref_cnt;276spinlock_t tg_pt_gp_mem_lock;277struct t10_alua_tg_pt_gp *tg_pt_gp;278struct se_port *tg_pt;279struct list_head tg_pt_gp_mem_list;280} ____cacheline_aligned;281282struct t10_vpd {283unsigned char device_identifier[INQUIRY_VPD_DEVICE_IDENTIFIER_LEN];284int protocol_identifier_set;285u32 protocol_identifier;286u32 device_identifier_code_set;287u32 association;288u32 device_identifier_type;289struct list_head vpd_list;290} ____cacheline_aligned;291292struct t10_wwn {293unsigned char vendor[8];294unsigned char model[16];295unsigned char revision[4];296unsigned char unit_serial[INQUIRY_VPD_SERIAL_LEN];297spinlock_t t10_vpd_lock;298struct se_subsystem_dev *t10_sub_dev;299struct config_group t10_wwn_group;300struct list_head t10_vpd_list;301} ____cacheline_aligned;302303304/*305* Used by TCM Core internally to signal if >= SPC-3 persistent reservations306* emulation is enabled or disabled, or running in with TCM/pSCSI passthrough307* mode308*/309typedef enum {310SPC_PASSTHROUGH,311SPC2_RESERVATIONS,312SPC3_PERSISTENT_RESERVATIONS313} t10_reservations_index_t;314315struct t10_pr_registration {316/* Used for fabrics that contain WWN+ISID */317#define PR_REG_ISID_LEN 16318/* PR_REG_ISID_LEN + ',i,0x' */319#define PR_REG_ISID_ID_LEN (PR_REG_ISID_LEN + 5)320char pr_reg_isid[PR_REG_ISID_LEN];321/* Used during APTPL metadata reading */322#define PR_APTPL_MAX_IPORT_LEN 256323unsigned char pr_iport[PR_APTPL_MAX_IPORT_LEN];324/* Used during APTPL metadata reading */325#define PR_APTPL_MAX_TPORT_LEN 256326unsigned char pr_tport[PR_APTPL_MAX_TPORT_LEN];327/* For writing out live meta data */328unsigned char *pr_aptpl_buf;329u16 pr_aptpl_rpti;330u16 pr_reg_tpgt;331/* Reservation effects all target ports */332int pr_reg_all_tg_pt;333/* Activate Persistence across Target Power Loss */334int pr_reg_aptpl;335int pr_res_holder;336int pr_res_type;337int pr_res_scope;338/* Used for fabric initiator WWPNs using a ISID */339bool isid_present_at_reg;340u32 pr_res_mapped_lun;341u32 pr_aptpl_target_lun;342u32 pr_res_generation;343u64 pr_reg_bin_isid;344u64 pr_res_key;345atomic_t pr_res_holders;346struct se_node_acl *pr_reg_nacl;347struct se_dev_entry *pr_reg_deve;348struct se_lun *pr_reg_tg_pt_lun;349struct list_head pr_reg_list;350struct list_head pr_reg_abort_list;351struct list_head pr_reg_aptpl_list;352struct list_head pr_reg_atp_list;353struct list_head pr_reg_atp_mem_list;354} ____cacheline_aligned;355356/*357* This set of function pointer ops is set based upon SPC3_PERSISTENT_RESERVATIONS,358* SPC2_RESERVATIONS or SPC_PASSTHROUGH in drivers/target/target_core_pr.c:359* core_setup_reservations()360*/361struct t10_reservation_ops {362int (*t10_reservation_check)(struct se_cmd *, u32 *);363int (*t10_seq_non_holder)(struct se_cmd *, unsigned char *, u32);364int (*t10_pr_register)(struct se_cmd *);365int (*t10_pr_clear)(struct se_cmd *);366};367368struct t10_reservation_template {369/* Reservation effects all target ports */370int pr_all_tg_pt;371/* Activate Persistence across Target Power Loss enabled372* for SCSI device */373int pr_aptpl_active;374/* Used by struct t10_reservation_template->pr_aptpl_buf_len */375#define PR_APTPL_BUF_LEN 8192376u32 pr_aptpl_buf_len;377u32 pr_generation;378t10_reservations_index_t res_type;379spinlock_t registration_lock;380spinlock_t aptpl_reg_lock;381/*382* This will always be set by one individual I_T Nexus.383* However with all_tg_pt=1, other I_T Nexus from the384* same initiator can access PR reg/res info on a different385* target port.386*387* There is also the 'All Registrants' case, where there is388* a single *pr_res_holder of the reservation, but all389* registrations are considered reservation holders.390*/391struct se_node_acl *pr_res_holder;392struct list_head registration_list;393struct list_head aptpl_reg_list;394struct t10_reservation_ops pr_ops;395} ____cacheline_aligned;396397struct se_queue_req {398int state;399void *cmd;400struct list_head qr_list;401} ____cacheline_aligned;402403struct se_queue_obj {404atomic_t queue_cnt;405spinlock_t cmd_queue_lock;406struct list_head qobj_list;407wait_queue_head_t thread_wq;408} ____cacheline_aligned;409410/*411* Used one per struct se_cmd to hold all extra struct se_task412* metadata. This structure is setup and allocated in413* drivers/target/target_core_transport.c:__transport_alloc_se_cmd()414*/415struct se_transport_task {416unsigned char *t_task_cdb;417unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];418unsigned long long t_task_lba;419int t_tasks_failed;420int t_tasks_fua;421bool t_tasks_bidi;422u32 t_task_cdbs;423u32 t_tasks_check;424u32 t_tasks_no;425u32 t_tasks_sectors;426u32 t_tasks_se_num;427u32 t_tasks_se_bidi_num;428u32 t_tasks_sg_chained_no;429atomic_t t_fe_count;430atomic_t t_se_count;431atomic_t t_task_cdbs_left;432atomic_t t_task_cdbs_ex_left;433atomic_t t_task_cdbs_timeout_left;434atomic_t t_task_cdbs_sent;435atomic_t t_transport_aborted;436atomic_t t_transport_active;437atomic_t t_transport_complete;438atomic_t t_transport_queue_active;439atomic_t t_transport_sent;440atomic_t t_transport_stop;441atomic_t t_transport_timeout;442atomic_t transport_dev_active;443atomic_t transport_lun_active;444atomic_t transport_lun_fe_stop;445atomic_t transport_lun_stop;446spinlock_t t_state_lock;447struct completion t_transport_stop_comp;448struct completion transport_lun_fe_stop_comp;449struct completion transport_lun_stop_comp;450struct scatterlist *t_tasks_sg_chained;451struct scatterlist t_tasks_sg_bounce;452void *t_task_buf;453/*454* Used for pre-registered fabric SGL passthrough WRITE and READ455* with the special SCF_PASSTHROUGH_CONTIG_TO_SG case for TCM_Loop456* and other HW target mode fabric modules.457*/458struct scatterlist *t_task_pt_sgl;459struct list_head *t_mem_list;460/* Used for BIDI READ */461struct list_head *t_mem_bidi_list;462struct list_head t_task_list;463} ____cacheline_aligned;464465struct se_task {466unsigned char task_sense;467struct scatterlist *task_sg;468struct scatterlist *task_sg_bidi;469u8 task_scsi_status;470u8 task_flags;471int task_error_status;472int task_state_flags;473bool task_padded_sg;474unsigned long long task_lba;475u32 task_no;476u32 task_sectors;477u32 task_size;478u32 task_sg_num;479u32 task_sg_offset;480enum dma_data_direction task_data_direction;481struct se_cmd *task_se_cmd;482struct se_device *se_dev;483struct completion task_stop_comp;484atomic_t task_active;485atomic_t task_execute_queue;486atomic_t task_timeout;487atomic_t task_sent;488atomic_t task_stop;489atomic_t task_state_active;490struct timer_list task_timer;491struct se_device *se_obj_ptr;492struct list_head t_list;493struct list_head t_execute_list;494struct list_head t_state_list;495} ____cacheline_aligned;496497#define TASK_CMD(task) ((task)->task_se_cmd)498#define TASK_DEV(task) ((task)->se_dev)499500struct se_cmd {501/* SAM response code being sent to initiator */502u8 scsi_status;503u8 scsi_asc;504u8 scsi_ascq;505u8 scsi_sense_reason;506u16 scsi_sense_length;507/* Delay for ALUA Active/NonOptimized state access in milliseconds */508int alua_nonop_delay;509/* See include/linux/dma-mapping.h */510enum dma_data_direction data_direction;511/* For SAM Task Attribute */512int sam_task_attr;513/* Transport protocol dependent state, see transport_state_table */514enum transport_state_table t_state;515/* Transport protocol dependent state for out of order CmdSNs */516int deferred_t_state;517/* Transport specific error status */518int transport_error_status;519/* See se_cmd_flags_table */520u32 se_cmd_flags;521u32 se_ordered_id;522/* Total size in bytes associated with command */523u32 data_length;524/* SCSI Presented Data Transfer Length */525u32 cmd_spdtl;526u32 residual_count;527u32 orig_fe_lun;528/* Persistent Reservation key */529u64 pr_res_key;530atomic_t transport_sent;531/* Used for sense data */532void *sense_buffer;533struct list_head se_delayed_list;534struct list_head se_ordered_list;535struct list_head se_lun_list;536struct se_device *se_dev;537struct se_dev_entry *se_deve;538struct se_device *se_obj_ptr;539struct se_device *se_orig_obj_ptr;540struct se_lun *se_lun;541/* Only used for internal passthrough and legacy TCM fabric modules */542struct se_session *se_sess;543struct se_tmr_req *se_tmr_req;544/* t_task is setup to t_task_backstore in transport_init_se_cmd() */545struct se_transport_task *t_task;546struct se_transport_task t_task_backstore;547struct target_core_fabric_ops *se_tfo;548int (*transport_emulate_cdb)(struct se_cmd *);549void (*transport_split_cdb)(unsigned long long, u32 *, unsigned char *);550void (*transport_wait_for_tasks)(struct se_cmd *, int, int);551void (*transport_complete_callback)(struct se_cmd *);552} ____cacheline_aligned;553554#define T_TASK(cmd) ((cmd)->t_task)555#define CMD_TFO(cmd) ((cmd)->se_tfo)556557struct se_tmr_req {558/* Task Management function to be preformed */559u8 function;560/* Task Management response to send */561u8 response;562int call_transport;563/* Reference to ITT that Task Mgmt should be preformed */564u32 ref_task_tag;565/* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */566u64 ref_task_lun;567void *fabric_tmr_ptr;568struct se_cmd *task_cmd;569struct se_cmd *ref_cmd;570struct se_device *tmr_dev;571struct se_lun *tmr_lun;572struct list_head tmr_list;573} ____cacheline_aligned;574575struct se_ua {576u8 ua_asc;577u8 ua_ascq;578struct se_node_acl *ua_nacl;579struct list_head ua_dev_list;580struct list_head ua_nacl_list;581} ____cacheline_aligned;582583struct se_node_acl {584char initiatorname[TRANSPORT_IQN_LEN];585/* Used to signal demo mode created ACL, disabled by default */586bool dynamic_node_acl;587u32 queue_depth;588u32 acl_index;589u64 num_cmds;590u64 read_bytes;591u64 write_bytes;592spinlock_t stats_lock;593/* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */594atomic_t acl_pr_ref_count;595struct se_dev_entry *device_list;596struct se_session *nacl_sess;597struct se_portal_group *se_tpg;598spinlock_t device_list_lock;599spinlock_t nacl_sess_lock;600struct config_group acl_group;601struct config_group acl_attrib_group;602struct config_group acl_auth_group;603struct config_group acl_param_group;604struct config_group acl_fabric_stat_group;605struct config_group *acl_default_groups[5];606struct list_head acl_list;607struct list_head acl_sess_list;608} ____cacheline_aligned;609610struct se_session {611u64 sess_bin_isid;612struct se_node_acl *se_node_acl;613struct se_portal_group *se_tpg;614void *fabric_sess_ptr;615struct list_head sess_list;616struct list_head sess_acl_list;617} ____cacheline_aligned;618619#define SE_SESS(cmd) ((cmd)->se_sess)620#define SE_NODE_ACL(sess) ((sess)->se_node_acl)621622struct se_device;623struct se_transform_info;624struct scatterlist;625626struct se_ml_stat_grps {627struct config_group stat_group;628struct config_group scsi_auth_intr_group;629struct config_group scsi_att_intr_port_group;630};631632struct se_lun_acl {633char initiatorname[TRANSPORT_IQN_LEN];634u32 mapped_lun;635struct se_node_acl *se_lun_nacl;636struct se_lun *se_lun;637struct list_head lacl_list;638struct config_group se_lun_group;639struct se_ml_stat_grps ml_stat_grps;640} ____cacheline_aligned;641642#define ML_STAT_GRPS(lacl) (&(lacl)->ml_stat_grps)643644struct se_dev_entry {645bool def_pr_registered;646/* See transport_lunflags_table */647u32 lun_flags;648u32 deve_cmds;649u32 mapped_lun;650u32 average_bytes;651u32 last_byte_count;652u32 total_cmds;653u32 total_bytes;654u64 pr_res_key;655u64 creation_time;656u32 attach_count;657u64 read_bytes;658u64 write_bytes;659atomic_t ua_count;660/* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */661atomic_t pr_ref_count;662struct se_lun_acl *se_lun_acl;663spinlock_t ua_lock;664struct se_lun *se_lun;665struct list_head alua_port_list;666struct list_head ua_list;667} ____cacheline_aligned;668669struct se_dev_limits {670/* Max supported HW queue depth */671u32 hw_queue_depth;672/* Max supported virtual queue depth */673u32 queue_depth;674/* From include/linux/blkdev.h for the other HW/SW limits. */675struct queue_limits limits;676} ____cacheline_aligned;677678struct se_dev_attrib {679int emulate_dpo;680int emulate_fua_write;681int emulate_fua_read;682int emulate_write_cache;683int emulate_ua_intlck_ctrl;684int emulate_tas;685int emulate_tpu;686int emulate_tpws;687int emulate_reservations;688int emulate_alua;689int enforce_pr_isids;690u32 hw_block_size;691u32 block_size;692u32 hw_max_sectors;693u32 max_sectors;694u32 optimal_sectors;695u32 hw_queue_depth;696u32 queue_depth;697u32 task_timeout;698u32 max_unmap_lba_count;699u32 max_unmap_block_desc_count;700u32 unmap_granularity;701u32 unmap_granularity_alignment;702struct se_subsystem_dev *da_sub_dev;703struct config_group da_group;704} ____cacheline_aligned;705706struct se_dev_stat_grps {707struct config_group stat_group;708struct config_group scsi_dev_group;709struct config_group scsi_tgt_dev_group;710struct config_group scsi_lu_group;711};712713struct se_subsystem_dev {714/* Used for struct se_subsystem_dev-->se_dev_alias, must be less than PAGE_SIZE */715#define SE_DEV_ALIAS_LEN 512716unsigned char se_dev_alias[SE_DEV_ALIAS_LEN];717/* Used for struct se_subsystem_dev->se_dev_udev_path[], must be less than PAGE_SIZE */718#define SE_UDEV_PATH_LEN 512719unsigned char se_dev_udev_path[SE_UDEV_PATH_LEN];720u32 su_dev_flags;721struct se_hba *se_dev_hba;722struct se_device *se_dev_ptr;723struct se_dev_attrib se_dev_attrib;724/* T10 Asymmetric Logical Unit Assignment for Target Ports */725struct t10_alua t10_alua;726/* T10 Inquiry and VPD WWN Information */727struct t10_wwn t10_wwn;728/* T10 SPC-2 + SPC-3 Reservations */729struct t10_reservation_template t10_reservation;730spinlock_t se_dev_lock;731void *se_dev_su_ptr;732struct list_head g_se_dev_list;733struct config_group se_dev_group;734/* For T10 Reservations */735struct config_group se_dev_pr_group;736/* For target_core_stat.c groups */737struct se_dev_stat_grps dev_stat_grps;738} ____cacheline_aligned;739740#define T10_ALUA(su_dev) (&(su_dev)->t10_alua)741#define T10_RES(su_dev) (&(su_dev)->t10_reservation)742#define T10_PR_OPS(su_dev) (&(su_dev)->t10_reservation.pr_ops)743#define DEV_STAT_GRP(dev) (&(dev)->dev_stat_grps)744745struct se_device {746/* Set to 1 if thread is NOT sleeping on thread_sem */747u8 thread_active;748u8 dev_status_timer_flags;749/* RELATIVE TARGET PORT IDENTIFER Counter */750u16 dev_rpti_counter;751/* Used for SAM Task Attribute ordering */752u32 dev_cur_ordered_id;753u32 dev_flags;754u32 dev_port_count;755/* See transport_device_status_table */756u32 dev_status;757u32 dev_tcq_window_closed;758/* Physical device queue depth */759u32 queue_depth;760/* Used for SPC-2 reservations enforce of ISIDs */761u64 dev_res_bin_isid;762t10_task_attr_index_t dev_task_attr_type;763/* Pointer to transport specific device structure */764void *dev_ptr;765u32 dev_index;766u64 creation_time;767u32 num_resets;768u64 num_cmds;769u64 read_bytes;770u64 write_bytes;771spinlock_t stats_lock;772/* Active commands on this virtual SE device */773atomic_t active_cmds;774atomic_t simple_cmds;775atomic_t depth_left;776atomic_t dev_ordered_id;777atomic_t dev_tur_active;778atomic_t execute_tasks;779atomic_t dev_status_thr_count;780atomic_t dev_hoq_count;781atomic_t dev_ordered_sync;782struct se_obj dev_obj;783struct se_obj dev_access_obj;784struct se_obj dev_export_obj;785struct se_queue_obj *dev_queue_obj;786struct se_queue_obj *dev_status_queue_obj;787spinlock_t delayed_cmd_lock;788spinlock_t ordered_cmd_lock;789spinlock_t execute_task_lock;790spinlock_t state_task_lock;791spinlock_t dev_alua_lock;792spinlock_t dev_reservation_lock;793spinlock_t dev_state_lock;794spinlock_t dev_status_lock;795spinlock_t dev_status_thr_lock;796spinlock_t se_port_lock;797spinlock_t se_tmr_lock;798/* Used for legacy SPC-2 reservationsa */799struct se_node_acl *dev_reserved_node_acl;800/* Used for ALUA Logical Unit Group membership */801struct t10_alua_lu_gp_member *dev_alua_lu_gp_mem;802/* Used for SPC-3 Persistent Reservations */803struct t10_pr_registration *dev_pr_res_holder;804struct list_head dev_sep_list;805struct list_head dev_tmr_list;806struct timer_list dev_status_timer;807/* Pointer to descriptor for processing thread */808struct task_struct *process_thread;809pid_t process_thread_pid;810struct task_struct *dev_mgmt_thread;811struct list_head delayed_cmd_list;812struct list_head ordered_cmd_list;813struct list_head execute_task_list;814struct list_head state_task_list;815/* Pointer to associated SE HBA */816struct se_hba *se_hba;817struct se_subsystem_dev *se_sub_dev;818/* Pointer to template of function pointers for transport */819struct se_subsystem_api *transport;820/* Linked list for struct se_hba struct se_device list */821struct list_head dev_list;822/* Linked list for struct se_global->g_se_dev_list */823struct list_head g_se_dev_list;824} ____cacheline_aligned;825826#define SE_DEV(cmd) ((cmd)->se_lun->lun_se_dev)827#define SU_DEV(dev) ((dev)->se_sub_dev)828#define DEV_ATTRIB(dev) (&(dev)->se_sub_dev->se_dev_attrib)829#define DEV_T10_WWN(dev) (&(dev)->se_sub_dev->t10_wwn)830831struct se_hba {832u16 hba_tpgt;833u32 hba_id;834/* See hba_flags_table */835u32 hba_flags;836/* Virtual iSCSI devices attached. */837u32 dev_count;838u32 hba_index;839atomic_t load_balance_queue;840atomic_t left_queue_depth;841/* Maximum queue depth the HBA can handle. */842atomic_t max_queue_depth;843/* Pointer to transport specific host structure. */844void *hba_ptr;845/* Linked list for struct se_device */846struct list_head hba_dev_list;847struct list_head hba_list;848spinlock_t device_lock;849spinlock_t hba_queue_lock;850struct config_group hba_group;851struct mutex hba_access_mutex;852struct se_subsystem_api *transport;853} ____cacheline_aligned;854855#define SE_HBA(dev) ((dev)->se_hba)856857struct se_port_stat_grps {858struct config_group stat_group;859struct config_group scsi_port_group;860struct config_group scsi_tgt_port_group;861struct config_group scsi_transport_group;862};863864struct se_lun {865/* See transport_lun_status_table */866enum transport_lun_status_table lun_status;867u32 lun_access;868u32 lun_flags;869u32 unpacked_lun;870atomic_t lun_acl_count;871spinlock_t lun_acl_lock;872spinlock_t lun_cmd_lock;873spinlock_t lun_sep_lock;874struct completion lun_shutdown_comp;875struct list_head lun_cmd_list;876struct list_head lun_acl_list;877struct se_device *lun_se_dev;878struct se_port *lun_sep;879struct config_group lun_group;880struct se_port_stat_grps port_stat_grps;881} ____cacheline_aligned;882883#define SE_LUN(cmd) ((cmd)->se_lun)884#define PORT_STAT_GRP(lun) (&(lun)->port_stat_grps)885886struct scsi_port_stats {887u64 cmd_pdus;888u64 tx_data_octets;889u64 rx_data_octets;890} ____cacheline_aligned;891892struct se_port {893/* RELATIVE TARGET PORT IDENTIFER */894u16 sep_rtpi;895int sep_tg_pt_secondary_stat;896int sep_tg_pt_secondary_write_md;897u32 sep_index;898struct scsi_port_stats sep_stats;899/* Used for ALUA Target Port Groups membership */900atomic_t sep_tg_pt_gp_active;901atomic_t sep_tg_pt_secondary_offline;902/* Used for PR ALL_TG_PT=1 */903atomic_t sep_tg_pt_ref_cnt;904spinlock_t sep_alua_lock;905struct mutex sep_tg_pt_md_mutex;906struct t10_alua_tg_pt_gp_member *sep_alua_tg_pt_gp_mem;907struct se_lun *sep_lun;908struct se_portal_group *sep_tpg;909struct list_head sep_alua_list;910struct list_head sep_list;911} ____cacheline_aligned;912913struct se_tpg_np {914struct se_portal_group *tpg_np_parent;915struct config_group tpg_np_group;916} ____cacheline_aligned;917918struct se_portal_group {919/* Type of target portal group, see transport_tpg_type_table */920enum transport_tpg_type_table se_tpg_type;921/* Number of ACLed Initiator Nodes for this TPG */922u32 num_node_acls;923/* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */924atomic_t tpg_pr_ref_count;925/* Spinlock for adding/removing ACLed Nodes */926spinlock_t acl_node_lock;927/* Spinlock for adding/removing sessions */928spinlock_t session_lock;929spinlock_t tpg_lun_lock;930/* Pointer to $FABRIC_MOD portal group */931void *se_tpg_fabric_ptr;932struct list_head se_tpg_list;933/* linked list for initiator ACL list */934struct list_head acl_node_list;935struct se_lun *tpg_lun_list;936struct se_lun tpg_virt_lun0;937/* List of TCM sessions associated wth this TPG */938struct list_head tpg_sess_list;939/* Pointer to $FABRIC_MOD dependent code */940struct target_core_fabric_ops *se_tpg_tfo;941struct se_wwn *se_tpg_wwn;942struct config_group tpg_group;943struct config_group *tpg_default_groups[6];944struct config_group tpg_lun_group;945struct config_group tpg_np_group;946struct config_group tpg_acl_group;947struct config_group tpg_attrib_group;948struct config_group tpg_param_group;949} ____cacheline_aligned;950951#define TPG_TFO(se_tpg) ((se_tpg)->se_tpg_tfo)952953struct se_wwn {954struct target_fabric_configfs *wwn_tf;955struct config_group wwn_group;956struct config_group *wwn_default_groups[2];957struct config_group fabric_stat_group;958} ____cacheline_aligned;959960struct se_global {961u16 alua_lu_gps_counter;962int g_sub_api_initialized;963u32 in_shutdown;964u32 alua_lu_gps_count;965u32 g_hba_id_counter;966struct config_group target_core_hbagroup;967struct config_group alua_group;968struct config_group alua_lu_gps_group;969struct list_head g_lu_gps_list;970struct list_head g_se_tpg_list;971struct list_head g_hba_list;972struct list_head g_se_dev_list;973struct se_hba *g_lun0_hba;974struct se_subsystem_dev *g_lun0_su_dev;975struct se_device *g_lun0_dev;976struct t10_alua_lu_gp *default_lu_gp;977spinlock_t g_device_lock;978spinlock_t hba_lock;979spinlock_t se_tpg_lock;980spinlock_t lu_gps_lock;981spinlock_t plugin_class_lock;982} ____cacheline_aligned;983984#endif /* TARGET_CORE_BASE_H */985986987