xref: /wlan-driver/qca-wifi-host-cmn/qdf/src/qdf_debug_domain.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017 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 
19 /**
20  * DOC: qdf_debug_domain
21  * QCA driver framework (QDF) debug domain APIs. Debug domains are used to track
22  * resource allocations across different driver states, particularly for runtime
23  * leak detection.
24  */
25 
26 #include "qdf_debug_domain.h"
27 #include "qdf_trace.h"
28 
29 static enum qdf_debug_domain qdf_debug_domain_current = QDF_DEBUG_DOMAIN_INIT;
30 
qdf_debug_domain_get(void)31 enum qdf_debug_domain qdf_debug_domain_get(void)
32 {
33 	return qdf_debug_domain_current;
34 }
35 
qdf_debug_domain_set(enum qdf_debug_domain domain)36 void qdf_debug_domain_set(enum qdf_debug_domain domain)
37 {
38 	QDF_BUG(qdf_debug_domain_valid(domain));
39 	if (!qdf_debug_domain_valid(domain))
40 		return;
41 
42 	qdf_debug_domain_current = domain;
43 }
44 
qdf_debug_domain_name(enum qdf_debug_domain domain)45 const char *qdf_debug_domain_name(enum qdf_debug_domain domain)
46 {
47 	switch (domain) {
48 	case QDF_DEBUG_DOMAIN_INIT:
49 		return "Init";
50 	case QDF_DEBUG_DOMAIN_ACTIVE:
51 		return "Active";
52 	default:
53 		return "Invalid";
54 	}
55 }
56 
qdf_debug_domain_valid(enum qdf_debug_domain domain)57 bool qdf_debug_domain_valid(enum qdf_debug_domain domain)
58 {
59 	return domain >= QDF_DEBUG_DOMAIN_INIT &&
60 		domain < QDF_DEBUG_DOMAIN_COUNT;
61 }
62