Skip to content

Commit a955215

Browse files
sumanku3herbertx
authored andcommitted
crypto: qat - add adf_rl_get_num_svc_aes() in rate limiting
Enhance the rate limiting (RL) infrastructure by adding adf_rl_get_num_svc_aes() which can be used to fetch the number of engines associated with the service type. Expand the structure adf_rl_hw_data with an array that contains the number of AEs per service. Implement adf_gen4_init_num_svc_aes() for QAT GEN4 devices to calculate the total number of acceleration engines dedicated to a specific service. Signed-off-by: Suman Kumar Chakraborty <[email protected]> Reviewed-by: Giovanni Cabiddu <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent fdf31c7 commit a955215

File tree

6 files changed

+40
-1
lines changed

6 files changed

+40
-1
lines changed

drivers/crypto/intel/qat/qat_420xx/adf_420xx_hw_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ static void adf_init_rl_data(struct adf_rl_hw_data *rl_data)
301301
rl_data->max_tp[SVC_DC] = ADF_420XX_RL_MAX_TP_DC;
302302
rl_data->scan_interval = ADF_420XX_RL_SCANS_PER_SEC;
303303
rl_data->scale_ref = ADF_420XX_RL_SLICE_REF;
304+
305+
adf_gen4_init_num_svc_aes(rl_data);
304306
}
305307

306308
static int get_rp_group(struct adf_accel_dev *accel_dev, u32 ae_mask)

drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ static void adf_init_rl_data(struct adf_rl_hw_data *rl_data)
227227
rl_data->max_tp[SVC_DC] = ADF_4XXX_RL_MAX_TP_DC;
228228
rl_data->scan_interval = ADF_4XXX_RL_SCANS_PER_SEC;
229229
rl_data->scale_ref = ADF_4XXX_RL_SLICE_REF;
230+
231+
adf_gen4_init_num_svc_aes(rl_data);
230232
}
231233

232234
static u32 uof_get_num_objs(struct adf_accel_dev *accel_dev)

drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,3 +558,25 @@ void adf_gen4_init_dc_ops(struct adf_dc_ops *dc_ops)
558558
dc_ops->build_decomp_block = adf_gen4_build_decomp_block;
559559
}
560560
EXPORT_SYMBOL_GPL(adf_gen4_init_dc_ops);
561+
562+
void adf_gen4_init_num_svc_aes(struct adf_rl_hw_data *device_data)
563+
{
564+
struct adf_hw_device_data *hw_data;
565+
unsigned int i;
566+
u32 ae_cnt;
567+
568+
hw_data = container_of(device_data, struct adf_hw_device_data, rl_data);
569+
ae_cnt = hweight32(hw_data->get_ae_mask(hw_data));
570+
if (!ae_cnt)
571+
return;
572+
573+
for (i = 0; i < SVC_BASE_COUNT; i++)
574+
device_data->svc_ae_mask[i] = ae_cnt - 1;
575+
576+
/*
577+
* The decompression service is not supported on QAT GEN4 devices.
578+
* Therefore, set svc_ae_mask to 0.
579+
*/
580+
device_data->svc_ae_mask[SVC_DECOMP] = 0;
581+
}
582+
EXPORT_SYMBOL_GPL(adf_gen4_init_num_svc_aes);

drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,6 @@ void adf_gen4_bank_drain_finish(struct adf_accel_dev *accel_dev,
175175
u32 bank_number);
176176
bool adf_gen4_services_supported(unsigned long service_mask);
177177
void adf_gen4_init_dc_ops(struct adf_dc_ops *dc_ops);
178+
void adf_gen4_init_num_svc_aes(struct adf_rl_hw_data *device_data);
178179

179180
#endif

drivers/crypto/intel/qat/qat_common/adf_rl.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,17 @@ u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val,
552552
return allocated_tokens;
553553
}
554554

555+
static u32 adf_rl_get_num_svc_aes(struct adf_accel_dev *accel_dev,
556+
enum adf_base_services svc)
557+
{
558+
struct adf_rl_hw_data *device_data = &accel_dev->hw_device->rl_data;
559+
560+
if (svc >= SVC_BASE_COUNT)
561+
return 0;
562+
563+
return device_data->svc_ae_mask[svc];
564+
}
565+
555566
u32 adf_rl_calculate_ae_cycles(struct adf_accel_dev *accel_dev, u32 sla_val,
556567
enum adf_base_services svc_type)
557568
{
@@ -563,7 +574,7 @@ u32 adf_rl_calculate_ae_cycles(struct adf_accel_dev *accel_dev, u32 sla_val,
563574
return 0;
564575

565576
avail_ae_cycles = hw_data->clock_frequency;
566-
avail_ae_cycles *= hw_data->get_num_aes(hw_data) - 1;
577+
avail_ae_cycles *= adf_rl_get_num_svc_aes(accel_dev, svc_type);
567578
do_div(avail_ae_cycles, device_data->scan_interval);
568579

569580
sla_val *= device_data->max_tp[svc_type];

drivers/crypto/intel/qat/qat_common/adf_rl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct adf_rl_hw_data {
8989
u32 pcie_scale_div;
9090
u32 dcpr_correction;
9191
u32 max_tp[RL_ROOT_MAX];
92+
u32 svc_ae_mask[SVC_BASE_COUNT];
9293
struct rl_slice_cnt slices;
9394
};
9495

0 commit comments

Comments
 (0)