xref: /wlan-dirver/qca-wifi-host-cmn/utils/fwlog/fw_dbglog_api.c (revision 4865edfd190c086bbe2c69aae12a8226f877b91e)
1 /*
2  * Copyright (c) 2018 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 
22 static inline struct dbglog_info *handle2info(
23 		struct common_dbglog_handle *dbg_handle)
24 {
25 	return (struct dbglog_info *)dbg_handle;
26 }
27 
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 
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 
49 int fwdbg_parse_debug_logs(struct common_dbglog_handle *dbg_handle,
50 		const char *name, uint8_t *datap, uint16_t len, void *context)
51 {
52 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
53 
54 	if (dbg_info->ops->dbglog_parse_debug_logs)
55 		return dbg_info->ops->dbglog_parse_debug_logs(name,
56 				datap, len, context);
57 
58 	return 0;
59 }
60 
61 void fwdbg_ratelimit_set(struct common_dbglog_handle *dbg_handle,
62 		uint32_t burst_limit)
63 {
64 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
65 
66 	if (dbg_info->ops->dbglog_ratelimit_set)
67 		dbg_info->ops->dbglog_ratelimit_set(burst_limit);
68 
69 }
70 
71 void fwdbg_vap_log_enable(struct common_dbglog_handle *dbg_handle, ol_scn_t scn,
72 				uint16_t vap_id, bool isenable)
73 {
74 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
75 
76 	if (dbg_info->ops->dbglog_vap_log_enable)
77 		dbg_info->ops->dbglog_vap_log_enable(scn, vap_id,
78 					isenable);
79 
80 }
81 
82 void fwdbg_set_timestamp_resolution(struct common_dbglog_handle *dbg_handle,
83 			ol_scn_t scn, uint16_t tsr)
84 {
85 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
86 
87 	if (dbg_info->ops->dbglog_set_timestamp_resolution)
88 		dbg_info->ops->dbglog_set_timestamp_resolution(scn, tsr);
89 
90 }
91 
92 void fwdbg_reporting_enable(struct common_dbglog_handle *dbg_handle,
93 			ol_scn_t scn, bool isenable)
94 {
95 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
96 
97 	if (dbg_info->ops->dbglog_reporting_enable)
98 		dbg_info->ops->dbglog_reporting_enable(scn, isenable);
99 
100 }
101 
102 void fwdbg_module_log_enable(struct common_dbglog_handle *dbg_handle,
103 			ol_scn_t scn, uint32_t mod_id, bool isenable)
104 {
105 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
106 
107 	if (dbg_info->ops->dbglog_module_log_enable)
108 		dbg_info->ops->dbglog_module_log_enable(scn, mod_id,
109 							isenable);
110 
111 }
112 
113 void fwdbg_init(struct common_dbglog_handle *dbg_handle, void *soc)
114 {
115 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
116 
117 	if (dbg_info->ops->dbglog_init)
118 		dbg_info->ops->dbglog_init(soc);
119 
120 }
121 
122 void fwdbg_free(struct common_dbglog_handle *dbg_handle, void *soc)
123 {
124 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
125 
126 	if (dbg_info->ops->dbglog_free)
127 		dbg_info->ops->dbglog_free(soc);
128 
129 }
130 
131 void fwdbg_set_report_size(struct common_dbglog_handle *dbg_handle,
132 			ol_scn_t scn, uint16_t size)
133 {
134 	struct dbglog_info *dbg_info = handle2info(dbg_handle);
135 
136 	if (dbg_info->ops->dbglog_set_report_size)
137 		dbg_info->ops->dbglog_set_report_size(scn, size);
138 
139 }
140 
141