scan.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 "wlcore.h"
  26. int wlcore_scan(struct wl1271 *wl, struct ieee80211_vif *vif,
  27. const u8 *ssid, size_t ssid_len,
  28. struct cfg80211_scan_request *req);
  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, struct wl12xx_vif *wlvif);
  33. void wl1271_scan_complete_work(struct work_struct *work);
  34. int wl1271_scan_sched_scan_config(struct wl1271 *wl,
  35. struct wl12xx_vif *wlvif,
  36. struct cfg80211_sched_scan_request *req,
  37. struct ieee80211_scan_ies *ies);
  38. int wl1271_scan_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif);
  39. void wlcore_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_SPLIT_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 30000 /* 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 wl1271_cmd_trigger_scan_to {
  61. struct wl1271_cmd_header header;
  62. __le32 timeout;
  63. } __packed;
  64. #define MAX_CHANNELS_2GHZ 14
  65. #define MAX_CHANNELS_4GHZ 4
  66. /*
  67. * This max value here is used only for the struct definition of
  68. * wlcore_scan_channels. This struct is used by both 12xx
  69. * and 18xx (which have different max 5ghz channels value).
  70. * In order to make sure this is large enough, just use the
  71. * max possible 5ghz channels.
  72. */
  73. #define MAX_CHANNELS_5GHZ 42
  74. #define SCAN_MAX_CYCLE_INTERVALS 16
  75. /* The FW intervals can take up to 16 entries.
  76. * The 1st entry isn't used (scan is immediate). The last
  77. * entry should be used for the long_interval
  78. */
  79. #define SCAN_MAX_SHORT_INTERVALS (SCAN_MAX_CYCLE_INTERVALS - 2)
  80. #define SCAN_MAX_BANDS 3
  81. enum {
  82. SCAN_SSID_FILTER_ANY = 0,
  83. SCAN_SSID_FILTER_SPECIFIC = 1,
  84. SCAN_SSID_FILTER_LIST = 2,
  85. SCAN_SSID_FILTER_DISABLED = 3
  86. };
  87. enum {
  88. SCAN_BSS_TYPE_INDEPENDENT,
  89. SCAN_BSS_TYPE_INFRASTRUCTURE,
  90. SCAN_BSS_TYPE_ANY,
  91. };
  92. #define SCAN_CHANNEL_FLAGS_DFS BIT(0) /* channel is passive until an
  93. activity is detected on it */
  94. #define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1)
  95. struct conn_scan_ch_params {
  96. __le16 min_duration;
  97. __le16 max_duration;
  98. __le16 passive_duration;
  99. u8 channel;
  100. u8 tx_power_att;
  101. /* bit 0: DFS channel; bit 1: DFS enabled */
  102. u8 flags;
  103. u8 padding[3];
  104. } __packed;
  105. #define SCHED_SCAN_MAX_SSIDS 16
  106. enum {
  107. SCAN_SSID_TYPE_PUBLIC = 0,
  108. SCAN_SSID_TYPE_HIDDEN = 1,
  109. };
  110. struct wl1271_ssid {
  111. u8 type;
  112. u8 len;
  113. u8 ssid[IEEE80211_MAX_SSID_LEN];
  114. /* u8 padding[2]; */
  115. } __packed;
  116. struct wl1271_cmd_sched_scan_ssid_list {
  117. struct wl1271_cmd_header header;
  118. u8 n_ssids;
  119. struct wl1271_ssid ssids[SCHED_SCAN_MAX_SSIDS];
  120. u8 role_id;
  121. u8 padding[2];
  122. } __packed;
  123. struct wlcore_scan_channels {
  124. u8 passive[SCAN_MAX_BANDS]; /* number of passive scan channels */
  125. u8 active[SCAN_MAX_BANDS]; /* number of active scan channels */
  126. u8 dfs; /* number of dfs channels in 5ghz */
  127. u8 passive_active; /* number of passive before active channels 2.4ghz */
  128. struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
  129. struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ];
  130. struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
  131. };
  132. enum {
  133. SCAN_TYPE_SEARCH = 0,
  134. SCAN_TYPE_PERIODIC = 1,
  135. SCAN_TYPE_TRACKING = 2,
  136. };
  137. bool
  138. wlcore_set_scan_chan_params(struct wl1271 *wl,
  139. struct wlcore_scan_channels *cfg,
  140. struct ieee80211_channel *channels[],
  141. u32 n_channels,
  142. u32 n_ssids,
  143. int scan_type);
  144. int
  145. wlcore_scan_sched_scan_ssid_list(struct wl1271 *wl,
  146. struct wl12xx_vif *wlvif,
  147. struct cfg80211_sched_scan_request *req);
  148. #endif /* __WL1271_SCAN_H__ */