xref: /wlan-dirver/qca-wifi-host-cmn/qdf/inc/qdf_notifier.h (revision 6d768494e5ce14eb1603a695c86739d12ecc6ec2)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /**
18  * @file qdf_notifier.h
19  * This file abstracts notifier chain call operations.
20  */
21 
22 #ifndef _QDF_NOTIFIER_H
23 #define _QDF_NOTIFIER_H
24 
25 #include <i_qdf_notifier.h>
26 #include <qdf_status.h>
27 
28 /*
29  * qdf_notif_block - qdf notifier block
30  * @__qdf_notifier_block: OS specific notifier block
31  * @priv_data: private data of the notifier block
32  */
33 typedef struct  {
34 	__qdf_notifier_block notif_block;
35 	void *priv_data;
36 } qdf_notif_block;
37 
38 typedef __qdf_blocking_notif_head qdf_blocking_notif_head;
39 typedef __qdf_atomic_notif_head qdf_atomic_notif_head;
40 typedef __qdf_notifier_block qdf_notifier_block;
41 
42 #ifdef WLAN_HANG_EVENT
43 
44 /**
45  * qdf_register_blocking_notifier_chain() - Register for blocking notifier chain
46  * @qdf_blocking_notif_head: Head of blocking notifier chain
47  * @qdf_notif_block: Notifier Block to be registered for this head chain
48  *
49  * This function is invoked to add a notifier block for the specific notifier
50  * head chain.
51  *
52  * Return: QDF_STATUS
53  */
54 
55 QDF_STATUS qdf_register_blocking_notifier_chain(qdf_blocking_notif_head *head,
56 						qdf_notif_block *qnb);
57 /**
58  * qdf_unregister_blocking_notifier_chain() - Unregister for blocking notifier
59  * chain
60  * @qdf_blocking_notif_head: Head of blocking notifier chain
61  * @qdf_notif_block: Notifier Block to be registered for this head chain
62  *
63  * This function is invoked to remove a notifier block for the specific notifier
64  * head chain.
65  *
66  * Return: QDF_STATUS
67  */
68 
69 QDF_STATUS qdf_unregister_blocking_notifier_chain(qdf_blocking_notif_head *head,
70 						  qdf_notif_block *qnb);
71 /**
72  * qdf_blocking_notfier_call() - Invoke the function in the blocking chain
73  * @qdf_blocking_notif_head: Head of blocking notifier chain
74  * @state: state passed during the invoking of the notifier
75  * @data: Private data to be passed to all the notifier functions
76  *
77  * This function is called to invoke all the notifier blocks for the specific
78  * notifier chain with state and private data.
79  * when success the notifier reply with NOTIFY_OK.
80  *
81  * Return: QDF_STATUS
82  */
83 
84 QDF_STATUS qdf_blocking_notfier_call(qdf_blocking_notif_head *head,
85 				     unsigned long state, void *data);
86 
87 /**
88  * qdf_register_atomic_notifier_chain() - Register for atomic notifier chain
89  * @qdf_blocking_notif_head: Head of atomic notifier chain
90  * @qdf_notif_block: Notifier Block to be registered for this head chain
91  *
92  * This function is invoked to add a notifier block for the specific atomic
93  * notifier head chain.
94  *
95  * Return: QDF_STATUS
96  */
97 
98 QDF_STATUS qdf_register_atomic_notifier_chain(qdf_atomic_notif_head *head,
99 					      qdf_notif_block *qnb);
100 /**
101  * qdf_unregister_atmoic_notifier_chain() - Unregister for atomic notifier
102  * chain
103  * @qdf_blocking_notif_head: Head of blocking notifier chain
104  * @qdf_notif_block: Notifier Block to be registered for this head chain
105  *
106  * This function is invoked to remove a notifier block for the specific notifier
107  * head chain.
108  *
109  * Return: QDF_STATUS
110  */
111 
112 QDF_STATUS qdf_unregister_atomic_notifier_chain(qdf_atomic_notif_head *head,
113 						qdf_notif_block *qnb);
114 /**
115  * qdf_blocking_notfier_call() - Invoke the function in the blocking chain
116  * @qdf_blocking_notif_head: Head of blocking notifier chain
117  * @v: Generally state passed during the invoking of the notifier
118  * @data: Private data to be passed to all the notifier functions
119  *
120  * This function is invoke a notifier block for the specific notifier head chain
121  * with state and private data. when success the notifier reply with NOTIFY_OK.
122  *
123  * Return: QDF_STATUS
124  */
125 
126 QDF_STATUS qdf_atomic_notfier_call(qdf_atomic_notif_head *head,
127 				   unsigned long v, void *data);
128 #else
129 
130 static inline QDF_STATUS qdf_register_blocking_notifier_chain(
131 						qdf_blocking_notif_head *head,
132 						qdf_notif_block *qnb)
133 {
134 	return QDF_STATUS_SUCCESS;
135 }
136 
137 static inline QDF_STATUS qdf_unregister_blocking_notifier_chain(
138 						qdf_blocking_notif_head *head,
139 						qdf_notif_block *qnb)
140 {
141 	return QDF_STATUS_SUCCESS;
142 }
143 
144 static inline QDF_STATUS qdf_blocking_notfier_call(
145 						qdf_blocking_notif_head *head,
146 						unsigned long v, void *data)
147 {
148 	return QDF_STATUS_SUCCESS;
149 }
150 
151 static inline QDF_STATUS qdf_register_atomic_notifier_chain(
152 						qdf_atomic_notif_head *head,
153 						qdf_notif_block *qnb)
154 {
155 	return QDF_STATUS_SUCCESS;
156 }
157 
158 static inline QDF_STATUS qdf_unregister_atomic_notifier_chain(
159 						qdf_atomic_notif_head *head,
160 						qdf_notif_block *qnb)
161 {
162 	return QDF_STATUS_SUCCESS;
163 }
164 
165 static inline QDF_STATUS qdf_atomic_notfier_call(qdf_atomic_notif_head *head,
166 						 unsigned long v, void *data)
167 {
168 	return QDF_STATUS_SUCCESS;
169 }
170 #endif
171 
172 #endif
173