cfp.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. /*
  2. * Marvell Wireless LAN device driver: Channel, Frequence and Power
  3. *
  4. * Copyright (C) 2011-2014, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available by writing to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  12. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  13. *
  14. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  16. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  17. * this warranty disclaimer.
  18. */
  19. #include "decl.h"
  20. #include "ioctl.h"
  21. #include "util.h"
  22. #include "fw.h"
  23. #include "main.h"
  24. #include "cfg80211.h"
  25. /* 100mW */
  26. #define MWIFIEX_TX_PWR_DEFAULT 20
  27. /* 100mW */
  28. #define MWIFIEX_TX_PWR_US_DEFAULT 20
  29. /* 50mW */
  30. #define MWIFIEX_TX_PWR_JP_DEFAULT 16
  31. /* 100mW */
  32. #define MWIFIEX_TX_PWR_FR_100MW 20
  33. /* 10mW */
  34. #define MWIFIEX_TX_PWR_FR_10MW 10
  35. /* 100mW */
  36. #define MWIFIEX_TX_PWR_EMEA_DEFAULT 20
  37. static u8 adhoc_rates_b[B_SUPPORTED_RATES] = { 0x82, 0x84, 0x8b, 0x96, 0 };
  38. static u8 adhoc_rates_g[G_SUPPORTED_RATES] = { 0x8c, 0x12, 0x98, 0x24,
  39. 0xb0, 0x48, 0x60, 0x6c, 0 };
  40. static u8 adhoc_rates_bg[BG_SUPPORTED_RATES] = { 0x82, 0x84, 0x8b, 0x96,
  41. 0x0c, 0x12, 0x18, 0x24,
  42. 0x30, 0x48, 0x60, 0x6c, 0 };
  43. static u8 adhoc_rates_a[A_SUPPORTED_RATES] = { 0x8c, 0x12, 0x98, 0x24,
  44. 0xb0, 0x48, 0x60, 0x6c, 0 };
  45. static u8 supported_rates_a[A_SUPPORTED_RATES] = { 0x0c, 0x12, 0x18, 0x24,
  46. 0xb0, 0x48, 0x60, 0x6c, 0 };
  47. static u16 mwifiex_data_rates[MWIFIEX_SUPPORTED_RATES_EXT] = { 0x02, 0x04,
  48. 0x0B, 0x16, 0x00, 0x0C, 0x12, 0x18,
  49. 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90,
  50. 0x0D, 0x1A, 0x27, 0x34, 0x4E, 0x68,
  51. 0x75, 0x82, 0x0C, 0x1B, 0x36, 0x51,
  52. 0x6C, 0xA2, 0xD8, 0xF3, 0x10E, 0x00 };
  53. static u8 supported_rates_b[B_SUPPORTED_RATES] = { 0x02, 0x04, 0x0b, 0x16, 0 };
  54. static u8 supported_rates_g[G_SUPPORTED_RATES] = { 0x0c, 0x12, 0x18, 0x24,
  55. 0x30, 0x48, 0x60, 0x6c, 0 };
  56. static u8 supported_rates_bg[BG_SUPPORTED_RATES] = { 0x02, 0x04, 0x0b, 0x0c,
  57. 0x12, 0x16, 0x18, 0x24, 0x30, 0x48,
  58. 0x60, 0x6c, 0 };
  59. u16 region_code_index[MWIFIEX_MAX_REGION_CODE] = { 0x10, 0x20, 0x30,
  60. 0x32, 0x40, 0x41, 0xff };
  61. static u8 supported_rates_n[N_SUPPORTED_RATES] = { 0x02, 0x04, 0 };
  62. /* For every mcs_rate line, the first 8 bytes are for stream 1x1,
  63. * and all 16 bytes are for stream 2x2.
  64. */
  65. static const u16 mcs_rate[4][16] = {
  66. /* LGI 40M */
  67. { 0x1b, 0x36, 0x51, 0x6c, 0xa2, 0xd8, 0xf3, 0x10e,
  68. 0x36, 0x6c, 0xa2, 0xd8, 0x144, 0x1b0, 0x1e6, 0x21c },
  69. /* SGI 40M */
  70. { 0x1e, 0x3c, 0x5a, 0x78, 0xb4, 0xf0, 0x10e, 0x12c,
  71. 0x3c, 0x78, 0xb4, 0xf0, 0x168, 0x1e0, 0x21c, 0x258 },
  72. /* LGI 20M */
  73. { 0x0d, 0x1a, 0x27, 0x34, 0x4e, 0x68, 0x75, 0x82,
  74. 0x1a, 0x34, 0x4e, 0x68, 0x9c, 0xd0, 0xea, 0x104 },
  75. /* SGI 20M */
  76. { 0x0e, 0x1c, 0x2b, 0x39, 0x56, 0x73, 0x82, 0x90,
  77. 0x1c, 0x39, 0x56, 0x73, 0xad, 0xe7, 0x104, 0x120 }
  78. };
  79. /* AC rates */
  80. static const u16 ac_mcs_rate_nss1[8][10] = {
  81. /* LG 160M */
  82. { 0x75, 0xEA, 0x15F, 0x1D4, 0x2BE, 0x3A8, 0x41D,
  83. 0x492, 0x57C, 0x618 },
  84. /* SG 160M */
  85. { 0x82, 0x104, 0x186, 0x208, 0x30C, 0x410, 0x492,
  86. 0x514, 0x618, 0x6C6 },
  87. /* LG 80M */
  88. { 0x3B, 0x75, 0xB0, 0xEA, 0x15F, 0x1D4, 0x20F,
  89. 0x249, 0x2BE, 0x30C },
  90. /* SG 80M */
  91. { 0x41, 0x82, 0xC3, 0x104, 0x186, 0x208, 0x249,
  92. 0x28A, 0x30C, 0x363 },
  93. /* LG 40M */
  94. { 0x1B, 0x36, 0x51, 0x6C, 0xA2, 0xD8, 0xF3,
  95. 0x10E, 0x144, 0x168 },
  96. /* SG 40M */
  97. { 0x1E, 0x3C, 0x5A, 0x78, 0xB4, 0xF0, 0x10E,
  98. 0x12C, 0x168, 0x190 },
  99. /* LG 20M */
  100. { 0xD, 0x1A, 0x27, 0x34, 0x4E, 0x68, 0x75, 0x82, 0x9C, 0x00 },
  101. /* SG 20M */
  102. { 0xF, 0x1D, 0x2C, 0x3A, 0x57, 0x74, 0x82, 0x91, 0xAE, 0x00 },
  103. };
  104. /* NSS2 note: the value in the table is 2 multiplier of the actual rate */
  105. static const u16 ac_mcs_rate_nss2[8][10] = {
  106. /* LG 160M */
  107. { 0xEA, 0x1D4, 0x2BE, 0x3A8, 0x57C, 0x750, 0x83A,
  108. 0x924, 0xAF8, 0xC30 },
  109. /* SG 160M */
  110. { 0x104, 0x208, 0x30C, 0x410, 0x618, 0x820, 0x924,
  111. 0xA28, 0xC30, 0xD8B },
  112. /* LG 80M */
  113. { 0x75, 0xEA, 0x15F, 0x1D4, 0x2BE, 0x3A8, 0x41D,
  114. 0x492, 0x57C, 0x618 },
  115. /* SG 80M */
  116. { 0x82, 0x104, 0x186, 0x208, 0x30C, 0x410, 0x492,
  117. 0x514, 0x618, 0x6C6 },
  118. /* LG 40M */
  119. { 0x36, 0x6C, 0xA2, 0xD8, 0x144, 0x1B0, 0x1E6,
  120. 0x21C, 0x288, 0x2D0 },
  121. /* SG 40M */
  122. { 0x3C, 0x78, 0xB4, 0xF0, 0x168, 0x1E0, 0x21C,
  123. 0x258, 0x2D0, 0x320 },
  124. /* LG 20M */
  125. { 0x1A, 0x34, 0x4A, 0x68, 0x9C, 0xD0, 0xEA, 0x104,
  126. 0x138, 0x00 },
  127. /* SG 20M */
  128. { 0x1D, 0x3A, 0x57, 0x74, 0xAE, 0xE6, 0x104, 0x121,
  129. 0x15B, 0x00 },
  130. };
  131. struct region_code_mapping {
  132. u8 code;
  133. u8 region[IEEE80211_COUNTRY_STRING_LEN];
  134. };
  135. static struct region_code_mapping region_code_mapping_t[] = {
  136. { 0x10, "US " }, /* US FCC */
  137. { 0x20, "CA " }, /* IC Canada */
  138. { 0x30, "EU " }, /* ETSI */
  139. { 0x31, "ES " }, /* Spain */
  140. { 0x32, "FR " }, /* France */
  141. { 0x40, "JP " }, /* Japan */
  142. { 0x41, "JP " }, /* Japan */
  143. { 0x50, "CN " }, /* China */
  144. };
  145. /* This function converts integer code to region string */
  146. u8 *mwifiex_11d_code_2_region(u8 code)
  147. {
  148. u8 i;
  149. u8 size = sizeof(region_code_mapping_t)/
  150. sizeof(struct region_code_mapping);
  151. /* Look for code in mapping table */
  152. for (i = 0; i < size; i++)
  153. if (region_code_mapping_t[i].code == code)
  154. return region_code_mapping_t[i].region;
  155. return NULL;
  156. }
  157. /*
  158. * This function maps an index in supported rates table into
  159. * the corresponding data rate.
  160. */
  161. u32 mwifiex_index_to_acs_data_rate(struct mwifiex_private *priv,
  162. u8 index, u8 ht_info)
  163. {
  164. u32 rate = 0;
  165. u8 mcs_index = 0;
  166. u8 bw = 0;
  167. u8 gi = 0;
  168. if ((ht_info & 0x3) == MWIFIEX_RATE_FORMAT_VHT) {
  169. mcs_index = min(index & 0xF, 9);
  170. /* 20M: bw=0, 40M: bw=1, 80M: bw=2, 160M: bw=3 */
  171. bw = (ht_info & 0xC) >> 2;
  172. /* LGI: gi =0, SGI: gi = 1 */
  173. gi = (ht_info & 0x10) >> 4;
  174. if ((index >> 4) == 1) /* NSS = 2 */
  175. rate = ac_mcs_rate_nss2[2 * (3 - bw) + gi][mcs_index];
  176. else /* NSS = 1 */
  177. rate = ac_mcs_rate_nss1[2 * (3 - bw) + gi][mcs_index];
  178. } else if ((ht_info & 0x3) == MWIFIEX_RATE_FORMAT_HT) {
  179. /* 20M: bw=0, 40M: bw=1 */
  180. bw = (ht_info & 0xC) >> 2;
  181. /* LGI: gi =0, SGI: gi = 1 */
  182. gi = (ht_info & 0x10) >> 4;
  183. if (index == MWIFIEX_RATE_BITMAP_MCS0) {
  184. if (gi == 1)
  185. rate = 0x0D; /* MCS 32 SGI rate */
  186. else
  187. rate = 0x0C; /* MCS 32 LGI rate */
  188. } else if (index < 16) {
  189. if ((bw == 1) || (bw == 0))
  190. rate = mcs_rate[2 * (1 - bw) + gi][index];
  191. else
  192. rate = mwifiex_data_rates[0];
  193. } else {
  194. rate = mwifiex_data_rates[0];
  195. }
  196. } else {
  197. /* 11n non-HT rates */
  198. if (index >= MWIFIEX_SUPPORTED_RATES_EXT)
  199. index = 0;
  200. rate = mwifiex_data_rates[index];
  201. }
  202. return rate;
  203. }
  204. /* This function maps an index in supported rates table into
  205. * the corresponding data rate.
  206. */
  207. u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv,
  208. u8 index, u8 ht_info)
  209. {
  210. u32 mcs_num_supp =
  211. (priv->adapter->user_dev_mcs_support == HT_STREAM_2X2) ? 16 : 8;
  212. u32 rate;
  213. if (priv->adapter->is_hw_11ac_capable)
  214. return mwifiex_index_to_acs_data_rate(priv, index, ht_info);
  215. if (ht_info & BIT(0)) {
  216. if (index == MWIFIEX_RATE_BITMAP_MCS0) {
  217. if (ht_info & BIT(2))
  218. rate = 0x0D; /* MCS 32 SGI rate */
  219. else
  220. rate = 0x0C; /* MCS 32 LGI rate */
  221. } else if (index < mcs_num_supp) {
  222. if (ht_info & BIT(1)) {
  223. if (ht_info & BIT(2))
  224. /* SGI, 40M */
  225. rate = mcs_rate[1][index];
  226. else
  227. /* LGI, 40M */
  228. rate = mcs_rate[0][index];
  229. } else {
  230. if (ht_info & BIT(2))
  231. /* SGI, 20M */
  232. rate = mcs_rate[3][index];
  233. else
  234. /* LGI, 20M */
  235. rate = mcs_rate[2][index];
  236. }
  237. } else
  238. rate = mwifiex_data_rates[0];
  239. } else {
  240. if (index >= MWIFIEX_SUPPORTED_RATES_EXT)
  241. index = 0;
  242. rate = mwifiex_data_rates[index];
  243. }
  244. return rate;
  245. }
  246. /*
  247. * This function returns the current active data rates.
  248. *
  249. * The result may vary depending upon connection status.
  250. */
  251. u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, u8 *rates)
  252. {
  253. if (!priv->media_connected)
  254. return mwifiex_get_supported_rates(priv, rates);
  255. else
  256. return mwifiex_copy_rates(rates, 0,
  257. priv->curr_bss_params.data_rates,
  258. priv->curr_bss_params.num_of_rates);
  259. }
  260. /*
  261. * This function locates the Channel-Frequency-Power triplet based upon
  262. * band and channel/frequency parameters.
  263. */
  264. struct mwifiex_chan_freq_power *
  265. mwifiex_get_cfp(struct mwifiex_private *priv, u8 band, u16 channel, u32 freq)
  266. {
  267. struct mwifiex_chan_freq_power *cfp = NULL;
  268. struct ieee80211_supported_band *sband;
  269. struct ieee80211_channel *ch = NULL;
  270. int i;
  271. if (!channel && !freq)
  272. return cfp;
  273. if (mwifiex_band_to_radio_type(band) == HostCmd_SCAN_RADIO_TYPE_BG)
  274. sband = priv->wdev.wiphy->bands[IEEE80211_BAND_2GHZ];
  275. else
  276. sband = priv->wdev.wiphy->bands[IEEE80211_BAND_5GHZ];
  277. if (!sband) {
  278. mwifiex_dbg(priv->adapter, ERROR,
  279. "%s: cannot find cfp by band %d\n",
  280. __func__, band);
  281. return cfp;
  282. }
  283. for (i = 0; i < sband->n_channels; i++) {
  284. ch = &sband->channels[i];
  285. if (ch->flags & IEEE80211_CHAN_DISABLED)
  286. continue;
  287. if (freq) {
  288. if (ch->center_freq == freq)
  289. break;
  290. } else {
  291. /* find by valid channel*/
  292. if (ch->hw_value == channel ||
  293. channel == FIRST_VALID_CHANNEL)
  294. break;
  295. }
  296. }
  297. if (i == sband->n_channels) {
  298. mwifiex_dbg(priv->adapter, ERROR,
  299. "%s: cannot find cfp by band %d\t"
  300. "& channel=%d freq=%d\n",
  301. __func__, band, channel, freq);
  302. } else {
  303. if (!ch)
  304. return cfp;
  305. priv->cfp.channel = ch->hw_value;
  306. priv->cfp.freq = ch->center_freq;
  307. priv->cfp.max_tx_power = ch->max_power;
  308. cfp = &priv->cfp;
  309. }
  310. return cfp;
  311. }
  312. /*
  313. * This function checks if the data rate is set to auto.
  314. */
  315. u8
  316. mwifiex_is_rate_auto(struct mwifiex_private *priv)
  317. {
  318. u32 i;
  319. int rate_num = 0;
  320. for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates); i++)
  321. if (priv->bitmap_rates[i])
  322. rate_num++;
  323. if (rate_num > 1)
  324. return true;
  325. else
  326. return false;
  327. }
  328. /* This function gets the supported data rates from bitmask inside
  329. * cfg80211_scan_request.
  330. */
  331. u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv,
  332. u8 *rates, u8 radio_type)
  333. {
  334. struct wiphy *wiphy = priv->adapter->wiphy;
  335. struct cfg80211_scan_request *request = priv->scan_request;
  336. u32 num_rates, rate_mask;
  337. struct ieee80211_supported_band *sband;
  338. int i;
  339. if (radio_type) {
  340. sband = wiphy->bands[IEEE80211_BAND_5GHZ];
  341. if (WARN_ON_ONCE(!sband))
  342. return 0;
  343. rate_mask = request->rates[IEEE80211_BAND_5GHZ];
  344. } else {
  345. sband = wiphy->bands[IEEE80211_BAND_2GHZ];
  346. if (WARN_ON_ONCE(!sband))
  347. return 0;
  348. rate_mask = request->rates[IEEE80211_BAND_2GHZ];
  349. }
  350. num_rates = 0;
  351. for (i = 0; i < sband->n_bitrates; i++) {
  352. if ((BIT(i) & rate_mask) == 0)
  353. continue; /* skip rate */
  354. rates[num_rates++] = (u8)(sband->bitrates[i].bitrate / 5);
  355. }
  356. return num_rates;
  357. }
  358. /* This function gets the supported data rates. The function works in
  359. * both Ad-Hoc and infra mode by printing the band and returning the
  360. * data rates.
  361. */
  362. u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates)
  363. {
  364. u32 k = 0;
  365. struct mwifiex_adapter *adapter = priv->adapter;
  366. if (priv->bss_mode == NL80211_IFTYPE_STATION ||
  367. priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) {
  368. switch (adapter->config_bands) {
  369. case BAND_B:
  370. mwifiex_dbg(adapter, INFO, "info: infra band=%d\t"
  371. "supported_rates_b\n",
  372. adapter->config_bands);
  373. k = mwifiex_copy_rates(rates, k, supported_rates_b,
  374. sizeof(supported_rates_b));
  375. break;
  376. case BAND_G:
  377. case BAND_G | BAND_GN:
  378. mwifiex_dbg(adapter, INFO, "info: infra band=%d\t"
  379. "supported_rates_g\n",
  380. adapter->config_bands);
  381. k = mwifiex_copy_rates(rates, k, supported_rates_g,
  382. sizeof(supported_rates_g));
  383. break;
  384. case BAND_B | BAND_G:
  385. case BAND_A | BAND_B | BAND_G:
  386. case BAND_A | BAND_B:
  387. case BAND_A | BAND_B | BAND_G | BAND_GN | BAND_AN:
  388. case BAND_A | BAND_B | BAND_G | BAND_GN | BAND_AN | BAND_AAC:
  389. case BAND_B | BAND_G | BAND_GN:
  390. mwifiex_dbg(adapter, INFO, "info: infra band=%d\t"
  391. "supported_rates_bg\n",
  392. adapter->config_bands);
  393. k = mwifiex_copy_rates(rates, k, supported_rates_bg,
  394. sizeof(supported_rates_bg));
  395. break;
  396. case BAND_A:
  397. case BAND_A | BAND_G:
  398. mwifiex_dbg(adapter, INFO, "info: infra band=%d\t"
  399. "supported_rates_a\n",
  400. adapter->config_bands);
  401. k = mwifiex_copy_rates(rates, k, supported_rates_a,
  402. sizeof(supported_rates_a));
  403. break;
  404. case BAND_AN:
  405. case BAND_A | BAND_AN:
  406. case BAND_A | BAND_AN | BAND_AAC:
  407. case BAND_A | BAND_G | BAND_AN | BAND_GN:
  408. case BAND_A | BAND_G | BAND_AN | BAND_GN | BAND_AAC:
  409. mwifiex_dbg(adapter, INFO, "info: infra band=%d\t"
  410. "supported_rates_a\n",
  411. adapter->config_bands);
  412. k = mwifiex_copy_rates(rates, k, supported_rates_a,
  413. sizeof(supported_rates_a));
  414. break;
  415. case BAND_GN:
  416. mwifiex_dbg(adapter, INFO, "info: infra band=%d\t"
  417. "supported_rates_n\n",
  418. adapter->config_bands);
  419. k = mwifiex_copy_rates(rates, k, supported_rates_n,
  420. sizeof(supported_rates_n));
  421. break;
  422. }
  423. } else {
  424. /* Ad-hoc mode */
  425. switch (adapter->adhoc_start_band) {
  426. case BAND_B:
  427. mwifiex_dbg(adapter, INFO, "info: adhoc B\n");
  428. k = mwifiex_copy_rates(rates, k, adhoc_rates_b,
  429. sizeof(adhoc_rates_b));
  430. break;
  431. case BAND_G:
  432. case BAND_G | BAND_GN:
  433. mwifiex_dbg(adapter, INFO, "info: adhoc G only\n");
  434. k = mwifiex_copy_rates(rates, k, adhoc_rates_g,
  435. sizeof(adhoc_rates_g));
  436. break;
  437. case BAND_B | BAND_G:
  438. case BAND_B | BAND_G | BAND_GN:
  439. mwifiex_dbg(adapter, INFO, "info: adhoc BG\n");
  440. k = mwifiex_copy_rates(rates, k, adhoc_rates_bg,
  441. sizeof(adhoc_rates_bg));
  442. break;
  443. case BAND_A:
  444. case BAND_A | BAND_AN:
  445. mwifiex_dbg(adapter, INFO, "info: adhoc A\n");
  446. k = mwifiex_copy_rates(rates, k, adhoc_rates_a,
  447. sizeof(adhoc_rates_a));
  448. break;
  449. }
  450. }
  451. return k;
  452. }
  453. u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
  454. u8 rx_rate, u8 rate_info)
  455. {
  456. u8 rate_index = 0;
  457. /* HT40 */
  458. if ((rate_info & BIT(0)) && (rate_info & BIT(1)))
  459. rate_index = MWIFIEX_RATE_INDEX_MCS0 +
  460. MWIFIEX_BW20_MCS_NUM + rx_rate;
  461. else if (rate_info & BIT(0)) /* HT20 */
  462. rate_index = MWIFIEX_RATE_INDEX_MCS0 + rx_rate;
  463. else
  464. rate_index = (rx_rate > MWIFIEX_RATE_INDEX_OFDM0) ?
  465. rx_rate - 1 : rx_rate;
  466. return rate_index;
  467. }