xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8723ds/include/rtw_p2p.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /******************************************************************************
2*4882a593Smuzhiyun  *
3*4882a593Smuzhiyun  * Copyright(c) 2007 - 2017 Realtek Corporation.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or modify it
6*4882a593Smuzhiyun  * under the terms of version 2 of the GNU General Public License as
7*4882a593Smuzhiyun  * published by the Free Software Foundation.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * This program is distributed in the hope that it will be useful, but WITHOUT
10*4882a593Smuzhiyun  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12*4882a593Smuzhiyun  * more details.
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  *****************************************************************************/
15*4882a593Smuzhiyun #ifndef __RTW_P2P_H_
16*4882a593Smuzhiyun #define __RTW_P2P_H_
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
20*4882a593Smuzhiyun u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
21*4882a593Smuzhiyun u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 *pssid, u8 ussidlen, u8 *pdev_raddr);
22*4882a593Smuzhiyun u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code);
23*4882a593Smuzhiyun u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
24*4882a593Smuzhiyun #ifdef CONFIG_WFD
25*4882a593Smuzhiyun int rtw_init_wifi_display_info(_adapter *padapter);
26*4882a593Smuzhiyun void rtw_wfd_enable(_adapter *adapter, bool on);
27*4882a593Smuzhiyun void rtw_wfd_set_ctrl_port(_adapter *adapter, u16 port);
28*4882a593Smuzhiyun void rtw_tdls_wfd_enable(_adapter *adapter, bool on);
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
31*4882a593Smuzhiyun u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunneled);
32*4882a593Smuzhiyun u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
33*4882a593Smuzhiyun u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
34*4882a593Smuzhiyun u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
35*4882a593Smuzhiyun u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
36*4882a593Smuzhiyun u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
37*4882a593Smuzhiyun u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
38*4882a593Smuzhiyun u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
39*4882a593Smuzhiyun u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
40*4882a593Smuzhiyun u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
41*4882a593Smuzhiyun u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun u32 rtw_append_beacon_wfd_ie(_adapter *adapter, u8 *pbuf);
44*4882a593Smuzhiyun u32 rtw_append_probe_req_wfd_ie(_adapter *adapter, u8 *pbuf);
45*4882a593Smuzhiyun u32 rtw_append_probe_resp_wfd_ie(_adapter *adapter, u8 *pbuf);
46*4882a593Smuzhiyun u32 rtw_append_assoc_req_wfd_ie(_adapter *adapter, u8 *pbuf);
47*4882a593Smuzhiyun u32 rtw_append_assoc_resp_wfd_ie(_adapter *adapter, u8 *pbuf);
48*4882a593Smuzhiyun #endif /*CONFIG_WFD */
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun void rtw_xframe_chk_wfd_ie(struct xmit_frame *xframe);
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
53*4882a593Smuzhiyun u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta);
54*4882a593Smuzhiyun u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
55*4882a593Smuzhiyun u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
56*4882a593Smuzhiyun u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo,  u8 *pframe, uint len);
57*4882a593Smuzhiyun u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo,  u8 *pframe);
58*4882a593Smuzhiyun u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
59*4882a593Smuzhiyun u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
60*4882a593Smuzhiyun u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
61*4882a593Smuzhiyun u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
62*4882a593Smuzhiyun int process_p2p_cross_connect_ie(PADAPTER padapter, u8 *IEs, u32 IELength);
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun s32 p2p_protocol_wk_hdl(_adapter *padapter, int intCmdType, u8 *buf);
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun #ifdef CONFIG_P2P_PS
67*4882a593Smuzhiyun void	process_p2p_ps_ie(PADAPTER padapter, u8 *IEs, u32 IELength);
68*4882a593Smuzhiyun void	p2p_ps_wk_hdl(_adapter *padapter, u8 p2p_ps_state);
69*4882a593Smuzhiyun u8	p2p_ps_wk_cmd(_adapter *padapter, u8 p2p_ps_state, u8 enqueue);
70*4882a593Smuzhiyun #endif /* CONFIG_P2P_PS */
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun #ifdef CONFIG_IOCTL_CFG80211
73*4882a593Smuzhiyun int rtw_p2p_check_frames(_adapter *padapter, const u8 *buf, u32 len, u8 tx);
74*4882a593Smuzhiyun #endif /* CONFIG_IOCTL_CFG80211 */
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun void reset_global_wifidirect_info(_adapter *padapter);
77*4882a593Smuzhiyun void rtw_init_wifidirect_timers(_adapter *padapter);
78*4882a593Smuzhiyun void rtw_init_wifidirect_addrs(_adapter *padapter, u8 *dev_addr, u8 *iface_addr);
79*4882a593Smuzhiyun void init_wifidirect_info(_adapter *padapter, enum P2P_ROLE role);
80*4882a593Smuzhiyun int rtw_p2p_enable(_adapter *padapter, enum P2P_ROLE role);
81*4882a593Smuzhiyun 
_rtw_p2p_set_state(struct wifidirect_info * wdinfo,enum P2P_STATE state)82*4882a593Smuzhiyun static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
83*4882a593Smuzhiyun {
84*4882a593Smuzhiyun 	if (wdinfo->p2p_state != state) {
85*4882a593Smuzhiyun 		/* wdinfo->pre_p2p_state = wdinfo->p2p_state; */
86*4882a593Smuzhiyun 		wdinfo->p2p_state = state;
87*4882a593Smuzhiyun 	}
88*4882a593Smuzhiyun }
_rtw_p2p_set_pre_state(struct wifidirect_info * wdinfo,enum P2P_STATE state)89*4882a593Smuzhiyun static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
90*4882a593Smuzhiyun {
91*4882a593Smuzhiyun 	if (wdinfo->pre_p2p_state != state)
92*4882a593Smuzhiyun 		wdinfo->pre_p2p_state = state;
93*4882a593Smuzhiyun }
94*4882a593Smuzhiyun #if 0
95*4882a593Smuzhiyun static inline void _rtw_p2p_restore_state(struct wifidirect_info *wdinfo)
96*4882a593Smuzhiyun {
97*4882a593Smuzhiyun 	if (wdinfo->pre_p2p_state != -1) {
98*4882a593Smuzhiyun 		wdinfo->p2p_state = wdinfo->pre_p2p_state;
99*4882a593Smuzhiyun 		wdinfo->pre_p2p_state = -1;
100*4882a593Smuzhiyun 	}
101*4882a593Smuzhiyun }
102*4882a593Smuzhiyun #endif
103*4882a593Smuzhiyun void _rtw_p2p_set_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role);
104*4882a593Smuzhiyun 
_rtw_p2p_state(struct wifidirect_info * wdinfo)105*4882a593Smuzhiyun static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo)
106*4882a593Smuzhiyun {
107*4882a593Smuzhiyun 	return wdinfo->p2p_state;
108*4882a593Smuzhiyun }
_rtw_p2p_pre_state(struct wifidirect_info * wdinfo)109*4882a593Smuzhiyun static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo)
110*4882a593Smuzhiyun {
111*4882a593Smuzhiyun 	return wdinfo->pre_p2p_state;
112*4882a593Smuzhiyun }
_rtw_p2p_role(struct wifidirect_info * wdinfo)113*4882a593Smuzhiyun static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo)
114*4882a593Smuzhiyun {
115*4882a593Smuzhiyun 	return wdinfo->role;
116*4882a593Smuzhiyun }
_rtw_p2p_chk_state(struct wifidirect_info * wdinfo,enum P2P_STATE state)117*4882a593Smuzhiyun static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
118*4882a593Smuzhiyun {
119*4882a593Smuzhiyun 	return wdinfo->p2p_state == state;
120*4882a593Smuzhiyun }
_rtw_p2p_chk_role(struct wifidirect_info * wdinfo,enum P2P_ROLE role)121*4882a593Smuzhiyun static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role)
122*4882a593Smuzhiyun {
123*4882a593Smuzhiyun 	return wdinfo->role == role;
124*4882a593Smuzhiyun }
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun #ifdef CONFIG_DBG_P2P
127*4882a593Smuzhiyun void dbg_rtw_p2p_set_state(struct wifidirect_info *wdinfo, enum P2P_STATE state, const char *caller, int line);
128*4882a593Smuzhiyun void dbg_rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, enum P2P_STATE state, const char *caller, int line);
129*4882a593Smuzhiyun /* void dbg_rtw_p2p_restore_state(struct wifidirect_info *wdinfo, const char *caller, int line); */
130*4882a593Smuzhiyun void dbg_rtw_p2p_set_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role, const char *caller, int line);
131*4882a593Smuzhiyun #define rtw_p2p_set_state(wdinfo, state) dbg_rtw_p2p_set_state(wdinfo, state, __FUNCTION__, __LINE__)
132*4882a593Smuzhiyun #define rtw_p2p_set_pre_state(wdinfo, state) dbg_rtw_p2p_set_pre_state(wdinfo, state, __FUNCTION__, __LINE__)
133*4882a593Smuzhiyun #define rtw_p2p_set_role(wdinfo, role) dbg_rtw_p2p_set_role(wdinfo, role, __FUNCTION__, __LINE__)
134*4882a593Smuzhiyun /* #define rtw_p2p_restore_state(wdinfo) dbg_rtw_p2p_restore_state(wdinfo, __FUNCTION__, __LINE__) */
135*4882a593Smuzhiyun #else /* CONFIG_DBG_P2P */
136*4882a593Smuzhiyun #define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state)
137*4882a593Smuzhiyun #define rtw_p2p_set_pre_state(wdinfo, state) _rtw_p2p_set_pre_state(wdinfo, state)
138*4882a593Smuzhiyun #define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role)
139*4882a593Smuzhiyun /* #define rtw_p2p_restore_state(wdinfo) _rtw_p2p_restore_state(wdinfo) */
140*4882a593Smuzhiyun #endif /* CONFIG_DBG_P2P */
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun #define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo)
143*4882a593Smuzhiyun #define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo)
144*4882a593Smuzhiyun #define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo)
145*4882a593Smuzhiyun #define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state)
146*4882a593Smuzhiyun #define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role)
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun #define rtw_p2p_findphase_ex_set(wdinfo, value) \
149*4882a593Smuzhiyun 	(wdinfo)->find_phase_state_exchange_cnt = (value)
150*4882a593Smuzhiyun 
151*4882a593Smuzhiyun #ifdef CONFIG_P2P
152*4882a593Smuzhiyun /* is this find phase exchange for social channel scan? */
153*4882a593Smuzhiyun #define rtw_p2p_findphase_ex_is_social(wdinfo)   \
154*4882a593Smuzhiyun 	(wdinfo)->find_phase_state_exchange_cnt >= P2P_FINDPHASE_EX_SOCIAL_FIRST
155*4882a593Smuzhiyun 
156*4882a593Smuzhiyun /* should we need find phase exchange anymore? */
157*4882a593Smuzhiyun #define rtw_p2p_findphase_ex_is_needed(wdinfo) \
158*4882a593Smuzhiyun 	((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \
159*4882a593Smuzhiyun 	 (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE && \
160*4882a593Smuzhiyun 	 !(wdinfo)->rx_invitereq_info.scan_op_ch_only && \
161*4882a593Smuzhiyun 	 !(wdinfo)->p2p_info.scan_op_ch_only)
162*4882a593Smuzhiyun #else
163*4882a593Smuzhiyun #define rtw_p2p_findphase_ex_is_social(wdinfo) 0
164*4882a593Smuzhiyun #define rtw_p2p_findphase_ex_is_needed(wdinfo) 0
165*4882a593Smuzhiyun #endif /* CONFIG_P2P */
166*4882a593Smuzhiyun 
167*4882a593Smuzhiyun #endif
168