pktlog_ac.h 6.7 KB

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