iscsi_if.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  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. 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. /* up events */
  65. ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
  66. ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
  67. ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
  68. ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
  69. ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
  70. ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
  71. ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
  72. ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
  73. ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9,
  74. ISCSI_KEVENT_HOST_EVENT = KEVENT_BASE + 10,
  75. ISCSI_KEVENT_PING_COMP = KEVENT_BASE + 11,
  76. };
  77. enum iscsi_tgt_dscvr {
  78. ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
  79. ISCSI_TGT_DSCVR_ISNS = 2,
  80. ISCSI_TGT_DSCVR_SLP = 3,
  81. };
  82. enum iscsi_host_event_code {
  83. ISCSI_EVENT_LINKUP = 1,
  84. ISCSI_EVENT_LINKDOWN,
  85. /* must always be last */
  86. ISCSI_EVENT_MAX,
  87. };
  88. struct iscsi_uevent {
  89. uint32_t type; /* k/u events type */
  90. uint32_t iferror; /* carries interface or resource errors */
  91. uint64_t transport_handle;
  92. union {
  93. /* messages u -> k */
  94. struct msg_create_session {
  95. uint32_t initial_cmdsn;
  96. uint16_t cmds_max;
  97. uint16_t queue_depth;
  98. } c_session;
  99. struct msg_create_bound_session {
  100. uint64_t ep_handle;
  101. uint32_t initial_cmdsn;
  102. uint16_t cmds_max;
  103. uint16_t queue_depth;
  104. } c_bound_session;
  105. struct msg_destroy_session {
  106. uint32_t sid;
  107. } d_session;
  108. struct msg_create_conn {
  109. uint32_t sid;
  110. uint32_t cid;
  111. } c_conn;
  112. struct msg_bind_conn {
  113. uint32_t sid;
  114. uint32_t cid;
  115. uint64_t transport_eph;
  116. uint32_t is_leading;
  117. } b_conn;
  118. struct msg_destroy_conn {
  119. uint32_t sid;
  120. uint32_t cid;
  121. } d_conn;
  122. struct msg_send_pdu {
  123. uint32_t sid;
  124. uint32_t cid;
  125. uint32_t hdr_size;
  126. uint32_t data_size;
  127. } send_pdu;
  128. struct msg_set_param {
  129. uint32_t sid;
  130. uint32_t cid;
  131. uint32_t param; /* enum iscsi_param */
  132. uint32_t len;
  133. } set_param;
  134. struct msg_start_conn {
  135. uint32_t sid;
  136. uint32_t cid;
  137. } start_conn;
  138. struct msg_stop_conn {
  139. uint32_t sid;
  140. uint32_t cid;
  141. uint64_t conn_handle;
  142. uint32_t flag;
  143. } stop_conn;
  144. struct msg_get_stats {
  145. uint32_t sid;
  146. uint32_t cid;
  147. } get_stats;
  148. struct msg_transport_connect {
  149. uint32_t non_blocking;
  150. } ep_connect;
  151. struct msg_transport_connect_through_host {
  152. uint32_t host_no;
  153. uint32_t non_blocking;
  154. } ep_connect_through_host;
  155. struct msg_transport_poll {
  156. uint64_t ep_handle;
  157. uint32_t timeout_ms;
  158. } ep_poll;
  159. struct msg_transport_disconnect {
  160. uint64_t ep_handle;
  161. } ep_disconnect;
  162. struct msg_tgt_dscvr {
  163. enum iscsi_tgt_dscvr type;
  164. uint32_t host_no;
  165. /*
  166. * enable = 1 to establish a new connection
  167. * with the server. enable = 0 to disconnect
  168. * from the server. Used primarily to switch
  169. * from one iSNS server to another.
  170. */
  171. uint32_t enable;
  172. } tgt_dscvr;
  173. struct msg_set_host_param {
  174. uint32_t host_no;
  175. uint32_t param; /* enum iscsi_host_param */
  176. uint32_t len;
  177. } set_host_param;
  178. struct msg_set_path {
  179. uint32_t host_no;
  180. } set_path;
  181. struct msg_set_iface_params {
  182. uint32_t host_no;
  183. uint32_t count;
  184. } set_iface_params;
  185. struct msg_iscsi_ping {
  186. uint32_t host_no;
  187. uint32_t iface_num;
  188. uint32_t iface_type;
  189. uint32_t payload_size;
  190. uint32_t pid; /* unique ping id associated
  191. with each ping request */
  192. } iscsi_ping;
  193. struct msg_get_chap {
  194. uint32_t host_no;
  195. uint32_t num_entries; /* number of CHAP entries
  196. * on request, number of
  197. * valid CHAP entries on
  198. * response */
  199. uint16_t chap_tbl_idx;
  200. } get_chap;
  201. struct msg_delete_chap {
  202. uint32_t host_no;
  203. uint16_t chap_tbl_idx;
  204. } delete_chap;
  205. struct msg_set_flashnode_param {
  206. uint32_t host_no;
  207. uint32_t flashnode_idx;
  208. uint32_t count;
  209. } set_flashnode;
  210. struct msg_new_flashnode {
  211. uint32_t host_no;
  212. uint32_t len;
  213. } new_flashnode;
  214. struct msg_del_flashnode {
  215. uint32_t host_no;
  216. uint32_t flashnode_idx;
  217. } del_flashnode;
  218. struct msg_login_flashnode {
  219. uint32_t host_no;
  220. uint32_t flashnode_idx;
  221. } login_flashnode;
  222. struct msg_logout_flashnode {
  223. uint32_t host_no;
  224. uint32_t flashnode_idx;
  225. } logout_flashnode;
  226. struct msg_logout_flashnode_sid {
  227. uint32_t host_no;
  228. uint32_t sid;
  229. } logout_flashnode_sid;
  230. } u;
  231. union {
  232. /* messages k -> u */
  233. int retcode;
  234. struct msg_create_session_ret {
  235. uint32_t sid;
  236. uint32_t host_no;
  237. } c_session_ret;
  238. struct msg_create_conn_ret {
  239. uint32_t sid;
  240. uint32_t cid;
  241. } c_conn_ret;
  242. struct msg_unbind_session {
  243. uint32_t sid;
  244. uint32_t host_no;
  245. } unbind_session;
  246. struct msg_recv_req {
  247. uint32_t sid;
  248. uint32_t cid;
  249. uint64_t recv_handle;
  250. } recv_req;
  251. struct msg_conn_login {
  252. uint32_t sid;
  253. uint32_t cid;
  254. uint32_t state; /* enum iscsi_conn_state */
  255. } conn_login;
  256. struct msg_conn_error {
  257. uint32_t sid;
  258. uint32_t cid;
  259. uint32_t error; /* enum iscsi_err */
  260. } connerror;
  261. struct msg_session_destroyed {
  262. uint32_t host_no;
  263. uint32_t sid;
  264. } d_session;
  265. struct msg_transport_connect_ret {
  266. uint64_t handle;
  267. } ep_connect_ret;
  268. struct msg_req_path {
  269. uint32_t host_no;
  270. } req_path;
  271. struct msg_notify_if_down {
  272. uint32_t host_no;
  273. } notify_if_down;
  274. struct msg_host_event {
  275. uint32_t host_no;
  276. uint32_t data_size;
  277. enum iscsi_host_event_code code;
  278. } host_event;
  279. struct msg_ping_comp {
  280. uint32_t host_no;
  281. uint32_t status; /* enum
  282. * iscsi_ping_status_code */
  283. uint32_t pid; /* unique ping id associated
  284. with each ping request */
  285. uint32_t data_size;
  286. } ping_comp;
  287. struct msg_new_flashnode_ret {
  288. uint32_t flashnode_idx;
  289. } new_flashnode_ret;
  290. } r;
  291. } __attribute__ ((aligned (sizeof(uint64_t))));
  292. enum iscsi_param_type {
  293. ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */
  294. ISCSI_HOST_PARAM, /* iscsi_host_param */
  295. ISCSI_NET_PARAM, /* iscsi_net_param */
  296. ISCSI_FLASHNODE_PARAM, /* iscsi_flashnode_param */
  297. ISCSI_CHAP_PARAM, /* iscsi_chap_param */
  298. };
  299. /* structure for minimalist usecase */
  300. struct iscsi_param_info {
  301. uint32_t len; /* Actual length of the param value */
  302. uint16_t param; /* iscsi param */
  303. uint8_t value[0]; /* length sized value follows */
  304. } __packed;
  305. struct iscsi_iface_param_info {
  306. uint32_t iface_num; /* iface number, 0 - n */
  307. uint32_t len; /* Actual length of the param */
  308. uint16_t param; /* iscsi param value */
  309. uint8_t iface_type; /* IPv4 or IPv6 */
  310. uint8_t param_type; /* iscsi_param_type */
  311. uint8_t value[0]; /* length sized value follows */
  312. } __packed;
  313. /*
  314. * To keep the struct iscsi_uevent size the same for userspace code
  315. * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
  316. * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
  317. * struct iscsi_uevent in the NETLINK_ISCSI message.
  318. */
  319. struct iscsi_path {
  320. uint64_t handle;
  321. uint8_t mac_addr[6];
  322. uint8_t mac_addr_old[6];
  323. uint32_t ip_addr_len; /* 4 or 16 */
  324. union {
  325. struct in_addr v4_addr;
  326. struct in6_addr v6_addr;
  327. } src;
  328. union {
  329. struct in_addr v4_addr;
  330. struct in6_addr v6_addr;
  331. } dst;
  332. uint16_t vlan_id;
  333. uint16_t pmtu;
  334. } __attribute__ ((aligned (sizeof(uint64_t))));
  335. /* iscsi iface enabled/disabled setting */
  336. #define ISCSI_IFACE_DISABLE 0x01
  337. #define ISCSI_IFACE_ENABLE 0x02
  338. /* ipv4 bootproto */
  339. #define ISCSI_BOOTPROTO_STATIC 0x01
  340. #define ISCSI_BOOTPROTO_DHCP 0x02
  341. /* ipv6 addr autoconfig type */
  342. #define ISCSI_IPV6_AUTOCFG_DISABLE 0x01
  343. #define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02
  344. #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03
  345. /* ipv6 link local addr type */
  346. #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01
  347. #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02
  348. /* ipv6 router addr type */
  349. #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01
  350. #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02
  351. #define ISCSI_IFACE_TYPE_IPV4 0x01
  352. #define ISCSI_IFACE_TYPE_IPV6 0x02
  353. #define ISCSI_MAX_VLAN_ID 4095
  354. #define ISCSI_MAX_VLAN_PRIORITY 7
  355. /* iscsi vlan enable/disabled setting */
  356. #define ISCSI_VLAN_DISABLE 0x01
  357. #define ISCSI_VLAN_ENABLE 0x02
  358. /* iSCSI network params */
  359. enum iscsi_net_param {
  360. ISCSI_NET_PARAM_IPV4_ADDR = 1,
  361. ISCSI_NET_PARAM_IPV4_SUBNET = 2,
  362. ISCSI_NET_PARAM_IPV4_GW = 3,
  363. ISCSI_NET_PARAM_IPV4_BOOTPROTO = 4,
  364. ISCSI_NET_PARAM_MAC = 5,
  365. ISCSI_NET_PARAM_IPV6_LINKLOCAL = 6,
  366. ISCSI_NET_PARAM_IPV6_ADDR = 7,
  367. ISCSI_NET_PARAM_IPV6_ROUTER = 8,
  368. ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG = 9,
  369. ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG = 10,
  370. ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG = 11,
  371. ISCSI_NET_PARAM_IFACE_ENABLE = 12,
  372. ISCSI_NET_PARAM_VLAN_ID = 13,
  373. ISCSI_NET_PARAM_VLAN_PRIORITY = 14,
  374. ISCSI_NET_PARAM_VLAN_ENABLED = 15,
  375. ISCSI_NET_PARAM_VLAN_TAG = 16,
  376. ISCSI_NET_PARAM_IFACE_TYPE = 17,
  377. ISCSI_NET_PARAM_IFACE_NAME = 18,
  378. ISCSI_NET_PARAM_MTU = 19,
  379. ISCSI_NET_PARAM_PORT = 20,
  380. };
  381. enum iscsi_conn_state {
  382. ISCSI_CONN_STATE_FREE,
  383. ISCSI_CONN_STATE_XPT_WAIT,
  384. ISCSI_CONN_STATE_IN_LOGIN,
  385. ISCSI_CONN_STATE_LOGGED_IN,
  386. ISCSI_CONN_STATE_IN_LOGOUT,
  387. ISCSI_CONN_STATE_LOGOUT_REQUESTED,
  388. ISCSI_CONN_STATE_CLEANUP_WAIT,
  389. };
  390. /*
  391. * Common error codes
  392. */
  393. enum iscsi_err {
  394. ISCSI_OK = 0,
  395. ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
  396. ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
  397. ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
  398. ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
  399. ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
  400. ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
  401. ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
  402. ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
  403. ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
  404. ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
  405. ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
  406. ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
  407. ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
  408. ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
  409. ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
  410. ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
  411. ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
  412. ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
  413. ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
  414. ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
  415. ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21,
  416. };
  417. /*
  418. * iSCSI Parameters (RFC3720)
  419. */
  420. enum iscsi_param {
  421. /* passed in using netlink set param */
  422. ISCSI_PARAM_MAX_RECV_DLENGTH,
  423. ISCSI_PARAM_MAX_XMIT_DLENGTH,
  424. ISCSI_PARAM_HDRDGST_EN,
  425. ISCSI_PARAM_DATADGST_EN,
  426. ISCSI_PARAM_INITIAL_R2T_EN,
  427. ISCSI_PARAM_MAX_R2T,
  428. ISCSI_PARAM_IMM_DATA_EN,
  429. ISCSI_PARAM_FIRST_BURST,
  430. ISCSI_PARAM_MAX_BURST,
  431. ISCSI_PARAM_PDU_INORDER_EN,
  432. ISCSI_PARAM_DATASEQ_INORDER_EN,
  433. ISCSI_PARAM_ERL,
  434. ISCSI_PARAM_IFMARKER_EN,
  435. ISCSI_PARAM_OFMARKER_EN,
  436. ISCSI_PARAM_EXP_STATSN,
  437. ISCSI_PARAM_TARGET_NAME,
  438. ISCSI_PARAM_TPGT,
  439. ISCSI_PARAM_PERSISTENT_ADDRESS,
  440. ISCSI_PARAM_PERSISTENT_PORT,
  441. ISCSI_PARAM_SESS_RECOVERY_TMO,
  442. /* passed in through bind conn using transport_fd */
  443. ISCSI_PARAM_CONN_PORT,
  444. ISCSI_PARAM_CONN_ADDRESS,
  445. ISCSI_PARAM_USERNAME,
  446. ISCSI_PARAM_USERNAME_IN,
  447. ISCSI_PARAM_PASSWORD,
  448. ISCSI_PARAM_PASSWORD_IN,
  449. ISCSI_PARAM_FAST_ABORT,
  450. ISCSI_PARAM_ABORT_TMO,
  451. ISCSI_PARAM_LU_RESET_TMO,
  452. ISCSI_PARAM_HOST_RESET_TMO,
  453. ISCSI_PARAM_PING_TMO,
  454. ISCSI_PARAM_RECV_TMO,
  455. ISCSI_PARAM_IFACE_NAME,
  456. ISCSI_PARAM_ISID,
  457. ISCSI_PARAM_INITIATOR_NAME,
  458. ISCSI_PARAM_TGT_RESET_TMO,
  459. ISCSI_PARAM_TARGET_ALIAS,
  460. ISCSI_PARAM_CHAP_IN_IDX,
  461. ISCSI_PARAM_CHAP_OUT_IDX,
  462. ISCSI_PARAM_BOOT_ROOT,
  463. ISCSI_PARAM_BOOT_NIC,
  464. ISCSI_PARAM_BOOT_TARGET,
  465. ISCSI_PARAM_AUTO_SND_TGT_DISABLE,
  466. ISCSI_PARAM_DISCOVERY_SESS,
  467. ISCSI_PARAM_PORTAL_TYPE,
  468. ISCSI_PARAM_CHAP_AUTH_EN,
  469. ISCSI_PARAM_DISCOVERY_LOGOUT_EN,
  470. ISCSI_PARAM_BIDI_CHAP_EN,
  471. ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL,
  472. ISCSI_PARAM_DEF_TIME2WAIT,
  473. ISCSI_PARAM_DEF_TIME2RETAIN,
  474. ISCSI_PARAM_MAX_SEGMENT_SIZE,
  475. ISCSI_PARAM_STATSN,
  476. ISCSI_PARAM_KEEPALIVE_TMO,
  477. ISCSI_PARAM_LOCAL_PORT,
  478. ISCSI_PARAM_TSID,
  479. ISCSI_PARAM_DEF_TASKMGMT_TMO,
  480. ISCSI_PARAM_TCP_TIMESTAMP_STAT,
  481. ISCSI_PARAM_TCP_WSF_DISABLE,
  482. ISCSI_PARAM_TCP_NAGLE_DISABLE,
  483. ISCSI_PARAM_TCP_TIMER_SCALE,
  484. ISCSI_PARAM_TCP_TIMESTAMP_EN,
  485. ISCSI_PARAM_TCP_XMIT_WSF,
  486. ISCSI_PARAM_TCP_RECV_WSF,
  487. ISCSI_PARAM_IP_FRAGMENT_DISABLE,
  488. ISCSI_PARAM_IPV4_TOS,
  489. ISCSI_PARAM_IPV6_TC,
  490. ISCSI_PARAM_IPV6_FLOW_LABEL,
  491. ISCSI_PARAM_IS_FW_ASSIGNED_IPV6,
  492. ISCSI_PARAM_DISCOVERY_PARENT_IDX,
  493. ISCSI_PARAM_DISCOVERY_PARENT_TYPE,
  494. /* must always be last */
  495. ISCSI_PARAM_MAX,
  496. };
  497. /* iSCSI HBA params */
  498. enum iscsi_host_param {
  499. ISCSI_HOST_PARAM_HWADDRESS,
  500. ISCSI_HOST_PARAM_INITIATOR_NAME,
  501. ISCSI_HOST_PARAM_NETDEV_NAME,
  502. ISCSI_HOST_PARAM_IPADDRESS,
  503. ISCSI_HOST_PARAM_PORT_STATE,
  504. ISCSI_HOST_PARAM_PORT_SPEED,
  505. ISCSI_HOST_PARAM_MAX,
  506. };
  507. /* portal type */
  508. #define PORTAL_TYPE_IPV4 "ipv4"
  509. #define PORTAL_TYPE_IPV6 "ipv6"
  510. /* iSCSI Flash Target params */
  511. enum iscsi_flashnode_param {
  512. ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6,
  513. ISCSI_FLASHNODE_PORTAL_TYPE,
  514. ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE,
  515. ISCSI_FLASHNODE_DISCOVERY_SESS,
  516. ISCSI_FLASHNODE_ENTRY_EN,
  517. ISCSI_FLASHNODE_HDR_DGST_EN,
  518. ISCSI_FLASHNODE_DATA_DGST_EN,
  519. ISCSI_FLASHNODE_IMM_DATA_EN,
  520. ISCSI_FLASHNODE_INITIAL_R2T_EN,
  521. ISCSI_FLASHNODE_DATASEQ_INORDER,
  522. ISCSI_FLASHNODE_PDU_INORDER,
  523. ISCSI_FLASHNODE_CHAP_AUTH_EN,
  524. ISCSI_FLASHNODE_SNACK_REQ_EN,
  525. ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN,
  526. ISCSI_FLASHNODE_BIDI_CHAP_EN,
  527. /* make authentication for discovery sessions optional */
  528. ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL,
  529. ISCSI_FLASHNODE_ERL,
  530. ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT,
  531. ISCSI_FLASHNODE_TCP_NAGLE_DISABLE,
  532. ISCSI_FLASHNODE_TCP_WSF_DISABLE,
  533. ISCSI_FLASHNODE_TCP_TIMER_SCALE,
  534. ISCSI_FLASHNODE_TCP_TIMESTAMP_EN,
  535. ISCSI_FLASHNODE_IP_FRAG_DISABLE,
  536. ISCSI_FLASHNODE_MAX_RECV_DLENGTH,
  537. ISCSI_FLASHNODE_MAX_XMIT_DLENGTH,
  538. ISCSI_FLASHNODE_FIRST_BURST,
  539. ISCSI_FLASHNODE_DEF_TIME2WAIT,
  540. ISCSI_FLASHNODE_DEF_TIME2RETAIN,
  541. ISCSI_FLASHNODE_MAX_R2T,
  542. ISCSI_FLASHNODE_KEEPALIVE_TMO,
  543. ISCSI_FLASHNODE_ISID,
  544. ISCSI_FLASHNODE_TSID,
  545. ISCSI_FLASHNODE_PORT,
  546. ISCSI_FLASHNODE_MAX_BURST,
  547. ISCSI_FLASHNODE_DEF_TASKMGMT_TMO,
  548. ISCSI_FLASHNODE_IPADDR,
  549. ISCSI_FLASHNODE_ALIAS,
  550. ISCSI_FLASHNODE_REDIRECT_IPADDR,
  551. ISCSI_FLASHNODE_MAX_SEGMENT_SIZE,
  552. ISCSI_FLASHNODE_LOCAL_PORT,
  553. ISCSI_FLASHNODE_IPV4_TOS,
  554. ISCSI_FLASHNODE_IPV6_TC,
  555. ISCSI_FLASHNODE_IPV6_FLOW_LABEL,
  556. ISCSI_FLASHNODE_NAME,
  557. ISCSI_FLASHNODE_TPGT,
  558. ISCSI_FLASHNODE_LINK_LOCAL_IPV6,
  559. ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX,
  560. ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE,
  561. ISCSI_FLASHNODE_TCP_XMIT_WSF,
  562. ISCSI_FLASHNODE_TCP_RECV_WSF,
  563. ISCSI_FLASHNODE_CHAP_IN_IDX,
  564. ISCSI_FLASHNODE_CHAP_OUT_IDX,
  565. ISCSI_FLASHNODE_USERNAME,
  566. ISCSI_FLASHNODE_USERNAME_IN,
  567. ISCSI_FLASHNODE_PASSWORD,
  568. ISCSI_FLASHNODE_PASSWORD_IN,
  569. ISCSI_FLASHNODE_STATSN,
  570. ISCSI_FLASHNODE_EXP_STATSN,
  571. ISCSI_FLASHNODE_IS_BOOT_TGT,
  572. ISCSI_FLASHNODE_MAX,
  573. };
  574. struct iscsi_flashnode_param_info {
  575. uint32_t len; /* Actual length of the param */
  576. uint16_t param; /* iscsi param value */
  577. uint8_t value[0]; /* length sized value follows */
  578. } __packed;
  579. enum iscsi_discovery_parent_type {
  580. ISCSI_DISC_PARENT_UNKNOWN = 0x1,
  581. ISCSI_DISC_PARENT_SENDTGT = 0x2,
  582. ISCSI_DISC_PARENT_ISNS = 0x3,
  583. };
  584. /* iSCSI port Speed */
  585. enum iscsi_port_speed {
  586. ISCSI_PORT_SPEED_UNKNOWN = 0x1,
  587. ISCSI_PORT_SPEED_10MBPS = 0x2,
  588. ISCSI_PORT_SPEED_100MBPS = 0x4,
  589. ISCSI_PORT_SPEED_1GBPS = 0x8,
  590. ISCSI_PORT_SPEED_10GBPS = 0x10,
  591. };
  592. /* iSCSI port state */
  593. enum iscsi_port_state {
  594. ISCSI_PORT_STATE_DOWN = 0x1,
  595. ISCSI_PORT_STATE_UP = 0x2,
  596. };
  597. /* iSCSI PING status/error code */
  598. enum iscsi_ping_status_code {
  599. ISCSI_PING_SUCCESS = 0,
  600. ISCSI_PING_FW_DISABLED = 0x1,
  601. ISCSI_PING_IPADDR_INVALID = 0x2,
  602. ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID = 0x3,
  603. ISCSI_PING_TIMEOUT = 0x4,
  604. ISCSI_PING_INVALID_DEST_ADDR = 0x5,
  605. ISCSI_PING_OVERSIZE_PACKET = 0x6,
  606. ISCSI_PING_ICMP_ERROR = 0x7,
  607. ISCSI_PING_MAX_REQ_EXCEEDED = 0x8,
  608. ISCSI_PING_NO_ARP_RECEIVED = 0x9,
  609. };
  610. #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
  611. #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
  612. /*
  613. * These flags presents iSCSI Data-Path capabilities.
  614. */
  615. #define CAP_RECOVERY_L0 0x1
  616. #define CAP_RECOVERY_L1 0x2
  617. #define CAP_RECOVERY_L2 0x4
  618. #define CAP_MULTI_R2T 0x8
  619. #define CAP_HDRDGST 0x10
  620. #define CAP_DATADGST 0x20
  621. #define CAP_MULTI_CONN 0x40
  622. #define CAP_TEXT_NEGO 0x80
  623. #define CAP_MARKERS 0x100
  624. #define CAP_FW_DB 0x200
  625. #define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
  626. #define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
  627. #define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
  628. #define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
  629. and verification */
  630. #define CAP_LOGIN_OFFLOAD 0x4000 /* offload session login */
  631. /*
  632. * These flags describes reason of stop_conn() call
  633. */
  634. #define STOP_CONN_TERM 0x1
  635. #define STOP_CONN_SUSPEND 0x2
  636. #define STOP_CONN_RECOVER 0x3
  637. #define ISCSI_STATS_CUSTOM_MAX 32
  638. #define ISCSI_STATS_CUSTOM_DESC_MAX 64
  639. struct iscsi_stats_custom {
  640. char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
  641. uint64_t value;
  642. };
  643. /*
  644. * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
  645. *
  646. * Note: this structure contains counters collected on per-connection basis.
  647. */
  648. struct iscsi_stats {
  649. /* octets */
  650. uint64_t txdata_octets;
  651. uint64_t rxdata_octets;
  652. /* xmit pdus */
  653. uint32_t noptx_pdus;
  654. uint32_t scsicmd_pdus;
  655. uint32_t tmfcmd_pdus;
  656. uint32_t login_pdus;
  657. uint32_t text_pdus;
  658. uint32_t dataout_pdus;
  659. uint32_t logout_pdus;
  660. uint32_t snack_pdus;
  661. /* recv pdus */
  662. uint32_t noprx_pdus;
  663. uint32_t scsirsp_pdus;
  664. uint32_t tmfrsp_pdus;
  665. uint32_t textrsp_pdus;
  666. uint32_t datain_pdus;
  667. uint32_t logoutrsp_pdus;
  668. uint32_t r2t_pdus;
  669. uint32_t async_pdus;
  670. uint32_t rjt_pdus;
  671. /* errors */
  672. uint32_t digest_err;
  673. uint32_t timeout_err;
  674. /*
  675. * iSCSI Custom Statistics support, i.e. Transport could
  676. * extend existing MIB statistics with its own specific statistics
  677. * up to ISCSI_STATS_CUSTOM_MAX
  678. */
  679. uint32_t custom_length;
  680. struct iscsi_stats_custom custom[0]
  681. __attribute__ ((aligned (sizeof(uint64_t))));
  682. };
  683. enum chap_type_e {
  684. CHAP_TYPE_OUT,
  685. CHAP_TYPE_IN,
  686. };
  687. enum iscsi_chap_param {
  688. ISCSI_CHAP_PARAM_INDEX,
  689. ISCSI_CHAP_PARAM_CHAP_TYPE,
  690. ISCSI_CHAP_PARAM_USERNAME,
  691. ISCSI_CHAP_PARAM_PASSWORD,
  692. ISCSI_CHAP_PARAM_PASSWORD_LEN
  693. };
  694. #define ISCSI_CHAP_AUTH_NAME_MAX_LEN 256
  695. #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256
  696. struct iscsi_chap_rec {
  697. uint16_t chap_tbl_idx;
  698. enum chap_type_e chap_type;
  699. char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
  700. uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
  701. uint8_t password_length;
  702. };
  703. #endif