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