zcrypt_api.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * zcrypt 2.1.0
  3. *
  4. * Copyright IBM Corp. 2001, 2006
  5. * Author(s): Robert Burroughs
  6. * Eric Rossman (edrossma@us.ibm.com)
  7. * Cornelia Huck <cornelia.huck@de.ibm.com>
  8. *
  9. * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  10. * Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
  11. * Ralph Wuerthner <rwuerthn@de.ibm.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2, or (at your option)
  16. * any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27. #ifndef _ZCRYPT_API_H_
  28. #define _ZCRYPT_API_H_
  29. #include "ap_bus.h"
  30. #include <asm/zcrypt.h>
  31. /* deprecated status calls */
  32. #define ICAZ90STATUS _IOR(ZCRYPT_IOCTL_MAGIC, 0x10, struct ica_z90_status)
  33. #define Z90STAT_PCIXCCCOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x43, int)
  34. /**
  35. * This structure is deprecated and the corresponding ioctl() has been
  36. * replaced with individual ioctl()s for each piece of data!
  37. */
  38. struct ica_z90_status {
  39. int totalcount;
  40. int leedslitecount; // PCICA
  41. int leeds2count; // PCICC
  42. // int PCIXCCCount; is not in struct for backward compatibility
  43. int requestqWaitCount;
  44. int pendingqWaitCount;
  45. int totalOpenCount;
  46. int cryptoDomain;
  47. // status: 0=not there, 1=PCICA, 2=PCICC, 3=PCIXCC_MCL2, 4=PCIXCC_MCL3,
  48. // 5=CEX2C
  49. unsigned char status[64];
  50. // qdepth: # work elements waiting for each device
  51. unsigned char qdepth[64];
  52. };
  53. /**
  54. * device type for an actual device is either PCICA, PCICC, PCIXCC_MCL2,
  55. * PCIXCC_MCL3, CEX2C, or CEX2A
  56. *
  57. * NOTE: PCIXCC_MCL3 refers to a PCIXCC with May 2004 version of Licensed
  58. * Internal Code (LIC) (EC J12220 level 29).
  59. * PCIXCC_MCL2 refers to any LIC before this level.
  60. */
  61. #define ZCRYPT_PCICA 1
  62. #define ZCRYPT_PCICC 2
  63. #define ZCRYPT_PCIXCC_MCL2 3
  64. #define ZCRYPT_PCIXCC_MCL3 4
  65. #define ZCRYPT_CEX2C 5
  66. #define ZCRYPT_CEX2A 6
  67. #define ZCRYPT_CEX3C 7
  68. #define ZCRYPT_CEX3A 8
  69. /**
  70. * Large random numbers are pulled in 4096 byte chunks from the crypto cards
  71. * and stored in a page. Be careful when increasing this buffer due to size
  72. * limitations for AP requests.
  73. */
  74. #define ZCRYPT_RNG_BUFFER_SIZE 4096
  75. struct zcrypt_device;
  76. struct zcrypt_ops {
  77. long (*rsa_modexpo)(struct zcrypt_device *, struct ica_rsa_modexpo *);
  78. long (*rsa_modexpo_crt)(struct zcrypt_device *,
  79. struct ica_rsa_modexpo_crt *);
  80. long (*send_cprb)(struct zcrypt_device *, struct ica_xcRB *);
  81. long (*rng)(struct zcrypt_device *, char *);
  82. };
  83. struct zcrypt_device {
  84. struct list_head list; /* Device list. */
  85. spinlock_t lock; /* Per device lock. */
  86. struct kref refcount; /* device refcounting */
  87. struct ap_device *ap_dev; /* The "real" ap device. */
  88. struct zcrypt_ops *ops; /* Crypto operations. */
  89. int online; /* User online/offline */
  90. int user_space_type; /* User space device id. */
  91. char *type_string; /* User space device name. */
  92. int min_mod_size; /* Min number of bits. */
  93. int max_mod_size; /* Max number of bits. */
  94. int short_crt; /* Card has crt length restriction. */
  95. int speed_rating; /* Speed of the crypto device. */
  96. int request_count; /* # current requests. */
  97. struct ap_message reply; /* Per-device reply structure. */
  98. int max_exp_bit_length;
  99. };
  100. struct zcrypt_device *zcrypt_device_alloc(size_t);
  101. void zcrypt_device_free(struct zcrypt_device *);
  102. void zcrypt_device_get(struct zcrypt_device *);
  103. int zcrypt_device_put(struct zcrypt_device *);
  104. int zcrypt_device_register(struct zcrypt_device *);
  105. void zcrypt_device_unregister(struct zcrypt_device *);
  106. int zcrypt_api_init(void);
  107. void zcrypt_api_exit(void);
  108. #endif /* _ZCRYPT_API_H_ */