Commit a9db48b7 authored by Eric Rossman's avatar Eric Rossman Committed by Linus Torvalds

[PATCH] s390: crypto device driver

crypto driver changes:
 - Add support for zero-pad and crypto express II (CEX2C).
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f2e30152
/* /*
* linux/drivers/s390/misc/z90common.h * linux/drivers/s390/misc/z90common.h
* *
* z90crypt 1.3.1 * z90crypt 1.3.2
* *
* Copyright (C) 2001, 2004 IBM Corporation * Copyright (C) 2001, 2004 IBM Corporation
* Author(s): Robert Burroughs (burrough@us.ibm.com) * Author(s): Robert Burroughs (burrough@us.ibm.com)
* Eric Rossman (edrossma@us.ibm.com) * Eric Rossman (edrossma@us.ibm.com)
* *
* Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com) * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
* *
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -27,12 +27,13 @@ ...@@ -27,12 +27,13 @@
#ifndef _Z90COMMON_ #ifndef _Z90COMMON_
#define _Z90COMMON_ #define _Z90COMMON_
#define VERSION_Z90COMMON_H "$Revision: 1.8 $" #define VERSION_Z90COMMON_H "$Revision: 1.15 $"
#define RESPBUFFSIZE 256 #define RESPBUFFSIZE 256
#define PCI_FUNC_KEY_DECRYPT 0x5044 #define PCI_FUNC_KEY_DECRYPT 0x5044
#define PCI_FUNC_KEY_ENCRYPT 0x504B #define PCI_FUNC_KEY_ENCRYPT 0x504B
extern int ext_bitlens;
enum devstat { enum devstat {
DEV_GONE, DEV_GONE,
...@@ -56,6 +57,7 @@ enum hdstat { ...@@ -56,6 +57,7 @@ enum hdstat {
HD_TSQ_EXCEPTION HD_TSQ_EXCEPTION
}; };
#define Z90C_NO_DEVICES 1
#define Z90C_AMBIGUOUS_DOMAIN 2 #define Z90C_AMBIGUOUS_DOMAIN 2
#define Z90C_INCORRECT_DOMAIN 3 #define Z90C_INCORRECT_DOMAIN 3
#define ENOTINIT 4 #define ENOTINIT 4
...@@ -74,13 +76,13 @@ enum hdstat { ...@@ -74,13 +76,13 @@ enum hdstat {
#define REC_OPERAND_SIZE 9 #define REC_OPERAND_SIZE 9
#define REC_EVEN_MOD 10 #define REC_EVEN_MOD 10
#define REC_NO_WORK 11 #define REC_NO_WORK 11
#define REC_HARDWAR_ERR 12 #define REC_HARDWAR_ERR 12
#define REC_NO_RESPONSE 13 #define REC_NO_RESPONSE 13
#define REC_RETRY_DEV 14 #define REC_RETRY_DEV 14
#define REC_USER_GONE 15 #define REC_USER_GONE 15
#define REC_BAD_MESSAGE 16 #define REC_BAD_MESSAGE 16
#define REC_INVALID_PAD 17 #define REC_INVALID_PAD 17
#define REC_RELEASED 28 #define REC_USE_PCICA 18
#define WRONG_DEVICE_TYPE 20 #define WRONG_DEVICE_TYPE 20
...@@ -89,18 +91,55 @@ enum hdstat { ...@@ -89,18 +91,55 @@ enum hdstat {
#define TSQ_FATAL_ERROR 34 #define TSQ_FATAL_ERROR 34
#define RSQ_FATAL_ERROR 35 #define RSQ_FATAL_ERROR 35
#define PCICA 0 #define Z90CRYPT_NUM_TYPES 5
#define PCICC 1 #define PCICA 0
#define PCIXCC 2 #define PCICC 1
#define NILDEV -1 #define PCIXCC_MCL2 2
#define ANYDEV -1 #define PCIXCC_MCL3 3
#define CEX2C 4
#define NILDEV -1
#define ANYDEV -1
#define PCIXCC_UNK -2
enum hdevice_type { enum hdevice_type {
PCICC_HW = 3, PCICC_HW = 3,
PCICA_HW = 4, PCICA_HW = 4,
PCIXCC_HW = 5, PCIXCC_HW = 5,
OTHER_HW = 6, OTHER_HW = 6,
OTHER2_HW = 7 CEX2C_HW = 7
};
struct CPRBX {
unsigned short cprb_len;
unsigned char cprb_ver_id;
unsigned char pad_000[3];
unsigned char func_id[2];
unsigned char cprb_flags[4];
unsigned int req_parml;
unsigned int req_datal;
unsigned int rpl_msgbl;
unsigned int rpld_parml;
unsigned int rpl_datal;
unsigned int rpld_datal;
unsigned int req_extbl;
unsigned char pad_001[4];
unsigned int rpld_extbl;
unsigned char req_parmb[16];
unsigned char req_datab[16];
unsigned char rpl_parmb[16];
unsigned char rpl_datab[16];
unsigned char req_extb[16];
unsigned char rpl_extb[16];
unsigned short ccp_rtcode;
unsigned short ccp_rscode;
unsigned int mac_data_len;
unsigned char logon_id[8];
unsigned char mac_value[8];
unsigned char mac_content_flgs;
unsigned char pad_002;
unsigned short domain;
unsigned char pad_003[12];
unsigned char pad_004[36];
}; };
#ifndef DEV_NAME #ifndef DEV_NAME
......
/* /*
* linux/drivers/s390/misc/z90crypt.h * linux/drivers/s390/misc/z90crypt.h
* *
* z90crypt 1.3.1 * z90crypt 1.3.2
* *
* Copyright (C) 2001, 2004 IBM Corporation * Copyright (C) 2001, 2004 IBM Corporation
* Author(s): Robert Burroughs (burrough@us.ibm.com) * Author(s): Robert Burroughs (burrough@us.ibm.com)
* Eric Rossman (edrossma@us.ibm.com) * Eric Rossman (edrossma@us.ibm.com)
* *
* Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com) * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
* *
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -29,11 +29,20 @@ ...@@ -29,11 +29,20 @@
#include <linux/ioctl.h> #include <linux/ioctl.h>
#define VERSION_Z90CRYPT_H "$Revision: 1.2 $" #define VERSION_Z90CRYPT_H "$Revision: 1.10 $"
#define z90crypt_VERSION 1 #define z90crypt_VERSION 1
#define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards #define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards
#define z90crypt_VARIANT 1 #define z90crypt_VARIANT 2 // 2 = added PCIXCC MCL3 and CEX2C support
/**
* If we are not using the sparse checker, __user has no use.
*/
#ifdef __CHECKER__
# define __user __attribute__((noderef, address_space(1)))
#else
# define __user
#endif
/** /**
* struct ica_rsa_modexpo * struct ica_rsa_modexpo
...@@ -93,16 +102,16 @@ struct ica_rsa_modexpo_crt { ...@@ -93,16 +102,16 @@ struct ica_rsa_modexpo_crt {
* This takes an ica_rsa_modexpo struct as its arg. * This takes an ica_rsa_modexpo struct as its arg.
* *
* NOTE: please refer to the comments preceding this structure * NOTE: please refer to the comments preceding this structure
* for the implementation details for the contents of the * for the implementation details for the contents of the
* block * block
* *
* ICARSACRT * ICARSACRT
* Perform an RSA operation using a Chinese-Remainder Theorem key * Perform an RSA operation using a Chinese-Remainder Theorem key
* This takes an ica_rsa_modexpo_crt struct as its arg. * This takes an ica_rsa_modexpo_crt struct as its arg.
* *
* NOTE: please refer to the comments preceding this structure * NOTE: please refer to the comments preceding this structure
* for the implementation details for the contents of the * for the implementation details for the contents of the
* block * block
* *
* Z90STAT_TOTALCOUNT * Z90STAT_TOTALCOUNT
* Return an integer count of all device types together. * Return an integer count of all device types together.
...@@ -113,8 +122,14 @@ struct ica_rsa_modexpo_crt { ...@@ -113,8 +122,14 @@ struct ica_rsa_modexpo_crt {
* Z90STAT_PCICCCOUNT * Z90STAT_PCICCCOUNT
* Return an integer count of all PCICCs. * Return an integer count of all PCICCs.
* *
* Z90STAT_PCIXCCCOUNT * Z90STAT_PCIXCCMCL2COUNT
* Return an integer count of all PCIXCCs. * Return an integer count of all MCL2 PCIXCCs.
*
* Z90STAT_PCIXCCMCL3COUNT
* Return an integer count of all MCL3 PCIXCCs.
*
* Z90STAT_CEX2CCOUNT
* Return an integer count of all CEX2Cs.
* *
* Z90STAT_REQUESTQ_COUNT * Z90STAT_REQUESTQ_COUNT
* Return an integer count of the number of entries waiting to be * Return an integer count of the number of entries waiting to be
...@@ -133,10 +148,12 @@ struct ica_rsa_modexpo_crt { ...@@ -133,10 +148,12 @@ struct ica_rsa_modexpo_crt {
* Z90STAT_STATUS_MASK * Z90STAT_STATUS_MASK
* Return an 64 element array of unsigned chars for the status of * Return an 64 element array of unsigned chars for the status of
* all devices. * all devices.
* 0x01: PCICA * 0x01: PCICA
* 0x02: PCICC * 0x02: PCICC
* 0x03: PCIXCC * 0x03: PCIXCC_MCL2
* 0x0d: device is disabled via the proc filesystem * 0x04: PCIXCC_MCL3
* 0x05: CEX2C
* 0x0d: device is disabled via the proc filesystem
* *
* Z90STAT_QDEPTH_MASK * Z90STAT_QDEPTH_MASK
* Return an 64 element array of unsigned chars for the queue * Return an 64 element array of unsigned chars for the queue
...@@ -152,18 +169,23 @@ struct ica_rsa_modexpo_crt { ...@@ -152,18 +169,23 @@ struct ica_rsa_modexpo_crt {
* This takes an ica_z90_status struct as its arg. * This takes an ica_z90_status struct as its arg.
* *
* NOTE: this ioctl() is deprecated, and has been replaced with * NOTE: this ioctl() is deprecated, and has been replaced with
* single ioctl()s for each type of status being requested * single ioctl()s for each type of status being requested
*
* Z90STAT_PCIXCCCOUNT (deprecated)
* Return an integer count of all PCIXCCs (MCL2 + MCL3).
* This is DEPRECATED now that MCL3 PCIXCCs are treated differently from
* MCL2 PCIXCCs.
* *
* Z90QUIESCE (not recommended) * Z90QUIESCE (not recommended)
* Quiesce the driver. This is intended to stop all new * Quiesce the driver. This is intended to stop all new
* requests from being processed. Its use is not recommended, * requests from being processed. Its use is NOT recommended,
* except in circumstances where there is no other way to stop * except in circumstances where there is no other way to stop
* callers from accessing the driver. Its original use was to * callers from accessing the driver. Its original use was to
* allow the driver to be "drained" of work in preparation for * allow the driver to be "drained" of work in preparation for
* a system shutdown. * a system shutdown.
* *
* NOTE: once issued, this ban on new work cannot be undone * NOTE: once issued, this ban on new work cannot be undone
* except by unloading and reloading the driver. * except by unloading and reloading the driver.
*/ */
/** /**
...@@ -172,8 +194,9 @@ struct ica_rsa_modexpo_crt { ...@@ -172,8 +194,9 @@ struct ica_rsa_modexpo_crt {
#define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x05, 0) #define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x05, 0)
#define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x06, 0) #define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, Z90_IOCTL_MAGIC, 0x06, 0)
/* DEPRECATED status call (bound for removal SOON) */ /* DEPRECATED status calls (bound for removal at some point) */
#define ICAZ90STATUS _IOR(Z90_IOCTL_MAGIC, 0x10, struct ica_z90_status) #define ICAZ90STATUS _IOR(Z90_IOCTL_MAGIC, 0x10, struct ica_z90_status)
#define Z90STAT_PCIXCCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x43, int)
/* unrelated to ICA callers */ /* unrelated to ICA callers */
#define Z90QUIESCE _IO(Z90_IOCTL_MAGIC, 0x11) #define Z90QUIESCE _IO(Z90_IOCTL_MAGIC, 0x11)
...@@ -182,7 +205,9 @@ struct ica_rsa_modexpo_crt { ...@@ -182,7 +205,9 @@ struct ica_rsa_modexpo_crt {
#define Z90STAT_TOTALCOUNT _IOR(Z90_IOCTL_MAGIC, 0x40, int) #define Z90STAT_TOTALCOUNT _IOR(Z90_IOCTL_MAGIC, 0x40, int)
#define Z90STAT_PCICACOUNT _IOR(Z90_IOCTL_MAGIC, 0x41, int) #define Z90STAT_PCICACOUNT _IOR(Z90_IOCTL_MAGIC, 0x41, int)
#define Z90STAT_PCICCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x42, int) #define Z90STAT_PCICCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x42, int)
#define Z90STAT_PCIXCCCOUNT _IOR(Z90_IOCTL_MAGIC, 0x43, int) #define Z90STAT_PCIXCCMCL2COUNT _IOR(Z90_IOCTL_MAGIC, 0x4b, int)
#define Z90STAT_PCIXCCMCL3COUNT _IOR(Z90_IOCTL_MAGIC, 0x4c, int)
#define Z90STAT_CEX2CCOUNT _IOR(Z90_IOCTL_MAGIC, 0x4d, int)
#define Z90STAT_REQUESTQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x44, int) #define Z90STAT_REQUESTQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x44, int)
#define Z90STAT_PENDINGQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x45, int) #define Z90STAT_PENDINGQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x45, int)
#define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int) #define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int)
...@@ -199,8 +224,9 @@ struct ica_rsa_modexpo_crt { ...@@ -199,8 +224,9 @@ struct ica_rsa_modexpo_crt {
#define ERELEASED 131 // user released while ioctl pending #define ERELEASED 131 // user released while ioctl pending
#define EQUIESCE 132 // z90crypt quiescing (no more work allowed) #define EQUIESCE 132 // z90crypt quiescing (no more work allowed)
#define ETIMEOUT 133 // request timed out #define ETIMEOUT 133 // request timed out
#define EUNKNOWN 134 // some unrecognized error occured #define EUNKNOWN 134 // some unrecognized error occured (retry may succeed)
#define EGETBUFF 135 // Error getting buffer #define EGETBUFF 135 // Error getting buffer or hardware lacks capability
// (retry in software)
/** /**
* DEPRECATED STRUCTURES * DEPRECATED STRUCTURES
...@@ -222,7 +248,8 @@ struct ica_z90_status { ...@@ -222,7 +248,8 @@ struct ica_z90_status {
int pendingqWaitCount; int pendingqWaitCount;
int totalOpenCount; int totalOpenCount;
int cryptoDomain; int cryptoDomain;
// status: 0=not there. 1=PCICA. 2=PCICC. 3=PCIXCC // status: 0=not there, 1=PCICA, 2=PCICC, 3=PCIXCC_MCL2, 4=PCIXCC_MCL3,
// 5=CEX2C
unsigned char status[MASK_LENGTH]; unsigned char status[MASK_LENGTH];
// qdepth: # work elements waiting for each device // qdepth: # work elements waiting for each device
unsigned char qdepth[MASK_LENGTH]; unsigned char qdepth[MASK_LENGTH];
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment