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