xref: /wlan-driver/qcacld-3.0/core/hdd/inc/wlan_hdd_debugfs.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2013-2018, 2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _WLAN_HDD_DEBUGFS_H
20 #define _WLAN_HDD_DEBUGFS_H
21 
22 #ifdef WLAN_DEBUGFS
23 
24 #define HDD_DEBUGFS_FILE_NAME_MAX 24
25 
26 /**
27  * enum hdd_debugfs_file_id - Debugfs file Identifier
28  * @HDD_DEBUFS_FILE_ID_ROAM_SCAN_STATS_INFO: roam_scan_stats file id
29  * @HDD_DEBUFS_FILE_ID_OFFLOAD_INFO: offload_info file id
30  * @HDD_DEBUGFS_FILE_ID_MAX: maximum id of csr debugfs file
31  */
32 enum hdd_debugfs_file_id {
33 	HDD_DEBUFS_FILE_ID_ROAM_SCAN_STATS_INFO = 0,
34 	HDD_DEBUFS_FILE_ID_OFFLOAD_INFO = 1,
35 
36 	HDD_DEBUGFS_FILE_ID_MAX,
37 };
38 
39 /**
40  * struct hdd_debugfs_file_info - Debugfs file info
41  * @name: name of debugfs file
42  * @id: id from enum hdd_debugfs_file_id used to identify file
43  * @buf_max_size: max size of buffer from which debugfs file is updated
44  * @entry: dentry pointer to debugfs file
45  */
46 struct hdd_debugfs_file_info {
47 	uint8_t name[HDD_DEBUGFS_FILE_NAME_MAX];
48 	enum hdd_debugfs_file_id id;
49 	ssize_t buf_max_size;
50 	struct dentry *entry;
51 };
52 
53 QDF_STATUS hdd_debugfs_init(struct hdd_adapter *adapter);
54 void hdd_debugfs_exit(struct hdd_adapter *adapter);
55 
56 /**
57  * hdd_wait_for_debugfs_threads_completion() - Wait for debugfs threads
58  * completion before proceeding further to stop modules
59  *
60  * Return: true if there is no debugfs open
61  *         false if there is at least one debugfs open
62  */
63 bool hdd_wait_for_debugfs_threads_completion(void);
64 
65 /**
66  * hdd_return_debugfs_threads_count() - Return active debugfs threads
67  *
68  * Return: total number of active debugfs threads in driver
69  */
70 int hdd_return_debugfs_threads_count(void);
71 
72 /**
73  * hdd_debugfs_thread_increment() - Increment debugfs thread count
74  *
75  * This function is used to increment and keep track of debugfs thread count.
76  * This is invoked for every file open operation.
77  *
78  * Return: None
79  */
80 void hdd_debugfs_thread_increment(void);
81 
82 /**
83  * hdd_debugfs_thread_decrement() - Decrement debugfs thread count
84  *
85  * This function is used to decrement and keep track of debugfs thread count.
86  * This is invoked for every file release operation.
87  *
88  * Return: None
89  */
90 void hdd_debugfs_thread_decrement(void);
91 
92 #else
hdd_debugfs_init(struct hdd_adapter * adapter)93 static inline QDF_STATUS hdd_debugfs_init(struct hdd_adapter *adapter)
94 {
95 	return QDF_STATUS_SUCCESS;
96 }
97 
hdd_debugfs_exit(struct hdd_adapter * adapter)98 static inline void hdd_debugfs_exit(struct hdd_adapter *adapter)
99 {
100 }
101 
102 /**
103  * hdd_wait_for_debugfs_threads_completion() - Wait for debugfs threads
104  * completion before proceeding further to stop modules
105  *
106  * Return: true if there is no debugfs open
107  *         false if there is at least one debugfs open
108  */
109 static inline
hdd_wait_for_debugfs_threads_completion(void)110 bool hdd_wait_for_debugfs_threads_completion(void)
111 {
112 	return true;
113 }
114 
115 /**
116  * hdd_return_debugfs_threads_count() - Return active debugfs threads
117  *
118  * Return: total number of active debugfs threads in driver
119  */
120 static inline
hdd_return_debugfs_threads_count(void)121 int hdd_return_debugfs_threads_count(void)
122 {
123 	return 0;
124 }
125 
126 /**
127  * hdd_debugfs_thread_increment() - Increment debugfs thread count
128  *
129  * This function is used to increment and keep track of debugfs thread count.
130  * This is invoked for every file open operation.
131  *
132  * Return: None
133  */
134 static inline
hdd_debugfs_thread_increment(void)135 void hdd_debugfs_thread_increment(void)
136 {
137 }
138 
139 /**
140  * hdd_debugfs_thread_decrement() - Decrement debugfs thread count
141  *
142  * This function is used to decrement and keep track of debugfs thread count.
143  * This is invoked for every file release operation.
144  *
145  * Return: None
146  */
147 static inline
hdd_debugfs_thread_decrement(void)148 void hdd_debugfs_thread_decrement(void)
149 {
150 }
151 
152 #endif /* #ifdef WLAN_DEBUGFS */
153 #endif /* #ifndef _WLAN_HDD_DEBUGFS_H */
154