|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
| 2 | +/* Copyright (c) 2023 Intel Corporation. */ |
| 3 | +#include <linux/export.h> |
| 4 | +#include <linux/kernel.h> |
| 5 | + |
| 6 | +#include "adf_gen4_tl.h" |
| 7 | +#include "adf_telemetry.h" |
| 8 | +#include "adf_tl_debugfs.h" |
| 9 | + |
| 10 | +#define ADF_GEN4_TL_DEV_REG_OFF(reg) ADF_TL_DEV_REG_OFF(reg, gen4) |
| 11 | + |
| 12 | +#define ADF_GEN4_TL_SL_UTIL_COUNTER(_name) \ |
| 13 | + ADF_TL_COUNTER("util_" #_name, \ |
| 14 | + ADF_TL_SIMPLE_COUNT, \ |
| 15 | + ADF_TL_SLICE_REG_OFF(_name, reg_tm_slice_util, gen4)) |
| 16 | + |
| 17 | +#define ADF_GEN4_TL_SL_EXEC_COUNTER(_name) \ |
| 18 | + ADF_TL_COUNTER("exec_" #_name, \ |
| 19 | + ADF_TL_SIMPLE_COUNT, \ |
| 20 | + ADF_TL_SLICE_REG_OFF(_name, reg_tm_slice_exec_cnt, gen4)) |
| 21 | + |
| 22 | +/* Device level counters. */ |
| 23 | +static const struct adf_tl_dbg_counter dev_counters[] = { |
| 24 | + /* PCIe partial transactions. */ |
| 25 | + ADF_TL_COUNTER(PCI_TRANS_CNT_NAME, ADF_TL_SIMPLE_COUNT, |
| 26 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_pci_trans_cnt)), |
| 27 | + /* Max read latency[ns]. */ |
| 28 | + ADF_TL_COUNTER(MAX_RD_LAT_NAME, ADF_TL_COUNTER_NS, |
| 29 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_rd_lat_max)), |
| 30 | + /* Read latency average[ns]. */ |
| 31 | + ADF_TL_COUNTER_LATENCY(RD_LAT_ACC_NAME, ADF_TL_COUNTER_NS_AVG, |
| 32 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_rd_lat_acc), |
| 33 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_rd_cmpl_cnt)), |
| 34 | + /* Max get to put latency[ns]. */ |
| 35 | + ADF_TL_COUNTER(MAX_LAT_NAME, ADF_TL_COUNTER_NS, |
| 36 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_gp_lat_max)), |
| 37 | + /* Get to put latency average[ns]. */ |
| 38 | + ADF_TL_COUNTER_LATENCY(LAT_ACC_NAME, ADF_TL_COUNTER_NS_AVG, |
| 39 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_gp_lat_acc), |
| 40 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_ae_put_cnt)), |
| 41 | + /* PCIe write bandwidth[Mbps]. */ |
| 42 | + ADF_TL_COUNTER(BW_IN_NAME, ADF_TL_COUNTER_MBPS, |
| 43 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_bw_in)), |
| 44 | + /* PCIe read bandwidth[Mbps]. */ |
| 45 | + ADF_TL_COUNTER(BW_OUT_NAME, ADF_TL_COUNTER_MBPS, |
| 46 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_bw_out)), |
| 47 | + /* Page request latency average[ns]. */ |
| 48 | + ADF_TL_COUNTER_LATENCY(PAGE_REQ_LAT_NAME, ADF_TL_COUNTER_NS_AVG, |
| 49 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_at_page_req_lat_acc), |
| 50 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_at_page_req_cnt)), |
| 51 | + /* Page translation latency average[ns]. */ |
| 52 | + ADF_TL_COUNTER_LATENCY(AT_TRANS_LAT_NAME, ADF_TL_COUNTER_NS_AVG, |
| 53 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_at_trans_lat_acc), |
| 54 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_at_trans_lat_cnt)), |
| 55 | + /* Maximum uTLB used. */ |
| 56 | + ADF_TL_COUNTER(AT_MAX_UTLB_USED_NAME, ADF_TL_SIMPLE_COUNT, |
| 57 | + ADF_GEN4_TL_DEV_REG_OFF(reg_tl_at_max_tlb_used)), |
| 58 | +}; |
| 59 | + |
| 60 | +/* Slice utilization counters. */ |
| 61 | +static const struct adf_tl_dbg_counter sl_util_counters[ADF_TL_SL_CNT_COUNT] = { |
| 62 | + /* Compression slice utilization. */ |
| 63 | + ADF_GEN4_TL_SL_UTIL_COUNTER(cpr), |
| 64 | + /* Translator slice utilization. */ |
| 65 | + ADF_GEN4_TL_SL_UTIL_COUNTER(xlt), |
| 66 | + /* Decompression slice utilization. */ |
| 67 | + ADF_GEN4_TL_SL_UTIL_COUNTER(dcpr), |
| 68 | + /* PKE utilization. */ |
| 69 | + ADF_GEN4_TL_SL_UTIL_COUNTER(pke), |
| 70 | + /* Wireless Authentication slice utilization. */ |
| 71 | + ADF_GEN4_TL_SL_UTIL_COUNTER(wat), |
| 72 | + /* Wireless Cipher slice utilization. */ |
| 73 | + ADF_GEN4_TL_SL_UTIL_COUNTER(wcp), |
| 74 | + /* UCS slice utilization. */ |
| 75 | + ADF_GEN4_TL_SL_UTIL_COUNTER(ucs), |
| 76 | + /* Cipher slice utilization. */ |
| 77 | + ADF_GEN4_TL_SL_UTIL_COUNTER(cph), |
| 78 | + /* Authentication slice utilization. */ |
| 79 | + ADF_GEN4_TL_SL_UTIL_COUNTER(ath), |
| 80 | +}; |
| 81 | + |
| 82 | +/* Slice execution counters. */ |
| 83 | +static const struct adf_tl_dbg_counter sl_exec_counters[ADF_TL_SL_CNT_COUNT] = { |
| 84 | + /* Compression slice execution count. */ |
| 85 | + ADF_GEN4_TL_SL_EXEC_COUNTER(cpr), |
| 86 | + /* Translator slice execution count. */ |
| 87 | + ADF_GEN4_TL_SL_EXEC_COUNTER(xlt), |
| 88 | + /* Decompression slice execution count. */ |
| 89 | + ADF_GEN4_TL_SL_EXEC_COUNTER(dcpr), |
| 90 | + /* PKE execution count. */ |
| 91 | + ADF_GEN4_TL_SL_EXEC_COUNTER(pke), |
| 92 | + /* Wireless Authentication slice execution count. */ |
| 93 | + ADF_GEN4_TL_SL_EXEC_COUNTER(wat), |
| 94 | + /* Wireless Cipher slice execution count. */ |
| 95 | + ADF_GEN4_TL_SL_EXEC_COUNTER(wcp), |
| 96 | + /* UCS slice execution count. */ |
| 97 | + ADF_GEN4_TL_SL_EXEC_COUNTER(ucs), |
| 98 | + /* Cipher slice execution count. */ |
| 99 | + ADF_GEN4_TL_SL_EXEC_COUNTER(cph), |
| 100 | + /* Authentication slice execution count. */ |
| 101 | + ADF_GEN4_TL_SL_EXEC_COUNTER(ath), |
| 102 | +}; |
| 103 | + |
| 104 | +void adf_gen4_init_tl_data(struct adf_tl_hw_data *tl_data) |
| 105 | +{ |
| 106 | + tl_data->layout_sz = ADF_GEN4_TL_LAYOUT_SZ; |
| 107 | + tl_data->slice_reg_sz = ADF_GEN4_TL_SLICE_REG_SZ; |
| 108 | + tl_data->num_hbuff = ADF_GEN4_TL_NUM_HIST_BUFFS; |
| 109 | + tl_data->msg_cnt_off = ADF_GEN4_TL_MSG_CNT_OFF; |
| 110 | + tl_data->cpp_ns_per_cycle = ADF_GEN4_CPP_NS_PER_CYCLE; |
| 111 | + tl_data->bw_units_to_bytes = ADF_GEN4_TL_BW_HW_UNITS_TO_BYTES; |
| 112 | + |
| 113 | + tl_data->dev_counters = dev_counters; |
| 114 | + tl_data->num_dev_counters = ARRAY_SIZE(dev_counters); |
| 115 | + tl_data->sl_util_counters = sl_util_counters; |
| 116 | + tl_data->sl_exec_counters = sl_exec_counters; |
| 117 | +} |
| 118 | +EXPORT_SYMBOL_GPL(adf_gen4_init_tl_data); |
0 commit comments