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

Configure Feed

Select the types of activity you want to include in your feed.

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: Ciunas Bennett <ciunas.bennett@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Damian Muszynski <damian.muszynski@intel.com>
Reviewed-by: Tero Kristo <tero.kristo@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ciunas Bennett and committed by
Herbert Xu
dbc8876d db74e162

+104
+32
Documentation/ABI/testing/sysfs-driver-qat
··· 95 95 0 96 96 97 97 This attribute is only available for qat_4xxx devices. 98 + 99 + What: /sys/bus/pci/devices/<BDF>/qat/rp2srv 100 + Date: January 2024 101 + KernelVersion: 6.7 102 + Contact: qat-linux@intel.com 103 + Description: 104 + (RW) This attribute provides a way for a user to query a 105 + specific ring pair for the type of service that it is currently 106 + configured for. 107 + 108 + When written to, the value is cached and used to perform the 109 + read operation. Allowed values are in the range 0 to N-1, where 110 + N is the max number of ring pairs supported by a device. This 111 + can be queried using the attribute qat/num_rps. 112 + 113 + A read returns the service associated to the ring pair queried. 114 + 115 + The values are: 116 + 117 + * dc: the ring pair is configured for running compression services 118 + * sym: the ring pair is configured for running symmetric crypto 119 + services 120 + * asym: the ring pair is configured for running asymmetric crypto 121 + services 122 + 123 + Example usage:: 124 + 125 + # echo 1 > /sys/bus/pci/devices/<BDF>/qat/rp2srv 126 + # cat /sys/bus/pci/devices/<BDF>/qat/rp2srv 127 + sym 128 + 129 + This attribute is only available for qat_4xxx devices.
+6
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h
··· 340 340 char __user *buf, size_t count, loff_t *pos); 341 341 }; 342 342 343 + struct adf_sysfs { 344 + int ring_num; 345 + struct rw_semaphore lock; /* protects access to the fields in this struct */ 346 + }; 347 + 343 348 struct adf_accel_dev { 344 349 struct adf_etr_data *transport; 345 350 struct adf_hw_device_data *hw_device; ··· 366 361 struct adf_timer *timer; 367 362 struct adf_heartbeat *heartbeat; 368 363 struct adf_rl *rate_limiting; 364 + struct adf_sysfs sysfs; 369 365 union { 370 366 struct { 371 367 /* protects VF2PF interrupts access */
+66
drivers/crypto/intel/qat/qat_common/adf_sysfs.c
··· 8 8 #include "adf_cfg_services.h" 9 9 #include "adf_common_drv.h" 10 10 11 + #define UNSET_RING_NUM -1 12 + 11 13 static const char * const state_operations[] = { 12 14 [DEV_DOWN] = "down", 13 15 [DEV_UP] = "up", ··· 207 205 static DEVICE_ATTR_RW(state); 208 206 static DEVICE_ATTR_RW(cfg_services); 209 207 208 + static ssize_t rp2srv_show(struct device *dev, struct device_attribute *attr, 209 + char *buf) 210 + { 211 + struct adf_hw_device_data *hw_data; 212 + struct adf_accel_dev *accel_dev; 213 + enum adf_cfg_service_type svc; 214 + 215 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 216 + hw_data = GET_HW_DATA(accel_dev); 217 + 218 + if (accel_dev->sysfs.ring_num == UNSET_RING_NUM) 219 + return -EINVAL; 220 + 221 + down_read(&accel_dev->sysfs.lock); 222 + svc = GET_SRV_TYPE(accel_dev, accel_dev->sysfs.ring_num % 223 + hw_data->num_banks_per_vf); 224 + up_read(&accel_dev->sysfs.lock); 225 + 226 + switch (svc) { 227 + case COMP: 228 + return sysfs_emit(buf, "%s\n", ADF_CFG_DC); 229 + case SYM: 230 + return sysfs_emit(buf, "%s\n", ADF_CFG_SYM); 231 + case ASYM: 232 + return sysfs_emit(buf, "%s\n", ADF_CFG_ASYM); 233 + default: 234 + break; 235 + } 236 + return -EINVAL; 237 + } 238 + 239 + static ssize_t rp2srv_store(struct device *dev, struct device_attribute *attr, 240 + const char *buf, size_t count) 241 + { 242 + struct adf_accel_dev *accel_dev; 243 + int ring, num_rings, ret; 244 + 245 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 246 + if (!accel_dev) 247 + return -EINVAL; 248 + 249 + ret = kstrtouint(buf, 10, &ring); 250 + if (ret) 251 + return ret; 252 + 253 + num_rings = GET_MAX_BANKS(accel_dev); 254 + if (ring >= num_rings) { 255 + dev_err(&GET_DEV(accel_dev), 256 + "Device does not support more than %u ring pairs\n", 257 + num_rings); 258 + return -EINVAL; 259 + } 260 + 261 + down_write(&accel_dev->sysfs.lock); 262 + accel_dev->sysfs.ring_num = ring; 263 + up_write(&accel_dev->sysfs.lock); 264 + 265 + return count; 266 + } 267 + static DEVICE_ATTR_RW(rp2srv); 268 + 210 269 static struct attribute *qat_attrs[] = { 211 270 &dev_attr_state.attr, 212 271 &dev_attr_cfg_services.attr, 213 272 &dev_attr_pm_idle_enabled.attr, 273 + &dev_attr_rp2srv.attr, 214 274 NULL, 215 275 }; 216 276 ··· 290 226 dev_err(&GET_DEV(accel_dev), 291 227 "Failed to create qat attribute group: %d\n", ret); 292 228 } 229 + 230 + accel_dev->sysfs.ring_num = UNSET_RING_NUM; 293 231 294 232 return ret; 295 233 }