scan.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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_PRIORITY_HIGH 4
  46. #define WL1271_SCAN_BAND_2_4_GHZ 0
  47. #define WL1271_SCAN_BAND_5_GHZ 1
  48. #define WL1271_SCAN_TIMEOUT 10000 /* msec */
  49. enum {
  50. WL1271_SCAN_STATE_IDLE,
  51. WL1271_SCAN_STATE_2GHZ_ACTIVE,
  52. WL1271_SCAN_STATE_2GHZ_PASSIVE,
  53. WL1271_SCAN_STATE_5GHZ_ACTIVE,
  54. WL1271_SCAN_STATE_5GHZ_PASSIVE,
  55. WL1271_SCAN_STATE_DONE
  56. };
  57. struct basic_scan_params {
  58. __le32 rx_config_options;
  59. __le32 rx_filter_options;
  60. /* Scan option flags (WL1271_SCAN_OPT_*) */
  61. __le16 scan_options;
  62. /* Number of scan channels in the list (maximum 30) */
  63. u8 n_ch;
  64. /* This field indicates the number of probe requests to send
  65. per channel for an active scan */
  66. u8 n_probe_reqs;
  67. /* Rate bit field for sending the probes */
  68. __le32 tx_rate;
  69. u8 tid_trigger;
  70. u8 ssid_len;
  71. /* in order to align */
  72. u8 padding1[2];
  73. u8 ssid[IW_ESSID_MAX_SIZE];
  74. /* Band to scan */
  75. u8 band;
  76. u8 use_ssid_list;
  77. u8 scan_tag;
  78. u8 padding2;
  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. } __packed;
  99. struct wl1271_cmd_trigger_scan_to {
  100. struct wl1271_cmd_header header;
  101. __le32 timeout;
  102. } __packed;
  103. #define MAX_CHANNELS_2GHZ 14
  104. #define MAX_CHANNELS_5GHZ 23
  105. #define MAX_CHANNELS_4GHZ 4
  106. #define SCAN_MAX_CYCLE_INTERVALS 16
  107. #define SCAN_MAX_BANDS 3
  108. enum {
  109. SCAN_SSID_FILTER_ANY = 0,
  110. SCAN_SSID_FILTER_SPECIFIC = 1,
  111. SCAN_SSID_FILTER_LIST = 2,
  112. SCAN_SSID_FILTER_DISABLED = 3
  113. };
  114. enum {
  115. SCAN_BSS_TYPE_INDEPENDENT,
  116. SCAN_BSS_TYPE_INFRASTRUCTURE,
  117. SCAN_BSS_TYPE_ANY,
  118. };
  119. #define SCAN_CHANNEL_FLAGS_DFS BIT(0)
  120. #define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1)
  121. struct conn_scan_ch_params {
  122. __le16 min_duration;
  123. __le16 max_duration;
  124. __le16 passive_duration;
  125. u8 channel;
  126. u8 tx_power_att;
  127. /* bit 0: DFS channel; bit 1: DFS enabled */
  128. u8 flags;
  129. u8 padding[3];
  130. } __packed;
  131. struct wl1271_cmd_sched_scan_config {
  132. struct wl1271_cmd_header header;
  133. __le32 intervals[SCAN_MAX_CYCLE_INTERVALS];
  134. s8 rssi_threshold; /* for filtering (in dBm) */
  135. s8 snr_threshold; /* for filtering (in dB) */
  136. u8 cycles; /* maximum number of scan cycles */
  137. u8 report_after; /* report when this number of results are received */
  138. u8 terminate; /* stop scanning after reporting */
  139. u8 tag;
  140. u8 bss_type; /* for filtering */
  141. u8 filter_type;
  142. u8 ssid_len; /* For SCAN_SSID_FILTER_SPECIFIC */
  143. u8 ssid[IW_ESSID_MAX_SIZE];
  144. u8 n_probe_reqs; /* Number of probes requests per channel */
  145. u8 passive[SCAN_MAX_BANDS];
  146. u8 active[SCAN_MAX_BANDS];
  147. u8 dfs;
  148. u8 padding[3];
  149. struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
  150. struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ];
  151. struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
  152. } __packed;
  153. #define SCHED_SCAN_MAX_SSIDS 8
  154. enum {
  155. SCAN_SSID_TYPE_PUBLIC = 0,
  156. SCAN_SSID_TYPE_HIDDEN = 1,
  157. };
  158. struct wl1271_ssid {
  159. u8 type;
  160. u8 len;
  161. u8 ssid[IW_ESSID_MAX_SIZE];
  162. /* u8 padding[2]; */
  163. } __packed;
  164. struct wl1271_cmd_sched_scan_ssid_list {
  165. struct wl1271_cmd_header header;
  166. u8 n_ssids;
  167. struct wl1271_ssid ssids[SCHED_SCAN_MAX_SSIDS];
  168. u8 padding[3];
  169. } __packed;
  170. struct wl1271_cmd_sched_scan_start {
  171. struct wl1271_cmd_header header;
  172. u8 tag;
  173. u8 padding[3];
  174. } __packed;
  175. struct wl1271_cmd_sched_scan_stop {
  176. struct wl1271_cmd_header header;
  177. u8 tag;
  178. u8 padding[3];
  179. } __packed;
  180. #endif /* __WL1271_SCAN_H__ */