📄 iscsi_initiator.h
字号:
/* one of these structures for each initiator session */struct session { struct list_head link; /* for threaded-list of sessions */ UNH_LOCK_TYPE sess_lock; /* spin lock for each session */ /* the following fields are used to store free command structures */ struct list_head free_commands; __u16 n_commands_alloced; /* no. of commands alloced to session */ __u16 n_luns_in_session; /* no. of active luns in session */ /* the following field is used to store free r2t cookies */ struct list_head free_r2t_cookies; __u32 scsi_target_id; /* target in [host,bus,target,lun] */ __u32 lun_bits; /* bits for lun in [host,bus,target,lun] */ __u32 session_state; /* SESSION_NOT_PRESENT, ... */ __u32 cur_task_tag; /* generator for unique ITTs */ __u32 cur_cmd_sn; /* generator for sequential CmdSNs */ __u32 exp_cmd_sn; /* last ExpCmdSN from target */ __u32 max_cmd_sn; /* last MaxCmdSN from target */ struct timer_list connrec_timer; /* Time2wait timer - SAI */ /* the following fields are initialized from configured hostdata */ __u32 session_flags; /* flags for session-wide control (none yet) */ __u32 init_conn_flags; /* initial connection-specific flags */ __u32 nop_period; /* no. of secs between sending NopOuts */ __u32 init_snack_flag; /* Store SNACK Related flags here - SAI */ int retran_period; /* retransmission threshold in sec - SAI */ int sched_scheme; /* connection scheduling scheme to use - SAI */ struct parameter_type (*session_params)[MAX_CONFIG_PARAMS];#ifdef ISCSI_STATS struct proc_dir_entry *proc_dir; /* Proc dir entry */ struct iscsi_session_stats *sess_stats; /* per session Stats */#endif /* the following 2 fields are manipulated by add_(remove_)session only*/ __u32 nconnections; /* no. of connections in next list */ struct connection *connection_head;/* list of connections in this sess*/ struct connection *rr_conn_head; /* round robin connection head SAI */ /* the following field is allocated late */ struct session_operational_parameters *oper_param; /* the following field is returned by target if first login succeeds */ __u16 tsih; /* target's handle for this session */ int n_rec_tasks; /* stores no. of tasks that were transfered from * a failing connection - SAI */ /* the following table is used only for CONN_SCHED_LUN scheduling */ /* index by LUN to find assigned connection */ struct connection *lun_assignments[MAX_LUNS]; /* the following 2 arrays are used to keep track of inquiry data */ /* index by LUN to get latest inquiry info */ char *inquiry_buf[MAX_LUNS]; /* buffer to hold inquiry data */ int inquiry_size[MAX_LUNS]; /* no of bytes alloced to inquiry_buf */ /* the following 2 arrays are used to keep track of read capacity data*/ /* index by LUN to get latest read capacity info */ __u32 capacity_lba[MAX_LUNS]; /* returned logical block address */ __u32 capacity_len[MAX_LUNS]; /* block length in bytes */ /* the following 2 arrays are used to keep track of block limits data */ /* index by LUN to get latest block limits info */ __u32 limit_max[MAX_LUNS]; /* max block length limit */ __u32 limit_min[MAX_LUNS]; /* min block length limit */};/* Target specific configuration data */struct iscsi_targetdata { __u32 nop_period; /* timer value to force NopOuts */ __u32 init_sess_flags; /* initial session-wide flags */ __u32 init_conn_flags; /* initial connection-specific flags */ __u8 init_snack_flag; /* holds SNACK related flags - SAI */ __u32 isid_type; /* holds isid type, max of 0x03 */ __u32 isid_number; /* holds isid number, max of 0xffffff */ __u32 isid_qualifier; /* holds isid qualifier, max of 0xffffff */ int retran_period; /* holds rexmit threshold in sec SAI */ int sched_scheme; /* holds scheduling algorithm to use with multiple connections - SAI */ /* chap support -CHONG */ struct auth_parameter_type auth_parameter; struct parameter_type param_tbl[MAX_CONFIG_PARAMS];};/* One of these structures forms the private data part for each * iscsi adaptor. Since we have only 1 such adaptor, we will * instantiate this structure only once, when the iscsi_initiator * module is first loaded. At that time the variable global_hostdata * will be set to point to the instantiation, and the fields will be * set up to the defaults (all 0 except for param_tbl, which gets a copy * of config_params[]). After that, whenever the user changes parameter * values using iscsi_manage, those changes are made to the values in this * structure. */struct iscsi_hostdata { __u32 nsessions; /* no. of targets/sessions so far */ struct list_head session_list; /* list of threaded struct sessions */ /* recovery session list - SAI */ struct sess_rec_group *sess_rec_head; int init_sessrec_flg; /* 1 if sess recovery in progress SAI */ /* puts scsi to sleep in sess recovery - SAI */ struct semaphore init_sessrec_sem; struct iscsi_targetdata target_data[MAX_TARGET_IDS];#ifdef K26 /* for 2.6.0 hot-plug HBA model */ struct list_head host_list; struct device dev; struct Scsi_Host *shost;#endif#ifdef ISCSI_STATS struct iscsi_instance_stats instance_stats; /* Login statistics */#endif};/* Add the Error Recovery Structure - SAI */struct init_error_rec { struct connection *curr_conn; struct command *related_cmd; __u8 err_type;};/*******************************************************************//* the following functions are defined in initiator_proc_ioface.c *//*******************************************************************//* Ming Zhang, mingz@ele.uri.edu */#ifdef K26int iscsi_initiator_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);#elseint iscsi_initiator_proc_info(char *, char **, off_t, int, int, int);#endif/**********************************************************//* the following functions are defined in initiator_rx.c *//**********************************************************/void iscsi_initiator_rx_thread(void *arg);/**********************************************************//* the following functions are defined in initiator_tx.c *//**********************************************************//* Called to send a NopOut to target as: * a new nop (nopin_cmd == NULL, size == 0 ) * or * a new ping (nopin_cmd == NULL, size != 0 ) * or * a response to a NopIn (nopin_cmd != NULL). * Buffer points to data to send, size is number of bytes of data to send. * If size > 0 then better have buffer != NULL. * Returns 1 if all ok, else 0. */int tx_nopout(struct connection *current_connection, __u32 i_bit, struct iscsi_targ_nopin *nopin_cmd, char **buffer, int size);/* drives sending of a nop out to the target */int drive_nopout(struct connection *conn, struct session *current_session, __u32 i_bit, __u32 want_data);/* drives the discovery session from within the tx_thread * returns 0 on success, 1 on failure */int drive_text_negotiate(struct connection *conn, struct session *current_session, __u32 i_bit, __u32 discovery);/* drives the logout of a session from within the tx_thread * returns 1 on success, 0 on failure * Modified to include connection logout - SAI */int drive_logout(struct session *current_session, struct connection *conn, int reason);void iscsi_initiator_tx_thread(void *);/************************************************************* * the following functions are defined in iscsi_initiator.c * *************************************************************//* initialize all fields in struct iscsi_targetdata for one target */void init_targetdata(struct iscsi_targetdata *targ_data);/* find a lun that is already in use in this session * returns -1 on error, else lun number in range [0..31] */intfind_used_lun(struct session *sess);/* uninitialize fields in struct iscsi_targetdata that need freeing */void uninit_targetdata(struct iscsi_targetdata *targ_data);/* Create a new recovery connection to keep the iSCSI session active. * Remember, iscsi requires at least one connection in a session to be active * for the session to be alive - SAI * Returns 1 on success, 0 on failure. */intcreate_rec_conn(struct connection *conn);void __attribute__ ((no_instrument_function))clear_free_conn(struct session *sess);/* Declaration needed as this function used by Error Recovery - SAI */struct connection * __attribute__ ((no_instrument_function))get_connection(struct scsi_cmnd * Cmnd, struct session *current_session);int create_session(__u32 target, struct sockaddr *ip_address, int ip_length, __u32 lun, __u32 cid, struct Scsi_Host *host);int remove_session_from_hostdata(__u32 target, __u32 lun, __u32 cid, struct iscsi_hostdata *hostdata);int find_connection(__u32 target, __u32 cid, struct iscsi_hostdata *hostdata, struct connection **old_connection, struct session **old_session);/* Mike Christie, mikenc@us.ibm.com * * remove all valid luns in session (last lun will take out session) * returns smallest lun number removed, -1 if none removed. */intremove_luns(struct session *sess, struct Scsi_Host *host, struct iscsi_hostdata *hostdata);/* SAI */int scsi_to_iscsi(struct scsi_cmnd * Cmnd, struct session *current_session);#ifdef CONFIG_ISCSI_DEBUGint __get_cpu_number(void);#endif/* From iscsi_device.c */extern int initiator_register_device(void);extern void initiator_unregister_device(void);#ifdef K26static inline int __attribute__ ((no_instrument_function))use_sendpage(struct connection *conn, struct command *cmnd){ if (!(conn->connection_flags & USE_DATADIGEST) && cmnd->SCpnt != NULL && cmnd->SCpnt->use_sg > 0) return 1; else return 0;}#endif#if !defined(list_for_each_entry)/* include/linux/list.h is out of date *//** * list_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop counter. * @head: the head for your list. * @member: the name of the list_struct within the struct. */#define list_for_each_entry(pos, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member), \ prefetch(pos->member.next); \ &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member), \ prefetch(pos->member.next))#endif/* searches the session_list pointed to by hostdata to try to find * a session with id that matches target_id * Returns pointer to that session if found, NULL if not found */static inline struct session * __attribute__ ((no_instrument_function))find_session_by_id(__u32 target_id, struct iscsi_hostdata *hostdata){ struct session * sess; list_for_each_entry(sess, &hostdata->session_list, link) { if (sess->scsi_target_id == target_id) { return sess; } } /* if loop finishes, no session with this id was found */ return NULL;}#endif /* _ISCSI_INITIATOR_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -