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

crypto: qat - add rate limiting sysfs interface

Add an interface for the rate limiting feature which allows to add,
remove and modify a QAT SLA (Service Level Agreement).

This adds a new sysfs attribute group, `qat_rl`, which can be accessed
from /sys/bus/pci/devices/<BUS:DEV:FUNCTION> with the following
hierarchy:
|-+ qat_rl
|---- id (RW) # SLA identifier
|---- cir (RW) # Committed Information Rate
|---- pir (RW) # Peak Information Rate
|---- srv (RW) # Service to be rate limited
|---- rp (RW) (HEX) # Ring pairs to be rate limited
|---- cap_rem (RW) # Remaining capability for a service
|---- sla_op (WO) # Allows to perform an operation on an SLA

The API works by setting the appropriate RW attributes and then
issuing a command through the `sla_op`. For example, to create an SLA, a
user needs to input the necessary data into the attributes cir, pir, srv
and rp and then write into `sla_op` the command `add` to execute the
operation.
The API also provides `cap_rem` attribute to get information about
the remaining device capability within a certain service which is
required when setting an SLA.

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
db74e162 d9fb8408

+706
+226
Documentation/ABI/testing/sysfs-driver-qat_rl
··· 1 + What: /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 2 + Date: January 2024 3 + KernelVersion: 6.7 4 + Contact: qat-linux@intel.com 5 + Description: 6 + (WO) This attribute is used to perform an operation on an SLA. 7 + The supported operations are: add, update, rm, rm_all, and get. 8 + 9 + Input values must be filled through the associated attribute in 10 + this group before a write to this file. 11 + If the operation completes successfully, the associated 12 + attributes will be updated. 13 + The associated attributes are: cir, pir, srv, rp, and id. 14 + 15 + Supported operations: 16 + 17 + * add: Creates a new SLA with the provided inputs from user. 18 + * Inputs: cir, pir, srv, and rp 19 + * Output: id 20 + 21 + * get: Returns the configuration of the specified SLA in id attribute 22 + * Inputs: id 23 + * Outputs: cir, pir, srv, and rp 24 + 25 + * update: Updates the SLA with new values set in the following attributes 26 + * Inputs: id, cir, and pir 27 + 28 + * rm: Removes the specified SLA in the id attribute. 29 + * Inputs: id 30 + 31 + * rm_all: Removes all the configured SLAs. 32 + * Inputs: None 33 + 34 + This attribute is only available for qat_4xxx devices. 35 + 36 + What: /sys/bus/pci/devices/<BDF>/qat_rl/rp 37 + Date: January 2024 38 + KernelVersion: 6.7 39 + Contact: qat-linux@intel.com 40 + Description: 41 + (RW) When read, reports the current assigned ring pairs for the 42 + queried SLA. 43 + When wrote to, configures the ring pairs associated to a new SLA. 44 + 45 + The value is a 64-bit bit mask and is written/displayed in hex. 46 + Each bit of this mask represents a single ring pair i.e., 47 + bit 1 == ring pair id 0; bit 3 == ring pair id 2. 48 + 49 + Selected ring pairs must to be assigned to a single service, 50 + i.e. the one provided with the srv attribute. The service 51 + assigned to a certain ring pair can be checked by querying 52 + the attribute qat/rp2srv. 53 + 54 + The maximum number of ring pairs is 4 per SLA. 55 + 56 + Applicability in sla_op: 57 + 58 + * WRITE: add operation 59 + * READ: get operation 60 + 61 + Example usage:: 62 + 63 + ## Read 64 + # echo 4 > /sys/bus/pci/devices/<BDF>/qat_rl/id 65 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/rp 66 + 0x5 67 + 68 + ## Write 69 + # echo 0x5 > /sys/bus/pci/devices/<BDF>/qat_rl/rp 70 + 71 + This attribute is only available for qat_4xxx devices. 72 + 73 + What: /sys/bus/pci/devices/<BDF>/qat_rl/id 74 + Date: January 2024 75 + KernelVersion: 6.7 76 + Contact: qat-linux@intel.com 77 + Description: 78 + (RW) If written to, the value is used to retrieve a particular 79 + SLA and operate on it. 80 + This is valid only for the following operations: update, rm, 81 + and get. 82 + A read of this attribute is only guaranteed to have correct data 83 + after creation of an SLA. 84 + 85 + Applicability in sla_op: 86 + 87 + * WRITE: rm and update operations 88 + * READ: add and get operations 89 + 90 + Example usage:: 91 + 92 + ## Read 93 + ## Set attributes e.g. cir, pir, srv, etc 94 + # echo "add" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 95 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/id 96 + 4 97 + 98 + ## Write 99 + # echo 7 > /sys/bus/pci/devices/<BDF>/qat_rl/id 100 + # echo "get" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 101 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/rp 102 + 0x5 ## ring pair ID 0 and ring pair ID 2 103 + 104 + This attribute is only available for qat_4xxx devices. 105 + 106 + What: /sys/bus/pci/devices/<BDF>/qat_rl/cir 107 + Date: January 2024 108 + KernelVersion: 6.7 109 + Contact: qat-linux@intel.com 110 + Description: 111 + (RW) Committed information rate (CIR). Rate guaranteed to be 112 + achieved by a particular SLA. The value is expressed in 113 + permille scale, i.e. 1000 refers to the maximum device 114 + throughput for a selected service. 115 + 116 + After sending a "get" to sla_op, this will be populated with the 117 + CIR for that queried SLA. 118 + Write to this file before sending an "add/update" sla_op, to set 119 + the SLA to the specified value. 120 + 121 + Applicability in sla_op: 122 + 123 + * WRITE: add and update operations 124 + * READ: get operation 125 + 126 + Example usage:: 127 + 128 + ## Write 129 + # echo 500 > /sys/bus/pci/devices/<BDF>/qat_rl/cir 130 + # echo "add" /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 131 + 132 + ## Read 133 + # echo 4 > /sys/bus/pci/devices/<BDF>/qat_rl/id 134 + # echo "get" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 135 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/cir 136 + 500 137 + 138 + This attribute is only available for qat_4xxx devices. 139 + 140 + What: /sys/bus/pci/devices/<BDF>/qat_rl/pir 141 + Date: January 2024 142 + KernelVersion: 6.7 143 + Contact: qat-linux@intel.com 144 + Description: 145 + (RW) Peak information rate (PIR). The maximum rate that can be 146 + achieved by that particular SLA. An SLA can reach a value 147 + between CIR and PIR when the device is not fully utilized by 148 + requests from other users (assigned to different SLAs). 149 + 150 + After sending a "get" to sla_op, this will be populated with the 151 + PIR for that queried SLA. 152 + Write to this file before sending an "add/update" sla_op, to set 153 + the SLA to the specified value. 154 + 155 + Applicability in sla_op: 156 + 157 + * WRITE: add and update operations 158 + * READ: get operation 159 + 160 + Example usage:: 161 + 162 + ## Write 163 + # echo 750 > /sys/bus/pci/devices/<BDF>/qat_rl/pir 164 + # echo "add" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 165 + 166 + ## Read 167 + # echo 4 > /sys/bus/pci/devices/<BDF>/qat_rl/id 168 + # echo "get" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 169 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/pir 170 + 750 171 + 172 + This attribute is only available for qat_4xxx devices. 173 + 174 + What: /sys/bus/pci/devices/<BDF>/qat_rl/srv 175 + Date: January 2024 176 + KernelVersion: 6.7 177 + Contact: qat-linux@intel.com 178 + Description: 179 + (RW) Service (SRV). Represents the service (sym, asym, dc) 180 + associated to an SLA. 181 + Can be written to or queried to set/show the SRV type for an SLA. 182 + The SRV attribute is used to specify the SRV type before adding 183 + an SLA. After an SLA is configured, reports the service 184 + associated to that SLA. 185 + 186 + Applicability in sla_op: 187 + 188 + * WRITE: add and update operations 189 + * READ: get operation 190 + 191 + Example usage:: 192 + 193 + ## Write 194 + # echo "dc" > /sys/bus/pci/devices/<BDF>/qat_rl/srv 195 + # echo "add" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 196 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/id 197 + 4 198 + 199 + ## Read 200 + # echo 4 > /sys/bus/pci/devices/<BDF>/qat_rl/id 201 + # echo "get" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 202 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/srv 203 + dc 204 + 205 + This attribute is only available for qat_4xxx devices. 206 + 207 + What: /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem 208 + Date: January 2024 209 + KernelVersion: 6.7 210 + Contact: qat-linux@intel.com 211 + Description: 212 + (RW) This file will return the remaining capability for a 213 + particular service/sla. This is the remaining value that a new 214 + SLA can be set to or a current SLA can be increased with. 215 + 216 + Example usage:: 217 + 218 + # echo "asym" > /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem 219 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem 220 + 250 221 + # echo 250 > /sys/bus/pci/devices/<BDF>/qat_rl/cir 222 + # echo "add" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op 223 + # cat /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem 224 + 0 225 + 226 + This attribute is only available for qat_4xxx devices.
+1
drivers/crypto/intel/qat/qat_common/Makefile
··· 30 30 qat_algs_send.o \ 31 31 adf_rl.o \ 32 32 adf_rl_admin.o \ 33 + adf_sysfs_rl.o \ 33 34 qat_uclo.o \ 34 35 qat_hal.o \ 35 36 qat_bl.o
+10
drivers/crypto/intel/qat/qat_common/adf_rl.c
··· 16 16 #include "adf_common_drv.h" 17 17 #include "adf_rl_admin.h" 18 18 #include "adf_rl.h" 19 + #include "adf_sysfs_rl.h" 19 20 20 21 #define RL_TOKEN_GRANULARITY_PCIEIN_BUCKET 0U 21 22 #define RL_TOKEN_GRANULARITY_PCIEOUT_BUCKET 0U ··· 1131 1130 goto ret_sla_rm; 1132 1131 } 1133 1132 1133 + ret = adf_sysfs_rl_add(accel_dev); 1134 + if (ret) { 1135 + dev_err(&GET_DEV(accel_dev), "failed to add sysfs interface\n"); 1136 + goto ret_sysfs_rm; 1137 + } 1138 + 1134 1139 return 0; 1135 1140 1141 + ret_sysfs_rm: 1142 + adf_sysfs_rl_rm(accel_dev); 1136 1143 ret_sla_rm: 1137 1144 adf_rl_remove_sla_all(accel_dev, true); 1138 1145 ret_free: ··· 1155 1146 if (!accel_dev->rate_limiting) 1156 1147 return; 1157 1148 1149 + adf_sysfs_rl_rm(accel_dev); 1158 1150 adf_rl_remove_sla_all(accel_dev, true); 1159 1151 } 1160 1152
+7
drivers/crypto/intel/qat/qat_common/adf_rl.h
··· 75 75 u8 cph_cnt; 76 76 }; 77 77 78 + struct adf_rl_interface_data { 79 + struct adf_rl_sla_input_data input; 80 + enum adf_base_services cap_rem_srv; 81 + struct rw_semaphore lock; 82 + }; 83 + 78 84 struct adf_rl_hw_data { 79 85 u32 scale_ref; 80 86 u32 scan_interval; ··· 119 113 bool rp_in_use[RL_RP_CNT_MAX]; 120 114 /* Mutex protecting writing to SLAs lists */ 121 115 struct mutex rl_lock; 116 + struct adf_rl_interface_data user_input; 122 117 }; 123 118 124 119 /**
+451
drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* Copyright(c) 2023 Intel Corporation */ 3 + 4 + #define dev_fmt(fmt) "RateLimiting: " fmt 5 + 6 + #include <linux/dev_printk.h> 7 + #include <linux/pci.h> 8 + #include <linux/sysfs.h> 9 + #include <linux/types.h> 10 + 11 + #include "adf_common_drv.h" 12 + #include "adf_rl.h" 13 + #include "adf_sysfs_rl.h" 14 + 15 + #define GET_RL_STRUCT(accel_dev) ((accel_dev)->rate_limiting->user_input) 16 + 17 + enum rl_ops { 18 + ADD, 19 + UPDATE, 20 + RM, 21 + RM_ALL, 22 + GET, 23 + }; 24 + 25 + enum rl_params { 26 + RP_MASK, 27 + ID, 28 + CIR, 29 + PIR, 30 + SRV, 31 + CAP_REM_SRV, 32 + }; 33 + 34 + static const char *const rl_services[] = { 35 + [ADF_SVC_ASYM] = "asym", 36 + [ADF_SVC_SYM] = "sym", 37 + [ADF_SVC_DC] = "dc", 38 + }; 39 + 40 + static const char *const rl_operations[] = { 41 + [ADD] = "add", 42 + [UPDATE] = "update", 43 + [RM] = "rm", 44 + [RM_ALL] = "rm_all", 45 + [GET] = "get", 46 + }; 47 + 48 + static int set_param_u(struct device *dev, enum rl_params param, u64 set) 49 + { 50 + struct adf_rl_interface_data *data; 51 + struct adf_accel_dev *accel_dev; 52 + int ret = 0; 53 + 54 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 55 + if (!accel_dev) 56 + return -EINVAL; 57 + 58 + data = &GET_RL_STRUCT(accel_dev); 59 + 60 + down_write(&data->lock); 61 + switch (param) { 62 + case RP_MASK: 63 + data->input.rp_mask = set; 64 + break; 65 + case CIR: 66 + data->input.cir = set; 67 + break; 68 + case PIR: 69 + data->input.pir = set; 70 + break; 71 + case SRV: 72 + data->input.srv = set; 73 + break; 74 + case CAP_REM_SRV: 75 + data->cap_rem_srv = set; 76 + break; 77 + default: 78 + ret = -EINVAL; 79 + break; 80 + } 81 + up_write(&data->lock); 82 + 83 + return ret; 84 + } 85 + 86 + static int set_param_s(struct device *dev, enum rl_params param, int set) 87 + { 88 + struct adf_rl_interface_data *data; 89 + struct adf_accel_dev *accel_dev; 90 + 91 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 92 + if (!accel_dev || param != ID) 93 + return -EINVAL; 94 + 95 + data = &GET_RL_STRUCT(accel_dev); 96 + 97 + down_write(&data->lock); 98 + data->input.sla_id = set; 99 + up_write(&data->lock); 100 + 101 + return 0; 102 + } 103 + 104 + static int get_param_u(struct device *dev, enum rl_params param, u64 *get) 105 + { 106 + struct adf_rl_interface_data *data; 107 + struct adf_accel_dev *accel_dev; 108 + int ret = 0; 109 + 110 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 111 + if (!accel_dev) 112 + return -EINVAL; 113 + 114 + data = &GET_RL_STRUCT(accel_dev); 115 + 116 + down_read(&data->lock); 117 + switch (param) { 118 + case RP_MASK: 119 + *get = data->input.rp_mask; 120 + break; 121 + case CIR: 122 + *get = data->input.cir; 123 + break; 124 + case PIR: 125 + *get = data->input.pir; 126 + break; 127 + case SRV: 128 + *get = data->input.srv; 129 + break; 130 + default: 131 + ret = -EINVAL; 132 + } 133 + up_read(&data->lock); 134 + 135 + return ret; 136 + } 137 + 138 + static int get_param_s(struct device *dev, enum rl_params param) 139 + { 140 + struct adf_rl_interface_data *data; 141 + struct adf_accel_dev *accel_dev; 142 + int ret = 0; 143 + 144 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 145 + if (!accel_dev) 146 + return -EINVAL; 147 + 148 + data = &GET_RL_STRUCT(accel_dev); 149 + 150 + down_read(&data->lock); 151 + if (param == ID) 152 + ret = data->input.sla_id; 153 + up_read(&data->lock); 154 + 155 + return ret; 156 + } 157 + 158 + static ssize_t rp_show(struct device *dev, struct device_attribute *attr, 159 + char *buf) 160 + { 161 + int ret; 162 + u64 get; 163 + 164 + ret = get_param_u(dev, RP_MASK, &get); 165 + if (ret) 166 + return ret; 167 + 168 + return sysfs_emit(buf, "%#llx\n", get); 169 + } 170 + 171 + static ssize_t rp_store(struct device *dev, struct device_attribute *attr, 172 + const char *buf, size_t count) 173 + { 174 + int err; 175 + u64 val; 176 + 177 + err = kstrtou64(buf, 16, &val); 178 + if (err) 179 + return err; 180 + 181 + err = set_param_u(dev, RP_MASK, val); 182 + if (err) 183 + return err; 184 + 185 + return count; 186 + } 187 + static DEVICE_ATTR_RW(rp); 188 + 189 + static ssize_t id_show(struct device *dev, struct device_attribute *attr, 190 + char *buf) 191 + { 192 + return sysfs_emit(buf, "%d\n", get_param_s(dev, ID)); 193 + } 194 + 195 + static ssize_t id_store(struct device *dev, struct device_attribute *attr, 196 + const char *buf, size_t count) 197 + { 198 + int err; 199 + int val; 200 + 201 + err = kstrtoint(buf, 10, &val); 202 + if (err) 203 + return err; 204 + 205 + err = set_param_s(dev, ID, val); 206 + if (err) 207 + return err; 208 + 209 + return count; 210 + } 211 + static DEVICE_ATTR_RW(id); 212 + 213 + static ssize_t cir_show(struct device *dev, struct device_attribute *attr, 214 + char *buf) 215 + { 216 + int ret; 217 + u64 get; 218 + 219 + ret = get_param_u(dev, CIR, &get); 220 + if (ret) 221 + return ret; 222 + 223 + return sysfs_emit(buf, "%llu\n", get); 224 + } 225 + 226 + static ssize_t cir_store(struct device *dev, struct device_attribute *attr, 227 + const char *buf, size_t count) 228 + { 229 + unsigned int val; 230 + int err; 231 + 232 + err = kstrtouint(buf, 10, &val); 233 + if (err) 234 + return err; 235 + 236 + err = set_param_u(dev, CIR, val); 237 + if (err) 238 + return err; 239 + 240 + return count; 241 + } 242 + static DEVICE_ATTR_RW(cir); 243 + 244 + static ssize_t pir_show(struct device *dev, struct device_attribute *attr, 245 + char *buf) 246 + { 247 + int ret; 248 + u64 get; 249 + 250 + ret = get_param_u(dev, PIR, &get); 251 + if (ret) 252 + return ret; 253 + 254 + return sysfs_emit(buf, "%llu\n", get); 255 + } 256 + 257 + static ssize_t pir_store(struct device *dev, struct device_attribute *attr, 258 + const char *buf, size_t count) 259 + { 260 + unsigned int val; 261 + int err; 262 + 263 + err = kstrtouint(buf, 10, &val); 264 + if (err) 265 + return err; 266 + 267 + err = set_param_u(dev, PIR, val); 268 + if (err) 269 + return err; 270 + 271 + return count; 272 + } 273 + static DEVICE_ATTR_RW(pir); 274 + 275 + static ssize_t srv_show(struct device *dev, struct device_attribute *attr, 276 + char *buf) 277 + { 278 + int ret; 279 + u64 get; 280 + 281 + ret = get_param_u(dev, SRV, &get); 282 + if (ret) 283 + return ret; 284 + 285 + if (get == ADF_SVC_NONE) 286 + return -EINVAL; 287 + 288 + return sysfs_emit(buf, "%s\n", rl_services[get]); 289 + } 290 + 291 + static ssize_t srv_store(struct device *dev, struct device_attribute *attr, 292 + const char *buf, size_t count) 293 + { 294 + unsigned int val; 295 + int ret; 296 + 297 + ret = sysfs_match_string(rl_services, buf); 298 + if (ret < 0) 299 + return ret; 300 + 301 + val = ret; 302 + ret = set_param_u(dev, SRV, val); 303 + if (ret) 304 + return ret; 305 + 306 + return count; 307 + } 308 + static DEVICE_ATTR_RW(srv); 309 + 310 + static ssize_t cap_rem_show(struct device *dev, struct device_attribute *attr, 311 + char *buf) 312 + { 313 + struct adf_rl_interface_data *data; 314 + struct adf_accel_dev *accel_dev; 315 + int ret, rem_cap; 316 + 317 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 318 + if (!accel_dev) 319 + return -EINVAL; 320 + 321 + data = &GET_RL_STRUCT(accel_dev); 322 + 323 + down_read(&data->lock); 324 + rem_cap = adf_rl_get_capability_remaining(accel_dev, data->cap_rem_srv, 325 + RL_SLA_EMPTY_ID); 326 + up_read(&data->lock); 327 + if (rem_cap < 0) 328 + return rem_cap; 329 + 330 + ret = sysfs_emit(buf, "%u\n", rem_cap); 331 + 332 + return ret; 333 + } 334 + 335 + static ssize_t cap_rem_store(struct device *dev, struct device_attribute *attr, 336 + const char *buf, size_t count) 337 + { 338 + unsigned int val; 339 + int ret; 340 + 341 + ret = sysfs_match_string(rl_services, buf); 342 + if (ret < 0) 343 + return ret; 344 + 345 + val = ret; 346 + ret = set_param_u(dev, CAP_REM_SRV, val); 347 + if (ret) 348 + return ret; 349 + 350 + return count; 351 + } 352 + static DEVICE_ATTR_RW(cap_rem); 353 + 354 + static ssize_t sla_op_store(struct device *dev, struct device_attribute *attr, 355 + const char *buf, size_t count) 356 + { 357 + struct adf_rl_interface_data *data; 358 + struct adf_accel_dev *accel_dev; 359 + int ret; 360 + 361 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 362 + if (!accel_dev) 363 + return -EINVAL; 364 + 365 + data = &GET_RL_STRUCT(accel_dev); 366 + 367 + ret = sysfs_match_string(rl_operations, buf); 368 + if (ret < 0) 369 + return ret; 370 + 371 + down_write(&data->lock); 372 + switch (ret) { 373 + case ADD: 374 + data->input.parent_id = RL_PARENT_DEFAULT_ID; 375 + data->input.type = RL_LEAF; 376 + data->input.sla_id = 0; 377 + ret = adf_rl_add_sla(accel_dev, &data->input); 378 + if (ret) 379 + goto err_free_lock; 380 + break; 381 + case UPDATE: 382 + ret = adf_rl_update_sla(accel_dev, &data->input); 383 + if (ret) 384 + goto err_free_lock; 385 + break; 386 + case RM: 387 + ret = adf_rl_remove_sla(accel_dev, data->input.sla_id); 388 + if (ret) 389 + goto err_free_lock; 390 + break; 391 + case RM_ALL: 392 + adf_rl_remove_sla_all(accel_dev, false); 393 + break; 394 + case GET: 395 + ret = adf_rl_get_sla(accel_dev, &data->input); 396 + if (ret) 397 + goto err_free_lock; 398 + break; 399 + default: 400 + ret = -EINVAL; 401 + goto err_free_lock; 402 + } 403 + up_write(&data->lock); 404 + 405 + return count; 406 + 407 + err_free_lock: 408 + up_write(&data->lock); 409 + 410 + return ret; 411 + } 412 + static DEVICE_ATTR_WO(sla_op); 413 + 414 + static struct attribute *qat_rl_attrs[] = { 415 + &dev_attr_rp.attr, 416 + &dev_attr_id.attr, 417 + &dev_attr_cir.attr, 418 + &dev_attr_pir.attr, 419 + &dev_attr_srv.attr, 420 + &dev_attr_cap_rem.attr, 421 + &dev_attr_sla_op.attr, 422 + NULL, 423 + }; 424 + 425 + static struct attribute_group qat_rl_group = { 426 + .attrs = qat_rl_attrs, 427 + .name = "qat_rl", 428 + }; 429 + 430 + int adf_sysfs_rl_add(struct adf_accel_dev *accel_dev) 431 + { 432 + struct adf_rl_interface_data *data; 433 + int ret; 434 + 435 + data = &GET_RL_STRUCT(accel_dev); 436 + 437 + ret = device_add_group(&GET_DEV(accel_dev), &qat_rl_group); 438 + if (ret) 439 + dev_err(&GET_DEV(accel_dev), 440 + "Failed to create qat_rl attribute group\n"); 441 + 442 + data->cap_rem_srv = ADF_SVC_NONE; 443 + data->input.srv = ADF_SVC_NONE; 444 + 445 + return ret; 446 + } 447 + 448 + void adf_sysfs_rl_rm(struct adf_accel_dev *accel_dev) 449 + { 450 + device_remove_group(&GET_DEV(accel_dev), &qat_rl_group); 451 + }
+11
drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* Copyright(c) 2023 Intel Corporation */ 3 + #ifndef ADF_SYSFS_RL_H_ 4 + #define ADF_SYSFS_RL_H_ 5 + 6 + struct adf_accel_dev; 7 + 8 + int adf_sysfs_rl_add(struct adf_accel_dev *accel_dev); 9 + void adf_sysfs_rl_rm(struct adf_accel_dev *accel_dev); 10 + 11 + #endif /* ADF_SYSFS_RL_H_ */