fcp.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef __FCPPROTO_H__
  18. #define __FCPPROTO_H__
  19. #include <protocol/scsi.h>
  20. #pragma pack(1)
  21. enum {
  22. FCP_RJT = 0x01000000, /* SRR reject */
  23. FCP_SRR_ACCEPT = 0x02000000, /* SRR accept */
  24. FCP_SRR = 0x14000000, /* Sequence Retransmission Request */
  25. };
  26. /*
  27. * SRR FC-4 LS payload
  28. */
  29. struct fc_srr_s{
  30. u32 ls_cmd;
  31. u32 ox_id:16; /* ox-id */
  32. u32 rx_id:16; /* rx-id */
  33. u32 ro; /* relative offset */
  34. u32 r_ctl:8; /* R_CTL for I.U. */
  35. u32 res:24;
  36. };
  37. /*
  38. * FCP_CMND definitions
  39. */
  40. #define FCP_CMND_CDB_LEN 16
  41. #define FCP_CMND_LUN_LEN 8
  42. struct fcp_cmnd_s{
  43. lun_t lun; /* 64-bit LU number */
  44. u8 crn; /* command reference number */
  45. #ifdef __BIGENDIAN
  46. u8 resvd:1,
  47. priority:4, /* FCP-3: SAM-3 priority */
  48. taskattr:3; /* scsi task attribute */
  49. #else
  50. u8 taskattr:3, /* scsi task attribute */
  51. priority:4, /* FCP-3: SAM-3 priority */
  52. resvd:1;
  53. #endif
  54. u8 tm_flags; /* task management flags */
  55. #ifdef __BIGENDIAN
  56. u8 addl_cdb_len:6, /* additional CDB length words */
  57. iodir:2; /* read/write FCP_DATA IUs */
  58. #else
  59. u8 iodir:2, /* read/write FCP_DATA IUs */
  60. addl_cdb_len:6; /* additional CDB length */
  61. #endif
  62. struct scsi_cdb_s cdb;
  63. /*
  64. * !!! additional cdb bytes follows here!!!
  65. */
  66. u32 fcp_dl; /* bytes to be transferred */
  67. };
  68. #define fcp_cmnd_cdb_len(_cmnd) ((_cmnd)->addl_cdb_len * 4 + FCP_CMND_CDB_LEN)
  69. #define fcp_cmnd_fcpdl(_cmnd) ((&(_cmnd)->fcp_dl)[(_cmnd)->addl_cdb_len])
  70. /*
  71. * fcp_cmnd_t.iodir field values
  72. */
  73. enum fcp_iodir{
  74. FCP_IODIR_NONE = 0,
  75. FCP_IODIR_WRITE = 1,
  76. FCP_IODIR_READ = 2,
  77. FCP_IODIR_RW = 3,
  78. };
  79. /*
  80. * Task attribute field
  81. */
  82. enum {
  83. FCP_TASK_ATTR_SIMPLE = 0,
  84. FCP_TASK_ATTR_HOQ = 1,
  85. FCP_TASK_ATTR_ORDERED = 2,
  86. FCP_TASK_ATTR_ACA = 4,
  87. FCP_TASK_ATTR_UNTAGGED = 5, /* obsolete in FCP-3 */
  88. };
  89. /*
  90. * Task management flags field - only one bit shall be set
  91. */
  92. #ifndef BIT
  93. #define BIT(_x) (1 << (_x))
  94. #endif
  95. enum fcp_tm_cmnd{
  96. FCP_TM_ABORT_TASK_SET = BIT(1),
  97. FCP_TM_CLEAR_TASK_SET = BIT(2),
  98. FCP_TM_LUN_RESET = BIT(4),
  99. FCP_TM_TARGET_RESET = BIT(5), /* obsolete in FCP-3 */
  100. FCP_TM_CLEAR_ACA = BIT(6),
  101. };
  102. /*
  103. * FCP_XFER_RDY IU defines
  104. */
  105. struct fcp_xfer_rdy_s{
  106. u32 data_ro;
  107. u32 burst_len;
  108. u32 reserved;
  109. };
  110. /*
  111. * FCP_RSP residue flags
  112. */
  113. enum fcp_residue{
  114. FCP_NO_RESIDUE = 0, /* no residue */
  115. FCP_RESID_OVER = 1, /* more data left that was not sent */
  116. FCP_RESID_UNDER = 2, /* less data than requested */
  117. };
  118. enum {
  119. FCP_RSPINFO_GOOD = 0,
  120. FCP_RSPINFO_DATALEN_MISMATCH = 1,
  121. FCP_RSPINFO_CMND_INVALID = 2,
  122. FCP_RSPINFO_ROLEN_MISMATCH = 3,
  123. FCP_RSPINFO_TM_NOT_SUPP = 4,
  124. FCP_RSPINFO_TM_FAILED = 5,
  125. };
  126. struct fcp_rspinfo_s{
  127. u32 res0:24;
  128. u32 rsp_code:8; /* response code (as above) */
  129. u32 res1;
  130. };
  131. struct fcp_resp_s{
  132. u32 reserved[2]; /* 2 words reserved */
  133. u16 reserved2;
  134. #ifdef __BIGENDIAN
  135. u8 reserved3:3;
  136. u8 fcp_conf_req:1; /* FCP_CONF is requested */
  137. u8 resid_flags:2; /* underflow/overflow */
  138. u8 sns_len_valid:1;/* sense len is valid */
  139. u8 rsp_len_valid:1;/* response len is valid */
  140. #else
  141. u8 rsp_len_valid:1;/* response len is valid */
  142. u8 sns_len_valid:1;/* sense len is valid */
  143. u8 resid_flags:2; /* underflow/overflow */
  144. u8 fcp_conf_req:1; /* FCP_CONF is requested */
  145. u8 reserved3:3;
  146. #endif
  147. u8 scsi_status; /* one byte SCSI status */
  148. u32 residue; /* residual data bytes */
  149. u32 sns_len; /* length od sense info */
  150. u32 rsp_len; /* length of response info */
  151. };
  152. #define fcp_snslen(__fcprsp) ((__fcprsp)->sns_len_valid ? \
  153. (__fcprsp)->sns_len : 0)
  154. #define fcp_rsplen(__fcprsp) ((__fcprsp)->rsp_len_valid ? \
  155. (__fcprsp)->rsp_len : 0)
  156. #define fcp_rspinfo(__fcprsp) ((struct fcp_rspinfo_s *)((__fcprsp) + 1))
  157. #define fcp_snsinfo(__fcprsp) (((u8 *)fcp_rspinfo(__fcprsp)) + \
  158. fcp_rsplen(__fcprsp))
  159. struct fcp_cmnd_fr_s{
  160. struct fchs_s fchs;
  161. struct fcp_cmnd_s fcp;
  162. };
  163. #pragma pack()
  164. #endif