2 * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
3 * By downloading, copying, installing or using the software you agree
4 * to this license. If you do not agree to this license, do not
5 * download, install, copy or use the software.
7 * Intel License Agreement
9 * Copyright (c) 2000, Intel Corporation
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * -Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
19 * -Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
24 * -The name of Intel Corporation may not be used to endorse or
25 * promote products derived from this software without specific prior
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
35 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 #include "iscsiprotocol.h"
45 #include "parameters.h"
48 #define CONFIG_INITIATOR_NUM_TARGETS 16
54 #define CONFIG_INITIATOR_QUEUE_DEPTH CONFIG_INITIATOR_NUM_TARGETS
55 #define CONFIG_INITIATOR_MAX_SESSIONS CONFIG_INITIATOR_NUM_TARGETS
58 INITIATOR_SESSION_STATE_INITIALIZING
= 0x001,
59 INITIATOR_SESSION_STATE_INITIALIZED
= 0x002,
60 INITIATOR_SESSION_STATE_CONNECTING
= 0x004,
61 INITIATOR_SESSION_STATE_CONNECTED
= 0x008,
62 INITIATOR_SESSION_STATE_LOGGING_IN
= 0x010,
63 INITIATOR_SESSION_STATE_AUTHENTICATED
= 0x020,
64 INITIATOR_SESSION_STATE_LOGGED_IN_NORMAL
= 0x040,
65 INITIATOR_SESSION_STATE_LOGGED_IN_DISCOVERY
= 0x080,
66 INITIATOR_SESSION_STATE_LOGGING_OUT
= 0x100,
67 INITIATOR_SESSION_STATE_LOGGED_OUT
= 0x200,
68 INITIATOR_SESSION_STATE_DESTROYING
= 0x400
72 TARGET_HOSTNAME_SIZE
= 1024,
74 TARGET_NAME_SIZE
= 256
77 #define INITIATOR_STATE_SHUTDOWN 1
84 typedef struct initiator_session_t
{
89 iscsi_queue_t tx_queue
;
90 iscsi_worker_t tx_worker
;
91 iscsi_worker_t rx_worker
;
96 iscsi_parameter_t
*params
;
97 struct initiator_cmd_t
*cmds
;
98 iscsi_spin_t cmds_spin
;
99 iscsi_sess_param_t sess_params
;
100 } initiator_session_t
;
102 typedef struct initiator_cmd_t
{
105 int (*callback
) (void *);
110 struct initiator_cmd_t
*next
;
111 struct initiator_cmd_t
*hash_next
;
113 char targetname
[TARGET_HOSTNAME_SIZE
];
116 typedef struct initiator_target_t
{
117 char name
[TARGET_HOSTNAME_SIZE
];
118 char ip
[TARGET_IP_SIZE
];
120 char TargetName
[TARGET_NAME_SIZE
];
121 initiator_session_t
*sess
;
123 char iqnwanted
[TARGET_NAME_SIZE
];
124 } initiator_target_t
;
126 DEFINE_ARRAY(strv_t
, char *);
133 int initiator_command(initiator_cmd_t
*);
134 int initiator_enqueue(initiator_cmd_t
*);
135 int initiator_abort(initiator_cmd_t
*);
137 void get_target_info(uint64_t, initiator_target_t
*);
139 int ii_initiator_init(const char *, int, int, const char *, char *, int, int, int);
141 int iscsi_initiator_get_targets(int, strv_t
*);
142 int initiator_set_target_name(int, char *);
144 #endif /* _INITIATOR_H_ */