iscsi_if.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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. #ifndef ISCSI_IF_H
  21. #define ISCSI_IF_H
  22. #include <scsi/iscsi_proto.h>
  23. #include <linux/in.h>
  24. #include <linux/in6.h>
  25. #define ISCSI_NL_GRP_ISCSID 1
  26. #define ISCSI_NL_GRP_UIP 2
  27. #define UEVENT_BASE 10
  28. #define KEVENT_BASE 100
  29. #define ISCSI_ERR_BASE 1000
  30. enum iscsi_uevent_e {
  31. ISCSI_UEVENT_UNKNOWN = 0,
  32. /* down events */
  33. ISCSI_UEVENT_CREATE_SESSION = UEVENT_BASE + 1,
  34. ISCSI_UEVENT_DESTROY_SESSION = UEVENT_BASE + 2,
  35. ISCSI_UEVENT_CREATE_CONN = UEVENT_BASE + 3,
  36. ISCSI_UEVENT_DESTROY_CONN = UEVENT_BASE + 4,
  37. ISCSI_UEVENT_BIND_CONN = UEVENT_BASE + 5,
  38. ISCSI_UEVENT_SET_PARAM = UEVENT_BASE + 6,
  39. ISCSI_UEVENT_START_CONN = UEVENT_BASE + 7,
  40. ISCSI_UEVENT_STOP_CONN = UEVENT_BASE + 8,
  41. ISCSI_UEVENT_SEND_PDU = UEVENT_BASE + 9,
  42. ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10,
  43. ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11,
  44. ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12,
  45. ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13,
  46. ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
  47. ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
  48. ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
  49. ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17,
  50. ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18,
  51. ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST = UEVENT_BASE + 19,
  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. /* up events */
  58. ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
  59. ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
  60. ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
  61. ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
  62. ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
  63. ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
  64. ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
  65. ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
  66. ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9,
  67. ISCSI_KEVENT_HOST_EVENT = KEVENT_BASE + 10,
  68. ISCSI_KEVENT_PING_COMP = KEVENT_BASE + 11,
  69. };
  70. enum iscsi_tgt_dscvr {
  71. ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
  72. ISCSI_TGT_DSCVR_ISNS = 2,
  73. ISCSI_TGT_DSCVR_SLP = 3,
  74. };
  75. enum iscsi_host_event_code {
  76. ISCSI_EVENT_LINKUP = 1,
  77. ISCSI_EVENT_LINKDOWN,
  78. /* must always be last */
  79. ISCSI_EVENT_MAX,
  80. };
  81. struct iscsi_uevent {
  82. uint32_t type; /* k/u events type */
  83. uint32_t iferror; /* carries interface or resource errors */
  84. uint64_t transport_handle;
  85. union {
  86. /* messages u -> k */
  87. struct msg_create_session {
  88. uint32_t initial_cmdsn;
  89. uint16_t cmds_max;
  90. uint16_t queue_depth;
  91. } c_session;
  92. struct msg_create_bound_session {
  93. uint64_t ep_handle;
  94. uint32_t initial_cmdsn;
  95. uint16_t cmds_max;
  96. uint16_t queue_depth;
  97. } c_bound_session;
  98. struct msg_destroy_session {
  99. uint32_t sid;
  100. } d_session;
  101. struct msg_create_conn {
  102. uint32_t sid;
  103. uint32_t cid;
  104. } c_conn;
  105. struct msg_bind_conn {
  106. uint32_t sid;
  107. uint32_t cid;
  108. uint64_t transport_eph;
  109. uint32_t is_leading;
  110. } b_conn;
  111. struct msg_destroy_conn {
  112. uint32_t sid;
  113. uint32_t cid;
  114. } d_conn;
  115. struct msg_send_pdu {
  116. uint32_t sid;
  117. uint32_t cid;
  118. uint32_t hdr_size;
  119. uint32_t data_size;
  120. } send_pdu;
  121. struct msg_set_param {
  122. uint32_t sid;
  123. uint32_t cid;
  124. uint32_t param; /* enum iscsi_param */
  125. uint32_t len;
  126. } set_param;
  127. struct msg_start_conn {
  128. uint32_t sid;
  129. uint32_t cid;
  130. } start_conn;
  131. struct msg_stop_conn {
  132. uint32_t sid;
  133. uint32_t cid;
  134. uint64_t conn_handle;
  135. uint32_t flag;
  136. } stop_conn;
  137. struct msg_get_stats {
  138. uint32_t sid;
  139. uint32_t cid;
  140. } get_stats;
  141. struct msg_transport_connect {
  142. uint32_t non_blocking;
  143. } ep_connect;
  144. struct msg_transport_connect_through_host {
  145. uint32_t host_no;
  146. uint32_t non_blocking;
  147. } ep_connect_through_host;
  148. struct msg_transport_poll {
  149. uint64_t ep_handle;
  150. uint32_t timeout_ms;
  151. } ep_poll;
  152. struct msg_transport_disconnect {
  153. uint64_t ep_handle;
  154. } ep_disconnect;
  155. struct msg_tgt_dscvr {
  156. enum iscsi_tgt_dscvr type;
  157. uint32_t host_no;
  158. /*
  159. * enable = 1 to establish a new connection
  160. * with the server. enable = 0 to disconnect
  161. * from the server. Used primarily to switch
  162. * from one iSNS server to another.
  163. */
  164. uint32_t enable;
  165. } tgt_dscvr;
  166. struct msg_set_host_param {
  167. uint32_t host_no;
  168. uint32_t param; /* enum iscsi_host_param */
  169. uint32_t len;
  170. } set_host_param;
  171. struct msg_set_path {
  172. uint32_t host_no;
  173. } set_path;
  174. struct msg_set_iface_params {
  175. uint32_t host_no;
  176. uint32_t count;
  177. } set_iface_params;
  178. struct msg_iscsi_ping {
  179. uint32_t host_no;
  180. uint32_t iface_num;
  181. uint32_t iface_type;
  182. uint32_t payload_size;
  183. uint32_t pid; /* unique ping id associated
  184. with each ping request */
  185. } iscsi_ping;
  186. struct msg_get_chap {
  187. uint32_t host_no;
  188. uint32_t num_entries; /* number of CHAP entries
  189. * on request, number of
  190. * valid CHAP entries on
  191. * response */
  192. uint16_t chap_tbl_idx;
  193. } get_chap;
  194. struct msg_delete_chap {
  195. uint32_t host_no;
  196. uint16_t chap_tbl_idx;
  197. } delete_chap;
  198. } u;
  199. union {
  200. /* messages k -> u */
  201. int retcode;
  202. struct msg_create_session_ret {
  203. uint32_t sid;
  204. uint32_t host_no;
  205. } c_session_ret;
  206. struct msg_create_conn_ret {
  207. uint32_t sid;
  208. uint32_t cid;
  209. } c_conn_ret;
  210. struct msg_unbind_session {
  211. uint32_t sid;
  212. uint32_t host_no;
  213. } unbind_session;
  214. struct msg_recv_req {
  215. uint32_t sid;
  216. uint32_t cid;
  217. uint64_t recv_handle;
  218. } recv_req;
  219. struct msg_conn_login {
  220. uint32_t sid;
  221. uint32_t cid;
  222. uint32_t state; /* enum iscsi_conn_state */
  223. } conn_login;
  224. struct msg_conn_error {
  225. uint32_t sid;
  226. uint32_t cid;
  227. uint32_t error; /* enum iscsi_err */
  228. } connerror;
  229. struct msg_session_destroyed {
  230. uint32_t host_no;
  231. uint32_t sid;
  232. } d_session;
  233. struct msg_transport_connect_ret {
  234. uint64_t handle;
  235. } ep_connect_ret;
  236. struct msg_req_path {
  237. uint32_t host_no;
  238. } req_path;
  239. struct msg_notify_if_down {
  240. uint32_t host_no;
  241. } notify_if_down;
  242. struct msg_host_event {
  243. uint32_t host_no;
  244. uint32_t data_size;
  245. enum iscsi_host_event_code code;
  246. } host_event;
  247. struct msg_ping_comp {
  248. uint32_t host_no;
  249. uint32_t status; /* enum
  250. * iscsi_ping_status_code */
  251. uint32_t pid; /* unique ping id associated
  252. with each ping request */
  253. uint32_t data_size;
  254. } ping_comp;
  255. } r;
  256. } __attribute__ ((aligned (sizeof(uint64_t))));
  257. enum iscsi_param_type {
  258. ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */
  259. ISCSI_HOST_PARAM, /* iscsi_host_param */
  260. ISCSI_NET_PARAM, /* iscsi_net_param */
  261. };
  262. struct iscsi_iface_param_info {
  263. uint32_t iface_num; /* iface number, 0 - n */
  264. uint32_t len; /* Actual length of the param */
  265. uint16_t param; /* iscsi param value */
  266. uint8_t iface_type; /* IPv4 or IPv6 */
  267. uint8_t param_type; /* iscsi_param_type */
  268. uint8_t value[0]; /* length sized value follows */
  269. } __packed;
  270. /*
  271. * To keep the struct iscsi_uevent size the same for userspace code
  272. * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
  273. * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
  274. * struct iscsi_uevent in the NETLINK_ISCSI message.
  275. */
  276. struct iscsi_path {
  277. uint64_t handle;
  278. uint8_t mac_addr[6];
  279. uint8_t mac_addr_old[6];
  280. uint32_t ip_addr_len; /* 4 or 16 */
  281. union {
  282. struct in_addr v4_addr;
  283. struct in6_addr v6_addr;
  284. } src;
  285. union {
  286. struct in_addr v4_addr;
  287. struct in6_addr v6_addr;
  288. } dst;
  289. uint16_t vlan_id;
  290. uint16_t pmtu;
  291. } __attribute__ ((aligned (sizeof(uint64_t))));
  292. /* iscsi iface enabled/disabled setting */
  293. #define ISCSI_IFACE_DISABLE 0x01
  294. #define ISCSI_IFACE_ENABLE 0x02
  295. /* ipv4 bootproto */
  296. #define ISCSI_BOOTPROTO_STATIC 0x01
  297. #define ISCSI_BOOTPROTO_DHCP 0x02
  298. /* ipv6 addr autoconfig type */
  299. #define ISCSI_IPV6_AUTOCFG_DISABLE 0x01
  300. #define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02
  301. #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03
  302. /* ipv6 link local addr type */
  303. #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01
  304. #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02
  305. /* ipv6 router addr type */
  306. #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01
  307. #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02
  308. #define ISCSI_IFACE_TYPE_IPV4 0x01
  309. #define ISCSI_IFACE_TYPE_IPV6 0x02
  310. #define ISCSI_MAX_VLAN_ID 4095
  311. #define ISCSI_MAX_VLAN_PRIORITY 7
  312. /* iscsi vlan enable/disabled setting */
  313. #define ISCSI_VLAN_DISABLE 0x01
  314. #define ISCSI_VLAN_ENABLE 0x02
  315. /* iSCSI network params */
  316. enum iscsi_net_param {
  317. ISCSI_NET_PARAM_IPV4_ADDR = 1,
  318. ISCSI_NET_PARAM_IPV4_SUBNET = 2,
  319. ISCSI_NET_PARAM_IPV4_GW = 3,
  320. ISCSI_NET_PARAM_IPV4_BOOTPROTO = 4,
  321. ISCSI_NET_PARAM_MAC = 5,
  322. ISCSI_NET_PARAM_IPV6_LINKLOCAL = 6,
  323. ISCSI_NET_PARAM_IPV6_ADDR = 7,
  324. ISCSI_NET_PARAM_IPV6_ROUTER = 8,
  325. ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG = 9,
  326. ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG = 10,
  327. ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG = 11,
  328. ISCSI_NET_PARAM_IFACE_ENABLE = 12,
  329. ISCSI_NET_PARAM_VLAN_ID = 13,
  330. ISCSI_NET_PARAM_VLAN_PRIORITY = 14,
  331. ISCSI_NET_PARAM_VLAN_ENABLED = 15,
  332. ISCSI_NET_PARAM_VLAN_TAG = 16,
  333. ISCSI_NET_PARAM_IFACE_TYPE = 17,
  334. ISCSI_NET_PARAM_IFACE_NAME = 18,
  335. ISCSI_NET_PARAM_MTU = 19,
  336. ISCSI_NET_PARAM_PORT = 20,
  337. };
  338. enum iscsi_conn_state {
  339. ISCSI_CONN_STATE_FREE,
  340. ISCSI_CONN_STATE_XPT_WAIT,
  341. ISCSI_CONN_STATE_IN_LOGIN,
  342. ISCSI_CONN_STATE_LOGGED_IN,
  343. ISCSI_CONN_STATE_IN_LOGOUT,
  344. ISCSI_CONN_STATE_LOGOUT_REQUESTED,
  345. ISCSI_CONN_STATE_CLEANUP_WAIT,
  346. };
  347. /*
  348. * Common error codes
  349. */
  350. enum iscsi_err {
  351. ISCSI_OK = 0,
  352. ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
  353. ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
  354. ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
  355. ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
  356. ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
  357. ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
  358. ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
  359. ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
  360. ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
  361. ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
  362. ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
  363. ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
  364. ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
  365. ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
  366. ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
  367. ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
  368. ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
  369. ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
  370. ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
  371. ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
  372. ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21,
  373. };
  374. /*
  375. * iSCSI Parameters (RFC3720)
  376. */
  377. enum iscsi_param {
  378. /* passed in using netlink set param */
  379. ISCSI_PARAM_MAX_RECV_DLENGTH,
  380. ISCSI_PARAM_MAX_XMIT_DLENGTH,
  381. ISCSI_PARAM_HDRDGST_EN,
  382. ISCSI_PARAM_DATADGST_EN,
  383. ISCSI_PARAM_INITIAL_R2T_EN,
  384. ISCSI_PARAM_MAX_R2T,
  385. ISCSI_PARAM_IMM_DATA_EN,
  386. ISCSI_PARAM_FIRST_BURST,
  387. ISCSI_PARAM_MAX_BURST,
  388. ISCSI_PARAM_PDU_INORDER_EN,
  389. ISCSI_PARAM_DATASEQ_INORDER_EN,
  390. ISCSI_PARAM_ERL,
  391. ISCSI_PARAM_IFMARKER_EN,
  392. ISCSI_PARAM_OFMARKER_EN,
  393. ISCSI_PARAM_EXP_STATSN,
  394. ISCSI_PARAM_TARGET_NAME,
  395. ISCSI_PARAM_TPGT,
  396. ISCSI_PARAM_PERSISTENT_ADDRESS,
  397. ISCSI_PARAM_PERSISTENT_PORT,
  398. ISCSI_PARAM_SESS_RECOVERY_TMO,
  399. /* passed in through bind conn using transport_fd */
  400. ISCSI_PARAM_CONN_PORT,
  401. ISCSI_PARAM_CONN_ADDRESS,
  402. ISCSI_PARAM_USERNAME,
  403. ISCSI_PARAM_USERNAME_IN,
  404. ISCSI_PARAM_PASSWORD,
  405. ISCSI_PARAM_PASSWORD_IN,
  406. ISCSI_PARAM_FAST_ABORT,
  407. ISCSI_PARAM_ABORT_TMO,
  408. ISCSI_PARAM_LU_RESET_TMO,
  409. ISCSI_PARAM_HOST_RESET_TMO,
  410. ISCSI_PARAM_PING_TMO,
  411. ISCSI_PARAM_RECV_TMO,
  412. ISCSI_PARAM_IFACE_NAME,
  413. ISCSI_PARAM_ISID,
  414. ISCSI_PARAM_INITIATOR_NAME,
  415. ISCSI_PARAM_TGT_RESET_TMO,
  416. ISCSI_PARAM_TARGET_ALIAS,
  417. ISCSI_PARAM_CHAP_IN_IDX,
  418. ISCSI_PARAM_CHAP_OUT_IDX,
  419. /* must always be last */
  420. ISCSI_PARAM_MAX,
  421. };
  422. /* iSCSI HBA params */
  423. enum iscsi_host_param {
  424. ISCSI_HOST_PARAM_HWADDRESS,
  425. ISCSI_HOST_PARAM_INITIATOR_NAME,
  426. ISCSI_HOST_PARAM_NETDEV_NAME,
  427. ISCSI_HOST_PARAM_IPADDRESS,
  428. ISCSI_HOST_PARAM_PORT_STATE,
  429. ISCSI_HOST_PARAM_PORT_SPEED,
  430. ISCSI_HOST_PARAM_MAX,
  431. };
  432. /* iSCSI port Speed */
  433. enum iscsi_port_speed {
  434. ISCSI_PORT_SPEED_UNKNOWN = 0x1,
  435. ISCSI_PORT_SPEED_10MBPS = 0x2,
  436. ISCSI_PORT_SPEED_100MBPS = 0x4,
  437. ISCSI_PORT_SPEED_1GBPS = 0x8,
  438. ISCSI_PORT_SPEED_10GBPS = 0x10,
  439. };
  440. /* iSCSI port state */
  441. enum iscsi_port_state {
  442. ISCSI_PORT_STATE_DOWN = 0x1,
  443. ISCSI_PORT_STATE_UP = 0x2,
  444. };
  445. /* iSCSI PING status/error code */
  446. enum iscsi_ping_status_code {
  447. ISCSI_PING_SUCCESS = 0,
  448. ISCSI_PING_FW_DISABLED = 0x1,
  449. ISCSI_PING_IPADDR_INVALID = 0x2,
  450. ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID = 0x3,
  451. ISCSI_PING_TIMEOUT = 0x4,
  452. ISCSI_PING_INVALID_DEST_ADDR = 0x5,
  453. ISCSI_PING_OVERSIZE_PACKET = 0x6,
  454. ISCSI_PING_ICMP_ERROR = 0x7,
  455. ISCSI_PING_MAX_REQ_EXCEEDED = 0x8,
  456. ISCSI_PING_NO_ARP_RECEIVED = 0x9,
  457. };
  458. #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
  459. #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
  460. /*
  461. * These flags presents iSCSI Data-Path capabilities.
  462. */
  463. #define CAP_RECOVERY_L0 0x1
  464. #define CAP_RECOVERY_L1 0x2
  465. #define CAP_RECOVERY_L2 0x4
  466. #define CAP_MULTI_R2T 0x8
  467. #define CAP_HDRDGST 0x10
  468. #define CAP_DATADGST 0x20
  469. #define CAP_MULTI_CONN 0x40
  470. #define CAP_TEXT_NEGO 0x80
  471. #define CAP_MARKERS 0x100
  472. #define CAP_FW_DB 0x200
  473. #define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
  474. #define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
  475. #define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
  476. #define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
  477. and verification */
  478. #define CAP_LOGIN_OFFLOAD 0x4000 /* offload session login */
  479. /*
  480. * These flags describes reason of stop_conn() call
  481. */
  482. #define STOP_CONN_TERM 0x1
  483. #define STOP_CONN_SUSPEND 0x2
  484. #define STOP_CONN_RECOVER 0x3
  485. #define ISCSI_STATS_CUSTOM_MAX 32
  486. #define ISCSI_STATS_CUSTOM_DESC_MAX 64
  487. struct iscsi_stats_custom {
  488. char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
  489. uint64_t value;
  490. };
  491. /*
  492. * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
  493. *
  494. * Note: this structure contains counters collected on per-connection basis.
  495. */
  496. struct iscsi_stats {
  497. /* octets */
  498. uint64_t txdata_octets;
  499. uint64_t rxdata_octets;
  500. /* xmit pdus */
  501. uint32_t noptx_pdus;
  502. uint32_t scsicmd_pdus;
  503. uint32_t tmfcmd_pdus;
  504. uint32_t login_pdus;
  505. uint32_t text_pdus;
  506. uint32_t dataout_pdus;
  507. uint32_t logout_pdus;
  508. uint32_t snack_pdus;
  509. /* recv pdus */
  510. uint32_t noprx_pdus;
  511. uint32_t scsirsp_pdus;
  512. uint32_t tmfrsp_pdus;
  513. uint32_t textrsp_pdus;
  514. uint32_t datain_pdus;
  515. uint32_t logoutrsp_pdus;
  516. uint32_t r2t_pdus;
  517. uint32_t async_pdus;
  518. uint32_t rjt_pdus;
  519. /* errors */
  520. uint32_t digest_err;
  521. uint32_t timeout_err;
  522. /*
  523. * iSCSI Custom Statistics support, i.e. Transport could
  524. * extend existing MIB statistics with its own specific statistics
  525. * up to ISCSI_STATS_CUSTOM_MAX
  526. */
  527. uint32_t custom_length;
  528. struct iscsi_stats_custom custom[0]
  529. __attribute__ ((aligned (sizeof(uint64_t))));
  530. };
  531. enum chap_type_e {
  532. CHAP_TYPE_OUT,
  533. CHAP_TYPE_IN,
  534. };
  535. #define ISCSI_CHAP_AUTH_NAME_MAX_LEN 256
  536. #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256
  537. struct iscsi_chap_rec {
  538. uint16_t chap_tbl_idx;
  539. enum chap_type_e chap_type;
  540. char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
  541. uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
  542. uint8_t password_length;
  543. };
  544. #endif