iscsi_if.h 19 KB

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