pktlog_ac.h 6.6 KB

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