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

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