aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorFelix Beck <felix.beck@de.ibm.com>2009-12-07 06:51:57 -0500
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>2009-12-07 06:51:35 -0500
commit8e89b6be76927751af5608490158100974b339e6 (patch)
treeeed6a8fc694856fecb2f477610d83c3abab71718 /drivers/s390
parentffda4f719866bb10a8edb7de3e6bf564ff7c3de4 (diff)
[S390] zcrypt: use definitions for cex3
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>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/crypto/zcrypt_api.h2
-rw-r--r--drivers/s390/crypto/zcrypt_cex2a.c71
-rw-r--r--drivers/s390/crypto/zcrypt_pcixcc.c22
3 files changed, 67 insertions, 28 deletions
diff --git a/drivers/s390/crypto/zcrypt_api.h b/drivers/s390/crypto/zcrypt_api.h
index 1d1ec74dadb2..8e7ffbf2466c 100644
--- a/drivers/s390/crypto/zcrypt_api.h
+++ b/drivers/s390/crypto/zcrypt_api.h
@@ -71,6 +71,8 @@ struct ica_z90_status {
71#define ZCRYPT_PCIXCC_MCL3 4 71#define ZCRYPT_PCIXCC_MCL3 4
72#define ZCRYPT_CEX2C 5 72#define ZCRYPT_CEX2C 5
73#define ZCRYPT_CEX2A 6 73#define ZCRYPT_CEX2A 6
74#define ZCRYPT_CEX3C 7
75#define ZCRYPT_CEX3A 8
74 76
75/** 77/**
76 * Large random numbers are pulled in 4096 byte chunks from the crypto cards 78 * Large random numbers are pulled in 4096 byte chunks from the crypto cards
diff --git a/drivers/s390/crypto/zcrypt_cex2a.c b/drivers/s390/crypto/zcrypt_cex2a.c
index d25b6dfed2e0..a90b76079fa9 100644
--- a/drivers/s390/crypto/zcrypt_cex2a.c
+++ b/drivers/s390/crypto/zcrypt_cex2a.c
@@ -39,13 +39,20 @@
39 39
40#define CEX2A_MIN_MOD_SIZE 1 /* 8 bits */ 40#define CEX2A_MIN_MOD_SIZE 1 /* 8 bits */
41#define CEX2A_MAX_MOD_SIZE 256 /* 2048 bits */ 41#define CEX2A_MAX_MOD_SIZE 256 /* 2048 bits */
42#define CEX3A_MIN_MOD_SIZE CEX2A_MIN_MOD_SIZE
43#define CEX3A_MAX_MOD_SIZE CEX2A_MAX_MOD_SIZE
42 44
43#define CEX2A_SPEED_RATING 970 45#define CEX2A_SPEED_RATING 970
46#define CEX3A_SPEED_RATING 1100
44 47
45#define CEX2A_MAX_MESSAGE_SIZE 0x390 /* sizeof(struct type50_crb2_msg) */ 48#define CEX2A_MAX_MESSAGE_SIZE 0x390 /* sizeof(struct type50_crb2_msg) */
46#define CEX2A_MAX_RESPONSE_SIZE 0x110 /* max outputdatalength + type80_hdr */ 49#define CEX2A_MAX_RESPONSE_SIZE 0x110 /* max outputdatalength + type80_hdr */
47 50
51#define CEX3A_MAX_MESSAGE_SIZE CEX2A_MAX_MESSAGE_SIZE
52#define CEX3A_MAX_RESPONSE_SIZE CEX2A_MAX_RESPONSE_SIZE
53
48#define CEX2A_CLEANUP_TIME (15*HZ) 54#define CEX2A_CLEANUP_TIME (15*HZ)
55#define CEX3A_CLEANUP_TIME CEX2A_CLEANUP_TIME
49 56
50static struct ap_device_id zcrypt_cex2a_ids[] = { 57static struct ap_device_id zcrypt_cex2a_ids[] = {
51 { AP_DEVICE(AP_DEVICE_TYPE_CEX2A) }, 58 { AP_DEVICE(AP_DEVICE_TYPE_CEX2A) },
@@ -375,31 +382,45 @@ static struct zcrypt_ops zcrypt_cex2a_ops = {
375 */ 382 */
376static int zcrypt_cex2a_probe(struct ap_device *ap_dev) 383static int zcrypt_cex2a_probe(struct ap_device *ap_dev)
377{ 384{
378 struct zcrypt_device *zdev; 385 struct zcrypt_device *zdev = NULL;
379 int rc; 386 int rc = 0;
380 387
381 zdev = zcrypt_device_alloc(CEX2A_MAX_RESPONSE_SIZE); 388 switch (ap_dev->device_type) {
382 if (!zdev) 389 case AP_DEVICE_TYPE_CEX2A:
383 return -ENOMEM; 390 zdev = zcrypt_device_alloc(CEX2A_MAX_RESPONSE_SIZE);
384 zdev->ap_dev = ap_dev; 391 if (!zdev)
385 zdev->ops = &zcrypt_cex2a_ops; 392 return -ENOMEM;
386 zdev->online = 1; 393 zdev->user_space_type = ZCRYPT_CEX2A;
387 zdev->user_space_type = ZCRYPT_CEX2A; 394 zdev->type_string = "CEX2A";
388 zdev->type_string = "CEX2A"; 395 zdev->min_mod_size = CEX2A_MIN_MOD_SIZE;
389 zdev->min_mod_size = CEX2A_MIN_MOD_SIZE; 396 zdev->max_mod_size = CEX2A_MAX_MOD_SIZE;
390 zdev->max_mod_size = CEX2A_MAX_MOD_SIZE; 397 zdev->short_crt = 1;
391 zdev->short_crt = 1; 398 zdev->speed_rating = CEX2A_SPEED_RATING;
392 zdev->speed_rating = CEX2A_SPEED_RATING; 399 break;
393 ap_dev->reply = &zdev->reply; 400 case AP_DEVICE_TYPE_CEX3A:
394 ap_dev->private = zdev; 401 zdev = zcrypt_device_alloc(CEX3A_MAX_RESPONSE_SIZE);
395 rc = zcrypt_device_register(zdev); 402 if (!zdev)
396 if (rc) 403 return -ENOMEM;
397 goto out_free; 404 zdev->user_space_type = ZCRYPT_CEX3A;
398 return 0; 405 zdev->type_string = "CEX3A";
399 406 zdev->min_mod_size = CEX3A_MIN_MOD_SIZE;
400out_free: 407 zdev->max_mod_size = CEX3A_MAX_MOD_SIZE;
401 ap_dev->private = NULL; 408 zdev->short_crt = 1;
402 zcrypt_device_free(zdev); 409 zdev->speed_rating = CEX3A_SPEED_RATING;
410 break;
411 }
412 if (zdev != NULL) {
413 zdev->ap_dev = ap_dev;
414 zdev->ops = &zcrypt_cex2a_ops;
415 zdev->online = 1;
416 ap_dev->reply = &zdev->reply;
417 ap_dev->private = zdev;
418 rc = zcrypt_device_register(zdev);
419 }
420 if (rc) {
421 ap_dev->private = NULL;
422 zcrypt_device_free(zdev);
423 }
403 return rc; 424 return rc;
404} 425}
405 426
diff --git a/drivers/s390/crypto/zcrypt_pcixcc.c b/drivers/s390/crypto/zcrypt_pcixcc.c
index cdaa401f20cd..d5f770a71d6c 100644
--- a/drivers/s390/crypto/zcrypt_pcixcc.c
+++ b/drivers/s390/crypto/zcrypt_pcixcc.c
@@ -43,10 +43,13 @@
43#define PCIXCC_MIN_MOD_SIZE 16 /* 128 bits */ 43#define PCIXCC_MIN_MOD_SIZE 16 /* 128 bits */
44#define PCIXCC_MIN_MOD_SIZE_OLD 64 /* 512 bits */ 44#define PCIXCC_MIN_MOD_SIZE_OLD 64 /* 512 bits */
45#define PCIXCC_MAX_MOD_SIZE 256 /* 2048 bits */ 45#define PCIXCC_MAX_MOD_SIZE 256 /* 2048 bits */
46#define CEX3C_MIN_MOD_SIZE PCIXCC_MIN_MOD_SIZE
47#define CEX3C_MAX_MOD_SIZE PCIXCC_MAX_MOD_SIZE
46 48
47#define PCIXCC_MCL2_SPEED_RATING 7870 /* FIXME: needs finetuning */ 49#define PCIXCC_MCL2_SPEED_RATING 7870 /* FIXME: needs finetuning */
48#define PCIXCC_MCL3_SPEED_RATING 7870 50#define PCIXCC_MCL3_SPEED_RATING 7870
49#define CEX2C_SPEED_RATING 8540 51#define CEX2C_SPEED_RATING 8540
52#define CEX3C_SPEED_RATING 10000 /* FIXME: needs finetuning */
50 53
51#define PCIXCC_MAX_ICA_MESSAGE_SIZE 0x77c /* max size type6 v2 crt message */ 54#define PCIXCC_MAX_ICA_MESSAGE_SIZE 0x77c /* max size type6 v2 crt message */
52#define PCIXCC_MAX_ICA_RESPONSE_SIZE 0x77c /* max size type86 v2 reply */ 55#define PCIXCC_MAX_ICA_RESPONSE_SIZE 0x77c /* max size type86 v2 reply */
@@ -1026,14 +1029,15 @@ out_free:
1026static int zcrypt_pcixcc_probe(struct ap_device *ap_dev) 1029static int zcrypt_pcixcc_probe(struct ap_device *ap_dev)
1027{ 1030{
1028 struct zcrypt_device *zdev; 1031 struct zcrypt_device *zdev;
1029 int rc; 1032 int rc = 0;
1030 1033
1031 zdev = zcrypt_device_alloc(PCIXCC_MAX_RESPONSE_SIZE); 1034 zdev = zcrypt_device_alloc(PCIXCC_MAX_RESPONSE_SIZE);
1032 if (!zdev) 1035 if (!zdev)
1033 return -ENOMEM; 1036 return -ENOMEM;
1034 zdev->ap_dev = ap_dev; 1037 zdev->ap_dev = ap_dev;
1035 zdev->online = 1; 1038 zdev->online = 1;
1036 if (ap_dev->device_type == AP_DEVICE_TYPE_PCIXCC) { 1039 switch (ap_dev->device_type) {
1040 case AP_DEVICE_TYPE_PCIXCC:
1037 rc = zcrypt_pcixcc_mcl(ap_dev); 1041 rc = zcrypt_pcixcc_mcl(ap_dev);
1038 if (rc < 0) { 1042 if (rc < 0) {
1039 zcrypt_device_free(zdev); 1043 zcrypt_device_free(zdev);
@@ -1051,13 +1055,25 @@ static int zcrypt_pcixcc_probe(struct ap_device *ap_dev)
1051 zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE; 1055 zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE;
1052 zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE; 1056 zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE;
1053 } 1057 }
1054 } else { 1058 break;
1059 case AP_DEVICE_TYPE_CEX2C:
1055 zdev->user_space_type = ZCRYPT_CEX2C; 1060 zdev->user_space_type = ZCRYPT_CEX2C;
1056 zdev->type_string = "CEX2C"; 1061 zdev->type_string = "CEX2C";
1057 zdev->speed_rating = CEX2C_SPEED_RATING; 1062 zdev->speed_rating = CEX2C_SPEED_RATING;
1058 zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE; 1063 zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE;
1059 zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE; 1064 zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE;
1065 break;
1066 case AP_DEVICE_TYPE_CEX3C:
1067 zdev->user_space_type = ZCRYPT_CEX3C;
1068 zdev->type_string = "CEX3C";
1069 zdev->speed_rating = CEX3C_SPEED_RATING;
1070 zdev->min_mod_size = CEX3C_MIN_MOD_SIZE;
1071 zdev->max_mod_size = CEX3C_MAX_MOD_SIZE;
1072 break;
1073 default:
1074 goto out_free;
1060 } 1075 }
1076
1061 rc = zcrypt_pcixcc_rng_supported(ap_dev); 1077 rc = zcrypt_pcixcc_rng_supported(ap_dev);
1062 if (rc < 0) { 1078 if (rc < 0) {
1063 zcrypt_device_free(zdev); 1079 zcrypt_device_free(zdev);