1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2023 Intel Corporation. */
3 #ifndef ADF_TELEMETRY_H
4 #define ADF_TELEMETRY_H
6 #include <linux/bits.h>
7 #include <linux/mutex.h>
8 #include <linux/types.h>
9 #include <linux/workqueue.h>
11 #include "icp_qat_fw_init_admin.h"
14 struct adf_tl_dbg_counter;
17 #define ADF_TL_SL_CNT_COUNT \
18 (sizeof(struct icp_qat_fw_init_admin_slice_cnt) / sizeof(__u8))
20 #define TL_CAPABILITY_BIT BIT(1)
21 /* Interval within device writes data to DMA region. Value in milliseconds. */
22 #define ADF_TL_DATA_WR_INTERVAL_MS 1000
23 /* Interval within timer interrupt should be handled. Value in milliseconds. */
24 #define ADF_TL_TIMER_INT_MS (ADF_TL_DATA_WR_INTERVAL_MS / 2)
26 #define ADF_TL_RP_REGS_DISABLED (0xff)
28 struct adf_tl_hw_data {
33 const struct adf_tl_dbg_counter *dev_counters;
34 const struct adf_tl_dbg_counter *sl_util_counters;
35 const struct adf_tl_dbg_counter *sl_exec_counters;
36 const struct adf_tl_dbg_counter *rp_counters;
45 struct adf_telemetry {
46 struct adf_accel_dev *accel_dev;
51 dma_addr_t regs_data_p; /* bus address for DMA mapping */
52 void *regs_data; /* virtual address for DMA mapping */
54 * @regs_hist_buff: array of pointers to copies of the last @hbuffs
55 * values of @regs_data
57 void **regs_hist_buff;
58 struct dentry *dbg_dir;
61 * @regs_hist_lock: protects from race conditions between write and read
62 * to the copies referenced by @regs_hist_buff
64 struct mutex regs_hist_lock;
66 * @wr_lock: protects from concurrent writes to debugfs telemetry files
69 struct delayed_work work_ctx;
70 struct icp_qat_fw_init_admin_slice_cnt slice_cnt;
73 #ifdef CONFIG_DEBUG_FS
74 int adf_tl_init(struct adf_accel_dev *accel_dev);
75 int adf_tl_start(struct adf_accel_dev *accel_dev);
76 void adf_tl_stop(struct adf_accel_dev *accel_dev);
77 void adf_tl_shutdown(struct adf_accel_dev *accel_dev);
78 int adf_tl_run(struct adf_accel_dev *accel_dev, int state);
79 int adf_tl_halt(struct adf_accel_dev *accel_dev);
81 static inline int adf_tl_init(struct adf_accel_dev *accel_dev)
86 static inline int adf_tl_start(struct adf_accel_dev *accel_dev)
91 static inline void adf_tl_stop(struct adf_accel_dev *accel_dev)
95 static inline void adf_tl_shutdown(struct adf_accel_dev *accel_dev)
98 #endif /* CONFIG_DEBUG_FS */
99 #endif /* ADF_TELEMETRY_H */