ppp: mppe: Revert "ppp: mppe: Add softdep to arc4"
[linux-2.6-microblaze.git] / include / scsi / iscsi_if.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * iSCSI User/Kernel Shares (Defines, Constants, Protocol definitions, etc)
4  *
5  * Copyright (C) 2005 Dmitry Yusupov
6  * Copyright (C) 2005 Alex Aizman
7  * maintained by open-iscsi@googlegroups.com
8  *
9  * See the file COPYING included with this distribution for more details.
10  */
11
12 #ifndef ISCSI_IF_H
13 #define ISCSI_IF_H
14
15 #include <scsi/iscsi_proto.h>
16 #include <linux/in.h>
17 #include <linux/in6.h>
18
19 #define ISCSI_NL_GRP_ISCSID     1
20 #define ISCSI_NL_GRP_UIP        2
21
22 #define UEVENT_BASE                     10
23 #define KEVENT_BASE                     100
24 #define ISCSI_ERR_BASE                  1000
25
26 enum iscsi_uevent_e {
27         ISCSI_UEVENT_UNKNOWN            = 0,
28
29         /* down events */
30         ISCSI_UEVENT_CREATE_SESSION     = UEVENT_BASE + 1,
31         ISCSI_UEVENT_DESTROY_SESSION    = UEVENT_BASE + 2,
32         ISCSI_UEVENT_CREATE_CONN        = UEVENT_BASE + 3,
33         ISCSI_UEVENT_DESTROY_CONN       = UEVENT_BASE + 4,
34         ISCSI_UEVENT_BIND_CONN          = UEVENT_BASE + 5,
35         ISCSI_UEVENT_SET_PARAM          = UEVENT_BASE + 6,
36         ISCSI_UEVENT_START_CONN         = UEVENT_BASE + 7,
37         ISCSI_UEVENT_STOP_CONN          = UEVENT_BASE + 8,
38         ISCSI_UEVENT_SEND_PDU           = UEVENT_BASE + 9,
39         ISCSI_UEVENT_GET_STATS          = UEVENT_BASE + 10,
40         ISCSI_UEVENT_GET_PARAM          = UEVENT_BASE + 11,
41
42         ISCSI_UEVENT_TRANSPORT_EP_CONNECT       = UEVENT_BASE + 12,
43         ISCSI_UEVENT_TRANSPORT_EP_POLL          = UEVENT_BASE + 13,
44         ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT    = UEVENT_BASE + 14,
45
46         ISCSI_UEVENT_TGT_DSCVR          = UEVENT_BASE + 15,
47         ISCSI_UEVENT_SET_HOST_PARAM     = UEVENT_BASE + 16,
48         ISCSI_UEVENT_UNBIND_SESSION     = UEVENT_BASE + 17,
49         ISCSI_UEVENT_CREATE_BOUND_SESSION               = UEVENT_BASE + 18,
50         ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST  = UEVENT_BASE + 19,
51
52         ISCSI_UEVENT_PATH_UPDATE        = UEVENT_BASE + 20,
53         ISCSI_UEVENT_SET_IFACE_PARAMS   = UEVENT_BASE + 21,
54         ISCSI_UEVENT_PING               = UEVENT_BASE + 22,
55         ISCSI_UEVENT_GET_CHAP           = UEVENT_BASE + 23,
56         ISCSI_UEVENT_DELETE_CHAP        = UEVENT_BASE + 24,
57         ISCSI_UEVENT_SET_FLASHNODE_PARAMS       = UEVENT_BASE + 25,
58         ISCSI_UEVENT_NEW_FLASHNODE      = UEVENT_BASE + 26,
59         ISCSI_UEVENT_DEL_FLASHNODE      = UEVENT_BASE + 27,
60         ISCSI_UEVENT_LOGIN_FLASHNODE    = UEVENT_BASE + 28,
61         ISCSI_UEVENT_LOGOUT_FLASHNODE   = UEVENT_BASE + 29,
62         ISCSI_UEVENT_LOGOUT_FLASHNODE_SID       = UEVENT_BASE + 30,
63         ISCSI_UEVENT_SET_CHAP           = UEVENT_BASE + 31,
64         ISCSI_UEVENT_GET_HOST_STATS     = UEVENT_BASE + 32,
65
66         /* up events */
67         ISCSI_KEVENT_RECV_PDU           = KEVENT_BASE + 1,
68         ISCSI_KEVENT_CONN_ERROR         = KEVENT_BASE + 2,
69         ISCSI_KEVENT_IF_ERROR           = KEVENT_BASE + 3,
70         ISCSI_KEVENT_DESTROY_SESSION    = KEVENT_BASE + 4,
71         ISCSI_KEVENT_UNBIND_SESSION     = KEVENT_BASE + 5,
72         ISCSI_KEVENT_CREATE_SESSION     = KEVENT_BASE + 6,
73
74         ISCSI_KEVENT_PATH_REQ           = KEVENT_BASE + 7,
75         ISCSI_KEVENT_IF_DOWN            = KEVENT_BASE + 8,
76         ISCSI_KEVENT_CONN_LOGIN_STATE   = KEVENT_BASE + 9,
77         ISCSI_KEVENT_HOST_EVENT         = KEVENT_BASE + 10,
78         ISCSI_KEVENT_PING_COMP          = KEVENT_BASE + 11,
79 };
80
81 enum iscsi_tgt_dscvr {
82         ISCSI_TGT_DSCVR_SEND_TARGETS    = 1,
83         ISCSI_TGT_DSCVR_ISNS            = 2,
84         ISCSI_TGT_DSCVR_SLP             = 3,
85 };
86
87 enum iscsi_host_event_code {
88         ISCSI_EVENT_LINKUP              = 1,
89         ISCSI_EVENT_LINKDOWN,
90         /* must always be last */
91         ISCSI_EVENT_MAX,
92 };
93
94 struct iscsi_uevent {
95         uint32_t type; /* k/u events type */
96         uint32_t iferror; /* carries interface or resource errors */
97         uint64_t transport_handle;
98
99         union {
100                 /* messages u -> k */
101                 struct msg_create_session {
102                         uint32_t        initial_cmdsn;
103                         uint16_t        cmds_max;
104                         uint16_t        queue_depth;
105                 } c_session;
106                 struct msg_create_bound_session {
107                         uint64_t        ep_handle;
108                         uint32_t        initial_cmdsn;
109                         uint16_t        cmds_max;
110                         uint16_t        queue_depth;
111                 } c_bound_session;
112                 struct msg_destroy_session {
113                         uint32_t        sid;
114                 } d_session;
115                 struct msg_create_conn {
116                         uint32_t        sid;
117                         uint32_t        cid;
118                 } c_conn;
119                 struct msg_bind_conn {
120                         uint32_t        sid;
121                         uint32_t        cid;
122                         uint64_t        transport_eph;
123                         uint32_t        is_leading;
124                 } b_conn;
125                 struct msg_destroy_conn {
126                         uint32_t        sid;
127                         uint32_t        cid;
128                 } d_conn;
129                 struct msg_send_pdu {
130                         uint32_t        sid;
131                         uint32_t        cid;
132                         uint32_t        hdr_size;
133                         uint32_t        data_size;
134                 } send_pdu;
135                 struct msg_set_param {
136                         uint32_t        sid;
137                         uint32_t        cid;
138                         uint32_t        param; /* enum iscsi_param */
139                         uint32_t        len;
140                 } set_param;
141                 struct msg_start_conn {
142                         uint32_t        sid;
143                         uint32_t        cid;
144                 } start_conn;
145                 struct msg_stop_conn {
146                         uint32_t        sid;
147                         uint32_t        cid;
148                         uint64_t        conn_handle;
149                         uint32_t        flag;
150                 } stop_conn;
151                 struct msg_get_stats {
152                         uint32_t        sid;
153                         uint32_t        cid;
154                 } get_stats;
155                 struct msg_transport_connect {
156                         uint32_t        non_blocking;
157                 } ep_connect;
158                 struct msg_transport_connect_through_host {
159                         uint32_t        host_no;
160                         uint32_t        non_blocking;
161                 } ep_connect_through_host;
162                 struct msg_transport_poll {
163                         uint64_t        ep_handle;
164                         uint32_t        timeout_ms;
165                 } ep_poll;
166                 struct msg_transport_disconnect {
167                         uint64_t        ep_handle;
168                 } ep_disconnect;
169                 struct msg_tgt_dscvr {
170                         enum iscsi_tgt_dscvr    type;
171                         uint32_t        host_no;
172                         /*
173                          * enable = 1 to establish a new connection
174                          * with the server. enable = 0 to disconnect
175                          * from the server. Used primarily to switch
176                          * from one iSNS server to another.
177                          */
178                         uint32_t        enable;
179                 } tgt_dscvr;
180                 struct msg_set_host_param {
181                         uint32_t        host_no;
182                         uint32_t        param; /* enum iscsi_host_param */
183                         uint32_t        len;
184                 } set_host_param;
185                 struct msg_set_path {
186                         uint32_t        host_no;
187                 } set_path;
188                 struct msg_set_iface_params {
189                         uint32_t        host_no;
190                         uint32_t        count;
191                 } set_iface_params;
192                 struct msg_iscsi_ping {
193                         uint32_t        host_no;
194                         uint32_t        iface_num;
195                         uint32_t        iface_type;
196                         uint32_t        payload_size;
197                         uint32_t        pid;    /* unique ping id associated
198                                                    with each ping request */
199                 } iscsi_ping;
200                 struct msg_get_chap {
201                         uint32_t        host_no;
202                         uint32_t        num_entries; /* number of CHAP entries
203                                                       * on request, number of
204                                                       * valid CHAP entries on
205                                                       * response */
206                         uint16_t        chap_tbl_idx;
207                 } get_chap;
208                 struct msg_delete_chap {
209                        uint32_t        host_no;
210                        uint16_t        chap_tbl_idx;
211                 } delete_chap;
212                 struct msg_set_flashnode_param {
213                         uint32_t        host_no;
214                         uint32_t        flashnode_idx;
215                         uint32_t        count;
216                 } set_flashnode;
217                 struct msg_new_flashnode {
218                         uint32_t        host_no;
219                         uint32_t        len;
220                 } new_flashnode;
221                 struct msg_del_flashnode {
222                         uint32_t        host_no;
223                         uint32_t        flashnode_idx;
224                 } del_flashnode;
225                 struct msg_login_flashnode {
226                         uint32_t        host_no;
227                         uint32_t        flashnode_idx;
228                 } login_flashnode;
229                 struct msg_logout_flashnode {
230                         uint32_t        host_no;
231                         uint32_t        flashnode_idx;
232                 } logout_flashnode;
233                 struct msg_logout_flashnode_sid {
234                         uint32_t        host_no;
235                         uint32_t        sid;
236                 } logout_flashnode_sid;
237                 struct msg_get_host_stats {
238                         uint32_t host_no;
239                 } get_host_stats;
240         } u;
241         union {
242                 /* messages k -> u */
243                 int                     retcode;
244                 struct msg_create_session_ret {
245                         uint32_t        sid;
246                         uint32_t        host_no;
247                 } c_session_ret;
248                 struct msg_create_conn_ret {
249                         uint32_t        sid;
250                         uint32_t        cid;
251                 } c_conn_ret;
252                 struct msg_unbind_session {
253                         uint32_t        sid;
254                         uint32_t        host_no;
255                 } unbind_session;
256                 struct msg_recv_req {
257                         uint32_t        sid;
258                         uint32_t        cid;
259                         uint64_t        recv_handle;
260                 } recv_req;
261                 struct msg_conn_login {
262                         uint32_t        sid;
263                         uint32_t        cid;
264                         uint32_t        state; /* enum iscsi_conn_state */
265                 } conn_login;
266                 struct msg_conn_error {
267                         uint32_t        sid;
268                         uint32_t        cid;
269                         uint32_t        error; /* enum iscsi_err */
270                 } connerror;
271                 struct msg_session_destroyed {
272                         uint32_t        host_no;
273                         uint32_t        sid;
274                 } d_session;
275                 struct msg_transport_connect_ret {
276                         uint64_t        handle;
277                 } ep_connect_ret;
278                 struct msg_req_path {
279                         uint32_t        host_no;
280                 } req_path;
281                 struct msg_notify_if_down {
282                         uint32_t        host_no;
283                 } notify_if_down;
284                 struct msg_host_event {
285                         uint32_t        host_no;
286                         uint32_t        data_size;
287                         enum iscsi_host_event_code code;
288                 } host_event;
289                 struct msg_ping_comp {
290                         uint32_t        host_no;
291                         uint32_t        status; /* enum
292                                                  * iscsi_ping_status_code */
293                         uint32_t        pid;    /* unique ping id associated
294                                                    with each ping request */
295                         uint32_t        data_size;
296                 } ping_comp;
297                 struct msg_new_flashnode_ret {
298                         uint32_t        flashnode_idx;
299                 } new_flashnode_ret;
300         } r;
301 } __attribute__ ((aligned (sizeof(uint64_t))));
302
303 enum iscsi_param_type {
304         ISCSI_PARAM,            /* iscsi_param (session, conn, target, LU) */
305         ISCSI_HOST_PARAM,       /* iscsi_host_param */
306         ISCSI_NET_PARAM,        /* iscsi_net_param */
307         ISCSI_FLASHNODE_PARAM,  /* iscsi_flashnode_param */
308         ISCSI_CHAP_PARAM,       /* iscsi_chap_param */
309         ISCSI_IFACE_PARAM,      /* iscsi_iface_param */
310 };
311
312 /* structure for minimalist usecase */
313 struct iscsi_param_info {
314         uint32_t len;           /* Actual length of the param value */
315         uint16_t param;         /* iscsi param */
316         uint8_t value[0];       /* length sized value follows */
317 } __packed;
318
319 struct iscsi_iface_param_info {
320         uint32_t iface_num;     /* iface number, 0 - n */
321         uint32_t len;           /* Actual length of the param */
322         uint16_t param;         /* iscsi param value */
323         uint8_t iface_type;     /* IPv4 or IPv6 */
324         uint8_t param_type;     /* iscsi_param_type */
325         uint8_t value[0];       /* length sized value follows */
326 } __packed;
327
328 /*
329  * To keep the struct iscsi_uevent size the same for userspace code
330  * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
331  * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
332  * struct iscsi_uevent in the NETLINK_ISCSI message.
333  */
334 struct iscsi_path {
335         uint64_t        handle;
336         uint8_t         mac_addr[6];
337         uint8_t         mac_addr_old[6];
338         uint32_t        ip_addr_len;    /* 4 or 16 */
339         union {
340                 struct in_addr  v4_addr;
341                 struct in6_addr v6_addr;
342         } src;
343         union {
344                 struct in_addr  v4_addr;
345                 struct in6_addr v6_addr;
346         } dst;
347         uint16_t        vlan_id;
348         uint16_t        pmtu;
349 } __attribute__ ((aligned (sizeof(uint64_t))));
350
351 /* iscsi iface enabled/disabled setting */
352 #define ISCSI_IFACE_DISABLE     0x01
353 #define ISCSI_IFACE_ENABLE      0x02
354
355 /* ipv4 bootproto */
356 #define ISCSI_BOOTPROTO_STATIC          0x01
357 #define ISCSI_BOOTPROTO_DHCP            0x02
358
359 /* ipv6 addr autoconfig type */
360 #define ISCSI_IPV6_AUTOCFG_DISABLE              0x01
361 #define ISCSI_IPV6_AUTOCFG_ND_ENABLE            0x02
362 #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE        0x03
363
364 /* ipv6 link local addr type */
365 #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE     0x01
366 #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE    0x02
367
368 /* ipv6 router addr type */
369 #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE        0x01
370 #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE       0x02
371
372 #define ISCSI_IFACE_TYPE_IPV4           0x01
373 #define ISCSI_IFACE_TYPE_IPV6           0x02
374
375 #define ISCSI_MAX_VLAN_ID               4095
376 #define ISCSI_MAX_VLAN_PRIORITY         7
377
378 /* iscsi vlan enable/disabled setting */
379 #define ISCSI_VLAN_DISABLE      0x01
380 #define ISCSI_VLAN_ENABLE       0x02
381
382 /* iscsi generic enable/disabled setting for various features */
383 #define ISCSI_NET_PARAM_DISABLE         0x01
384 #define ISCSI_NET_PARAM_ENABLE          0x02
385
386 /* iSCSI network params */
387 enum iscsi_net_param {
388         ISCSI_NET_PARAM_IPV4_ADDR               = 1,
389         ISCSI_NET_PARAM_IPV4_SUBNET,
390         ISCSI_NET_PARAM_IPV4_GW,
391         ISCSI_NET_PARAM_IPV4_BOOTPROTO,
392         ISCSI_NET_PARAM_MAC,
393         ISCSI_NET_PARAM_IPV6_LINKLOCAL,
394         ISCSI_NET_PARAM_IPV6_ADDR,
395         ISCSI_NET_PARAM_IPV6_ROUTER,
396         ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG,
397         ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG,
398         ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG,
399         ISCSI_NET_PARAM_IFACE_ENABLE,
400         ISCSI_NET_PARAM_VLAN_ID,
401         ISCSI_NET_PARAM_VLAN_PRIORITY,
402         ISCSI_NET_PARAM_VLAN_ENABLED,
403         ISCSI_NET_PARAM_VLAN_TAG,
404         ISCSI_NET_PARAM_IFACE_TYPE,
405         ISCSI_NET_PARAM_IFACE_NAME,
406         ISCSI_NET_PARAM_MTU,
407         ISCSI_NET_PARAM_PORT,
408         ISCSI_NET_PARAM_IPADDR_STATE,
409         ISCSI_NET_PARAM_IPV6_LINKLOCAL_STATE,
410         ISCSI_NET_PARAM_IPV6_ROUTER_STATE,
411         ISCSI_NET_PARAM_DELAYED_ACK_EN,
412         ISCSI_NET_PARAM_TCP_NAGLE_DISABLE,
413         ISCSI_NET_PARAM_TCP_WSF_DISABLE,
414         ISCSI_NET_PARAM_TCP_WSF,
415         ISCSI_NET_PARAM_TCP_TIMER_SCALE,
416         ISCSI_NET_PARAM_TCP_TIMESTAMP_EN,
417         ISCSI_NET_PARAM_CACHE_ID,
418         ISCSI_NET_PARAM_IPV4_DHCP_DNS_ADDR_EN,
419         ISCSI_NET_PARAM_IPV4_DHCP_SLP_DA_EN,
420         ISCSI_NET_PARAM_IPV4_TOS_EN,
421         ISCSI_NET_PARAM_IPV4_TOS,
422         ISCSI_NET_PARAM_IPV4_GRAT_ARP_EN,
423         ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID_EN,
424         ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID,
425         ISCSI_NET_PARAM_IPV4_DHCP_REQ_VENDOR_ID_EN,
426         ISCSI_NET_PARAM_IPV4_DHCP_USE_VENDOR_ID_EN,
427         ISCSI_NET_PARAM_IPV4_DHCP_VENDOR_ID,
428         ISCSI_NET_PARAM_IPV4_DHCP_LEARN_IQN_EN,
429         ISCSI_NET_PARAM_IPV4_FRAGMENT_DISABLE,
430         ISCSI_NET_PARAM_IPV4_IN_FORWARD_EN,
431         ISCSI_NET_PARAM_IPV4_TTL,
432         ISCSI_NET_PARAM_IPV6_GRAT_NEIGHBOR_ADV_EN,
433         ISCSI_NET_PARAM_IPV6_MLD_EN,
434         ISCSI_NET_PARAM_IPV6_FLOW_LABEL,
435         ISCSI_NET_PARAM_IPV6_TRAFFIC_CLASS,
436         ISCSI_NET_PARAM_IPV6_HOP_LIMIT,
437         ISCSI_NET_PARAM_IPV6_ND_REACHABLE_TMO,
438         ISCSI_NET_PARAM_IPV6_ND_REXMIT_TIME,
439         ISCSI_NET_PARAM_IPV6_ND_STALE_TMO,
440         ISCSI_NET_PARAM_IPV6_DUP_ADDR_DETECT_CNT,
441         ISCSI_NET_PARAM_IPV6_RTR_ADV_LINK_MTU,
442         ISCSI_NET_PARAM_REDIRECT_EN,
443 };
444
445 enum iscsi_ipaddress_state {
446         ISCSI_IPDDRESS_STATE_UNCONFIGURED,
447         ISCSI_IPDDRESS_STATE_ACQUIRING,
448         ISCSI_IPDDRESS_STATE_TENTATIVE,
449         ISCSI_IPDDRESS_STATE_VALID,
450         ISCSI_IPDDRESS_STATE_DISABLING,
451         ISCSI_IPDDRESS_STATE_INVALID,
452         ISCSI_IPDDRESS_STATE_DEPRECATED,
453 };
454
455 enum iscsi_router_state {
456         ISCSI_ROUTER_STATE_UNKNOWN,
457         ISCSI_ROUTER_STATE_ADVERTISED,
458         ISCSI_ROUTER_STATE_MANUAL,
459         ISCSI_ROUTER_STATE_STALE,
460 };
461
462 /* iSCSI specific settings params for iface */
463 enum iscsi_iface_param {
464         ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO,
465         ISCSI_IFACE_PARAM_HDRDGST_EN,
466         ISCSI_IFACE_PARAM_DATADGST_EN,
467         ISCSI_IFACE_PARAM_IMM_DATA_EN,
468         ISCSI_IFACE_PARAM_INITIAL_R2T_EN,
469         ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN,
470         ISCSI_IFACE_PARAM_PDU_INORDER_EN,
471         ISCSI_IFACE_PARAM_ERL,
472         ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH,
473         ISCSI_IFACE_PARAM_FIRST_BURST,
474         ISCSI_IFACE_PARAM_MAX_R2T,
475         ISCSI_IFACE_PARAM_MAX_BURST,
476         ISCSI_IFACE_PARAM_CHAP_AUTH_EN,
477         ISCSI_IFACE_PARAM_BIDI_CHAP_EN,
478         ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL,
479         ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN,
480         ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN,
481         ISCSI_IFACE_PARAM_INITIATOR_NAME,
482 };
483
484 enum iscsi_conn_state {
485         ISCSI_CONN_STATE_FREE,
486         ISCSI_CONN_STATE_XPT_WAIT,
487         ISCSI_CONN_STATE_IN_LOGIN,
488         ISCSI_CONN_STATE_LOGGED_IN,
489         ISCSI_CONN_STATE_IN_LOGOUT,
490         ISCSI_CONN_STATE_LOGOUT_REQUESTED,
491         ISCSI_CONN_STATE_CLEANUP_WAIT,
492 };
493
494 /*
495  * Common error codes
496  */
497 enum iscsi_err {
498         ISCSI_OK                        = 0,
499
500         ISCSI_ERR_DATASN                = ISCSI_ERR_BASE + 1,
501         ISCSI_ERR_DATA_OFFSET           = ISCSI_ERR_BASE + 2,
502         ISCSI_ERR_MAX_CMDSN             = ISCSI_ERR_BASE + 3,
503         ISCSI_ERR_EXP_CMDSN             = ISCSI_ERR_BASE + 4,
504         ISCSI_ERR_BAD_OPCODE            = ISCSI_ERR_BASE + 5,
505         ISCSI_ERR_DATALEN               = ISCSI_ERR_BASE + 6,
506         ISCSI_ERR_AHSLEN                = ISCSI_ERR_BASE + 7,
507         ISCSI_ERR_PROTO                 = ISCSI_ERR_BASE + 8,
508         ISCSI_ERR_LUN                   = ISCSI_ERR_BASE + 9,
509         ISCSI_ERR_BAD_ITT               = ISCSI_ERR_BASE + 10,
510         ISCSI_ERR_CONN_FAILED           = ISCSI_ERR_BASE + 11,
511         ISCSI_ERR_R2TSN                 = ISCSI_ERR_BASE + 12,
512         ISCSI_ERR_SESSION_FAILED        = ISCSI_ERR_BASE + 13,
513         ISCSI_ERR_HDR_DGST              = ISCSI_ERR_BASE + 14,
514         ISCSI_ERR_DATA_DGST             = ISCSI_ERR_BASE + 15,
515         ISCSI_ERR_PARAM_NOT_FOUND       = ISCSI_ERR_BASE + 16,
516         ISCSI_ERR_NO_SCSI_CMD           = ISCSI_ERR_BASE + 17,
517         ISCSI_ERR_INVALID_HOST          = ISCSI_ERR_BASE + 18,
518         ISCSI_ERR_XMIT_FAILED           = ISCSI_ERR_BASE + 19,
519         ISCSI_ERR_TCP_CONN_CLOSE        = ISCSI_ERR_BASE + 20,
520         ISCSI_ERR_SCSI_EH_SESSION_RST   = ISCSI_ERR_BASE + 21,
521         ISCSI_ERR_NOP_TIMEDOUT          = ISCSI_ERR_BASE + 22,
522 };
523
524 /*
525  * iSCSI Parameters (RFC3720)
526  */
527 enum iscsi_param {
528         /* passed in using netlink set param */
529         ISCSI_PARAM_MAX_RECV_DLENGTH,
530         ISCSI_PARAM_MAX_XMIT_DLENGTH,
531         ISCSI_PARAM_HDRDGST_EN,
532         ISCSI_PARAM_DATADGST_EN,
533         ISCSI_PARAM_INITIAL_R2T_EN,
534         ISCSI_PARAM_MAX_R2T,
535         ISCSI_PARAM_IMM_DATA_EN,
536         ISCSI_PARAM_FIRST_BURST,
537         ISCSI_PARAM_MAX_BURST,
538         ISCSI_PARAM_PDU_INORDER_EN,
539         ISCSI_PARAM_DATASEQ_INORDER_EN,
540         ISCSI_PARAM_ERL,
541         ISCSI_PARAM_IFMARKER_EN,
542         ISCSI_PARAM_OFMARKER_EN,
543         ISCSI_PARAM_EXP_STATSN,
544         ISCSI_PARAM_TARGET_NAME,
545         ISCSI_PARAM_TPGT,
546         ISCSI_PARAM_PERSISTENT_ADDRESS,
547         ISCSI_PARAM_PERSISTENT_PORT,
548         ISCSI_PARAM_SESS_RECOVERY_TMO,
549
550         /* passed in through bind conn using transport_fd */
551         ISCSI_PARAM_CONN_PORT,
552         ISCSI_PARAM_CONN_ADDRESS,
553
554         ISCSI_PARAM_USERNAME,
555         ISCSI_PARAM_USERNAME_IN,
556         ISCSI_PARAM_PASSWORD,
557         ISCSI_PARAM_PASSWORD_IN,
558
559         ISCSI_PARAM_FAST_ABORT,
560         ISCSI_PARAM_ABORT_TMO,
561         ISCSI_PARAM_LU_RESET_TMO,
562         ISCSI_PARAM_HOST_RESET_TMO,
563
564         ISCSI_PARAM_PING_TMO,
565         ISCSI_PARAM_RECV_TMO,
566
567         ISCSI_PARAM_IFACE_NAME,
568         ISCSI_PARAM_ISID,
569         ISCSI_PARAM_INITIATOR_NAME,
570
571         ISCSI_PARAM_TGT_RESET_TMO,
572         ISCSI_PARAM_TARGET_ALIAS,
573
574         ISCSI_PARAM_CHAP_IN_IDX,
575         ISCSI_PARAM_CHAP_OUT_IDX,
576
577         ISCSI_PARAM_BOOT_ROOT,
578         ISCSI_PARAM_BOOT_NIC,
579         ISCSI_PARAM_BOOT_TARGET,
580
581         ISCSI_PARAM_AUTO_SND_TGT_DISABLE,
582         ISCSI_PARAM_DISCOVERY_SESS,
583         ISCSI_PARAM_PORTAL_TYPE,
584         ISCSI_PARAM_CHAP_AUTH_EN,
585         ISCSI_PARAM_DISCOVERY_LOGOUT_EN,
586         ISCSI_PARAM_BIDI_CHAP_EN,
587         ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL,
588
589         ISCSI_PARAM_DEF_TIME2WAIT,
590         ISCSI_PARAM_DEF_TIME2RETAIN,
591         ISCSI_PARAM_MAX_SEGMENT_SIZE,
592         ISCSI_PARAM_STATSN,
593         ISCSI_PARAM_KEEPALIVE_TMO,
594         ISCSI_PARAM_LOCAL_PORT,
595         ISCSI_PARAM_TSID,
596         ISCSI_PARAM_DEF_TASKMGMT_TMO,
597
598         ISCSI_PARAM_TCP_TIMESTAMP_STAT,
599         ISCSI_PARAM_TCP_WSF_DISABLE,
600         ISCSI_PARAM_TCP_NAGLE_DISABLE,
601         ISCSI_PARAM_TCP_TIMER_SCALE,
602         ISCSI_PARAM_TCP_TIMESTAMP_EN,
603         ISCSI_PARAM_TCP_XMIT_WSF,
604         ISCSI_PARAM_TCP_RECV_WSF,
605         ISCSI_PARAM_IP_FRAGMENT_DISABLE,
606         ISCSI_PARAM_IPV4_TOS,
607         ISCSI_PARAM_IPV6_TC,
608         ISCSI_PARAM_IPV6_FLOW_LABEL,
609         ISCSI_PARAM_IS_FW_ASSIGNED_IPV6,
610
611         ISCSI_PARAM_DISCOVERY_PARENT_IDX,
612         ISCSI_PARAM_DISCOVERY_PARENT_TYPE,
613         ISCSI_PARAM_LOCAL_IPADDR,
614         /* must always be last */
615         ISCSI_PARAM_MAX,
616 };
617
618 /* iSCSI HBA params */
619 enum iscsi_host_param {
620         ISCSI_HOST_PARAM_HWADDRESS,
621         ISCSI_HOST_PARAM_INITIATOR_NAME,
622         ISCSI_HOST_PARAM_NETDEV_NAME,
623         ISCSI_HOST_PARAM_IPADDRESS,
624         ISCSI_HOST_PARAM_PORT_STATE,
625         ISCSI_HOST_PARAM_PORT_SPEED,
626         ISCSI_HOST_PARAM_MAX,
627 };
628
629 /* portal type */
630 #define PORTAL_TYPE_IPV4        "ipv4"
631 #define PORTAL_TYPE_IPV6        "ipv6"
632
633 /* iSCSI Flash Target params */
634 enum iscsi_flashnode_param {
635         ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6,
636         ISCSI_FLASHNODE_PORTAL_TYPE,
637         ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE,
638         ISCSI_FLASHNODE_DISCOVERY_SESS,
639         ISCSI_FLASHNODE_ENTRY_EN,
640         ISCSI_FLASHNODE_HDR_DGST_EN,
641         ISCSI_FLASHNODE_DATA_DGST_EN,
642         ISCSI_FLASHNODE_IMM_DATA_EN,
643         ISCSI_FLASHNODE_INITIAL_R2T_EN,
644         ISCSI_FLASHNODE_DATASEQ_INORDER,
645         ISCSI_FLASHNODE_PDU_INORDER,
646         ISCSI_FLASHNODE_CHAP_AUTH_EN,
647         ISCSI_FLASHNODE_SNACK_REQ_EN,
648         ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN,
649         ISCSI_FLASHNODE_BIDI_CHAP_EN,
650         /* make authentication for discovery sessions optional */
651         ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL,
652         ISCSI_FLASHNODE_ERL,
653         ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT,
654         ISCSI_FLASHNODE_TCP_NAGLE_DISABLE,
655         ISCSI_FLASHNODE_TCP_WSF_DISABLE,
656         ISCSI_FLASHNODE_TCP_TIMER_SCALE,
657         ISCSI_FLASHNODE_TCP_TIMESTAMP_EN,
658         ISCSI_FLASHNODE_IP_FRAG_DISABLE,
659         ISCSI_FLASHNODE_MAX_RECV_DLENGTH,
660         ISCSI_FLASHNODE_MAX_XMIT_DLENGTH,
661         ISCSI_FLASHNODE_FIRST_BURST,
662         ISCSI_FLASHNODE_DEF_TIME2WAIT,
663         ISCSI_FLASHNODE_DEF_TIME2RETAIN,
664         ISCSI_FLASHNODE_MAX_R2T,
665         ISCSI_FLASHNODE_KEEPALIVE_TMO,
666         ISCSI_FLASHNODE_ISID,
667         ISCSI_FLASHNODE_TSID,
668         ISCSI_FLASHNODE_PORT,
669         ISCSI_FLASHNODE_MAX_BURST,
670         ISCSI_FLASHNODE_DEF_TASKMGMT_TMO,
671         ISCSI_FLASHNODE_IPADDR,
672         ISCSI_FLASHNODE_ALIAS,
673         ISCSI_FLASHNODE_REDIRECT_IPADDR,
674         ISCSI_FLASHNODE_MAX_SEGMENT_SIZE,
675         ISCSI_FLASHNODE_LOCAL_PORT,
676         ISCSI_FLASHNODE_IPV4_TOS,
677         ISCSI_FLASHNODE_IPV6_TC,
678         ISCSI_FLASHNODE_IPV6_FLOW_LABEL,
679         ISCSI_FLASHNODE_NAME,
680         ISCSI_FLASHNODE_TPGT,
681         ISCSI_FLASHNODE_LINK_LOCAL_IPV6,
682         ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX,
683         ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE,
684         ISCSI_FLASHNODE_TCP_XMIT_WSF,
685         ISCSI_FLASHNODE_TCP_RECV_WSF,
686         ISCSI_FLASHNODE_CHAP_IN_IDX,
687         ISCSI_FLASHNODE_CHAP_OUT_IDX,
688         ISCSI_FLASHNODE_USERNAME,
689         ISCSI_FLASHNODE_USERNAME_IN,
690         ISCSI_FLASHNODE_PASSWORD,
691         ISCSI_FLASHNODE_PASSWORD_IN,
692         ISCSI_FLASHNODE_STATSN,
693         ISCSI_FLASHNODE_EXP_STATSN,
694         ISCSI_FLASHNODE_IS_BOOT_TGT,
695
696         ISCSI_FLASHNODE_MAX,
697 };
698
699 struct iscsi_flashnode_param_info {
700         uint32_t len;           /* Actual length of the param */
701         uint16_t param;         /* iscsi param value */
702         uint8_t value[0];       /* length sized value follows */
703 } __packed;
704
705 enum iscsi_discovery_parent_type {
706         ISCSI_DISC_PARENT_UNKNOWN       = 0x1,
707         ISCSI_DISC_PARENT_SENDTGT       = 0x2,
708         ISCSI_DISC_PARENT_ISNS          = 0x3,
709 };
710
711 /* iSCSI port Speed */
712 enum iscsi_port_speed {
713         ISCSI_PORT_SPEED_UNKNOWN        = 0x1,
714         ISCSI_PORT_SPEED_10MBPS         = 0x2,
715         ISCSI_PORT_SPEED_100MBPS        = 0x4,
716         ISCSI_PORT_SPEED_1GBPS          = 0x8,
717         ISCSI_PORT_SPEED_10GBPS         = 0x10,
718         ISCSI_PORT_SPEED_25GBPS         = 0x20,
719         ISCSI_PORT_SPEED_40GBPS         = 0x40,
720 };
721
722 /* iSCSI port state */
723 enum iscsi_port_state {
724         ISCSI_PORT_STATE_DOWN           = 0x1,
725         ISCSI_PORT_STATE_UP             = 0x2,
726 };
727
728 /* iSCSI PING status/error code */
729 enum iscsi_ping_status_code {
730         ISCSI_PING_SUCCESS                      = 0,
731         ISCSI_PING_FW_DISABLED                  = 0x1,
732         ISCSI_PING_IPADDR_INVALID               = 0x2,
733         ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID  = 0x3,
734         ISCSI_PING_TIMEOUT                      = 0x4,
735         ISCSI_PING_INVALID_DEST_ADDR            = 0x5,
736         ISCSI_PING_OVERSIZE_PACKET              = 0x6,
737         ISCSI_PING_ICMP_ERROR                   = 0x7,
738         ISCSI_PING_MAX_REQ_EXCEEDED             = 0x8,
739         ISCSI_PING_NO_ARP_RECEIVED              = 0x9,
740 };
741
742 #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
743 #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
744
745 /*
746  * These flags presents iSCSI Data-Path capabilities.
747  */
748 #define CAP_RECOVERY_L0         0x1
749 #define CAP_RECOVERY_L1         0x2
750 #define CAP_RECOVERY_L2         0x4
751 #define CAP_MULTI_R2T           0x8
752 #define CAP_HDRDGST             0x10
753 #define CAP_DATADGST            0x20
754 #define CAP_MULTI_CONN          0x40
755 #define CAP_TEXT_NEGO           0x80
756 #define CAP_MARKERS             0x100
757 #define CAP_FW_DB               0x200
758 #define CAP_SENDTARGETS_OFFLOAD 0x400   /* offload discovery process */
759 #define CAP_DATA_PATH_OFFLOAD   0x800   /* offload entire IO path */
760 #define CAP_DIGEST_OFFLOAD      0x1000  /* offload hdr and data digests */
761 #define CAP_PADDING_OFFLOAD     0x2000  /* offload padding insertion, removal,
762                                          and verification */
763 #define CAP_LOGIN_OFFLOAD       0x4000  /* offload session login */
764
765 /*
766  * These flags describes reason of stop_conn() call
767  */
768 #define STOP_CONN_TERM          0x1
769 #define STOP_CONN_SUSPEND       0x2
770 #define STOP_CONN_RECOVER       0x3
771
772 #define ISCSI_STATS_CUSTOM_MAX          32
773 #define ISCSI_STATS_CUSTOM_DESC_MAX     64
774 struct iscsi_stats_custom {
775         char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
776         uint64_t value;
777 };
778
779 /*
780  * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
781  *
782  * Note: this structure contains counters collected on per-connection basis.
783  */
784 struct iscsi_stats {
785         /* octets */
786         uint64_t txdata_octets;
787         uint64_t rxdata_octets;
788
789         /* xmit pdus */
790         uint32_t noptx_pdus;
791         uint32_t scsicmd_pdus;
792         uint32_t tmfcmd_pdus;
793         uint32_t login_pdus;
794         uint32_t text_pdus;
795         uint32_t dataout_pdus;
796         uint32_t logout_pdus;
797         uint32_t snack_pdus;
798
799         /* recv pdus */
800         uint32_t noprx_pdus;
801         uint32_t scsirsp_pdus;
802         uint32_t tmfrsp_pdus;
803         uint32_t textrsp_pdus;
804         uint32_t datain_pdus;
805         uint32_t logoutrsp_pdus;
806         uint32_t r2t_pdus;
807         uint32_t async_pdus;
808         uint32_t rjt_pdus;
809
810         /* errors */
811         uint32_t digest_err;
812         uint32_t timeout_err;
813
814         /*
815          * iSCSI Custom Statistics support, i.e. Transport could
816          * extend existing MIB statistics with its own specific statistics
817          * up to ISCSI_STATS_CUSTOM_MAX
818          */
819         uint32_t custom_length;
820         struct iscsi_stats_custom custom[0]
821                 __attribute__ ((aligned (sizeof(uint64_t))));
822 };
823
824 enum chap_type_e {
825         CHAP_TYPE_OUT,
826         CHAP_TYPE_IN,
827 };
828
829 enum iscsi_chap_param {
830         ISCSI_CHAP_PARAM_INDEX,
831         ISCSI_CHAP_PARAM_CHAP_TYPE,
832         ISCSI_CHAP_PARAM_USERNAME,
833         ISCSI_CHAP_PARAM_PASSWORD,
834         ISCSI_CHAP_PARAM_PASSWORD_LEN
835 };
836
837 #define ISCSI_CHAP_AUTH_NAME_MAX_LEN    256
838 #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN  256
839 struct iscsi_chap_rec {
840         uint16_t chap_tbl_idx;
841         enum chap_type_e chap_type;
842         char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
843         uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
844         uint8_t password_length;
845 };
846
847 #define ISCSI_HOST_STATS_CUSTOM_MAX             32
848 #define ISCSI_HOST_STATS_CUSTOM_DESC_MAX        64
849 struct iscsi_host_stats_custom {
850         char desc[ISCSI_HOST_STATS_CUSTOM_DESC_MAX];
851         uint64_t value;
852 };
853
854 /* struct iscsi_offload_host_stats: Host statistics,
855  * Include statistics for MAC, IP, TCP & iSCSI.
856  */
857 struct iscsi_offload_host_stats {
858         /* MAC */
859         uint64_t mactx_frames;
860         uint64_t mactx_bytes;
861         uint64_t mactx_multicast_frames;
862         uint64_t mactx_broadcast_frames;
863         uint64_t mactx_pause_frames;
864         uint64_t mactx_control_frames;
865         uint64_t mactx_deferral;
866         uint64_t mactx_excess_deferral;
867         uint64_t mactx_late_collision;
868         uint64_t mactx_abort;
869         uint64_t mactx_single_collision;
870         uint64_t mactx_multiple_collision;
871         uint64_t mactx_collision;
872         uint64_t mactx_frames_dropped;
873         uint64_t mactx_jumbo_frames;
874         uint64_t macrx_frames;
875         uint64_t macrx_bytes;
876         uint64_t macrx_unknown_control_frames;
877         uint64_t macrx_pause_frames;
878         uint64_t macrx_control_frames;
879         uint64_t macrx_dribble;
880         uint64_t macrx_frame_length_error;
881         uint64_t macrx_jabber;
882         uint64_t macrx_carrier_sense_error;
883         uint64_t macrx_frame_discarded;
884         uint64_t macrx_frames_dropped;
885         uint64_t mac_crc_error;
886         uint64_t mac_encoding_error;
887         uint64_t macrx_length_error_large;
888         uint64_t macrx_length_error_small;
889         uint64_t macrx_multicast_frames;
890         uint64_t macrx_broadcast_frames;
891         /* IP */
892         uint64_t iptx_packets;
893         uint64_t iptx_bytes;
894         uint64_t iptx_fragments;
895         uint64_t iprx_packets;
896         uint64_t iprx_bytes;
897         uint64_t iprx_fragments;
898         uint64_t ip_datagram_reassembly;
899         uint64_t ip_invalid_address_error;
900         uint64_t ip_error_packets;
901         uint64_t ip_fragrx_overlap;
902         uint64_t ip_fragrx_outoforder;
903         uint64_t ip_datagram_reassembly_timeout;
904         uint64_t ipv6tx_packets;
905         uint64_t ipv6tx_bytes;
906         uint64_t ipv6tx_fragments;
907         uint64_t ipv6rx_packets;
908         uint64_t ipv6rx_bytes;
909         uint64_t ipv6rx_fragments;
910         uint64_t ipv6_datagram_reassembly;
911         uint64_t ipv6_invalid_address_error;
912         uint64_t ipv6_error_packets;
913         uint64_t ipv6_fragrx_overlap;
914         uint64_t ipv6_fragrx_outoforder;
915         uint64_t ipv6_datagram_reassembly_timeout;
916         /* TCP */
917         uint64_t tcptx_segments;
918         uint64_t tcptx_bytes;
919         uint64_t tcprx_segments;
920         uint64_t tcprx_byte;
921         uint64_t tcp_duplicate_ack_retx;
922         uint64_t tcp_retx_timer_expired;
923         uint64_t tcprx_duplicate_ack;
924         uint64_t tcprx_pure_ackr;
925         uint64_t tcptx_delayed_ack;
926         uint64_t tcptx_pure_ack;
927         uint64_t tcprx_segment_error;
928         uint64_t tcprx_segment_outoforder;
929         uint64_t tcprx_window_probe;
930         uint64_t tcprx_window_update;
931         uint64_t tcptx_window_probe_persist;
932         /* ECC */
933         uint64_t ecc_error_correction;
934         /* iSCSI */
935         uint64_t iscsi_pdu_tx;
936         uint64_t iscsi_data_bytes_tx;
937         uint64_t iscsi_pdu_rx;
938         uint64_t iscsi_data_bytes_rx;
939         uint64_t iscsi_io_completed;
940         uint64_t iscsi_unexpected_io_rx;
941         uint64_t iscsi_format_error;
942         uint64_t iscsi_hdr_digest_error;
943         uint64_t iscsi_data_digest_error;
944         uint64_t iscsi_sequence_error;
945         /*
946          * iSCSI Custom Host Statistics support, i.e. Transport could
947          * extend existing host statistics with its own specific statistics
948          * up to ISCSI_HOST_STATS_CUSTOM_MAX
949          */
950         uint32_t custom_length;
951         struct iscsi_host_stats_custom custom[0]
952                 __aligned(sizeof(uint64_t));
953 };
954
955 #endif