Commit dbc8876d authored by Ciunas Bennett's avatar Ciunas Bennett Committed by Herbert Xu

crypto: qat - add rp2svc sysfs attribute

Add the attribute `rp2svc` to the `qat` attribute group. This provides a
way for a user to query a specific ring pair for the type of service
that is currently configured for.

When read, the service will be returned for the defined ring pair.
When written to this value will be stored as the ring pair to return
the service of.
Signed-off-by: default avatarCiunas Bennett <ciunas.bennett@intel.com>
Reviewed-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: default avatarDamian Muszynski <damian.muszynski@intel.com>
Reviewed-by: default avatarTero Kristo <tero.kristo@linux.intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent db74e162
......@@ -95,3 +95,35 @@ Description: (RW) This configuration option provides a way to force the device i
0
This attribute is only available for qat_4xxx devices.
What: /sys/bus/pci/devices/<BDF>/qat/rp2srv
Date: January 2024
KernelVersion: 6.7
Contact: qat-linux@intel.com
Description:
(RW) This attribute provides a way for a user to query a
specific ring pair for the type of service that it is currently
configured for.
When written to, the value is cached and used to perform the
read operation. Allowed values are in the range 0 to N-1, where
N is the max number of ring pairs supported by a device. This
can be queried using the attribute qat/num_rps.
A read returns the service associated to the ring pair queried.
The values are:
* dc: the ring pair is configured for running compression services
* sym: the ring pair is configured for running symmetric crypto
services
* asym: the ring pair is configured for running asymmetric crypto
services
Example usage::
# echo 1 > /sys/bus/pci/devices/<BDF>/qat/rp2srv
# cat /sys/bus/pci/devices/<BDF>/qat/rp2srv
sym
This attribute is only available for qat_4xxx devices.
......@@ -340,6 +340,11 @@ struct adf_pm {
char __user *buf, size_t count, loff_t *pos);
};
struct adf_sysfs {
int ring_num;
struct rw_semaphore lock; /* protects access to the fields in this struct */
};
struct adf_accel_dev {
struct adf_etr_data *transport;
struct adf_hw_device_data *hw_device;
......@@ -361,6 +366,7 @@ struct adf_accel_dev {
struct adf_timer *timer;
struct adf_heartbeat *heartbeat;
struct adf_rl *rate_limiting;
struct adf_sysfs sysfs;
union {
struct {
/* protects VF2PF interrupts access */
......
......@@ -8,6 +8,8 @@
#include "adf_cfg_services.h"
#include "adf_common_drv.h"
#define UNSET_RING_NUM -1
static const char * const state_operations[] = {
[DEV_DOWN] = "down",
[DEV_UP] = "up",
......@@ -205,10 +207,72 @@ static DEVICE_ATTR_RW(pm_idle_enabled);
static DEVICE_ATTR_RW(state);
static DEVICE_ATTR_RW(cfg_services);
static ssize_t rp2srv_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct adf_hw_device_data *hw_data;
struct adf_accel_dev *accel_dev;
enum adf_cfg_service_type svc;
accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
hw_data = GET_HW_DATA(accel_dev);
if (accel_dev->sysfs.ring_num == UNSET_RING_NUM)
return -EINVAL;
down_read(&accel_dev->sysfs.lock);
svc = GET_SRV_TYPE(accel_dev, accel_dev->sysfs.ring_num %
hw_data->num_banks_per_vf);
up_read(&accel_dev->sysfs.lock);
switch (svc) {
case COMP:
return sysfs_emit(buf, "%s\n", ADF_CFG_DC);
case SYM:
return sysfs_emit(buf, "%s\n", ADF_CFG_SYM);
case ASYM:
return sysfs_emit(buf, "%s\n", ADF_CFG_ASYM);
default:
break;
}
return -EINVAL;
}
static ssize_t rp2srv_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct adf_accel_dev *accel_dev;
int ring, num_rings, ret;
accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
if (!accel_dev)
return -EINVAL;
ret = kstrtouint(buf, 10, &ring);
if (ret)
return ret;
num_rings = GET_MAX_BANKS(accel_dev);
if (ring >= num_rings) {
dev_err(&GET_DEV(accel_dev),
"Device does not support more than %u ring pairs\n",
num_rings);
return -EINVAL;
}
down_write(&accel_dev->sysfs.lock);
accel_dev->sysfs.ring_num = ring;
up_write(&accel_dev->sysfs.lock);
return count;
}
static DEVICE_ATTR_RW(rp2srv);
static struct attribute *qat_attrs[] = {
&dev_attr_state.attr,
&dev_attr_cfg_services.attr,
&dev_attr_pm_idle_enabled.attr,
&dev_attr_rp2srv.attr,
NULL,
};
......@@ -227,6 +291,8 @@ int adf_sysfs_init(struct adf_accel_dev *accel_dev)
"Failed to create qat attribute group: %d\n", ret);
}
accel_dev->sysfs.ring_num = UNSET_RING_NUM;
return ret;
}
EXPORT_SYMBOL_GPL(adf_sysfs_init);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment