xref: /wlan-driver/qca-wifi-host-cmn/qdf/inc/qdf_dev.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: qdf_dev
22  * QCA driver framework (QDF) device management APIs
23  */
24 
25 #if !defined(__QDF_DEV_H)
26 #define __QDF_DEV_H
27 
28 /* Include Files */
29 #include <qdf_types.h>
30 #include "i_qdf_dev.h"
31 
32 #define qdf_cpumask_pr_args(maskp) __qdf_cpumask_pr_args(maskp)
33 #define qdf_for_each_possible_cpu(cpu) __qdf_for_each_possible_cpu(cpu)
34 #define qdf_for_each_online_cpu(cpu) __qdf_for_each_online_cpu(cpu)
35 #define qdf_for_each_cpu(cpu, maskp) __qdf_for_each_cpu(cpu, maskp)
36 #define qdf_for_each_cpu_not(cpu, maskp) \
37 __qdf_for_each_cpu_not(cpu, maskp)
38 
39 #ifdef ENHANCED_OS_ABSTRACTION
40 /**
41  * qdf_dev_alloc_mem() - allocate memory
42  * @qdfdev: Device handle
43  * @mrptr: Pointer to the allocated memory
44  * @reqsize: Allocation request in bytes
45  * @mask: Property mask to be associated to the allocated memory
46  *
47  * This function will acquire memory to be associated with a device
48  *
49  * Return: QDF_STATUS_SUCCESS on success
50  */
51 QDF_STATUS
52 qdf_dev_alloc_mem(struct qdf_dev *qdfdev, struct qdf_devm **mrptr,
53 		  uint32_t reqsize, uint32_t mask);
54 
55 /**
56  * qdf_dev_release_mem() - release memory
57  * @qdfdev: Device handle
58  * @mrptr: Pointer to the allocated memory
59  *
60  * This function will acquire memory to be associated with a device
61  *
62  * Return: QDF_STATUS_SUCCESS on success
63  */
64 QDF_STATUS
65 qdf_dev_release_mem(struct qdf_dev *qdfdev, struct qdf_devm *mrptr);
66 
67 /**
68  * qdf_dev_modify_irq_status() - modify irq
69  * @irnum: irq number
70  * @cmask: Bitmap to be cleared for the property mask
71  * @smask: Bitmap to be set for the property mask
72  *
73  * This function will acquire memory to be associated with a device
74  *
75  * Return: QDF_STATUS_SUCCESS on success
76  */
77 QDF_STATUS
78 qdf_dev_modify_irq_status(uint32_t irnum, unsigned long cmask,
79 			  unsigned long smask);
80 
81 /**
82  * qdf_dev_set_irq_affinity() - set irq affinity
83  * @irnum: irq number
84  * @cpmask: cpu affinity bitmap
85  *
86  * This function will set the affinity level for an irq
87  *
88  * Return: QDF_STATUS_SUCCESS on success
89  */
90 QDF_STATUS
91 qdf_dev_set_irq_affinity(uint32_t irnum, struct qdf_cpu_mask *cpmask);
92 
93 /**
94  * qdf_dev_set_irq_status_flags() - set irq status flags
95  * @irnum: irq number
96  * @set: status flag to set
97  *
98  * This function will set the status for an irq
99  *
100  * Return: QDF_STATUS_SUCCESS on success
101  */
102 QDF_STATUS
103 qdf_dev_set_irq_status_flags(unsigned int irnum, unsigned long set);
104 
105 /**
106  * qdf_dev_clear_irq_status_flags() - clear irq status flags
107  * @irnum: irq number
108  * @clr: status flag to clear
109  *
110  * This function will clear the status for an irq
111  *
112  * Return: QDF_STATUS_SUCCESS on success
113  */
114 QDF_STATUS
115 qdf_dev_clear_irq_status_flags(unsigned int irnum, unsigned long clr);
116 #else
117 static inline QDF_STATUS
qdf_dev_alloc_mem(struct qdf_dev * qdfdev,struct qdf_devm ** mrptr,uint32_t reqsize,uint32_t mask)118 qdf_dev_alloc_mem(struct qdf_dev *qdfdev, struct qdf_devm **mrptr,
119 		  uint32_t reqsize, uint32_t mask)
120 {
121 	return __qdf_dev_alloc_mem(qdfdev, mrptr, reqsize, mask);
122 }
123 
124 static inline QDF_STATUS
qdf_dev_release_mem(struct qdf_dev * qdfdev,struct qdf_devm * mrptr)125 qdf_dev_release_mem(struct qdf_dev *qdfdev, struct qdf_devm *mrptr)
126 {
127 	return __qdf_dev_release_mem(qdfdev, mrptr);
128 }
129 
130 static inline QDF_STATUS
qdf_dev_modify_irq_status(uint32_t irnum,unsigned long cmask,unsigned long smask)131 qdf_dev_modify_irq_status(uint32_t irnum, unsigned long cmask,
132 			  unsigned long smask)
133 {
134 	return __qdf_dev_modify_irq_status(irnum, cmask, smask);
135 }
136 
137 static inline QDF_STATUS
qdf_dev_set_irq_affinity(uint32_t irnum,struct qdf_cpu_mask * cpmask)138 qdf_dev_set_irq_affinity(uint32_t irnum, struct qdf_cpu_mask *cpmask)
139 {
140 	return __qdf_dev_set_irq_affinity(irnum, cpmask);
141 }
142 
143 static inline QDF_STATUS
qdf_dev_set_irq_status_flags(unsigned int irnum,unsigned long set)144 qdf_dev_set_irq_status_flags(unsigned int irnum, unsigned long set)
145 {
146 	return __qdf_dev_set_irq_status_flags(irnum, set);
147 }
148 
149 static inline QDF_STATUS
qdf_dev_clear_irq_status_flags(unsigned int irnum,unsigned long clr)150 qdf_dev_clear_irq_status_flags(unsigned int irnum, unsigned long clr)
151 {
152 	return __qdf_dev_clear_irq_status_flags(irnum, clr);
153 }
154 #endif
155 
qdf_topology_physical_package_id(unsigned int cpu)156 static inline int qdf_topology_physical_package_id(unsigned int cpu)
157 {
158 	return __qdf_topology_physical_package_id(cpu);
159 }
160 
qdf_cpumask_subset(qdf_cpu_mask * srcp1,const qdf_cpu_mask * srcp2)161 static inline int qdf_cpumask_subset(qdf_cpu_mask *srcp1,
162 				     const qdf_cpu_mask *srcp2)
163 {
164 	return __qdf_cpumask_subset(srcp1, srcp2);
165 }
166 
qdf_cpumask_intersects(qdf_cpu_mask * srcp1,const qdf_cpu_mask * srcp2)167 static inline int qdf_cpumask_intersects(qdf_cpu_mask *srcp1,
168 					 const qdf_cpu_mask *srcp2)
169 {
170 	return __qdf_cpumask_intersects(srcp1, srcp2);
171 }
172 
qdf_core_ctl_set_boost(bool boost)173 static inline int qdf_core_ctl_set_boost(bool boost)
174 {
175 	return __qdf_core_ctl_set_boost(boost);
176 }
177 #endif /* __QDF_DEV_H */
178