FILE
adf_rl.h
File preview with syntax highlighting.
linux-6.19.14/drivers/crypto/intel/qat/qat_common/adf_rl.h
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* Copyright(c) 2023 Intel Corporation */ 3 4#ifndef ADF_RL_H_ 5#define ADF_RL_H_ 6 7#include <linux/mutex.h> 8#include <linux/types.h> 9 10#include "adf_cfg_services.h" 11 12struct adf_accel_dev; 13 14#define RL_ROOT_MAX 4 15#define RL_CLUSTER_MAX 16 16#define RL_LEAF_MAX 64 17#define RL_NODES_CNT_MAX (RL_ROOT_MAX + RL_CLUSTER_MAX + RL_LEAF_MAX) 18#define RL_RP_CNT_PER_LEAF_MAX 4U 19#define RL_RP_CNT_MAX 64 20#define RL_SLA_EMPTY_ID -1 21#define RL_PARENT_DEFAULT_ID -1 22 23enum rl_node_type { 24 RL_ROOT, 25 RL_CLUSTER, 26 RL_LEAF, 27}; 28 29/** 30 * struct adf_rl_sla_input_data - ratelimiting user input data structure 31 * @rp_mask: 64 bit bitmask of ring pair IDs which will be assigned to SLA. 32 * Eg. 0x5 -> RP0 and RP2 assigned; 0xA005 -> RP0,2,13,15 assigned. 33 * @sla_id: ID of current SLA for operations update, rm, get. For the add 34 * operation, this field will be updated with the ID of the newly 35 * added SLA 36 * @parent_id: ID of the SLA to which the current one should be assigned. 37 * Set to -1 to refer to the default parent. 38 * @cir: Committed information rate. Rate guaranteed to be achieved. Input value 39 * is expressed in permille scale, i.e. 1000 refers to the maximum 40 * device throughput for a selected service. 41 * @pir: Peak information rate. Maximum rate available that the SLA can achieve. 42 * Input value is expressed in permille scale, i.e. 1000 refers to 43 * the maximum device throughput for a selected service. 44 * @type: SLA type: root, cluster, node 45 * @srv: Service associated to the SLA: asym, sym dc. 46 * 47 * This structure is used to perform operations on an SLA. 48 * Depending on the operation, some of the parameters are ignored. 49 * The following list reports which parameters should be set for each operation. 50 * - add: all except sla_id 51 * - update: cir, pir, sla_id 52 * - rm: sla_id 53 * - rm_all: - 54 * - get: sla_id 55 * - get_capability_rem: srv, sla_id 56 */ 57struct adf_rl_sla_input_data { 58 u64 rp_mask; 59 int sla_id; 60 int parent_id; 61 unsigned int cir; 62 unsigned int pir; 63 enum rl_node_type type; 64 enum adf_base_services srv; 65}; 66 67struct rl_slice_cnt { 68 u8 dcpr_cnt; 69 u8 pke_cnt; 70 u8 cph_cnt; 71 u8 cpr_cnt; 72}; 73 74struct adf_rl_interface_data { 75 struct adf_rl_sla_input_data input; 76 enum adf_base_services cap_rem_srv; 77 struct rw_semaphore lock; 78 bool sysfs_added; 79}; 80 81struct adf_rl_hw_data { 82 u32 scale_ref; 83 u32 scan_interval; 84 u32 r2l_offset; 85 u32 l2c_offset; 86 u32 c2s_offset; 87 u32 pciin_tb_offset; 88 u32 pciout_tb_offset; 89 u32 pcie_scale_mul; 90 u32 pcie_scale_div; 91 u32 dcpr_correction; 92 u32 max_tp[RL_ROOT_MAX]; 93 u32 svc_ae_mask[SVC_BASE_COUNT]; 94 struct rl_slice_cnt slices; 95}; 96 97/** 98 * struct adf_rl - ratelimiting data structure 99 * @accel_dev: pointer to acceleration device data 100 * @device_data: pointer to rate limiting data specific to a device type (or revision) 101 * @sla: array of pointers to SLA objects 102 * @root: array of pointers to root type SLAs, element number reflects node_id 103 * @cluster: array of pointers to cluster type SLAs, element number reflects node_id 104 * @leaf: array of pointers to leaf type SLAs, element number reflects node_id 105 * @rp_in_use: array of ring pair IDs already used in one of SLAs 106 * @rl_lock: mutex object which is protecting data in this structure 107 * @input: structure which is used for holding the data received from user 108 */ 109struct adf_rl { 110 struct adf_accel_dev *accel_dev; 111 struct adf_rl_hw_data *device_data; 112 /* mapping sla_id to SLA objects */ 113 struct rl_sla *sla[RL_NODES_CNT_MAX]; 114 struct rl_sla *root[RL_ROOT_MAX]; 115 struct rl_sla *cluster[RL_CLUSTER_MAX]; 116 struct rl_sla *leaf[RL_LEAF_MAX]; 117 bool rp_in_use[RL_RP_CNT_MAX]; 118 /* Mutex protecting writing to SLAs lists */ 119 struct mutex rl_lock; 120 struct adf_rl_interface_data user_input; 121}; 122 123/** 124 * struct rl_sla - SLA object data structure 125 * @parent: pointer to the parent SLA (root/cluster) 126 * @type: SLA type 127 * @srv: service associated with this SLA 128 * @sla_id: ID of the SLA, used as element number in SLA array and as identifier 129 * shared with the user 130 * @node_id: ID of node, each of SLA type have a separate ID list 131 * @cir: committed information rate 132 * @pir: peak information rate (PIR >= CIR) 133 * @rem_cir: if this SLA is a parent then this field represents a remaining 134 * value to be used by child SLAs. 135 * @ring_pairs_ids: array with numeric ring pairs IDs assigned to this SLA 136 * @ring_pairs_cnt: number of assigned ring pairs listed in the array above 137 */ 138struct rl_sla { 139 struct rl_sla *parent; 140 enum rl_node_type type; 141 enum adf_base_services srv; 142 u32 sla_id; 143 u32 node_id; 144 u32 cir; 145 u32 pir; 146 u32 rem_cir; 147 u16 ring_pairs_ids[RL_RP_CNT_PER_LEAF_MAX]; 148 u16 ring_pairs_cnt; 149}; 150 151u32 adf_rl_get_sla_arr_of_type(struct adf_rl *rl_data, enum rl_node_type type, 152 struct rl_sla ***sla_arr); 153int adf_rl_add_sla(struct adf_accel_dev *accel_dev, 154 struct adf_rl_sla_input_data *sla_in); 155int adf_rl_update_sla(struct adf_accel_dev *accel_dev, 156 struct adf_rl_sla_input_data *sla_in); 157int adf_rl_get_sla(struct adf_accel_dev *accel_dev, 158 struct adf_rl_sla_input_data *sla_in); 159int adf_rl_get_capability_remaining(struct adf_accel_dev *accel_dev, 160 enum adf_base_services srv, int sla_id); 161int adf_rl_remove_sla(struct adf_accel_dev *accel_dev, u32 sla_id); 162void adf_rl_remove_sla_all(struct adf_accel_dev *accel_dev, bool incl_default); 163 164int adf_rl_init(struct adf_accel_dev *accel_dev); 165int adf_rl_start(struct adf_accel_dev *accel_dev); 166void adf_rl_stop(struct adf_accel_dev *accel_dev); 167void adf_rl_exit(struct adf_accel_dev *accel_dev); 168 169u32 adf_rl_calculate_pci_bw(struct adf_accel_dev *accel_dev, u32 sla_val, 170 enum adf_base_services svc_type, bool is_bw_out); 171u32 adf_rl_calculate_ae_cycles(struct adf_accel_dev *accel_dev, u32 sla_val, 172 enum adf_base_services svc_type); 173u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val, 174 enum adf_base_services svc_type); 175 176#endif /* ADF_RL_H_ */
~/
Read-only file preview.