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 - relocate service related functions

Rename (1) is_service_enabled() to adf_is_service_enabled(), and
(2) srv_to_cfg_svc_type() to adf_srv_to_cfg_svc_type(), and move them to
adf_cfg_services.c which is the appropriate place for configuration-related
service logic. This improves code organization and modularity by grouping
related service configuration logic in a single location.

Signed-off-by: Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Suman Kumar Chakraborty and committed by
Herbert Xu
fdf31c75 d8d7e283

+38 -36
+32
drivers/crypto/intel/qat/qat_common/adf_cfg_services.c
··· 7 7 #include <linux/pci.h> 8 8 #include <linux/string.h> 9 9 #include "adf_cfg.h" 10 + #include "adf_cfg_common.h" 10 11 #include "adf_cfg_services.h" 11 12 #include "adf_cfg_strings.h" 12 13 ··· 179 178 return -EINVAL; 180 179 } 181 180 EXPORT_SYMBOL_GPL(adf_get_service_enabled); 181 + 182 + enum adf_cfg_service_type adf_srv_to_cfg_svc_type(enum adf_base_services svc) 183 + { 184 + switch (svc) { 185 + case SVC_ASYM: 186 + return ASYM; 187 + case SVC_SYM: 188 + return SYM; 189 + case SVC_DC: 190 + return COMP; 191 + case SVC_DECOMP: 192 + return DECOMP; 193 + default: 194 + return UNUSED; 195 + } 196 + } 197 + 198 + bool adf_is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services svc) 199 + { 200 + enum adf_cfg_service_type arb_srv = adf_srv_to_cfg_svc_type(svc); 201 + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); 202 + u8 rps_per_bundle = hw_data->num_banks_per_vf; 203 + int i; 204 + 205 + for (i = 0; i < rps_per_bundle; i++) { 206 + if (GET_SRV_TYPE(accel_dev, i) == arb_srv) 207 + return true; 208 + } 209 + 210 + return false; 211 + }
+2
drivers/crypto/intel/qat/qat_common/adf_cfg_services.h
··· 38 38 size_t in_len, char *out, size_t out_len); 39 39 int adf_get_service_enabled(struct adf_accel_dev *accel_dev); 40 40 int adf_get_service_mask(struct adf_accel_dev *accel_dev, unsigned long *mask); 41 + enum adf_cfg_service_type adf_srv_to_cfg_svc_type(enum adf_base_services svc); 42 + bool adf_is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services svc); 41 43 42 44 #endif
+3 -34
drivers/crypto/intel/qat/qat_common/adf_rl.c
··· 169 169 return NULL; 170 170 } 171 171 172 - static enum adf_cfg_service_type srv_to_cfg_svc_type(enum adf_base_services rl_srv) 173 - { 174 - switch (rl_srv) { 175 - case SVC_ASYM: 176 - return ASYM; 177 - case SVC_SYM: 178 - return SYM; 179 - case SVC_DC: 180 - return COMP; 181 - case SVC_DECOMP: 182 - return DECOMP; 183 - default: 184 - return UNUSED; 185 - } 186 - } 187 - 188 172 /** 189 173 * adf_rl_get_sla_arr_of_type() - Returns a pointer to SLA type specific array 190 174 * @rl_data: pointer to ratelimiting data ··· 196 212 } 197 213 } 198 214 199 - bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv) 200 - { 201 - enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(rl_srv); 202 - struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); 203 - u8 rps_per_bundle = hw_data->num_banks_per_vf; 204 - int i; 205 - 206 - for (i = 0; i < rps_per_bundle; i++) { 207 - if (GET_SRV_TYPE(accel_dev, i) == arb_srv) 208 - return true; 209 - } 210 - 211 - return false; 212 - } 213 - 214 215 /** 215 216 * prepare_rp_ids() - Creates an array of ring pair IDs from bitmask 216 217 * @accel_dev: pointer to acceleration device structure ··· 214 245 static int prepare_rp_ids(struct adf_accel_dev *accel_dev, struct rl_sla *sla, 215 246 const unsigned long rp_mask) 216 247 { 217 - enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(sla->srv); 248 + enum adf_cfg_service_type arb_srv = adf_srv_to_cfg_svc_type(sla->srv); 218 249 u16 rps_per_bundle = GET_HW_DATA(accel_dev)->num_banks_per_vf; 219 250 bool *rp_in_use = accel_dev->rate_limiting->rp_in_use; 220 251 size_t rp_cnt_max = ARRAY_SIZE(sla->ring_pairs_ids); ··· 630 661 } 631 662 *sla_out = sla; 632 663 633 - if (!is_service_enabled(accel_dev, sla_in->srv)) { 664 + if (!adf_is_service_enabled(accel_dev, sla_in->srv)) { 634 665 dev_notice(&GET_DEV(accel_dev), 635 666 "Provided service is not enabled\n"); 636 667 ret = -EINVAL; ··· 701 732 sla_in.parent_id = RL_PARENT_DEFAULT_ID; 702 733 703 734 for (i = 0; i < SVC_BASE_COUNT; i++) { 704 - if (!is_service_enabled(accel_dev, i)) 735 + if (!adf_is_service_enabled(accel_dev, i)) 705 736 continue; 706 737 707 738 sla_in.cir = device_data->scale_ref;
-1
drivers/crypto/intel/qat/qat_common/adf_rl.h
··· 170 170 enum adf_base_services svc_type); 171 171 u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val, 172 172 enum adf_base_services svc_type); 173 - bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv); 174 173 175 174 #endif /* ADF_RL_H_ */
+1 -1
drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c
··· 305 305 return ret; 306 306 307 307 val = ret; 308 - if (!is_service_enabled(accel_dev, val)) 308 + if (!adf_is_service_enabled(accel_dev, val)) 309 309 return -EINVAL; 310 310 311 311 ret = set_param_u(dev, SRV, val);