Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
iscsi_if.h
Go to the documentation of this file.
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 [email protected]
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 #include <linux/in.h>
26 #include <linux/in6.h>
27 
28 #define ISCSI_NL_GRP_ISCSID 1
29 #define ISCSI_NL_GRP_UIP 2
30 
31 #define UEVENT_BASE 10
32 #define KEVENT_BASE 100
33 #define ISCSI_ERR_BASE 1000
34 
37 
38  /* down events */
50 
54 
60 
66 
67  /* up events */
74 
80 };
81 
86 };
87 
91  /* must always be last */
93 };
94 
95 struct iscsi_uevent {
96  uint32_t type; /* k/u events type */
97  uint32_t iferror; /* carries interface or resource errors */
99 
100  union {
101  /* messages u -> k */
102  struct msg_create_session {
106  } c_session;
107  struct msg_create_bound_session {
112  } c_bound_session;
113  struct msg_destroy_session {
115  } d_session;
116  struct msg_create_conn {
117  uint32_t sid;
119  } c_conn;
120  struct msg_bind_conn {
121  uint32_t sid;
122  uint32_t cid;
125  } b_conn;
126  struct msg_destroy_conn {
127  uint32_t sid;
128  uint32_t cid;
129  } d_conn;
130  struct msg_send_pdu {
131  uint32_t sid;
132  uint32_t cid;
135  } send_pdu;
136  struct msg_set_param {
137  uint32_t sid;
138  uint32_t cid;
139  uint32_t param; /* enum iscsi_param */
141  } set_param;
142  struct msg_start_conn {
143  uint32_t sid;
144  uint32_t cid;
145  } start_conn;
146  struct msg_stop_conn {
147  uint32_t sid;
148  uint32_t cid;
151  } stop_conn;
152  struct msg_get_stats {
153  uint32_t sid;
154  uint32_t cid;
155  } get_stats;
156  struct msg_transport_connect {
158  } ep_connect;
159  struct msg_transport_connect_through_host {
163  struct msg_transport_poll {
166  } ep_poll;
167  struct msg_transport_disconnect {
169  } ep_disconnect;
170  struct msg_tgt_dscvr {
173  /*
174  * enable = 1 to establish a new connection
175  * with the server. enable = 0 to disconnect
176  * from the server. Used primarily to switch
177  * from one iSNS server to another.
178  */
180  } tgt_dscvr;
181  struct msg_set_host_param {
183  uint32_t param; /* enum iscsi_host_param */
184  uint32_t len;
185  } set_host_param;
186  struct msg_set_path {
188  } set_path;
189  struct msg_set_iface_params {
193  struct msg_iscsi_ping {
198  uint32_t pid; /* unique ping id associated
199  with each ping request */
200  } iscsi_ping;
201  struct msg_get_chap {
203  uint32_t num_entries; /* number of CHAP entries
204  * on request, number of
205  * valid CHAP entries on
206  * response */
208  } get_chap;
209  struct msg_delete_chap {
212  } delete_chap;
213  } u;
214  union {
215  /* messages k -> u */
216  int retcode;
217  struct msg_create_session_ret {
218  uint32_t sid;
220  } c_session_ret;
221  struct msg_create_conn_ret {
222  uint32_t sid;
223  uint32_t cid;
224  } c_conn_ret;
225  struct msg_unbind_session {
226  uint32_t sid;
228  } unbind_session;
229  struct msg_recv_req {
230  uint32_t sid;
231  uint32_t cid;
233  } recv_req;
234  struct msg_conn_login {
235  uint32_t sid;
236  uint32_t cid;
237  uint32_t state; /* enum iscsi_conn_state */
238  } conn_login;
239  struct msg_conn_error {
240  uint32_t sid;
241  uint32_t cid;
242  uint32_t error; /* enum iscsi_err */
243  } connerror;
244  struct msg_session_destroyed {
246  uint32_t sid;
247  } d_session;
248  struct msg_transport_connect_ret {
250  } ep_connect_ret;
251  struct msg_req_path {
253  } req_path;
254  struct msg_notify_if_down {
256  } notify_if_down;
257  struct msg_host_event {
261  } host_event;
262  struct msg_ping_comp {
264  uint32_t status; /* enum
265  * iscsi_ping_status_code */
266  uint32_t pid; /* unique ping id associated
267  with each ping request */
269  } ping_comp;
270  } r;
271 } __attribute__ ((aligned (sizeof(uint64_t))));
274  ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */
275  ISCSI_HOST_PARAM, /* iscsi_host_param */
276  ISCSI_NET_PARAM, /* iscsi_net_param */
277 };
278 
280  uint32_t iface_num; /* iface number, 0 - n */
281  uint32_t len; /* Actual length of the param */
282  uint16_t param; /* iscsi param value */
283  uint8_t iface_type; /* IPv4 or IPv6 */
284  uint8_t param_type; /* iscsi_param_type */
285  uint8_t value[0]; /* length sized value follows */
286 } __packed;
287 
288 /*
289  * To keep the struct iscsi_uevent size the same for userspace code
290  * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
291  * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
292  * struct iscsi_uevent in the NETLINK_ISCSI message.
293  */
294 struct iscsi_path {
298  uint32_t ip_addr_len; /* 4 or 16 */
299  union {
300  struct in_addr v4_addr;
302  } src;
303  union {
304  struct in_addr v4_addr;
305  struct in6_addr v6_addr;
306  } dst;
311 /* iscsi iface enabled/disabled setting */
312 #define ISCSI_IFACE_DISABLE 0x01
313 #define ISCSI_IFACE_ENABLE 0x02
314 
315 /* ipv4 bootproto */
316 #define ISCSI_BOOTPROTO_STATIC 0x01
317 #define ISCSI_BOOTPROTO_DHCP 0x02
318 
319 /* ipv6 addr autoconfig type */
320 #define ISCSI_IPV6_AUTOCFG_DISABLE 0x01
321 #define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02
322 #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03
324 /* ipv6 link local addr type */
325 #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01
326 #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02
327 
328 /* ipv6 router addr type */
329 #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01
330 #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02
331 
332 #define ISCSI_IFACE_TYPE_IPV4 0x01
333 #define ISCSI_IFACE_TYPE_IPV6 0x02
334 
335 #define ISCSI_MAX_VLAN_ID 4095
336 #define ISCSI_MAX_VLAN_PRIORITY 7
337 
338 /* iscsi vlan enable/disabled setting */
339 #define ISCSI_VLAN_DISABLE 0x01
340 #define ISCSI_VLAN_ENABLE 0x02
342 /* iSCSI network params */
364 };
365 
374 };
375 
376 /*
377  * Common error codes
378  */
379 enum iscsi_err {
380  ISCSI_OK = 0,
381 
403 };
404 
405 /*
406  * iSCSI Parameters (RFC3720)
407  */
409  /* passed in using netlink set param */
430 
431  /* passed in through bind conn using transport_fd */
434 
439 
444 
447 
451 
454 
457  /* must always be last */
459 };
460 
461 /* iSCSI HBA params */
470 };
471 
472 /* iSCSI port Speed */
479 };
480 
481 /* iSCSI port state */
485 };
486 
487 /* iSCSI PING status/error code */
499 };
500 
501 #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
502 #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
503 
504 /*
505  * These flags presents iSCSI Data-Path capabilities.
506  */
507 #define CAP_RECOVERY_L0 0x1
508 #define CAP_RECOVERY_L1 0x2
509 #define CAP_RECOVERY_L2 0x4
510 #define CAP_MULTI_R2T 0x8
511 #define CAP_HDRDGST 0x10
512 #define CAP_DATADGST 0x20
513 #define CAP_MULTI_CONN 0x40
514 #define CAP_TEXT_NEGO 0x80
515 #define CAP_MARKERS 0x100
516 #define CAP_FW_DB 0x200
517 #define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
518 #define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
519 #define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
520 #define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
521  and verification */
522 #define CAP_LOGIN_OFFLOAD 0x4000 /* offload session login */
523 
524 /*
525  * These flags describes reason of stop_conn() call
526  */
527 #define STOP_CONN_TERM 0x1
528 #define STOP_CONN_SUSPEND 0x2
529 #define STOP_CONN_RECOVER 0x3
531 #define ISCSI_STATS_CUSTOM_MAX 32
532 #define ISCSI_STATS_CUSTOM_DESC_MAX 64
535  uint64_t value;
536 };
537 
538 /*
539  * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
540  *
541  * Note: this structure contains counters collected on per-connection basis.
542  */
543 struct iscsi_stats {
544  /* octets */
547 
548  /* xmit pdus */
557 
558  /* recv pdus */
568 
569  /* errors */
572 
573  /*
574  * iSCSI Custom Statistics support, i.e. Transport could
575  * extend existing MIB statistics with its own specific statistics
576  * up to ISCSI_STATS_CUSTOM_MAX
577  */
579  struct iscsi_stats_custom custom[0]
581 };
585  CHAP_TYPE_IN,
586 };
588 #define ISCSI_CHAP_AUTH_NAME_MAX_LEN 256
589 #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256
596 };
597 
598 #endif