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 17KB

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