blob: 0289f5745fb9a687e92f46625a8bd38fa81407d0 [file] [log] [blame]
Mike Christie7996a772006-04-06 21:13:41 -05001/*
2 * iSCSI lib definitions
3 *
4 * Copyright (C) 2006 Red Hat, Inc. All rights reserved.
5 * Copyright (C) 2004 - 2006 Mike Christie
6 * Copyright (C) 2004 - 2005 Dmitry Yusupov
7 * Copyright (C) 2004 - 2005 Alex Aizman
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23#ifndef LIBISCSI_H
24#define LIBISCSI_H
25
26#include <linux/types.h>
Mike Christie40753ca2008-05-21 15:53:56 -050027#include <linux/wait.h>
Mike Christie7996a772006-04-06 21:13:41 -050028#include <linux/mutex.h>
Al Virof6a57032006-10-18 01:47:25 -040029#include <linux/timer.h>
30#include <linux/workqueue.h>
Mike Christie7996a772006-04-06 21:13:41 -050031#include <scsi/iscsi_proto.h>
32#include <scsi/iscsi_if.h>
Mike Christie262ef632008-12-02 00:32:13 -060033#include <scsi/scsi_transport_iscsi.h>
Mike Christie7996a772006-04-06 21:13:41 -050034
35struct scsi_transport_template;
Mike Christiea4804cd2008-05-21 15:54:00 -050036struct scsi_host_template;
Mike Christie7996a772006-04-06 21:13:41 -050037struct scsi_device;
38struct Scsi_Host;
Mike Christie6b5d6c42009-04-21 15:32:32 -050039struct scsi_target;
Mike Christie7996a772006-04-06 21:13:41 -050040struct scsi_cmnd;
41struct socket;
42struct iscsi_transport;
43struct iscsi_cls_session;
44struct iscsi_cls_conn;
45struct iscsi_session;
46struct iscsi_nopin;
Mike Christiea4804cd2008-05-21 15:54:00 -050047struct device;
Mike Christie7996a772006-04-06 21:13:41 -050048
Mike Christie15482712007-05-30 12:57:19 -050049#define ISCSI_DEF_XMIT_CMDS_MAX 128 /* must be power of 2 */
Mike Christie3cf7b232008-05-21 15:54:17 -050050#define ISCSI_MGMT_CMDS_MAX 15
Mike Christie7996a772006-04-06 21:13:41 -050051
Mike Christiee28f3d52009-03-05 14:46:01 -060052#define ISCSI_DEF_CMD_PER_LUN 32
Mike Christie7996a772006-04-06 21:13:41 -050053
54/* Task Mgmt states */
Mike Christie843c0a82007-12-13 12:43:20 -060055enum {
56 TMF_INITIAL,
57 TMF_QUEUED,
58 TMF_SUCCESS,
59 TMF_FAILED,
60 TMF_TIMEDOUT,
61 TMF_NOT_FOUND,
62};
Mike Christie7996a772006-04-06 21:13:41 -050063
64/* Connection suspend "bit" */
65#define ISCSI_SUSPEND_BIT 1
66
Mike Christie262ef632008-12-02 00:32:13 -060067#define ISCSI_ITT_MASK 0x1fff
Mike Christie3cf7b232008-05-21 15:54:17 -050068#define ISCSI_TOTAL_CMDS_MAX 4096
69/* this must be a power of two greater than ISCSI_MGMT_CMDS_MAX */
70#define ISCSI_TOTAL_CMDS_MIN 16
Mike Christie7996a772006-04-06 21:13:41 -050071#define ISCSI_AGE_SHIFT 28
Mike Christie262ef632008-12-02 00:32:13 -060072#define ISCSI_AGE_MASK 0xf
Mike Christie7996a772006-04-06 21:13:41 -050073
Mike Christie22236962007-05-30 12:57:24 -050074#define ISCSI_ADDRESS_BUF_LEN 64
75
Olaf Kirchda32dd62007-12-13 12:43:21 -060076enum {
Boaz Harrosh004d6532007-12-13 12:43:23 -060077 /* this is the maximum possible storage for AHSs */
78 ISCSI_MAX_AHS_SIZE = sizeof(struct iscsi_ecdb_ahdr) +
79 sizeof(struct iscsi_rlength_ahdr),
Olaf Kirchda32dd62007-12-13 12:43:21 -060080 ISCSI_DIGEST_SIZE = sizeof(__u32),
81};
82
Mike Christie7996a772006-04-06 21:13:41 -050083
Mike Christieb6c395e2006-07-24 15:47:15 -050084enum {
85 ISCSI_TASK_COMPLETED,
86 ISCSI_TASK_PENDING,
87 ISCSI_TASK_RUNNING,
88};
89
Mike Christie577577d2008-12-02 00:32:05 -060090struct iscsi_r2t_info {
91 __be32 ttt; /* copied from R2T */
92 __be32 exp_statsn; /* copied from R2T */
93 uint32_t data_length; /* copied from R2T */
94 uint32_t data_offset; /* copied from R2T */
95 int data_count; /* DATA-Out payload progress */
96 int datasn;
97 /* LLDs should set/update these values */
98 int sent; /* R2T sequence progress */
99};
100
Mike Christie9c19a7d2008-05-21 15:54:09 -0500101struct iscsi_task {
Mike Christie7996a772006-04-06 21:13:41 -0500102 /*
Boaz Harrosh004d6532007-12-13 12:43:23 -0600103 * Because LLDs allocate their hdr differently, this is a pointer
104 * and length to that storage. It must be setup at session
105 * creation time.
Mike Christie7996a772006-04-06 21:13:41 -0500106 */
Mike Christie577577d2008-12-02 00:32:05 -0600107 struct iscsi_hdr *hdr;
Boaz Harrosh004d6532007-12-13 12:43:23 -0600108 unsigned short hdr_max;
109 unsigned short hdr_len; /* accumulated size of hdr used */
Mike Christie577577d2008-12-02 00:32:05 -0600110 /* copied values in case we need to send tmfs */
111 itt_t hdr_itt;
112 __be32 cmdsn;
113 uint8_t lun[8];
114
Mike Christie7996a772006-04-06 21:13:41 -0500115 int itt; /* this ITT */
Mike Christie7996a772006-04-06 21:13:41 -0500116
Mike Christie857ae0b2007-05-30 12:57:15 -0500117 unsigned imm_count; /* imm-data (bytes) */
Mike Christieffd04362006-08-31 18:09:24 -0400118 /* offset in unsolicited stream (bytes); */
Mike Christie577577d2008-12-02 00:32:05 -0600119 struct iscsi_r2t_info unsol_r2t;
Mike Christie3e5c28a2008-05-21 15:54:06 -0500120 char *data; /* mgmt payload */
Mike Christie577577d2008-12-02 00:32:05 -0600121 unsigned data_count;
Mike Christie7996a772006-04-06 21:13:41 -0500122 struct scsi_cmnd *sc; /* associated SCSI cmd*/
Mike Christie7996a772006-04-06 21:13:41 -0500123 struct iscsi_conn *conn; /* used connection */
Mike Christie7996a772006-04-06 21:13:41 -0500124
Mike Christieb6c395e2006-07-24 15:47:15 -0500125 /* state set/tested under session->lock */
126 int state;
Mike Christie60ecebf2006-08-31 18:09:25 -0400127 atomic_t refcount;
Mike Christie7996a772006-04-06 21:13:41 -0500128 struct list_head running; /* running cmd list */
129 void *dd_data; /* driver/transport data */
130};
131
Mike Christie577577d2008-12-02 00:32:05 -0600132static inline int iscsi_task_has_unsol_data(struct iscsi_task *task)
133{
134 return task->unsol_r2t.data_length > task->unsol_r2t.sent;
135}
136
Mike Christie9c19a7d2008-05-21 15:54:09 -0500137static inline void* iscsi_next_hdr(struct iscsi_task *task)
Boaz Harrosh004d6532007-12-13 12:43:23 -0600138{
Mike Christie9c19a7d2008-05-21 15:54:09 -0500139 return (void*)task->hdr + task->hdr_len;
Boaz Harrosh004d6532007-12-13 12:43:23 -0600140}
141
Mike Christie6eabafb2008-01-31 13:36:43 -0600142/* Connection's states */
143enum {
144 ISCSI_CONN_INITIAL_STAGE,
145 ISCSI_CONN_STARTED,
146 ISCSI_CONN_STOPPED,
147 ISCSI_CONN_CLEANUP_WAIT,
148};
149
Mike Christie7996a772006-04-06 21:13:41 -0500150struct iscsi_conn {
151 struct iscsi_cls_conn *cls_conn; /* ptr to class connection */
152 void *dd_data; /* iscsi_transport data */
153 struct iscsi_session *session; /* parent session */
154 /*
Mike Christie7996a772006-04-06 21:13:41 -0500155 * conn_stop() flag: stop to recover, stop to terminate
156 */
157 int stop_stage;
Mike Christief6d51802007-12-13 12:43:30 -0600158 struct timer_list transport_timer;
159 unsigned long last_recv;
160 unsigned long last_ping;
161 int ping_timeout;
162 int recv_timeout;
Mike Christie9c19a7d2008-05-21 15:54:09 -0500163 struct iscsi_task *ping_task;
Mike Christie7996a772006-04-06 21:13:41 -0500164
165 /* iSCSI connection-wide sequencing */
166 uint32_t exp_statsn;
167
168 /* control data */
169 int id; /* CID */
Mike Christie7996a772006-04-06 21:13:41 -0500170 int c_stage; /* connection state */
Mike Christiec8dc1e52006-07-24 15:47:39 -0500171 /*
172 * Preallocated buffer for pdus that have data but do not
173 * originate from scsi-ml. We never have two pdus using the
174 * buffer at the same time. It is only allocated to
175 * the default max recv size because the pdus we support
176 * should always fit in this buffer
177 */
178 char *data;
Mike Christie9c19a7d2008-05-21 15:54:09 -0500179 struct iscsi_task *login_task; /* mtask used for login/text */
180 struct iscsi_task *task; /* xmit task in progress */
Mike Christie7996a772006-04-06 21:13:41 -0500181
182 /* xmit */
Mike Christie843c0a82007-12-13 12:43:20 -0600183 struct list_head mgmtqueue; /* mgmt (control) xmit queue */
Mike Christie7996a772006-04-06 21:13:41 -0500184 struct list_head mgmt_run_list; /* list of control tasks */
Mike Christieb6c395e2006-07-24 15:47:15 -0500185 struct list_head xmitqueue; /* data-path cmd queue */
Mike Christie7996a772006-04-06 21:13:41 -0500186 struct list_head run_list; /* list of cmds in progress */
Mike Christie843c0a82007-12-13 12:43:20 -0600187 struct list_head requeue; /* tasks needing another run */
Mike Christie7996a772006-04-06 21:13:41 -0500188 struct work_struct xmitwork; /* per-conn. xmit workqueue */
Mike Christie7996a772006-04-06 21:13:41 -0500189 unsigned long suspend_tx; /* suspend Tx */
190 unsigned long suspend_rx; /* suspend Rx */
191
192 /* abort */
193 wait_queue_head_t ehwait; /* used in eh_abort() */
194 struct iscsi_tm tmhdr;
Mike Christie843c0a82007-12-13 12:43:20 -0600195 struct timer_list tmf_timer;
196 int tmf_state; /* see TMF_INITIAL, etc.*/
Mike Christie7996a772006-04-06 21:13:41 -0500197
198 /* negotiated params */
Mike Christie857ae0b2007-05-30 12:57:15 -0500199 unsigned max_recv_dlength; /* initiator_max_recv_dsl*/
200 unsigned max_xmit_dlength; /* target_max_recv_dsl */
Mike Christie7996a772006-04-06 21:13:41 -0500201 int hdrdgst_en;
202 int datadgst_en;
Mike Christiea54a52c2006-06-28 12:00:23 -0500203 int ifmarker_en;
204 int ofmarker_en;
205 /* values userspace uses to id a conn */
206 int persistent_port;
207 char *persistent_address;
Mike Christie22236962007-05-30 12:57:24 -0500208 /* remote portal currently connected to */
209 int portal_port;
210 char portal_address[ISCSI_ADDRESS_BUF_LEN];
Mike Christie7996a772006-04-06 21:13:41 -0500211
212 /* MIB-statistics */
213 uint64_t txdata_octets;
214 uint64_t rxdata_octets;
215 uint32_t scsicmd_pdus_cnt;
216 uint32_t dataout_pdus_cnt;
217 uint32_t scsirsp_pdus_cnt;
218 uint32_t datain_pdus_cnt;
219 uint32_t r2t_pdus_cnt;
220 uint32_t tmfcmd_pdus_cnt;
221 int32_t tmfrsp_pdus_cnt;
222
223 /* custom statistics */
224 uint32_t eh_abort_cnt;
Eli Dorfman87528222008-04-29 13:46:52 -0700225 uint32_t fmr_unalign_cnt;
Mike Christie7996a772006-04-06 21:13:41 -0500226};
227
Olaf Kirch63203772007-12-13 12:43:25 -0600228struct iscsi_pool {
Mike Christie7996a772006-04-06 21:13:41 -0500229 struct kfifo *queue; /* FIFO Queue */
230 void **pool; /* Pool of elements */
231 int max; /* Max number of elements */
232};
233
Mike Christie6eabafb2008-01-31 13:36:43 -0600234/* Session's states */
235enum {
236 ISCSI_STATE_FREE = 1,
237 ISCSI_STATE_LOGGED_IN,
238 ISCSI_STATE_FAILED,
239 ISCSI_STATE_TERMINATE,
240 ISCSI_STATE_IN_RECOVERY,
241 ISCSI_STATE_RECOVERY_FAILED,
242 ISCSI_STATE_LOGGING_OUT,
243};
244
Mike Christie7996a772006-04-06 21:13:41 -0500245struct iscsi_session {
Mike Christie75613522008-05-21 15:53:59 -0500246 struct iscsi_cls_session *cls_session;
Mike Christie6724add2007-08-15 01:38:30 -0500247 /*
248 * Syncs up the scsi eh thread with the iscsi eh thread when sending
249 * task management functions. This must be taken before the session
250 * and recv lock.
251 */
252 struct mutex eh_mutex;
253
Mike Christie7996a772006-04-06 21:13:41 -0500254 /* iSCSI session-wide sequencing */
255 uint32_t cmdsn;
256 uint32_t exp_cmdsn;
257 uint32_t max_cmdsn;
258
Mike Christiee0726402007-07-26 12:46:48 -0500259 /* This tracks the reqs queued into the initiator */
260 uint32_t queued_cmdsn;
261
Mike Christie7996a772006-04-06 21:13:41 -0500262 /* configuration */
Mike Christief6d51802007-12-13 12:43:30 -0600263 int abort_timeout;
264 int lu_reset_timeout;
Mike Christie7996a772006-04-06 21:13:41 -0500265 int initial_r2t_en;
Mike Christie857ae0b2007-05-30 12:57:15 -0500266 unsigned max_r2t;
Mike Christie7996a772006-04-06 21:13:41 -0500267 int imm_data_en;
Mike Christie857ae0b2007-05-30 12:57:15 -0500268 unsigned first_burst;
269 unsigned max_burst;
Mike Christie7996a772006-04-06 21:13:41 -0500270 int time2wait;
271 int time2retain;
272 int pdu_inorder_en;
273 int dataseq_inorder_en;
274 int erl;
Mike Christie843c0a82007-12-13 12:43:20 -0600275 int fast_abort;
Mike Christiea54a52c2006-06-28 12:00:23 -0500276 int tpgt;
Mike Christieb2c64162007-05-30 12:57:16 -0500277 char *username;
278 char *username_in;
279 char *password;
280 char *password_in;
Mike Christiea54a52c2006-06-28 12:00:23 -0500281 char *targetname;
Mike Christie88dfd342008-05-21 15:54:16 -0500282 char *ifacename;
283 char *initiatorname;
Mike Christie7996a772006-04-06 21:13:41 -0500284 /* control data */
285 struct iscsi_transport *tt;
286 struct Scsi_Host *host;
287 struct iscsi_conn *leadconn; /* leading connection */
288 spinlock_t lock; /* protects session state, *
289 * sequence numbers, *
290 * session resources: *
291 * - cmdpool, *
292 * - mgmtpool, *
293 * - r2tpool */
294 int state; /* session state */
Mike Christie7996a772006-04-06 21:13:41 -0500295 int age; /* counts session re-opens */
296
Mike Christie3e5c28a2008-05-21 15:54:06 -0500297 int scsi_cmds_max; /* max scsi commands */
Mike Christie7996a772006-04-06 21:13:41 -0500298 int cmds_max; /* size of cmds array */
Mike Christie9c19a7d2008-05-21 15:54:09 -0500299 struct iscsi_task **cmds; /* Original Cmds arr */
Olaf Kirch63203772007-12-13 12:43:25 -0600300 struct iscsi_pool cmdpool; /* PDU's pool */
Mike Christie7996a772006-04-06 21:13:41 -0500301};
302
Mike Christiee5bd7b52008-09-24 11:46:10 -0500303enum {
304 ISCSI_HOST_SETUP,
305 ISCSI_HOST_REMOVED,
306};
307
Mike Christie75613522008-05-21 15:53:59 -0500308struct iscsi_host {
309 char *initiatorname;
310 /* hw address or netdev iscsi connection is bound to */
311 char *hwaddress;
312 char *netdev;
313 /* local address */
314 int local_port;
315 char local_address[ISCSI_ADDRESS_BUF_LEN];
Mike Christiee5bd7b52008-09-24 11:46:10 -0500316
317 wait_queue_head_t session_removal_wq;
318 /* protects sessions and state */
319 spinlock_t lock;
320 int num_sessions;
321 int state;
Mike Christie32ae7632009-03-05 14:46:03 -0600322
323 struct workqueue_struct *workq;
324 char workq_name[20];
Mike Christie75613522008-05-21 15:53:59 -0500325};
326
Mike Christie7996a772006-04-06 21:13:41 -0500327/*
328 * scsi host template
329 */
330extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth);
331extern int iscsi_eh_abort(struct scsi_cmnd *sc);
Mike Christie8e124522008-09-24 11:46:12 -0500332extern int iscsi_eh_target_reset(struct scsi_cmnd *sc);
Mike Christie843c0a82007-12-13 12:43:20 -0600333extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
Mike Christie7996a772006-04-06 21:13:41 -0500334extern int iscsi_queuecommand(struct scsi_cmnd *sc,
335 void (*done)(struct scsi_cmnd *));
336
Mike Christie0801c242007-05-30 12:57:12 -0500337/*
338 * iSCSI host helpers.
339 */
Mike Christie5d91e202008-05-21 15:54:01 -0500340#define iscsi_host_priv(_shost) \
341 (shost_priv(_shost) + sizeof(struct iscsi_host))
342
Mike Christie0801c242007-05-30 12:57:12 -0500343extern int iscsi_host_set_param(struct Scsi_Host *shost,
344 enum iscsi_host_param param, char *buf,
345 int buflen);
346extern int iscsi_host_get_param(struct Scsi_Host *shost,
347 enum iscsi_host_param param, char *buf);
Mike Christiea4804cd2008-05-21 15:54:00 -0500348extern int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev);
349extern struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
Mike Christie4d108352009-03-05 14:46:04 -0600350 int dd_data_size,
Mike Christie32ae7632009-03-05 14:46:03 -0600351 bool xmit_can_sleep);
Mike Christiea4804cd2008-05-21 15:54:00 -0500352extern void iscsi_host_remove(struct Scsi_Host *shost);
353extern void iscsi_host_free(struct Scsi_Host *shost);
Mike Christie6b5d6c42009-04-21 15:32:32 -0500354extern int iscsi_target_alloc(struct scsi_target *starget);
Mike Christie0801c242007-05-30 12:57:12 -0500355
Mike Christie7996a772006-04-06 21:13:41 -0500356/*
357 * session management
358 */
359extern struct iscsi_cls_session *
Mike Christie75613522008-05-21 15:53:59 -0500360iscsi_session_setup(struct iscsi_transport *, struct Scsi_Host *shost,
Mike Christie79706342008-05-21 15:54:12 -0500361 uint16_t, int, uint32_t, unsigned int);
Mike Christie7996a772006-04-06 21:13:41 -0500362extern void iscsi_session_teardown(struct iscsi_cls_session *);
Mike Christie7996a772006-04-06 21:13:41 -0500363extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *);
Mike Christiea54a52c2006-06-28 12:00:23 -0500364extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
365 enum iscsi_param param, char *buf, int buflen);
366extern int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
367 enum iscsi_param param, char *buf);
Mike Christie7996a772006-04-06 21:13:41 -0500368
Mike Christie322d7392008-01-31 13:36:52 -0600369#define iscsi_session_printk(prefix, _sess, fmt, a...) \
Mike Christie75613522008-05-21 15:53:59 -0500370 iscsi_cls_session_printk(prefix, _sess->cls_session, fmt, ##a)
Mike Christie322d7392008-01-31 13:36:52 -0600371
Mike Christie7996a772006-04-06 21:13:41 -0500372/*
373 * connection management
374 */
375extern struct iscsi_cls_conn *iscsi_conn_setup(struct iscsi_cls_session *,
Mike Christie5d91e202008-05-21 15:54:01 -0500376 int, uint32_t);
Mike Christie7996a772006-04-06 21:13:41 -0500377extern void iscsi_conn_teardown(struct iscsi_cls_conn *);
378extern int iscsi_conn_start(struct iscsi_cls_conn *);
379extern void iscsi_conn_stop(struct iscsi_cls_conn *, int);
380extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
381 int);
382extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err);
Mike Christie40a06e72009-03-05 14:46:05 -0600383extern void iscsi_session_failure(struct iscsi_session *session,
Mike Christiee5bd7b52008-09-24 11:46:10 -0500384 enum iscsi_err err);
Mike Christiea54a52c2006-06-28 12:00:23 -0500385extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
386 enum iscsi_param param, char *buf);
Mike Christie5af3e912008-05-21 15:54:02 -0500387extern void iscsi_suspend_tx(struct iscsi_conn *conn);
Mike Christie32ae7632009-03-05 14:46:03 -0600388extern void iscsi_conn_queue_work(struct iscsi_conn *conn);
Mike Christie7996a772006-04-06 21:13:41 -0500389
Mike Christie322d7392008-01-31 13:36:52 -0600390#define iscsi_conn_printk(prefix, _c, fmt, a...) \
Mike Christie5af3e912008-05-21 15:54:02 -0500391 iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \
392 fmt, ##a)
Mike Christie322d7392008-01-31 13:36:52 -0600393
Mike Christie7996a772006-04-06 21:13:41 -0500394/*
395 * pdu and task processing
396 */
Mike Christie77a23c22007-05-30 12:57:18 -0500397extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *);
Mike Christie577577d2008-12-02 00:32:05 -0600398extern void iscsi_prep_data_out_pdu(struct iscsi_task *task,
399 struct iscsi_r2t_info *r2t,
400 struct iscsi_data *hdr);
Mike Christie7996a772006-04-06 21:13:41 -0500401extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
402 char *, uint32_t);
403extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
404 char *, int);
Mike Christie913e5bf2008-05-21 15:54:18 -0500405extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
406 char *, int);
Mike Christie0af967f2008-05-21 15:54:04 -0500407extern int iscsi_verify_itt(struct iscsi_conn *, itt_t);
Mike Christie9c19a7d2008-05-21 15:54:09 -0500408extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
409extern void iscsi_requeue_task(struct iscsi_task *task);
410extern void iscsi_put_task(struct iscsi_task *task);
Mike Christie913e5bf2008-05-21 15:54:18 -0500411extern void __iscsi_get_task(struct iscsi_task *task);
Mike Christie7996a772006-04-06 21:13:41 -0500412
413/*
414 * generic helpers
415 */
Olaf Kirch63203772007-12-13 12:43:25 -0600416extern void iscsi_pool_free(struct iscsi_pool *);
417extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int);
Mike Christie7996a772006-04-06 21:13:41 -0500418
Boaz Harrosh004d6532007-12-13 12:43:23 -0600419/*
420 * inline functions to deal with padding.
421 */
422static inline unsigned int
423iscsi_padded(unsigned int len)
424{
425 return (len + ISCSI_PAD_LEN - 1) & ~(ISCSI_PAD_LEN - 1);
426}
427
428static inline unsigned int
429iscsi_padding(unsigned int len)
430{
431 len &= (ISCSI_PAD_LEN - 1);
432 if (len)
433 len = ISCSI_PAD_LEN - len;
434 return len;
435}
436
Mike Christie7996a772006-04-06 21:13:41 -0500437#endif