[S390] zcrypt: use definitions for cex3
authorFelix Beck <felix.beck@de.ibm.com>
Mon, 7 Dec 2009 11:51:57 +0000 (12:51 +0100)
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>
Mon, 7 Dec 2009 11:51:35 +0000 (12:51 +0100)
New definitions are added for CEX3 device types. They will be set
in the according probe functions. CEX3 device types will be handled
in the same modules as CEX2 device types. In the first step they are
the same as CEX2 types, but they can be adjusted for further
characteristics of CEX3 easily.

Signed-off-by: Felix Beck <felix.beck@de.ibm.com>
Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/crypto/zcrypt_api.h
drivers/s390/crypto/zcrypt_cex2a.c
drivers/s390/crypto/zcrypt_pcixcc.c

index 1d1ec74..8e7ffbf 100644 (file)
@@ -71,6 +71,8 @@ struct ica_z90_status {
 #define ZCRYPT_PCIXCC_MCL3     4
 #define ZCRYPT_CEX2C           5
 #define ZCRYPT_CEX2A           6
+#define ZCRYPT_CEX3C           7
+#define ZCRYPT_CEX3A           8
 
 /**
  * Large random numbers are pulled in 4096 byte chunks from the crypto cards
index d25b6df..a90b760 100644 (file)
 
 #define CEX2A_MIN_MOD_SIZE       1     /*    8 bits    */
 #define CEX2A_MAX_MOD_SIZE     256     /* 2048 bits    */
+#define CEX3A_MIN_MOD_SIZE     CEX2A_MIN_MOD_SIZE
+#define CEX3A_MAX_MOD_SIZE     CEX2A_MAX_MOD_SIZE
 
 #define CEX2A_SPEED_RATING     970
+#define CEX3A_SPEED_RATING     1100
 
 #define CEX2A_MAX_MESSAGE_SIZE 0x390   /* sizeof(struct type50_crb2_msg)    */
 #define CEX2A_MAX_RESPONSE_SIZE 0x110  /* max outputdatalength + type80_hdr */
 
+#define CEX3A_MAX_MESSAGE_SIZE CEX2A_MAX_MESSAGE_SIZE
+#define CEX3A_MAX_RESPONSE_SIZE        CEX2A_MAX_RESPONSE_SIZE
+
 #define CEX2A_CLEANUP_TIME     (15*HZ)
+#define CEX3A_CLEANUP_TIME     CEX2A_CLEANUP_TIME
 
 static struct ap_device_id zcrypt_cex2a_ids[] = {
        { AP_DEVICE(AP_DEVICE_TYPE_CEX2A) },
@@ -375,31 +382,45 @@ static struct zcrypt_ops zcrypt_cex2a_ops = {
  */
 static int zcrypt_cex2a_probe(struct ap_device *ap_dev)
 {
-       struct zcrypt_device *zdev;
-       int rc;
-
-       zdev = zcrypt_device_alloc(CEX2A_MAX_RESPONSE_SIZE);
-       if (!zdev)
-               return -ENOMEM;
-       zdev->ap_dev = ap_dev;
-       zdev->ops = &zcrypt_cex2a_ops;
-       zdev->online = 1;
-       zdev->user_space_type = ZCRYPT_CEX2A;
-       zdev->type_string = "CEX2A";
-       zdev->min_mod_size = CEX2A_MIN_MOD_SIZE;
-       zdev->max_mod_size = CEX2A_MAX_MOD_SIZE;
-       zdev->short_crt = 1;
-       zdev->speed_rating = CEX2A_SPEED_RATING;
-       ap_dev->reply = &zdev->reply;
-       ap_dev->private = zdev;
-       rc = zcrypt_device_register(zdev);
-       if (rc)
-               goto out_free;
-       return 0;
-
-out_free:
-       ap_dev->private = NULL;
-       zcrypt_device_free(zdev);
+       struct zcrypt_device *zdev = NULL;
+       int rc = 0;
+
+       switch (ap_dev->device_type) {
+       case AP_DEVICE_TYPE_CEX2A:
+               zdev = zcrypt_device_alloc(CEX2A_MAX_RESPONSE_SIZE);
+               if (!zdev)
+                       return -ENOMEM;
+               zdev->user_space_type = ZCRYPT_CEX2A;
+               zdev->type_string = "CEX2A";
+               zdev->min_mod_size = CEX2A_MIN_MOD_SIZE;
+               zdev->max_mod_size = CEX2A_MAX_MOD_SIZE;
+               zdev->short_crt = 1;
+               zdev->speed_rating = CEX2A_SPEED_RATING;
+               break;
+       case AP_DEVICE_TYPE_CEX3A:
+               zdev = zcrypt_device_alloc(CEX3A_MAX_RESPONSE_SIZE);
+               if (!zdev)
+                       return -ENOMEM;
+               zdev->user_space_type = ZCRYPT_CEX3A;
+               zdev->type_string = "CEX3A";
+               zdev->min_mod_size = CEX3A_MIN_MOD_SIZE;
+               zdev->max_mod_size = CEX3A_MAX_MOD_SIZE;
+               zdev->short_crt = 1;
+               zdev->speed_rating = CEX3A_SPEED_RATING;
+               break;
+       }
+       if (zdev != NULL) {
+               zdev->ap_dev = ap_dev;
+               zdev->ops = &zcrypt_cex2a_ops;
+               zdev->online = 1;
+               ap_dev->reply = &zdev->reply;
+               ap_dev->private = zdev;
+               rc = zcrypt_device_register(zdev);
+       }
+       if (rc) {
+               ap_dev->private = NULL;
+               zcrypt_device_free(zdev);
+       }
        return rc;
 }
 
index cdaa401..d5f770a 100644 (file)
 #define PCIXCC_MIN_MOD_SIZE     16     /*  128 bits    */
 #define PCIXCC_MIN_MOD_SIZE_OLD         64     /*  512 bits    */
 #define PCIXCC_MAX_MOD_SIZE    256     /* 2048 bits    */
+#define CEX3C_MIN_MOD_SIZE     PCIXCC_MIN_MOD_SIZE
+#define CEX3C_MAX_MOD_SIZE     PCIXCC_MAX_MOD_SIZE
 
 #define PCIXCC_MCL2_SPEED_RATING       7870    /* FIXME: needs finetuning */
 #define PCIXCC_MCL3_SPEED_RATING       7870
 #define CEX2C_SPEED_RATING             8540
+#define CEX3C_SPEED_RATING             10000   /* FIXME: needs finetuning */
 
 #define PCIXCC_MAX_ICA_MESSAGE_SIZE 0x77c  /* max size type6 v2 crt message */
 #define PCIXCC_MAX_ICA_RESPONSE_SIZE 0x77c /* max size type86 v2 reply     */
@@ -1026,14 +1029,15 @@ out_free:
 static int zcrypt_pcixcc_probe(struct ap_device *ap_dev)
 {
        struct zcrypt_device *zdev;
-       int rc;
+       int rc = 0;
 
        zdev = zcrypt_device_alloc(PCIXCC_MAX_RESPONSE_SIZE);
        if (!zdev)
                return -ENOMEM;
        zdev->ap_dev = ap_dev;
        zdev->online = 1;
-       if (ap_dev->device_type == AP_DEVICE_TYPE_PCIXCC) {
+       switch (ap_dev->device_type) {
+       case AP_DEVICE_TYPE_PCIXCC:
                rc = zcrypt_pcixcc_mcl(ap_dev);
                if (rc < 0) {
                        zcrypt_device_free(zdev);
@@ -1051,13 +1055,25 @@ static int zcrypt_pcixcc_probe(struct ap_device *ap_dev)
                        zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE;
                        zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE;
                }
-       } else {
+               break;
+       case AP_DEVICE_TYPE_CEX2C:
                zdev->user_space_type = ZCRYPT_CEX2C;
                zdev->type_string = "CEX2C";
                zdev->speed_rating = CEX2C_SPEED_RATING;
                zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE;
                zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE;
+               break;
+       case AP_DEVICE_TYPE_CEX3C:
+               zdev->user_space_type = ZCRYPT_CEX3C;
+               zdev->type_string = "CEX3C";
+               zdev->speed_rating = CEX3C_SPEED_RATING;
+               zdev->min_mod_size = CEX3C_MIN_MOD_SIZE;
+               zdev->max_mod_size = CEX3C_MAX_MOD_SIZE;
+               break;
+       default:
+               goto out_free;
        }
+
        rc = zcrypt_pcixcc_rng_supported(ap_dev);
        if (rc < 0) {
                zcrypt_device_free(zdev);