1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Functions for assembling fcx enabled I/O control blocks.
5 * Copyright IBM Corp. 2008
9 #ifndef _ASM_S390_FCX_H
10 #define _ASM_S390_FCX_H
12 #include <linux/types.h>
13 #include <asm/dma-types.h>
15 #define TCW_FORMAT_DEFAULT 0
16 #define TCW_TIDAW_FORMAT_DEFAULT 0
17 #define TCW_FLAGS_INPUT_TIDA (1 << (23 - 5))
18 #define TCW_FLAGS_TCCB_TIDA (1 << (23 - 6))
19 #define TCW_FLAGS_OUTPUT_TIDA (1 << (23 - 7))
20 #define TCW_FLAGS_TIDAW_FORMAT(x) ((x) & 3) << (23 - 9)
21 #define TCW_FLAGS_GET_TIDAW_FORMAT(x) (((x) >> (23 - 9)) & 3)
24 * struct tcw - Transport Control Word (TCW)
27 * @tccbl: Transport-Command-Control-Block Length
29 * @w: Write Operations
30 * @output: Output-Data Address
31 * @input: Input-Data Address
32 * @tsb: Transport-Status-Block Address
33 * @tccb: Transport-Command-Control-Block Address
34 * @output_count: Output Count
35 * @input_count: Input Count
36 * @intrg: Interrogate TCW Address
57 } __attribute__ ((packed, aligned(64)));
59 #define TIDAW_FLAGS_LAST (1 << (7 - 0))
60 #define TIDAW_FLAGS_SKIP (1 << (7 - 1))
61 #define TIDAW_FLAGS_DATA_INT (1 << (7 - 2))
62 #define TIDAW_FLAGS_TTIC (1 << (7 - 3))
63 #define TIDAW_FLAGS_INSERT_CBC (1 << (7 - 4))
66 * struct tidaw - Transport-Indirect-Addressing Word (TIDAW)
67 * @flags: TIDAW flags. Can be an arithmetic OR of the following constants:
68 * %TIDAW_FLAGS_LAST, %TIDAW_FLAGS_SKIP, %TIDAW_FLAGS_DATA_INT,
69 * %TIDAW_FLAGS_TTIC, %TIDAW_FLAGS_INSERT_CBC
78 } __attribute__ ((packed, aligned(16)));
81 * struct tsa_iostat - I/O-Status Transport-Status Area (IO-Stat TSA)
82 * @dev_time: Device Time
83 * @def_time: Defer Time
84 * @queue_time: Queue Time
85 * @dev_busy_time: Device-Busy Time
86 * @dev_act_time: Device-Active-Only Time
87 * @sense: Sense Data (if present)
96 } __attribute__ ((packed));
99 * struct tsa_ddpcs - Device-Detected-Program-Check Transport-Status Area (DDPC TSA)
101 * @rcq: Reason Code Qualifier
102 * @sense: Sense Data (if present)
109 } __attribute__ ((packed));
111 #define TSA_INTRG_FLAGS_CU_STATE_VALID (1 << (7 - 0))
112 #define TSA_INTRG_FLAGS_DEV_STATE_VALID (1 << (7 - 1))
113 #define TSA_INTRG_FLAGS_OP_STATE_VALID (1 << (7 - 2))
116 * struct tsa_intrg - Interrogate Transport-Status Area (Intrg. TSA)
118 * @flags: Flags. Can be an arithmetic OR of the following constants:
119 * %TSA_INTRG_FLAGS_CU_STATE_VALID, %TSA_INTRG_FLAGS_DEV_STATE_VALID,
120 * %TSA_INTRG_FLAGS_OP_STATE_VALID
121 * @cu_state: Controle-Unit State
122 * @dev_state: Device State
123 * @op_state: Operation State
124 * @sd_info: State-Dependent Information
125 * @dl_id: Device-Level Identifier
126 * @dd_data: Device-Dependent Data
138 } __attribute__ ((packed));
140 #define TSB_FORMAT_NONE 0
141 #define TSB_FORMAT_IOSTAT 1
142 #define TSB_FORMAT_DDPC 2
143 #define TSB_FORMAT_INTRG 3
145 #define TSB_FLAGS_DCW_OFFSET_VALID (1 << (7 - 0))
146 #define TSB_FLAGS_COUNT_VALID (1 << (7 - 1))
147 #define TSB_FLAGS_CACHE_MISS (1 << (7 - 2))
148 #define TSB_FLAGS_TIME_VALID (1 << (7 - 3))
149 #define TSB_FLAGS_FORMAT(x) ((x) & 7)
150 #define TSB_FORMAT(t) ((t)->flags & 7)
153 * struct tsb - Transport-Status Block (TSB)
155 * @flags: Flags. Can be an arithmetic OR of the following constants:
156 * %TSB_FLAGS_DCW_OFFSET_VALID, %TSB_FLAGS_COUNT_VALID, %TSB_FLAGS_CACHE_MISS,
157 * %TSB_FLAGS_TIME_VALID
158 * @dcw_offset: DCW Offset
160 * @tsa: Transport-Status-Area
169 struct tsa_iostat iostat;
170 struct tsa_ddpc ddpc;
171 struct tsa_intrg intrg;
172 } __attribute__ ((packed)) tsa;
173 } __attribute__ ((packed, aligned(8)));
175 #define DCW_INTRG_FORMAT_DEFAULT 0
177 #define DCW_INTRG_RC_UNSPECIFIED 0
178 #define DCW_INTRG_RC_TIMEOUT 1
180 #define DCW_INTRG_RCQ_UNSPECIFIED 0
181 #define DCW_INTRG_RCQ_PRIMARY 1
182 #define DCW_INTRG_RCQ_SECONDARY 2
184 #define DCW_INTRG_FLAGS_MPM (1 << (7 - 0))
185 #define DCW_INTRG_FLAGS_PPR (1 << (7 - 1))
186 #define DCW_INTRG_FLAGS_CRIT (1 << (7 - 2))
189 * struct dcw_intrg_data - Interrogate DCW data
190 * @format: Format. Should be %DCW_INTRG_FORMAT_DEFAULT
191 * @rc: Reason Code. Can be one of %DCW_INTRG_RC_UNSPECIFIED,
192 * %DCW_INTRG_RC_TIMEOUT
193 * @rcq: Reason Code Qualifier: Can be one of %DCW_INTRG_RCQ_UNSPECIFIED,
194 * %DCW_INTRG_RCQ_PRIMARY, %DCW_INTRG_RCQ_SECONDARY
195 * @lpm: Logical-Path Mask
196 * @pam: Path-Available Mask
197 * @pim: Path-Installed Mask
199 * @flags: Flags. Can be an arithmetic OR of %DCW_INTRG_FLAGS_MPM,
200 * %DCW_INTRG_FLAGS_PPR, %DCW_INTRG_FLAGS_CRIT
202 * @prog_id: Program Identifier
203 * @prog_data: Program-Dependent Data
205 struct dcw_intrg_data {
219 } __attribute__ ((packed));
221 #define DCW_FLAGS_CC (1 << (7 - 1))
223 #define DCW_CMD_WRITE 0x01
224 #define DCW_CMD_READ 0x02
225 #define DCW_CMD_CONTROL 0x03
226 #define DCW_CMD_SENSE 0x04
227 #define DCW_CMD_SENSE_ID 0xe4
228 #define DCW_CMD_INTRG 0x40
231 * struct dcw - Device-Command Word (DCW)
232 * @cmd: Command Code. Can be one of %DCW_CMD_WRITE, %DCW_CMD_READ,
233 * %DCW_CMD_CONTROL, %DCW_CMD_SENSE, %DCW_CMD_SENSE_ID, %DCW_CMD_INTRG
234 * @flags: Flags. Can be an arithmetic OR of %DCW_FLAGS_CC
235 * @cd_count: Control-Data Count
246 } __attribute__ ((packed));
248 #define TCCB_FORMAT_DEFAULT 0x7f
249 #define TCCB_MAX_DCW 30
250 #define TCCB_MAX_SIZE (sizeof(struct tccb_tcah) + \
251 TCCB_MAX_DCW * sizeof(struct dcw) + \
252 sizeof(struct tccb_tcat))
253 #define TCCB_SAC_DEFAULT 0x1ffe
254 #define TCCB_SAC_INTRG 0x1fff
257 * struct tccb_tcah - Transport-Command-Area Header (TCAH)
258 * @format: Format. Should be %TCCB_FORMAT_DEFAULT
259 * @tcal: Transport-Command-Area Length
260 * @sac: Service-Action Code. Can be one of %TCCB_SAC_DEFAULT, %TCCB_SAC_INTRG
272 } __attribute__ ((packed));
275 * struct tccb_tcat - Transport-Command-Area Trailer (TCAT)
276 * @count: Transport Count
281 } __attribute__ ((packed));
284 * struct tccb - (partial) Transport-Command-Control Block (TCCB)
286 * @tca: Transport-Command Area
289 struct tccb_tcah tcah;
291 } __attribute__ ((packed, aligned(8)));
293 struct tcw *tcw_get_intrg(struct tcw *tcw);
294 void *tcw_get_data(struct tcw *tcw);
295 struct tccb *tcw_get_tccb(struct tcw *tcw);
296 struct tsb *tcw_get_tsb(struct tcw *tcw);
298 void tcw_init(struct tcw *tcw, int r, int w);
299 void tcw_finalize(struct tcw *tcw, int num_tidaws);
301 void tcw_set_intrg(struct tcw *tcw, struct tcw *intrg_tcw);
302 void tcw_set_data(struct tcw *tcw, void *data, int use_tidal);
303 void tcw_set_tccb(struct tcw *tcw, struct tccb *tccb);
304 void tcw_set_tsb(struct tcw *tcw, struct tsb *tsb);
306 void tccb_init(struct tccb *tccb, size_t tccb_size, u32 sac);
307 void tsb_init(struct tsb *tsb);
308 struct dcw *tccb_add_dcw(struct tccb *tccb, size_t tccb_size, u8 cmd, u8 flags,
309 void *cd, u8 cd_count, u32 count);
310 struct tidaw *tcw_add_tidaw(struct tcw *tcw, int num_tidaws, u8 flags,
311 void *addr, u32 count);
313 #endif /* _ASM_S390_FCX_H */