1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* Copyright (c) 2023 Intel Corporation. */ 3 #ifndef ADF_TL_DEBUGFS_H 4 #define ADF_TL_DEBUGFS_H 5 6 #include <linux/types.h> 7 8 struct adf_accel_dev; 9 10 #define MAX_COUNT_NAME_SIZE 32 11 #define SNAPSHOT_CNT_MSG "sample_cnt" 12 #define RP_NUM_INDEX "rp_num" 13 #define PCI_TRANS_CNT_NAME "pci_trans_cnt" 14 #define MAX_RD_LAT_NAME "max_rd_lat" 15 #define RD_LAT_ACC_NAME "rd_lat_acc_avg" 16 #define MAX_LAT_NAME "max_gp_lat" 17 #define LAT_ACC_NAME "gp_lat_acc_avg" 18 #define BW_IN_NAME "bw_in" 19 #define BW_OUT_NAME "bw_out" 20 #define RE_ACC_NAME "re_acc_avg" 21 #define PAGE_REQ_LAT_NAME "at_page_req_lat_avg" 22 #define AT_TRANS_LAT_NAME "at_trans_lat_avg" 23 #define AT_MAX_UTLB_USED_NAME "at_max_tlb_used" 24 #define AT_GLOB_DTLB_HIT_NAME "at_glob_devtlb_hit" 25 #define AT_GLOB_DTLB_MISS_NAME "at_glob_devtlb_miss" 26 #define AT_PAYLD_DTLB_HIT_NAME "tl_at_payld_devtlb_hit" 27 #define AT_PAYLD_DTLB_MISS_NAME "tl_at_payld_devtlb_miss" 28 #define RP_SERVICE_TYPE "service_type" 29 30 #define ADF_TL_DBG_RP_ALPHA_INDEX(index) ((index) + 'A') 31 #define ADF_TL_DBG_RP_INDEX_ALPHA(alpha) ((alpha) - 'A') 32 33 #define ADF_TL_RP_REGS_FNAME "rp_%c_data" 34 #define ADF_TL_RP_REGS_FNAME_SIZE 16 35 36 #define ADF_TL_DATA_REG_OFF(reg, qat_gen) \ 37 offsetof(struct adf_##qat_gen##_tl_layout, reg) 38 39 #define ADF_TL_DEV_REG_OFF(reg, qat_gen) \ 40 (ADF_TL_DATA_REG_OFF(tl_device_data_regs, qat_gen) + \ 41 offsetof(struct adf_##qat_gen##_tl_device_data_regs, reg)) 42 43 #define ADF_TL_SLICE_REG_OFF(slice, reg, qat_gen) \ 44 (ADF_TL_DEV_REG_OFF(slice##_slices[0], qat_gen) + \ 45 offsetof(struct adf_##qat_gen##_tl_slice_data_regs, reg)) 46 47 #define ADF_TL_CMDQ_REG_OFF(slice, reg, qat_gen) \ 48 (ADF_TL_DEV_REG_OFF(slice##_cmdq[0], qat_gen) + \ 49 offsetof(struct adf_##qat_gen##_tl_cmdq_data_regs, reg)) 50 51 #define ADF_TL_RP_REG_OFF(reg, qat_gen) \ 52 (ADF_TL_DATA_REG_OFF(tl_ring_pairs_data_regs[0], qat_gen) + \ 53 offsetof(struct adf_##qat_gen##_tl_ring_pair_data_regs, reg)) 54 55 /** 56 * enum adf_tl_counter_type - telemetry counter types 57 * @ADF_TL_COUNTER_UNSUPPORTED: unsupported counter 58 * @ADF_TL_SIMPLE_COUNT: simple counter 59 * @ADF_TL_COUNTER_NS: latency counter, value in ns 60 * @ADF_TL_COUNTER_NS_AVG: accumulated average latency counter, value in ns 61 * @ADF_TL_COUNTER_MBPS: bandwidth, value in MBps 62 */ 63 enum adf_tl_counter_type { 64 ADF_TL_COUNTER_UNSUPPORTED, 65 ADF_TL_SIMPLE_COUNT, 66 ADF_TL_COUNTER_NS, 67 ADF_TL_COUNTER_NS_AVG, 68 ADF_TL_COUNTER_MBPS, 69 }; 70 71 /** 72 * struct adf_tl_dbg_counter - telemetry counter definition 73 * @name: name of the counter as printed in the report 74 * @adf_tl_counter_type: type of the counter 75 * @offset1: offset of 1st register 76 * @offset2: offset of 2nd optional register 77 */ 78 struct adf_tl_dbg_counter { 79 const char *name; 80 enum adf_tl_counter_type type; 81 size_t offset1; 82 size_t offset2; 83 }; 84 85 #define ADF_TL_COUNTER(_name, _type, _offset) \ 86 { .name = _name, \ 87 .type = _type, \ 88 .offset1 = _offset \ 89 } 90 91 #define ADF_TL_COUNTER_LATENCY(_name, _type, _offset1, _offset2) \ 92 { .name = _name, \ 93 .type = _type, \ 94 .offset1 = _offset1, \ 95 .offset2 = _offset2 \ 96 } 97 98 /* Telemetry counter aggregated values. */ 99 struct adf_tl_dbg_aggr_values { 100 u64 curr; 101 u64 min; 102 u64 max; 103 u64 avg; 104 }; 105 106 /** 107 * adf_tl_dbgfs_add() - Add telemetry's debug fs entries. 108 * @accel_dev: Pointer to acceleration device. 109 * 110 * Creates telemetry's debug fs folder and attributes in QAT debug fs root. 111 */ 112 void adf_tl_dbgfs_add(struct adf_accel_dev *accel_dev); 113 114 /** 115 * adf_tl_dbgfs_rm() - Remove telemetry's debug fs entries. 116 * @accel_dev: Pointer to acceleration device. 117 * 118 * Removes telemetry's debug fs folder and attributes from QAT debug fs root. 119 */ 120 void adf_tl_dbgfs_rm(struct adf_accel_dev *accel_dev); 121 122 #endif /* ADF_TL_DEBUGFS_H */ 123