• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __RTW_TDLS_H_
16 #define __RTW_TDLS_H_
17 
18 
19 #ifdef CONFIG_TDLS
20 /* TDLS STA state */
21 
22 
23 /* TDLS Diect Link Establishment */
24 #define	TDLS_STATE_NONE				0x00000000		/* Default state */
25 #define	TDLS_INITIATOR_STATE		BIT(28)			/* 0x10000000 */
26 #define	TDLS_RESPONDER_STATE		BIT(29)			/* 0x20000000 */
27 #define	TDLS_LINKED_STATE			BIT(30)			/* 0x40000000 */
28 /* TDLS PU Buffer STA */
29 #define	TDLS_WAIT_PTR_STATE			BIT(24)			/* 0x01000000 */	/* Waiting peer's TDLS_PEER_TRAFFIC_RESPONSE frame */
30 /* TDLS Check ALive */
31 #define	TDLS_ALIVE_STATE			BIT(20)			/* 0x00100000 */	/* Check if peer sta is alived. */
32 /* TDLS Channel Switch */
33 #define	TDLS_CH_SWITCH_PREPARE_STATE	BIT(15)			/* 0x00008000 */
34 #define	TDLS_CH_SWITCH_ON_STATE			BIT(16)			/* 0x00010000 */
35 #define	TDLS_PEER_AT_OFF_STATE			BIT(17)			/* 0x00020000 */	/* Could send pkt on target ch */
36 #define	TDLS_CH_SW_INITIATOR_STATE		BIT(18)			/* 0x00040000 */	/* Avoid duplicated or unconditional ch. switch rsp. */
37 #define	TDLS_WAIT_CH_RSP_STATE			BIT(19)			/* 0x00080000 */	/* Wait Ch. response as we are TDLS channel switch initiator */
38 
39 
40 #define	TDLS_TPK_RESEND_COUNT			86400	/*Unit: seconds */
41 #define	TDLS_CH_SWITCH_TIME				15
42 #define	TDLS_CH_SWITCH_TIMEOUT			30
43 #define	TDLS_CH_SWITCH_OPER_OFFLOAD_TIMEOUT	10
44 #define	TDLS_SIGNAL_THRESH			0x20
45 #define	TDLS_WATCHDOG_PERIOD		10	/* Periodically sending tdls discovery request in TDLS_WATCHDOG_PERIOD * 2 sec */
46 #define	TDLS_HANDSHAKE_TIME			3000
47 #define	TDLS_PTI_TIME				7000
48 
49 #define TDLS_CH_SW_STAY_ON_BASE_CHNL_TIMEOUT	20		/* ms */
50 #define TDLS_CH_SW_MONITOR_TIMEOUT				2000	/*ms */
51 
52 #define TDLS_MIC_LEN 16
53 #define WPA_NONCE_LEN 32
54 #define TDLS_TIMEOUT_LEN 4
55 
56 enum TDLS_CH_SW_CHNL {
57 	TDLS_CH_SW_BASE_CHNL = 0,
58 	TDLS_CH_SW_OFF_CHNL
59 };
60 
61 #define TDLS_MIC_CTRL_LEN 2
62 #define TDLS_FTIE_DATA_LEN (TDLS_MIC_CTRL_LEN + TDLS_MIC_LEN + \
63 							WPA_NONCE_LEN + WPA_NONCE_LEN)
64 struct wpa_tdls_ftie {
65 	u8 ie_type; /* FTIE */
66 	u8 ie_len;
67 	union {
68 		struct {
69 			u8 mic_ctrl[TDLS_MIC_CTRL_LEN];
70 			u8 mic[TDLS_MIC_LEN];
71 			u8 Anonce[WPA_NONCE_LEN]; /* Responder Nonce in TDLS */
72 			u8 Snonce[WPA_NONCE_LEN]; /* Initiator Nonce in TDLS */
73 		};
74 		struct {
75 			u8 data[TDLS_FTIE_DATA_LEN];
76 		};
77 	};
78 	/* followed by optional elements */
79 } ;
80 
81 struct wpa_tdls_lnkid {
82 	u8 ie_type; /* Link Identifier IE */
83 	u8 ie_len;
84 	u8 bssid[ETH_ALEN];
85 	u8 init_sta[ETH_ALEN];
86 	u8 resp_sta[ETH_ALEN];
87 } ;
88 
89 static u8 TDLS_RSNIE[20] = {	0x01, 0x00,	/* Version shall be set to 1 */
90 				0x00, 0x0f, 0xac, 0x07,	/* Group sipher suite */
91 				0x01, 0x00,	/* Pairwise cipher suite count */
92 	0x00, 0x0f, 0xac, 0x04,	/* Pairwise cipher suite list; CCMP only */
93 				0x01, 0x00,	/* AKM suite count */
94 				0x00, 0x0f, 0xac, 0x07,	/* TPK Handshake */
95 				0x0c, 0x02,
96 				/* PMKID shall not be present */
97 			   };
98 
99 static u8 TDLS_WMMIE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};	/* Qos info all set zero */
100 
101 static u8 TDLS_WMM_PARAM_IE[] = {0x00, 0x00, 0x03, 0xa4, 0x00, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00};
102 
103 static u8 TDLS_EXT_CAPIE[] = {0x00, 0x00, 0x00, 0x50, 0x20, 0x00, 0x00, 0x00};	/* bit(28), bit(30), bit(37) */
104 
105 /* SRC: Supported Regulatory Classes */
106 static u8 TDLS_SRC[] = { 0x01, 0x01, 0x02, 0x03, 0x04, 0x0c, 0x16, 0x17, 0x18, 0x19, 0x1b, 0x1c, 0x1d, 0x1e, 0x20, 0x21 };
107 
108 int check_ap_tdls_prohibited(u8 *pframe, u8 pkt_len);
109 int check_ap_tdls_ch_switching_prohibited(u8 *pframe, u8 pkt_len);
110 
111 void rtw_set_tdls_enable(_adapter *padapter, u8 enable);
112 u8 rtw_is_tdls_enabled(_adapter *padapter);
113 u8 rtw_is_tdls_sta_existed(_adapter *padapter);
114 u8 rtw_tdls_is_setup_allowed(_adapter *padapter);
115 #ifdef CONFIG_TDLS_CH_SW
116 u8 rtw_tdls_is_chsw_allowed(_adapter *padapter);
117 #endif
118 
119 void rtw_tdls_set_link_established(_adapter *adapter, bool en);
120 void rtw_reset_tdls_info(_adapter *padapter);
121 int rtw_init_tdls_info(_adapter *padapter);
122 void rtw_free_tdls_info(struct tdls_info *ptdlsinfo);
123 void rtw_free_all_tdls_sta(_adapter *padapter, u8 enqueue_cmd);
124 void rtw_enable_tdls_func(_adapter *padapter);
125 void rtw_disable_tdls_func(_adapter *padapter, u8 enqueue_cmd);
126 int issue_nulldata_to_TDLS_peer_STA(_adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms);
127 void rtw_init_tdls_timer(_adapter *padapter, struct sta_info *psta);
128 void	rtw_cancel_tdls_timer(struct sta_info *psta);
129 void rtw_tdls_teardown_pre_hdl(_adapter *padapter, struct sta_info *psta);
130 void rtw_tdls_teardown_post_hdl(_adapter *padapter, struct sta_info *psta, u8 enqueue_cmd);
131 
132 #ifdef CONFIG_TDLS_CH_SW
133 void rtw_tdls_set_ch_sw_oper_control(_adapter *padapter, u8 enable);
134 void rtw_tdls_ch_sw_back_to_base_chnl(_adapter *padapter);
135 s32 rtw_tdls_do_ch_sw(_adapter *padapter, struct sta_info *ptdls_sta, u8 chnl_type, u8 channel, u8 channel_offset, u16 bwmode, u16 ch_switch_time);
136 void rtw_tdls_chsw_oper_done(_adapter *padapter);
137 #endif
138 
139 #ifdef CONFIG_WFD
140 int issue_tunneled_probe_req(_adapter *padapter);
141 int issue_tunneled_probe_rsp(_adapter *padapter, union recv_frame *precv_frame);
142 #endif /* CONFIG_WFD */
143 int issue_tdls_dis_req(_adapter *padapter, struct tdls_txmgmt *ptxmgmt);
144 int issue_tdls_setup_req(_adapter *padapter, struct tdls_txmgmt *ptxmgmt, int wait_ack);
145 int issue_tdls_setup_rsp(_adapter *padapter, struct tdls_txmgmt *ptxmgmt);
146 int issue_tdls_setup_cfm(_adapter *padapter, struct tdls_txmgmt *ptxmgmt);
147 int issue_tdls_dis_rsp(_adapter *padapter, struct tdls_txmgmt *ptxmgmt, u8 privacy);
148 int issue_tdls_teardown(_adapter *padapter, struct tdls_txmgmt *ptxmgmt, u8 wait_ack);
149 int issue_tdls_peer_traffic_rsp(_adapter *padapter, struct sta_info *psta, struct tdls_txmgmt *ptxmgmt);
150 int issue_tdls_peer_traffic_indication(_adapter *padapter, struct sta_info *psta);
151 #ifdef CONFIG_TDLS_CH_SW
152 int issue_tdls_ch_switch_req(_adapter *padapter, struct sta_info *ptdls_sta);
153 int issue_tdls_ch_switch_rsp(_adapter *padapter, struct tdls_txmgmt *ptxmgmt, int wait_ack);
154 #endif
155 sint On_TDLS_Dis_Rsp(_adapter *adapter, union recv_frame *precv_frame);
156 sint On_TDLS_Setup_Req(_adapter *adapter, union recv_frame *precv_frame, struct sta_info *ptdls_sta);
157 int On_TDLS_Setup_Rsp(_adapter *adapter, union recv_frame *precv_frame, struct sta_info *ptdls_sta);
158 int On_TDLS_Setup_Cfm(_adapter *adapter, union recv_frame *precv_frame, struct sta_info *ptdls_sta);
159 int On_TDLS_Dis_Req(_adapter *adapter, union recv_frame *precv_frame);
160 int On_TDLS_Teardown(_adapter *adapter, union recv_frame *precv_frame, struct sta_info *ptdls_sta);
161 int On_TDLS_Peer_Traffic_Indication(_adapter *adapter, union recv_frame *precv_frame, struct sta_info *ptdls_sta);
162 int On_TDLS_Peer_Traffic_Rsp(_adapter *adapter, union recv_frame *precv_frame, struct sta_info *ptdls_sta);
163 #ifdef CONFIG_TDLS_CH_SW
164 sint On_TDLS_Ch_Switch_Req(_adapter *adapter, union recv_frame *precv_frame, struct sta_info *ptdls_sta);
165 sint On_TDLS_Ch_Switch_Rsp(_adapter *adapter, union recv_frame *precv_frame, struct sta_info *ptdls_sta);
166 void rtw_build_tdls_ch_switch_req_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, struct sta_info *ptdls_sta);
167 void rtw_build_tdls_ch_switch_rsp_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, struct sta_info *ptdls_sta);
168 #endif
169 void rtw_build_tdls_setup_req_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, struct sta_info *ptdls_sta);
170 void rtw_build_tdls_setup_rsp_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, struct sta_info *ptdls_sta);
171 void rtw_build_tdls_setup_cfm_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, struct sta_info *ptdls_sta);
172 void rtw_build_tdls_teardown_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, struct sta_info *ptdls_sta);
173 void rtw_build_tdls_dis_req_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt);
174 void rtw_build_tdls_dis_rsp_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, u8 privacy);
175 void rtw_build_tdls_peer_traffic_rsp_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, struct sta_info *ptdls_sta);
176 void rtw_build_tdls_peer_traffic_indication_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe, struct tdls_txmgmt *ptxmgmt, struct sta_info *ptdls_sta);
177 void rtw_build_tunneled_probe_req_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe);
178 void rtw_build_tunneled_probe_rsp_ies(_adapter *padapter, struct xmit_frame *pxmitframe, u8 *pframe);
179 
180 int rtw_tdls_is_driver_setup(_adapter *padapter);
181 void rtw_tdls_set_key(_adapter *padapter, struct sta_info *ptdls_sta);
182 const char *rtw_tdls_action_txt(enum TDLS_ACTION_FIELD action);
183 #endif /* CONFIG_TDLS */
184 
185 #endif
186