blob: b0e7a8a1253344ac624ebd81788e3ebe2313590b [file] [log] [blame]
Gopichand Nakkalabd9fa2d2013-01-08 13:16:22 -08001/*
2 * Copyright (c) 2012-2013, 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 */
Kiran V1ccee932012-12-12 14:49:46 -080021#ifndef __HDD_TDSL_H
22#define __HDD_TDSL_H
23/**===========================================================================
24
25\file wlan_hdd_tdls.h
26
27\brief Linux HDD TDLS include file
Gopichand Nakkala0c1331e2013-01-07 22:49:07 -080028
Kiran V1ccee932012-12-12 14:49:46 -080029==========================================================================*/
30
Chilam NG571c65a2013-01-19 12:27:36 +053031#define MAX_NUM_TDLS_PEER 3
Kiran V1ccee932012-12-12 14:49:46 -080032
Gopichand Nakkalac3694582013-02-13 20:51:22 -080033#define TDLS_SUB_DISCOVERY_PERIOD 100
34
35#define TDLS_MAX_DISCOVER_REQS_PER_TIMER 1
Kiran V1ccee932012-12-12 14:49:46 -080036
Chilam NG571c65a2013-01-19 12:27:36 +053037#define TDLS_DISCOVERY_PERIOD 3600000
Kiran V1ccee932012-12-12 14:49:46 -080038
Chilam NG571c65a2013-01-19 12:27:36 +053039#define TDLS_TX_STATS_PERIOD 3600000
40
41#define TDLS_IMPLICIT_TRIGGER_PKT_THRESHOLD 100
42
43#define TDLS_RX_IDLE_TIMEOUT 5000
44
45#define TDLS_RSSI_TRIGGER_HYSTERESIS 50
46
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070047/* before UpdateTimer expires, we want to timeout discovery response.
48should not be more than 2000 */
49#define TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE 1000
Gopichand Nakkala75e7b282013-03-15 18:37:13 -070050
Hoonki Lee93e67ff2013-03-19 15:49:25 -070051#define TDLS_CTX_MAGIC 0x54444c53 // "TDLS"
52
53#define TDLS_MAX_SCAN_SCHEDULE 10
Hoonki Leefb8df672013-04-10 18:20:34 -070054#define TDLS_MAX_SCAN_REJECT 5
Hoonki Lee93e67ff2013-03-19 15:49:25 -070055#define TDLS_DELAY_SCAN_PER_CONNECTION 100
56
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070057#define TDLS_IS_CONNECTED(peer) \
58 ((eTDLS_LINK_CONNECTED == (peer)->link_status) || \
59 (eTDLS_LINK_TEARING == (peer)->link_status))
Chilam NG571c65a2013-01-19 12:27:36 +053060typedef struct
61{
Chilam Ng01120412013-02-19 18:32:21 -080062 tANI_U32 tdls;
Chilam NG571c65a2013-01-19 12:27:36 +053063 tANI_U32 tx_period_t;
64 tANI_U32 tx_packet_n;
65 tANI_U32 discovery_period_t;
66 tANI_U32 discovery_tries_n;
Chilam Ng01120412013-02-19 18:32:21 -080067 tANI_U32 idle_timeout_t;
68 tANI_U32 idle_packet_n;
Chilam NG571c65a2013-01-19 12:27:36 +053069 tANI_U32 rssi_hysteresis;
Chilam Ng01120412013-02-19 18:32:21 -080070 tANI_S32 rssi_trigger_threshold;
71 tANI_S32 rssi_teardown_threshold;
Chilam NG571c65a2013-01-19 12:27:36 +053072} tdls_config_params_t;
73
Hoonki Lee93e67ff2013-03-19 15:49:25 -070074typedef struct
75{
76 struct wiphy *wiphy;
77#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
78 struct net_device *dev;
79#endif
80 struct cfg80211_scan_request *scan_request;
81 int magic;
82 int attempt;
Hoonki Leefb8df672013-04-10 18:20:34 -070083 int reject;
Hoonki Lee93e67ff2013-03-19 15:49:25 -070084 struct delayed_work tdls_scan_work;
85} tdls_scan_context_t;
86
Chilam NG571c65a2013-01-19 12:27:36 +053087typedef enum {
Hoonki Lee27511902013-03-14 18:19:06 -070088 eTDLS_SUPPORT_NOT_ENABLED = 0,
89 eTDLS_SUPPORT_DISABLED, /* suppress implicit trigger and not respond to the peer */
90 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY, /* suppress implicit trigger, but respond to the peer */
91 eTDLS_SUPPORT_ENABLED, /* implicit trigger */
Chilam Ng01120412013-02-19 18:32:21 -080092} eTDLSSupportMode;
93
Gopichand Nakkala901e8922013-03-04 23:45:58 -080094typedef enum eTDLSCapType{
Chilam NG571c65a2013-01-19 12:27:36 +053095 eTDLS_CAP_NOT_SUPPORTED = -1,
96 eTDLS_CAP_UNKNOWN = 0,
97 eTDLS_CAP_SUPPORTED = 1,
Gopichand Nakkala901e8922013-03-04 23:45:58 -080098} tTDLSCapType;
Chilam NG571c65a2013-01-19 12:27:36 +053099
Gopichand Nakkala901e8922013-03-04 23:45:58 -0800100typedef enum eTDLSLinkStatus {
101 eTDLS_LINK_IDLE = 0,
102 eTDLS_LINK_DISCOVERING,
Gopichand Nakkala05922802013-03-14 12:23:19 -0700103 eTDLS_LINK_DISCOVERED,
Gopichand Nakkala901e8922013-03-04 23:45:58 -0800104 eTDLS_LINK_CONNECTING,
105 eTDLS_LINK_CONNECTED,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -0700106 eTDLS_LINK_TEARING,
Gopichand Nakkala901e8922013-03-04 23:45:58 -0800107} tTDLSLinkStatus;
Chilam NG571c65a2013-01-19 12:27:36 +0530108
109typedef struct {
110 tANI_U16 period;
111 tANI_U16 bytes;
112} tdls_tx_tput_config_t;
113
114typedef struct {
115 tANI_U16 period;
116 tANI_U16 tries;
117} tdls_discovery_config_t;
118
119typedef struct {
120 tANI_U16 timeout;
121} tdls_rx_idle_config_t;
122
123typedef struct {
124 tANI_U16 rssi_thres;
125} tdls_rssi_config_t;
126
Hoonki Leed37cbb32013-04-20 00:31:14 -0700127struct _hddTdlsPeer_t;
Sunil Dutt41de4e22013-11-14 18:09:02 +0530128
129typedef struct {
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800130 struct list_head peer_list[256];
131 hdd_adapter_t *pAdapter;
Hoonki Leed37cbb32013-04-20 00:31:14 -0700132#ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800133 vos_timer_t peerDiscoverTimer;
Hoonki Leed37cbb32013-04-20 00:31:14 -0700134#endif
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800135 vos_timer_t peerUpdateTimer;
Gopichand Nakkala75e7b282013-03-15 18:37:13 -0700136 vos_timer_t peerDiscoveryTimeoutTimer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800137 tdls_config_params_t threshold_config;
138 tANI_S32 discovery_peer_cnt;
Gopichand Nakkala75e7b282013-03-15 18:37:13 -0700139 tANI_U32 discovery_sent_cnt;
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800140 tANI_S8 ap_rssi;
Hoonki Leed37cbb32013-04-20 00:31:14 -0700141 struct _hddTdlsPeer_t *curr_candidate;
142 struct work_struct implicit_setup;
143 v_U32_t magic;
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800144} tdlsCtx_t;
145
Hoonki Leed37cbb32013-04-20 00:31:14 -0700146typedef struct _hddTdlsPeer_t {
Hoonki Lee387663d2013-02-05 18:08:43 -0800147 struct list_head node;
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800148 tdlsCtx_t *pHddTdlsCtx;
Hoonki Lee387663d2013-02-05 18:08:43 -0800149 tSirMacAddr peerMac;
150 tANI_U16 staId ;
151 tANI_S8 rssi;
Gopichand Nakkala901e8922013-03-04 23:45:58 -0800152 tTDLSCapType tdls_support;
153 tTDLSLinkStatus link_status;
Hoonki Lee11f7dda2013-02-14 16:55:44 -0800154 tANI_U8 signature;
Hoonki Leea34dd892013-02-05 22:56:02 -0800155 tANI_U8 is_responder;
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800156 tANI_U8 discovery_processed;
Hoonki Lee387663d2013-02-05 18:08:43 -0800157 tANI_U16 discovery_attempt;
158 tANI_U16 tx_pkt;
159 tANI_U16 rx_pkt;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530160 tANI_U8 uapsdQueues;
161 tANI_U8 maxSp;
162 tANI_U8 isBufSta;
Hoonki Lee387663d2013-02-05 18:08:43 -0800163 vos_timer_t peerIdleTimer;
Hoonki Lee14621352013-04-16 17:51:19 -0700164 vos_timer_t initiatorWaitTimeoutTimer;
Naresh Jayaram937abdf2013-11-26 19:50:25 +0530165 tANI_BOOLEAN isForcedPeer;
Hoonki Lee387663d2013-02-05 18:08:43 -0800166} hddTdlsPeer_t;
167
Hoonki Lee387663d2013-02-05 18:08:43 -0800168typedef struct {
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800169 /* Session ID */
170 tANI_U8 sessionId;
171 /*TDLS peer station id */
172 v_U8_t staId;
173 /* TDLS peer mac Address */
174 v_MACADDR_t peerMac;
175} tdlsConnInfo_t;
Chilam NG571c65a2013-01-19 12:27:36 +0530176
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800177int wlan_hdd_tdls_init(hdd_adapter_t *pAdapter);
Chilam NG571c65a2013-01-19 12:27:36 +0530178
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800179void wlan_hdd_tdls_exit(hdd_adapter_t *pAdapter);
Chilam NG571c65a2013-01-19 12:27:36 +0530180
Hoonki Lee387663d2013-02-05 18:08:43 -0800181void wlan_hdd_tdls_extract_da(struct sk_buff *skb, u8 *mac);
Chilam NG571c65a2013-01-19 12:27:36 +0530182
Hoonki Lee387663d2013-02-05 18:08:43 -0800183void wlan_hdd_tdls_extract_sa(struct sk_buff *skb, u8 *mac);
Chilam Ng1279e232013-01-25 15:06:52 -0800184
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800185int wlan_hdd_tdls_increment_pkt_count(hdd_adapter_t *pAdapter, u8 *mac, u8 tx);
Chilam NG571c65a2013-01-19 12:27:36 +0530186
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800187int wlan_hdd_tdls_set_sta_id(hdd_adapter_t *pAdapter, u8 *mac, u8 staId);
Chilam NG571c65a2013-01-19 12:27:36 +0530188
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +0530189hddTdlsPeer_t *wlan_hdd_tdls_find_peer(hdd_adapter_t *pAdapter, u8 *mac, tANI_BOOLEAN mutexLock);
Chilam NG571c65a2013-01-19 12:27:36 +0530190
Hoonki Leea6d49be2013-04-05 09:43:25 -0700191hddTdlsPeer_t *wlan_hdd_tdls_find_all_peer(hdd_context_t *pHddCtx, u8 *mac);
192
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530193int wlan_hdd_tdls_get_link_establish_params(hdd_adapter_t *pAdapter, u8 *mac,
194 tCsrTdlsLinkEstablishParams* tdlsLinkEstablishParams);
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800195hddTdlsPeer_t *wlan_hdd_tdls_get_peer(hdd_adapter_t *pAdapter, u8 *mac);
Hoonki Lee387663d2013-02-05 18:08:43 -0800196
Gopichand Nakkala34d1b062013-03-19 15:28:33 -0700197int wlan_hdd_tdls_set_cap(hdd_adapter_t *pAdapter, u8* mac, tTDLSCapType cap);
Hoonki Lee27511902013-03-14 18:19:06 -0700198
Gopichand Nakkala8b00c632013-03-08 19:47:52 -0800199void wlan_hdd_tdls_set_peer_link_status(hddTdlsPeer_t *curr_peer, tTDLSLinkStatus status);
200
201void wlan_hdd_tdls_set_link_status(hdd_adapter_t *pAdapter, u8* mac, tTDLSLinkStatus status);
Chilam NG571c65a2013-01-19 12:27:36 +0530202
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800203int wlan_hdd_tdls_recv_discovery_resp(hdd_adapter_t *pAdapter, u8 *mac);
Chilam NG571c65a2013-01-19 12:27:36 +0530204
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530205int wlan_hdd_tdls_set_peer_caps(hdd_adapter_t *pAdapter,
206 u8 *mac,
207 tANI_U8 uapsdQueues,
208 tANI_U8 maxSp,
209 tANI_BOOLEAN isBufSta);
210
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800211int wlan_hdd_tdls_set_rssi(hdd_adapter_t *pAdapter, u8 *mac, tANI_S8 rxRssi);
Chilam NG571c65a2013-01-19 12:27:36 +0530212
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800213int wlan_hdd_tdls_set_responder(hdd_adapter_t *pAdapter, u8 *mac, tANI_U8 responder);
Hoonki Leea34dd892013-02-05 22:56:02 -0800214
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800215int wlan_hdd_tdls_get_responder(hdd_adapter_t *pAdapter, u8 *mac);
Hoonki Leea34dd892013-02-05 22:56:02 -0800216
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800217int wlan_hdd_tdls_set_signature(hdd_adapter_t *pAdapter, u8 *mac, tANI_U8 uSignature);
Hoonki Lee11f7dda2013-02-14 16:55:44 -0800218
Chilam Ng01120412013-02-19 18:32:21 -0800219int wlan_hdd_tdls_set_params(struct net_device *dev, tdls_config_params_t *config);
Chilam NG571c65a2013-01-19 12:27:36 +0530220
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800221int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, u8 *mac);
Hoonki Lee387663d2013-02-05 18:08:43 -0800222
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800223tANI_U16 wlan_hdd_tdlsConnectedPeers(hdd_adapter_t *pAdapter);
Lee Hoonkic1262f22013-01-24 21:59:00 -0800224
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800225int wlan_hdd_tdls_get_all_peers(hdd_adapter_t *pAdapter, char *buf, int buflen);
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800226
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800227void wlan_hdd_tdls_connection_callback(hdd_adapter_t *pAdapter);
228
229void wlan_hdd_tdls_disconnection_callback(hdd_adapter_t *pAdapter);
230
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800231void wlan_hdd_tdls_mgmt_completion_callback(hdd_adapter_t *pAdapter, tANI_U32 statusCode);
232
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800233void wlan_hdd_tdls_increment_peer_count(hdd_adapter_t *pAdapter);
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800234
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800235void wlan_hdd_tdls_decrement_peer_count(hdd_adapter_t *pAdapter);
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800236
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800237void wlan_hdd_tdls_check_bmps(hdd_adapter_t *pAdapter);
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800238
Gopichand Nakkala34d1b062013-03-19 15:28:33 -0700239u8 wlan_hdd_tdls_is_peer_progress(hdd_adapter_t *pAdapter, u8 *mac);
240
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +0530241hddTdlsPeer_t *wlan_hdd_tdls_is_progress(hdd_context_t *pHddCtx, u8* mac, u8 skip_self);
Hoonki Lee387663d2013-02-05 18:08:43 -0800242
Gopichand Nakkaladcbcf4e2013-03-23 14:32:39 -0700243void wlan_hdd_tdls_set_mode(hdd_context_t *pHddCtx,
244 eTDLSSupportMode tdls_mode,
245 v_BOOL_t bUpdateLast);
Hoonki Lee27511902013-03-14 18:19:06 -0700246
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700247tANI_U32 wlan_hdd_tdls_discovery_sent_cnt(hdd_context_t *pHddCtx);
248
Gopichand Nakkala34d1b062013-03-19 15:28:33 -0700249void wlan_hdd_tdls_check_power_save_prohibited(hdd_adapter_t *pAdapter);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700250
Hoonki Lee93e67ff2013-03-19 15:49:25 -0700251void wlan_hdd_tdls_free_scan_request (tdls_scan_context_t *tdls_scan_ctx);
252
253int wlan_hdd_tdls_copy_scan_context(hdd_context_t *pHddCtx,
254 struct wiphy *wiphy,
255#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
256 struct net_device *dev,
257#endif
258 struct cfg80211_scan_request *request);
259
260int wlan_hdd_tdls_scan_callback (hdd_adapter_t *pAdapter,
261 struct wiphy *wiphy,
262#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
263 struct net_device *dev,
264#endif
265 struct cfg80211_scan_request *request);
266
267void wlan_hdd_tdls_scan_done_callback(hdd_adapter_t *pAdapter);
268
Gopichand Nakkala3046fc92013-03-23 13:56:43 -0700269void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter,
270 vos_timer_t *timer,
271 v_U32_t expirationTime);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -0700272void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter,
273 hddTdlsPeer_t *curr_peer,
274 tANI_U16 reason);
275
Naresh Jayaram937abdf2013-11-26 19:50:25 +0530276int wlan_hdd_tdls_set_force_peer(hdd_adapter_t *pAdapter, u8 *mac,
277 tANI_BOOLEAN forcePeer);
Gopichand Nakkala3046fc92013-03-23 13:56:43 -0700278
Kiran V1ccee932012-12-12 14:49:46 -0800279#endif // __HDD_TDSL_H