diff options
author | Holger Dengler <hd@linux.vnet.ibm.com> | 2012-08-28 10:43:48 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2012-09-26 09:44:55 -0400 |
commit | b26bd9413c8359bd9f5c9bd1b789a10ebd2bb484 (patch) | |
tree | 89f0809ea27a39f7ef43061173b760e941408f02 /drivers/s390/crypto | |
parent | 75014550516b147e5f530b84c71496341e036d6f (diff) |
s390/ap: Add functiton facility information as AP device attribute.
Add the function facility information as new ap_device and sysfs
attribute. Also make the number of requests in device
queue and in device driver queue accessible in sysfs.
Reviewed-by: Ingo Tuchscherer <ingo.tuchscherer@linux.vnet.ibm.com>
Signed-off-by: Holger Dengler <hd@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/crypto')
-rw-r--r-- | drivers/s390/crypto/ap_bus.c | 60 | ||||
-rw-r--r-- | drivers/s390/crypto/ap_bus.h | 11 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_cex2a.c | 3 |
3 files changed, 52 insertions, 22 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 047c7327b1b4..f0b53ee6802f 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
@@ -325,25 +325,6 @@ static int ap_query_functions(ap_qid_t qid, unsigned int *functions) | |||
325 | } | 325 | } |
326 | 326 | ||
327 | /** | 327 | /** |
328 | * ap_4096_commands_availablen(): Check for availability of 4096 bit RSA | ||
329 | * support. | ||
330 | * @qid: The AP queue number | ||
331 | * | ||
332 | * Returns 1 if 4096 bit RSA keys are support fo the AP, returns 0 if not. | ||
333 | */ | ||
334 | int ap_4096_commands_available(ap_qid_t qid) | ||
335 | { | ||
336 | unsigned int functions; | ||
337 | |||
338 | if (ap_query_functions(qid, &functions)) | ||
339 | return 0; | ||
340 | |||
341 | return ap_test_bit(&functions, 1) && | ||
342 | ap_test_bit(&functions, 2); | ||
343 | } | ||
344 | EXPORT_SYMBOL(ap_4096_commands_available); | ||
345 | |||
346 | /** | ||
347 | * ap_queue_enable_interruption(): Enable interruption on an AP. | 328 | * ap_queue_enable_interruption(): Enable interruption on an AP. |
348 | * @qid: The AP queue number | 329 | * @qid: The AP queue number |
349 | * @ind: the notification indicator byte | 330 | * @ind: the notification indicator byte |
@@ -690,6 +671,34 @@ static ssize_t ap_request_count_show(struct device *dev, | |||
690 | 671 | ||
691 | static DEVICE_ATTR(request_count, 0444, ap_request_count_show, NULL); | 672 | static DEVICE_ATTR(request_count, 0444, ap_request_count_show, NULL); |
692 | 673 | ||
674 | static ssize_t ap_requestq_count_show(struct device *dev, | ||
675 | struct device_attribute *attr, char *buf) | ||
676 | { | ||
677 | struct ap_device *ap_dev = to_ap_dev(dev); | ||
678 | int rc; | ||
679 | |||
680 | spin_lock_bh(&ap_dev->lock); | ||
681 | rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->requestq_count); | ||
682 | spin_unlock_bh(&ap_dev->lock); | ||
683 | return rc; | ||
684 | } | ||
685 | |||
686 | static DEVICE_ATTR(requestq_count, 0444, ap_requestq_count_show, NULL); | ||
687 | |||
688 | static ssize_t ap_pendingq_count_show(struct device *dev, | ||
689 | struct device_attribute *attr, char *buf) | ||
690 | { | ||
691 | struct ap_device *ap_dev = to_ap_dev(dev); | ||
692 | int rc; | ||
693 | |||
694 | spin_lock_bh(&ap_dev->lock); | ||
695 | rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->pendingq_count); | ||
696 | spin_unlock_bh(&ap_dev->lock); | ||
697 | return rc; | ||
698 | } | ||
699 | |||
700 | static DEVICE_ATTR(pendingq_count, 0444, ap_pendingq_count_show, NULL); | ||
701 | |||
693 | static ssize_t ap_modalias_show(struct device *dev, | 702 | static ssize_t ap_modalias_show(struct device *dev, |
694 | struct device_attribute *attr, char *buf) | 703 | struct device_attribute *attr, char *buf) |
695 | { | 704 | { |
@@ -698,11 +707,23 @@ static ssize_t ap_modalias_show(struct device *dev, | |||
698 | 707 | ||
699 | static DEVICE_ATTR(modalias, 0444, ap_modalias_show, NULL); | 708 | static DEVICE_ATTR(modalias, 0444, ap_modalias_show, NULL); |
700 | 709 | ||
710 | static ssize_t ap_functions_show(struct device *dev, | ||
711 | struct device_attribute *attr, char *buf) | ||
712 | { | ||
713 | struct ap_device *ap_dev = to_ap_dev(dev); | ||
714 | return snprintf(buf, PAGE_SIZE, "0x%08X\n", ap_dev->functions); | ||
715 | } | ||
716 | |||
717 | static DEVICE_ATTR(ap_functions, 0444, ap_functions_show, NULL); | ||
718 | |||
701 | static struct attribute *ap_dev_attrs[] = { | 719 | static struct attribute *ap_dev_attrs[] = { |
702 | &dev_attr_hwtype.attr, | 720 | &dev_attr_hwtype.attr, |
703 | &dev_attr_depth.attr, | 721 | &dev_attr_depth.attr, |
704 | &dev_attr_request_count.attr, | 722 | &dev_attr_request_count.attr, |
723 | &dev_attr_requestq_count.attr, | ||
724 | &dev_attr_pendingq_count.attr, | ||
705 | &dev_attr_modalias.attr, | 725 | &dev_attr_modalias.attr, |
726 | &dev_attr_ap_functions.attr, | ||
706 | NULL | 727 | NULL |
707 | }; | 728 | }; |
708 | static struct attribute_group ap_dev_attr_group = { | 729 | static struct attribute_group ap_dev_attr_group = { |
@@ -1329,6 +1350,7 @@ static void ap_scan_bus(struct work_struct *unused) | |||
1329 | kfree(ap_dev); | 1350 | kfree(ap_dev); |
1330 | continue; | 1351 | continue; |
1331 | } | 1352 | } |
1353 | ap_dev->functions = device_functions; | ||
1332 | if (ap_test_bit(&device_functions, 3)) | 1354 | if (ap_test_bit(&device_functions, 3)) |
1333 | ap_dev->device_type = AP_DEVICE_TYPE_CEX3C; | 1355 | ap_dev->device_type = AP_DEVICE_TYPE_CEX3C; |
1334 | else if (ap_test_bit(&device_functions, 4)) | 1356 | else if (ap_test_bit(&device_functions, 4)) |
diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h index 5018f66dada5..e49bcf4d4081 100644 --- a/drivers/s390/crypto/ap_bus.h +++ b/drivers/s390/crypto/ap_bus.h | |||
@@ -118,6 +118,14 @@ static inline int ap_test_bit(unsigned int *ptr, unsigned int nr) | |||
118 | #define AP_DEVICE_TYPE_CEX3C 9 | 118 | #define AP_DEVICE_TYPE_CEX3C 9 |
119 | 119 | ||
120 | /* | 120 | /* |
121 | * Known function facilities | ||
122 | */ | ||
123 | #define AP_FUNC_MEX4K 1 | ||
124 | #define AP_FUNC_CRT4K 2 | ||
125 | #define AP_FUNC_COPRO 3 | ||
126 | #define AP_FUNC_ACCEL 4 | ||
127 | |||
128 | /* | ||
121 | * AP reset flag states | 129 | * AP reset flag states |
122 | */ | 130 | */ |
123 | #define AP_RESET_IGNORE 0 /* request timeout will be ignored */ | 131 | #define AP_RESET_IGNORE 0 /* request timeout will be ignored */ |
@@ -150,6 +158,7 @@ struct ap_device { | |||
150 | ap_qid_t qid; /* AP queue id. */ | 158 | ap_qid_t qid; /* AP queue id. */ |
151 | int queue_depth; /* AP queue depth.*/ | 159 | int queue_depth; /* AP queue depth.*/ |
152 | int device_type; /* AP device type. */ | 160 | int device_type; /* AP device type. */ |
161 | unsigned int functions; /* AP device function bitfield. */ | ||
153 | int unregistered; /* marks AP device as unregistered */ | 162 | int unregistered; /* marks AP device as unregistered */ |
154 | struct timer_list timeout; /* Timer for request timeouts. */ | 163 | struct timer_list timeout; /* Timer for request timeouts. */ |
155 | int reset; /* Reset required after req. timeout. */ | 164 | int reset; /* Reset required after req. timeout. */ |
@@ -225,6 +234,4 @@ void ap_flush_queue(struct ap_device *ap_dev); | |||
225 | int ap_module_init(void); | 234 | int ap_module_init(void); |
226 | void ap_module_exit(void); | 235 | void ap_module_exit(void); |
227 | 236 | ||
228 | int ap_4096_commands_available(ap_qid_t qid); | ||
229 | |||
230 | #endif /* _AP_BUS_H_ */ | 237 | #endif /* _AP_BUS_H_ */ |
diff --git a/drivers/s390/crypto/zcrypt_cex2a.c b/drivers/s390/crypto/zcrypt_cex2a.c index 744c668f586c..8f5f70b43b29 100644 --- a/drivers/s390/crypto/zcrypt_cex2a.c +++ b/drivers/s390/crypto/zcrypt_cex2a.c | |||
@@ -449,7 +449,8 @@ static int zcrypt_cex2a_probe(struct ap_device *ap_dev) | |||
449 | zdev->min_mod_size = CEX2A_MIN_MOD_SIZE; | 449 | zdev->min_mod_size = CEX2A_MIN_MOD_SIZE; |
450 | zdev->max_mod_size = CEX2A_MAX_MOD_SIZE; | 450 | zdev->max_mod_size = CEX2A_MAX_MOD_SIZE; |
451 | zdev->max_exp_bit_length = CEX2A_MAX_MOD_SIZE; | 451 | zdev->max_exp_bit_length = CEX2A_MAX_MOD_SIZE; |
452 | if (ap_4096_commands_available(ap_dev->qid)) { | 452 | if (ap_test_bit(&ap_dev->functions, AP_FUNC_MEX4K) && |
453 | ap_test_bit(&ap_dev->functions, AP_FUNC_CRT4K)) { | ||
453 | zdev->max_mod_size = CEX3A_MAX_MOD_SIZE; | 454 | zdev->max_mod_size = CEX3A_MAX_MOD_SIZE; |
454 | zdev->max_exp_bit_length = CEX3A_MAX_MOD_SIZE; | 455 | zdev->max_exp_bit_length = CEX3A_MAX_MOD_SIZE; |
455 | } | 456 | } |