fcx.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /*
  2. * Functions for assembling fcx enabled I/O control blocks.
  3. *
  4. * Copyright IBM Corp. 2008
  5. * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
  6. */
  7. #ifndef _ASM_S390_FCX_H
  8. #define _ASM_S390_FCX_H
  9. #include <linux/types.h>
  10. #define TCW_FORMAT_DEFAULT 0
  11. #define TCW_TIDAW_FORMAT_DEFAULT 0
  12. #define TCW_FLAGS_INPUT_TIDA (1 << (23 - 5))
  13. #define TCW_FLAGS_TCCB_TIDA (1 << (23 - 6))
  14. #define TCW_FLAGS_OUTPUT_TIDA (1 << (23 - 7))
  15. #define TCW_FLAGS_TIDAW_FORMAT(x) ((x) & 3) << (23 - 9)
  16. #define TCW_FLAGS_GET_TIDAW_FORMAT(x) (((x) >> (23 - 9)) & 3)
  17. /**
  18. * struct tcw - Transport Control Word (TCW)
  19. * @format: TCW format
  20. * @flags: TCW flags
  21. * @tccbl: Transport-Command-Control-Block Length
  22. * @r: Read Operations
  23. * @w: Write Operations
  24. * @output: Output-Data Address
  25. * @input: Input-Data Address
  26. * @tsb: Transport-Status-Block Address
  27. * @tccb: Transport-Command-Control-Block Address
  28. * @output_count: Output Count
  29. * @input_count: Input Count
  30. * @intrg: Interrogate TCW Address
  31. */
  32. struct tcw {
  33. u32 format:2;
  34. u32 :6;
  35. u32 flags:24;
  36. u32 :8;
  37. u32 tccbl:6;
  38. u32 r:1;
  39. u32 w:1;
  40. u32 :16;
  41. u64 output;
  42. u64 input;
  43. u64 tsb;
  44. u64 tccb;
  45. u32 output_count;
  46. u32 input_count;
  47. u32 :32;
  48. u32 :32;
  49. u32 :32;
  50. u32 intrg;
  51. } __attribute__ ((packed, aligned(64)));
  52. #define TIDAW_FLAGS_LAST (1 << (7 - 0))
  53. #define TIDAW_FLAGS_SKIP (1 << (7 - 1))
  54. #define TIDAW_FLAGS_DATA_INT (1 << (7 - 2))
  55. #define TIDAW_FLAGS_TTIC (1 << (7 - 3))
  56. #define TIDAW_FLAGS_INSERT_CBC (1 << (7 - 4))
  57. /**
  58. * struct tidaw - Transport-Indirect-Addressing Word (TIDAW)
  59. * @flags: TIDAW flags. Can be an arithmetic OR of the following constants:
  60. * %TIDAW_FLAGS_LAST, %TIDAW_FLAGS_SKIP, %TIDAW_FLAGS_DATA_INT,
  61. * %TIDAW_FLAGS_TTIC, %TIDAW_FLAGS_INSERT_CBC
  62. * @count: Count
  63. * @addr: Address
  64. */
  65. struct tidaw {
  66. u32 flags:8;
  67. u32 :24;
  68. u32 count;
  69. u64 addr;
  70. } __attribute__ ((packed, aligned(16)));
  71. /**
  72. * struct tsa_iostat - I/O-Status Transport-Status Area (IO-Stat TSA)
  73. * @dev_time: Device Time
  74. * @def_time: Defer Time
  75. * @queue_time: Queue Time
  76. * @dev_busy_time: Device-Busy Time
  77. * @dev_act_time: Device-Active-Only Time
  78. * @sense: Sense Data (if present)
  79. */
  80. struct tsa_iostat {
  81. u32 dev_time;
  82. u32 def_time;
  83. u32 queue_time;
  84. u32 dev_busy_time;
  85. u32 dev_act_time;
  86. u8 sense[32];
  87. } __attribute__ ((packed));
  88. /**
  89. * struct tsa_ddpcs - Device-Detected-Program-Check Transport-Status Area (DDPC TSA)
  90. * @rc: Reason Code
  91. * @rcq: Reason Code Qualifier
  92. * @sense: Sense Data (if present)
  93. */
  94. struct tsa_ddpc {
  95. u32 :24;
  96. u32 rc:8;
  97. u8 rcq[16];
  98. u8 sense[32];
  99. } __attribute__ ((packed));
  100. #define TSA_INTRG_FLAGS_CU_STATE_VALID (1 << (7 - 0))
  101. #define TSA_INTRG_FLAGS_DEV_STATE_VALID (1 << (7 - 1))
  102. #define TSA_INTRG_FLAGS_OP_STATE_VALID (1 << (7 - 2))
  103. /**
  104. * struct tsa_intrg - Interrogate Transport-Status Area (Intrg. TSA)
  105. * @format: Format
  106. * @flags: Flags. Can be an arithmetic OR of the following constants:
  107. * %TSA_INTRG_FLAGS_CU_STATE_VALID, %TSA_INTRG_FLAGS_DEV_STATE_VALID,
  108. * %TSA_INTRG_FLAGS_OP_STATE_VALID
  109. * @cu_state: Controle-Unit State
  110. * @dev_state: Device State
  111. * @op_state: Operation State
  112. * @sd_info: State-Dependent Information
  113. * @dl_id: Device-Level Identifier
  114. * @dd_data: Device-Dependent Data
  115. */
  116. struct tsa_intrg {
  117. u32 format:8;
  118. u32 flags:8;
  119. u32 cu_state:8;
  120. u32 dev_state:8;
  121. u32 op_state:8;
  122. u32 :24;
  123. u8 sd_info[12];
  124. u32 dl_id;
  125. u8 dd_data[28];
  126. } __attribute__ ((packed));
  127. #define TSB_FORMAT_NONE 0
  128. #define TSB_FORMAT_IOSTAT 1
  129. #define TSB_FORMAT_DDPC 2
  130. #define TSB_FORMAT_INTRG 3
  131. #define TSB_FLAGS_DCW_OFFSET_VALID (1 << (7 - 0))
  132. #define TSB_FLAGS_COUNT_VALID (1 << (7 - 1))
  133. #define TSB_FLAGS_CACHE_MISS (1 << (7 - 2))
  134. #define TSB_FLAGS_TIME_VALID (1 << (7 - 3))
  135. #define TSB_FLAGS_FORMAT(x) ((x) & 7)
  136. #define TSB_FORMAT(t) ((t)->flags & 7)
  137. /**
  138. * struct tsb - Transport-Status Block (TSB)
  139. * @length: Length
  140. * @flags: Flags. Can be an arithmetic OR of the following constants:
  141. * %TSB_FLAGS_DCW_OFFSET_VALID, %TSB_FLAGS_COUNT_VALID, %TSB_FLAGS_CACHE_MISS,
  142. * %TSB_FLAGS_TIME_VALID
  143. * @dcw_offset: DCW Offset
  144. * @count: Count
  145. * @tsa: Transport-Status-Area
  146. */
  147. struct tsb {
  148. u32 length:8;
  149. u32 flags:8;
  150. u32 dcw_offset:16;
  151. u32 count;
  152. u32 :32;
  153. union {
  154. struct tsa_iostat iostat;
  155. struct tsa_ddpc ddpc;
  156. struct tsa_intrg intrg;
  157. } __attribute__ ((packed)) tsa;
  158. } __attribute__ ((packed, aligned(8)));
  159. #define DCW_INTRG_FORMAT_DEFAULT 0
  160. #define DCW_INTRG_RC_UNSPECIFIED 0
  161. #define DCW_INTRG_RC_TIMEOUT 1
  162. #define DCW_INTRG_RCQ_UNSPECIFIED 0
  163. #define DCW_INTRG_RCQ_PRIMARY 1
  164. #define DCW_INTRG_RCQ_SECONDARY 2
  165. #define DCW_INTRG_FLAGS_MPM (1 << (7 - 0))
  166. #define DCW_INTRG_FLAGS_PPR (1 << (7 - 1))
  167. #define DCW_INTRG_FLAGS_CRIT (1 << (7 - 2))
  168. /**
  169. * struct dcw_intrg_data - Interrogate DCW data
  170. * @format: Format. Should be %DCW_INTRG_FORMAT_DEFAULT
  171. * @rc: Reason Code. Can be one of %DCW_INTRG_RC_UNSPECIFIED,
  172. * %DCW_INTRG_RC_TIMEOUT
  173. * @rcq: Reason Code Qualifier: Can be one of %DCW_INTRG_RCQ_UNSPECIFIED,
  174. * %DCW_INTRG_RCQ_PRIMARY, %DCW_INTRG_RCQ_SECONDARY
  175. * @lpm: Logical-Path Mask
  176. * @pam: Path-Available Mask
  177. * @pim: Path-Installed Mask
  178. * @timeout: Timeout
  179. * @flags: Flags. Can be an arithmetic OR of %DCW_INTRG_FLAGS_MPM,
  180. * %DCW_INTRG_FLAGS_PPR, %DCW_INTRG_FLAGS_CRIT
  181. * @time: Time
  182. * @prog_id: Program Identifier
  183. * @prog_data: Program-Dependent Data
  184. */
  185. struct dcw_intrg_data {
  186. u32 format:8;
  187. u32 rc:8;
  188. u32 rcq:8;
  189. u32 lpm:8;
  190. u32 pam:8;
  191. u32 pim:8;
  192. u32 timeout:16;
  193. u32 flags:8;
  194. u32 :24;
  195. u32 :32;
  196. u64 time;
  197. u64 prog_id;
  198. u8 prog_data[0];
  199. } __attribute__ ((packed));
  200. #define DCW_FLAGS_CC (1 << (7 - 1))
  201. #define DCW_CMD_WRITE 0x01
  202. #define DCW_CMD_READ 0x02
  203. #define DCW_CMD_CONTROL 0x03
  204. #define DCW_CMD_SENSE 0x04
  205. #define DCW_CMD_SENSE_ID 0xe4
  206. #define DCW_CMD_INTRG 0x40
  207. /**
  208. * struct dcw - Device-Command Word (DCW)
  209. * @cmd: Command Code. Can be one of %DCW_CMD_WRITE, %DCW_CMD_READ,
  210. * %DCW_CMD_CONTROL, %DCW_CMD_SENSE, %DCW_CMD_SENSE_ID, %DCW_CMD_INTRG
  211. * @flags: Flags. Can be an arithmetic OR of %DCW_FLAGS_CC
  212. * @cd_count: Control-Data Count
  213. * @count: Count
  214. * @cd: Control Data
  215. */
  216. struct dcw {
  217. u32 cmd:8;
  218. u32 flags:8;
  219. u32 :8;
  220. u32 cd_count:8;
  221. u32 count;
  222. u8 cd[0];
  223. } __attribute__ ((packed));
  224. #define TCCB_FORMAT_DEFAULT 0x7f
  225. #define TCCB_MAX_DCW 30
  226. #define TCCB_MAX_SIZE (sizeof(struct tccb_tcah) + \
  227. TCCB_MAX_DCW * sizeof(struct dcw) + \
  228. sizeof(struct tccb_tcat))
  229. #define TCCB_SAC_DEFAULT 0x1ffe
  230. #define TCCB_SAC_INTRG 0x1fff
  231. /**
  232. * struct tccb_tcah - Transport-Command-Area Header (TCAH)
  233. * @format: Format. Should be %TCCB_FORMAT_DEFAULT
  234. * @tcal: Transport-Command-Area Length
  235. * @sac: Service-Action Code. Can be one of %TCCB_SAC_DEFAULT, %TCCB_SAC_INTRG
  236. * @prio: Priority
  237. */
  238. struct tccb_tcah {
  239. u32 format:8;
  240. u32 :24;
  241. u32 :24;
  242. u32 tcal:8;
  243. u32 sac:16;
  244. u32 :8;
  245. u32 prio:8;
  246. u32 :32;
  247. } __attribute__ ((packed));
  248. /**
  249. * struct tccb_tcat - Transport-Command-Area Trailer (TCAT)
  250. * @count: Transport Count
  251. */
  252. struct tccb_tcat {
  253. u32 :32;
  254. u32 count;
  255. } __attribute__ ((packed));
  256. /**
  257. * struct tccb - (partial) Transport-Command-Control Block (TCCB)
  258. * @tcah: TCAH
  259. * @tca: Transport-Command Area
  260. */
  261. struct tccb {
  262. struct tccb_tcah tcah;
  263. u8 tca[0];
  264. } __attribute__ ((packed, aligned(8)));
  265. struct tcw *tcw_get_intrg(struct tcw *tcw);
  266. void *tcw_get_data(struct tcw *tcw);
  267. struct tccb *tcw_get_tccb(struct tcw *tcw);
  268. struct tsb *tcw_get_tsb(struct tcw *tcw);
  269. void tcw_init(struct tcw *tcw, int r, int w);
  270. void tcw_finalize(struct tcw *tcw, int num_tidaws);
  271. void tcw_set_intrg(struct tcw *tcw, struct tcw *intrg_tcw);
  272. void tcw_set_data(struct tcw *tcw, void *data, int use_tidal);
  273. void tcw_set_tccb(struct tcw *tcw, struct tccb *tccb);
  274. void tcw_set_tsb(struct tcw *tcw, struct tsb *tsb);
  275. void tccb_init(struct tccb *tccb, size_t tccb_size, u32 sac);
  276. void tsb_init(struct tsb *tsb);
  277. struct dcw *tccb_add_dcw(struct tccb *tccb, size_t tccb_size, u8 cmd, u8 flags,
  278. void *cd, u8 cd_count, u32 count);
  279. struct tidaw *tcw_add_tidaw(struct tcw *tcw, int num_tidaws, u8 flags,
  280. void *addr, u32 count);
  281. #endif /* _ASM_S390_FCX_H */