Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2014 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: cdf_defer.h |
| 30 | * This file abstracts deferred execution contexts. |
| 31 | */ |
| 32 | |
| 33 | #ifndef __CDF_DEFER_H |
| 34 | #define __CDF_DEFER_H |
| 35 | |
| 36 | #include <cdf_types.h> |
| 37 | #include <i_cdf_defer.h> |
| 38 | |
| 39 | /** |
| 40 | * This implements work queues (worker threads, kernel threads etc.). |
| 41 | * Note that there is no cancel on a scheduled work. You cannot free a work |
| 42 | * item if its queued. You cannot know if a work item is queued or not unless |
| 43 | * its running, whence you know its not queued. |
| 44 | * |
| 45 | * so if, say, a module is asked to unload itself, how exactly will it make |
| 46 | * sure that the work's not queued, for OS'es that dont provide such a |
| 47 | * mechanism?? |
| 48 | */ |
| 49 | |
| 50 | /* cdf_work_t - representation of a work queue */ |
| 51 | typedef __cdf_work_t cdf_work_t; |
| 52 | |
| 53 | /* cdf_work_t - representation of a bottom half */ |
| 54 | typedef __cdf_bh_t cdf_bh_t; |
| 55 | |
| 56 | /** |
| 57 | * cdf_create_bh() - this creates the Bottom half deferred handler |
| 58 | * @hdl: OS handle |
| 59 | * @bh: Bottom instance |
| 60 | * @func: Func deferred function to run at bottom half interrupt |
| 61 | * context |
| 62 | * Return: None |
| 63 | */ |
| 64 | static inline void |
| 65 | cdf_create_bh(cdf_handle_t hdl, cdf_bh_t *bh, cdf_defer_fn_t func, void *arg) |
| 66 | { |
| 67 | __cdf_init_bh(hdl, bh, func, arg); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * cdf_sched_bh() - schedule a bottom half (DPC) |
| 72 | * @hdl: OS handle |
| 73 | * @bh: Bottom instance |
| 74 | * |
| 75 | * Return: None |
| 76 | */ |
| 77 | static inline void cdf_sched_bh(cdf_handle_t hdl, cdf_bh_t *bh) |
| 78 | { |
| 79 | __cdf_sched_bh(hdl, bh); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * cdf_destroy_bh() - destroy a bottom half (DPC) |
| 84 | * @hdl: OS handle |
| 85 | * @bh: Bottom instance |
| 86 | * |
| 87 | * Return: None |
| 88 | */ |
| 89 | static inline void cdf_destroy_bh(cdf_handle_t hdl, cdf_bh_t *bh) |
| 90 | { |
| 91 | __cdf_disable_bh(hdl, bh); |
| 92 | } |
| 93 | |
| 94 | /*********************Non-Interrupt Context deferred Execution***************/ |
| 95 | |
| 96 | /** |
| 97 | * cdf_create_work() - create a work/task queue, This runs in non-interrupt |
| 98 | * context, so can be preempted by H/W & S/W intr |
| 99 | * @hdl: OS handle |
| 100 | * @work: Work instance |
| 101 | * @func: Deferred function to run at bottom half non-interrupt |
| 102 | * context |
| 103 | * @arg: Argument for the deferred function |
| 104 | * |
| 105 | * Return: None |
| 106 | */ |
| 107 | static inline void |
| 108 | cdf_create_work(cdf_handle_t hdl, cdf_work_t *work, |
| 109 | cdf_defer_fn_t func, void *arg) |
| 110 | { |
| 111 | __cdf_init_work(hdl, work, func, arg); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * cdf_sched_work() - schedule a deferred task on non-interrupt context |
| 116 | * @hdl: OS handle |
| 117 | * @work: Work instance |
| 118 | * |
| 119 | * Return: None |
| 120 | */ |
| 121 | static inline void cdf_sched_work(cdf_handle_t hdl, cdf_work_t *work) |
| 122 | { |
| 123 | __cdf_sched_work(hdl, work); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * cdf_destroy_work() - destroy the deferred task (synchronous) |
| 128 | * @hdl: OS handle |
| 129 | * @work: Work instance |
| 130 | * |
| 131 | * Return: None |
| 132 | */ |
| 133 | static inline void cdf_destroy_work(cdf_handle_t hdl, cdf_work_t *work) |
| 134 | { |
| 135 | __cdf_disable_work(hdl, work); |
| 136 | } |
| 137 | |
| 138 | #endif /*__CDF_DEFER_H*/ |