1 #ifndef ISCSI_TARGET_CORE_H
2 #define ISCSI_TARGET_CORE_H
5 #include <linux/configfs.h>
8 #include <scsi/scsi_cmnd.h>
9 #include <scsi/iscsi_proto.h>
10 #include <target/target_core_base.h>
12 #define ISCSIT_VERSION "v4.1.0-rc1"
13 #define ISCSI_MAX_DATASN_MISSING_COUNT 16
14 #define ISCSI_TX_THREAD_TCP_TIMEOUT 2
15 #define ISCSI_RX_THREAD_TCP_TIMEOUT 2
16 #define SECONDS_FOR_ASYNC_LOGOUT 10
17 #define SECONDS_FOR_ASYNC_TEXT 10
18 #define SECONDS_FOR_LOGOUT_COMP 15
19 #define WHITE_SPACE " \t\v\f\n\r"
21 /* struct iscsi_node_attrib sanity values */
22 #define NA_DATAOUT_TIMEOUT 3
23 #define NA_DATAOUT_TIMEOUT_MAX 60
24 #define NA_DATAOUT_TIMEOUT_MIX 2
25 #define NA_DATAOUT_TIMEOUT_RETRIES 5
26 #define NA_DATAOUT_TIMEOUT_RETRIES_MAX 15
27 #define NA_DATAOUT_TIMEOUT_RETRIES_MIN 1
28 #define NA_NOPIN_TIMEOUT 5
29 #define NA_NOPIN_TIMEOUT_MAX 60
30 #define NA_NOPIN_TIMEOUT_MIN 3
31 #define NA_NOPIN_RESPONSE_TIMEOUT 5
32 #define NA_NOPIN_RESPONSE_TIMEOUT_MAX 60
33 #define NA_NOPIN_RESPONSE_TIMEOUT_MIN 3
34 #define NA_RANDOM_DATAIN_PDU_OFFSETS 0
35 #define NA_RANDOM_DATAIN_SEQ_OFFSETS 0
36 #define NA_RANDOM_R2T_OFFSETS 0
37 #define NA_DEFAULT_ERL 0
38 #define NA_DEFAULT_ERL_MAX 2
39 #define NA_DEFAULT_ERL_MIN 0
41 /* struct iscsi_tpg_attrib sanity values */
42 #define TA_AUTHENTICATION 1
43 #define TA_LOGIN_TIMEOUT 15
44 #define TA_LOGIN_TIMEOUT_MAX 30
45 #define TA_LOGIN_TIMEOUT_MIN 5
46 #define TA_NETIF_TIMEOUT 2
47 #define TA_NETIF_TIMEOUT_MAX 15
48 #define TA_NETIF_TIMEOUT_MIN 2
49 #define TA_GENERATE_NODE_ACLS 0
50 #define TA_DEFAULT_CMDSN_DEPTH 16
51 #define TA_DEFAULT_CMDSN_DEPTH_MAX 512
52 #define TA_DEFAULT_CMDSN_DEPTH_MIN 1
53 #define TA_CACHE_DYNAMIC_ACLS 0
54 /* Enabled by default in demo mode (generic_node_acls=1) */
55 #define TA_DEMO_MODE_WRITE_PROTECT 1
56 /* Disabled by default in production mode w/ explict ACLs */
57 #define TA_PROD_MODE_WRITE_PROTECT 0
58 #define TA_CACHE_CORE_NPS 0
61 #define ISCSI_IOV_DATA_BUFFER 5
63 enum tpg_np_network_transport_table
{
72 /* RFC-3720 7.1.4 Standard Connection State Diagram for a Target */
73 enum target_conn_state_table
{
74 TARG_CONN_STATE_FREE
= 0x1,
75 TARG_CONN_STATE_XPT_UP
= 0x3,
76 TARG_CONN_STATE_IN_LOGIN
= 0x4,
77 TARG_CONN_STATE_LOGGED_IN
= 0x5,
78 TARG_CONN_STATE_IN_LOGOUT
= 0x6,
79 TARG_CONN_STATE_LOGOUT_REQUESTED
= 0x7,
80 TARG_CONN_STATE_CLEANUP_WAIT
= 0x8,
83 /* RFC-3720 7.3.2 Session State Diagram for a Target */
84 enum target_sess_state_table
{
85 TARG_SESS_STATE_FREE
= 0x1,
86 TARG_SESS_STATE_ACTIVE
= 0x2,
87 TARG_SESS_STATE_LOGGED_IN
= 0x3,
88 TARG_SESS_STATE_FAILED
= 0x4,
89 TARG_SESS_STATE_IN_CONTINUE
= 0x5,
92 /* struct iscsi_data_count->type */
93 enum data_count_type
{
98 /* struct iscsi_datain_req->dr_complete */
99 enum datain_req_comp_table
{
100 DATAIN_COMPLETE_NORMAL
= 1,
101 DATAIN_COMPLETE_WITHIN_COMMAND_RECOVERY
= 2,
102 DATAIN_COMPLETE_CONNECTION_RECOVERY
= 3,
105 /* struct iscsi_datain_req->recovery */
106 enum datain_req_rec_table
{
107 DATAIN_WITHIN_COMMAND_RECOVERY
= 1,
108 DATAIN_CONNECTION_RECOVERY
= 2,
111 /* struct iscsi_portal_group->state */
112 enum tpg_state_table
{
114 TPG_STATE_ACTIVE
= 1,
115 TPG_STATE_INACTIVE
= 2,
116 TPG_STATE_COLD_RESET
= 3,
119 /* struct iscsi_tiqn->tiqn_state */
120 enum tiqn_state_table
{
121 TIQN_STATE_ACTIVE
= 1,
122 TIQN_STATE_SHUTDOWN
= 2,
125 /* struct iscsi_cmd->cmd_flags */
126 enum cmd_flags_table
{
127 ICF_GOT_LAST_DATAOUT
= 0x00000001,
128 ICF_GOT_DATACK_SNACK
= 0x00000002,
129 ICF_NON_IMMEDIATE_UNSOLICITED_DATA
= 0x00000004,
130 ICF_SENT_LAST_R2T
= 0x00000008,
131 ICF_WITHIN_COMMAND_RECOVERY
= 0x00000010,
132 ICF_CONTIG_MEMORY
= 0x00000020,
133 ICF_ATTACHED_TO_RQUEUE
= 0x00000040,
134 ICF_OOO_CMDSN
= 0x00000080,
135 ICF_REJECT_FAIL_CONN
= 0x00000100,
138 /* struct iscsi_cmd->i_state */
139 enum cmd_i_state_table
{
142 ISTATE_DEFERRED_CMD
= 2,
143 ISTATE_UNSOLICITED_DATA
= 3,
144 ISTATE_RECEIVE_DATAOUT
= 4,
145 ISTATE_RECEIVE_DATAOUT_RECOVERY
= 5,
146 ISTATE_RECEIVED_LAST_DATAOUT
= 6,
147 ISTATE_WITHIN_DATAOUT_RECOVERY
= 7,
148 ISTATE_IN_CONNECTION_RECOVERY
= 8,
149 ISTATE_RECEIVED_TASKMGT
= 9,
150 ISTATE_SEND_ASYNCMSG
= 10,
151 ISTATE_SENT_ASYNCMSG
= 11,
152 ISTATE_SEND_DATAIN
= 12,
153 ISTATE_SEND_LAST_DATAIN
= 13,
154 ISTATE_SENT_LAST_DATAIN
= 14,
155 ISTATE_SEND_LOGOUTRSP
= 15,
156 ISTATE_SENT_LOGOUTRSP
= 16,
157 ISTATE_SEND_NOPIN
= 17,
158 ISTATE_SENT_NOPIN
= 18,
159 ISTATE_SEND_REJECT
= 19,
160 ISTATE_SENT_REJECT
= 20,
161 ISTATE_SEND_R2T
= 21,
162 ISTATE_SENT_R2T
= 22,
163 ISTATE_SEND_R2T_RECOVERY
= 23,
164 ISTATE_SENT_R2T_RECOVERY
= 24,
165 ISTATE_SEND_LAST_R2T
= 25,
166 ISTATE_SENT_LAST_R2T
= 26,
167 ISTATE_SEND_LAST_R2T_RECOVERY
= 27,
168 ISTATE_SENT_LAST_R2T_RECOVERY
= 28,
169 ISTATE_SEND_STATUS
= 29,
170 ISTATE_SEND_STATUS_BROKEN_PC
= 30,
171 ISTATE_SENT_STATUS
= 31,
172 ISTATE_SEND_STATUS_RECOVERY
= 32,
173 ISTATE_SENT_STATUS_RECOVERY
= 33,
174 ISTATE_SEND_TASKMGTRSP
= 34,
175 ISTATE_SENT_TASKMGTRSP
= 35,
176 ISTATE_SEND_TEXTRSP
= 36,
177 ISTATE_SENT_TEXTRSP
= 37,
178 ISTATE_SEND_NOPIN_WANT_RESPONSE
= 38,
179 ISTATE_SENT_NOPIN_WANT_RESPONSE
= 39,
180 ISTATE_SEND_NOPIN_NO_RESPONSE
= 40,
185 /* Used for iscsi_recover_cmdsn() return values */
186 enum recover_cmdsn_ret_table
{
187 CMDSN_ERROR_CANNOT_RECOVER
= -1,
188 CMDSN_NORMAL_OPERATION
= 0,
189 CMDSN_LOWER_THAN_EXP
= 1,
190 CMDSN_HIGHER_THAN_EXP
= 2,
193 /* Used for iscsi_handle_immediate_data() return values */
194 enum immedate_data_ret_table
{
195 IMMEDIATE_DATA_CANNOT_RECOVER
= -1,
196 IMMEDIATE_DATA_NORMAL_OPERATION
= 0,
197 IMMEDIATE_DATA_ERL1_CRC_FAILURE
= 1,
200 /* Used for iscsi_decide_dataout_action() return values */
201 enum dataout_action_ret_table
{
202 DATAOUT_CANNOT_RECOVER
= -1,
204 DATAOUT_SEND_R2T
= 1,
205 DATAOUT_SEND_TO_TRANSPORT
= 2,
206 DATAOUT_WITHIN_COMMAND_RECOVERY
= 3,
209 /* Used for struct iscsi_node_auth->naf_flags */
210 enum naf_flags_table
{
211 NAF_USERID_SET
= 0x01,
212 NAF_PASSWORD_SET
= 0x02,
213 NAF_USERID_IN_SET
= 0x04,
214 NAF_PASSWORD_IN_SET
= 0x08,
217 /* Used by various struct timer_list to manage iSCSI specific state */
218 enum iscsi_timer_flags_table
{
219 ISCSI_TF_RUNNING
= 0x01,
220 ISCSI_TF_STOP
= 0x02,
221 ISCSI_TF_EXPIRED
= 0x04,
224 /* Used for struct iscsi_np->np_flags */
225 enum np_flags_table
{
226 NPF_IP_NETWORK
= 0x00,
227 NPF_SCTP_STRUCT_FILE
= 0x01 /* Bugfix */
230 /* Used for struct iscsi_np->np_thread_state */
231 enum np_thread_state_table
{
232 ISCSI_NP_THREAD_ACTIVE
= 1,
233 ISCSI_NP_THREAD_INACTIVE
= 2,
234 ISCSI_NP_THREAD_RESET
= 3,
235 ISCSI_NP_THREAD_SHUTDOWN
= 4,
236 ISCSI_NP_THREAD_EXIT
= 5,
239 struct iscsi_conn_ops
{
240 u8 HeaderDigest
; /* [0,1] == [None,CRC32C] */
241 u8 DataDigest
; /* [0,1] == [None,CRC32C] */
242 u32 MaxRecvDataSegmentLength
; /* [512..2**24-1] */
243 u8 OFMarker
; /* [0,1] == [No,Yes] */
244 u8 IFMarker
; /* [0,1] == [No,Yes] */
245 u32 OFMarkInt
; /* [1..65535] */
246 u32 IFMarkInt
; /* [1..65535] */
249 struct iscsi_sess_ops
{
250 char InitiatorName
[224];
251 char InitiatorAlias
[256];
252 char TargetName
[224];
253 char TargetAlias
[256];
254 char TargetAddress
[256];
255 u16 TargetPortalGroupTag
; /* [0..65535] */
256 u16 MaxConnections
; /* [1..65535] */
257 u8 InitialR2T
; /* [0,1] == [No,Yes] */
258 u8 ImmediateData
; /* [0,1] == [No,Yes] */
259 u32 MaxBurstLength
; /* [512..2**24-1] */
260 u32 FirstBurstLength
; /* [512..2**24-1] */
261 u16 DefaultTime2Wait
; /* [0..3600] */
262 u16 DefaultTime2Retain
; /* [0..3600] */
263 u16 MaxOutstandingR2T
; /* [1..65535] */
264 u8 DataPDUInOrder
; /* [0,1] == [No,Yes] */
265 u8 DataSequenceInOrder
; /* [0,1] == [No,Yes] */
266 u8 ErrorRecoveryLevel
; /* [0..2] */
267 u8 SessionType
; /* [0,1] == [Normal,Discovery]*/
270 struct iscsi_queue_req
{
272 struct iscsi_cmd
*cmd
;
273 struct list_head qr_list
;
276 struct iscsi_data_count
{
278 int sync_and_steering
;
279 enum data_count_type type
;
286 struct iscsi_param_list
{
287 struct list_head param_list
;
288 struct list_head extra_response_list
;
291 struct iscsi_datain_req
{
292 enum datain_req_comp_table dr_complete
;
293 int generate_recovery_values
;
294 enum datain_req_rec_table recovery
;
304 struct list_head dr_list
;
305 } ____cacheline_aligned
;
307 struct iscsi_ooo_cmdsn
{
312 struct iscsi_cmd
*cmd
;
313 struct list_head ooo_list
;
314 } ____cacheline_aligned
;
316 struct iscsi_datain
{
321 } ____cacheline_aligned
;
331 struct list_head r2t_list
;
332 } ____cacheline_aligned
;
335 enum iscsi_timer_flags_table dataout_timer_flags
;
336 /* DataOUT timeout retries */
337 u8 dataout_timeout_retries
;
338 /* Within command recovery count */
339 u8 error_recovery_count
;
340 /* iSCSI dependent state for out or order CmdSNs */
341 enum cmd_i_state_table deferred_i_state
;
342 /* iSCSI dependent state */
343 enum cmd_i_state_table i_state
;
344 /* Command is an immediate command (ISCSI_OP_IMMEDIATE set) */
346 /* Immediate data present */
350 /* iSCSI Response Code */
352 /* Logout reason when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
354 /* Logout response code when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
356 /* MaxCmdSN has been incremented */
358 /* Immediate Unsolicited Dataout */
360 /* CID contained in logout PDU when opcode == ISCSI_INIT_LOGOUT_CMND */
363 enum cmd_flags_table cmd_flags
;
364 /* Initiator Task Tag assigned from Initiator */
366 /* Target Transfer Tag assigned from Target */
368 /* CmdSN assigned from Initiator */
370 /* ExpStatSN assigned from Initiator */
372 /* StatSN assigned to this ITT */
378 /* Last DataSN acknowledged via DataAck SNACK */
380 /* Used for echoing NOPOUT ping data */
382 /* Used to store DataDigest */
384 /* Total size in bytes associated with command */
386 /* Counter for MaxOutstandingR2T */
387 u32 outstanding_r2ts
;
388 /* Next R2T Offset when DataSequenceInOrder=Yes */
390 /* Iovec current and orig count for iscsi_cmd->iov_data */
392 u32 orig_iov_data_count
;
393 /* Number of miscellaneous iovecs used for IP stack calls */
395 /* Number of struct iscsi_pdu in struct iscsi_cmd->pdu_list */
397 /* Next struct iscsi_pdu to send in struct iscsi_cmd->pdu_list */
399 /* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */
401 /* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */
403 /* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */
405 /* Current struct iscsi_seq in struct iscsi_cmd->seq_list */
407 /* Lowest offset in current DataOUT sequence */
408 u32 seq_start_offset
;
409 /* Highest offset in current DataOUT sequence */
411 /* Total size in bytes received so far of READ data */
413 /* Total size in bytes received so far of WRITE data */
415 /* Counter for FirstBurstLength key */
417 /* Counter for MaxBurstLength key */
419 /* Transfer size used for IP stack calls */
421 /* Buffer used for various purposes */
423 /* See include/linux/dma-mapping.h */
424 enum dma_data_direction data_direction
;
425 /* iSCSI PDU Header + CRC */
426 unsigned char pdu
[ISCSI_HDR_LEN
+ ISCSI_CRC_LEN
];
427 /* Number of times struct iscsi_cmd is present in immediate queue */
428 atomic_t immed_queue_count
;
429 atomic_t response_queue_count
;
430 spinlock_t datain_lock
;
431 spinlock_t dataout_timeout_lock
;
432 /* spinlock for protecting struct iscsi_cmd->i_state */
433 spinlock_t istate_lock
;
434 /* spinlock for adding within command recovery entries */
435 spinlock_t error_lock
;
436 /* spinlock for adding R2Ts */
439 struct list_head datain_list
;
441 struct list_head cmd_r2t_list
;
442 struct completion reject_comp
;
443 /* Timer for DataOUT */
444 struct timer_list dataout_timer
;
445 /* Iovecs for SCSI data payload RX/TX w/ kernel level sockets */
446 struct kvec
*iov_data
;
447 /* Iovecs for miscellaneous purposes */
448 #define ISCSI_MISC_IOVECS 5
449 struct kvec iov_misc
[ISCSI_MISC_IOVECS
];
450 /* Array of struct iscsi_pdu used for DataPDUInOrder=No */
451 struct iscsi_pdu
*pdu_list
;
452 /* Current struct iscsi_pdu used for DataPDUInOrder=No */
453 struct iscsi_pdu
*pdu_ptr
;
454 /* Array of struct iscsi_seq used for DataSequenceInOrder=No */
455 struct iscsi_seq
*seq_list
;
456 /* Current struct iscsi_seq used for DataSequenceInOrder=No */
457 struct iscsi_seq
*seq_ptr
;
458 /* TMR Request when iscsi_opcode == ISCSI_OP_SCSI_TMFUNC */
459 struct iscsi_tmr_req
*tmr_req
;
460 /* Connection this command is alligient to */
461 struct iscsi_conn
*conn
;
462 /* Pointer to connection recovery entry */
463 struct iscsi_conn_recovery
*cr
;
464 /* Session the command is part of, used for connection recovery */
465 struct iscsi_session
*sess
;
466 /* list_head for connection list */
467 struct list_head i_list
;
468 /* The TCM I/O descriptor that is accessed via container_of() */
469 struct se_cmd se_cmd
;
470 /* Sense buffer that will be mapped into outgoing status */
471 #define ISCSI_SENSE_BUFFER_LEN (TRANSPORT_SENSE_BUFFER + 2)
472 unsigned char sense_buffer
[ISCSI_SENSE_BUFFER_LEN
];
474 struct scatterlist
*t_mem_sg
;
480 struct scatterlist
*first_data_sg
;
481 u32 first_data_sg_off
;
484 } ____cacheline_aligned
;
486 struct iscsi_tmr_req
{
487 bool task_reassign
:1;
490 struct iscsi_conn_recovery
*conn_recovery
;
491 struct se_tmr_req
*se_tmr_req
;
495 /* Authentication Successful for this connection */
497 /* State connection is currently in */
499 u8 conn_logout_reason
;
500 u8 network_transport
;
501 enum iscsi_timer_flags_table nopin_timer_flags
;
502 enum iscsi_timer_flags_table nopin_response_timer_flags
;
503 u8 tx_immediate_queue
;
504 u8 tx_response_queue
;
505 /* Used to know what thread encountered a transport failure */
507 /* connection id assigned by the Initiator */
509 /* Remote TCP Port */
514 #define CONNFLAG_SCTP_STRUCT_FILE 0x01
516 /* Used for iscsi_tx_login_rsp() */
519 /* Per connection status sequence number */
521 /* IFMarkInt's Current Value */
523 /* OFMarkInt's Current Value */
525 /* Used for calculating OFMarker offset to next PDU */
526 u32 of_marker_offset
;
527 /* Complete Bad PDU for sending reject */
528 unsigned char bad_hdr
[ISCSI_HDR_LEN
];
529 #define IPV6_ADDRESS_SPACE 48
530 unsigned char login_ip
[IPV6_ADDRESS_SPACE
];
531 unsigned char local_ip
[IPV6_ADDRESS_SPACE
];
532 int conn_usage_count
;
533 int conn_waiting_on_uc
;
534 atomic_t check_immediate_queue
;
535 atomic_t conn_logout_remove
;
536 atomic_t connection_exit
;
537 atomic_t connection_recovery
;
538 atomic_t connection_reinstatement
;
539 atomic_t connection_wait_rcfr
;
540 atomic_t sleep_on_conn_wait_comp
;
541 atomic_t transport_failed
;
542 struct completion conn_post_wait_comp
;
543 struct completion conn_wait_comp
;
544 struct completion conn_wait_rcfr_comp
;
545 struct completion conn_waiting_on_uc_comp
;
546 struct completion conn_logout_comp
;
547 struct completion tx_half_close_comp
;
548 struct completion rx_half_close_comp
;
549 /* socket used by this connection */
551 struct timer_list nopin_timer
;
552 struct timer_list nopin_response_timer
;
553 struct timer_list transport_timer
;
554 /* Spinlock used for add/deleting cmd's from conn_cmd_list */
556 spinlock_t conn_usage_lock
;
557 spinlock_t immed_queue_lock
;
558 spinlock_t nopin_timer_lock
;
559 spinlock_t response_queue_lock
;
560 spinlock_t state_lock
;
561 /* libcrypto RX and TX contexts for crc32c */
562 struct hash_desc conn_rx_hash
;
563 struct hash_desc conn_tx_hash
;
564 /* Used for scheduling TX and RX connection kthreads */
565 cpumask_var_t conn_cpumask
;
566 unsigned int conn_rx_reset_cpumask
:1;
567 unsigned int conn_tx_reset_cpumask
:1;
568 /* list_head of struct iscsi_cmd for this connection */
569 struct list_head conn_cmd_list
;
570 struct list_head immed_queue_list
;
571 struct list_head response_queue_list
;
572 struct iscsi_conn_ops
*conn_ops
;
573 struct iscsi_param_list
*param_list
;
574 /* Used for per connection auth state machine */
576 struct iscsi_login_thread_s
*login_thread
;
577 struct iscsi_portal_group
*tpg
;
578 /* Pointer to parent session */
579 struct iscsi_session
*sess
;
580 /* Pointer to thread_set in use for this conn's threads */
581 struct iscsi_thread_set
*thread_set
;
582 /* list_head for session connection list */
583 struct list_head conn_list
;
584 } ____cacheline_aligned
;
586 struct iscsi_conn_recovery
{
589 u32 maxrecvdatasegmentlength
;
590 int ready_for_reallegiance
;
591 struct list_head conn_recovery_cmd_list
;
592 spinlock_t conn_recovery_cmd_lock
;
593 struct timer_list time2retain_timer
;
594 struct iscsi_session
*sess
;
595 struct list_head cr_list
;
596 } ____cacheline_aligned
;
598 struct iscsi_session
{
601 enum iscsi_timer_flags_table time2retain_timer_flags
;
604 u16 conn_recovery_count
;
606 /* state session is currently in */
608 /* session wide counter: initiator assigned task tag */
610 /* session wide counter: target assigned task tag */
614 /* protects cmdsn values */
615 struct mutex cmdsn_mutex
;
616 /* session wide counter: expected command sequence number */
618 /* session wide counter: maximum allowed command sequence number */
620 struct list_head sess_ooo_cmdsn_list
;
622 /* LIO specific session ID */
625 /* unique within the target */
627 /* Used for session reference counting */
628 int session_usage_count
;
629 int session_waiting_on_uc
;
634 u32 conn_digest_errors
;
635 u32 conn_timeout_errors
;
637 spinlock_t session_stats_lock
;
638 /* Number of active connections */
640 atomic_t session_continuation
;
641 atomic_t session_fall_back_to_erl0
;
642 atomic_t session_logout
;
643 atomic_t session_reinstatement
;
644 atomic_t session_stop_active
;
645 atomic_t sleep_on_sess_wait_comp
;
646 /* connection list */
647 struct list_head sess_conn_list
;
648 struct list_head cr_active_list
;
649 struct list_head cr_inactive_list
;
650 spinlock_t conn_lock
;
651 spinlock_t cr_a_lock
;
652 spinlock_t cr_i_lock
;
653 spinlock_t session_usage_lock
;
655 struct completion async_msg_comp
;
656 struct completion reinstatement_comp
;
657 struct completion session_wait_comp
;
658 struct completion session_waiting_on_uc_comp
;
659 struct timer_list time2retain_timer
;
660 struct iscsi_sess_ops
*sess_ops
;
661 struct se_session
*se_sess
;
662 struct iscsi_portal_group
*tpg
;
663 } ____cacheline_aligned
;
667 u8 checked_for_existing
;
669 u8 leading_connection
;
676 u32 initial_exp_statsn
;
684 } ____cacheline_aligned
;
686 struct iscsi_node_attrib
{
688 u32 dataout_timeout_retries
;
691 u32 nopin_response_timeout
;
692 u32 random_datain_pdu_offsets
;
693 u32 random_datain_seq_offsets
;
694 u32 random_r2t_offsets
;
697 struct iscsi_node_acl
*nacl
;
700 struct se_dev_entry_s
;
702 struct iscsi_node_auth
{
703 enum naf_flags_table naf_flags
;
704 int authenticate_target
;
705 /* Used for iscsit_global->discovery_auth,
706 * set to zero (auth disabled) by default */
707 int enforce_discovery_auth
;
708 #define MAX_USER_LEN 256
709 #define MAX_PASS_LEN 256
710 char userid
[MAX_USER_LEN
];
711 char password
[MAX_PASS_LEN
];
712 char userid_mutual
[MAX_USER_LEN
];
713 char password_mutual
[MAX_PASS_LEN
];
716 #include "iscsi_target_stat.h"
718 struct iscsi_node_stat_grps
{
719 struct config_group iscsi_sess_stats_group
;
720 struct config_group iscsi_conn_stats_group
;
723 struct iscsi_node_acl
{
724 struct iscsi_node_attrib node_attrib
;
725 struct iscsi_node_auth node_auth
;
726 struct iscsi_node_stat_grps node_stat_grps
;
727 struct se_node_acl se_node_acl
;
730 #define NODE_STAT_GRPS(nacl) (&(nacl)->node_stat_grps)
732 #define ISCSI_NODE_ATTRIB(t) (&(t)->node_attrib)
733 #define ISCSI_NODE_AUTH(t) (&(t)->node_auth)
735 struct iscsi_tpg_attrib
{
739 u32 generate_node_acls
;
740 u32 cache_dynamic_acls
;
741 u32 default_cmdsn_depth
;
742 u32 demo_mode_write_protect
;
743 u32 prod_mode_write_protect
;
744 struct iscsi_portal_group
*tpg
;
748 int np_network_transport
;
751 enum np_thread_state_table np_thread_state
;
752 enum iscsi_timer_flags_table np_login_timer_flags
;
754 enum np_flags_table np_flags
;
755 unsigned char np_ip
[IPV6_ADDRESS_SPACE
];
757 spinlock_t np_thread_lock
;
758 struct completion np_restart_comp
;
759 struct socket
*np_socket
;
760 struct __kernel_sockaddr_storage np_sockaddr
;
761 struct task_struct
*np_thread
;
762 struct timer_list np_login_timer
;
763 struct iscsi_portal_group
*np_login_tpg
;
764 struct list_head np_list
;
765 } ____cacheline_aligned
;
767 struct iscsi_tpg_np
{
768 struct iscsi_np
*tpg_np
;
769 struct iscsi_portal_group
*tpg
;
770 struct iscsi_tpg_np
*tpg_np_parent
;
771 struct list_head tpg_np_list
;
772 struct list_head tpg_np_child_list
;
773 struct list_head tpg_np_parent_list
;
774 struct se_tpg_np se_tpg_np
;
775 spinlock_t tpg_np_parent_lock
;
778 struct iscsi_portal_group
{
779 unsigned char tpg_chap_id
;
781 enum tpg_state_table tpg_state
;
782 /* Target Portal Group Tag */
784 /* Id assigned to target sessions */
786 /* Number of active sessions */
788 /* Number of Network Portals available for this TPG */
790 /* Per TPG LIO specific session ID. */
792 /* Spinlock for adding/removing Network Portals */
793 spinlock_t tpg_np_lock
;
794 spinlock_t tpg_state_lock
;
795 struct se_portal_group tpg_se_tpg
;
796 struct mutex tpg_access_lock
;
797 struct mutex np_login_lock
;
798 struct iscsi_tpg_attrib tpg_attrib
;
799 /* Pointer to default list of iSCSI parameters for TPG */
800 struct iscsi_param_list
*param_list
;
801 struct iscsi_tiqn
*tpg_tiqn
;
802 struct list_head tpg_gnp_list
;
803 struct list_head tpg_list
;
804 } ____cacheline_aligned
;
806 #define ISCSI_TPG_C(c) ((struct iscsi_portal_group *)(c)->tpg)
807 #define ISCSI_TPG_LUN(c, l) ((iscsi_tpg_list_t *)(c)->tpg->tpg_lun_list_t[l])
808 #define ISCSI_TPG_S(s) ((struct iscsi_portal_group *)(s)->tpg)
809 #define ISCSI_TPG_ATTRIB(t) (&(t)->tpg_attrib)
810 #define SE_TPG(tpg) (&(tpg)->tpg_se_tpg)
812 struct iscsi_wwn_stat_grps
{
813 struct config_group iscsi_stat_group
;
814 struct config_group iscsi_instance_group
;
815 struct config_group iscsi_sess_err_group
;
816 struct config_group iscsi_tgt_attr_group
;
817 struct config_group iscsi_login_stats_group
;
818 struct config_group iscsi_logout_stats_group
;
822 #define ISCSI_IQN_LEN 224
823 unsigned char tiqn
[ISCSI_IQN_LEN
];
824 enum tiqn_state_table tiqn_state
;
825 int tiqn_access_count
;
826 u32 tiqn_active_tpgs
;
828 u32 tiqn_num_tpg_nps
;
830 struct list_head tiqn_list
;
831 struct list_head tiqn_tpg_list
;
832 spinlock_t tiqn_state_lock
;
833 spinlock_t tiqn_tpg_lock
;
834 struct se_wwn tiqn_wwn
;
835 struct iscsi_wwn_stat_grps tiqn_stat_grps
;
837 struct iscsi_sess_err_stats sess_err_stats
;
838 struct iscsi_login_stats login_stats
;
839 struct iscsi_logout_stats logout_stats
;
840 } ____cacheline_aligned
;
842 #define WWN_STAT_GRPS(tiqn) (&(tiqn)->tiqn_stat_grps)
844 struct iscsit_global
{
845 /* In core shutdown */
848 /* Unique identifier used for the authentication daemon */
851 /* Thread Set bitmap count */
853 /* Thread Set bitmap pointer */
854 unsigned long *ts_bitmap
;
855 /* Used for iSCSI discovery session authentication */
856 struct iscsi_node_acl discovery_acl
;
857 struct iscsi_portal_group
*discovery_tpg
;
860 #endif /* ISCSI_TARGET_CORE_H */