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.

srp.h 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. #ifndef _IPXE_SRP_H
  2. #define _IPXE_SRP_H
  3. /** @file
  4. *
  5. * SCSI RDMA Protocol
  6. *
  7. */
  8. FILE_LICENCE ( BSD2 );
  9. #include <stdint.h>
  10. #include <byteswap.h>
  11. #include <ipxe/iobuf.h>
  12. #include <ipxe/xfer.h>
  13. #include <ipxe/scsi.h>
  14. #include <ipxe/acpi.h>
  15. /*****************************************************************************
  16. *
  17. * Common fields
  18. *
  19. *****************************************************************************
  20. */
  21. /** An SRP information unit tag */
  22. union srp_tag {
  23. uint8_t bytes[8];
  24. uint32_t dwords[2];
  25. } __attribute__ (( packed ));
  26. /** SRP tag magic marker */
  27. #define SRP_TAG_MAGIC 0x69505845
  28. /** An SRP port ID */
  29. union srp_port_id {
  30. uint8_t bytes[16];
  31. uint32_t dwords[4];
  32. } __attribute__ (( packed ));
  33. /** SRP information unit common fields */
  34. struct srp_common {
  35. /** Information unit type */
  36. uint8_t type;
  37. /** Reserved */
  38. uint8_t reserved0[7];
  39. /** Tag */
  40. union srp_tag tag;
  41. } __attribute__ (( packed ));
  42. /*****************************************************************************
  43. *
  44. * Login request
  45. *
  46. *****************************************************************************
  47. */
  48. /** An SRP login request information unit */
  49. struct srp_login_req {
  50. /** Information unit type
  51. *
  52. * This must be @c SRP_LOGIN_REQ
  53. */
  54. uint8_t type;
  55. /** Reserved */
  56. uint8_t reserved0[7];
  57. /** Tag */
  58. union srp_tag tag;
  59. /** Requested maximum initiator to target IU length */
  60. uint32_t max_i_t_iu_len;
  61. /** Reserved */
  62. uint8_t reserved1[4];
  63. /** Required buffer formats
  64. *
  65. * This is the bitwise OR of one or more @c
  66. * SRP_LOGIN_REQ_FMT_XXX constants.
  67. */
  68. uint16_t required_buffer_formats;
  69. /** Flags
  70. *
  71. * This is the bitwise OR of zero or more @c
  72. * SRP_LOGIN_REQ_FLAG_XXX and @c SRP_LOGIN_REQ_MCA_XXX
  73. * constants.
  74. */
  75. uint8_t flags;
  76. /** Reserved */
  77. uint8_t reserved2[5];
  78. /** Initiator port identifier */
  79. union srp_port_id initiator;
  80. /** Target port identifier */
  81. union srp_port_id target;
  82. } __attribute__ (( packed ));
  83. /** Type of an SRP login request */
  84. #define SRP_LOGIN_REQ 0x00
  85. /** Require indirect data buffer descriptor format */
  86. #define SRP_LOGIN_REQ_FMT_IDBD 0x04
  87. /** Require direct data buffer descriptor format */
  88. #define SRP_LOGIN_REQ_FMT_DDBD 0x02
  89. /** Use solicited notification for asynchronous events */
  90. #define SRP_LOGIN_REQ_FLAG_AESOLNT 0x40
  91. /** Use solicited notification for credit request */
  92. #define SRP_LOGIN_REQ_FLAG_CRSOLNT 0x20
  93. /** Use solicited notification for logouts */
  94. #define SRP_LOGIN_REQ_FLAG_LOSOLNT 0x10
  95. /** Multi-channel action mask */
  96. #define SRP_LOGIN_REQ_MCA_MASK 0x03
  97. /** Single RDMA channel operation */
  98. #define SRP_LOGIN_REQ_MCA_SINGLE_CHANNEL 0x00
  99. /** Multiple independent RDMA channel operation */
  100. #define SRP_LOGIN_REQ_MCA_MULTIPLE_CHANNELS 0x01
  101. /*****************************************************************************
  102. *
  103. * Login response
  104. *
  105. *****************************************************************************
  106. */
  107. /** An SRP login response */
  108. struct srp_login_rsp {
  109. /** Information unit type
  110. *
  111. * This must be @c SRP_LOGIN_RSP
  112. */
  113. uint8_t type;
  114. /** Reserved */
  115. uint8_t reserved0[3];
  116. /** Request limit delta */
  117. uint32_t request_limit_delta;
  118. /** Tag */
  119. union srp_tag tag;
  120. /** Maximum initiator to target IU length */
  121. uint32_t max_i_t_iu_len;
  122. /** Maximum target to initiator IU length */
  123. uint32_t max_t_i_iu_len;
  124. /** Supported buffer formats
  125. *
  126. * This is the bitwise OR of one or more @c
  127. * SRP_LOGIN_RSP_FMT_XXX constants.
  128. */
  129. uint16_t supported_buffer_formats;
  130. /** Flags
  131. *
  132. * This is the bitwise OR of zero or more @c
  133. * SRP_LOGIN_RSP_FLAG_XXX and @c SRP_LOGIN_RSP_MCR_XXX
  134. * constants.
  135. */
  136. uint8_t flags;
  137. /** Reserved */
  138. uint8_t reserved1[25];
  139. } __attribute__ (( packed ));
  140. /** Type of an SRP login response */
  141. #define SRP_LOGIN_RSP 0xc0
  142. /** Indirect data buffer descriptor format supported */
  143. #define SRP_LOGIN_RSP_FMT_IDBD 0x04
  144. /** Direct data buffer descriptor format supported */
  145. #define SRP_LOGIN_RSP_FMT_DDBD 0x02
  146. /** Solicited notification is supported */
  147. #define SRP_LOGIN_RSP_FLAG_SOLNTSUP 0x10
  148. /** Multi-channel result mask */
  149. #define SRP_LOGIN_RSP_MCR_MASK 0x03
  150. /** No existing RDMA channels were associated with the same I_T nexus */
  151. #define SRP_LOGIN_RSP_MCR_NO_EXISTING_CHANNELS 0x00
  152. /** One or more existing RDMA channels were terminated */
  153. #define SRP_LOGIN_RSP_MCR_EXISTING_CHANNELS_TERMINATED 0x01
  154. /** One or more existing RDMA channels continue to operate independently */
  155. #define SRP_LOGIN_RSP_MCR_EXISTING_CHANNELS_CONTINUE 0x02
  156. /*****************************************************************************
  157. *
  158. * Login rejection
  159. *
  160. *****************************************************************************
  161. */
  162. /** An SRP login rejection */
  163. struct srp_login_rej {
  164. /** Information unit type
  165. *
  166. * This must be @c SRP_LOGIN_REJ
  167. */
  168. uint8_t type;
  169. /** Reserved */
  170. uint8_t reserved0[3];
  171. /** Reason
  172. *
  173. * This is a @c SRP_LOGIN_REJ_REASON_XXX constant.
  174. */
  175. uint32_t reason;
  176. /** Tag */
  177. union srp_tag tag;
  178. /** Reserved */
  179. uint8_t reserved1[8];
  180. /** Supported buffer formats
  181. *
  182. * This is the bitwise OR of one or more @c
  183. * SRP_LOGIN_REJ_FMT_XXX constants.
  184. */
  185. uint16_t supported_buffer_formats;
  186. /** Reserved */
  187. uint8_t reserved2[6];
  188. } __attribute__ (( packed ));
  189. /** Type of an SRP login rejection */
  190. #define SRP_LOGIN_REJ 0xc2
  191. /** Unable to establish RDMA channel, no reason specified */
  192. #define SRP_LOGIN_REJ_REASON_UNKNOWN 0x00010000UL
  193. /** Insufficient RDMA channel resources */
  194. #define SRP_LOGIN_REJ_REASON_INSUFFICIENT_RESOURCES 0x00010001UL
  195. /** Requested maximum initiator to target IU length value too large */
  196. #define SRP_LOGIN_REJ_REASON_BAD_MAX_I_T_IU_LEN 0x00010002UL
  197. /** Unable to associate RDMA channel with specified I_T nexus */
  198. #define SRP_LOGIN_REJ_REASON_CANNOT_ASSOCIATE 0x00010003UL
  199. /** One or more requested data buffer descriptor formats are not supported */
  200. #define SRP_LOGIN_REJ_REASON_UNSUPPORTED_BUFFER_FORMAT 0x00010004UL
  201. /** SRP target port does not support multiple RDMA channels per I_T nexus */
  202. #define SRP_LOGIN_REJ_REASON_NO_MULTIPLE_CHANNELS 0x00010005UL
  203. /** RDMA channel limit reached for this initiator */
  204. #define SRP_LOGIN_REJ_REASON_NO_MORE_CHANNELS 0x00010006UL
  205. /** SRP login rejection reason is defined */
  206. #define SRP_LOGIN_REJ_REASON_DEFINED( reason ) \
  207. ( ( (reason) & 0xfffffff0UL ) == 0x00010000UL )
  208. /** Indirect data buffer descriptor format supported */
  209. #define SRP_LOGIN_REJ_FMT_IDBD 0x04
  210. /** Direct data buffer descriptor format supported */
  211. #define SRP_LOGIN_REJ_FMT_DDBD 0x02
  212. /*****************************************************************************
  213. *
  214. * Initiator logout
  215. *
  216. *****************************************************************************
  217. */
  218. /** An SRP initiator logout request */
  219. struct srp_i_logout {
  220. /** Information unit type
  221. *
  222. * This must be @c SRP_I_LOGOUT
  223. */
  224. uint8_t type;
  225. /** Reserved */
  226. uint8_t reserved0[7];
  227. /** Tag */
  228. union srp_tag tag;
  229. } __attribute__ (( packed ));
  230. /** Type of an SRP initiator logout request */
  231. #define SRP_I_LOGOUT 0x03
  232. /*****************************************************************************
  233. *
  234. * Target logout
  235. *
  236. *****************************************************************************
  237. */
  238. /** An SRP target logout request */
  239. struct srp_t_logout {
  240. /** Information unit type
  241. *
  242. * This must be @c SRP_T_LOGOUT
  243. */
  244. uint8_t type;
  245. /** Flags
  246. *
  247. * This is the bitwise OR of zero or more @c
  248. * SRP_T_LOGOUT_FLAG_XXX constants.
  249. */
  250. uint8_t flags;
  251. /** Reserved */
  252. uint8_t reserved0[2];
  253. /** Reason
  254. *
  255. * This is a @c SRP_T_LOGOUT_REASON_XXX constant.
  256. */
  257. uint32_t reason;
  258. /** Tag */
  259. union srp_tag tag;
  260. } __attribute__ (( packed ));
  261. /** Type of an SRP target logout request */
  262. #define SRP_T_LOGOUT 0x80
  263. /** The initiator specified solicited notification of logouts */
  264. #define SRP_T_LOGOUT_FLAG_SOLNT 0x01
  265. /** No reason specified */
  266. #define SRP_T_LOGOUT_REASON_UNKNOWN 0x00000000UL
  267. /** Inactive RDMA channel (reclaiming resources) */
  268. #define SRP_T_LOGOUT_REASON_INACTIVE 0x00000001UL
  269. /** Invalid information unit type code received by SRP target port */
  270. #define SRP_T_LOGOUT_REASON_INVALID_TYPE 0x00000002UL
  271. /** SRP initiator port sent response with no corresponding request */
  272. #define SRP_T_LOGOUT_REASON_SPURIOUS_RESPONSE 0x00000003UL
  273. /** RDMA channel disconnected due to multi-channel action code in new login */
  274. #define SRP_T_LOGOUT_REASON_MCA 0x00000004UL
  275. /** Unsuppported format code value specified in data-out buffer descriptor */
  276. #define SRP_T_LOGOUT_UNSUPPORTED_DATA_OUT_FORMAT 0x00000005UL
  277. /** Unsuppported format code value specified in data-in buffer descriptor */
  278. #define SRP_T_LOGOUT_UNSUPPORTED_DATA_IN_FORMAT 0x00000006UL
  279. /** Invalid length for IU type */
  280. #define SRP_T_LOGOUT_INVALID_IU_LEN 0x00000008UL
  281. /*****************************************************************************
  282. *
  283. * Task management
  284. *
  285. *****************************************************************************
  286. */
  287. /** An SRP task management request */
  288. struct srp_tsk_mgmt {
  289. /** Information unit type
  290. *
  291. * This must be @c SRP_TSK_MGMT
  292. */
  293. uint8_t type;
  294. /** Flags
  295. *
  296. * This is the bitwise OR of zero or more
  297. * @c SRP_TSK_MGMT_FLAG_XXX constants.
  298. */
  299. uint8_t flags;
  300. /** Reserved */
  301. uint8_t reserved0[6];
  302. /** Tag */
  303. union srp_tag tag;
  304. /** Reserved */
  305. uint8_t reserved1[4];
  306. /** Logical unit number */
  307. struct scsi_lun lun;
  308. /** Reserved */
  309. uint8_t reserved2[2];
  310. /** Task management function
  311. *
  312. * This is a @c SRP_TASK_MGMT_FUNC_XXX constant
  313. */
  314. uint8_t function;
  315. /** Reserved */
  316. uint8_t reserved3[1];
  317. /** Tag of task to be managed */
  318. union srp_tag managed_tag;
  319. /** Reserved */
  320. uint8_t reserved4[8];
  321. } __attribute__ (( packed ));
  322. /** Type of an SRP task management request */
  323. #define SRP_TSK_MGMT 0x01
  324. /** Use solicited notification for unsuccessful completions */
  325. #define SRP_TSK_MGMT_FLAG_UCSOLNT 0x04
  326. /** Use solicited notification for successful completions */
  327. #define SRP_TSK_MGMT_FLAG_SCSOLNT 0x02
  328. /** The task manager shall perform an ABORT TASK function */
  329. #define SRP_TSK_MGMT_FUNC_ABORT_TASK 0x01
  330. /** The task manager shall perform an ABORT TASK SET function */
  331. #define SRP_TSK_MGMT_FUNC_ABORT_TASK_SET 0x02
  332. /** The task manager shall perform a CLEAR TASK SET function */
  333. #define SRP_TSK_MGMT_FUNC_CLEAR_TASK_SET 0x04
  334. /** The task manager shall perform a LOGICAL UNIT RESET function */
  335. #define SRP_TSK_MGMT_FUNC_LOGICAL_UNIT_RESET 0x08
  336. /** The task manager shall perform a CLEAR ACA function */
  337. #define SRP_TSK_MGMT_FUNC_CLEAR_ACA 0x40
  338. /*****************************************************************************
  339. *
  340. * SCSI command
  341. *
  342. *****************************************************************************
  343. */
  344. /** An SRP SCSI command */
  345. struct srp_cmd {
  346. /** Information unit type
  347. *
  348. * This must be @c SRP_CMD
  349. */
  350. uint8_t type;
  351. /** Flags
  352. *
  353. * This is the bitwise OR of zero or more @c SRP_CMD_FLAG_XXX
  354. * constants.
  355. */
  356. uint8_t flags;
  357. /** Reserved */
  358. uint8_t reserved0[3];
  359. /** Data buffer descriptor formats
  360. *
  361. * This is the bitwise OR of one @c SRP_CMD_DO_FMT_XXX and one @c
  362. * SRP_CMD_DI_FMT_XXX constant.
  363. */
  364. uint8_t data_buffer_formats;
  365. /** Data-out buffer descriptor count */
  366. uint8_t data_out_buffer_count;
  367. /** Data-in buffer descriptor count */
  368. uint8_t data_in_buffer_count;
  369. /** Tag */
  370. union srp_tag tag;
  371. /** Reserved */
  372. uint8_t reserved1[4];
  373. /** Logical unit number */
  374. struct scsi_lun lun;
  375. /** Reserved */
  376. uint8_t reserved2[1];
  377. /** Task attribute
  378. *
  379. * This is a @c SRP_CMD_TASK_ATTR_XXX constant.
  380. */
  381. uint8_t task_attr;
  382. /** Reserved */
  383. uint8_t reserved3[1];
  384. /** Additional CDB length */
  385. uint8_t additional_cdb_len;
  386. /** Command data block */
  387. union scsi_cdb cdb;
  388. } __attribute__ (( packed ));
  389. /** Type of an SRP SCSI command */
  390. #define SRP_CMD 0x02
  391. /** Use solicited notification for unsuccessful completions */
  392. #define SRP_CMD_FLAG_UCSOLNT 0x04
  393. /** Use solicited notification for successful completions */
  394. #define SRP_CMD_FLAG_SCSOLNT 0x02
  395. /** Data-out buffer format mask */
  396. #define SRP_CMD_DO_FMT_MASK 0xf0
  397. /** Direct data-out buffer format */
  398. #define SRP_CMD_DO_FMT_DIRECT 0x10
  399. /** Indirect data-out buffer format */
  400. #define SRP_CMD_DO_FMT_INDIRECT 0x20
  401. /** Data-in buffer format mask */
  402. #define SRP_CMD_DI_FMT_MASK 0x0f
  403. /** Direct data-in buffer format */
  404. #define SRP_CMD_DI_FMT_DIRECT 0x01
  405. /** Indirect data-in buffer format */
  406. #define SRP_CMD_DI_FMT_INDIRECT 0x02
  407. /** Use the rules for a simple task attribute */
  408. #define SRP_CMD_TASK_ATTR_SIMPLE 0x00
  409. /** Use the rules for a head of queue task attribute */
  410. #define SRP_CMD_TASK_ATTR_QUEUE_HEAD 0x01
  411. /** Use the rules for an ordered task attribute */
  412. #define SRP_CMD_TASK_ATTR_ORDERED 0x02
  413. /** Use the rules for an automatic contingent allegiance task attribute */
  414. #define SRP_CMD_TASK_ATTR_AUTOMATIC_CONTINGENT_ALLEGIANCE 0x08
  415. /** An SRP memory descriptor */
  416. struct srp_memory_descriptor {
  417. /** Virtual address */
  418. uint64_t address;
  419. /** Memory handle */
  420. uint32_t handle;
  421. /** Data length */
  422. uint32_t len;
  423. } __attribute__ (( packed ));
  424. /*****************************************************************************
  425. *
  426. * SCSI response
  427. *
  428. *****************************************************************************
  429. */
  430. /** An SRP SCSI response */
  431. struct srp_rsp {
  432. /** Information unit type
  433. *
  434. * This must be @c SRP_RSP
  435. */
  436. uint8_t type;
  437. /** Flags
  438. *
  439. * This is the bitwise OR of zero or more @c SRP_RSP_FLAG_XXX
  440. * constants.
  441. */
  442. uint8_t flags;
  443. /** Reserved */
  444. uint8_t reserved0[2];
  445. /** Request limit delta */
  446. uint32_t request_limit_delta;
  447. /** Tag */
  448. union srp_tag tag;
  449. /** Reserved */
  450. uint8_t reserved1[2];
  451. /** Valid fields
  452. *
  453. * This is the bitwise OR of zero or more @c SRP_RSP_VALID_XXX
  454. * constants.
  455. */
  456. uint8_t valid;
  457. /** Status
  458. *
  459. * This is the SCSI status code.
  460. */
  461. uint8_t status;
  462. /** Data-out residual count */
  463. uint32_t data_out_residual_count;
  464. /** Data-in residual count */
  465. uint32_t data_in_residual_count;
  466. /** Sense data list length */
  467. uint32_t sense_data_len;
  468. /** Response data list length */
  469. uint32_t response_data_len;
  470. } __attribute__ (( packed ));
  471. /** Type of an SRP SCSI response */
  472. #define SRP_RSP 0xc1
  473. /** The initiator specified solicited notification of this response */
  474. #define SRP_RSP_FLAG_SOLNT 0x01
  475. /** Data-in residual count field is valid and represents an underflow */
  476. #define SRP_RSP_VALID_DIUNDER 0x20
  477. /** Data-in residual count field is valid and represents an overflow */
  478. #define SRP_RSP_VALID_DIOVER 0x10
  479. /** Data-out residual count field is valid and represents an underflow */
  480. #define SRP_RSP_VALID_DOUNDER 0x08
  481. /** Data-out residual count field is valid and represents an overflow */
  482. #define SRP_RSP_VALID_DOOVER 0x04
  483. /** Sense data list length field is valid */
  484. #define SRP_RSP_VALID_SNSVALID 0x02
  485. /** Response data list length field is valid */
  486. #define SRP_RSP_VALID_RSPVALID 0x01
  487. /**
  488. * Get response data portion of SCSI response
  489. *
  490. * @v rsp SCSI response
  491. * @ret response_data Response data, or NULL if not present
  492. */
  493. static inline const void * srp_rsp_response_data ( const struct srp_rsp *rsp ) {
  494. return ( ( rsp->valid & SRP_RSP_VALID_RSPVALID ) ?
  495. ( ( ( const void * ) rsp ) + sizeof ( *rsp ) ) : NULL );
  496. }
  497. /**
  498. * Get length of response data portion of SCSI response
  499. *
  500. * @v rsp SCSI response
  501. * @ret response_data_len Response data length
  502. */
  503. static inline size_t srp_rsp_response_data_len ( const struct srp_rsp *rsp ) {
  504. return ( ( rsp->valid & SRP_RSP_VALID_RSPVALID ) ?
  505. ntohl ( rsp->response_data_len ) : 0 );
  506. }
  507. /**
  508. * Get sense data portion of SCSI response
  509. *
  510. * @v rsp SCSI response
  511. * @ret sense_data Sense data, or NULL if not present
  512. */
  513. static inline const void * srp_rsp_sense_data ( const struct srp_rsp *rsp ) {
  514. return ( ( rsp->valid & SRP_RSP_VALID_SNSVALID ) ?
  515. ( ( ( const void * ) rsp ) + sizeof ( *rsp ) +
  516. srp_rsp_response_data_len ( rsp ) ) : NULL );
  517. }
  518. /**
  519. * Get length of sense data portion of SCSI response
  520. *
  521. * @v rsp SCSI response
  522. * @ret sense_data_len Sense data length
  523. */
  524. static inline size_t srp_rsp_sense_data_len ( const struct srp_rsp *rsp ) {
  525. return ( ( rsp->valid & SRP_RSP_VALID_SNSVALID ) ?
  526. ntohl ( rsp->sense_data_len ) : 0 );
  527. }
  528. /*****************************************************************************
  529. *
  530. * Credit request
  531. *
  532. *****************************************************************************
  533. */
  534. /** An SRP credit request */
  535. struct srp_cred_req {
  536. /** Information unit type
  537. *
  538. * This must be @c SRP_CRED_REQ
  539. */
  540. uint8_t type;
  541. /** Flags
  542. *
  543. * This is the bitwise OR of zero or more
  544. * @c SRP_CRED_REQ_FLAG_XXX constants.
  545. */
  546. uint8_t flags;
  547. /** Reserved */
  548. uint8_t reserved0[2];
  549. /** Request limit delta */
  550. uint32_t request_limit_delta;
  551. /** Tag */
  552. union srp_tag tag;
  553. } __attribute__ (( packed ));
  554. /** Type of an SRP credit request */
  555. #define SRP_CRED_REQ 0x81
  556. /** The initiator specified solicited notification of credit requests */
  557. #define SRP_CRED_REQ_FLAG_SOLNT 0x01
  558. /*****************************************************************************
  559. *
  560. * Credit response
  561. *
  562. *****************************************************************************
  563. */
  564. /** An SRP credit response */
  565. struct srp_cred_rsp {
  566. /** Information unit type
  567. *
  568. * This must be @c SRP_CRED_RSP
  569. */
  570. uint8_t type;
  571. /** Reserved */
  572. uint8_t reserved0[7];
  573. /** Tag */
  574. union srp_tag tag;
  575. } __attribute__ (( packed ));
  576. /** Type of an SRP credit response */
  577. #define SRP_CRED_RSP 0x41
  578. /*****************************************************************************
  579. *
  580. * Asynchronous event request
  581. *
  582. *****************************************************************************
  583. */
  584. /** An SRP asynchronous event request */
  585. struct srp_aer_req {
  586. /** Information unit type
  587. *
  588. * This must be @c SRP_AER_REQ
  589. */
  590. uint8_t type;
  591. /** Flags
  592. *
  593. * This is the bitwise OR of zero or more @c
  594. * SRP_AER_REQ_FLAG_XXX constants.
  595. */
  596. uint8_t flags;
  597. /** Reserved */
  598. uint8_t reserved0[2];
  599. /** Request limit delta */
  600. uint32_t request_limit_delta;
  601. /** Tag */
  602. union srp_tag tag;
  603. /** Reserved */
  604. uint8_t reserved1[4];
  605. /** Logical unit number */
  606. struct scsi_lun lun;
  607. /** Sense data list length */
  608. uint32_t sense_data_len;
  609. /** Reserved */
  610. uint8_t reserved2[4];
  611. } __attribute__ (( packed ));
  612. /** Type of an SRP asynchronous event request */
  613. #define SRP_AER_REQ 0x82
  614. /** The initiator specified solicited notification of asynchronous events */
  615. #define SRP_AER_REQ_FLAG_SOLNT 0x01
  616. /**
  617. * Get sense data portion of asynchronous event request
  618. *
  619. * @v aer_req SRP asynchronous event request
  620. * @ret sense_data Sense data
  621. */
  622. static inline __always_inline void *
  623. srp_aer_req_sense_data ( struct srp_aer_req *aer_req ) {
  624. return ( ( ( void * ) aer_req ) + sizeof ( *aer_req ) );
  625. }
  626. /**
  627. * Get length of sense data portion of asynchronous event request
  628. *
  629. * @v aer_req SRP asynchronous event request
  630. * @ret sense_data_len Sense data length
  631. */
  632. static inline __always_inline size_t
  633. srp_aer_req_sense_data_len ( struct srp_aer_req *aer_req ) {
  634. return ( ntohl ( aer_req->sense_data_len ) );
  635. }
  636. /*****************************************************************************
  637. *
  638. * Asynchronous event response
  639. *
  640. *****************************************************************************
  641. */
  642. /** An SRP asynchronous event response */
  643. struct srp_aer_rsp {
  644. /** Information unit type
  645. *
  646. * This must be @c SRP_AER_RSP
  647. */
  648. uint8_t type;
  649. /** Reserved */
  650. uint8_t reserved0[7];
  651. /** Tag */
  652. union srp_tag tag;
  653. } __attribute__ (( packed ));
  654. /** Type of an SRP asynchronous event response */
  655. #define SRP_AER_RSP 0x42
  656. /*****************************************************************************
  657. *
  658. * SRP boot firmware table
  659. *
  660. * The working draft specification for the SRP boot firmware table can
  661. * be found at
  662. *
  663. * http://ipxe.org/wiki/srp/sbft
  664. *
  665. *****************************************************************************
  666. */
  667. /** SRP Boot Firmware Table signature */
  668. #define SBFT_SIG ACPI_SIGNATURE ( 's', 'B', 'F', 'T' )
  669. /** An offset from the start of the sBFT */
  670. typedef uint16_t sbft_off_t;
  671. /**
  672. * SRP Boot Firmware Table
  673. */
  674. struct sbft_table {
  675. /** ACPI header */
  676. struct acpi_header acpi;
  677. /** Offset to SCSI subtable */
  678. sbft_off_t scsi_offset;
  679. /** Offset to SRP subtable */
  680. sbft_off_t srp_offset;
  681. /** Offset to IB subtable, if present */
  682. sbft_off_t ib_offset;
  683. /** Reserved */
  684. uint8_t reserved[6];
  685. } __attribute__ (( packed ));
  686. /**
  687. * sBFT SCSI subtable
  688. */
  689. struct sbft_scsi_subtable {
  690. /** LUN */
  691. struct scsi_lun lun;
  692. } __attribute__ (( packed ));
  693. /**
  694. * sBFT SRP subtable
  695. */
  696. struct sbft_srp_subtable {
  697. /** Initiator port identifier */
  698. union srp_port_id initiator;
  699. /** Target port identifier */
  700. union srp_port_id target;
  701. } __attribute__ (( packed ));
  702. /*****************************************************************************
  703. *
  704. * SRP devices
  705. *
  706. *****************************************************************************
  707. */
  708. extern int srp_open ( struct interface *block, struct interface *socket,
  709. union srp_port_id *initiator, union srp_port_id *target,
  710. uint32_t memory_handle, struct scsi_lun *lun );
  711. #endif /* _IPXE_SRP_H */