1 /* 2 * Copyright (c) 2012-2020 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 65 /** 66 * wdi_pktlog_unsubscribe() - Unsubscribe pktlog callbacks 67 * @pdev_id: pdev id 68 * @log_state: Pktlog registration 69 * 70 * Return: zero on success, non-zero on failure 71 */ 72 A_STATUS wdi_pktlog_unsubscribe(uint8_t pdev_id, uint32_t log_state); 73 74 struct ol_pl_arch_dep_funcs { 75 void (*pktlog_init)(struct hif_opaque_softc *scn); 76 int (*pktlog_enable)(struct hif_opaque_softc *scn, int32_t log_state, 77 bool ini, uint8_t user, 78 uint32_t is_iwpriv_command); 79 int (*pktlog_setsize)(struct hif_opaque_softc *scn, int32_t log_state); 80 int (*pktlog_disable)(struct hif_opaque_softc *scn); 81 }; 82 83 struct ol_pl_os_dep_funcs { 84 int (*pktlog_attach)(struct hif_opaque_softc *scn); 85 void (*pktlog_detach)(struct hif_opaque_softc *scn); 86 87 }; 88 89 struct ath_pktlog_wmi_params { 90 WMI_PKTLOG_EVENT pktlog_event; 91 WMI_CMD_ID cmd_id; 92 bool ini_triggered; 93 uint8_t user_triggered; 94 }; 95 96 extern struct ol_pl_arch_dep_funcs ol_pl_funcs; 97 extern struct ol_pl_os_dep_funcs *g_ol_pl_os_dep_funcs; 98 99 /* Pktlog handler to save the state of the pktlogs */ 100 struct pktlog_dev_t { 101 struct ol_pl_arch_dep_funcs *pl_funcs; 102 struct ath_pktlog_info *pl_info; 103 ol_ath_generic_softc_handle scn; 104 uint8_t pdev_id; 105 char *name; 106 bool tgt_pktlog_alloced; 107 bool is_pktlog_cb_subscribed; 108 bool mt_pktlog_enabled; 109 uint32_t htc_err_cnt; 110 uint8_t htc_endpoint; 111 void *htc_pdev; 112 bool vendor_cmd_send; 113 uint8_t callback_type; 114 uint32_t invalid_packets; 115 }; 116 117 #define PKTLOG_SYSCTL_SIZE 14 118 #define PKTLOG_MAX_SEND_QUEUE_DEPTH 64 119 120 /* 121 * Linux specific pktlog state information 122 */ 123 struct ath_pktlog_info_lnx { 124 struct ath_pktlog_info info; 125 struct ctl_table sysctls[PKTLOG_SYSCTL_SIZE]; 126 struct proc_dir_entry *proc_entry; 127 struct ctl_table_header *sysctl_header; 128 }; 129 130 #define PL_INFO_LNX(_pl_info) ((struct ath_pktlog_info_lnx *)(_pl_info)) 131 132 extern struct ol_pktlog_dev_t ol_pl_dev; 133 134 /* 135 * WDI related data and functions 136 * Callback function to the WDI events 137 */ 138 void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data, 139 u_int16_t peer_id, uint32_t status); 140 141 void pktlog_init(struct hif_opaque_softc *scn); 142 int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state, 143 bool, uint8_t, uint32_t); 144 int __pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state, 145 bool ini_triggered, uint8_t user_triggered, 146 uint32_t is_iwpriv_command); 147 int pktlog_setsize(struct hif_opaque_softc *scn, int32_t log_state); 148 int pktlog_clearbuff(struct hif_opaque_softc *scn, bool clear_buff); 149 int pktlog_disable(struct hif_opaque_softc *scn); 150 int pktlogmod_init(void *context); 151 void pktlogmod_exit(void *context); 152 int pktlog_htc_attach(void); 153 154 /** 155 * pktlog_process_fw_msg() - process packetlog message 156 * @pdev_id: physical device instance id 157 * @msg_word: message buffer 158 * @msg_len: message length 159 * 160 * Return: None 161 */ 162 void pktlog_process_fw_msg(uint8_t pdev_id, uint32_t *msg_word, 163 uint32_t msg_len); 164 void lit_pktlog_callback(void *context, enum WDI_EVENT event, void *log_data, 165 u_int16_t peer_id, uint32_t status); 166 167 #define ol_pktlog_attach(_scn) \ 168 do { \ 169 if (g_ol_pl_os_dep_funcs) { \ 170 g_ol_pl_os_dep_funcs->pktlog_attach(_scn); \ 171 } \ 172 } while (0) 173 174 #define ol_pktlog_detach(_scn) \ 175 do { \ 176 if (g_ol_pl_os_dep_funcs) { \ 177 g_ol_pl_os_dep_funcs->pktlog_detach(_scn); \ 178 } \ 179 } while (0) 180 181 #else /* REMOVE_PKT_LOG */ 182 #define ol_pktlog_attach(_scn) ({ (void)_scn; }) 183 #define ol_pktlog_detach(_scn) ({ (void)_scn; }) 184 static inline void pktlog_init(struct hif_opaque_softc *scn) 185 { 186 return; 187 } 188 189 static inline int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state, 190 bool ini, uint8_t user, 191 uint32_t is_iwpriv_command) 192 { 193 return 0; 194 } 195 196 static inline 197 int __pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state, 198 bool ini_triggered, uint8_t user_triggered, 199 uint32_t is_iwpriv_command) 200 { 201 return 0; 202 } 203 204 static inline int pktlog_setsize(struct hif_opaque_softc *scn, 205 int32_t log_state) 206 { 207 return 0; 208 } 209 210 static inline int pktlog_clearbuff(struct hif_opaque_softc *scn, 211 bool clear_buff) 212 { 213 return 0; 214 } 215 216 static inline int pktlog_disable(struct hif_opaque_softc *scn) 217 { 218 return 0; 219 } 220 221 static inline int pktlog_htc_attach(void) 222 { 223 return 0; 224 } 225 226 static inline void pktlog_process_fw_msg(uint8_t pdev_id, uint32_t *msg_word, 227 uint32_t msg_len) 228 { } 229 #endif /* REMOVE_PKT_LOG */ 230 #endif /* _PKTLOG_AC_H_ */ 231