Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

fcp.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef _IPXE_FCP_H
  2. #define _IPXE_FCP_H
  3. /**
  4. * @file
  5. *
  6. * Fibre Channel Protocol
  7. *
  8. */
  9. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  10. #include <stdint.h>
  11. #include <ipxe/fc.h>
  12. #include <ipxe/fcels.h>
  13. #include <ipxe/scsi.h>
  14. /** An FCP command IU */
  15. struct fcp_cmnd {
  16. /** SCSI LUN */
  17. struct scsi_lun lun;
  18. /** Command reference number */
  19. uint8_t ref;
  20. /** Priority and task attributes */
  21. uint8_t priority;
  22. /** Task management flags */
  23. uint8_t flags;
  24. /** Direction */
  25. uint8_t dirn;
  26. /** SCSI CDB */
  27. union scsi_cdb cdb;
  28. /** Data length */
  29. uint32_t len;
  30. } __attribute__ (( packed ));
  31. /** Command includes data-out */
  32. #define FCP_CMND_WRDATA 0x01
  33. /** Command includes data-in */
  34. #define FCP_CMND_RDDATA 0x02
  35. /** FCP tag magic marker */
  36. #define FCP_TAG_MAGIC 0x18ae0000
  37. /** An FCP transfer ready IU */
  38. struct fcp_xfer_rdy {
  39. /** Relative offset of data */
  40. uint32_t offset;
  41. /** Burst length */
  42. uint32_t len;
  43. /** Reserved */
  44. uint32_t reserved;
  45. } __attribute__ (( packed ));
  46. /** An FCP response IU */
  47. struct fcp_rsp {
  48. /** Reserved */
  49. uint8_t reserved[8];
  50. /** Retry delay timer */
  51. uint16_t retry_delay;
  52. /** Flags */
  53. uint8_t flags;
  54. /** SCSI status code */
  55. uint8_t status;
  56. /** Residual data count */
  57. uint32_t residual;
  58. /** Sense data length */
  59. uint32_t sense_len;
  60. /** Response data length */
  61. uint32_t response_len;
  62. } __attribute__ (( packed ));
  63. /** Response length field is valid */
  64. #define FCP_RSP_RESPONSE_LEN_VALID 0x01
  65. /** Sense length field is valid */
  66. #define FCP_RSP_SENSE_LEN_VALID 0x02
  67. /** Residual represents overrun */
  68. #define FCP_RSP_RESIDUAL_OVERRUN 0x04
  69. /** Residual represents underrun */
  70. #define FCP_RSP_RESIDUAL_UNDERRUN 0x08
  71. /**
  72. * Get response data portion of FCP response
  73. *
  74. * @v rsp FCP response
  75. * @ret response_data Response data, or NULL if not present
  76. */
  77. static inline void * fcp_rsp_response_data ( struct fcp_rsp *rsp ) {
  78. return ( ( rsp->flags & FCP_RSP_RESPONSE_LEN_VALID ) ?
  79. ( ( ( void * ) rsp ) + sizeof ( *rsp ) ) : NULL );
  80. }
  81. /**
  82. * Get length of response data portion of FCP response
  83. *
  84. * @v rsp FCP response
  85. * @ret response_data_len Response data length
  86. */
  87. static inline size_t fcp_rsp_response_data_len ( struct fcp_rsp *rsp ) {
  88. return ( ( rsp->flags & FCP_RSP_RESPONSE_LEN_VALID ) ?
  89. ntohl ( rsp->response_len ) : 0 );
  90. }
  91. /**
  92. * Get sense data portion of FCP response
  93. *
  94. * @v rsp FCP response
  95. * @ret sense_data Sense data, or NULL if not present
  96. */
  97. static inline void * fcp_rsp_sense_data ( struct fcp_rsp *rsp ) {
  98. return ( ( rsp->flags & FCP_RSP_SENSE_LEN_VALID ) ?
  99. ( ( ( void * ) rsp ) + sizeof ( *rsp ) +
  100. fcp_rsp_response_data_len ( rsp ) ) : NULL );
  101. }
  102. /**
  103. * Get length of sense data portion of FCP response
  104. *
  105. * @v rsp FCP response
  106. * @ret sense_data_len Sense data length
  107. */
  108. static inline size_t fcp_rsp_sense_data_len ( struct fcp_rsp *rsp ) {
  109. return ( ( rsp->flags & FCP_RSP_SENSE_LEN_VALID ) ?
  110. ntohl ( rsp->sense_len ) : 0 );
  111. }
  112. /** An FCP PRLI service parameter page */
  113. struct fcp_prli_service_parameters {
  114. /** Flags */
  115. uint32_t flags;
  116. } __attribute__ (( packed ));
  117. /** Write FCP_XFER_RDY disabled */
  118. #define FCP_PRLI_NO_WRITE_RDY 0x0001
  119. /** Read FCP_XFER_RDY disabled */
  120. #define FCP_PRLI_NO_READ_RDY 0x0002
  121. /** Has target functionality */
  122. #define FCP_PRLI_TARGET 0x0010
  123. /** Has initiator functionality */
  124. #define FCP_PRLI_INITIATOR 0x0020
  125. /** Data overlay allowed */
  126. #define FCP_PRLI_OVERLAY 0x0040
  127. /** Confirm completion allowed */
  128. #define FCP_PRLI_CONF 0x0080
  129. /** Retransmission supported */
  130. #define FCP_PRLI_RETRY 0x0100
  131. /** Task retry identification */
  132. #define FCP_PRLI_TASK_RETRY 0x0200
  133. /** REC ELS supported */
  134. #define FCP_PRLI_REC 0x0400
  135. /** Enhanced discovery supported */
  136. #define FCP_PRLI_ENH_DISC 0x0800
  137. #endif /* _IPXE_FCP_H */