xref: /wlan-driver/qca-wifi-host-cmn/qdf/inc/qdf_cpuhp.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2018 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_cpuhp (CPU hotplug)
22  * QCA driver framework (QDF) CPU hotplug APIs
23  */
24 
25 #ifndef __QDF_CPUHP_H
26 #define __QDF_CPUHP_H
27 
28 #include "qdf_status.h"
29 #include "qdf_types.h"
30 
31 /*
32  * struct qdf_cpuhp_handler - an opaque hotplug event registration handle
33  */
34 struct qdf_cpuhp_handler;
35 
36 typedef void (*qdf_cpuhp_callback)(void *context, uint32_t cpu);
37 
38 #ifdef QCA_CONFIG_SMP
39 /**
40  * qdf_cpuhp_init() - Initialize the CPU hotplug event infrastructure
41  *
42  * To be called once, globally.
43  *
44  * Return: None
45  */
46 QDF_STATUS qdf_cpuhp_init(void);
47 
48 /**
49  * qdf_cpuhp_deinit() - De-initialize the CPU hotplug event infrastructure
50  *
51  * To be called once, globally.
52  *
53  * Return: None
54  */
55 QDF_STATUS qdf_cpuhp_deinit(void);
56 
57 /**
58  * qdf_cpuhp_register() - Register for CPU up/down event notifications
59  * @handler: a double pointer to the event registration handle to allocate
60  * @context: an opaque context to pass back to event listeners
61  * @up_callback: the function pointer to invoke for CPU up events
62  * @down_callback: the function pointer to invoke for CPU down events
63  *
64  * "Up" happens just after the CPU is up. Inversely, "down" happens just before
65  * the CPU goes down.
66  *
67  * @handler will point to a valid memory address on success, or NULL on failure.
68  *
69  * Return: QDF_STATUS
70  */
71 QDF_STATUS qdf_cpuhp_register(struct qdf_cpuhp_handler **handler,
72 			      void *context,
73 			      qdf_cpuhp_callback up_callback,
74 			      qdf_cpuhp_callback down_callback);
75 
76 /**
77  * qdf_cpuhp_unregister() - Un-register for CPU up/down event notifications
78  * @handler: a double pointer to the event registration handle to de-allocate
79  *
80  * @handler point to NULL upon completion
81  *
82  * Return: None
83  */
84 void qdf_cpuhp_unregister(struct qdf_cpuhp_handler **handler);
85 #else
qdf_cpuhp_init(void)86 static inline QDF_STATUS qdf_cpuhp_init(void)
87 {
88 	return QDF_STATUS_SUCCESS;
89 }
90 
qdf_cpuhp_deinit(void)91 static inline QDF_STATUS qdf_cpuhp_deinit(void)
92 {
93 	return QDF_STATUS_SUCCESS;
94 }
95 
qdf_cpuhp_register(struct qdf_cpuhp_handler ** handler,void * context,qdf_cpuhp_callback up_callback,qdf_cpuhp_callback down_callback)96 static inline QDF_STATUS qdf_cpuhp_register(struct qdf_cpuhp_handler **handler,
97 					    void *context,
98 					    qdf_cpuhp_callback up_callback,
99 					    qdf_cpuhp_callback down_callback)
100 {
101 	return QDF_STATUS_SUCCESS;
102 }
103 
qdf_cpuhp_unregister(struct qdf_cpuhp_handler ** handler)104 static inline void qdf_cpuhp_unregister(struct qdf_cpuhp_handler **handler) {}
105 #endif /* QCA_CONFIG_SMP */
106 
107 #endif /* __QDF_CPUHP_H */
108