forked from mirrors/linux
		
	 ee410de890
			
		
	
	
		ee410de890
		
	
	
	
	
		
			
			Some cleanup in the s390 zcrypt device driver:
- Removed fragments of pcixx crypto card code. This code
  can't be reached anymore because the hardware detection
  function does not recognize crypto cards < CEX2 since
  commit f56545430736 ("s390/zcrypt: Introduce QACT support
  for AP bus devices.")
- Rename of some files and driver names which where still
  reflecting pcixx support to cex2a/cex2c.
- Removed all the zcrypt version strings in the file headers.
  There is only one place left - the zcrypt.h header file is
  now the only place for zcrypt device driver version info.
- Zcrypt version pump up from 2.2.0 to 2.2.1.
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
		
	
			
		
			
				
	
	
		
			149 lines
		
	
	
	
		
			4.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			149 lines
		
	
	
	
		
			4.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* SPDX-License-Identifier: GPL-2.0+ */
 | |
| /*
 | |
|  *  Copyright IBM Corp. 2001, 2018
 | |
|  *  Author(s): Robert Burroughs
 | |
|  *	       Eric Rossman (edrossma@us.ibm.com)
 | |
|  *	       Cornelia Huck <cornelia.huck@de.ibm.com>
 | |
|  *
 | |
|  *  Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
 | |
|  *  Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
 | |
|  *				  Ralph Wuerthner <rwuerthn@de.ibm.com>
 | |
|  *  MSGTYPE restruct:		  Holger Dengler <hd@linux.vnet.ibm.com>
 | |
|  */
 | |
| 
 | |
| #ifndef _ZCRYPT_API_H_
 | |
| #define _ZCRYPT_API_H_
 | |
| 
 | |
| #include <linux/atomic.h>
 | |
| #include <asm/debug.h>
 | |
| #include <asm/zcrypt.h>
 | |
| #include "ap_bus.h"
 | |
| 
 | |
| /**
 | |
|  * Supported device types
 | |
|  */
 | |
| #define ZCRYPT_CEX2C		5
 | |
| #define ZCRYPT_CEX2A		6
 | |
| #define ZCRYPT_CEX3C		7
 | |
| #define ZCRYPT_CEX3A		8
 | |
| #define ZCRYPT_CEX4	       10
 | |
| #define ZCRYPT_CEX5	       11
 | |
| #define ZCRYPT_CEX6	       12
 | |
| 
 | |
| /**
 | |
|  * Large random numbers are pulled in 4096 byte chunks from the crypto cards
 | |
|  * and stored in a page. Be careful when increasing this buffer due to size
 | |
|  * limitations for AP requests.
 | |
|  */
 | |
| #define ZCRYPT_RNG_BUFFER_SIZE	4096
 | |
| 
 | |
| /*
 | |
|  * Identifier for Crypto Request Performance Index
 | |
|  */
 | |
| enum crypto_ops {
 | |
| 	MEX_1K,
 | |
| 	MEX_2K,
 | |
| 	MEX_4K,
 | |
| 	CRT_1K,
 | |
| 	CRT_2K,
 | |
| 	CRT_4K,
 | |
| 	HWRNG,
 | |
| 	SECKEY,
 | |
| 	NUM_OPS
 | |
| };
 | |
| 
 | |
| struct zcrypt_queue;
 | |
| 
 | |
| struct zcrypt_ops {
 | |
| 	long (*rsa_modexpo)(struct zcrypt_queue *, struct ica_rsa_modexpo *);
 | |
| 	long (*rsa_modexpo_crt)(struct zcrypt_queue *,
 | |
| 				struct ica_rsa_modexpo_crt *);
 | |
| 	long (*send_cprb)(struct zcrypt_queue *, struct ica_xcRB *,
 | |
| 			  struct ap_message *);
 | |
| 	long (*send_ep11_cprb)(struct zcrypt_queue *, struct ep11_urb *,
 | |
| 			       struct ap_message *);
 | |
| 	long (*rng)(struct zcrypt_queue *, char *, struct ap_message *);
 | |
| 	struct list_head list;		/* zcrypt ops list. */
 | |
| 	struct module *owner;
 | |
| 	int variant;
 | |
| 	char name[128];
 | |
| };
 | |
| 
 | |
| struct zcrypt_card {
 | |
| 	struct list_head list;		/* Device list. */
 | |
| 	struct list_head zqueues;	/* List of zcrypt queues */
 | |
| 	struct kref refcount;		/* device refcounting */
 | |
| 	struct ap_card *card;		/* The "real" ap card device. */
 | |
| 	int online;			/* User online/offline */
 | |
| 
 | |
| 	int user_space_type;		/* User space device id. */
 | |
| 	char *type_string;		/* User space device name. */
 | |
| 	int min_mod_size;		/* Min number of bits. */
 | |
| 	int max_mod_size;		/* Max number of bits. */
 | |
| 	int max_exp_bit_length;
 | |
| 	int speed_rating[NUM_OPS];	/* Speed idx of crypto ops. */
 | |
| 	atomic_t load;			/* Utilization of the crypto device */
 | |
| 
 | |
| 	int request_count;		/* # current requests. */
 | |
| };
 | |
| 
 | |
| struct zcrypt_queue {
 | |
| 	struct list_head list;		/* Device list. */
 | |
| 	struct kref refcount;		/* device refcounting */
 | |
| 	struct zcrypt_card *zcard;
 | |
| 	struct zcrypt_ops *ops;		/* Crypto operations. */
 | |
| 	struct ap_queue *queue;		/* The "real" ap queue device. */
 | |
| 	int online;			/* User online/offline */
 | |
| 
 | |
| 	atomic_t load;			/* Utilization of the crypto device */
 | |
| 
 | |
| 	int request_count;		/* # current requests. */
 | |
| 
 | |
| 	struct ap_message reply;	/* Per-device reply structure. */
 | |
| };
 | |
| 
 | |
| /* transport layer rescanning */
 | |
| extern atomic_t zcrypt_rescan_req;
 | |
| 
 | |
| extern spinlock_t zcrypt_list_lock;
 | |
| extern int zcrypt_device_count;
 | |
| extern struct list_head zcrypt_card_list;
 | |
| 
 | |
| #define for_each_zcrypt_card(_zc) \
 | |
| 	list_for_each_entry(_zc, &zcrypt_card_list, list)
 | |
| 
 | |
| #define for_each_zcrypt_queue(_zq, _zc) \
 | |
| 	list_for_each_entry(_zq, &(_zc)->zqueues, list)
 | |
| 
 | |
| struct zcrypt_card *zcrypt_card_alloc(void);
 | |
| void zcrypt_card_free(struct zcrypt_card *);
 | |
| void zcrypt_card_get(struct zcrypt_card *);
 | |
| int zcrypt_card_put(struct zcrypt_card *);
 | |
| int zcrypt_card_register(struct zcrypt_card *);
 | |
| void zcrypt_card_unregister(struct zcrypt_card *);
 | |
| struct zcrypt_card *zcrypt_card_get_best(unsigned int *,
 | |
| 					 unsigned int, unsigned int);
 | |
| void zcrypt_card_put_best(struct zcrypt_card *, unsigned int);
 | |
| 
 | |
| struct zcrypt_queue *zcrypt_queue_alloc(size_t);
 | |
| void zcrypt_queue_free(struct zcrypt_queue *);
 | |
| void zcrypt_queue_get(struct zcrypt_queue *);
 | |
| int zcrypt_queue_put(struct zcrypt_queue *);
 | |
| int zcrypt_queue_register(struct zcrypt_queue *);
 | |
| void zcrypt_queue_unregister(struct zcrypt_queue *);
 | |
| void zcrypt_queue_force_online(struct zcrypt_queue *, int);
 | |
| struct zcrypt_queue *zcrypt_queue_get_best(unsigned int, unsigned int);
 | |
| void  zcrypt_queue_put_best(struct zcrypt_queue *, unsigned int);
 | |
| 
 | |
| int zcrypt_rng_device_add(void);
 | |
| void zcrypt_rng_device_remove(void);
 | |
| 
 | |
| void zcrypt_msgtype_register(struct zcrypt_ops *);
 | |
| void zcrypt_msgtype_unregister(struct zcrypt_ops *);
 | |
| struct zcrypt_ops *zcrypt_msgtype(unsigned char *, int);
 | |
| int zcrypt_api_init(void);
 | |
| void zcrypt_api_exit(void);
 | |
| long zcrypt_send_cprb(struct ica_xcRB *xcRB);
 | |
| void zcrypt_device_status_mask_ext(struct zcrypt_device_status_ext *devstatus);
 | |
| 
 | |
| #endif /* _ZCRYPT_API_H_ */
 |