z90crypt.h 8.3 KB

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