mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-13 07:08:21 -04:00
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>
This commit is contained in:
committed by
Herbert Xu
parent
d8d7e283e0
commit
fdf31c7509
@@ -7,6 +7,7 @@
|
||||
#include <linux/pci.h>
|
||||
#include <linux/string.h>
|
||||
#include "adf_cfg.h"
|
||||
#include "adf_cfg_common.h"
|
||||
#include "adf_cfg_services.h"
|
||||
#include "adf_cfg_strings.h"
|
||||
|
||||
@@ -178,3 +179,34 @@ int adf_get_service_enabled(struct adf_accel_dev *accel_dev)
|
||||
return -EINVAL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(adf_get_service_enabled);
|
||||
|
||||
enum adf_cfg_service_type adf_srv_to_cfg_svc_type(enum adf_base_services svc)
|
||||
{
|
||||
switch (svc) {
|
||||
case SVC_ASYM:
|
||||
return ASYM;
|
||||
case SVC_SYM:
|
||||
return SYM;
|
||||
case SVC_DC:
|
||||
return COMP;
|
||||
case SVC_DECOMP:
|
||||
return DECOMP;
|
||||
default:
|
||||
return UNUSED;
|
||||
}
|
||||
}
|
||||
|
||||
bool adf_is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services svc)
|
||||
{
|
||||
enum adf_cfg_service_type arb_srv = adf_srv_to_cfg_svc_type(svc);
|
||||
struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev);
|
||||
u8 rps_per_bundle = hw_data->num_banks_per_vf;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < rps_per_bundle; i++) {
|
||||
if (GET_SRV_TYPE(accel_dev, i) == arb_srv)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,5 +38,7 @@ int adf_parse_service_string(struct adf_accel_dev *accel_dev, const char *in,
|
||||
size_t in_len, char *out, size_t out_len);
|
||||
int adf_get_service_enabled(struct adf_accel_dev *accel_dev);
|
||||
int adf_get_service_mask(struct adf_accel_dev *accel_dev, unsigned long *mask);
|
||||
enum adf_cfg_service_type adf_srv_to_cfg_svc_type(enum adf_base_services svc);
|
||||
bool adf_is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services svc);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -169,22 +169,6 @@ static struct rl_sla *find_parent(struct adf_rl *rl_data,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static enum adf_cfg_service_type srv_to_cfg_svc_type(enum adf_base_services rl_srv)
|
||||
{
|
||||
switch (rl_srv) {
|
||||
case SVC_ASYM:
|
||||
return ASYM;
|
||||
case SVC_SYM:
|
||||
return SYM;
|
||||
case SVC_DC:
|
||||
return COMP;
|
||||
case SVC_DECOMP:
|
||||
return DECOMP;
|
||||
default:
|
||||
return UNUSED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* adf_rl_get_sla_arr_of_type() - Returns a pointer to SLA type specific array
|
||||
* @rl_data: pointer to ratelimiting data
|
||||
@@ -212,21 +196,6 @@ u32 adf_rl_get_sla_arr_of_type(struct adf_rl *rl_data, enum rl_node_type type,
|
||||
}
|
||||
}
|
||||
|
||||
bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv)
|
||||
{
|
||||
enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(rl_srv);
|
||||
struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev);
|
||||
u8 rps_per_bundle = hw_data->num_banks_per_vf;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < rps_per_bundle; i++) {
|
||||
if (GET_SRV_TYPE(accel_dev, i) == arb_srv)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* prepare_rp_ids() - Creates an array of ring pair IDs from bitmask
|
||||
* @accel_dev: pointer to acceleration device structure
|
||||
@@ -245,7 +214,7 @@ bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services
|
||||
static int prepare_rp_ids(struct adf_accel_dev *accel_dev, struct rl_sla *sla,
|
||||
const unsigned long rp_mask)
|
||||
{
|
||||
enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(sla->srv);
|
||||
enum adf_cfg_service_type arb_srv = adf_srv_to_cfg_svc_type(sla->srv);
|
||||
u16 rps_per_bundle = GET_HW_DATA(accel_dev)->num_banks_per_vf;
|
||||
bool *rp_in_use = accel_dev->rate_limiting->rp_in_use;
|
||||
size_t rp_cnt_max = ARRAY_SIZE(sla->ring_pairs_ids);
|
||||
@@ -661,7 +630,7 @@ static int add_new_sla_entry(struct adf_accel_dev *accel_dev,
|
||||
}
|
||||
*sla_out = sla;
|
||||
|
||||
if (!is_service_enabled(accel_dev, sla_in->srv)) {
|
||||
if (!adf_is_service_enabled(accel_dev, sla_in->srv)) {
|
||||
dev_notice(&GET_DEV(accel_dev),
|
||||
"Provided service is not enabled\n");
|
||||
ret = -EINVAL;
|
||||
@@ -732,7 +701,7 @@ static int initialize_default_nodes(struct adf_accel_dev *accel_dev)
|
||||
sla_in.parent_id = RL_PARENT_DEFAULT_ID;
|
||||
|
||||
for (i = 0; i < SVC_BASE_COUNT; i++) {
|
||||
if (!is_service_enabled(accel_dev, i))
|
||||
if (!adf_is_service_enabled(accel_dev, i))
|
||||
continue;
|
||||
|
||||
sla_in.cir = device_data->scale_ref;
|
||||
|
||||
@@ -170,6 +170,5 @@ u32 adf_rl_calculate_ae_cycles(struct adf_accel_dev *accel_dev, u32 sla_val,
|
||||
enum adf_base_services svc_type);
|
||||
u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val,
|
||||
enum adf_base_services svc_type);
|
||||
bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv);
|
||||
|
||||
#endif /* ADF_RL_H_ */
|
||||
|
||||
@@ -305,7 +305,7 @@ static ssize_t srv_store(struct device *dev, struct device_attribute *attr,
|
||||
return ret;
|
||||
|
||||
val = ret;
|
||||
if (!is_service_enabled(accel_dev, val))
|
||||
if (!adf_is_service_enabled(accel_dev, val))
|
||||
return -EINVAL;
|
||||
|
||||
ret = set_param_u(dev, SRV, val);
|
||||
|
||||
Reference in New Issue
Block a user