fc_fcp.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright(c) 2007 Intel Corporation. All rights reserved.
  4. *
  5. * Maintained at www.Open-FCoE.org
  6. */
  7. #ifndef _FC_FCP_H_
  8. #define _FC_FCP_H_
  9. #include <scsi/scsi.h>
  10. /*
  11. * Fibre Channel Protocol for SCSI.
  12. * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005.
  13. */
  14. /*
  15. * fc/fs.h defines FC_TYPE_FCP.
  16. */
  17. /*
  18. * Service parameter page parameters (word 3 bits) for Process Login.
  19. */
  20. #define FCP_SPPF_TASK_RETRY_ID 0x0200 /* task retry ID requested */
  21. #define FCP_SPPF_RETRY 0x0100 /* retry supported */
  22. #define FCP_SPPF_CONF_COMPL 0x0080 /* confirmed completion allowed */
  23. #define FCP_SPPF_OVLY_ALLOW 0x0040 /* data overlay allowed */
  24. #define FCP_SPPF_INIT_FCN 0x0020 /* initiator function */
  25. #define FCP_SPPF_TARG_FCN 0x0010 /* target function */
  26. #define FCP_SPPF_RD_XRDY_DIS 0x0002 /* disable XFER_RDY for reads */
  27. #define FCP_SPPF_WR_XRDY_DIS 0x0001 /* disable XFER_RDY for writes */
  28. /*
  29. * FCP_CMND IU Payload.
  30. */
  31. struct fcp_cmnd {
  32. struct scsi_lun fc_lun; /* logical unit number */
  33. __u8 fc_cmdref; /* command reference number */
  34. __u8 fc_pri_ta; /* priority and task attribute */
  35. __u8 fc_tm_flags; /* task management flags */
  36. __u8 fc_flags; /* additional len & flags */
  37. __u8 fc_cdb[16]; /* base CDB */
  38. __be32 fc_dl; /* data length (must follow fc_cdb) */
  39. };
  40. #define FCP_CMND_LEN 32 /* expected length of structure */
  41. struct fcp_cmnd32 {
  42. struct scsi_lun fc_lun; /* logical unit number */
  43. __u8 fc_cmdref; /* command reference number */
  44. __u8 fc_pri_ta; /* priority and task attribute */
  45. __u8 fc_tm_flags; /* task management flags */
  46. __u8 fc_flags; /* additional len & flags */
  47. __u8 fc_cdb[32]; /* base CDB */
  48. __be32 fc_dl; /* data length (must follow fc_cdb) */
  49. };
  50. #define FCP_CMND32_LEN 48 /* expected length of structure */
  51. #define FCP_CMND32_ADD_LEN (16 / 4) /* Additional cdb length */
  52. /*
  53. * fc_pri_ta.
  54. */
  55. #define FCP_PTA_SIMPLE 0 /* simple task attribute */
  56. #define FCP_PTA_HEADQ 1 /* head of queue task attribute */
  57. #define FCP_PTA_ORDERED 2 /* ordered task attribute */
  58. #define FCP_PTA_ACA 4 /* auto. contingent allegiance */
  59. #define FCP_PTA_MASK 7 /* mask for task attribute field */
  60. #define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */
  61. #define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */
  62. /*
  63. * fc_tm_flags - task management flags field.
  64. */
  65. #define FCP_TMF_CLR_ACA 0x40 /* clear ACA condition */
  66. #define FCP_TMF_TGT_RESET 0x20 /* target reset task management,
  67. deprecated as of FCP-3 */
  68. #define FCP_TMF_LUN_RESET 0x10 /* logical unit reset task management */
  69. #define FCP_TMF_CLR_TASK_SET 0x04 /* clear task set */
  70. #define FCP_TMF_ABT_TASK_SET 0x02 /* abort task set */
  71. /*
  72. * fc_flags.
  73. * Bits 7:2 are the additional FCP_CDB length / 4.
  74. */
  75. #define FCP_CFL_LEN_MASK 0xfc /* mask for additional length */
  76. #define FCP_CFL_LEN_SHIFT 2 /* shift bits for additional length */
  77. #define FCP_CFL_RDDATA 0x02 /* read data */
  78. #define FCP_CFL_WRDATA 0x01 /* write data */
  79. /*
  80. * FCP_TXRDY IU - transfer ready payload.
  81. */
  82. struct fcp_txrdy {
  83. __be32 ft_data_ro; /* data relative offset */
  84. __be32 ft_burst_len; /* burst length */
  85. __u8 _ft_resvd[4]; /* reserved */
  86. };
  87. #define FCP_TXRDY_LEN 12 /* expected length of structure */
  88. /*
  89. * FCP_RESP IU - response payload.
  90. *
  91. * The response payload comes in three parts: the flags/status, the
  92. * sense/response lengths and the sense data/response info section.
  93. *
  94. * From FCP3r04, note 6 of section 9.5.13:
  95. *
  96. * Some early implementations presented the FCP_RSP IU without the FCP_RESID,
  97. * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER,
  98. * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This
  99. * non-standard behavior should be tolerated.
  100. *
  101. * All response frames will always contain the fcp_resp template. Some
  102. * will also include the fcp_resp_len template.
  103. *
  104. * From Table 23, the FCP_RSP_INFO can either be 4 bytes or 8 bytes, both
  105. * are valid length.
  106. */
  107. struct fcp_resp {
  108. __u8 _fr_resvd[8]; /* reserved */
  109. __be16 fr_retry_delay; /* retry delay timer */
  110. __u8 fr_flags; /* flags */
  111. __u8 fr_status; /* SCSI status code */
  112. };
  113. #define FCP_RESP_LEN 12 /* expected length of structure */
  114. struct fcp_resp_ext {
  115. __be32 fr_resid; /* Residual value */
  116. __be32 fr_sns_len; /* SCSI Sense length */
  117. __be32 fr_rsp_len; /* Response Info length */
  118. /*
  119. * Optionally followed by RSP info and/or SNS info and/or
  120. * bidirectional read residual length, if any.
  121. */
  122. };
  123. #define FCP_RESP_EXT_LEN 12 /* expected length of the structure */
  124. struct fcp_resp_rsp_info {
  125. __u8 _fr_resvd[3]; /* reserved */
  126. __u8 rsp_code; /* Response Info Code */
  127. __u8 _fr_resvd2[4]; /* reserved */
  128. };
  129. #define FCP_RESP_RSP_INFO_LEN4 4 /* without reserved field */
  130. #define FCP_RESP_RSP_INFO_LEN8 8 /* with reserved field */
  131. struct fcp_resp_with_ext {
  132. struct fcp_resp resp;
  133. struct fcp_resp_ext ext;
  134. };
  135. #define FCP_RESP_WITH_EXT (FCP_RESP_LEN + FCP_RESP_EXT_LEN)
  136. /*
  137. * fr_flags.
  138. */
  139. #define FCP_BIDI_RSP 0x80 /* bidirectional read response */
  140. #define FCP_BIDI_READ_UNDER 0x40 /* bidir. read less than requested */
  141. #define FCP_BIDI_READ_OVER 0x20 /* DL insufficient for full transfer */
  142. #define FCP_CONF_REQ 0x10 /* confirmation requested */
  143. #define FCP_RESID_UNDER 0x08 /* transfer shorter than expected */
  144. #define FCP_RESID_OVER 0x04 /* DL insufficient for full transfer */
  145. #define FCP_SNS_LEN_VAL 0x02 /* SNS_LEN field is valid */
  146. #define FCP_RSP_LEN_VAL 0x01 /* RSP_LEN field is valid */
  147. /*
  148. * rsp_codes
  149. */
  150. enum fcp_resp_rsp_codes {
  151. FCP_TMF_CMPL = 0,
  152. FCP_DATA_LEN_INVALID = 1,
  153. FCP_CMND_FIELDS_INVALID = 2,
  154. FCP_DATA_PARAM_MISMATCH = 3,
  155. FCP_TMF_REJECTED = 4,
  156. FCP_TMF_FAILED = 5,
  157. FCP_TMF_INVALID_LUN = 9,
  158. };
  159. /*
  160. * FCP SRR Link Service request - Sequence Retransmission Request.
  161. */
  162. struct fcp_srr {
  163. __u8 srr_op; /* opcode ELS_SRR */
  164. __u8 srr_resvd[3]; /* opcode / reserved - must be zero */
  165. __be16 srr_ox_id; /* OX_ID of failed command */
  166. __be16 srr_rx_id; /* RX_ID of failed command */
  167. __be32 srr_rel_off; /* relative offset */
  168. __u8 srr_r_ctl; /* r_ctl for the information unit */
  169. __u8 srr_resvd2[3]; /* reserved */
  170. };
  171. /*
  172. * Feature bits in name server FC-4 Features object.
  173. */
  174. #define FCP_FEAT_TARG (1 << 0) /* target function supported */
  175. #define FCP_FEAT_INIT (1 << 1) /* initiator function supported */
  176. #endif /* _FC_FCP_H_ */