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