PageRenderTime 28ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/bcmdhd/src/wl/sys/wl_cfgp2p.h

https://github.com/CyanogenMod/lge-kernel-omap4
C Header | 291 lines | 213 code | 40 blank | 38 comment | 23 complexity | 8a75f988af709240fe1f0687b92470f9 MD5 | raw file
  1. /*
  2. * Linux cfgp2p driver
  3. *
  4. * Copyright (C) 1999-2012, 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 316197 2012-02-21 13:16:39Z $
  25. */
  26. #ifndef _wl_cfgp2p_h_
  27. #define _wl_cfgp2p_h_
  28. #include <proto/802.11.h>
  29. #include <proto/p2p.h>
  30. struct wl_priv;
  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. #define IE_MAX_LEN 300
  44. //LGE_UPDATE_S, moon-wifi@lge.com by wo0ngs 2012-06-15, yangseon.so, set p2p_res_max_len to 1400
  45. #define P2P_RES_MAX_LEN 1400
  46. //LGE_UPDATE_E, moon-wifi@lge.com by wo0ngs 2012-06-15, yangseon.so, set p2p_res_max_len to 1400
  47. /* Structure to hold all saved P2P and WPS IEs for a BSSCFG */
  48. struct p2p_saved_ie {
  49. u8 p2p_probe_req_ie[IE_MAX_LEN];
  50. //LGE_UPDATE_S, moon-wifi@lge.com by wo0ngs 2012-06-15, yangseon.so, set p2p_res_max_len to 1400
  51. // u8 p2p_probe_res_ie[IE_MAX_LEN]; //ori.
  52. u8 p2p_probe_res_ie[P2P_RES_MAX_LEN];
  53. //LGE_UPDATE_E, moon-wifi@lge.com by wo0ngs 2012-06-15, yangseon.so, set p2p_res_max_len to 1400
  54. u8 p2p_assoc_req_ie[IE_MAX_LEN];
  55. u8 p2p_assoc_res_ie[IE_MAX_LEN];
  56. u8 p2p_beacon_ie[IE_MAX_LEN];
  57. u32 p2p_probe_req_ie_len;
  58. u32 p2p_probe_res_ie_len;
  59. u32 p2p_assoc_req_ie_len;
  60. u32 p2p_assoc_res_ie_len;
  61. u32 p2p_beacon_ie_len;
  62. };
  63. struct p2p_bss {
  64. u32 bssidx;
  65. struct net_device *dev;
  66. struct p2p_saved_ie saved_ie;
  67. void *private_data;
  68. };
  69. struct p2p_info {
  70. bool on; /* p2p on/off switch */
  71. bool scan;
  72. bool vif_created;
  73. s8 vir_ifname[IFNAMSIZ];
  74. unsigned long status;
  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;
  79. wl_p2p_sched_t noa;
  80. wl_p2p_ops_t ops;
  81. wlc_ssid_t ssid;
  82. spinlock_t timer_lock;
  83. };
  84. /* dongle status */
  85. enum wl_cfgp2p_status {
  86. WLP2P_STATUS_DISCOVERY_ON = 0,
  87. WLP2P_STATUS_SEARCH_ENABLED,
  88. WLP2P_STATUS_IF_ADD,
  89. WLP2P_STATUS_IF_DEL,
  90. WLP2P_STATUS_IF_DELETING,
  91. WLP2P_STATUS_IF_CHANGING,
  92. WLP2P_STATUS_IF_CHANGED,
  93. WLP2P_STATUS_LISTEN_EXPIRED,
  94. WLP2P_STATUS_ACTION_TX_COMPLETED,
  95. WLP2P_STATUS_ACTION_TX_NOACK,
  96. WLP2P_STATUS_SCANNING
  97. };
  98. #define wl_to_p2p_bss_ndev(w, type) ((wl)->p2p->bss_idx[type].dev)
  99. #define wl_to_p2p_bss_bssidx(w, type) ((wl)->p2p->bss_idx[type].bssidx)
  100. #define wl_to_p2p_bss_saved_ie(w, type) ((wl)->p2p->bss_idx[type].saved_ie)
  101. #define wl_to_p2p_bss_private(w, type) ((wl)->p2p->bss_idx[type].private_data)
  102. #define wl_to_p2p_bss(wl, type) ((wl)->p2p->bss_idx[type])
  103. #define wl_get_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : test_bit(WLP2P_STATUS_ ## stat, \
  104. &(wl)->p2p->status))
  105. #define wl_set_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : set_bit(WLP2P_STATUS_ ## stat, \
  106. &(wl)->p2p->status))
  107. #define wl_clr_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0 : clear_bit(WLP2P_STATUS_ ## stat, \
  108. &(wl)->p2p->status))
  109. #define wl_chg_p2p_status(wl, stat) ((!(wl)->p2p_supported) ? 0:change_bit(WLP2P_STATUS_ ## stat, \
  110. &(wl)->p2p->status))
  111. #define p2p_on(wl) ((wl)->p2p->on)
  112. #define p2p_scan(wl) ((wl)->p2p->scan)
  113. #define p2p_is_on(wl) ((wl)->p2p && (wl)->p2p->on)
  114. /* dword align allocation */
  115. #define WLC_IOCTL_MAXLEN 8192
  116. #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  117. #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  118. #define CFGP2P_ERR(args) \
  119. do { \
  120. if (wl_dbg_level & WL_DBG_ERR) { \
  121. printk(KERN_ERR "CFGP2P-ERROR) %s : ", __func__); \
  122. printk args; \
  123. } \
  124. } while (0)
  125. #define CFGP2P_INFO(args) \
  126. do { \
  127. if (wl_dbg_level & WL_DBG_INFO) { \
  128. printk(KERN_ERR "CFGP2P-INFO) %s : ", __func__); \
  129. printk args; \
  130. } \
  131. } while (0)
  132. #define CFGP2P_DBG(args) \
  133. do { \
  134. if (wl_dbg_level & WL_DBG_DBG) { \
  135. printk(KERN_ERR "CFGP2P-DEBUG) %s :", __func__); \
  136. printk args; \
  137. } \
  138. } while (0)
  139. extern bool
  140. wl_cfgp2p_is_pub_action(void *frame, u32 frame_len);
  141. extern bool
  142. wl_cfgp2p_is_p2p_action(void *frame, u32 frame_len);
  143. extern bool
  144. wl_cfgp2p_is_gas_action(void *frame, u32 frame_len);
  145. extern void
  146. wl_cfgp2p_print_actframe(bool tx, void *frame, u32 frame_len);
  147. extern s32
  148. wl_cfgp2p_init_priv(struct wl_priv *wl);
  149. extern void
  150. wl_cfgp2p_deinit_priv(struct wl_priv *wl);
  151. extern s32
  152. wl_cfgp2p_set_firm_p2p(struct wl_priv *wl);
  153. extern s32
  154. wl_cfgp2p_set_p2p_mode(struct wl_priv *wl, u8 mode,
  155. u32 channel, u16 listen_ms, int bssidx);
  156. extern s32
  157. wl_cfgp2p_ifadd(struct wl_priv *wl, struct ether_addr *mac, u8 if_type,
  158. chanspec_t chspec);
  159. extern s32
  160. wl_cfgp2p_ifdel(struct wl_priv *wl, struct ether_addr *mac);
  161. extern s32
  162. wl_cfgp2p_ifchange(struct wl_priv *wl, struct ether_addr *mac, u8 if_type, chanspec_t chspec);
  163. extern s32
  164. wl_cfgp2p_ifidx(struct wl_priv *wl, struct ether_addr *mac, s32 *index);
  165. extern s32
  166. wl_cfgp2p_init_discovery(struct wl_priv *wl);
  167. extern s32
  168. wl_cfgp2p_enable_discovery(struct wl_priv *wl, struct net_device *dev, const u8 *ie, u32 ie_len);
  169. extern s32
  170. wl_cfgp2p_disable_discovery(struct wl_priv *wl);
  171. extern s32
  172. wl_cfgp2p_escan(struct wl_priv *wl, struct net_device *dev, u16 active, u32 num_chans,
  173. u16 *channels,
  174. s32 search_state, u16 action, u32 bssidx);
  175. extern s32
  176. wl_cfgp2p_act_frm_search(struct wl_priv *wl, struct net_device *ndev,
  177. s32 bssidx, s32 channel);
  178. extern wpa_ie_fixed_t *
  179. wl_cfgp2p_find_wpaie(u8 *parse, u32 len);
  180. extern wpa_ie_fixed_t *
  181. wl_cfgp2p_find_wpsie(u8 *parse, u32 len);
  182. extern wifi_p2p_ie_t *
  183. wl_cfgp2p_find_p2pie(u8 *parse, u32 len);
  184. extern wifi_wfd_ie_t *
  185. wl_cfgp2p_find_wfdie(u8 *parse, u32 len);
  186. extern s32
  187. wl_cfgp2p_set_management_ie(struct wl_priv *wl, struct net_device *ndev, s32 bssidx,
  188. s32 pktflag, const u8 *vndr_ie, u32 vndr_ie_len);
  189. extern s32
  190. wl_cfgp2p_clear_management_ie(struct wl_priv *wl, s32 bssidx);
  191. extern s32
  192. wl_cfgp2p_find_idx(struct wl_priv *wl, struct net_device *ndev);
  193. extern s32
  194. wl_cfgp2p_listen_complete(struct wl_priv *wl, struct net_device *ndev,
  195. const wl_event_msg_t *e, void *data);
  196. extern s32
  197. wl_cfgp2p_discover_listen(struct wl_priv *wl, s32 channel, u32 duration_ms);
  198. extern s32
  199. wl_cfgp2p_discover_enable_search(struct wl_priv *wl, u8 enable);
  200. extern s32
  201. wl_cfgp2p_action_tx_complete(struct wl_priv *wl, struct net_device *ndev,
  202. const wl_event_msg_t *e, void *data);
  203. extern s32
  204. wl_cfgp2p_tx_action_frame(struct wl_priv *wl, struct net_device *dev,
  205. wl_af_params_t *af_params, s32 bssidx);
  206. extern void
  207. wl_cfgp2p_generate_bss_mac(struct ether_addr *primary_addr, struct ether_addr *out_dev_addr,
  208. struct ether_addr *out_int_addr);
  209. extern void
  210. wl_cfg80211_change_ifaddr(u8* buf, struct ether_addr *p2p_int_addr, u8 element_id);
  211. extern bool
  212. wl_cfgp2p_bss_isup(struct net_device *ndev, int bsscfg_idx);
  213. extern s32
  214. wl_cfgp2p_bss(struct wl_priv *wl, struct net_device *ndev, s32 bsscfg_idx, s32 up);
  215. extern s32
  216. wl_cfgp2p_supported(struct wl_priv *wl, struct net_device *ndev);
  217. extern s32
  218. wl_cfgp2p_down(struct wl_priv *wl);
  219. extern s32
  220. wl_cfgp2p_set_p2p_noa(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
  221. extern s32
  222. wl_cfgp2p_get_p2p_noa(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
  223. extern s32
  224. wl_cfgp2p_set_p2p_ps(struct wl_priv *wl, struct net_device *ndev, char* buf, int len);
  225. extern u8 *
  226. wl_cfgp2p_retreive_p2pattrib(void *buf, u8 element_id);
  227. extern u8 *
  228. wl_cfgp2p_retreive_p2p_dev_addr(wl_bss_info_t *bi, u32 bi_length);
  229. extern s32
  230. wl_cfgp2p_register_ndev(struct wl_priv *wl);
  231. extern s32
  232. wl_cfgp2p_unregister_ndev(struct wl_priv *wl);
  233. /* WiFi Direct */
  234. #define SOCIAL_CHAN_1 1
  235. #define SOCIAL_CHAN_2 6
  236. #define SOCIAL_CHAN_3 11
  237. #define SOCIAL_CHAN_CNT 3
  238. #define WL_P2P_WILDCARD_SSID "DIRECT-"
  239. #define WL_P2P_WILDCARD_SSID_LEN 7
  240. #define WL_P2P_INTERFACE_PREFIX "p2p"
  241. #define WL_P2P_TEMP_CHAN 11
  242. #define IS_GAS_REQ(frame, len) (wl_cfgp2p_is_gas_action(frame, len) && \
  243. ((frame->action == P2PSD_ACTION_ID_GAS_IREQ) || \
  244. (frame->action == P2PSD_ACTION_ID_GAS_CREQ)))
  245. #define IS_P2P_PUB_ACT_REQ(frame, len) (wl_cfgp2p_is_pub_action(frame, len) && \
  246. ((frame->subtype == P2P_PAF_GON_REQ) || \
  247. (frame->subtype == P2P_PAF_INVITE_REQ) || \
  248. (frame->subtype == P2P_PAF_PROVDIS_REQ)))
  249. #define IS_P2P_SOCIAL(ch) ((ch == SOCIAL_CHAN_1) || (ch == SOCIAL_CHAN_2) || (ch == SOCIAL_CHAN_3))
  250. #define IS_P2P_SSID(ssid) (memcmp(ssid, WL_P2P_WILDCARD_SSID, WL_P2P_WILDCARD_SSID_LEN) == 0)
  251. #endif /* _wl_cfgp2p_h_ */