iser-target: Fix isert_put_reject payload buffer post
[deliverable/linux.git] / drivers / target / iscsi / iscsi_target_core.h
CommitLineData
e48354ce
NB
1#ifndef ISCSI_TARGET_CORE_H
2#define ISCSI_TARGET_CORE_H
3
4#include <linux/in.h>
5#include <linux/configfs.h>
6#include <net/sock.h>
7#include <net/tcp.h>
8#include <scsi/scsi_cmnd.h>
9#include <scsi/iscsi_proto.h>
10#include <target/target_core_base.h>
11
9765b1f3 12#define ISCSIT_VERSION "v4.1.0-rc2"
e48354ce
NB
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
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
cf0eb28d 28#define NA_NOPIN_TIMEOUT 15
e48354ce
NB
29#define NA_NOPIN_TIMEOUT_MAX 60
30#define NA_NOPIN_TIMEOUT_MIN 3
cf0eb28d 31#define NA_NOPIN_RESPONSE_TIMEOUT 30
e48354ce
NB
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
40
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
59
c0427f15
CH
60
61#define ISCSI_IOV_DATA_BUFFER 5
62
baa4d64b 63enum iscsit_transport_type {
e48354ce
NB
64 ISCSI_TCP = 0,
65 ISCSI_SCTP_TCP = 1,
66 ISCSI_SCTP_UDP = 2,
67 ISCSI_IWARP_TCP = 3,
68 ISCSI_IWARP_SCTP = 4,
69 ISCSI_INFINIBAND = 5,
70};
71
72/* RFC-3720 7.1.4 Standard Connection State Diagram for a Target */
73enum 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,
81};
82
83/* RFC-3720 7.3.2 Session State Diagram for a Target */
84enum 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,
90};
91
92/* struct iscsi_data_count->type */
93enum data_count_type {
94 ISCSI_RX_DATA = 1,
95 ISCSI_TX_DATA = 2,
96};
97
98/* struct iscsi_datain_req->dr_complete */
99enum datain_req_comp_table {
100 DATAIN_COMPLETE_NORMAL = 1,
101 DATAIN_COMPLETE_WITHIN_COMMAND_RECOVERY = 2,
102 DATAIN_COMPLETE_CONNECTION_RECOVERY = 3,
103};
104
105/* struct iscsi_datain_req->recovery */
106enum datain_req_rec_table {
107 DATAIN_WITHIN_COMMAND_RECOVERY = 1,
108 DATAIN_CONNECTION_RECOVERY = 2,
109};
110
111/* struct iscsi_portal_group->state */
112enum tpg_state_table {
113 TPG_STATE_FREE = 0,
114 TPG_STATE_ACTIVE = 1,
115 TPG_STATE_INACTIVE = 2,
116 TPG_STATE_COLD_RESET = 3,
117};
118
119/* struct iscsi_tiqn->tiqn_state */
120enum tiqn_state_table {
121 TIQN_STATE_ACTIVE = 1,
122 TIQN_STATE_SHUTDOWN = 2,
123};
124
125/* struct iscsi_cmd->cmd_flags */
126enum 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,
9864ca9d 136 IFC_SENDTARGETS_ALL = 0x00000200,
6665889c 137 IFC_SENDTARGETS_SINGLE = 0x00000400,
e48354ce
NB
138};
139
140/* struct iscsi_cmd->i_state */
141enum cmd_i_state_table {
142 ISTATE_NO_STATE = 0,
143 ISTATE_NEW_CMD = 1,
144 ISTATE_DEFERRED_CMD = 2,
145 ISTATE_UNSOLICITED_DATA = 3,
146 ISTATE_RECEIVE_DATAOUT = 4,
147 ISTATE_RECEIVE_DATAOUT_RECOVERY = 5,
148 ISTATE_RECEIVED_LAST_DATAOUT = 6,
149 ISTATE_WITHIN_DATAOUT_RECOVERY = 7,
150 ISTATE_IN_CONNECTION_RECOVERY = 8,
151 ISTATE_RECEIVED_TASKMGT = 9,
152 ISTATE_SEND_ASYNCMSG = 10,
153 ISTATE_SENT_ASYNCMSG = 11,
154 ISTATE_SEND_DATAIN = 12,
155 ISTATE_SEND_LAST_DATAIN = 13,
156 ISTATE_SENT_LAST_DATAIN = 14,
157 ISTATE_SEND_LOGOUTRSP = 15,
158 ISTATE_SENT_LOGOUTRSP = 16,
159 ISTATE_SEND_NOPIN = 17,
160 ISTATE_SENT_NOPIN = 18,
161 ISTATE_SEND_REJECT = 19,
162 ISTATE_SENT_REJECT = 20,
163 ISTATE_SEND_R2T = 21,
164 ISTATE_SENT_R2T = 22,
165 ISTATE_SEND_R2T_RECOVERY = 23,
166 ISTATE_SENT_R2T_RECOVERY = 24,
167 ISTATE_SEND_LAST_R2T = 25,
168 ISTATE_SENT_LAST_R2T = 26,
169 ISTATE_SEND_LAST_R2T_RECOVERY = 27,
170 ISTATE_SENT_LAST_R2T_RECOVERY = 28,
171 ISTATE_SEND_STATUS = 29,
172 ISTATE_SEND_STATUS_BROKEN_PC = 30,
173 ISTATE_SENT_STATUS = 31,
174 ISTATE_SEND_STATUS_RECOVERY = 32,
175 ISTATE_SENT_STATUS_RECOVERY = 33,
176 ISTATE_SEND_TASKMGTRSP = 34,
177 ISTATE_SENT_TASKMGTRSP = 35,
178 ISTATE_SEND_TEXTRSP = 36,
179 ISTATE_SENT_TEXTRSP = 37,
180 ISTATE_SEND_NOPIN_WANT_RESPONSE = 38,
181 ISTATE_SENT_NOPIN_WANT_RESPONSE = 39,
182 ISTATE_SEND_NOPIN_NO_RESPONSE = 40,
183 ISTATE_REMOVE = 41,
184 ISTATE_FREE = 42,
185};
186
187/* Used for iscsi_recover_cmdsn() return values */
188enum recover_cmdsn_ret_table {
189 CMDSN_ERROR_CANNOT_RECOVER = -1,
190 CMDSN_NORMAL_OPERATION = 0,
191 CMDSN_LOWER_THAN_EXP = 1,
192 CMDSN_HIGHER_THAN_EXP = 2,
193};
194
195/* Used for iscsi_handle_immediate_data() return values */
196enum immedate_data_ret_table {
197 IMMEDIATE_DATA_CANNOT_RECOVER = -1,
198 IMMEDIATE_DATA_NORMAL_OPERATION = 0,
199 IMMEDIATE_DATA_ERL1_CRC_FAILURE = 1,
200};
201
202/* Used for iscsi_decide_dataout_action() return values */
203enum dataout_action_ret_table {
204 DATAOUT_CANNOT_RECOVER = -1,
205 DATAOUT_NORMAL = 0,
206 DATAOUT_SEND_R2T = 1,
207 DATAOUT_SEND_TO_TRANSPORT = 2,
208 DATAOUT_WITHIN_COMMAND_RECOVERY = 3,
209};
210
211/* Used for struct iscsi_node_auth->naf_flags */
212enum naf_flags_table {
213 NAF_USERID_SET = 0x01,
214 NAF_PASSWORD_SET = 0x02,
215 NAF_USERID_IN_SET = 0x04,
216 NAF_PASSWORD_IN_SET = 0x08,
217};
218
219/* Used by various struct timer_list to manage iSCSI specific state */
220enum iscsi_timer_flags_table {
221 ISCSI_TF_RUNNING = 0x01,
222 ISCSI_TF_STOP = 0x02,
223 ISCSI_TF_EXPIRED = 0x04,
224};
225
226/* Used for struct iscsi_np->np_flags */
227enum np_flags_table {
228 NPF_IP_NETWORK = 0x00,
e48354ce
NB
229};
230
231/* Used for struct iscsi_np->np_thread_state */
232enum np_thread_state_table {
233 ISCSI_NP_THREAD_ACTIVE = 1,
234 ISCSI_NP_THREAD_INACTIVE = 2,
235 ISCSI_NP_THREAD_RESET = 3,
236 ISCSI_NP_THREAD_SHUTDOWN = 4,
237 ISCSI_NP_THREAD_EXIT = 5,
238};
239
240struct iscsi_conn_ops {
241 u8 HeaderDigest; /* [0,1] == [None,CRC32C] */
242 u8 DataDigest; /* [0,1] == [None,CRC32C] */
243 u32 MaxRecvDataSegmentLength; /* [512..2**24-1] */
e004cb25 244 u32 MaxXmitDataSegmentLength; /* [512..2**24-1] */
e48354ce
NB
245 u8 OFMarker; /* [0,1] == [No,Yes] */
246 u8 IFMarker; /* [0,1] == [No,Yes] */
247 u32 OFMarkInt; /* [1..65535] */
248 u32 IFMarkInt; /* [1..65535] */
03aa2070
NB
249 /*
250 * iSER specific connection parameters
251 */
252 u32 InitiatorRecvDataSegmentLength; /* [512..2**24-1] */
253 u32 TargetRecvDataSegmentLength; /* [512..2**24-1] */
e48354ce
NB
254};
255
256struct iscsi_sess_ops {
257 char InitiatorName[224];
258 char InitiatorAlias[256];
259 char TargetName[224];
260 char TargetAlias[256];
261 char TargetAddress[256];
262 u16 TargetPortalGroupTag; /* [0..65535] */
263 u16 MaxConnections; /* [1..65535] */
264 u8 InitialR2T; /* [0,1] == [No,Yes] */
265 u8 ImmediateData; /* [0,1] == [No,Yes] */
266 u32 MaxBurstLength; /* [512..2**24-1] */
267 u32 FirstBurstLength; /* [512..2**24-1] */
268 u16 DefaultTime2Wait; /* [0..3600] */
269 u16 DefaultTime2Retain; /* [0..3600] */
270 u16 MaxOutstandingR2T; /* [1..65535] */
271 u8 DataPDUInOrder; /* [0,1] == [No,Yes] */
272 u8 DataSequenceInOrder; /* [0,1] == [No,Yes] */
273 u8 ErrorRecoveryLevel; /* [0..2] */
274 u8 SessionType; /* [0,1] == [Normal,Discovery]*/
03aa2070
NB
275 /*
276 * iSER specific session parameters
277 */
278 u8 RDMAExtensions; /* [0,1] == [No,Yes] */
e48354ce
NB
279};
280
281struct iscsi_queue_req {
282 int state;
283 struct iscsi_cmd *cmd;
284 struct list_head qr_list;
285};
286
287struct iscsi_data_count {
288 int data_length;
289 int sync_and_steering;
290 enum data_count_type type;
291 u32 iov_count;
292 u32 ss_iov_count;
293 u32 ss_marker_count;
294 struct kvec *iov;
295};
296
297struct iscsi_param_list {
03aa2070 298 bool iser;
e48354ce
NB
299 struct list_head param_list;
300 struct list_head extra_response_list;
301};
302
303struct iscsi_datain_req {
304 enum datain_req_comp_table dr_complete;
305 int generate_recovery_values;
306 enum datain_req_rec_table recovery;
307 u32 begrun;
308 u32 runlength;
309 u32 data_length;
310 u32 data_offset;
e48354ce
NB
311 u32 data_sn;
312 u32 next_burst_len;
313 u32 read_data_done;
314 u32 seq_send_order;
8b1e1244 315 struct list_head cmd_datain_node;
e48354ce
NB
316} ____cacheline_aligned;
317
318struct iscsi_ooo_cmdsn {
319 u16 cid;
320 u32 batch_count;
321 u32 cmdsn;
322 u32 exp_cmdsn;
323 struct iscsi_cmd *cmd;
324 struct list_head ooo_list;
325} ____cacheline_aligned;
326
327struct iscsi_datain {
328 u8 flags;
329 u32 data_sn;
330 u32 length;
331 u32 offset;
332} ____cacheline_aligned;
333
334struct iscsi_r2t {
335 int seq_complete;
336 int recovery_r2t;
337 int sent_r2t;
338 u32 r2t_sn;
339 u32 offset;
340 u32 targ_xfer_tag;
341 u32 xfer_len;
342 struct list_head r2t_list;
343} ____cacheline_aligned;
344
345struct iscsi_cmd {
346 enum iscsi_timer_flags_table dataout_timer_flags;
347 /* DataOUT timeout retries */
348 u8 dataout_timeout_retries;
349 /* Within command recovery count */
350 u8 error_recovery_count;
351 /* iSCSI dependent state for out or order CmdSNs */
352 enum cmd_i_state_table deferred_i_state;
353 /* iSCSI dependent state */
354 enum cmd_i_state_table i_state;
355 /* Command is an immediate command (ISCSI_OP_IMMEDIATE set) */
356 u8 immediate_cmd;
357 /* Immediate data present */
358 u8 immediate_data;
359 /* iSCSI Opcode */
360 u8 iscsi_opcode;
361 /* iSCSI Response Code */
362 u8 iscsi_response;
363 /* Logout reason when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
364 u8 logout_reason;
365 /* Logout response code when iscsi_opcode == ISCSI_INIT_LOGOUT_CMND */
366 u8 logout_response;
367 /* MaxCmdSN has been incremented */
368 u8 maxcmdsn_inc;
369 /* Immediate Unsolicited Dataout */
370 u8 unsolicited_data;
371 /* CID contained in logout PDU when opcode == ISCSI_INIT_LOGOUT_CMND */
372 u16 logout_cid;
373 /* Command flags */
374 enum cmd_flags_table cmd_flags;
375 /* Initiator Task Tag assigned from Initiator */
66c7db68 376 itt_t init_task_tag;
e48354ce
NB
377 /* Target Transfer Tag assigned from Target */
378 u32 targ_xfer_tag;
379 /* CmdSN assigned from Initiator */
380 u32 cmd_sn;
381 /* ExpStatSN assigned from Initiator */
382 u32 exp_stat_sn;
383 /* StatSN assigned to this ITT */
384 u32 stat_sn;
385 /* DataSN Counter */
386 u32 data_sn;
387 /* R2TSN Counter */
388 u32 r2t_sn;
389 /* Last DataSN acknowledged via DataAck SNACK */
390 u32 acked_data_sn;
391 /* Used for echoing NOPOUT ping data */
392 u32 buf_ptr_size;
393 /* Used to store DataDigest */
394 u32 data_crc;
e48354ce
NB
395 /* Counter for MaxOutstandingR2T */
396 u32 outstanding_r2ts;
397 /* Next R2T Offset when DataSequenceInOrder=Yes */
398 u32 r2t_offset;
399 /* Iovec current and orig count for iscsi_cmd->iov_data */
400 u32 iov_data_count;
401 u32 orig_iov_data_count;
402 /* Number of miscellaneous iovecs used for IP stack calls */
403 u32 iov_misc_count;
404 /* Number of struct iscsi_pdu in struct iscsi_cmd->pdu_list */
405 u32 pdu_count;
406 /* Next struct iscsi_pdu to send in struct iscsi_cmd->pdu_list */
407 u32 pdu_send_order;
408 /* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */
409 u32 pdu_start;
e48354ce
NB
410 /* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */
411 u32 seq_send_order;
412 /* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */
413 u32 seq_count;
414 /* Current struct iscsi_seq in struct iscsi_cmd->seq_list */
415 u32 seq_no;
416 /* Lowest offset in current DataOUT sequence */
417 u32 seq_start_offset;
418 /* Highest offset in current DataOUT sequence */
419 u32 seq_end_offset;
420 /* Total size in bytes received so far of READ data */
421 u32 read_data_done;
422 /* Total size in bytes received so far of WRITE data */
423 u32 write_data_done;
424 /* Counter for FirstBurstLength key */
425 u32 first_burst_len;
426 /* Counter for MaxBurstLength key */
427 u32 next_burst_len;
428 /* Transfer size used for IP stack calls */
429 u32 tx_size;
430 /* Buffer used for various purposes */
431 void *buf_ptr;
9864ca9d
NB
432 /* Used by SendTargets=[iqn.,eui.] discovery */
433 void *text_in_ptr;
e48354ce
NB
434 /* See include/linux/dma-mapping.h */
435 enum dma_data_direction data_direction;
436 /* iSCSI PDU Header + CRC */
437 unsigned char pdu[ISCSI_HDR_LEN + ISCSI_CRC_LEN];
438 /* Number of times struct iscsi_cmd is present in immediate queue */
439 atomic_t immed_queue_count;
440 atomic_t response_queue_count;
e48354ce
NB
441 spinlock_t datain_lock;
442 spinlock_t dataout_timeout_lock;
443 /* spinlock for protecting struct iscsi_cmd->i_state */
444 spinlock_t istate_lock;
445 /* spinlock for adding within command recovery entries */
446 spinlock_t error_lock;
447 /* spinlock for adding R2Ts */
448 spinlock_t r2t_lock;
449 /* DataIN List */
450 struct list_head datain_list;
451 /* R2T List */
452 struct list_head cmd_r2t_list;
453 struct completion reject_comp;
454 /* Timer for DataOUT */
455 struct timer_list dataout_timer;
456 /* Iovecs for SCSI data payload RX/TX w/ kernel level sockets */
457 struct kvec *iov_data;
458 /* Iovecs for miscellaneous purposes */
459#define ISCSI_MISC_IOVECS 5
460 struct kvec iov_misc[ISCSI_MISC_IOVECS];
461 /* Array of struct iscsi_pdu used for DataPDUInOrder=No */
462 struct iscsi_pdu *pdu_list;
463 /* Current struct iscsi_pdu used for DataPDUInOrder=No */
464 struct iscsi_pdu *pdu_ptr;
465 /* Array of struct iscsi_seq used for DataSequenceInOrder=No */
466 struct iscsi_seq *seq_list;
467 /* Current struct iscsi_seq used for DataSequenceInOrder=No */
468 struct iscsi_seq *seq_ptr;
469 /* TMR Request when iscsi_opcode == ISCSI_OP_SCSI_TMFUNC */
470 struct iscsi_tmr_req *tmr_req;
471 /* Connection this command is alligient to */
472 struct iscsi_conn *conn;
473 /* Pointer to connection recovery entry */
474 struct iscsi_conn_recovery *cr;
475 /* Session the command is part of, used for connection recovery */
476 struct iscsi_session *sess;
477 /* list_head for connection list */
2fbb471e 478 struct list_head i_conn_node;
e48354ce
NB
479 /* The TCM I/O descriptor that is accessed via container_of() */
480 struct se_cmd se_cmd;
481 /* Sense buffer that will be mapped into outgoing status */
482#define ISCSI_SENSE_BUFFER_LEN (TRANSPORT_SENSE_BUFFER + 2)
483 unsigned char sense_buffer[ISCSI_SENSE_BUFFER_LEN];
484
e48354ce
NB
485 u32 padding;
486 u8 pad_bytes[4];
487
488 struct scatterlist *first_data_sg;
489 u32 first_data_sg_off;
490 u32 kmapped_nents;
de103c93 491 sense_reason_t sense_reason;
cdb72665 492 void (*release_cmd)(struct iscsi_cmd *);
e48354ce
NB
493} ____cacheline_aligned;
494
495struct iscsi_tmr_req {
496 bool task_reassign:1;
e48354ce 497 u32 exp_data_sn;
9f3eb93e 498 struct iscsi_cmd *ref_cmd;
e48354ce
NB
499 struct iscsi_conn_recovery *conn_recovery;
500 struct se_tmr_req *se_tmr_req;
501};
502
503struct iscsi_conn {
d5627acb 504 wait_queue_head_t queues_wq;
e48354ce
NB
505 /* Authentication Successful for this connection */
506 u8 auth_complete;
507 /* State connection is currently in */
508 u8 conn_state;
509 u8 conn_logout_reason;
510 u8 network_transport;
511 enum iscsi_timer_flags_table nopin_timer_flags;
512 enum iscsi_timer_flags_table nopin_response_timer_flags;
e48354ce
NB
513 /* Used to know what thread encountered a transport failure */
514 u8 which_thread;
515 /* connection id assigned by the Initiator */
516 u16 cid;
517 /* Remote TCP Port */
518 u16 login_port;
2f9bc894 519 u16 local_port;
e48354ce 520 int net_size;
baa4d64b 521 int login_family;
e48354ce 522 u32 auth_id;
e48354ce
NB
523 u32 conn_flags;
524 /* Used for iscsi_tx_login_rsp() */
66c7db68 525 itt_t login_itt;
e48354ce
NB
526 u32 exp_statsn;
527 /* Per connection status sequence number */
528 u32 stat_sn;
529 /* IFMarkInt's Current Value */
530 u32 if_marker;
531 /* OFMarkInt's Current Value */
532 u32 of_marker;
533 /* Used for calculating OFMarker offset to next PDU */
534 u32 of_marker_offset;
e48354ce
NB
535#define IPV6_ADDRESS_SPACE 48
536 unsigned char login_ip[IPV6_ADDRESS_SPACE];
2f9bc894 537 unsigned char local_ip[IPV6_ADDRESS_SPACE];
e48354ce
NB
538 int conn_usage_count;
539 int conn_waiting_on_uc;
540 atomic_t check_immediate_queue;
541 atomic_t conn_logout_remove;
542 atomic_t connection_exit;
543 atomic_t connection_recovery;
544 atomic_t connection_reinstatement;
e48354ce
NB
545 atomic_t connection_wait_rcfr;
546 atomic_t sleep_on_conn_wait_comp;
547 atomic_t transport_failed;
548 struct completion conn_post_wait_comp;
549 struct completion conn_wait_comp;
550 struct completion conn_wait_rcfr_comp;
551 struct completion conn_waiting_on_uc_comp;
552 struct completion conn_logout_comp;
553 struct completion tx_half_close_comp;
554 struct completion rx_half_close_comp;
555 /* socket used by this connection */
556 struct socket *sock;
557 struct timer_list nopin_timer;
558 struct timer_list nopin_response_timer;
559 struct timer_list transport_timer;
560 /* Spinlock used for add/deleting cmd's from conn_cmd_list */
561 spinlock_t cmd_lock;
562 spinlock_t conn_usage_lock;
563 spinlock_t immed_queue_lock;
564 spinlock_t nopin_timer_lock;
565 spinlock_t response_queue_lock;
566 spinlock_t state_lock;
567 /* libcrypto RX and TX contexts for crc32c */
568 struct hash_desc conn_rx_hash;
569 struct hash_desc conn_tx_hash;
570 /* Used for scheduling TX and RX connection kthreads */
571 cpumask_var_t conn_cpumask;
f8d48ae5
DC
572 unsigned int conn_rx_reset_cpumask:1;
573 unsigned int conn_tx_reset_cpumask:1;
e48354ce
NB
574 /* list_head of struct iscsi_cmd for this connection */
575 struct list_head conn_cmd_list;
576 struct list_head immed_queue_list;
577 struct list_head response_queue_list;
578 struct iscsi_conn_ops *conn_ops;
baa4d64b
NB
579 struct iscsi_login *conn_login;
580 struct iscsit_transport *conn_transport;
e48354ce
NB
581 struct iscsi_param_list *param_list;
582 /* Used for per connection auth state machine */
583 void *auth_protocol;
baa4d64b 584 void *context;
e48354ce
NB
585 struct iscsi_login_thread_s *login_thread;
586 struct iscsi_portal_group *tpg;
587 /* Pointer to parent session */
588 struct iscsi_session *sess;
589 /* Pointer to thread_set in use for this conn's threads */
590 struct iscsi_thread_set *thread_set;
591 /* list_head for session connection list */
592 struct list_head conn_list;
593} ____cacheline_aligned;
594
595struct iscsi_conn_recovery {
596 u16 cid;
597 u32 cmd_count;
598 u32 maxrecvdatasegmentlength;
1c417f39 599 u32 maxxmitdatasegmentlength;
e48354ce
NB
600 int ready_for_reallegiance;
601 struct list_head conn_recovery_cmd_list;
602 spinlock_t conn_recovery_cmd_lock;
603 struct timer_list time2retain_timer;
604 struct iscsi_session *sess;
605 struct list_head cr_list;
606} ____cacheline_aligned;
607
608struct iscsi_session {
609 u8 initiator_vendor;
610 u8 isid[6];
611 enum iscsi_timer_flags_table time2retain_timer_flags;
612 u8 version_active;
613 u16 cid_called;
614 u16 conn_recovery_count;
615 u16 tsih;
616 /* state session is currently in */
617 u32 session_state;
618 /* session wide counter: initiator assigned task tag */
66c7db68 619 itt_t init_task_tag;
e48354ce
NB
620 /* session wide counter: target assigned task tag */
621 u32 targ_xfer_tag;
622 u32 cmdsn_window;
623
624 /* protects cmdsn values */
625 struct mutex cmdsn_mutex;
626 /* session wide counter: expected command sequence number */
627 u32 exp_cmd_sn;
628 /* session wide counter: maximum allowed command sequence number */
629 u32 max_cmd_sn;
630 struct list_head sess_ooo_cmdsn_list;
631
632 /* LIO specific session ID */
633 u32 sid;
634 char auth_type[8];
635 /* unique within the target */
636 int session_index;
637 /* Used for session reference counting */
638 int session_usage_count;
639 int session_waiting_on_uc;
640 u32 cmd_pdus;
641 u32 rsp_pdus;
642 u64 tx_data_octets;
643 u64 rx_data_octets;
644 u32 conn_digest_errors;
645 u32 conn_timeout_errors;
646 u64 creation_time;
647 spinlock_t session_stats_lock;
648 /* Number of active connections */
649 atomic_t nconn;
650 atomic_t session_continuation;
651 atomic_t session_fall_back_to_erl0;
652 atomic_t session_logout;
653 atomic_t session_reinstatement;
654 atomic_t session_stop_active;
655 atomic_t sleep_on_sess_wait_comp;
e48354ce
NB
656 /* connection list */
657 struct list_head sess_conn_list;
658 struct list_head cr_active_list;
659 struct list_head cr_inactive_list;
660 spinlock_t conn_lock;
661 spinlock_t cr_a_lock;
662 spinlock_t cr_i_lock;
663 spinlock_t session_usage_lock;
664 spinlock_t ttt_lock;
665 struct completion async_msg_comp;
666 struct completion reinstatement_comp;
667 struct completion session_wait_comp;
668 struct completion session_waiting_on_uc_comp;
669 struct timer_list time2retain_timer;
670 struct iscsi_sess_ops *sess_ops;
671 struct se_session *se_sess;
672 struct iscsi_portal_group *tpg;
673} ____cacheline_aligned;
674
675struct iscsi_login {
676 u8 auth_complete;
677 u8 checked_for_existing;
678 u8 current_stage;
679 u8 leading_connection;
680 u8 first_request;
681 u8 version_min;
682 u8 version_max;
baa4d64b
NB
683 u8 login_complete;
684 u8 login_failed;
e48354ce
NB
685 char isid[6];
686 u32 cmd_sn;
66c7db68 687 itt_t init_task_tag;
e48354ce
NB
688 u32 initial_exp_statsn;
689 u32 rsp_length;
690 u16 cid;
691 u16 tsih;
baa4d64b
NB
692 char req[ISCSI_HDR_LEN];
693 char rsp[ISCSI_HDR_LEN];
e48354ce
NB
694 char *req_buf;
695 char *rsp_buf;
baa4d64b 696 struct iscsi_conn *conn;
e48354ce
NB
697} ____cacheline_aligned;
698
699struct iscsi_node_attrib {
700 u32 dataout_timeout;
701 u32 dataout_timeout_retries;
702 u32 default_erl;
703 u32 nopin_timeout;
704 u32 nopin_response_timeout;
705 u32 random_datain_pdu_offsets;
706 u32 random_datain_seq_offsets;
707 u32 random_r2t_offsets;
708 u32 tmr_cold_reset;
709 u32 tmr_warm_reset;
710 struct iscsi_node_acl *nacl;
711};
712
713struct se_dev_entry_s;
714
715struct iscsi_node_auth {
716 enum naf_flags_table naf_flags;
717 int authenticate_target;
718 /* Used for iscsit_global->discovery_auth,
719 * set to zero (auth disabled) by default */
720 int enforce_discovery_auth;
721#define MAX_USER_LEN 256
722#define MAX_PASS_LEN 256
723 char userid[MAX_USER_LEN];
724 char password[MAX_PASS_LEN];
725 char userid_mutual[MAX_USER_LEN];
726 char password_mutual[MAX_PASS_LEN];
727};
728
729#include "iscsi_target_stat.h"
730
731struct iscsi_node_stat_grps {
732 struct config_group iscsi_sess_stats_group;
733 struct config_group iscsi_conn_stats_group;
734};
735
736struct iscsi_node_acl {
737 struct iscsi_node_attrib node_attrib;
738 struct iscsi_node_auth node_auth;
739 struct iscsi_node_stat_grps node_stat_grps;
740 struct se_node_acl se_node_acl;
741};
742
743#define NODE_STAT_GRPS(nacl) (&(nacl)->node_stat_grps)
744
745#define ISCSI_NODE_ATTRIB(t) (&(t)->node_attrib)
746#define ISCSI_NODE_AUTH(t) (&(t)->node_auth)
747
748struct iscsi_tpg_attrib {
749 u32 authentication;
750 u32 login_timeout;
751 u32 netif_timeout;
752 u32 generate_node_acls;
753 u32 cache_dynamic_acls;
754 u32 default_cmdsn_depth;
755 u32 demo_mode_write_protect;
756 u32 prod_mode_write_protect;
757 struct iscsi_portal_group *tpg;
758};
759
760struct iscsi_np {
761 int np_network_transport;
762 int np_ip_proto;
763 int np_sock_type;
764 enum np_thread_state_table np_thread_state;
765 enum iscsi_timer_flags_table np_login_timer_flags;
766 u32 np_exports;
767 enum np_flags_table np_flags;
768 unsigned char np_ip[IPV6_ADDRESS_SPACE];
769 u16 np_port;
770 spinlock_t np_thread_lock;
771 struct completion np_restart_comp;
772 struct socket *np_socket;
773 struct __kernel_sockaddr_storage np_sockaddr;
774 struct task_struct *np_thread;
775 struct timer_list np_login_timer;
776 struct iscsi_portal_group *np_login_tpg;
baa4d64b
NB
777 void *np_context;
778 struct iscsit_transport *np_transport;
e48354ce
NB
779 struct list_head np_list;
780} ____cacheline_aligned;
781
782struct iscsi_tpg_np {
783 struct iscsi_np *tpg_np;
784 struct iscsi_portal_group *tpg;
785 struct iscsi_tpg_np *tpg_np_parent;
786 struct list_head tpg_np_list;
787 struct list_head tpg_np_child_list;
788 struct list_head tpg_np_parent_list;
789 struct se_tpg_np se_tpg_np;
790 spinlock_t tpg_np_parent_lock;
791};
792
793struct iscsi_portal_group {
794 unsigned char tpg_chap_id;
795 /* TPG State */
796 enum tpg_state_table tpg_state;
797 /* Target Portal Group Tag */
798 u16 tpgt;
799 /* Id assigned to target sessions */
800 u16 ntsih;
801 /* Number of active sessions */
802 u32 nsessions;
803 /* Number of Network Portals available for this TPG */
804 u32 num_tpg_nps;
805 /* Per TPG LIO specific session ID. */
806 u32 sid;
807 /* Spinlock for adding/removing Network Portals */
808 spinlock_t tpg_np_lock;
809 spinlock_t tpg_state_lock;
810 struct se_portal_group tpg_se_tpg;
811 struct mutex tpg_access_lock;
812 struct mutex np_login_lock;
813 struct iscsi_tpg_attrib tpg_attrib;
c3e51442 814 struct iscsi_node_auth tpg_demo_auth;
e48354ce
NB
815 /* Pointer to default list of iSCSI parameters for TPG */
816 struct iscsi_param_list *param_list;
817 struct iscsi_tiqn *tpg_tiqn;
818 struct list_head tpg_gnp_list;
819 struct list_head tpg_list;
820} ____cacheline_aligned;
821
822#define ISCSI_TPG_C(c) ((struct iscsi_portal_group *)(c)->tpg)
823#define ISCSI_TPG_LUN(c, l) ((iscsi_tpg_list_t *)(c)->tpg->tpg_lun_list_t[l])
824#define ISCSI_TPG_S(s) ((struct iscsi_portal_group *)(s)->tpg)
825#define ISCSI_TPG_ATTRIB(t) (&(t)->tpg_attrib)
826#define SE_TPG(tpg) (&(tpg)->tpg_se_tpg)
827
828struct iscsi_wwn_stat_grps {
829 struct config_group iscsi_stat_group;
830 struct config_group iscsi_instance_group;
831 struct config_group iscsi_sess_err_group;
832 struct config_group iscsi_tgt_attr_group;
833 struct config_group iscsi_login_stats_group;
834 struct config_group iscsi_logout_stats_group;
835};
836
837struct iscsi_tiqn {
838#define ISCSI_IQN_LEN 224
839 unsigned char tiqn[ISCSI_IQN_LEN];
840 enum tiqn_state_table tiqn_state;
841 int tiqn_access_count;
842 u32 tiqn_active_tpgs;
843 u32 tiqn_ntpgs;
844 u32 tiqn_num_tpg_nps;
845 u32 tiqn_nsessions;
846 struct list_head tiqn_list;
847 struct list_head tiqn_tpg_list;
848 spinlock_t tiqn_state_lock;
849 spinlock_t tiqn_tpg_lock;
850 struct se_wwn tiqn_wwn;
851 struct iscsi_wwn_stat_grps tiqn_stat_grps;
852 int tiqn_index;
853 struct iscsi_sess_err_stats sess_err_stats;
854 struct iscsi_login_stats login_stats;
855 struct iscsi_logout_stats logout_stats;
856} ____cacheline_aligned;
857
858#define WWN_STAT_GRPS(tiqn) (&(tiqn)->tiqn_stat_grps)
859
860struct iscsit_global {
861 /* In core shutdown */
862 u32 in_shutdown;
863 u32 active_ts;
864 /* Unique identifier used for the authentication daemon */
865 u32 auth_id;
866 u32 inactive_ts;
867 /* Thread Set bitmap count */
868 int ts_bitmap_count;
869 /* Thread Set bitmap pointer */
870 unsigned long *ts_bitmap;
871 /* Used for iSCSI discovery session authentication */
872 struct iscsi_node_acl discovery_acl;
873 struct iscsi_portal_group *discovery_tpg;
874};
875
876#endif /* ISCSI_TARGET_CORE_H */
This page took 0.186966 seconds and 5 git commands to generate.