1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
24 u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
25 u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
26 u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8* pssid, u8 ussidlen, u8* pdev_raddr );
27 u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code);
28 u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
30 int rtw_init_wifi_display_info(_adapter *padapter);
31 void rtw_wfd_enable(_adapter *adapter, bool on);
32 void rtw_wfd_set_ctrl_port(_adapter *adapter, u16 port);
33 void rtw_tdls_wfd_enable(_adapter *adapter, bool on);
35 u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
36 u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunneled);
37 u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
38 u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
39 u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
40 u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
41 u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
42 u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
43 u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
44 u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
45 u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
46 u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
48 u32 rtw_append_beacon_wfd_ie(_adapter *adapter, u8 *pbuf);
49 u32 rtw_append_probe_req_wfd_ie(_adapter *adapter, u8 *pbuf);
50 u32 rtw_append_probe_resp_wfd_ie(_adapter *adapter, u8 *pbuf);
51 u32 rtw_append_assoc_req_wfd_ie(_adapter *adapter, u8 *pbuf);
52 u32 rtw_append_assoc_resp_wfd_ie(_adapter *adapter, u8 *pbuf);
53 #endif /*CONFIG_WFD */
55 void rtw_xframe_chk_wfd_ie(struct xmit_frame *xframe);
57 u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
58 u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta);
59 u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
60 u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
61 u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
62 u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe);
63 u8 process_p2p_group_negotation_req( struct wifidirect_info *pwdinfo, u8 *pframe, uint len );
64 u8 process_p2p_group_negotation_resp( struct wifidirect_info *pwdinfo, u8 *pframe, uint len );
65 u8 process_p2p_group_negotation_confirm( struct wifidirect_info *pwdinfo, u8 *pframe, uint len );
66 u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
67 int process_p2p_cross_connect_ie(PADAPTER padapter, u8 *IEs, u32 IELength);
69 void p2p_protocol_wk_hdl(_adapter *padapter, int intCmdType);
72 void process_p2p_ps_ie(PADAPTER padapter, u8 *IEs, u32 IELength);
73 void p2p_ps_wk_hdl(_adapter *padapter, u8 p2p_ps_state);
74 u8 p2p_ps_wk_cmd(_adapter*padapter, u8 p2p_ps_state, u8 enqueue);
75 #endif // CONFIG_P2P_PS
77 #ifdef CONFIG_IOCTL_CFG80211
78 void rtw_init_cfg80211_wifidirect_info( _adapter* padapter);
79 int rtw_p2p_check_frames(_adapter *padapter, const u8 *buf, u32 len, u8 tx);
80 #endif /* CONFIG_IOCTL_CFG80211 */
82 void reset_global_wifidirect_info( _adapter* padapter );
83 void rtw_init_wifidirect_timers(_adapter* padapter);
84 void rtw_init_wifidirect_addrs(_adapter* padapter, u8 *dev_addr, u8 *iface_addr);
85 void init_wifidirect_info( _adapter* padapter, enum P2P_ROLE role);
86 int rtw_p2p_enable(_adapter *padapter, enum P2P_ROLE role);
88 static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
90 if(wdinfo->p2p_state != state) {
91 //wdinfo->pre_p2p_state = wdinfo->p2p_state;
92 wdinfo->p2p_state = state;
95 static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
97 if(wdinfo->pre_p2p_state != state) {
98 wdinfo->pre_p2p_state = state;
102 static inline void _rtw_p2p_restore_state(struct wifidirect_info *wdinfo)
104 if(wdinfo->pre_p2p_state != -1) {
105 wdinfo->p2p_state = wdinfo->pre_p2p_state;
106 wdinfo->pre_p2p_state = -1;
110 static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role)
112 if(wdinfo->role != role) {
116 static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo)
118 return wdinfo->p2p_state;
120 static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo)
122 return wdinfo->pre_p2p_state;
124 static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo)
128 static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
130 return wdinfo->p2p_state == state;
132 static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role)
134 return wdinfo->role == role;
137 #ifdef CONFIG_DBG_P2P
138 void dbg_rtw_p2p_set_state(struct wifidirect_info *wdinfo, enum P2P_STATE state, const char *caller, int line);
139 void dbg_rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, enum P2P_STATE state, const char *caller, int line);
140 //void dbg_rtw_p2p_restore_state(struct wifidirect_info *wdinfo, const char *caller, int line);
141 void dbg_rtw_p2p_set_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role, const char *caller, int line);
142 #define rtw_p2p_set_state(wdinfo, state) dbg_rtw_p2p_set_state(wdinfo, state, __FUNCTION__, __LINE__)
143 #define rtw_p2p_set_pre_state(wdinfo, state) dbg_rtw_p2p_set_pre_state(wdinfo, state, __FUNCTION__, __LINE__)
144 #define rtw_p2p_set_role(wdinfo, role) dbg_rtw_p2p_set_role(wdinfo, role, __FUNCTION__, __LINE__)
145 //#define rtw_p2p_restore_state(wdinfo) dbg_rtw_p2p_restore_state(wdinfo, __FUNCTION__, __LINE__)
146 #else //CONFIG_DBG_P2P
147 #define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state)
148 #define rtw_p2p_set_pre_state(wdinfo, state) _rtw_p2p_set_pre_state(wdinfo, state)
149 #define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role)
150 //#define rtw_p2p_restore_state(wdinfo) _rtw_p2p_restore_state(wdinfo)
151 #endif //CONFIG_DBG_P2P
153 #define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo)
154 #define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo)
155 #define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo)
156 #define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state)
157 #define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role)
159 #define rtw_p2p_findphase_ex_set(wdinfo, value) \
160 (wdinfo)->find_phase_state_exchange_cnt = (value)
163 //is this find phase exchange for social channel scan?
164 #define rtw_p2p_findphase_ex_is_social(wdinfo) \
165 (wdinfo)->find_phase_state_exchange_cnt >= P2P_FINDPHASE_EX_SOCIAL_FIRST
167 //should we need find phase exchange anymore?
168 #define rtw_p2p_findphase_ex_is_needed(wdinfo) \
169 ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \
170 (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE && \
171 !(wdinfo)->rx_invitereq_info.scan_op_ch_only && \
172 !(wdinfo)->p2p_info.scan_op_ch_only)
174 #define rtw_p2p_findphase_ex_is_social(wdinfo) 0
175 #define rtw_p2p_findphase_ex_is_needed(wdinfo) 0
176 #endif /* CONFIG_P2P */