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 * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 6 */ 7 8 #include <linux/export.h> 9 #include <linux/vmalloc.h> 10 #include "core.h" 11 #include "debug.h" 12 13 void ath11k_info(struct ath11k_base *ab, const char *fmt, ...) 14 { 15 struct va_format vaf = { 16 .fmt = fmt, 17 }; 18 va_list args; 19 20 va_start(args, fmt); 21 vaf.va = &args; 22 dev_info(ab->dev, "%pV", &vaf); 23 trace_ath11k_log_info(ab, &vaf); 24 va_end(args); 25 } 26 EXPORT_SYMBOL(ath11k_info); 27 28 void ath11k_err(struct ath11k_base *ab, const char *fmt, ...) 29 { 30 struct va_format vaf = { 31 .fmt = fmt, 32 }; 33 va_list args; 34 35 va_start(args, fmt); 36 vaf.va = &args; 37 dev_err(ab->dev, "%pV", &vaf); 38 trace_ath11k_log_err(ab, &vaf); 39 va_end(args); 40 } 41 EXPORT_SYMBOL(ath11k_err); 42 43 void ath11k_warn(struct ath11k_base *ab, const char *fmt, ...) 44 { 45 struct va_format vaf = { 46 .fmt = fmt, 47 }; 48 va_list args; 49 50 va_start(args, fmt); 51 vaf.va = &args; 52 dev_warn_ratelimited(ab->dev, "%pV", &vaf); 53 trace_ath11k_log_warn(ab, &vaf); 54 va_end(args); 55 } 56 EXPORT_SYMBOL(ath11k_warn); 57 58 #ifdef CONFIG_ATH11K_DEBUG 59 60 void __ath11k_dbg(struct ath11k_base *ab, enum ath11k_debug_mask mask, 61 const char *fmt, ...) 62 { 63 struct va_format vaf; 64 va_list args; 65 66 va_start(args, fmt); 67 68 vaf.fmt = fmt; 69 vaf.va = &args; 70 71 if (ath11k_debug_mask & mask) 72 dev_printk(KERN_DEBUG, ab->dev, "%s %pV", ath11k_dbg_str(mask), &vaf); 73 74 trace_ath11k_log_dbg(ab, mask, &vaf); 75 76 va_end(args); 77 } 78 EXPORT_SYMBOL(__ath11k_dbg); 79 80 void ath11k_dbg_dump(struct ath11k_base *ab, 81 enum ath11k_debug_mask mask, 82 const char *msg, const char *prefix, 83 const void *buf, size_t len) 84 { 85 char linebuf[256]; 86 size_t linebuflen; 87 const void *ptr; 88 89 if (ath11k_debug_mask & mask) { 90 if (msg) 91 __ath11k_dbg(ab, mask, "%s\n", msg); 92 93 for (ptr = buf; (ptr - buf) < len; ptr += 16) { 94 linebuflen = 0; 95 linebuflen += scnprintf(linebuf + linebuflen, 96 sizeof(linebuf) - linebuflen, 97 "%s%08x: ", 98 (prefix ? prefix : ""), 99 (unsigned int)(ptr - buf)); 100 hex_dump_to_buffer(ptr, len - (ptr - buf), 16, 1, 101 linebuf + linebuflen, 102 sizeof(linebuf) - linebuflen, true); 103 dev_printk(KERN_DEBUG, ab->dev, "%s\n", linebuf); 104 } 105 } 106 107 /* tracing code doesn't like null strings */ 108 trace_ath11k_log_dbg_dump(ab, msg ? msg : "", prefix ? prefix : "", 109 buf, len); 110 } 111 EXPORT_SYMBOL(ath11k_dbg_dump); 112 113 #endif /* CONFIG_ATH11K_DEBUG */ 114