blob: 0d6a3e2a3349c2c73ef0cc3c29a534d29f0224c2 [file] [log] [blame]
Martin Schwidefsky2dbc2412006-09-20 15:58:27 +02001/*
2 * include/asm-s390/zcrypt.h
3 *
4 * zcrypt 2.0.0 (user-visible header)
5 *
6 * Copyright (C) 2001, 2006 IBM Corporation
7 * Author(s): Robert Burroughs
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 __ASM_S390_ZCRYPT_H
28#define __ASM_S390_ZCRYPT_H
29
30#define ZCRYPT_VERSION 2
31#define ZCRYPT_RELEASE 1
32#define ZCRYPT_VARIANT 0
33
34#include <linux/ioctl.h>
35#include <linux/compiler.h>
36
37/**
38 * struct ica_rsa_modexpo
39 *
40 * Requirements:
41 * - outputdatalength is at least as large as inputdatalength.
42 * - All key parts are right justified in their fields, padded on
43 * the left with zeroes.
44 * - length(b_key) = inputdatalength
45 * - length(n_modulus) = inputdatalength
46 */
47struct ica_rsa_modexpo {
48 char __user * inputdata;
49 unsigned int inputdatalength;
50 char __user * outputdata;
51 unsigned int outputdatalength;
52 char __user * b_key;
53 char __user * n_modulus;
54};
55
56/**
57 * struct ica_rsa_modexpo_crt
58 *
59 * Requirements:
60 * - inputdatalength is even.
61 * - outputdatalength is at least as large as inputdatalength.
62 * - All key parts are right justified in their fields, padded on
63 * the left with zeroes.
64 * - length(bp_key) = inputdatalength/2 + 8
65 * - length(bq_key) = inputdatalength/2
66 * - length(np_key) = inputdatalength/2 + 8
67 * - length(nq_key) = inputdatalength/2
68 * - length(u_mult_inv) = inputdatalength/2 + 8
69 */
70struct ica_rsa_modexpo_crt {
71 char __user * inputdata;
72 unsigned int inputdatalength;
73 char __user * outputdata;
74 unsigned int outputdatalength;
75 char __user * bp_key;
76 char __user * bq_key;
77 char __user * np_prime;
78 char __user * nq_prime;
79 char __user * u_mult_inv;
80};
81
82#define ZCRYPT_IOCTL_MAGIC 'z'
83
84/**
85 * Interface notes:
86 *
87 * The ioctl()s which are implemented (along with relevant details)
88 * are:
89 *
90 * ICARSAMODEXPO
91 * Perform an RSA operation using a Modulus-Exponent pair
92 * This takes an ica_rsa_modexpo struct as its arg.
93 *
94 * NOTE: please refer to the comments preceding this structure
95 * for the implementation details for the contents of the
96 * block
97 *
98 * ICARSACRT
99 * Perform an RSA operation using a Chinese-Remainder Theorem key
100 * This takes an ica_rsa_modexpo_crt struct as its arg.
101 *
102 * NOTE: please refer to the comments preceding this structure
103 * for the implementation details for the contents of the
104 * block
105 *
106 * Z90STAT_TOTALCOUNT
107 * Return an integer count of all device types together.
108 *
109 * Z90STAT_PCICACOUNT
110 * Return an integer count of all PCICAs.
111 *
112 * Z90STAT_PCICCCOUNT
113 * Return an integer count of all PCICCs.
114 *
115 * Z90STAT_PCIXCCMCL2COUNT
116 * Return an integer count of all MCL2 PCIXCCs.
117 *
118 * Z90STAT_PCIXCCMCL3COUNT
119 * Return an integer count of all MCL3 PCIXCCs.
120 *
121 * Z90STAT_CEX2CCOUNT
122 * Return an integer count of all CEX2Cs.
123 *
124 * Z90STAT_CEX2ACOUNT
125 * Return an integer count of all CEX2As.
126 *
127 * Z90STAT_REQUESTQ_COUNT
128 * Return an integer count of the number of entries waiting to be
129 * sent to a device.
130 *
131 * Z90STAT_PENDINGQ_COUNT
132 * Return an integer count of the number of entries sent to a
133 * device awaiting the reply.
134 *
135 * Z90STAT_TOTALOPEN_COUNT
136 * Return an integer count of the number of open file handles.
137 *
138 * Z90STAT_DOMAIN_INDEX
139 * Return the integer value of the Cryptographic Domain.
140 *
141 * Z90STAT_STATUS_MASK
142 * Return an 64 element array of unsigned chars for the status of
143 * all devices.
144 * 0x01: PCICA
145 * 0x02: PCICC
146 * 0x03: PCIXCC_MCL2
147 * 0x04: PCIXCC_MCL3
148 * 0x05: CEX2C
149 * 0x06: CEX2A
150 * 0x0d: device is disabled via the proc filesystem
151 *
152 * Z90STAT_QDEPTH_MASK
153 * Return an 64 element array of unsigned chars for the queue
154 * depth of all devices.
155 *
156 * Z90STAT_PERDEV_REQCNT
157 * Return an 64 element array of unsigned integers for the number
158 * of successfully completed requests per device since the device
159 * was detected and made available.
160 *
161 * ICAZ90STATUS (deprecated)
162 * Return some device driver status in a ica_z90_status struct
163 * This takes an ica_z90_status struct as its arg.
164 *
165 * NOTE: this ioctl() is deprecated, and has been replaced with
166 * single ioctl()s for each type of status being requested
167 *
168 * Z90STAT_PCIXCCCOUNT (deprecated)
169 * Return an integer count of all PCIXCCs (MCL2 + MCL3).
170 * This is DEPRECATED now that MCL3 PCIXCCs are treated differently from
171 * MCL2 PCIXCCs.
172 *
173 * Z90QUIESCE (not recommended)
174 * Quiesce the driver. This is intended to stop all new
175 * requests from being processed. Its use is NOT recommended,
176 * except in circumstances where there is no other way to stop
177 * callers from accessing the driver. Its original use was to
178 * allow the driver to be "drained" of work in preparation for
179 * a system shutdown.
180 *
181 * NOTE: once issued, this ban on new work cannot be undone
182 * except by unloading and reloading the driver.
183 */
184
185/**
186 * Supported ioctl calls
187 */
188#define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0)
189#define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
190
191/* New status calls */
192#define Z90STAT_TOTALCOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x40, int)
193#define Z90STAT_PCICACOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x41, int)
194#define Z90STAT_PCICCCOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x42, int)
195#define Z90STAT_PCIXCCMCL2COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4b, int)
196#define Z90STAT_PCIXCCMCL3COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4c, int)
197#define Z90STAT_CEX2CCOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4d, int)
198#define Z90STAT_CEX2ACOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4e, int)
199#define Z90STAT_REQUESTQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x44, int)
200#define Z90STAT_PENDINGQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x45, int)
201#define Z90STAT_TOTALOPEN_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x46, int)
202#define Z90STAT_DOMAIN_INDEX _IOR(ZCRYPT_IOCTL_MAGIC, 0x47, int)
203#define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64])
204#define Z90STAT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x49, char[64])
205#define Z90STAT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4a, int[64])
206
207#endif /* __ASM_S390_ZCRYPT_H */