2 * linux/drivers/s390/crypto/z90crypt.h
6 * Copyright (C) 2001, 2005 IBM Corporation
7 * Author(s): Robert Burroughs (burrough@us.ibm.com)
8 * Eric Rossman (edrossma@us.ibm.com)
10 * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
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)
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.
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.
30 #include <linux/ioctl.h>
32 #define VERSION_Z90CRYPT_H "$Revision: 1.2.2.4 $"
34 #define z90crypt_VERSION 1
35 #define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards
36 #define z90crypt_VARIANT 3 // 3 = CEX2A support
39 * struct ica_rsa_modexpo
42 * - outputdatalength is at least as large as inputdatalength.
43 * - All key parts are right justified in their fields, padded on
44 * the left with zeroes.
45 * - length(b_key) = inputdatalength
46 * - length(n_modulus) = inputdatalength
48 struct ica_rsa_modexpo {
49 char __user * inputdata;
50 unsigned int inputdatalength;
51 char __user * outputdata;
52 unsigned int outputdatalength;
54 char __user * n_modulus;
58 * struct ica_rsa_modexpo_crt
61 * - inputdatalength is even.
62 * - outputdatalength is at least as large as inputdatalength.
63 * - All key parts are right justified in their fields, padded on
64 * the left with zeroes.
65 * - length(bp_key) = inputdatalength/2 + 8
66 * - length(bq_key) = inputdatalength/2
67 * - length(np_key) = inputdatalength/2 + 8
68 * - length(nq_key) = inputdatalength/2
69 * - length(u_mult_inv) = inputdatalength/2 + 8
71 struct ica_rsa_modexpo_crt {
72 char __user * inputdata;
73 unsigned int inputdatalength;
74 char __user * outputdata;
75 unsigned int outputdatalength;
78 char __user * np_prime;
79 char __user * nq_prime;
80 char __user * u_mult_inv;
83 #define Z90_IOCTL_MAGIC 'z' // NOTE: Need to allocate from linux folks
88 * The ioctl()s which are implemented (along with relevant details)
92 * Perform an RSA operation using a Modulus-Exponent pair
93 * This takes an ica_rsa_modexpo struct as its arg.
95 * NOTE: please refer to the comments preceding this structure
96 * for the implementation details for the contents of the
100 * Perform an RSA operation using a Chinese-Remainder Theorem key
101 * This takes an ica_rsa_modexpo_crt struct as its arg.
103 * NOTE: please refer to the comments preceding this structure
104 * for the implementation details for the contents of the
108 * Return an integer count of all device types together.
111 * Return an integer count of all PCICAs.
114 * Return an integer count of all PCICCs.
116 * Z90STAT_PCIXCCMCL2COUNT
117 * Return an integer count of all MCL2 PCIXCCs.
119 * Z90STAT_PCIXCCMCL3COUNT
120 * Return an integer count of all MCL3 PCIXCCs.
123 * Return an integer count of all CEX2Cs.
126 * Return an integer count of all CEX2As.
128 * Z90STAT_REQUESTQ_COUNT
129 * Return an integer count of the number of entries waiting to be
132 * Z90STAT_PENDINGQ_COUNT
133 * Return an integer count of the number of entries sent to a
134 * device awaiting the reply.
136 * Z90STAT_TOTALOPEN_COUNT
137 * Return an integer count of the number of open file handles.
139 * Z90STAT_DOMAIN_INDEX
140 * Return the integer value of the Cryptographic Domain.
142 * Z90STAT_STATUS_MASK
143 * Return an 64 element array of unsigned chars for the status of
151 * 0x0d: device is disabled via the proc filesystem
153 * Z90STAT_QDEPTH_MASK
154 * Return an 64 element array of unsigned chars for the queue
155 * depth of all devices.
157 * Z90STAT_PERDEV_REQCNT
158 * Return an 64 element array of unsigned integers for the number
159 * of successfully completed requests per device since the device
160 * was detected and made available.
162 * ICAZ90STATUS (deprecated)
163 * Return some device driver status in a ica_z90_status struct
164 * This takes an ica_z90_status struct as its arg.
166 * NOTE: this ioctl() is deprecated, and has been replaced with
167 * single ioctl()s for each type of status being requested
169 * Z90STAT_PCIXCCCOUNT (deprecated)
170 * Return an integer count of all PCIXCCs (MCL2 + MCL3).
171 * This is DEPRECATED now that MCL3 PCIXCCs are treated differently from
174 * Z90QUIESCE (not recommended)
175 * Quiesce the driver. This is intended to stop all new
176 * requests from being processed. Its use is NOT recommended,
177 * except in circumstances where there is no other way to stop
178 * callers from accessing the driver. Its original use was to
179 * allow the driver to be "drained" of work in preparation for
182 * NOTE: once issued, this ban on new work cannot be undone
183 * except by unloading and reloading the driver.
187 * Supported ioctl calls
189 #define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x05, 0)
190 #define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x06, 0)
192 /* DEPRECATED status calls (bound for removal at some point) */
193 #define ICAZ90STATUS _IOR(Z90_IOCTL_MAGIC, 0x10, struct ica_z90_status)
194 #define Z90STAT_PCIXCCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x43, int)
196 /* unrelated to ICA callers */
197 #define Z90QUIESCE _IO(Z90_IOCTL_MAGIC, 0x11)
199 /* New status calls */
200 #define Z90STAT_TOTALCOUNT _IOR(Z90_IOCTL_MAGIC, 0x40, int)
201 #define Z90STAT_PCICACOUNT _IOR(Z90_IOCTL_MAGIC, 0x41, int)
202 #define Z90STAT_PCICCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x42, int)
203 #define Z90STAT_PCIXCCMCL2COUNT _IOR(Z90_IOCTL_MAGIC, 0x4b, int)
204 #define Z90STAT_PCIXCCMCL3COUNT _IOR(Z90_IOCTL_MAGIC, 0x4c, int)
205 #define Z90STAT_CEX2CCOUNT _IOR(Z90_IOCTL_MAGIC, 0x4d, int)
206 #define Z90STAT_CEX2ACOUNT _IOR(Z90_IOCTL_MAGIC, 0x4e, int)
207 #define Z90STAT_REQUESTQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x44, int)
208 #define Z90STAT_PENDINGQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x45, int)
209 #define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int)
210 #define Z90STAT_DOMAIN_INDEX _IOR(Z90_IOCTL_MAGIC, 0x47, int)
211 #define Z90STAT_STATUS_MASK _IOR(Z90_IOCTL_MAGIC, 0x48, char[64])
212 #define Z90STAT_QDEPTH_MASK _IOR(Z90_IOCTL_MAGIC, 0x49, char[64])
213 #define Z90STAT_PERDEV_REQCNT _IOR(Z90_IOCTL_MAGIC, 0x4a, int[64])
216 * local errno definitions
218 #define ENOBUFF 129 // filp->private_data->...>work_elem_p->buffer is NULL
219 #define EWORKPEND 130 // user issues ioctl while another pending
220 #define ERELEASED 131 // user released while ioctl pending
221 #define EQUIESCE 132 // z90crypt quiescing (no more work allowed)
222 #define ETIMEOUT 133 // request timed out
223 #define EUNKNOWN 134 // some unrecognized error occured (retry may succeed)
224 #define EGETBUFF 135 // Error getting buffer or hardware lacks capability
225 // (retry in software)
228 * DEPRECATED STRUCTURES
232 * This structure is DEPRECATED and the corresponding ioctl() has been
233 * replaced with individual ioctl()s for each piece of data!
234 * This structure will NOT survive past version 1.3.1, so switch to the
237 #define MASK_LENGTH 64 // mask length
238 struct ica_z90_status {
240 int leedslitecount; // PCICA
241 int leeds2count; // PCICC
242 // int PCIXCCCount; is not in struct for backward compatibility
243 int requestqWaitCount;
244 int pendingqWaitCount;
247 // status: 0=not there, 1=PCICA, 2=PCICC, 3=PCIXCC_MCL2, 4=PCIXCC_MCL3,
249 unsigned char status[MASK_LENGTH];
250 // qdepth: # work elements waiting for each device
251 unsigned char qdepth[MASK_LENGTH];
254 #endif /* _Z90CRYPT_H_ */