brintos

brintos / linux-shallow public Read only

0
0
Text · 2.3 KiB · 16fdfb4 Raw
101 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/* Copyright(c) 2023 Intel Corporation */3 4#ifndef ADF_HEARTBEAT_H_5#define ADF_HEARTBEAT_H_6 7#include <linux/types.h>8 9struct adf_accel_dev;10struct dentry;11 12#define ADF_CFG_HB_TIMER_MIN_MS 20013#define ADF_CFG_HB_TIMER_DEFAULT_MS 50014#define ADF_CFG_HB_COUNT_THRESHOLD 315 16#define ADF_CFG_HB_RESET_MS 500017 18enum adf_device_heartbeat_status {19	HB_DEV_UNRESPONSIVE = 0,20	HB_DEV_ALIVE,21	HB_DEV_UNSUPPORTED,22};23 24/* Heartbeat counter pair */25struct hb_cnt_pair {26	__u16 resp_heartbeat_cnt;27	__u16 req_heartbeat_cnt;28};29 30struct adf_heartbeat {31	unsigned int hb_sent_counter;32	unsigned int hb_failed_counter;33	unsigned int hb_timer;34	u64 last_hb_check_time;35	u64 last_hb_reset_time;36	bool ctrs_cnt_checked;37	struct hb_dma_addr {38		dma_addr_t phy_addr;39		void *virt_addr;40	} dma;41	struct {42		struct dentry *base_dir;43		struct dentry *status;44		struct dentry *cfg;45		struct dentry *sent;46		struct dentry *failed;47#ifdef CONFIG_CRYPTO_DEV_QAT_ERROR_INJECTION48		struct dentry *inject_error;49#endif50	} dbgfs;51};52 53#ifdef CONFIG_DEBUG_FS54int adf_heartbeat_init(struct adf_accel_dev *accel_dev);55int adf_heartbeat_start(struct adf_accel_dev *accel_dev);56void adf_heartbeat_shutdown(struct adf_accel_dev *accel_dev);57 58int adf_heartbeat_ms_to_ticks(struct adf_accel_dev *accel_dev, unsigned int time_ms,59			      uint32_t *value);60int adf_heartbeat_save_cfg_param(struct adf_accel_dev *accel_dev,61				 unsigned int timer_ms);62void adf_heartbeat_status(struct adf_accel_dev *accel_dev,63			  enum adf_device_heartbeat_status *hb_status);64void adf_heartbeat_check_ctrs(struct adf_accel_dev *accel_dev);65 66#ifdef CONFIG_CRYPTO_DEV_QAT_ERROR_INJECTION67int adf_heartbeat_inject_error(struct adf_accel_dev *accel_dev);68#else69static inline int adf_heartbeat_inject_error(struct adf_accel_dev *accel_dev)70{71	return -EPERM;72}73#endif74 75#else76static inline int adf_heartbeat_init(struct adf_accel_dev *accel_dev)77{78	return 0;79}80 81static inline int adf_heartbeat_start(struct adf_accel_dev *accel_dev)82{83	return 0;84}85 86static inline void adf_heartbeat_shutdown(struct adf_accel_dev *accel_dev)87{88}89 90static inline int adf_heartbeat_save_cfg_param(struct adf_accel_dev *accel_dev,91					       unsigned int timer_ms)92{93	return 0;94}95 96static inline void adf_heartbeat_check_ctrs(struct adf_accel_dev *accel_dev)97{98}99#endif100#endif /* ADF_HEARTBEAT_H_ */101