pktlog_ac.h 5.7 KB

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