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