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