1 /* 2 * Copyright (c) 2012-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 #ifndef _PKTLOG_AC_H_ 20 #define _PKTLOG_AC_H_ 21 22 #include "hif.h" 23 #ifndef REMOVE_PKT_LOG 24 #include "ol_if_athvar.h" 25 #include "osdep.h" 26 #include <wmi_unified.h> 27 #include <wmi_unified_api.h> 28 #include <wdi_event_api.h> 29 #include <ol_defines.h> 30 #include <pktlog_ac_api.h> 31 #include <pktlog_ac_fmt.h> 32 33 #define NO_REG_FUNCS 4 34 35 /* Locking interface for pktlog */ 36 #define PKTLOG_LOCK_INIT(_pl_info) qdf_spinlock_create(&(_pl_info)->log_lock) 37 #define PKTLOG_LOCK_DESTROY(_pl_info) \ 38 qdf_spinlock_destroy(&(_pl_info)->log_lock) 39 #define PKTLOG_LOCK(_pl_info) qdf_spin_lock_bh(&(_pl_info)->log_lock) 40 #define PKTLOG_UNLOCK(_pl_info) qdf_spin_unlock_bh(&(_pl_info)->log_lock) 41 42 #define PKTLOG_MODE_SYSTEM 1 43 #define PKTLOG_MODE_ADAPTER 2 44 45 /* 46 * The proc entry starts with magic number and version field which will be 47 * used by post processing scripts. These fields are not needed by applications 48 * that do not use these scripts. This is skipped using the offset value. 49 */ 50 #define PKTLOG_READ_OFFSET 8 51 52 /* forward declaration for cdp_pdev */ 53 struct cdp_pdev; 54 55 /* Opaque softc */ 56 struct ol_ath_generic_softc_t; 57 typedef struct ol_ath_generic_softc_t *ol_ath_generic_softc_handle; 58 extern void pktlog_disable_adapter_logging(struct hif_opaque_softc *scn); 59 extern int pktlog_alloc_buf(struct hif_opaque_softc *scn); 60 extern void pktlog_release_buf(struct hif_opaque_softc *scn); 61 62 ssize_t pktlog_read_proc_entry(char *buf, size_t nbytes, loff_t *ppos, 63 struct ath_pktlog_info *pl_info, bool *read_complete); 64 A_STATUS wdi_pktlog_unsubscribe(struct cdp_pdev *txrx_pdev, uint32_t log_state); 65 66 struct ol_pl_arch_dep_funcs { 67 void (*pktlog_init)(struct hif_opaque_softc *scn); 68 int (*pktlog_enable)(struct hif_opaque_softc *scn, int32_t log_state, 69 bool ini, uint8_t user, 70 uint32_t is_iwpriv_command); 71 int (*pktlog_setsize)(struct hif_opaque_softc *scn, int32_t log_state); 72 int (*pktlog_disable)(struct hif_opaque_softc *scn); 73 }; 74 75 struct ol_pl_os_dep_funcs { 76 int (*pktlog_attach)(struct hif_opaque_softc *scn); 77 void (*pktlog_detach)(struct hif_opaque_softc *scn); 78 79 }; 80 81 struct ath_pktlog_wmi_params { 82 WMI_PKTLOG_EVENT pktlog_event; 83 WMI_CMD_ID cmd_id; 84 bool ini_triggered; 85 uint8_t user_triggered; 86 }; 87 88 extern struct ol_pl_arch_dep_funcs ol_pl_funcs; 89 extern struct ol_pl_os_dep_funcs *g_ol_pl_os_dep_funcs; 90 91 /* Pktlog handler to save the state of the pktlogs */ 92 struct pktlog_dev_t { 93 struct ol_pl_arch_dep_funcs *pl_funcs; 94 struct ath_pktlog_info *pl_info; 95 ol_ath_generic_softc_handle scn; 96 char *name; 97 bool tgt_pktlog_alloced; 98 bool is_pktlog_cb_subscribed; 99 bool mt_pktlog_enabled; 100 uint32_t htc_err_cnt; 101 uint8_t htc_endpoint; 102 void *htc_pdev; 103 bool vendor_cmd_send; 104 uint8_t callback_type; 105 uint32_t invalid_packets; 106 }; 107 108 #define PKTLOG_SYSCTL_SIZE 14 109 #define PKTLOG_MAX_SEND_QUEUE_DEPTH 64 110 111 /* 112 * Linux specific pktlog state information 113 */ 114 struct ath_pktlog_info_lnx { 115 struct ath_pktlog_info info; 116 struct ctl_table sysctls[PKTLOG_SYSCTL_SIZE]; 117 struct proc_dir_entry *proc_entry; 118 struct ctl_table_header *sysctl_header; 119 }; 120 121 #define PL_INFO_LNX(_pl_info) ((struct ath_pktlog_info_lnx *)(_pl_info)) 122 123 extern struct ol_pktlog_dev_t ol_pl_dev; 124 125 /* 126 * WDI related data and functions 127 * Callback function to the WDI events 128 */ 129 void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data, 130 u_int16_t peer_id, uint32_t status); 131 132 void pktlog_init(struct hif_opaque_softc *scn); 133 int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state, 134 bool, uint8_t, uint32_t); 135 int pktlog_setsize(struct hif_opaque_softc *scn, int32_t log_state); 136 int pktlog_clearbuff(struct hif_opaque_softc *scn, bool clear_buff); 137 int pktlog_disable(struct hif_opaque_softc *scn); 138 int pktlogmod_init(void *context); 139 void pktlogmod_exit(void *context); 140 int pktlog_htc_attach(void); 141 void pktlog_process_fw_msg(uint32_t *msg_word, uint32_t msg_len); 142 void lit_pktlog_callback(void *context, enum WDI_EVENT event, void *log_data, 143 u_int16_t peer_id, uint32_t status); 144 145 #define ol_pktlog_attach(_scn) \ 146 do { \ 147 if (g_ol_pl_os_dep_funcs) { \ 148 g_ol_pl_os_dep_funcs->pktlog_attach(_scn); \ 149 } \ 150 } while (0) 151 152 #define ol_pktlog_detach(_scn) \ 153 do { \ 154 if (g_ol_pl_os_dep_funcs) { \ 155 g_ol_pl_os_dep_funcs->pktlog_detach(_scn); \ 156 } \ 157 } while (0) 158 159 #else /* REMOVE_PKT_LOG */ 160 #define ol_pktlog_attach(_scn) ({ (void)_scn; }) 161 #define ol_pktlog_detach(_scn) ({ (void)_scn; }) 162 static inline void pktlog_init(struct hif_opaque_softc *scn) 163 { 164 return; 165 } 166 167 static inline int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state, 168 bool ini, uint8_t user, 169 uint32_t is_iwpriv_command) 170 { 171 return 0; 172 } 173 174 static inline int pktlog_setsize(struct hif_opaque_softc *scn, 175 int32_t log_state) 176 { 177 return 0; 178 } 179 180 static inline int pktlog_clearbuff(struct hif_opaque_softc *scn, 181 bool clear_buff) 182 { 183 return 0; 184 } 185 186 static inline int pktlog_disable(struct hif_opaque_softc *scn) 187 { 188 return 0; 189 } 190 191 static inline int pktlog_htc_attach(void) 192 { 193 return 0; 194 } 195 196 static inline void pktlog_process_fw_msg(uint32_t *msg_word, uint32_t msg_len) 197 { } 198 #endif /* REMOVE_PKT_LOG */ 199 #endif /* _PKTLOG_AC_H_ */ 200