~ubuntu-branches/ubuntu/hardy/open-iscsi/hardy-updates

« back to all changes in this revision

Viewing changes to usr/initiator.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Zobel-Helas
  • Date: 2006-12-03 16:54:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061203165421-xhttz5j4l9sowg8u
Tags: 2.0.730-0.2
upload to unstable, as no new bugs arised.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "actor.h"
32
32
#include "queue.h"
33
33
 
34
 
#define CONFIG_FILE             "/etc/iscsid.conf"
 
34
#define ST_CONFIG_DIR           "/etc/iscsi/send_targets"
 
35
#define NODE_CONFIG_DIR         "/etc/iscsi/nodes"
 
36
#define CONFIG_FILE             "/etc/iscsi/iscsid.conf"
35
37
#define PID_FILE                "/var/run/iscsid.pid"
36
38
#define INITIATOR_NAME_FILE     "/etc/initiatorname.iscsi"
37
 
#ifndef DISCOVERY_FILE
38
 
#define DISCOVERY_FILE          "/var/db/iscsi/discovery"
39
 
#endif
40
 
#ifndef NODE_FILE
41
 
#define NODE_FILE               "/var/db/iscsi/node"
42
 
#endif
 
39
#define LOCK_DIR                "/var/lock/iscsi"
 
40
#define LOCK_FILE               "/var/lock/iscsi/lock"
 
41
#define LOCK_WRITE_FILE         "/var/lock/iscsi/lock.write"
43
42
 
44
43
#define DEF_ISCSI_PORT          3260
45
44
 
65
64
        LOGIN_REDIRECT                  = 9,
66
65
};
67
66
 
68
 
enum iscsi_rdma_ext {
69
 
        RDMA_EXT_NO                     = 0,
70
 
        RDMA_EXT_YES                    = 1,
71
 
        RDMA_EXT_NOT_NEGOTIATED         = 2,
72
 
};
73
 
 
74
67
typedef enum iscsi_conn_state_e {
75
68
        STATE_FREE                      = 0,
76
69
        STATE_XPT_WAIT                  = 1,
85
78
        R_STAGE_NO_CHANGE               = 0,
86
79
        R_STAGE_SESSION_CLEANUP         = 1,
87
80
        R_STAGE_SESSION_REOPEN          = 2,
 
81
        R_STAGE_SESSION_REDIRECT        = 3,
88
82
} iscsi_session_r_stage_e;
89
83
 
90
84
typedef enum iscsi_event_e {
123
117
struct iscsi_session;
124
118
struct iscsi_conn;
125
119
 
126
 
typedef void (*send_pdu_begin_f) (uint64_t transport_handle, uint64_t connh,
127
 
                                int hdr_size, int data_size);
128
 
typedef int (*send_pdu_end_f) (uint64_t transport_handle, uint64_t connh,
129
 
                             int *retcode);
130
 
typedef int (*recv_pdu_begin_f) (uint64_t transport_handle, uint64_t connh,
131
 
                                uintptr_t recv_handle, uintptr_t *pdu_handle,
132
 
                                int *pdu_size);
 
120
typedef void (*send_pdu_begin_f) (uint64_t transport_handle, uint32_t sid,
 
121
                                  uint32_t cid, int hdr_size, int data_size);
 
122
typedef int (*send_pdu_end_f) (uint64_t transport_handle, uint32_t sid,
 
123
                               uint32_t cid, int *retcode);
 
124
typedef int (*recv_pdu_begin_f) (uint64_t transport_handle, 
 
125
                                 uintptr_t recv_handle, uintptr_t *pdu_handle,
 
126
                                 int *pdu_size);
133
127
typedef int (*recv_pdu_end_f) (uint64_t transport_handle, uintptr_t conn_handle,
134
128
                             uintptr_t pdu_handle);
135
129
typedef void (*send_pdu_timer_add_f)(struct iscsi_conn *conn, int timeout);
138
132
/* daemon's connection structure */
139
133
typedef struct iscsi_conn {
140
134
        struct qelem item; /* must stay at the top */
141
 
        int id;
142
 
        uint64_t handle;
 
135
        uint32_t id;
143
136
        uintptr_t recv_handle;
144
137
        struct iscsi_session *session;
145
138
        iscsi_login_context_t login_context;
 
139
        struct queue_task *logout_qtask;
146
140
        char data[DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH];
 
141
        char host[NI_MAXHOST];  /* scratch */
147
142
        iscsi_conn_state_e state;
148
143
        actor_t connect_timer;
149
144
        actor_t send_pdu_timer;
 
145
        actor_t logout_timer;
150
146
 
151
147
        actor_t noop_out_timer;
152
148
        actor_t noop_out_timeout_timer;
172
168
 
173
169
        /* tcp/socket settings */
174
170
        int socket_fd;
 
171
        /* address being used for normal session connection */
175
172
        struct sockaddr_storage saddr;
 
173
        /* address recieved during login */
 
174
        struct sockaddr_storage failback_saddr;
176
175
        int tcp_window_size;
177
176
        int type_of_service;
178
177
 
 
178
        /* used for the IPC of bind and for connect/poll/disconnect by
 
179
         * transports (eg iser) which does these ops from the kernel.
 
180
         * In the case of TCP, it is just the transport_fd casted to u64. */
 
181
        uint64_t transport_ep_handle;
 
182
 
179
183
        /* timeouts */
180
184
        int login_timeout;
 
185
        int logout_timeout;
181
186
        int auth_timeout;
182
187
        int active_timeout;
183
188
        int idle_timeout;
222
227
        PROVIDER_STATUS_FAILED          = 2,
223
228
} iscsi_provider_status_e;
224
229
 
 
230
struct iscsi_uspace_transport;
 
231
 
225
232
/* represents data path provider */
226
233
typedef struct iscsi_provider_t {
 
234
        struct qelem list;
227
235
        uint64_t handle;
228
236
        uint32_t caps;
229
 
        unsigned short af;      
230
 
        unsigned short rdma;
231
237
        iscsi_provider_status_e status;
232
238
        char name[ISCSI_TRANSPORT_NAME_MAXLEN];
233
239
        struct qelem sessions;
 
240
        struct iscsi_uspace_transport *utransport;
234
241
} iscsi_provider_t;
235
242
 
236
243
/* daemon's session structure */
237
244
typedef struct iscsi_session {
238
245
        struct qelem item; /* must stay at the top */
239
246
        uint32_t id;
 
247
        uint32_t hostno;
 
248
        int refcount;
240
249
        uint64_t transport_handle;
241
 
        uint64_t handle;
242
250
        iscsi_provider_t *provider;
243
251
        node_rec_t nrec; /* copy of original Node record in database */
244
252
        unsigned int irrelevant_keys_bitmap;
254
262
        uint32_t max_burst;
255
263
        uint32_t pdu_inorder_en;
256
264
        uint32_t dataseq_inorder_en;
 
265
        uint32_t time2wait;
257
266
        uint32_t def_time2wait;
258
267
        uint32_t def_time2retain;
259
268
        int type;
289
298
        int reopen_cnt;
290
299
        queue_task_t reopen_qtask;
291
300
        iscsi_session_r_stage_e r_stage;
 
301
        uint32_t replacement_timeout;
292
302
 
293
303
        /* session's processing */
294
304
        actor_t mainloop;
295
305
        queue_t *queue;
 
306
        queue_t *splice_queue;
296
307
 
297
 
        enum iscsi_rdma_ext rdma_ext;
298
308
} iscsi_session_t;
299
309
 
300
 
/* iscsid.c */
301
 
extern iscsi_provider_t *provider;
302
 
extern int num_providers;
303
 
 
304
310
/* login.c */
305
311
 
306
312
#define ISCSI_SESSION_TYPE_NORMAL 0
341
347
#define IRRELEVANT_DATAPDUINORDER       0x40
342
348
#define IRRELEVANT_DATASEQUENCEINORDER  0x80
343
349
 
 
350
 
 
351
/*
 
352
 * These user/kernel IPC calls are used by transports (eg iSER) that have their
 
353
 * native connection managed from the kernel. The IPC for having the user space
 
354
 * code being able to do it, is implemented as an enhancement of the open iscsi
 
355
 * netlink IPC scheme, currently with the ability to connect/poll-for-establish
 
356
 * ment/disconnect an opaque transport dependent 64 bit ep (endpoint) handle.
 
357
 * The exact IPC ABI for that matter is defined in iscsi_if.h
 
358
 */
 
359
/* netlink.c */
 
360
extern int ktransport_ep_connect(iscsi_conn_t *conn, int non_blocking);
 
361
extern int ktransport_ep_poll(iscsi_conn_t *conn, int timeout_ms);
 
362
extern void ktransport_ep_disconnect(iscsi_conn_t *conn);
 
363
 
344
364
/* io.c */
345
 
extern int iscsi_io_tcp_poll(iscsi_conn_t *conn);
 
365
extern int iscsi_io_tcp_poll(iscsi_conn_t *conn, int timeout_ms);
346
366
extern int iscsi_io_tcp_connect(iscsi_conn_t *conn, int non_blocking);
 
367
extern void iscsi_io_tcp_disconnect(iscsi_conn_t *conn);
 
368
 
347
369
extern int iscsi_io_connect(iscsi_conn_t *conn);
348
370
extern void iscsi_io_disconnect(iscsi_conn_t *conn);
349
371
extern int iscsi_io_send_pdu(iscsi_conn_t *conn, struct iscsi_hdr *hdr,
355
377
/* initiator.c */
356
378
extern int session_login_task(node_rec_t *rec, queue_task_t *qtask);
357
379
extern int session_logout_task(iscsi_session_t *session, queue_task_t *qtask);
358
 
extern iscsi_session_t* session_find_by_rec(node_rec_t *rec);
 
380
extern iscsi_session_t *session_find_by_rec(node_rec_t *rec);
 
381
extern int session_is_running(node_rec_t *rec);
359
382
extern void* recvpool_get(iscsi_conn_t *conn, int ev_size);
360
383
extern void recvpool_put(iscsi_conn_t *conn, void *handle);
 
384
extern mgmt_ipc_err_e iscsi_sync_session(node_rec_t *rec, queue_task_t
 
385
                                         *tsk, uint32_t sid);
361
386
 
362
387
#endif /* INITIATOR_H */