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