iscsi_if.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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. /* up events */
  55. ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
  56. ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
  57. ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
  58. ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
  59. ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
  60. ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
  61. ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
  62. ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
  63. };
  64. enum iscsi_tgt_dscvr {
  65. ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
  66. ISCSI_TGT_DSCVR_ISNS = 2,
  67. ISCSI_TGT_DSCVR_SLP = 3,
  68. };
  69. struct iscsi_uevent {
  70. uint32_t type; /* k/u events type */
  71. uint32_t iferror; /* carries interface or resource errors */
  72. uint64_t transport_handle;
  73. union {
  74. /* messages u -> k */
  75. struct msg_create_session {
  76. uint32_t initial_cmdsn;
  77. uint16_t cmds_max;
  78. uint16_t queue_depth;
  79. } c_session;
  80. struct msg_create_bound_session {
  81. uint64_t ep_handle;
  82. uint32_t initial_cmdsn;
  83. uint16_t cmds_max;
  84. uint16_t queue_depth;
  85. } c_bound_session;
  86. struct msg_destroy_session {
  87. uint32_t sid;
  88. } d_session;
  89. struct msg_create_conn {
  90. uint32_t sid;
  91. uint32_t cid;
  92. } c_conn;
  93. struct msg_bind_conn {
  94. uint32_t sid;
  95. uint32_t cid;
  96. uint64_t transport_eph;
  97. uint32_t is_leading;
  98. } b_conn;
  99. struct msg_destroy_conn {
  100. uint32_t sid;
  101. uint32_t cid;
  102. } d_conn;
  103. struct msg_send_pdu {
  104. uint32_t sid;
  105. uint32_t cid;
  106. uint32_t hdr_size;
  107. uint32_t data_size;
  108. } send_pdu;
  109. struct msg_set_param {
  110. uint32_t sid;
  111. uint32_t cid;
  112. uint32_t param; /* enum iscsi_param */
  113. uint32_t len;
  114. } set_param;
  115. struct msg_start_conn {
  116. uint32_t sid;
  117. uint32_t cid;
  118. } start_conn;
  119. struct msg_stop_conn {
  120. uint32_t sid;
  121. uint32_t cid;
  122. uint64_t conn_handle;
  123. uint32_t flag;
  124. } stop_conn;
  125. struct msg_get_stats {
  126. uint32_t sid;
  127. uint32_t cid;
  128. } get_stats;
  129. struct msg_transport_connect {
  130. uint32_t non_blocking;
  131. } ep_connect;
  132. struct msg_transport_connect_through_host {
  133. uint32_t host_no;
  134. uint32_t non_blocking;
  135. } ep_connect_through_host;
  136. struct msg_transport_poll {
  137. uint64_t ep_handle;
  138. uint32_t timeout_ms;
  139. } ep_poll;
  140. struct msg_transport_disconnect {
  141. uint64_t ep_handle;
  142. } ep_disconnect;
  143. struct msg_tgt_dscvr {
  144. enum iscsi_tgt_dscvr type;
  145. uint32_t host_no;
  146. /*
  147. * enable = 1 to establish a new connection
  148. * with the server. enable = 0 to disconnect
  149. * from the server. Used primarily to switch
  150. * from one iSNS server to another.
  151. */
  152. uint32_t enable;
  153. } tgt_dscvr;
  154. struct msg_set_host_param {
  155. uint32_t host_no;
  156. uint32_t param; /* enum iscsi_host_param */
  157. uint32_t len;
  158. } set_host_param;
  159. struct msg_set_path {
  160. uint32_t host_no;
  161. } set_path;
  162. struct msg_set_iface_params {
  163. uint32_t host_no;
  164. uint32_t count;
  165. } set_iface_params;
  166. } u;
  167. union {
  168. /* messages k -> u */
  169. int retcode;
  170. struct msg_create_session_ret {
  171. uint32_t sid;
  172. uint32_t host_no;
  173. } c_session_ret;
  174. struct msg_create_conn_ret {
  175. uint32_t sid;
  176. uint32_t cid;
  177. } c_conn_ret;
  178. struct msg_unbind_session {
  179. uint32_t sid;
  180. uint32_t host_no;
  181. } unbind_session;
  182. struct msg_recv_req {
  183. uint32_t sid;
  184. uint32_t cid;
  185. uint64_t recv_handle;
  186. } recv_req;
  187. struct msg_conn_error {
  188. uint32_t sid;
  189. uint32_t cid;
  190. uint32_t error; /* enum iscsi_err */
  191. } connerror;
  192. struct msg_session_destroyed {
  193. uint32_t host_no;
  194. uint32_t sid;
  195. } d_session;
  196. struct msg_transport_connect_ret {
  197. uint64_t handle;
  198. } ep_connect_ret;
  199. struct msg_req_path {
  200. uint32_t host_no;
  201. } req_path;
  202. struct msg_notify_if_down {
  203. uint32_t host_no;
  204. } notify_if_down;
  205. } r;
  206. } __attribute__ ((aligned (sizeof(uint64_t))));
  207. enum iscsi_param_type {
  208. ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */
  209. ISCSI_HOST_PARAM, /* iscsi_host_param */
  210. ISCSI_NET_PARAM, /* iscsi_net_param */
  211. };
  212. struct iscsi_iface_param_info {
  213. uint32_t iface_num; /* iface number, 0 - n */
  214. uint32_t len; /* Actual length of the param */
  215. uint16_t param; /* iscsi param value */
  216. uint8_t iface_type; /* IPv4 or IPv6 */
  217. uint8_t param_type; /* iscsi_param_type */
  218. uint8_t value[0]; /* length sized value follows */
  219. } __packed;
  220. /*
  221. * To keep the struct iscsi_uevent size the same for userspace code
  222. * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
  223. * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
  224. * struct iscsi_uevent in the NETLINK_ISCSI message.
  225. */
  226. struct iscsi_path {
  227. uint64_t handle;
  228. uint8_t mac_addr[6];
  229. uint8_t mac_addr_old[6];
  230. uint32_t ip_addr_len; /* 4 or 16 */
  231. union {
  232. struct in_addr v4_addr;
  233. struct in6_addr v6_addr;
  234. } src;
  235. union {
  236. struct in_addr v4_addr;
  237. struct in6_addr v6_addr;
  238. } dst;
  239. uint16_t vlan_id;
  240. uint16_t pmtu;
  241. } __attribute__ ((aligned (sizeof(uint64_t))));
  242. /* iscsi iface enabled/disabled setting */
  243. #define ISCSI_IFACE_DISABLE 0x01
  244. #define ISCSI_IFACE_ENABLE 0x02
  245. /* ipv4 bootproto */
  246. #define ISCSI_BOOTPROTO_STATIC 0x01
  247. #define ISCSI_BOOTPROTO_DHCP 0x02
  248. /* ipv6 addr autoconfig type */
  249. #define ISCSI_IPV6_AUTOCFG_DISABLE 0x01
  250. #define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02
  251. #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03
  252. /* ipv6 link local addr type */
  253. #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01
  254. #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02
  255. /* ipv6 router addr type */
  256. #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01
  257. #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02
  258. #define ISCSI_IFACE_TYPE_IPV4 0x01
  259. #define ISCSI_IFACE_TYPE_IPV6 0x02
  260. /* iSCSI network params */
  261. enum iscsi_net_param {
  262. ISCSI_NET_PARAM_IPV4_ADDR = 1,
  263. ISCSI_NET_PARAM_IPV4_SUBNET = 2,
  264. ISCSI_NET_PARAM_IPV4_GW = 3,
  265. ISCSI_NET_PARAM_IPV4_BOOTPROTO = 4,
  266. ISCSI_NET_PARAM_MAC = 5,
  267. ISCSI_NET_PARAM_IPV6_LINKLOCAL = 6,
  268. ISCSI_NET_PARAM_IPV6_ADDR = 7,
  269. ISCSI_NET_PARAM_IPV6_ROUTER = 8,
  270. ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG = 9,
  271. ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG = 10,
  272. ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG = 11,
  273. ISCSI_NET_PARAM_IFACE_ENABLE = 12,
  274. ISCSI_NET_PARAM_VLAN_ID = 13,
  275. ISCSI_NET_PARAM_IFACE_TYPE = 14,
  276. ISCSI_NET_PARAM_IFACE_NAME = 15,
  277. };
  278. #define ISCSI_NET_IPV4_ADDR (1ULL << ISCSI_NET_PARAM_IPV4_ADDR)
  279. #define ISCSI_NET_IPV4_SUBNET (1ULL << ISCSI_NET_PARAM_IPV4_SUBNET)
  280. #define ISCSI_NET_IPV4_GW (1ULL << ISCSI_NET_PARAM_IPV4_GW)
  281. #define ISCSI_NET_IPV4_BOOTPROTO (1ULL << ISCSI_NET_PARAM_IPV4_BOOTPROTO)
  282. #define ISCSI_NET_MAC (1ULL << ISCSI_NET_PARAM_MAC)
  283. #define ISCSI_NET_IPV6_LINKLOCAL (1ULL << ISCSI_NET_PARAM_IPV6_LINKLOCAL)
  284. #define ISCSI_NET_IPV6_ADDR (1ULL << ISCSI_NET_PARAM_IPV6_ADDR)
  285. #define ISCSI_NET_IPV6_ROUTER (1ULL << ISCSI_NET_PARAM_IPV6_ROUTER)
  286. #define ISCSI_NET_IPV6_ADDR_AUTOCFG \
  287. (1ULL << ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG)
  288. #define ISCSI_NET_IPV6_LINKLOCAL_AUTOCFG \
  289. (1ULL << ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG)
  290. #define ISCSI_NET_IPV6_ROUTER_AUTOCFG \
  291. (1ULL << ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG)
  292. #define ISCSI_NET_IFACE_ENABLE (1ULL << ISCSI_NET_PARAM_IFACE_ENABLE)
  293. #define ISCSI_NET_VLAN_ID (1ULL << ISCSI_NET_PARAM_VLAN_ID)
  294. /*
  295. * Common error codes
  296. */
  297. enum iscsi_err {
  298. ISCSI_OK = 0,
  299. ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
  300. ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
  301. ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
  302. ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
  303. ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
  304. ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
  305. ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
  306. ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
  307. ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
  308. ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
  309. ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
  310. ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
  311. ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
  312. ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
  313. ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
  314. ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
  315. ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
  316. ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
  317. ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
  318. ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
  319. ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21,
  320. };
  321. /*
  322. * iSCSI Parameters (RFC3720)
  323. */
  324. enum iscsi_param {
  325. /* passed in using netlink set param */
  326. ISCSI_PARAM_MAX_RECV_DLENGTH,
  327. ISCSI_PARAM_MAX_XMIT_DLENGTH,
  328. ISCSI_PARAM_HDRDGST_EN,
  329. ISCSI_PARAM_DATADGST_EN,
  330. ISCSI_PARAM_INITIAL_R2T_EN,
  331. ISCSI_PARAM_MAX_R2T,
  332. ISCSI_PARAM_IMM_DATA_EN,
  333. ISCSI_PARAM_FIRST_BURST,
  334. ISCSI_PARAM_MAX_BURST,
  335. ISCSI_PARAM_PDU_INORDER_EN,
  336. ISCSI_PARAM_DATASEQ_INORDER_EN,
  337. ISCSI_PARAM_ERL,
  338. ISCSI_PARAM_IFMARKER_EN,
  339. ISCSI_PARAM_OFMARKER_EN,
  340. ISCSI_PARAM_EXP_STATSN,
  341. ISCSI_PARAM_TARGET_NAME,
  342. ISCSI_PARAM_TPGT,
  343. ISCSI_PARAM_PERSISTENT_ADDRESS,
  344. ISCSI_PARAM_PERSISTENT_PORT,
  345. ISCSI_PARAM_SESS_RECOVERY_TMO,
  346. /* passed in through bind conn using transport_fd */
  347. ISCSI_PARAM_CONN_PORT,
  348. ISCSI_PARAM_CONN_ADDRESS,
  349. ISCSI_PARAM_USERNAME,
  350. ISCSI_PARAM_USERNAME_IN,
  351. ISCSI_PARAM_PASSWORD,
  352. ISCSI_PARAM_PASSWORD_IN,
  353. ISCSI_PARAM_FAST_ABORT,
  354. ISCSI_PARAM_ABORT_TMO,
  355. ISCSI_PARAM_LU_RESET_TMO,
  356. ISCSI_PARAM_HOST_RESET_TMO,
  357. ISCSI_PARAM_PING_TMO,
  358. ISCSI_PARAM_RECV_TMO,
  359. ISCSI_PARAM_IFACE_NAME,
  360. ISCSI_PARAM_ISID,
  361. ISCSI_PARAM_INITIATOR_NAME,
  362. ISCSI_PARAM_TGT_RESET_TMO,
  363. ISCSI_PARAM_TARGET_ALIAS,
  364. /* must always be last */
  365. ISCSI_PARAM_MAX,
  366. };
  367. #define ISCSI_MAX_RECV_DLENGTH (1ULL << ISCSI_PARAM_MAX_RECV_DLENGTH)
  368. #define ISCSI_MAX_XMIT_DLENGTH (1ULL << ISCSI_PARAM_MAX_XMIT_DLENGTH)
  369. #define ISCSI_HDRDGST_EN (1ULL << ISCSI_PARAM_HDRDGST_EN)
  370. #define ISCSI_DATADGST_EN (1ULL << ISCSI_PARAM_DATADGST_EN)
  371. #define ISCSI_INITIAL_R2T_EN (1ULL << ISCSI_PARAM_INITIAL_R2T_EN)
  372. #define ISCSI_MAX_R2T (1ULL << ISCSI_PARAM_MAX_R2T)
  373. #define ISCSI_IMM_DATA_EN (1ULL << ISCSI_PARAM_IMM_DATA_EN)
  374. #define ISCSI_FIRST_BURST (1ULL << ISCSI_PARAM_FIRST_BURST)
  375. #define ISCSI_MAX_BURST (1ULL << ISCSI_PARAM_MAX_BURST)
  376. #define ISCSI_PDU_INORDER_EN (1ULL << ISCSI_PARAM_PDU_INORDER_EN)
  377. #define ISCSI_DATASEQ_INORDER_EN (1ULL << ISCSI_PARAM_DATASEQ_INORDER_EN)
  378. #define ISCSI_ERL (1ULL << ISCSI_PARAM_ERL)
  379. #define ISCSI_IFMARKER_EN (1ULL << ISCSI_PARAM_IFMARKER_EN)
  380. #define ISCSI_OFMARKER_EN (1ULL << ISCSI_PARAM_OFMARKER_EN)
  381. #define ISCSI_EXP_STATSN (1ULL << ISCSI_PARAM_EXP_STATSN)
  382. #define ISCSI_TARGET_NAME (1ULL << ISCSI_PARAM_TARGET_NAME)
  383. #define ISCSI_TPGT (1ULL << ISCSI_PARAM_TPGT)
  384. #define ISCSI_PERSISTENT_ADDRESS (1ULL << ISCSI_PARAM_PERSISTENT_ADDRESS)
  385. #define ISCSI_PERSISTENT_PORT (1ULL << ISCSI_PARAM_PERSISTENT_PORT)
  386. #define ISCSI_SESS_RECOVERY_TMO (1ULL << ISCSI_PARAM_SESS_RECOVERY_TMO)
  387. #define ISCSI_CONN_PORT (1ULL << ISCSI_PARAM_CONN_PORT)
  388. #define ISCSI_CONN_ADDRESS (1ULL << ISCSI_PARAM_CONN_ADDRESS)
  389. #define ISCSI_USERNAME (1ULL << ISCSI_PARAM_USERNAME)
  390. #define ISCSI_USERNAME_IN (1ULL << ISCSI_PARAM_USERNAME_IN)
  391. #define ISCSI_PASSWORD (1ULL << ISCSI_PARAM_PASSWORD)
  392. #define ISCSI_PASSWORD_IN (1ULL << ISCSI_PARAM_PASSWORD_IN)
  393. #define ISCSI_FAST_ABORT (1ULL << ISCSI_PARAM_FAST_ABORT)
  394. #define ISCSI_ABORT_TMO (1ULL << ISCSI_PARAM_ABORT_TMO)
  395. #define ISCSI_LU_RESET_TMO (1ULL << ISCSI_PARAM_LU_RESET_TMO)
  396. #define ISCSI_HOST_RESET_TMO (1ULL << ISCSI_PARAM_HOST_RESET_TMO)
  397. #define ISCSI_PING_TMO (1ULL << ISCSI_PARAM_PING_TMO)
  398. #define ISCSI_RECV_TMO (1ULL << ISCSI_PARAM_RECV_TMO)
  399. #define ISCSI_IFACE_NAME (1ULL << ISCSI_PARAM_IFACE_NAME)
  400. #define ISCSI_ISID (1ULL << ISCSI_PARAM_ISID)
  401. #define ISCSI_INITIATOR_NAME (1ULL << ISCSI_PARAM_INITIATOR_NAME)
  402. #define ISCSI_TGT_RESET_TMO (1ULL << ISCSI_PARAM_TGT_RESET_TMO)
  403. #define ISCSI_TARGET_ALIAS (1ULL << ISCSI_PARAM_TARGET_ALIAS)
  404. /* iSCSI HBA params */
  405. enum iscsi_host_param {
  406. ISCSI_HOST_PARAM_HWADDRESS,
  407. ISCSI_HOST_PARAM_INITIATOR_NAME,
  408. ISCSI_HOST_PARAM_NETDEV_NAME,
  409. ISCSI_HOST_PARAM_IPADDRESS,
  410. ISCSI_HOST_PARAM_MAX,
  411. };
  412. #define ISCSI_HOST_HWADDRESS (1ULL << ISCSI_HOST_PARAM_HWADDRESS)
  413. #define ISCSI_HOST_INITIATOR_NAME (1ULL << ISCSI_HOST_PARAM_INITIATOR_NAME)
  414. #define ISCSI_HOST_NETDEV_NAME (1ULL << ISCSI_HOST_PARAM_NETDEV_NAME)
  415. #define ISCSI_HOST_IPADDRESS (1ULL << ISCSI_HOST_PARAM_IPADDRESS)
  416. #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
  417. #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
  418. /*
  419. * These flags presents iSCSI Data-Path capabilities.
  420. */
  421. #define CAP_RECOVERY_L0 0x1
  422. #define CAP_RECOVERY_L1 0x2
  423. #define CAP_RECOVERY_L2 0x4
  424. #define CAP_MULTI_R2T 0x8
  425. #define CAP_HDRDGST 0x10
  426. #define CAP_DATADGST 0x20
  427. #define CAP_MULTI_CONN 0x40
  428. #define CAP_TEXT_NEGO 0x80
  429. #define CAP_MARKERS 0x100
  430. #define CAP_FW_DB 0x200
  431. #define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
  432. #define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
  433. #define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
  434. #define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
  435. and verification */
  436. /*
  437. * These flags describes reason of stop_conn() call
  438. */
  439. #define STOP_CONN_TERM 0x1
  440. #define STOP_CONN_SUSPEND 0x2
  441. #define STOP_CONN_RECOVER 0x3
  442. #define ISCSI_STATS_CUSTOM_MAX 32
  443. #define ISCSI_STATS_CUSTOM_DESC_MAX 64
  444. struct iscsi_stats_custom {
  445. char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
  446. uint64_t value;
  447. };
  448. /*
  449. * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
  450. *
  451. * Note: this structure contains counters collected on per-connection basis.
  452. */
  453. struct iscsi_stats {
  454. /* octets */
  455. uint64_t txdata_octets;
  456. uint64_t rxdata_octets;
  457. /* xmit pdus */
  458. uint32_t noptx_pdus;
  459. uint32_t scsicmd_pdus;
  460. uint32_t tmfcmd_pdus;
  461. uint32_t login_pdus;
  462. uint32_t text_pdus;
  463. uint32_t dataout_pdus;
  464. uint32_t logout_pdus;
  465. uint32_t snack_pdus;
  466. /* recv pdus */
  467. uint32_t noprx_pdus;
  468. uint32_t scsirsp_pdus;
  469. uint32_t tmfrsp_pdus;
  470. uint32_t textrsp_pdus;
  471. uint32_t datain_pdus;
  472. uint32_t logoutrsp_pdus;
  473. uint32_t r2t_pdus;
  474. uint32_t async_pdus;
  475. uint32_t rjt_pdus;
  476. /* errors */
  477. uint32_t digest_err;
  478. uint32_t timeout_err;
  479. /*
  480. * iSCSI Custom Statistics support, i.e. Transport could
  481. * extend existing MIB statistics with its own specific statistics
  482. * up to ISCSI_STATS_CUSTOM_MAX
  483. */
  484. uint32_t custom_length;
  485. struct iscsi_stats_custom custom[0]
  486. __attribute__ ((aligned (sizeof(uint64_t))));
  487. };
  488. #endif