1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3
4 #ifndef __RTW_P2P_H_
5 #define __RTW_P2P_H_
6
7 #include "drv_types.h"
8
9 u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
10 u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
11 u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo,
12 u8 *pbuf, u8 *pssid, u8 ussidlen,
13 u8 *pdev_raddr);
14 u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo,
15 u8 *pbuf, u8 status_code);
16 u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo,
17 u8 *pframe, uint len);
18 u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo,
19 u8 *pframe, uint len, struct sta_info *psta);
20 u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo,
21 u8 *pframe, uint len);
22 u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo,
23 u8 *pframe, uint len);
24 u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo,
25 u8 *pframe, uint len);
26 u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe);
27 u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo,
28 u8 *pframe, uint len);
29 u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo,
30 u8 *pframe, uint len);
31 u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo,
32 u8 *pframe, uint len);
33 u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe,
34 uint len);
35 void p2p_protocol_wk_hdl(struct adapter *padapter, int intcmdtype);
36 void process_p2p_ps_ie(struct adapter *padapter, u8 *ies, u32 ielength);
37 void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state);
38 u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue);
39 void reset_global_wifidirect_info(struct adapter *padapter);
40 int rtw_init_wifi_display_info(struct adapter *padapter);
41 void rtw_init_wifidirect_timers(struct adapter *padapter);
42 void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr,
43 u8 *iface_addr);
44 void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role);
45 int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role);
46
_rtw_p2p_set_state(struct wifidirect_info * wdinfo,enum P2P_STATE state)47 static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo,
48 enum P2P_STATE state)
49 {
50 if (wdinfo->p2p_state != state)
51 wdinfo->p2p_state = state;
52 }
53
_rtw_p2p_set_pre_state(struct wifidirect_info * wdinfo,enum P2P_STATE state)54 static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo,
55 enum P2P_STATE state)
56 {
57 if (wdinfo->pre_p2p_state != state)
58 wdinfo->pre_p2p_state = state;
59 }
60
_rtw_p2p_set_role(struct wifidirect_info * wdinfo,enum P2P_ROLE role)61 static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo,
62 enum P2P_ROLE role)
63 {
64 if (wdinfo->role != role)
65 wdinfo->role = role;
66 }
67
_rtw_p2p_state(struct wifidirect_info * wdinfo)68 static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo)
69 {
70 return wdinfo->p2p_state;
71 }
72
_rtw_p2p_pre_state(struct wifidirect_info * wdinfo)73 static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo)
74 {
75 return wdinfo->pre_p2p_state;
76 }
77
_rtw_p2p_role(struct wifidirect_info * wdinfo)78 static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo)
79 {
80 return wdinfo->role;
81 }
82
_rtw_p2p_chk_state(struct wifidirect_info * wdinfo,enum P2P_STATE state)83 static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo,
84 enum P2P_STATE state)
85 {
86 return wdinfo->p2p_state == state;
87 }
88
_rtw_p2p_chk_role(struct wifidirect_info * wdinfo,enum P2P_ROLE role)89 static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo,
90 enum P2P_ROLE role)
91 {
92 return wdinfo->role == role;
93 }
94
95 #define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state)
96 #define rtw_p2p_set_pre_state(wdinfo, state) \
97 _rtw_p2p_set_pre_state(wdinfo, state)
98 #define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role)
99
100 #define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo)
101 #define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo)
102 #define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo)
103 #define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state)
104 #define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role)
105
106 #define rtw_p2p_findphase_ex_set(wdinfo, value) \
107 ((wdinfo)->find_phase_state_exchange_cnt = (value))
108
109 /* is this find phase exchange for social channel scan? */
110 #define rtw_p2p_findphase_ex_is_social(wdinfo) \
111 ((wdinfo)->find_phase_state_exchange_cnt >= P2P_FINDPHASE_EX_SOCIAL_FIRST)
112
113 /* should we need find phase exchange anymore? */
114 #define rtw_p2p_findphase_ex_is_needed(wdinfo) \
115 ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \
116 (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE)
117
118 #endif
119