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

Commit b26bd941 authored by Holger Dengler's avatar Holger Dengler Committed by Martin Schwidefsky
Browse files

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: default avatarIngo Tuchscherer <ingo.tuchscherer@linux.vnet.ibm.com>
Signed-off-by: default avatarHolger Dengler <hd@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 75014550
Loading
Loading
Loading
Loading
+41 −19
Original line number Diff line number Diff line
@@ -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))
+9 −2
Original line number Diff line number Diff line
@@ -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_ */
+2 −1
Original line number Diff line number Diff line
@@ -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;
		}