xref: /wlan-dirver/qca-wifi-host-cmn/utils/logging/inc/wlan_logging_sock_svc.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2014-2021 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 /******************************************************************************
20 * wlan_logging_sock_svc.h
21 *
22 ******************************************************************************/
23 
24 #ifndef WLAN_LOGGING_SOCK_SVC_H
25 #define WLAN_LOGGING_SOCK_SVC_H
26 
27 #include <wlan_nlink_srv.h>
28 #include <qdf_status.h>
29 #include <qdf_trace.h>
30 #include <wlan_nlink_common.h>
31 
32 int wlan_logging_sock_init_svc(void);
33 int wlan_logging_sock_deinit_svc(void);
34 int wlan_log_to_user(QDF_TRACE_LEVEL log_level, char *to_be_sent, int length);
35 
36 /**
37  * wlan_logging_set_flush_timer() - Sets the time period for log flush timer
38  * @milliseconds: Time period in milliseconds
39  *
40  * This function sets the time period interval during which the log buffers
41  * will be flushed out to user space. Setting this interval can set an
42  * approximate maximum delay after which any message logged through QDF_TRACE
43  * will appear at user-space
44  *
45  * Return: void
46  */
47 int wlan_logging_set_flush_timer(uint32_t milliseconds);
48 
49 /**
50  * wlan_logging_notifier_init() - registers to panic notifier chain
51  * @dump_at_kernel_enable: qdf logging at kernel level enabled
52  *
53  * This function registers an handler to panic notifier chain if
54  * qdf logging at kernel level is disabled.
55  *
56  * Return: 0 on success
57  */
58 int wlan_logging_notifier_init(bool dump_at_kernel_enable);
59 
60 /**
61  * wlan_logging_notifier_deinit() - unregisters to panic notifier chain
62  * @dump_at_kernel_enable: qdf logging at kernel level enabled
63  *
64  * This function unregisters an handler to panic notifier chain if
65  * qdf logging at kernel level is disabled.
66  *
67  * Return: 0 on success
68  */
69 int wlan_logging_notifier_deinit(bool dump_at_kernel_enable);
70 
71 #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
72 /**
73  * wlan_logging_wait_for_flush_log_completion() -  Wait for flush log completion
74  *
75  * Return: QDF_STATUS
76  */
77 QDF_STATUS wlan_logging_wait_for_flush_log_completion(void);
78 
79 void wlan_logging_set_per_pkt_stats(void);
80 
81 /**
82  * wlan_logging_set_connectivity_log() - INterrupt the gwlan_logging thread
83  * to send the connectivity logs
84  *
85  * Return: None
86  */
87 void wlan_logging_set_connectivity_log(void);
88 void wlan_logging_set_fw_flush_complete(void);
89 void wlan_flush_host_logs_for_fatal(void);
90 void wlan_logging_set_active(bool active);
91 void wlan_set_console_log_levels(uint32_t console_log_levels);
92 #else
93 static inline QDF_STATUS wlan_logging_wait_for_flush_log_completion(void)
94 {
95 	return QDF_STATUS_SUCCESS;
96 }
97 static inline void wlan_flush_host_logs_for_fatal(void) {}
98 static inline void wlan_logging_set_per_pkt_stats(void) {}
99 static inline void wlan_logging_set_fw_flush_complete(void) {}
100 static inline void wlan_logging_set_active(bool active) {}
101 static inline void wlan_set_console_log_levels(uint32_t console_log_levels) {}
102 #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */
103 
104 #if defined(WLAN_LOGGING_SOCK_SVC_ENABLE) && \
105 	defined(FEATURE_PKTLOG) && !defined(REMOVE_PKT_LOG)
106 /**
107  * wlan_deregister_txrx_packetdump() - tx/rx packet dump
108  *  deregistration
109  * @pdev_id: id of the datapath pdev handle
110  *
111  * This function is used to deregister tx/rx packet dump callbacks
112  * with ol, pe and htt layers
113  *
114  * Return: None
115  *
116  */
117 void wlan_deregister_txrx_packetdump(uint8_t pdev_id);
118 
119 /**
120  * wlan_register_txrx_packetdump() - tx/rx packet dump
121  * registration
122  * @pdev_id: id of the datapath pdev handle
123  *
124  * This function is used to register tx/rx packet dump callbacks
125  * with ol, pe and htt layers
126  *
127  * Return: None
128  *
129  */
130 void wlan_register_txrx_packetdump(uint8_t pdev_id);
131 #else
132 static inline void wlan_deregister_txrx_packetdump(uint8_t pdev_id) {}
133 static inline void wlan_register_txrx_packetdump(uint8_t pdev_id) {}
134 #endif
135 
136 #if defined(WLAN_LOGGING_SOCK_SVC_ENABLE) && defined(FEATURE_WLAN_DIAG_SUPPORT)
137 void wlan_report_log_completion(uint32_t is_fatal,
138 		uint32_t indicator,
139 		uint32_t reason_code,
140 		uint8_t ring_id);
141 #else
142 static inline void wlan_report_log_completion(uint32_t is_fatal,
143 		uint32_t indicator,
144 		uint32_t reason_code,
145 		uint8_t ring_id)
146 {
147 	return;
148 }
149 
150 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
151 
152 #if defined(WLAN_LOGGING_SOCK_SVC_ENABLE) && \
153 	defined(FEATURE_PKTLOG) && !defined(REMOVE_PKT_LOG)
154 void wlan_pkt_stats_to_logger_thread(void *pl_hdr, void *pkt_dump, void *data);
155 #else
156 static inline
157 void wlan_pkt_stats_to_logger_thread(void *pl_hdr, void *pkt_dump, void *data)
158 {
159 }
160 #endif
161 
162 /**
163  * enum tx_status - tx status
164  * @tx_status_ok: successfully sent + acked
165  * @tx_status_discard: discard - not sent (congestion control)
166  * @tx_status_no_ack: no_ack - sent, but no ack
167  * @tx_status_download_fail: download_fail -
168  * the host could not deliver the tx frame to the target
169  * @tx_status_peer_del: peer_del - tx completion for
170  * already deleted peer used for HL case
171  *
172  * This enum has tx status types
173  */
174 enum tx_status {
175 	tx_status_ok,
176 	tx_status_discard,
177 	tx_status_no_ack,
178 	tx_status_download_fail,
179 	tx_status_peer_del,
180 };
181 
182 #endif /* WLAN_LOGGING_SOCK_SVC_H */
183