1 /*
2 * Copyright (c) 2018-2019 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 #include "fw_dbglog_api.h"
20 #include "fw_dbglog_priv.h"
21
handle2info(struct common_dbglog_handle * dbg_handle)22 static inline struct dbglog_info *handle2info(
23 struct common_dbglog_handle *dbg_handle)
24 {
25 return (struct dbglog_info *)dbg_handle;
26 }
27
fwdbg_set_log_lvl(struct common_dbglog_handle * dbg_handle,ol_scn_t scn,uint32_t log_lvl)28 void fwdbg_set_log_lvl(struct common_dbglog_handle *dbg_handle, ol_scn_t scn,
29 uint32_t log_lvl)
30 {
31 struct dbglog_info *dbg_info = handle2info(dbg_handle);
32
33 if (dbg_info->ops->dbglog_set_log_lvl)
34 dbg_info->ops->dbglog_set_log_lvl(scn, log_lvl);
35
36 }
37
fwdbg_fw_handler(struct common_dbglog_handle * dbg_handle,ol_scn_t soc,uint8_t * data,uint32_t datalen)38 int fwdbg_fw_handler(struct common_dbglog_handle *dbg_handle, ol_scn_t soc,
39 uint8_t *data, uint32_t datalen)
40 {
41 struct dbglog_info *dbg_info = handle2info(dbg_handle);
42
43 if (dbg_info->ops->dbglog_fw_handler)
44 return dbg_info->ops->dbglog_fw_handler(soc, data, datalen);
45
46 return 0;
47 }
48
fwdbg_parse_debug_logs(struct common_dbglog_handle * dbg_handle,ol_scn_t soc,uint8_t * datap,uint16_t len,void * context)49 int fwdbg_parse_debug_logs(struct common_dbglog_handle *dbg_handle,
50 ol_scn_t soc, uint8_t *datap,
51 uint16_t len, void *context)
52 {
53 struct dbglog_info *dbg_info = handle2info(dbg_handle);
54
55 if (dbg_info->ops->dbglog_parse_debug_logs)
56 return dbg_info->ops->dbglog_parse_debug_logs(soc,
57 datap, len, context);
58
59 return 0;
60 }
61 qdf_export_symbol(fwdbg_parse_debug_logs);
62
fwdbg_ratelimit_set(struct common_dbglog_handle * dbg_handle,uint32_t burst_limit)63 void fwdbg_ratelimit_set(struct common_dbglog_handle *dbg_handle,
64 uint32_t burst_limit)
65 {
66 struct dbglog_info *dbg_info = handle2info(dbg_handle);
67
68 if (dbg_info->ops->dbglog_ratelimit_set)
69 dbg_info->ops->dbglog_ratelimit_set(burst_limit);
70
71 }
72
fwdbg_vap_log_enable(struct common_dbglog_handle * dbg_handle,ol_scn_t scn,uint16_t vap_id,bool isenable)73 void fwdbg_vap_log_enable(struct common_dbglog_handle *dbg_handle, ol_scn_t scn,
74 uint16_t vap_id, bool isenable)
75 {
76 struct dbglog_info *dbg_info = handle2info(dbg_handle);
77
78 if (dbg_info->ops->dbglog_vap_log_enable)
79 dbg_info->ops->dbglog_vap_log_enable(scn, vap_id,
80 isenable);
81
82 }
83
fwdbg_set_timestamp_resolution(struct common_dbglog_handle * dbg_handle,ol_scn_t scn,uint16_t tsr)84 void fwdbg_set_timestamp_resolution(struct common_dbglog_handle *dbg_handle,
85 ol_scn_t scn, uint16_t tsr)
86 {
87 struct dbglog_info *dbg_info = handle2info(dbg_handle);
88
89 if (dbg_info->ops->dbglog_set_timestamp_resolution)
90 dbg_info->ops->dbglog_set_timestamp_resolution(scn, tsr);
91
92 }
93
fwdbg_reporting_enable(struct common_dbglog_handle * dbg_handle,ol_scn_t scn,bool isenable)94 void fwdbg_reporting_enable(struct common_dbglog_handle *dbg_handle,
95 ol_scn_t scn, bool isenable)
96 {
97 struct dbglog_info *dbg_info = handle2info(dbg_handle);
98
99 if (dbg_info->ops->dbglog_reporting_enable)
100 dbg_info->ops->dbglog_reporting_enable(scn, isenable);
101
102 }
103
fwdbg_module_log_enable(struct common_dbglog_handle * dbg_handle,ol_scn_t scn,uint32_t mod_id,bool isenable)104 void fwdbg_module_log_enable(struct common_dbglog_handle *dbg_handle,
105 ol_scn_t scn, uint32_t mod_id, bool isenable)
106 {
107 struct dbglog_info *dbg_info = handle2info(dbg_handle);
108
109 if (dbg_info->ops->dbglog_module_log_enable)
110 dbg_info->ops->dbglog_module_log_enable(scn, mod_id,
111 isenable);
112
113 }
114
fwdbg_init(struct common_dbglog_handle * dbg_handle,void * soc)115 void fwdbg_init(struct common_dbglog_handle *dbg_handle, void *soc)
116 {
117 struct dbglog_info *dbg_info = handle2info(dbg_handle);
118
119 if (dbg_info->ops->dbglog_init)
120 dbg_info->ops->dbglog_init(soc);
121
122 }
123
fwdbg_free(struct common_dbglog_handle * dbg_handle,void * soc)124 void fwdbg_free(struct common_dbglog_handle *dbg_handle, void *soc)
125 {
126 struct dbglog_info *dbg_info = handle2info(dbg_handle);
127
128 if (dbg_info->ops->dbglog_free)
129 dbg_info->ops->dbglog_free(soc);
130
131 }
132
fwdbg_set_report_size(struct common_dbglog_handle * dbg_handle,ol_scn_t scn,uint16_t size)133 void fwdbg_set_report_size(struct common_dbglog_handle *dbg_handle,
134 ol_scn_t scn, uint16_t size)
135 {
136 struct dbglog_info *dbg_info = handle2info(dbg_handle);
137
138 if (dbg_info->ops->dbglog_set_report_size)
139 dbg_info->ops->dbglog_set_report_size(scn, size);
140
141 }
142
fwdbg_smartlog_init(struct common_dbglog_handle * dbg_handle,void * icp)143 int fwdbg_smartlog_init(struct common_dbglog_handle *dbg_handle, void *icp)
144 {
145 struct dbglog_info *dbg_info = handle2info(dbg_handle);
146
147 if (dbg_info->ops->smartlog_init)
148 return dbg_info->ops->smartlog_init(icp);
149
150 return 0;
151 }
152
fwdbg_smartlog_deinit(struct common_dbglog_handle * dbg_handle,void * sc)153 void fwdbg_smartlog_deinit(struct common_dbglog_handle *dbg_handle, void *sc)
154 {
155 struct dbglog_info *dbg_info = handle2info(dbg_handle);
156
157 if (dbg_info->ops->smartlog_deinit)
158 dbg_info->ops->smartlog_deinit(sc);
159 }
160
fwdbg_smartlog_dump(struct common_dbglog_handle * dbg_handle,struct device * dev,struct device_attribute * attr,char * buf)161 ssize_t fwdbg_smartlog_dump(struct common_dbglog_handle *dbg_handle,
162 struct device *dev,
163 struct device_attribute *attr, char *buf)
164 {
165 struct dbglog_info *dbg_info = handle2info(dbg_handle);
166
167 if (dbg_info->ops->smartlog_dump)
168 return dbg_info->ops->smartlog_dump(dev, attr, buf);
169
170 return 0;
171 }
172