debug.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: BSD-3-Clause-Clear
  2. /*
  3. * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/vmalloc.h>
  7. #include "core.h"
  8. #include "debug.h"
  9. void ath11k_info(struct ath11k_base *ab, const char *fmt, ...)
  10. {
  11. struct va_format vaf = {
  12. .fmt = fmt,
  13. };
  14. va_list args;
  15. va_start(args, fmt);
  16. vaf.va = &args;
  17. dev_info(ab->dev, "%pV", &vaf);
  18. trace_ath11k_log_info(ab, &vaf);
  19. va_end(args);
  20. }
  21. EXPORT_SYMBOL(ath11k_info);
  22. void ath11k_err(struct ath11k_base *ab, const char *fmt, ...)
  23. {
  24. struct va_format vaf = {
  25. .fmt = fmt,
  26. };
  27. va_list args;
  28. va_start(args, fmt);
  29. vaf.va = &args;
  30. dev_err(ab->dev, "%pV", &vaf);
  31. trace_ath11k_log_err(ab, &vaf);
  32. va_end(args);
  33. }
  34. EXPORT_SYMBOL(ath11k_err);
  35. void ath11k_warn(struct ath11k_base *ab, const char *fmt, ...)
  36. {
  37. struct va_format vaf = {
  38. .fmt = fmt,
  39. };
  40. va_list args;
  41. va_start(args, fmt);
  42. vaf.va = &args;
  43. dev_warn_ratelimited(ab->dev, "%pV", &vaf);
  44. trace_ath11k_log_warn(ab, &vaf);
  45. va_end(args);
  46. }
  47. EXPORT_SYMBOL(ath11k_warn);
  48. #ifdef CONFIG_ATH11K_DEBUG
  49. void __ath11k_dbg(struct ath11k_base *ab, enum ath11k_debug_mask mask,
  50. const char *fmt, ...)
  51. {
  52. struct va_format vaf;
  53. va_list args;
  54. va_start(args, fmt);
  55. vaf.fmt = fmt;
  56. vaf.va = &args;
  57. if (ath11k_debug_mask & mask)
  58. dev_printk(KERN_DEBUG, ab->dev, "%s %pV", ath11k_dbg_str(mask), &vaf);
  59. trace_ath11k_log_dbg(ab, mask, &vaf);
  60. va_end(args);
  61. }
  62. EXPORT_SYMBOL(__ath11k_dbg);
  63. void ath11k_dbg_dump(struct ath11k_base *ab,
  64. enum ath11k_debug_mask mask,
  65. const char *msg, const char *prefix,
  66. const void *buf, size_t len)
  67. {
  68. char linebuf[256];
  69. size_t linebuflen;
  70. const void *ptr;
  71. if (ath11k_debug_mask & mask) {
  72. if (msg)
  73. __ath11k_dbg(ab, mask, "%s\n", msg);
  74. for (ptr = buf; (ptr - buf) < len; ptr += 16) {
  75. linebuflen = 0;
  76. linebuflen += scnprintf(linebuf + linebuflen,
  77. sizeof(linebuf) - linebuflen,
  78. "%s%08x: ",
  79. (prefix ? prefix : ""),
  80. (unsigned int)(ptr - buf));
  81. hex_dump_to_buffer(ptr, len - (ptr - buf), 16, 1,
  82. linebuf + linebuflen,
  83. sizeof(linebuf) - linebuflen, true);
  84. dev_printk(KERN_DEBUG, ab->dev, "%s\n", linebuf);
  85. }
  86. }
  87. /* tracing code doesn't like null strings */
  88. trace_ath11k_log_dbg_dump(ab, msg ? msg : "", prefix ? prefix : "",
  89. buf, len);
  90. }
  91. EXPORT_SYMBOL(ath11k_dbg_dump);
  92. #endif /* CONFIG_ATH11K_DEBUG */