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