blob: b004f6cf4a37a93eb8c4fc5033b6eaa4edea198e [file] [log] [blame]
chrmhoffmannbb97ca42017-05-13 21:27:44 +02001/*
2 * Copyright (c) 2012-2015 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#ifndef __HDD_TDSL_H
29#define __HDD_TDSL_H
30/**===========================================================================
31
32\file wlan_hdd_tdls.h
33
34\brief Linux HDD TDLS include file
35==========================================================================*/
36
37#ifdef FEATURE_WLAN_TDLS
38
39#define MAX_NUM_TDLS_PEER 3
40
41#define TDLS_SUB_DISCOVERY_PERIOD 100
42
43#define TDLS_MAX_DISCOVER_REQS_PER_TIMER 1
44
45#define TDLS_DISCOVERY_PERIOD 3600000
46
47#define TDLS_TX_STATS_PERIOD 3600000
48
49#define TDLS_IMPLICIT_TRIGGER_PKT_THRESHOLD 100
50
51#define TDLS_RX_IDLE_TIMEOUT 5000
52
53#define TDLS_RSSI_TRIGGER_HYSTERESIS 50
54
55/* before UpdateTimer expires, we want to timeout discovery response.
56should not be more than 2000 */
57#define TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE 1000
58
59#define TDLS_CTX_MAGIC 0x54444c53 // "TDLS"
60
61#define TDLS_MAX_SCAN_SCHEDULE 10
62#define TDLS_MAX_SCAN_REJECT 5
63#define TDLS_DELAY_SCAN_PER_CONNECTION 100
64
65#define TDLS_IS_CONNECTED(peer) \
66 ((eTDLS_LINK_CONNECTED == (peer)->link_status) || \
67 (eTDLS_LINK_TEARING == (peer)->link_status))
68
69/* TDLS Off Channel Bandwidth Offset */
70#define TDLS_OFF_CHANNEL_BW_OFFSET 0
71
72/* TDLS Channel Switch Request */
73#define TDLS_CHANNEL_SWITCH_ENABLE 1
74#define TDLS_CHANNEL_SWITCH_DISABLE 2
75
76typedef struct
77{
78 tANI_U32 tdls;
79 tANI_U32 tx_period_t;
80 tANI_U32 tx_packet_n;
81 tANI_U32 discovery_period_t;
82 tANI_U32 discovery_tries_n;
83 tANI_U32 idle_timeout_t;
84 tANI_U32 idle_packet_n;
85 tANI_U32 rssi_hysteresis;
86 tANI_S32 rssi_trigger_threshold;
87 tANI_S32 rssi_teardown_threshold;
88} tdls_config_params_t;
89
90typedef struct
91{
92 struct wiphy *wiphy;
93#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
94 struct net_device *dev;
95#endif
96 struct cfg80211_scan_request *scan_request;
97 int magic;
98 int attempt;
99 int reject;
100 struct delayed_work tdls_scan_work;
101} tdls_scan_context_t;
102
103typedef enum {
104 eTDLS_SUPPORT_NOT_ENABLED = 0,
105 eTDLS_SUPPORT_DISABLED, /* suppress implicit trigger and not respond to the peer */
106 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY, /* suppress implicit trigger, but respond to the peer */
107 eTDLS_SUPPORT_ENABLED, /* implicit trigger */
108} eTDLSSupportMode;
109
110typedef enum eTDLSCapType{
111 eTDLS_CAP_NOT_SUPPORTED = -1,
112 eTDLS_CAP_UNKNOWN = 0,
113 eTDLS_CAP_SUPPORTED = 1,
114} tTDLSCapType;
115
116typedef enum eTDLSLinkStatus {
117 eTDLS_LINK_IDLE = 0,
118 eTDLS_LINK_DISCOVERING,
119 eTDLS_LINK_DISCOVERED,
120 eTDLS_LINK_CONNECTING,
121 eTDLS_LINK_CONNECTED,
122 eTDLS_LINK_TEARING,
123} tTDLSLinkStatus;
124
125
126typedef enum {
127 eTDLS_LINK_SUCCESS, /* Success */
128 eTDLS_LINK_UNSPECIFIED = -1, /* Unspecified reason */
129 eTDLS_LINK_NOT_SUPPORTED = -2, /* Remote side doesn't support TDLS */
130 eTDLS_LINK_UNSUPPORTED_BAND = -3, /* Remote side doesn't support this band */
131 eTDLS_LINK_NOT_BENEFICIAL = -4, /* Going to AP is better than going direct */
132 eTDLS_LINK_DROPPED_BY_REMOTE = -5 /* Remote side doesn't want it anymore */
133} tTDLSLinkReason;
134
135typedef struct {
136 int channel; /* channel hint, in channel number (NOT frequency ) */
137 int global_operating_class; /* operating class to use */
138 int max_latency_ms; /* max latency that can be tolerated by apps */
139 int min_bandwidth_kbps; /* bandwidth required by apps, in kilo bits per second */
140} tdls_req_params_t;
141
142typedef enum {
143 WIFI_TDLS_DISABLED, /* TDLS is not enabled, or is disabled now */
144 WIFI_TDLS_ENABLED, /* TDLS is enabled, but not yet tried */
145 WIFI_TDLS_TRYING, /* Direct link is being attempted (optional) */
146 WIFI_TDLS_ESTABLISHED, /* Direct link is established */
147 WIFI_TDLS_ESTABLISHED_OFF_CHANNEL, /* Direct link is established using MCC */
148 WIFI_TDLS_DROPPED, /* Direct link was established, but is now dropped */
149 WIFI_TDLS_FAILED /* Direct link failed */
150} tdls_state_t;
151
152typedef int (*cfg80211_exttdls_callback)(
153#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
154 const tANI_U8* mac,
155#else
156 tANI_U8* mac,
157#endif
158 tANI_S32 state,
159 tANI_S32 reason,
160 void *ctx);
161typedef struct {
162 tANI_U16 period;
163 tANI_U16 bytes;
164} tdls_tx_tput_config_t;
165
166typedef struct {
167 tANI_U16 period;
168 tANI_U16 tries;
169} tdls_discovery_config_t;
170
171typedef struct {
172 tANI_U16 timeout;
173} tdls_rx_idle_config_t;
174
175typedef struct {
176 tANI_U16 rssi_thres;
177} tdls_rssi_config_t;
178
179struct _hddTdlsPeer_t;
180
181typedef struct {
182 struct list_head peer_list[256];
183 hdd_adapter_t *pAdapter;
184#ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER
185 vos_timer_t peerDiscoverTimer;
186#endif
187 vos_timer_t peerUpdateTimer;
188 vos_timer_t peerDiscoveryTimeoutTimer;
189 tdls_config_params_t threshold_config;
190 tANI_S32 discovery_peer_cnt;
191 tANI_U32 discovery_sent_cnt;
192 tANI_S8 ap_rssi;
193 struct _hddTdlsPeer_t *curr_candidate;
194 struct work_struct implicit_setup;
195 v_U32_t magic;
196} tdlsCtx_t;
197
198typedef struct _hddTdlsPeer_t {
199 struct list_head node;
200 tdlsCtx_t *pHddTdlsCtx;
201 tSirMacAddr peerMac;
202 tANI_U16 staId ;
203 tANI_S8 rssi;
204 tTDLSCapType tdls_support;
205 tTDLSLinkStatus link_status;
206 tANI_U8 signature;
207 tANI_U8 is_responder;
208 tANI_U8 discovery_processed;
209 tANI_U16 discovery_attempt;
210 tANI_U16 tx_pkt;
211 tANI_U16 rx_pkt;
212 tANI_U8 uapsdQueues;
213 tANI_U8 qos;
214 tANI_U8 maxSp;
215 tANI_U8 isBufSta;
216 tANI_U8 isOffChannelSupported;
217 tANI_U8 supported_channels_len;
218 tANI_U8 supported_channels[SIR_MAC_MAX_SUPP_CHANNELS];
219 tANI_U8 supported_oper_classes_len;
220 tANI_U8 supported_oper_classes[SIR_MAC_MAX_SUPP_OPER_CLASSES];
221 vos_timer_t peerIdleTimer;
222 vos_timer_t initiatorWaitTimeoutTimer;
223 tANI_BOOLEAN isForcedPeer;
224 /*EXT TDLS*/
225 tTDLSLinkReason reason;
226 cfg80211_exttdls_callback state_change_notification;
227 tANI_BOOLEAN isOffChannelConfigured;
228 tANI_BOOLEAN isOffChannelEstablished;
229 tdls_req_params_t peerParams;
230} hddTdlsPeer_t;
231
232typedef struct {
233 /* Session ID */
234 tANI_U8 sessionId;
235 /*TDLS peer station id */
236 v_U8_t staId;
237 /* TDLS peer mac Address */
238 v_MACADDR_t peerMac;
239} tdlsConnInfo_t;
240
241int wlan_hdd_sta_tdls_init(hdd_adapter_t *pAdapter);
242
243void wlan_hdd_tdls_init(hdd_context_t * pHddCtx);
244
245void wlan_hdd_tdls_exit(hdd_adapter_t *pAdapter, tANI_BOOLEAN mutexLock);
246
247void wlan_hdd_tdls_extract_da(struct sk_buff *skb, u8 *mac);
248
249void wlan_hdd_tdls_extract_sa(struct sk_buff *skb, u8 *mac);
250
251int wlan_hdd_tdls_increment_pkt_count(hdd_adapter_t *pAdapter,
252#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
253 const u8 *mac,
254#else
255 u8 *mac,
256#endif
257 u8 tx);
258
259int wlan_hdd_tdls_set_sta_id(hdd_adapter_t *pAdapter,
260#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
261 const u8 *mac,
262#else
263 u8 *mac,
264#endif
265 u8 staId);
266
267hddTdlsPeer_t *wlan_hdd_tdls_find_peer(hdd_adapter_t *pAdapter,
268#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
269 const u8 *mac,
270#else
271 u8 *mac,
272#endif
273 tANI_BOOLEAN mutexLock);
274
275hddTdlsPeer_t *wlan_hdd_tdls_find_all_peer(hdd_context_t *pHddCtx,
276#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
277 const u8 *mac
278#else
279 u8 *mac
280#endif
281);
282
283int wlan_hdd_tdls_get_link_establish_params(hdd_adapter_t *pAdapter,
284#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
285 const u8 *mac,
286#else
287 u8 *mac,
288#endif
289 tCsrTdlsLinkEstablishParams* tdlsLinkEstablishParams);
290hddTdlsPeer_t *wlan_hdd_tdls_get_peer(hdd_adapter_t *pAdapter,
291#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
292 const u8 *mac
293#else
294 u8 *mac
295#endif
296 );
297
298int wlan_hdd_tdls_set_cap(hdd_adapter_t *pAdapter,
299#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
300 const u8* mac,
301#else
302 u8* mac,
303#endif
304 tTDLSCapType cap);
305
306void wlan_hdd_tdls_set_peer_link_status(hddTdlsPeer_t *curr_peer,
307 tTDLSLinkStatus status,
308 tTDLSLinkReason reason);
309void wlan_hdd_tdls_set_link_status(hdd_adapter_t *pAdapter,
310#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
311 const u8 *mac,
312#else
313 u8 *mac,
314#endif
315 tTDLSLinkStatus linkStatus,
316 tTDLSLinkReason reason);
317
318int wlan_hdd_tdls_recv_discovery_resp(hdd_adapter_t *pAdapter, u8 *mac);
319
320int wlan_hdd_tdls_set_peer_caps(hdd_adapter_t *pAdapter,
321#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
322 const u8 *mac,
323#else
324 u8 *mac,
325#endif
326 tCsrStaParams *StaParams,
327 tANI_BOOLEAN isBufSta,
Gururaj Patil6b8abb32019-09-23 13:48:29 +0000328 tANI_BOOLEAN isOffChannelSupported);
chrmhoffmannbb97ca42017-05-13 21:27:44 +0200329
330int wlan_hdd_tdls_set_rssi(hdd_adapter_t *pAdapter,
331#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
332 const u8 *mac,
333#else
334 u8 *mac,
335#endif
336 tANI_S8 rxRssi);
337
338int wlan_hdd_tdls_set_responder(hdd_adapter_t *pAdapter,
339#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
340 const u8 *mac,
341#else
342 u8 *mac,
343#endif
344 tANI_U8 responder);
345
346int wlan_hdd_tdls_get_responder(hdd_adapter_t *pAdapter, u8 *mac);
347
348int wlan_hdd_tdls_set_signature(hdd_adapter_t *pAdapter,
349#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
350 const u8 *mac,
351#else
352 u8 *mac,
353#endif
354 tANI_U8 uSignature);
355
356int wlan_hdd_tdls_set_params(struct net_device *dev, tdls_config_params_t *config);
357
358int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter,
359#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
360 const u8 *mac
361#else
362 u8 *mac
363#endif
364 );
365
366tANI_U16 wlan_hdd_tdlsConnectedPeers(hdd_adapter_t *pAdapter);
367
368int wlan_hdd_tdls_get_all_peers(hdd_adapter_t *pAdapter, char *buf, int buflen);
369
370void wlan_hdd_tdls_connection_callback(hdd_adapter_t *pAdapter);
371
372void wlan_hdd_tdls_disconnection_callback(hdd_adapter_t *pAdapter);
373
374void wlan_hdd_tdls_mgmt_completion_callback(hdd_adapter_t *pAdapter, tANI_U32 statusCode);
375
376void wlan_hdd_tdls_increment_peer_count(hdd_adapter_t *pAdapter);
377
378void wlan_hdd_tdls_decrement_peer_count(hdd_adapter_t *pAdapter);
379
380void wlan_hdd_tdls_check_bmps(hdd_adapter_t *pAdapter);
381
382u8 wlan_hdd_tdls_is_peer_progress(hdd_adapter_t *pAdapter, u8 *mac);
383
384hddTdlsPeer_t *wlan_hdd_tdls_is_progress(hdd_context_t *pHddCtx,
385#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
386 const u8 *mac,
387#else
388 u8 *mac,
389#endif
390 u8 skip_self, tANI_BOOLEAN mutexLock);
391
392void wlan_hdd_tdls_set_mode(hdd_context_t *pHddCtx,
393 eTDLSSupportMode tdls_mode,
394 v_BOOL_t bUpdateLast);
395
396tANI_U32 wlan_hdd_tdls_discovery_sent_cnt(hdd_context_t *pHddCtx);
397
398void wlan_hdd_tdls_check_power_save_prohibited(hdd_adapter_t *pAdapter);
399
400void wlan_hdd_tdls_free_scan_request (tdls_scan_context_t *tdls_scan_ctx);
401
402int wlan_hdd_tdls_copy_scan_context(hdd_context_t *pHddCtx,
403 struct wiphy *wiphy,
404#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
405 struct net_device *dev,
406#endif
407 struct cfg80211_scan_request *request);
408
409int wlan_hdd_tdls_scan_callback (hdd_adapter_t *pAdapter,
410 struct wiphy *wiphy,
411#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
412 struct net_device *dev,
413#endif
414 struct cfg80211_scan_request *request);
415
416void wlan_hdd_tdls_scan_done_callback(hdd_adapter_t *pAdapter);
417
418void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter,
419 vos_timer_t *timer,
420 v_U32_t expirationTime);
421void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter,
422 hddTdlsPeer_t *curr_peer,
423 tANI_U16 reason);
424
425int wlan_hdd_tdls_set_force_peer(hdd_adapter_t *pAdapter,
426#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
427 const u8 *mac,
428#else
429 u8 *mac,
430#endif
431 tANI_BOOLEAN forcePeer);
432int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
433#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
434 const u8 *peer
435#else
436 u8 *peer
437#endif
438);
439int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
440#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
441 const u8 *peer,
442#else
443 u8 *peer,
444#endif
445 tdls_req_params_t *tdls_peer_params,
446 cfg80211_exttdls_callback callback);
447void hdd_tdls_notify_mode_change(hdd_adapter_t *pAdapter,
448 hdd_context_t *pHddCtx);
449void wlan_hdd_tdls_disable_offchan_and_teardown_links(hdd_context_t *pHddCtx);
450/*EXT TDLS*/
451int wlan_hdd_tdls_get_status(hdd_adapter_t *pAdapter,
452#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
453 const tANI_U8* mac,
454#else
455 tANI_U8* mac,
456#endif
457 tANI_S32 *state,
458 tANI_S32 *reason);
459void wlan_hdd_tdls_get_wifi_hal_state(hddTdlsPeer_t *curr_peer,
460 tANI_S32 *state,
461 tANI_S32 *reason);
462int wlan_hdd_set_callback(hddTdlsPeer_t *curr_peer,
463 cfg80211_exttdls_callback callback);
464int hdd_set_tdls_scan_type(hdd_adapter_t *pAdapter,
465 tANI_U8 *ptr);
466
467// tdlsoffchan
468hddTdlsPeer_t *wlan_hdd_tdls_get_connected_peer(hdd_adapter_t *pAdapter);
469
470int wlan_hdd_validate_tdls_context(hdd_context_t *pHddCtx, tdlsCtx_t *pTdlsCtx);
471
472void wlan_hdd_tdls_reenable(hdd_context_t *pHddCtx);
473#else
474static inline void hdd_tdls_notify_mode_change(hdd_adapter_t *pAdapter,
475 hdd_context_t *pHddCtx)
476{
477}
478static inline void
479wlan_hdd_tdls_disable_offchan_and_teardown_links(hdd_context_t *pHddCtx)
480{
481}
482static inline void
483wlan_hdd_tdls_reenable(hdd_context_t *pHddCtx)
484{
485}
486#endif
487void wlan_hdd_tdls_update_rx_pkt_cnt_n_rssi(hdd_adapter_t *pAdapter,
488 u8 *mac, v_S7_t rssiAvg);
489
490
491tdlsConnInfo_t *wlan_hdd_get_conn_info(hdd_context_t *pHddCtx,
492 tANI_U8 idx);
493
494v_VOID_t wlan_hdd_tdls_initiator_wait_cb(v_PVOID_t userData);
495
496#endif // __HDD_TDSL_H