z90crypt.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*
  2. * linux/drivers/s390/crypto/z90crypt.h
  3. *
  4. * z90crypt 1.3.3
  5. *
  6. * Copyright (C) 2001, 2005 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. #ifndef _Z90CRYPT_H_
  27. #define _Z90CRYPT_H_
  28. #include <linux/ioctl.h>
  29. #define VERSION_Z90CRYPT_H "$Revision: 1.2.2.4 $"
  30. #define z90crypt_VERSION 1
  31. #define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards
  32. #define z90crypt_VARIANT 3 // 3 = CEX2A support
  33. /**
  34. * struct ica_rsa_modexpo
  35. *
  36. * Requirements:
  37. * - outputdatalength is at least as large as inputdatalength.
  38. * - All key parts are right justified in their fields, padded on
  39. * the left with zeroes.
  40. * - length(b_key) = inputdatalength
  41. * - length(n_modulus) = inputdatalength
  42. */
  43. struct ica_rsa_modexpo {
  44. char __user * inputdata;
  45. unsigned int inputdatalength;
  46. char __user * outputdata;
  47. unsigned int outputdatalength;
  48. char __user * b_key;
  49. char __user * n_modulus;
  50. };
  51. /**
  52. * struct ica_rsa_modexpo_crt
  53. *
  54. * Requirements:
  55. * - inputdatalength is even.
  56. * - outputdatalength is at least as large as inputdatalength.
  57. * - All key parts are right justified in their fields, padded on
  58. * the left with zeroes.
  59. * - length(bp_key) = inputdatalength/2 + 8
  60. * - length(bq_key) = inputdatalength/2
  61. * - length(np_key) = inputdatalength/2 + 8
  62. * - length(nq_key) = inputdatalength/2
  63. * - length(u_mult_inv) = inputdatalength/2 + 8
  64. */
  65. struct ica_rsa_modexpo_crt {
  66. char __user * inputdata;
  67. unsigned int inputdatalength;
  68. char __user * outputdata;
  69. unsigned int outputdatalength;
  70. char __user * bp_key;
  71. char __user * bq_key;
  72. char __user * np_prime;
  73. char __user * nq_prime;
  74. char __user * u_mult_inv;
  75. };
  76. #define Z90_IOCTL_MAGIC 'z' // NOTE: Need to allocate from linux folks
  77. /**
  78. * Interface notes:
  79. *
  80. * The ioctl()s which are implemented (along with relevant details)
  81. * are:
  82. *
  83. * ICARSAMODEXPO
  84. * Perform an RSA operation using a Modulus-Exponent pair
  85. * This takes an ica_rsa_modexpo struct as its arg.
  86. *
  87. * NOTE: please refer to the comments preceding this structure
  88. * for the implementation details for the contents of the
  89. * block
  90. *
  91. * ICARSACRT
  92. * Perform an RSA operation using a Chinese-Remainder Theorem key
  93. * This takes an ica_rsa_modexpo_crt struct as its arg.
  94. *
  95. * NOTE: please refer to the comments preceding this structure
  96. * for the implementation details for the contents of the
  97. * block
  98. *
  99. * Z90STAT_TOTALCOUNT
  100. * Return an integer count of all device types together.
  101. *
  102. * Z90STAT_PCICACOUNT
  103. * Return an integer count of all PCICAs.
  104. *
  105. * Z90STAT_PCICCCOUNT
  106. * Return an integer count of all PCICCs.
  107. *
  108. * Z90STAT_PCIXCCMCL2COUNT
  109. * Return an integer count of all MCL2 PCIXCCs.
  110. *
  111. * Z90STAT_PCIXCCMCL3COUNT
  112. * Return an integer count of all MCL3 PCIXCCs.
  113. *
  114. * Z90STAT_CEX2CCOUNT
  115. * Return an integer count of all CEX2Cs.
  116. *
  117. * Z90STAT_CEX2ACOUNT
  118. * Return an integer count of all CEX2As.
  119. *
  120. * Z90STAT_REQUESTQ_COUNT
  121. * Return an integer count of the number of entries waiting to be
  122. * sent to a device.
  123. *
  124. * Z90STAT_PENDINGQ_COUNT
  125. * Return an integer count of the number of entries sent to a
  126. * device awaiting the reply.
  127. *
  128. * Z90STAT_TOTALOPEN_COUNT
  129. * Return an integer count of the number of open file handles.
  130. *
  131. * Z90STAT_DOMAIN_INDEX
  132. * Return the integer value of the Cryptographic Domain.
  133. *
  134. * Z90STAT_STATUS_MASK
  135. * Return an 64 element array of unsigned chars for the status of
  136. * all devices.
  137. * 0x01: PCICA
  138. * 0x02: PCICC
  139. * 0x03: PCIXCC_MCL2
  140. * 0x04: PCIXCC_MCL3
  141. * 0x05: CEX2C
  142. * 0x06: CEX2A
  143. * 0x0d: device is disabled via the proc filesystem
  144. *
  145. * Z90STAT_QDEPTH_MASK
  146. * Return an 64 element array of unsigned chars for the queue
  147. * depth of all devices.
  148. *
  149. * Z90STAT_PERDEV_REQCNT
  150. * Return an 64 element array of unsigned integers for the number
  151. * of successfully completed requests per device since the device
  152. * was detected and made available.
  153. *
  154. * ICAZ90STATUS (deprecated)
  155. * Return some device driver status in a ica_z90_status struct
  156. * This takes an ica_z90_status struct as its arg.
  157. *
  158. * NOTE: this ioctl() is deprecated, and has been replaced with
  159. * single ioctl()s for each type of status being requested
  160. *
  161. * Z90STAT_PCIXCCCOUNT (deprecated)
  162. * Return an integer count of all PCIXCCs (MCL2 + MCL3).
  163. * This is DEPRECATED now that MCL3 PCIXCCs are treated differently from
  164. * MCL2 PCIXCCs.
  165. *
  166. * Z90QUIESCE (not recommended)
  167. * Quiesce the driver. This is intended to stop all new
  168. * requests from being processed. Its use is NOT recommended,
  169. * except in circumstances where there is no other way to stop
  170. * callers from accessing the driver. Its original use was to
  171. * allow the driver to be "drained" of work in preparation for
  172. * a system shutdown.
  173. *
  174. * NOTE: once issued, this ban on new work cannot be undone
  175. * except by unloading and reloading the driver.
  176. */
  177. /**
  178. * Supported ioctl calls
  179. */
  180. #define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x05, 0)
  181. #define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x06, 0)
  182. /* DEPRECATED status calls (bound for removal at some point) */
  183. #define ICAZ90STATUS _IOR(Z90_IOCTL_MAGIC, 0x10, struct ica_z90_status)
  184. #define Z90STAT_PCIXCCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x43, int)
  185. /* unrelated to ICA callers */
  186. #define Z90QUIESCE _IO(Z90_IOCTL_MAGIC, 0x11)
  187. /* New status calls */
  188. #define Z90STAT_TOTALCOUNT _IOR(Z90_IOCTL_MAGIC, 0x40, int)
  189. #define Z90STAT_PCICACOUNT _IOR(Z90_IOCTL_MAGIC, 0x41, int)
  190. #define Z90STAT_PCICCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x42, int)
  191. #define Z90STAT_PCIXCCMCL2COUNT _IOR(Z90_IOCTL_MAGIC, 0x4b, int)
  192. #define Z90STAT_PCIXCCMCL3COUNT _IOR(Z90_IOCTL_MAGIC, 0x4c, int)
  193. #define Z90STAT_CEX2CCOUNT _IOR(Z90_IOCTL_MAGIC, 0x4d, int)
  194. #define Z90STAT_CEX2ACOUNT _IOR(Z90_IOCTL_MAGIC, 0x4e, int)
  195. #define Z90STAT_REQUESTQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x44, int)
  196. #define Z90STAT_PENDINGQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x45, int)
  197. #define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int)
  198. #define Z90STAT_DOMAIN_INDEX _IOR(Z90_IOCTL_MAGIC, 0x47, int)
  199. #define Z90STAT_STATUS_MASK _IOR(Z90_IOCTL_MAGIC, 0x48, char[64])
  200. #define Z90STAT_QDEPTH_MASK _IOR(Z90_IOCTL_MAGIC, 0x49, char[64])
  201. #define Z90STAT_PERDEV_REQCNT _IOR(Z90_IOCTL_MAGIC, 0x4a, int[64])
  202. /**
  203. * local errno definitions
  204. */
  205. #define ENOBUFF 129 // filp->private_data->...>work_elem_p->buffer is NULL
  206. #define EWORKPEND 130 // user issues ioctl while another pending
  207. #define ERELEASED 131 // user released while ioctl pending
  208. #define EQUIESCE 132 // z90crypt quiescing (no more work allowed)
  209. #define ETIMEOUT 133 // request timed out
  210. #define EUNKNOWN 134 // some unrecognized error occured (retry may succeed)
  211. #define EGETBUFF 135 // Error getting buffer or hardware lacks capability
  212. // (retry in software)
  213. /**
  214. * DEPRECATED STRUCTURES
  215. */
  216. /**
  217. * This structure is DEPRECATED and the corresponding ioctl() has been
  218. * replaced with individual ioctl()s for each piece of data!
  219. * This structure will NOT survive past version 1.3.1, so switch to the
  220. * new ioctl()s.
  221. */
  222. #define MASK_LENGTH 64 // mask length
  223. struct ica_z90_status {
  224. int totalcount;
  225. int leedslitecount; // PCICA
  226. int leeds2count; // PCICC
  227. // int PCIXCCCount; is not in struct for backward compatibility
  228. int requestqWaitCount;
  229. int pendingqWaitCount;
  230. int totalOpenCount;
  231. int cryptoDomain;
  232. // status: 0=not there, 1=PCICA, 2=PCICC, 3=PCIXCC_MCL2, 4=PCIXCC_MCL3,
  233. // 5=CEX2C
  234. unsigned char status[MASK_LENGTH];
  235. // qdepth: # work elements waiting for each device
  236. unsigned char qdepth[MASK_LENGTH];
  237. };
  238. #endif /* _Z90CRYPT_H_ */