fcp.h 4.6 KB

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