PageRenderTime 29ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/bcmdhd4358/wl_cfgp2p.h

https://gitlab.com/SerenityS/slteskt_kernel
C Header | 429 lines | 325 code | 64 blank | 40 comment | 40 complexity | cc26a1842cfdacf5cc22dd5a1c76e821 MD5 | raw file
  1. /*
  2. * Linux cfgp2p driver
  3. *
  4. * Copyright (C) 1999-2015, Broadcom Corporation
  5. *
  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:
  11. *
  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.
  19. *
  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.
  23. *
  24. * $Id: wl_cfgp2p.h 525774 2015-01-12 12:51:24Z $
  25. */
  26. #ifndef _wl_cfgp2p_h_
  27. #define _wl_cfgp2p_h_
  28. #include <proto/802.11.h>
  29. #include <proto/p2p.h>
  30. struct bcm_cfg80211;
  31. extern u32 wl_dbg_level;
  32. typedef struct wifi_p2p_ie wifi_wfd_ie_t;
  33. /* Enumeration of the usages of the BSSCFGs used by the P2P Library. Do not
  34. * confuse this with a bsscfg index. This value is an index into the
  35. * saved_ie[] array of structures which in turn contains a bsscfg index field.
  36. */
  37. typedef enum {
  38. P2PAPI_BSSCFG_PRIMARY, /* maps to driver's primary bsscfg */
  39. P2PAPI_BSSCFG_DEVICE, /* maps to driver's P2P device discovery bsscfg */
  40. P2PAPI_BSSCFG_CONNECTION, /* maps to driver's P2P connection bsscfg */
  41. P2PAPI_BSSCFG_MAX
  42. } p2p_bsscfg_type_t;
  43. typedef enum {
  44. P2P_SCAN_PURPOSE_MIN,
  45. P2P_SCAN_SOCIAL_CHANNEL, /* scan for social channel */
  46. P2P_SCAN_AFX_PEER_NORMAL, /* scan for action frame search */
  47. P2P_SCAN_AFX_PEER_REDUCED, /* scan for action frame search with short time */
  48. P2P_SCAN_DURING_CONNECTED, /* scan during connected status */
  49. P2P_SCAN_CONNECT_TRY, /* scan for connecting */
  50. P2P_SCAN_NORMAL, /* scan during not-connected status */
  51. P2P_SCAN_PURPOSE_MAX
  52. } p2p_scan_purpose_t;
  53. /* vendor ies max buffer length for probe response or beacon */
  54. #define VNDR_IES_MAX_BUF_LEN 1400
  55. /* normal vendor ies buffer length */
  56. #define VNDR_IES_BUF_LEN 512
  57. /* Structure to hold all saved P2P and WPS IEs for a BSSCFG */
  58. struct p2p_saved_ie {
  59. u8 p2p_probe_req_ie[VNDR_IES_BUF_LEN];
  60. u8 p2p_probe_res_ie[VNDR_IES_MAX_BUF_LEN];
  61. u8 p2p_assoc_req_ie[VNDR_IES_BUF_LEN];
  62. u8 p2p_assoc_res_ie[VNDR_IES_BUF_LEN];
  63. u8 p2p_beacon_ie[VNDR_IES_MAX_BUF_LEN];
  64. u32 p2p_probe_req_ie_len;
  65. u32 p2p_probe_res_ie_len;
  66. u32 p2p_assoc_req_ie_len;
  67. u32 p2p_assoc_res_ie_len;
  68. u32 p2p_beacon_ie_len;
  69. };
  70. struct p2p_bss {
  71. s32 bssidx;
  72. struct net_device *dev;
  73. struct p2p_saved_ie saved_ie;
  74. void *private_data;
  75. };
  76. struct p2p_info {
  77. bool on; /* p2p on/off switch */
  78. bool scan;
  79. int16 search_state;
  80. bool vif_created;
  81. s8 vir_ifname[IFNAMSIZ];
  82. unsigned long status;
  83. struct ether_addr dev_addr;
  84. struct ether_addr int_addr;
  85. struct p2p_bss bss[P2PAPI_BSSCFG_MAX];
  86. struct timer_list listen_timer;
  87. wl_p2p_sched_t noa;
  88. wl_p2p_ops_t ops;
  89. wlc_ssid_t ssid;
  90. };
  91. #define MAX_VNDR_IE_NUMBER 5
  92. struct parsed_vndr_ie_info {
  93. char *ie_ptr;
  94. u32 ie_len; /* total length including id & length field */
  95. vndr_ie_t vndrie;
  96. };
  97. struct parsed_vndr_ies {
  98. u32 count;
  99. struct parsed_vndr_ie_info ie_info[MAX_VNDR_IE_NUMBER];
  100. };
  101. /* dongle status */
  102. enum wl_cfgp2p_status {
  103. WLP2P_STATUS_DISCOVERY_ON = 0,
  104. WLP2P_STATUS_SEARCH_ENABLED,
  105. WLP2P_STATUS_IF_ADDING,
  106. WLP2P_STATUS_IF_DELETING,
  107. WLP2P_STATUS_IF_CHANGING,
  108. WLP2P_STATUS_IF_CHANGED,
  109. WLP2P_STATUS_LISTEN_EXPIRED,
  110. WLP2P_STATUS_ACTION_TX_COMPLETED,
  111. WLP2P_STATUS_ACTION_TX_NOACK,
  112. WLP2P_STATUS_SCANNING,
  113. WLP2P_STATUS_GO_NEG_PHASE,
  114. WLP2P_STATUS_DISC_IN_PROGRESS
  115. };
  116. #define wl_to_p2p_bss_ndev(cfg, type) ((cfg)->p2p->bss[type].dev)
  117. #define wl_to_p2p_bss_bssidx(cfg, type) ((cfg)->p2p->bss[type].bssidx)
  118. #define wl_to_p2p_bss_saved_ie(cfg, type) ((cfg)->p2p->bss[type].saved_ie)
  119. #define wl_to_p2p_bss_private(cfg, type) ((cfg)->p2p->bss[type].private_data)
  120. #define wl_to_p2p_bss(cfg, type) ((cfg)->p2p->bss[type])
  121. #define wl_get_p2p_status(cfg, stat) ((!(cfg)->p2p_supported) ? 0 : \
  122. test_bit(WLP2P_STATUS_ ## stat, &(cfg)->p2p->status))
  123. #define wl_set_p2p_status(cfg, stat) ((!(cfg)->p2p_supported) ? 0 : \
  124. set_bit(WLP2P_STATUS_ ## stat, &(cfg)->p2p->status))
  125. #define wl_clr_p2p_status(cfg, stat) ((!(cfg)->p2p_supported) ? 0 : \
  126. clear_bit(WLP2P_STATUS_ ## stat, &(cfg)->p2p->status))
  127. #define wl_chg_p2p_status(cfg, stat) ((!(cfg)->p2p_supported) ? 0 : \
  128. change_bit(WLP2P_STATUS_ ## stat, &(cfg)->p2p->status))
  129. #define p2p_on(cfg) ((cfg)->p2p->on)
  130. #define p2p_scan(cfg) ((cfg)->p2p->scan)
  131. #define p2p_is_on(cfg) ((cfg)->p2p && (cfg)->p2p->on)
  132. /* dword align allocation */
  133. #define WLC_IOCTL_MAXLEN 8192
  134. #ifdef CUSTOMER_HW4
  135. #define CFGP2P_ERROR_TEXT "CFGP2P-INFO2) "
  136. #else
  137. #define CFGP2P_ERROR_TEXT "CFGP2P-ERROR) "
  138. #endif
  139. #define CFGP2P_ERR(args) \
  140. do { \
  141. if (wl_dbg_level & WL_DBG_ERR) { \
  142. printk(KERN_INFO CFGP2P_ERROR_TEXT "%s : ", __func__); \
  143. printk args; \
  144. } \
  145. } while (0)
  146. #define CFGP2P_INFO(args) \
  147. do { \
  148. if (wl_dbg_level & WL_DBG_INFO) { \
  149. printk(KERN_INFO "CFGP2P-INFO) %s : ", __func__); \
  150. printk args; \
  151. } \
  152. } while (0)
  153. #define CFGP2P_DBG(args) \
  154. do { \
  155. if (wl_dbg_level & WL_DBG_DBG) { \
  156. printk(KERN_DEBUG "CFGP2P-DEBUG) %s :", __func__); \
  157. printk args; \
  158. } \
  159. } while (0)
  160. #define CFGP2P_ACTION(args) \
  161. do { \
  162. if (wl_dbg_level & WL_DBG_P2P_ACTION) { \
  163. printk(KERN_DEBUG "CFGP2P-ACTION) %s :", __func__); \
  164. printk args; \
  165. } \
  166. } while (0)
  167. #define INIT_TIMER(timer, func, duration, extra_delay) \
  168. do { \
  169. init_timer(timer); \
  170. timer->function = func; \
  171. timer->expires = jiffies + msecs_to_jiffies(duration + extra_delay); \
  172. timer->data = (unsigned long) cfg; \
  173. add_timer(timer); \
  174. } while (0);
  175. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) && !defined(WL_CFG80211_P2P_DEV_IF)
  176. #define WL_CFG80211_P2P_DEV_IF
  177. #ifdef WL_ENABLE_P2P_IF
  178. #undef WL_ENABLE_P2P_IF
  179. #endif
  180. #ifdef WL_SUPPORT_BACKPORTED_KPATCHES
  181. #undef WL_SUPPORT_BACKPORTED_KPATCHES
  182. #endif
  183. #else
  184. #ifdef WLP2P
  185. #ifndef WL_ENABLE_P2P_IF
  186. /* Enable P2P network Interface if P2P support is enabled */
  187. #define WL_ENABLE_P2P_IF
  188. #endif /* WL_ENABLE_P2P_IF */
  189. #endif /* WLP2P */
  190. #endif /* (LINUX_VERSION >= VERSION(3, 8, 0)) */
  191. #ifndef WL_CFG80211_P2P_DEV_IF
  192. #ifdef WL_NEWCFG_PRIVCMD_SUPPORT
  193. #undef WL_NEWCFG_PRIVCMD_SUPPORT
  194. #endif
  195. #endif /* WL_CFG80211_P2P_DEV_IF */
  196. #if defined(WL_ENABLE_P2P_IF) && (defined(WL_CFG80211_P2P_DEV_IF) || \
  197. (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)))
  198. #error Disable 'WL_ENABLE_P2P_IF', if 'WL_CFG80211_P2P_DEV_IF' is enabled \
  199. or kernel version is 3.8.0 or above
  200. #endif /* WL_ENABLE_P2P_IF && (WL_CFG80211_P2P_DEV_IF || (LINUX_VERSION >= VERSION(3, 8, 0))) */
  201. #if !defined(WLP2P) && (defined(WL_ENABLE_P2P_IF) || defined(WL_CFG80211_P2P_DEV_IF))
  202. #error WLP2P not defined
  203. #endif /* !WLP2P && (WL_ENABLE_P2P_IF || WL_CFG80211_P2P_DEV_IF) */
  204. #if defined(WL_CFG80211_P2P_DEV_IF)
  205. #define bcm_struct_cfgdev struct wireless_dev
  206. #else
  207. #define bcm_struct_cfgdev struct net_device
  208. #endif /* WL_CFG80211_P2P_DEV_IF */
  209. extern void
  210. wl_cfgp2p_listen_expired(unsigned long data);
  211. extern bool
  212. wl_cfgp2p_is_pub_action(void *frame, u32 frame_len);
  213. extern bool
  214. wl_cfgp2p_is_p2p_action(void *frame, u32 frame_len);
  215. extern bool
  216. wl_cfgp2p_is_gas_action(void *frame, u32 frame_len);
  217. extern bool
  218. wl_cfgp2p_find_gas_subtype(u8 subtype, u8* data, u32 len);
  219. extern bool
  220. wl_cfgp2p_is_p2p_gas_action(void *frame, u32 frame_len);
  221. extern void
  222. wl_cfgp2p_print_actframe(bool tx, void *frame, u32 frame_len, u32 channel);
  223. extern s32
  224. wl_cfgp2p_init_priv(struct bcm_cfg80211 *cfg);
  225. extern void
  226. wl_cfgp2p_deinit_priv(struct bcm_cfg80211 *cfg);
  227. extern s32
  228. wl_cfgp2p_set_firm_p2p(struct bcm_cfg80211 *cfg);
  229. extern s32
  230. wl_cfgp2p_set_p2p_mode(struct bcm_cfg80211 *cfg, u8 mode,
  231. u32 channel, u16 listen_ms, int bssidx);
  232. extern s32
  233. wl_cfgp2p_ifadd(struct bcm_cfg80211 *cfg, struct ether_addr *mac, u8 if_type,
  234. chanspec_t chspec);
  235. extern s32
  236. wl_cfgp2p_ifdisable(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
  237. extern s32
  238. wl_cfgp2p_ifdel(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
  239. extern s32
  240. wl_cfgp2p_ifchange(struct bcm_cfg80211 *cfg, struct ether_addr *mac, u8 if_type, chanspec_t chspec);
  241. extern s32
  242. wl_cfgp2p_ifidx(struct bcm_cfg80211 *cfg, struct ether_addr *mac, s32 *index);
  243. extern s32
  244. wl_cfgp2p_init_discovery(struct bcm_cfg80211 *cfg);
  245. extern s32
  246. wl_cfgp2p_enable_discovery(struct bcm_cfg80211 *cfg, struct net_device *dev, const u8 *ie,
  247. u32 ie_len);
  248. extern s32
  249. wl_cfgp2p_disable_discovery(struct bcm_cfg80211 *cfg);
  250. extern s32
  251. wl_cfgp2p_escan(struct bcm_cfg80211 *cfg, struct net_device *dev, u16 active, u32 num_chans,
  252. u16 *channels,
  253. s32 search_state, u16 action, u32 bssidx, struct ether_addr *tx_dst_addr,
  254. p2p_scan_purpose_t p2p_scan_purpose);
  255. extern s32
  256. wl_cfgp2p_act_frm_search(struct bcm_cfg80211 *cfg, struct net_device *ndev,
  257. s32 bssidx, s32 channel, struct ether_addr *tx_dst_addr);
  258. extern wpa_ie_fixed_t *
  259. wl_cfgp2p_find_wpaie(u8 *parse, u32 len);
  260. extern wpa_ie_fixed_t *
  261. wl_cfgp2p_find_wpsie(u8 *parse, u32 len);
  262. extern wifi_p2p_ie_t *
  263. wl_cfgp2p_find_p2pie(u8 *parse, u32 len);
  264. extern wifi_wfd_ie_t *
  265. wl_cfgp2p_find_wfdie(u8 *parse, u32 len);
  266. extern s32
  267. wl_cfgp2p_set_management_ie(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 bssidx,
  268. s32 pktflag, const u8 *vndr_ie, u32 vndr_ie_len);
  269. extern s32
  270. wl_cfgp2p_clear_management_ie(struct bcm_cfg80211 *cfg, s32 bssidx);
  271. extern s32
  272. wl_cfgp2p_find_idx(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 *index);
  273. extern struct net_device *
  274. wl_cfgp2p_find_ndev(struct bcm_cfg80211 *cfg, s32 bssidx);
  275. extern s32
  276. wl_cfgp2p_find_type(struct bcm_cfg80211 *cfg, s32 bssidx, s32 *type);
  277. extern s32
  278. wl_cfgp2p_listen_complete(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
  279. const wl_event_msg_t *e, void *data);
  280. extern s32
  281. wl_cfgp2p_discover_listen(struct bcm_cfg80211 *cfg, s32 channel, u32 duration_ms);
  282. extern s32
  283. wl_cfgp2p_discover_enable_search(struct bcm_cfg80211 *cfg, u8 enable);
  284. extern s32
  285. wl_cfgp2p_action_tx_complete(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
  286. const wl_event_msg_t *e, void *data);
  287. extern s32
  288. wl_cfgp2p_tx_action_frame(struct bcm_cfg80211 *cfg, struct net_device *dev,
  289. wl_af_params_t *af_params, s32 bssidx);
  290. extern void
  291. wl_cfgp2p_generate_bss_mac(struct ether_addr *primary_addr, struct ether_addr *out_dev_addr,
  292. struct ether_addr *out_int_addr);
  293. extern void
  294. wl_cfg80211_change_ifaddr(u8* buf, struct ether_addr *p2p_int_addr, u8 element_id);
  295. extern bool
  296. wl_cfgp2p_bss_isup(struct net_device *ndev, int bsscfg_idx);
  297. extern s32
  298. wl_cfgp2p_bss(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 bsscfg_idx, s32 up);
  299. extern s32
  300. wl_cfgp2p_supported(struct bcm_cfg80211 *cfg, struct net_device *ndev);
  301. extern s32
  302. wl_cfgp2p_down(struct bcm_cfg80211 *cfg);
  303. extern s32
  304. wl_cfgp2p_set_p2p_noa(struct bcm_cfg80211 *cfg, struct net_device *ndev, char* buf, int len);
  305. extern s32
  306. wl_cfgp2p_get_p2p_noa(struct bcm_cfg80211 *cfg, struct net_device *ndev, char* buf, int len);
  307. extern s32
  308. wl_cfgp2p_set_p2p_ps(struct bcm_cfg80211 *cfg, struct net_device *ndev, char* buf, int len);
  309. extern u8 *
  310. wl_cfgp2p_retreive_p2pattrib(void *buf, u8 element_id);
  311. extern u8*
  312. wl_cfgp2p_find_attrib_in_all_p2p_Ies(u8 *parse, u32 len, u32 attrib);
  313. extern u8 *
  314. wl_cfgp2p_retreive_p2p_dev_addr(wl_bss_info_t *bi, u32 bi_length);
  315. extern s32
  316. wl_cfgp2p_register_ndev(struct bcm_cfg80211 *cfg);
  317. extern s32
  318. wl_cfgp2p_unregister_ndev(struct bcm_cfg80211 *cfg);
  319. extern bool
  320. wl_cfgp2p_is_ifops(const struct net_device_ops *if_ops);
  321. #if defined(WL_CFG80211_P2P_DEV_IF)
  322. extern struct wireless_dev *
  323. wl_cfgp2p_add_p2p_disc_if(struct bcm_cfg80211 *cfg);
  324. extern int
  325. wl_cfgp2p_start_p2p_device(struct wiphy *wiphy, struct wireless_dev *wdev);
  326. extern void
  327. wl_cfgp2p_stop_p2p_device(struct wiphy *wiphy, struct wireless_dev *wdev);
  328. extern int
  329. wl_cfgp2p_del_p2p_disc_if(struct wireless_dev *wdev, struct bcm_cfg80211 *cfg);
  330. #endif /* WL_CFG80211_P2P_DEV_IF */
  331. extern void
  332. wl_cfgp2p_need_wait_actfrmae(struct bcm_cfg80211 *cfg, void *frame, u32 frame_len, bool tx);
  333. extern int
  334. wl_cfgp2p_is_p2p_specific_scan(struct cfg80211_scan_request *request);
  335. /* WiFi Direct */
  336. #define SOCIAL_CHAN_1 1
  337. #define SOCIAL_CHAN_2 6
  338. #define SOCIAL_CHAN_3 11
  339. #define IS_P2P_SOCIAL_CHANNEL(channel) ((channel == SOCIAL_CHAN_1) || \
  340. (channel == SOCIAL_CHAN_2) || \
  341. (channel == SOCIAL_CHAN_3))
  342. #define SOCIAL_CHAN_CNT 3
  343. #define AF_PEER_SEARCH_CNT 2
  344. #define WL_P2P_WILDCARD_SSID "DIRECT-"
  345. #define WL_P2P_WILDCARD_SSID_LEN 7
  346. #define WL_P2P_INTERFACE_PREFIX "p2p"
  347. #define WL_P2P_TEMP_CHAN 11
  348. #define WL_P2P_AF_STATUS_OFFSET 9
  349. /* If the provision discovery is for JOIN operations,
  350. * or the device discoverablity frame is destined to GO
  351. * then we need not do an internal scan to find GO.
  352. */
  353. #define IS_ACTPUB_WITHOUT_GROUP_ID(p2p_ie, len) \
  354. (wl_cfgp2p_retreive_p2pattrib(p2p_ie, P2P_SEID_GROUP_ID) == NULL)
  355. #define IS_GAS_REQ(frame, len) (wl_cfgp2p_is_gas_action(frame, len) && \
  356. ((frame->action == P2PSD_ACTION_ID_GAS_IREQ) || \
  357. (frame->action == P2PSD_ACTION_ID_GAS_CREQ)))
  358. #define IS_P2P_PUB_ACT_RSP_SUBTYPE(subtype) ((subtype == P2P_PAF_GON_RSP) || \
  359. ((subtype == P2P_PAF_GON_CONF) || \
  360. (subtype == P2P_PAF_INVITE_RSP) || \
  361. (subtype == P2P_PAF_PROVDIS_RSP)))
  362. #define IS_P2P_SOCIAL(ch) ((ch == SOCIAL_CHAN_1) || (ch == SOCIAL_CHAN_2) || (ch == SOCIAL_CHAN_3))
  363. #define IS_P2P_SSID(ssid, len) (!memcmp(ssid, WL_P2P_WILDCARD_SSID, WL_P2P_WILDCARD_SSID_LEN) && \
  364. (len == WL_P2P_WILDCARD_SSID_LEN))
  365. #endif /* _wl_cfgp2p_h_ */