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

crypto: qat - enable rate limiting feature for GEN6 devices

Add support for enabling rate limiting(RL) feature for QAT GEN6 by
initializing the rl_data member in adf_hw_device_data structure.

Implement init_num_svc_aes() for GEN6 which will populate the number of
AEs associated with the RL service type.

Implement adf_gen6_get_svc_slice_cnt() for GEN6 which will return
the slice count that can support the RL service type.

Co-developed-by: George Abraham P <george.abraham.p@intel.com>
Signed-off-by: George Abraham P <george.abraham.p@intel.com>
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
3471c899 45515eec

+98 -7
+7 -7
Documentation/ABI/testing/sysfs-driver-qat_rl
··· 31 31 * rm_all: Removes all the configured SLAs. 32 32 * Inputs: None 33 33 34 - This attribute is only available for qat_4xxx devices. 34 + This attribute is only available for qat_4xxx and qat_6xxx devices. 35 35 36 36 What: /sys/bus/pci/devices/<BDF>/qat_rl/rp 37 37 Date: January 2024 ··· 68 68 ## Write 69 69 # echo 0x5 > /sys/bus/pci/devices/<BDF>/qat_rl/rp 70 70 71 - This attribute is only available for qat_4xxx devices. 71 + This attribute is only available for qat_4xxx and qat_6xxx devices. 72 72 73 73 What: /sys/bus/pci/devices/<BDF>/qat_rl/id 74 74 Date: January 2024 ··· 101 101 # cat /sys/bus/pci/devices/<BDF>/qat_rl/rp 102 102 0x5 ## ring pair ID 0 and ring pair ID 2 103 103 104 - This attribute is only available for qat_4xxx devices. 104 + This attribute is only available for qat_4xxx and qat_6xxx devices. 105 105 106 106 What: /sys/bus/pci/devices/<BDF>/qat_rl/cir 107 107 Date: January 2024 ··· 135 135 # cat /sys/bus/pci/devices/<BDF>/qat_rl/cir 136 136 500 137 137 138 - This attribute is only available for qat_4xxx devices. 138 + This attribute is only available for qat_4xxx and qat_6xxx devices. 139 139 140 140 What: /sys/bus/pci/devices/<BDF>/qat_rl/pir 141 141 Date: January 2024 ··· 169 169 # cat /sys/bus/pci/devices/<BDF>/qat_rl/pir 170 170 750 171 171 172 - This attribute is only available for qat_4xxx devices. 172 + This attribute is only available for qat_4xxx and qat_6xxx devices. 173 173 174 174 What: /sys/bus/pci/devices/<BDF>/qat_rl/srv 175 175 Date: January 2024 ··· 202 202 # cat /sys/bus/pci/devices/<BDF>/qat_rl/srv 203 203 dc 204 204 205 - This attribute is only available for qat_4xxx devices. 205 + This attribute is only available for qat_4xxx and qat_6xxx devices. 206 206 207 207 What: /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem 208 208 Date: January 2024 ··· 223 223 # cat /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem 224 224 0 225 225 226 - This attribute is only available for qat_4xxx devices. 226 + This attribute is only available for qat_4xxx and qat_6xxx devices.
+71
drivers/crypto/intel/qat/qat_6xxx/adf_6xxx_hw_data.c
··· 524 524 return 0; 525 525 } 526 526 527 + static void init_num_svc_aes(struct adf_rl_hw_data *device_data) 528 + { 529 + enum adf_fw_objs obj_type, obj_iter; 530 + unsigned int svc, i, num_grp; 531 + u32 ae_mask; 532 + 533 + for (svc = 0; svc < SVC_BASE_COUNT; svc++) { 534 + switch (svc) { 535 + case SVC_SYM: 536 + case SVC_ASYM: 537 + obj_type = ADF_FW_CY_OBJ; 538 + break; 539 + case SVC_DC: 540 + case SVC_DECOMP: 541 + obj_type = ADF_FW_DC_OBJ; 542 + break; 543 + } 544 + 545 + num_grp = ARRAY_SIZE(adf_default_fw_config); 546 + for (i = 0; i < num_grp; i++) { 547 + obj_iter = adf_default_fw_config[i].obj; 548 + if (obj_iter == obj_type) { 549 + ae_mask = adf_default_fw_config[i].ae_mask; 550 + device_data->svc_ae_mask[svc] = hweight32(ae_mask); 551 + break; 552 + } 553 + } 554 + } 555 + } 556 + 557 + static u32 adf_gen6_get_svc_slice_cnt(struct adf_accel_dev *accel_dev, 558 + enum adf_base_services svc) 559 + { 560 + struct adf_rl_hw_data *device_data = &accel_dev->hw_device->rl_data; 561 + 562 + switch (svc) { 563 + case SVC_SYM: 564 + return device_data->slices.cph_cnt; 565 + case SVC_ASYM: 566 + return device_data->slices.pke_cnt; 567 + case SVC_DC: 568 + return device_data->slices.cpr_cnt + device_data->slices.dcpr_cnt; 569 + case SVC_DECOMP: 570 + return device_data->slices.dcpr_cnt; 571 + default: 572 + return 0; 573 + } 574 + } 575 + 527 576 static void set_vc_csr_for_bank(void __iomem *csr, u32 bank_number) 528 577 { 529 578 u32 value; ··· 854 805 return ret; 855 806 } 856 807 808 + static void adf_gen6_init_rl_data(struct adf_rl_hw_data *rl_data) 809 + { 810 + rl_data->pciout_tb_offset = ADF_GEN6_RL_TOKEN_PCIEOUT_BUCKET_OFFSET; 811 + rl_data->pciin_tb_offset = ADF_GEN6_RL_TOKEN_PCIEIN_BUCKET_OFFSET; 812 + rl_data->r2l_offset = ADF_GEN6_RL_R2L_OFFSET; 813 + rl_data->l2c_offset = ADF_GEN6_RL_L2C_OFFSET; 814 + rl_data->c2s_offset = ADF_GEN6_RL_C2S_OFFSET; 815 + rl_data->pcie_scale_div = ADF_6XXX_RL_PCIE_SCALE_FACTOR_DIV; 816 + rl_data->pcie_scale_mul = ADF_6XXX_RL_PCIE_SCALE_FACTOR_MUL; 817 + rl_data->max_tp[SVC_ASYM] = ADF_6XXX_RL_MAX_TP_ASYM; 818 + rl_data->max_tp[SVC_SYM] = ADF_6XXX_RL_MAX_TP_SYM; 819 + rl_data->max_tp[SVC_DC] = ADF_6XXX_RL_MAX_TP_DC; 820 + rl_data->max_tp[SVC_DECOMP] = ADF_6XXX_RL_MAX_TP_DECOMP; 821 + rl_data->scan_interval = ADF_6XXX_RL_SCANS_PER_SEC; 822 + rl_data->scale_ref = ADF_6XXX_RL_SLICE_REF; 823 + 824 + init_num_svc_aes(rl_data); 825 + } 826 + 857 827 void adf_init_hw_data_6xxx(struct adf_hw_device_data *hw_data) 858 828 { 859 829 hw_data->dev_class = &adf_6xxx_class; ··· 931 863 hw_data->enable_pm = enable_pm; 932 864 hw_data->services_supported = services_supported; 933 865 hw_data->num_rps = ADF_GEN6_ETR_MAX_BANKS; 866 + hw_data->clock_frequency = ADF_6XXX_AE_FREQ; 867 + hw_data->get_svc_slice_cnt = adf_gen6_get_svc_slice_cnt; 934 868 935 869 adf_gen6_init_hw_csr_ops(&hw_data->csr_ops); 936 870 adf_gen6_init_pf_pfvf_ops(&hw_data->pfvf_ops); ··· 940 870 adf_gen6_init_vf_mig_ops(&hw_data->vfmig_ops); 941 871 adf_gen6_init_ras_ops(&hw_data->ras_ops); 942 872 adf_gen6_init_tl_data(&hw_data->tl_data); 873 + adf_gen6_init_rl_data(&hw_data->rl_data); 943 874 } 944 875 945 876 void adf_clean_hw_data_6xxx(struct adf_hw_device_data *hw_data)
+20
drivers/crypto/intel/qat/qat_6xxx/adf_6xxx_hw_data.h
··· 122 122 /* Number of heartbeat counter pairs */ 123 123 #define ADF_NUM_HB_CNT_PER_AE ADF_NUM_THREADS_PER_AE 124 124 125 + /* Rate Limiting */ 126 + #define ADF_GEN6_RL_R2L_OFFSET 0x508000 127 + #define ADF_GEN6_RL_L2C_OFFSET 0x509000 128 + #define ADF_GEN6_RL_C2S_OFFSET 0x508818 129 + #define ADF_GEN6_RL_TOKEN_PCIEIN_BUCKET_OFFSET 0x508800 130 + #define ADF_GEN6_RL_TOKEN_PCIEOUT_BUCKET_OFFSET 0x508804 131 + 125 132 /* Physical function fuses */ 126 133 #define ADF_6XXX_ACCELENGINES_MASK GENMASK(8, 0) 127 134 #define ADF_6XXX_ADMIN_AE_MASK GENMASK(8, 8) ··· 139 132 #define ADF_6XXX_CY_OBJ "qat_6xxx_cy.bin" 140 133 #define ADF_6XXX_DC_OBJ "qat_6xxx_dc.bin" 141 134 #define ADF_6XXX_ADMIN_OBJ "qat_6xxx_admin.bin" 135 + 136 + /* RL constants */ 137 + #define ADF_6XXX_RL_PCIE_SCALE_FACTOR_DIV 100 138 + #define ADF_6XXX_RL_PCIE_SCALE_FACTOR_MUL 102 139 + #define ADF_6XXX_RL_SCANS_PER_SEC 954 140 + #define ADF_6XXX_RL_MAX_TP_ASYM 173750UL 141 + #define ADF_6XXX_RL_MAX_TP_SYM 95000UL 142 + #define ADF_6XXX_RL_MAX_TP_DC 40000UL 143 + #define ADF_6XXX_RL_MAX_TP_DECOMP 40000UL 144 + #define ADF_6XXX_RL_SLICE_REF 1000UL 145 + 146 + /* Clock frequency */ 147 + #define ADF_6XXX_AE_FREQ (1000 * HZ_PER_MHZ) 142 148 143 149 enum icp_qat_gen6_slice_mask { 144 150 ICP_ACCEL_GEN6_MASK_UCS_SLICE = BIT(0),