1 /*
2 * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for
6 * any purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 /**
21 * DOC: wlan_hdd_debugfs_csr.h
22 *
23 * WLAN Host Device Driver implementation to update
24 * debugfs with connect, scan and roam information
25 */
26
27 #ifndef _WLAN_HDD_DEBUGFS_CSR_H
28 #define _WLAN_HDD_DEBUGFS_CSR_H
29
30 #include <wlan_hdd_includes.h>
31
32 #ifdef WLAN_DEBUGFS
33
34 #define DEBUGFS_OFFLOAD_INFO_BUF_SIZE (4 * 1024)
35 #define DEBUGFS_ROAM_SCAN_STATS_INFO_BUF_SIZE (4 * 1024)
36
37 /**
38 * struct wlan_hdd_debugfs_buffer_info - Debugfs buffer info
39 * @length: current length of the debugfs buffer
40 * @max_buf_len: maximum buffer length of the debugfs buffer
41 * @id: id from enum hdd_debugfs_file_id used to identify file
42 * @data: start of debugfs buffer from which file read starts
43 * @adapter: pointer to adapter
44 *
45 * This structure is used to hold the debugfs buffer details and is stored in
46 * private data of file argument in file open operation.
47 */
48 struct wlan_hdd_debugfs_buffer_info {
49 ssize_t length;
50 ssize_t max_buf_len;
51 enum hdd_debugfs_file_id id;
52 uint8_t *data;
53 struct hdd_adapter *adapter;
54 };
55
56 /**
57 * struct hdd_roam_scan_stats_debugfs_priv - private data for request mgr
58 * @roam_scan_stats_res: pointer to roam scan stats response
59 */
60 struct hdd_roam_scan_stats_debugfs_priv {
61 struct wmi_roam_scan_stats_res *roam_scan_stats_res;
62 };
63
64 /**
65 * wlan_hdd_debugfs_csr_init() - Create wifi diagnostic debugfs files
66 * @adapter: pointer to adapter for which debugfs files are to be created
67 *
68 * Return: None
69 */
70 void wlan_hdd_debugfs_csr_init(struct hdd_adapter *adapter);
71
72 /**
73 * wlan_hdd_debugfs_csr_deinit() - Remove wifi diagnostic debugfs files
74 * @adapter: pointer to adapter for which debugfs files are to be removed
75 *
76 * Return: None
77 */
78 void wlan_hdd_debugfs_csr_deinit(struct hdd_adapter *adapter);
79
80 /**
81 * wlan_hdd_current_time_info_debugfs() - API to get time into user buffer
82 * @buf: output buffer to hold current time when queried
83 * @buf_avail_len: available buffer length
84 *
85 * Return: No.of bytes copied
86 */
87 ssize_t
88 wlan_hdd_current_time_info_debugfs(uint8_t *buf, ssize_t buf_avail_len);
89
90 /**
91 * wlan_hdd_debugfs_update_filters_info() - API to get offload info
92 * into user buffer
93 * @hdd_ctx: Pointer to hdd context
94 * @adapter: pointer to the adapter targeted by the debugfs operation
95 * @buf: output buffer to hold offload info
96 * @buf_avail_len: available buffer length
97 *
98 * Return: No.of bytes copied
99 */
100 ssize_t
101 wlan_hdd_debugfs_update_filters_info(struct hdd_context *hdd_ctx,
102 struct hdd_adapter *adapter,
103 uint8_t *buf, ssize_t buf_avail_len);
104
105 /**
106 * wlan_hdd_debugfs_update_roam_stats() - API to get roam scan stats info
107 * into user buffer
108 * @hdd_ctx: Pointer to hdd context
109 * @adapter: pointer to the adapter targeted by the debugfs operation
110 * @buf: output buffer to hold roam scan stats info
111 * @buf_avail_len: available buffer length
112 *
113 * Return: No.of bytes copied
114 */
115 ssize_t
116 wlan_hdd_debugfs_update_roam_stats(struct hdd_context *hdd_ctx,
117 struct hdd_adapter *adapter,
118 uint8_t *buf, ssize_t buf_avail_len);
119
120 #else
121
wlan_hdd_debugfs_csr_init(struct hdd_adapter * adapter)122 static inline void wlan_hdd_debugfs_csr_init(struct hdd_adapter *adapter)
123 {
124 }
125
wlan_hdd_debugfs_csr_deinit(struct hdd_adapter * adapter)126 static inline void wlan_hdd_debugfs_csr_deinit(struct hdd_adapter *adapter)
127 {
128 }
129
130 static inline ssize_t
wlan_hdd_current_time_info_debugfs(uint8_t * buf,ssize_t buf_avail_len)131 wlan_hdd_current_time_info_debugfs(uint8_t *buf, ssize_t buf_avail_len)
132 {
133 return 0;
134 }
135
136 static inline ssize_t
wlan_hdd_debugfs_update_filters_info(struct hdd_context * hdd_ctx,struct hdd_adapter * adapter,uint8_t * buf,ssize_t buf_avail_len)137 wlan_hdd_debugfs_update_filters_info(struct hdd_context *hdd_ctx,
138 struct hdd_adapter *adapter,
139 uint8_t *buf, ssize_t buf_avail_len)
140 {
141 return 0;
142 }
143
144 static inline ssize_t
wlan_hdd_debugfs_update_roam_stats(struct hdd_context * hdd_ctx,struct hdd_adapter * adapter,uint8_t * buf,ssize_t buf_avail_len)145 wlan_hdd_debugfs_update_roam_stats(struct hdd_context *hdd_ctx,
146 struct hdd_adapter *adapter,
147 uint8_t *buf, ssize_t buf_avail_len)
148 {
149 return 0;
150 }
151
152 #endif
153
154 #endif /* _WLAN_HDD_DEBUGFS_CSR_H */
155