xref: /freebsd/sys/contrib/dev/broadcom/brcm80211/brcmfmac/p2p.h (revision 9375e11f079d725d42c5b431de33044088ad14f7)
1b4c3e9b5SBjoern A. Zeeb // SPDX-License-Identifier: ISC
2b4c3e9b5SBjoern A. Zeeb /*
3b4c3e9b5SBjoern A. Zeeb  * Copyright (c) 2012 Broadcom Corporation
4b4c3e9b5SBjoern A. Zeeb  */
5b4c3e9b5SBjoern A. Zeeb #ifndef WL_CFGP2P_H_
6b4c3e9b5SBjoern A. Zeeb #define WL_CFGP2P_H_
7b4c3e9b5SBjoern A. Zeeb 
8b4c3e9b5SBjoern A. Zeeb #include <net/cfg80211.h>
9b4c3e9b5SBjoern A. Zeeb 
10b4c3e9b5SBjoern A. Zeeb struct brcmf_cfg80211_info;
11b4c3e9b5SBjoern A. Zeeb 
12b4c3e9b5SBjoern A. Zeeb /**
13b4c3e9b5SBjoern A. Zeeb  * enum p2p_bss_type - different type of BSS configurations.
14b4c3e9b5SBjoern A. Zeeb  *
15b4c3e9b5SBjoern A. Zeeb  * @P2PAPI_BSSCFG_PRIMARY: maps to driver's primary bsscfg.
16b4c3e9b5SBjoern A. Zeeb  * @P2PAPI_BSSCFG_DEVICE: maps to driver's P2P device discovery bsscfg.
17b4c3e9b5SBjoern A. Zeeb  * @P2PAPI_BSSCFG_CONNECTION: maps to driver's 1st P2P connection bsscfg.
18b4c3e9b5SBjoern A. Zeeb  * @P2PAPI_BSSCFG_CONNECTION2: maps to driver's 2nd P2P connection bsscfg.
19b4c3e9b5SBjoern A. Zeeb  * @P2PAPI_BSSCFG_MAX: used for range checking.
20b4c3e9b5SBjoern A. Zeeb  */
21b4c3e9b5SBjoern A. Zeeb enum p2p_bss_type {
22b4c3e9b5SBjoern A. Zeeb 	P2PAPI_BSSCFG_PRIMARY, /* maps to driver's primary bsscfg */
23b4c3e9b5SBjoern A. Zeeb 	P2PAPI_BSSCFG_DEVICE, /* maps to driver's P2P device discovery bsscfg */
24b4c3e9b5SBjoern A. Zeeb 	P2PAPI_BSSCFG_CONNECTION, /* driver's 1st P2P connection bsscfg */
25b4c3e9b5SBjoern A. Zeeb 	P2PAPI_BSSCFG_CONNECTION2, /* driver's 2nd P2P connection bsscfg */
26b4c3e9b5SBjoern A. Zeeb 	P2PAPI_BSSCFG_MAX
27b4c3e9b5SBjoern A. Zeeb };
28b4c3e9b5SBjoern A. Zeeb 
29b4c3e9b5SBjoern A. Zeeb /**
30b4c3e9b5SBjoern A. Zeeb  * struct p2p_bss - peer-to-peer bss related information.
31b4c3e9b5SBjoern A. Zeeb  *
32b4c3e9b5SBjoern A. Zeeb  * @vif: virtual interface of this P2P bss.
33b4c3e9b5SBjoern A. Zeeb  * @private_data: TBD
34b4c3e9b5SBjoern A. Zeeb  */
35b4c3e9b5SBjoern A. Zeeb struct p2p_bss {
36b4c3e9b5SBjoern A. Zeeb 	struct brcmf_cfg80211_vif *vif;
37b4c3e9b5SBjoern A. Zeeb 	void *private_data;
38b4c3e9b5SBjoern A. Zeeb };
39b4c3e9b5SBjoern A. Zeeb 
40b4c3e9b5SBjoern A. Zeeb /**
41b4c3e9b5SBjoern A. Zeeb  * enum brcmf_p2p_status - P2P specific dongle status.
42b4c3e9b5SBjoern A. Zeeb  *
43b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_IF_ADD: peer-to-peer vif add sent to dongle.
44b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_IF_DEL: NOT-USED?
45b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_IF_DELETING: peer-to-peer vif delete sent to dongle.
46b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_IF_CHANGING: peer-to-peer vif change sent to dongle.
47b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_IF_CHANGED: peer-to-peer vif change completed on dongle.
48b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_ACTION_TX_COMPLETED: action frame tx completed.
49b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_ACTION_TX_NOACK: action frame tx not acked.
50b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_GO_NEG_PHASE: P2P GO negotiation ongoing.
51b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_DISCOVER_LISTEN: P2P listen, remaining on channel.
52b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_SENDING_ACT_FRAME: In the process of sending action frame.
53b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_WAITING_NEXT_AF_LISTEN: extra listen time for af tx.
54b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_WAITING_NEXT_ACT_FRAME: waiting for action frame response.
55b4c3e9b5SBjoern A. Zeeb  * @BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL: search channel for AF active.
56b4c3e9b5SBjoern A. Zeeb  */
57b4c3e9b5SBjoern A. Zeeb enum brcmf_p2p_status {
58b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_ENABLED,
59b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_IF_ADD,
60b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_IF_DEL,
61b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_IF_DELETING,
62b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_IF_CHANGING,
63b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_IF_CHANGED,
64b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_ACTION_TX_COMPLETED,
65b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_ACTION_TX_NOACK,
66b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_GO_NEG_PHASE,
67b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_DISCOVER_LISTEN,
68b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_SENDING_ACT_FRAME,
69b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_WAITING_NEXT_AF_LISTEN,
70b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_WAITING_NEXT_ACT_FRAME,
71b4c3e9b5SBjoern A. Zeeb 	BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL
72b4c3e9b5SBjoern A. Zeeb };
73b4c3e9b5SBjoern A. Zeeb 
74b4c3e9b5SBjoern A. Zeeb /**
75b4c3e9b5SBjoern A. Zeeb  * struct afx_hdl - action frame off channel storage.
76b4c3e9b5SBjoern A. Zeeb  *
77b4c3e9b5SBjoern A. Zeeb  * @afx_work: worker thread for searching channel
78b4c3e9b5SBjoern A. Zeeb  * @act_frm_scan: thread synchronizing struct.
79b4c3e9b5SBjoern A. Zeeb  * @is_active: channel searching active.
80b4c3e9b5SBjoern A. Zeeb  * @peer_chan: current channel.
81b4c3e9b5SBjoern A. Zeeb  * @is_listen: sets mode for afx worker.
82b4c3e9b5SBjoern A. Zeeb  * @my_listen_chan: this peers listen channel.
83b4c3e9b5SBjoern A. Zeeb  * @peer_listen_chan: remote peers listen channel.
84b4c3e9b5SBjoern A. Zeeb  * @tx_dst_addr: mac address where tx af should be sent to.
85b4c3e9b5SBjoern A. Zeeb  */
86b4c3e9b5SBjoern A. Zeeb struct afx_hdl {
87b4c3e9b5SBjoern A. Zeeb 	struct work_struct afx_work;
88b4c3e9b5SBjoern A. Zeeb 	struct completion act_frm_scan;
89b4c3e9b5SBjoern A. Zeeb 	bool is_active;
90b4c3e9b5SBjoern A. Zeeb 	s32 peer_chan;
91b4c3e9b5SBjoern A. Zeeb 	bool is_listen;
92b4c3e9b5SBjoern A. Zeeb 	u16 my_listen_chan;
93b4c3e9b5SBjoern A. Zeeb 	u16 peer_listen_chan;
94b4c3e9b5SBjoern A. Zeeb 	u8 tx_dst_addr[ETH_ALEN];
95b4c3e9b5SBjoern A. Zeeb };
96b4c3e9b5SBjoern A. Zeeb 
97b4c3e9b5SBjoern A. Zeeb /**
98b4c3e9b5SBjoern A. Zeeb  * struct brcmf_p2p_info - p2p specific driver information.
99b4c3e9b5SBjoern A. Zeeb  *
100b4c3e9b5SBjoern A. Zeeb  * @cfg: driver private data for cfg80211 interface.
101b4c3e9b5SBjoern A. Zeeb  * @status: status of P2P (see enum brcmf_p2p_status).
102b4c3e9b5SBjoern A. Zeeb  * @dev_addr: P2P device address.
103b4c3e9b5SBjoern A. Zeeb  * @int_addr: P2P interface address.
104b4c3e9b5SBjoern A. Zeeb  * @bss_idx: informate for P2P bss types.
105b4c3e9b5SBjoern A. Zeeb  * @listen_timer: timer for @WL_P2P_DISC_ST_LISTEN discover state.
106b4c3e9b5SBjoern A. Zeeb  * @listen_channel: channel for @WL_P2P_DISC_ST_LISTEN discover state.
107b4c3e9b5SBjoern A. Zeeb  * @remain_on_channel: contains copy of struct used by cfg80211.
108b4c3e9b5SBjoern A. Zeeb  * @remain_on_channel_cookie: cookie counter for remain on channel cmd
109b4c3e9b5SBjoern A. Zeeb  * @next_af_subtype: expected action frame subtype.
110b4c3e9b5SBjoern A. Zeeb  * @send_af_done: indication that action frame tx is complete.
111b4c3e9b5SBjoern A. Zeeb  * @afx_hdl: action frame search handler info.
112b4c3e9b5SBjoern A. Zeeb  * @af_sent_channel: channel action frame is sent.
113b4c3e9b5SBjoern A. Zeeb  * @af_tx_sent_jiffies: jiffies time when af tx was transmitted.
114b4c3e9b5SBjoern A. Zeeb  * @wait_next_af: thread synchronizing struct.
115b4c3e9b5SBjoern A. Zeeb  * @gon_req_action: about to send go negotiation requets frame.
116b4c3e9b5SBjoern A. Zeeb  * @block_gon_req_tx: drop tx go negotiation requets frame.
117b4c3e9b5SBjoern A. Zeeb  * @p2pdev_dynamically: is p2p device if created by module param or supplicant.
118b4c3e9b5SBjoern A. Zeeb  * @wait_for_offchan_complete: wait for off-channel tx completion event.
119b4c3e9b5SBjoern A. Zeeb  */
120b4c3e9b5SBjoern A. Zeeb struct brcmf_p2p_info {
121b4c3e9b5SBjoern A. Zeeb 	struct brcmf_cfg80211_info *cfg;
122b4c3e9b5SBjoern A. Zeeb 	unsigned long status;
123b4c3e9b5SBjoern A. Zeeb 	u8 dev_addr[ETH_ALEN];
124b4c3e9b5SBjoern A. Zeeb 	u8 conn_int_addr[ETH_ALEN];
125b4c3e9b5SBjoern A. Zeeb 	u8 conn2_int_addr[ETH_ALEN];
126b4c3e9b5SBjoern A. Zeeb 	struct p2p_bss bss_idx[P2PAPI_BSSCFG_MAX];
127b4c3e9b5SBjoern A. Zeeb 	struct timer_list listen_timer;
128b4c3e9b5SBjoern A. Zeeb 	u8 listen_channel;
129b4c3e9b5SBjoern A. Zeeb 	struct ieee80211_channel remain_on_channel;
130b4c3e9b5SBjoern A. Zeeb 	u32 remain_on_channel_cookie;
131b4c3e9b5SBjoern A. Zeeb 	u8 next_af_subtype;
132b4c3e9b5SBjoern A. Zeeb 	struct completion send_af_done;
133b4c3e9b5SBjoern A. Zeeb 	struct afx_hdl afx_hdl;
134b4c3e9b5SBjoern A. Zeeb 	u32 af_sent_channel;
135b4c3e9b5SBjoern A. Zeeb 	unsigned long af_tx_sent_jiffies;
136b4c3e9b5SBjoern A. Zeeb 	struct completion wait_next_af;
137b4c3e9b5SBjoern A. Zeeb 	bool gon_req_action;
138b4c3e9b5SBjoern A. Zeeb 	bool block_gon_req_tx;
139b4c3e9b5SBjoern A. Zeeb 	bool p2pdev_dynamically;
140b4c3e9b5SBjoern A. Zeeb 	bool wait_for_offchan_complete;
141b4c3e9b5SBjoern A. Zeeb };
142b4c3e9b5SBjoern A. Zeeb 
143b4c3e9b5SBjoern A. Zeeb s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg, bool p2pdev_forced);
144b4c3e9b5SBjoern A. Zeeb void brcmf_p2p_detach(struct brcmf_p2p_info *p2p);
145b4c3e9b5SBjoern A. Zeeb struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name,
146b4c3e9b5SBjoern A. Zeeb 				       unsigned char name_assign_type,
147b4c3e9b5SBjoern A. Zeeb 				       enum nl80211_iftype type,
148b4c3e9b5SBjoern A. Zeeb 				       struct vif_params *params);
149b4c3e9b5SBjoern A. Zeeb int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev);
150b4c3e9b5SBjoern A. Zeeb int brcmf_p2p_ifchange(struct brcmf_cfg80211_info *cfg,
151b4c3e9b5SBjoern A. Zeeb 		       enum brcmf_fil_p2p_if_types if_type);
152b4c3e9b5SBjoern A. Zeeb void brcmf_p2p_ifp_removed(struct brcmf_if *ifp, bool rtnl_locked);
153b4c3e9b5SBjoern A. Zeeb int brcmf_p2p_start_device(struct wiphy *wiphy, struct wireless_dev *wdev);
154b4c3e9b5SBjoern A. Zeeb void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev);
155b4c3e9b5SBjoern A. Zeeb int brcmf_p2p_scan_prep(struct wiphy *wiphy,
156b4c3e9b5SBjoern A. Zeeb 			struct cfg80211_scan_request *request,
157b4c3e9b5SBjoern A. Zeeb 			struct brcmf_cfg80211_vif *vif);
158b4c3e9b5SBjoern A. Zeeb int brcmf_p2p_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
159b4c3e9b5SBjoern A. Zeeb 				struct ieee80211_channel *channel,
160b4c3e9b5SBjoern A. Zeeb 				unsigned int duration, u64 *cookie);
161b4c3e9b5SBjoern A. Zeeb int brcmf_p2p_notify_listen_complete(struct brcmf_if *ifp,
162b4c3e9b5SBjoern A. Zeeb 				     const struct brcmf_event_msg *e,
163b4c3e9b5SBjoern A. Zeeb 				     void *data);
164b4c3e9b5SBjoern A. Zeeb void brcmf_p2p_cancel_remain_on_channel(struct brcmf_if *ifp);
165b4c3e9b5SBjoern A. Zeeb int brcmf_p2p_notify_action_frame_rx(struct brcmf_if *ifp,
166b4c3e9b5SBjoern A. Zeeb 				     const struct brcmf_event_msg *e,
167b4c3e9b5SBjoern A. Zeeb 				     void *data);
168b4c3e9b5SBjoern A. Zeeb int brcmf_p2p_notify_action_tx_complete(struct brcmf_if *ifp,
169b4c3e9b5SBjoern A. Zeeb 					const struct brcmf_event_msg *e,
170b4c3e9b5SBjoern A. Zeeb 					void *data);
171*9375e11fSBjoern A. Zeeb bool brcmf_p2p_send_action_frame(struct brcmf_if *ifp,
172b4c3e9b5SBjoern A. Zeeb 				 struct brcmf_fil_af_params_le *af_params);
173b4c3e9b5SBjoern A. Zeeb bool brcmf_p2p_scan_finding_common_channel(struct brcmf_cfg80211_info *cfg,
174b4c3e9b5SBjoern A. Zeeb 					   struct brcmf_bss_info_le *bi);
175b4c3e9b5SBjoern A. Zeeb s32 brcmf_p2p_notify_rx_mgmt_p2p_probereq(struct brcmf_if *ifp,
176b4c3e9b5SBjoern A. Zeeb 					  const struct brcmf_event_msg *e,
177b4c3e9b5SBjoern A. Zeeb 					  void *data);
178b4c3e9b5SBjoern A. Zeeb #endif /* WL_CFGP2P_H_ */
179