1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2024 Intel Corporation 4 */ 5 6 #ifndef _XE_GT_STATS_H_ 7 #define _XE_GT_STATS_H_ 8 9 #include <linux/ktime.h> 10 11 #include "xe_gt_stats_types.h" 12 13 struct xe_gt; 14 struct drm_printer; 15 16 #ifdef CONFIG_DEBUG_FS 17 int xe_gt_stats_init(struct xe_gt *gt); 18 int xe_gt_stats_print_info(struct xe_gt *gt, struct drm_printer *p); 19 void xe_gt_stats_clear(struct xe_gt *gt); 20 void xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, int incr); 21 #else 22 static inline int xe_gt_stats_init(struct xe_gt *gt) 23 { 24 return 0; 25 } 26 27 static inline void 28 xe_gt_stats_incr(struct xe_gt *gt, const enum xe_gt_stats_id id, 29 int incr) 30 { 31 } 32 33 #endif 34 35 /** 36 * xe_gt_stats_ktime_us_delta() - Get delta in microseconds between now and a 37 * start time 38 * @start: Start time 39 * 40 * Helper for GT stats to get delta in microseconds between now and a start 41 * time, compiles out if GT stats are disabled. 42 * 43 * Return: Delta in microseconds between now and a start time 44 */ 45 static inline s64 xe_gt_stats_ktime_us_delta(ktime_t start) 46 { 47 return IS_ENABLED(CONFIG_DEBUG_FS) ? 48 ktime_us_delta(ktime_get(), start) : 0; 49 } 50 51 /** 52 * xe_gt_stats_ktime_get() - Get current ktime 53 * 54 * Helper for GT stats to get current ktime, compiles out if GT stats are 55 * disabled. 56 * 57 * Return: Get current ktime 58 */ 59 static inline ktime_t xe_gt_stats_ktime_get(void) 60 { 61 return IS_ENABLED(CONFIG_DEBUG_FS) ? ktime_get() : 0; 62 } 63 64 #endif 65