]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
s390/ap: Add functiton facility information as AP device attribute.
authorHolger Dengler <hd@linux.vnet.ibm.com>
Tue, 28 Aug 2012 14:43:48 +0000 (16:43 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 18 Sep 2012 07:04:51 +0000 (09:04 +0200)
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>
drivers/s390/crypto/ap_bus.c
drivers/s390/crypto/ap_bus.h
drivers/s390/crypto/zcrypt_cex2a.c

index 047c7327b1b4843ebc637e290b20c090081c16e1..f0b53ee6802fee9641841b1c61ca4388b5690bc4 100644 (file)
@@ -324,25 +324,6 @@ static int ap_query_functions(ap_qid_t qid, unsigned int *functions)
 #endif
 }
 
-/**
- * ap_4096_commands_availablen(): Check for availability of 4096 bit RSA
- * support.
- * @qid: The AP queue number
- *
- * Returns 1 if 4096 bit RSA keys are support fo the AP, returns 0 if not.
- */
-int ap_4096_commands_available(ap_qid_t qid)
-{
-       unsigned int functions;
-
-       if (ap_query_functions(qid, &functions))
-               return 0;
-
-       return ap_test_bit(&functions, 1) &&
-              ap_test_bit(&functions, 2);
-}
-EXPORT_SYMBOL(ap_4096_commands_available);
-
 /**
  * ap_queue_enable_interruption(): Enable interruption on an AP.
  * @qid: The AP queue number
@@ -690,6 +671,34 @@ static ssize_t ap_request_count_show(struct device *dev,
 
 static DEVICE_ATTR(request_count, 0444, ap_request_count_show, NULL);
 
+static ssize_t ap_requestq_count_show(struct device *dev,
+                                     struct device_attribute *attr, char *buf)
+{
+       struct ap_device *ap_dev = to_ap_dev(dev);
+       int rc;
+
+       spin_lock_bh(&ap_dev->lock);
+       rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->requestq_count);
+       spin_unlock_bh(&ap_dev->lock);
+       return rc;
+}
+
+static DEVICE_ATTR(requestq_count, 0444, ap_requestq_count_show, NULL);
+
+static ssize_t ap_pendingq_count_show(struct device *dev,
+                                     struct device_attribute *attr, char *buf)
+{
+       struct ap_device *ap_dev = to_ap_dev(dev);
+       int rc;
+
+       spin_lock_bh(&ap_dev->lock);
+       rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->pendingq_count);
+       spin_unlock_bh(&ap_dev->lock);
+       return rc;
+}
+
+static DEVICE_ATTR(pendingq_count, 0444, ap_pendingq_count_show, NULL);
+
 static ssize_t ap_modalias_show(struct device *dev,
                                struct device_attribute *attr, char *buf)
 {
@@ -698,11 +707,23 @@ static ssize_t ap_modalias_show(struct device *dev,
 
 static DEVICE_ATTR(modalias, 0444, ap_modalias_show, NULL);
 
+static ssize_t ap_functions_show(struct device *dev,
+                                struct device_attribute *attr, char *buf)
+{
+       struct ap_device *ap_dev = to_ap_dev(dev);
+       return snprintf(buf, PAGE_SIZE, "0x%08X\n", ap_dev->functions);
+}
+
+static DEVICE_ATTR(ap_functions, 0444, ap_functions_show, NULL);
+
 static struct attribute *ap_dev_attrs[] = {
        &dev_attr_hwtype.attr,
        &dev_attr_depth.attr,
        &dev_attr_request_count.attr,
+       &dev_attr_requestq_count.attr,
+       &dev_attr_pendingq_count.attr,
        &dev_attr_modalias.attr,
+       &dev_attr_ap_functions.attr,
        NULL
 };
 static struct attribute_group ap_dev_attr_group = {
@@ -1329,6 +1350,7 @@ static void ap_scan_bus(struct work_struct *unused)
                                kfree(ap_dev);
                                continue;
                        }
+                       ap_dev->functions = device_functions;
                        if (ap_test_bit(&device_functions, 3))
                                ap_dev->device_type = AP_DEVICE_TYPE_CEX3C;
                        else if (ap_test_bit(&device_functions, 4))
index 5018f66dada50c4b44125569adae8deca7112c64..e49bcf4d40811c39f6c306fe2728b61edb9c4e49 100644 (file)
@@ -117,6 +117,14 @@ static inline int ap_test_bit(unsigned int *ptr, unsigned int nr)
 #define AP_DEVICE_TYPE_CEX3A   8
 #define AP_DEVICE_TYPE_CEX3C   9
 
+/*
+ * Known function facilities
+ */
+#define AP_FUNC_MEX4K 1
+#define AP_FUNC_CRT4K 2
+#define AP_FUNC_COPRO 3
+#define AP_FUNC_ACCEL 4
+
 /*
  * AP reset flag states
  */
@@ -150,6 +158,7 @@ struct ap_device {
        ap_qid_t qid;                   /* AP queue id. */
        int queue_depth;                /* AP queue depth.*/
        int device_type;                /* AP device type. */
+       unsigned int functions;         /* AP device function bitfield. */
        int unregistered;               /* marks AP device as unregistered */
        struct timer_list timeout;      /* Timer for request timeouts. */
        int reset;                      /* Reset required after req. timeout. */
@@ -225,6 +234,4 @@ void ap_flush_queue(struct ap_device *ap_dev);
 int ap_module_init(void);
 void ap_module_exit(void);
 
-int ap_4096_commands_available(ap_qid_t qid);
-
 #endif /* _AP_BUS_H_ */
index 744c668f586c56b749ca55ed9c9d40af206f9169..8f5f70b43b296ffa3265d3cbb84b269f0972513c 100644 (file)
@@ -449,7 +449,8 @@ static int zcrypt_cex2a_probe(struct ap_device *ap_dev)
                zdev->min_mod_size = CEX2A_MIN_MOD_SIZE;
                zdev->max_mod_size = CEX2A_MAX_MOD_SIZE;
                zdev->max_exp_bit_length = CEX2A_MAX_MOD_SIZE;
-               if (ap_4096_commands_available(ap_dev->qid)) {
+               if (ap_test_bit(&ap_dev->functions, AP_FUNC_MEX4K) &&
+                   ap_test_bit(&ap_dev->functions, AP_FUNC_CRT4K)) {
                        zdev->max_mod_size = CEX3A_MAX_MOD_SIZE;
                        zdev->max_exp_bit_length = CEX3A_MAX_MOD_SIZE;
                }