Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdea1f1b authored by Ingo Tuchscherer's avatar Ingo Tuchscherer Committed by Martin Schwidefsky
Browse files

s390/zcrypt: Add support for new crypto express (CEX5S) adapter.



Extends the generic cryptographic device driver (zcrypt)
to support the Crypto Express 5S adapter.

Signed-off-by: default avatarIngo Tuchscherer <ingo.tuchscherer@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 5bc334bf
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -1489,9 +1489,6 @@ static void ap_scan_bus(struct work_struct *unused)
				continue;
			}
			break;
		case 11:
			ap_dev->device_type = 10;
			break;
		default:
			ap_dev->device_type = device_type;
		}
+1 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ static inline int ap_test_bit(unsigned int *ptr, unsigned int nr)
#define AP_DEVICE_TYPE_CEX3A	8
#define AP_DEVICE_TYPE_CEX3C	9
#define AP_DEVICE_TYPE_CEX4	10
#define AP_DEVICE_TYPE_CEX5	11

/*
 * Known function facilities
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ struct ica_z90_status {
#define ZCRYPT_CEX3C		7
#define ZCRYPT_CEX3A		8
#define ZCRYPT_CEX4	       10
#define ZCRYPT_CEX5	       11

/**
 * Large random numbers are pulled in 4096 byte chunks from the crypto cards
+27 −6
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@

#define CEX4A_SPEED_RATING	900	 /* TODO new card, new speed rating */
#define CEX4C_SPEED_RATING	6500	 /* TODO new card, new speed rating */
#define CEX4P_SPEED_RATING	7000	 /* TODO new card, new speed rating */
#define CEX5A_SPEED_RATING	450	 /* TODO new card, new speed rating */
#define CEX5C_SPEED_RATING	3250	 /* TODO new card, new speed rating */
#define CEX5P_SPEED_RATING	3500	 /* TODO new card, new speed rating */

#define CEX4A_MAX_MESSAGE_SIZE	MSGTYPE50_CRB3_MAX_MSG_SIZE
#define CEX4C_MAX_MESSAGE_SIZE	MSGTYPE06_MAX_MSG_SIZE
@@ -39,6 +43,7 @@

static struct ap_device_id zcrypt_cex4_ids[] = {
	{ AP_DEVICE(AP_DEVICE_TYPE_CEX4)  },
	{ AP_DEVICE(AP_DEVICE_TYPE_CEX5)  },
	{ /* end of list */ },
};

@@ -70,11 +75,18 @@ static int zcrypt_cex4_probe(struct ap_device *ap_dev)

	switch (ap_dev->device_type) {
	case AP_DEVICE_TYPE_CEX4:
	case AP_DEVICE_TYPE_CEX5:
		if (ap_test_bit(&ap_dev->functions, AP_FUNC_ACCEL)) {
			zdev = zcrypt_device_alloc(CEX4A_MAX_MESSAGE_SIZE);
			if (!zdev)
				return -ENOMEM;
			if (ap_dev->device_type == AP_DEVICE_TYPE_CEX4) {
				zdev->type_string = "CEX4A";
				zdev->speed_rating = CEX4A_SPEED_RATING;
			} else {
				zdev->type_string = "CEX5A";
				zdev->speed_rating = CEX5A_SPEED_RATING;
			}
			zdev->user_space_type = ZCRYPT_CEX3A;
			zdev->min_mod_size = CEX4A_MIN_MOD_SIZE;
			if (ap_test_bit(&ap_dev->functions, AP_FUNC_MEX4K) &&
@@ -90,33 +102,42 @@ static int zcrypt_cex4_probe(struct ap_device *ap_dev)
					CEX4A_MAX_MOD_SIZE_2K;
			}
			zdev->short_crt = 1;
			zdev->speed_rating = CEX4A_SPEED_RATING;
			zdev->ops = zcrypt_msgtype_request(MSGTYPE50_NAME,
							   MSGTYPE50_VARIANT_DEFAULT);
		} else if (ap_test_bit(&ap_dev->functions, AP_FUNC_COPRO)) {
			zdev = zcrypt_device_alloc(CEX4C_MAX_MESSAGE_SIZE);
			if (!zdev)
				return -ENOMEM;
			if (ap_dev->device_type == AP_DEVICE_TYPE_CEX4) {
				zdev->type_string = "CEX4C";
				zdev->speed_rating = CEX4C_SPEED_RATING;
			} else {
				zdev->type_string = "CEX5C";
				zdev->speed_rating = CEX5C_SPEED_RATING;
			}
			zdev->user_space_type = ZCRYPT_CEX3C;
			zdev->min_mod_size = CEX4C_MIN_MOD_SIZE;
			zdev->max_mod_size = CEX4C_MAX_MOD_SIZE;
			zdev->max_exp_bit_length = CEX4C_MAX_MOD_SIZE;
			zdev->short_crt = 0;
			zdev->speed_rating = CEX4C_SPEED_RATING;
			zdev->ops = zcrypt_msgtype_request(MSGTYPE06_NAME,
							   MSGTYPE06_VARIANT_DEFAULT);
		} else if (ap_test_bit(&ap_dev->functions, AP_FUNC_EP11)) {
			zdev = zcrypt_device_alloc(CEX4C_MAX_MESSAGE_SIZE);
			if (!zdev)
				return -ENOMEM;
			if (ap_dev->device_type == AP_DEVICE_TYPE_CEX4) {
				zdev->type_string = "CEX4P";
				zdev->speed_rating = CEX4P_SPEED_RATING;
			} else {
				zdev->type_string = "CEX5P";
				zdev->speed_rating = CEX5P_SPEED_RATING;
			}
			zdev->user_space_type = ZCRYPT_CEX4;
			zdev->min_mod_size = CEX4C_MIN_MOD_SIZE;
			zdev->max_mod_size = CEX4C_MAX_MOD_SIZE;
			zdev->max_exp_bit_length = CEX4C_MAX_MOD_SIZE;
			zdev->short_crt = 0;
			zdev->speed_rating = CEX4C_SPEED_RATING;
			zdev->ops = zcrypt_msgtype_request(MSGTYPE06_NAME,
							MSGTYPE06_VARIANT_EP11);
		}