fw.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * wlanfae <wlanfae@realtek.com>
  23. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  24. * Hsinchu 300, Taiwan.
  25. *
  26. * Larry Finger <Larry.Finger@lwfinger.net>
  27. *
  28. ****************************************************************************
  29. */
  30. #include "../wifi.h"
  31. #include "../pci.h"
  32. #include "../base.h"
  33. #include "reg.h"
  34. #include "def.h"
  35. #include "fw.h"
  36. static void _rtl8723ae_enable_fw_download(struct ieee80211_hw *hw, bool enable)
  37. {
  38. struct rtl_priv *rtlpriv = rtl_priv(hw);
  39. u8 tmp;
  40. if (enable) {
  41. tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
  42. rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmp | 0x04);
  43. tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL);
  44. rtl_write_byte(rtlpriv, REG_MCUFWDL, tmp | 0x01);
  45. tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL + 2);
  46. rtl_write_byte(rtlpriv, REG_MCUFWDL + 2, tmp & 0xf7);
  47. } else {
  48. tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL);
  49. rtl_write_byte(rtlpriv, REG_MCUFWDL, tmp & 0xfe);
  50. rtl_write_byte(rtlpriv, REG_MCUFWDL + 1, 0x00);
  51. }
  52. }
  53. static void _rtl8723ae_fw_block_write(struct ieee80211_hw *hw,
  54. const u8 *buffer, u32 size)
  55. {
  56. struct rtl_priv *rtlpriv = rtl_priv(hw);
  57. u32 blockSize = sizeof(u32);
  58. u8 *bufferPtr = (u8 *) buffer;
  59. u32 *pu4BytePtr = (u32 *) buffer;
  60. u32 i, offset, blockCount, remainSize;
  61. blockCount = size / blockSize;
  62. remainSize = size % blockSize;
  63. for (i = 0; i < blockCount; i++) {
  64. offset = i * blockSize;
  65. rtl_write_dword(rtlpriv, (FW_8192C_START_ADDRESS + offset),
  66. *(pu4BytePtr + i));
  67. }
  68. if (remainSize) {
  69. offset = blockCount * blockSize;
  70. bufferPtr += offset;
  71. for (i = 0; i < remainSize; i++) {
  72. rtl_write_byte(rtlpriv, (FW_8192C_START_ADDRESS +
  73. offset + i), *(bufferPtr + i));
  74. }
  75. }
  76. }
  77. static void _rtl8723ae_fw_page_write(struct ieee80211_hw *hw,
  78. u32 page, const u8 *buffer, u32 size)
  79. {
  80. struct rtl_priv *rtlpriv = rtl_priv(hw);
  81. u8 value8;
  82. u8 u8page = (u8) (page & 0x07);
  83. value8 = (rtl_read_byte(rtlpriv, REG_MCUFWDL + 2) & 0xF8) | u8page;
  84. rtl_write_byte(rtlpriv, (REG_MCUFWDL + 2), value8);
  85. _rtl8723ae_fw_block_write(hw, buffer, size);
  86. }
  87. static void _rtl8723ae_write_fw(struct ieee80211_hw *hw,
  88. enum version_8723e version, u8 *buffer,
  89. u32 size)
  90. {
  91. struct rtl_priv *rtlpriv = rtl_priv(hw);
  92. u8 *bufferPtr = (u8 *) buffer;
  93. u32 page_nums, remain_size;
  94. u32 page, offset;
  95. RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes,\n", size);
  96. page_nums = size / FW_8192C_PAGE_SIZE;
  97. remain_size = size % FW_8192C_PAGE_SIZE;
  98. if (page_nums > 6) {
  99. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  100. "Page numbers should not be greater then 6\n");
  101. }
  102. for (page = 0; page < page_nums; page++) {
  103. offset = page * FW_8192C_PAGE_SIZE;
  104. _rtl8723ae_fw_page_write(hw, page, (bufferPtr + offset),
  105. FW_8192C_PAGE_SIZE);
  106. }
  107. if (remain_size) {
  108. offset = page_nums * FW_8192C_PAGE_SIZE;
  109. page = page_nums;
  110. _rtl8723ae_fw_page_write(hw, page, (bufferPtr + offset),
  111. remain_size);
  112. }
  113. RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW write done.\n");
  114. }
  115. static int _rtl8723ae_fw_free_to_go(struct ieee80211_hw *hw)
  116. {
  117. struct rtl_priv *rtlpriv = rtl_priv(hw);
  118. int err = -EIO;
  119. u32 counter = 0;
  120. u32 value32;
  121. do {
  122. value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
  123. } while ((counter++ < FW_8192C_POLLING_TIMEOUT_COUNT) &&
  124. (!(value32 & FWDL_ChkSum_rpt)));
  125. if (counter >= FW_8192C_POLLING_TIMEOUT_COUNT) {
  126. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  127. "chksum report faill ! REG_MCUFWDL:0x%08x .\n",
  128. value32);
  129. goto exit;
  130. }
  131. RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
  132. "Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32);
  133. value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
  134. value32 |= MCUFWDL_RDY;
  135. value32 &= ~WINTINI_RDY;
  136. rtl_write_dword(rtlpriv, REG_MCUFWDL, value32);
  137. counter = 0;
  138. do {
  139. value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
  140. if (value32 & WINTINI_RDY) {
  141. RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
  142. "Polling FW ready success!! REG_MCUFWDL:0x%08x .\n",
  143. value32);
  144. err = 0;
  145. goto exit;
  146. }
  147. mdelay(FW_8192C_POLLING_DELAY);
  148. } while (counter++ < FW_8192C_POLLING_TIMEOUT_COUNT);
  149. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  150. "Polling FW ready fail!! REG_MCUFWDL:0x%08x .\n", value32);
  151. exit:
  152. return err;
  153. }
  154. int rtl8723ae_download_fw(struct ieee80211_hw *hw)
  155. {
  156. struct rtl_priv *rtlpriv = rtl_priv(hw);
  157. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  158. struct rtl8723ae_firmware_header *pfwheader;
  159. u8 *pfwdata;
  160. u32 fwsize;
  161. int err;
  162. enum version_8723e version = rtlhal->version;
  163. if (!rtlhal->pfirmware)
  164. return 1;
  165. pfwheader = (struct rtl8723ae_firmware_header *)rtlhal->pfirmware;
  166. pfwdata = (u8 *) rtlhal->pfirmware;
  167. fwsize = rtlhal->fwsize;
  168. if (IS_FW_HEADER_EXIST(pfwheader)) {
  169. RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
  170. "Firmware Version(%d), Signature(%#x),Size(%d)\n",
  171. pfwheader->version, pfwheader->signature,
  172. (int)sizeof(struct rtl8723ae_firmware_header));
  173. pfwdata = pfwdata + sizeof(struct rtl8723ae_firmware_header);
  174. fwsize = fwsize - sizeof(struct rtl8723ae_firmware_header);
  175. }
  176. if (rtl_read_byte(rtlpriv, REG_MCUFWDL)&BIT(7)) {
  177. rtl8723ae_firmware_selfreset(hw);
  178. rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00);
  179. }
  180. _rtl8723ae_enable_fw_download(hw, true);
  181. _rtl8723ae_write_fw(hw, version, pfwdata, fwsize);
  182. _rtl8723ae_enable_fw_download(hw, false);
  183. err = _rtl8723ae_fw_free_to_go(hw);
  184. if (err) {
  185. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  186. "Firmware is not ready to run!\n");
  187. } else {
  188. RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
  189. "Firmware is ready to run!\n");
  190. }
  191. return 0;
  192. }
  193. static bool rtl8723ae_check_fw_read_last_h2c(struct ieee80211_hw *hw, u8 boxnum)
  194. {
  195. struct rtl_priv *rtlpriv = rtl_priv(hw);
  196. u8 val_hmetfr, val_mcutst_1;
  197. bool result = false;
  198. val_hmetfr = rtl_read_byte(rtlpriv, REG_HMETFR);
  199. val_mcutst_1 = rtl_read_byte(rtlpriv, (REG_MCUTST_1 + boxnum));
  200. if (((val_hmetfr >> boxnum) & BIT(0)) == 0 && val_mcutst_1 == 0)
  201. result = true;
  202. return result;
  203. }
  204. static void _rtl8723ae_fill_h2c_command(struct ieee80211_hw *hw,
  205. u8 element_id, u32 cmd_len,
  206. u8 *p_cmdbuffer)
  207. {
  208. struct rtl_priv *rtlpriv = rtl_priv(hw);
  209. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  210. u8 boxnum;
  211. u16 box_reg = 0, box_extreg = 0;
  212. u8 u1tmp;
  213. bool isfw_rd = false;
  214. bool bwrite_success = false;
  215. u8 wait_h2c_limmit = 100;
  216. u8 wait_writeh2c_limmit = 100;
  217. u8 boxcontent[4], boxextcontent[2];
  218. u32 h2c_waitcounter = 0;
  219. unsigned long flag;
  220. u8 idx;
  221. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n");
  222. while (true) {
  223. spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
  224. if (rtlhal->h2c_setinprogress) {
  225. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
  226. "H2C set in progress! Wait to set..element_id(%d).\n",
  227. element_id);
  228. while (rtlhal->h2c_setinprogress) {
  229. spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock,
  230. flag);
  231. h2c_waitcounter++;
  232. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
  233. "Wait 100 us (%d times)...\n",
  234. h2c_waitcounter);
  235. udelay(100);
  236. if (h2c_waitcounter > 1000)
  237. return;
  238. spin_lock_irqsave(&rtlpriv->locks.h2c_lock,
  239. flag);
  240. }
  241. spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
  242. } else {
  243. rtlhal->h2c_setinprogress = true;
  244. spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
  245. break;
  246. }
  247. }
  248. while (!bwrite_success) {
  249. wait_writeh2c_limmit--;
  250. if (wait_writeh2c_limmit == 0) {
  251. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  252. "Write H2C fail because no trigger "
  253. "for FW INT!\n");
  254. break;
  255. }
  256. boxnum = rtlhal->last_hmeboxnum;
  257. switch (boxnum) {
  258. case 0:
  259. box_reg = REG_HMEBOX_0;
  260. box_extreg = REG_HMEBOX_EXT_0;
  261. break;
  262. case 1:
  263. box_reg = REG_HMEBOX_1;
  264. box_extreg = REG_HMEBOX_EXT_1;
  265. break;
  266. case 2:
  267. box_reg = REG_HMEBOX_2;
  268. box_extreg = REG_HMEBOX_EXT_2;
  269. break;
  270. case 3:
  271. box_reg = REG_HMEBOX_3;
  272. box_extreg = REG_HMEBOX_EXT_3;
  273. break;
  274. default:
  275. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  276. "switch case not processed\n");
  277. break;
  278. }
  279. isfw_rd = rtl8723ae_check_fw_read_last_h2c(hw, boxnum);
  280. while (!isfw_rd) {
  281. wait_h2c_limmit--;
  282. if (wait_h2c_limmit == 0) {
  283. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
  284. "Wating too long for FW read clear HMEBox(%d)!\n",
  285. boxnum);
  286. break;
  287. }
  288. udelay(10);
  289. isfw_rd = rtl8723ae_check_fw_read_last_h2c(hw, boxnum);
  290. u1tmp = rtl_read_byte(rtlpriv, 0x1BF);
  291. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
  292. "Wating for FW read clear HMEBox(%d)!!! "
  293. "0x1BF = %2x\n", boxnum, u1tmp);
  294. }
  295. if (!isfw_rd) {
  296. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
  297. "Write H2C register BOX[%d] fail!!!!! "
  298. "Fw do not read.\n", boxnum);
  299. break;
  300. }
  301. memset(boxcontent, 0, sizeof(boxcontent));
  302. memset(boxextcontent, 0, sizeof(boxextcontent));
  303. boxcontent[0] = element_id;
  304. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
  305. "Write element_id box_reg(%4x) = %2x\n",
  306. box_reg, element_id);
  307. switch (cmd_len) {
  308. case 1:
  309. boxcontent[0] &= ~(BIT(7));
  310. memcpy((u8 *) (boxcontent) + 1,
  311. p_cmdbuffer, 1);
  312. for (idx = 0; idx < 4; idx++) {
  313. rtl_write_byte(rtlpriv, box_reg + idx,
  314. boxcontent[idx]);
  315. }
  316. break;
  317. case 2:
  318. boxcontent[0] &= ~(BIT(7));
  319. memcpy((u8 *) (boxcontent) + 1,
  320. p_cmdbuffer, 2);
  321. for (idx = 0; idx < 4; idx++) {
  322. rtl_write_byte(rtlpriv, box_reg + idx,
  323. boxcontent[idx]);
  324. }
  325. break;
  326. case 3:
  327. boxcontent[0] &= ~(BIT(7));
  328. memcpy((u8 *) (boxcontent) + 1,
  329. p_cmdbuffer, 3);
  330. for (idx = 0; idx < 4; idx++) {
  331. rtl_write_byte(rtlpriv, box_reg + idx,
  332. boxcontent[idx]);
  333. }
  334. break;
  335. case 4:
  336. boxcontent[0] |= (BIT(7));
  337. memcpy((u8 *) (boxextcontent),
  338. p_cmdbuffer, 2);
  339. memcpy((u8 *) (boxcontent) + 1,
  340. p_cmdbuffer + 2, 2);
  341. for (idx = 0; idx < 2; idx++) {
  342. rtl_write_byte(rtlpriv, box_extreg + idx,
  343. boxextcontent[idx]);
  344. }
  345. for (idx = 0; idx < 4; idx++) {
  346. rtl_write_byte(rtlpriv, box_reg + idx,
  347. boxcontent[idx]);
  348. }
  349. break;
  350. case 5:
  351. boxcontent[0] |= (BIT(7));
  352. memcpy((u8 *) (boxextcontent),
  353. p_cmdbuffer, 2);
  354. memcpy((u8 *) (boxcontent) + 1,
  355. p_cmdbuffer + 2, 3);
  356. for (idx = 0; idx < 2; idx++) {
  357. rtl_write_byte(rtlpriv, box_extreg + idx,
  358. boxextcontent[idx]);
  359. }
  360. for (idx = 0; idx < 4; idx++) {
  361. rtl_write_byte(rtlpriv, box_reg + idx,
  362. boxcontent[idx]);
  363. }
  364. break;
  365. default:
  366. RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
  367. "switch case not process\n");
  368. break;
  369. }
  370. bwrite_success = true;
  371. rtlhal->last_hmeboxnum = boxnum + 1;
  372. if (rtlhal->last_hmeboxnum == 4)
  373. rtlhal->last_hmeboxnum = 0;
  374. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
  375. "pHalData->last_hmeboxnum = %d\n",
  376. rtlhal->last_hmeboxnum);
  377. }
  378. spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
  379. rtlhal->h2c_setinprogress = false;
  380. spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
  381. RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n");
  382. }
  383. void rtl8723ae_fill_h2c_cmd(struct ieee80211_hw *hw,
  384. u8 element_id, u32 cmd_len, u8 *p_cmdbuffer)
  385. {
  386. struct rtl_priv *rtlpriv = rtl_priv(hw);
  387. struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
  388. if (rtlhal->fw_ready == false) {
  389. RT_ASSERT(false,
  390. "return H2C cmd because of Fw download fail!!!\n");
  391. return;
  392. }
  393. _rtl8723ae_fill_h2c_command(hw, element_id, cmd_len, p_cmdbuffer);
  394. return;
  395. }
  396. void rtl8723ae_firmware_selfreset(struct ieee80211_hw *hw)
  397. {
  398. u8 u1tmp;
  399. u8 delay = 100;
  400. struct rtl_priv *rtlpriv = rtl_priv(hw);
  401. rtl_write_byte(rtlpriv, REG_HMETFR + 3, 0x20);
  402. u1tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
  403. while (u1tmp & BIT(2)) {
  404. delay--;
  405. if (delay == 0)
  406. break;
  407. udelay(50);
  408. u1tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
  409. }
  410. if (delay == 0) {
  411. u1tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
  412. rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, u1tmp&(~BIT(2)));
  413. }
  414. }
  415. void rtl8723ae_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)
  416. {
  417. struct rtl_priv *rtlpriv = rtl_priv(hw);
  418. u8 u1_h2c_set_pwrmode[3] = { 0 };
  419. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  420. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode);
  421. SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode);
  422. SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1);
  423. SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode,
  424. ppsc->reg_max_lps_awakeintvl);
  425. RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
  426. "rtl8723ae_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode\n",
  427. u1_h2c_set_pwrmode, 3);
  428. rtl8723ae_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode);
  429. }
  430. static bool _rtl8723ae_cmd_send_packet(struct ieee80211_hw *hw,
  431. struct sk_buff *skb)
  432. {
  433. struct rtl_priv *rtlpriv = rtl_priv(hw);
  434. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  435. struct rtl8192_tx_ring *ring;
  436. struct rtl_tx_desc *pdesc;
  437. unsigned long flags;
  438. struct sk_buff *pskb = NULL;
  439. ring = &rtlpci->tx_ring[BEACON_QUEUE];
  440. pskb = __skb_dequeue(&ring->queue);
  441. if (pskb)
  442. kfree_skb(pskb);
  443. spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
  444. pdesc = &ring->desc[0];
  445. rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *) pdesc, 1, 1, skb);
  446. __skb_queue_tail(&ring->queue, skb);
  447. spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
  448. rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE);
  449. return true;
  450. }
  451. static u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = {
  452. /* page 0 beacon */
  453. 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
  454. 0xFF, 0xFF, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42,
  455. 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x50, 0x08,
  456. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  457. 0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69,
  458. 0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C,
  459. 0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96,
  460. 0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A,
  461. 0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C,
  462. 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18,
  463. 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  464. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  465. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  466. 0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02,
  467. 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  468. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  469. /* page 1 beacon */
  470. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  471. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  472. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  473. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  474. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  475. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  476. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  477. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  478. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  479. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  480. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  481. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  482. 0x10, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x10, 0x00,
  483. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  484. 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  485. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  486. /* page 2 ps-poll */
  487. 0xA4, 0x10, 0x01, 0xC0, 0x00, 0x40, 0x10, 0x10,
  488. 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42,
  489. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  490. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  491. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  492. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  493. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  494. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  495. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  496. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  497. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  498. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  499. 0x18, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x00, 0x00,
  500. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  501. 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  502. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  503. /* page 3 null */
  504. 0x48, 0x01, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10,
  505. 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42,
  506. 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00,
  507. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  508. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  509. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  510. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  511. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  512. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  513. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  514. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  515. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  516. 0x72, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x00, 0x00,
  517. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  518. 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  519. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  520. /* page 4 probe_resp */
  521. 0x50, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10,
  522. 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42,
  523. 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00,
  524. 0x9E, 0x46, 0x15, 0x32, 0x27, 0xF2, 0x2D, 0x00,
  525. 0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69,
  526. 0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C,
  527. 0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96,
  528. 0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A,
  529. 0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C,
  530. 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18,
  531. 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  532. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  533. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  534. 0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02,
  535. 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  536. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  537. /* page 5 probe_resp */
  538. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  539. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  540. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  541. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  542. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  543. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  544. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  545. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  546. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  547. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  548. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  549. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  550. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  551. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  552. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  553. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  554. };
  555. void rtl8723ae_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished)
  556. {
  557. struct rtl_priv *rtlpriv = rtl_priv(hw);
  558. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  559. struct sk_buff *skb = NULL;
  560. u32 totalpacketlen;
  561. bool rtstatus;
  562. u8 u1RsvdPageLoc[3] = { 0 };
  563. bool dlok = false;
  564. u8 *beacon;
  565. u8 *p_pspoll;
  566. u8 *nullfunc;
  567. u8 *p_probersp;
  568. /*---------------------------------------------------------
  569. (1) beacon
  570. ---------------------------------------------------------
  571. */
  572. beacon = &reserved_page_packet[BEACON_PG * 128];
  573. SET_80211_HDR_ADDRESS2(beacon, mac->mac_addr);
  574. SET_80211_HDR_ADDRESS3(beacon, mac->bssid);
  575. /*-------------------------------------------------------
  576. (2) ps-poll
  577. --------------------------------------------------------
  578. */
  579. p_pspoll = &reserved_page_packet[PSPOLL_PG * 128];
  580. SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
  581. SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
  582. SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
  583. SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1RsvdPageLoc, PSPOLL_PG);
  584. /*--------------------------------------------------------
  585. (3) null data
  586. ---------------------------------------------------------i
  587. */
  588. nullfunc = &reserved_page_packet[NULL_PG * 128];
  589. SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid);
  590. SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr);
  591. SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid);
  592. SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1RsvdPageLoc, NULL_PG);
  593. /*---------------------------------------------------------
  594. (4) probe response
  595. ----------------------------------------------------------
  596. */
  597. p_probersp = &reserved_page_packet[PROBERSP_PG * 128];
  598. SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid);
  599. SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr);
  600. SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid);
  601. SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG);
  602. totalpacketlen = TOTAL_RESERVED_PKT_LEN;
  603. RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
  604. "rtl8723ae_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n",
  605. &reserved_page_packet[0], totalpacketlen);
  606. RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
  607. "rtl8723ae_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n",
  608. u1RsvdPageLoc, 3);
  609. skb = dev_alloc_skb(totalpacketlen);
  610. memcpy((u8 *) skb_put(skb, totalpacketlen),
  611. &reserved_page_packet, totalpacketlen);
  612. rtstatus = _rtl8723ae_cmd_send_packet(hw, skb);
  613. if (rtstatus)
  614. dlok = true;
  615. if (dlok) {
  616. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
  617. "Set RSVD page location to Fw.\n");
  618. RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
  619. "H2C_RSVDPAGE:\n",
  620. u1RsvdPageLoc, 3);
  621. rtl8723ae_fill_h2c_cmd(hw, H2C_RSVDPAGE,
  622. sizeof(u1RsvdPageLoc), u1RsvdPageLoc);
  623. } else
  624. RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
  625. "Set RSVD page location to Fw FAIL!!!!!!.\n");
  626. }
  627. void rtl8723ae_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus)
  628. {
  629. u8 u1_joinbssrpt_parm[1] = { 0 };
  630. SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(u1_joinbssrpt_parm, mstatus);
  631. rtl8723ae_fill_h2c_cmd(hw, H2C_JOINBSSRPT, 1, u1_joinbssrpt_parm);
  632. }