[SCSI] iscsi_transport: Check iscsi interface skb allocation return value
[deliverable/linux.git] / include / scsi / iscsi_if.h
CommitLineData
39e84790
AA
1/*
2 * iSCSI User/Kernel Shares (Defines, Constants, Protocol definitions, etc)
3 *
4 * Copyright (C) 2005 Dmitry Yusupov
5 * Copyright (C) 2005 Alex Aizman
6 * maintained by open-iscsi@googlegroups.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * See the file COPYING included with this distribution for more details.
19 */
20
21#ifndef ISCSI_IF_H
22#define ISCSI_IF_H
23
24#include <scsi/iscsi_proto.h>
25
26#define UEVENT_BASE 10
27#define KEVENT_BASE 100
28#define ISCSI_ERR_BASE 1000
29
30enum iscsi_uevent_e {
31 ISCSI_UEVENT_UNKNOWN = 0,
32
33 /* down events */
34 ISCSI_UEVENT_CREATE_SESSION = UEVENT_BASE + 1,
35 ISCSI_UEVENT_DESTROY_SESSION = UEVENT_BASE + 2,
36 ISCSI_UEVENT_CREATE_CONN = UEVENT_BASE + 3,
37 ISCSI_UEVENT_DESTROY_CONN = UEVENT_BASE + 4,
38 ISCSI_UEVENT_BIND_CONN = UEVENT_BASE + 5,
39 ISCSI_UEVENT_SET_PARAM = UEVENT_BASE + 6,
40 ISCSI_UEVENT_START_CONN = UEVENT_BASE + 7,
41 ISCSI_UEVENT_STOP_CONN = UEVENT_BASE + 8,
42 ISCSI_UEVENT_SEND_PDU = UEVENT_BASE + 9,
43 ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10,
44 ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11,
45
264faaaa
OG
46 ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12,
47 ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13,
48 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
49
01cb225d
MC
50 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
51
39e84790
AA
52 /* up events */
53 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
54 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
55 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
53cb8a1f 56 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
39e84790
AA
57};
58
01cb225d
MC
59enum iscsi_tgt_dscvr {
60 ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
61 ISCSI_TGT_DSCVR_ISNS = 2,
62 ISCSI_TGT_DSCVR_SLP = 3,
63};
64
39e84790
AA
65struct iscsi_uevent {
66 uint32_t type; /* k/u events type */
67 uint32_t iferror; /* carries interface or resource errors */
68 uint64_t transport_handle;
69
70 union {
71 /* messages u -> k */
72 struct msg_create_session {
73 uint32_t initial_cmdsn;
74 } c_session;
75 struct msg_destroy_session {
39e84790
AA
76 uint32_t sid;
77 } d_session;
78 struct msg_create_conn {
39e84790 79 uint32_t sid;
b5c7a12d 80 uint32_t cid;
39e84790
AA
81 } c_conn;
82 struct msg_bind_conn {
b5c7a12d
MC
83 uint32_t sid;
84 uint32_t cid;
264faaaa 85 uint64_t transport_eph;
39e84790
AA
86 uint32_t is_leading;
87 } b_conn;
88 struct msg_destroy_conn {
b5c7a12d 89 uint32_t sid;
39e84790
AA
90 uint32_t cid;
91 } d_conn;
92 struct msg_send_pdu {
b5c7a12d
MC
93 uint32_t sid;
94 uint32_t cid;
39e84790
AA
95 uint32_t hdr_size;
96 uint32_t data_size;
39e84790
AA
97 } send_pdu;
98 struct msg_set_param {
b5c7a12d
MC
99 uint32_t sid;
100 uint32_t cid;
39e84790 101 uint32_t param; /* enum iscsi_param */
fd7255f5 102 uint32_t len;
39e84790
AA
103 } set_param;
104 struct msg_start_conn {
b5c7a12d
MC
105 uint32_t sid;
106 uint32_t cid;
39e84790
AA
107 } start_conn;
108 struct msg_stop_conn {
b5c7a12d
MC
109 uint32_t sid;
110 uint32_t cid;
39e84790
AA
111 uint64_t conn_handle;
112 uint32_t flag;
113 } stop_conn;
114 struct msg_get_stats {
b5c7a12d
MC
115 uint32_t sid;
116 uint32_t cid;
39e84790 117 } get_stats;
264faaaa
OG
118 struct msg_transport_connect {
119 uint32_t non_blocking;
120 } ep_connect;
121 struct msg_transport_poll {
122 uint64_t ep_handle;
123 uint32_t timeout_ms;
124 } ep_poll;
125 struct msg_transport_disconnect {
126 uint64_t ep_handle;
127 } ep_disconnect;
01cb225d
MC
128 struct msg_tgt_dscvr {
129 enum iscsi_tgt_dscvr type;
130 uint32_t host_no;
131 /*
132 * enable = 1 to establish a new connection
133 * with the server. enable = 0 to disconnect
134 * from the server. Used primarily to switch
135 * from one iSNS server to another.
136 */
137 uint32_t enable;
138 } tgt_dscvr;
39e84790
AA
139 } u;
140 union {
141 /* messages k -> u */
39e84790
AA
142 int retcode;
143 struct msg_create_session_ret {
39e84790 144 uint32_t sid;
b5c7a12d 145 uint32_t host_no;
39e84790 146 } c_session_ret;
b5c7a12d
MC
147 struct msg_create_conn_ret {
148 uint32_t sid;
149 uint32_t cid;
150 } c_conn_ret;
39e84790 151 struct msg_recv_req {
b5c7a12d
MC
152 uint32_t sid;
153 uint32_t cid;
39e84790 154 uint64_t recv_handle;
39e84790
AA
155 } recv_req;
156 struct msg_conn_error {
b5c7a12d
MC
157 uint32_t sid;
158 uint32_t cid;
39e84790
AA
159 uint32_t error; /* enum iscsi_err */
160 } connerror;
53cb8a1f
MC
161 struct msg_session_destroyed {
162 uint32_t host_no;
163 uint32_t sid;
164 } d_session;
264faaaa
OG
165 struct msg_transport_connect_ret {
166 uint64_t handle;
167 } ep_connect_ret;
39e84790
AA
168 } r;
169} __attribute__ ((aligned (sizeof(uint64_t))));
170
171/*
172 * Common error codes
173 */
174enum iscsi_err {
175 ISCSI_OK = 0,
176
177 ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
178 ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
179 ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
180 ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
181 ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
182 ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
183 ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
184 ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
185 ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
186 ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
187 ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
188 ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
189 ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
190 ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
191 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
7996a778
MC
192 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
193 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
39e84790
AA
194};
195
196/*
197 * iSCSI Parameters (RFC3720)
198 */
199enum iscsi_param {
fd7255f5
MC
200 /* passed in using netlink set param */
201 ISCSI_PARAM_MAX_RECV_DLENGTH,
202 ISCSI_PARAM_MAX_XMIT_DLENGTH,
203 ISCSI_PARAM_HDRDGST_EN,
204 ISCSI_PARAM_DATADGST_EN,
205 ISCSI_PARAM_INITIAL_R2T_EN,
206 ISCSI_PARAM_MAX_R2T,
207 ISCSI_PARAM_IMM_DATA_EN,
208 ISCSI_PARAM_FIRST_BURST,
209 ISCSI_PARAM_MAX_BURST,
210 ISCSI_PARAM_PDU_INORDER_EN,
211 ISCSI_PARAM_DATASEQ_INORDER_EN,
212 ISCSI_PARAM_ERL,
213 ISCSI_PARAM_IFMARKER_EN,
214 ISCSI_PARAM_OFMARKER_EN,
8d2860b3 215 ISCSI_PARAM_EXP_STATSN,
fd7255f5
MC
216 ISCSI_PARAM_TARGET_NAME,
217 ISCSI_PARAM_TPGT,
218 ISCSI_PARAM_PERSISTENT_ADDRESS,
219 ISCSI_PARAM_PERSISTENT_PORT,
30a6c652 220 ISCSI_PARAM_SESS_RECOVERY_TMO,
fd7255f5
MC
221
222 /* pased in through bind conn using transport_fd */
223 ISCSI_PARAM_CONN_PORT,
224 ISCSI_PARAM_CONN_ADDRESS,
225
226 /* must always be last */
227 ISCSI_PARAM_MAX,
39e84790 228};
fd7255f5
MC
229
230#define ISCSI_MAX_RECV_DLENGTH (1 << ISCSI_PARAM_MAX_RECV_DLENGTH)
231#define ISCSI_MAX_XMIT_DLENGTH (1 << ISCSI_PARAM_MAX_XMIT_DLENGTH)
232#define ISCSI_HDRDGST_EN (1 << ISCSI_PARAM_HDRDGST_EN)
233#define ISCSI_DATADGST_EN (1 << ISCSI_PARAM_DATADGST_EN)
234#define ISCSI_INITIAL_R2T_EN (1 << ISCSI_PARAM_INITIAL_R2T_EN)
235#define ISCSI_MAX_R2T (1 << ISCSI_PARAM_MAX_R2T)
236#define ISCSI_IMM_DATA_EN (1 << ISCSI_PARAM_IMM_DATA_EN)
237#define ISCSI_FIRST_BURST (1 << ISCSI_PARAM_FIRST_BURST)
238#define ISCSI_MAX_BURST (1 << ISCSI_PARAM_MAX_BURST)
239#define ISCSI_PDU_INORDER_EN (1 << ISCSI_PARAM_PDU_INORDER_EN)
240#define ISCSI_DATASEQ_INORDER_EN (1 << ISCSI_PARAM_DATASEQ_INORDER_EN)
241#define ISCSI_ERL (1 << ISCSI_PARAM_ERL)
242#define ISCSI_IFMARKER_EN (1 << ISCSI_PARAM_IFMARKER_EN)
243#define ISCSI_OFMARKER_EN (1 << ISCSI_PARAM_OFMARKER_EN)
8d2860b3 244#define ISCSI_EXP_STATSN (1 << ISCSI_PARAM_EXP_STATSN)
fd7255f5
MC
245#define ISCSI_TARGET_NAME (1 << ISCSI_PARAM_TARGET_NAME)
246#define ISCSI_TPGT (1 << ISCSI_PARAM_TPGT)
247#define ISCSI_PERSISTENT_ADDRESS (1 << ISCSI_PARAM_PERSISTENT_ADDRESS)
248#define ISCSI_PERSISTENT_PORT (1 << ISCSI_PARAM_PERSISTENT_PORT)
30a6c652 249#define ISCSI_SESS_RECOVERY_TMO (1 << ISCSI_PARAM_SESS_RECOVERY_TMO)
fd7255f5
MC
250#define ISCSI_CONN_PORT (1 << ISCSI_PARAM_CONN_PORT)
251#define ISCSI_CONN_ADDRESS (1 << ISCSI_PARAM_CONN_ADDRESS)
39e84790 252
39e84790
AA
253#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
254#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
7b8631b5
MC
255#define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))
256
257/**
258 * iscsi_hostdata - get LLD hostdata from scsi_host
259 * @_hostdata: pointer to scsi host's hostdata
260 **/
39e84790
AA
261#define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long))
262
263/*
264 * These flags presents iSCSI Data-Path capabilities.
265 */
266#define CAP_RECOVERY_L0 0x1
267#define CAP_RECOVERY_L1 0x2
268#define CAP_RECOVERY_L2 0x4
269#define CAP_MULTI_R2T 0x8
270#define CAP_HDRDGST 0x10
271#define CAP_DATADGST 0x20
272#define CAP_MULTI_CONN 0x40
273#define CAP_TEXT_NEGO 0x80
274#define CAP_MARKERS 0x100
275
276/*
277 * These flags describes reason of stop_conn() call
278 */
279#define STOP_CONN_TERM 0x1
280#define STOP_CONN_SUSPEND 0x2
281#define STOP_CONN_RECOVER 0x3
282
283#define ISCSI_STATS_CUSTOM_MAX 32
284#define ISCSI_STATS_CUSTOM_DESC_MAX 64
285struct iscsi_stats_custom {
286 char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
287 uint64_t value;
288};
289
290/*
291 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
292 *
293 * Note: this structure contains counters collected on per-connection basis.
294 */
295struct iscsi_stats {
296 /* octets */
297 uint64_t txdata_octets;
298 uint64_t rxdata_octets;
299
300 /* xmit pdus */
301 uint32_t noptx_pdus;
302 uint32_t scsicmd_pdus;
303 uint32_t tmfcmd_pdus;
304 uint32_t login_pdus;
305 uint32_t text_pdus;
306 uint32_t dataout_pdus;
307 uint32_t logout_pdus;
308 uint32_t snack_pdus;
309
310 /* recv pdus */
311 uint32_t noprx_pdus;
312 uint32_t scsirsp_pdus;
313 uint32_t tmfrsp_pdus;
314 uint32_t textrsp_pdus;
315 uint32_t datain_pdus;
316 uint32_t logoutrsp_pdus;
317 uint32_t r2t_pdus;
318 uint32_t async_pdus;
319 uint32_t rjt_pdus;
320
321 /* errors */
322 uint32_t digest_err;
323 uint32_t timeout_err;
324
325 /*
326 * iSCSI Custom Statistics support, i.e. Transport could
327 * extend existing MIB statistics with its own specific statistics
328 * up to ISCSI_STATS_CUSTOM_MAX
329 */
330 uint32_t custom_length;
331 struct iscsi_stats_custom custom[0]
332 __attribute__ ((aligned (sizeof(uint64_t))));
333};
334
335#endif
This page took 0.162109 seconds and 5 git commands to generate.