Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Holger Dengler and committed by
Martin Schwidefsky
b26bd941 75014550

+52 -22
+41 -19
drivers/s390/crypto/ap_bus.c
··· 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 328 * ap_queue_enable_interruption(): Enable interruption on an AP. 348 329 * @qid: The AP queue number 349 330 * @ind: the notification indicator byte ··· 671 690 672 691 static DEVICE_ATTR(request_count, 0444, ap_request_count_show, NULL); 673 692 693 + static ssize_t ap_requestq_count_show(struct device *dev, 694 + struct device_attribute *attr, char *buf) 695 + { 696 + struct ap_device *ap_dev = to_ap_dev(dev); 697 + int rc; 698 + 699 + spin_lock_bh(&ap_dev->lock); 700 + rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->requestq_count); 701 + spin_unlock_bh(&ap_dev->lock); 702 + return rc; 703 + } 704 + 705 + static DEVICE_ATTR(requestq_count, 0444, ap_requestq_count_show, NULL); 706 + 707 + static ssize_t ap_pendingq_count_show(struct device *dev, 708 + struct device_attribute *attr, char *buf) 709 + { 710 + struct ap_device *ap_dev = to_ap_dev(dev); 711 + int rc; 712 + 713 + spin_lock_bh(&ap_dev->lock); 714 + rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->pendingq_count); 715 + spin_unlock_bh(&ap_dev->lock); 716 + return rc; 717 + } 718 + 719 + static DEVICE_ATTR(pendingq_count, 0444, ap_pendingq_count_show, NULL); 720 + 674 721 static ssize_t ap_modalias_show(struct device *dev, 675 722 struct device_attribute *attr, char *buf) 676 723 { ··· 707 698 708 699 static DEVICE_ATTR(modalias, 0444, ap_modalias_show, NULL); 709 700 701 + static ssize_t ap_functions_show(struct device *dev, 702 + struct device_attribute *attr, char *buf) 703 + { 704 + struct ap_device *ap_dev = to_ap_dev(dev); 705 + return snprintf(buf, PAGE_SIZE, "0x%08X\n", ap_dev->functions); 706 + } 707 + 708 + static DEVICE_ATTR(ap_functions, 0444, ap_functions_show, NULL); 709 + 710 710 static struct attribute *ap_dev_attrs[] = { 711 711 &dev_attr_hwtype.attr, 712 712 &dev_attr_depth.attr, 713 713 &dev_attr_request_count.attr, 714 + &dev_attr_requestq_count.attr, 715 + &dev_attr_pendingq_count.attr, 714 716 &dev_attr_modalias.attr, 717 + &dev_attr_ap_functions.attr, 715 718 NULL 716 719 }; 717 720 static struct attribute_group ap_dev_attr_group = { ··· 1350 1329 kfree(ap_dev); 1351 1330 continue; 1352 1331 } 1332 + ap_dev->functions = device_functions; 1353 1333 if (ap_test_bit(&device_functions, 3)) 1354 1334 ap_dev->device_type = AP_DEVICE_TYPE_CEX3C; 1355 1335 else if (ap_test_bit(&device_functions, 4))
+9 -2
drivers/s390/crypto/ap_bus.h
··· 118 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 129 * AP reset flag states 122 130 */ 123 131 #define AP_RESET_IGNORE 0 /* request timeout will be ignored */ ··· 158 150 ap_qid_t qid; /* AP queue id. */ 159 151 int queue_depth; /* AP queue depth.*/ 160 152 int device_type; /* AP device type. */ 153 + unsigned int functions; /* AP device function bitfield. */ 161 154 int unregistered; /* marks AP device as unregistered */ 162 155 struct timer_list timeout; /* Timer for request timeouts. */ 163 156 int reset; /* Reset required after req. timeout. */ ··· 233 224 234 225 int ap_module_init(void); 235 226 void ap_module_exit(void); 236 - 237 - int ap_4096_commands_available(ap_qid_t qid); 238 227 239 228 #endif /* _AP_BUS_H_ */
+2 -1
drivers/s390/crypto/zcrypt_cex2a.c
··· 449 449 zdev->min_mod_size = CEX2A_MIN_MOD_SIZE; 450 450 zdev->max_mod_size = CEX2A_MAX_MOD_SIZE; 451 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 454 zdev->max_mod_size = CEX3A_MAX_MOD_SIZE; 454 455 zdev->max_exp_bit_length = CEX3A_MAX_MOD_SIZE; 455 456 }