1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name *
5*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name * above copyright notice and this permission notice appear in all
8*5113495bSYour Name * copies.
9*5113495bSYour Name *
10*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name */
19*5113495bSYour Name
20*5113495bSYour Name /**
21*5113495bSYour Name * DOC: qdf_cpuhp (CPU hotplug)
22*5113495bSYour Name * QCA driver framework (QDF) CPU hotplug APIs
23*5113495bSYour Name */
24*5113495bSYour Name
25*5113495bSYour Name #ifndef __QDF_CPUHP_H
26*5113495bSYour Name #define __QDF_CPUHP_H
27*5113495bSYour Name
28*5113495bSYour Name #include "qdf_status.h"
29*5113495bSYour Name #include "qdf_types.h"
30*5113495bSYour Name
31*5113495bSYour Name /*
32*5113495bSYour Name * struct qdf_cpuhp_handler - an opaque hotplug event registration handle
33*5113495bSYour Name */
34*5113495bSYour Name struct qdf_cpuhp_handler;
35*5113495bSYour Name
36*5113495bSYour Name typedef void (*qdf_cpuhp_callback)(void *context, uint32_t cpu);
37*5113495bSYour Name
38*5113495bSYour Name #ifdef QCA_CONFIG_SMP
39*5113495bSYour Name /**
40*5113495bSYour Name * qdf_cpuhp_init() - Initialize the CPU hotplug event infrastructure
41*5113495bSYour Name *
42*5113495bSYour Name * To be called once, globally.
43*5113495bSYour Name *
44*5113495bSYour Name * Return: None
45*5113495bSYour Name */
46*5113495bSYour Name QDF_STATUS qdf_cpuhp_init(void);
47*5113495bSYour Name
48*5113495bSYour Name /**
49*5113495bSYour Name * qdf_cpuhp_deinit() - De-initialize the CPU hotplug event infrastructure
50*5113495bSYour Name *
51*5113495bSYour Name * To be called once, globally.
52*5113495bSYour Name *
53*5113495bSYour Name * Return: None
54*5113495bSYour Name */
55*5113495bSYour Name QDF_STATUS qdf_cpuhp_deinit(void);
56*5113495bSYour Name
57*5113495bSYour Name /**
58*5113495bSYour Name * qdf_cpuhp_register() - Register for CPU up/down event notifications
59*5113495bSYour Name * @handler: a double pointer to the event registration handle to allocate
60*5113495bSYour Name * @context: an opaque context to pass back to event listeners
61*5113495bSYour Name * @up_callback: the function pointer to invoke for CPU up events
62*5113495bSYour Name * @down_callback: the function pointer to invoke for CPU down events
63*5113495bSYour Name *
64*5113495bSYour Name * "Up" happens just after the CPU is up. Inversely, "down" happens just before
65*5113495bSYour Name * the CPU goes down.
66*5113495bSYour Name *
67*5113495bSYour Name * @handler will point to a valid memory address on success, or NULL on failure.
68*5113495bSYour Name *
69*5113495bSYour Name * Return: QDF_STATUS
70*5113495bSYour Name */
71*5113495bSYour Name QDF_STATUS qdf_cpuhp_register(struct qdf_cpuhp_handler **handler,
72*5113495bSYour Name void *context,
73*5113495bSYour Name qdf_cpuhp_callback up_callback,
74*5113495bSYour Name qdf_cpuhp_callback down_callback);
75*5113495bSYour Name
76*5113495bSYour Name /**
77*5113495bSYour Name * qdf_cpuhp_unregister() - Un-register for CPU up/down event notifications
78*5113495bSYour Name * @handler: a double pointer to the event registration handle to de-allocate
79*5113495bSYour Name *
80*5113495bSYour Name * @handler point to NULL upon completion
81*5113495bSYour Name *
82*5113495bSYour Name * Return: None
83*5113495bSYour Name */
84*5113495bSYour Name void qdf_cpuhp_unregister(struct qdf_cpuhp_handler **handler);
85*5113495bSYour Name #else
qdf_cpuhp_init(void)86*5113495bSYour Name static inline QDF_STATUS qdf_cpuhp_init(void)
87*5113495bSYour Name {
88*5113495bSYour Name return QDF_STATUS_SUCCESS;
89*5113495bSYour Name }
90*5113495bSYour Name
qdf_cpuhp_deinit(void)91*5113495bSYour Name static inline QDF_STATUS qdf_cpuhp_deinit(void)
92*5113495bSYour Name {
93*5113495bSYour Name return QDF_STATUS_SUCCESS;
94*5113495bSYour Name }
95*5113495bSYour Name
qdf_cpuhp_register(struct qdf_cpuhp_handler ** handler,void * context,qdf_cpuhp_callback up_callback,qdf_cpuhp_callback down_callback)96*5113495bSYour Name static inline QDF_STATUS qdf_cpuhp_register(struct qdf_cpuhp_handler **handler,
97*5113495bSYour Name void *context,
98*5113495bSYour Name qdf_cpuhp_callback up_callback,
99*5113495bSYour Name qdf_cpuhp_callback down_callback)
100*5113495bSYour Name {
101*5113495bSYour Name return QDF_STATUS_SUCCESS;
102*5113495bSYour Name }
103*5113495bSYour Name
qdf_cpuhp_unregister(struct qdf_cpuhp_handler ** handler)104*5113495bSYour Name static inline void qdf_cpuhp_unregister(struct qdf_cpuhp_handler **handler) {}
105*5113495bSYour Name #endif /* QCA_CONFIG_SMP */
106*5113495bSYour Name
107*5113495bSYour Name #endif /* __QDF_CPUHP_H */
108