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

crypto: qat - add support for ring pair level telemetry

Expose through debugfs ring pair telemetry data for QAT GEN4 devices.

This allows to gather metrics about the PCIe channel and device TLB for
a selected ring pair. It is possible to monitor maximum 4 ring pairs at
the time per device.

For details, refer to debugfs-driver-qat_telemetry in Documentation/ABI.

This patch is based on earlier work done by Wojciech Ziemba.

Signed-off-by: Lucas Segarra Fernandez <lucas.segarra.fernandez@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Damian Muszynski <damian.muszynski@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Lucas Segarra Fernandez and committed by
Herbert Xu
eb527077 69e7649f

+449 -5
+125
Documentation/ABI/testing/debugfs-driver-qat_telemetry
··· 101 101 attribute is not reported. 102 102 103 103 This attribute is only available for qat_4xxx devices. 104 + 105 + What: /sys/kernel/debug/qat_<device>_<BDF>/telemetry/rp_<A/B/C/D>_data 106 + Date: March 2024 107 + KernelVersion: 6.8 108 + Contact: qat-linux@intel.com 109 + Description: (RW) Selects up to 4 Ring Pairs (RP) to monitor, one per file, 110 + and report telemetry counters related to each. 111 + 112 + Allowed values to write: 113 + ======================== 114 + * 0 to ``<num_rps - 1>``: 115 + Ring pair to be monitored. The value of ``num_rps`` can be 116 + retrieved through ``/sys/bus/pci/devices/<BDF>/qat/num_rps``. 117 + See Documentation/ABI/testing/sysfs-driver-qat. 118 + 119 + Reads report metrics about performance and utilization of 120 + the selected RP: 121 + 122 + ======================= ======================================== 123 + Field Description 124 + ======================= ======================================== 125 + sample_cnt number of acquisitions of telemetry data 126 + from the device. Reads are performed 127 + every 1000 ms 128 + rp_num RP number associated with slot <A/B/C/D> 129 + service_type service associated to the RP 130 + pci_trans_cnt number of PCIe partial transactions 131 + gp_lat_acc_avg average get to put latency [ns] 132 + bw_in PCIe, write bandwidth [Mbps] 133 + bw_out PCIe, read bandwidth [Mbps] 134 + at_glob_devtlb_hit Message descriptor DevTLB hit rate 135 + at_glob_devtlb_miss Message descriptor DevTLB miss rate 136 + tl_at_payld_devtlb_hit Payload DevTLB hit rate 137 + tl_at_payld_devtlb_miss Payload DevTLB miss rate 138 + ======================= ======================================== 139 + 140 + Example. 141 + 142 + Writing the value '32' to the file ``rp_C_data`` starts the 143 + collection of telemetry metrics for ring pair 32:: 144 + 145 + echo 32 > /sys/kernel/debug/qat_4xxx_0000:6b:00.0/telemetry/rp_C_data 146 + 147 + Once a ring pair is selected, statistics can be read accessing 148 + the file:: 149 + 150 + cat /sys/kernel/debug/qat_4xxx_0000:6b:00.0/telemetry/rp_C_data 151 + 152 + If ``control`` is set to 1, only the current values of the 153 + counters are displayed:: 154 + 155 + <counter_name> <current> 156 + 157 + If ``control`` is 2, 3 or 4, counters are displayed in the 158 + following format:: 159 + 160 + <counter_name> <current> <min> <max> <avg> 161 + 162 + 163 + On QAT GEN4 devices there are 64 RPs on a PF, so the allowed 164 + values are 0..63. This number is absolute to the device. 165 + If Virtual Functions (VF) are used, the ring pair number can 166 + be derived from the Bus, Device, Function of the VF: 167 + 168 + ============ ====== ====== ====== ====== 169 + PCI BDF/VF RP0 RP1 RP2 RP3 170 + ============ ====== ====== ====== ====== 171 + 0000:6b:0.1 RP 0 RP 1 RP 2 RP 3 172 + 0000:6b:0.2 RP 4 RP 5 RP 6 RP 7 173 + 0000:6b:0.3 RP 8 RP 9 RP 10 RP 11 174 + 0000:6b:0.4 RP 12 RP 13 RP 14 RP 15 175 + 0000:6b:0.5 RP 16 RP 17 RP 18 RP 19 176 + 0000:6b:0.6 RP 20 RP 21 RP 22 RP 23 177 + 0000:6b:0.7 RP 24 RP 25 RP 26 RP 27 178 + 0000:6b:1.0 RP 28 RP 29 RP 30 RP 31 179 + 0000:6b:1.1 RP 32 RP 33 RP 34 RP 35 180 + 0000:6b:1.2 RP 36 RP 37 RP 38 RP 39 181 + 0000:6b:1.3 RP 40 RP 41 RP 42 RP 43 182 + 0000:6b:1.4 RP 44 RP 45 RP 46 RP 47 183 + 0000:6b:1.5 RP 48 RP 49 RP 50 RP 51 184 + 0000:6b:1.6 RP 52 RP 53 RP 54 RP 55 185 + 0000:6b:1.7 RP 56 RP 57 RP 58 RP 59 186 + 0000:6b:2.0 RP 60 RP 61 RP 62 RP 63 187 + ============ ====== ====== ====== ====== 188 + 189 + The mapping is only valid for the BDFs of VFs on the host. 190 + 191 + 192 + The service provided on a ring-pair varies depending on the 193 + configuration. The configuration for a given device can be 194 + queried and set using ``cfg_services``. 195 + See Documentation/ABI/testing/sysfs-driver-qat for details. 196 + 197 + The following table reports how ring pairs are mapped to VFs 198 + on the PF 0000:6b:0.0 configured for `sym;asym` or `asym;sym`: 199 + 200 + =========== ============ =========== ============ =========== 201 + PCI BDF/VF RP0/service RP1/service RP2/service RP3/service 202 + =========== ============ =========== ============ =========== 203 + 0000:6b:0.1 RP 0 asym RP 1 sym RP 2 asym RP 3 sym 204 + 0000:6b:0.2 RP 4 asym RP 5 sym RP 6 asym RP 7 sym 205 + 0000:6b:0.3 RP 8 asym RP 9 sym RP10 asym RP11 sym 206 + ... ... ... ... ... 207 + =========== ============ =========== ============ =========== 208 + 209 + All VFs follow the same pattern. 210 + 211 + 212 + The following table reports how ring pairs are mapped to VFs on 213 + the PF 0000:6b:0.0 configured for `dc`: 214 + 215 + =========== ============ =========== ============ =========== 216 + PCI BDF/VF RP0/service RP1/service RP2/service RP3/service 217 + =========== ============ =========== ============ =========== 218 + 0000:6b:0.1 RP 0 dc RP 1 dc RP 2 dc RP 3 dc 219 + 0000:6b:0.2 RP 4 dc RP 5 dc RP 6 dc RP 7 dc 220 + 0000:6b:0.3 RP 8 dc RP 9 dc RP10 dc RP11 dc 221 + ... ... ... ... ... 222 + =========== ============ =========== ============ =========== 223 + 224 + The mapping of a RP to a service can be retrieved using 225 + ``rp2srv`` from sysfs. 226 + See Documentation/ABI/testing/sysfs-driver-qat for details. 227 + 228 + This attribute is only available for qat_4xxx devices.
+1
drivers/crypto/intel/qat/qat_420xx/adf_420xx_hw_data.c
··· 520 520 hw_data->init_device = adf_gen4_init_device; 521 521 hw_data->reset_device = adf_reset_flr; 522 522 hw_data->admin_ae_mask = ADF_420XX_ADMIN_AE_MASK; 523 + hw_data->num_rps = ADF_GEN4_MAX_RPS; 523 524 hw_data->fw_name = ADF_420XX_FW; 524 525 hw_data->fw_mmp_name = ADF_420XX_MMP; 525 526 hw_data->uof_get_name = uof_get_name_420xx;
+1
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c
··· 421 421 hw_data->init_device = adf_gen4_init_device; 422 422 hw_data->reset_device = adf_reset_flr; 423 423 hw_data->admin_ae_mask = ADF_4XXX_ADMIN_AE_MASK; 424 + hw_data->num_rps = ADF_GEN4_MAX_RPS; 424 425 switch (dev_id) { 425 426 case ADF_402XX_PCI_DEVICE_ID: 426 427 hw_data->fw_name = ADF_402XX_FW;
+1
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h
··· 278 278 u8 num_logical_accel; 279 279 u8 num_engines; 280 280 u32 num_hb_ctrs; 281 + u8 num_rps; 281 282 }; 282 283 283 284 /* CSR write macro */
+1
drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.h
··· 36 36 #define ADF_GEN4_MSIX_RTTABLE_OFFSET(i) (0x409000 + ((i) * 0x04)) 37 37 38 38 /* Bank and ring configuration */ 39 + #define ADF_GEN4_MAX_RPS 64 39 40 #define ADF_GEN4_NUM_RINGS_PER_BANK 2 40 41 #define ADF_GEN4_NUM_BANKS_PER_VF 4 41 42 #define ADF_GEN4_ETR_MAX_BANKS 64
+35
drivers/crypto/intel/qat/qat_common/adf_gen4_tl.c
··· 9 9 10 10 #define ADF_GEN4_TL_DEV_REG_OFF(reg) ADF_TL_DEV_REG_OFF(reg, gen4) 11 11 12 + #define ADF_GEN4_TL_RP_REG_OFF(reg) ADF_TL_RP_REG_OFF(reg, gen4) 13 + 12 14 #define ADF_GEN4_TL_SL_UTIL_COUNTER(_name) \ 13 15 ADF_TL_COUNTER("util_" #_name, \ 14 16 ADF_TL_SIMPLE_COUNT, \ ··· 103 101 ADF_GEN4_TL_SL_EXEC_COUNTER(ath), 104 102 }; 105 103 104 + /* Ring pair counters. */ 105 + static const struct adf_tl_dbg_counter rp_counters[] = { 106 + /* PCIe partial transactions. */ 107 + ADF_TL_COUNTER(PCI_TRANS_CNT_NAME, ADF_TL_SIMPLE_COUNT, 108 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_pci_trans_cnt)), 109 + /* Get to put latency average[ns]. */ 110 + ADF_TL_COUNTER_LATENCY(LAT_ACC_NAME, ADF_TL_COUNTER_NS_AVG, 111 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_gp_lat_acc), 112 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_ae_put_cnt)), 113 + /* PCIe write bandwidth[Mbps]. */ 114 + ADF_TL_COUNTER(BW_IN_NAME, ADF_TL_COUNTER_MBPS, 115 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_bw_in)), 116 + /* PCIe read bandwidth[Mbps]. */ 117 + ADF_TL_COUNTER(BW_OUT_NAME, ADF_TL_COUNTER_MBPS, 118 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_bw_out)), 119 + /* Message descriptor DevTLB hit rate. */ 120 + ADF_TL_COUNTER(AT_GLOB_DTLB_HIT_NAME, ADF_TL_SIMPLE_COUNT, 121 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_at_glob_devtlb_hit)), 122 + /* Message descriptor DevTLB miss rate. */ 123 + ADF_TL_COUNTER(AT_GLOB_DTLB_MISS_NAME, ADF_TL_SIMPLE_COUNT, 124 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_at_glob_devtlb_miss)), 125 + /* Payload DevTLB hit rate. */ 126 + ADF_TL_COUNTER(AT_PAYLD_DTLB_HIT_NAME, ADF_TL_SIMPLE_COUNT, 127 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_at_payld_devtlb_hit)), 128 + /* Payload DevTLB miss rate. */ 129 + ADF_TL_COUNTER(AT_PAYLD_DTLB_MISS_NAME, ADF_TL_SIMPLE_COUNT, 130 + ADF_GEN4_TL_RP_REG_OFF(reg_tl_at_payld_devtlb_miss)), 131 + }; 132 + 106 133 void adf_gen4_init_tl_data(struct adf_tl_hw_data *tl_data) 107 134 { 108 135 tl_data->layout_sz = ADF_GEN4_TL_LAYOUT_SZ; 109 136 tl_data->slice_reg_sz = ADF_GEN4_TL_SLICE_REG_SZ; 137 + tl_data->rp_reg_sz = ADF_GEN4_TL_RP_REG_SZ; 110 138 tl_data->num_hbuff = ADF_GEN4_TL_NUM_HIST_BUFFS; 139 + tl_data->max_rp = ADF_GEN4_TL_MAX_RP_NUM; 111 140 tl_data->msg_cnt_off = ADF_GEN4_TL_MSG_CNT_OFF; 112 141 tl_data->cpp_ns_per_cycle = ADF_GEN4_CPP_NS_PER_CYCLE; 113 142 tl_data->bw_units_to_bytes = ADF_GEN4_TL_BW_HW_UNITS_TO_BYTES; ··· 147 114 tl_data->num_dev_counters = ARRAY_SIZE(dev_counters); 148 115 tl_data->sl_util_counters = sl_util_counters; 149 116 tl_data->sl_exec_counters = sl_exec_counters; 117 + tl_data->rp_counters = rp_counters; 118 + tl_data->num_rp_counters = ARRAY_SIZE(rp_counters); 150 119 } 151 120 EXPORT_SYMBOL_GPL(adf_gen4_init_tl_data);
+39 -2
drivers/crypto/intel/qat/qat_common/adf_gen4_tl.h
··· 21 21 /* Max number of HW resources of one type. */ 22 22 #define ADF_GEN4_TL_MAX_SLICES_PER_TYPE 24 23 23 24 + /* Max number of simultaneously monitored ring pairs. */ 25 + #define ADF_GEN4_TL_MAX_RP_NUM 4 26 + 24 27 /** 25 28 * struct adf_gen4_tl_slice_data_regs - HW slice data as populated by FW. 26 29 * @reg_tm_slice_exec_cnt: Slice execution count. ··· 96 93 }; 97 94 98 95 /** 96 + * struct adf_gen4_tl_ring_pair_data_regs - This structure stores Ring Pair 97 + * telemetry counter values as are being populated periodically by device. 98 + * @reg_tl_gp_lat_acc: get-put latency accumulator 99 + * @reserved: reserved 100 + * @reg_tl_pci_trans_cnt: PCIe partial transactions 101 + * @reg_tl_ae_put_cnt: Accelerator Engine put counts across all rings 102 + * @reg_tl_bw_in: PCIe write bandwidth 103 + * @reg_tl_bw_out: PCIe read bandwidth 104 + * @reg_tl_at_glob_devtlb_hit: Message descriptor DevTLB hit rate 105 + * @reg_tl_at_glob_devtlb_miss: Message descriptor DevTLB miss rate 106 + * @reg_tl_at_payld_devtlb_hit: Payload DevTLB hit rate 107 + * @reg_tl_at_payld_devtlb_miss: Payload DevTLB miss rate 108 + * @reg_tl_re_cnt: ring empty time samples count 109 + * @reserved1: reserved 110 + */ 111 + struct adf_gen4_tl_ring_pair_data_regs { 112 + __u64 reg_tl_gp_lat_acc; 113 + __u64 reserved; 114 + __u32 reg_tl_pci_trans_cnt; 115 + __u32 reg_tl_ae_put_cnt; 116 + __u32 reg_tl_bw_in; 117 + __u32 reg_tl_bw_out; 118 + __u32 reg_tl_at_glob_devtlb_hit; 119 + __u32 reg_tl_at_glob_devtlb_miss; 120 + __u32 reg_tl_at_payld_devtlb_hit; 121 + __u32 reg_tl_at_payld_devtlb_miss; 122 + __u32 reg_tl_re_cnt; 123 + __u32 reserved1; 124 + }; 125 + 126 + #define ADF_GEN4_TL_RP_REG_SZ sizeof(struct adf_gen4_tl_ring_pair_data_regs) 127 + 128 + /** 99 129 * struct adf_gen4_tl_layout - This structure represents entire telemetry 100 130 * counters data: Device + 4 Ring Pairs as are being populated periodically 101 131 * by device. 102 132 * @tl_device_data_regs: structure of device telemetry registers 103 - * @reserved1: reserved 133 + * @tl_ring_pairs_data_regs: array of ring pairs telemetry registers 104 134 * @reg_tl_msg_cnt: telemetry messages counter 105 135 * @reserved: reserved 106 136 */ 107 137 struct adf_gen4_tl_layout { 108 138 struct adf_gen4_tl_device_data_regs tl_device_data_regs; 109 - __u32 reserved1[14]; 139 + struct adf_gen4_tl_ring_pair_data_regs 140 + tl_ring_pairs_data_regs[ADF_GEN4_TL_MAX_RP_NUM]; 110 141 __u32 reg_tl_msg_cnt; 111 142 __u32 reserved; 112 143 };
+20 -3
drivers/crypto/intel/qat/qat_common/adf_telemetry.c
··· 33 33 if (!tl_data->dev_counters || 34 34 TL_IS_ZERO(tl_data->num_dev_counters) || 35 35 !tl_data->sl_util_counters || 36 - !tl_data->sl_exec_counters) 36 + !tl_data->sl_exec_counters || 37 + !tl_data->rp_counters || 38 + TL_IS_ZERO(tl_data->num_rp_counters)) 37 39 return -EOPNOTSUPP; 38 40 39 41 return 0; ··· 55 53 if (!telemetry) 56 54 return -ENOMEM; 57 55 56 + telemetry->rp_num_indexes = kmalloc_array(tl_data->max_rp, 57 + sizeof(*telemetry->rp_num_indexes), 58 + GFP_KERNEL); 59 + if (!telemetry->rp_num_indexes) 60 + goto err_free_tl; 61 + 58 62 telemetry->regs_hist_buff = kmalloc_array(tl_data->num_hbuff, 59 63 sizeof(*telemetry->regs_hist_buff), 60 64 GFP_KERNEL); 61 65 if (!telemetry->regs_hist_buff) 62 - goto err_free_tl; 66 + goto err_free_rp_indexes; 63 67 64 68 telemetry->regs_data = dma_alloc_coherent(dev, regs_sz, 65 69 &telemetry->regs_data_p, ··· 94 86 95 87 err_free_regs_hist_buff: 96 88 kfree(telemetry->regs_hist_buff); 89 + err_free_rp_indexes: 90 + kfree(telemetry->rp_num_indexes); 97 91 err_free_tl: 98 92 kfree(telemetry); 99 93 ··· 117 107 telemetry->regs_data_p); 118 108 119 109 kfree(telemetry->regs_hist_buff); 110 + kfree(telemetry->rp_num_indexes); 120 111 kfree(telemetry); 121 112 accel_dev->telemetry = NULL; 122 113 } ··· 207 196 int ret; 208 197 209 198 ret = adf_send_admin_tl_start(accel_dev, telemetry->regs_data_p, 210 - layout_sz, NULL, &telemetry->slice_cnt); 199 + layout_sz, telemetry->rp_num_indexes, 200 + &telemetry->slice_cnt); 211 201 if (ret) { 212 202 dev_err(dev, "failed to start telemetry\n"); 213 203 return ret; ··· 225 213 int adf_tl_init(struct adf_accel_dev *accel_dev) 226 214 { 227 215 struct adf_tl_hw_data *tl_data = &GET_TL_DATA(accel_dev); 216 + u8 max_rp = GET_TL_DATA(accel_dev).max_rp; 228 217 struct device *dev = &GET_DEV(accel_dev); 229 218 struct adf_telemetry *telemetry; 219 + unsigned int i; 230 220 int ret; 231 221 232 222 ret = validate_tl_data(tl_data); ··· 247 233 mutex_init(&telemetry->wr_lock); 248 234 mutex_init(&telemetry->regs_hist_lock); 249 235 INIT_DELAYED_WORK(&telemetry->work_ctx, tl_work_handler); 236 + 237 + for (i = 0; i < max_rp; i++) 238 + telemetry->rp_num_indexes[i] = ADF_TL_RP_REGS_DISABLED; 250 239 251 240 return 0; 252 241 }
+7
drivers/crypto/intel/qat/qat_common/adf_telemetry.h
··· 23 23 /* Interval within timer interrupt should be handled. Value in milliseconds. */ 24 24 #define ADF_TL_TIMER_INT_MS (ADF_TL_DATA_WR_INTERVAL_MS / 2) 25 25 26 + #define ADF_TL_RP_REGS_DISABLED (0xff) 27 + 26 28 struct adf_tl_hw_data { 27 29 size_t layout_sz; 28 30 size_t slice_reg_sz; 31 + size_t rp_reg_sz; 29 32 size_t msg_cnt_off; 30 33 const struct adf_tl_dbg_counter *dev_counters; 31 34 const struct adf_tl_dbg_counter *sl_util_counters; 32 35 const struct adf_tl_dbg_counter *sl_exec_counters; 36 + const struct adf_tl_dbg_counter *rp_counters; 33 37 u8 num_hbuff; 34 38 u8 cpp_ns_per_cycle; 35 39 u8 bw_units_to_bytes; 36 40 u8 num_dev_counters; 41 + u8 num_rp_counters; 42 + u8 max_rp; 37 43 }; 38 44 39 45 struct adf_telemetry { ··· 56 50 */ 57 51 void **regs_hist_buff; 58 52 struct dentry *dbg_dir; 53 + u8 *rp_num_indexes; 59 54 /** 60 55 * @regs_hist_lock: protects from race conditions between write and read 61 56 * to the copies referenced by @regs_hist_buff
+208
drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.c
··· 6 6 #include <linux/debugfs.h> 7 7 #include <linux/dev_printk.h> 8 8 #include <linux/dcache.h> 9 + #include <linux/file.h> 9 10 #include <linux/kernel.h> 10 11 #include <linux/math64.h> 11 12 #include <linux/mutex.h> ··· 15 14 #include <linux/units.h> 16 15 17 16 #include "adf_accel_devices.h" 17 + #include "adf_cfg_strings.h" 18 18 #include "adf_telemetry.h" 19 19 #include "adf_tl_debugfs.h" 20 20 21 21 #define TL_VALUE_MIN_PADDING 20 22 22 #define TL_KEY_MIN_PADDING 23 23 + #define TL_RP_SRV_UNKNOWN "Unknown" 23 24 24 25 static int tl_collect_values_u32(struct adf_telemetry *telemetry, 25 26 size_t counter_offset, u64 *arr) ··· 473 470 } 474 471 DEFINE_SHOW_STORE_ATTRIBUTE(tl_control); 475 472 473 + static int get_rp_index_from_file(const struct file *f, u8 *rp_id, u8 rp_num) 474 + { 475 + char alpha; 476 + u8 index; 477 + int ret; 478 + 479 + ret = sscanf(f->f_path.dentry->d_name.name, ADF_TL_RP_REGS_FNAME, &alpha); 480 + if (ret != 1) 481 + return -EINVAL; 482 + 483 + index = ADF_TL_DBG_RP_INDEX_ALPHA(alpha); 484 + *rp_id = index; 485 + 486 + return 0; 487 + } 488 + 489 + static int adf_tl_dbg_change_rp_index(struct adf_accel_dev *accel_dev, 490 + unsigned int new_rp_num, 491 + unsigned int rp_regs_index) 492 + { 493 + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); 494 + struct adf_telemetry *telemetry = accel_dev->telemetry; 495 + struct device *dev = &GET_DEV(accel_dev); 496 + unsigned int i; 497 + u8 curr_state; 498 + int ret; 499 + 500 + if (new_rp_num >= hw_data->num_rps) { 501 + dev_info(dev, "invalid Ring Pair number selected\n"); 502 + return -EINVAL; 503 + } 504 + 505 + for (i = 0; i < hw_data->tl_data.max_rp; i++) { 506 + if (telemetry->rp_num_indexes[i] == new_rp_num) { 507 + dev_info(dev, "RP nr: %d is already selected in slot rp_%c_data\n", 508 + new_rp_num, ADF_TL_DBG_RP_ALPHA_INDEX(i)); 509 + return 0; 510 + } 511 + } 512 + 513 + dev_dbg(dev, "selecting RP nr %u into slot rp_%c_data\n", 514 + new_rp_num, ADF_TL_DBG_RP_ALPHA_INDEX(rp_regs_index)); 515 + 516 + curr_state = atomic_read(&telemetry->state); 517 + 518 + if (curr_state) { 519 + ret = adf_tl_halt(accel_dev); 520 + if (ret) 521 + return ret; 522 + 523 + telemetry->rp_num_indexes[rp_regs_index] = new_rp_num; 524 + 525 + ret = adf_tl_run(accel_dev, curr_state); 526 + if (ret) 527 + return ret; 528 + } else { 529 + telemetry->rp_num_indexes[rp_regs_index] = new_rp_num; 530 + } 531 + 532 + return 0; 533 + } 534 + 535 + static void tl_print_rp_srv(struct adf_accel_dev *accel_dev, struct seq_file *s, 536 + u8 rp_idx) 537 + { 538 + u32 banks_per_vf = GET_HW_DATA(accel_dev)->num_banks_per_vf; 539 + enum adf_cfg_service_type svc; 540 + 541 + seq_printf(s, "%-*s", TL_KEY_MIN_PADDING, RP_SERVICE_TYPE); 542 + 543 + svc = GET_SRV_TYPE(accel_dev, rp_idx % banks_per_vf); 544 + switch (svc) { 545 + case COMP: 546 + seq_printf(s, "%*s\n", TL_VALUE_MIN_PADDING, ADF_CFG_DC); 547 + break; 548 + case SYM: 549 + seq_printf(s, "%*s\n", TL_VALUE_MIN_PADDING, ADF_CFG_SYM); 550 + break; 551 + case ASYM: 552 + seq_printf(s, "%*s\n", TL_VALUE_MIN_PADDING, ADF_CFG_ASYM); 553 + break; 554 + default: 555 + seq_printf(s, "%*s\n", TL_VALUE_MIN_PADDING, TL_RP_SRV_UNKNOWN); 556 + break; 557 + } 558 + } 559 + 560 + static int tl_print_rp_data(struct adf_accel_dev *accel_dev, struct seq_file *s, 561 + u8 rp_regs_index) 562 + { 563 + struct adf_tl_hw_data *tl_data = &GET_TL_DATA(accel_dev); 564 + struct adf_telemetry *telemetry = accel_dev->telemetry; 565 + const struct adf_tl_dbg_counter *rp_tl_counters; 566 + u8 num_rp_counters = tl_data->num_rp_counters; 567 + size_t rp_regs_sz = tl_data->rp_reg_sz; 568 + struct adf_tl_dbg_counter ctr; 569 + unsigned int i; 570 + u8 rp_idx; 571 + int ret; 572 + 573 + if (!atomic_read(&telemetry->state)) { 574 + dev_info(&GET_DEV(accel_dev), "not enabled\n"); 575 + return -EPERM; 576 + } 577 + 578 + rp_tl_counters = tl_data->rp_counters; 579 + rp_idx = telemetry->rp_num_indexes[rp_regs_index]; 580 + 581 + if (rp_idx == ADF_TL_RP_REGS_DISABLED) { 582 + dev_info(&GET_DEV(accel_dev), "no RP number selected in rp_%c_data\n", 583 + ADF_TL_DBG_RP_ALPHA_INDEX(rp_regs_index)); 584 + return -EPERM; 585 + } 586 + 587 + tl_print_msg_cnt(s, telemetry->msg_cnt); 588 + seq_printf(s, "%-*s", TL_KEY_MIN_PADDING, RP_NUM_INDEX); 589 + seq_printf(s, "%*d\n", TL_VALUE_MIN_PADDING, rp_idx); 590 + tl_print_rp_srv(accel_dev, s, rp_idx); 591 + 592 + for (i = 0; i < num_rp_counters; i++) { 593 + ctr = rp_tl_counters[i]; 594 + ctr.offset1 += rp_regs_sz * rp_regs_index; 595 + ctr.offset2 += rp_regs_sz * rp_regs_index; 596 + ret = tl_calc_and_print_counter(telemetry, s, &ctr, NULL); 597 + if (ret) { 598 + dev_dbg(&GET_DEV(accel_dev), 599 + "invalid RP counter type\n"); 600 + return ret; 601 + } 602 + } 603 + 604 + return 0; 605 + } 606 + 607 + static int tl_rp_data_show(struct seq_file *s, void *unused) 608 + { 609 + struct adf_accel_dev *accel_dev = s->private; 610 + u8 rp_regs_index; 611 + u8 max_rp; 612 + int ret; 613 + 614 + if (!accel_dev) 615 + return -EINVAL; 616 + 617 + max_rp = GET_TL_DATA(accel_dev).max_rp; 618 + ret = get_rp_index_from_file(s->file, &rp_regs_index, max_rp); 619 + if (ret) { 620 + dev_dbg(&GET_DEV(accel_dev), "invalid RP data file name\n"); 621 + return ret; 622 + } 623 + 624 + return tl_print_rp_data(accel_dev, s, rp_regs_index); 625 + } 626 + 627 + static ssize_t tl_rp_data_write(struct file *file, const char __user *userbuf, 628 + size_t count, loff_t *ppos) 629 + { 630 + struct seq_file *seq_f = file->private_data; 631 + struct adf_accel_dev *accel_dev; 632 + struct adf_telemetry *telemetry; 633 + unsigned int new_rp_num; 634 + u8 rp_regs_index; 635 + u8 max_rp; 636 + int ret; 637 + 638 + accel_dev = seq_f->private; 639 + if (!accel_dev) 640 + return -EINVAL; 641 + 642 + telemetry = accel_dev->telemetry; 643 + max_rp = GET_TL_DATA(accel_dev).max_rp; 644 + 645 + mutex_lock(&telemetry->wr_lock); 646 + 647 + ret = get_rp_index_from_file(file, &rp_regs_index, max_rp); 648 + if (ret) { 649 + dev_dbg(&GET_DEV(accel_dev), "invalid RP data file name\n"); 650 + goto unlock_and_exit; 651 + } 652 + 653 + ret = kstrtou32_from_user(userbuf, count, 10, &new_rp_num); 654 + if (ret) 655 + goto unlock_and_exit; 656 + 657 + ret = adf_tl_dbg_change_rp_index(accel_dev, new_rp_num, rp_regs_index); 658 + if (ret) 659 + goto unlock_and_exit; 660 + 661 + ret = count; 662 + 663 + unlock_and_exit: 664 + mutex_unlock(&telemetry->wr_lock); 665 + return ret; 666 + } 667 + DEFINE_SHOW_STORE_ATTRIBUTE(tl_rp_data); 668 + 476 669 void adf_tl_dbgfs_add(struct adf_accel_dev *accel_dev) 477 670 { 478 671 struct adf_telemetry *telemetry = accel_dev->telemetry; 479 672 struct dentry *parent = accel_dev->debugfs_dir; 673 + u8 max_rp = GET_TL_DATA(accel_dev).max_rp; 674 + char name[ADF_TL_RP_REGS_FNAME_SIZE]; 480 675 struct dentry *dir; 676 + unsigned int i; 481 677 482 678 if (!telemetry) 483 679 return; ··· 685 483 accel_dev->telemetry->dbg_dir = dir; 686 484 debugfs_create_file("device_data", 0444, dir, accel_dev, &tl_dev_data_fops); 687 485 debugfs_create_file("control", 0644, dir, accel_dev, &tl_control_fops); 486 + 487 + for (i = 0; i < max_rp; i++) { 488 + snprintf(name, sizeof(name), ADF_TL_RP_REGS_FNAME, 489 + ADF_TL_DBG_RP_ALPHA_INDEX(i)); 490 + debugfs_create_file(name, 0644, dir, accel_dev, &tl_rp_data_fops); 491 + } 688 492 } 689 493 690 494 void adf_tl_dbgfs_rm(struct adf_accel_dev *accel_dev)
+11
drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.h
··· 24 24 #define AT_GLOB_DTLB_MISS_NAME "at_glob_devtlb_miss" 25 25 #define AT_PAYLD_DTLB_HIT_NAME "tl_at_payld_devtlb_hit" 26 26 #define AT_PAYLD_DTLB_MISS_NAME "tl_at_payld_devtlb_miss" 27 + #define RP_SERVICE_TYPE "service_type" 28 + 29 + #define ADF_TL_DBG_RP_ALPHA_INDEX(index) ((index) + 'A') 30 + #define ADF_TL_DBG_RP_INDEX_ALPHA(alpha) ((alpha) - 'A') 31 + 32 + #define ADF_TL_RP_REGS_FNAME "rp_%c_data" 33 + #define ADF_TL_RP_REGS_FNAME_SIZE 16 27 34 28 35 #define ADF_TL_DATA_REG_OFF(reg, qat_gen) \ 29 36 offsetof(struct adf_##qat_gen##_tl_layout, reg) ··· 42 35 #define ADF_TL_SLICE_REG_OFF(slice, reg, qat_gen) \ 43 36 (ADF_TL_DEV_REG_OFF(slice##_slices[0], qat_gen) + \ 44 37 offsetof(struct adf_##qat_gen##_tl_slice_data_regs, reg)) 38 + 39 + #define ADF_TL_RP_REG_OFF(reg, qat_gen) \ 40 + (ADF_TL_DATA_REG_OFF(tl_ring_pairs_data_regs[0], qat_gen) + \ 41 + offsetof(struct adf_##qat_gen##_tl_ring_pair_data_regs, reg)) 45 42 46 43 /** 47 44 * enum adf_tl_counter_type - telemetry counter types