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
38struct ica_rsa_modexpo {
39 __u8 __user *inputdata;
40 __u32 inputdatalength;
41 __u8 __user *outputdata;
42 __u32 outputdatalength;
43 __u8 __user *b_key;
44 __u8 __user *n_modulus;
45};
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61struct ica_rsa_modexpo_crt {
62 __u8 __user *inputdata;
63 __u32 inputdatalength;
64 __u8 __user *outputdata;
65 __u32 outputdatalength;
66 __u8 __user *bp_key;
67 __u8 __user *bq_key;
68 __u8 __user *np_prime;
69 __u8 __user *nq_prime;
70 __u8 __user *u_mult_inv;
71};
72
73
74
75
76
77
78
79
80
81
82
83
84
85struct CPRBX {
86 __u16 cprb_len;
87 __u8 cprb_ver_id;
88 __u8 pad_000[3];
89 __u8 func_id[2];
90 __u8 cprb_flags[4];
91 __u32 req_parml;
92 __u32 req_datal;
93 __u32 rpl_msgbl;
94 __u32 rpld_parml;
95 __u32 rpl_datal;
96 __u32 rpld_datal;
97 __u32 req_extbl;
98 __u8 pad_001[4];
99 __u32 rpld_extbl;
100 __u8 padx000[16 - sizeof(__u8 *)];
101 __u8 __user *req_parmb;
102 __u8 padx001[16 - sizeof(__u8 *)];
103 __u8 __user *req_datab;
104 __u8 padx002[16 - sizeof(__u8 *)];
105 __u8 __user *rpl_parmb;
106 __u8 padx003[16 - sizeof(__u8 *)];
107 __u8 __user *rpl_datab;
108 __u8 padx004[16 - sizeof(__u8 *)];
109 __u8 __user *req_extb;
110 __u8 padx005[16 - sizeof(__u8 *)];
111 __u8 __user *rpl_extb;
112 __u16 ccp_rtcode;
113 __u16 ccp_rscode;
114 __u32 mac_data_len;
115 __u8 logon_id[8];
116 __u8 mac_value[8];
117 __u8 mac_content_flgs;
118 __u8 pad_002;
119 __u16 domain;
120 __u8 usage_domain[4];
121 __u8 cntrl_domain[4];
122 __u8 S390enf_mask[4];
123 __u8 pad_004[36];
124} __attribute__((packed));
125
126
127
128
129struct ica_xcRB {
130 __u16 agent_ID;
131 __u32 user_defined;
132 __u16 request_ID;
133 __u32 request_control_blk_length;
134 __u8 _padding1[16 - sizeof(__u8 *)];
135 __u8 __user *request_control_blk_addr;
136 __u32 request_data_length;
137 __u8 _padding2[16 - sizeof(__u8 *)];
138 __u8 __user *request_data_address;
139 __u32 reply_control_blk_length;
140 __u8 _padding3[16 - sizeof(__u8 *)];
141 __u8 __user *reply_control_blk_addr;
142 __u32 reply_data_length;
143 __u8 __padding4[16 - sizeof(__u8 *)];
144 __u8 __user *reply_data_addr;
145 __u16 priority_window;
146 __u32 status;
147} __attribute__((packed));
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163struct ep11_cprb {
164 __u16 cprb_len;
165 __u8 cprb_ver_id;
166 __u8 pad_000[2];
167 __u8 flags;
168 __u8 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
182struct ep11_target_dev {
183 __u16 ap_id;
184 __u16 dom_id;
185};
186
187
188
189
190
191
192
193
194
195
196
197
198struct ep11_urb {
199 __u16 targets_num;
200 __u8 __user *targets;
201 __u64 weight;
202 __u64 req_no;
203 __u64 req_len;
204 __u8 __user *req;
205 __u64 resp_len;
206 __u8 __user *resp;
207} __attribute__((packed));
208
209
210
211
212
213
214
215
216
217
218
219
220
221struct 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
236struct zcrypt_device_matrix_ext {
237 struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT];
238};
239
240#define AUTOSELECT 0xFFFFFFFF
241#define AUTOSEL_AP ((__u16) 0xFFFF)
242#define AUTOSEL_DOM ((__u16) 0xFFFF)
243
244#define ZCRYPT_IOCTL_MAGIC 'z'
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
307
308#define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0)
309#define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
310#define ZSECSENDCPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0)
311#define ZSENDEP11CPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0)
312
313#define ZCRYPT_DEVICE_STATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x5f, 0)
314#define ZCRYPT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x58, char[MAX_ZDEV_CARDIDS_EXT])
315#define ZCRYPT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x59, char[MAX_ZDEV_CARDIDS_EXT])
316#define ZCRYPT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x5a, int[MAX_ZDEV_CARDIDS_EXT])
317
318
319
320
321
322
323#define ZCRYPT_MAX_MINOR_NODES 256
324
325
326#define MAX_ZDEV_IOCTLS (1 << _IOC_NRBITS)
327
328
329
330
331
332
333#define MAX_ZDEV_CARDIDS 64
334
335#define MAX_ZDEV_DOMAINS 256
336
337
338#define MAX_ZDEV_ENTRIES (MAX_ZDEV_CARDIDS * MAX_ZDEV_DOMAINS)
339
340
341struct zcrypt_device_status {
342 unsigned int hwtype:8;
343 unsigned int qid:14;
344 unsigned int online:1;
345 unsigned int functions:6;
346 unsigned int reserved:3;
347};
348
349
350struct zcrypt_device_matrix {
351 struct zcrypt_device_status device[MAX_ZDEV_ENTRIES];
352};
353
354
355#define ZDEVICESTATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0)
356
357#define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64])
358
359#define Z90STAT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x49, char[64])
360
361#define Z90STAT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4a, int[64])
362
363
364#define Z90STAT_REQUESTQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x44, int)
365#define Z90STAT_PENDINGQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x45, int)
366#define Z90STAT_TOTALOPEN_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x46, int)
367#define Z90STAT_DOMAIN_INDEX _IOR(ZCRYPT_IOCTL_MAGIC, 0x47, int)
368
369
370
371
372
373
374#endif
375