4 * Copyright (C) 1999-2018, Broadcom.
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.
25 * <<Broadcom-WL-IPTag/Open:>>
27 * $Id: wl_cfgp2p.h 710886 2017-07-14 08:39:03Z $
35 extern u32 wl_dbg_level
;
37 typedef struct wifi_p2p_ie wifi_wfd_ie_t
;
38 /* Enumeration of the usages of the BSSCFGs used by the P2P Library. Do not
39 * confuse this with a bsscfg index. This value is an index into the
40 * saved_ie[] array of structures which in turn contains a bsscfg index field.
43 P2PAPI_BSSCFG_PRIMARY
, /**< maps to driver's primary bsscfg */
44 P2PAPI_BSSCFG_DEVICE
, /**< maps to driver's P2P device discovery bsscfg */
45 P2PAPI_BSSCFG_CONNECTION1
, /**< maps to driver's P2P connection bsscfg */
46 P2PAPI_BSSCFG_CONNECTION2
,
52 P2P_SCAN_SOCIAL_CHANNEL
, /**< scan for social channel */
53 P2P_SCAN_AFX_PEER_NORMAL
, /**< scan for action frame search */
54 P2P_SCAN_AFX_PEER_REDUCED
, /**< scan for action frame search with short time */
55 P2P_SCAN_DURING_CONNECTED
, /**< scan during connected status */
56 P2P_SCAN_CONNECT_TRY
, /**< scan for connecting */
57 P2P_SCAN_NORMAL
, /**< scan during not-connected status */
61 /** vendor ies max buffer length for probe response or beacon */
62 #define VNDR_IES_MAX_BUF_LEN 1400
63 /** normal vendor ies buffer length */
64 #define VNDR_IES_BUF_LEN 512
68 struct net_device
*dev
;
70 struct ether_addr mac_addr
;
74 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
75 struct bcm_cfg80211
*cfg
;
77 bool on
; /**< p2p on/off switch */
80 s8 vir_ifname
[IFNAMSIZ
];
82 struct p2p_bss bss
[P2PAPI_BSSCFG_MAX
];
83 struct timer_list listen_timer
;
90 #define MAX_VNDR_IE_NUMBER 10
92 struct parsed_vndr_ie_info
{
94 u32 ie_len
; /**< total length including id & length field */
98 struct parsed_vndr_ies
{
100 struct parsed_vndr_ie_info ie_info
[MAX_VNDR_IE_NUMBER
];
104 enum wl_cfgp2p_status
{
105 WLP2P_STATUS_DISCOVERY_ON
= 0,
106 WLP2P_STATUS_SEARCH_ENABLED
,
107 WLP2P_STATUS_IF_ADDING
,
108 WLP2P_STATUS_IF_DELETING
,
109 WLP2P_STATUS_IF_CHANGING
,
110 WLP2P_STATUS_IF_CHANGED
,
111 WLP2P_STATUS_LISTEN_EXPIRED
,
112 WLP2P_STATUS_ACTION_TX_COMPLETED
,
113 WLP2P_STATUS_ACTION_TX_NOACK
,
114 WLP2P_STATUS_SCANNING
,
115 WLP2P_STATUS_GO_NEG_PHASE
,
116 WLP2P_STATUS_DISC_IN_PROGRESS
119 #define wl_to_p2p_bss_ndev(cfg, type) ((cfg)->p2p->bss[type].dev)
120 #define wl_to_p2p_bss_bssidx(cfg, type) ((cfg)->p2p->bss[type].bssidx)
121 #define wl_to_p2p_bss_macaddr(cfg, type) &((cfg)->p2p->bss[type].mac_addr)
122 #define wl_to_p2p_bss_saved_ie(cfg, type) ((cfg)->p2p->bss[type].saved_ie)
123 #define wl_to_p2p_bss_private(cfg, type) ((cfg)->p2p->bss[type].private_data)
124 #define wl_to_p2p_bss(cfg, type) ((cfg)->p2p->bss[type])
125 #define wl_get_p2p_status(cfg, stat) ((!(cfg)->p2p_supported) ? 0 : \
126 test_bit(WLP2P_STATUS_ ## stat, &(cfg)->p2p->status))
127 #define wl_set_p2p_status(cfg, stat) ((!(cfg)->p2p_supported) ? 0 : \
128 set_bit(WLP2P_STATUS_ ## stat, &(cfg)->p2p->status))
129 #define wl_clr_p2p_status(cfg, stat) ((!(cfg)->p2p_supported) ? 0 : \
130 clear_bit(WLP2P_STATUS_ ## stat, &(cfg)->p2p->status))
131 #define wl_chg_p2p_status(cfg, stat) ((!(cfg)->p2p_supported) ? 0 : \
132 change_bit(WLP2P_STATUS_ ## stat, &(cfg)->p2p->status))
133 #define p2p_on(cfg) ((cfg)->p2p->on)
134 #define p2p_scan(cfg) ((cfg)->p2p->scan)
135 #define p2p_is_on(cfg) ((cfg)->p2p && (cfg)->p2p->on)
137 /* dword align allocation */
138 #define WLC_IOCTL_MAXLEN 8192
140 #define CFGP2P_ERROR_TEXT "CFGP2P-ERROR) "
143 #define CFGP2P_ERR(args) \
145 if (wl_dbg_level & WL_DBG_ERR) { \
146 printk(KERN_INFO CFGP2P_ERROR_TEXT "%s : ", __func__); \
148 DHD_LOG_DUMP_WRITE("[%s] %s: ", \
149 dhd_log_dump_get_timestamp(), __func__); \
150 DHD_LOG_DUMP_WRITE args; \
153 #define CFGP2P_INFO(args) \
155 if (wl_dbg_level & WL_DBG_INFO) { \
156 printk(KERN_INFO "CFGP2P-INFO) %s : ", __func__); \
158 DHD_LOG_DUMP_WRITE("[%s] %s: ", \
159 dhd_log_dump_get_timestamp(), __func__); \
160 DHD_LOG_DUMP_WRITE args; \
164 #define CFGP2P_ERR(args) \
166 if (wl_dbg_level & WL_DBG_ERR) { \
167 printk(KERN_INFO CFGP2P_ERROR_TEXT "%s : ", __func__); \
171 #define CFGP2P_INFO(args) \
173 if (wl_dbg_level & WL_DBG_INFO) { \
174 printk(KERN_INFO "CFGP2P-INFO) %s : ", __func__); \
178 #endif /* DHD_LOG_DUMP */
179 #define CFGP2P_DBG(args) \
181 if (wl_dbg_level & WL_DBG_DBG) { \
182 printk(KERN_INFO "CFGP2P-DEBUG) %s :", __func__); \
187 #define CFGP2P_ACTION(args) \
189 if (wl_dbg_level & WL_DBG_P2P_ACTION) { \
190 printk(KERN_INFO "CFGP2P-ACTION) %s :", __func__); \
194 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
195 #define INIT_TIMER(timer, func, duration, extra_delay) \
197 timer_setup(timer, func, 0); \
198 timer->expires = jiffies + msecs_to_jiffies(duration + extra_delay); \
202 #define INIT_TIMER(timer, func, duration, extra_delay) \
205 timer->function = func; \
206 timer->expires = jiffies + msecs_to_jiffies(duration + extra_delay); \
207 timer->data = (unsigned long) cfg; \
212 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 0, 8))
213 #ifdef WL_SUPPORT_BACKPORTED_KPATCHES
214 #undef WL_SUPPORT_BACKPORTED_KPATCHES
218 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0))
219 #ifdef WL_CFG80211_STA_EVENT
220 #undef WL_CFG80211_STA_EVENT
224 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) && !defined(WL_CFG80211_P2P_DEV_IF)
225 #define WL_CFG80211_P2P_DEV_IF
227 #ifdef WL_SUPPORT_BACKPORTED_KPATCHES
228 #undef WL_SUPPORT_BACKPORTED_KPATCHES
232 /* Enable P2P network Interface if P2P support is enabled */
233 #define WL_ENABLE_P2P_IF
235 #endif /* (LINUX_VERSION >= VERSION(3, 8, 0)) */
237 #ifndef WL_CFG80211_P2P_DEV_IF
238 #endif /* WL_CFG80211_P2P_DEV_IF */
240 #if defined(WL_ENABLE_P2P_IF) && (defined(WL_CFG80211_P2P_DEV_IF) || \
241 (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)))
242 #error Disable 'WL_ENABLE_P2P_IF', if 'WL_CFG80211_P2P_DEV_IF' is enabled \
243 or kernel version is 3.8.0 or above
244 #endif /* WL_ENABLE_P2P_IF && (WL_CFG80211_P2P_DEV_IF || (LINUX_VERSION >= VERSION(3, 8, 0))) */
246 #if !defined(WLP2P) && (defined(WL_ENABLE_P2P_IF) || defined(WL_CFG80211_P2P_DEV_IF))
247 #error WLP2P not defined
248 #endif /* !WLP2P && (WL_ENABLE_P2P_IF || WL_CFG80211_P2P_DEV_IF) */
250 #if defined(WL_CFG80211_P2P_DEV_IF)
251 #define bcm_struct_cfgdev struct wireless_dev
253 #define bcm_struct_cfgdev struct net_device
254 #endif /* WL_CFG80211_P2P_DEV_IF */
256 #define P2P_ECSA_CNT 50
259 wl_cfgp2p_listen_expired(
260 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
267 wl_cfgp2p_is_pub_action(void *frame
, u32 frame_len
);
269 wl_cfgp2p_is_p2p_action(void *frame
, u32 frame_len
);
271 wl_cfgp2p_is_gas_action(void *frame
, u32 frame_len
);
273 wl_cfgp2p_find_gas_subtype(u8 subtype
, u8
* data
, u32 len
);
275 wl_cfgp2p_is_p2p_gas_action(void *frame
, u32 frame_len
);
277 wl_cfgp2p_print_actframe(bool tx
, void *frame
, u32 frame_len
, u32 channel
);
279 wl_cfgp2p_init_priv(struct bcm_cfg80211
*cfg
);
281 wl_cfgp2p_deinit_priv(struct bcm_cfg80211
*cfg
);
283 wl_cfgp2p_set_firm_p2p(struct bcm_cfg80211
*cfg
);
285 wl_cfgp2p_set_p2p_mode(struct bcm_cfg80211
*cfg
, u8 mode
,
286 u32 channel
, u16 listen_ms
, int bssidx
);
288 wl_cfgp2p_ifadd(struct bcm_cfg80211
*cfg
, struct ether_addr
*mac
, u8 if_type
,
291 wl_cfgp2p_ifdisable(struct bcm_cfg80211
*cfg
, struct ether_addr
*mac
);
293 wl_cfgp2p_ifdel(struct bcm_cfg80211
*cfg
, struct ether_addr
*mac
);
295 wl_cfgp2p_ifchange(struct bcm_cfg80211
*cfg
, struct ether_addr
*mac
, u8 if_type
,
296 chanspec_t chspec
, s32 conn_idx
);
299 wl_cfgp2p_ifidx(struct bcm_cfg80211
*cfg
, struct ether_addr
*mac
, s32
*index
);
302 wl_cfgp2p_init_discovery(struct bcm_cfg80211
*cfg
);
304 wl_cfgp2p_enable_discovery(struct bcm_cfg80211
*cfg
, struct net_device
*dev
, const u8
*ie
,
307 wl_cfgp2p_disable_discovery(struct bcm_cfg80211
*cfg
);
309 wl_cfgp2p_escan(struct bcm_cfg80211
*cfg
, struct net_device
*dev
, u16 active
, u32 num_chans
,
311 s32 search_state
, u16 action
, u32 bssidx
, struct ether_addr
*tx_dst_addr
,
312 p2p_scan_purpose_t p2p_scan_purpose
);
315 wl_cfgp2p_act_frm_search(struct bcm_cfg80211
*cfg
, struct net_device
*ndev
,
316 s32 bssidx
, s32 channel
, struct ether_addr
*tx_dst_addr
);
318 extern const wpa_ie_fixed_t
*
319 wl_cfgp2p_find_wpaie(const u8
*parse
, u32 len
);
321 extern const wpa_ie_fixed_t
*
322 wl_cfgp2p_find_wpsie(const u8
*parse
, u32 len
);
324 extern wifi_p2p_ie_t
*
325 wl_cfgp2p_find_p2pie(const u8
*parse
, u32 len
);
327 extern const wifi_wfd_ie_t
*
328 wl_cfgp2p_find_wfdie(const u8
*parse
, u32 len
);
330 wl_cfgp2p_set_management_ie(struct bcm_cfg80211
*cfg
, struct net_device
*ndev
, s32 bssidx
,
331 s32 pktflag
, const u8
*vndr_ie
, u32 vndr_ie_len
);
333 wl_cfgp2p_clear_management_ie(struct bcm_cfg80211
*cfg
, s32 bssidx
);
335 extern struct net_device
*
336 wl_cfgp2p_find_ndev(struct bcm_cfg80211
*cfg
, s32 bssidx
);
338 wl_cfgp2p_find_type(struct bcm_cfg80211
*cfg
, s32 bssidx
, s32
*type
);
341 wl_cfgp2p_listen_complete(struct bcm_cfg80211
*cfg
, bcm_struct_cfgdev
*cfgdev
,
342 const wl_event_msg_t
*e
, void *data
);
344 wl_cfgp2p_discover_listen(struct bcm_cfg80211
*cfg
, s32 channel
, u32 duration_ms
);
347 wl_cfgp2p_discover_enable_search(struct bcm_cfg80211
*cfg
, u8 enable
);
350 wl_cfgp2p_action_tx_complete(struct bcm_cfg80211
*cfg
, bcm_struct_cfgdev
*cfgdev
,
351 const wl_event_msg_t
*e
, void *data
);
354 wl_cfgp2p_tx_action_frame(struct bcm_cfg80211
*cfg
, struct net_device
*dev
,
355 wl_af_params_t
*af_params
, s32 bssidx
);
358 wl_cfgp2p_generate_bss_mac(struct bcm_cfg80211
*cfg
, struct ether_addr
*primary_addr
);
361 wl_cfg80211_change_ifaddr(u8
* buf
, struct ether_addr
*p2p_int_addr
, u8 element_id
);
364 wl_cfgp2p_supported(struct bcm_cfg80211
*cfg
, struct net_device
*ndev
);
367 wl_cfgp2p_down(struct bcm_cfg80211
*cfg
);
370 wl_cfgp2p_set_p2p_noa(struct bcm_cfg80211
*cfg
, struct net_device
*ndev
, char* buf
, int len
);
373 wl_cfgp2p_get_p2p_noa(struct bcm_cfg80211
*cfg
, struct net_device
*ndev
, char* buf
, int len
);
376 wl_cfgp2p_set_p2p_ps(struct bcm_cfg80211
*cfg
, struct net_device
*ndev
, char* buf
, int len
);
379 wl_cfgp2p_set_p2p_ecsa(struct bcm_cfg80211
*cfg
, struct net_device
*ndev
, char* buf
, int len
);
382 wl_cfgp2p_increase_p2p_bw(struct bcm_cfg80211
*cfg
, struct net_device
*ndev
, char* buf
, int len
);
385 wl_cfgp2p_retreive_p2pattrib(const void *buf
, u8 element_id
);
388 wl_cfgp2p_find_attrib_in_all_p2p_Ies(const u8
*parse
, u32 len
, u32 attrib
);
391 wl_cfgp2p_retreive_p2p_dev_addr(wl_bss_info_t
*bi
, u32 bi_length
);
394 wl_cfgp2p_register_ndev(struct bcm_cfg80211
*cfg
);
397 wl_cfgp2p_unregister_ndev(struct bcm_cfg80211
*cfg
);
400 wl_cfgp2p_is_ifops(const struct net_device_ops
*if_ops
);
403 wl_cfgp2p_vndr_ie(struct bcm_cfg80211
*cfg
, u8
*iebuf
, s32 pktflag
,
404 s8
*oui
, s32 ie_id
, const s8
*data
, s32 datalen
, const s8
* add_del_cmd
);
406 extern int wl_cfgp2p_get_conn_idx(struct bcm_cfg80211
*cfg
);
409 int wl_cfg_multip2p_operational(struct bcm_cfg80211
*cfg
);
412 int wl_cfgp2p_vif_created(struct bcm_cfg80211
*cfg
);
414 #if defined(WL_CFG80211_P2P_DEV_IF)
415 extern struct wireless_dev
*
416 wl_cfgp2p_add_p2p_disc_if(struct bcm_cfg80211
*cfg
);
419 wl_cfgp2p_start_p2p_device(struct wiphy
*wiphy
, struct wireless_dev
*wdev
);
422 wl_cfgp2p_stop_p2p_device(struct wiphy
*wiphy
, struct wireless_dev
*wdev
);
425 wl_cfgp2p_del_p2p_disc_if(struct wireless_dev
*wdev
, struct bcm_cfg80211
*cfg
);
427 #endif /* WL_CFG80211_P2P_DEV_IF */
430 wl_cfgp2p_need_wait_actfrmae(struct bcm_cfg80211
*cfg
, void *frame
, u32 frame_len
, bool tx
);
433 wl_cfgp2p_is_p2p_specific_scan(struct cfg80211_scan_request
*request
);
436 #define SOCIAL_CHAN_1 1
437 #define SOCIAL_CHAN_2 6
438 #define SOCIAL_CHAN_3 11
439 #define IS_P2P_SOCIAL_CHANNEL(channel) ((channel == SOCIAL_CHAN_1) || \
440 (channel == SOCIAL_CHAN_2) || \
441 (channel == SOCIAL_CHAN_3))
442 #define SOCIAL_CHAN_CNT 3
443 #define AF_PEER_SEARCH_CNT 2
444 #define WL_P2P_WILDCARD_SSID "DIRECT-"
445 #define WL_P2P_WILDCARD_SSID_LEN 7
446 #define WL_P2P_INTERFACE_PREFIX "p2p"
447 #define WL_P2P_TEMP_CHAN 11
448 #define WL_P2P_TEMP_CHAN_5G 36
449 #define WL_P2P_AF_STATUS_OFFSET 9
451 /* If the provision discovery is for JOIN operations,
452 * or the device discoverablity frame is destined to GO
453 * then we need not do an internal scan to find GO.
455 #define IS_ACTPUB_WITHOUT_GROUP_ID(p2p_ie, len) \
456 (wl_cfgp2p_retreive_p2pattrib(p2p_ie, P2P_SEID_GROUP_ID) == NULL)
458 #define IS_GAS_REQ(frame, len) (wl_cfgp2p_is_gas_action(frame, len) && \
459 ((frame->action == P2PSD_ACTION_ID_GAS_IREQ) || \
460 (frame->action == P2PSD_ACTION_ID_GAS_CREQ)))
462 #define IS_P2P_PUB_ACT_RSP_SUBTYPE(subtype) ((subtype == P2P_PAF_GON_RSP) || \
463 ((subtype == P2P_PAF_GON_CONF) || \
464 (subtype == P2P_PAF_INVITE_RSP) || \
465 (subtype == P2P_PAF_PROVDIS_RSP)))
466 #define IS_P2P_SOCIAL(ch) ((ch == SOCIAL_CHAN_1) || (ch == SOCIAL_CHAN_2) || (ch == SOCIAL_CHAN_3))
467 #define IS_P2P_SSID(ssid, len) (!memcmp(ssid, WL_P2P_WILDCARD_SSID, WL_P2P_WILDCARD_SSID_LEN) && \
468 (len == WL_P2P_WILDCARD_SSID_LEN))
469 #endif /* _wl_cfgp2p_h_ */