fw_dbglog_api.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (c) 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. #include "fw_dbglog_api.h"
  19. #include "fw_dbglog_priv.h"
  20. static inline struct dbglog_info *handle2info(
  21. struct common_dbglog_handle *dbg_handle)
  22. {
  23. return (struct dbglog_info *)dbg_handle;
  24. }
  25. void fwdbg_set_log_lvl(struct common_dbglog_handle *dbg_handle, ol_scn_t scn,
  26. uint32_t log_lvl)
  27. {
  28. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  29. if (dbg_info->ops->dbglog_set_log_lvl)
  30. dbg_info->ops->dbglog_set_log_lvl(scn, log_lvl);
  31. }
  32. int fwdbg_fw_handler(struct common_dbglog_handle *dbg_handle, ol_scn_t soc,
  33. uint8_t *data, uint32_t datalen)
  34. {
  35. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  36. if (dbg_info->ops->dbglog_fw_handler)
  37. return dbg_info->ops->dbglog_fw_handler(soc, data, datalen);
  38. return 0;
  39. }
  40. int fwdbg_parse_debug_logs(struct common_dbglog_handle *dbg_handle,
  41. const char *name, uint8_t *datap, uint16_t len, void *context)
  42. {
  43. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  44. if (dbg_info->ops->dbglog_parse_debug_logs)
  45. return dbg_info->ops->dbglog_parse_debug_logs(name,
  46. datap, len, context);
  47. return 0;
  48. }
  49. void fwdbg_ratelimit_set(struct common_dbglog_handle *dbg_handle,
  50. uint32_t burst_limit)
  51. {
  52. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  53. if (dbg_info->ops->dbglog_ratelimit_set)
  54. dbg_info->ops->dbglog_ratelimit_set(burst_limit);
  55. }
  56. void fwdbg_vap_log_enable(struct common_dbglog_handle *dbg_handle, ol_scn_t scn,
  57. uint16_t vap_id, bool isenable)
  58. {
  59. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  60. if (dbg_info->ops->dbglog_vap_log_enable)
  61. dbg_info->ops->dbglog_vap_log_enable(scn, vap_id,
  62. isenable);
  63. }
  64. void fwdbg_set_timestamp_resolution(struct common_dbglog_handle *dbg_handle,
  65. ol_scn_t scn, uint16_t tsr)
  66. {
  67. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  68. if (dbg_info->ops->dbglog_set_timestamp_resolution)
  69. dbg_info->ops->dbglog_set_timestamp_resolution(scn, tsr);
  70. }
  71. void fwdbg_reporting_enable(struct common_dbglog_handle *dbg_handle,
  72. ol_scn_t scn, bool isenable)
  73. {
  74. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  75. if (dbg_info->ops->dbglog_reporting_enable)
  76. dbg_info->ops->dbglog_reporting_enable(scn, isenable);
  77. }
  78. void fwdbg_module_log_enable(struct common_dbglog_handle *dbg_handle,
  79. ol_scn_t scn, uint32_t mod_id, bool isenable)
  80. {
  81. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  82. if (dbg_info->ops->dbglog_module_log_enable)
  83. dbg_info->ops->dbglog_module_log_enable(scn, mod_id,
  84. isenable);
  85. }
  86. void fwdbg_init(struct common_dbglog_handle *dbg_handle, void *soc)
  87. {
  88. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  89. if (dbg_info->ops->dbglog_init)
  90. dbg_info->ops->dbglog_init(soc);
  91. }
  92. void fwdbg_free(struct common_dbglog_handle *dbg_handle, void *soc)
  93. {
  94. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  95. if (dbg_info->ops->dbglog_free)
  96. dbg_info->ops->dbglog_free(soc);
  97. }
  98. void fwdbg_set_report_size(struct common_dbglog_handle *dbg_handle,
  99. ol_scn_t scn, uint16_t size)
  100. {
  101. struct dbglog_info *dbg_info = handle2info(dbg_handle);
  102. if (dbg_info->ops->dbglog_set_report_size)
  103. dbg_info->ops->dbglog_set_report_size(scn, size);
  104. }