diff options
Diffstat (limited to 'drivers/s390/crypto/zcrypt_cex2a.c')
-rw-r--r-- | drivers/s390/crypto/zcrypt_cex2a.c | 71 |
1 files changed, 46 insertions, 25 deletions
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 | ||
50 | static struct ap_device_id zcrypt_cex2a_ids[] = { | 57 | static 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 | */ |
376 | static int zcrypt_cex2a_probe(struct ap_device *ap_dev) | 383 | static 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; | |
400 | out_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 | ||