Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * iSCSI User/Kernel Shares (Defines, Constants, Protocol definitions, etc)
0004  *
0005  * Copyright (C) 2005 Dmitry Yusupov
0006  * Copyright (C) 2005 Alex Aizman
0007  * maintained by open-iscsi@googlegroups.com
0008  */
0009 
0010 #ifndef ISCSI_IF_H
0011 #define ISCSI_IF_H
0012 
0013 #include <scsi/iscsi_proto.h>
0014 #include <linux/in.h>
0015 #include <linux/in6.h>
0016 
0017 #define ISCSI_NL_GRP_ISCSID 1
0018 #define ISCSI_NL_GRP_UIP    2
0019 
0020 #define UEVENT_BASE         10
0021 #define KEVENT_BASE         100
0022 #define ISCSI_ERR_BASE          1000
0023 
0024 enum iscsi_uevent_e {
0025     ISCSI_UEVENT_UNKNOWN        = 0,
0026 
0027     /* down events */
0028     ISCSI_UEVENT_CREATE_SESSION = UEVENT_BASE + 1,
0029     ISCSI_UEVENT_DESTROY_SESSION    = UEVENT_BASE + 2,
0030     ISCSI_UEVENT_CREATE_CONN    = UEVENT_BASE + 3,
0031     ISCSI_UEVENT_DESTROY_CONN   = UEVENT_BASE + 4,
0032     ISCSI_UEVENT_BIND_CONN      = UEVENT_BASE + 5,
0033     ISCSI_UEVENT_SET_PARAM      = UEVENT_BASE + 6,
0034     ISCSI_UEVENT_START_CONN     = UEVENT_BASE + 7,
0035     ISCSI_UEVENT_STOP_CONN      = UEVENT_BASE + 8,
0036     ISCSI_UEVENT_SEND_PDU       = UEVENT_BASE + 9,
0037     ISCSI_UEVENT_GET_STATS      = UEVENT_BASE + 10,
0038     ISCSI_UEVENT_GET_PARAM      = UEVENT_BASE + 11,
0039 
0040     ISCSI_UEVENT_TRANSPORT_EP_CONNECT   = UEVENT_BASE + 12,
0041     ISCSI_UEVENT_TRANSPORT_EP_POLL      = UEVENT_BASE + 13,
0042     ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT    = UEVENT_BASE + 14,
0043 
0044     ISCSI_UEVENT_TGT_DSCVR      = UEVENT_BASE + 15,
0045     ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
0046     ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17,
0047     ISCSI_UEVENT_CREATE_BOUND_SESSION       = UEVENT_BASE + 18,
0048     ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST  = UEVENT_BASE + 19,
0049 
0050     ISCSI_UEVENT_PATH_UPDATE    = UEVENT_BASE + 20,
0051     ISCSI_UEVENT_SET_IFACE_PARAMS   = UEVENT_BASE + 21,
0052     ISCSI_UEVENT_PING       = UEVENT_BASE + 22,
0053     ISCSI_UEVENT_GET_CHAP       = UEVENT_BASE + 23,
0054     ISCSI_UEVENT_DELETE_CHAP    = UEVENT_BASE + 24,
0055     ISCSI_UEVENT_SET_FLASHNODE_PARAMS   = UEVENT_BASE + 25,
0056     ISCSI_UEVENT_NEW_FLASHNODE  = UEVENT_BASE + 26,
0057     ISCSI_UEVENT_DEL_FLASHNODE  = UEVENT_BASE + 27,
0058     ISCSI_UEVENT_LOGIN_FLASHNODE    = UEVENT_BASE + 28,
0059     ISCSI_UEVENT_LOGOUT_FLASHNODE   = UEVENT_BASE + 29,
0060     ISCSI_UEVENT_LOGOUT_FLASHNODE_SID   = UEVENT_BASE + 30,
0061     ISCSI_UEVENT_SET_CHAP       = UEVENT_BASE + 31,
0062     ISCSI_UEVENT_GET_HOST_STATS = UEVENT_BASE + 32,
0063     ISCSI_UEVENT_DESTROY_SESSION_ASYNC  = UEVENT_BASE + 33,
0064 
0065     /* up events */
0066     ISCSI_KEVENT_RECV_PDU       = KEVENT_BASE + 1,
0067     ISCSI_KEVENT_CONN_ERROR     = KEVENT_BASE + 2,
0068     ISCSI_KEVENT_IF_ERROR       = KEVENT_BASE + 3,
0069     ISCSI_KEVENT_DESTROY_SESSION    = KEVENT_BASE + 4,
0070     ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
0071     ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
0072 
0073     ISCSI_KEVENT_PATH_REQ       = KEVENT_BASE + 7,
0074     ISCSI_KEVENT_IF_DOWN        = KEVENT_BASE + 8,
0075     ISCSI_KEVENT_CONN_LOGIN_STATE   = KEVENT_BASE + 9,
0076     ISCSI_KEVENT_HOST_EVENT     = KEVENT_BASE + 10,
0077     ISCSI_KEVENT_PING_COMP      = KEVENT_BASE + 11,
0078 };
0079 
0080 enum iscsi_tgt_dscvr {
0081     ISCSI_TGT_DSCVR_SEND_TARGETS    = 1,
0082     ISCSI_TGT_DSCVR_ISNS        = 2,
0083     ISCSI_TGT_DSCVR_SLP     = 3,
0084 };
0085 
0086 enum iscsi_host_event_code {
0087     ISCSI_EVENT_LINKUP      = 1,
0088     ISCSI_EVENT_LINKDOWN,
0089     /* must always be last */
0090     ISCSI_EVENT_MAX,
0091 };
0092 
0093 struct iscsi_uevent {
0094     uint32_t type; /* k/u events type */
0095     uint32_t iferror; /* carries interface or resource errors */
0096     uint64_t transport_handle;
0097 
0098     union {
0099         /* messages u -> k */
0100         struct msg_create_session {
0101             uint32_t    initial_cmdsn;
0102             uint16_t    cmds_max;
0103             uint16_t    queue_depth;
0104         } c_session;
0105         struct msg_create_bound_session {
0106             uint64_t    ep_handle;
0107             uint32_t    initial_cmdsn;
0108             uint16_t    cmds_max;
0109             uint16_t    queue_depth;
0110         } c_bound_session;
0111         struct msg_destroy_session {
0112             uint32_t    sid;
0113         } d_session;
0114         struct msg_create_conn {
0115             uint32_t    sid;
0116             uint32_t    cid;
0117         } c_conn;
0118         struct msg_bind_conn {
0119             uint32_t    sid;
0120             uint32_t    cid;
0121             uint64_t    transport_eph;
0122             uint32_t    is_leading;
0123         } b_conn;
0124         struct msg_destroy_conn {
0125             uint32_t    sid;
0126             uint32_t    cid;
0127         } d_conn;
0128         struct msg_send_pdu {
0129             uint32_t    sid;
0130             uint32_t    cid;
0131             uint32_t    hdr_size;
0132             uint32_t    data_size;
0133         } send_pdu;
0134         struct msg_set_param {
0135             uint32_t    sid;
0136             uint32_t    cid;
0137             uint32_t    param; /* enum iscsi_param */
0138             uint32_t    len;
0139         } set_param;
0140         struct msg_start_conn {
0141             uint32_t    sid;
0142             uint32_t    cid;
0143         } start_conn;
0144         struct msg_stop_conn {
0145             uint32_t    sid;
0146             uint32_t    cid;
0147             uint64_t    conn_handle;
0148             uint32_t    flag;
0149         } stop_conn;
0150         struct msg_get_stats {
0151             uint32_t    sid;
0152             uint32_t    cid;
0153         } get_stats;
0154         struct msg_transport_connect {
0155             uint32_t    non_blocking;
0156         } ep_connect;
0157         struct msg_transport_connect_through_host {
0158             uint32_t    host_no;
0159             uint32_t    non_blocking;
0160         } ep_connect_through_host;
0161         struct msg_transport_poll {
0162             uint64_t    ep_handle;
0163             uint32_t    timeout_ms;
0164         } ep_poll;
0165         struct msg_transport_disconnect {
0166             uint64_t    ep_handle;
0167         } ep_disconnect;
0168         struct msg_tgt_dscvr {
0169             enum iscsi_tgt_dscvr    type;
0170             uint32_t    host_no;
0171             /*
0172              * enable = 1 to establish a new connection
0173              * with the server. enable = 0 to disconnect
0174              * from the server. Used primarily to switch
0175              * from one iSNS server to another.
0176              */
0177             uint32_t    enable;
0178         } tgt_dscvr;
0179         struct msg_set_host_param {
0180             uint32_t    host_no;
0181             uint32_t    param; /* enum iscsi_host_param */
0182             uint32_t    len;
0183         } set_host_param;
0184         struct msg_set_path {
0185             uint32_t    host_no;
0186         } set_path;
0187         struct msg_set_iface_params {
0188             uint32_t    host_no;
0189             uint32_t    count;
0190         } set_iface_params;
0191         struct msg_iscsi_ping {
0192             uint32_t        host_no;
0193             uint32_t        iface_num;
0194             uint32_t        iface_type;
0195             uint32_t        payload_size;
0196             uint32_t    pid;    /* unique ping id associated
0197                            with each ping request */
0198         } iscsi_ping;
0199         struct msg_get_chap {
0200             uint32_t    host_no;
0201             uint32_t    num_entries; /* number of CHAP entries
0202                               * on request, number of
0203                               * valid CHAP entries on
0204                               * response */
0205             uint16_t    chap_tbl_idx;
0206         } get_chap;
0207         struct msg_delete_chap {
0208                uint32_t        host_no;
0209                uint16_t        chap_tbl_idx;
0210         } delete_chap;
0211         struct msg_set_flashnode_param {
0212             uint32_t    host_no;
0213             uint32_t    flashnode_idx;
0214             uint32_t    count;
0215         } set_flashnode;
0216         struct msg_new_flashnode {
0217             uint32_t    host_no;
0218             uint32_t    len;
0219         } new_flashnode;
0220         struct msg_del_flashnode {
0221             uint32_t    host_no;
0222             uint32_t    flashnode_idx;
0223         } del_flashnode;
0224         struct msg_login_flashnode {
0225             uint32_t    host_no;
0226             uint32_t    flashnode_idx;
0227         } login_flashnode;
0228         struct msg_logout_flashnode {
0229             uint32_t    host_no;
0230             uint32_t    flashnode_idx;
0231         } logout_flashnode;
0232         struct msg_logout_flashnode_sid {
0233             uint32_t    host_no;
0234             uint32_t    sid;
0235         } logout_flashnode_sid;
0236         struct msg_get_host_stats {
0237             uint32_t host_no;
0238         } get_host_stats;
0239     } u;
0240     union {
0241         /* messages k -> u */
0242         int         retcode;
0243         struct msg_create_session_ret {
0244             uint32_t    sid;
0245             uint32_t    host_no;
0246         } c_session_ret;
0247         struct msg_create_conn_ret {
0248             uint32_t    sid;
0249             uint32_t    cid;
0250         } c_conn_ret;
0251         struct msg_unbind_session {
0252             uint32_t    sid;
0253             uint32_t    host_no;
0254         } unbind_session;
0255         struct msg_recv_req {
0256             uint32_t    sid;
0257             uint32_t    cid;
0258             uint64_t    recv_handle;
0259         } recv_req;
0260         struct msg_conn_login {
0261             uint32_t        sid;
0262             uint32_t        cid;
0263             uint32_t        state; /* enum iscsi_conn_state */
0264         } conn_login;
0265         struct msg_conn_error {
0266             uint32_t    sid;
0267             uint32_t    cid;
0268             uint32_t    error; /* enum iscsi_err */
0269         } connerror;
0270         struct msg_session_destroyed {
0271             uint32_t    host_no;
0272             uint32_t    sid;
0273         } d_session;
0274         struct msg_transport_connect_ret {
0275             uint64_t    handle;
0276         } ep_connect_ret;
0277         struct msg_req_path {
0278             uint32_t    host_no;
0279         } req_path;
0280         struct msg_notify_if_down {
0281             uint32_t    host_no;
0282         } notify_if_down;
0283         struct msg_host_event {
0284             uint32_t    host_no;
0285             uint32_t    data_size;
0286             enum iscsi_host_event_code code;
0287         } host_event;
0288         struct msg_ping_comp {
0289             uint32_t        host_no;
0290             uint32_t        status; /* enum
0291                          * iscsi_ping_status_code */
0292             uint32_t    pid;    /* unique ping id associated
0293                            with each ping request */
0294             uint32_t        data_size;
0295         } ping_comp;
0296         struct msg_new_flashnode_ret {
0297             uint32_t    flashnode_idx;
0298         } new_flashnode_ret;
0299     } r;
0300 } __attribute__ ((aligned (sizeof(uint64_t))));
0301 
0302 enum iscsi_param_type {
0303     ISCSI_PARAM,        /* iscsi_param (session, conn, target, LU) */
0304     ISCSI_HOST_PARAM,   /* iscsi_host_param */
0305     ISCSI_NET_PARAM,    /* iscsi_net_param */
0306     ISCSI_FLASHNODE_PARAM,  /* iscsi_flashnode_param */
0307     ISCSI_CHAP_PARAM,   /* iscsi_chap_param */
0308     ISCSI_IFACE_PARAM,  /* iscsi_iface_param */
0309 };
0310 
0311 /* structure for minimalist usecase */
0312 struct iscsi_param_info {
0313     uint32_t len;       /* Actual length of the param value */
0314     uint16_t param;     /* iscsi param */
0315     uint8_t value[];    /* length sized value follows */
0316 } __packed;
0317 
0318 struct iscsi_iface_param_info {
0319     uint32_t iface_num; /* iface number, 0 - n */
0320     uint32_t len;       /* Actual length of the param */
0321     uint16_t param;     /* iscsi param value */
0322     uint8_t iface_type; /* IPv4 or IPv6 */
0323     uint8_t param_type; /* iscsi_param_type */
0324     uint8_t value[];    /* length sized value follows */
0325 } __packed;
0326 
0327 /*
0328  * To keep the struct iscsi_uevent size the same for userspace code
0329  * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
0330  * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
0331  * struct iscsi_uevent in the NETLINK_ISCSI message.
0332  */
0333 struct iscsi_path {
0334     uint64_t    handle;
0335     uint8_t     mac_addr[6];
0336     uint8_t     mac_addr_old[6];
0337     uint32_t    ip_addr_len;    /* 4 or 16 */
0338     union {
0339         struct in_addr  v4_addr;
0340         struct in6_addr v6_addr;
0341     } src;
0342     union {
0343         struct in_addr  v4_addr;
0344         struct in6_addr v6_addr;
0345     } dst;
0346     uint16_t    vlan_id;
0347     uint16_t    pmtu;
0348 } __attribute__ ((aligned (sizeof(uint64_t))));
0349 
0350 /* iscsi iface enabled/disabled setting */
0351 #define ISCSI_IFACE_DISABLE 0x01
0352 #define ISCSI_IFACE_ENABLE  0x02
0353 
0354 /* ipv4 bootproto */
0355 #define ISCSI_BOOTPROTO_STATIC      0x01
0356 #define ISCSI_BOOTPROTO_DHCP        0x02
0357 
0358 /* ipv6 addr autoconfig type */
0359 #define ISCSI_IPV6_AUTOCFG_DISABLE      0x01
0360 #define ISCSI_IPV6_AUTOCFG_ND_ENABLE        0x02
0361 #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE    0x03
0362 
0363 /* ipv6 link local addr type */
0364 #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01
0365 #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE    0x02
0366 
0367 /* ipv6 router addr type */
0368 #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE    0x01
0369 #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE   0x02
0370 
0371 #define ISCSI_IFACE_TYPE_IPV4       0x01
0372 #define ISCSI_IFACE_TYPE_IPV6       0x02
0373 
0374 #define ISCSI_MAX_VLAN_ID       4095
0375 #define ISCSI_MAX_VLAN_PRIORITY     7
0376 
0377 /* iscsi vlan enable/disabled setting */
0378 #define ISCSI_VLAN_DISABLE  0x01
0379 #define ISCSI_VLAN_ENABLE   0x02
0380 
0381 /* iscsi generic enable/disabled setting for various features */
0382 #define ISCSI_NET_PARAM_DISABLE     0x01
0383 #define ISCSI_NET_PARAM_ENABLE      0x02
0384 
0385 /* iSCSI network params */
0386 enum iscsi_net_param {
0387     ISCSI_NET_PARAM_IPV4_ADDR       = 1,
0388     ISCSI_NET_PARAM_IPV4_SUBNET,
0389     ISCSI_NET_PARAM_IPV4_GW,
0390     ISCSI_NET_PARAM_IPV4_BOOTPROTO,
0391     ISCSI_NET_PARAM_MAC,
0392     ISCSI_NET_PARAM_IPV6_LINKLOCAL,
0393     ISCSI_NET_PARAM_IPV6_ADDR,
0394     ISCSI_NET_PARAM_IPV6_ROUTER,
0395     ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG,
0396     ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG,
0397     ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG,
0398     ISCSI_NET_PARAM_IFACE_ENABLE,
0399     ISCSI_NET_PARAM_VLAN_ID,
0400     ISCSI_NET_PARAM_VLAN_PRIORITY,
0401     ISCSI_NET_PARAM_VLAN_ENABLED,
0402     ISCSI_NET_PARAM_VLAN_TAG,
0403     ISCSI_NET_PARAM_IFACE_TYPE,
0404     ISCSI_NET_PARAM_IFACE_NAME,
0405     ISCSI_NET_PARAM_MTU,
0406     ISCSI_NET_PARAM_PORT,
0407     ISCSI_NET_PARAM_IPADDR_STATE,
0408     ISCSI_NET_PARAM_IPV6_LINKLOCAL_STATE,
0409     ISCSI_NET_PARAM_IPV6_ROUTER_STATE,
0410     ISCSI_NET_PARAM_DELAYED_ACK_EN,
0411     ISCSI_NET_PARAM_TCP_NAGLE_DISABLE,
0412     ISCSI_NET_PARAM_TCP_WSF_DISABLE,
0413     ISCSI_NET_PARAM_TCP_WSF,
0414     ISCSI_NET_PARAM_TCP_TIMER_SCALE,
0415     ISCSI_NET_PARAM_TCP_TIMESTAMP_EN,
0416     ISCSI_NET_PARAM_CACHE_ID,
0417     ISCSI_NET_PARAM_IPV4_DHCP_DNS_ADDR_EN,
0418     ISCSI_NET_PARAM_IPV4_DHCP_SLP_DA_EN,
0419     ISCSI_NET_PARAM_IPV4_TOS_EN,
0420     ISCSI_NET_PARAM_IPV4_TOS,
0421     ISCSI_NET_PARAM_IPV4_GRAT_ARP_EN,
0422     ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID_EN,
0423     ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID,
0424     ISCSI_NET_PARAM_IPV4_DHCP_REQ_VENDOR_ID_EN,
0425     ISCSI_NET_PARAM_IPV4_DHCP_USE_VENDOR_ID_EN,
0426     ISCSI_NET_PARAM_IPV4_DHCP_VENDOR_ID,
0427     ISCSI_NET_PARAM_IPV4_DHCP_LEARN_IQN_EN,
0428     ISCSI_NET_PARAM_IPV4_FRAGMENT_DISABLE,
0429     ISCSI_NET_PARAM_IPV4_IN_FORWARD_EN,
0430     ISCSI_NET_PARAM_IPV4_TTL,
0431     ISCSI_NET_PARAM_IPV6_GRAT_NEIGHBOR_ADV_EN,
0432     ISCSI_NET_PARAM_IPV6_MLD_EN,
0433     ISCSI_NET_PARAM_IPV6_FLOW_LABEL,
0434     ISCSI_NET_PARAM_IPV6_TRAFFIC_CLASS,
0435     ISCSI_NET_PARAM_IPV6_HOP_LIMIT,
0436     ISCSI_NET_PARAM_IPV6_ND_REACHABLE_TMO,
0437     ISCSI_NET_PARAM_IPV6_ND_REXMIT_TIME,
0438     ISCSI_NET_PARAM_IPV6_ND_STALE_TMO,
0439     ISCSI_NET_PARAM_IPV6_DUP_ADDR_DETECT_CNT,
0440     ISCSI_NET_PARAM_IPV6_RTR_ADV_LINK_MTU,
0441     ISCSI_NET_PARAM_REDIRECT_EN,
0442 };
0443 
0444 enum iscsi_ipaddress_state {
0445     ISCSI_IPDDRESS_STATE_UNCONFIGURED,
0446     ISCSI_IPDDRESS_STATE_ACQUIRING,
0447     ISCSI_IPDDRESS_STATE_TENTATIVE,
0448     ISCSI_IPDDRESS_STATE_VALID,
0449     ISCSI_IPDDRESS_STATE_DISABLING,
0450     ISCSI_IPDDRESS_STATE_INVALID,
0451     ISCSI_IPDDRESS_STATE_DEPRECATED,
0452 };
0453 
0454 enum iscsi_router_state {
0455     ISCSI_ROUTER_STATE_UNKNOWN,
0456     ISCSI_ROUTER_STATE_ADVERTISED,
0457     ISCSI_ROUTER_STATE_MANUAL,
0458     ISCSI_ROUTER_STATE_STALE,
0459 };
0460 
0461 /* iSCSI specific settings params for iface */
0462 enum iscsi_iface_param {
0463     ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO,
0464     ISCSI_IFACE_PARAM_HDRDGST_EN,
0465     ISCSI_IFACE_PARAM_DATADGST_EN,
0466     ISCSI_IFACE_PARAM_IMM_DATA_EN,
0467     ISCSI_IFACE_PARAM_INITIAL_R2T_EN,
0468     ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN,
0469     ISCSI_IFACE_PARAM_PDU_INORDER_EN,
0470     ISCSI_IFACE_PARAM_ERL,
0471     ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH,
0472     ISCSI_IFACE_PARAM_FIRST_BURST,
0473     ISCSI_IFACE_PARAM_MAX_R2T,
0474     ISCSI_IFACE_PARAM_MAX_BURST,
0475     ISCSI_IFACE_PARAM_CHAP_AUTH_EN,
0476     ISCSI_IFACE_PARAM_BIDI_CHAP_EN,
0477     ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL,
0478     ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN,
0479     ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN,
0480     ISCSI_IFACE_PARAM_INITIATOR_NAME,
0481 };
0482 
0483 enum iscsi_conn_state {
0484     ISCSI_CONN_STATE_FREE,
0485     ISCSI_CONN_STATE_XPT_WAIT,
0486     ISCSI_CONN_STATE_IN_LOGIN,
0487     ISCSI_CONN_STATE_LOGGED_IN,
0488     ISCSI_CONN_STATE_IN_LOGOUT,
0489     ISCSI_CONN_STATE_LOGOUT_REQUESTED,
0490     ISCSI_CONN_STATE_CLEANUP_WAIT,
0491 };
0492 
0493 /*
0494  * Common error codes
0495  */
0496 enum iscsi_err {
0497     ISCSI_OK            = 0,
0498 
0499     ISCSI_ERR_DATASN        = ISCSI_ERR_BASE + 1,
0500     ISCSI_ERR_DATA_OFFSET       = ISCSI_ERR_BASE + 2,
0501     ISCSI_ERR_MAX_CMDSN     = ISCSI_ERR_BASE + 3,
0502     ISCSI_ERR_EXP_CMDSN     = ISCSI_ERR_BASE + 4,
0503     ISCSI_ERR_BAD_OPCODE        = ISCSI_ERR_BASE + 5,
0504     ISCSI_ERR_DATALEN       = ISCSI_ERR_BASE + 6,
0505     ISCSI_ERR_AHSLEN        = ISCSI_ERR_BASE + 7,
0506     ISCSI_ERR_PROTO         = ISCSI_ERR_BASE + 8,
0507     ISCSI_ERR_LUN           = ISCSI_ERR_BASE + 9,
0508     ISCSI_ERR_BAD_ITT       = ISCSI_ERR_BASE + 10,
0509     ISCSI_ERR_CONN_FAILED       = ISCSI_ERR_BASE + 11,
0510     ISCSI_ERR_R2TSN         = ISCSI_ERR_BASE + 12,
0511     ISCSI_ERR_SESSION_FAILED    = ISCSI_ERR_BASE + 13,
0512     ISCSI_ERR_HDR_DGST      = ISCSI_ERR_BASE + 14,
0513     ISCSI_ERR_DATA_DGST     = ISCSI_ERR_BASE + 15,
0514     ISCSI_ERR_PARAM_NOT_FOUND   = ISCSI_ERR_BASE + 16,
0515     ISCSI_ERR_NO_SCSI_CMD       = ISCSI_ERR_BASE + 17,
0516     ISCSI_ERR_INVALID_HOST      = ISCSI_ERR_BASE + 18,
0517     ISCSI_ERR_XMIT_FAILED       = ISCSI_ERR_BASE + 19,
0518     ISCSI_ERR_TCP_CONN_CLOSE    = ISCSI_ERR_BASE + 20,
0519     ISCSI_ERR_SCSI_EH_SESSION_RST   = ISCSI_ERR_BASE + 21,
0520     ISCSI_ERR_NOP_TIMEDOUT      = ISCSI_ERR_BASE + 22,
0521 };
0522 
0523 /*
0524  * iSCSI Parameters (RFC3720)
0525  */
0526 enum iscsi_param {
0527     /* passed in using netlink set param */
0528     ISCSI_PARAM_MAX_RECV_DLENGTH,
0529     ISCSI_PARAM_MAX_XMIT_DLENGTH,
0530     ISCSI_PARAM_HDRDGST_EN,
0531     ISCSI_PARAM_DATADGST_EN,
0532     ISCSI_PARAM_INITIAL_R2T_EN,
0533     ISCSI_PARAM_MAX_R2T,
0534     ISCSI_PARAM_IMM_DATA_EN,
0535     ISCSI_PARAM_FIRST_BURST,
0536     ISCSI_PARAM_MAX_BURST,
0537     ISCSI_PARAM_PDU_INORDER_EN,
0538     ISCSI_PARAM_DATASEQ_INORDER_EN,
0539     ISCSI_PARAM_ERL,
0540     ISCSI_PARAM_IFMARKER_EN,
0541     ISCSI_PARAM_OFMARKER_EN,
0542     ISCSI_PARAM_EXP_STATSN,
0543     ISCSI_PARAM_TARGET_NAME,
0544     ISCSI_PARAM_TPGT,
0545     ISCSI_PARAM_PERSISTENT_ADDRESS,
0546     ISCSI_PARAM_PERSISTENT_PORT,
0547     ISCSI_PARAM_SESS_RECOVERY_TMO,
0548 
0549     /* passed in through bind conn using transport_fd */
0550     ISCSI_PARAM_CONN_PORT,
0551     ISCSI_PARAM_CONN_ADDRESS,
0552 
0553     ISCSI_PARAM_USERNAME,
0554     ISCSI_PARAM_USERNAME_IN,
0555     ISCSI_PARAM_PASSWORD,
0556     ISCSI_PARAM_PASSWORD_IN,
0557 
0558     ISCSI_PARAM_FAST_ABORT,
0559     ISCSI_PARAM_ABORT_TMO,
0560     ISCSI_PARAM_LU_RESET_TMO,
0561     ISCSI_PARAM_HOST_RESET_TMO,
0562 
0563     ISCSI_PARAM_PING_TMO,
0564     ISCSI_PARAM_RECV_TMO,
0565 
0566     ISCSI_PARAM_IFACE_NAME,
0567     ISCSI_PARAM_ISID,
0568     ISCSI_PARAM_INITIATOR_NAME,
0569 
0570     ISCSI_PARAM_TGT_RESET_TMO,
0571     ISCSI_PARAM_TARGET_ALIAS,
0572 
0573     ISCSI_PARAM_CHAP_IN_IDX,
0574     ISCSI_PARAM_CHAP_OUT_IDX,
0575 
0576     ISCSI_PARAM_BOOT_ROOT,
0577     ISCSI_PARAM_BOOT_NIC,
0578     ISCSI_PARAM_BOOT_TARGET,
0579 
0580     ISCSI_PARAM_AUTO_SND_TGT_DISABLE,
0581     ISCSI_PARAM_DISCOVERY_SESS,
0582     ISCSI_PARAM_PORTAL_TYPE,
0583     ISCSI_PARAM_CHAP_AUTH_EN,
0584     ISCSI_PARAM_DISCOVERY_LOGOUT_EN,
0585     ISCSI_PARAM_BIDI_CHAP_EN,
0586     ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL,
0587 
0588     ISCSI_PARAM_DEF_TIME2WAIT,
0589     ISCSI_PARAM_DEF_TIME2RETAIN,
0590     ISCSI_PARAM_MAX_SEGMENT_SIZE,
0591     ISCSI_PARAM_STATSN,
0592     ISCSI_PARAM_KEEPALIVE_TMO,
0593     ISCSI_PARAM_LOCAL_PORT,
0594     ISCSI_PARAM_TSID,
0595     ISCSI_PARAM_DEF_TASKMGMT_TMO,
0596 
0597     ISCSI_PARAM_TCP_TIMESTAMP_STAT,
0598     ISCSI_PARAM_TCP_WSF_DISABLE,
0599     ISCSI_PARAM_TCP_NAGLE_DISABLE,
0600     ISCSI_PARAM_TCP_TIMER_SCALE,
0601     ISCSI_PARAM_TCP_TIMESTAMP_EN,
0602     ISCSI_PARAM_TCP_XMIT_WSF,
0603     ISCSI_PARAM_TCP_RECV_WSF,
0604     ISCSI_PARAM_IP_FRAGMENT_DISABLE,
0605     ISCSI_PARAM_IPV4_TOS,
0606     ISCSI_PARAM_IPV6_TC,
0607     ISCSI_PARAM_IPV6_FLOW_LABEL,
0608     ISCSI_PARAM_IS_FW_ASSIGNED_IPV6,
0609 
0610     ISCSI_PARAM_DISCOVERY_PARENT_IDX,
0611     ISCSI_PARAM_DISCOVERY_PARENT_TYPE,
0612     ISCSI_PARAM_LOCAL_IPADDR,
0613     /* must always be last */
0614     ISCSI_PARAM_MAX,
0615 };
0616 
0617 /* iSCSI HBA params */
0618 enum iscsi_host_param {
0619     ISCSI_HOST_PARAM_HWADDRESS,
0620     ISCSI_HOST_PARAM_INITIATOR_NAME,
0621     ISCSI_HOST_PARAM_NETDEV_NAME,
0622     ISCSI_HOST_PARAM_IPADDRESS,
0623     ISCSI_HOST_PARAM_PORT_STATE,
0624     ISCSI_HOST_PARAM_PORT_SPEED,
0625     ISCSI_HOST_PARAM_MAX,
0626 };
0627 
0628 /* portal type */
0629 #define PORTAL_TYPE_IPV4    "ipv4"
0630 #define PORTAL_TYPE_IPV6    "ipv6"
0631 
0632 /* iSCSI Flash Target params */
0633 enum iscsi_flashnode_param {
0634     ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6,
0635     ISCSI_FLASHNODE_PORTAL_TYPE,
0636     ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE,
0637     ISCSI_FLASHNODE_DISCOVERY_SESS,
0638     ISCSI_FLASHNODE_ENTRY_EN,
0639     ISCSI_FLASHNODE_HDR_DGST_EN,
0640     ISCSI_FLASHNODE_DATA_DGST_EN,
0641     ISCSI_FLASHNODE_IMM_DATA_EN,
0642     ISCSI_FLASHNODE_INITIAL_R2T_EN,
0643     ISCSI_FLASHNODE_DATASEQ_INORDER,
0644     ISCSI_FLASHNODE_PDU_INORDER,
0645     ISCSI_FLASHNODE_CHAP_AUTH_EN,
0646     ISCSI_FLASHNODE_SNACK_REQ_EN,
0647     ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN,
0648     ISCSI_FLASHNODE_BIDI_CHAP_EN,
0649     /* make authentication for discovery sessions optional */
0650     ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL,
0651     ISCSI_FLASHNODE_ERL,
0652     ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT,
0653     ISCSI_FLASHNODE_TCP_NAGLE_DISABLE,
0654     ISCSI_FLASHNODE_TCP_WSF_DISABLE,
0655     ISCSI_FLASHNODE_TCP_TIMER_SCALE,
0656     ISCSI_FLASHNODE_TCP_TIMESTAMP_EN,
0657     ISCSI_FLASHNODE_IP_FRAG_DISABLE,
0658     ISCSI_FLASHNODE_MAX_RECV_DLENGTH,
0659     ISCSI_FLASHNODE_MAX_XMIT_DLENGTH,
0660     ISCSI_FLASHNODE_FIRST_BURST,
0661     ISCSI_FLASHNODE_DEF_TIME2WAIT,
0662     ISCSI_FLASHNODE_DEF_TIME2RETAIN,
0663     ISCSI_FLASHNODE_MAX_R2T,
0664     ISCSI_FLASHNODE_KEEPALIVE_TMO,
0665     ISCSI_FLASHNODE_ISID,
0666     ISCSI_FLASHNODE_TSID,
0667     ISCSI_FLASHNODE_PORT,
0668     ISCSI_FLASHNODE_MAX_BURST,
0669     ISCSI_FLASHNODE_DEF_TASKMGMT_TMO,
0670     ISCSI_FLASHNODE_IPADDR,
0671     ISCSI_FLASHNODE_ALIAS,
0672     ISCSI_FLASHNODE_REDIRECT_IPADDR,
0673     ISCSI_FLASHNODE_MAX_SEGMENT_SIZE,
0674     ISCSI_FLASHNODE_LOCAL_PORT,
0675     ISCSI_FLASHNODE_IPV4_TOS,
0676     ISCSI_FLASHNODE_IPV6_TC,
0677     ISCSI_FLASHNODE_IPV6_FLOW_LABEL,
0678     ISCSI_FLASHNODE_NAME,
0679     ISCSI_FLASHNODE_TPGT,
0680     ISCSI_FLASHNODE_LINK_LOCAL_IPV6,
0681     ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX,
0682     ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE,
0683     ISCSI_FLASHNODE_TCP_XMIT_WSF,
0684     ISCSI_FLASHNODE_TCP_RECV_WSF,
0685     ISCSI_FLASHNODE_CHAP_IN_IDX,
0686     ISCSI_FLASHNODE_CHAP_OUT_IDX,
0687     ISCSI_FLASHNODE_USERNAME,
0688     ISCSI_FLASHNODE_USERNAME_IN,
0689     ISCSI_FLASHNODE_PASSWORD,
0690     ISCSI_FLASHNODE_PASSWORD_IN,
0691     ISCSI_FLASHNODE_STATSN,
0692     ISCSI_FLASHNODE_EXP_STATSN,
0693     ISCSI_FLASHNODE_IS_BOOT_TGT,
0694 
0695     ISCSI_FLASHNODE_MAX,
0696 };
0697 
0698 struct iscsi_flashnode_param_info {
0699     uint32_t len;       /* Actual length of the param */
0700     uint16_t param;     /* iscsi param value */
0701     uint8_t value[];    /* length sized value follows */
0702 } __packed;
0703 
0704 enum iscsi_discovery_parent_type {
0705     ISCSI_DISC_PARENT_UNKNOWN   = 0x1,
0706     ISCSI_DISC_PARENT_SENDTGT   = 0x2,
0707     ISCSI_DISC_PARENT_ISNS      = 0x3,
0708 };
0709 
0710 /* iSCSI port Speed */
0711 enum iscsi_port_speed {
0712     ISCSI_PORT_SPEED_UNKNOWN    = 0x1,
0713     ISCSI_PORT_SPEED_10MBPS     = 0x2,
0714     ISCSI_PORT_SPEED_100MBPS    = 0x4,
0715     ISCSI_PORT_SPEED_1GBPS      = 0x8,
0716     ISCSI_PORT_SPEED_10GBPS     = 0x10,
0717     ISCSI_PORT_SPEED_25GBPS         = 0x20,
0718     ISCSI_PORT_SPEED_40GBPS         = 0x40,
0719 };
0720 
0721 /* iSCSI port state */
0722 enum iscsi_port_state {
0723     ISCSI_PORT_STATE_DOWN       = 0x1,
0724     ISCSI_PORT_STATE_UP     = 0x2,
0725 };
0726 
0727 /* iSCSI PING status/error code */
0728 enum iscsi_ping_status_code {
0729     ISCSI_PING_SUCCESS          = 0,
0730     ISCSI_PING_FW_DISABLED          = 0x1,
0731     ISCSI_PING_IPADDR_INVALID       = 0x2,
0732     ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID  = 0x3,
0733     ISCSI_PING_TIMEOUT          = 0x4,
0734     ISCSI_PING_INVALID_DEST_ADDR        = 0x5,
0735     ISCSI_PING_OVERSIZE_PACKET      = 0x6,
0736     ISCSI_PING_ICMP_ERROR           = 0x7,
0737     ISCSI_PING_MAX_REQ_EXCEEDED     = 0x8,
0738     ISCSI_PING_NO_ARP_RECEIVED      = 0x9,
0739 };
0740 
0741 #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
0742 #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
0743 
0744 /*
0745  * These flags presents iSCSI Data-Path capabilities.
0746  */
0747 #define CAP_RECOVERY_L0     0x1
0748 #define CAP_RECOVERY_L1     0x2
0749 #define CAP_RECOVERY_L2     0x4
0750 #define CAP_MULTI_R2T       0x8
0751 #define CAP_HDRDGST     0x10
0752 #define CAP_DATADGST        0x20
0753 #define CAP_MULTI_CONN      0x40
0754 #define CAP_TEXT_NEGO       0x80
0755 #define CAP_MARKERS     0x100
0756 #define CAP_FW_DB       0x200
0757 #define CAP_SENDTARGETS_OFFLOAD 0x400   /* offload discovery process */
0758 #define CAP_DATA_PATH_OFFLOAD   0x800   /* offload entire IO path */
0759 #define CAP_DIGEST_OFFLOAD  0x1000  /* offload hdr and data digests */
0760 #define CAP_PADDING_OFFLOAD 0x2000  /* offload padding insertion, removal,
0761                      and verification */
0762 #define CAP_LOGIN_OFFLOAD   0x4000  /* offload session login */
0763 
0764 /*
0765  * These flags describes reason of stop_conn() call
0766  */
0767 #define STOP_CONN_TERM      0x1
0768 #define STOP_CONN_SUSPEND   0x2
0769 #define STOP_CONN_RECOVER   0x3
0770 
0771 #define ISCSI_STATS_CUSTOM_MAX      32
0772 #define ISCSI_STATS_CUSTOM_DESC_MAX 64
0773 struct iscsi_stats_custom {
0774     char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
0775     uint64_t value;
0776 };
0777 
0778 /*
0779  * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
0780  *
0781  * Note: this structure contains counters collected on per-connection basis.
0782  */
0783 struct iscsi_stats {
0784     /* octets */
0785     uint64_t txdata_octets;
0786     uint64_t rxdata_octets;
0787 
0788     /* xmit pdus */
0789     uint32_t noptx_pdus;
0790     uint32_t scsicmd_pdus;
0791     uint32_t tmfcmd_pdus;
0792     uint32_t login_pdus;
0793     uint32_t text_pdus;
0794     uint32_t dataout_pdus;
0795     uint32_t logout_pdus;
0796     uint32_t snack_pdus;
0797 
0798     /* recv pdus */
0799     uint32_t noprx_pdus;
0800     uint32_t scsirsp_pdus;
0801     uint32_t tmfrsp_pdus;
0802     uint32_t textrsp_pdus;
0803     uint32_t datain_pdus;
0804     uint32_t logoutrsp_pdus;
0805     uint32_t r2t_pdus;
0806     uint32_t async_pdus;
0807     uint32_t rjt_pdus;
0808 
0809     /* errors */
0810     uint32_t digest_err;
0811     uint32_t timeout_err;
0812 
0813     /*
0814      * iSCSI Custom Statistics support, i.e. Transport could
0815      * extend existing MIB statistics with its own specific statistics
0816      * up to ISCSI_STATS_CUSTOM_MAX
0817      */
0818     uint32_t custom_length;
0819     struct iscsi_stats_custom custom[]
0820         __attribute__ ((aligned (sizeof(uint64_t))));
0821 };
0822 
0823 enum chap_type_e {
0824     CHAP_TYPE_OUT,
0825     CHAP_TYPE_IN,
0826 };
0827 
0828 enum iscsi_chap_param {
0829     ISCSI_CHAP_PARAM_INDEX,
0830     ISCSI_CHAP_PARAM_CHAP_TYPE,
0831     ISCSI_CHAP_PARAM_USERNAME,
0832     ISCSI_CHAP_PARAM_PASSWORD,
0833     ISCSI_CHAP_PARAM_PASSWORD_LEN
0834 };
0835 
0836 #define ISCSI_CHAP_AUTH_NAME_MAX_LEN    256
0837 #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN  256
0838 struct iscsi_chap_rec {
0839     uint16_t chap_tbl_idx;
0840     enum chap_type_e chap_type;
0841     char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
0842     uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
0843     uint8_t password_length;
0844 };
0845 
0846 #define ISCSI_HOST_STATS_CUSTOM_MAX             32
0847 #define ISCSI_HOST_STATS_CUSTOM_DESC_MAX        64
0848 struct iscsi_host_stats_custom {
0849     char desc[ISCSI_HOST_STATS_CUSTOM_DESC_MAX];
0850     uint64_t value;
0851 };
0852 
0853 /* struct iscsi_offload_host_stats: Host statistics,
0854  * Include statistics for MAC, IP, TCP & iSCSI.
0855  */
0856 struct iscsi_offload_host_stats {
0857     /* MAC */
0858     uint64_t mactx_frames;
0859     uint64_t mactx_bytes;
0860     uint64_t mactx_multicast_frames;
0861     uint64_t mactx_broadcast_frames;
0862     uint64_t mactx_pause_frames;
0863     uint64_t mactx_control_frames;
0864     uint64_t mactx_deferral;
0865     uint64_t mactx_excess_deferral;
0866     uint64_t mactx_late_collision;
0867     uint64_t mactx_abort;
0868     uint64_t mactx_single_collision;
0869     uint64_t mactx_multiple_collision;
0870     uint64_t mactx_collision;
0871     uint64_t mactx_frames_dropped;
0872     uint64_t mactx_jumbo_frames;
0873     uint64_t macrx_frames;
0874     uint64_t macrx_bytes;
0875     uint64_t macrx_unknown_control_frames;
0876     uint64_t macrx_pause_frames;
0877     uint64_t macrx_control_frames;
0878     uint64_t macrx_dribble;
0879     uint64_t macrx_frame_length_error;
0880     uint64_t macrx_jabber;
0881     uint64_t macrx_carrier_sense_error;
0882     uint64_t macrx_frame_discarded;
0883     uint64_t macrx_frames_dropped;
0884     uint64_t mac_crc_error;
0885     uint64_t mac_encoding_error;
0886     uint64_t macrx_length_error_large;
0887     uint64_t macrx_length_error_small;
0888     uint64_t macrx_multicast_frames;
0889     uint64_t macrx_broadcast_frames;
0890     /* IP */
0891     uint64_t iptx_packets;
0892     uint64_t iptx_bytes;
0893     uint64_t iptx_fragments;
0894     uint64_t iprx_packets;
0895     uint64_t iprx_bytes;
0896     uint64_t iprx_fragments;
0897     uint64_t ip_datagram_reassembly;
0898     uint64_t ip_invalid_address_error;
0899     uint64_t ip_error_packets;
0900     uint64_t ip_fragrx_overlap;
0901     uint64_t ip_fragrx_outoforder;
0902     uint64_t ip_datagram_reassembly_timeout;
0903     uint64_t ipv6tx_packets;
0904     uint64_t ipv6tx_bytes;
0905     uint64_t ipv6tx_fragments;
0906     uint64_t ipv6rx_packets;
0907     uint64_t ipv6rx_bytes;
0908     uint64_t ipv6rx_fragments;
0909     uint64_t ipv6_datagram_reassembly;
0910     uint64_t ipv6_invalid_address_error;
0911     uint64_t ipv6_error_packets;
0912     uint64_t ipv6_fragrx_overlap;
0913     uint64_t ipv6_fragrx_outoforder;
0914     uint64_t ipv6_datagram_reassembly_timeout;
0915     /* TCP */
0916     uint64_t tcptx_segments;
0917     uint64_t tcptx_bytes;
0918     uint64_t tcprx_segments;
0919     uint64_t tcprx_byte;
0920     uint64_t tcp_duplicate_ack_retx;
0921     uint64_t tcp_retx_timer_expired;
0922     uint64_t tcprx_duplicate_ack;
0923     uint64_t tcprx_pure_ackr;
0924     uint64_t tcptx_delayed_ack;
0925     uint64_t tcptx_pure_ack;
0926     uint64_t tcprx_segment_error;
0927     uint64_t tcprx_segment_outoforder;
0928     uint64_t tcprx_window_probe;
0929     uint64_t tcprx_window_update;
0930     uint64_t tcptx_window_probe_persist;
0931     /* ECC */
0932     uint64_t ecc_error_correction;
0933     /* iSCSI */
0934     uint64_t iscsi_pdu_tx;
0935     uint64_t iscsi_data_bytes_tx;
0936     uint64_t iscsi_pdu_rx;
0937     uint64_t iscsi_data_bytes_rx;
0938     uint64_t iscsi_io_completed;
0939     uint64_t iscsi_unexpected_io_rx;
0940     uint64_t iscsi_format_error;
0941     uint64_t iscsi_hdr_digest_error;
0942     uint64_t iscsi_data_digest_error;
0943     uint64_t iscsi_sequence_error;
0944     /*
0945      * iSCSI Custom Host Statistics support, i.e. Transport could
0946      * extend existing host statistics with its own specific statistics
0947      * up to ISCSI_HOST_STATS_CUSTOM_MAX
0948      */
0949     uint32_t custom_length;
0950     struct iscsi_host_stats_custom custom[]
0951         __aligned(sizeof(uint64_t));
0952 };
0953 
0954 #endif