aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/crypto/z90crypt.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/crypto/z90crypt.h')
-rw-r--r--drivers/s390/crypto/z90crypt.h258
1 files changed, 258 insertions, 0 deletions
diff --git a/drivers/s390/crypto/z90crypt.h b/drivers/s390/crypto/z90crypt.h
new file mode 100644
index 000000000000..82a1d97001d7
--- /dev/null
+++ b/drivers/s390/crypto/z90crypt.h
@@ -0,0 +1,258 @@
1/*
2 * linux/drivers/s390/crypto/z90crypt.h
3 *
4 * z90crypt 1.3.2
5 *
6 * Copyright (C) 2001, 2004 IBM Corporation
7 * Author(s): Robert Burroughs (burrough@us.ibm.com)
8 * Eric Rossman (edrossma@us.ibm.com)
9 *
10 * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27#ifndef _Z90CRYPT_H_
28#define _Z90CRYPT_H_
29
30#include <linux/ioctl.h>
31
32#define VERSION_Z90CRYPT_H "$Revision: 1.11 $"
33
34#define z90crypt_VERSION 1
35#define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards
36#define z90crypt_VARIANT 2 // 2 = added PCIXCC MCL3 and CEX2C support
37
38/**
39 * If we are not using the sparse checker, __user has no use.
40 */
41#ifdef __CHECKER__
42# define __user __attribute__((noderef, address_space(1)))
43#else
44# define __user
45#endif
46
47/**
48 * struct ica_rsa_modexpo
49 *
50 * Requirements:
51 * - outputdatalength is at least as large as inputdatalength.
52 * - All key parts are right justified in their fields, padded on
53 * the left with zeroes.
54 * - length(b_key) = inputdatalength
55 * - length(n_modulus) = inputdatalength
56 */
57struct ica_rsa_modexpo {
58 char __user * inputdata;
59 unsigned int inputdatalength;
60 char __user * outputdata;
61 unsigned int outputdatalength;
62 char __user * b_key;
63 char __user * n_modulus;
64};
65
66/**
67 * struct ica_rsa_modexpo_crt
68 *
69 * Requirements:
70 * - inputdatalength is even.
71 * - outputdatalength is at least as large as inputdatalength.
72 * - All key parts are right justified in their fields, padded on
73 * the left with zeroes.
74 * - length(bp_key) = inputdatalength/2 + 8
75 * - length(bq_key) = inputdatalength/2
76 * - length(np_key) = inputdatalength/2 + 8
77 * - length(nq_key) = inputdatalength/2
78 * - length(u_mult_inv) = inputdatalength/2 + 8
79 */
80struct ica_rsa_modexpo_crt {
81 char __user * inputdata;
82 unsigned int inputdatalength;
83 char __user * outputdata;
84 unsigned int outputdatalength;
85 char __user * bp_key;
86 char __user * bq_key;
87 char __user * np_prime;
88 char __user * nq_prime;
89 char __user * u_mult_inv;
90};
91
92#define Z90_IOCTL_MAGIC 'z' // NOTE: Need to allocate from linux folks
93
94/**
95 * Interface notes:
96 *
97 * The ioctl()s which are implemented (along with relevant details)
98 * are:
99 *
100 * ICARSAMODEXPO
101 * Perform an RSA operation using a Modulus-Exponent pair
102 * This takes an ica_rsa_modexpo struct as its arg.
103 *
104 * NOTE: please refer to the comments preceding this structure
105 * for the implementation details for the contents of the
106 * block
107 *
108 * ICARSACRT
109 * Perform an RSA operation using a Chinese-Remainder Theorem key
110 * This takes an ica_rsa_modexpo_crt struct as its arg.
111 *
112 * NOTE: please refer to the comments preceding this structure
113 * for the implementation details for the contents of the
114 * block
115 *
116 * Z90STAT_TOTALCOUNT
117 * Return an integer count of all device types together.
118 *
119 * Z90STAT_PCICACOUNT
120 * Return an integer count of all PCICAs.
121 *
122 * Z90STAT_PCICCCOUNT
123 * Return an integer count of all PCICCs.
124 *
125 * Z90STAT_PCIXCCMCL2COUNT
126 * Return an integer count of all MCL2 PCIXCCs.
127 *
128 * Z90STAT_PCIXCCMCL3COUNT
129 * Return an integer count of all MCL3 PCIXCCs.
130 *
131 * Z90STAT_CEX2CCOUNT
132 * Return an integer count of all CEX2Cs.
133 *
134 * Z90STAT_REQUESTQ_COUNT
135 * Return an integer count of the number of entries waiting to be
136 * sent to a device.
137 *
138 * Z90STAT_PENDINGQ_COUNT
139 * Return an integer count of the number of entries sent to a
140 * device awaiting the reply.
141 *
142 * Z90STAT_TOTALOPEN_COUNT
143 * Return an integer count of the number of open file handles.
144 *
145 * Z90STAT_DOMAIN_INDEX
146 * Return the integer value of the Cryptographic Domain.
147 *
148 * Z90STAT_STATUS_MASK
149 * Return an 64 element array of unsigned chars for the status of
150 * all devices.
151 * 0x01: PCICA
152 * 0x02: PCICC
153 * 0x03: PCIXCC_MCL2
154 * 0x04: PCIXCC_MCL3
155 * 0x05: CEX2C
156 * 0x0d: device is disabled via the proc filesystem
157 *
158 * Z90STAT_QDEPTH_MASK
159 * Return an 64 element array of unsigned chars for the queue
160 * depth of all devices.
161 *
162 * Z90STAT_PERDEV_REQCNT
163 * Return an 64 element array of unsigned integers for the number
164 * of successfully completed requests per device since the device
165 * was detected and made available.
166 *
167 * ICAZ90STATUS (deprecated)
168 * Return some device driver status in a ica_z90_status struct
169 * This takes an ica_z90_status struct as its arg.
170 *
171 * NOTE: this ioctl() is deprecated, and has been replaced with
172 * single ioctl()s for each type of status being requested
173 *
174 * Z90STAT_PCIXCCCOUNT (deprecated)
175 * Return an integer count of all PCIXCCs (MCL2 + MCL3).
176 * This is DEPRECATED now that MCL3 PCIXCCs are treated differently from
177 * MCL2 PCIXCCs.
178 *
179 * Z90QUIESCE (not recommended)
180 * Quiesce the driver. This is intended to stop all new
181 * requests from being processed. Its use is NOT recommended,
182 * except in circumstances where there is no other way to stop
183 * callers from accessing the driver. Its original use was to
184 * allow the driver to be "drained" of work in preparation for
185 * a system shutdown.
186 *
187 * NOTE: once issued, this ban on new work cannot be undone
188 * except by unloading and reloading the driver.
189 */
190
191/**
192 * Supported ioctl calls
193 */
194#define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x05, 0)
195#define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x06, 0)
196
197/* DEPRECATED status calls (bound for removal at some point) */
198#define ICAZ90STATUS _IOR(Z90_IOCTL_MAGIC, 0x10, struct ica_z90_status)
199#define Z90STAT_PCIXCCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x43, int)
200
201/* unrelated to ICA callers */
202#define Z90QUIESCE _IO(Z90_IOCTL_MAGIC, 0x11)
203
204/* New status calls */
205#define Z90STAT_TOTALCOUNT _IOR(Z90_IOCTL_MAGIC, 0x40, int)
206#define Z90STAT_PCICACOUNT _IOR(Z90_IOCTL_MAGIC, 0x41, int)
207#define Z90STAT_PCICCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x42, int)
208#define Z90STAT_PCIXCCMCL2COUNT _IOR(Z90_IOCTL_MAGIC, 0x4b, int)
209#define Z90STAT_PCIXCCMCL3COUNT _IOR(Z90_IOCTL_MAGIC, 0x4c, int)
210#define Z90STAT_CEX2CCOUNT _IOR(Z90_IOCTL_MAGIC, 0x4d, int)
211#define Z90STAT_REQUESTQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x44, int)
212#define Z90STAT_PENDINGQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x45, int)
213#define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int)
214#define Z90STAT_DOMAIN_INDEX _IOR(Z90_IOCTL_MAGIC, 0x47, int)
215#define Z90STAT_STATUS_MASK _IOR(Z90_IOCTL_MAGIC, 0x48, char[64])
216#define Z90STAT_QDEPTH_MASK _IOR(Z90_IOCTL_MAGIC, 0x49, char[64])
217#define Z90STAT_PERDEV_REQCNT _IOR(Z90_IOCTL_MAGIC, 0x4a, int[64])
218
219/**
220 * local errno definitions
221 */
222#define ENOBUFF 129 // filp->private_data->...>work_elem_p->buffer is NULL
223#define EWORKPEND 130 // user issues ioctl while another pending
224#define ERELEASED 131 // user released while ioctl pending
225#define EQUIESCE 132 // z90crypt quiescing (no more work allowed)
226#define ETIMEOUT 133 // request timed out
227#define EUNKNOWN 134 // some unrecognized error occured (retry may succeed)
228#define EGETBUFF 135 // Error getting buffer or hardware lacks capability
229 // (retry in software)
230
231/**
232 * DEPRECATED STRUCTURES
233 */
234
235/**
236 * This structure is DEPRECATED and the corresponding ioctl() has been
237 * replaced with individual ioctl()s for each piece of data!
238 * This structure will NOT survive past version 1.3.1, so switch to the
239 * new ioctl()s.
240 */
241#define MASK_LENGTH 64 // mask length
242struct ica_z90_status {
243 int totalcount;
244 int leedslitecount; // PCICA
245 int leeds2count; // PCICC
246 // int PCIXCCCount; is not in struct for backward compatibility
247 int requestqWaitCount;
248 int pendingqWaitCount;
249 int totalOpenCount;
250 int cryptoDomain;
251 // status: 0=not there, 1=PCICA, 2=PCICC, 3=PCIXCC_MCL2, 4=PCIXCC_MCL3,
252 // 5=CEX2C
253 unsigned char status[MASK_LENGTH];
254 // qdepth: # work elements waiting for each device
255 unsigned char qdepth[MASK_LENGTH];
256};
257
258#endif /* _Z90CRYPT_H_ */