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