1 /* 2 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. 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: Declare private data structures and APIs which shall be used 21 * internally only in twt component. 22 * 23 * Note: This API should be never accessed out of twt component. 24 */ 25 26 #ifndef _WLAN_TWT_PRIV_H_ 27 #define _WLAN_TWT_PRIV_H_ 28 29 #include <wlan_twt_public_structs.h> 30 #include <wlan_twt_ext_defs.h> 31 #include <wlan_twt_ext_type.h> 32 33 /** 34 * struct twt_tgt_caps - 35 * @twt_requestor: twt requestor 36 * @twt_responder: twt responder 37 * @legacy_bcast_twt_support: legacy bcast twt support 38 * @twt_bcast_req_support: bcast requestor support 39 * @twt_bcast_res_support: bcast responder support 40 * @twt_nudge_enabled: twt nudge enabled 41 * @all_twt_enabled: all twt enabled 42 * @twt_stats_enabled: twt stats enabled 43 * @twt_ack_supported: twt ack supported 44 * @restricted_twt_support: Restricted TWT supported 45 */ 46 struct twt_tgt_caps { 47 bool twt_requestor; 48 bool twt_responder; 49 bool legacy_bcast_twt_support; 50 bool twt_bcast_req_support; 51 bool twt_bcast_res_support; 52 bool twt_nudge_enabled; 53 bool all_twt_enabled; 54 bool twt_stats_enabled; 55 bool twt_ack_supported; 56 bool restricted_twt_support; 57 }; 58 59 /** 60 * struct twt_psoc_priv_obj - 61 * @cfg_params: cfg params 62 * @twt_caps: twt caps 63 * @enable_context: enable context 64 * @disable_context: disable context 65 */ 66 struct twt_psoc_priv_obj { 67 psoc_twt_ext_cfg_params_t cfg_params; 68 struct twt_tgt_caps twt_caps; 69 struct twt_en_dis_context enable_context; 70 struct twt_en_dis_context disable_context; 71 }; 72 73 /** 74 * struct twt_vdev_priv_obj - 75 * @twt_wait_for_notify: wait for notify 76 * @dialog_id: TWT dialog id 77 * @peer_macaddr: Peer mac address 78 * @next_action: next action of TWT worker queue 79 */ 80 struct twt_vdev_priv_obj { 81 bool twt_wait_for_notify; 82 uint32_t dialog_id; 83 struct qdf_mac_addr peer_macaddr; 84 enum HOST_TWT_NEXT_WORK_ACTION next_action; 85 }; 86 87 /** 88 * struct twt_session - 89 * @dialog_id: dialog id 90 * @state: state 91 * @setup_done: setup done 92 * @active_cmd: active command 93 * @twt_ack_ctx: twt ack context 94 * @wake_dur: TWT wake duration 95 * @wake_interval: TWT wake interval 96 */ 97 struct twt_session { 98 uint8_t dialog_id; 99 uint8_t state; 100 bool setup_done; 101 enum wlan_twt_commands active_cmd; 102 void *twt_ack_ctx; 103 uint32_t wake_dur; 104 uint32_t wake_interval; 105 }; 106 107 /** 108 * struct twt_peer_priv_obj - 109 * @twt_peer_lock: peer lock 110 * @peer_capability: peer capability 111 * @num_twt_sessions: number of twt sessions 112 * @session_info: session info 113 */ 114 struct twt_peer_priv_obj { 115 #ifdef WLAN_TWT_SPINLOCK 116 qdf_spinlock_t twt_peer_lock; 117 #else 118 qdf_mutex_t twt_peer_lock; 119 #endif 120 uint8_t peer_capability; 121 uint8_t num_twt_sessions; 122 struct twt_session session_info 123 [WLAN_MAX_TWT_SESSIONS_PER_PEER]; 124 }; 125 126 #ifdef WLAN_TWT_SPINLOCK 127 /** 128 * twt_lock_create - Create TWT peer mutex/spinlock 129 * @twt_lock: lock object 130 * 131 * Creates TWT peer mutex/spinlock 132 * 133 * Return: void 134 */ 135 static inline void 136 twt_lock_create(qdf_spinlock_t *twt_lock) 137 { 138 qdf_spinlock_create(twt_lock); 139 } 140 141 /** 142 * twt_lock_destroy - Destroy TWT mutex/spinlock 143 * @twt_lock: lock object 144 * 145 * Destroy TWT peer mutex/spinlock 146 * 147 * Return: void 148 */ 149 static inline void 150 twt_lock_destroy(qdf_spinlock_t *twt_lock) 151 { 152 qdf_spinlock_destroy(twt_lock); 153 } 154 155 /** 156 * twt_lock_acquire - acquire TWT mutex/spinlock 157 * @twt_lock: lock object 158 * 159 * acquire TWT mutex/spinlock 160 * 161 * return: void 162 */ 163 static inline void twt_lock_acquire(qdf_spinlock_t *twt_lock) 164 { 165 qdf_spin_lock_bh(twt_lock); 166 } 167 168 /** 169 * twt_lock_release - release TWT mutex/spinlock 170 * @twt_lock: lock object 171 * 172 * release TWT mutex/spinlock 173 * 174 * return: void 175 */ 176 static inline void twt_lock_release(qdf_spinlock_t *twt_lock) 177 { 178 qdf_spin_unlock_bh(twt_lock); 179 } 180 #else 181 static inline void 182 twt_lock_create(qdf_mutex_t *twt_lock) 183 { 184 qdf_mutex_create(twt_lock); 185 } 186 187 static inline void 188 twt_lock_destroy(qdf_mutex_t *twt_lock) 189 { 190 qdf_mutex_destroy(twt_lock); 191 } 192 193 static inline void twt_lock_acquire(qdf_mutex_t *twt_lock) 194 { 195 qdf_mutex_acquire(twt_lock); 196 } 197 198 static inline void twt_lock_release(qdf_mutex_t *twt_lock) 199 { 200 qdf_mutex_release(twt_lock); 201 } 202 #endif /* WLAN_TWT_SPINLOCK */ 203 204 #endif /* End of _WLAN_TWT_PRIV_H_ */ 205 206