4 * $Copyright Open Broadcom Corporation$
6 * $Id: wl_cfgp2p.h 415640 2013-07-31 02:43:28Z $
10 #include <proto/802.11.h>
11 #include <proto/p2p.h>
14 extern u32 wl_dbg_level;
16 typedef struct wifi_p2p_ie wifi_wfd_ie_t;
17 /* Enumeration of the usages of the BSSCFGs used by the P2P Library. Do not
18 * confuse this with a bsscfg index. This value is an index into the
19 * saved_ie[] array of structures which in turn contains a bsscfg index field.
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, /* maps to driver's P2P connection bsscfg */
30 P2P_SCAN_SOCIAL_CHANNEL, /* scan for social channel */
31 P2P_SCAN_AFX_PEER_NORMAL, /* scan for action frame search */
32 P2P_SCAN_AFX_PEER_REDUCED, /* scan for action frame search with short time */
33 P2P_SCAN_DURING_CONNECTED, /* scan during connected status */
34 P2P_SCAN_CONNECT_TRY, /* scan for connecting */
35 P2P_SCAN_NORMAL, /* scan during not-connected status */
39 /* vendor ies max buffer length for probe response or beacon */
40 #define VNDR_IES_MAX_BUF_LEN 1400
41 /* normal vendor ies buffer length */
42 #define VNDR_IES_BUF_LEN 512
44 /* Structure to hold all saved P2P and WPS IEs for a BSSCFG */
46 u8 p2p_probe_req_ie[VNDR_IES_BUF_LEN];
47 u8 p2p_probe_res_ie[VNDR_IES_MAX_BUF_LEN];
48 u8 p2p_assoc_req_ie[VNDR_IES_BUF_LEN];
49 u8 p2p_assoc_res_ie[VNDR_IES_BUF_LEN];
50 u8 p2p_beacon_ie[VNDR_IES_MAX_BUF_LEN];
51 u32 p2p_probe_req_ie_len;
52 u32 p2p_probe_res_ie_len;
53 u32 p2p_assoc_req_ie_len;
54 u32 p2p_assoc_res_ie_len;
55 u32 p2p_beacon_ie_len;
60 struct net_device *dev;
61 struct p2p_saved_ie saved_ie;
66 bool on; /* p2p on/off switch */
70 s8 vir_ifname[IFNAMSIZ];
72 struct ether_addr dev_addr;
73 struct ether_addr int_addr;
74 struct p2p_bss bss[P2PAPI_BSSCFG_MAX];
75 struct timer_list listen_timer;
81 #define MAX_VNDR_IE_NUMBER 5
83 struct parsed_vndr_ie_info {
85 u32 ie_len; /* total length including id & length field */
89 struct parsed_vndr_ies {
91 struct parsed_vndr_ie_info ie_info[MAX_VNDR_IE_NUMBER];
95 enum wl_cfgp2p_status {
96 WLP2P_STATUS_DISCOVERY_ON = 0,
97 WLP2P_STATUS_SEARCH_ENABLED,
100 WLP2P_STATUS_IF_DELETING,
101 WLP2P_STATUS_IF_CHANGING,
102 WLP2P_STATUS_IF_CHANGED,
103 WLP2P_STATUS_LISTEN_EXPIRED,
104 WLP2P_STATUS_ACTION_TX_COMPLETED,
105 WLP2P_STATUS_ACTION_TX_NOACK,
106 WLP2P_STATUS_SCANNING,
107 WLP2P_STATUS_GO_NEG_PHASE,
108 WLP2P_STATUS_DISC_IN_PROGRESS
112 #define wl_to_p2p_bss_ndev(wl, type) ((wl)->p2p->bss[type].dev)
113 #define wl_to_p2p_bss_bssidx(wl, type) ((wl)->p2p->bss[type].bssidx)
114 #define wl_to_p2p_bss_saved_ie(wl, type) ((wl)->p2p->bss[type].saved_ie)
115 #define wl_to_p2p_bss_private(wl, type) ((wl)->p2p->bss[type].private_data)
116 #define wl_to_p2p_bss(wl, type) ((wl)->p2p->bss[type])
117 #define wl_get_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : test_bit(WLP2P_STATUS_ ## stat, \
119 #define wl_set_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : set_bit(WLP2P_STATUS_ ## stat, \
121 #define wl_clr_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : clear_bit(WLP2P_STATUS_ ## stat, \
123 #define wl_chg_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0:change_bit(WLP2P_STATUS_ ## stat, \
125 #define p2p_on(wl) ((wl)->p2p->on)
126 #define p2p_scan(wl) ((wl)->p2p->scan)
127 #define p2p_is_on(wl) ((wl)->p2p && (wl)->p2p->on)
129 /* dword align allocation */
130 #define WLC_IOCTL_MAXLEN 8192
132 #define CFGP2P_ERROR_TEXT "CFGP2P-ERROR) "
135 #define CFGP2P_ERR(args) \
137 if (wl_dbg_level & WL_DBG_ERR) { \
138 printk(KERN_INFO CFGP2P_ERROR_TEXT "%s : ", __func__); \
142 #define CFGP2P_INFO(args) \
144 if (wl_dbg_level & WL_DBG_INFO) { \
145 printk(KERN_INFO "CFGP2P-INFO) %s : ", __func__); \
149 #define CFGP2P_DBG(args) \
151 if (wl_dbg_level & WL_DBG_DBG) { \
152 printk(KERN_INFO "CFGP2P-DEBUG) %s :", __func__); \
157 #define CFGP2P_ACTION(args) \
159 if (wl_dbg_level & WL_DBG_P2P_ACTION) { \
160 printk(KERN_INFO "CFGP2P-ACTION) %s :", __func__); \
164 #define INIT_TIMER(timer, func, duration, extra_delay) \
167 timer->function = func; \
168 timer->expires = jiffies + msecs_to_jiffies(duration + extra_delay); \
169 timer->data = (unsigned long) wl; \
173 #if !defined(WL_CFG80211_P2P_DEV_IF) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
174 #define WL_CFG80211_P2P_DEV_IF
175 #undef WL_ENABLE_P2P_IF
176 #endif /* !WL_CFG80211_P2P_DEV_IF && (LINUX_VERSION >= VERSION(3, 8, 0)) */
178 #if defined(WL_ENABLE_P2P_IF) && (defined(WL_CFG80211_P2P_DEV_IF) || \
179 (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)))
180 #error Disable 'WL_ENABLE_P2P_IF', if 'WL_CFG80211_P2P_DEV_IF' is enabled \
181 or kernel version is 3.8.0 or above
182 #endif /* WL_ENABLE_P2P_IF && (WL_CFG80211_P2P_DEV_IF || (LINUX_VERSION >= VERSION(3, 8, 0))) */
184 #if !defined(WLP2P) && (defined(WL_ENABLE_P2P_IF) || defined(WL_CFG80211_P2P_DEV_IF))
185 #error WLP2P not defined
186 #endif /* !WLP2P && (WL_ENABLE_P2P_IF || WL_CFG80211_P2P_DEV_IF) */
188 #if defined(WL_CFG80211_P2P_DEV_IF)
189 #define bcm_struct_cfgdev struct wireless_dev
191 #define bcm_struct_cfgdev struct net_device
192 #endif /* WL_CFG80211_P2P_DEV_IF */
195 wl_cfgp2p_listen_expired(unsigned long data);
197 wl_cfgp2p_is_pub_action(void *frame, u32 frame_len);
199 wl_cfgp2p_is_p2p_action(void *frame, u32 frame_len);
201 wl_cfgp2p_is_gas_action(void *frame, u32 frame_len);
203 wl_cfgp2p_find_gas_subtype(u8 subtype, u8* data, u32 len);
205 wl_cfgp2p_print_actframe(bool tx, void *frame, u32 frame_len, u32 channel);
207 wl_cfgp2p_init_priv(struct wl_priv *wl);
209 wl_cfgp2p_deinit_priv(struct wl_priv *wl);
211 wl_cfgp2p_set_firm_p2p(struct wl_priv *wl);
213 wl_cfgp2p_set_p2p_mode(struct wl_priv *wl, u8 mode,
214 u32 channel, u16 listen_ms, int bssidx);
216 wl_cfgp2p_ifadd(struct wl_priv *wl, struct ether_addr *mac, u8 if_type,
219 wl_cfgp2p_ifdisable(struct wl_priv *wl, struct ether_addr *mac);
221 wl_cfgp2p_ifdel(struct wl_priv *wl, struct ether_addr *mac);
223 wl_cfgp2p_ifchange(struct wl_priv *wl, struct ether_addr *mac, u8 if_type, chanspec_t chspec);
226 wl_cfgp2p_ifidx(struct wl_priv *wl, struct ether_addr *mac, s32 *index);
229 wl_cfgp2p_init_discovery(struct wl_priv *wl);
231 wl_cfgp2p_enable_discovery(struct wl_priv *wl, struct net_device *dev, const u8 *ie, u32 ie_len);
233 wl_cfgp2p_disable_discovery(struct wl_priv *wl);
235 wl_cfgp2p_escan(struct wl_priv *wl, struct net_device *dev, u16 active, u32 num_chans,
237 s32 search_state, u16 action, u32 bssidx, struct ether_addr *tx_dst_addr,
238 p2p_scan_purpose_t p2p_scan_purpose);
241 wl_cfgp2p_act_frm_search(struct wl_priv *wl, struct net_device *ndev,
242 s32 bssidx, s32 channel, struct ether_addr *tx_dst_addr);
244 extern wpa_ie_fixed_t *
245 wl_cfgp2p_find_wpaie(u8 *parse, u32 len);
247 extern wpa_ie_fixed_t *
248 wl_cfgp2p_find_wpsie(u8 *parse, u32 len);
250 extern wifi_p2p_ie_t *
251 wl_cfgp2p_find_p2pie(u8 *parse, u32 len);
253 extern wifi_wfd_ie_t *
254 wl_cfgp2p_find_wfdie(u8 *parse, u32 len);
256 wl_cfgp2p_set_management_ie(struct wl_priv *wl, struct net_device *ndev, s32 bssidx,
257 s32 pktflag, const u8 *vndr_ie, u32 vndr_ie_len);
259 wl_cfgp2p_clear_management_ie(struct wl_priv *wl, s32 bssidx);
262 wl_cfgp2p_find_idx(struct wl_priv *wl, struct net_device *ndev, s32 *index);
263 extern struct net_device *
264 wl_cfgp2p_find_ndev(struct wl_priv *wl, s32 bssidx);
266 wl_cfgp2p_find_type(struct wl_priv *wl, s32 bssidx, s32 *type);
270 wl_cfgp2p_listen_complete(struct wl_priv *wl, bcm_struct_cfgdev *cfgdev,
271 const wl_event_msg_t *e, void *data);
273 wl_cfgp2p_discover_listen(struct wl_priv *wl, s32 channel, u32 duration_ms);
276 wl_cfgp2p_discover_enable_search(struct wl_priv *wl, u8 enable);
279 wl_cfgp2p_action_tx_complete(struct wl_priv *wl, bcm_struct_cfgdev *cfgdev,
280 const wl_event_msg_t *e, void *data);
283 wl_cfgp2p_tx_action_frame(struct wl_priv *wl, struct net_device *dev,
284 wl_af_params_t *af_params, s32 bssidx);
287 wl_cfgp2p_generate_bss_mac(struct ether_addr *primary_addr, struct ether_addr *out_dev_addr,
288 struct ether_addr *out_int_addr);
291 wl_cfg80211_change_ifaddr(u8* buf, struct ether_addr *p2p_int_addr, u8 element_id);
293 wl_cfgp2p_bss_isup(struct net_device *ndev, int bsscfg_idx);
296 wl_cfgp2p_bss(struct wl_priv *wl, struct net_device *ndev, s32 bsscfg_idx, s32 up);
300 wl_cfgp2p_supported(struct wl_priv *wl, struct net_device *ndev);
303 wl_cfgp2p_down(struct wl_priv *wl);
306 wl_cfgp2p_set_p2p_noa(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
309 wl_cfgp2p_get_p2p_noa(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
312 wl_cfgp2p_set_p2p_ps(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
315 wl_cfgp2p_retreive_p2pattrib(void *buf, u8 element_id);
318 wl_cfgp2p_find_attrib_in_all_p2p_Ies(u8 *parse, u32 len, u32 attrib);
321 wl_cfgp2p_retreive_p2p_dev_addr(wl_bss_info_t *bi, u32 bi_length);
324 wl_cfgp2p_register_ndev(struct wl_priv *wl);
327 wl_cfgp2p_unregister_ndev(struct wl_priv *wl);
330 wl_cfgp2p_is_ifops(const struct net_device_ops *if_ops);
332 #if defined(WL_CFG80211_P2P_DEV_IF)
333 extern struct wireless_dev *
334 wl_cfgp2p_add_p2p_disc_if(void);
337 wl_cfgp2p_start_p2p_device(struct wiphy *wiphy, struct wireless_dev *wdev);
340 wl_cfgp2p_stop_p2p_device(struct wiphy *wiphy, struct wireless_dev *wdev);
343 wl_cfgp2p_del_p2p_disc_if(struct wireless_dev *wdev);
344 #endif /* WL_CFG80211_P2P_DEV_IF */
347 #define SOCIAL_CHAN_1 1
348 #define SOCIAL_CHAN_2 6
349 #define SOCIAL_CHAN_3 11
350 #define IS_P2P_SOCIAL_CHANNEL(channel) ((channel == SOCIAL_CHAN_1) || \
351 (channel == SOCIAL_CHAN_2) || \
352 (channel == SOCIAL_CHAN_3))
353 #define SOCIAL_CHAN_CNT 3
354 #define AF_PEER_SEARCH_CNT 2
355 #define WL_P2P_WILDCARD_SSID "DIRECT-"
356 #define WL_P2P_WILDCARD_SSID_LEN 7
357 #define WL_P2P_INTERFACE_PREFIX "p2p"
358 #define WL_P2P_TEMP_CHAN 11
360 /* If the provision discovery is for JOIN operations,
361 * or the device discoverablity frame is destined to GO
362 * then we need not do an internal scan to find GO.
364 #define IS_ACTPUB_WITHOUT_GROUP_ID(p2p_ie, len) \
365 (wl_cfgp2p_retreive_p2pattrib(p2p_ie, P2P_SEID_GROUP_ID) == NULL)
367 #define IS_GAS_REQ(frame, len) (wl_cfgp2p_is_gas_action(frame, len) && \
368 ((frame->action == P2PSD_ACTION_ID_GAS_IREQ) || \
369 (frame->action == P2PSD_ACTION_ID_GAS_CREQ)))
371 #define IS_P2P_PUB_ACT_RSP_SUBTYPE(subtype) ((subtype == P2P_PAF_GON_RSP) || \
372 ((subtype == P2P_PAF_GON_CONF) || \
373 (subtype == P2P_PAF_INVITE_RSP) || \
374 (subtype == P2P_PAF_PROVDIS_RSP)))
375 #define IS_P2P_SOCIAL(ch) ((ch == SOCIAL_CHAN_1) || (ch == SOCIAL_CHAN_2) || (ch == SOCIAL_CHAN_3))
376 #define IS_P2P_SSID(ssid, len) (!memcmp(ssid, WL_P2P_WILDCARD_SSID, WL_P2P_WILDCARD_SSID_LEN) && \
377 (len == WL_P2P_WILDCARD_SSID_LEN))
378 #endif /* _wl_cfgp2p_h_ */