home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / include / scsi / iscsi_if.h next >
Encoding:
C/C++ Source or Header  |  2006-08-11  |  6.3 KB  |  249 lines

  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.  
  30. enum 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.  
  46.     /* up events */
  47.     ISCSI_KEVENT_RECV_PDU        = KEVENT_BASE + 1,
  48.     ISCSI_KEVENT_CONN_ERROR        = KEVENT_BASE + 2,
  49.     ISCSI_KEVENT_IF_ERROR        = KEVENT_BASE + 3,
  50. };
  51.  
  52. struct iscsi_uevent {
  53.     uint32_t type; /* k/u events type */
  54.     uint32_t iferror; /* carries interface or resource errors */
  55.     uint64_t transport_handle;
  56.  
  57.     union {
  58.         /* messages u -> k */
  59.         struct msg_create_session {
  60.             uint32_t    initial_cmdsn;
  61.         } c_session;
  62.         struct msg_destroy_session {
  63.             uint64_t    session_handle;
  64.             uint32_t    sid;
  65.         } d_session;
  66.         struct msg_create_conn {
  67.             uint64_t    session_handle;
  68.             uint32_t    cid;
  69.             uint32_t    sid;
  70.         } c_conn;
  71.         struct msg_bind_conn {
  72.             uint64_t    session_handle;
  73.             uint64_t    conn_handle;
  74.             uint32_t    transport_fd;
  75.             uint32_t    is_leading;
  76.         } b_conn;
  77.         struct msg_destroy_conn {
  78.             uint64_t    conn_handle;
  79.             uint32_t    cid;
  80.         } d_conn;
  81.         struct msg_send_pdu {
  82.             uint32_t    hdr_size;
  83.             uint32_t    data_size;
  84.             uint64_t    conn_handle;
  85.         } send_pdu;
  86.         struct msg_set_param {
  87.             uint64_t    conn_handle;
  88.             uint32_t    param; /* enum iscsi_param */
  89.             uint32_t    value;
  90.         } set_param;
  91.         struct msg_start_conn {
  92.             uint64_t    conn_handle;
  93.         } start_conn;
  94.         struct msg_stop_conn {
  95.             uint64_t    conn_handle;
  96.             uint32_t    flag;
  97.         } stop_conn;
  98.         struct msg_get_stats {
  99.             uint64_t    conn_handle;
  100.         } get_stats;
  101.     } u;
  102.     union {
  103.         /* messages k -> u */
  104.         uint64_t        handle;
  105.         int            retcode;
  106.         struct msg_create_session_ret {
  107.             uint64_t    session_handle;
  108.             uint32_t    sid;
  109.         } c_session_ret;
  110.         struct msg_recv_req {
  111.             uint64_t    recv_handle;
  112.             uint64_t    conn_handle;
  113.         } recv_req;
  114.         struct msg_conn_error {
  115.             uint64_t    conn_handle;
  116.             uint32_t    error; /* enum iscsi_err */
  117.         } connerror;
  118.     } r;
  119. } __attribute__ ((aligned (sizeof(uint64_t))));
  120.  
  121. /*
  122.  * Common error codes
  123.  */
  124. enum iscsi_err {
  125.     ISCSI_OK            = 0,
  126.  
  127.     ISCSI_ERR_DATASN        = ISCSI_ERR_BASE + 1,
  128.     ISCSI_ERR_DATA_OFFSET        = ISCSI_ERR_BASE + 2,
  129.     ISCSI_ERR_MAX_CMDSN        = ISCSI_ERR_BASE + 3,
  130.     ISCSI_ERR_EXP_CMDSN        = ISCSI_ERR_BASE + 4,
  131.     ISCSI_ERR_BAD_OPCODE        = ISCSI_ERR_BASE + 5,
  132.     ISCSI_ERR_DATALEN        = ISCSI_ERR_BASE + 6,
  133.     ISCSI_ERR_AHSLEN        = ISCSI_ERR_BASE + 7,
  134.     ISCSI_ERR_PROTO            = ISCSI_ERR_BASE + 8,
  135.     ISCSI_ERR_LUN            = ISCSI_ERR_BASE + 9,
  136.     ISCSI_ERR_BAD_ITT        = ISCSI_ERR_BASE + 10,
  137.     ISCSI_ERR_CONN_FAILED        = ISCSI_ERR_BASE + 11,
  138.     ISCSI_ERR_R2TSN            = ISCSI_ERR_BASE + 12,
  139.     ISCSI_ERR_SESSION_FAILED    = ISCSI_ERR_BASE + 13,
  140.     ISCSI_ERR_HDR_DGST        = ISCSI_ERR_BASE + 14,
  141.     ISCSI_ERR_DATA_DGST        = ISCSI_ERR_BASE + 15,
  142.     ISCSI_ERR_PARAM_NOT_FOUND    = ISCSI_ERR_BASE + 16
  143. };
  144.  
  145. /*
  146.  * iSCSI Parameters (RFC3720)
  147.  */
  148. enum iscsi_param {
  149.     ISCSI_PARAM_MAX_RECV_DLENGTH    = 0,
  150.     ISCSI_PARAM_MAX_XMIT_DLENGTH    = 1,
  151.     ISCSI_PARAM_HDRDGST_EN        = 2,
  152.     ISCSI_PARAM_DATADGST_EN        = 3,
  153.     ISCSI_PARAM_INITIAL_R2T_EN    = 4,
  154.     ISCSI_PARAM_MAX_R2T        = 5,
  155.     ISCSI_PARAM_IMM_DATA_EN        = 6,
  156.     ISCSI_PARAM_FIRST_BURST        = 7,
  157.     ISCSI_PARAM_MAX_BURST        = 8,
  158.     ISCSI_PARAM_PDU_INORDER_EN    = 9,
  159.     ISCSI_PARAM_DATASEQ_INORDER_EN    = 10,
  160.     ISCSI_PARAM_ERL            = 11,
  161.     ISCSI_PARAM_IFMARKER_EN        = 12,
  162.     ISCSI_PARAM_OFMARKER_EN        = 13,
  163. };
  164. #define ISCSI_PARAM_MAX            14
  165.  
  166. #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
  167. #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
  168. #define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))
  169.  
  170. /**
  171.  * iscsi_hostdata - get LLD hostdata from scsi_host
  172.  * @_hostdata: pointer to scsi host's hostdata
  173.  **/
  174. #define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long))
  175.  
  176. /*
  177.  * These flags presents iSCSI Data-Path capabilities.
  178.  */
  179. #define CAP_RECOVERY_L0        0x1
  180. #define CAP_RECOVERY_L1        0x2
  181. #define CAP_RECOVERY_L2        0x4
  182. #define CAP_MULTI_R2T        0x8
  183. #define CAP_HDRDGST        0x10
  184. #define CAP_DATADGST        0x20
  185. #define CAP_MULTI_CONN        0x40
  186. #define CAP_TEXT_NEGO        0x80
  187. #define CAP_MARKERS        0x100
  188.  
  189. /*
  190.  * These flags describes reason of stop_conn() call
  191.  */
  192. #define STOP_CONN_TERM        0x1
  193. #define STOP_CONN_SUSPEND    0x2
  194. #define STOP_CONN_RECOVER    0x3
  195.  
  196. #define ISCSI_STATS_CUSTOM_MAX        32
  197. #define ISCSI_STATS_CUSTOM_DESC_MAX    64
  198. struct iscsi_stats_custom {
  199.     char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
  200.     uint64_t value;
  201. };
  202.  
  203. /*
  204.  * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
  205.  *
  206.  * Note: this structure contains counters collected on per-connection basis.
  207.  */
  208. struct iscsi_stats {
  209.     /* octets */
  210.     uint64_t txdata_octets;
  211.     uint64_t rxdata_octets;
  212.  
  213.     /* xmit pdus */
  214.     uint32_t noptx_pdus;
  215.     uint32_t scsicmd_pdus;
  216.     uint32_t tmfcmd_pdus;
  217.     uint32_t login_pdus;
  218.     uint32_t text_pdus;
  219.     uint32_t dataout_pdus;
  220.     uint32_t logout_pdus;
  221.     uint32_t snack_pdus;
  222.  
  223.     /* recv pdus */
  224.     uint32_t noprx_pdus;
  225.     uint32_t scsirsp_pdus;
  226.     uint32_t tmfrsp_pdus;
  227.     uint32_t textrsp_pdus;
  228.     uint32_t datain_pdus;
  229.     uint32_t logoutrsp_pdus;
  230.     uint32_t r2t_pdus;
  231.     uint32_t async_pdus;
  232.     uint32_t rjt_pdus;
  233.  
  234.     /* errors */
  235.     uint32_t digest_err;
  236.     uint32_t timeout_err;
  237.  
  238.     /*
  239.      * iSCSI Custom Statistics support, i.e. Transport could
  240.      * extend existing MIB statistics with its own specific statistics
  241.      * up to ISCSI_STATS_CUSTOM_MAX
  242.      */
  243.     uint32_t custom_length;
  244.     struct iscsi_stats_custom custom[0]
  245.         __attribute__ ((aligned (sizeof(uint64_t))));
  246. };
  247.  
  248. #endif
  249.