4 * Copyright (C) 1999-2011, Broadcom Corporation
6 * Unless you and Broadcom execute a separate written software license
7 * agreement governing use of this software, this software is licensed to you
8 * under the terms of the GNU General Public License version 2 (the "GPL"),
9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10 * following added to such license:
12 * As a special exception, the copyright holders of this software give you
13 * permission to link this software with independent modules, and to copy and
14 * distribute the resulting executable under terms of your choice, provided that
15 * you also meet, for each linked independent module, the terms and conditions of
16 * the license of that module. An independent module is a module which is not
17 * derived from this software. The special exception does not apply to any
18 * modifications of the software.
20 * Notwithstanding the above, under no circumstances may you combine this
21 * software in any way with any other Broadcom software provided under a license
22 * other than the GPL, without Broadcom's express prior written consent.
24 * $Id: wl_cfgp2p.h 307885 2012-01-12 23:30:48Z $
28 #include <proto/802.11.h>
29 #include <proto/p2p.h>
32 extern u32 wl_dbg_level;
34 typedef struct wifi_p2p_ie wifi_wfd_ie_t;
35 /* Enumeration of the usages of the BSSCFGs used by the P2P Library. Do not
36 * confuse this with a bsscfg index. This value is an index into the
37 * saved_ie[] array of structures which in turn contains a bsscfg index field.
40 P2PAPI_BSSCFG_PRIMARY, /* maps to driver's primary bsscfg */
41 P2PAPI_BSSCFG_DEVICE, /* maps to driver's P2P device discovery bsscfg */
42 P2PAPI_BSSCFG_CONNECTION, /* maps to driver's P2P connection bsscfg */
46 #define IE_MAX_LEN 300
47 #define P2P_RES_MAX_LEN 1400
48 /* Structure to hold all saved P2P and WPS IEs for a BSSCFG */
50 u8 p2p_probe_req_ie[IE_MAX_LEN];
51 u8 p2p_probe_res_ie[P2P_RES_MAX_LEN];
52 u8 p2p_assoc_req_ie[IE_MAX_LEN];
53 u8 p2p_assoc_res_ie[IE_MAX_LEN];
54 u8 p2p_beacon_ie[IE_MAX_LEN];
55 u32 p2p_probe_req_ie_len;
56 u32 p2p_probe_res_ie_len;
57 u32 p2p_assoc_req_ie_len;
58 u32 p2p_assoc_res_ie_len;
59 u32 p2p_beacon_ie_len;
64 struct net_device *dev;
65 struct p2p_saved_ie saved_ie;
70 bool on; /* p2p on/off switch */
73 s8 vir_ifname[IFNAMSIZ];
75 struct ether_addr dev_addr;
76 struct ether_addr int_addr;
77 struct p2p_bss bss_idx[P2PAPI_BSSCFG_MAX];
78 struct timer_list listen_timer;
82 spinlock_t timer_lock;
86 enum wl_cfgp2p_status {
87 WLP2P_STATUS_DISCOVERY_ON = 0,
88 WLP2P_STATUS_SEARCH_ENABLED,
91 WLP2P_STATUS_IF_DELETING,
92 WLP2P_STATUS_IF_CHANGING,
93 WLP2P_STATUS_IF_CHANGED,
94 WLP2P_STATUS_LISTEN_EXPIRED,
95 WLP2P_STATUS_ACTION_TX_COMPLETED,
96 WLP2P_STATUS_ACTION_TX_NOACK,
101 #define wl_to_p2p_bss_ndev(w, type) ((wl)->p2p->bss_idx[type].dev)
102 #define wl_to_p2p_bss_bssidx(w, type) ((wl)->p2p->bss_idx[type].bssidx)
103 #define wl_to_p2p_bss_saved_ie(w, type) ((wl)->p2p->bss_idx[type].saved_ie)
104 #define wl_to_p2p_bss_private(w, type) ((wl)->p2p->bss_idx[type].private_data)
105 #define wl_to_p2p_bss(wl, type) ((wl)->p2p->bss_idx[type])
106 #define wl_get_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : test_bit(WLP2P_STATUS_ ## stat, \
108 #define wl_set_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : set_bit(WLP2P_STATUS_ ## stat, \
110 #define wl_clr_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : clear_bit(WLP2P_STATUS_ ## stat, \
112 #define wl_chg_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0:change_bit(WLP2P_STATUS_ ## stat, \
114 #define p2p_on(wl) ((wl)->p2p->on)
115 #define p2p_scan(wl) ((wl)->p2p->scan)
116 #define p2p_is_on(wl) ((wl)->p2p && (wl)->p2p->on)
118 /* dword align allocation */
119 #define WLC_IOCTL_MAXLEN 8192
120 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
121 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
123 #define CFGP2P_ERR(args) \
125 if (wl_dbg_level & WL_DBG_ERR) { \
126 printk(KERN_INFO "CFGP2P-INFO2) %s : ", __func__); \
130 #define CFGP2P_INFO(args) \
132 if (wl_dbg_level & WL_DBG_INFO) { \
133 printk(KERN_INFO "CFGP2P-INFO) %s : ", __func__); \
137 #define CFGP2P_DBG(args) \
139 if (wl_dbg_level & WL_DBG_DBG) { \
140 printk(KERN_DEBUG "CFGP2P-DEBUG) %s :", __func__); \
144 #define INIT_TIMER(timer, func, duration, extra_delay) \
147 timer->function = func; \
148 timer->expires = jiffies + msecs_to_jiffies(duration + extra_delay); \
149 timer->data = (unsigned long) wl; \
153 wl_cfgp2p_listen_expired(unsigned long data);
155 wl_cfgp2p_is_pub_action(void *frame, u32 frame_len);
157 wl_cfgp2p_is_p2p_action(void *frame, u32 frame_len);
159 wl_cfgp2p_is_gas_action(void *frame, u32 frame_len);
161 wl_cfgp2p_print_actframe(bool tx, void *frame, u32 frame_len);
163 wl_cfgp2p_init_priv(struct wl_priv *wl);
165 wl_cfgp2p_deinit_priv(struct wl_priv *wl);
167 wl_cfgp2p_set_firm_p2p(struct wl_priv *wl);
169 wl_cfgp2p_set_p2p_mode(struct wl_priv *wl, u8 mode,
170 u32 channel, u16 listen_ms, int bssidx);
172 wl_cfgp2p_ifadd(struct wl_priv *wl, struct ether_addr *mac, u8 if_type,
175 wl_cfgp2p_ifdisable(struct wl_priv *wl, struct ether_addr *mac);
177 wl_cfgp2p_ifdel(struct wl_priv *wl, struct ether_addr *mac);
179 wl_cfgp2p_ifchange(struct wl_priv *wl, struct ether_addr *mac, u8 if_type, chanspec_t chspec);
182 wl_cfgp2p_ifidx(struct wl_priv *wl, struct ether_addr *mac, s32 *index);
185 wl_cfgp2p_init_discovery(struct wl_priv *wl);
187 wl_cfgp2p_enable_discovery(struct wl_priv *wl, struct net_device *dev, const u8 *ie, u32 ie_len);
189 wl_cfgp2p_disable_discovery(struct wl_priv *wl);
191 wl_cfgp2p_escan(struct wl_priv *wl, struct net_device *dev, u16 active, u32 num_chans,
193 s32 search_state, u16 action, u32 bssidx);
196 wl_cfgp2p_act_frm_search(struct wl_priv *wl, struct net_device *ndev,
197 s32 bssidx, s32 channel);
199 extern wpa_ie_fixed_t *
200 wl_cfgp2p_find_wpaie(u8 *parse, u32 len);
202 extern wpa_ie_fixed_t *
203 wl_cfgp2p_find_wpsie(u8 *parse, u32 len);
205 extern wifi_p2p_ie_t *
206 wl_cfgp2p_find_customer_ie(u8 *parse, u32 *len);
208 extern wifi_p2p_ie_t *
209 wl_cfgp2p_find_p2pie(u8 *parse, u32 len);
211 extern wifi_wfd_ie_t *
212 wl_cfgp2p_find_wfdie(u8 *parse, u32 len);
214 wl_cfgp2p_set_management_ie(struct wl_priv *wl, struct net_device *ndev, s32 bssidx,
215 s32 pktflag, const u8 *vndr_ie, u32 vndr_ie_len);
217 wl_cfgp2p_clear_management_ie(struct wl_priv *wl, s32 bssidx);
220 wl_cfgp2p_find_idx(struct wl_priv *wl, struct net_device *ndev);
224 wl_cfgp2p_p2p_listen_suspend(void);
226 wl_cfgp2p_listen_complete(struct wl_priv *wl, struct net_device *ndev,
227 const wl_event_msg_t *e, void *data);
229 wl_cfgp2p_discover_listen(struct wl_priv *wl, s32 channel, u32 duration_ms);
232 wl_cfgp2p_discover_enable_search(struct wl_priv *wl, u8 enable);
235 wl_cfgp2p_action_tx_complete(struct wl_priv *wl, struct net_device *ndev,
236 const wl_event_msg_t *e, void *data);
238 wl_cfgp2p_tx_action_frame(struct wl_priv *wl, struct net_device *dev,
239 wl_af_params_t *af_params, s32 bssidx);
242 wl_cfgp2p_generate_bss_mac(struct ether_addr *primary_addr, struct ether_addr *out_dev_addr,
243 struct ether_addr *out_int_addr);
246 wl_cfg80211_change_ifaddr(u8* buf, struct ether_addr *p2p_int_addr, u8 element_id);
248 wl_cfgp2p_bss_isup(struct net_device *ndev, int bsscfg_idx);
251 wl_cfgp2p_bss(struct wl_priv *wl, struct net_device *ndev, s32 bsscfg_idx, s32 up);
255 wl_cfgp2p_supported(struct wl_priv *wl, struct net_device *ndev);
258 wl_cfgp2p_down(struct wl_priv *wl);
261 wl_cfgp2p_set_p2p_noa(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
264 wl_cfgp2p_get_p2p_noa(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
267 wl_cfgp2p_set_p2p_ps(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
270 wl_cfgp2p_retreive_p2pattrib(void *buf, u8 element_id);
273 wl_cfgp2p_retreive_p2p_dev_addr(wl_bss_info_t *bi, u32 bi_length);
276 wl_cfgp2p_register_ndev(struct wl_priv *wl);
279 wl_cfgp2p_unregister_ndev(struct wl_priv *wl);
282 #define SOCIAL_CHAN_1 1
283 #define SOCIAL_CHAN_2 6
284 #define SOCIAL_CHAN_3 11
285 #define SOCIAL_CHAN_CNT 3
286 #define AF_PEER_SEARCH_CNT 2
287 #define WL_P2P_WILDCARD_SSID "DIRECT-"
288 #define WL_P2P_WILDCARD_SSID_LEN 7
289 #define WL_P2P_INTERFACE_PREFIX "p2p"
290 #define WL_P2P_TEMP_CHAN "11"
293 #define IS_GAS_REQ(frame, len) (wl_cfgp2p_is_gas_action(frame, len) && \
294 ((frame->action == P2PSD_ACTION_ID_GAS_IREQ) || \
295 (frame->action == P2PSD_ACTION_ID_GAS_CREQ)))
296 #define IS_P2P_PUB_ACT_REQ(frame, len) (wl_cfgp2p_is_pub_action(frame, len) && \
297 ((frame->subtype == P2P_PAF_GON_REQ) || \
298 (frame->subtype == P2P_PAF_INVITE_REQ) || \
299 (frame->subtype == P2P_PAF_PROVDIS_REQ)))
300 #define IS_P2P_PUB_ACT_RSP_SUBTYPE(subtype) ((subtype == P2P_PAF_GON_RSP) || \
301 ((subtype == P2P_PAF_GON_CONF) || \
302 (subtype == P2P_PAF_INVITE_RSP) || \
303 (subtype == P2P_PAF_PROVDIS_RSP)))
304 #define IS_P2P_SOCIAL(ch) ((ch == SOCIAL_CHAN_1) || (ch == SOCIAL_CHAN_2) || (ch == SOCIAL_CHAN_3))
305 #define IS_P2P_SSID(ssid, len) (!memcmp(ssid, WL_P2P_WILDCARD_SSID, WL_P2P_WILDCARD_SSID_LEN) && (len == WL_P2P_WILDCARD_SSID_LEN))
306 #endif /* _wl_cfgp2p_h_ */