scan.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 2009-2010 Nokia Corporation
  5. *
  6. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #ifndef __SCAN_H__
  24. #define __SCAN_H__
  25. #include "wl12xx.h"
  26. int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
  27. struct cfg80211_scan_request *req);
  28. int wl1271_scan_stop(struct wl1271 *wl);
  29. int wl1271_scan_build_probe_req(struct wl1271 *wl,
  30. const u8 *ssid, size_t ssid_len,
  31. const u8 *ie, size_t ie_len, u8 band);
  32. void wl1271_scan_stm(struct wl1271 *wl);
  33. void wl1271_scan_complete_work(struct work_struct *work);
  34. int wl1271_scan_sched_scan_config(struct wl1271 *wl,
  35. struct cfg80211_sched_scan_request *req,
  36. struct ieee80211_sched_scan_ies *ies);
  37. int wl1271_scan_sched_scan_start(struct wl1271 *wl);
  38. void wl1271_scan_sched_scan_stop(struct wl1271 *wl);
  39. void wl1271_scan_sched_scan_results(struct wl1271 *wl);
  40. #define WL1271_SCAN_MAX_CHANNELS 24
  41. #define WL1271_SCAN_DEFAULT_TAG 1
  42. #define WL1271_SCAN_CURRENT_TX_PWR 0
  43. #define WL1271_SCAN_OPT_ACTIVE 0
  44. #define WL1271_SCAN_OPT_PASSIVE 1
  45. #define WL1271_SCAN_OPT_TRIGGERED_SCAN 2
  46. #define WL1271_SCAN_OPT_PRIORITY_HIGH 4
  47. /* scan even if we fail to enter psm */
  48. #define WL1271_SCAN_OPT_FORCE 8
  49. #define WL1271_SCAN_BAND_2_4_GHZ 0
  50. #define WL1271_SCAN_BAND_5_GHZ 1
  51. #define WL1271_SCAN_TIMEOUT 10000 /* msec */
  52. enum {
  53. WL1271_SCAN_STATE_IDLE,
  54. WL1271_SCAN_STATE_2GHZ_ACTIVE,
  55. WL1271_SCAN_STATE_2GHZ_PASSIVE,
  56. WL1271_SCAN_STATE_5GHZ_ACTIVE,
  57. WL1271_SCAN_STATE_5GHZ_PASSIVE,
  58. WL1271_SCAN_STATE_DONE
  59. };
  60. struct basic_scan_params {
  61. /* Scan option flags (WL1271_SCAN_OPT_*) */
  62. __le16 scan_options;
  63. u8 role_id;
  64. /* Number of scan channels in the list (maximum 30) */
  65. u8 n_ch;
  66. /* This field indicates the number of probe requests to send
  67. per channel for an active scan */
  68. u8 n_probe_reqs;
  69. u8 tid_trigger;
  70. u8 ssid_len;
  71. u8 use_ssid_list;
  72. /* Rate bit field for sending the probes */
  73. __le32 tx_rate;
  74. u8 ssid[IEEE80211_MAX_SSID_LEN];
  75. /* Band to scan */
  76. u8 band;
  77. u8 scan_tag;
  78. u8 padding2[2];
  79. } __packed;
  80. struct basic_scan_channel_params {
  81. /* Duration in TU to wait for frames on a channel for active scan */
  82. __le32 min_duration;
  83. __le32 max_duration;
  84. __le32 bssid_lsb;
  85. __le16 bssid_msb;
  86. u8 early_termination;
  87. u8 tx_power_att;
  88. u8 channel;
  89. /* FW internal use only! */
  90. u8 dfs_candidate;
  91. u8 activity_detected;
  92. u8 pad;
  93. } __packed;
  94. struct wl1271_cmd_scan {
  95. struct wl1271_cmd_header header;
  96. struct basic_scan_params params;
  97. struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];
  98. /* src mac address */
  99. u8 addr[ETH_ALEN];
  100. u8 padding[2];
  101. } __packed;
  102. struct wl1271_cmd_trigger_scan_to {
  103. struct wl1271_cmd_header header;
  104. __le32 timeout;
  105. } __packed;
  106. #define MAX_CHANNELS_2GHZ 14
  107. #define MAX_CHANNELS_5GHZ 23
  108. #define MAX_CHANNELS_4GHZ 4
  109. #define SCAN_MAX_CYCLE_INTERVALS 16
  110. #define SCAN_MAX_BANDS 3
  111. enum {
  112. SCAN_SSID_FILTER_ANY = 0,
  113. SCAN_SSID_FILTER_SPECIFIC = 1,
  114. SCAN_SSID_FILTER_LIST = 2,
  115. SCAN_SSID_FILTER_DISABLED = 3
  116. };
  117. enum {
  118. SCAN_BSS_TYPE_INDEPENDENT,
  119. SCAN_BSS_TYPE_INFRASTRUCTURE,
  120. SCAN_BSS_TYPE_ANY,
  121. };
  122. #define SCAN_CHANNEL_FLAGS_DFS BIT(0)
  123. #define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1)
  124. struct conn_scan_ch_params {
  125. __le16 min_duration;
  126. __le16 max_duration;
  127. __le16 passive_duration;
  128. u8 channel;
  129. u8 tx_power_att;
  130. /* bit 0: DFS channel; bit 1: DFS enabled */
  131. u8 flags;
  132. u8 padding[3];
  133. } __packed;
  134. struct wl1271_cmd_sched_scan_config {
  135. struct wl1271_cmd_header header;
  136. __le32 intervals[SCAN_MAX_CYCLE_INTERVALS];
  137. s8 rssi_threshold; /* for filtering (in dBm) */
  138. s8 snr_threshold; /* for filtering (in dB) */
  139. u8 cycles; /* maximum number of scan cycles */
  140. u8 report_after; /* report when this number of results are received */
  141. u8 terminate; /* stop scanning after reporting */
  142. u8 tag;
  143. u8 bss_type; /* for filtering */
  144. u8 filter_type;
  145. u8 ssid_len; /* For SCAN_SSID_FILTER_SPECIFIC */
  146. u8 ssid[IEEE80211_MAX_SSID_LEN];
  147. u8 n_probe_reqs; /* Number of probes requests per channel */
  148. u8 passive[SCAN_MAX_BANDS];
  149. u8 active[SCAN_MAX_BANDS];
  150. u8 dfs;
  151. u8 padding[3];
  152. struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
  153. struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ];
  154. struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
  155. } __packed;
  156. #define SCHED_SCAN_MAX_SSIDS 16
  157. enum {
  158. SCAN_SSID_TYPE_PUBLIC = 0,
  159. SCAN_SSID_TYPE_HIDDEN = 1,
  160. };
  161. struct wl1271_ssid {
  162. u8 type;
  163. u8 len;
  164. u8 ssid[IEEE80211_MAX_SSID_LEN];
  165. /* u8 padding[2]; */
  166. } __packed;
  167. struct wl1271_cmd_sched_scan_ssid_list {
  168. struct wl1271_cmd_header header;
  169. u8 n_ssids;
  170. struct wl1271_ssid ssids[SCHED_SCAN_MAX_SSIDS];
  171. u8 padding[3];
  172. } __packed;
  173. struct wl1271_cmd_sched_scan_start {
  174. struct wl1271_cmd_header header;
  175. u8 tag;
  176. u8 padding[3];
  177. } __packed;
  178. struct wl1271_cmd_sched_scan_stop {
  179. struct wl1271_cmd_header header;
  180. u8 tag;
  181. u8 padding[3];
  182. } __packed;
  183. #endif /* __WL1271_SCAN_H__ */