xref: /wlan-driver/qca-wifi-host-cmn/qdf/linux/src/qdf_defer.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2014-2019,2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022,2024 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_defer.c
22  * This file provides OS dependent deferred API's.
23  */
24 
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/workqueue.h>
28 
29 #include "i_qdf_defer.h"
30 #include <qdf_module.h>
31 #include <qdf_defer.h>
32 
__qdf_defer_func(struct work_struct * work)33 void __qdf_defer_func(struct work_struct *work)
34 {
35 	__qdf_work_t *ctx = container_of(work, __qdf_work_t, work);
36 
37 	if (!ctx->fn) {
38 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
39 			  "No callback registered !!");
40 		return;
41 	}
42 	ctx->fn(ctx->arg);
43 }
44 qdf_export_symbol(__qdf_defer_func);
45 
__qdf_bh_func(unsigned long arg)46 void __qdf_bh_func(unsigned long arg)
47 {
48 	__qdf_bh_t *ctx = (__qdf_bh_t *)arg;
49 
50 	if (!ctx->fn) {
51 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
52 			  "No callback registered !!");
53 		return;
54 	}
55 	ctx->fn(ctx->arg);
56 }
57 qdf_export_symbol(__qdf_bh_func);
58 
59 #ifdef ENHANCED_OS_ABSTRACTION
60 void
qdf_create_bh(qdf_bh_t * bh,qdf_defer_fn_t func,void * arg)61 qdf_create_bh(qdf_bh_t  *bh, qdf_defer_fn_t  func, void  *arg)
62 {
63 	__qdf_init_bh(bh, func, arg);
64 }
65 
qdf_sched_bh(qdf_bh_t * bh)66 void qdf_sched_bh(qdf_bh_t *bh)
67 {
68 	__qdf_sched_bh(bh);
69 }
70 
qdf_destroy_bh(qdf_bh_t * bh)71 void qdf_destroy_bh(qdf_bh_t *bh)
72 {
73 	__qdf_disable_bh(bh);
74 }
75 
qdf_destroy_work(qdf_handle_t hdl,qdf_work_t * work)76 void qdf_destroy_work(qdf_handle_t hdl, qdf_work_t *work)
77 {
78 	__qdf_disable_work(work);
79 }
80 
81 qdf_export_symbol(qdf_destroy_work);
82 
qdf_flush_work(qdf_work_t * work)83 void qdf_flush_work(qdf_work_t *work)
84 {
85 	__qdf_flush_work(work);
86 }
87 
88 qdf_export_symbol(qdf_flush_work);
89 
qdf_disable_work(qdf_work_t * work)90 uint32_t qdf_disable_work(qdf_work_t *work)
91 {
92 	return __qdf_disable_work(work);
93 }
94 
95 qdf_export_symbol(qdf_disable_work);
96 
qdf_cancel_work(qdf_work_t * work)97 bool qdf_cancel_work(qdf_work_t *work)
98 {
99 	return __qdf_cancel_work(work);
100 }
101 
102 qdf_export_symbol(qdf_cancel_work);
103 
qdf_create_workqueue(char * name)104 qdf_workqueue_t *qdf_create_workqueue(char *name)
105 {
106 	return  __qdf_create_workqueue(name);
107 }
108 
109 qdf_export_symbol(qdf_create_workqueue);
110 
qdf_create_singlethread_workqueue(char * name)111 qdf_workqueue_t *qdf_create_singlethread_workqueue(char *name)
112 {
113 	return  __qdf_create_singlethread_workqueue(name);
114 }
115 
116 qdf_export_symbol(qdf_create_singlethread_workqueue);
117 
qdf_destroy_workqueue(qdf_handle_t hdl,qdf_workqueue_t * wqueue)118 void qdf_destroy_workqueue(qdf_handle_t hdl,
119 			   qdf_workqueue_t *wqueue)
120 {
121 	return  __qdf_destroy_workqueue(wqueue);
122 }
123 
124 qdf_export_symbol(qdf_destroy_workqueue);
125 
qdf_alloc_unbound_workqueue(char * name)126 qdf_workqueue_t *qdf_alloc_unbound_workqueue(char *name)
127 {
128 	return  __qdf_alloc_unbound_workqueue(name);
129 }
130 
131 qdf_export_symbol(qdf_alloc_unbound_workqueue);
132 
qdf_create_work(qdf_handle_t hdl,qdf_work_t * work,qdf_defer_fn_t func,void * arg)133 QDF_STATUS qdf_create_work(qdf_handle_t hdl, qdf_work_t  *work,
134 			   qdf_defer_fn_t  func, void  *arg)
135 {
136 	return __qdf_init_work(work, func, arg);
137 }
138 
139 qdf_export_symbol(qdf_create_work);
140 
qdf_sched_work(qdf_handle_t hdl,qdf_work_t * work)141 bool qdf_sched_work(qdf_handle_t hdl, qdf_work_t *work)
142 {
143 	return __qdf_sched_work(work);
144 }
145 
146 qdf_export_symbol(qdf_sched_work);
147 
148 bool
qdf_queue_work(qdf_handle_t hdl,qdf_workqueue_t * wqueue,qdf_work_t * work)149 qdf_queue_work(qdf_handle_t hdl, qdf_workqueue_t *wqueue, qdf_work_t *work)
150 {
151 	return  __qdf_queue_work(wqueue, work);
152 }
153 
154 qdf_export_symbol(qdf_queue_work);
155 
qdf_flush_workqueue(qdf_handle_t hdl,qdf_workqueue_t * wqueue)156 void qdf_flush_workqueue(qdf_handle_t hdl, qdf_workqueue_t *wqueue)
157 {
158 	return  __qdf_flush_workqueue(wqueue);
159 }
160 
161 qdf_export_symbol(qdf_flush_workqueue);
162 
qdf_local_bh_disable(void)163 void qdf_local_bh_disable(void)
164 {
165 	__qdf_local_bh_disable();
166 }
167 
168 qdf_export_symbol(qdf_local_bh_disable);
169 
qdf_local_bh_enable(void)170 void qdf_local_bh_enable(void)
171 {
172 	__qdf_local_bh_enable();
173 }
174 
175 qdf_export_symbol(qdf_local_bh_enable);
176 #endif
177