bcmwifi_channels.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. /*
  2. * Misc utility routines for WL and Apps
  3. * This header file housing the define and function prototype use by
  4. * both the wl driver, tools & Apps.
  5. *
  6. * Copyright (C) 1999-2015, Broadcom Corporation
  7. *
  8. * Unless you and Broadcom execute a separate written software license
  9. * agreement governing use of this software, this software is licensed to you
  10. * under the terms of the GNU General Public License version 2 (the "GPL"),
  11. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  12. * following added to such license:
  13. *
  14. * As a special exception, the copyright holders of this software give you
  15. * permission to link this software with independent modules, and to copy and
  16. * distribute the resulting executable under terms of your choice, provided that
  17. * you also meet, for each linked independent module, the terms and conditions of
  18. * the license of that module. An independent module is a module which is not
  19. * derived from this software. The special exception does not apply to any
  20. * modifications of the software.
  21. *
  22. * Notwithstanding the above, under no circumstances may you combine this
  23. * software in any way with any other Broadcom software provided under a license
  24. * other than the GPL, without Broadcom's express prior written consent.
  25. *
  26. * $Id: bcmwifi_channels.h 309193 2012-01-19 00:03:57Z $
  27. */
  28. #ifndef _bcmwifi_channels_h_
  29. #define _bcmwifi_channels_h_
  30. /* A chanspec holds the channel number, band, bandwidth and control sideband */
  31. typedef uint16 chanspec_t;
  32. /* channel defines */
  33. #define CH_UPPER_SB 0x01
  34. #define CH_LOWER_SB 0x02
  35. #define CH_EWA_VALID 0x04
  36. #define CH_80MHZ_APART 16
  37. #define CH_40MHZ_APART 8
  38. #define CH_20MHZ_APART 4
  39. #define CH_10MHZ_APART 2
  40. #define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */
  41. #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
  42. #define MAXCHANNEL 224 /* max # supported channels. The max channel no is 216,
  43. * this is that + 1 rounded up to a multiple of NBBY (8).
  44. * DO NOT MAKE it > 255: channels are uint8's all over
  45. */
  46. #define CHSPEC_CTLOVLP(sp1, sp2, sep) (ABS(wf_chspec_ctlchan(sp1) - wf_chspec_ctlchan(sp2)) < \
  47. (sep))
  48. /* All builds use the new 11ac ratespec/chanspec */
  49. #undef D11AC_IOTYPES
  50. #define D11AC_IOTYPES
  51. #define WL_CHANSPEC_CHAN_MASK 0x00ff
  52. #define WL_CHANSPEC_CHAN_SHIFT 0
  53. #define WL_CHANSPEC_CHAN1_MASK 0x000f
  54. #define WL_CHANSPEC_CHAN1_SHIFT 0
  55. #define WL_CHANSPEC_CHAN2_MASK 0x00f0
  56. #define WL_CHANSPEC_CHAN2_SHIFT 4
  57. #define WL_CHANSPEC_CTL_SB_MASK 0x0700
  58. #define WL_CHANSPEC_CTL_SB_SHIFT 8
  59. #define WL_CHANSPEC_CTL_SB_LLL 0x0000
  60. #define WL_CHANSPEC_CTL_SB_LLU 0x0100
  61. #define WL_CHANSPEC_CTL_SB_LUL 0x0200
  62. #define WL_CHANSPEC_CTL_SB_LUU 0x0300
  63. #define WL_CHANSPEC_CTL_SB_ULL 0x0400
  64. #define WL_CHANSPEC_CTL_SB_ULU 0x0500
  65. #define WL_CHANSPEC_CTL_SB_UUL 0x0600
  66. #define WL_CHANSPEC_CTL_SB_UUU 0x0700
  67. #define WL_CHANSPEC_CTL_SB_LL WL_CHANSPEC_CTL_SB_LLL
  68. #define WL_CHANSPEC_CTL_SB_LU WL_CHANSPEC_CTL_SB_LLU
  69. #define WL_CHANSPEC_CTL_SB_UL WL_CHANSPEC_CTL_SB_LUL
  70. #define WL_CHANSPEC_CTL_SB_UU WL_CHANSPEC_CTL_SB_LUU
  71. #define WL_CHANSPEC_CTL_SB_L WL_CHANSPEC_CTL_SB_LLL
  72. #define WL_CHANSPEC_CTL_SB_U WL_CHANSPEC_CTL_SB_LLU
  73. #define WL_CHANSPEC_CTL_SB_LOWER WL_CHANSPEC_CTL_SB_LLL
  74. #define WL_CHANSPEC_CTL_SB_UPPER WL_CHANSPEC_CTL_SB_LLU
  75. #define WL_CHANSPEC_CTL_SB_NONE WL_CHANSPEC_CTL_SB_LLL
  76. #define WL_CHANSPEC_BW_MASK 0x3800
  77. #define WL_CHANSPEC_BW_SHIFT 11
  78. #define WL_CHANSPEC_BW_5 0x0000
  79. #define WL_CHANSPEC_BW_10 0x0800
  80. #define WL_CHANSPEC_BW_20 0x1000
  81. #define WL_CHANSPEC_BW_40 0x1800
  82. #define WL_CHANSPEC_BW_80 0x2000
  83. #define WL_CHANSPEC_BW_160 0x2800
  84. #define WL_CHANSPEC_BW_8080 0x3000
  85. #define WL_CHANSPEC_BAND_MASK 0xc000
  86. #define WL_CHANSPEC_BAND_SHIFT 14
  87. #define WL_CHANSPEC_BAND_2G 0x0000
  88. #define WL_CHANSPEC_BAND_3G 0x4000
  89. #define WL_CHANSPEC_BAND_4G 0x8000
  90. #define WL_CHANSPEC_BAND_5G 0xc000
  91. #define INVCHANSPEC 255
  92. /* channel defines */
  93. #define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? \
  94. ((channel) - CH_10MHZ_APART) : 0)
  95. #define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
  96. ((channel) + CH_10MHZ_APART) : 0)
  97. #define LL_20_SB(channel) (((channel) > 3 * CH_10MHZ_APART) ? ((channel) - 3 * CH_10MHZ_APART) : 0)
  98. #define UU_20_SB(channel) (((channel) < (MAXCHANNEL - 3 * CH_10MHZ_APART)) ? \
  99. ((channel) + 3 * CH_10MHZ_APART) : 0)
  100. #define LU_20_SB(channel) LOWER_20_SB(channel)
  101. #define UL_20_SB(channel) UPPER_20_SB(channel)
  102. #define LOWER_40_SB(channel) ((channel) - CH_20MHZ_APART)
  103. #define UPPER_40_SB(channel) ((channel) + CH_20MHZ_APART)
  104. #define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
  105. #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
  106. (((channel) <= CH_MAX_2G_CHANNEL) ? \
  107. WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
  108. #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
  109. ((channel) + CH_20MHZ_APART) : 0)
  110. #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
  111. ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
  112. ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
  113. WL_CHANSPEC_BAND_5G))
  114. #define CH80MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
  115. ((channel) | (ctlsb) | \
  116. WL_CHANSPEC_BW_80 | WL_CHANSPEC_BAND_5G)
  117. #define CH160MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
  118. ((channel) | (ctlsb) | \
  119. WL_CHANSPEC_BW_160 | WL_CHANSPEC_BAND_5G)
  120. /* simple MACROs to get different fields of chanspec */
  121. #define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
  122. #define CHSPEC_CHAN1(chspec) ((chspec) & WL_CHANSPEC_CHAN1_MASK) >> WL_CHANSPEC_CHAN1_SHIFT
  123. #define CHSPEC_CHAN2(chspec) ((chspec) & WL_CHANSPEC_CHAN2_MASK) >> WL_CHANSPEC_CHAN2_SHIFT
  124. #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
  125. #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
  126. #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
  127. #ifdef WL11N_20MHZONLY
  128. #define CHSPEC_IS10(chspec) 0
  129. #define CHSPEC_IS20(chspec) 1
  130. #ifndef CHSPEC_IS40
  131. #define CHSPEC_IS40(chspec) 0
  132. #endif
  133. #ifndef CHSPEC_IS80
  134. #define CHSPEC_IS80(chspec) 0
  135. #endif
  136. #ifndef CHSPEC_IS160
  137. #define CHSPEC_IS160(chspec) 0
  138. #endif
  139. #ifndef CHSPEC_IS8080
  140. #define CHSPEC_IS8080(chspec) 0
  141. #endif
  142. #else /* !WL11N_20MHZONLY */
  143. #define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
  144. #define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
  145. #ifndef CHSPEC_IS40
  146. #define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
  147. #endif
  148. #ifndef CHSPEC_IS80
  149. #define CHSPEC_IS80(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
  150. #endif
  151. #ifndef CHSPEC_IS160
  152. #define CHSPEC_IS160(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_160)
  153. #endif
  154. #ifndef CHSPEC_IS8080
  155. #define CHSPEC_IS8080(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_8080)
  156. #endif
  157. #endif /* !WL11N_20MHZONLY */
  158. #define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
  159. #define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
  160. #define CHSPEC_SB_UPPER(chspec) \
  161. ((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) && \
  162. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
  163. #define CHSPEC_SB_LOWER(chspec) \
  164. ((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) && \
  165. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
  166. #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
  167. /**
  168. * Number of chars needed for wf_chspec_ntoa() destination character buffer.
  169. */
  170. #define CHANSPEC_STR_LEN 20
  171. #define CHSPEC_IS_BW_160_WIDE(chspec) (CHSPEC_BW(chspec) == WL_CHANSPEC_BW_160 ||\
  172. CHSPEC_BW(chspec) == WL_CHANSPEC_BW_8080)
  173. /* BW inequality comparisons, LE (<=), GE (>=), LT (<), GT (>), comparisons can be made
  174. * as simple numeric comparisons, with the exception that 160 is the same BW as 80+80,
  175. * but have different numeric values; (WL_CHANSPEC_BW_160 < WL_CHANSPEC_BW_8080).
  176. *
  177. * The LT/LE/GT/GE macros check first checks whether both chspec bandwidth and bw are 160 wide.
  178. * If both chspec bandwidth and bw is not 160 wide, then the comparison is made.
  179. */
  180. #define CHSPEC_BW_GE(chspec, bw) \
  181. ((CHSPEC_IS_BW_160_WIDE(chspec) &&\
  182. (bw == WL_CHANSPEC_BW_160 || bw == WL_CHANSPEC_BW_8080)) ||\
  183. (CHSPEC_BW(chspec) >= bw))
  184. #define CHSPEC_BW_LE(chspec, bw) \
  185. ((CHSPEC_IS_BW_160_WIDE(chspec) &&\
  186. (bw == WL_CHANSPEC_BW_160 || bw == WL_CHANSPEC_BW_8080)) ||\
  187. (CHSPEC_BW(chspec) <= bw))
  188. #define CHSPEC_BW_GT(chspec, bw) \
  189. (!(CHSPEC_IS_BW_160_WIDE(chspec) &&\
  190. (bw == WL_CHANSPEC_BW_160 || bw == WL_CHANSPEC_BW_8080)) &&\
  191. (CHSPEC_BW(chspec) > bw))
  192. #define CHSPEC_BW_LT(chspec, bw) \
  193. (!(CHSPEC_IS_BW_160_WIDE(chspec) &&\
  194. (bw == WL_CHANSPEC_BW_160 || bw == WL_CHANSPEC_BW_8080)) &&\
  195. (CHSPEC_BW(chspec) < bw))
  196. /* Legacy Chanspec defines
  197. * These are the defines for the previous format of the chanspec_t
  198. */
  199. #define WL_LCHANSPEC_CHAN_MASK 0x00ff
  200. #define WL_LCHANSPEC_CHAN_SHIFT 0
  201. #define WL_LCHANSPEC_CTL_SB_MASK 0x0300
  202. #define WL_LCHANSPEC_CTL_SB_SHIFT 8
  203. #define WL_LCHANSPEC_CTL_SB_LOWER 0x0100
  204. #define WL_LCHANSPEC_CTL_SB_UPPER 0x0200
  205. #define WL_LCHANSPEC_CTL_SB_NONE 0x0300
  206. #define WL_LCHANSPEC_BW_MASK 0x0C00
  207. #define WL_LCHANSPEC_BW_SHIFT 10
  208. #define WL_LCHANSPEC_BW_10 0x0400
  209. #define WL_LCHANSPEC_BW_20 0x0800
  210. #define WL_LCHANSPEC_BW_40 0x0C00
  211. #define WL_LCHANSPEC_BAND_MASK 0xf000
  212. #define WL_LCHANSPEC_BAND_SHIFT 12
  213. #define WL_LCHANSPEC_BAND_5G 0x1000
  214. #define WL_LCHANSPEC_BAND_2G 0x2000
  215. #define LCHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_LCHANSPEC_CHAN_MASK))
  216. #define LCHSPEC_BAND(chspec) ((chspec) & WL_LCHANSPEC_BAND_MASK)
  217. #define LCHSPEC_CTL_SB(chspec) ((chspec) & WL_LCHANSPEC_CTL_SB_MASK)
  218. #define LCHSPEC_BW(chspec) ((chspec) & WL_LCHANSPEC_BW_MASK)
  219. #define LCHSPEC_IS10(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_10)
  220. #define LCHSPEC_IS20(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_20)
  221. #define LCHSPEC_IS40(chspec) (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_40)
  222. #define LCHSPEC_IS5G(chspec) (((chspec) & WL_LCHANSPEC_BAND_MASK) == WL_LCHANSPEC_BAND_5G)
  223. #define LCHSPEC_IS2G(chspec) (((chspec) & WL_LCHANSPEC_BAND_MASK) == WL_LCHANSPEC_BAND_2G)
  224. #define LCHSPEC_SB_UPPER(chspec) \
  225. ((((chspec) & WL_LCHANSPEC_CTL_SB_MASK) == WL_LCHANSPEC_CTL_SB_UPPER) && \
  226. (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_40))
  227. #define LCHSPEC_SB_LOWER(chspec) \
  228. ((((chspec) & WL_LCHANSPEC_CTL_SB_MASK) == WL_LCHANSPEC_CTL_SB_LOWER) && \
  229. (((chspec) & WL_LCHANSPEC_BW_MASK) == WL_LCHANSPEC_BW_40))
  230. #define LCHSPEC_CREATE(chan, band, bw, sb) ((uint16)((chan) | (sb) | (bw) | (band)))
  231. #define CH20MHZ_LCHSPEC(channel) \
  232. (chanspec_t)((chanspec_t)(channel) | WL_LCHANSPEC_BW_20 | \
  233. WL_LCHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \
  234. WL_LCHANSPEC_BAND_2G : WL_LCHANSPEC_BAND_5G))
  235. /*
  236. * WF_CHAN_FACTOR_* constants are used to calculate channel frequency
  237. * given a channel number.
  238. * chan_freq = chan_factor * 500Mhz + chan_number * 5
  239. */
  240. /**
  241. * Channel Factor for the starting frequence of 2.4 GHz channels.
  242. * The value corresponds to 2407 MHz.
  243. */
  244. #define WF_CHAN_FACTOR_2_4_G 4814 /* 2.4 GHz band, 2407 MHz */
  245. /**
  246. * Channel Factor for the starting frequence of 5 GHz channels.
  247. * The value corresponds to 5000 MHz.
  248. */
  249. #define WF_CHAN_FACTOR_5_G 10000 /* 5 GHz band, 5000 MHz */
  250. /**
  251. * Channel Factor for the starting frequence of 4.9 GHz channels.
  252. * The value corresponds to 4000 MHz.
  253. */
  254. #define WF_CHAN_FACTOR_4_G 8000 /* 4.9 GHz band for Japan */
  255. #define WLC_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */
  256. /**
  257. * Convert chanspec to ascii string
  258. *
  259. * @param chspec chanspec format
  260. * @param buf ascii string of chanspec
  261. *
  262. * @return pointer to buf with room for at least CHANSPEC_STR_LEN bytes
  263. *
  264. * @see CHANSPEC_STR_LEN
  265. */
  266. extern char * wf_chspec_ntoa(chanspec_t chspec, char *buf);
  267. /**
  268. * Convert ascii string to chanspec
  269. *
  270. * @param a pointer to input string
  271. *
  272. * @return >= 0 if successful or 0 otherwise
  273. */
  274. extern chanspec_t wf_chspec_aton(const char *a);
  275. /**
  276. * Verify the chanspec fields are valid.
  277. *
  278. * Verify the chanspec is using a legal set field values, i.e. that the chanspec
  279. * specified a band, bw, ctl_sb and channel and that the combination could be
  280. * legal given some set of circumstances.
  281. *
  282. * @param chanspec input chanspec to verify
  283. *
  284. * @return TRUE if the chanspec is malformed, FALSE if it looks good.
  285. */
  286. extern bool wf_chspec_malformed(chanspec_t chanspec);
  287. /**
  288. * Verify the chanspec specifies a valid channel according to 802.11.
  289. *
  290. * @param chanspec input chanspec to verify
  291. *
  292. * @return TRUE if the chanspec is a valid 802.11 channel
  293. */
  294. extern bool wf_chspec_valid(chanspec_t chanspec);
  295. /**
  296. * Return the primary (control) channel.
  297. *
  298. * This function returns the channel number of the primary 20MHz channel. For
  299. * 20MHz channels this is just the channel number. For 40MHz or wider channels
  300. * it is the primary 20MHz channel specified by the chanspec.
  301. *
  302. * @param chspec input chanspec
  303. *
  304. * @return Returns the channel number of the primary 20MHz channel
  305. */
  306. extern uint8 wf_chspec_ctlchan(chanspec_t chspec);
  307. /*
  308. * Return the bandwidth string.
  309. *
  310. * This function returns the bandwidth string for the passed chanspec.
  311. *
  312. * @param chspec input chanspec
  313. *
  314. * @return Returns the bandwidth string
  315. */
  316. extern char * wf_chspec_to_bw_str(chanspec_t chspec);
  317. /**
  318. * Return the primary (control) chanspec.
  319. *
  320. * This function returns the chanspec of the primary 20MHz channel. For 20MHz
  321. * channels this is just the chanspec. For 40MHz or wider channels it is the
  322. * chanspec of the primary 20MHZ channel specified by the chanspec.
  323. *
  324. * @param chspec input chanspec
  325. *
  326. * @return Returns the chanspec of the primary 20MHz channel
  327. */
  328. extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec);
  329. /**
  330. * Return a channel number corresponding to a frequency.
  331. *
  332. * This function returns the chanspec for the primary 40MHz of an 80MHz channel.
  333. * The control sideband specifies the same 20MHz channel that the 80MHz channel is using
  334. * as the primary 20MHz channel.
  335. */
  336. extern chanspec_t wf_chspec_primary40_chspec(chanspec_t chspec);
  337. /*
  338. * Return the channel number for a given frequency and base frequency.
  339. * The returned channel number is relative to the given base frequency.
  340. * If the given base frequency is zero, a base frequency of 5 GHz is assumed for
  341. * frequencies from 5 - 6 GHz, and 2.407 GHz is assumed for 2.4 - 2.5 GHz.
  342. *
  343. * Frequency is specified in MHz.
  344. * The base frequency is specified as (start_factor * 500 kHz).
  345. * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
  346. * 2.4 GHz and 5 GHz bands.
  347. *
  348. * The returned channel will be in the range [1, 14] in the 2.4 GHz band
  349. * and [0, 200] otherwise.
  350. * -1 is returned if the start_factor is WF_CHAN_FACTOR_2_4_G and the
  351. * frequency is not a 2.4 GHz channel, or if the frequency is not and even
  352. * multiple of 5 MHz from the base frequency to the base plus 1 GHz.
  353. *
  354. * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
  355. *
  356. * @param freq frequency in MHz
  357. * @param start_factor base frequency in 500 kHz units, e.g. 10000 for 5 GHz
  358. *
  359. * @return Returns a channel number
  360. *
  361. * @see WF_CHAN_FACTOR_2_4_G
  362. * @see WF_CHAN_FACTOR_5_G
  363. */
  364. extern int wf_mhz2channel(uint freq, uint start_factor);
  365. /**
  366. * Return the center frequency in MHz of the given channel and base frequency.
  367. *
  368. * Return the center frequency in MHz of the given channel and base frequency.
  369. * The channel number is interpreted relative to the given base frequency.
  370. *
  371. * The valid channel range is [1, 14] in the 2.4 GHz band and [0, 200] otherwise.
  372. * The base frequency is specified as (start_factor * 500 kHz).
  373. * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
  374. * 2.4 GHz and 5 GHz bands.
  375. * The channel range of [1, 14] is only checked for a start_factor of
  376. * WF_CHAN_FACTOR_2_4_G (4814).
  377. * Odd start_factors produce channels on .5 MHz boundaries, in which case
  378. * the answer is rounded down to an integral MHz.
  379. * -1 is returned for an out of range channel.
  380. *
  381. * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
  382. *
  383. * @param channel input channel number
  384. * @param start_factor base frequency in 500 kHz units, e.g. 10000 for 5 GHz
  385. *
  386. * @return Returns a frequency in MHz
  387. *
  388. * @see WF_CHAN_FACTOR_2_4_G
  389. * @see WF_CHAN_FACTOR_5_G
  390. */
  391. extern int wf_channel2mhz(uint channel, uint start_factor);
  392. /**
  393. * Convert ctl chan and bw to chanspec
  394. *
  395. * @param ctl_ch channel
  396. * @param bw bandwidth
  397. *
  398. * @return > 0 if successful or 0 otherwise
  399. *
  400. */
  401. extern uint16 wf_channel2chspec(uint ctl_ch, uint bw);
  402. extern uint wf_channel2freq(uint channel);
  403. extern uint wf_freq2channel(uint freq);
  404. /*
  405. * Returns the 80+80 chanspec corresponding to the following input parameters
  406. *
  407. * primary_20mhz - Primary 20 Mhz channel
  408. * chan1 - channel number of first 80 Mhz band
  409. * chan2 - channel number of second 80 Mhz band
  410. *
  411. * parameters chan1 and chan2 are channel numbers in {42, 58, 106, 122, 138, 155}
  412. *
  413. * returns INVCHANSPEC in case of error
  414. */
  415. extern chanspec_t wf_chspec_get8080_chspec(uint8 primary_20mhz,
  416. uint8 chan1_80Mhz, uint8 chan2_80Mhz);
  417. /*
  418. * Returns the primary 80 Mhz channel for the provided chanspec
  419. *
  420. * chanspec - Input chanspec for which the 80MHz primary channel has to be retrieved
  421. *
  422. * returns -1 in case the provided channel is 20/40 Mhz chanspec
  423. */
  424. extern uint8 wf_chspec_primary80_channel(chanspec_t chanspec);
  425. /*
  426. * Returns the secondary 80 Mhz channel for the provided chanspec
  427. *
  428. * chanspec - Input chanspec for which the 80MHz secondary channel has to be retrieved
  429. *
  430. * returns -1 in case the provided channel is 20/40 Mhz chanspec
  431. */
  432. extern uint8 wf_chspec_secondary80_channel(chanspec_t chanspec);
  433. /*
  434. * This function returns the chanspec for the primary 80MHz of an 160MHz or 80+80 channel.
  435. */
  436. extern chanspec_t wf_chspec_primary80_chspec(chanspec_t chspec);
  437. #endif /* _bcmwifi_channels_h_ */