📄 iscsi_initiator.h
字号:
*/struct r2t_cookie { struct list_head link; struct list_head order_link; /* order of this r2t on a connection */ __u32 target_xfer_tag; /*opaque -- in network order (from target r2t)*/ __u32 offset; /* SCSI buffer offset of next InOrder Data Out*/ /* but is limit of next Out-of-Order Data Out */ __u32 r2t_xfer_length; /* no. of bytes left to send in r2t sequence */ /* or no. received so far in DataIn sequence */ __u32 data_out_sn; /* incremented from 0 by DataOuts for this r2t*/};struct command { struct list_head link; /* for threaded, doubly-linked circular lists */ __u8 cmd_state; /* state of this cdb/cmd */ __u8 header_opcode; /* copy of opcode when sending a pdu */ __u8 header_flags; /* copy of flags when sending a pdu */ __u8 activity_flg; /* Stores Activity from target for command SAI*/ __u8 need_write_built; /* Create write infrastruct within xmit thread*/ __u8 header_complete; /* ExpStatSN and header CRC have been done */ __u32 init_task_tag; __u32 data_offset; /* offset to next data to receive or r2t */ __u32 recvd_length; /* bytes received so far in DataIn sequence */ __u32 still_to_send; /* total data bytes left to sent in write cmd */ __u32 data_in_sn; /* incremented from 0 by DataIns for this cmd */ __u32 cmd_msg_flags; /* MSG_MORE on writes when more data follows */ struct order_range r2t_range_list; /* for out-of-order r2ts */ struct order_range pdu_range_list; /* for out-of-order DataIn pdu*/ __u32 n_r2t_cookies; /* no. of real (not implied) r2ts outstanding */ __u32 r2t_sn; /* incremented from 0 by r2ts */ void *buffer_to_free; /* free this buffer after xmit (if not NULL) */ __u8 snack_flags; /* Command response and SNACK reject bits SAI */ __u8 cmd_error_state; /* CMD_OK_SO_FAR, ... */ __u8 task_mgt_response; __u8 task_mgt_function; __u32 cmd_error_begrun; /* first missing DataSn to ask for in SNACK */ __u32 cmd_error_offset; /* offset of first missing DataIn pdu */ __u32 cmd_error_runlen; /* number of missing DataIn pdus to ask for */ __u32 cmd_error_size; /* size of good DataIn pdus since last bad one*/ __u32 tx_data_length; /* length of attached data for tx stats */ struct iscsi_init_scsi_cmnd iscsi_cmd; /* SCSI Cmnd PDU hdr blt here */ /* structures from this point on are NOT zeroed on command setup! * Therefore, do NOT move the position of "SCpnt" unless you change * the memset() in setup_command()! */ struct scsi_cmnd *SCpnt; /* pointer to SCSI command */ struct list_head r2t_cookies; /* list of unsatisfied r2ts */ __u32 abit_in_sn; /* saved data_in_sn for A-bit rexmit */ __u32 abit_ttt; /* saved target_xfer_tag for A-bit rx */ __u64 abit_lun; /* saved lun for A-bit rexmit */ __u32 abit_offset; /* saved offset for A-bit rx */ __u32 ref_task_tag; /* TASK REASSIGN needs this */ __u32 time_stamp; /* time when command xmitted */ __u32 tx_wait_to_send; /* deadline til next send of this cmd */ __u32 tx_size; /* no. of bytes to send in sendmsg */ __u32 tx_sent_so_far; /* no. of bytes sent in prev sendmsgs */ __u32 retransmit_tx_size; /* original command tx_size - SAI */ __u32 tx_iovlen; /* no. of used tx_iov[]slots */ struct iovec tx_iov[MAX_IOV_SLOTS]; /* socket iovector built here */ struct iovec tx_iov_copy[MAX_IOV_SLOTS];/* copy of tx_iov for sendmsg */ struct msghdr tx_msghdr; /* socket message hdr blt here*/ __u32 data_checksum; /* checksum for attached data */ struct iscsi_init_scsi_data_out data; /* DataOut PDU hdr built here */#ifdef K26 struct scatterlist sg[MAX_IOV_SLOTS]; __u32 pindex; __u32 padding;#endif};/* * cmd_state state flags */#define CMD_STATE_TXDONE 0x01 /* tx_thread is done with cmd */#define CMD_STATE_RXDONE 0x02 /* rx_thread is done with cmd */#define CMD_STATE_REXMIT_ORIG 0x04 /* rebuild orig cmd in case of rexmit */#define CMD_STATE_TXSTARTED 0x08 /* tx_thread sent something on cmd */#define CMD_STATE_ABORTING 0x10 /* command is being aborted */#define CMD_NEEDS_WRITE_BUILT 0x01 /* xmit thread needs to call build_write *//* * The following structure holds the statistic value, * it is a per session structure. */#ifdef ISCSI_STATS/* * These are some session wide stats */struct iscsi_session_stats { __u32 iscsi_ssn_noptx_pdus; /* #of nop PDUs txd */ __u32 iscsi_ssn_scsicmd_pdus; /* #of command PDUs transferred */ __u32 iscsi_ssn_tskmgmtcmd_pdus; /* #of tast mgmt PDUs */ __u32 iscsi_ssn_login_pdus; /* #of login req pdus */ __u32 iscsi_ssn_text_pdus; /* #of test req pdus */ __u32 iscsi_ssn_dataout_pdus; /* #of data out -WRITE PDUs */ __u32 iscsi_ssn_logout_pdus; /* #of logout pdus */ __u32 iscsi_ssn_snack_pdus; /* #of SNACK pdus */ __u32 iscsi_ssn_noprx_pdus; /* #of nop PDUs rxd */ __u32 iscsi_ssn_rsp_pdus; /* #of rsp PDUs transferred */ __u32 iscsi_ssn_tskmgmtrsp_pdus; /* #of task mgmt func resp */ __u32 iscsi_ssn_textrsp_pdus; /* #of text resp */ __u32 iscsi_ssn_datain_pdus; /* #of data in -READ PDUs */ __u32 iscsi_ssn_logoutrsp_pdus; /* #of logout pdus */ __u32 iscsi_ssn_r2t_pdus; /* #of r2t rxd */ __u32 iscsi_ssn_async_pdus; /* #of async pdu rxd */ __u32 iscsi_ssn_rjt_pdus; /* #of reject pdus rxd */ __u32 iscsi_ssn_digest_err; /* PDUs with data/hdr digest error */ __u32 iscsi_ssn_timeout_err; /* connections terminated due to timeouts */ __u64 iscsi_ssn_txdata_octets; /* Data octets transmitted */ __u64 iscsi_ssn_rxdata_octets; /* Data octets received */};#define UPDATE_TX_SESS_STATS(opcode, command, sess_stats, connection) \ do {\ __u64 txlength;\ switch(opcode) {\ case ISCSI_INIT_NOP_OUT:\ sess_stats->iscsi_ssn_noptx_pdus++;\ break;\ case ISCSI_INIT_SCSI_CMND:\ sess_stats->iscsi_ssn_scsicmd_pdus++;\ txlength = command->tx_data_length;\ sess_stats->iscsi_ssn_txdata_octets += txlength;\ connection->iscsi_conn_txdata_octets += txlength;\ break;\ case ISCSI_INIT_TASK_MGMT_CMND:\ sess_stats->iscsi_ssn_tskmgmtcmd_pdus++;\ break;\ case ISCSI_INIT_TEXT_CMND:\ sess_stats->iscsi_ssn_text_pdus++;\ break;\ case ISCSI_INIT_SCSI_DATA_OUT:\ sess_stats->iscsi_ssn_dataout_pdus++;\ txlength = command->tx_data_length;\ sess_stats->iscsi_ssn_txdata_octets += txlength;\ connection->iscsi_conn_txdata_octets += txlength;\ break;\ case ISCSI_INIT_LOGOUT_CMND:\ sess_stats->iscsi_ssn_logout_pdus++;\ break;\ case ISCSI_INIT_SNACK:\ sess_stats->iscsi_ssn_snack_pdus++;\ break;\ default:\ break;\ }\ } while(0)#define UPDATE_RX_SESS_STATS(opcode, size, sess_stats, connection) \ switch(opcode) {\ case ISCSI_TARG_NOP_IN:\ sess_stats->iscsi_ssn_noprx_pdus++;\ break;\ case ISCSI_TARG_SCSI_RSP:\ sess_stats->iscsi_ssn_rsp_pdus++;\ break;\ case ISCSI_TARG_TASK_MGMT_RSP:\ sess_stats->iscsi_ssn_tskmgmtrsp_pdus++;\ break;\ case ISCSI_TARG_TEXT_RSP:\ sess_stats->iscsi_ssn_textrsp_pdus++;\ break;\ case ISCSI_TARG_SCSI_DATA_IN:\ sess_stats->iscsi_ssn_datain_pdus++;\ sess_stats->iscsi_ssn_rxdata_octets += size;\ connection->iscsi_conn_rxdata_octets += size;\ break;\ case ISCSI_TARG_R2T:\ sess_stats->iscsi_ssn_r2t_pdus++;\ break;\ case ISCSI_TARG_ASYNC_MSG:\ sess_stats->iscsi_ssn_async_pdus++;\ break;\ case ISCSI_TARG_RJT:\ sess_stats->iscsi_ssn_rjt_pdus++;\ break;\ default:\ break;\ }/* * These are what the SNMP Stats care about */enum login_failure_type { UNKNOWN_FAILURE =0, ACCEPT_RESPONSE, REDIRECT_RESPONSE, AUTH_FAIL_RESPONSE, AUTHENTICATE_FAIL, NEGOTIATE_FAIL, OTHER_FAIL};enum session_failure_type { UNKNOWN_ERROR = 0, DIGEST_ERROR, ISCSI_TIMEOUT_ERROR, FORMAT_ERROR};/* * These are some of the Instance wide stats */struct iscsi_instance_stats { __u32 iscsi_intr_ssn_failure; /* # time the sessions failed */ enum session_failure_type iscsi_last_ssn_failure_type; /* Last session failure type */ __u32 iscsi_ssn_digest_error; /* Sess which were failed due to receipt of a PDU containing header/data digest error */ __u32 iscsi_ssn_csn_timeout_error; /* Sess which were failed due to sequence exceeding a time limit */ __u32 iscsi_ssn_format_error; /* Sess which were failed due to receipt of aPDU containing format error */ __u32 iscsi_intr_login_failure; /* # login attempt from this initiator failed */ enum login_failure_type iscsi_intr_last_failure_type; /* Last failure type */ __u32 iscsi_intr_login_accept_rsp; /* Login rsp pdus with status 0x000 */ __u32 iscsi_intr_login_redirect_rsp; /* Login rsp pdus with status class 0x01 */ __u32 iscsi_intr_login_auth_fail_rsp; /* Login rsp pdus with status class 0x201 */ __u32 iscsi_intr_login_authenticate_fails; /* Intr aborted because tgt couldn't be authenticated */ __u32 iscsi_intr_login_negotiate_fails; /* parameter neg. with tgt failed */ __u32 iscsi_intr_login_other_fail_rsp; /* login rsp pdus with status not defined below */ __u32 iscsi_intr_logout_normals; /* logout cmd pdus with reason code 0x0 */ __u32 iscsi_intr_logout_others; /* logout cmd pdus with reason code other than 0 */ struct timeval iscsi_intr_last_failure_time; /* timestamp of most recent login failure */ char *iscsi_intr_last_tgt_failure_name; /* Target name */ struct sockaddr *iscsi_intr_last_tgt_failure_address; /* Target address */};#endif/* one of these per connection */struct connection { unsigned long rx_lock_flags; /* irqsave when rx_thread holds lock */ unsigned long tx_lock_flags; /* irqsave when tx_thread holds lock */ __u32 connection_id; /* CID within session */ __u32 max_send_length; /* MaxRecvDataSegmentLength from targ */ __u32 max_recv_length; /* MaxRecvDataSegmentLength of init */ __u32 nop_counter; /* counter used in NopOut ping data */ __u32 exp_stat_sn; /* next StatSN expected from target */ __u32 increment; /* added to exp_stat_sn after recovery*/ struct session *my_session; /* ptr to sess this conn belongs to */ __u32 connection_flags; /* bits for hdr/data digests, activity*/ __u32 connection_state; /* CONNECTION_NOT_PRESENT, ... */ struct semaphore rx_done_sem; /* wait here for rx_thread start/stop */ struct semaphore tx_sem; /* tx_thread waits here for work */ struct semaphore tx_done_sem; /* wait here for tx_thread start/stop */ struct semaphore task_mgt_sem; /* wait here for task mgt resp/timeout*/ __u32 nop_remaining; /* no. of secs until next NopOut sent */ atomic_t tx_timer_went_off; /* no. of pending timer expirations */ struct timer_list tx_timer; /* timer for sending nops */ /* the following field is manipulated by add_(remove_)session only */ struct connection *next; /* list of connections in this session*/ struct socket *sock; /* pointer to open socket to target */ __u8 *rx_buf; /* PDU headers from target read into here */ /* the following 2 fields are only set up after login succeeds */ struct task_struct *rx_thread; /* pointer to TCB of rx_thread */ struct task_struct *tx_thread; /* pointer to TCB of tx_thread */ int rec_tests; /* Indicator to initiate conn recovery SAI */ /* the following 5 fields are used by the rx_thread during operation */ struct list_head pending_commands;/* SCSI commands active on this conn*/ struct msghdr rx_msg; /* header for sock_recvmsg on this conn */ struct iovec rx_iov[MAX_IOV_SLOTS]; /* recvmsg iovec built here */ struct iovec rx_iov_copy[MAX_IOV_SLOTS];/* copy of rx_iov if digest */ struct list_head r2t_list; /* threaded order to send r2ts */ /* following 2 fields are used by tx_thread during operation */ struct command *short_command; /* Non-null if partially sent command */ __u32 process_r2t_order; /*next r2t to process in order on conn*/ struct sockaddr *ip_address; /* holds target's ipv4/ipv6 address */ int ip_length; /* used no. of bytes of ip_address */ struct sockaddr *local_ip_address;/* holds init's ipv4/ipv6 address */ /* the following field is only used for CONN_SCHED_LUN scheduling */ __u32 assigned_lun_count; /* no. of luns assigned to this conn */ __u32 basic_hdr_len; /* includes CRC_LEN as necessary */#ifdef ISCSI_STATS struct proc_dir_entry *proc_dir; /* Proc dir entry */ __u64 iscsi_conn_txdata_octets; /* Data octets transmitted */ __u64 iscsi_conn_rxdata_octets; /* Data octets received */#endif};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -