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"
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"
20 #define ISCSIT_MIN_TAGS 16
21 #define ISCSIT_EXTRA_TAGS 8
22 #define ISCSIT_TCP_BACKLOG 256
24 /* struct iscsi_node_attrib sanity values */
25 #define NA_DATAOUT_TIMEOUT 3
26 #define NA_DATAOUT_TIMEOUT_MAX 60
27 #define NA_DATAOUT_TIMEOUT_MIX 2
28 #define NA_DATAOUT_TIMEOUT_RETRIES 5
29 #define NA_DATAOUT_TIMEOUT_RETRIES_MAX 15
30 #define NA_DATAOUT_TIMEOUT_RETRIES_MIN 1
31 #define NA_NOPIN_TIMEOUT 15
32 #define NA_NOPIN_TIMEOUT_MAX 60
33 #define NA_NOPIN_TIMEOUT_MIN 3
34 #define NA_NOPIN_RESPONSE_TIMEOUT 30
35 #define NA_NOPIN_RESPONSE_TIMEOUT_MAX 60
36 #define NA_NOPIN_RESPONSE_TIMEOUT_MIN 3
37 #define NA_RANDOM_DATAIN_PDU_OFFSETS 0
38 #define NA_RANDOM_DATAIN_SEQ_OFFSETS 0
39 #define NA_RANDOM_R2T_OFFSETS 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 64
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_DEMO_MODE_DISCOVERY 1
59 #define TA_DEFAULT_ERL 0
60 #define TA_CACHE_CORE_NPS 0
61 /* T10 protection information disabled by default */
62 #define TA_DEFAULT_T10_PI 0
64 #define ISCSI_IOV_DATA_BUFFER 5
66 enum iscsit_transport_type
{
75 /* RFC-3720 7.1.4 Standard Connection State Diagram for a Target */
76 enum target_conn_state_table
{
77 TARG_CONN_STATE_FREE
= 0x1,
78 TARG_CONN_STATE_XPT_UP
= 0x3,
79 TARG_CONN_STATE_IN_LOGIN
= 0x4,
80 TARG_CONN_STATE_LOGGED_IN
= 0x5,
81 TARG_CONN_STATE_IN_LOGOUT
= 0x6,
82 TARG_CONN_STATE_LOGOUT_REQUESTED
= 0x7,
83 TARG_CONN_STATE_CLEANUP_WAIT
= 0x8,
86 /* RFC-3720 7.3.2 Session State Diagram for a Target */
87 enum target_sess_state_table
{
88 TARG_SESS_STATE_FREE
= 0x1,
89 TARG_SESS_STATE_ACTIVE
= 0x2,
90 TARG_SESS_STATE_LOGGED_IN
= 0x3,
91 TARG_SESS_STATE_FAILED
= 0x4,
92 TARG_SESS_STATE_IN_CONTINUE
= 0x5,
95 /* struct iscsi_data_count->type */
96 enum data_count_type
{
101 /* struct iscsi_datain_req->dr_complete */
102 enum datain_req_comp_table
{
103 DATAIN_COMPLETE_NORMAL
= 1,
104 DATAIN_COMPLETE_WITHIN_COMMAND_RECOVERY
= 2,
105 DATAIN_COMPLETE_CONNECTION_RECOVERY
= 3,
108 /* struct iscsi_datain_req->recovery */
109 enum datain_req_rec_table
{
110 DATAIN_WITHIN_COMMAND_RECOVERY
= 1,
111 DATAIN_CONNECTION_RECOVERY
= 2,
114 /* struct iscsi_portal_group->state */
115 enum tpg_state_table
{
117 TPG_STATE_ACTIVE
= 1,
118 TPG_STATE_INACTIVE
= 2,
119 TPG_STATE_COLD_RESET
= 3,
122 /* struct iscsi_tiqn->tiqn_state */
123 enum tiqn_state_table
{
124 TIQN_STATE_ACTIVE
= 1,
125 TIQN_STATE_SHUTDOWN
= 2,
128 /* struct iscsi_cmd->cmd_flags */
129 enum cmd_flags_table
{
130 ICF_GOT_LAST_DATAOUT
= 0x00000001,
131 ICF_GOT_DATACK_SNACK
= 0x00000002,
132 ICF_NON_IMMEDIATE_UNSOLICITED_DATA
= 0x00000004,
133 ICF_SENT_LAST_R2T
= 0x00000008,
134 ICF_WITHIN_COMMAND_RECOVERY
= 0x00000010,
135 ICF_CONTIG_MEMORY
= 0x00000020,
136 ICF_ATTACHED_TO_RQUEUE
= 0x00000040,
137 ICF_OOO_CMDSN
= 0x00000080,
138 IFC_SENDTARGETS_ALL
= 0x00000100,
139 IFC_SENDTARGETS_SINGLE
= 0x00000200,
142 /* struct iscsi_cmd->i_state */
143 enum cmd_i_state_table
{
146 ISTATE_DEFERRED_CMD
= 2,
147 ISTATE_UNSOLICITED_DATA
= 3,
148 ISTATE_RECEIVE_DATAOUT
= 4,
149 ISTATE_RECEIVE_DATAOUT_RECOVERY
= 5,
150 ISTATE_RECEIVED_LAST_DATAOUT
= 6,
151 ISTATE_WITHIN_DATAOUT_RECOVERY
= 7,
152 ISTATE_IN_CONNECTION_RECOVERY
= 8,
153 ISTATE_RECEIVED_TASKMGT
= 9,
154 ISTATE_SEND_ASYNCMSG
= 10,
155 ISTATE_SENT_ASYNCMSG
= 11,
156 ISTATE_SEND_DATAIN
= 12,
157 ISTATE_SEND_LAST_DATAIN
= 13,
158 ISTATE_SENT_LAST_DATAIN
= 14,
159 ISTATE_SEND_LOGOUTRSP
= 15,
160 ISTATE_SENT_LOGOUTRSP
= 16,
161 ISTATE_SEND_NOPIN
= 17,
162 ISTATE_SENT_NOPIN
= 18,
163 ISTATE_SEND_REJECT
= 19,
164 ISTATE_SENT_REJECT
= 20,
165 ISTATE_SEND_R2T
= 21,
166 ISTATE_SENT_R2T
= 22,
167 ISTATE_SEND_R2T_RECOVERY
= 23,
168 ISTATE_SENT_R2T_RECOVERY
= 24,
169 ISTATE_SEND_LAST_R2T
= 25,
170 ISTATE_SENT_LAST_R2T
= 26,
171 ISTATE_SEND_LAST_R2T_RECOVERY
= 27,
172 ISTATE_SENT_LAST_R2T_RECOVERY
= 28,
173 ISTATE_SEND_STATUS
= 29,
174 ISTATE_SEND_STATUS_BROKEN_PC
= 30,
175 ISTATE_SENT_STATUS
= 31,
176 ISTATE_SEND_STATUS_RECOVERY
= 32,
177 ISTATE_SENT_STATUS_RECOVERY
= 33,
178 ISTATE_SEND_TASKMGTRSP
= 34,
179 ISTATE_SENT_TASKMGTRSP
= 35,
180 ISTATE_SEND_TEXTRSP
= 36,
181 ISTATE_SENT_TEXTRSP
= 37,
182 ISTATE_SEND_NOPIN_WANT_RESPONSE
= 38,
183 ISTATE_SENT_NOPIN_WANT_RESPONSE
= 39,
184 ISTATE_SEND_NOPIN_NO_RESPONSE
= 40,
189 /* Used for iscsi_recover_cmdsn() return values */
190 enum recover_cmdsn_ret_table
{
191 CMDSN_ERROR_CANNOT_RECOVER
= -1,
192 CMDSN_NORMAL_OPERATION
= 0,
193 CMDSN_LOWER_THAN_EXP
= 1,
194 CMDSN_HIGHER_THAN_EXP
= 2,
195 CMDSN_MAXCMDSN_OVERRUN
= 3,
198 /* Used for iscsi_handle_immediate_data() return values */
199 enum immedate_data_ret_table
{
200 IMMEDIATE_DATA_CANNOT_RECOVER
= -1,
201 IMMEDIATE_DATA_NORMAL_OPERATION
= 0,
202 IMMEDIATE_DATA_ERL1_CRC_FAILURE
= 1,
205 /* Used for iscsi_decide_dataout_action() return values */
206 enum dataout_action_ret_table
{
207 DATAOUT_CANNOT_RECOVER
= -1,
209 DATAOUT_SEND_R2T
= 1,
210 DATAOUT_SEND_TO_TRANSPORT
= 2,
211 DATAOUT_WITHIN_COMMAND_RECOVERY
= 3,
214 /* Used for struct iscsi_node_auth->naf_flags */
215 enum naf_flags_table
{
216 NAF_USERID_SET
= 0x01,
217 NAF_PASSWORD_SET
= 0x02,
218 NAF_USERID_IN_SET
= 0x04,
219 NAF_PASSWORD_IN_SET
= 0x08,
222 /* Used by various struct timer_list to manage iSCSI specific state */
223 enum iscsi_timer_flags_table
{
224 ISCSI_TF_RUNNING
= 0x01,
225 ISCSI_TF_STOP
= 0x02,
226 ISCSI_TF_EXPIRED
= 0x04,
229 /* Used for struct iscsi_np->np_flags */
230 enum np_flags_table
{
231 NPF_IP_NETWORK
= 0x00,
234 /* Used for struct iscsi_np->np_thread_state */
235 enum np_thread_state_table
{
236 ISCSI_NP_THREAD_ACTIVE
= 1,
237 ISCSI_NP_THREAD_INACTIVE
= 2,
238 ISCSI_NP_THREAD_RESET
= 3,
239 ISCSI_NP_THREAD_SHUTDOWN
= 4,
240 ISCSI_NP_THREAD_EXIT
= 5,
243 struct iscsi_conn_ops
{
244 u8 HeaderDigest
; /* [0,1] == [None,CRC32C] */
245 u8 DataDigest
; /* [0,1] == [None,CRC32C] */
246 u32 MaxRecvDataSegmentLength
; /* [512..2**24-1] */
247 u32 MaxXmitDataSegmentLength
; /* [512..2**24-1] */
248 u8 OFMarker
; /* [0,1] == [No,Yes] */
249 u8 IFMarker
; /* [0,1] == [No,Yes] */
250 u32 OFMarkInt
; /* [1..65535] */
251 u32 IFMarkInt
; /* [1..65535] */
253 * iSER specific connection parameters
255 u32 InitiatorRecvDataSegmentLength
; /* [512..2**24-1] */
256 u32 TargetRecvDataSegmentLength
; /* [512..2**24-1] */
259 struct iscsi_sess_ops
{
260 char InitiatorName
[224];
261 char InitiatorAlias
[256];
262 char TargetName
[224];
263 char TargetAlias
[256];
264 char TargetAddress
[256];
265 u16 TargetPortalGroupTag
; /* [0..65535] */
266 u16 MaxConnections
; /* [1..65535] */
267 u8 InitialR2T
; /* [0,1] == [No,Yes] */
268 u8 ImmediateData
; /* [0,1] == [No,Yes] */
269 u32 MaxBurstLength
; /* [512..2**24-1] */
270 u32 FirstBurstLength
; /* [512..2**24-1] */
271 u16 DefaultTime2Wait
; /* [0..3600] */
272 u16 DefaultTime2Retain
; /* [0..3600] */
273 u16 MaxOutstandingR2T
; /* [1..65535] */
274 u8 DataPDUInOrder
; /* [0,1] == [No,Yes] */
275 u8 DataSequenceInOrder
; /* [0,1] == [No,Yes] */
276 u8 ErrorRecoveryLevel
; /* [0..2] */
277 u8 SessionType
; /* [0,1] == [Normal,Discovery]*/
279 * iSER specific session parameters
281 u8 RDMAExtensions
; /* [0,1] == [No,Yes] */
284 struct iscsi_queue_req
{
286 struct iscsi_cmd
*cmd
;
287 struct list_head qr_list
;
290 struct iscsi_data_count
{
292 int sync_and_steering
;
293 enum data_count_type type
;
300 struct iscsi_param_list
{
302 struct list_head param_list
;
303 struct list_head extra_response_list
;
306 struct iscsi_datain_req
{
307 enum datain_req_comp_table dr_complete
;
308 int generate_recovery_values
;
309 enum datain_req_rec_table recovery
;
318 struct list_head cmd_datain_node
;
319 } ____cacheline_aligned
;
321 struct iscsi_ooo_cmdsn
{
326 struct iscsi_cmd
*cmd
;
327 struct list_head ooo_list
;
328 } ____cacheline_aligned
;
330 struct iscsi_datain
{
335 } ____cacheline_aligned
;
345 struct list_head r2t_list
;
346 } ____cacheline_aligned
;
349 enum iscsi_timer_flags_table dataout_timer_flags
;
350 /* DataOUT timeout retries */
351 u8 dataout_timeout_retries
;
352 /* Within command recovery count */
353 u8 error_recovery_count
;
354 /* iSCSI dependent state for out or order CmdSNs */
355 enum cmd_i_state_table deferred_i_state
;
356 /* iSCSI dependent state */
357 enum cmd_i_state_table i_state
;
358 /* Command is an immediate command (ISCSI_OP_IMMEDIATE set) */
360 /* Immediate data present */
364 /* iSCSI Response Code */
366 /* Logout reason when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
368 /* Logout response code when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
370 /* MaxCmdSN has been incremented */
372 /* Immediate Unsolicited Dataout */
374 /* Reject reason code */
376 /* CID contained in logout PDU when opcode == ISCSI_INIT_LOGOUT_CMND */
379 enum cmd_flags_table cmd_flags
;
380 /* Initiator Task Tag assigned from Initiator */
382 /* Target Transfer Tag assigned from Target */
384 /* CmdSN assigned from Initiator */
386 /* ExpStatSN assigned from Initiator */
388 /* StatSN assigned to this ITT */
394 /* Last DataSN acknowledged via DataAck SNACK */
396 /* Used for echoing NOPOUT ping data */
398 /* Used to store DataDigest */
400 /* Counter for MaxOutstandingR2T */
401 u32 outstanding_r2ts
;
402 /* Next R2T Offset when DataSequenceInOrder=Yes */
404 /* Iovec current and orig count for iscsi_cmd->iov_data */
406 u32 orig_iov_data_count
;
407 /* Number of miscellaneous iovecs used for IP stack calls */
409 /* Number of struct iscsi_pdu in struct iscsi_cmd->pdu_list */
411 /* Next struct iscsi_pdu to send in struct iscsi_cmd->pdu_list */
413 /* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */
415 /* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */
417 /* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */
419 /* Current struct iscsi_seq in struct iscsi_cmd->seq_list */
421 /* Lowest offset in current DataOUT sequence */
422 u32 seq_start_offset
;
423 /* Highest offset in current DataOUT sequence */
425 /* Total size in bytes received so far of READ data */
427 /* Total size in bytes received so far of WRITE data */
429 /* Counter for FirstBurstLength key */
431 /* Counter for MaxBurstLength key */
433 /* Transfer size used for IP stack calls */
435 /* Buffer used for various purposes */
437 /* Used by SendTargets=[iqn.,eui.] discovery */
439 /* See include/linux/dma-mapping.h */
440 enum dma_data_direction data_direction
;
441 /* iSCSI PDU Header + CRC */
442 unsigned char pdu
[ISCSI_HDR_LEN
+ ISCSI_CRC_LEN
];
443 /* Number of times struct iscsi_cmd is present in immediate queue */
444 atomic_t immed_queue_count
;
445 atomic_t response_queue_count
;
446 spinlock_t datain_lock
;
447 spinlock_t dataout_timeout_lock
;
448 /* spinlock for protecting struct iscsi_cmd->i_state */
449 spinlock_t istate_lock
;
450 /* spinlock for adding within command recovery entries */
451 spinlock_t error_lock
;
452 /* spinlock for adding R2Ts */
455 struct list_head datain_list
;
457 struct list_head cmd_r2t_list
;
458 /* Timer for DataOUT */
459 struct timer_list dataout_timer
;
460 /* Iovecs for SCSI data payload RX/TX w/ kernel level sockets */
461 struct kvec
*iov_data
;
462 /* Iovecs for miscellaneous purposes */
463 #define ISCSI_MISC_IOVECS 5
464 struct kvec iov_misc
[ISCSI_MISC_IOVECS
];
465 /* Array of struct iscsi_pdu used for DataPDUInOrder=No */
466 struct iscsi_pdu
*pdu_list
;
467 /* Current struct iscsi_pdu used for DataPDUInOrder=No */
468 struct iscsi_pdu
*pdu_ptr
;
469 /* Array of struct iscsi_seq used for DataSequenceInOrder=No */
470 struct iscsi_seq
*seq_list
;
471 /* Current struct iscsi_seq used for DataSequenceInOrder=No */
472 struct iscsi_seq
*seq_ptr
;
473 /* TMR Request when iscsi_opcode == ISCSI_OP_SCSI_TMFUNC */
474 struct iscsi_tmr_req
*tmr_req
;
475 /* Connection this command is alligient to */
476 struct iscsi_conn
*conn
;
477 /* Pointer to connection recovery entry */
478 struct iscsi_conn_recovery
*cr
;
479 /* Session the command is part of, used for connection recovery */
480 struct iscsi_session
*sess
;
481 /* list_head for connection list */
482 struct list_head i_conn_node
;
483 /* The TCM I/O descriptor that is accessed via container_of() */
484 struct se_cmd se_cmd
;
485 /* Sense buffer that will be mapped into outgoing status */
486 #define ISCSI_SENSE_BUFFER_LEN (TRANSPORT_SENSE_BUFFER + 2)
487 unsigned char sense_buffer
[ISCSI_SENSE_BUFFER_LEN
];
492 struct scatterlist
*first_data_sg
;
493 u32 first_data_sg_off
;
495 sense_reason_t sense_reason
;
496 } ____cacheline_aligned
;
498 struct iscsi_tmr_req
{
499 bool task_reassign
:1;
501 struct iscsi_cmd
*ref_cmd
;
502 struct iscsi_conn_recovery
*conn_recovery
;
503 struct se_tmr_req
*se_tmr_req
;
507 wait_queue_head_t queues_wq
;
508 /* Authentication Successful for this connection */
510 /* State connection is currently in */
512 u8 conn_logout_reason
;
513 u8 network_transport
;
514 enum iscsi_timer_flags_table nopin_timer_flags
;
515 enum iscsi_timer_flags_table nopin_response_timer_flags
;
516 /* Used to know what thread encountered a transport failure */
518 /* connection id assigned by the Initiator */
520 /* Remote TCP Port */
527 /* Used for iscsi_tx_login_rsp() */
530 /* Per connection status sequence number */
532 /* IFMarkInt's Current Value */
534 /* OFMarkInt's Current Value */
536 /* Used for calculating OFMarker offset to next PDU */
537 u32 of_marker_offset
;
538 #define IPV6_ADDRESS_SPACE 48
539 unsigned char login_ip
[IPV6_ADDRESS_SPACE
];
540 unsigned char local_ip
[IPV6_ADDRESS_SPACE
];
541 int conn_usage_count
;
542 int conn_waiting_on_uc
;
543 atomic_t check_immediate_queue
;
544 atomic_t conn_logout_remove
;
545 atomic_t connection_exit
;
546 atomic_t connection_recovery
;
547 atomic_t connection_reinstatement
;
548 atomic_t connection_wait_rcfr
;
549 atomic_t sleep_on_conn_wait_comp
;
550 atomic_t transport_failed
;
551 struct completion conn_post_wait_comp
;
552 struct completion conn_wait_comp
;
553 struct completion conn_wait_rcfr_comp
;
554 struct completion conn_waiting_on_uc_comp
;
555 struct completion conn_logout_comp
;
556 struct completion tx_half_close_comp
;
557 struct completion rx_half_close_comp
;
558 /* socket used by this connection */
560 void (*orig_data_ready
)(struct sock
*);
561 void (*orig_state_change
)(struct sock
*);
562 #define LOGIN_FLAGS_READ_ACTIVE 1
563 #define LOGIN_FLAGS_CLOSED 2
564 #define LOGIN_FLAGS_READY 4
565 unsigned long login_flags
;
566 struct delayed_work login_work
;
567 struct delayed_work login_cleanup_work
;
568 struct iscsi_login
*login
;
569 struct timer_list nopin_timer
;
570 struct timer_list nopin_response_timer
;
571 struct timer_list transport_timer
;
572 struct task_struct
*login_kworker
;
573 /* Spinlock used for add/deleting cmd's from conn_cmd_list */
575 spinlock_t conn_usage_lock
;
576 spinlock_t immed_queue_lock
;
577 spinlock_t nopin_timer_lock
;
578 spinlock_t response_queue_lock
;
579 spinlock_t state_lock
;
580 /* libcrypto RX and TX contexts for crc32c */
581 struct hash_desc conn_rx_hash
;
582 struct hash_desc conn_tx_hash
;
583 /* Used for scheduling TX and RX connection kthreads */
584 cpumask_var_t conn_cpumask
;
585 unsigned int conn_rx_reset_cpumask
:1;
586 unsigned int conn_tx_reset_cpumask
:1;
587 /* list_head of struct iscsi_cmd for this connection */
588 struct list_head conn_cmd_list
;
589 struct list_head immed_queue_list
;
590 struct list_head response_queue_list
;
591 struct iscsi_conn_ops
*conn_ops
;
592 struct iscsi_login
*conn_login
;
593 struct iscsit_transport
*conn_transport
;
594 struct iscsi_param_list
*param_list
;
595 /* Used for per connection auth state machine */
598 struct iscsi_login_thread_s
*login_thread
;
599 struct iscsi_portal_group
*tpg
;
600 struct iscsi_tpg_np
*tpg_np
;
601 /* Pointer to parent session */
602 struct iscsi_session
*sess
;
603 /* Pointer to thread_set in use for this conn's threads */
604 struct iscsi_thread_set
*thread_set
;
605 /* list_head for session connection list */
606 struct list_head conn_list
;
607 } ____cacheline_aligned
;
609 struct iscsi_conn_recovery
{
612 u32 maxrecvdatasegmentlength
;
613 u32 maxxmitdatasegmentlength
;
614 int ready_for_reallegiance
;
615 struct list_head conn_recovery_cmd_list
;
616 spinlock_t conn_recovery_cmd_lock
;
617 struct timer_list time2retain_timer
;
618 struct iscsi_session
*sess
;
619 struct list_head cr_list
;
620 } ____cacheline_aligned
;
622 struct iscsi_session
{
625 enum iscsi_timer_flags_table time2retain_timer_flags
;
628 u16 conn_recovery_count
;
630 /* state session is currently in */
632 /* session wide counter: initiator assigned task tag */
634 /* session wide counter: target assigned task tag */
638 /* protects cmdsn values */
639 struct mutex cmdsn_mutex
;
640 /* session wide counter: expected command sequence number */
642 /* session wide counter: maximum allowed command sequence number */
644 struct list_head sess_ooo_cmdsn_list
;
646 /* LIO specific session ID */
649 /* unique within the target */
651 /* Used for session reference counting */
652 int session_usage_count
;
653 int session_waiting_on_uc
;
654 atomic_long_t cmd_pdus
;
655 atomic_long_t rsp_pdus
;
656 atomic_long_t tx_data_octets
;
657 atomic_long_t rx_data_octets
;
658 atomic_long_t conn_digest_errors
;
659 atomic_long_t conn_timeout_errors
;
661 /* Number of active connections */
663 atomic_t session_continuation
;
664 atomic_t session_fall_back_to_erl0
;
665 atomic_t session_logout
;
666 atomic_t session_reinstatement
;
667 atomic_t session_stop_active
;
668 atomic_t sleep_on_sess_wait_comp
;
669 /* connection list */
670 struct list_head sess_conn_list
;
671 struct list_head cr_active_list
;
672 struct list_head cr_inactive_list
;
673 spinlock_t conn_lock
;
674 spinlock_t cr_a_lock
;
675 spinlock_t cr_i_lock
;
676 spinlock_t session_usage_lock
;
678 struct completion async_msg_comp
;
679 struct completion reinstatement_comp
;
680 struct completion session_wait_comp
;
681 struct completion session_waiting_on_uc_comp
;
682 struct timer_list time2retain_timer
;
683 struct iscsi_sess_ops
*sess_ops
;
684 struct se_session
*se_sess
;
685 struct iscsi_portal_group
*tpg
;
686 } ____cacheline_aligned
;
690 u8 checked_for_existing
;
692 u8 leading_connection
;
702 u32 initial_exp_statsn
;
706 char req
[ISCSI_HDR_LEN
];
707 char rsp
[ISCSI_HDR_LEN
];
710 struct iscsi_conn
*conn
;
712 } ____cacheline_aligned
;
714 struct iscsi_node_attrib
{
716 u32 dataout_timeout_retries
;
719 u32 nopin_response_timeout
;
720 u32 random_datain_pdu_offsets
;
721 u32 random_datain_seq_offsets
;
722 u32 random_r2t_offsets
;
725 struct iscsi_node_acl
*nacl
;
728 struct se_dev_entry_s
;
730 struct iscsi_node_auth
{
731 enum naf_flags_table naf_flags
;
732 int authenticate_target
;
733 /* Used for iscsit_global->discovery_auth,
734 * set to zero (auth disabled) by default */
735 int enforce_discovery_auth
;
736 #define MAX_USER_LEN 256
737 #define MAX_PASS_LEN 256
738 char userid
[MAX_USER_LEN
];
739 char password
[MAX_PASS_LEN
];
740 char userid_mutual
[MAX_USER_LEN
];
741 char password_mutual
[MAX_PASS_LEN
];
744 #include "iscsi_target_stat.h"
746 struct iscsi_node_stat_grps
{
747 struct config_group iscsi_sess_stats_group
;
748 struct config_group iscsi_conn_stats_group
;
751 struct iscsi_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
;
755 struct se_node_acl se_node_acl
;
758 struct iscsi_tpg_attrib
{
762 u32 generate_node_acls
;
763 u32 cache_dynamic_acls
;
764 u32 default_cmdsn_depth
;
765 u32 demo_mode_write_protect
;
766 u32 prod_mode_write_protect
;
767 u32 demo_mode_discovery
;
770 struct iscsi_portal_group
*tpg
;
774 int np_network_transport
;
777 enum np_thread_state_table np_thread_state
;
778 enum iscsi_timer_flags_table np_login_timer_flags
;
780 enum np_flags_table np_flags
;
781 unsigned char np_ip
[IPV6_ADDRESS_SPACE
];
783 spinlock_t np_thread_lock
;
784 struct completion np_restart_comp
;
785 struct socket
*np_socket
;
786 struct __kernel_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 struct iscsi_tpg_np
*tpg_np
;
793 } ____cacheline_aligned
;
795 struct iscsi_tpg_np
{
796 struct iscsi_np
*tpg_np
;
797 struct iscsi_portal_group
*tpg
;
798 struct iscsi_tpg_np
*tpg_np_parent
;
799 struct list_head tpg_np_list
;
800 struct list_head tpg_np_child_list
;
801 struct list_head tpg_np_parent_list
;
802 struct se_tpg_np se_tpg_np
;
803 spinlock_t tpg_np_parent_lock
;
804 struct completion tpg_np_comp
;
805 struct kref tpg_np_kref
;
808 struct iscsi_portal_group
{
809 unsigned char tpg_chap_id
;
811 enum tpg_state_table tpg_state
;
812 /* Target Portal Group Tag */
814 /* Id assigned to target sessions */
816 /* Number of active sessions */
818 /* Number of Network Portals available for this TPG */
820 /* Per TPG LIO specific session ID. */
822 /* Spinlock for adding/removing Network Portals */
823 spinlock_t tpg_np_lock
;
824 spinlock_t tpg_state_lock
;
825 struct se_portal_group tpg_se_tpg
;
826 struct mutex tpg_access_lock
;
827 struct semaphore np_login_sem
;
828 struct iscsi_tpg_attrib tpg_attrib
;
829 struct iscsi_node_auth tpg_demo_auth
;
830 /* Pointer to default list of iSCSI parameters for TPG */
831 struct iscsi_param_list
*param_list
;
832 struct iscsi_tiqn
*tpg_tiqn
;
833 struct list_head tpg_gnp_list
;
834 struct list_head tpg_list
;
835 } ____cacheline_aligned
;
837 struct iscsi_wwn_stat_grps
{
838 struct config_group iscsi_stat_group
;
839 struct config_group iscsi_instance_group
;
840 struct config_group iscsi_sess_err_group
;
841 struct config_group iscsi_tgt_attr_group
;
842 struct config_group iscsi_login_stats_group
;
843 struct config_group iscsi_logout_stats_group
;
847 #define ISCSI_IQN_LEN 224
848 unsigned char tiqn
[ISCSI_IQN_LEN
];
849 enum tiqn_state_table tiqn_state
;
850 int tiqn_access_count
;
851 u32 tiqn_active_tpgs
;
853 u32 tiqn_num_tpg_nps
;
855 struct list_head tiqn_list
;
856 struct list_head tiqn_tpg_list
;
857 spinlock_t tiqn_state_lock
;
858 spinlock_t tiqn_tpg_lock
;
859 struct se_wwn tiqn_wwn
;
860 struct iscsi_wwn_stat_grps tiqn_stat_grps
;
862 struct iscsi_sess_err_stats sess_err_stats
;
863 struct iscsi_login_stats login_stats
;
864 struct iscsi_logout_stats logout_stats
;
865 } ____cacheline_aligned
;
867 struct iscsit_global
{
868 /* In core shutdown */
871 /* Unique identifier used for the authentication daemon */
874 /* Thread Set bitmap count */
876 /* Thread Set bitmap pointer */
877 unsigned long *ts_bitmap
;
878 /* Used for iSCSI discovery session authentication */
879 struct iscsi_node_acl discovery_acl
;
880 struct iscsi_portal_group
*discovery_tpg
;
883 #endif /* ISCSI_TARGET_CORE_H */