xref: /wlan-driver/qca-wifi-host-cmn/qdf/src/qdf_debug_domain.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2017 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  *
4*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
5*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
6*5113495bSYour Name  * above copyright notice and this permission notice appear in all
7*5113495bSYour Name  * copies.
8*5113495bSYour Name  *
9*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
17*5113495bSYour Name  */
18*5113495bSYour Name 
19*5113495bSYour Name /**
20*5113495bSYour Name  * DOC: qdf_debug_domain
21*5113495bSYour Name  * QCA driver framework (QDF) debug domain APIs. Debug domains are used to track
22*5113495bSYour Name  * resource allocations across different driver states, particularly for runtime
23*5113495bSYour Name  * leak detection.
24*5113495bSYour Name  */
25*5113495bSYour Name 
26*5113495bSYour Name #include "qdf_debug_domain.h"
27*5113495bSYour Name #include "qdf_trace.h"
28*5113495bSYour Name 
29*5113495bSYour Name static enum qdf_debug_domain qdf_debug_domain_current = QDF_DEBUG_DOMAIN_INIT;
30*5113495bSYour Name 
qdf_debug_domain_get(void)31*5113495bSYour Name enum qdf_debug_domain qdf_debug_domain_get(void)
32*5113495bSYour Name {
33*5113495bSYour Name 	return qdf_debug_domain_current;
34*5113495bSYour Name }
35*5113495bSYour Name 
qdf_debug_domain_set(enum qdf_debug_domain domain)36*5113495bSYour Name void qdf_debug_domain_set(enum qdf_debug_domain domain)
37*5113495bSYour Name {
38*5113495bSYour Name 	QDF_BUG(qdf_debug_domain_valid(domain));
39*5113495bSYour Name 	if (!qdf_debug_domain_valid(domain))
40*5113495bSYour Name 		return;
41*5113495bSYour Name 
42*5113495bSYour Name 	qdf_debug_domain_current = domain;
43*5113495bSYour Name }
44*5113495bSYour Name 
qdf_debug_domain_name(enum qdf_debug_domain domain)45*5113495bSYour Name const char *qdf_debug_domain_name(enum qdf_debug_domain domain)
46*5113495bSYour Name {
47*5113495bSYour Name 	switch (domain) {
48*5113495bSYour Name 	case QDF_DEBUG_DOMAIN_INIT:
49*5113495bSYour Name 		return "Init";
50*5113495bSYour Name 	case QDF_DEBUG_DOMAIN_ACTIVE:
51*5113495bSYour Name 		return "Active";
52*5113495bSYour Name 	default:
53*5113495bSYour Name 		return "Invalid";
54*5113495bSYour Name 	}
55*5113495bSYour Name }
56*5113495bSYour Name 
qdf_debug_domain_valid(enum qdf_debug_domain domain)57*5113495bSYour Name bool qdf_debug_domain_valid(enum qdf_debug_domain domain)
58*5113495bSYour Name {
59*5113495bSYour Name 	return domain >= QDF_DEBUG_DOMAIN_INIT &&
60*5113495bSYour Name 		domain < QDF_DEBUG_DOMAIN_COUNT;
61*5113495bSYour Name }
62