1 /* 2 * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 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: wlan_tdls_peer.h 22 * 23 * TDLS peer function declaration 24 */ 25 26 #if !defined(_WLAN_TDLS_PEER_H_) 27 #define _WLAN_TDLS_PEER_H_ 28 29 /** 30 * struct tdls_search_peer_param - used to search TDLS peer 31 * @macaddr: MAC address of peer 32 * @peer: pointer to the found peer 33 */ 34 struct tdls_search_peer_param { 35 const uint8_t *macaddr; 36 struct tdls_peer *peer; 37 }; 38 39 /** 40 * struct tdls_search_progress_param - used to search progress TDLS peer 41 * @skip_self: skip self peer 42 * @macaddr: MAC address of peer 43 * @peer: pointer to the found peer 44 */ 45 struct tdls_search_progress_param { 46 uint8_t skip_self; 47 const uint8_t *macaddr; 48 struct tdls_peer *peer; 49 }; 50 51 /** 52 * tdls_get_peer() - find or add an TDLS peer in TDLS vdev object 53 * @vdev_obj: TDLS vdev object 54 * @macaddr: MAC address of peer 55 * 56 * Search the TDLS peer in the hash table and create a new one if not found. 57 * 58 * Return: Pointer to tdls_peer, NULL if failed. 59 */ 60 struct tdls_peer *tdls_get_peer(struct tdls_vdev_priv_obj *vdev_obj, 61 const uint8_t *macaddr); 62 63 /** 64 * tdls_find_peer() - find TDLS peer in TDLS vdev object 65 * @vdev_obj: TDLS vdev object 66 * @macaddr: MAC address of peer 67 * 68 * This is in scheduler thread context, no lock required. 69 * 70 * Return: If peer is found, then it returns pointer to tdls_peer; 71 * otherwise, it returns NULL. 72 */ 73 struct tdls_peer *tdls_find_peer(struct tdls_vdev_priv_obj *vdev_obj, 74 const uint8_t *macaddr); 75 76 /** 77 * tdls_find_all_peer() - find peer matching the input MACaddr in soc range 78 * @soc_obj: TDLS soc object 79 * @macaddr: MAC address of TDLS peer 80 * 81 * This is in scheduler thread context, no lock required. 82 * 83 * Return: TDLS peer if a matching is detected; NULL otherwise 84 */ 85 struct tdls_peer * 86 tdls_find_all_peer(struct tdls_soc_priv_obj *soc_obj, const uint8_t *macaddr); 87 88 /** 89 * tdls_find_opclass() - find Operating Class based upon channel 90 * @psoc: objmgr soc object 91 * @channel:channel number 92 * @bw_offset: offset to bandwidth 93 * 94 * This is in scheduler thread context, no lock required. 95 * 96 * Return: Operating class 97 */ 98 uint8_t tdls_find_opclass(struct wlan_objmgr_psoc *psoc, 99 uint8_t channel, 100 uint8_t bw_offset); 101 102 /** 103 * tdls_find_first_connected_peer() - find the 1st connected tdls peer from vdev 104 * @vdev_obj: tdls vdev object 105 * 106 * This function searches for the 1st connected TDLS peer 107 * 108 * Return: The 1st connected TDLS peer if found; NULL otherwise 109 */ 110 struct tdls_peer * 111 tdls_find_first_connected_peer(struct tdls_vdev_priv_obj *vdev_obj); 112 113 /** 114 * tdls_is_progress() - find the peer with ongoing TDLS progress on present psoc 115 * @vdev_obj: TDLS vdev object 116 * @macaddr: MAC address of the peer 117 * @skip_self: if 1, skip checking self. If 0, search include self 118 * 119 * This is used in scheduler thread context, no lock required. 120 * 121 * Return: TDLS peer if found; NULL otherwise 122 */ 123 struct tdls_peer *tdls_is_progress(struct tdls_vdev_priv_obj *vdev_obj, 124 const uint8_t *macaddr, uint8_t skip_self); 125 126 /** 127 * tdls_get_offchan_freq() - Get preferred offchannel frequency 128 * @vdev: Pointer to vdev 129 * @soc_obj: TDLS SOC object 130 * 131 * This function gets preferred offchannel frequency. 132 * 133 * Return: Preferred offchannel frequency 134 */ 135 qdf_freq_t tdls_get_offchan_freq(struct wlan_objmgr_vdev *vdev, 136 struct tdls_soc_priv_obj *soc_obj); 137 138 /** 139 * tdls_get_offchan_bw() - Get preferred offchannel bandwidth on basis of 140 * frequency 141 * @soc_obj: TDLS SOC object 142 * @off_chan_freq: Offchannel frequency 143 * 144 * 145 * This function gets preferred offchannel bandwidth on basis of frequency. 146 * 147 * Return: Preferred offchannel bw 148 */ 149 uint32_t tdls_get_offchan_bw(struct tdls_soc_priv_obj *soc_obj, 150 qdf_freq_t off_chan_freq); 151 152 /** 153 * tdls_extract_peer_state_param() - extract peer update params from TDL peer 154 * @peer_param: output peer update params 155 * @peer: TDLS peer 156 * 157 * This is used when enable TDLS link 158 * 159 * Return: None. 160 */ 161 void tdls_extract_peer_state_param(struct tdls_peer_update_state *peer_param, 162 struct tdls_peer *peer); 163 164 /** 165 * tdls_set_peer_link_status() - set link statue for TDLS peer 166 * @peer: TDLS peer 167 * @link_state: link state 168 * @link_reason: reason with link status 169 * 170 * This is in scheduler thread context, no lock required. 171 * 172 * Return: None. 173 */ 174 void tdls_set_peer_link_status(struct tdls_peer *peer, 175 enum tdls_link_state link_state, 176 enum tdls_link_state_reason link_reason); 177 178 /** 179 * tdls_set_peer_caps() - set capability for TDLS peer 180 * @vdev_obj: TDLS vdev object 181 * @macaddr: MAC address for the TDLS peer 182 * @req_info: parameters to update peer capability 183 * 184 * This is in scheduler thread context, no lock required. 185 * 186 * Return: None. 187 */ 188 void tdls_set_peer_caps(struct tdls_vdev_priv_obj *vdev_obj, 189 const uint8_t *macaddr, 190 struct tdls_update_peer_params *req_info); 191 192 /** 193 * tdls_set_valid() - set station ID on a TDLS peer 194 * @vdev_obj: TDLS vdev object 195 * @macaddr: MAC address of the TDLS peer 196 * 197 * Return: QDF_STATUS_SUCCESS if success; other values if failed 198 */ 199 QDF_STATUS tdls_set_valid(struct tdls_vdev_priv_obj *vdev_obj, 200 const uint8_t *macaddr); 201 202 /** 203 * tdls_set_force_peer() - set/clear is_forced_peer flag on peer 204 * @vdev_obj: TDLS vdev object 205 * @macaddr: MAC address of TDLS peer 206 * @forcepeer: value used to set is_forced_peer flag 207 * 208 * This is used in scheduler thread context, no lock required. 209 * 210 * Return: QDF_STATUS_SUCCESS if success; other values if failed 211 */ 212 QDF_STATUS tdls_set_force_peer(struct tdls_vdev_priv_obj *vdev_obj, 213 const uint8_t *macaddr, bool forcepeer); 214 215 /** 216 * tdls_set_callback() - set state change callback on current TDLS peer 217 * @peer: TDLS peer 218 * @callback: state change callback 219 * 220 * This is used in scheduler thread context, no lock required. 221 * 222 * Return: QDF_STATUS_SUCCESS if success; other values if failed 223 */ 224 QDF_STATUS tdls_set_callback(struct tdls_peer *peer, 225 tdls_state_change_callback callback); 226 227 /** 228 * tdls_set_extctrl_param() - set external control parameter on TDLS peer 229 * @peer: TDLS peer 230 * @ch_freq: channel frequency 231 * @max_latency: maximum latency 232 * @op_class: operation class 233 * @min_bandwidth: minimal bandwidth 234 * 235 * This is used in scheduler thread context, no lock required. 236 * 237 * Return: QDF_STATUS_SUCCESS if success; other values if failed 238 */ 239 QDF_STATUS tdls_set_extctrl_param(struct tdls_peer *peer, qdf_freq_t ch_freq, 240 uint32_t max_latency, uint32_t op_class, 241 uint32_t min_bandwidth); 242 243 /** 244 * tdls_reset_peer() - reset TDLS peer identified by MAC address 245 * @vdev_obj: TDLS vdev object 246 * @mac: MAC address of the peer 247 * 248 * Return: QDF_STATUS_SUCCESS if success; other values if failed 249 */ 250 QDF_STATUS tdls_reset_peer(struct tdls_vdev_priv_obj *vdev_obj, 251 const uint8_t *mac); 252 253 /** 254 * tdls_peer_idle_timers_destroy() - destroy peer idle timers 255 * @vdev_obj: TDLS vdev object 256 * 257 * Loop through the idle peer list and destroy their timers 258 * 259 * Return: None 260 */ 261 void tdls_peer_idle_timers_destroy(struct tdls_vdev_priv_obj *vdev_obj); 262 263 /** 264 * tdls_free_peer_list() - free TDLS peer list 265 * @vdev_obj: TDLS vdev object 266 * 267 * Free all the tdls peers 268 * 269 * Return: None 270 */ 271 void tdls_free_peer_list(struct tdls_vdev_priv_obj *vdev_obj); 272 #endif 273