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 ******************************************************************************/
23 #include <drv_types.h>
25 u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
26 u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
27 u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo,
28 u8 *pbuf, u8 *pssid, u8 ussidlen,
30 u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo,
31 u8 *pbuf, u8 status_code);
32 u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
33 u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo,
34 u8 *pframe, uint len);
35 u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo,
36 u8 *pframe, uint len, struct sta_info *psta);
37 u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo,
38 u8 *pframe, uint len);
39 u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo,
40 u8 *pframe, uint len);
41 u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo,
42 u8 *pframe, uint len);
43 u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe);
44 u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo,
45 u8 *pframe, uint len);
46 u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo,
47 u8 *pframe, uint len);
48 u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo,
49 u8 *pframe, uint len);
50 u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe,
52 void p2p_protocol_wk_hdl(struct adapter *padapter, int intcmdtype);
53 void process_p2p_ps_ie(struct adapter *padapter, u8 *ies, u32 ielength);
54 void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state);
55 u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue);
56 void reset_global_wifidirect_info(struct adapter *padapter);
57 int rtw_init_wifi_display_info(struct adapter *padapter);
58 void rtw_init_wifidirect_timers(struct adapter *padapter);
59 void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr,
61 void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role);
62 int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role);
64 static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo,
67 if (wdinfo->p2p_state != state)
68 wdinfo->p2p_state = state;
71 static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo,
74 if (wdinfo->pre_p2p_state != state)
75 wdinfo->pre_p2p_state = state;
78 static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo,
81 if (wdinfo->role != role)
85 static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo)
87 return wdinfo->p2p_state;
90 static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo)
92 return wdinfo->pre_p2p_state;
95 static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo)
100 static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo,
101 enum P2P_STATE state)
103 return wdinfo->p2p_state == state;
106 static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo,
109 return wdinfo->role == role;
112 #define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state)
113 #define rtw_p2p_set_pre_state(wdinfo, state) \
114 _rtw_p2p_set_pre_state(wdinfo, state)
115 #define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role)
117 #define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo)
118 #define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo)
119 #define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo)
120 #define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state)
121 #define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role)
123 #define rtw_p2p_findphase_ex_set(wdinfo, value) \
124 ((wdinfo)->find_phase_state_exchange_cnt = (value))
126 /* is this find phase exchange for social channel scan? */
127 #define rtw_p2p_findphase_ex_is_social(wdinfo) \
128 ((wdinfo)->find_phase_state_exchange_cnt >= P2P_FINDPHASE_EX_SOCIAL_FIRST)
130 /* should we need find phase exchange anymore? */
131 #define rtw_p2p_findphase_ex_is_needed(wdinfo) \
132 ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \
133 (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE)