You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

iscsi.h 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. #ifndef _IPXE_ISCSI_H
  2. #define _IPXE_ISCSI_H
  3. /** @file
  4. *
  5. * iSCSI protocol
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/socket.h>
  11. #include <ipxe/scsi.h>
  12. #include <ipxe/chap.h>
  13. #include <ipxe/refcnt.h>
  14. #include <ipxe/xfer.h>
  15. #include <ipxe/process.h>
  16. #include <ipxe/acpi.h>
  17. #include <ipxe/settings.h>
  18. /** Default iSCSI port */
  19. #define ISCSI_PORT 3260
  20. /**
  21. * iSCSI segment lengths
  22. *
  23. * iSCSI uses an icky structure with one one-byte field (a dword
  24. * count) and one three-byte field (a byte count). This structure,
  25. * and the accompanying macros, relieve some of the pain.
  26. */
  27. union iscsi_segment_lengths {
  28. struct {
  29. /** The AHS length (measured in dwords) */
  30. uint8_t ahs_len;
  31. /** The data length (measured in bytes), in network
  32. * byte order
  33. */
  34. uint8_t data_len[3];
  35. } bytes;
  36. /** The data length (measured in bytes), in network byte
  37. * order, with ahs_len as the first byte.
  38. */
  39. uint32_t ahs_and_data_len;
  40. };
  41. /** The length of the additional header segment, in dwords */
  42. #define ISCSI_AHS_LEN( segment_lengths ) \
  43. ( (segment_lengths).bytes.ahs_len )
  44. /** The length of the data segment, in bytes, excluding any padding */
  45. #define ISCSI_DATA_LEN( segment_lengths ) \
  46. ( ntohl ( (segment_lengths).ahs_and_data_len ) & 0xffffff )
  47. /** The padding of the data segment, in bytes */
  48. #define ISCSI_DATA_PAD_LEN( segment_lengths ) \
  49. ( ( 0 - (segment_lengths).bytes.data_len[2] ) & 0x03 )
  50. /** Set additional header and data segment lengths */
  51. #define ISCSI_SET_LENGTHS( segment_lengths, ahs_len, data_len ) do { \
  52. (segment_lengths).ahs_and_data_len = \
  53. htonl ( data_len | ( ahs_len << 24 ) ); \
  54. } while ( 0 )
  55. /**
  56. * iSCSI basic header segment common fields
  57. *
  58. */
  59. struct iscsi_bhs_common {
  60. /** Opcode */
  61. uint8_t opcode;
  62. /** Flags */
  63. uint8_t flags;
  64. /** Fields specific to the PDU type */
  65. uint8_t other_a[2];
  66. /** Segment lengths */
  67. union iscsi_segment_lengths lengths;
  68. /** Fields specific to the PDU type */
  69. uint8_t other_b[8];
  70. /** Initiator Task Tag */
  71. uint32_t itt;
  72. /** Fields specific to the PDU type */
  73. uint8_t other_c[28];
  74. };
  75. /** Opcode mask */
  76. #define ISCSI_OPCODE_MASK 0x3f
  77. /** Immediate delivery */
  78. #define ISCSI_FLAG_IMMEDIATE 0x40
  79. /** Final PDU of a sequence */
  80. #define ISCSI_FLAG_FINAL 0x80
  81. /** iSCSI tag magic marker */
  82. #define ISCSI_TAG_MAGIC 0x18ae0000
  83. /** iSCSI reserved tag value */
  84. #define ISCSI_TAG_RESERVED 0xffffffff
  85. /**
  86. * iSCSI basic header segment common request fields
  87. *
  88. */
  89. struct iscsi_bhs_common_response {
  90. /** Opcode */
  91. uint8_t opcode;
  92. /** Flags */
  93. uint8_t flags;
  94. /** Fields specific to the PDU type */
  95. uint8_t other_a[2];
  96. /** Segment lengths */
  97. union iscsi_segment_lengths lengths;
  98. /** Fields specific to the PDU type */
  99. uint8_t other_b[8];
  100. /** Initiator Task Tag */
  101. uint32_t itt;
  102. /** Fields specific to the PDU type */
  103. uint8_t other_c[4];
  104. /** Status sequence number */
  105. uint32_t statsn;
  106. /** Expected command sequence number */
  107. uint32_t expcmdsn;
  108. /** Fields specific to the PDU type */
  109. uint8_t other_d[16];
  110. };
  111. /**
  112. * iSCSI login request basic header segment
  113. *
  114. */
  115. struct iscsi_bhs_login_request {
  116. /** Opcode */
  117. uint8_t opcode;
  118. /** Flags */
  119. uint8_t flags;
  120. /** Maximum supported version number */
  121. uint8_t version_max;
  122. /** Minimum supported version number */
  123. uint8_t version_min;
  124. /** Segment lengths */
  125. union iscsi_segment_lengths lengths;
  126. /** Initiator session ID (IANA format) enterprise number and flags */
  127. uint32_t isid_iana_en;
  128. /** Initiator session ID (IANA format) qualifier */
  129. uint16_t isid_iana_qual;
  130. /** Target session identifying handle */
  131. uint16_t tsih;
  132. /** Initiator Task Tag */
  133. uint32_t itt;
  134. /** Connection ID */
  135. uint16_t cid;
  136. /** Reserved */
  137. uint16_t reserved_a;
  138. /** Command sequence number */
  139. uint32_t cmdsn;
  140. /** Expected status sequence number */
  141. uint32_t expstatsn;
  142. /** Reserved */
  143. uint8_t reserved_b[16];
  144. };
  145. /** Login request opcode */
  146. #define ISCSI_OPCODE_LOGIN_REQUEST 0x03
  147. /** Willingness to transition to next stage */
  148. #define ISCSI_LOGIN_FLAG_TRANSITION 0x80
  149. /** Key=value pairs continued in subsequent request */
  150. #define ISCSI_LOGIN_FLAG_CONTINUE 0x40
  151. /* Current stage values and mask */
  152. #define ISCSI_LOGIN_CSG_MASK 0x0c
  153. #define ISCSI_LOGIN_CSG_SECURITY_NEGOTIATION 0x00
  154. #define ISCSI_LOGIN_CSG_OPERATIONAL_NEGOTIATION 0x04
  155. #define ISCSI_LOGIN_CSG_FULL_FEATURE_PHASE 0x0c
  156. /* Next stage values and mask */
  157. #define ISCSI_LOGIN_NSG_MASK 0x03
  158. #define ISCSI_LOGIN_NSG_SECURITY_NEGOTIATION 0x00
  159. #define ISCSI_LOGIN_NSG_OPERATIONAL_NEGOTIATION 0x01
  160. #define ISCSI_LOGIN_NSG_FULL_FEATURE_PHASE 0x03
  161. /** ISID IANA format marker */
  162. #define ISCSI_ISID_IANA 0x40000000
  163. /** Fen Systems Ltd. IANA enterprise number
  164. *
  165. * Permission is hereby granted to use Fen Systems Ltd.'s IANA
  166. * enterprise number with this iSCSI implementation.
  167. */
  168. #define IANA_EN_FEN_SYSTEMS 10019
  169. /**
  170. * iSCSI login response basic header segment
  171. *
  172. */
  173. struct iscsi_bhs_login_response {
  174. /** Opcode */
  175. uint8_t opcode;
  176. /** Flags */
  177. uint8_t flags;
  178. /** Maximum supported version number */
  179. uint8_t version_max;
  180. /** Minimum supported version number */
  181. uint8_t version_min;
  182. /** Segment lengths */
  183. union iscsi_segment_lengths lengths;
  184. /** Initiator session ID (IANA format) enterprise number and flags */
  185. uint32_t isid_iana_en;
  186. /** Initiator session ID (IANA format) qualifier */
  187. uint16_t isid_iana_qual;
  188. /** Target session identifying handle */
  189. uint16_t tsih;
  190. /** Initiator Task Tag */
  191. uint32_t itt;
  192. /** Reserved */
  193. uint32_t reserved_a;
  194. /** Status sequence number */
  195. uint32_t statsn;
  196. /** Expected command sequence number */
  197. uint32_t expcmdsn;
  198. /** Maximum command sequence number */
  199. uint32_t maxcmdsn;
  200. /** Status class */
  201. uint8_t status_class;
  202. /** Status detail */
  203. uint8_t status_detail;
  204. /** Reserved */
  205. uint8_t reserved_b[10];
  206. };
  207. /** Login response opcode */
  208. #define ISCSI_OPCODE_LOGIN_RESPONSE 0x23
  209. /* Login response status codes */
  210. #define ISCSI_STATUS_SUCCESS 0x00
  211. #define ISCSI_STATUS_REDIRECT 0x01
  212. #define ISCSI_STATUS_INITIATOR_ERROR 0x02
  213. #define ISCSI_STATUS_INITIATOR_ERROR_AUTHENTICATION 0x01
  214. #define ISCSI_STATUS_INITIATOR_ERROR_AUTHORISATION 0x02
  215. #define ISCSI_STATUS_INITIATOR_ERROR_NOT_FOUND 0x03
  216. #define ISCSI_STATUS_INITIATOR_ERROR_REMOVED 0x04
  217. #define ISCSI_STATUS_TARGET_ERROR 0x03
  218. #define ISCSI_STATUS_TARGET_ERROR_UNAVAILABLE 0x01
  219. #define ISCSI_STATUS_TARGET_ERROR_NO_RESOURCES 0x02
  220. /**
  221. * iSCSI SCSI command basic header segment
  222. *
  223. */
  224. struct iscsi_bhs_scsi_command {
  225. /** Opcode */
  226. uint8_t opcode;
  227. /** Flags */
  228. uint8_t flags;
  229. /** Reserved */
  230. uint16_t reserved_a;
  231. /** Segment lengths */
  232. union iscsi_segment_lengths lengths;
  233. /** SCSI Logical Unit Number */
  234. struct scsi_lun lun;
  235. /** Initiator Task Tag */
  236. uint32_t itt;
  237. /** Expected data transfer length */
  238. uint32_t exp_len;
  239. /** Command sequence number */
  240. uint32_t cmdsn;
  241. /** Expected status sequence number */
  242. uint32_t expstatsn;
  243. /** SCSI Command Descriptor Block (CDB) */
  244. union scsi_cdb cdb;
  245. };
  246. /** SCSI command opcode */
  247. #define ISCSI_OPCODE_SCSI_COMMAND 0x01
  248. /** Command will read data */
  249. #define ISCSI_COMMAND_FLAG_READ 0x40
  250. /** Command will write data */
  251. #define ISCSI_COMMAND_FLAG_WRITE 0x20
  252. /* Task attributes */
  253. #define ISCSI_COMMAND_ATTR_UNTAGGED 0x00
  254. #define ISCSI_COMMAND_ATTR_SIMPLE 0x01
  255. #define ISCSI_COMMAND_ATTR_ORDERED 0x02
  256. #define ISCSI_COMMAND_ATTR_HEAD_OF_QUEUE 0x03
  257. #define ISCSI_COMMAND_ATTR_ACA 0x04
  258. /**
  259. * iSCSI SCSI response basic header segment
  260. *
  261. */
  262. struct iscsi_bhs_scsi_response {
  263. /** Opcode */
  264. uint8_t opcode;
  265. /** Flags */
  266. uint8_t flags;
  267. /** Response code */
  268. uint8_t response;
  269. /** SCSI status code */
  270. uint8_t status;
  271. /** Segment lengths */
  272. union iscsi_segment_lengths lengths;
  273. /** Reserved */
  274. uint8_t reserved_a[8];
  275. /** Initiator Task Tag */
  276. uint32_t itt;
  277. /** SNACK tag */
  278. uint32_t snack;
  279. /** Status sequence number */
  280. uint32_t statsn;
  281. /** Expected command sequence number */
  282. uint32_t expcmdsn;
  283. /** Maximum command sequence number */
  284. uint32_t maxcmdsn;
  285. /** Expected data sequence number */
  286. uint32_t expdatasn;
  287. /** Bidirectional read residual count */
  288. uint32_t bidi_residual_count;
  289. /** Residual count */
  290. uint32_t residual_count;
  291. };
  292. /** SCSI response opcode */
  293. #define ISCSI_OPCODE_SCSI_RESPONSE 0x21
  294. /** SCSI command completed at target */
  295. #define ISCSI_RESPONSE_COMMAND_COMPLETE 0x00
  296. /** SCSI target failure */
  297. #define ISCSI_RESPONSE_TARGET_FAILURE 0x01
  298. /** Data overflow occurred */
  299. #define ISCSI_RESPONSE_FLAG_OVERFLOW 0x20
  300. /** Data underflow occurred */
  301. #define ISCSI_RESPONSE_FLAG_UNDERFLOW 0x40
  302. /**
  303. * iSCSI data-in basic header segment
  304. *
  305. */
  306. struct iscsi_bhs_data_in {
  307. /** Opcode */
  308. uint8_t opcode;
  309. /** Flags */
  310. uint8_t flags;
  311. /** Reserved */
  312. uint8_t reserved_a;
  313. /** SCSI status code */
  314. uint8_t status;
  315. /** Segment lengths */
  316. union iscsi_segment_lengths lengths;
  317. /** Logical Unit Number */
  318. struct scsi_lun lun;
  319. /** Initiator Task Tag */
  320. uint32_t itt;
  321. /** Target Transfer Tag */
  322. uint32_t ttt;
  323. /** Status sequence number */
  324. uint32_t statsn;
  325. /** Expected command sequence number */
  326. uint32_t expcmdsn;
  327. /** Maximum command sequence number */
  328. uint32_t maxcmdsn;
  329. /** Data sequence number */
  330. uint32_t datasn;
  331. /** Buffer offset */
  332. uint32_t offset;
  333. /** Residual count */
  334. uint32_t residual_count;
  335. };
  336. /** Data-in opcode */
  337. #define ISCSI_OPCODE_DATA_IN 0x25
  338. /** Data requires acknowledgement */
  339. #define ISCSI_DATA_FLAG_ACKNOWLEDGE 0x40
  340. /** Data overflow occurred */
  341. #define ISCSI_DATA_FLAG_OVERFLOW 0x04
  342. /** Data underflow occurred */
  343. #define ISCSI_DATA_FLAG_UNDERFLOW 0x02
  344. /** SCSI status code and overflow/underflow flags are valid */
  345. #define ISCSI_DATA_FLAG_STATUS 0x01
  346. /**
  347. * iSCSI data-out basic header segment
  348. *
  349. */
  350. struct iscsi_bhs_data_out {
  351. /** Opcode */
  352. uint8_t opcode;
  353. /** Flags */
  354. uint8_t flags;
  355. /** Reserved */
  356. uint16_t reserved_a;
  357. /** Segment lengths */
  358. union iscsi_segment_lengths lengths;
  359. /** Logical Unit Number */
  360. struct scsi_lun lun;
  361. /** Initiator Task Tag */
  362. uint32_t itt;
  363. /** Target Transfer Tag */
  364. uint32_t ttt;
  365. /** Reserved */
  366. uint32_t reserved_b;
  367. /** Expected status sequence number */
  368. uint32_t expstatsn;
  369. /** Reserved */
  370. uint32_t reserved_c;
  371. /** Data sequence number */
  372. uint32_t datasn;
  373. /** Buffer offset */
  374. uint32_t offset;
  375. /** Reserved */
  376. uint32_t reserved_d;
  377. };
  378. /** Data-out opcode */
  379. #define ISCSI_OPCODE_DATA_OUT 0x05
  380. /**
  381. * iSCSI request to transfer basic header segment
  382. *
  383. */
  384. struct iscsi_bhs_r2t {
  385. /** Opcode */
  386. uint8_t opcode;
  387. /** Flags */
  388. uint8_t flags;
  389. /** Reserved */
  390. uint16_t reserved_a;
  391. /** Segment lengths */
  392. union iscsi_segment_lengths lengths;
  393. /** Logical Unit Number */
  394. struct scsi_lun lun;
  395. /** Initiator Task Tag */
  396. uint32_t itt;
  397. /** Target Transfer Tag */
  398. uint32_t ttt;
  399. /** Status sequence number */
  400. uint32_t statsn;
  401. /** Expected command sequence number */
  402. uint32_t expcmdsn;
  403. /** Maximum command sequence number */
  404. uint32_t maxcmdsn;
  405. /** R2T sequence number */
  406. uint32_t r2tsn;
  407. /** Buffer offset */
  408. uint32_t offset;
  409. /** Desired data transfer length */
  410. uint32_t len;
  411. };
  412. /** R2T opcode */
  413. #define ISCSI_OPCODE_R2T 0x31
  414. /**
  415. * iSCSI NOP-In basic header segment
  416. *
  417. */
  418. struct iscsi_nop_in {
  419. /** Opcode */
  420. uint8_t opcode;
  421. /** Reserved */
  422. uint8_t reserved_a[3];
  423. /** Segment lengths */
  424. union iscsi_segment_lengths lengths;
  425. /** Logical Unit Number */
  426. struct scsi_lun lun;
  427. /** Initiator Task Tag */
  428. uint32_t itt;
  429. /** Target Transfer Tag */
  430. uint32_t ttt;
  431. /** Status sequence number */
  432. uint32_t statsn;
  433. /** Expected command sequence number */
  434. uint32_t expcmdsn;
  435. /** Maximum command sequence number */
  436. uint32_t maxcmdsn;
  437. /** Reserved */
  438. uint8_t reserved_b[12];
  439. };
  440. /** NOP-In opcode */
  441. #define ISCSI_OPCODE_NOP_IN 0x20
  442. /**
  443. * An iSCSI basic header segment
  444. */
  445. union iscsi_bhs {
  446. struct iscsi_bhs_common common;
  447. struct iscsi_bhs_common_response common_response;
  448. struct iscsi_bhs_login_request login_request;
  449. struct iscsi_bhs_login_response login_response;
  450. struct iscsi_bhs_scsi_command scsi_command;
  451. struct iscsi_bhs_scsi_response scsi_response;
  452. struct iscsi_bhs_data_in data_in;
  453. struct iscsi_bhs_data_out data_out;
  454. struct iscsi_bhs_r2t r2t;
  455. struct iscsi_nop_in nop_in;
  456. unsigned char bytes[ sizeof ( struct iscsi_bhs_common ) ];
  457. };
  458. /** State of an iSCSI TX engine */
  459. enum iscsi_tx_state {
  460. /** Nothing to send */
  461. ISCSI_TX_IDLE = 0,
  462. /** Sending the basic header segment */
  463. ISCSI_TX_BHS,
  464. /** Sending the additional header segment */
  465. ISCSI_TX_AHS,
  466. /** Sending the data segment */
  467. ISCSI_TX_DATA,
  468. };
  469. /** State of an iSCSI RX engine */
  470. enum iscsi_rx_state {
  471. /** Receiving the basic header segment */
  472. ISCSI_RX_BHS = 0,
  473. /** Receiving the additional header segment */
  474. ISCSI_RX_AHS,
  475. /** Receiving the data segment */
  476. ISCSI_RX_DATA,
  477. /** Receiving the data segment padding */
  478. ISCSI_RX_DATA_PADDING,
  479. };
  480. /** An iSCSI session */
  481. struct iscsi_session {
  482. /** Reference counter */
  483. struct refcnt refcnt;
  484. /** SCSI command-issuing interface */
  485. struct interface control;
  486. /** SCSI command interface */
  487. struct interface data;
  488. /** Transport-layer socket */
  489. struct interface socket;
  490. /** Initiator IQN */
  491. char *initiator_iqn;
  492. /** Target address */
  493. char *target_address;
  494. /** Target port */
  495. unsigned int target_port;
  496. /** Target IQN */
  497. char *target_iqn;
  498. /** Session status
  499. *
  500. * This is the bitwise-OR of zero or more ISCSI_STATUS_XXX
  501. * constants.
  502. */
  503. int status;
  504. /** Initiator username (if any) */
  505. char *initiator_username;
  506. /** Initiator password (if any) */
  507. char *initiator_password;
  508. /** Target username (if any) */
  509. char *target_username;
  510. /** Target password (if any) */
  511. char *target_password;
  512. /** CHAP challenge (for target auth only)
  513. *
  514. * This is a block of random data; the first byte is used as
  515. * the CHAP identifier (CHAP_I) and the remainder as the CHAP
  516. * challenge (CHAP_C).
  517. */
  518. unsigned char chap_challenge[17];
  519. /** CHAP response (used for both initiator and target auth) */
  520. struct chap_response chap;
  521. /** Initiator session ID (IANA format) qualifier
  522. *
  523. * This is part of the ISID. It is generated randomly
  524. * whenever a new connection is opened.
  525. */
  526. uint16_t isid_iana_qual;
  527. /** Initiator task tag
  528. *
  529. * This is the tag of the current command. It is incremented
  530. * whenever a new command is started.
  531. */
  532. uint32_t itt;
  533. /** Target transfer tag
  534. *
  535. * This is the tag attached to a sequence of data-out PDUs in
  536. * response to an R2T.
  537. */
  538. uint32_t ttt;
  539. /** Transfer offset
  540. *
  541. * This is the offset for an in-progress sequence of data-out
  542. * PDUs in response to an R2T.
  543. */
  544. uint32_t transfer_offset;
  545. /** Transfer length
  546. *
  547. * This is the length for an in-progress sequence of data-out
  548. * PDUs in response to an R2T.
  549. */
  550. uint32_t transfer_len;
  551. /** Command sequence number
  552. *
  553. * This is the sequence number of the current command, used to
  554. * fill out the CmdSN field in iSCSI request PDUs. It is
  555. * updated with the value of the ExpCmdSN field whenever we
  556. * receive an iSCSI response PDU containing such a field.
  557. */
  558. uint32_t cmdsn;
  559. /** Status sequence number
  560. *
  561. * This is the most recent status sequence number present in
  562. * the StatSN field of an iSCSI response PDU containing such a
  563. * field. Whenever we send an iSCSI request PDU, we fill out
  564. * the ExpStatSN field with this value plus one.
  565. */
  566. uint32_t statsn;
  567. /** Basic header segment for current TX PDU */
  568. union iscsi_bhs tx_bhs;
  569. /** State of the TX engine */
  570. enum iscsi_tx_state tx_state;
  571. /** TX process */
  572. struct process process;
  573. /** Basic header segment for current RX PDU */
  574. union iscsi_bhs rx_bhs;
  575. /** State of the RX engine */
  576. enum iscsi_rx_state rx_state;
  577. /** Byte offset within the current RX state */
  578. size_t rx_offset;
  579. /** Length of the current RX state */
  580. size_t rx_len;
  581. /** Buffer for received data (not always used) */
  582. void *rx_buffer;
  583. /** Current SCSI command, if any */
  584. struct scsi_cmd *command;
  585. /** Target socket address (for boot firmware table) */
  586. struct sockaddr target_sockaddr;
  587. /** SCSI LUN (for boot firmware table) */
  588. struct scsi_lun lun;
  589. /** ACPI descriptor */
  590. struct acpi_descriptor desc;
  591. };
  592. /** iSCSI session is currently in the security negotiation phase */
  593. #define ISCSI_STATUS_SECURITY_NEGOTIATION_PHASE \
  594. ( ISCSI_LOGIN_CSG_SECURITY_NEGOTIATION | \
  595. ISCSI_LOGIN_NSG_OPERATIONAL_NEGOTIATION )
  596. /** iSCSI session is currently in the operational parameter
  597. * negotiation phase
  598. */
  599. #define ISCSI_STATUS_OPERATIONAL_NEGOTIATION_PHASE \
  600. ( ISCSI_LOGIN_CSG_OPERATIONAL_NEGOTIATION | \
  601. ISCSI_LOGIN_NSG_FULL_FEATURE_PHASE )
  602. /** iSCSI session is currently in the full feature phase */
  603. #define ISCSI_STATUS_FULL_FEATURE_PHASE ISCSI_LOGIN_CSG_FULL_FEATURE_PHASE
  604. /** Mask for all iSCSI session phases */
  605. #define ISCSI_STATUS_PHASE_MASK ( ISCSI_LOGIN_CSG_MASK | ISCSI_LOGIN_NSG_MASK )
  606. /** iSCSI session needs to send the initial security negotiation strings */
  607. #define ISCSI_STATUS_STRINGS_SECURITY 0x0100
  608. /** iSCSI session needs to send the CHAP_A string */
  609. #define ISCSI_STATUS_STRINGS_CHAP_ALGORITHM 0x0200
  610. /** iSCSI session needs to send the CHAP response */
  611. #define ISCSI_STATUS_STRINGS_CHAP_RESPONSE 0x0400
  612. /** iSCSI session needs to send the mutual CHAP challenge */
  613. #define ISCSI_STATUS_STRINGS_CHAP_CHALLENGE 0x0800
  614. /** iSCSI session needs to send the operational negotiation strings */
  615. #define ISCSI_STATUS_STRINGS_OPERATIONAL 0x1000
  616. /** Mask for all iSCSI "needs to send" flags */
  617. #define ISCSI_STATUS_STRINGS_MASK 0xff00
  618. /** Target has requested forward (initiator) authentication */
  619. #define ISCSI_STATUS_AUTH_FORWARD_REQUIRED 0x00010000
  620. /** Initiator requires target (reverse) authentication */
  621. #define ISCSI_STATUS_AUTH_REVERSE_REQUIRED 0x00020000
  622. /** Target authenticated itself correctly */
  623. #define ISCSI_STATUS_AUTH_REVERSE_OK 0x00040000
  624. /** Default initiator IQN prefix */
  625. #define ISCSI_DEFAULT_IQN_PREFIX "iqn.2010-04.org.ipxe"
  626. extern const struct setting
  627. initiator_iqn_setting __setting ( SETTING_SANBOOT_EXTRA, initiator-iqn );
  628. #endif /* _IPXE_ISCSI_H */