Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  Functions for assembling fcx enabled I/O control blocks.
0004  *
0005  *    Copyright IBM Corp. 2008
0006  *    Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
0007  */
0008 
0009 #ifndef _ASM_S390_FCX_H
0010 #define _ASM_S390_FCX_H
0011 
0012 #include <linux/types.h>
0013 
0014 #define TCW_FORMAT_DEFAULT      0
0015 #define TCW_TIDAW_FORMAT_DEFAULT    0
0016 #define TCW_FLAGS_INPUT_TIDA        (1 << (23 - 5))
0017 #define TCW_FLAGS_TCCB_TIDA     (1 << (23 - 6))
0018 #define TCW_FLAGS_OUTPUT_TIDA       (1 << (23 - 7))
0019 #define TCW_FLAGS_TIDAW_FORMAT(x)   ((x) & 3) << (23 - 9)
0020 #define TCW_FLAGS_GET_TIDAW_FORMAT(x)   (((x) >> (23 - 9)) & 3)
0021 
0022 /**
0023  * struct tcw - Transport Control Word (TCW)
0024  * @format: TCW format
0025  * @flags: TCW flags
0026  * @tccbl: Transport-Command-Control-Block Length
0027  * @r: Read Operations
0028  * @w: Write Operations
0029  * @output: Output-Data Address
0030  * @input: Input-Data Address
0031  * @tsb: Transport-Status-Block Address
0032  * @tccb: Transport-Command-Control-Block Address
0033  * @output_count: Output Count
0034  * @input_count: Input Count
0035  * @intrg: Interrogate TCW Address
0036  */
0037 struct tcw {
0038     u32 format:2;
0039     u32 :6;
0040     u32 flags:24;
0041     u32 :8;
0042     u32 tccbl:6;
0043     u32 r:1;
0044     u32 w:1;
0045     u32 :16;
0046     u64 output;
0047     u64 input;
0048     u64 tsb;
0049     u64 tccb;
0050     u32 output_count;
0051     u32 input_count;
0052     u32 :32;
0053     u32 :32;
0054     u32 :32;
0055     u32 intrg;
0056 } __attribute__ ((packed, aligned(64)));
0057 
0058 #define TIDAW_FLAGS_LAST        (1 << (7 - 0))
0059 #define TIDAW_FLAGS_SKIP        (1 << (7 - 1))
0060 #define TIDAW_FLAGS_DATA_INT        (1 << (7 - 2))
0061 #define TIDAW_FLAGS_TTIC        (1 << (7 - 3))
0062 #define TIDAW_FLAGS_INSERT_CBC      (1 << (7 - 4))
0063 
0064 /**
0065  * struct tidaw - Transport-Indirect-Addressing Word (TIDAW)
0066  * @flags: TIDAW flags. Can be an arithmetic OR of the following constants:
0067  * %TIDAW_FLAGS_LAST, %TIDAW_FLAGS_SKIP, %TIDAW_FLAGS_DATA_INT,
0068  * %TIDAW_FLAGS_TTIC, %TIDAW_FLAGS_INSERT_CBC
0069  * @count: Count
0070  * @addr: Address
0071  */
0072 struct tidaw {
0073     u32 flags:8;
0074     u32 :24;
0075     u32 count;
0076     u64 addr;
0077 } __attribute__ ((packed, aligned(16)));
0078 
0079 /**
0080  * struct tsa_iostat - I/O-Status Transport-Status Area (IO-Stat TSA)
0081  * @dev_time: Device Time
0082  * @def_time: Defer Time
0083  * @queue_time: Queue Time
0084  * @dev_busy_time: Device-Busy Time
0085  * @dev_act_time: Device-Active-Only Time
0086  * @sense: Sense Data (if present)
0087  */
0088 struct tsa_iostat {
0089     u32 dev_time;
0090     u32 def_time;
0091     u32 queue_time;
0092     u32 dev_busy_time;
0093     u32 dev_act_time;
0094     u8 sense[32];
0095 } __attribute__ ((packed));
0096 
0097 /**
0098  * struct tsa_ddpcs - Device-Detected-Program-Check Transport-Status Area (DDPC TSA)
0099  * @rc: Reason Code
0100  * @rcq: Reason Code Qualifier
0101  * @sense: Sense Data (if present)
0102  */
0103 struct tsa_ddpc {
0104     u32 :24;
0105     u32 rc:8;
0106     u8 rcq[16];
0107     u8 sense[32];
0108 } __attribute__ ((packed));
0109 
0110 #define TSA_INTRG_FLAGS_CU_STATE_VALID      (1 << (7 - 0))
0111 #define TSA_INTRG_FLAGS_DEV_STATE_VALID     (1 << (7 - 1))
0112 #define TSA_INTRG_FLAGS_OP_STATE_VALID      (1 << (7 - 2))
0113 
0114 /**
0115  * struct tsa_intrg - Interrogate Transport-Status Area (Intrg. TSA)
0116  * @format: Format
0117  * @flags: Flags. Can be an arithmetic OR of the following constants:
0118  * %TSA_INTRG_FLAGS_CU_STATE_VALID, %TSA_INTRG_FLAGS_DEV_STATE_VALID,
0119  * %TSA_INTRG_FLAGS_OP_STATE_VALID
0120  * @cu_state: Controle-Unit State
0121  * @dev_state: Device State
0122  * @op_state: Operation State
0123  * @sd_info: State-Dependent Information
0124  * @dl_id: Device-Level Identifier
0125  * @dd_data: Device-Dependent Data
0126  */
0127 struct tsa_intrg {
0128     u32 format:8;
0129     u32 flags:8;
0130     u32 cu_state:8;
0131     u32 dev_state:8;
0132     u32 op_state:8;
0133     u32 :24;
0134     u8 sd_info[12];
0135     u32 dl_id;
0136     u8 dd_data[28];
0137 } __attribute__ ((packed));
0138 
0139 #define TSB_FORMAT_NONE     0
0140 #define TSB_FORMAT_IOSTAT   1
0141 #define TSB_FORMAT_DDPC     2
0142 #define TSB_FORMAT_INTRG    3
0143 
0144 #define TSB_FLAGS_DCW_OFFSET_VALID  (1 << (7 - 0))
0145 #define TSB_FLAGS_COUNT_VALID       (1 << (7 - 1))
0146 #define TSB_FLAGS_CACHE_MISS        (1 << (7 - 2))
0147 #define TSB_FLAGS_TIME_VALID        (1 << (7 - 3))
0148 #define TSB_FLAGS_FORMAT(x)     ((x) & 7)
0149 #define TSB_FORMAT(t)           ((t)->flags & 7)
0150 
0151 /**
0152  * struct tsb - Transport-Status Block (TSB)
0153  * @length: Length
0154  * @flags: Flags. Can be an arithmetic OR of the following constants:
0155  * %TSB_FLAGS_DCW_OFFSET_VALID, %TSB_FLAGS_COUNT_VALID, %TSB_FLAGS_CACHE_MISS,
0156  * %TSB_FLAGS_TIME_VALID
0157  * @dcw_offset: DCW Offset
0158  * @count: Count
0159  * @tsa: Transport-Status-Area
0160  */
0161 struct tsb {
0162     u32 length:8;
0163     u32 flags:8;
0164     u32 dcw_offset:16;
0165     u32 count;
0166     u32 :32;
0167     union {
0168         struct tsa_iostat iostat;
0169         struct tsa_ddpc ddpc;
0170         struct tsa_intrg intrg;
0171     } __attribute__ ((packed)) tsa;
0172 } __attribute__ ((packed, aligned(8)));
0173 
0174 #define DCW_INTRG_FORMAT_DEFAULT    0
0175 
0176 #define DCW_INTRG_RC_UNSPECIFIED    0
0177 #define DCW_INTRG_RC_TIMEOUT        1
0178 
0179 #define DCW_INTRG_RCQ_UNSPECIFIED   0
0180 #define DCW_INTRG_RCQ_PRIMARY       1
0181 #define DCW_INTRG_RCQ_SECONDARY     2
0182 
0183 #define DCW_INTRG_FLAGS_MPM     (1 << (7 - 0))
0184 #define DCW_INTRG_FLAGS_PPR     (1 << (7 - 1))
0185 #define DCW_INTRG_FLAGS_CRIT        (1 << (7 - 2))
0186 
0187 /**
0188  * struct dcw_intrg_data - Interrogate DCW data
0189  * @format: Format. Should be %DCW_INTRG_FORMAT_DEFAULT
0190  * @rc: Reason Code. Can be one of %DCW_INTRG_RC_UNSPECIFIED,
0191  * %DCW_INTRG_RC_TIMEOUT
0192  * @rcq: Reason Code Qualifier: Can be one of %DCW_INTRG_RCQ_UNSPECIFIED,
0193  * %DCW_INTRG_RCQ_PRIMARY, %DCW_INTRG_RCQ_SECONDARY
0194  * @lpm: Logical-Path Mask
0195  * @pam: Path-Available Mask
0196  * @pim: Path-Installed Mask
0197  * @timeout: Timeout
0198  * @flags: Flags. Can be an arithmetic OR of %DCW_INTRG_FLAGS_MPM,
0199  * %DCW_INTRG_FLAGS_PPR, %DCW_INTRG_FLAGS_CRIT
0200  * @time: Time
0201  * @prog_id: Program Identifier
0202  * @prog_data: Program-Dependent Data
0203  */
0204 struct dcw_intrg_data {
0205     u32 format:8;
0206     u32 rc:8;
0207     u32 rcq:8;
0208     u32 lpm:8;
0209     u32 pam:8;
0210     u32 pim:8;
0211     u32 timeout:16;
0212     u32 flags:8;
0213     u32 :24;
0214     u32 :32;
0215     u64 time;
0216     u64 prog_id;
0217     u8  prog_data[];
0218 } __attribute__ ((packed));
0219 
0220 #define DCW_FLAGS_CC        (1 << (7 - 1))
0221 
0222 #define DCW_CMD_WRITE       0x01
0223 #define DCW_CMD_READ        0x02
0224 #define DCW_CMD_CONTROL     0x03
0225 #define DCW_CMD_SENSE       0x04
0226 #define DCW_CMD_SENSE_ID    0xe4
0227 #define DCW_CMD_INTRG       0x40
0228 
0229 /**
0230  * struct dcw - Device-Command Word (DCW)
0231  * @cmd: Command Code. Can be one of %DCW_CMD_WRITE, %DCW_CMD_READ,
0232  * %DCW_CMD_CONTROL, %DCW_CMD_SENSE, %DCW_CMD_SENSE_ID, %DCW_CMD_INTRG
0233  * @flags: Flags. Can be an arithmetic OR of %DCW_FLAGS_CC
0234  * @cd_count: Control-Data Count
0235  * @count: Count
0236  * @cd: Control Data
0237  */
0238 struct dcw {
0239     u32 cmd:8;
0240     u32 flags:8;
0241     u32 :8;
0242     u32 cd_count:8;
0243     u32 count;
0244     u8 cd[];
0245 } __attribute__ ((packed));
0246 
0247 #define TCCB_FORMAT_DEFAULT 0x7f
0248 #define TCCB_MAX_DCW        30
0249 #define TCCB_MAX_SIZE       (sizeof(struct tccb_tcah) + \
0250                  TCCB_MAX_DCW * sizeof(struct dcw) + \
0251                  sizeof(struct tccb_tcat))
0252 #define TCCB_SAC_DEFAULT    0x1ffe
0253 #define TCCB_SAC_INTRG      0x1fff
0254 
0255 /**
0256  * struct tccb_tcah - Transport-Command-Area Header (TCAH)
0257  * @format: Format. Should be %TCCB_FORMAT_DEFAULT
0258  * @tcal: Transport-Command-Area Length
0259  * @sac: Service-Action Code. Can be one of %TCCB_SAC_DEFAULT, %TCCB_SAC_INTRG
0260  * @prio: Priority
0261  */
0262 struct tccb_tcah {
0263     u32 format:8;
0264     u32 :24;
0265     u32 :24;
0266     u32 tcal:8;
0267     u32 sac:16;
0268     u32 :8;
0269     u32 prio:8;
0270     u32 :32;
0271 } __attribute__ ((packed));
0272 
0273 /**
0274  * struct tccb_tcat - Transport-Command-Area Trailer (TCAT)
0275  * @count: Transport Count
0276  */
0277 struct tccb_tcat {
0278     u32 :32;
0279     u32 count;
0280 } __attribute__ ((packed));
0281 
0282 /**
0283  * struct tccb - (partial) Transport-Command-Control Block (TCCB)
0284  * @tcah: TCAH
0285  * @tca: Transport-Command Area
0286  */
0287 struct tccb {
0288     struct tccb_tcah tcah;
0289     u8 tca[0];
0290 } __attribute__ ((packed, aligned(8)));
0291 
0292 struct tcw *tcw_get_intrg(struct tcw *tcw);
0293 void *tcw_get_data(struct tcw *tcw);
0294 struct tccb *tcw_get_tccb(struct tcw *tcw);
0295 struct tsb *tcw_get_tsb(struct tcw *tcw);
0296 
0297 void tcw_init(struct tcw *tcw, int r, int w);
0298 void tcw_finalize(struct tcw *tcw, int num_tidaws);
0299 
0300 void tcw_set_intrg(struct tcw *tcw, struct tcw *intrg_tcw);
0301 void tcw_set_data(struct tcw *tcw, void *data, int use_tidal);
0302 void tcw_set_tccb(struct tcw *tcw, struct tccb *tccb);
0303 void tcw_set_tsb(struct tcw *tcw, struct tsb *tsb);
0304 
0305 void tccb_init(struct tccb *tccb, size_t tccb_size, u32 sac);
0306 void tsb_init(struct tsb *tsb);
0307 struct dcw *tccb_add_dcw(struct tccb *tccb, size_t tccb_size, u8 cmd, u8 flags,
0308              void *cd, u8 cd_count, u32 count);
0309 struct tidaw *tcw_add_tidaw(struct tcw *tcw, int num_tidaws, u8 flags,
0310                 void *addr, u32 count);
0311 
0312 #endif /* _ASM_S390_FCX_H */