1022f324cSLucas De Marchi /* SPDX-License-Identifier: MIT */ 2022f324cSLucas De Marchi /* 3022f324cSLucas De Marchi * Copyright © 2019 Intel Corporation 4022f324cSLucas De Marchi */ 5022f324cSLucas De Marchi 6022f324cSLucas De Marchi #ifndef INTEL_GT_DEBUGFS_H 7022f324cSLucas De Marchi #define INTEL_GT_DEBUGFS_H 8022f324cSLucas De Marchi 9022f324cSLucas De Marchi #include <linux/file.h> 10022f324cSLucas De Marchi 11022f324cSLucas De Marchi struct intel_gt; 12022f324cSLucas De Marchi 1357b427a7SJohn Harrison #define __GT_DEBUGFS_ATTRIBUTE_FOPS(__name) \ 14022f324cSLucas De Marchi static const struct file_operations __name ## _fops = { \ 15022f324cSLucas De Marchi .owner = THIS_MODULE, \ 16022f324cSLucas De Marchi .open = __name ## _open, \ 17022f324cSLucas De Marchi .read = seq_read, \ 18022f324cSLucas De Marchi .llseek = seq_lseek, \ 19022f324cSLucas De Marchi .release = single_release, \ 20022f324cSLucas De Marchi } 21022f324cSLucas De Marchi 2257b427a7SJohn Harrison #define DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(__name) \ 2357b427a7SJohn Harrison static int __name ## _open(struct inode *inode, struct file *file) \ 2457b427a7SJohn Harrison { \ 2557b427a7SJohn Harrison return single_open(file, __name ## _show, inode->i_private); \ 2657b427a7SJohn Harrison } \ 2757b427a7SJohn Harrison __GT_DEBUGFS_ATTRIBUTE_FOPS(__name) 2857b427a7SJohn Harrison 2957b427a7SJohn Harrison #define DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE_WITH_SIZE(__name, __size_vf) \ 3057b427a7SJohn Harrison static int __name ## _open(struct inode *inode, struct file *file) \ 3157b427a7SJohn Harrison { \ 3257b427a7SJohn Harrison return single_open_size(file, __name ## _show, inode->i_private, \ 3357b427a7SJohn Harrison __size_vf(inode->i_private)); \ 3457b427a7SJohn Harrison } \ 3557b427a7SJohn Harrison __GT_DEBUGFS_ATTRIBUTE_FOPS(__name) 3657b427a7SJohn Harrison 37022f324cSLucas De Marchi void intel_gt_debugfs_register(struct intel_gt *gt); 38022f324cSLucas De Marchi 39022f324cSLucas De Marchi struct intel_gt_debugfs_file { 40022f324cSLucas De Marchi const char *name; 41022f324cSLucas De Marchi const struct file_operations *fops; 42022f324cSLucas De Marchi bool (*eval)(void *data); 43022f324cSLucas De Marchi }; 44022f324cSLucas De Marchi 45022f324cSLucas De Marchi void intel_gt_debugfs_register_files(struct dentry *root, 46022f324cSLucas De Marchi const struct intel_gt_debugfs_file *files, 47022f324cSLucas De Marchi unsigned long count, void *data); 48022f324cSLucas De Marchi 4982a149a6SAndi Shyti /* functions that need to be accessed by the upper level non-gt interfaces */ 5082a149a6SAndi Shyti int intel_gt_debugfs_reset_show(struct intel_gt *gt, u64 *val); 51*7d14db8bSAndi Shyti void intel_gt_debugfs_reset_store(struct intel_gt *gt, u64 val); 5282a149a6SAndi Shyti 53022f324cSLucas De Marchi #endif /* INTEL_GT_DEBUGFS_H */ 54