1
2
3
4
5
6
7
8
9
10
11
12
13
14 #ifndef __ASM_S390_ZCRYPT_H
15 #define __ASM_S390_ZCRYPT_H
16
17 #define ZCRYPT_VERSION 2
18 #define ZCRYPT_RELEASE 2
19 #define ZCRYPT_VARIANT 1
20
21 #include <linux/ioctl.h>
22 #include <linux/compiler.h>
23 #include <linux/types.h>
24
25
26 #define ZCRYPT_NAME "zcrypt"
27
28
29
30
31
32
33
34
35
36
37
38 struct ica_rsa_modexpo {
39 char __user *inputdata;
40 unsigned int inputdatalength;
41 char __user *outputdata;
42 unsigned int outputdatalength;
43 char __user *b_key;
44 char __user *n_modulus;
45 };
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 struct ica_rsa_modexpo_crt {
62 char __user *inputdata;
63 unsigned int inputdatalength;
64 char __user *outputdata;
65 unsigned int outputdatalength;
66 char __user *bp_key;
67 char __user *bq_key;
68 char __user *np_prime;
69 char __user *nq_prime;
70 char __user *u_mult_inv;
71 };
72
73
74
75
76
77
78
79
80
81
82
83
84
85 struct CPRBX {
86 unsigned short cprb_len;
87 unsigned char cprb_ver_id;
88 unsigned char pad_000[3];
89 unsigned char func_id[2];
90 unsigned char cprb_flags[4];
91 unsigned int req_parml;
92 unsigned int req_datal;
93 unsigned int rpl_msgbl;
94 unsigned int rpld_parml;
95 unsigned int rpl_datal;
96 unsigned int rpld_datal;
97 unsigned int req_extbl;
98 unsigned char pad_001[4];
99 unsigned int rpld_extbl;
100 unsigned char padx000[16 - sizeof(char *)];
101 unsigned char *req_parmb;
102 unsigned char padx001[16 - sizeof(char *)];
103 unsigned char *req_datab;
104 unsigned char padx002[16 - sizeof(char *)];
105 unsigned char *rpl_parmb;
106 unsigned char padx003[16 - sizeof(char *)];
107 unsigned char *rpl_datab;
108 unsigned char padx004[16 - sizeof(char *)];
109 unsigned char *req_extb;
110 unsigned char padx005[16 - sizeof(char *)];
111 unsigned char *rpl_extb;
112 unsigned short ccp_rtcode;
113 unsigned short ccp_rscode;
114 unsigned int mac_data_len;
115 unsigned char logon_id[8];
116 unsigned char mac_value[8];
117 unsigned char mac_content_flgs;
118 unsigned char pad_002;
119 unsigned short domain;
120 unsigned char usage_domain[4];
121 unsigned char cntrl_domain[4];
122 unsigned char S390enf_mask[4];
123 unsigned char pad_004[36];
124 } __attribute__((packed));
125
126
127
128
129 struct ica_xcRB {
130 unsigned short agent_ID;
131 unsigned int user_defined;
132 unsigned short request_ID;
133 unsigned int request_control_blk_length;
134 unsigned char padding1[16 - sizeof(char *)];
135 char __user *request_control_blk_addr;
136 unsigned int request_data_length;
137 char padding2[16 - sizeof(char *)];
138 char __user *request_data_address;
139 unsigned int reply_control_blk_length;
140 char padding3[16 - sizeof(char *)];
141 char __user *reply_control_blk_addr;
142 unsigned int reply_data_length;
143 char padding4[16 - sizeof(char *)];
144 char __user *reply_data_addr;
145 unsigned short priority_window;
146 unsigned int status;
147 } __attribute__((packed));
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163 struct ep11_cprb {
164 __u16 cprb_len;
165 unsigned char cprb_ver_id;
166 unsigned char pad_000[2];
167 unsigned char flags;
168 unsigned char func_id[2];
169 __u32 source_id;
170 __u32 target_id;
171 __u32 ret_code;
172 __u32 reserved1;
173 __u32 reserved2;
174 __u32 payload_len;
175 } __attribute__((packed));
176
177
178
179
180
181
182 struct ep11_target_dev {
183 __u16 ap_id;
184 __u16 dom_id;
185 };
186
187
188
189
190
191
192
193
194
195
196
197
198 struct ep11_urb {
199 __u16 targets_num;
200 __u64 targets;
201 __u64 weight;
202 __u64 req_no;
203 __u64 req_len;
204 __u64 req;
205 __u64 resp_len;
206 __u64 resp;
207 } __attribute__((packed));
208
209
210
211
212
213
214
215
216
217
218
219
220
221 struct zcrypt_device_status_ext {
222 unsigned int hwtype:8;
223 unsigned int qid:16;
224 unsigned int online:1;
225 unsigned int functions:6;
226 unsigned int reserved:1;
227 };
228
229 #define MAX_ZDEV_CARDIDS_EXT 256
230 #define MAX_ZDEV_DOMAINS_EXT 256
231
232
233 #define MAX_ZDEV_ENTRIES_EXT (MAX_ZDEV_CARDIDS_EXT * MAX_ZDEV_DOMAINS_EXT)
234
235
236 struct zcrypt_device_matrix_ext {
237 struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT];
238 };
239
240 #define AUTOSELECT 0xFFFFFFFF
241
242 #define ZCRYPT_IOCTL_MAGIC 'z'
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306 #define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0)
307 #define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
308 #define ZSECSENDCPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0)
309 #define ZSENDEP11CPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0)
310
311 #define ZCRYPT_DEVICE_STATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x5f, 0)
312 #define ZCRYPT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x58, char[MAX_ZDEV_CARDIDS_EXT])
313 #define ZCRYPT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x59, char[MAX_ZDEV_CARDIDS_EXT])
314 #define ZCRYPT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x5a, int[MAX_ZDEV_CARDIDS_EXT])
315
316
317
318
319
320
321 #define ZCRYPT_MAX_MINOR_NODES 256
322
323
324 #define MAX_ZDEV_IOCTLS (1 << _IOC_NRBITS)
325
326
327
328
329
330
331 #define MAX_ZDEV_CARDIDS 64
332
333 #define MAX_ZDEV_DOMAINS 256
334
335
336 #define MAX_ZDEV_ENTRIES (MAX_ZDEV_CARDIDS * MAX_ZDEV_DOMAINS)
337
338
339 struct zcrypt_device_status {
340 unsigned int hwtype:8;
341 unsigned int qid:14;
342 unsigned int online:1;
343 unsigned int functions:6;
344 unsigned int reserved:3;
345 };
346
347
348 struct zcrypt_device_matrix {
349 struct zcrypt_device_status device[MAX_ZDEV_ENTRIES];
350 };
351
352
353 #define ZDEVICESTATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0)
354
355 #define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64])
356
357 #define Z90STAT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x49, char[64])
358
359 #define Z90STAT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4a, int[64])
360
361
362 #define Z90STAT_REQUESTQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x44, int)
363 #define Z90STAT_PENDINGQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x45, int)
364 #define Z90STAT_TOTALOPEN_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x46, int)
365 #define Z90STAT_DOMAIN_INDEX _IOR(ZCRYPT_IOCTL_MAGIC, 0x47, int)
366
367
368
369
370
371
372 #endif