Blame view

include/scsi/libiscsi.h 14.3 KB
7996a778f   Mike Christie   [SCSI] iscsi: add...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  /*
   * iSCSI lib definitions
   *
   * Copyright (C) 2006 Red Hat, Inc.  All rights reserved.
   * Copyright (C) 2004 - 2006 Mike Christie
   * Copyright (C) 2004 - 2005 Dmitry Yusupov
   * Copyright (C) 2004 - 2005 Alex Aizman
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   */
  #ifndef LIBISCSI_H
  #define LIBISCSI_H
  
  #include <linux/types.h>
40753caa3   Mike Christie   [SCSI] iscsi clas...
27
  #include <linux/wait.h>
7996a778f   Mike Christie   [SCSI] iscsi: add...
28
  #include <linux/mutex.h>
f6a570333   Al Viro   [PATCH] severing ...
29
30
  #include <linux/timer.h>
  #include <linux/workqueue.h>
454654878   Stefani Seibold   kfifo: move struc...
31
  #include <linux/kfifo.h>
6dc618cdd   Elena Reshetova   scsi: libiscsi: q...
32
  #include <linux/refcount.h>
7996a778f   Mike Christie   [SCSI] iscsi: add...
33
34
  #include <scsi/iscsi_proto.h>
  #include <scsi/iscsi_if.h>
262ef6362   Mike Christie   [SCSI] libiscsi: ...
35
  #include <scsi/scsi_transport_iscsi.h>
7996a778f   Mike Christie   [SCSI] iscsi: add...
36
37
  
  struct scsi_transport_template;
a4804cd6e   Mike Christie   [SCSI] iscsi: add...
38
  struct scsi_host_template;
7996a778f   Mike Christie   [SCSI] iscsi: add...
39
40
  struct scsi_device;
  struct Scsi_Host;
6b5d6c443   Mike Christie   [SCSI] cxgb3i, is...
41
  struct scsi_target;
7996a778f   Mike Christie   [SCSI] iscsi: add...
42
43
44
45
46
47
48
  struct scsi_cmnd;
  struct socket;
  struct iscsi_transport;
  struct iscsi_cls_session;
  struct iscsi_cls_conn;
  struct iscsi_session;
  struct iscsi_nopin;
a4804cd6e   Mike Christie   [SCSI] iscsi: add...
49
  struct device;
7996a778f   Mike Christie   [SCSI] iscsi: add...
50

1548271ec   Mike Christie   [SCSI] libiscsi: ...
51
  #define ISCSI_DEF_XMIT_CMDS_MAX	128	/* must be power of 2 */
3cf7b233f   Mike Christie   [SCSI] libiscsi: ...
52
  #define ISCSI_MGMT_CMDS_MAX	15
7996a778f   Mike Christie   [SCSI] iscsi: add...
53

e28f3d5b5   Mike Christie   [SCSI] libiscsi: ...
54
  #define ISCSI_DEF_CMD_PER_LUN	32
7996a778f   Mike Christie   [SCSI] iscsi: add...
55
56
  
  /* Task Mgmt states */
843c0a8a7   Mike Christie   [SCSI] libiscsi, ...
57
58
59
60
61
62
63
64
  enum {
  	TMF_INITIAL,
  	TMF_QUEUED,
  	TMF_SUCCESS,
  	TMF_FAILED,
  	TMF_TIMEDOUT,
  	TMF_NOT_FOUND,
  };
7996a778f   Mike Christie   [SCSI] iscsi: add...
65

f8525eb4c   Adheer Chandravanshi   [SCSI] libiscsi: ...
66
  #define ISID_SIZE			6
7996a778f   Mike Christie   [SCSI] iscsi: add...
67
68
  /* Connection suspend "bit" */
  #define ISCSI_SUSPEND_BIT		1
262ef6362   Mike Christie   [SCSI] libiscsi: ...
69
  #define ISCSI_ITT_MASK			0x1fff
3cf7b233f   Mike Christie   [SCSI] libiscsi: ...
70
71
72
  #define ISCSI_TOTAL_CMDS_MAX		4096
  /* this must be a power of two greater than ISCSI_MGMT_CMDS_MAX */
  #define ISCSI_TOTAL_CMDS_MIN		16
7996a778f   Mike Christie   [SCSI] iscsi: add...
73
  #define ISCSI_AGE_SHIFT			28
262ef6362   Mike Christie   [SCSI] libiscsi: ...
74
  #define ISCSI_AGE_MASK			0xf
7996a778f   Mike Christie   [SCSI] iscsi: add...
75

222369619   Mike Christie   [SCSI] iscsi clas...
76
  #define ISCSI_ADDRESS_BUF_LEN		64
da32dd681   Olaf Kirch   [SCSI] iscsi_tcp:...
77
  enum {
004d6530f   Boaz Harrosh   [SCSI] iscsi_tcp,...
78
79
80
  	/* this is the maximum possible storage for AHSs */
  	ISCSI_MAX_AHS_SIZE = sizeof(struct iscsi_ecdb_ahdr) +
  				sizeof(struct iscsi_rlength_ahdr),
da32dd681   Olaf Kirch   [SCSI] iscsi_tcp:...
81
82
  	ISCSI_DIGEST_SIZE = sizeof(__u32),
  };
7996a778f   Mike Christie   [SCSI] iscsi: add...
83

b6c395ed0   Mike Christie   [SCSI] iscsi bugf...
84
  enum {
3bbaaad95   Mike Christie   [SCSI] libiscsi: ...
85
  	ISCSI_TASK_FREE,
b6c395ed0   Mike Christie   [SCSI] iscsi bugf...
86
87
88
  	ISCSI_TASK_COMPLETED,
  	ISCSI_TASK_PENDING,
  	ISCSI_TASK_RUNNING,
b3cd5050b   Mike Christie   [SCSI] libiscsi: ...
89
90
  	ISCSI_TASK_ABRT_TMF,		/* aborted due to TMF */
  	ISCSI_TASK_ABRT_SESS_RECOV,	/* aborted due to session recovery */
f41d47217   Mike Christie   [SCSI] libiscsi: ...
91
  	ISCSI_TASK_REQUEUE_SCSIQ,	/* qcmd requeueing to scsi-ml */
b6c395ed0   Mike Christie   [SCSI] iscsi bugf...
92
  };
577577da6   Mike Christie   [SCSI] libiscsi: ...
93
94
95
96
97
98
99
100
101
102
  struct iscsi_r2t_info {
  	__be32			ttt;		/* copied from R2T */
  	__be32			exp_statsn;	/* copied from R2T */
  	uint32_t		data_length;	/* copied from R2T */
  	uint32_t		data_offset;	/* copied from R2T */
  	int			data_count;	/* DATA-Out payload progress */
  	int			datasn;
  	/* LLDs should set/update these values */
  	int			sent;		/* R2T sequence progress */
  };
9c19a7d03   Mike Christie   [SCSI] libiscsi: ...
103
  struct iscsi_task {
7996a778f   Mike Christie   [SCSI] iscsi: add...
104
  	/*
004d6530f   Boaz Harrosh   [SCSI] iscsi_tcp,...
105
106
107
  	 * Because LLDs allocate their hdr differently, this is a pointer
  	 * and length to that storage. It must be setup at session
  	 * creation time.
7996a778f   Mike Christie   [SCSI] iscsi: add...
108
  	 */
577577da6   Mike Christie   [SCSI] libiscsi: ...
109
  	struct iscsi_hdr	*hdr;
004d6530f   Boaz Harrosh   [SCSI] iscsi_tcp,...
110
111
  	unsigned short		hdr_max;
  	unsigned short		hdr_len;	/* accumulated size of hdr used */
577577da6   Mike Christie   [SCSI] libiscsi: ...
112
113
114
  	/* copied values in case we need to send tmfs */
  	itt_t			hdr_itt;
  	__be32			cmdsn;
516f43a2a   Andy Grover   [SCSI] iscsi: Use...
115
  	struct scsi_lun		lun;
577577da6   Mike Christie   [SCSI] libiscsi: ...
116

7996a778f   Mike Christie   [SCSI] iscsi: add...
117
  	int			itt;		/* this ITT */
7996a778f   Mike Christie   [SCSI] iscsi: add...
118

857ae0bdb   Mike Christie   [SCSI] iscsi: Som...
119
  	unsigned		imm_count;	/* imm-data (bytes)   */
ffd0436ed   Mike Christie   [SCSI] libiscsi, ...
120
  	/* offset in unsolicited stream (bytes); */
577577da6   Mike Christie   [SCSI] libiscsi: ...
121
  	struct iscsi_r2t_info	unsol_r2t;
3e5c28ad0   Mike Christie   [SCSI] libiscsi: ...
122
  	char			*data;		/* mgmt payload */
577577da6   Mike Christie   [SCSI] libiscsi: ...
123
  	unsigned		data_count;
7996a778f   Mike Christie   [SCSI] iscsi: add...
124
  	struct scsi_cmnd	*sc;		/* associated SCSI cmd*/
7996a778f   Mike Christie   [SCSI] iscsi: add...
125
  	struct iscsi_conn	*conn;		/* used connection    */
7996a778f   Mike Christie   [SCSI] iscsi: add...
126

d355e57d5   Mike Christie   libiscsi: don't r...
127
128
129
130
  	/* data processing tracking */
  	unsigned long		last_xfer;
  	unsigned long		last_timeout;
  	bool			have_checked_conn;
55e51eda4   Sagi Grimberg   SCSI/libiscsi: Ad...
131
132
133
  
  	/* T10 protection information */
  	bool			protected;
b6c395ed0   Mike Christie   [SCSI] iscsi bugf...
134
135
  	/* state set/tested under session->lock */
  	int			state;
6dc618cdd   Elena Reshetova   scsi: libiscsi: q...
136
  	refcount_t		refcount;
7996a778f   Mike Christie   [SCSI] iscsi: add...
137
138
139
  	struct list_head	running;	/* running cmd list */
  	void			*dd_data;	/* driver/transport data */
  };
577577da6   Mike Christie   [SCSI] libiscsi: ...
140
141
142
143
  static inline int iscsi_task_has_unsol_data(struct iscsi_task *task)
  {
  	return task->unsol_r2t.data_length > task->unsol_r2t.sent;
  }
9c19a7d03   Mike Christie   [SCSI] libiscsi: ...
144
  static inline void* iscsi_next_hdr(struct iscsi_task *task)
004d6530f   Boaz Harrosh   [SCSI] iscsi_tcp,...
145
  {
9c19a7d03   Mike Christie   [SCSI] libiscsi: ...
146
  	return (void*)task->hdr + task->hdr_len;
004d6530f   Boaz Harrosh   [SCSI] iscsi_tcp,...
147
  }
6eabafbe6   Mike Christie   [SCSI] iscsi clas...
148
149
150
151
152
153
154
  /* Connection's states */
  enum {
  	ISCSI_CONN_INITIAL_STAGE,
  	ISCSI_CONN_STARTED,
  	ISCSI_CONN_STOPPED,
  	ISCSI_CONN_CLEANUP_WAIT,
  };
7996a778f   Mike Christie   [SCSI] iscsi: add...
155
156
157
158
159
  struct iscsi_conn {
  	struct iscsi_cls_conn	*cls_conn;	/* ptr to class connection */
  	void			*dd_data;	/* iscsi_transport data */
  	struct iscsi_session	*session;	/* parent session */
  	/*
7996a778f   Mike Christie   [SCSI] iscsi: add...
160
161
162
  	 * conn_stop() flag: stop to recover, stop to terminate
  	 */
          int			stop_stage;
f6d5180c7   Mike Christie   [SCSI] libiscsi: ...
163
164
165
166
167
  	struct timer_list	transport_timer;
  	unsigned long		last_recv;
  	unsigned long		last_ping;
  	int			ping_timeout;
  	int			recv_timeout;
9c19a7d03   Mike Christie   [SCSI] libiscsi: ...
168
  	struct iscsi_task 	*ping_task;
7996a778f   Mike Christie   [SCSI] iscsi: add...
169
170
171
  
  	/* iSCSI connection-wide sequencing */
  	uint32_t		exp_statsn;
f8525eb4c   Adheer Chandravanshi   [SCSI] libiscsi: ...
172
  	uint32_t		statsn;
7996a778f   Mike Christie   [SCSI] iscsi: add...
173
174
175
  
  	/* control data */
  	int			id;		/* CID */
7996a778f   Mike Christie   [SCSI] iscsi: add...
176
  	int			c_stage;	/* connection state */
c8dc1e523   Mike Christie   [SCSI] iscsi bugf...
177
178
179
180
181
182
183
184
  	/*
  	 * Preallocated buffer for pdus that have data but do not
  	 * originate from scsi-ml. We never have two pdus using the
  	 * buffer at the same time. It is only allocated to
  	 * the default max recv size because the pdus we support
  	 * should always fit in this buffer
  	 */
  	char			*data;
9c19a7d03   Mike Christie   [SCSI] libiscsi: ...
185
186
  	struct iscsi_task 	*login_task;	/* mtask used for login/text */
  	struct iscsi_task	*task;		/* xmit task in progress */
7996a778f   Mike Christie   [SCSI] iscsi: add...
187
188
  
  	/* xmit */
6f8830f5b   Chris Leech   scsi: libiscsi: a...
189
  	spinlock_t		taskqueuelock;  /* protects the next three lists */
843c0a8a7   Mike Christie   [SCSI] libiscsi, ...
190
  	struct list_head	mgmtqueue;	/* mgmt (control) xmit queue */
3bbaaad95   Mike Christie   [SCSI] libiscsi: ...
191
  	struct list_head	cmdqueue;	/* data-path cmd queue */
843c0a8a7   Mike Christie   [SCSI] libiscsi, ...
192
  	struct list_head	requeue;	/* tasks needing another run */
7996a778f   Mike Christie   [SCSI] iscsi: add...
193
  	struct work_struct	xmitwork;	/* per-conn. xmit workqueue */
7996a778f   Mike Christie   [SCSI] iscsi: add...
194
195
196
197
198
199
  	unsigned long		suspend_tx;	/* suspend Tx */
  	unsigned long		suspend_rx;	/* suspend Rx */
  
  	/* abort */
  	wait_queue_head_t	ehwait;		/* used in eh_abort() */
  	struct iscsi_tm		tmhdr;
843c0a8a7   Mike Christie   [SCSI] libiscsi, ...
200
201
  	struct timer_list	tmf_timer;
  	int			tmf_state;	/* see TMF_INITIAL, etc.*/
7996a778f   Mike Christie   [SCSI] iscsi: add...
202
203
  
  	/* negotiated params */
857ae0bdb   Mike Christie   [SCSI] iscsi: Som...
204
205
  	unsigned		max_recv_dlength; /* initiator_max_recv_dsl*/
  	unsigned		max_xmit_dlength; /* target_max_recv_dsl */
7996a778f   Mike Christie   [SCSI] iscsi: add...
206
207
  	int			hdrdgst_en;
  	int			datadgst_en;
a54a52caa   Mike Christie   [SCSI] iscsi: fix...
208
209
210
211
212
  	int			ifmarker_en;
  	int			ofmarker_en;
  	/* values userspace uses to id a conn */
  	int			persistent_port;
  	char			*persistent_address;
7996a778f   Mike Christie   [SCSI] iscsi: add...
213

f8525eb4c   Adheer Chandravanshi   [SCSI] libiscsi: ...
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
  	unsigned		max_segment_size;
  	unsigned		tcp_xmit_wsf;
  	unsigned		tcp_recv_wsf;
  	uint16_t		keepalive_tmo;
  	uint16_t		local_port;
  	uint8_t			tcp_timestamp_stat;
  	uint8_t			tcp_nagle_disable;
  	uint8_t			tcp_wsf_disable;
  	uint8_t			tcp_timer_scale;
  	uint8_t			tcp_timestamp_en;
  	uint8_t			fragment_disable;
  	uint8_t			ipv4_tos;
  	uint8_t			ipv6_traffic_class;
  	uint8_t			ipv6_flow_label;
  	uint8_t			is_fw_assigned_ipv6;
ae56ff408   Adheer Chandravanshi   [SCSI] libiscsi: ...
229
  	char			*local_ipaddr;
f8525eb4c   Adheer Chandravanshi   [SCSI] libiscsi: ...
230

7996a778f   Mike Christie   [SCSI] iscsi: add...
231
232
233
234
235
236
237
238
239
240
241
242
243
  	/* MIB-statistics */
  	uint64_t		txdata_octets;
  	uint64_t		rxdata_octets;
  	uint32_t		scsicmd_pdus_cnt;
  	uint32_t		dataout_pdus_cnt;
  	uint32_t		scsirsp_pdus_cnt;
  	uint32_t		datain_pdus_cnt;
  	uint32_t		r2t_pdus_cnt;
  	uint32_t		tmfcmd_pdus_cnt;
  	int32_t			tmfrsp_pdus_cnt;
  
  	/* custom statistics */
  	uint32_t		eh_abort_cnt;
87528227d   Eli Dorfman   IB/iser: Count FM...
244
  	uint32_t		fmr_unalign_cnt;
7996a778f   Mike Christie   [SCSI] iscsi: add...
245
  };
6320377fd   Olaf Kirch   [SCSI] libiscsi, ...
246
  struct iscsi_pool {
454654878   Stefani Seibold   kfifo: move struc...
247
  	struct kfifo		queue;		/* FIFO Queue */
7996a778f   Mike Christie   [SCSI] iscsi: add...
248
249
250
  	void			**pool;		/* Pool of elements */
  	int			max;		/* Max number of elements */
  };
6eabafbe6   Mike Christie   [SCSI] iscsi clas...
251
252
253
254
255
256
257
258
259
260
  /* Session's states */
  enum {
  	ISCSI_STATE_FREE = 1,
  	ISCSI_STATE_LOGGED_IN,
  	ISCSI_STATE_FAILED,
  	ISCSI_STATE_TERMINATE,
  	ISCSI_STATE_IN_RECOVERY,
  	ISCSI_STATE_RECOVERY_FAILED,
  	ISCSI_STATE_LOGGING_OUT,
  };
7996a778f   Mike Christie   [SCSI] iscsi: add...
261
  struct iscsi_session {
756135215   Mike Christie   [SCSI] iscsi: rem...
262
  	struct iscsi_cls_session *cls_session;
6724add1b   Mike Christie   [SCSI] libiscsi: ...
263
264
265
266
267
268
  	/*
  	 * Syncs up the scsi eh thread with the iscsi eh thread when sending
  	 * task management functions. This must be taken before the session
  	 * and recv lock.
  	 */
  	struct mutex		eh_mutex;
7996a778f   Mike Christie   [SCSI] iscsi: add...
269
270
271
272
  	/* iSCSI session-wide sequencing */
  	uint32_t		cmdsn;
  	uint32_t		exp_cmdsn;
  	uint32_t		max_cmdsn;
e07264071   Mike Christie   [SCSI] libiscsi: ...
273
274
  	/* This tracks the reqs queued into the initiator */
  	uint32_t		queued_cmdsn;
7996a778f   Mike Christie   [SCSI] iscsi: add...
275
  	/* configuration */
f6d5180c7   Mike Christie   [SCSI] libiscsi: ...
276
277
  	int			abort_timeout;
  	int			lu_reset_timeout;
3fe5ae8b4   Mike Christie   [SCSI] libiscsi: ...
278
  	int			tgt_reset_timeout;
7996a778f   Mike Christie   [SCSI] iscsi: add...
279
  	int			initial_r2t_en;
1304be5fe   Mike Christie   [SCSI] libiscsi_t...
280
  	unsigned short		max_r2t;
7996a778f   Mike Christie   [SCSI] iscsi: add...
281
  	int			imm_data_en;
857ae0bdb   Mike Christie   [SCSI] iscsi: Som...
282
283
  	unsigned		first_burst;
  	unsigned		max_burst;
7996a778f   Mike Christie   [SCSI] iscsi: add...
284
285
286
287
288
  	int			time2wait;
  	int			time2retain;
  	int			pdu_inorder_en;
  	int			dataseq_inorder_en;
  	int			erl;
843c0a8a7   Mike Christie   [SCSI] libiscsi, ...
289
  	int			fast_abort;
a54a52caa   Mike Christie   [SCSI] iscsi: fix...
290
  	int			tpgt;
b2c641673   Mike Christie   [SCSI] iscsi clas...
291
292
293
294
  	char			*username;
  	char			*username_in;
  	char			*password;
  	char			*password_in;
a54a52caa   Mike Christie   [SCSI] iscsi: fix...
295
  	char			*targetname;
3c5c48011   Vikas Chaudhary   [SCSI] libiscsi: ...
296
  	char			*targetalias;
88dfd340b   Mike Christie   [SCSI] iscsi clas...
297
298
  	char			*ifacename;
  	char			*initiatorname;
3b9373e95   Eddie Wai   [SCSI] libiscsi: ...
299
300
301
  	char			*boot_root;
  	char			*boot_nic;
  	char			*boot_target;
f8525eb4c   Adheer Chandravanshi   [SCSI] libiscsi: ...
302
303
304
305
306
307
308
309
310
311
312
313
  	char			*portal_type;
  	char			*discovery_parent_type;
  	uint16_t		discovery_parent_idx;
  	uint16_t		def_taskmgmt_tmo;
  	uint16_t		tsid;
  	uint8_t			auto_snd_tgt_disable;
  	uint8_t			discovery_sess;
  	uint8_t			chap_auth_en;
  	uint8_t			discovery_logout_en;
  	uint8_t			bidi_chap_en;
  	uint8_t			discovery_auth_optional;
  	uint8_t			isid[ISID_SIZE];
3b9373e95   Eddie Wai   [SCSI] libiscsi: ...
314

7996a778f   Mike Christie   [SCSI] iscsi: add...
315
316
317
318
  	/* control data */
  	struct iscsi_transport	*tt;
  	struct Scsi_Host	*host;
  	struct iscsi_conn	*leadconn;	/* leading connection */
659743b02   Shlomo Pongratz   [SCSI] libiscsi: ...
319
320
321
322
323
324
325
  	/* Between the forward and the backward locks exists a strict locking
  	 * hierarchy. The mutual exclusion zone protected by the forward lock
  	 * can enclose the mutual exclusion zone protected by the backward lock
  	 * but not vice versa.
  	 */
  	spinlock_t		frwd_lock;	/* protects session state, *
  						 * cmdsn, queued_cmdsn     *
7996a778f   Mike Christie   [SCSI] iscsi: add...
326
  						 * session resources:      *
659743b02   Shlomo Pongratz   [SCSI] libiscsi: ...
327
328
329
330
331
  						 * - cmdpool kfifo_out ,   *
  						 * - mgmtpool,		   */
  	spinlock_t		back_lock;	/* protects cmdsn_exp      *
  						 * cmdsn_max,              *
  						 * cmdpool kfifo_in        */
7996a778f   Mike Christie   [SCSI] iscsi: add...
332
  	int			state;		/* session state           */
7996a778f   Mike Christie   [SCSI] iscsi: add...
333
  	int			age;		/* counts session re-opens */
3e5c28ad0   Mike Christie   [SCSI] libiscsi: ...
334
  	int			scsi_cmds_max; 	/* max scsi commands */
7996a778f   Mike Christie   [SCSI] iscsi: add...
335
  	int			cmds_max;	/* size of cmds array */
9c19a7d03   Mike Christie   [SCSI] libiscsi: ...
336
  	struct iscsi_task	**cmds;		/* Original Cmds arr */
6320377fd   Olaf Kirch   [SCSI] libiscsi, ...
337
  	struct iscsi_pool	cmdpool;	/* PDU's pool */
b8b9e1b81   Jayamohan Kallickal   [SCSI] libiscsi: ...
338
  	void			*dd_data;	/* LLD private data */
7996a778f   Mike Christie   [SCSI] iscsi: add...
339
  };
e5bd7b54e   Mike Christie   [SCSI] libiscsi: ...
340
341
342
343
  enum {
  	ISCSI_HOST_SETUP,
  	ISCSI_HOST_REMOVED,
  };
756135215   Mike Christie   [SCSI] iscsi: rem...
344
345
346
347
348
  struct iscsi_host {
  	char			*initiatorname;
  	/* hw address or netdev iscsi connection is bound to */
  	char			*hwaddress;
  	char			*netdev;
e5bd7b54e   Mike Christie   [SCSI] libiscsi: ...
349
350
351
352
353
354
  
  	wait_queue_head_t	session_removal_wq;
  	/* protects sessions and state */
  	spinlock_t		lock;
  	int			num_sessions;
  	int			state;
32ae763e3   Mike Christie   [SCSI] iscsi lib:...
355
356
357
  
  	struct workqueue_struct	*workq;
  	char			workq_name[20];
756135215   Mike Christie   [SCSI] iscsi: rem...
358
  };
7996a778f   Mike Christie   [SCSI] iscsi: add...
359
360
361
  /*
   * scsi host template
   */
7996a778f   Mike Christie   [SCSI] iscsi: add...
362
  extern int iscsi_eh_abort(struct scsi_cmnd *sc);
309ce156a   Jayamohan Kallickal   [SCSI] libiscsi: ...
363
364
  extern int iscsi_eh_recover_target(struct scsi_cmnd *sc);
  extern int iscsi_eh_session_reset(struct scsi_cmnd *sc);
843c0a8a7   Mike Christie   [SCSI] libiscsi, ...
365
  extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
f41d47217   Mike Christie   [SCSI] libiscsi: ...
366
  extern int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc);
b6a05c823   Christoph Hellwig   scsi: remove eh_t...
367
  extern enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc);
0801c242a   Mike Christie   [SCSI] libiscsi, ...
368

0801c242a   Mike Christie   [SCSI] libiscsi, ...
369
370
371
  /*
   * iSCSI host helpers.
   */
5d91e209f   Mike Christie   [SCSI] iscsi: rem...
372
373
  #define iscsi_host_priv(_shost) \
  	(shost_priv(_shost) + sizeof(struct iscsi_host))
0801c242a   Mike Christie   [SCSI] libiscsi, ...
374
375
376
377
378
  extern int iscsi_host_set_param(struct Scsi_Host *shost,
  				enum iscsi_host_param param, char *buf,
  				int buflen);
  extern int iscsi_host_get_param(struct Scsi_Host *shost,
  				enum iscsi_host_param param, char *buf);
a4804cd6e   Mike Christie   [SCSI] iscsi: add...
379
380
  extern int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev);
  extern struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
4d1083509   Mike Christie   [SCSI] iscsi lib:...
381
  					  int dd_data_size,
32ae763e3   Mike Christie   [SCSI] iscsi lib:...
382
  					  bool xmit_can_sleep);
a4804cd6e   Mike Christie   [SCSI] iscsi: add...
383
384
  extern void iscsi_host_remove(struct Scsi_Host *shost);
  extern void iscsi_host_free(struct Scsi_Host *shost);
6b5d6c443   Mike Christie   [SCSI] cxgb3i, is...
385
  extern int iscsi_target_alloc(struct scsi_target *starget);
7996a778f   Mike Christie   [SCSI] iscsi: add...
386
387
388
389
390
  
  /*
   * session management
   */
  extern struct iscsi_cls_session *
756135215   Mike Christie   [SCSI] iscsi: rem...
391
  iscsi_session_setup(struct iscsi_transport *, struct Scsi_Host *shost,
b8b9e1b81   Jayamohan Kallickal   [SCSI] libiscsi: ...
392
  		    uint16_t, int, int, uint32_t, unsigned int);
7996a778f   Mike Christie   [SCSI] iscsi: add...
393
  extern void iscsi_session_teardown(struct iscsi_cls_session *);
7996a778f   Mike Christie   [SCSI] iscsi: add...
394
  extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *);
a54a52caa   Mike Christie   [SCSI] iscsi: fix...
395
396
397
398
  extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
  			   enum iscsi_param param, char *buf, int buflen);
  extern int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
  				   enum iscsi_param param, char *buf);
7996a778f   Mike Christie   [SCSI] iscsi: add...
399

322d739da   Mike Christie   [SCSI] iscsi: fix...
400
  #define iscsi_session_printk(prefix, _sess, fmt, a...)	\
756135215   Mike Christie   [SCSI] iscsi: rem...
401
  	iscsi_cls_session_printk(prefix, _sess->cls_session, fmt, ##a)
322d739da   Mike Christie   [SCSI] iscsi: fix...
402

7996a778f   Mike Christie   [SCSI] iscsi: add...
403
404
405
406
  /*
   * connection management
   */
  extern struct iscsi_cls_conn *iscsi_conn_setup(struct iscsi_cls_session *,
5d91e209f   Mike Christie   [SCSI] iscsi: rem...
407
  					       int, uint32_t);
7996a778f   Mike Christie   [SCSI] iscsi: add...
408
409
410
411
412
413
  extern void iscsi_conn_teardown(struct iscsi_cls_conn *);
  extern int iscsi_conn_start(struct iscsi_cls_conn *);
  extern void iscsi_conn_stop(struct iscsi_cls_conn *, int);
  extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
  			   int);
  extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err);
40a06e755   Mike Christie   [SCSI] libiscsi: ...
414
  extern void iscsi_session_failure(struct iscsi_session *session,
e5bd7b54e   Mike Christie   [SCSI] libiscsi: ...
415
  				  enum iscsi_err err);
a54a52caa   Mike Christie   [SCSI] iscsi: fix...
416
417
  extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
  				enum iscsi_param param, char *buf);
00f3708e6   Mike Christie   [SCSI] libiscsi: ...
418
419
  extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr,
  				     enum iscsi_param param, char *buf);
5af3e91d2   Mike Christie   [SCSI] iscsi: mod...
420
  extern void iscsi_suspend_tx(struct iscsi_conn *conn);
661134ad3   Mike Christie   [SCSI] libiscsi, ...
421
  extern void iscsi_suspend_queue(struct iscsi_conn *conn);
32ae763e3   Mike Christie   [SCSI] iscsi lib:...
422
  extern void iscsi_conn_queue_work(struct iscsi_conn *conn);
7996a778f   Mike Christie   [SCSI] iscsi: add...
423

322d739da   Mike Christie   [SCSI] iscsi: fix...
424
  #define iscsi_conn_printk(prefix, _c, fmt, a...) \
5af3e91d2   Mike Christie   [SCSI] iscsi: mod...
425
426
  	iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \
  			      fmt, ##a)
322d739da   Mike Christie   [SCSI] iscsi: fix...
427

7996a778f   Mike Christie   [SCSI] iscsi: add...
428
429
430
  /*
   * pdu and task processing
   */
77a23c21a   Mike Christie   [SCSI] libiscsi: ...
431
  extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *);
577577da6   Mike Christie   [SCSI] libiscsi: ...
432
433
434
  extern void iscsi_prep_data_out_pdu(struct iscsi_task *task,
  				    struct iscsi_r2t_info *r2t,
  				    struct iscsi_data *hdr);
7996a778f   Mike Christie   [SCSI] iscsi: add...
435
436
437
438
  extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
  				char *, uint32_t);
  extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
  			      char *, int);
913e5bf43   Mike Christie   [SCSI] libiscsi, ...
439
440
  extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
  				char *, int);
0af967f5d   Mike Christie   [SCSI] libiscsi, ...
441
  extern int iscsi_verify_itt(struct iscsi_conn *, itt_t);
9c19a7d03   Mike Christie   [SCSI] libiscsi: ...
442
  extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
8f9256cea   Mike Christie   [SCSI] libiscsi: ...
443
  extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
9c19a7d03   Mike Christie   [SCSI] libiscsi: ...
444
445
  extern void iscsi_requeue_task(struct iscsi_task *task);
  extern void iscsi_put_task(struct iscsi_task *task);
8eea2f55a   Eddie Wai   [SCSI] bnx2i: Add...
446
  extern void __iscsi_put_task(struct iscsi_task *task);
913e5bf43   Mike Christie   [SCSI] libiscsi, ...
447
  extern void __iscsi_get_task(struct iscsi_task *task);
4c0ba5d25   Mike Christie   [SCSI] libiscsi: ...
448
449
  extern void iscsi_complete_scsi_task(struct iscsi_task *task,
  				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
7996a778f   Mike Christie   [SCSI] iscsi: add...
450
451
452
453
  
  /*
   * generic helpers
   */
6320377fd   Olaf Kirch   [SCSI] libiscsi, ...
454
455
  extern void iscsi_pool_free(struct iscsi_pool *);
  extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int);
adaf6990d   Adheer Chandravanshi   [SCSI] libiscsi: ...
456
  extern int iscsi_switch_str_param(char **, char *);
7996a778f   Mike Christie   [SCSI] iscsi: add...
457

004d6530f   Boaz Harrosh   [SCSI] iscsi_tcp,...
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
  /*
   * inline functions to deal with padding.
   */
  static inline unsigned int
  iscsi_padded(unsigned int len)
  {
  	return (len + ISCSI_PAD_LEN - 1) & ~(ISCSI_PAD_LEN - 1);
  }
  
  static inline unsigned int
  iscsi_padding(unsigned int len)
  {
  	len &= (ISCSI_PAD_LEN - 1);
  	if (len)
  		len = ISCSI_PAD_LEN - len;
  	return len;
  }
7996a778f   Mike Christie   [SCSI] iscsi: add...
475
  #endif