1 #ifndef ISCSI_TARGET_CORE_H
2 #define ISCSI_TARGET_CORE_H
4 #include <linux/dma-direction.h> /* enum dma_data_direction */
5 #include <linux/list.h> /* struct list_head */
6 #include <linux/socket.h> /* struct sockaddr_storage */
7 #include <linux/types.h> /* u8 */
8 #include <scsi/iscsi_proto.h> /* itt_t */
9 #include <target/target_core_base.h> /* struct se_cmd */
13 #define ISCSIT_VERSION "v4.1.0"
14 #define ISCSI_MAX_DATASN_MISSING_COUNT 16
15 #define ISCSI_TX_THREAD_TCP_TIMEOUT 2
16 #define ISCSI_RX_THREAD_TCP_TIMEOUT 2
17 #define SECONDS_FOR_ASYNC_LOGOUT 10
18 #define SECONDS_FOR_ASYNC_TEXT 10
19 #define SECONDS_FOR_LOGOUT_COMP 15
20 #define WHITE_SPACE " \t\v\f\n\r"
21 #define ISCSIT_MIN_TAGS 16
22 #define ISCSIT_EXTRA_TAGS 8
23 #define ISCSIT_TCP_BACKLOG 256
24 #define ISCSI_RX_THREAD_NAME "iscsi_trx"
25 #define ISCSI_TX_THREAD_NAME "iscsi_ttx"
27 /* struct iscsi_node_attrib sanity values */
28 #define NA_DATAOUT_TIMEOUT 3
29 #define NA_DATAOUT_TIMEOUT_MAX 60
30 #define NA_DATAOUT_TIMEOUT_MIX 2
31 #define NA_DATAOUT_TIMEOUT_RETRIES 5
32 #define NA_DATAOUT_TIMEOUT_RETRIES_MAX 15
33 #define NA_DATAOUT_TIMEOUT_RETRIES_MIN 1
34 #define NA_NOPIN_TIMEOUT 15
35 #define NA_NOPIN_TIMEOUT_MAX 60
36 #define NA_NOPIN_TIMEOUT_MIN 3
37 #define NA_NOPIN_RESPONSE_TIMEOUT 30
38 #define NA_NOPIN_RESPONSE_TIMEOUT_MAX 60
39 #define NA_NOPIN_RESPONSE_TIMEOUT_MIN 3
40 #define NA_RANDOM_DATAIN_PDU_OFFSETS 0
41 #define NA_RANDOM_DATAIN_SEQ_OFFSETS 0
42 #define NA_RANDOM_R2T_OFFSETS 0
44 /* struct iscsi_tpg_attrib sanity values */
45 #define TA_AUTHENTICATION 1
46 #define TA_LOGIN_TIMEOUT 15
47 #define TA_LOGIN_TIMEOUT_MAX 30
48 #define TA_LOGIN_TIMEOUT_MIN 5
49 #define TA_NETIF_TIMEOUT 2
50 #define TA_NETIF_TIMEOUT_MAX 15
51 #define TA_NETIF_TIMEOUT_MIN 2
52 #define TA_GENERATE_NODE_ACLS 0
53 #define TA_DEFAULT_CMDSN_DEPTH 64
54 #define TA_DEFAULT_CMDSN_DEPTH_MAX 512
55 #define TA_DEFAULT_CMDSN_DEPTH_MIN 1
56 #define TA_CACHE_DYNAMIC_ACLS 0
57 /* Enabled by default in demo mode (generic_node_acls=1) */
58 #define TA_DEMO_MODE_WRITE_PROTECT 1
59 /* Disabled by default in production mode w/ explict ACLs */
60 #define TA_PROD_MODE_WRITE_PROTECT 0
61 #define TA_DEMO_MODE_DISCOVERY 1
62 #define TA_DEFAULT_ERL 0
63 #define TA_CACHE_CORE_NPS 0
64 /* T10 protection information disabled by default */
65 #define TA_DEFAULT_T10_PI 0
66 #define TA_DEFAULT_FABRIC_PROT_TYPE 0
67 /* TPG status needs to be enabled to return sendtargets discovery endpoint info */
68 #define TA_DEFAULT_TPG_ENABLED_SENDTARGETS 1
70 #define ISCSI_IOV_DATA_BUFFER 5
72 enum iscsit_transport_type
{
82 /* RFC-3720 7.1.4 Standard Connection State Diagram for a Target */
83 enum target_conn_state_table
{
84 TARG_CONN_STATE_FREE
= 0x1,
85 TARG_CONN_STATE_XPT_UP
= 0x3,
86 TARG_CONN_STATE_IN_LOGIN
= 0x4,
87 TARG_CONN_STATE_LOGGED_IN
= 0x5,
88 TARG_CONN_STATE_IN_LOGOUT
= 0x6,
89 TARG_CONN_STATE_LOGOUT_REQUESTED
= 0x7,
90 TARG_CONN_STATE_CLEANUP_WAIT
= 0x8,
93 /* RFC-3720 7.3.2 Session State Diagram for a Target */
94 enum target_sess_state_table
{
95 TARG_SESS_STATE_FREE
= 0x1,
96 TARG_SESS_STATE_ACTIVE
= 0x2,
97 TARG_SESS_STATE_LOGGED_IN
= 0x3,
98 TARG_SESS_STATE_FAILED
= 0x4,
99 TARG_SESS_STATE_IN_CONTINUE
= 0x5,
102 /* struct iscsi_data_count->type */
103 enum data_count_type
{
108 /* struct iscsi_datain_req->dr_complete */
109 enum datain_req_comp_table
{
110 DATAIN_COMPLETE_NORMAL
= 1,
111 DATAIN_COMPLETE_WITHIN_COMMAND_RECOVERY
= 2,
112 DATAIN_COMPLETE_CONNECTION_RECOVERY
= 3,
115 /* struct iscsi_datain_req->recovery */
116 enum datain_req_rec_table
{
117 DATAIN_WITHIN_COMMAND_RECOVERY
= 1,
118 DATAIN_CONNECTION_RECOVERY
= 2,
121 /* struct iscsi_portal_group->state */
122 enum tpg_state_table
{
124 TPG_STATE_ACTIVE
= 1,
125 TPG_STATE_INACTIVE
= 2,
126 TPG_STATE_COLD_RESET
= 3,
129 /* struct iscsi_tiqn->tiqn_state */
130 enum tiqn_state_table
{
131 TIQN_STATE_ACTIVE
= 1,
132 TIQN_STATE_SHUTDOWN
= 2,
135 /* struct iscsi_cmd->cmd_flags */
136 enum cmd_flags_table
{
137 ICF_GOT_LAST_DATAOUT
= 0x00000001,
138 ICF_GOT_DATACK_SNACK
= 0x00000002,
139 ICF_NON_IMMEDIATE_UNSOLICITED_DATA
= 0x00000004,
140 ICF_SENT_LAST_R2T
= 0x00000008,
141 ICF_WITHIN_COMMAND_RECOVERY
= 0x00000010,
142 ICF_CONTIG_MEMORY
= 0x00000020,
143 ICF_ATTACHED_TO_RQUEUE
= 0x00000040,
144 ICF_OOO_CMDSN
= 0x00000080,
145 ICF_SENDTARGETS_ALL
= 0x00000100,
146 ICF_SENDTARGETS_SINGLE
= 0x00000200,
149 /* struct iscsi_cmd->i_state */
150 enum cmd_i_state_table
{
153 ISTATE_DEFERRED_CMD
= 2,
154 ISTATE_UNSOLICITED_DATA
= 3,
155 ISTATE_RECEIVE_DATAOUT
= 4,
156 ISTATE_RECEIVE_DATAOUT_RECOVERY
= 5,
157 ISTATE_RECEIVED_LAST_DATAOUT
= 6,
158 ISTATE_WITHIN_DATAOUT_RECOVERY
= 7,
159 ISTATE_IN_CONNECTION_RECOVERY
= 8,
160 ISTATE_RECEIVED_TASKMGT
= 9,
161 ISTATE_SEND_ASYNCMSG
= 10,
162 ISTATE_SENT_ASYNCMSG
= 11,
163 ISTATE_SEND_DATAIN
= 12,
164 ISTATE_SEND_LAST_DATAIN
= 13,
165 ISTATE_SENT_LAST_DATAIN
= 14,
166 ISTATE_SEND_LOGOUTRSP
= 15,
167 ISTATE_SENT_LOGOUTRSP
= 16,
168 ISTATE_SEND_NOPIN
= 17,
169 ISTATE_SENT_NOPIN
= 18,
170 ISTATE_SEND_REJECT
= 19,
171 ISTATE_SENT_REJECT
= 20,
172 ISTATE_SEND_R2T
= 21,
173 ISTATE_SENT_R2T
= 22,
174 ISTATE_SEND_R2T_RECOVERY
= 23,
175 ISTATE_SENT_R2T_RECOVERY
= 24,
176 ISTATE_SEND_LAST_R2T
= 25,
177 ISTATE_SENT_LAST_R2T
= 26,
178 ISTATE_SEND_LAST_R2T_RECOVERY
= 27,
179 ISTATE_SENT_LAST_R2T_RECOVERY
= 28,
180 ISTATE_SEND_STATUS
= 29,
181 ISTATE_SEND_STATUS_BROKEN_PC
= 30,
182 ISTATE_SENT_STATUS
= 31,
183 ISTATE_SEND_STATUS_RECOVERY
= 32,
184 ISTATE_SENT_STATUS_RECOVERY
= 33,
185 ISTATE_SEND_TASKMGTRSP
= 34,
186 ISTATE_SENT_TASKMGTRSP
= 35,
187 ISTATE_SEND_TEXTRSP
= 36,
188 ISTATE_SENT_TEXTRSP
= 37,
189 ISTATE_SEND_NOPIN_WANT_RESPONSE
= 38,
190 ISTATE_SENT_NOPIN_WANT_RESPONSE
= 39,
191 ISTATE_SEND_NOPIN_NO_RESPONSE
= 40,
196 /* Used for iscsi_recover_cmdsn() return values */
197 enum recover_cmdsn_ret_table
{
198 CMDSN_ERROR_CANNOT_RECOVER
= -1,
199 CMDSN_NORMAL_OPERATION
= 0,
200 CMDSN_LOWER_THAN_EXP
= 1,
201 CMDSN_HIGHER_THAN_EXP
= 2,
202 CMDSN_MAXCMDSN_OVERRUN
= 3,
205 /* Used for iscsi_handle_immediate_data() return values */
206 enum immedate_data_ret_table
{
207 IMMEDIATE_DATA_CANNOT_RECOVER
= -1,
208 IMMEDIATE_DATA_NORMAL_OPERATION
= 0,
209 IMMEDIATE_DATA_ERL1_CRC_FAILURE
= 1,
212 /* Used for iscsi_decide_dataout_action() return values */
213 enum dataout_action_ret_table
{
214 DATAOUT_CANNOT_RECOVER
= -1,
216 DATAOUT_SEND_R2T
= 1,
217 DATAOUT_SEND_TO_TRANSPORT
= 2,
218 DATAOUT_WITHIN_COMMAND_RECOVERY
= 3,
221 /* Used for struct iscsi_node_auth->naf_flags */
222 enum naf_flags_table
{
223 NAF_USERID_SET
= 0x01,
224 NAF_PASSWORD_SET
= 0x02,
225 NAF_USERID_IN_SET
= 0x04,
226 NAF_PASSWORD_IN_SET
= 0x08,
229 /* Used by various struct timer_list to manage iSCSI specific state */
230 enum iscsi_timer_flags_table
{
231 ISCSI_TF_RUNNING
= 0x01,
232 ISCSI_TF_STOP
= 0x02,
233 ISCSI_TF_EXPIRED
= 0x04,
236 /* Used for struct iscsi_np->np_flags */
237 enum np_flags_table
{
238 NPF_IP_NETWORK
= 0x00,
241 /* Used for struct iscsi_np->np_thread_state */
242 enum np_thread_state_table
{
243 ISCSI_NP_THREAD_ACTIVE
= 1,
244 ISCSI_NP_THREAD_INACTIVE
= 2,
245 ISCSI_NP_THREAD_RESET
= 3,
246 ISCSI_NP_THREAD_SHUTDOWN
= 4,
247 ISCSI_NP_THREAD_EXIT
= 5,
250 struct iscsi_conn_ops
{
251 u8 HeaderDigest
; /* [0,1] == [None,CRC32C] */
252 u8 DataDigest
; /* [0,1] == [None,CRC32C] */
253 u32 MaxRecvDataSegmentLength
; /* [512..2**24-1] */
254 u32 MaxXmitDataSegmentLength
; /* [512..2**24-1] */
256 * iSER specific connection parameters
258 u32 InitiatorRecvDataSegmentLength
; /* [512..2**24-1] */
259 u32 TargetRecvDataSegmentLength
; /* [512..2**24-1] */
262 struct iscsi_sess_ops
{
263 char InitiatorName
[224];
264 char InitiatorAlias
[256];
265 char TargetName
[224];
266 char TargetAlias
[256];
267 char TargetAddress
[256];
268 u16 TargetPortalGroupTag
; /* [0..65535] */
269 u16 MaxConnections
; /* [1..65535] */
270 u8 InitialR2T
; /* [0,1] == [No,Yes] */
271 u8 ImmediateData
; /* [0,1] == [No,Yes] */
272 u32 MaxBurstLength
; /* [512..2**24-1] */
273 u32 FirstBurstLength
; /* [512..2**24-1] */
274 u16 DefaultTime2Wait
; /* [0..3600] */
275 u16 DefaultTime2Retain
; /* [0..3600] */
276 u16 MaxOutstandingR2T
; /* [1..65535] */
277 u8 DataPDUInOrder
; /* [0,1] == [No,Yes] */
278 u8 DataSequenceInOrder
; /* [0,1] == [No,Yes] */
279 u8 ErrorRecoveryLevel
; /* [0..2] */
280 u8 SessionType
; /* [0,1] == [Normal,Discovery]*/
282 * iSER specific session parameters
284 u8 RDMAExtensions
; /* [0,1] == [No,Yes] */
287 struct iscsi_queue_req
{
289 struct iscsi_cmd
*cmd
;
290 struct list_head qr_list
;
293 struct iscsi_data_count
{
295 int sync_and_steering
;
296 enum data_count_type type
;
303 struct iscsi_param_list
{
305 struct list_head param_list
;
306 struct list_head extra_response_list
;
309 struct iscsi_datain_req
{
310 enum datain_req_comp_table dr_complete
;
311 int generate_recovery_values
;
312 enum datain_req_rec_table recovery
;
321 struct list_head cmd_datain_node
;
322 } ____cacheline_aligned
;
324 struct iscsi_ooo_cmdsn
{
329 struct iscsi_cmd
*cmd
;
330 struct list_head ooo_list
;
331 } ____cacheline_aligned
;
333 struct iscsi_datain
{
338 } ____cacheline_aligned
;
348 struct list_head r2t_list
;
349 } ____cacheline_aligned
;
352 enum iscsi_timer_flags_table dataout_timer_flags
;
353 /* DataOUT timeout retries */
354 u8 dataout_timeout_retries
;
355 /* Within command recovery count */
356 u8 error_recovery_count
;
357 /* iSCSI dependent state for out or order CmdSNs */
358 enum cmd_i_state_table deferred_i_state
;
359 /* iSCSI dependent state */
360 enum cmd_i_state_table i_state
;
361 /* Command is an immediate command (ISCSI_OP_IMMEDIATE set) */
363 /* Immediate data present */
367 /* iSCSI Response Code */
369 /* Logout reason when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
371 /* Logout response code when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
373 /* MaxCmdSN has been incremented */
375 /* Immediate Unsolicited Dataout */
377 /* Reject reason code */
379 /* CID contained in logout PDU when opcode == ISCSI_INIT_LOGOUT_CMND */
382 enum cmd_flags_table cmd_flags
;
383 /* Initiator Task Tag assigned from Initiator */
385 /* Target Transfer Tag assigned from Target */
387 /* CmdSN assigned from Initiator */
389 /* ExpStatSN assigned from Initiator */
391 /* StatSN assigned to this ITT */
397 /* Last DataSN acknowledged via DataAck SNACK */
399 /* Used for echoing NOPOUT ping data */
401 /* Used to store DataDigest */
403 /* Counter for MaxOutstandingR2T */
404 u32 outstanding_r2ts
;
405 /* Next R2T Offset when DataSequenceInOrder=Yes */
407 /* Iovec current and orig count for iscsi_cmd->iov_data */
409 u32 orig_iov_data_count
;
410 /* Number of miscellaneous iovecs used for IP stack calls */
412 /* Number of struct iscsi_pdu in struct iscsi_cmd->pdu_list */
414 /* Next struct iscsi_pdu to send in struct iscsi_cmd->pdu_list */
416 /* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */
418 /* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */
420 /* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */
422 /* Current struct iscsi_seq in struct iscsi_cmd->seq_list */
424 /* Lowest offset in current DataOUT sequence */
425 u32 seq_start_offset
;
426 /* Highest offset in current DataOUT sequence */
428 /* Total size in bytes received so far of READ data */
430 /* Total size in bytes received so far of WRITE data */
432 /* Counter for FirstBurstLength key */
434 /* Counter for MaxBurstLength key */
436 /* Transfer size used for IP stack calls */
438 /* Buffer used for various purposes */
440 /* Used by SendTargets=[iqn.,eui.] discovery */
442 /* See include/linux/dma-mapping.h */
443 enum dma_data_direction data_direction
;
444 /* iSCSI PDU Header + CRC */
445 unsigned char pdu
[ISCSI_HDR_LEN
+ ISCSI_CRC_LEN
];
446 /* Number of times struct iscsi_cmd is present in immediate queue */
447 atomic_t immed_queue_count
;
448 atomic_t response_queue_count
;
449 spinlock_t datain_lock
;
450 spinlock_t dataout_timeout_lock
;
451 /* spinlock for protecting struct iscsi_cmd->i_state */
452 spinlock_t istate_lock
;
453 /* spinlock for adding within command recovery entries */
454 spinlock_t error_lock
;
455 /* spinlock for adding R2Ts */
458 struct list_head datain_list
;
460 struct list_head cmd_r2t_list
;
461 /* Timer for DataOUT */
462 struct timer_list dataout_timer
;
463 /* Iovecs for SCSI data payload RX/TX w/ kernel level sockets */
464 struct kvec
*iov_data
;
465 /* Iovecs for miscellaneous purposes */
466 #define ISCSI_MISC_IOVECS 5
467 struct kvec iov_misc
[ISCSI_MISC_IOVECS
];
468 /* Array of struct iscsi_pdu used for DataPDUInOrder=No */
469 struct iscsi_pdu
*pdu_list
;
470 /* Current struct iscsi_pdu used for DataPDUInOrder=No */
471 struct iscsi_pdu
*pdu_ptr
;
472 /* Array of struct iscsi_seq used for DataSequenceInOrder=No */
473 struct iscsi_seq
*seq_list
;
474 /* Current struct iscsi_seq used for DataSequenceInOrder=No */
475 struct iscsi_seq
*seq_ptr
;
476 /* TMR Request when iscsi_opcode == ISCSI_OP_SCSI_TMFUNC */
477 struct iscsi_tmr_req
*tmr_req
;
478 /* Connection this command is alligient to */
479 struct iscsi_conn
*conn
;
480 /* Pointer to connection recovery entry */
481 struct iscsi_conn_recovery
*cr
;
482 /* Session the command is part of, used for connection recovery */
483 struct iscsi_session
*sess
;
484 /* list_head for connection list */
485 struct list_head i_conn_node
;
486 /* The TCM I/O descriptor that is accessed via container_of() */
487 struct se_cmd se_cmd
;
488 /* Sense buffer that will be mapped into outgoing status */
489 #define ISCSI_SENSE_BUFFER_LEN (TRANSPORT_SENSE_BUFFER + 2)
490 unsigned char sense_buffer
[ISCSI_SENSE_BUFFER_LEN
];
495 struct scatterlist
*first_data_sg
;
496 u32 first_data_sg_off
;
498 sense_reason_t sense_reason
;
499 } ____cacheline_aligned
;
501 struct iscsi_tmr_req
{
502 bool task_reassign
:1;
504 struct iscsi_cmd
*ref_cmd
;
505 struct iscsi_conn_recovery
*conn_recovery
;
506 struct se_tmr_req
*se_tmr_req
;
510 wait_queue_head_t queues_wq
;
511 /* Authentication Successful for this connection */
513 /* State connection is currently in */
515 u8 conn_logout_reason
;
516 u8 network_transport
;
517 enum iscsi_timer_flags_table nopin_timer_flags
;
518 enum iscsi_timer_flags_table nopin_response_timer_flags
;
519 /* Used to know what thread encountered a transport failure */
521 /* connection id assigned by the Initiator */
523 /* Remote TCP Port */
529 /* Used for iscsi_tx_login_rsp() */
532 /* Per connection status sequence number */
534 struct sockaddr_storage login_sockaddr
;
535 struct sockaddr_storage local_sockaddr
;
536 int conn_usage_count
;
537 int conn_waiting_on_uc
;
538 atomic_t check_immediate_queue
;
539 atomic_t conn_logout_remove
;
540 atomic_t connection_exit
;
541 atomic_t connection_recovery
;
542 atomic_t connection_reinstatement
;
543 atomic_t connection_wait_rcfr
;
544 atomic_t sleep_on_conn_wait_comp
;
545 atomic_t transport_failed
;
546 struct completion conn_post_wait_comp
;
547 struct completion conn_wait_comp
;
548 struct completion conn_wait_rcfr_comp
;
549 struct completion conn_waiting_on_uc_comp
;
550 struct completion conn_logout_comp
;
551 struct completion tx_half_close_comp
;
552 struct completion rx_half_close_comp
;
553 /* socket used by this connection */
555 void (*orig_data_ready
)(struct sock
*);
556 void (*orig_state_change
)(struct sock
*);
557 #define LOGIN_FLAGS_READ_ACTIVE 1
558 #define LOGIN_FLAGS_CLOSED 2
559 #define LOGIN_FLAGS_READY 4
560 unsigned long login_flags
;
561 struct delayed_work login_work
;
562 struct delayed_work login_cleanup_work
;
563 struct iscsi_login
*login
;
564 struct timer_list nopin_timer
;
565 struct timer_list nopin_response_timer
;
566 struct timer_list transport_timer
;
567 struct task_struct
*login_kworker
;
568 /* Spinlock used for add/deleting cmd's from conn_cmd_list */
570 spinlock_t conn_usage_lock
;
571 spinlock_t immed_queue_lock
;
572 spinlock_t nopin_timer_lock
;
573 spinlock_t response_queue_lock
;
574 spinlock_t state_lock
;
575 /* libcrypto RX and TX contexts for crc32c */
576 struct ahash_request
*conn_rx_hash
;
577 struct ahash_request
*conn_tx_hash
;
578 /* Used for scheduling TX and RX connection kthreads */
579 cpumask_var_t conn_cpumask
;
580 unsigned int conn_rx_reset_cpumask
:1;
581 unsigned int conn_tx_reset_cpumask
:1;
582 /* list_head of struct iscsi_cmd for this connection */
583 struct list_head conn_cmd_list
;
584 struct list_head immed_queue_list
;
585 struct list_head response_queue_list
;
586 struct iscsi_conn_ops
*conn_ops
;
587 struct iscsi_login
*conn_login
;
588 struct iscsit_transport
*conn_transport
;
589 struct iscsi_param_list
*param_list
;
590 /* Used for per connection auth state machine */
593 struct iscsi_login_thread_s
*login_thread
;
594 struct iscsi_portal_group
*tpg
;
595 struct iscsi_tpg_np
*tpg_np
;
596 /* Pointer to parent session */
597 struct iscsi_session
*sess
;
599 int rx_thread_active
;
600 struct task_struct
*rx_thread
;
601 struct completion rx_login_comp
;
602 int tx_thread_active
;
603 struct task_struct
*tx_thread
;
604 /* list_head for session connection list */
605 struct list_head conn_list
;
606 } ____cacheline_aligned
;
608 struct iscsi_conn_recovery
{
611 u32 maxrecvdatasegmentlength
;
612 u32 maxxmitdatasegmentlength
;
613 int ready_for_reallegiance
;
614 struct list_head conn_recovery_cmd_list
;
615 spinlock_t conn_recovery_cmd_lock
;
616 struct timer_list time2retain_timer
;
617 struct iscsi_session
*sess
;
618 struct list_head cr_list
;
619 } ____cacheline_aligned
;
621 struct iscsi_session
{
624 enum iscsi_timer_flags_table time2retain_timer_flags
;
627 u16 conn_recovery_count
;
629 /* state session is currently in */
631 /* session wide counter: initiator assigned task tag */
633 /* session wide counter: target assigned task tag */
637 /* protects cmdsn values */
638 struct mutex cmdsn_mutex
;
639 /* session wide counter: expected command sequence number */
641 /* session wide counter: maximum allowed command sequence number */
643 struct list_head sess_ooo_cmdsn_list
;
645 /* LIO specific session ID */
648 /* unique within the target */
650 /* Used for session reference counting */
651 int session_usage_count
;
652 int session_waiting_on_uc
;
653 atomic_long_t cmd_pdus
;
654 atomic_long_t rsp_pdus
;
655 atomic_long_t tx_data_octets
;
656 atomic_long_t rx_data_octets
;
657 atomic_long_t conn_digest_errors
;
658 atomic_long_t conn_timeout_errors
;
660 /* Number of active connections */
662 atomic_t session_continuation
;
663 atomic_t session_fall_back_to_erl0
;
664 atomic_t session_logout
;
665 atomic_t session_reinstatement
;
666 atomic_t session_stop_active
;
667 atomic_t sleep_on_sess_wait_comp
;
668 /* connection list */
669 struct list_head sess_conn_list
;
670 struct list_head cr_active_list
;
671 struct list_head cr_inactive_list
;
672 spinlock_t conn_lock
;
673 spinlock_t cr_a_lock
;
674 spinlock_t cr_i_lock
;
675 spinlock_t session_usage_lock
;
677 struct completion async_msg_comp
;
678 struct completion reinstatement_comp
;
679 struct completion session_wait_comp
;
680 struct completion session_waiting_on_uc_comp
;
681 struct timer_list time2retain_timer
;
682 struct iscsi_sess_ops
*sess_ops
;
683 struct se_session
*se_sess
;
684 struct iscsi_portal_group
*tpg
;
685 } ____cacheline_aligned
;
689 u8 checked_for_existing
;
691 u8 leading_connection
;
701 u32 initial_exp_statsn
;
705 char req
[ISCSI_HDR_LEN
];
706 char rsp
[ISCSI_HDR_LEN
];
709 struct iscsi_conn
*conn
;
711 } ____cacheline_aligned
;
713 struct iscsi_node_attrib
{
715 u32 dataout_timeout_retries
;
718 u32 nopin_response_timeout
;
719 u32 random_datain_pdu_offsets
;
720 u32 random_datain_seq_offsets
;
721 u32 random_r2t_offsets
;
724 struct iscsi_node_acl
*nacl
;
727 struct se_dev_entry_s
;
729 struct iscsi_node_auth
{
730 enum naf_flags_table naf_flags
;
731 int authenticate_target
;
732 /* Used for iscsit_global->discovery_auth,
733 * set to zero (auth disabled) by default */
734 int enforce_discovery_auth
;
735 #define MAX_USER_LEN 256
736 #define MAX_PASS_LEN 256
737 char userid
[MAX_USER_LEN
];
738 char password
[MAX_PASS_LEN
];
739 char userid_mutual
[MAX_USER_LEN
];
740 char password_mutual
[MAX_PASS_LEN
];
743 #include "iscsi_target_stat.h"
745 struct iscsi_node_stat_grps
{
746 struct config_group iscsi_sess_stats_group
;
747 struct config_group iscsi_conn_stats_group
;
750 struct iscsi_node_acl
{
751 struct se_node_acl se_node_acl
;
752 struct iscsi_node_attrib node_attrib
;
753 struct iscsi_node_auth node_auth
;
754 struct iscsi_node_stat_grps node_stat_grps
;
757 struct iscsi_tpg_attrib
{
761 u32 generate_node_acls
;
762 u32 cache_dynamic_acls
;
763 u32 default_cmdsn_depth
;
764 u32 demo_mode_write_protect
;
765 u32 prod_mode_write_protect
;
766 u32 demo_mode_discovery
;
769 u32 fabric_prot_type
;
770 u32 tpg_enabled_sendtargets
;
771 struct iscsi_portal_group
*tpg
;
775 int np_network_transport
;
778 enum np_thread_state_table np_thread_state
;
780 enum iscsi_timer_flags_table np_login_timer_flags
;
782 enum np_flags_table np_flags
;
783 spinlock_t np_thread_lock
;
784 struct completion np_restart_comp
;
785 struct socket
*np_socket
;
786 struct sockaddr_storage np_sockaddr
;
787 struct task_struct
*np_thread
;
788 struct timer_list np_login_timer
;
790 struct iscsit_transport
*np_transport
;
791 struct list_head np_list
;
792 } ____cacheline_aligned
;
794 struct iscsi_tpg_np
{
795 struct iscsi_np
*tpg_np
;
796 struct iscsi_portal_group
*tpg
;
797 struct iscsi_tpg_np
*tpg_np_parent
;
798 struct list_head tpg_np_list
;
799 struct list_head tpg_np_child_list
;
800 struct list_head tpg_np_parent_list
;
801 struct se_tpg_np se_tpg_np
;
802 spinlock_t tpg_np_parent_lock
;
803 struct completion tpg_np_comp
;
804 struct kref tpg_np_kref
;
807 struct iscsi_portal_group
{
808 unsigned char tpg_chap_id
;
810 enum tpg_state_table tpg_state
;
811 /* Target Portal Group Tag */
813 /* Id assigned to target sessions */
815 /* Number of active sessions */
817 /* Number of Network Portals available for this TPG */
819 /* Per TPG LIO specific session ID. */
821 /* Spinlock for adding/removing Network Portals */
822 spinlock_t tpg_np_lock
;
823 spinlock_t tpg_state_lock
;
824 struct se_portal_group tpg_se_tpg
;
825 struct mutex tpg_access_lock
;
826 struct semaphore np_login_sem
;
827 struct iscsi_tpg_attrib tpg_attrib
;
828 struct iscsi_node_auth tpg_demo_auth
;
829 /* Pointer to default list of iSCSI parameters for TPG */
830 struct iscsi_param_list
*param_list
;
831 struct iscsi_tiqn
*tpg_tiqn
;
832 struct list_head tpg_gnp_list
;
833 struct list_head tpg_list
;
834 } ____cacheline_aligned
;
836 struct iscsi_wwn_stat_grps
{
837 struct config_group iscsi_stat_group
;
838 struct config_group iscsi_instance_group
;
839 struct config_group iscsi_sess_err_group
;
840 struct config_group iscsi_tgt_attr_group
;
841 struct config_group iscsi_login_stats_group
;
842 struct config_group iscsi_logout_stats_group
;
846 #define ISCSI_IQN_LEN 224
847 unsigned char tiqn
[ISCSI_IQN_LEN
];
848 enum tiqn_state_table tiqn_state
;
849 int tiqn_access_count
;
850 u32 tiqn_active_tpgs
;
852 u32 tiqn_num_tpg_nps
;
854 struct list_head tiqn_list
;
855 struct list_head tiqn_tpg_list
;
856 spinlock_t tiqn_state_lock
;
857 spinlock_t tiqn_tpg_lock
;
858 struct se_wwn tiqn_wwn
;
859 struct iscsi_wwn_stat_grps tiqn_stat_grps
;
861 struct iscsi_sess_err_stats sess_err_stats
;
862 struct iscsi_login_stats login_stats
;
863 struct iscsi_logout_stats logout_stats
;
864 } ____cacheline_aligned
;
866 struct iscsit_global
{
867 /* In core shutdown */
870 /* Unique identifier used for the authentication daemon */
873 #define ISCSIT_BITMAP_BITS 262144
874 /* Thread Set bitmap pointer */
875 unsigned long *ts_bitmap
;
876 spinlock_t ts_bitmap_lock
;
877 /* Used for iSCSI discovery session authentication */
878 struct iscsi_node_acl discovery_acl
;
879 struct iscsi_portal_group
*discovery_tpg
;
882 static inline u32
session_get_next_ttt(struct iscsi_session
*session
)
886 spin_lock_bh(&session
->ttt_lock
);
887 ttt
= session
->targ_xfer_tag
++;
888 if (ttt
== 0xFFFFFFFF)
889 ttt
= session
->targ_xfer_tag
++;
890 spin_unlock_bh(&session
->ttt_lock
);
895 extern struct iscsi_cmd
*iscsit_find_cmd_from_itt(struct iscsi_conn
*, itt_t
);
897 static inline void iscsit_thread_check_cpumask(
898 struct iscsi_conn
*conn
,
899 struct task_struct
*p
,
903 * mode == 1 signals iscsi_target_tx_thread() usage.
904 * mode == 0 signals iscsi_target_rx_thread() usage.
907 if (!conn
->conn_tx_reset_cpumask
)
909 conn
->conn_tx_reset_cpumask
= 0;
911 if (!conn
->conn_rx_reset_cpumask
)
913 conn
->conn_rx_reset_cpumask
= 0;
916 * Update the CPU mask for this single kthread so that
917 * both TX and RX kthreads are scheduled to run on the
920 set_cpus_allowed_ptr(p
, conn
->conn_cpumask
);
922 #endif /* ISCSI_TARGET_CORE_H */