1 #ifndef ISCSI_TARGET_CORE_H
2 #define ISCSI_TARGET_CORE_H
5 #include <linux/configfs.h>
8 #include <scsi/iscsi_proto.h>
9 #include <target/target_core_base.h>
11 #define ISCSIT_VERSION "v4.1.0"
12 #define ISCSI_MAX_DATASN_MISSING_COUNT 16
13 #define ISCSI_TX_THREAD_TCP_TIMEOUT 2
14 #define ISCSI_RX_THREAD_TCP_TIMEOUT 2
15 #define SECONDS_FOR_ASYNC_LOGOUT 10
16 #define SECONDS_FOR_ASYNC_TEXT 10
17 #define SECONDS_FOR_LOGOUT_COMP 15
18 #define WHITE_SPACE " \t\v\f\n\r"
19 #define ISCSIT_MIN_TAGS 16
20 #define ISCSIT_EXTRA_TAGS 8
21 #define ISCSIT_TCP_BACKLOG 256
22 #define ISCSI_RX_THREAD_NAME "iscsi_trx"
23 #define ISCSI_TX_THREAD_NAME "iscsi_ttx"
25 /* struct iscsi_node_attrib sanity values */
26 #define NA_DATAOUT_TIMEOUT 3
27 #define NA_DATAOUT_TIMEOUT_MAX 60
28 #define NA_DATAOUT_TIMEOUT_MIX 2
29 #define NA_DATAOUT_TIMEOUT_RETRIES 5
30 #define NA_DATAOUT_TIMEOUT_RETRIES_MAX 15
31 #define NA_DATAOUT_TIMEOUT_RETRIES_MIN 1
32 #define NA_NOPIN_TIMEOUT 15
33 #define NA_NOPIN_TIMEOUT_MAX 60
34 #define NA_NOPIN_TIMEOUT_MIN 3
35 #define NA_NOPIN_RESPONSE_TIMEOUT 30
36 #define NA_NOPIN_RESPONSE_TIMEOUT_MAX 60
37 #define NA_NOPIN_RESPONSE_TIMEOUT_MIN 3
38 #define NA_RANDOM_DATAIN_PDU_OFFSETS 0
39 #define NA_RANDOM_DATAIN_SEQ_OFFSETS 0
40 #define NA_RANDOM_R2T_OFFSETS 0
42 /* struct iscsi_tpg_attrib sanity values */
43 #define TA_AUTHENTICATION 1
44 #define TA_LOGIN_TIMEOUT 15
45 #define TA_LOGIN_TIMEOUT_MAX 30
46 #define TA_LOGIN_TIMEOUT_MIN 5
47 #define TA_NETIF_TIMEOUT 2
48 #define TA_NETIF_TIMEOUT_MAX 15
49 #define TA_NETIF_TIMEOUT_MIN 2
50 #define TA_GENERATE_NODE_ACLS 0
51 #define TA_DEFAULT_CMDSN_DEPTH 64
52 #define TA_DEFAULT_CMDSN_DEPTH_MAX 512
53 #define TA_DEFAULT_CMDSN_DEPTH_MIN 1
54 #define TA_CACHE_DYNAMIC_ACLS 0
55 /* Enabled by default in demo mode (generic_node_acls=1) */
56 #define TA_DEMO_MODE_WRITE_PROTECT 1
57 /* Disabled by default in production mode w/ explict ACLs */
58 #define TA_PROD_MODE_WRITE_PROTECT 0
59 #define TA_DEMO_MODE_DISCOVERY 1
60 #define TA_DEFAULT_ERL 0
61 #define TA_CACHE_CORE_NPS 0
62 /* T10 protection information disabled by default */
63 #define TA_DEFAULT_T10_PI 0
64 #define TA_DEFAULT_FABRIC_PROT_TYPE 0
66 #define ISCSI_IOV_DATA_BUFFER 5
68 enum iscsit_transport_type
{
77 /* RFC-3720 7.1.4 Standard Connection State Diagram for a Target */
78 enum target_conn_state_table
{
79 TARG_CONN_STATE_FREE
= 0x1,
80 TARG_CONN_STATE_XPT_UP
= 0x3,
81 TARG_CONN_STATE_IN_LOGIN
= 0x4,
82 TARG_CONN_STATE_LOGGED_IN
= 0x5,
83 TARG_CONN_STATE_IN_LOGOUT
= 0x6,
84 TARG_CONN_STATE_LOGOUT_REQUESTED
= 0x7,
85 TARG_CONN_STATE_CLEANUP_WAIT
= 0x8,
88 /* RFC-3720 7.3.2 Session State Diagram for a Target */
89 enum target_sess_state_table
{
90 TARG_SESS_STATE_FREE
= 0x1,
91 TARG_SESS_STATE_ACTIVE
= 0x2,
92 TARG_SESS_STATE_LOGGED_IN
= 0x3,
93 TARG_SESS_STATE_FAILED
= 0x4,
94 TARG_SESS_STATE_IN_CONTINUE
= 0x5,
97 /* struct iscsi_data_count->type */
98 enum data_count_type
{
103 /* struct iscsi_datain_req->dr_complete */
104 enum datain_req_comp_table
{
105 DATAIN_COMPLETE_NORMAL
= 1,
106 DATAIN_COMPLETE_WITHIN_COMMAND_RECOVERY
= 2,
107 DATAIN_COMPLETE_CONNECTION_RECOVERY
= 3,
110 /* struct iscsi_datain_req->recovery */
111 enum datain_req_rec_table
{
112 DATAIN_WITHIN_COMMAND_RECOVERY
= 1,
113 DATAIN_CONNECTION_RECOVERY
= 2,
116 /* struct iscsi_portal_group->state */
117 enum tpg_state_table
{
119 TPG_STATE_ACTIVE
= 1,
120 TPG_STATE_INACTIVE
= 2,
121 TPG_STATE_COLD_RESET
= 3,
124 /* struct iscsi_tiqn->tiqn_state */
125 enum tiqn_state_table
{
126 TIQN_STATE_ACTIVE
= 1,
127 TIQN_STATE_SHUTDOWN
= 2,
130 /* struct iscsi_cmd->cmd_flags */
131 enum cmd_flags_table
{
132 ICF_GOT_LAST_DATAOUT
= 0x00000001,
133 ICF_GOT_DATACK_SNACK
= 0x00000002,
134 ICF_NON_IMMEDIATE_UNSOLICITED_DATA
= 0x00000004,
135 ICF_SENT_LAST_R2T
= 0x00000008,
136 ICF_WITHIN_COMMAND_RECOVERY
= 0x00000010,
137 ICF_CONTIG_MEMORY
= 0x00000020,
138 ICF_ATTACHED_TO_RQUEUE
= 0x00000040,
139 ICF_OOO_CMDSN
= 0x00000080,
140 ICF_SENDTARGETS_ALL
= 0x00000100,
141 ICF_SENDTARGETS_SINGLE
= 0x00000200,
144 /* struct iscsi_cmd->i_state */
145 enum cmd_i_state_table
{
148 ISTATE_DEFERRED_CMD
= 2,
149 ISTATE_UNSOLICITED_DATA
= 3,
150 ISTATE_RECEIVE_DATAOUT
= 4,
151 ISTATE_RECEIVE_DATAOUT_RECOVERY
= 5,
152 ISTATE_RECEIVED_LAST_DATAOUT
= 6,
153 ISTATE_WITHIN_DATAOUT_RECOVERY
= 7,
154 ISTATE_IN_CONNECTION_RECOVERY
= 8,
155 ISTATE_RECEIVED_TASKMGT
= 9,
156 ISTATE_SEND_ASYNCMSG
= 10,
157 ISTATE_SENT_ASYNCMSG
= 11,
158 ISTATE_SEND_DATAIN
= 12,
159 ISTATE_SEND_LAST_DATAIN
= 13,
160 ISTATE_SENT_LAST_DATAIN
= 14,
161 ISTATE_SEND_LOGOUTRSP
= 15,
162 ISTATE_SENT_LOGOUTRSP
= 16,
163 ISTATE_SEND_NOPIN
= 17,
164 ISTATE_SENT_NOPIN
= 18,
165 ISTATE_SEND_REJECT
= 19,
166 ISTATE_SENT_REJECT
= 20,
167 ISTATE_SEND_R2T
= 21,
168 ISTATE_SENT_R2T
= 22,
169 ISTATE_SEND_R2T_RECOVERY
= 23,
170 ISTATE_SENT_R2T_RECOVERY
= 24,
171 ISTATE_SEND_LAST_R2T
= 25,
172 ISTATE_SENT_LAST_R2T
= 26,
173 ISTATE_SEND_LAST_R2T_RECOVERY
= 27,
174 ISTATE_SENT_LAST_R2T_RECOVERY
= 28,
175 ISTATE_SEND_STATUS
= 29,
176 ISTATE_SEND_STATUS_BROKEN_PC
= 30,
177 ISTATE_SENT_STATUS
= 31,
178 ISTATE_SEND_STATUS_RECOVERY
= 32,
179 ISTATE_SENT_STATUS_RECOVERY
= 33,
180 ISTATE_SEND_TASKMGTRSP
= 34,
181 ISTATE_SENT_TASKMGTRSP
= 35,
182 ISTATE_SEND_TEXTRSP
= 36,
183 ISTATE_SENT_TEXTRSP
= 37,
184 ISTATE_SEND_NOPIN_WANT_RESPONSE
= 38,
185 ISTATE_SENT_NOPIN_WANT_RESPONSE
= 39,
186 ISTATE_SEND_NOPIN_NO_RESPONSE
= 40,
191 /* Used for iscsi_recover_cmdsn() return values */
192 enum recover_cmdsn_ret_table
{
193 CMDSN_ERROR_CANNOT_RECOVER
= -1,
194 CMDSN_NORMAL_OPERATION
= 0,
195 CMDSN_LOWER_THAN_EXP
= 1,
196 CMDSN_HIGHER_THAN_EXP
= 2,
197 CMDSN_MAXCMDSN_OVERRUN
= 3,
200 /* Used for iscsi_handle_immediate_data() return values */
201 enum immedate_data_ret_table
{
202 IMMEDIATE_DATA_CANNOT_RECOVER
= -1,
203 IMMEDIATE_DATA_NORMAL_OPERATION
= 0,
204 IMMEDIATE_DATA_ERL1_CRC_FAILURE
= 1,
207 /* Used for iscsi_decide_dataout_action() return values */
208 enum dataout_action_ret_table
{
209 DATAOUT_CANNOT_RECOVER
= -1,
211 DATAOUT_SEND_R2T
= 1,
212 DATAOUT_SEND_TO_TRANSPORT
= 2,
213 DATAOUT_WITHIN_COMMAND_RECOVERY
= 3,
216 /* Used for struct iscsi_node_auth->naf_flags */
217 enum naf_flags_table
{
218 NAF_USERID_SET
= 0x01,
219 NAF_PASSWORD_SET
= 0x02,
220 NAF_USERID_IN_SET
= 0x04,
221 NAF_PASSWORD_IN_SET
= 0x08,
224 /* Used by various struct timer_list to manage iSCSI specific state */
225 enum iscsi_timer_flags_table
{
226 ISCSI_TF_RUNNING
= 0x01,
227 ISCSI_TF_STOP
= 0x02,
228 ISCSI_TF_EXPIRED
= 0x04,
231 /* Used for struct iscsi_np->np_flags */
232 enum np_flags_table
{
233 NPF_IP_NETWORK
= 0x00,
236 /* Used for struct iscsi_np->np_thread_state */
237 enum np_thread_state_table
{
238 ISCSI_NP_THREAD_ACTIVE
= 1,
239 ISCSI_NP_THREAD_INACTIVE
= 2,
240 ISCSI_NP_THREAD_RESET
= 3,
241 ISCSI_NP_THREAD_SHUTDOWN
= 4,
242 ISCSI_NP_THREAD_EXIT
= 5,
245 struct iscsi_conn_ops
{
246 u8 HeaderDigest
; /* [0,1] == [None,CRC32C] */
247 u8 DataDigest
; /* [0,1] == [None,CRC32C] */
248 u32 MaxRecvDataSegmentLength
; /* [512..2**24-1] */
249 u32 MaxXmitDataSegmentLength
; /* [512..2**24-1] */
251 * iSER specific connection parameters
253 u32 InitiatorRecvDataSegmentLength
; /* [512..2**24-1] */
254 u32 TargetRecvDataSegmentLength
; /* [512..2**24-1] */
257 struct iscsi_sess_ops
{
258 char InitiatorName
[224];
259 char InitiatorAlias
[256];
260 char TargetName
[224];
261 char TargetAlias
[256];
262 char TargetAddress
[256];
263 u16 TargetPortalGroupTag
; /* [0..65535] */
264 u16 MaxConnections
; /* [1..65535] */
265 u8 InitialR2T
; /* [0,1] == [No,Yes] */
266 u8 ImmediateData
; /* [0,1] == [No,Yes] */
267 u32 MaxBurstLength
; /* [512..2**24-1] */
268 u32 FirstBurstLength
; /* [512..2**24-1] */
269 u16 DefaultTime2Wait
; /* [0..3600] */
270 u16 DefaultTime2Retain
; /* [0..3600] */
271 u16 MaxOutstandingR2T
; /* [1..65535] */
272 u8 DataPDUInOrder
; /* [0,1] == [No,Yes] */
273 u8 DataSequenceInOrder
; /* [0,1] == [No,Yes] */
274 u8 ErrorRecoveryLevel
; /* [0..2] */
275 u8 SessionType
; /* [0,1] == [Normal,Discovery]*/
277 * iSER specific session parameters
279 u8 RDMAExtensions
; /* [0,1] == [No,Yes] */
282 struct iscsi_queue_req
{
284 struct iscsi_cmd
*cmd
;
285 struct list_head qr_list
;
288 struct iscsi_data_count
{
290 int sync_and_steering
;
291 enum data_count_type type
;
298 struct iscsi_param_list
{
300 struct list_head param_list
;
301 struct list_head extra_response_list
;
304 struct iscsi_datain_req
{
305 enum datain_req_comp_table dr_complete
;
306 int generate_recovery_values
;
307 enum datain_req_rec_table recovery
;
316 struct list_head cmd_datain_node
;
317 } ____cacheline_aligned
;
319 struct iscsi_ooo_cmdsn
{
324 struct iscsi_cmd
*cmd
;
325 struct list_head ooo_list
;
326 } ____cacheline_aligned
;
328 struct iscsi_datain
{
333 } ____cacheline_aligned
;
343 struct list_head r2t_list
;
344 } ____cacheline_aligned
;
347 enum iscsi_timer_flags_table dataout_timer_flags
;
348 /* DataOUT timeout retries */
349 u8 dataout_timeout_retries
;
350 /* Within command recovery count */
351 u8 error_recovery_count
;
352 /* iSCSI dependent state for out or order CmdSNs */
353 enum cmd_i_state_table deferred_i_state
;
354 /* iSCSI dependent state */
355 enum cmd_i_state_table i_state
;
356 /* Command is an immediate command (ISCSI_OP_IMMEDIATE set) */
358 /* Immediate data present */
362 /* iSCSI Response Code */
364 /* Logout reason when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
366 /* Logout response code when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
368 /* MaxCmdSN has been incremented */
370 /* Immediate Unsolicited Dataout */
372 /* Reject reason code */
374 /* CID contained in logout PDU when opcode == ISCSI_INIT_LOGOUT_CMND */
377 enum cmd_flags_table cmd_flags
;
378 /* Initiator Task Tag assigned from Initiator */
380 /* Target Transfer Tag assigned from Target */
382 /* CmdSN assigned from Initiator */
384 /* ExpStatSN assigned from Initiator */
386 /* StatSN assigned to this ITT */
392 /* Last DataSN acknowledged via DataAck SNACK */
394 /* Used for echoing NOPOUT ping data */
396 /* Used to store DataDigest */
398 /* Counter for MaxOutstandingR2T */
399 u32 outstanding_r2ts
;
400 /* Next R2T Offset when DataSequenceInOrder=Yes */
402 /* Iovec current and orig count for iscsi_cmd->iov_data */
404 u32 orig_iov_data_count
;
405 /* Number of miscellaneous iovecs used for IP stack calls */
407 /* Number of struct iscsi_pdu in struct iscsi_cmd->pdu_list */
409 /* Next struct iscsi_pdu to send in struct iscsi_cmd->pdu_list */
411 /* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */
413 /* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */
415 /* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */
417 /* Current struct iscsi_seq in struct iscsi_cmd->seq_list */
419 /* Lowest offset in current DataOUT sequence */
420 u32 seq_start_offset
;
421 /* Highest offset in current DataOUT sequence */
423 /* Total size in bytes received so far of READ data */
425 /* Total size in bytes received so far of WRITE data */
427 /* Counter for FirstBurstLength key */
429 /* Counter for MaxBurstLength key */
431 /* Transfer size used for IP stack calls */
433 /* Buffer used for various purposes */
435 /* Used by SendTargets=[iqn.,eui.] discovery */
437 /* See include/linux/dma-mapping.h */
438 enum dma_data_direction data_direction
;
439 /* iSCSI PDU Header + CRC */
440 unsigned char pdu
[ISCSI_HDR_LEN
+ ISCSI_CRC_LEN
];
441 /* Number of times struct iscsi_cmd is present in immediate queue */
442 atomic_t immed_queue_count
;
443 atomic_t response_queue_count
;
444 spinlock_t datain_lock
;
445 spinlock_t dataout_timeout_lock
;
446 /* spinlock for protecting struct iscsi_cmd->i_state */
447 spinlock_t istate_lock
;
448 /* spinlock for adding within command recovery entries */
449 spinlock_t error_lock
;
450 /* spinlock for adding R2Ts */
453 struct list_head datain_list
;
455 struct list_head cmd_r2t_list
;
456 /* Timer for DataOUT */
457 struct timer_list dataout_timer
;
458 /* Iovecs for SCSI data payload RX/TX w/ kernel level sockets */
459 struct kvec
*iov_data
;
460 /* Iovecs for miscellaneous purposes */
461 #define ISCSI_MISC_IOVECS 5
462 struct kvec iov_misc
[ISCSI_MISC_IOVECS
];
463 /* Array of struct iscsi_pdu used for DataPDUInOrder=No */
464 struct iscsi_pdu
*pdu_list
;
465 /* Current struct iscsi_pdu used for DataPDUInOrder=No */
466 struct iscsi_pdu
*pdu_ptr
;
467 /* Array of struct iscsi_seq used for DataSequenceInOrder=No */
468 struct iscsi_seq
*seq_list
;
469 /* Current struct iscsi_seq used for DataSequenceInOrder=No */
470 struct iscsi_seq
*seq_ptr
;
471 /* TMR Request when iscsi_opcode == ISCSI_OP_SCSI_TMFUNC */
472 struct iscsi_tmr_req
*tmr_req
;
473 /* Connection this command is alligient to */
474 struct iscsi_conn
*conn
;
475 /* Pointer to connection recovery entry */
476 struct iscsi_conn_recovery
*cr
;
477 /* Session the command is part of, used for connection recovery */
478 struct iscsi_session
*sess
;
479 /* list_head for connection list */
480 struct list_head i_conn_node
;
481 /* The TCM I/O descriptor that is accessed via container_of() */
482 struct se_cmd se_cmd
;
483 /* Sense buffer that will be mapped into outgoing status */
484 #define ISCSI_SENSE_BUFFER_LEN (TRANSPORT_SENSE_BUFFER + 2)
485 unsigned char sense_buffer
[ISCSI_SENSE_BUFFER_LEN
];
490 struct scatterlist
*first_data_sg
;
491 u32 first_data_sg_off
;
493 sense_reason_t sense_reason
;
494 } ____cacheline_aligned
;
496 struct iscsi_tmr_req
{
497 bool task_reassign
:1;
499 struct iscsi_cmd
*ref_cmd
;
500 struct iscsi_conn_recovery
*conn_recovery
;
501 struct se_tmr_req
*se_tmr_req
;
505 wait_queue_head_t queues_wq
;
506 /* Authentication Successful for this connection */
508 /* State connection is currently in */
510 u8 conn_logout_reason
;
511 u8 network_transport
;
512 enum iscsi_timer_flags_table nopin_timer_flags
;
513 enum iscsi_timer_flags_table nopin_response_timer_flags
;
514 /* Used to know what thread encountered a transport failure */
516 /* connection id assigned by the Initiator */
518 /* Remote TCP Port */
525 /* Used for iscsi_tx_login_rsp() */
528 /* Per connection status sequence number */
530 #define IPV6_ADDRESS_SPACE 48
531 unsigned char login_ip
[IPV6_ADDRESS_SPACE
];
532 unsigned char local_ip
[IPV6_ADDRESS_SPACE
];
533 int conn_usage_count
;
534 int conn_waiting_on_uc
;
535 atomic_t check_immediate_queue
;
536 atomic_t conn_logout_remove
;
537 atomic_t connection_exit
;
538 atomic_t connection_recovery
;
539 atomic_t connection_reinstatement
;
540 atomic_t connection_wait_rcfr
;
541 atomic_t sleep_on_conn_wait_comp
;
542 atomic_t transport_failed
;
543 struct completion conn_post_wait_comp
;
544 struct completion conn_wait_comp
;
545 struct completion conn_wait_rcfr_comp
;
546 struct completion conn_waiting_on_uc_comp
;
547 struct completion conn_logout_comp
;
548 struct completion tx_half_close_comp
;
549 struct completion rx_half_close_comp
;
550 /* socket used by this connection */
552 void (*orig_data_ready
)(struct sock
*);
553 void (*orig_state_change
)(struct sock
*);
554 #define LOGIN_FLAGS_READ_ACTIVE 1
555 #define LOGIN_FLAGS_CLOSED 2
556 #define LOGIN_FLAGS_READY 4
557 unsigned long login_flags
;
558 struct delayed_work login_work
;
559 struct delayed_work login_cleanup_work
;
560 struct iscsi_login
*login
;
561 struct timer_list nopin_timer
;
562 struct timer_list nopin_response_timer
;
563 struct timer_list transport_timer
;
564 struct task_struct
*login_kworker
;
565 /* Spinlock used for add/deleting cmd's from conn_cmd_list */
567 spinlock_t conn_usage_lock
;
568 spinlock_t immed_queue_lock
;
569 spinlock_t nopin_timer_lock
;
570 spinlock_t response_queue_lock
;
571 spinlock_t state_lock
;
572 /* libcrypto RX and TX contexts for crc32c */
573 struct hash_desc conn_rx_hash
;
574 struct hash_desc conn_tx_hash
;
575 /* Used for scheduling TX and RX connection kthreads */
576 cpumask_var_t conn_cpumask
;
577 unsigned int conn_rx_reset_cpumask
:1;
578 unsigned int conn_tx_reset_cpumask
:1;
579 /* list_head of struct iscsi_cmd for this connection */
580 struct list_head conn_cmd_list
;
581 struct list_head immed_queue_list
;
582 struct list_head response_queue_list
;
583 struct iscsi_conn_ops
*conn_ops
;
584 struct iscsi_login
*conn_login
;
585 struct iscsit_transport
*conn_transport
;
586 struct iscsi_param_list
*param_list
;
587 /* Used for per connection auth state machine */
590 struct iscsi_login_thread_s
*login_thread
;
591 struct iscsi_portal_group
*tpg
;
592 struct iscsi_tpg_np
*tpg_np
;
593 /* Pointer to parent session */
594 struct iscsi_session
*sess
;
596 int rx_thread_active
;
597 struct task_struct
*rx_thread
;
598 struct completion rx_login_comp
;
599 int tx_thread_active
;
600 struct task_struct
*tx_thread
;
601 /* list_head for session connection list */
602 struct list_head conn_list
;
603 } ____cacheline_aligned
;
605 struct iscsi_conn_recovery
{
608 u32 maxrecvdatasegmentlength
;
609 u32 maxxmitdatasegmentlength
;
610 int ready_for_reallegiance
;
611 struct list_head conn_recovery_cmd_list
;
612 spinlock_t conn_recovery_cmd_lock
;
613 struct timer_list time2retain_timer
;
614 struct iscsi_session
*sess
;
615 struct list_head cr_list
;
616 } ____cacheline_aligned
;
618 struct iscsi_session
{
621 enum iscsi_timer_flags_table time2retain_timer_flags
;
624 u16 conn_recovery_count
;
626 /* state session is currently in */
628 /* session wide counter: initiator assigned task tag */
630 /* session wide counter: target assigned task tag */
634 /* protects cmdsn values */
635 struct mutex cmdsn_mutex
;
636 /* session wide counter: expected command sequence number */
638 /* session wide counter: maximum allowed command sequence number */
640 struct list_head sess_ooo_cmdsn_list
;
642 /* LIO specific session ID */
645 /* unique within the target */
647 /* Used for session reference counting */
648 int session_usage_count
;
649 int session_waiting_on_uc
;
650 atomic_long_t cmd_pdus
;
651 atomic_long_t rsp_pdus
;
652 atomic_long_t tx_data_octets
;
653 atomic_long_t rx_data_octets
;
654 atomic_long_t conn_digest_errors
;
655 atomic_long_t conn_timeout_errors
;
657 /* Number of active connections */
659 atomic_t session_continuation
;
660 atomic_t session_fall_back_to_erl0
;
661 atomic_t session_logout
;
662 atomic_t session_reinstatement
;
663 atomic_t session_stop_active
;
664 atomic_t sleep_on_sess_wait_comp
;
665 /* connection list */
666 struct list_head sess_conn_list
;
667 struct list_head cr_active_list
;
668 struct list_head cr_inactive_list
;
669 spinlock_t conn_lock
;
670 spinlock_t cr_a_lock
;
671 spinlock_t cr_i_lock
;
672 spinlock_t session_usage_lock
;
674 struct completion async_msg_comp
;
675 struct completion reinstatement_comp
;
676 struct completion session_wait_comp
;
677 struct completion session_waiting_on_uc_comp
;
678 struct timer_list time2retain_timer
;
679 struct iscsi_sess_ops
*sess_ops
;
680 struct se_session
*se_sess
;
681 struct iscsi_portal_group
*tpg
;
682 } ____cacheline_aligned
;
686 u8 checked_for_existing
;
688 u8 leading_connection
;
698 u32 initial_exp_statsn
;
702 char req
[ISCSI_HDR_LEN
];
703 char rsp
[ISCSI_HDR_LEN
];
706 struct iscsi_conn
*conn
;
708 } ____cacheline_aligned
;
710 struct iscsi_node_attrib
{
712 u32 dataout_timeout_retries
;
715 u32 nopin_response_timeout
;
716 u32 random_datain_pdu_offsets
;
717 u32 random_datain_seq_offsets
;
718 u32 random_r2t_offsets
;
721 struct iscsi_node_acl
*nacl
;
724 struct se_dev_entry_s
;
726 struct iscsi_node_auth
{
727 enum naf_flags_table naf_flags
;
728 int authenticate_target
;
729 /* Used for iscsit_global->discovery_auth,
730 * set to zero (auth disabled) by default */
731 int enforce_discovery_auth
;
732 #define MAX_USER_LEN 256
733 #define MAX_PASS_LEN 256
734 char userid
[MAX_USER_LEN
];
735 char password
[MAX_PASS_LEN
];
736 char userid_mutual
[MAX_USER_LEN
];
737 char password_mutual
[MAX_PASS_LEN
];
740 #include "iscsi_target_stat.h"
742 struct iscsi_node_stat_grps
{
743 struct config_group iscsi_sess_stats_group
;
744 struct config_group iscsi_conn_stats_group
;
747 struct iscsi_node_acl
{
748 struct se_node_acl se_node_acl
;
749 struct iscsi_node_attrib node_attrib
;
750 struct iscsi_node_auth node_auth
;
751 struct iscsi_node_stat_grps node_stat_grps
;
754 struct iscsi_tpg_attrib
{
758 u32 generate_node_acls
;
759 u32 cache_dynamic_acls
;
760 u32 default_cmdsn_depth
;
761 u32 demo_mode_write_protect
;
762 u32 prod_mode_write_protect
;
763 u32 demo_mode_discovery
;
766 u32 fabric_prot_type
;
767 struct iscsi_portal_group
*tpg
;
771 int np_network_transport
;
774 enum np_thread_state_table np_thread_state
;
776 enum iscsi_timer_flags_table np_login_timer_flags
;
778 enum np_flags_table np_flags
;
779 unsigned char np_ip
[IPV6_ADDRESS_SPACE
];
781 spinlock_t np_thread_lock
;
782 struct completion np_restart_comp
;
783 struct socket
*np_socket
;
784 struct __kernel_sockaddr_storage np_sockaddr
;
785 struct task_struct
*np_thread
;
786 struct timer_list np_login_timer
;
788 struct iscsit_transport
*np_transport
;
789 struct list_head np_list
;
790 } ____cacheline_aligned
;
792 struct iscsi_tpg_np
{
793 struct iscsi_np
*tpg_np
;
794 struct iscsi_portal_group
*tpg
;
795 struct iscsi_tpg_np
*tpg_np_parent
;
796 struct list_head tpg_np_list
;
797 struct list_head tpg_np_child_list
;
798 struct list_head tpg_np_parent_list
;
799 struct se_tpg_np se_tpg_np
;
800 spinlock_t tpg_np_parent_lock
;
801 struct completion tpg_np_comp
;
802 struct kref tpg_np_kref
;
805 struct iscsi_portal_group
{
806 unsigned char tpg_chap_id
;
808 enum tpg_state_table tpg_state
;
809 /* Target Portal Group Tag */
811 /* Id assigned to target sessions */
813 /* Number of active sessions */
815 /* Number of Network Portals available for this TPG */
817 /* Per TPG LIO specific session ID. */
819 /* Spinlock for adding/removing Network Portals */
820 spinlock_t tpg_np_lock
;
821 spinlock_t tpg_state_lock
;
822 struct se_portal_group tpg_se_tpg
;
823 struct mutex tpg_access_lock
;
824 struct semaphore np_login_sem
;
825 struct iscsi_tpg_attrib tpg_attrib
;
826 struct iscsi_node_auth tpg_demo_auth
;
827 /* Pointer to default list of iSCSI parameters for TPG */
828 struct iscsi_param_list
*param_list
;
829 struct iscsi_tiqn
*tpg_tiqn
;
830 struct list_head tpg_gnp_list
;
831 struct list_head tpg_list
;
832 } ____cacheline_aligned
;
834 struct iscsi_wwn_stat_grps
{
835 struct config_group iscsi_stat_group
;
836 struct config_group iscsi_instance_group
;
837 struct config_group iscsi_sess_err_group
;
838 struct config_group iscsi_tgt_attr_group
;
839 struct config_group iscsi_login_stats_group
;
840 struct config_group iscsi_logout_stats_group
;
844 #define ISCSI_IQN_LEN 224
845 unsigned char tiqn
[ISCSI_IQN_LEN
];
846 enum tiqn_state_table tiqn_state
;
847 int tiqn_access_count
;
848 u32 tiqn_active_tpgs
;
850 u32 tiqn_num_tpg_nps
;
852 struct list_head tiqn_list
;
853 struct list_head tiqn_tpg_list
;
854 spinlock_t tiqn_state_lock
;
855 spinlock_t tiqn_tpg_lock
;
856 struct se_wwn tiqn_wwn
;
857 struct iscsi_wwn_stat_grps tiqn_stat_grps
;
859 struct iscsi_sess_err_stats sess_err_stats
;
860 struct iscsi_login_stats login_stats
;
861 struct iscsi_logout_stats logout_stats
;
862 } ____cacheline_aligned
;
864 struct iscsit_global
{
865 /* In core shutdown */
868 /* Unique identifier used for the authentication daemon */
871 #define ISCSIT_BITMAP_BITS 262144
872 /* Thread Set bitmap pointer */
873 unsigned long *ts_bitmap
;
874 spinlock_t ts_bitmap_lock
;
875 /* Used for iSCSI discovery session authentication */
876 struct iscsi_node_acl discovery_acl
;
877 struct iscsi_portal_group
*discovery_tpg
;
880 static inline u32
session_get_next_ttt(struct iscsi_session
*session
)
884 spin_lock_bh(&session
->ttt_lock
);
885 ttt
= session
->targ_xfer_tag
++;
886 if (ttt
== 0xFFFFFFFF)
887 ttt
= session
->targ_xfer_tag
++;
888 spin_unlock_bh(&session
->ttt_lock
);
893 extern struct iscsi_cmd
*iscsit_find_cmd_from_itt(struct iscsi_conn
*, itt_t
);
894 #endif /* ISCSI_TARGET_CORE_H */