Commit d8d7e283 authored by Suman Kumar Chakraborty's avatar Suman Kumar Chakraborty Committed by Herbert Xu
Browse files

crypto: qat - consolidate service enums



The enums `adf_base_services` (used in rate limiting) and `adf_services`
define the same values, resulting in code duplication.

To improve consistency across the QAT driver: (1) rename `adf_services`
to `adf_base_services` in adf_cfg_services.c to better reflect its role
in defining core services (those with dedicated accelerators),
(2) introduce a new `adf_extended_services` enum starting from
`SVC_BASE_COUNT`, and move `SVC_DCC` into it, as it represents an
extended service (DC with chaining), and (3) remove the redundant
`adf_base_services` enum from the rate limiting implementation.

This does not introduce any functional change.

Signed-off-by: default avatarSuman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>
Reviewed-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent fa37d386
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -296,9 +296,9 @@ static void adf_init_rl_data(struct adf_rl_hw_data *rl_data)
	rl_data->pcie_scale_div = ADF_420XX_RL_PCIE_SCALE_FACTOR_DIV;
	rl_data->pcie_scale_mul = ADF_420XX_RL_PCIE_SCALE_FACTOR_MUL;
	rl_data->dcpr_correction = ADF_420XX_RL_DCPR_CORRECTION;
	rl_data->max_tp[ADF_SVC_ASYM] = ADF_420XX_RL_MAX_TP_ASYM;
	rl_data->max_tp[ADF_SVC_SYM] = ADF_420XX_RL_MAX_TP_SYM;
	rl_data->max_tp[ADF_SVC_DC] = ADF_420XX_RL_MAX_TP_DC;
	rl_data->max_tp[SVC_ASYM] = ADF_420XX_RL_MAX_TP_ASYM;
	rl_data->max_tp[SVC_SYM] = ADF_420XX_RL_MAX_TP_SYM;
	rl_data->max_tp[SVC_DC] = ADF_420XX_RL_MAX_TP_DC;
	rl_data->scan_interval = ADF_420XX_RL_SCANS_PER_SEC;
	rl_data->scale_ref = ADF_420XX_RL_SLICE_REF;
}
+3 −3
Original line number Diff line number Diff line
@@ -222,9 +222,9 @@ static void adf_init_rl_data(struct adf_rl_hw_data *rl_data)
	rl_data->pcie_scale_div = ADF_4XXX_RL_PCIE_SCALE_FACTOR_DIV;
	rl_data->pcie_scale_mul = ADF_4XXX_RL_PCIE_SCALE_FACTOR_MUL;
	rl_data->dcpr_correction = ADF_4XXX_RL_DCPR_CORRECTION;
	rl_data->max_tp[ADF_SVC_ASYM] = ADF_4XXX_RL_MAX_TP_ASYM;
	rl_data->max_tp[ADF_SVC_SYM] = ADF_4XXX_RL_MAX_TP_SYM;
	rl_data->max_tp[ADF_SVC_DC] = ADF_4XXX_RL_MAX_TP_DC;
	rl_data->max_tp[SVC_ASYM] = ADF_4XXX_RL_MAX_TP_ASYM;
	rl_data->max_tp[SVC_SYM] = ADF_4XXX_RL_MAX_TP_SYM;
	rl_data->max_tp[SVC_DC] = ADF_4XXX_RL_MAX_TP_DC;
	rl_data->scan_interval = ADF_4XXX_RL_SCANS_PER_SEC;
	rl_data->scale_ref = ADF_4XXX_RL_SLICE_REF;
}
+3 −3
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ static bool services_supported(unsigned long mask)
{
	int num_svc;

	if (mask >= BIT(SVC_BASE_COUNT))
	if (mask >= BIT(SVC_COUNT))
		return false;

	num_svc = hweight_long(mask);
@@ -138,7 +138,7 @@ static int get_service(unsigned long *mask)
	return -EINVAL;
}

static enum adf_cfg_service_type get_ring_type(enum adf_services service)
static enum adf_cfg_service_type get_ring_type(unsigned int service)
{
	switch (service) {
	case SVC_SYM:
@@ -155,7 +155,7 @@ static enum adf_cfg_service_type get_ring_type(enum adf_services service)
	}
}

static const unsigned long *get_thrd_mask(enum adf_services service)
static const unsigned long *get_thrd_mask(unsigned int service)
{
	switch (service) {
	case SVC_SYM:
+4 −4
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@ static const char *const adf_cfg_services[] = {

/*
 * Ensure that the size of the array matches the number of services,
 * SVC_BASE_COUNT, that is used to size the bitmap.
 * SVC_COUNT, that is used to size the bitmap.
 */
static_assert(ARRAY_SIZE(adf_cfg_services) == SVC_BASE_COUNT);
static_assert(ARRAY_SIZE(adf_cfg_services) == SVC_COUNT);

/*
 * Ensure that the maximum number of concurrent services that can be
@@ -35,7 +35,7 @@ static_assert(ARRAY_SIZE(adf_cfg_services) >= MAX_NUM_CONCURR_SVC);
 * Ensure that the number of services fit a single unsigned long, as each
 * service is represented by a bit in the mask.
 */
static_assert(BITS_PER_LONG >= SVC_BASE_COUNT);
static_assert(BITS_PER_LONG >= SVC_COUNT);

/*
 * Ensure that size of the concatenation of all service strings is smaller
@@ -90,7 +90,7 @@ static int adf_service_mask_to_string(unsigned long mask, char *buf, size_t len)
	if (len < ADF_CFG_MAX_VAL_LEN_IN_BYTES)
		return -ENOSPC;

	for_each_set_bit(bit, &mask, SVC_BASE_COUNT) {
	for_each_set_bit(bit, &mask, SVC_COUNT) {
		if (offset)
			offset += scnprintf(buf + offset, len - offset,
					    ADF_SERVICES_DELIMITER);
+7 −3
Original line number Diff line number Diff line
@@ -7,17 +7,21 @@

struct adf_accel_dev;

enum adf_services {
enum adf_base_services {
	SVC_ASYM = 0,
	SVC_SYM,
	SVC_DC,
	SVC_DECOMP,
	SVC_DCC,
	SVC_BASE_COUNT
};

enum adf_extended_services {
	SVC_DCC = SVC_BASE_COUNT,
	SVC_COUNT
};

enum adf_composed_services {
	SVC_SYM_ASYM = SVC_BASE_COUNT,
	SVC_SYM_ASYM = SVC_COUNT,
	SVC_SYM_DC,
	SVC_ASYM_DC,
};
Loading