linux/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
<<
>>
Prefs
   1/******************************************************************************
   2 *
   3 * Copyright(c) 2009-2010  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 * The full GNU General Public License is included in this distribution in the
  15 * file called LICENSE.
  16 *
  17 * Contact Information:
  18 * wlanfae <wlanfae@realtek.com>
  19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20 * Hsinchu 300, Taiwan.
  21 *
  22 * Larry Finger <Larry.Finger@lwfinger.net>
  23 *
  24 *****************************************************************************/
  25
  26#include "../wifi.h"
  27#include "../pci.h"
  28#include "../base.h"
  29#include "../core.h"
  30#include "reg.h"
  31#include "def.h"
  32#include "fw.h"
  33#include "dm.h"
  34
  35static void _rtl8821ae_enable_fw_download(struct ieee80211_hw *hw, bool enable)
  36{
  37        struct rtl_priv *rtlpriv = rtl_priv(hw);
  38        u8 tmp;
  39
  40        if (enable) {
  41                rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x05);
  42
  43                tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL + 2);
  44                rtl_write_byte(rtlpriv, REG_MCUFWDL + 2, tmp & 0xf7);
  45
  46                tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL);
  47        } else {
  48                tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL);
  49                rtl_write_byte(rtlpriv, REG_MCUFWDL, tmp & 0xfe);
  50                tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL);
  51        }
  52}
  53
  54static void _rtl8821ae_fw_block_write(struct ieee80211_hw *hw,
  55                                      const u8 *buffer, u32 size)
  56{
  57        struct rtl_priv *rtlpriv = rtl_priv(hw);
  58        u32 blocksize = sizeof(u32);
  59        u8 *bufferptr = (u8 *)buffer;
  60        u32 *pu4byteptr = (u32 *)buffer;
  61        u32 i, offset, blockcount, remainsize;
  62
  63        blockcount = size / blocksize;
  64        remainsize = size % blocksize;
  65
  66        for (i = 0; i < blockcount; i++) {
  67                offset = i * blocksize;
  68                rtl_write_dword(rtlpriv, (FW_8821AE_START_ADDRESS + offset),
  69                                *(pu4byteptr + i));
  70        }
  71
  72        if (remainsize) {
  73                offset = blockcount * blocksize;
  74                bufferptr += offset;
  75                for (i = 0; i < remainsize; i++) {
  76                        rtl_write_byte(rtlpriv, (FW_8821AE_START_ADDRESS +
  77                                        offset + i), *(bufferptr + i));
  78                }
  79        }
  80}
  81
  82static void _rtl8821ae_fw_page_write(struct ieee80211_hw *hw,
  83                                     u32 page, const u8 *buffer, u32 size)
  84{
  85        struct rtl_priv *rtlpriv = rtl_priv(hw);
  86        u8 value8;
  87        u8 u8page = (u8)(page & 0x07);
  88
  89        value8 = (rtl_read_byte(rtlpriv, REG_MCUFWDL + 2) & 0xF8) | u8page;
  90
  91        rtl_write_byte(rtlpriv, (REG_MCUFWDL + 2), value8);
  92        _rtl8821ae_fw_block_write(hw, buffer, size);
  93}
  94
  95static void _rtl8821ae_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
  96{
  97        u32 fwlen = *pfwlen;
  98        u8 remain = (u8)(fwlen % 4);
  99
 100        remain = (remain == 0) ? 0 : (4 - remain);
 101
 102        while (remain > 0) {
 103                pfwbuf[fwlen] = 0;
 104                fwlen++;
 105                remain--;
 106        }
 107
 108        *pfwlen = fwlen;
 109}
 110
 111static void _rtl8821ae_write_fw(struct ieee80211_hw *hw,
 112                                enum version_8821ae version,
 113                                u8 *buffer, u32 size)
 114{
 115        struct rtl_priv *rtlpriv = rtl_priv(hw);
 116        u8 *bufferptr = (u8 *)buffer;
 117        u32 pagenums, remainsize;
 118        u32 page, offset;
 119
 120        RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "FW size is %d bytes,\n", size);
 121
 122        _rtl8821ae_fill_dummy(bufferptr, &size);
 123
 124        pagenums = size / FW_8821AE_PAGE_SIZE;
 125        remainsize = size % FW_8821AE_PAGE_SIZE;
 126
 127        if (pagenums > 8) {
 128                RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
 129                         "Page numbers should not greater then 8\n");
 130        }
 131
 132        for (page = 0; page < pagenums; page++) {
 133                offset = page * FW_8821AE_PAGE_SIZE;
 134                _rtl8821ae_fw_page_write(hw, page, (bufferptr + offset),
 135                                         FW_8821AE_PAGE_SIZE);
 136        }
 137
 138        if (remainsize) {
 139                offset = pagenums * FW_8821AE_PAGE_SIZE;
 140                page = pagenums;
 141                _rtl8821ae_fw_page_write(hw, page, (bufferptr + offset),
 142                                         remainsize);
 143        }
 144}
 145
 146static int _rtl8821ae_fw_free_to_go(struct ieee80211_hw *hw)
 147{
 148        struct rtl_priv *rtlpriv = rtl_priv(hw);
 149        int err = -EIO;
 150        u32 counter = 0;
 151        u32 value32;
 152
 153        do {
 154                value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
 155        } while ((counter++ < FW_8821AE_POLLING_TIMEOUT_COUNT) &&
 156                 (!(value32 & FWDL_CHKSUM_RPT)));
 157
 158        if (counter >= FW_8821AE_POLLING_TIMEOUT_COUNT) {
 159                RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
 160                         "chksum report faill ! REG_MCUFWDL:0x%08x .\n",
 161                          value32);
 162                goto exit;
 163        }
 164
 165        RT_TRACE(rtlpriv, COMP_FW, DBG_EMERG,
 166                 "Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32);
 167
 168        value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
 169        value32 |= MCUFWDL_RDY;
 170        value32 &= ~WINTINI_RDY;
 171        rtl_write_dword(rtlpriv, REG_MCUFWDL, value32);
 172
 173        rtl8821ae_firmware_selfreset(hw);
 174
 175        counter = 0;
 176        do {
 177                value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
 178                if (value32 & WINTINI_RDY) {
 179                        RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD,
 180                                 "Polling FW ready success!! REG_MCUFWDL:0x%08x .\n",
 181                                  value32);
 182                        err = 0;
 183                        goto exit;
 184                }
 185
 186                udelay(FW_8821AE_POLLING_DELAY);
 187        } while (counter++ < FW_8821AE_POLLING_TIMEOUT_COUNT);
 188
 189        RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
 190                 "Polling FW ready fail!! REG_MCUFWDL:0x%08x .\n",
 191                 value32);
 192
 193exit:
 194        return err;
 195}
 196
 197static void _rtl8821ae_wait_for_h2c_cmd_finish(struct rtl_priv *rtlpriv)
 198{
 199        u8 val;
 200        u16 count = 0;
 201
 202        do {
 203                val = rtl_read_byte(rtlpriv, REG_HMETFR);
 204                mdelay(1);
 205                count++;
 206        } while ((val & 0x0F) && (count < 1000));
 207}
 208
 209int rtl8821ae_download_fw(struct ieee80211_hw *hw, bool buse_wake_on_wlan_fw)
 210{
 211        struct rtl_priv *rtlpriv = rtl_priv(hw);
 212        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 213        struct rtlwifi_firmware_header *pfwheader;
 214        u8 *pfwdata;
 215        u32 fwsize;
 216        int err;
 217        bool support_remote_wakeup;
 218        enum version_8821ae version = rtlhal->version;
 219
 220        rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN,
 221                                      (u8 *)(&support_remote_wakeup));
 222
 223        if (support_remote_wakeup)
 224                _rtl8821ae_wait_for_h2c_cmd_finish(rtlpriv);
 225
 226        if (buse_wake_on_wlan_fw) {
 227                if (!rtlhal->wowlan_firmware)
 228                        return 1;
 229
 230                pfwheader =
 231                  (struct rtlwifi_firmware_header *)rtlhal->wowlan_firmware;
 232                rtlhal->fw_version = le16_to_cpu(pfwheader->version);
 233                rtlhal->fw_subversion = pfwheader->subversion;
 234                pfwdata = (u8 *)rtlhal->wowlan_firmware;
 235                fwsize = rtlhal->wowlan_fwsize;
 236        } else {
 237                if (!rtlhal->pfirmware)
 238                        return 1;
 239
 240                pfwheader =
 241                  (struct rtlwifi_firmware_header *)rtlhal->pfirmware;
 242                rtlhal->fw_version = le16_to_cpu(pfwheader->version);
 243                rtlhal->fw_subversion = pfwheader->subversion;
 244                pfwdata = (u8 *)rtlhal->pfirmware;
 245                fwsize = rtlhal->fwsize;
 246        }
 247
 248        RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
 249                 "%s Firmware SIZE %d\n",
 250                 buse_wake_on_wlan_fw ? "Wowlan" : "Normal", fwsize);
 251
 252        if (IS_FW_HEADER_EXIST_8812(pfwheader) ||
 253            IS_FW_HEADER_EXIST_8821(pfwheader)) {
 254                RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
 255                         "Firmware Version(%d), Signature(%#x)\n",
 256                         pfwheader->version, pfwheader->signature);
 257
 258                pfwdata = pfwdata + sizeof(struct rtlwifi_firmware_header);
 259                fwsize = fwsize - sizeof(struct rtlwifi_firmware_header);
 260        }
 261
 262        if (rtlhal->mac_func_enable) {
 263                if (rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) {
 264                        rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00);
 265                        rtl8821ae_firmware_selfreset(hw);
 266                }
 267        }
 268        _rtl8821ae_enable_fw_download(hw, true);
 269        _rtl8821ae_write_fw(hw, version, pfwdata, fwsize);
 270        _rtl8821ae_enable_fw_download(hw, false);
 271
 272        err = _rtl8821ae_fw_free_to_go(hw);
 273        if (err) {
 274                RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
 275                         "Firmware is not ready to run!\n");
 276        } else {
 277                RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD,
 278                         "Firmware is ready to run!\n");
 279        }
 280
 281        return 0;
 282}
 283
 284#if (USE_SPECIFIC_FW_TO_SUPPORT_WOWLAN == 1)
 285void rtl8821ae_set_fw_related_for_wowlan(struct ieee80211_hw *hw,
 286                                         bool used_wowlan_fw)
 287{
 288        struct rtl_priv *rtlpriv = rtl_priv(hw);
 289        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 290        struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 291        /* 1. Before WoWLAN or After WOWLAN we need to re-download Fw. */
 292        if (rtl8821ae_download_fw(hw, used_wowlan_fw)) {
 293                RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
 294                         "Re-Download Firmware failed!!\n");
 295                rtlhal->fw_ready = false;
 296                return;
 297        }
 298        RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
 299                 "Re-Download Firmware Success !!\n");
 300        rtlhal->fw_ready = true;
 301
 302        /* 2. Re-Init the variables about Fw related setting. */
 303        ppsc->fw_current_inpsmode = false;
 304        rtlhal->fw_ps_state = FW_PS_STATE_ALL_ON_8821AE;
 305        rtlhal->fw_clk_change_in_progress = false;
 306        rtlhal->allow_sw_to_change_hwclc = false;
 307        rtlhal->last_hmeboxnum = 0;
 308}
 309#endif
 310
 311static bool _rtl8821ae_check_fw_read_last_h2c(struct ieee80211_hw *hw,
 312                                              u8 boxnum)
 313{
 314        struct rtl_priv *rtlpriv = rtl_priv(hw);
 315        u8 val_hmetfr;
 316        bool result = false;
 317
 318        val_hmetfr = rtl_read_byte(rtlpriv, REG_HMETFR);
 319        if (((val_hmetfr >> boxnum) & BIT(0)) == 0)
 320                result = true;
 321        return result;
 322}
 323
 324static void _rtl8821ae_fill_h2c_command(struct ieee80211_hw *hw,
 325                                        u8 element_id, u32 cmd_len,
 326                                        u8 *cmdbuffer)
 327{
 328        struct rtl_priv *rtlpriv = rtl_priv(hw);
 329        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 330        u8 boxnum = 0;
 331        u16 box_reg = 0, box_extreg = 0;
 332        u8 u1b_tmp = 0;
 333        bool isfw_read = false;
 334        u8 buf_index = 0;
 335        bool bwrite_sucess = false;
 336        u8 wait_h2c_limmit = 100;
 337        /*u8 wait_writeh2c_limmit = 100;*/
 338        u8 boxcontent[4], boxextcontent[4];
 339        u32 h2c_waitcounter = 0;
 340        unsigned long flag = 0;
 341        u8 idx = 0;
 342
 343        RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n");
 344
 345        while (true) {
 346                spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
 347                if (rtlhal->h2c_setinprogress) {
 348                        RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
 349                                 "H2C set in progress! Wait to set..element_id(%d).\n",
 350                                 element_id);
 351
 352                        while (rtlhal->h2c_setinprogress) {
 353                                spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock,
 354                                                       flag);
 355                                h2c_waitcounter++;
 356                                RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
 357                                         "Wait 100 us (%d times)...\n",
 358                                          h2c_waitcounter);
 359                                udelay(100);
 360
 361                                if (h2c_waitcounter > 1000)
 362                                        return;
 363                                spin_lock_irqsave(&rtlpriv->locks.h2c_lock,
 364                                                  flag);
 365                        }
 366                        spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
 367                } else {
 368                        rtlhal->h2c_setinprogress = true;
 369                        spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
 370                        break;
 371                }
 372        }
 373
 374        while (!bwrite_sucess) {
 375                boxnum = rtlhal->last_hmeboxnum;
 376                switch (boxnum) {
 377                case 0:
 378                        box_reg = REG_HMEBOX_0;
 379                        box_extreg = REG_HMEBOX_EXT_0;
 380                        break;
 381                case 1:
 382                        box_reg = REG_HMEBOX_1;
 383                        box_extreg = REG_HMEBOX_EXT_1;
 384                        break;
 385                case 2:
 386                        box_reg = REG_HMEBOX_2;
 387                        box_extreg = REG_HMEBOX_EXT_2;
 388                        break;
 389                case 3:
 390                        box_reg = REG_HMEBOX_3;
 391                        box_extreg = REG_HMEBOX_EXT_3;
 392                        break;
 393                default:
 394                        RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
 395                                 "switch case not process\n");
 396                        break;
 397                }
 398
 399                isfw_read = false;
 400                u1b_tmp = rtl_read_byte(rtlpriv, REG_CR);
 401
 402                if (u1b_tmp != 0xEA) {
 403                        isfw_read = true;
 404                } else {
 405                        if (rtl_read_byte(rtlpriv, REG_TXDMA_STATUS) == 0xEA ||
 406                            rtl_read_byte(rtlpriv, REG_TXPKT_EMPTY) == 0xEA)
 407                                rtl_write_byte(rtlpriv, REG_SYS_CFG1 + 3, 0xFF);
 408                }
 409
 410                if (isfw_read) {
 411                        wait_h2c_limmit = 100;
 412                        isfw_read =
 413                          _rtl8821ae_check_fw_read_last_h2c(hw, boxnum);
 414                        while (!isfw_read) {
 415                                /*wait until Fw read*/
 416                                wait_h2c_limmit--;
 417                                if (wait_h2c_limmit == 0) {
 418                                        RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
 419                                                 "Waiting too long for FW read clear HMEBox(%d)!\n",
 420                                                 boxnum);
 421                                        break;
 422                                }
 423
 424                                udelay(10);
 425
 426                                isfw_read =
 427                                  _rtl8821ae_check_fw_read_last_h2c(hw, boxnum);
 428                                u1b_tmp = rtl_read_byte(rtlpriv, 0x130);
 429                                RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
 430                                         "Waiting for FW read clear HMEBox(%d)!!! 0x130 = %2x\n",
 431                                         boxnum, u1b_tmp);
 432                        }
 433                }
 434
 435                if (!isfw_read) {
 436                        RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
 437                                 "Write H2C register BOX[%d] fail!!!!! Fw do not read.\n",
 438                                 boxnum);
 439                        break;
 440                }
 441
 442                memset(boxcontent, 0, sizeof(boxcontent));
 443                memset(boxextcontent, 0, sizeof(boxextcontent));
 444                boxcontent[0] = element_id;
 445                RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
 446                         "Write element_id box_reg(%4x) = %2x\n",
 447                         box_reg, element_id);
 448
 449                switch (cmd_len) {
 450                case 1:
 451                case 2:
 452                case 3:
 453                        /*boxcontent[0] &= ~(BIT(7));*/
 454                        memcpy((u8 *)(boxcontent) + 1,
 455                               cmdbuffer + buf_index, cmd_len);
 456
 457                        for (idx = 0; idx < 4; idx++) {
 458                                rtl_write_byte(rtlpriv, box_reg + idx,
 459                                               boxcontent[idx]);
 460                        }
 461                        break;
 462                case 4:
 463                case 5:
 464                case 6:
 465                case 7:
 466                        /*boxcontent[0] |= (BIT(7));*/
 467                        memcpy((u8 *)(boxextcontent),
 468                               cmdbuffer + buf_index+3, cmd_len-3);
 469                        memcpy((u8 *)(boxcontent) + 1,
 470                               cmdbuffer + buf_index, 3);
 471
 472                        for (idx = 0; idx < 4; idx++) {
 473                                rtl_write_byte(rtlpriv, box_extreg + idx,
 474                                               boxextcontent[idx]);
 475                        }
 476
 477                        for (idx = 0; idx < 4; idx++) {
 478                                rtl_write_byte(rtlpriv, box_reg + idx,
 479                                               boxcontent[idx]);
 480                        }
 481                        break;
 482                default:
 483                        RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
 484                                 "switch case not process\n");
 485                        break;
 486                }
 487
 488                bwrite_sucess = true;
 489
 490                rtlhal->last_hmeboxnum = boxnum + 1;
 491                if (rtlhal->last_hmeboxnum == 4)
 492                        rtlhal->last_hmeboxnum = 0;
 493
 494                RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
 495                         "pHalData->last_hmeboxnum  = %d\n",
 496                          rtlhal->last_hmeboxnum);
 497        }
 498
 499        spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
 500        rtlhal->h2c_setinprogress = false;
 501        spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
 502
 503        RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n");
 504}
 505
 506void rtl8821ae_fill_h2c_cmd(struct ieee80211_hw *hw,
 507                            u8 element_id, u32 cmd_len, u8 *cmdbuffer)
 508{
 509        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 510        u32 tmp_cmdbuf[2];
 511
 512        if (!rtlhal->fw_ready) {
 513                RT_ASSERT(false,
 514                          "return H2C cmd because of Fw download fail!!!\n");
 515                return;
 516        }
 517
 518        memset(tmp_cmdbuf, 0, 8);
 519        memcpy(tmp_cmdbuf, cmdbuffer, cmd_len);
 520        _rtl8821ae_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf);
 521}
 522
 523void rtl8821ae_firmware_selfreset(struct ieee80211_hw *hw)
 524{
 525        struct rtl_priv *rtlpriv = rtl_priv(hw);
 526        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 527        u8 u1b_tmp;
 528
 529        if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) {
 530                u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL+1);
 531                rtl_write_byte(rtlpriv, REG_RSV_CTRL+1, (u1b_tmp & (~BIT(3))));
 532        } else {
 533                u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL+1);
 534                rtl_write_byte(rtlpriv, REG_RSV_CTRL+1, (u1b_tmp & (~BIT(0))));
 535        }
 536
 537        u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN+1);
 538        rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN+1, (u1b_tmp & (~BIT(2))));
 539        udelay(50);
 540
 541        if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) {
 542                u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL+1);
 543                rtl_write_byte(rtlpriv, REG_RSV_CTRL+1, (u1b_tmp | BIT(3)));
 544        } else {
 545                u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL+1);
 546                rtl_write_byte(rtlpriv, REG_RSV_CTRL+1, (u1b_tmp | BIT(0)));
 547        }
 548
 549        u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN+1);
 550        rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN+1, (u1b_tmp | BIT(2)));
 551
 552        RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
 553                 "_8051Reset8812ae(): 8051 reset success .\n");
 554}
 555
 556void rtl8821ae_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)
 557{
 558        struct rtl_priv *rtlpriv = rtl_priv(hw);
 559        u8 u1_h2c_set_pwrmode[H2C_8821AE_PWEMODE_LENGTH] = { 0 };
 560        struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 561        u8 rlbm, power_state = 0;
 562
 563        RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode);
 564
 565        SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, ((mode) ? 1 : 0));
 566        rlbm = 0;/*YJ,temp,120316. FW now not support RLBM=2.*/
 567        SET_H2CCMD_PWRMODE_PARM_RLBM(u1_h2c_set_pwrmode, rlbm);
 568        SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode,
 569                                         (rtlpriv->mac80211.p2p) ?
 570                                         ppsc->smart_ps : 1);
 571        SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(u1_h2c_set_pwrmode,
 572                                               ppsc->reg_max_lps_awakeintvl);
 573        SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(u1_h2c_set_pwrmode, 0);
 574        if (mode == FW_PS_ACTIVE_MODE)
 575                power_state |= FW_PWR_STATE_ACTIVE;
 576        else
 577                power_state |= FW_PWR_STATE_RF_OFF;
 578
 579        SET_H2CCMD_PWRMODE_PARM_PWR_STATE(u1_h2c_set_pwrmode, power_state);
 580
 581        RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
 582                      "rtl92c_set_fw_pwrmode(): u1_h2c_set_pwrmode\n",
 583                      u1_h2c_set_pwrmode, H2C_8821AE_PWEMODE_LENGTH);
 584        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_SETPWRMODE,
 585                               H2C_8821AE_PWEMODE_LENGTH,
 586                               u1_h2c_set_pwrmode);
 587}
 588
 589void rtl8821ae_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw,
 590                                           u8 mstatus)
 591{
 592        u8 parm[3] = { 0, 0, 0 };
 593        /* parm[0]: bit0=0-->Disconnect, bit0=1-->Connect
 594         *          bit1=0-->update Media Status to MACID
 595         *          bit1=1-->update Media Status from MACID to MACID_End
 596         * parm[1]: MACID, if this is INFRA_STA, MacID = 0
 597         * parm[2]: MACID_End
 598         */
 599
 600        SET_H2CCMD_MSRRPT_PARM_OPMODE(parm, mstatus);
 601        SET_H2CCMD_MSRRPT_PARM_MACID_IND(parm, 0);
 602
 603        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_MSRRPT, 3, parm);
 604}
 605
 606void rtl8821ae_set_fw_ap_off_load_cmd(struct ieee80211_hw *hw,
 607                                      u8 ap_offload_enable)
 608{
 609        struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 610        u8 u1_apoffload_parm[H2C_8821AE_AP_OFFLOAD_LENGTH] = { 0 };
 611
 612        SET_H2CCMD_AP_OFFLOAD_ON(u1_apoffload_parm, ap_offload_enable);
 613        SET_H2CCMD_AP_OFFLOAD_HIDDEN(u1_apoffload_parm, mac->hiddenssid);
 614        SET_H2CCMD_AP_OFFLOAD_DENYANY(u1_apoffload_parm, 0);
 615
 616        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_AP_OFFLOAD,
 617                               H2C_8821AE_AP_OFFLOAD_LENGTH,
 618                               u1_apoffload_parm);
 619}
 620
 621void rtl8821ae_set_fw_wowlan_mode(struct ieee80211_hw *hw, bool func_en)
 622{
 623        struct rtl_priv *rtlpriv = rtl_priv(hw);
 624        struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 625        u8 fw_wowlan_info[H2C_8821AE_WOWLAN_LENGTH] = {0};
 626
 627        RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "enable(%d)\n", func_en);
 628
 629        SET_8812_H2CCMD_WOWLAN_FUNC_ENABLE(fw_wowlan_info,
 630                                           (func_en ? true : false));
 631
 632        SET_8812_H2CCMD_WOWLAN_PATTERN_MATCH_ENABLE(fw_wowlan_info,
 633                ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) ? 1 : 0));
 634        SET_8812_H2CCMD_WOWLAN_MAGIC_PKT_ENABLE(fw_wowlan_info,
 635                ((ppsc->wo_wlan_mode & WAKE_ON_MAGIC_PACKET) ? 1 : 0));
 636
 637        SET_8812_H2CCMD_WOWLAN_UNICAST_PKT_ENABLE(fw_wowlan_info, 0);
 638        SET_8812_H2CCMD_WOWLAN_ALL_PKT_DROP(fw_wowlan_info, false);
 639        SET_8812_H2CCMD_WOWLAN_GPIO_ACTIVE(fw_wowlan_info, 0);
 640        SET_8812_H2CCMD_WOWLAN_DISCONNECT_WAKE_UP(fw_wowlan_info, 1);
 641        SET_8812_H2CCMD_WOWLAN_GPIONUM(fw_wowlan_info, 0);
 642        SET_8812_H2CCMD_WOWLAN_GPIO_DURATION(fw_wowlan_info, 0);
 643
 644        RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_DMESG,
 645                      "wowlan mode: cmd 0x80: Content:\n",
 646                      fw_wowlan_info, H2C_8821AE_WOWLAN_LENGTH);
 647
 648        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_WO_WLAN,
 649                               H2C_8821AE_WOWLAN_LENGTH,
 650                               fw_wowlan_info);
 651}
 652
 653void rtl8821ae_set_fw_remote_wake_ctrl_cmd(struct ieee80211_hw *hw,
 654                                           u8 enable)
 655{
 656        struct rtl_priv *rtlpriv = rtl_priv(hw);
 657        struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 658        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 659        u8 remote_wake_ctrl_parm[H2C_8821AE_REMOTE_WAKE_CTRL_LEN] = {0};
 660
 661        RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
 662                 "enable=%d, ARP offload=%d, GTK offload=%d\n",
 663                 enable, ppsc->arp_offload_enable, ppsc->gtk_offload_enable);
 664
 665        SET_8812_H2CCMD_REMOTE_WAKECTRL_ENABLE(remote_wake_ctrl_parm, enable);
 666        SET_8812_H2CCMD_REMOTE_WAKE_CTRL_ARP_OFFLOAD_EN(remote_wake_ctrl_parm,
 667                                        (ppsc->arp_offload_enable ? 1 : 0));
 668        SET_8812_H2CCMD_REMOTE_WAKE_CTRL_GTK_OFFLOAD_EN(remote_wake_ctrl_parm,
 669                                        (ppsc->gtk_offload_enable ? 1 : 0));
 670        SET_8812_H2CCMD_REMOTE_WAKE_CTRL_REALWOWV2_EN(remote_wake_ctrl_parm,
 671                                        (rtlhal->real_wow_v2_enable ? 1 : 0));
 672
 673        RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
 674                      "remote_wake_ctrl: cmd 0x4: Content:\n",
 675                      remote_wake_ctrl_parm, H2C_8821AE_REMOTE_WAKE_CTRL_LEN);
 676
 677        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_REMOTE_WAKE_CTRL,
 678                               H2C_8821AE_REMOTE_WAKE_CTRL_LEN,
 679                               remote_wake_ctrl_parm);
 680}
 681
 682void rtl8821ae_set_fw_keep_alive_cmd(struct ieee80211_hw *hw,
 683                                     bool func_en)
 684{
 685        struct rtl_priv *rtlpriv = rtl_priv(hw);
 686        u8 keep_alive_info[H2C_8821AE_KEEP_ALIVE_CTRL_LENGTH] = {0};
 687
 688        RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "Enable(%d)\n", func_en);
 689
 690        SET_8812_H2CCMD_KEEP_ALIVE_ENABLE(keep_alive_info, func_en);
 691        /* 1: the period is controled by driver, 0: by Fw default */
 692        SET_8812_H2CCMD_KEEP_ALIVE_ACCPEPT_USER_DEFINED(keep_alive_info, 1);
 693        SET_8812_H2CCMD_KEEP_ALIVE_PERIOD(keep_alive_info, 10); /* 10 sec */
 694
 695        RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
 696                      "keep alive: cmd 0x3: Content:\n",
 697                      keep_alive_info, H2C_8821AE_KEEP_ALIVE_CTRL);
 698        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_KEEP_ALIVE_CTRL,
 699                               H2C_8821AE_KEEP_ALIVE_CTRL_LENGTH,
 700                               keep_alive_info);
 701}
 702
 703void rtl8821ae_set_fw_disconnect_decision_ctrl_cmd(struct ieee80211_hw *hw,
 704                                                   bool enabled)
 705{
 706        struct rtl_priv *rtlpriv = rtl_priv(hw);
 707        u8 parm[H2C_8821AE_DISCONNECT_DECISION_CTRL_LEN] = {0};
 708
 709        SET_8812_H2CCMD_DISCONNECT_DECISION_CTRL_ENABLE(parm, enabled);
 710        SET_8812_H2CCMD_DISCONNECT_DECISION_CTRL_USER_SETTING(parm, 1);
 711        SET_8812_H2CCMD_DISCONNECT_DECISION_CTRL_CHECK_PERIOD(parm, 30);
 712        SET_8812_H2CCMD_DISCONNECT_DECISION_CTRL_TRYPKT_NUM(parm, 3);
 713
 714        RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
 715                      "disconnect_decision_ctrl: cmd 0x4: Content:\n",
 716                      parm, H2C_8821AE_DISCONNECT_DECISION_CTRL_LEN);
 717        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_DISCONNECT_DECISION,
 718                               H2C_8821AE_DISCONNECT_DECISION_CTRL_LEN, parm);
 719}
 720
 721void rtl8821ae_set_fw_global_info_cmd(struct ieee80211_hw *hw)
 722{
 723        struct rtl_priv *rtlpriv = rtl_priv(hw);
 724        struct rtl_security *sec = &rtlpriv->sec;
 725        u8 remote_wakeup_sec_info[H2C_8821AE_AOAC_GLOBAL_INFO_LEN] = {0};
 726
 727        RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
 728                 "PairwiseEncAlgorithm=%d, GroupEncAlgorithm=%d\n",
 729                 sec->pairwise_enc_algorithm, sec->group_enc_algorithm);
 730
 731        SET_8812_H2CCMD_AOAC_GLOBAL_INFO_PAIRWISE_ENC_ALG(
 732                                                remote_wakeup_sec_info,
 733                                                sec->pairwise_enc_algorithm);
 734        SET_8812_H2CCMD_AOAC_GLOBAL_INFO_GROUP_ENC_ALG(remote_wakeup_sec_info,
 735                                                      sec->group_enc_algorithm);
 736
 737        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_AOAC_GLOBAL_INFO,
 738                               H2C_8821AE_AOAC_GLOBAL_INFO_LEN,
 739                               remote_wakeup_sec_info);
 740
 741        RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_TRACE,
 742                      "rtl8821ae_set_global_info: cmd 0x82:\n",
 743                      remote_wakeup_sec_info, H2C_8821AE_AOAC_GLOBAL_INFO_LEN);
 744}
 745
 746#define BEACON_PG               0
 747#define PSPOLL_PG               1
 748#define NULL_PG                 2
 749#define QOSNULL_PG              3
 750#define ARPRESP_PG              4
 751#define REMOTE_PG               5
 752#define GTKEXT_PG               6
 753
 754#define TOTAL_RESERVED_PKT_LEN_8812     3584
 755#define TOTAL_RESERVED_PKT_LEN_8821     1792
 756
 757static u8 reserved_page_packet_8821[TOTAL_RESERVED_PKT_LEN_8821] = {
 758        /* page 0: beacon */
 759        0x80, 0x00, 0x00, 0x00,  0xff, 0xff, 0xff, 0xff,
 760        0xff, 0xff, 0x00, 0xe0,  0x4c, 0x02, 0xe2, 0x64,
 761        0x40, 0x16, 0x9f, 0x23,  0xd4, 0x46, 0x20, 0x00,
 762        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 763        0x64, 0x00, 0x20, 0x04,  0x00, 0x06, 0x64, 0x6c,
 764        0x69, 0x6e, 0x6b, 0x31,  0x01, 0x08, 0x82, 0x84,
 765        0x8b, 0x96, 0x0c, 0x18,  0x30, 0x48, 0x03, 0x01,
 766        0x0b, 0x06, 0x02, 0x00,  0x00, 0x2a, 0x01, 0x8b,
 767        0x32, 0x04, 0x12, 0x24,  0x60, 0x6c, 0x00, 0x00,
 768        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 769        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 770        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 771        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 772        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 773        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 774        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 775        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 776        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 777        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 778        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 779        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 780        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 781        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 782        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 783        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 784        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 785        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 786        0x10, 0x00, 0x28, 0x8c,  0x00, 0x12, 0x00, 0x00,
 787        0x00, 0x00, 0x00, 0x00,  0x00, 0x81, 0x00, 0x00,
 788        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 789        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 790        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 791        /* page 1: ps-poll */
 792        0xa4, 0x10, 0x01, 0xc0,  0x40, 0x16, 0x9f, 0x23,
 793        0xd4, 0x46, 0x00, 0xe0,  0x4c, 0x02, 0xe2, 0x64,
 794        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 795        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 796        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 797        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 798        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 799        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 800        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 801        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 802        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 803        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 804        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 805        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 806        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 807        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 808        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 809        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 810        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 811        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 812        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 813        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 814        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 815        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 816        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 817        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 818        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 819        0x18, 0x00, 0x28, 0x8c,  0x00, 0x12, 0x00, 0x00,
 820        0x00, 0x00, 0x00, 0x00,  0x00, 0x01, 0x00, 0x00,
 821        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 822        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 823        0x00, 0x80, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 824        /* page 2: null data */
 825        0x48, 0x01, 0x00, 0x00,  0x40, 0x16, 0x9f, 0x23,
 826        0xd4, 0x46, 0x00, 0xe0,  0x4c, 0x02, 0xe2, 0x64,
 827        0x40, 0x16, 0x9f, 0x23,  0xd4, 0x46, 0x00, 0x00,
 828        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 829        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 830        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 831        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 832        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 833        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 834        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 835        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 836        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 837        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 838        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 839        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 840        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 841        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 842        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 843        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 844        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 845        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 846        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 847        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 848        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 849        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 850        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 851        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 852        0x1A, 0x00, 0x28, 0x8C,  0x00, 0x12, 0x00, 0x00,
 853        0x00, 0x00, 0x00, 0x00,  0x00, 0x01, 0x00, 0x00,
 854        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 855        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 856        0x00, 0x80, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 857        /* page 3: qos null data */
 858        0xC8, 0x01, 0x00, 0x00,  0x84, 0xC9, 0xB2, 0xA7,
 859        0xB3, 0x6E, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
 860        0x84, 0xC9, 0xB2, 0xA7,  0xB3, 0x6E, 0x00, 0x00,
 861        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 862        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 863        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 864        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 865        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 866        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 867        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 868        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 869        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 870        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 871        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 872        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 873        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 874        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 875        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 876        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 877        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 878        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 879        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 880        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 881        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 882        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 883        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 884        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 885        0x3C, 0x00, 0x28, 0x8C,  0x00, 0x12, 0x00, 0x00,
 886        0x00, 0x00, 0x00, 0x00,  0x00, 0x01, 0x00, 0x00,
 887        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 888        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 889        0x00, 0x80, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 890        /* page 4~6 is for wowlan */
 891        /* page 4: ARP resp */
 892        0x08, 0x01, 0x00, 0x00,  0x84, 0xC9, 0xB2, 0xA7,
 893        0xB3, 0x6E, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
 894        0x84, 0xC9, 0xB2, 0xA7,  0xB3, 0x6E, 0x00, 0x00,
 895        0xAA, 0xAA, 0x03, 0x00,  0x00, 0x00, 0x08, 0x06,
 896        0x00, 0x01, 0x08, 0x00,  0x06, 0x04, 0x00, 0x02,
 897        0x00, 0xE0, 0x4C, 0x02,  0x51, 0x02, 0x00, 0x00,
 898        0x00, 0x00, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
 899        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 900        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 901        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 902        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 903        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 904        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 905        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 906        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 907        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 908        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 909        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 910        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 911        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 912        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 913        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 914        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 915        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 916        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 917        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 918        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 919        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 920        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 921        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 922        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 923        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 924        /* page 5: H2C_REMOTE_WAKE_CTRL_INFO */
 925        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 926        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 927        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 928        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 929        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 930        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 931        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 932        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 933        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 934        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 935        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 936        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 937        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 938        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 939        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 940        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 941        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 942        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 943        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 944        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 945        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 946        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 947        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 948        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 949        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 950        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 951        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 952        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 953        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 954        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 955        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 956        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 957        /* page 6: Rsvd GTK extend memory (zero memory) */
 958        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 959        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 960        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 961        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 962        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 963        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 964        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 965        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 966        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 967        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 968        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 969        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 970        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 971        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 972        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 973        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 974        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 975        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 976        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 977        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 978        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 979        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 980        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 981        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 982        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 983        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 984        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 985        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 986        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 987        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 988        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 989        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 990};
 991
 992static u8 reserved_page_packet_8812[TOTAL_RESERVED_PKT_LEN_8812] = {
 993        /* page 0: beacon */
 994        0x80, 0x00, 0x00, 0x00,  0xFF, 0xFF, 0xFF, 0xFF,
 995        0xFF, 0xFF, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
 996        0x84, 0xC9, 0xB2, 0xA7,  0xB3, 0x6E, 0x60, 0x00,
 997        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
 998        0x64, 0x00, 0x20, 0x04,  0x00, 0x03, 0x32, 0x31,
 999        0x35, 0x01, 0x08, 0x82,  0x84, 0x8B, 0x96, 0x0C,
1000        0x12, 0x18, 0x24, 0x03,  0x01, 0x01, 0x06, 0x02,
1001        0x00, 0x00, 0x2A, 0x01,  0x02, 0x32, 0x04, 0x30,
1002        0x48, 0x60, 0x6C, 0x2D,  0x1A, 0xED, 0x09, 0x03,
1003        0xFF, 0xFF, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1004        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1005        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x3D,
1006        0x00, 0xDD, 0x07, 0x00,  0xE0, 0x4C, 0x02, 0x02,
1007        0x08, 0x04, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1008        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1009        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1010        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1011        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1012        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1013        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1014        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1015        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1016        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1017        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1018        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1019        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1020        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1021        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1022        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1023        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1024        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1025        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1026        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1027        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1028        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1029        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1030        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1031        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1032        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1033        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1034        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1035        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1036        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1037        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1038        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1039        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1040        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1041        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1042        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1043        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1044        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1045        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1046        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1047        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1048        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1049        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1050        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1051        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1052        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1053        0x10, 0x00, 0x28, 0x8C,  0x00, 0x12, 0x00, 0x00,
1054        0x00, 0x00, 0x00, 0x00,  0x00, 0x81, 0x00, 0x00,
1055        0x04, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1056        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1057        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1058        /* page 1: ps-poll */
1059        0xA4, 0x10, 0x09, 0xC0,  0x84, 0xC9, 0xB2, 0xA7,
1060        0xB3, 0x6E, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
1061        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1062        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1063        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1064        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1065        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1066        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1067        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1068        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1069        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1070        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1071        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1072        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1073        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1074        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1075        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1076        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1077        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1078        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1079        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1080        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1081        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1082        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1083        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1084        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1085        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1086        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1087        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1088        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1089        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1090        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1091        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1092        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1093        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1094        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1095        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1096        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1097        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1098        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1099        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1100        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1101        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1102        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1103        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1104        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1105        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1106        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1107        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1108        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1109        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1110        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1111        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1112        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1113        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1114        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1115        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1116        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1117        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1118        0x18, 0x00, 0x28, 0x8C,  0x00, 0x12, 0x00, 0x00,
1119        0x00, 0x00, 0x00, 0x00,  0x00, 0x01, 0x00, 0x00,
1120        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1121        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1122        0x00, 0x80, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1123        /* page 2: null data */
1124        0x48, 0x01, 0x00, 0x00,  0x84, 0xC9, 0xB2, 0xA7,
1125        0xB3, 0x6E, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
1126        0x84, 0xC9, 0xB2, 0xA7,  0xB3, 0x6E, 0x00, 0x00,
1127        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1128        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1129        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1130        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1131        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1132        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1133        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1134        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1135        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1136        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1137        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1138        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1139        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1140        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1141        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1142        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1143        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1144        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1145        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1146        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1147        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1148        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1149        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1150        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1151        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1152        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1153        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1154        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1155        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1156        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1157        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1158        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1159        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1160        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1161        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1162        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1163        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1164        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1165        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1166        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1167        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1168        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1169        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1170        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1171        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1172        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1173        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1174        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1175        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1176        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1177        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1178        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1179        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1180        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1181        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1182        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1183        0x1A, 0x00, 0x28, 0x8C,  0x00, 0x12, 0x00, 0x00,
1184        0x00, 0x00, 0x00, 0x00,  0x00, 0x01, 0x00, 0x00,
1185        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1186        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1187        0x00, 0x80, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1188        /* page 3: Qos null data */
1189        0xC8, 0x01, 0x00, 0x00,  0x84, 0xC9, 0xB2, 0xA7,
1190        0xB3, 0x6E, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
1191        0x84, 0xC9, 0xB2, 0xA7,  0xB3, 0x6E, 0x00, 0x00,
1192        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1193        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1194        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1195        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1196        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1197        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1198        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1199        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1200        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1201        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1202        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1203        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1204        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1205        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1206        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1207        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1208        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1209        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1210        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1211        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1212        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1213        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1214        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1215        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1216        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1217        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1218        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1219        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1220        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1221        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1222        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1223        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1224        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1225        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1226        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1227        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1228        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1229        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1230        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1231        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1232        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1233        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1234        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1235        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1236        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1237        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1238        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1239        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1240        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1241        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1242        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1243        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1244        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1245        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1246        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1247        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1248        0x3C, 0x00, 0x28, 0x8C,  0x00, 0x12, 0x00, 0x00,
1249        0x00, 0x00, 0x00, 0x00,  0x00, 0x01, 0x00, 0x00,
1250        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1251        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1252        0x00, 0x80, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1253        /* page 4~6 is for wowlan */
1254        /* page 4: ARP resp */
1255        0x08, 0x01, 0x00, 0x00,  0x84, 0xC9, 0xB2, 0xA7,
1256        0xB3, 0x6E, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
1257        0x84, 0xC9, 0xB2, 0xA7,  0xB3, 0x6E, 0x00, 0x00,
1258        0xAA, 0xAA, 0x03, 0x00,  0x00, 0x00, 0x08, 0x06,
1259        0x00, 0x01, 0x08, 0x00,  0x06, 0x04, 0x00, 0x02,
1260        0x00, 0xE0, 0x4C, 0x02,  0x51, 0x02, 0x00, 0x00,
1261        0x00, 0x00, 0x00, 0xE0,  0x4C, 0x02, 0x51, 0x02,
1262        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1263        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1264        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1265        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1266        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1267        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1268        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1269        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1270        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1271        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1272        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1273        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1274        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1275        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1276        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1277        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1278        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1279        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1280        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1281        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1282        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1283        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1284        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1285        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1286        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1287        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1288        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1289        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1290        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1291        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1292        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1293        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1294        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1295        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1296        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1297        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1298        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1299        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1300        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1301        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1302        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1303        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1304        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1305        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1306        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1307        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1308        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1309        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1310        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1311        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1312        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1313        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1314        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1315        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1316        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1317        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1318        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1319        /* page 5: H2C_REMOTE_WAKE_CTRL_INFO */
1320        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1321        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1322        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1323        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1324        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1325        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1326        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1327        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1328        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1329        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1330        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1331        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1332        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1333        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1334        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1335        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1336        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1337        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1338        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1339        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1340        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1341        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1342        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1343        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1344        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1345        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1346        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1347        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1348        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1349        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1350        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1351        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1352        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1353        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1354        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1355        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1356        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1357        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1358        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1359        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1360        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1361        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1362        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1363        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1364        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1365        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1366        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1367        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1368        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1369        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1370        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1371        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1372        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1373        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1374        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1375        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1376        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1377        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1378        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1379        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1380        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1381        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1382        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1383        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1384        /* page 6: Rsvd GTK extend memory (zero memory) */
1385        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1386        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1387        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1388        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1389        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1390        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1391        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1392        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1393        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1394        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1395        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1396        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1397        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1398        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1399        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1400        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1401        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1402        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1403        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1404        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1405        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1406        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1407        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1408        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1409        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1410        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1411        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1412        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1413        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1414        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1415        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1416        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1417        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1418        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1419        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1420        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1421        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1422        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1423        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1424        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1425        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1426        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1427        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1428        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1429        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1430        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1431        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1432        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1433        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1434        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1435        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1436        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1437        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1438        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1439        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1440        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1441        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1442        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1443        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1444        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1445        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1446        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1447        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1448        0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
1449};
1450
1451void rtl8812ae_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
1452                                  bool b_dl_finished, bool dl_whole_packets)
1453{
1454        struct rtl_priv *rtlpriv = rtl_priv(hw);
1455        struct rtl_mac *mac = rtl_mac(rtlpriv);
1456        struct sk_buff *skb = NULL;
1457        u32 totalpacketlen;
1458        bool rtstatus;
1459        u8 u1RsvdPageLoc[5] = { 0 };
1460        u8 u1RsvdPageLoc2[7] = { 0 };
1461        bool b_dlok = false;
1462        u8 *beacon;
1463        u8 *p_pspoll;
1464        u8 *nullfunc;
1465        u8 *qosnull;
1466        u8 *arpresp;
1467
1468        /*---------------------------------------------------------
1469         *                      (1) beacon
1470         *---------------------------------------------------------
1471         */
1472        beacon = &reserved_page_packet_8812[BEACON_PG * 512];
1473        SET_80211_HDR_ADDRESS2(beacon, mac->mac_addr);
1474        SET_80211_HDR_ADDRESS3(beacon, mac->bssid);
1475
1476        if (b_dl_finished) {
1477                totalpacketlen = 512 - 40;
1478                goto out;
1479        }
1480        /*-------------------------------------------------------
1481         *                      (2) ps-poll
1482         *--------------------------------------------------------
1483         */
1484        p_pspoll = &reserved_page_packet_8812[PSPOLL_PG * 512];
1485        SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
1486        SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
1487        SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
1488
1489        SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1RsvdPageLoc, PSPOLL_PG);
1490
1491        /*--------------------------------------------------------
1492         *                      (3) null data
1493         *---------------------------------------------------------
1494         */
1495        nullfunc = &reserved_page_packet_8812[NULL_PG * 512];
1496        SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid);
1497        SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr);
1498        SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid);
1499
1500        SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1RsvdPageLoc, NULL_PG);
1501
1502        /*---------------------------------------------------------
1503         *                      (4) Qos null data
1504         *----------------------------------------------------------
1505         */
1506        qosnull = &reserved_page_packet_8812[QOSNULL_PG * 512];
1507        SET_80211_HDR_ADDRESS1(qosnull, mac->bssid);
1508        SET_80211_HDR_ADDRESS2(qosnull, mac->mac_addr);
1509        SET_80211_HDR_ADDRESS3(qosnull, mac->bssid);
1510
1511        SET_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(u1RsvdPageLoc, QOSNULL_PG);
1512
1513        if (!dl_whole_packets) {
1514                totalpacketlen = 512 * (QOSNULL_PG + 1) - 40;
1515                goto out;
1516        }
1517        /*---------------------------------------------------------
1518         *                      (5) ARP Resp
1519         *----------------------------------------------------------
1520         */
1521        arpresp = &reserved_page_packet_8812[ARPRESP_PG * 512];
1522        SET_80211_HDR_ADDRESS1(arpresp, mac->bssid);
1523        SET_80211_HDR_ADDRESS2(arpresp, mac->mac_addr);
1524        SET_80211_HDR_ADDRESS3(arpresp, mac->bssid);
1525
1526        SET_8821AE_H2CCMD_AOAC_RSVDPAGE_LOC_ARP_RSP(u1RsvdPageLoc2, ARPRESP_PG);
1527
1528        /*---------------------------------------------------------
1529         *                      (6) Remote Wake Ctrl
1530         *----------------------------------------------------------
1531         */
1532        SET_8821AE_H2CCMD_AOAC_RSVDPAGE_LOC_REMOTE_WAKE_CTRL_INFO(u1RsvdPageLoc2,
1533                                                                REMOTE_PG);
1534
1535        /*---------------------------------------------------------
1536         *                      (7) GTK Ext Memory
1537         *----------------------------------------------------------
1538         */
1539        SET_8821AE_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_EXT_MEM(u1RsvdPageLoc2, GTKEXT_PG);
1540
1541        totalpacketlen = TOTAL_RESERVED_PKT_LEN_8812 - 40;
1542
1543out:
1544        RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
1545                      "rtl8812ae_set_fw_rsvdpagepkt(): packet data\n",
1546                      &reserved_page_packet_8812[0], totalpacketlen);
1547
1548        skb = dev_alloc_skb(totalpacketlen);
1549        memcpy((u8 *)skb_put(skb, totalpacketlen),
1550               &reserved_page_packet_8812, totalpacketlen);
1551
1552        rtstatus = rtl_cmd_send_packet(hw, skb);
1553
1554        if (rtstatus)
1555                b_dlok = true;
1556
1557        if (!b_dl_finished && b_dlok) {
1558                RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
1559                              "H2C_RSVDPAGE:\n", u1RsvdPageLoc, 5);
1560                rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_RSVDPAGE,
1561                                       sizeof(u1RsvdPageLoc), u1RsvdPageLoc);
1562                if (dl_whole_packets) {
1563                        RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
1564                                      "wowlan H2C_RSVDPAGE:\n", u1RsvdPageLoc2, 7);
1565                        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_AOAC_RSVDPAGE,
1566                                               sizeof(u1RsvdPageLoc2), u1RsvdPageLoc2);
1567                }
1568        }
1569
1570        if (!b_dlok)
1571                RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1572                         "Set RSVD page location to Fw FAIL!!!!!!.\n");
1573}
1574
1575void rtl8821ae_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
1576                                  bool b_dl_finished, bool dl_whole_packets)
1577{
1578        struct rtl_priv *rtlpriv = rtl_priv(hw);
1579        struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1580        struct sk_buff *skb = NULL;
1581        u32 totalpacketlen;
1582        bool rtstatus;
1583        u8 u1RsvdPageLoc[5] = { 0 };
1584        u8 u1RsvdPageLoc2[7] = { 0 };
1585        bool b_dlok = false;
1586        u8 *beacon;
1587        u8 *p_pspoll;
1588        u8 *nullfunc;
1589        u8 *qosnull;
1590        u8 *arpresp;
1591
1592        /*---------------------------------------------------------
1593         *                      (1) beacon
1594         *---------------------------------------------------------
1595         */
1596        beacon = &reserved_page_packet_8821[BEACON_PG * 256];
1597        SET_80211_HDR_ADDRESS2(beacon, mac->mac_addr);
1598        SET_80211_HDR_ADDRESS3(beacon, mac->bssid);
1599
1600        if (b_dl_finished) {
1601                totalpacketlen = 256 - 40;
1602                goto out;
1603        }
1604        /*-------------------------------------------------------
1605         *                      (2) ps-poll
1606         *--------------------------------------------------------
1607         */
1608        p_pspoll = &reserved_page_packet_8821[PSPOLL_PG * 256];
1609        SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
1610        SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
1611        SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
1612
1613        SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1RsvdPageLoc, PSPOLL_PG);
1614
1615        /*--------------------------------------------------------
1616         *                      (3) null data
1617         *---------------------------------------------------------i
1618         */
1619        nullfunc = &reserved_page_packet_8821[NULL_PG * 256];
1620        SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid);
1621        SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr);
1622        SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid);
1623
1624        SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1RsvdPageLoc, NULL_PG);
1625
1626        /*---------------------------------------------------------
1627         *                      (4) Qos null data
1628         *----------------------------------------------------------
1629         */
1630        qosnull = &reserved_page_packet_8821[QOSNULL_PG * 256];
1631        SET_80211_HDR_ADDRESS1(qosnull, mac->bssid);
1632        SET_80211_HDR_ADDRESS2(qosnull, mac->mac_addr);
1633        SET_80211_HDR_ADDRESS3(qosnull, mac->bssid);
1634
1635        SET_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(u1RsvdPageLoc, QOSNULL_PG);
1636
1637        if (!dl_whole_packets) {
1638                totalpacketlen = 256 * (QOSNULL_PG + 1) - 40;
1639                goto out;
1640        }
1641        /*---------------------------------------------------------
1642         *                      (5) ARP Resp
1643         *----------------------------------------------------------
1644         */
1645        arpresp = &reserved_page_packet_8821[ARPRESP_PG * 256];
1646        SET_80211_HDR_ADDRESS1(arpresp, mac->bssid);
1647        SET_80211_HDR_ADDRESS2(arpresp, mac->mac_addr);
1648        SET_80211_HDR_ADDRESS3(arpresp, mac->bssid);
1649
1650        SET_8821AE_H2CCMD_AOAC_RSVDPAGE_LOC_ARP_RSP(u1RsvdPageLoc2, ARPRESP_PG);
1651
1652        /*---------------------------------------------------------
1653         *                      (6) Remote Wake Ctrl
1654         *----------------------------------------------------------
1655         */
1656        SET_8821AE_H2CCMD_AOAC_RSVDPAGE_LOC_REMOTE_WAKE_CTRL_INFO(u1RsvdPageLoc2,
1657                                                                        REMOTE_PG);
1658
1659        /*---------------------------------------------------------
1660         *                      (7) GTK Ext Memory
1661         *----------------------------------------------------------
1662         */
1663        SET_8821AE_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_EXT_MEM(u1RsvdPageLoc2, GTKEXT_PG);
1664
1665        totalpacketlen = TOTAL_RESERVED_PKT_LEN_8821 - 40;
1666
1667out:
1668
1669        RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
1670                      "rtl8821ae_set_fw_rsvdpagepkt(): packet data\n",
1671                      &reserved_page_packet_8821[0], totalpacketlen);
1672
1673        skb = dev_alloc_skb(totalpacketlen);
1674        memcpy((u8 *)skb_put(skb, totalpacketlen),
1675               &reserved_page_packet_8821, totalpacketlen);
1676
1677        rtstatus = rtl_cmd_send_packet(hw, skb);
1678
1679        if (rtstatus)
1680                b_dlok = true;
1681
1682        if (!b_dl_finished && b_dlok) {
1683                RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1684                         "Set RSVD page location to Fw.\n");
1685                RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
1686                                "H2C_RSVDPAGE:\n", u1RsvdPageLoc, 5);
1687                rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_RSVDPAGE,
1688                                       sizeof(u1RsvdPageLoc), u1RsvdPageLoc);
1689                if (dl_whole_packets) {
1690                        RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
1691                                      "wowlan H2C_RSVDPAGE:\n",
1692                                      u1RsvdPageLoc2, 7);
1693                        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_AOAC_RSVDPAGE,
1694                                               sizeof(u1RsvdPageLoc2),
1695                                               u1RsvdPageLoc2);
1696                }
1697        }
1698
1699        if (!b_dlok) {
1700                RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1701                         "Set RSVD page location to Fw FAIL!!!!!!.\n");
1702        }
1703}
1704
1705/*Should check FW support p2p or not.*/
1706static void rtl8821ae_set_p2p_ctw_period_cmd(struct ieee80211_hw *hw, u8 ctwindow)
1707{
1708        u8 u1_ctwindow_period[1] = { ctwindow};
1709
1710        rtl8821ae_fill_h2c_cmd(hw, H2C_8821AE_P2P_PS_CTW_CMD, 1,
1711                               u1_ctwindow_period);
1712}
1713
1714void rtl8821ae_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state)
1715{
1716        struct rtl_priv *rtlpriv = rtl_priv(hw);
1717        struct rtl_ps_ctl *rtlps = rtl_psc(rtl_priv(hw));
1718        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1719        struct rtl_p2p_ps_info *p2pinfo = &rtlps->p2p_ps_info;
1720        struct p2p_ps_offload_t *p2p_ps_offload = &rtlhal->p2p_ps_offload;
1721        u8      i;
1722        u16     ctwindow;
1723        u32     start_time, tsf_low;
1724
1725        switch (p2p_ps_state) {
1726        case P2P_PS_DISABLE:
1727                RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_DISABLE\n");
1728                memset(p2p_ps_offload, 0, sizeof(*p2p_ps_offload));
1729                break;
1730        case P2P_PS_ENABLE:
1731                RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_ENABLE\n");
1732                /* update CTWindow value. */
1733                if (p2pinfo->ctwindow > 0) {
1734                        p2p_ps_offload->ctwindow_en = 1;
1735                        ctwindow = p2pinfo->ctwindow;
1736                        rtl8821ae_set_p2p_ctw_period_cmd(hw, ctwindow);
1737                }
1738
1739                /* hw only support 2 set of NoA */
1740                for (i = 0 ; i < p2pinfo->noa_num ; i++) {
1741                        /* To control the register setting for which NOA*/
1742                        rtl_write_byte(rtlpriv, 0x5cf, (i << 4));
1743                        if (i == 0)
1744                                p2p_ps_offload->noa0_en = 1;
1745                        else
1746                                p2p_ps_offload->noa1_en = 1;
1747
1748                        /* config P2P NoA Descriptor Register */
1749                        rtl_write_dword(rtlpriv, 0x5E0, p2pinfo->noa_duration[i]);
1750                        rtl_write_dword(rtlpriv, 0x5E4, p2pinfo->noa_interval[i]);
1751
1752                        /*Get Current TSF value */
1753                        tsf_low = rtl_read_dword(rtlpriv, REG_TSFTR);
1754
1755                        start_time = p2pinfo->noa_start_time[i];
1756                        if (p2pinfo->noa_count_type[i] != 1) {
1757                                while (start_time <= (tsf_low+(50*1024))) {
1758                                        start_time += p2pinfo->noa_interval[i];
1759                                        if (p2pinfo->noa_count_type[i] != 255)
1760                                                p2pinfo->noa_count_type[i]--;
1761                                }
1762                        }
1763                        rtl_write_dword(rtlpriv, 0x5E8, start_time);
1764                        rtl_write_dword(rtlpriv, 0x5EC,
1765                                        p2pinfo->noa_count_type[i]);
1766                }
1767
1768                if ((p2pinfo->opp_ps == 1) || (p2pinfo->noa_num > 0)) {
1769                        /* rst p2p circuit */
1770                        rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, BIT(4));
1771
1772                        p2p_ps_offload->offload_en = 1;
1773
1774                        if (P2P_ROLE_GO == rtlpriv->mac80211.p2p) {
1775                                p2p_ps_offload->role = 1;
1776                                p2p_ps_offload->allstasleep = 0;
1777                        } else {
1778                                p2p_ps_offload->role = 0;
1779                        }
1780
1781                        p2p_ps_offload->discovery = 0;
1782                }
1783                break;
1784        case P2P_PS_SCAN:
1785                RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_SCAN\n");
1786                p2p_ps_offload->discovery = 1;
1787                break;
1788        case P2P_PS_SCAN_DONE:
1789                RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_SCAN_DONE\n");
1790                p2p_ps_offload->discovery = 0;
1791                p2pinfo->p2p_ps_state = P2P_PS_ENABLE;
1792                break;
1793        default:
1794                break;
1795        }
1796
1797        rtl8821ae_fill_h2c_cmd(hw,
1798                        H2C_8821AE_P2P_PS_OFFLOAD, 1, (u8 *)p2p_ps_offload);
1799}
1800
1801static void rtl8821ae_c2h_ra_report_handler(struct ieee80211_hw *hw,
1802                                     u8 *cmd_buf, u8 cmd_len)
1803{
1804        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1805        u8 rate = cmd_buf[0] & 0x3F;
1806
1807        rtlhal->current_ra_rate = rtl8821ae_hw_rate_to_mrate(hw, rate);
1808
1809        rtl8821ae_dm_update_init_rate(hw, rate);
1810}
1811
1812static void _rtl8821ae_c2h_content_parsing(struct ieee80211_hw *hw,
1813                                           u8 c2h_cmd_id, u8 c2h_cmd_len,
1814                                           u8 *tmp_buf)
1815{
1816        struct rtl_priv *rtlpriv = rtl_priv(hw);
1817
1818        switch (c2h_cmd_id) {
1819        case C2H_8812_DBG:
1820                RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "[C2H], C2H_8812_DBG!!\n");
1821                break;
1822        case C2H_8812_RA_RPT:
1823                rtl8821ae_c2h_ra_report_handler(hw, tmp_buf, c2h_cmd_len);
1824                break;
1825        case C2H_8812_BT_INFO:
1826                RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD,
1827                         "[C2H], C2H_8812_BT_INFO!!\n");
1828                if (rtlpriv->cfg->ops->get_btc_status())
1829                        rtlpriv->btcoexist.btc_ops->btc_btinfo_notify(rtlpriv,
1830                                                                      tmp_buf,
1831                                                                      c2h_cmd_len);
1832                break;
1833        default:
1834                break;
1835        }
1836}
1837
1838void rtl8821ae_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer,
1839                                  u8 length)
1840{
1841        struct rtl_priv *rtlpriv = rtl_priv(hw);
1842        u8 c2h_cmd_id = 0, c2h_cmd_seq = 0, c2h_cmd_len = 0;
1843        u8 *tmp_buf = NULL;
1844
1845        c2h_cmd_id = buffer[0];
1846        c2h_cmd_seq = buffer[1];
1847        c2h_cmd_len = length - 2;
1848        tmp_buf = buffer + 2;
1849
1850        RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD,
1851                 "[C2H packet], c2hCmdId=0x%x, c2hCmdSeq=0x%x, c2hCmdLen=%d\n",
1852                 c2h_cmd_id, c2h_cmd_seq, c2h_cmd_len);
1853
1854        RT_PRINT_DATA(rtlpriv, COMP_FW, DBG_LOUD,
1855                      "[C2H packet], Content Hex:\n", tmp_buf, c2h_cmd_len);
1856        _rtl8821ae_c2h_content_parsing(hw, c2h_cmd_id, c2h_cmd_len, tmp_buf);
1857}
1858