1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name *
5*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name * above copyright notice and this permission notice appear in all
8*5113495bSYour Name * copies.
9*5113495bSYour Name *
10*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name */
19*5113495bSYour Name
20*5113495bSYour Name #ifndef _PKTLOG_AC_H_
21*5113495bSYour Name #define _PKTLOG_AC_H_
22*5113495bSYour Name
23*5113495bSYour Name #include "hif.h"
24*5113495bSYour Name #if defined(CONNECTIVITY_PKTLOG) || !defined(REMOVE_PKT_LOG)
25*5113495bSYour Name #include "ol_if_athvar.h"
26*5113495bSYour Name #include "osdep.h"
27*5113495bSYour Name #include <wmi_unified.h>
28*5113495bSYour Name #include <wmi_unified_api.h>
29*5113495bSYour Name #include <wdi_event_api.h>
30*5113495bSYour Name #include <ol_defines.h>
31*5113495bSYour Name #include <pktlog_ac_api.h>
32*5113495bSYour Name #include <pktlog_ac_fmt.h>
33*5113495bSYour Name
34*5113495bSYour Name #define NO_REG_FUNCS 4
35*5113495bSYour Name
36*5113495bSYour Name /* Locking interface for pktlog */
37*5113495bSYour Name #define PKTLOG_LOCK_INIT(_pl_info) qdf_spinlock_create(&(_pl_info)->log_lock)
38*5113495bSYour Name #define PKTLOG_LOCK_DESTROY(_pl_info) \
39*5113495bSYour Name qdf_spinlock_destroy(&(_pl_info)->log_lock)
40*5113495bSYour Name #define PKTLOG_LOCK(_pl_info) qdf_spin_lock_bh(&(_pl_info)->log_lock)
41*5113495bSYour Name #define PKTLOG_UNLOCK(_pl_info) qdf_spin_unlock_bh(&(_pl_info)->log_lock)
42*5113495bSYour Name
43*5113495bSYour Name #define PKTLOG_MODE_SYSTEM 1
44*5113495bSYour Name #define PKTLOG_MODE_ADAPTER 2
45*5113495bSYour Name
46*5113495bSYour Name /*
47*5113495bSYour Name * The proc entry starts with magic number and version field which will be
48*5113495bSYour Name * used by post processing scripts. These fields are not needed by applications
49*5113495bSYour Name * that do not use these scripts. This is skipped using the offset value.
50*5113495bSYour Name */
51*5113495bSYour Name #define PKTLOG_READ_OFFSET 8
52*5113495bSYour Name
53*5113495bSYour Name /* forward declaration for cdp_pdev */
54*5113495bSYour Name struct cdp_pdev;
55*5113495bSYour Name
56*5113495bSYour Name /* Opaque softc */
57*5113495bSYour Name struct ol_ath_generic_softc_t;
58*5113495bSYour Name typedef struct ol_ath_generic_softc_t *ol_ath_generic_softc_handle;
59*5113495bSYour Name extern void pktlog_disable_adapter_logging(struct hif_opaque_softc *scn);
60*5113495bSYour Name extern int pktlog_alloc_buf(struct hif_opaque_softc *scn);
61*5113495bSYour Name extern void pktlog_release_buf(struct hif_opaque_softc *scn);
62*5113495bSYour Name
63*5113495bSYour Name ssize_t pktlog_read_proc_entry(char *buf, size_t nbytes, loff_t *ppos,
64*5113495bSYour Name struct ath_pktlog_info *pl_info, bool *read_complete);
65*5113495bSYour Name
66*5113495bSYour Name /**
67*5113495bSYour Name * wdi_pktlog_unsubscribe() - Unsubscribe pktlog callbacks
68*5113495bSYour Name * @pdev_id: pdev id
69*5113495bSYour Name * @log_state: Pktlog registration
70*5113495bSYour Name *
71*5113495bSYour Name * Return: zero on success, non-zero on failure
72*5113495bSYour Name */
73*5113495bSYour Name A_STATUS wdi_pktlog_unsubscribe(uint8_t pdev_id, uint32_t log_state);
74*5113495bSYour Name
75*5113495bSYour Name struct ol_pl_arch_dep_funcs {
76*5113495bSYour Name void (*pktlog_init)(struct hif_opaque_softc *scn);
77*5113495bSYour Name int (*pktlog_enable)(struct hif_opaque_softc *scn, int32_t log_state,
78*5113495bSYour Name bool ini, uint8_t user,
79*5113495bSYour Name uint32_t is_iwpriv_command);
80*5113495bSYour Name int (*pktlog_setsize)(struct hif_opaque_softc *scn, int32_t log_state);
81*5113495bSYour Name int (*pktlog_disable)(struct hif_opaque_softc *scn);
82*5113495bSYour Name };
83*5113495bSYour Name
84*5113495bSYour Name struct ol_pl_os_dep_funcs {
85*5113495bSYour Name int (*pktlog_attach)(struct hif_opaque_softc *scn);
86*5113495bSYour Name void (*pktlog_detach)(struct hif_opaque_softc *scn);
87*5113495bSYour Name
88*5113495bSYour Name };
89*5113495bSYour Name
90*5113495bSYour Name struct ath_pktlog_wmi_params {
91*5113495bSYour Name WMI_PKTLOG_EVENT pktlog_event;
92*5113495bSYour Name WMI_CMD_ID cmd_id;
93*5113495bSYour Name bool ini_triggered;
94*5113495bSYour Name uint8_t user_triggered;
95*5113495bSYour Name };
96*5113495bSYour Name
97*5113495bSYour Name extern struct ol_pl_arch_dep_funcs ol_pl_funcs;
98*5113495bSYour Name extern struct ol_pl_os_dep_funcs *g_ol_pl_os_dep_funcs;
99*5113495bSYour Name
100*5113495bSYour Name /* Pktlog handler to save the state of the pktlogs */
101*5113495bSYour Name struct pktlog_dev_t {
102*5113495bSYour Name struct ol_pl_arch_dep_funcs *pl_funcs;
103*5113495bSYour Name struct ath_pktlog_info *pl_info;
104*5113495bSYour Name ol_ath_generic_softc_handle scn;
105*5113495bSYour Name uint8_t pdev_id;
106*5113495bSYour Name char *name;
107*5113495bSYour Name bool tgt_pktlog_alloced;
108*5113495bSYour Name bool is_pktlog_cb_subscribed;
109*5113495bSYour Name bool mt_pktlog_enabled;
110*5113495bSYour Name uint32_t htc_err_cnt;
111*5113495bSYour Name uint8_t htc_endpoint;
112*5113495bSYour Name void *htc_pdev;
113*5113495bSYour Name bool vendor_cmd_send;
114*5113495bSYour Name uint8_t callback_type;
115*5113495bSYour Name uint32_t invalid_packets;
116*5113495bSYour Name };
117*5113495bSYour Name
118*5113495bSYour Name #define PKTLOG_SYSCTL_SIZE 14
119*5113495bSYour Name #define PKTLOG_MAX_SEND_QUEUE_DEPTH 64
120*5113495bSYour Name
121*5113495bSYour Name /*
122*5113495bSYour Name * Linux specific pktlog state information
123*5113495bSYour Name */
124*5113495bSYour Name struct ath_pktlog_info_lnx {
125*5113495bSYour Name struct ath_pktlog_info info;
126*5113495bSYour Name struct ctl_table sysctls[PKTLOG_SYSCTL_SIZE];
127*5113495bSYour Name struct proc_dir_entry *proc_entry;
128*5113495bSYour Name struct ctl_table_header *sysctl_header;
129*5113495bSYour Name };
130*5113495bSYour Name
131*5113495bSYour Name #define PL_INFO_LNX(_pl_info) ((struct ath_pktlog_info_lnx *)(_pl_info))
132*5113495bSYour Name
133*5113495bSYour Name /*
134*5113495bSYour Name * WDI related data and functions
135*5113495bSYour Name * Callback function to the WDI events
136*5113495bSYour Name */
137*5113495bSYour Name void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data,
138*5113495bSYour Name u_int16_t peer_id, uint32_t status);
139*5113495bSYour Name
140*5113495bSYour Name void pktlog_init(struct hif_opaque_softc *scn);
141*5113495bSYour Name int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
142*5113495bSYour Name bool, uint8_t, uint32_t);
143*5113495bSYour Name int __pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
144*5113495bSYour Name bool ini_triggered, uint8_t user_triggered,
145*5113495bSYour Name uint32_t is_iwpriv_command);
146*5113495bSYour Name int pktlog_setsize(struct hif_opaque_softc *scn, int32_t log_state);
147*5113495bSYour Name int pktlog_clearbuff(struct hif_opaque_softc *scn, bool clear_buff);
148*5113495bSYour Name int pktlog_disable(struct hif_opaque_softc *scn);
149*5113495bSYour Name int pktlogmod_init(void *context);
150*5113495bSYour Name void pktlogmod_exit(void *context);
151*5113495bSYour Name int pktlog_htc_attach(void);
152*5113495bSYour Name
153*5113495bSYour Name /**
154*5113495bSYour Name * pktlog_process_fw_msg() - process packetlog message
155*5113495bSYour Name * @pdev_id: physical device instance id
156*5113495bSYour Name * @msg_word: message buffer
157*5113495bSYour Name * @msg_len: message length
158*5113495bSYour Name *
159*5113495bSYour Name * Return: None
160*5113495bSYour Name */
161*5113495bSYour Name void pktlog_process_fw_msg(uint8_t pdev_id, uint32_t *msg_word,
162*5113495bSYour Name uint32_t msg_len);
163*5113495bSYour Name void lit_pktlog_callback(void *context, enum WDI_EVENT event, void *log_data,
164*5113495bSYour Name u_int16_t peer_id, uint32_t status);
165*5113495bSYour Name
166*5113495bSYour Name #define ol_pktlog_attach(_scn) \
167*5113495bSYour Name do { \
168*5113495bSYour Name if (g_ol_pl_os_dep_funcs) { \
169*5113495bSYour Name g_ol_pl_os_dep_funcs->pktlog_attach(_scn); \
170*5113495bSYour Name } \
171*5113495bSYour Name } while (0)
172*5113495bSYour Name
173*5113495bSYour Name #define ol_pktlog_detach(_scn) \
174*5113495bSYour Name do { \
175*5113495bSYour Name if (g_ol_pl_os_dep_funcs) { \
176*5113495bSYour Name g_ol_pl_os_dep_funcs->pktlog_detach(_scn); \
177*5113495bSYour Name } \
178*5113495bSYour Name } while (0)
179*5113495bSYour Name
180*5113495bSYour Name #else /* REMOVE_PKT_LOG */
181*5113495bSYour Name #define ol_pktlog_attach(_scn) ({ (void)_scn; })
182*5113495bSYour Name #define ol_pktlog_detach(_scn) ({ (void)_scn; })
pktlog_init(struct hif_opaque_softc * scn)183*5113495bSYour Name static inline void pktlog_init(struct hif_opaque_softc *scn)
184*5113495bSYour Name {
185*5113495bSYour Name return;
186*5113495bSYour Name }
187*5113495bSYour Name
pktlog_enable(struct hif_opaque_softc * scn,int32_t log_state,bool ini,uint8_t user,uint32_t is_iwpriv_command)188*5113495bSYour Name static inline int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
189*5113495bSYour Name bool ini, uint8_t user,
190*5113495bSYour Name uint32_t is_iwpriv_command)
191*5113495bSYour Name {
192*5113495bSYour Name return 0;
193*5113495bSYour Name }
194*5113495bSYour Name
195*5113495bSYour Name static inline
__pktlog_enable(struct hif_opaque_softc * scn,int32_t log_state,bool ini_triggered,uint8_t user_triggered,uint32_t is_iwpriv_command)196*5113495bSYour Name int __pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
197*5113495bSYour Name bool ini_triggered, uint8_t user_triggered,
198*5113495bSYour Name uint32_t is_iwpriv_command)
199*5113495bSYour Name {
200*5113495bSYour Name return 0;
201*5113495bSYour Name }
202*5113495bSYour Name
pktlog_setsize(struct hif_opaque_softc * scn,int32_t log_state)203*5113495bSYour Name static inline int pktlog_setsize(struct hif_opaque_softc *scn,
204*5113495bSYour Name int32_t log_state)
205*5113495bSYour Name {
206*5113495bSYour Name return 0;
207*5113495bSYour Name }
208*5113495bSYour Name
pktlog_clearbuff(struct hif_opaque_softc * scn,bool clear_buff)209*5113495bSYour Name static inline int pktlog_clearbuff(struct hif_opaque_softc *scn,
210*5113495bSYour Name bool clear_buff)
211*5113495bSYour Name {
212*5113495bSYour Name return 0;
213*5113495bSYour Name }
214*5113495bSYour Name
pktlog_disable(struct hif_opaque_softc * scn)215*5113495bSYour Name static inline int pktlog_disable(struct hif_opaque_softc *scn)
216*5113495bSYour Name {
217*5113495bSYour Name return 0;
218*5113495bSYour Name }
219*5113495bSYour Name
pktlog_htc_attach(void)220*5113495bSYour Name static inline int pktlog_htc_attach(void)
221*5113495bSYour Name {
222*5113495bSYour Name return 0;
223*5113495bSYour Name }
224*5113495bSYour Name
pktlog_process_fw_msg(uint8_t pdev_id,uint32_t * msg_word,uint32_t msg_len)225*5113495bSYour Name static inline void pktlog_process_fw_msg(uint8_t pdev_id, uint32_t *msg_word,
226*5113495bSYour Name uint32_t msg_len)
227*5113495bSYour Name { }
228*5113495bSYour Name #endif /* REMOVE_PKT_LOG */
229*5113495bSYour Name #endif /* _PKTLOG_AC_H_ */
230