crypto: qat - add rate limiting feature to qat_4xxx
Subsystems (2)
v2 cover crypto: qat - add rate limiting feature to qat_4xxx
This set enables hardware rate limiting capabilities on QAT 4xxx accelerators. Rate Limiting allows to control the rate of the requests that can be submitted to a ring pair (RP). This allows sharing a QAT device among multiple users while ensuring guaranteed throughput.
The driver provides a mechanism that allows users to set policies, through a sysfs interface, that are then programmed to the device. The device is then enforcing the policies.
The first six commits are refactoring and additions in preparation for
the feature.
Patch #6 introduces a mechanism for retrieving firmware feature
capabilities.
Patch #8 implements the core of the rate limiting feature by providing
mechanisms to set rate limiting policies (aka SLAs).
The final three commits add the required sysfs interface that allow
users to configure SLAs.
Changes since v1:
- Removed unnecessary check
- Simplified a few error paths
- Reduced a few local variables
- Fixed repeated error message
- Moved mutex lock above sla_id existence check.
- Added Reviewed-by tag from Tero Kristo received from an internal review of the set.
Ciunas Bennett (3):
crypto: qat - add rate limiting sysfs interface
crypto: qat - add rp2svc sysfs attribute
crypto: qat - add num_rps sysfs attribute
Damian Muszynski (4):
units: Add BYTES_PER_*BIT
crypto: qat - add bits.h to icp_qat_hw.h
crypto: qat - add retrieval of fw capabilities
crypto: qat - add rate limiting feature to qat_4xxx
Giovanni Cabiddu (4):
crypto: qat - refactor fw config related functions
crypto: qat - use masks for AE groups
crypto: qat - fix ring to service map for QAT GEN4
crypto: qat - move admin api
Documentation/ABI/testing/sysfs-driver-qat | 46 + Documentation/ABI/testing/sysfs-driver-qat_rl | 227 ++++ .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 190 ++- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.h | 13 +- .../intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../intel/qat/qat_c62x/adf_c62x_hw_data.c | 1 + drivers/crypto/intel/qat/qat_common/Makefile | 3 + .../intel/qat/qat_common/adf_accel_devices.h | 11 + .../crypto/intel/qat/qat_common/adf_admin.c | 71 + .../crypto/intel/qat/qat_common/adf_admin.h | 27 + .../crypto/intel/qat/qat_common/adf_clock.c | 1 + .../intel/qat/qat_common/adf_cnv_dbgfs.c | 1 + .../intel/qat/qat_common/adf_common_drv.h | 10 - .../intel/qat/qat_common/adf_fw_counters.c | 1 + .../intel/qat/qat_common/adf_gen4_hw_data.h | 7 + .../crypto/intel/qat/qat_common/adf_gen4_pm.c | 1 + .../qat/qat_common/adf_gen4_pm_debugfs.c | 1 + .../intel/qat/qat_common/adf_gen4_timer.c | 1 + .../intel/qat/qat_common/adf_heartbeat.c | 1 + .../qat/qat_common/adf_heartbeat_dbgfs.c | 1 + .../crypto/intel/qat/qat_common/adf_init.c | 13 + drivers/crypto/intel/qat/qat_common/adf_rl.c | 1169 +++++++++++++++++ drivers/crypto/intel/qat/qat_common/adf_rl.h | 176 +++ .../intel/qat/qat_common/adf_rl_admin.c | 97 ++ .../intel/qat/qat_common/adf_rl_admin.h | 18 + .../crypto/intel/qat/qat_common/adf_sysfs.c | 80 ++ .../intel/qat/qat_common/adf_sysfs_rl.c | 451 +++++++ .../intel/qat/qat_common/adf_sysfs_rl.h | 11 + .../qat/qat_common/icp_qat_fw_init_admin.h | 41 + .../crypto/intel/qat/qat_common/icp_qat_hw.h | 2 + .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 + include/linux/units.h | 4 + 32 files changed, 2605 insertions(+), 73 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-qat_rl create mode 100644 drivers/crypto/intel/qat/qat_common/adf_admin.h create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl.h create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl_admin.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl_admin.h create mode 100644 drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h
base-commit: 1bb03421eab67940b6509fe0869ff43df5fbe3e6
Signature · 1 line
2.34.1
PATCH v2 1/11 crypto: qat - refactor fw config related functions
From: Giovanni Cabiddu <[email protected]>
The logic that selects the correct adf_fw_config structure based on the configured service is replicated twice in the uof_get_name() and uof_get_ae_mask() functions. Refactor the code so that there is no replication.
This does not introduce any functional change.
--- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 69 ++++++++----------- 1 file changed, 28 insertions(+), 41 deletions(-)
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +28 -41
@@ -395,40 +395,42 @@ static u32 uof_get_num_objs(void)return ARRAY_SIZE (adf_fw_cy_config); } -static const char *uof_get_name (struct adf_accel_dev *accel_dev,u32 obj_num, -const char *const fw_objs[],int num_objs) +static const struct adf_fw_config *get_fw_config (struct adf_accel_dev *accel_dev) { -int id; -switch (get_service_enabled (accel_dev)) {case SVC_CY :case SVC_CY2 : - id = adf_fw_cy_config[obj_num].obj; -break ; +return adf_fw_cy_config;case SVC_DC : - id = adf_fw_dc_config[obj_num].obj; -break ; +return adf_fw_dc_config;case SVC_DCC : - id = adf_fw_dcc_config[obj_num].obj; -break ; +return adf_fw_dcc_config;case SVC_SYM : - id = adf_fw_sym_config[obj_num].obj; -break ; +return adf_fw_sym_config;case SVC_ASYM : - id = adf_fw_asym_config[obj_num].obj; -break ; +return adf_fw_asym_config;case SVC_ASYM_DC :case SVC_DC_ASYM : - id = adf_fw_asym_dc_config[obj_num].obj; -break ; +return adf_fw_asym_dc_config;case SVC_SYM_DC :case SVC_DC_SYM : - id = adf_fw_sym_dc_config[obj_num].obj; -break ; +return adf_fw_sym_dc_config;default : - id = -EINVAL ; -break ; +return NULL ; } +} + +static const char *uof_get_name (struct adf_accel_dev *accel_dev,u32 obj_num, +const char *const fw_objs[],int num_objs) +{ +const struct adf_fw_config *fw_config; +int id; + + fw_config =get_fw_config (accel_dev); +if (fw_config) + id = fw_config[obj_num].obj; +else + id = -EINVAL ;if (id <0 || id > num_objs)return NULL ;
@@ -452,28 +454,13 @@ static const char *uof_get_name_402xx(struct adf_accel_dev *accel_dev, u32 obj_nstatic u32 uof_get_ae_mask (struct adf_accel_dev *accel_dev,u32 obj_num) { -switch (get_service_enabled (accel_dev)) { -case SVC_CY : -return adf_fw_cy_config[obj_num].ae_mask; -case SVC_DC : -return adf_fw_dc_config[obj_num].ae_mask; -case SVC_DCC : -return adf_fw_dcc_config[obj_num].ae_mask; -case SVC_CY2 : -return adf_fw_cy_config[obj_num].ae_mask; -case SVC_SYM : -return adf_fw_sym_config[obj_num].ae_mask; -case SVC_ASYM : -return adf_fw_asym_config[obj_num].ae_mask; -case SVC_ASYM_DC : -case SVC_DC_ASYM : -return adf_fw_asym_dc_config[obj_num].ae_mask; -case SVC_SYM_DC : -case SVC_DC_SYM : -return adf_fw_sym_dc_config[obj_num].ae_mask; -default : +const struct adf_fw_config *fw_config; + + fw_config =get_fw_config (accel_dev); +if (!fw_config)return 0 ; - } + +return fw_config[obj_num].ae_mask; }static void adf_gen4_set_err_mask (struct adf_dev_err_mask *dev_err_mask)
Signature · 1 line
2.34.1
PATCH v2 2/11 crypto: qat - use masks for AE groups
In reply to Damian MuszynskiFrom: Giovanni Cabiddu <[email protected]>
The adf_fw_config structures hardcode a bit mask that represents the acceleration engines (AEs) where a certain firmware image will have to be loaded to. Remove the hardcoded masks and replace them with defines.
This does not introduce any functional change.
--- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-)
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +25 -21
@@ -15,6 +15,10 @@#include "adf_cfg_services.h" #include "icp_qat_hw.h" +#define ADF_AE_GROUP_0 GENMASK(3, 0) +#define ADF_AE_GROUP_1 GENMASK(7, 4) +#define ADF_AE_GROUP_2 BIT(8) +enum adf_fw_objs {ADF_FW_SYM_OBJ ,ADF_FW_ASYM_OBJ ,
@@ -42,45 +46,45 @@ struct adf_fw_config { };static const struct adf_fw_config adf_fw_cy_config[] = { - {0xF0 ,ADF_FW_SYM_OBJ }, - {0xF ,ADF_FW_ASYM_OBJ }, - {0x100 ,ADF_FW_ADMIN_OBJ }, + {ADF_AE_GROUP_1 ,ADF_FW_SYM_OBJ }, + {ADF_AE_GROUP_0 ,ADF_FW_ASYM_OBJ }, + {ADF_AE_GROUP_2 ,ADF_FW_ADMIN_OBJ }, };static const struct adf_fw_config adf_fw_dc_config[] = { - {0xF0 ,ADF_FW_DC_OBJ }, - {0xF ,ADF_FW_DC_OBJ }, - {0x100 ,ADF_FW_ADMIN_OBJ }, + {ADF_AE_GROUP_1 ,ADF_FW_DC_OBJ }, + {ADF_AE_GROUP_0 ,ADF_FW_DC_OBJ }, + {ADF_AE_GROUP_2 ,ADF_FW_ADMIN_OBJ }, };static const struct adf_fw_config adf_fw_sym_config[] = { - {0xF0 ,ADF_FW_SYM_OBJ }, - {0xF ,ADF_FW_SYM_OBJ }, - {0x100 ,ADF_FW_ADMIN_OBJ }, + {ADF_AE_GROUP_1 ,ADF_FW_SYM_OBJ }, + {ADF_AE_GROUP_0 ,ADF_FW_SYM_OBJ }, + {ADF_AE_GROUP_2 ,ADF_FW_ADMIN_OBJ }, };static const struct adf_fw_config adf_fw_asym_config[] = { - {0xF0 ,ADF_FW_ASYM_OBJ }, - {0xF ,ADF_FW_ASYM_OBJ }, - {0x100 ,ADF_FW_ADMIN_OBJ }, + {ADF_AE_GROUP_1 ,ADF_FW_ASYM_OBJ }, + {ADF_AE_GROUP_0 ,ADF_FW_ASYM_OBJ }, + {ADF_AE_GROUP_2 ,ADF_FW_ADMIN_OBJ }, };static const struct adf_fw_config adf_fw_asym_dc_config[] = { - {0xF0 ,ADF_FW_ASYM_OBJ }, - {0xF ,ADF_FW_DC_OBJ }, - {0x100 ,ADF_FW_ADMIN_OBJ }, + {ADF_AE_GROUP_1 ,ADF_FW_ASYM_OBJ }, + {ADF_AE_GROUP_0 ,ADF_FW_DC_OBJ }, + {ADF_AE_GROUP_2 ,ADF_FW_ADMIN_OBJ }, };static const struct adf_fw_config adf_fw_sym_dc_config[] = { - {0xF0 ,ADF_FW_SYM_OBJ }, - {0xF ,ADF_FW_DC_OBJ }, - {0x100 ,ADF_FW_ADMIN_OBJ }, + {ADF_AE_GROUP_1 ,ADF_FW_SYM_OBJ }, + {ADF_AE_GROUP_0 ,ADF_FW_DC_OBJ }, + {ADF_AE_GROUP_2 ,ADF_FW_ADMIN_OBJ }, };static const struct adf_fw_config adf_fw_dcc_config[] = { - {0xF0 ,ADF_FW_DC_OBJ }, - {0xF ,ADF_FW_SYM_OBJ }, - {0x100 ,ADF_FW_ADMIN_OBJ }, + {ADF_AE_GROUP_1 ,ADF_FW_DC_OBJ }, + {ADF_AE_GROUP_0 ,ADF_FW_SYM_OBJ }, + {ADF_AE_GROUP_2 ,ADF_FW_ADMIN_OBJ }, };static_assert (ARRAY_SIZE (adf_fw_cy_config) ==ARRAY_SIZE (adf_fw_dc_config));
Signature · 1 line
2.34.1
PATCH v2 3/11 crypto: qat - fix ring to service map for QAT GEN4
In reply to Damian MuszynskiFrom: Giovanni Cabiddu <[email protected]>
The 4xxx drivers hardcode the ring to service mapping. However, when additional configurations where added to the driver, the mappings were not updated. This implies that an incorrect mapping might be reported through pfvf for certain configurations.
Add an algorithm that computes the correct ring to service mapping based on the firmware loaded on the device.
--- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 54 +++++++++++++++++++ .../intel/qat/qat_common/adf_accel_devices.h | 1 + .../crypto/intel/qat/qat_common/adf_init.c | 3 ++ 3 files changed, 58 insertions(+)
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +54 -0
@@ -424,6 +424,59 @@ static const struct adf_fw_config *get_fw_config(struct adf_accel_dev *accel_dev } } +enum adf_rp_groups { +RP_GROUP_0 =0 , +RP_GROUP_1 , +RP_GROUP_COUNT +}; + +static u16 get_ring_to_svc_map (struct adf_accel_dev *accel_dev) +{ +enum adf_cfg_service_type rps[RP_GROUP_COUNT ]; +const struct adf_fw_config *fw_config; +u16 ring_to_svc_map; +int i, j; + + fw_config =get_fw_config (accel_dev); +if (!fw_config) +return 0 ; + +for (i =0 ; i <RP_GROUP_COUNT ; i++) { +switch (fw_config[i].ae_mask) { +case ADF_AE_GROUP_0 : + j =RP_GROUP_0 ; +break ; +case ADF_AE_GROUP_1 : + j =RP_GROUP_1 ; +break ; +default : +return 0 ; + } + +switch (fw_config[i].obj) { +case ADF_FW_SYM_OBJ : + rps[j] =SYM ; +break ; +case ADF_FW_ASYM_OBJ : + rps[j] =ASYM ; +break ; +case ADF_FW_DC_OBJ : + rps[j] =COMP ; +break ; +default : + rps[j] =0 ; +break ; + } + } + + ring_to_svc_map = rps[RP_GROUP_0 ] <<ADF_CFG_SERV_RING_PAIR_0_SHIFT | + rps[RP_GROUP_1 ] <<ADF_CFG_SERV_RING_PAIR_1_SHIFT | + rps[RP_GROUP_0 ] <<ADF_CFG_SERV_RING_PAIR_2_SHIFT | + rps[RP_GROUP_1 ] <<ADF_CFG_SERV_RING_PAIR_3_SHIFT ; + +return ring_to_svc_map; +} +static const char *uof_get_name (struct adf_accel_dev *accel_dev,u32 obj_num,const char *const fw_objs[],int num_objs) {
@@ -530,6 +583,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data, u32 dev_id) hw_data->uof_get_ae_mask = uof_get_ae_mask; hw_data->set_msix_rttable = set_msix_default_rttable; hw_data->set_ssm_wdtimer = adf_gen4_set_ssm_wdtimer; + hw_data->get_ring_to_svc_map = get_ring_to_svc_map; hw_data->disable_iov = adf_disable_sriov; hw_data->ring_pair_reset = adf_gen4_ring_pair_reset; hw_data->enable_pm = adf_gen4_enable_pm;
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +1 -0
@@ -212,6 +212,7 @@ struct adf_hw_device_data {void (*get_arb_info)(struct arb_info *arb_csrs_info);void (*get_admin_info)(struct admin_info *admin_csrs_info);enum dev_sku_info (*get_sku)(struct adf_hw_device_data *self); +u16 (*get_ring_to_svc_map)(struct adf_accel_dev *accel_dev);int (*alloc_irq)(struct adf_accel_dev *accel_dev);void (*free_irq)(struct adf_accel_dev *accel_dev);void (*enable_error_correction)(struct adf_accel_dev *accel_dev);
drivers/crypto/intel/qat/qat_common/adf_init.c +3 -0
@@ -97,6 +97,9 @@ static int adf_dev_init(struct adf_accel_dev *accel_dev)return -EFAULT ; } +if (hw_data->get_ring_to_svc_map) + hw_data->ring_to_svc_map = hw_data->get_ring_to_svc_map (accel_dev); +if (adf_ae_init (accel_dev)) {dev_err (&GET_DEV (accel_dev),"Failed to initialise Acceleration Engine\n" );
Signature · 1 line
2.34.1
PATCH v2 4/11 crypto: qat - move admin api
In reply to Damian MuszynskiFrom: Giovanni Cabiddu <[email protected]>
The admin API is growing and deserves its own include. Move it from adf_common_drv.h to adf_admin.h.
--- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 1 + .../intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../intel/qat/qat_c62x/adf_c62x_hw_data.c | 1 + .../crypto/intel/qat/qat_common/adf_admin.c | 1 + .../crypto/intel/qat/qat_common/adf_admin.h | 19 +++++++++++++++++++ .../crypto/intel/qat/qat_common/adf_clock.c | 1 + .../intel/qat/qat_common/adf_cnv_dbgfs.c | 1 + .../intel/qat/qat_common/adf_common_drv.h | 10 ---------- .../intel/qat/qat_common/adf_fw_counters.c | 1 + .../crypto/intel/qat/qat_common/adf_gen4_pm.c | 1 + .../qat/qat_common/adf_gen4_pm_debugfs.c | 1 + .../intel/qat/qat_common/adf_gen4_timer.c | 1 + .../intel/qat/qat_common/adf_heartbeat.c | 1 + .../qat/qat_common/adf_heartbeat_dbgfs.c | 1 + .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 + 15 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 drivers/crypto/intel/qat/qat_common/adf_admin.h
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +1 -0
@@ -2,6 +2,7 @@/* Copyright(c) 2020 - 2021 Intel Corporation */ #include <linux/iopoll.h> #include <adf_accel_devices.h> +#include <adf_admin.h> #include <adf_cfg.h> #include <adf_clock.h> #include <adf_common_drv.h>
drivers/crypto/intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> +#include <adf_admin.h> #include <adf_clock.h> #include <adf_common_drv.h> #include <adf_gen2_config.h>
drivers/crypto/intel/qat/qat_c62x/adf_c62x_hw_data.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> +#include <adf_admin.h> #include <adf_clock.h> #include <adf_common_drv.h> #include <adf_gen2_config.h>
drivers/crypto/intel/qat/qat_common/adf_admin.c +1 -0
@@ -7,6 +7,7 @@#include <linux/pci.h> #include <linux/dma-mapping.h> #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_cfg.h" #include "adf_heartbeat.h"
drivers/crypto/intel/qat/qat_common/adf_admin.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2023 Intel Corporation */ +#ifndef ADF_ADMIN +#define ADF_ADMIN + +struct adf_accel_dev ; + +int adf_init_admin_comms (struct adf_accel_dev *accel_dev); +void adf_exit_admin_comms (struct adf_accel_dev *accel_dev); +int adf_send_admin_init (struct adf_accel_dev *accel_dev); +int adf_get_ae_fw_counters (struct adf_accel_dev *accel_dev,u16 ae,u64 *reqs,u64 *resps); +int adf_init_admin_pm (struct adf_accel_dev *accel_dev,u32 idle_delay); +int adf_send_admin_tim_sync (struct adf_accel_dev *accel_dev,u32 cnt); +int adf_send_admin_hb_timer (struct adf_accel_dev *accel_dev,uint32_t ticks); +int adf_get_fw_timestamp (struct adf_accel_dev *accel_dev,u64 *timestamp); +int adf_get_pm_info (struct adf_accel_dev *accel_dev,dma_addr_t p_state_addr,size_t buff_size); +int adf_get_cnv_stats (struct adf_accel_dev *accel_dev,u16 ae,u16 *err_cnt,u16 *latest_err); + +#endif
drivers/crypto/intel/qat/qat_common/adf_clock.c +1 -0
@@ -10,6 +10,7 @@#include <linux/types.h> #include <linux/units.h> #include <asm/errno.h> +#include "adf_admin.h" #include "adf_accel_devices.h" #include "adf_clock.h" #include "adf_common_drv.h"
drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c +1 -0
@@ -6,6 +6,7 @@#include <linux/kernel.h> #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_cnv_dbgfs.h" #include "qat_compression.h"
drivers/crypto/intel/qat/qat_common/adf_common_drv.h +0 -10
@@ -87,16 +87,6 @@ void adf_reset_flr(struct adf_accel_dev *accel_dev);void adf_dev_restore (struct adf_accel_dev *accel_dev);int adf_init_aer (void );void adf_exit_aer (void ); -int adf_init_admin_comms (struct adf_accel_dev *accel_dev); -void adf_exit_admin_comms (struct adf_accel_dev *accel_dev); -int adf_send_admin_init (struct adf_accel_dev *accel_dev); -int adf_get_ae_fw_counters (struct adf_accel_dev *accel_dev,u16 ae,u64 *reqs,u64 *resps); -int adf_init_admin_pm (struct adf_accel_dev *accel_dev,u32 idle_delay); -int adf_send_admin_tim_sync (struct adf_accel_dev *accel_dev,u32 cnt); -int adf_send_admin_hb_timer (struct adf_accel_dev *accel_dev,uint32_t ticks); -int adf_get_fw_timestamp (struct adf_accel_dev *accel_dev,u64 *timestamp); -int adf_get_pm_info (struct adf_accel_dev *accel_dev,dma_addr_t p_state_addr,size_t buff_size); -int adf_get_cnv_stats (struct adf_accel_dev *accel_dev,u16 ae,u16 *err_cnt,u16 *latest_err);int adf_init_arb (struct adf_accel_dev *accel_dev);void adf_exit_arb (struct adf_accel_dev *accel_dev);void adf_update_ring_arb (struct adf_etr_ring_data *ring);
drivers/crypto/intel/qat/qat_common/adf_fw_counters.c +1 -0
@@ -9,6 +9,7 @@#include <linux/types.h> #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_fw_counters.h"
drivers/crypto/intel/qat/qat_common/adf_gen4_pm.c +1 -0
@@ -5,6 +5,7 @@#include <linux/kernel.h> #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_gen4_pm.h" #include "adf_cfg_strings.h"
drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c +1 -0
@@ -6,6 +6,7 @@#include <linux/stringify.h> #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_gen4_pm.h" #include "icp_qat_fw_init_admin.h"
drivers/crypto/intel/qat/qat_common/adf_gen4_timer.c +1 -0
@@ -9,6 +9,7 @@#include <linux/slab.h> #include <linux/workqueue.h> +#include "adf_admin.h" #include "adf_accel_devices.h" #include "adf_common_drv.h" #include "adf_gen4_timer.h"
drivers/crypto/intel/qat/qat_common/adf_heartbeat.c +1 -0
@@ -12,6 +12,7 @@#include <linux/types.h> #include <asm/errno.h> #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_cfg.h" #include "adf_cfg_strings.h" #include "adf_clock.h"
drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c +1 -0
@@ -8,6 +8,7 @@#include <linux/kernel.h> #include <linux/kstrtox.h> #include <linux/types.h> +#include "adf_admin.h" #include "adf_cfg.h" #include "adf_common_drv.h" #include "adf_heartbeat.h"
drivers/crypto/intel/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2014 - 2021 Intel Corporation */ #include <adf_accel_devices.h> +#include <adf_admin.h> #include <adf_common_drv.h> #include <adf_gen2_config.h> #include <adf_gen2_dc.h>
Signature · 1 line
2.34.1
PATCH v2 5/11 units: Add BYTES_PER_*BIT
In reply to Damian MuszynskiThere is going to be a new user of the BYTES_PER_[K/M/G]BIT definition besides possibly existing ones. Add them to the header.
--- include/linux/units.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/units.h +4 -0
@@ -31,6 +31,10 @@#define MICROWATT_PER_MILLIWATT 1000UL#define MICROWATT_PER_WATT 1000000UL +#define BYTES_PER_KBIT (KILO / BITS_PER_BYTE) +#define BYTES_PER_MBIT (MEGA / BITS_PER_BYTE) +#define BYTES_PER_GBIT (GIGA / BITS_PER_BYTE) +#define ABSOLUTE_ZERO_MILLICELSIUS -273150static inline long milli_kelvin_to_millicelsius (long t)
Signature · 1 line
2.34.1
PATCH v2 6/11 crypto: qat - add bits.h to icp_qat_hw.h
In reply to Damian MuszynskiSome enums use the macro BIT. Include bits.h as it is missing.
--- drivers/crypto/intel/qat/qat_common/icp_qat_hw.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/intel/qat/qat_common/icp_qat_hw.h +2 -0
@@ -3,6 +3,8 @@#ifndef _ICP_QAT_HW_H_#define _ICP_QAT_HW_H_ +#include <linux/bits.h> +enum icp_qat_hw_ae_id {ICP_QAT_HW_AE_0 =0 , ICP_QAT_HW_AE_1 = 1,
Signature · 1 line
2.34.1
PATCH v2 7/11 crypto: qat - add retrieval of fw capabilities
In reply to Damian MuszynskiThe QAT firmware provides a mechanism to retrieve its capabilities through the init admin interface.
Add logic to retrieve the firmware capability mask from the firmware through the init/admin channel. This mask reports if the power management, telemetry and rate limiting features are supported.
The fw capabilities are stored in the accel_dev structure and are used to detect if a certain feature is supported by the firmware loaded in the device.
This is supported only by devices which have an admin AE.
--- .../intel/qat/qat_common/adf_accel_devices.h | 1 + .../crypto/intel/qat/qat_common/adf_admin.c | 23 +++++++++++++++++++ .../qat/qat_common/icp_qat_fw_init_admin.h | 3 +++ 3 files changed, 27 insertions(+)
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +1 -0
@@ -253,6 +253,7 @@ struct adf_hw_device_data {u32 straps;u32 accel_capabilities_mask;u32 extended_dc_capabilities; +u16 fw_capabilities;u32 clock_frequency;u32 instance_id;u16 accel_mask;
drivers/crypto/intel/qat/qat_common/adf_admin.c +23 -0
@@ -310,6 +310,26 @@ static bool is_dcc_enabled(struct adf_accel_dev *accel_dev)return !strcmp (services,"dcc" ); } +static int adf_get_fw_capabilities (struct adf_accel_dev *accel_dev,u16 *caps) +{ +u32 ae_mask = accel_dev->hw_device->admin_ae_mask; +struct icp_qat_fw_init_admin_resp resp = { }; +struct icp_qat_fw_init_admin_req req = { }; +int ret; + +if (!ae_mask) +return 0 ; + + req.cmd_id =ICP_QAT_FW_CAPABILITIES_GET ; + ret =adf_send_admin (accel_dev, &req, &resp, ae_mask); +if (ret) +return ret; + + *caps = resp.fw_capabilities; + +return 0 ; +} +/** * adf_send_admin_init() - Function sends init message to FW * @accel_dev: Pointer to acceleration device.
@@ -320,6 +340,7 @@ static bool is_dcc_enabled(struct adf_accel_dev *accel_dev)*/ int adf_send_admin_init (struct adf_accel_dev *accel_dev) { +struct adf_hw_device_data *hw_data =GET_HW_DATA (accel_dev);u32 dc_capabilities =0 ;int ret;
@@ -340,6 +361,8 @@ int adf_send_admin_init(struct adf_accel_dev *accel_dev) } accel_dev->hw_device->extended_dc_capabilities = dc_capabilities; +adf_get_fw_capabilities (accel_dev, &hw_data->fw_capabilities); +return adf_init_ae (accel_dev); }EXPORT_SYMBOL_GPL (adf_send_admin_init);
drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h +3 -0
@@ -16,6 +16,7 @@ enum icp_qat_fw_init_admin_cmd_id {ICP_QAT_FW_HEARTBEAT_SYNC =7 ,ICP_QAT_FW_HEARTBEAT_GET =8 ,ICP_QAT_FW_COMP_CAPABILITY_GET =9 , +ICP_QAT_FW_CRYPTO_CAPABILITY_GET =10 ,ICP_QAT_FW_DC_CHAIN_INIT =11 ,ICP_QAT_FW_HEARTBEAT_TIMER_SET =13 , ICP_QAT_FW_TIMER_GET = 19,
@@ -109,10 +110,12 @@ struct icp_qat_fw_init_admin_resp {__u32 unsuccessful_count;__u64 resrvd8; }; +__u16 fw_capabilities; }; } __packed;#define ICP_QAT_FW_SYNC ICP_QAT_FW_HEARTBEAT_SYNC +#define ICP_QAT_FW_CAPABILITIES_GET ICP_QAT_FW_CRYPTO_CAPABILITY_GET#define ICP_QAT_NUMBER_OF_PM_EVENTS 8
Signature · 1 line
2.34.1
PATCH v2 8/11 crypto: qat - add rate limiting feature to qat_4xxx
In reply to Damian MuszynskiThe Rate Limiting (RL) feature allows to control the rate of requests that can be submitted on a ring pair (RP). This allows sharing a QAT device among multiple users while ensuring a guaranteed throughput.
The driver provides a mechanism that allows users to set policies, that are programmed to the device. The device is then enforcing those policies.
Configuration of RL is accomplished through entities called SLAs (Service Level Agreement). Each SLA object gets a unique identifier and defines the limitations for a single service across up to four ring pairs (RPs count allocated to a single VF).
The rate is determined using two fields:
* CIR (Committed Information Rate), i.e., the guaranteed rate.
* PIR (Peak Information Rate), i.e., the maximum rate achievable when the device has available resources.
The rate values are expressed in permille scale i.e. 0-1000. Ring pair selection is achieved by providing a 64-bit mask, where each bit corresponds to one of the ring pairs.
This adds an interface and logic that allow to add, update, retrieve and remove an SLA.
--- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 20 + .../intel/qat/qat_4xxx/adf_4xxx_hw_data.h | 13 +- drivers/crypto/intel/qat/qat_common/Makefile | 2 + .../intel/qat/qat_common/adf_accel_devices.h | 3 + .../crypto/intel/qat/qat_common/adf_admin.c | 47 + .../crypto/intel/qat/qat_common/adf_admin.h | 8 + .../intel/qat/qat_common/adf_gen4_hw_data.h | 7 + .../crypto/intel/qat/qat_common/adf_init.c | 10 + drivers/crypto/intel/qat/qat_common/adf_rl.c | 1159 +++++++++++++++++ drivers/crypto/intel/qat/qat_common/adf_rl.h | 169 +++ .../intel/qat/qat_common/adf_rl_admin.c | 97 ++ .../intel/qat/qat_common/adf_rl_admin.h | 18 + .../qat/qat_common/icp_qat_fw_init_admin.h | 38 + 13 files changed, 1590 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl.h create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl_admin.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl_admin.h
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +20 -0
@@ -343,6 +343,24 @@ static u32 get_heartbeat_clock(struct adf_hw_device_data *self)return ADF_4XXX_KPT_COUNTER_FREQ ; } +static void adf_init_rl_data (struct adf_rl_hw_data *rl_data) +{ + rl_data->pciout_tb_offset =ADF_GEN4_RL_TOKEN_PCIEOUT_BUCKET_OFFSET ; + rl_data->pciin_tb_offset =ADF_GEN4_RL_TOKEN_PCIEIN_BUCKET_OFFSET ; + rl_data->r2l_offset =ADF_GEN4_RL_R2L_OFFSET ; + rl_data->l2c_offset =ADF_GEN4_RL_L2C_OFFSET ; + rl_data->c2s_offset =ADF_GEN4_RL_C2S_OFFSET ; + + 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->scan_interval =ADF_4XXX_RL_SCANS_PER_SEC ; + rl_data->scale_ref =ADF_4XXX_RL_SLICE_REF ; +} +static void adf_enable_error_correction (struct adf_accel_dev *accel_dev) {struct adf_bar *misc_bar = &GET_BARS (accel_dev)[ADF_4XXX_PMISC_BAR ];
@@ -594,12 +612,14 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data, u32 dev_id) hw_data->stop_timer = adf_gen4_timer_stop; hw_data->get_hb_clock = get_heartbeat_clock; hw_data->num_hb_ctrs =ADF_NUM_HB_CNT_PER_AE ; + hw_data->clock_frequency =ADF_4XXX_AE_FREQ ;adf_gen4_set_err_mask (&hw_data->dev_err_mask);adf_gen4_init_hw_csr_ops (&hw_data->csr_ops);adf_gen4_init_pf_pfvf_ops (&hw_data->pfvf_ops);adf_gen4_init_dc_ops (&hw_data->dc_ops);adf_gen4_init_ras_ops (&hw_data->ras_ops); +adf_init_rl_data (&hw_data->rl_data); }void adf_clean_hw_data_4xxx (struct adf_hw_device_data *hw_data)
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.h +12 -1
@@ -82,8 +82,19 @@#define ADF_402XX_ASYM_OBJ "qat_402xx_asym.bin"#define ADF_402XX_ADMIN_OBJ "qat_402xx_admin.bin" +/* RL constants */ +#define ADF_4XXX_RL_PCIE_SCALE_FACTOR_DIV 100 +#define ADF_4XXX_RL_PCIE_SCALE_FACTOR_MUL 102 +#define ADF_4XXX_RL_DCPR_CORRECTION 1 +#define ADF_4XXX_RL_SCANS_PER_SEC 954 +#define ADF_4XXX_RL_MAX_TP_ASYM 173750UL +#define ADF_4XXX_RL_MAX_TP_SYM 95000UL +#define ADF_4XXX_RL_MAX_TP_DC 45000UL +#define ADF_4XXX_RL_SLICE_REF 1000UL +/* Clocks frequency */ -#define ADF_4XXX_KPT_COUNTER_FREQ (100 * HZ_PER_MHZ) +#define ADF_4XXX_KPT_COUNTER_FREQ (100 * HZ_PER_MHZ) +#define ADF_4XXX_AE_FREQ (1000 * HZ_PER_MHZ)/* qat_4xxx fuse bits are different from old GENs, redefine them */ enum icp_qat_4xxx_slice_mask {
drivers/crypto/intel/qat/qat_common/Makefile +2 -0
@@ -28,6 +28,8 @@ intel_qat-objs := adf_cfg.o \ qat_algs.o \ qat_asym_algs.o \ qat_algs_send.o \ + adf_rl.o \ + adf_rl_admin.o \ qat_uclo.o \ qat_hal.o \ qat_bl.o
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +3 -0
@@ -9,6 +9,7 @@#include <linux/ratelimit.h> #include <linux/types.h> #include "adf_cfg_common.h" +#include "adf_rl.h" #include "adf_pfvf_msg.h" #define ADF_DH895XCC_DEVICE_NAME "dh895xcc"
@@ -247,6 +248,7 @@ struct adf_hw_device_data {struct adf_dc_ops dc_ops;struct adf_ras_ops ras_ops;struct adf_dev_err_mask dev_err_mask; +struct adf_rl_hw_data rl_data;const char *fw_name;const char *fw_mmp_name;u32 fuses;
@@ -358,6 +360,7 @@ struct adf_accel_dev {struct adf_accel_pci accel_pci_dev;struct adf_timer *timer;struct adf_heartbeat *heartbeat; +struct adf_rl *rate_limiting; union { struct { /* protects VF2PF interrupts access */
drivers/crypto/intel/qat/qat_common/adf_admin.c +47 -0
53 lines not on this page · raw message
drivers/crypto/intel/qat/qat_common/adf_admin.h +8 -0
@@ -3,6 +3,8 @@#ifndef ADF_ADMIN #define ADF_ADMIN +#include "icp_qat_fw_init_admin.h" +struct adf_accel_dev ;int adf_init_admin_comms (struct adf_accel_dev *accel_dev);
@@ -12,6 +14,12 @@ int adf_get_ae_fw_counters(struct adf_accel_dev *accel_dev, u16 ae, u64 *reqs, uint adf_init_admin_pm (struct adf_accel_dev *accel_dev,u32 idle_delay);int adf_send_admin_tim_sync (struct adf_accel_dev *accel_dev,u32 cnt);int adf_send_admin_hb_timer (struct adf_accel_dev *accel_dev,uint32_t ticks); +int adf_send_admin_rl_init (struct adf_accel_dev *accel_dev, +struct icp_qat_fw_init_admin_slice_cnt *slices); +int adf_send_admin_rl_add_update (struct adf_accel_dev *accel_dev, +struct icp_qat_fw_init_admin_req *req); +int adf_send_admin_rl_delete (struct adf_accel_dev *accel_dev,u16 node_id, +u8 node_type);int adf_get_fw_timestamp (struct adf_accel_dev *accel_dev,u64 *timestamp);int adf_get_pm_info (struct adf_accel_dev *accel_dev,dma_addr_t p_state_addr,size_t buff_size);int adf_get_cnv_stats (struct adf_accel_dev *accel_dev,u16 ae,u16 *err_cnt,u16 *latest_err);
drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.h +7 -0
@@ -139,6 +139,13 @@ do { \/* Number of heartbeat counter pairs */ #define ADF_NUM_HB_CNT_PER_AE ADF_NUM_THREADS_PER_AE +/* Rate Limiting */ +#define ADF_GEN4_RL_R2L_OFFSET 0x508000 +#define ADF_GEN4_RL_L2C_OFFSET 0x509000 +#define ADF_GEN4_RL_C2S_OFFSET 0x508818 +#define ADF_GEN4_RL_TOKEN_PCIEIN_BUCKET_OFFSET 0x508800 +#define ADF_GEN4_RL_TOKEN_PCIEOUT_BUCKET_OFFSET 0x508804 +void adf_gen4_set_ssm_wdtimer (struct adf_accel_dev *accel_dev);void adf_gen4_init_hw_csr_ops (struct adf_hw_csr_ops *csr_ops);int adf_gen4_ring_pair_reset (struct adf_accel_dev *accel_dev,u32 bank_number);
drivers/crypto/intel/qat/qat_common/adf_init.c +10 -0
@@ -9,6 +9,7 @@#include "adf_common_drv.h" #include "adf_dbgfs.h" #include "adf_heartbeat.h" +#include "adf_rl.h" #include "adf_sysfs_ras_counters.h" static LIST_HEAD (service_table);
@@ -137,6 +138,9 @@ static int adf_dev_init(struct adf_accel_dev *accel_dev) }adf_heartbeat_init (accel_dev); + ret =adf_rl_init (accel_dev); +if (ret && ret != -EOPNOTSUPP ) +return ret;/* * Subservice initialisation is divided into two stages: init and start.
@@ -212,6 +216,9 @@ static int adf_dev_start(struct adf_accel_dev *accel_dev) }adf_heartbeat_start (accel_dev); + ret =adf_rl_start (accel_dev); +if (ret && ret != -EOPNOTSUPP ) +return ret;list_for_each_entry (service, &service_table, list) {if (service->event_hld (accel_dev,ADF_EVENT_START )) {
@@ -272,6 +279,7 @@ static void adf_dev_stop(struct adf_accel_dev *accel_dev) !test_bit(ADF_STATUS_STARTING, &accel_dev->status)) return; +adf_rl_stop (accel_dev);adf_dbgfs_rm (accel_dev);adf_sysfs_stop_ras (accel_dev);
@@ -359,6 +367,8 @@ static void adf_dev_shutdown(struct adf_accel_dev *accel_dev)clear_bit (accel_dev->accel_id, service->init_status); } +adf_rl_exit (accel_dev); +if (hw_data->ras_ops.disable_ras_errors) hw_data->ras_ops.disable_ras_errors (accel_dev);
drivers/crypto/intel/qat/qat_common/adf_rl.c new file +1159 -0
1,159 lines not on this page · raw message
drivers/crypto/intel/qat/qat_common/adf_rl.h new file +169 -0
169 lines not on this page · raw message
drivers/crypto/intel/qat/qat_common/adf_rl_admin.c new file +97 -0
97 lines not on this page · raw message
drivers/crypto/intel/qat/qat_common/adf_rl_admin.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2023 Intel Corporation */ + +#ifndef ADF_RL_ADMIN_H_ +#define ADF_RL_ADMIN_H_ + +#include <linux/types.h> + +#include "adf_rl.h" + +int adf_rl_send_admin_init_msg (struct adf_accel_dev *accel_dev, +struct rl_slice_cnt *slices_int); +int adf_rl_send_admin_add_update_msg (struct adf_accel_dev *accel_dev, +struct rl_sla *sla,bool is_update); +int adf_rl_send_admin_delete_msg (struct adf_accel_dev *accel_dev,u16 node_id, +u8 node_type); + +#endif /* ADF_RL_ADMIN_H_ */
drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h +38 -0
@@ -5,6 +5,8 @@#include "icp_qat_fw.h" +#define RL_MAX_RP_IDS 16 +enum icp_qat_fw_init_admin_cmd_id {ICP_QAT_FW_INIT_AE =0 ,ICP_QAT_FW_TRNG_ENABLE =1 ,
@@ -19,10 +21,14 @@ enum icp_qat_fw_init_admin_cmd_id {ICP_QAT_FW_CRYPTO_CAPABILITY_GET =10 ,ICP_QAT_FW_DC_CHAIN_INIT =11 ,ICP_QAT_FW_HEARTBEAT_TIMER_SET =13 , +ICP_QAT_FW_RL_INIT =15 ,ICP_QAT_FW_TIMER_GET =19 ,ICP_QAT_FW_CNV_STATS_GET =20 ,ICP_QAT_FW_PM_STATE_CONFIG =128 ,ICP_QAT_FW_PM_INFO =129 , +ICP_QAT_FW_RL_ADD =134 , +ICP_QAT_FW_RL_UPDATE =135 , + ICP_QAT_FW_RL_REMOVE = 136, }; enum icp_qat_fw_init_admin_resp_status {
@@ -30,6 +36,30 @@ enum icp_qat_fw_init_admin_resp_status {ICP_QAT_FW_INIT_RESP_STATUS_FAIL }; +struct icp_qat_fw_init_admin_slice_cnt { +__u8 cpr_cnt; +__u8 xlt_cnt; +__u8 dcpr_cnt; +__u8 pke_cnt; +__u8 wat_cnt; +__u8 wcp_cnt; +__u8 ucs_cnt; +__u8 cph_cnt; +__u8 ath_cnt; +}; + +struct icp_qat_fw_init_admin_sla_config_params { +__u32 pcie_in_cir; +__u32 pcie_in_pir; +__u32 pcie_out_cir; +__u32 pcie_out_pir; +__u32 slice_util_cir; +__u32 slice_util_pir; +__u32 ae_util_cir; +__u32 ae_util_pir; +__u16 rp_ids[RL_MAX_RP_IDS ]; +}; +struct icp_qat_fw_init_admin_req {__u16 init_cfg_sz;__u8 resrvd1;
@@ -49,6 +79,13 @@ struct icp_qat_fw_init_admin_req {struct {__u32 heartbeat_ticks; }; +struct { +__u16 node_id; +__u8 node_type; +__u8 svc_type; +__u8 resrvd5[3 ]; +__u8 rp_count; + };__u32 idle_filter; };
@@ -110,6 +147,7 @@ struct icp_qat_fw_init_admin_resp {__u32 unsuccessful_count;__u64 resrvd8; }; +struct icp_qat_fw_init_admin_slice_cnt slices;__u16 fw_capabilities; }; } __packed;
Signature · 1 line
2.34.1
PATCH v2 9/11 crypto: qat - add rate limiting sysfs interface
In reply to Damian MuszynskiFrom: Ciunas Bennett <[email protected]>
Add an interface for the rate limiting feature which allows to add, remove and modify a QAT SLA (Service Level Agreement).
This adds a new sysfs attribute group, qat_rl, which can be accessed from /sys/bus/pci/devices/<BUS:DEV:FUNCTION> with the following hierarchy:
|-+ qat_rl
|---- id (RW) # SLA identifier
|---- cir (RW) # Committed Information Rate
|---- pir (RW) # Peak Information Rate
|---- srv (RW) # Service to be rate limited
|---- rp (RW) (HEX) # Ring pairs to be rate limited |---- cap_rem (RW) # Remaining capability for a service
|---- sla_op (WO) # Allows to perform an operation on an SLA
The API works by setting the appropriate RW attributes and then issuing a command through the sla_op. For example, to create an SLA, a user needs to input the necessary data into the attributes cir, pir, srv and rp and then write into sla_op the command add to execute the operation.
The API also provides cap_rem attribute to get information about the remaining device capability within a certain service which is required when setting an SLA.
--- Documentation/ABI/testing/sysfs-driver-qat_rl | 227 +++++++++ drivers/crypto/intel/qat/qat_common/Makefile | 1 + drivers/crypto/intel/qat/qat_common/adf_rl.c | 10 + drivers/crypto/intel/qat/qat_common/adf_rl.h | 7 + .../intel/qat/qat_common/adf_sysfs_rl.c | 451 ++++++++++++++++++ .../intel/qat/qat_common/adf_sysfs_rl.h | 11 + 6 files changed, 707 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-qat_rl create mode 100644 drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h
Documentation/ABI/testing/sysfs-driver-qat_rl new file +227 -0
@@ -0,0 +1,227 @@ +What: /sys/bus/pci/devices/<BDF>/qat_rl/sla_op +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (WO) This attribute is used to perform an operation on an SLA. + The supported operations are: add, update, rm, rm_all, and get. + + Input values must be filled through the associated attribute in + this group before a write to this file. + If the operation completes successfully, the associated + attributes will be updated. + The associated attributes are: cir, pir, srv, rp, and id. + + Supported operations: + + * add: Creates a new SLA with the provided inputs from user. + * Inputs: cir, pir, srv, and rp + * Output: id + + * get: Returns the configuration of the specified SLA in id attribute + * Inputs: id + * Outputs: cir, pir, srv, and rp + + * update: Updates the SLA with new values set in the following attributes + * Inputs: id, cir, and pir + + * rm: Removes the specified SLA in the id attribute. + * Inputs: id + + * rm_all: Removes all the configured SLAs. + * Inputs: None + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices/<BDF>/qat_rl/rp +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (RW) When read, reports the current assigned ring pairs for the + queried SLA. + When wrote to, configures the ring pairs associated to a new SLA. + + The value is a 64-bit bit mask and is written/displayed in hex. + Each bit of this mask represents a single ring pair i.e., + bit 1 == ring pair id 0; bit 3 == ring pair id 2. + + Selected ring pairs must to be assigned to a single service, + i.e. the one provided with the srv attribute. The service + assigned to a certain ring pair can be checked by querying + the attribute qat/rp2srv. + + The maximum number of ring pairs is 4 per SLA. + + Applicability in sla_op: + + * WRITE: add operation + * READ: get operation + + Example usage:: + + ## Read + # echo 4 > /sys/bus/pci/devices/<BDF>/qat_rl/id + # cat /sys/bus/pci/devices/<BDF>/qat_rl/rp + 0x5 + + ## Write + # echo 0x5 > /sys/bus/pci/devices/<BDF>/qat_rl/rp + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices/<BDF>/qat_rl/id +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (RW) If written to, the value is used to retrieve a particular + SLA and operate on it. + This is valid only for the following operations: update, rm, + and get. + A read of this attribute is only guaranteed to have correct data + after creation of an SLA. + + Applicability in sla_op: + + * WRITE: rm and update operations + * READ: add and get operations + + Example usage:: + + ## Read + ## Set attributes e.g. cir, pir, srv, etc + # echo "add" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + # cat /sys/bus/pci/devices/<BDF>/qat_rl/id + 4 + + ## Write + # echo 7 > /sys/bus/pci/devices/<BDF>/qat_rl/id + # echo "get" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + # cat /sys/bus/pci/devices/<BDF>/qat_rl/rp + 0x5 ## ring pair ID 0 and ring pair ID 2 + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices/<BDF>/qat_rl/cir +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (RW) Committed information rate (CIR). Rate guaranteed to be + achieved by a particular SLA. The value is expressed in + permille scale, i.e. 1000 refers to the maximum device + throughput for a selected service. + + After sending a "get" to sla_op, this will be populated with the + CIR for that queried SLA. + Write to this file before sending an "add/update" sla_op, to set + the SLA to the specified value. + + Applicability in sla_op: + + * WRITE: add and update operations + * READ: get operation + + Example usage:: + + ## Write + # echo 500 > /sys/bus/pci/devices/<BDF>/qat_rl/cir + # echo "add" /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + + ## Read + # echo 4 > /sys/bus/pci/devices/<BDF>/qat_rl/id + # echo "get" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + # cat /sys/bus/pci/devices/<BDF>/qat_rl/cir + 500 + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices/<BDF>/qat_rl/pir +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (RW) Peak information rate (PIR). The maximum rate that can be + achieved by that particular SLA. An SLA can reach a value + between CIR and PIR when the device is not fully utilized by + requests from other users (assigned to different SLAs). + + After sending a "get" to sla_op, this will be populated with the + PIR for that queried SLA. + Write to this file before sending an "add/update" sla_op, to set + the SLA to the specified value. + + Applicability in sla_op: + + * WRITE: add and update operations + * READ: get operation + + Example usage:: + + ## Write + # echo 750 > /sys/bus/pci/devices/<BDF>/qat_rl/pir + # echo "add" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + + ## Read + # echo 4 > /sys/bus/pci/devices/<BDF>/qat_rl/id + # echo "get" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + # cat /sys/bus/pci/devices/<BDF>/qat_rl/pir + 750 + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices/<BDF>/qat_rl/srv +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (RW) Service (SRV). Represents the service (sym, asym, dc) + associated to an SLA. + Can be written to or queried to set/show the SRV type for an SLA. + The SRV attribute is used to specify the SRV type before adding + an SLA. After an SLA is configured, reports the service + associated to that SLA. + + Applicability in sla_op: + + * WRITE: add and update operations + * READ: get operation + + Example usage:: + + ## Write + # echo "dc" > /sys/bus/pci/devices/<BDF>/qat_rl/srv + # echo "add" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + # cat /sys/bus/pci/devices/<BDF>/qat_rl/id + 4 + + ## Read + # echo 4 > /sys/bus/pci/devices/<BDF>/qat_rl/id + # echo "get" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + # cat /sys/bus/pci/devices/<BDF>/qat_rl/srv + dc + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (RW) This file will return the remaining capability for a + particular service/sla. This is the remaining value that a new + SLA can be set to or a current SLA can be increased with. + + Example usage:: + + # echo "asym" > /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem + # cat /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem + 250 + # echo 250 > /sys/bus/pci/devices/<BDF>/qat_rl/cir + # echo "add" > /sys/bus/pci/devices/<BDF>/qat_rl/sla_op + # cat /sys/bus/pci/devices/<BDF>/qat_rl/cap_rem + 0 + + This attribute is only available for qat_4xxx devices. +
drivers/crypto/intel/qat/qat_common/Makefile +1 -0
@@ -30,6 +30,7 @@ intel_qat-objs := adf_cfg.o \ qat_algs_send.o \ adf_rl.o \ adf_rl_admin.o \ + adf_sysfs_rl.o \ qat_uclo.o \ qat_hal.o \ qat_bl.o
drivers/crypto/intel/qat/qat_common/adf_rl.c +10 -0
@@ -16,6 +16,7 @@#include "adf_common_drv.h" #include "adf_rl_admin.h" #include "adf_rl.h" +#include "adf_sysfs_rl.h" #define RL_TOKEN_GRANULARITY_PCIEIN_BUCKET 0U#define RL_TOKEN_GRANULARITY_PCIEOUT_BUCKET 0U
@@ -1130,8 +1131,16 @@ int adf_rl_start(struct adf_accel_dev *accel_dev) goto ret_sla_rm; } + ret =adf_sysfs_rl_add (accel_dev); +if (ret) { +dev_err (&GET_DEV (accel_dev),"failed to add sysfs interface\n" ); + goto ret_sysfs_rm; + } +return 0 ; +ret_sysfs_rm: +adf_sysfs_rl_rm (accel_dev); ret_sla_rm:adf_rl_remove_sla_all (accel_dev, true); ret_free:
@@ -1146,6 +1155,7 @@ void adf_rl_stop(struct adf_accel_dev *accel_dev)if (!accel_dev->rate_limiting)return ; +adf_sysfs_rl_rm (accel_dev);adf_rl_remove_sla_all (accel_dev, true); }
drivers/crypto/intel/qat/qat_common/adf_rl.h +7 -0
@@ -75,6 +75,12 @@ struct rl_slice_cnt {u8 cph_cnt; }; +struct adf_rl_interface_data { +struct adf_rl_sla_input_data input; +enum adf_base_services cap_rem_srv; +struct rw_semaphore lock; +}; +struct adf_rl_hw_data {u32 scale_ref;u32 scan_interval;
@@ -113,6 +119,7 @@ struct adf_rl {bool rp_in_use[RL_RP_CNT_MAX ];/* Mutex protecting writing to SLAs lists */ struct mutex rl_lock; +struct adf_rl_interface_data user_input; };/**
drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c new file +451 -0
451 lines not on this page · raw message
drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2023 Intel Corporation */ +#ifndef ADF_SYSFS_RL_H_ +#define ADF_SYSFS_RL_H_ + +struct adf_accel_dev ; + +int adf_sysfs_rl_add (struct adf_accel_dev *accel_dev); +void adf_sysfs_rl_rm (struct adf_accel_dev *accel_dev); + +#endif /* ADF_SYSFS_RL_H_ */
Signature · 1 line
2.34.1
PATCH v2 10/11 crypto: qat - add rp2svc sysfs attribute
In reply to Damian MuszynskiFrom: Ciunas Bennett <[email protected]>
Add the attribute rp2svc to the qat attribute group. This provides a way for a user to query a specific ring pair for the type of service that is currently configured for.
When read, the service will be returned for the defined ring pair. When written to this value will be stored as the ring pair to return the service of.
--- Documentation/ABI/testing/sysfs-driver-qat | 32 +++++++++ .../intel/qat/qat_common/adf_accel_devices.h | 6 ++ .../crypto/intel/qat/qat_common/adf_sysfs.c | 66 +++++++++++++++++++ 3 files changed, 104 insertions(+)
Documentation/ABI/testing/sysfs-driver-qat +32 -0
@@ -95,3 +95,35 @@ Description: (RW) This configuration option provides a way to force the device i 0 This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices/<BDF>/qat/rp2srv +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (RW) This attribute provides a way for a user to query a + specific ring pair for the type of service that it is currently + configured for. + + When written to, the value is cached and used to perform the + read operation. Allowed values are in the range 0 to N-1, where + N is the max number of ring pairs supported by a device. This + can be queried using the attribute qat/num_rps. + + A read returns the service associated to the ring pair queried. + + The values are: + + * dc: the ring pair is configured for running compression services + * sym: the ring pair is configured for running symmetric crypto + services + * asym: the ring pair is configured for running asymmetric crypto + services + + Example usage:: + + # echo 1 > /sys/bus/pci/devices/<BDF>/qat/rp2srv + # cat /sys/bus/pci/devices/<BDF>/qat/rp2srv + sym + + This attribute is only available for qat_4xxx devices.
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +6 -0
@@ -340,6 +340,11 @@ struct adf_pm { char __user *buf, size_t count, loff_t *pos); }; +struct adf_sysfs { +int ring_num; +struct rw_semaphore lock;/* protects access to the fields in this struct */ +}; +struct adf_accel_dev {struct adf_etr_data *transport;struct adf_hw_device_data *hw_device;
@@ -361,6 +366,7 @@ struct adf_accel_dev {struct adf_timer *timer;struct adf_heartbeat *heartbeat;struct adf_rl *rate_limiting; +struct adf_sysfs sysfs; union { struct { /* protects VF2PF interrupts access */
drivers/crypto/intel/qat/qat_common/adf_sysfs.c +66 -0
88 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 11/11 crypto: qat - add num_rps sysfs attribute
In reply to Damian MuszynskiFrom: Ciunas Bennett <[email protected]>
Add the attribute num_rps to the qat attribute group. This returns the number of ring pairs that a single device has. This allows to know the maximum value that can be set to the attribute rp2svc.
--- Documentation/ABI/testing/sysfs-driver-qat | 14 ++++++++++++++ drivers/crypto/intel/qat/qat_common/adf_sysfs.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+)
Documentation/ABI/testing/sysfs-driver-qat +14 -0
@@ -127,3 +127,17 @@ Description: sym This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices/<BDF>/qat/num_rps +Date: January 2024 +KernelVersion: 6.7 +Contact: [email protected] +Description: + (RO) Returns the number of ring pairs that a single device has. + + Example usage:: + + # cat /sys/bus/pci/devices/<BDF>/qat/num_rps + 64 + + This attribute is only available for qat_4xxx devices.
drivers/crypto/intel/qat/qat_common/adf_sysfs.c +14 -0
@@ -268,11 +268,25 @@ static ssize_t rp2srv_store(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RW (rp2srv); +static ssize_t num_rps_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct adf_accel_dev *accel_dev; + + accel_dev =adf_devmgr_pci_to_accel_dev (to_pci_dev (dev)); +if (!accel_dev) +return -EINVAL ; + +return sysfs_emit (buf,"%u\n" ,GET_MAX_BANKS (accel_dev)); +} +static DEVICE_ATTR_RO (num_rps); +static struct attribute *qat_attrs[] = { &dev_attr_state.attr, &dev_attr_cfg_services.attr, &dev_attr_pm_idle_enabled.attr, &dev_attr_rp2srv.attr, + &dev_attr_num_rps.attr,NULL , };
Signature · 1 line
2.34.1
Herbert Xu
maintainerQuoted 87 lines · Damian Muszynski
This set enables hardware rate limiting capabilities on QAT 4xxx accelerators. Rate Limiting allows to control the rate of the requests that can be submitted to a ring pair (RP). This allows sharing a QAT device among multiple users while ensuring guaranteed throughput.
The driver provides a mechanism that allows users to set policies, through a sysfs interface, that are then programmed to the device. The device is then enforcing the policies.
The first six commits are refactoring and additions in preparation for
the feature.
Patch #6 introduces a mechanism for retrieving firmware feature
capabilities.
Patch #8 implements the core of the rate limiting feature by providing
mechanisms to set rate limiting policies (aka SLAs).
The final three commits add the required sysfs interface that allow
users to configure SLAs.Changes since v1:
- Removed unnecessary check
- Simplified a few error paths
- Reduced a few local variables
- Fixed repeated error message
- Moved mutex lock abovesla_idexistence check.
- Added Reviewed-by tag from Tero Kristo received from an internal review of the set.Ciunas Bennett (3):
crypto: qat - add rate limiting sysfs interface
crypto: qat - add rp2svc sysfs attribute
crypto: qat - addnum_rpssysfs attributeDamian Muszynski (4):
units: Add BYTES_PER_*BIT
crypto: qat - addbits.htoicp_qat_hw.h
crypto: qat - add retrieval of fw capabilities
crypto: qat - add rate limiting feature toqat_4xxxGiovanni Cabiddu (4):
crypto: qat - refactor fw config related functions
crypto: qat - use masks for AE groups
crypto: qat - fix ring to service map for QAT GEN4
crypto: qat - move admin apiDocumentation/ABI/testing/sysfs-driver-qat | 46 + Documentation/ABI/testing/sysfs-driver-qat_rl | 227 ++++ .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 190 ++- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.h | 13 +- .../intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../intel/qat/qat_c62x/adf_c62x_hw_data.c | 1 + drivers/crypto/intel/qat/qat_common/Makefile | 3 + .../intel/qat/qat_common/adf_accel_devices.h | 11 + .../crypto/intel/qat/qat_common/adf_admin.c | 71 + .../crypto/intel/qat/qat_common/adf_admin.h | 27 + .../crypto/intel/qat/qat_common/adf_clock.c | 1 + .../intel/qat/qat_common/adf_cnv_dbgfs.c | 1 + .../intel/qat/qat_common/adf_common_drv.h | 10 - .../intel/qat/qat_common/adf_fw_counters.c | 1 + .../intel/qat/qat_common/adf_gen4_hw_data.h | 7 + .../crypto/intel/qat/qat_common/adf_gen4_pm.c | 1 + .../qat/qat_common/adf_gen4_pm_debugfs.c | 1 + .../intel/qat/qat_common/adf_gen4_timer.c | 1 + .../intel/qat/qat_common/adf_heartbeat.c | 1 + .../qat/qat_common/adf_heartbeat_dbgfs.c | 1 + .../crypto/intel/qat/qat_common/adf_init.c | 13 + drivers/crypto/intel/qat/qat_common/adf_rl.c | 1169 +++++++++++++++++ drivers/crypto/intel/qat/qat_common/adf_rl.h | 176 +++ .../intel/qat/qat_common/adf_rl_admin.c | 97 ++ .../intel/qat/qat_common/adf_rl_admin.h | 18 + .../crypto/intel/qat/qat_common/adf_sysfs.c | 80 ++ .../intel/qat/qat_common/adf_sysfs_rl.c | 451 +++++++ .../intel/qat/qat_common/adf_sysfs_rl.h | 11 + .../qat/qat_common/icp_qat_fw_init_admin.h | 41 + .../crypto/intel/qat/qat_common/icp_qat_hw.h | 2 + .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 + include/linux/units.h | 4 + 32 files changed, 2605 insertions(+), 73 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-qat_rl create mode 100644 drivers/crypto/intel/qat/qat_common/adf_admin.h create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl.h create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl_admin.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl_admin.h create mode 100644 drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h
Quoted 3 lines
base-commit:
1bb03421eab67940b6509fe0869ff43df5fbe3e6Signature · 1 line
2.34.1
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt