iscsi_proto.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /*
  2. * RFC 3720 (iSCSI) protocol data types
  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_PROTO_H
  21. #define ISCSI_PROTO_H
  22. #include <linux/types.h>
  23. #include <scsi/scsi.h>
  24. #define ISCSI_DRAFT20_VERSION 0x00
  25. /* default iSCSI listen port for incoming connections */
  26. #define ISCSI_LISTEN_PORT 3260
  27. /* Padding word length */
  28. #define ISCSI_PAD_LEN 4
  29. /*
  30. * useful common(control and data pathes) macro
  31. */
  32. #define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
  33. #define hton24(p, v) { \
  34. p[0] = (((v) >> 16) & 0xFF); \
  35. p[1] = (((v) >> 8) & 0xFF); \
  36. p[2] = ((v) & 0xFF); \
  37. }
  38. #define zero_data(p) {p[0]=0;p[1]=0;p[2]=0;}
  39. /* initiator tags; opaque for target */
  40. typedef uint32_t __bitwise__ itt_t;
  41. /* below makes sense only for initiator that created this tag */
  42. #define build_itt(itt, age) ((__force itt_t)\
  43. ((itt) | ((age) << ISCSI_AGE_SHIFT)))
  44. #define get_itt(itt) ((__force uint32_t)(itt_t)(itt) & ISCSI_ITT_MASK)
  45. #define RESERVED_ITT ((__force itt_t)0xffffffff)
  46. /*
  47. * iSCSI Template Message Header
  48. */
  49. struct iscsi_hdr {
  50. uint8_t opcode;
  51. uint8_t flags; /* Final bit */
  52. uint8_t rsvd2[2];
  53. uint8_t hlength; /* AHSs total length */
  54. uint8_t dlength[3]; /* Data length */
  55. uint8_t lun[8];
  56. itt_t itt; /* Initiator Task Tag, opaque for target */
  57. __be32 ttt; /* Target Task Tag */
  58. __be32 statsn;
  59. __be32 exp_statsn;
  60. __be32 max_statsn;
  61. uint8_t other[12];
  62. };
  63. /************************* RFC 3720 Begin *****************************/
  64. #define ISCSI_RESERVED_TAG 0xffffffff
  65. /* Opcode encoding bits */
  66. #define ISCSI_OP_RETRY 0x80
  67. #define ISCSI_OP_IMMEDIATE 0x40
  68. #define ISCSI_OPCODE_MASK 0x3F
  69. /* Initiator Opcode values */
  70. #define ISCSI_OP_NOOP_OUT 0x00
  71. #define ISCSI_OP_SCSI_CMD 0x01
  72. #define ISCSI_OP_SCSI_TMFUNC 0x02
  73. #define ISCSI_OP_LOGIN 0x03
  74. #define ISCSI_OP_TEXT 0x04
  75. #define ISCSI_OP_SCSI_DATA_OUT 0x05
  76. #define ISCSI_OP_LOGOUT 0x06
  77. #define ISCSI_OP_SNACK 0x10
  78. #define ISCSI_OP_VENDOR1_CMD 0x1c
  79. #define ISCSI_OP_VENDOR2_CMD 0x1d
  80. #define ISCSI_OP_VENDOR3_CMD 0x1e
  81. #define ISCSI_OP_VENDOR4_CMD 0x1f
  82. /* Target Opcode values */
  83. #define ISCSI_OP_NOOP_IN 0x20
  84. #define ISCSI_OP_SCSI_CMD_RSP 0x21
  85. #define ISCSI_OP_SCSI_TMFUNC_RSP 0x22
  86. #define ISCSI_OP_LOGIN_RSP 0x23
  87. #define ISCSI_OP_TEXT_RSP 0x24
  88. #define ISCSI_OP_SCSI_DATA_IN 0x25
  89. #define ISCSI_OP_LOGOUT_RSP 0x26
  90. #define ISCSI_OP_R2T 0x31
  91. #define ISCSI_OP_ASYNC_EVENT 0x32
  92. #define ISCSI_OP_REJECT 0x3f
  93. struct iscsi_ahs_hdr {
  94. __be16 ahslength;
  95. uint8_t ahstype;
  96. uint8_t ahspec[5];
  97. };
  98. #define ISCSI_AHSTYPE_CDB 1
  99. #define ISCSI_AHSTYPE_RLENGTH 2
  100. #define ISCSI_CDB_SIZE 16
  101. /* iSCSI PDU Header */
  102. struct iscsi_cmd {
  103. uint8_t opcode;
  104. uint8_t flags;
  105. __be16 rsvd2;
  106. uint8_t hlength;
  107. uint8_t dlength[3];
  108. uint8_t lun[8];
  109. itt_t itt; /* Initiator Task Tag */
  110. __be32 data_length;
  111. __be32 cmdsn;
  112. __be32 exp_statsn;
  113. uint8_t cdb[ISCSI_CDB_SIZE]; /* SCSI Command Block */
  114. /* Additional Data (Command Dependent) */
  115. };
  116. /* Command PDU flags */
  117. #define ISCSI_FLAG_CMD_FINAL 0x80
  118. #define ISCSI_FLAG_CMD_READ 0x40
  119. #define ISCSI_FLAG_CMD_WRITE 0x20
  120. #define ISCSI_FLAG_CMD_ATTR_MASK 0x07 /* 3 bits */
  121. /* SCSI Command Attribute values */
  122. #define ISCSI_ATTR_UNTAGGED 0
  123. #define ISCSI_ATTR_SIMPLE 1
  124. #define ISCSI_ATTR_ORDERED 2
  125. #define ISCSI_ATTR_HEAD_OF_QUEUE 3
  126. #define ISCSI_ATTR_ACA 4
  127. struct iscsi_rlength_ahdr {
  128. __be16 ahslength;
  129. uint8_t ahstype;
  130. uint8_t reserved;
  131. __be32 read_length;
  132. };
  133. /* Extended CDB AHS */
  134. struct iscsi_ecdb_ahdr {
  135. __be16 ahslength; /* CDB length - 15, including reserved byte */
  136. uint8_t ahstype;
  137. uint8_t reserved;
  138. /* 4-byte aligned extended CDB spillover */
  139. uint8_t ecdb[SCSI_MAX_VARLEN_CDB_SIZE - ISCSI_CDB_SIZE];
  140. };
  141. /* SCSI Response Header */
  142. struct iscsi_cmd_rsp {
  143. uint8_t opcode;
  144. uint8_t flags;
  145. uint8_t response;
  146. uint8_t cmd_status;
  147. uint8_t hlength;
  148. uint8_t dlength[3];
  149. uint8_t rsvd[8];
  150. itt_t itt; /* Initiator Task Tag */
  151. __be32 rsvd1;
  152. __be32 statsn;
  153. __be32 exp_cmdsn;
  154. __be32 max_cmdsn;
  155. __be32 exp_datasn;
  156. __be32 bi_residual_count;
  157. __be32 residual_count;
  158. /* Response or Sense Data (optional) */
  159. };
  160. /* Command Response PDU flags */
  161. #define ISCSI_FLAG_CMD_BIDI_OVERFLOW 0x10
  162. #define ISCSI_FLAG_CMD_BIDI_UNDERFLOW 0x08
  163. #define ISCSI_FLAG_CMD_OVERFLOW 0x04
  164. #define ISCSI_FLAG_CMD_UNDERFLOW 0x02
  165. /* iSCSI Status values. Valid if Rsp Selector bit is not set */
  166. #define ISCSI_STATUS_CMD_COMPLETED 0
  167. #define ISCSI_STATUS_TARGET_FAILURE 1
  168. #define ISCSI_STATUS_SUBSYS_FAILURE 2
  169. /* Asynchronous Event Header */
  170. struct iscsi_async {
  171. uint8_t opcode;
  172. uint8_t flags;
  173. uint8_t rsvd2[2];
  174. uint8_t rsvd3;
  175. uint8_t dlength[3];
  176. uint8_t lun[8];
  177. uint8_t rsvd4[8];
  178. __be32 statsn;
  179. __be32 exp_cmdsn;
  180. __be32 max_cmdsn;
  181. uint8_t async_event;
  182. uint8_t async_vcode;
  183. __be16 param1;
  184. __be16 param2;
  185. __be16 param3;
  186. uint8_t rsvd5[4];
  187. };
  188. /* iSCSI Event Codes */
  189. #define ISCSI_ASYNC_MSG_SCSI_EVENT 0
  190. #define ISCSI_ASYNC_MSG_REQUEST_LOGOUT 1
  191. #define ISCSI_ASYNC_MSG_DROPPING_CONNECTION 2
  192. #define ISCSI_ASYNC_MSG_DROPPING_ALL_CONNECTIONS 3
  193. #define ISCSI_ASYNC_MSG_PARAM_NEGOTIATION 4
  194. #define ISCSI_ASYNC_MSG_VENDOR_SPECIFIC 255
  195. /* NOP-Out Message */
  196. struct iscsi_nopout {
  197. uint8_t opcode;
  198. uint8_t flags;
  199. __be16 rsvd2;
  200. uint8_t rsvd3;
  201. uint8_t dlength[3];
  202. uint8_t lun[8];
  203. itt_t itt; /* Initiator Task Tag */
  204. __be32 ttt; /* Target Transfer Tag */
  205. __be32 cmdsn;
  206. __be32 exp_statsn;
  207. uint8_t rsvd4[16];
  208. };
  209. /* NOP-In Message */
  210. struct iscsi_nopin {
  211. uint8_t opcode;
  212. uint8_t flags;
  213. __be16 rsvd2;
  214. uint8_t rsvd3;
  215. uint8_t dlength[3];
  216. uint8_t lun[8];
  217. itt_t itt; /* Initiator Task Tag */
  218. __be32 ttt; /* Target Transfer Tag */
  219. __be32 statsn;
  220. __be32 exp_cmdsn;
  221. __be32 max_cmdsn;
  222. uint8_t rsvd4[12];
  223. };
  224. /* SCSI Task Management Message Header */
  225. struct iscsi_tm {
  226. uint8_t opcode;
  227. uint8_t flags;
  228. uint8_t rsvd1[2];
  229. uint8_t hlength;
  230. uint8_t dlength[3];
  231. uint8_t lun[8];
  232. itt_t itt; /* Initiator Task Tag */
  233. itt_t rtt; /* Reference Task Tag */
  234. __be32 cmdsn;
  235. __be32 exp_statsn;
  236. __be32 refcmdsn;
  237. __be32 exp_datasn;
  238. uint8_t rsvd2[8];
  239. };
  240. #define ISCSI_FLAG_TM_FUNC_MASK 0x7F
  241. /* Function values */
  242. #define ISCSI_TM_FUNC_ABORT_TASK 1
  243. #define ISCSI_TM_FUNC_ABORT_TASK_SET 2
  244. #define ISCSI_TM_FUNC_CLEAR_ACA 3
  245. #define ISCSI_TM_FUNC_CLEAR_TASK_SET 4
  246. #define ISCSI_TM_FUNC_LOGICAL_UNIT_RESET 5
  247. #define ISCSI_TM_FUNC_TARGET_WARM_RESET 6
  248. #define ISCSI_TM_FUNC_TARGET_COLD_RESET 7
  249. #define ISCSI_TM_FUNC_TASK_REASSIGN 8
  250. #define ISCSI_TM_FUNC_VALUE(hdr) ((hdr)->flags & ISCSI_FLAG_TM_FUNC_MASK)
  251. /* SCSI Task Management Response Header */
  252. struct iscsi_tm_rsp {
  253. uint8_t opcode;
  254. uint8_t flags;
  255. uint8_t response; /* see Response values below */
  256. uint8_t qualifier;
  257. uint8_t hlength;
  258. uint8_t dlength[3];
  259. uint8_t rsvd2[8];
  260. itt_t itt; /* Initiator Task Tag */
  261. itt_t rtt; /* Reference Task Tag */
  262. __be32 statsn;
  263. __be32 exp_cmdsn;
  264. __be32 max_cmdsn;
  265. uint8_t rsvd3[12];
  266. };
  267. /* Response values */
  268. #define ISCSI_TMF_RSP_COMPLETE 0x00
  269. #define ISCSI_TMF_RSP_NO_TASK 0x01
  270. #define ISCSI_TMF_RSP_NO_LUN 0x02
  271. #define ISCSI_TMF_RSP_TASK_ALLEGIANT 0x03
  272. #define ISCSI_TMF_RSP_NO_FAILOVER 0x04
  273. #define ISCSI_TMF_RSP_NOT_SUPPORTED 0x05
  274. #define ISCSI_TMF_RSP_AUTH_FAILED 0x06
  275. #define ISCSI_TMF_RSP_REJECTED 0xff
  276. /* Ready To Transfer Header */
  277. struct iscsi_r2t_rsp {
  278. uint8_t opcode;
  279. uint8_t flags;
  280. uint8_t rsvd2[2];
  281. uint8_t hlength;
  282. uint8_t dlength[3];
  283. uint8_t lun[8];
  284. itt_t itt; /* Initiator Task Tag */
  285. __be32 ttt; /* Target Transfer Tag */
  286. __be32 statsn;
  287. __be32 exp_cmdsn;
  288. __be32 max_cmdsn;
  289. __be32 r2tsn;
  290. __be32 data_offset;
  291. __be32 data_length;
  292. };
  293. /* SCSI Data Hdr */
  294. struct iscsi_data {
  295. uint8_t opcode;
  296. uint8_t flags;
  297. uint8_t rsvd2[2];
  298. uint8_t rsvd3;
  299. uint8_t dlength[3];
  300. uint8_t lun[8];
  301. itt_t itt;
  302. __be32 ttt;
  303. __be32 rsvd4;
  304. __be32 exp_statsn;
  305. __be32 rsvd5;
  306. __be32 datasn;
  307. __be32 offset;
  308. __be32 rsvd6;
  309. /* Payload */
  310. };
  311. /* SCSI Data Response Hdr */
  312. struct iscsi_data_rsp {
  313. uint8_t opcode;
  314. uint8_t flags;
  315. uint8_t rsvd2;
  316. uint8_t cmd_status;
  317. uint8_t hlength;
  318. uint8_t dlength[3];
  319. uint8_t lun[8];
  320. itt_t itt;
  321. __be32 ttt;
  322. __be32 statsn;
  323. __be32 exp_cmdsn;
  324. __be32 max_cmdsn;
  325. __be32 datasn;
  326. __be32 offset;
  327. __be32 residual_count;
  328. };
  329. /* Data Response PDU flags */
  330. #define ISCSI_FLAG_DATA_ACK 0x40
  331. #define ISCSI_FLAG_DATA_OVERFLOW 0x04
  332. #define ISCSI_FLAG_DATA_UNDERFLOW 0x02
  333. #define ISCSI_FLAG_DATA_STATUS 0x01
  334. /* Text Header */
  335. struct iscsi_text {
  336. uint8_t opcode;
  337. uint8_t flags;
  338. uint8_t rsvd2[2];
  339. uint8_t hlength;
  340. uint8_t dlength[3];
  341. uint8_t rsvd4[8];
  342. itt_t itt;
  343. __be32 ttt;
  344. __be32 cmdsn;
  345. __be32 exp_statsn;
  346. uint8_t rsvd5[16];
  347. /* Text - key=value pairs */
  348. };
  349. #define ISCSI_FLAG_TEXT_CONTINUE 0x40
  350. /* Text Response Header */
  351. struct iscsi_text_rsp {
  352. uint8_t opcode;
  353. uint8_t flags;
  354. uint8_t rsvd2[2];
  355. uint8_t hlength;
  356. uint8_t dlength[3];
  357. uint8_t rsvd4[8];
  358. itt_t itt;
  359. __be32 ttt;
  360. __be32 statsn;
  361. __be32 exp_cmdsn;
  362. __be32 max_cmdsn;
  363. uint8_t rsvd5[12];
  364. /* Text Response - key:value pairs */
  365. };
  366. /* Login Header */
  367. struct iscsi_login {
  368. uint8_t opcode;
  369. uint8_t flags;
  370. uint8_t max_version; /* Max. version supported */
  371. uint8_t min_version; /* Min. version supported */
  372. uint8_t hlength;
  373. uint8_t dlength[3];
  374. uint8_t isid[6]; /* Initiator Session ID */
  375. __be16 tsih; /* Target Session Handle */
  376. itt_t itt; /* Initiator Task Tag */
  377. __be16 cid;
  378. __be16 rsvd3;
  379. __be32 cmdsn;
  380. __be32 exp_statsn;
  381. uint8_t rsvd5[16];
  382. };
  383. /* Login PDU flags */
  384. #define ISCSI_FLAG_LOGIN_TRANSIT 0x80
  385. #define ISCSI_FLAG_LOGIN_CONTINUE 0x40
  386. #define ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK 0x0C /* 2 bits */
  387. #define ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK 0x03 /* 2 bits */
  388. #define ISCSI_LOGIN_CURRENT_STAGE(flags) \
  389. ((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2)
  390. #define ISCSI_LOGIN_NEXT_STAGE(flags) \
  391. (flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK)
  392. /* Login Response Header */
  393. struct iscsi_login_rsp {
  394. uint8_t opcode;
  395. uint8_t flags;
  396. uint8_t max_version; /* Max. version supported */
  397. uint8_t active_version; /* Active version */
  398. uint8_t hlength;
  399. uint8_t dlength[3];
  400. uint8_t isid[6]; /* Initiator Session ID */
  401. __be16 tsih; /* Target Session Handle */
  402. itt_t itt; /* Initiator Task Tag */
  403. __be32 rsvd3;
  404. __be32 statsn;
  405. __be32 exp_cmdsn;
  406. __be32 max_cmdsn;
  407. uint8_t status_class; /* see Login RSP ststus classes below */
  408. uint8_t status_detail; /* see Login RSP Status details below */
  409. uint8_t rsvd4[10];
  410. };
  411. /* Login stage (phase) codes for CSG, NSG */
  412. #define ISCSI_INITIAL_LOGIN_STAGE -1
  413. #define ISCSI_SECURITY_NEGOTIATION_STAGE 0
  414. #define ISCSI_OP_PARMS_NEGOTIATION_STAGE 1
  415. #define ISCSI_FULL_FEATURE_PHASE 3
  416. /* Login Status response classes */
  417. #define ISCSI_STATUS_CLS_SUCCESS 0x00
  418. #define ISCSI_STATUS_CLS_REDIRECT 0x01
  419. #define ISCSI_STATUS_CLS_INITIATOR_ERR 0x02
  420. #define ISCSI_STATUS_CLS_TARGET_ERR 0x03
  421. /* Login Status response detail codes */
  422. /* Class-0 (Success) */
  423. #define ISCSI_LOGIN_STATUS_ACCEPT 0x00
  424. /* Class-1 (Redirection) */
  425. #define ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP 0x01
  426. #define ISCSI_LOGIN_STATUS_TGT_MOVED_PERM 0x02
  427. /* Class-2 (Initiator Error) */
  428. #define ISCSI_LOGIN_STATUS_INIT_ERR 0x00
  429. #define ISCSI_LOGIN_STATUS_AUTH_FAILED 0x01
  430. #define ISCSI_LOGIN_STATUS_TGT_FORBIDDEN 0x02
  431. #define ISCSI_LOGIN_STATUS_TGT_NOT_FOUND 0x03
  432. #define ISCSI_LOGIN_STATUS_TGT_REMOVED 0x04
  433. #define ISCSI_LOGIN_STATUS_NO_VERSION 0x05
  434. #define ISCSI_LOGIN_STATUS_ISID_ERROR 0x06
  435. #define ISCSI_LOGIN_STATUS_MISSING_FIELDS 0x07
  436. #define ISCSI_LOGIN_STATUS_CONN_ADD_FAILED 0x08
  437. #define ISCSI_LOGIN_STATUS_NO_SESSION_TYPE 0x09
  438. #define ISCSI_LOGIN_STATUS_NO_SESSION 0x0a
  439. #define ISCSI_LOGIN_STATUS_INVALID_REQUEST 0x0b
  440. /* Class-3 (Target Error) */
  441. #define ISCSI_LOGIN_STATUS_TARGET_ERROR 0x00
  442. #define ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE 0x01
  443. #define ISCSI_LOGIN_STATUS_NO_RESOURCES 0x02
  444. /* Logout Header */
  445. struct iscsi_logout {
  446. uint8_t opcode;
  447. uint8_t flags;
  448. uint8_t rsvd1[2];
  449. uint8_t hlength;
  450. uint8_t dlength[3];
  451. uint8_t rsvd2[8];
  452. itt_t itt; /* Initiator Task Tag */
  453. __be16 cid;
  454. uint8_t rsvd3[2];
  455. __be32 cmdsn;
  456. __be32 exp_statsn;
  457. uint8_t rsvd4[16];
  458. };
  459. /* Logout PDU flags */
  460. #define ISCSI_FLAG_LOGOUT_REASON_MASK 0x7F
  461. /* logout reason_code values */
  462. #define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0
  463. #define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1
  464. #define ISCSI_LOGOUT_REASON_RECOVERY 2
  465. #define ISCSI_LOGOUT_REASON_AEN_REQUEST 3
  466. /* Logout Response Header */
  467. struct iscsi_logout_rsp {
  468. uint8_t opcode;
  469. uint8_t flags;
  470. uint8_t response; /* see Logout response values below */
  471. uint8_t rsvd2;
  472. uint8_t hlength;
  473. uint8_t dlength[3];
  474. uint8_t rsvd3[8];
  475. itt_t itt; /* Initiator Task Tag */
  476. __be32 rsvd4;
  477. __be32 statsn;
  478. __be32 exp_cmdsn;
  479. __be32 max_cmdsn;
  480. __be32 rsvd5;
  481. __be16 t2wait;
  482. __be16 t2retain;
  483. __be32 rsvd6;
  484. };
  485. /* logout response status values */
  486. #define ISCSI_LOGOUT_SUCCESS 0
  487. #define ISCSI_LOGOUT_CID_NOT_FOUND 1
  488. #define ISCSI_LOGOUT_RECOVERY_UNSUPPORTED 2
  489. #define ISCSI_LOGOUT_CLEANUP_FAILED 3
  490. /* SNACK Header */
  491. struct iscsi_snack {
  492. uint8_t opcode;
  493. uint8_t flags;
  494. uint8_t rsvd2[14];
  495. itt_t itt;
  496. __be32 begrun;
  497. __be32 runlength;
  498. __be32 exp_statsn;
  499. __be32 rsvd3;
  500. __be32 exp_datasn;
  501. uint8_t rsvd6[8];
  502. };
  503. /* SNACK PDU flags */
  504. #define ISCSI_FLAG_SNACK_TYPE_MASK 0x0F /* 4 bits */
  505. /* Reject Message Header */
  506. struct iscsi_reject {
  507. uint8_t opcode;
  508. uint8_t flags;
  509. uint8_t reason;
  510. uint8_t rsvd2;
  511. uint8_t hlength;
  512. uint8_t dlength[3];
  513. uint8_t rsvd3[8];
  514. __be32 ffffffff;
  515. uint8_t rsvd4[4];
  516. __be32 statsn;
  517. __be32 exp_cmdsn;
  518. __be32 max_cmdsn;
  519. __be32 datasn;
  520. uint8_t rsvd5[8];
  521. /* Text - Rejected hdr */
  522. };
  523. /* Reason for Reject */
  524. #define ISCSI_REASON_CMD_BEFORE_LOGIN 1
  525. #define ISCSI_REASON_DATA_DIGEST_ERROR 2
  526. #define ISCSI_REASON_DATA_SNACK_REJECT 3
  527. #define ISCSI_REASON_PROTOCOL_ERROR 4
  528. #define ISCSI_REASON_CMD_NOT_SUPPORTED 5
  529. #define ISCSI_REASON_IMM_CMD_REJECT 6
  530. #define ISCSI_REASON_TASK_IN_PROGRESS 7
  531. #define ISCSI_REASON_INVALID_SNACK 8
  532. #define ISCSI_REASON_BOOKMARK_INVALID 9
  533. #define ISCSI_REASON_BOOKMARK_NO_RESOURCES 10
  534. #define ISCSI_REASON_NEGOTIATION_RESET 11
  535. /* Max. number of Key=Value pairs in a text message */
  536. #define MAX_KEY_VALUE_PAIRS 8192
  537. /* maximum length for text keys/values */
  538. #define KEY_MAXLEN 64
  539. #define VALUE_MAXLEN 255
  540. #define TARGET_NAME_MAXLEN VALUE_MAXLEN
  541. #define ISCSI_DEF_MAX_RECV_SEG_LEN 8192
  542. #define ISCSI_MIN_MAX_RECV_SEG_LEN 512
  543. #define ISCSI_MAX_MAX_RECV_SEG_LEN 16777215
  544. #define ISCSI_DEF_FIRST_BURST_LEN 65536
  545. #define ISCSI_MIN_FIRST_BURST_LEN 512
  546. #define ISCSI_MAX_FIRST_BURST_LEN 16777215
  547. #define ISCSI_DEF_MAX_BURST_LEN 262144
  548. #define ISCSI_MIN_MAX_BURST_LEN 512
  549. #define ISCSI_MAX_MAX_BURST_LEN 16777215
  550. #define ISCSI_DEF_TIME2WAIT 2
  551. /************************* RFC 3720 End *****************************/
  552. #endif /* ISCSI_PROTO_H */