18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* Copyright(c) 2009-2014 Realtek Corporation.*/ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#include "../wifi.h" 58c2ecf20Sopenharmony_ci#include "../pci.h" 68c2ecf20Sopenharmony_ci#include "../base.h" 78c2ecf20Sopenharmony_ci#include "../core.h" 88c2ecf20Sopenharmony_ci#include "reg.h" 98c2ecf20Sopenharmony_ci#include "def.h" 108c2ecf20Sopenharmony_ci#include "fw.h" 118c2ecf20Sopenharmony_ci#include "../rtl8723com/fw_common.h" 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistatic bool _rtl8723be_check_fw_read_last_h2c(struct ieee80211_hw *hw, 148c2ecf20Sopenharmony_ci u8 boxnum) 158c2ecf20Sopenharmony_ci{ 168c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 178c2ecf20Sopenharmony_ci u8 val_hmetfr; 188c2ecf20Sopenharmony_ci bool result = false; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci val_hmetfr = rtl_read_byte(rtlpriv, REG_HMETFR); 218c2ecf20Sopenharmony_ci if (((val_hmetfr >> boxnum) & BIT(0)) == 0) 228c2ecf20Sopenharmony_ci result = true; 238c2ecf20Sopenharmony_ci return result; 248c2ecf20Sopenharmony_ci} 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistatic void _rtl8723be_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id, 278c2ecf20Sopenharmony_ci u32 cmd_len, u8 *p_cmdbuffer) 288c2ecf20Sopenharmony_ci{ 298c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 308c2ecf20Sopenharmony_ci struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 318c2ecf20Sopenharmony_ci u8 boxnum; 328c2ecf20Sopenharmony_ci u16 box_reg = 0, box_extreg = 0; 338c2ecf20Sopenharmony_ci u8 u1b_tmp; 348c2ecf20Sopenharmony_ci bool isfw_read = false; 358c2ecf20Sopenharmony_ci u8 buf_index = 0; 368c2ecf20Sopenharmony_ci bool bwrite_sucess = false; 378c2ecf20Sopenharmony_ci u8 wait_h2c_limmit = 100; 388c2ecf20Sopenharmony_ci u8 wait_writeh2c_limmit = 100; 398c2ecf20Sopenharmony_ci u8 boxcontent[4], boxextcontent[4]; 408c2ecf20Sopenharmony_ci u32 h2c_waitcounter = 0; 418c2ecf20Sopenharmony_ci unsigned long flag; 428c2ecf20Sopenharmony_ci u8 idx; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n"); 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci while (true) { 478c2ecf20Sopenharmony_ci spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); 488c2ecf20Sopenharmony_ci if (rtlhal->h2c_setinprogress) { 498c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 508c2ecf20Sopenharmony_ci "H2C set in progress! Wait to set..element_id(%d).\n", 518c2ecf20Sopenharmony_ci element_id); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci while (rtlhal->h2c_setinprogress) { 548c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, 558c2ecf20Sopenharmony_ci flag); 568c2ecf20Sopenharmony_ci h2c_waitcounter++; 578c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 588c2ecf20Sopenharmony_ci "Wait 100 us (%d times)...\n", 598c2ecf20Sopenharmony_ci h2c_waitcounter); 608c2ecf20Sopenharmony_ci udelay(100); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci if (h2c_waitcounter > 1000) 638c2ecf20Sopenharmony_ci return; 648c2ecf20Sopenharmony_ci spin_lock_irqsave(&rtlpriv->locks.h2c_lock, 658c2ecf20Sopenharmony_ci flag); 668c2ecf20Sopenharmony_ci } 678c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); 688c2ecf20Sopenharmony_ci } else { 698c2ecf20Sopenharmony_ci rtlhal->h2c_setinprogress = true; 708c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); 718c2ecf20Sopenharmony_ci break; 728c2ecf20Sopenharmony_ci } 738c2ecf20Sopenharmony_ci } 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci while (!bwrite_sucess) { 768c2ecf20Sopenharmony_ci wait_writeh2c_limmit--; 778c2ecf20Sopenharmony_ci if (wait_writeh2c_limmit == 0) { 788c2ecf20Sopenharmony_ci pr_err("Write H2C fail because no trigger for FW INT!\n"); 798c2ecf20Sopenharmony_ci break; 808c2ecf20Sopenharmony_ci } 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci boxnum = rtlhal->last_hmeboxnum; 838c2ecf20Sopenharmony_ci switch (boxnum) { 848c2ecf20Sopenharmony_ci case 0: 858c2ecf20Sopenharmony_ci box_reg = REG_HMEBOX_0; 868c2ecf20Sopenharmony_ci box_extreg = REG_HMEBOX_EXT_0; 878c2ecf20Sopenharmony_ci break; 888c2ecf20Sopenharmony_ci case 1: 898c2ecf20Sopenharmony_ci box_reg = REG_HMEBOX_1; 908c2ecf20Sopenharmony_ci box_extreg = REG_HMEBOX_EXT_1; 918c2ecf20Sopenharmony_ci break; 928c2ecf20Sopenharmony_ci case 2: 938c2ecf20Sopenharmony_ci box_reg = REG_HMEBOX_2; 948c2ecf20Sopenharmony_ci box_extreg = REG_HMEBOX_EXT_2; 958c2ecf20Sopenharmony_ci break; 968c2ecf20Sopenharmony_ci case 3: 978c2ecf20Sopenharmony_ci box_reg = REG_HMEBOX_3; 988c2ecf20Sopenharmony_ci box_extreg = REG_HMEBOX_EXT_3; 998c2ecf20Sopenharmony_ci break; 1008c2ecf20Sopenharmony_ci default: 1018c2ecf20Sopenharmony_ci pr_err("switch case %#x not processed\n", 1028c2ecf20Sopenharmony_ci boxnum); 1038c2ecf20Sopenharmony_ci break; 1048c2ecf20Sopenharmony_ci } 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci isfw_read = _rtl8723be_check_fw_read_last_h2c(hw, boxnum); 1078c2ecf20Sopenharmony_ci while (!isfw_read) { 1088c2ecf20Sopenharmony_ci wait_h2c_limmit--; 1098c2ecf20Sopenharmony_ci if (wait_h2c_limmit == 0) { 1108c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1118c2ecf20Sopenharmony_ci "Waiting too long for FW read clear HMEBox(%d)!\n", 1128c2ecf20Sopenharmony_ci boxnum); 1138c2ecf20Sopenharmony_ci break; 1148c2ecf20Sopenharmony_ci } 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci udelay(10); 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci isfw_read = _rtl8723be_check_fw_read_last_h2c(hw, 1198c2ecf20Sopenharmony_ci boxnum); 1208c2ecf20Sopenharmony_ci u1b_tmp = rtl_read_byte(rtlpriv, 0x130); 1218c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1228c2ecf20Sopenharmony_ci "Waiting for FW read clear HMEBox(%d)!!! 0x130 = %2x\n", 1238c2ecf20Sopenharmony_ci boxnum, u1b_tmp); 1248c2ecf20Sopenharmony_ci } 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci if (!isfw_read) { 1278c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1288c2ecf20Sopenharmony_ci "Write H2C register BOX[%d] fail!!!!! Fw do not read.\n", 1298c2ecf20Sopenharmony_ci boxnum); 1308c2ecf20Sopenharmony_ci break; 1318c2ecf20Sopenharmony_ci } 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci memset(boxcontent, 0, sizeof(boxcontent)); 1348c2ecf20Sopenharmony_ci memset(boxextcontent, 0, sizeof(boxextcontent)); 1358c2ecf20Sopenharmony_ci boxcontent[0] = element_id; 1368c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1378c2ecf20Sopenharmony_ci "Write element_id box_reg(%4x) = %2x\n", 1388c2ecf20Sopenharmony_ci box_reg, element_id); 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci switch (cmd_len) { 1418c2ecf20Sopenharmony_ci case 1: 1428c2ecf20Sopenharmony_ci case 2: 1438c2ecf20Sopenharmony_ci case 3: 1448c2ecf20Sopenharmony_ci /*boxcontent[0] &= ~(BIT(7));*/ 1458c2ecf20Sopenharmony_ci memcpy((u8 *)(boxcontent) + 1, 1468c2ecf20Sopenharmony_ci p_cmdbuffer + buf_index, cmd_len); 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci for (idx = 0; idx < 4; idx++) { 1498c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_reg + idx, 1508c2ecf20Sopenharmony_ci boxcontent[idx]); 1518c2ecf20Sopenharmony_ci } 1528c2ecf20Sopenharmony_ci break; 1538c2ecf20Sopenharmony_ci case 4: 1548c2ecf20Sopenharmony_ci case 5: 1558c2ecf20Sopenharmony_ci case 6: 1568c2ecf20Sopenharmony_ci case 7: 1578c2ecf20Sopenharmony_ci /*boxcontent[0] |= (BIT(7));*/ 1588c2ecf20Sopenharmony_ci memcpy((u8 *)(boxextcontent), 1598c2ecf20Sopenharmony_ci p_cmdbuffer + buf_index+3, cmd_len-3); 1608c2ecf20Sopenharmony_ci memcpy((u8 *)(boxcontent) + 1, 1618c2ecf20Sopenharmony_ci p_cmdbuffer + buf_index, 3); 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci for (idx = 0; idx < 4; idx++) { 1648c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_extreg + idx, 1658c2ecf20Sopenharmony_ci boxextcontent[idx]); 1668c2ecf20Sopenharmony_ci } 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci for (idx = 0; idx < 4; idx++) { 1698c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, box_reg + idx, 1708c2ecf20Sopenharmony_ci boxcontent[idx]); 1718c2ecf20Sopenharmony_ci } 1728c2ecf20Sopenharmony_ci break; 1738c2ecf20Sopenharmony_ci default: 1748c2ecf20Sopenharmony_ci pr_err("switch case %#x not processed\n", 1758c2ecf20Sopenharmony_ci cmd_len); 1768c2ecf20Sopenharmony_ci break; 1778c2ecf20Sopenharmony_ci } 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci bwrite_sucess = true; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci rtlhal->last_hmeboxnum = boxnum + 1; 1828c2ecf20Sopenharmony_ci if (rtlhal->last_hmeboxnum == 4) 1838c2ecf20Sopenharmony_ci rtlhal->last_hmeboxnum = 0; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, 1868c2ecf20Sopenharmony_ci "pHalData->last_hmeboxnum = %d\n", 1878c2ecf20Sopenharmony_ci rtlhal->last_hmeboxnum); 1888c2ecf20Sopenharmony_ci } 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); 1918c2ecf20Sopenharmony_ci rtlhal->h2c_setinprogress = false; 1928c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n"); 1958c2ecf20Sopenharmony_ci} 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_civoid rtl8723be_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, 1988c2ecf20Sopenharmony_ci u32 cmd_len, u8 *p_cmdbuffer) 1998c2ecf20Sopenharmony_ci{ 2008c2ecf20Sopenharmony_ci struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 2018c2ecf20Sopenharmony_ci u32 tmp_cmdbuf[2]; 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci if (!rtlhal->fw_ready) { 2048c2ecf20Sopenharmony_ci WARN_ONCE(true, 2058c2ecf20Sopenharmony_ci "rtl8723be: error H2C cmd because of Fw download fail!!!\n"); 2068c2ecf20Sopenharmony_ci return; 2078c2ecf20Sopenharmony_ci } 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci memset(tmp_cmdbuf, 0, 8); 2108c2ecf20Sopenharmony_ci memcpy(tmp_cmdbuf, p_cmdbuffer, cmd_len); 2118c2ecf20Sopenharmony_ci _rtl8723be_fill_h2c_command(hw, element_id, cmd_len, 2128c2ecf20Sopenharmony_ci (u8 *)&tmp_cmdbuf); 2138c2ecf20Sopenharmony_ci return; 2148c2ecf20Sopenharmony_ci} 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_civoid rtl8723be_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) 2178c2ecf20Sopenharmony_ci{ 2188c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 2198c2ecf20Sopenharmony_ci u8 u1_h2c_set_pwrmode[H2C_PWEMODE_LENGTH] = { 0 }; 2208c2ecf20Sopenharmony_ci struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 2218c2ecf20Sopenharmony_ci u8 rlbm, power_state = 0, byte5 = 0; 2228c2ecf20Sopenharmony_ci u8 awake_intvl; /* DTIM = (awake_intvl - 1) */ 2238c2ecf20Sopenharmony_ci struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops; 2248c2ecf20Sopenharmony_ci bool bt_ctrl_lps = (rtlpriv->cfg->ops->get_btc_status() ? 2258c2ecf20Sopenharmony_ci btc_ops->btc_is_bt_ctrl_lps(rtlpriv) : false); 2268c2ecf20Sopenharmony_ci bool bt_lps_on = (rtlpriv->cfg->ops->get_btc_status() ? 2278c2ecf20Sopenharmony_ci btc_ops->btc_is_bt_lps_on(rtlpriv) : false); 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci if (bt_ctrl_lps) 2308c2ecf20Sopenharmony_ci mode = (bt_lps_on ? FW_PS_MIN_MODE : FW_PS_ACTIVE_MODE); 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_POWER, DBG_DMESG, "FW LPS mode = %d (coex:%d)\n", 2338c2ecf20Sopenharmony_ci mode, bt_ctrl_lps); 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci switch (mode) { 2368c2ecf20Sopenharmony_ci case FW_PS_MIN_MODE: 2378c2ecf20Sopenharmony_ci rlbm = 0; 2388c2ecf20Sopenharmony_ci awake_intvl = 2; 2398c2ecf20Sopenharmony_ci break; 2408c2ecf20Sopenharmony_ci case FW_PS_MAX_MODE: 2418c2ecf20Sopenharmony_ci rlbm = 1; 2428c2ecf20Sopenharmony_ci awake_intvl = 2; 2438c2ecf20Sopenharmony_ci break; 2448c2ecf20Sopenharmony_ci case FW_PS_DTIM_MODE: 2458c2ecf20Sopenharmony_ci rlbm = 2; 2468c2ecf20Sopenharmony_ci awake_intvl = ppsc->reg_max_lps_awakeintvl; 2478c2ecf20Sopenharmony_ci /* hw->conf.ps_dtim_period or mac->vif->bss_conf.dtim_period 2488c2ecf20Sopenharmony_ci * is only used in swlps. 2498c2ecf20Sopenharmony_ci */ 2508c2ecf20Sopenharmony_ci break; 2518c2ecf20Sopenharmony_ci default: 2528c2ecf20Sopenharmony_ci rlbm = 2; 2538c2ecf20Sopenharmony_ci awake_intvl = 4; 2548c2ecf20Sopenharmony_ci break; 2558c2ecf20Sopenharmony_ci } 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci if (rtlpriv->mac80211.p2p) { 2588c2ecf20Sopenharmony_ci awake_intvl = 2; 2598c2ecf20Sopenharmony_ci rlbm = 1; 2608c2ecf20Sopenharmony_ci } 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci if (mode == FW_PS_ACTIVE_MODE) { 2638c2ecf20Sopenharmony_ci byte5 = 0x40; 2648c2ecf20Sopenharmony_ci power_state = FW_PWR_STATE_ACTIVE; 2658c2ecf20Sopenharmony_ci } else { 2668c2ecf20Sopenharmony_ci if (bt_ctrl_lps) { 2678c2ecf20Sopenharmony_ci byte5 = btc_ops->btc_get_lps_val(rtlpriv); 2688c2ecf20Sopenharmony_ci power_state = btc_ops->btc_get_rpwm_val(rtlpriv); 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci if ((rlbm == 2) && (byte5 & BIT(4))) { 2718c2ecf20Sopenharmony_ci /* Keep awake interval to 1 to prevent from 2728c2ecf20Sopenharmony_ci * decreasing coex performance 2738c2ecf20Sopenharmony_ci */ 2748c2ecf20Sopenharmony_ci awake_intvl = 2; 2758c2ecf20Sopenharmony_ci rlbm = 2; 2768c2ecf20Sopenharmony_ci } 2778c2ecf20Sopenharmony_ci } else { 2788c2ecf20Sopenharmony_ci byte5 = 0x40; 2798c2ecf20Sopenharmony_ci power_state = FW_PWR_STATE_RF_OFF; 2808c2ecf20Sopenharmony_ci } 2818c2ecf20Sopenharmony_ci } 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, ((mode) ? 1 : 0)); 2848c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_RLBM(u1_h2c_set_pwrmode, rlbm); 2858c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 2868c2ecf20Sopenharmony_ci bt_ctrl_lps ? 0 : ppsc->smart_ps); 2878c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(u1_h2c_set_pwrmode, 2888c2ecf20Sopenharmony_ci awake_intvl); 2898c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(u1_h2c_set_pwrmode, 0); 2908c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_PWR_STATE(u1_h2c_set_pwrmode, power_state); 2918c2ecf20Sopenharmony_ci SET_H2CCMD_PWRMODE_PARM_BYTE5(u1_h2c_set_pwrmode, byte5); 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 2948c2ecf20Sopenharmony_ci "rtl92c_set_fw_pwrmode(): u1_h2c_set_pwrmode\n", 2958c2ecf20Sopenharmony_ci u1_h2c_set_pwrmode, H2C_PWEMODE_LENGTH); 2968c2ecf20Sopenharmony_ci if (rtlpriv->cfg->ops->get_btc_status()) 2978c2ecf20Sopenharmony_ci btc_ops->btc_record_pwr_mode(rtlpriv, u1_h2c_set_pwrmode, 2988c2ecf20Sopenharmony_ci H2C_PWEMODE_LENGTH); 2998c2ecf20Sopenharmony_ci rtl8723be_fill_h2c_cmd(hw, H2C_8723B_SETPWRMODE, H2C_PWEMODE_LENGTH, 3008c2ecf20Sopenharmony_ci u1_h2c_set_pwrmode); 3018c2ecf20Sopenharmony_ci} 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_civoid rtl8723be_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw, u8 mstatus) 3048c2ecf20Sopenharmony_ci{ 3058c2ecf20Sopenharmony_ci u8 parm[3] = { 0, 0, 0 }; 3068c2ecf20Sopenharmony_ci /* parm[0]: bit0=0-->Disconnect, bit0=1-->Connect 3078c2ecf20Sopenharmony_ci * bit1=0-->update Media Status to MACID 3088c2ecf20Sopenharmony_ci * bit1=1-->update Media Status from MACID to MACID_End 3098c2ecf20Sopenharmony_ci * parm[1]: MACID, if this is INFRA_STA, MacID = 0 3108c2ecf20Sopenharmony_ci * parm[2]: MACID_End 3118c2ecf20Sopenharmony_ci */ 3128c2ecf20Sopenharmony_ci SET_H2CCMD_MSRRPT_PARM_OPMODE(parm, mstatus); 3138c2ecf20Sopenharmony_ci SET_H2CCMD_MSRRPT_PARM_MACID_IND(parm, 0); 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci rtl8723be_fill_h2c_cmd(hw, H2C_8723B_MSRRPT, 3, parm); 3168c2ecf20Sopenharmony_ci} 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci#define BEACON_PG 0 /* ->1 */ 3198c2ecf20Sopenharmony_ci#define PSPOLL_PG 2 3208c2ecf20Sopenharmony_ci#define NULL_PG 3 3218c2ecf20Sopenharmony_ci#define PROBERSP_PG 4 /* ->5 */ 3228c2ecf20Sopenharmony_ci#define QOS_NULL_PG 6 3238c2ecf20Sopenharmony_ci#define BT_QOS_NULL_PG 7 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci#define TOTAL_RESERVED_PKT_LEN 1024 /* can be up to 1280 (tx_bndy=245) */ 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_cistatic u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = { 3288c2ecf20Sopenharmony_ci /* page 0 beacon */ 3298c2ecf20Sopenharmony_ci 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 3308c2ecf20Sopenharmony_ci 0xFF, 0xFF, 0x00, 0xE0, 0x4C, 0x02, 0xB1, 0x78, 3318c2ecf20Sopenharmony_ci 0xEC, 0x1A, 0x59, 0x0B, 0xAD, 0xD4, 0x20, 0x00, 3328c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3338c2ecf20Sopenharmony_ci 0x64, 0x00, 0x10, 0x04, 0x00, 0x05, 0x54, 0x65, 3348c2ecf20Sopenharmony_ci 0x73, 0x74, 0x32, 0x01, 0x08, 0x82, 0x84, 0x0B, 3358c2ecf20Sopenharmony_ci 0x16, 0x24, 0x30, 0x48, 0x6C, 0x03, 0x01, 0x06, 3368c2ecf20Sopenharmony_ci 0x06, 0x02, 0x00, 0x00, 0x2A, 0x01, 0x02, 0x32, 3378c2ecf20Sopenharmony_ci 0x04, 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 3388c2ecf20Sopenharmony_ci 0x09, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 3398c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3408c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3418c2ecf20Sopenharmony_ci 0x00, 0x3D, 0x00, 0xDD, 0x07, 0x00, 0xE0, 0x4C, 3428c2ecf20Sopenharmony_ci 0x02, 0x02, 0x00, 0x00, 0xDD, 0x18, 0x00, 0x50, 3438c2ecf20Sopenharmony_ci 0xF2, 0x01, 0x01, 0x00, 0x00, 0x50, 0xF2, 0x04, 3448c2ecf20Sopenharmony_ci 0x01, 0x00, 0x00, 0x50, 0xF2, 0x04, 0x01, 0x00, 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci /* page 1 beacon */ 3478c2ecf20Sopenharmony_ci 0x00, 0x50, 0xF2, 0x02, 0x00, 0x00, 0x00, 0x00, 3488c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3498c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3508c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3518c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3528c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3538c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3548c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3558c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3568c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3578c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3588c2ecf20Sopenharmony_ci 0x10, 0x00, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, 3598c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 3608c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3618c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3628c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci /* page 2 ps-poll */ 3658c2ecf20Sopenharmony_ci 0xA4, 0x10, 0x01, 0xC0, 0xEC, 0x1A, 0x59, 0x0B, 3668c2ecf20Sopenharmony_ci 0xAD, 0xD4, 0x00, 0xE0, 0x4C, 0x02, 0xB1, 0x78, 3678c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3688c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3698c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3708c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3718c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3728c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3738c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3748c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3758c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3768c2ecf20Sopenharmony_ci 0x18, 0x00, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, 3778c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 3788c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3798c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3808c2ecf20Sopenharmony_ci 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci /* page 3 null */ 3838c2ecf20Sopenharmony_ci 0x48, 0x01, 0x00, 0x00, 0xEC, 0x1A, 0x59, 0x0B, 3848c2ecf20Sopenharmony_ci 0xAD, 0xD4, 0x00, 0xE0, 0x4C, 0x02, 0xB1, 0x78, 3858c2ecf20Sopenharmony_ci 0xEC, 0x1A, 0x59, 0x0B, 0xAD, 0xD4, 0x00, 0x00, 3868c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3878c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3888c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3898c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3908c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3918c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3928c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3938c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3948c2ecf20Sopenharmony_ci 0x72, 0x00, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, 3958c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 3968c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3978c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3988c2ecf20Sopenharmony_ci 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci /* page 4 probe_resp */ 4018c2ecf20Sopenharmony_ci 0x50, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, 4028c2ecf20Sopenharmony_ci 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, 4038c2ecf20Sopenharmony_ci 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 4048c2ecf20Sopenharmony_ci 0x9E, 0x46, 0x15, 0x32, 0x27, 0xF2, 0x2D, 0x00, 4058c2ecf20Sopenharmony_ci 0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69, 4068c2ecf20Sopenharmony_ci 0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C, 4078c2ecf20Sopenharmony_ci 0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96, 4088c2ecf20Sopenharmony_ci 0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A, 4098c2ecf20Sopenharmony_ci 0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C, 4108c2ecf20Sopenharmony_ci 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18, 4118c2ecf20Sopenharmony_ci 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4128c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4138c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4148c2ecf20Sopenharmony_ci 0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02, 4158c2ecf20Sopenharmony_ci 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4168c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci /* page 5 probe_resp */ 4198c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4208c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4218c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4228c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4238c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4248c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4258c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4268c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4278c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4288c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4298c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4308c2ecf20Sopenharmony_ci 0x1A, 0x00, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, 4318c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 4328c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4338c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4348c2ecf20Sopenharmony_ci 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci /* page 6 qos null data */ 4378c2ecf20Sopenharmony_ci 0xC8, 0x01, 0x00, 0x00, 0x84, 0xC9, 0xB2, 0xA7, 4388c2ecf20Sopenharmony_ci 0xB3, 0x6E, 0x00, 0xE0, 0x4C, 0x02, 0x51, 0x02, 4398c2ecf20Sopenharmony_ci 0x84, 0xC9, 0xB2, 0xA7, 0xB3, 0x6E, 0x00, 0x00, 4408c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4418c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4428c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4438c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4448c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4458c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4468c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4478c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4488c2ecf20Sopenharmony_ci 0x1A, 0x00, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, 4498c2ecf20Sopenharmony_ci 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 4508c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4518c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4528c2ecf20Sopenharmony_ci 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci /* page 7 BT-qos null data */ 4558c2ecf20Sopenharmony_ci 0xC8, 0x01, 0x00, 0x00, 0x84, 0xC9, 0xB2, 0xA7, 4568c2ecf20Sopenharmony_ci 0xB3, 0x6E, 0x00, 0xE0, 0x4C, 0x02, 0x51, 0x02, 4578c2ecf20Sopenharmony_ci 0x84, 0xC9, 0xB2, 0xA7, 0xB3, 0x6E, 0x00, 0x00, 4588c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4598c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4608c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4618c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4628c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4638c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4648c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4658c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4668c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4678c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4688c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4698c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4708c2ecf20Sopenharmony_ci 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_ci}; 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_civoid rtl8723be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, 4758c2ecf20Sopenharmony_ci bool b_dl_finished) 4768c2ecf20Sopenharmony_ci{ 4778c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 4788c2ecf20Sopenharmony_ci struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 4798c2ecf20Sopenharmony_ci struct sk_buff *skb = NULL; 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_ci u32 totalpacketlen; 4828c2ecf20Sopenharmony_ci bool rtstatus; 4838c2ecf20Sopenharmony_ci u8 u1rsvdpageloc[5] = { 0 }; 4848c2ecf20Sopenharmony_ci bool b_dlok = false; 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci u8 *beacon; 4878c2ecf20Sopenharmony_ci u8 *p_pspoll; 4888c2ecf20Sopenharmony_ci u8 *nullfunc; 4898c2ecf20Sopenharmony_ci u8 *p_probersp; 4908c2ecf20Sopenharmony_ci u8 *qosnull; 4918c2ecf20Sopenharmony_ci u8 *btqosnull; 4928c2ecf20Sopenharmony_ci /*--------------------------------------------------------- 4938c2ecf20Sopenharmony_ci * (1) beacon 4948c2ecf20Sopenharmony_ci *--------------------------------------------------------- 4958c2ecf20Sopenharmony_ci */ 4968c2ecf20Sopenharmony_ci beacon = &reserved_page_packet[BEACON_PG * 128]; 4978c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS2(beacon, mac->mac_addr); 4988c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS3(beacon, mac->bssid); 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci /*------------------------------------------------------- 5018c2ecf20Sopenharmony_ci * (2) ps-poll 5028c2ecf20Sopenharmony_ci *------------------------------------------------------- 5038c2ecf20Sopenharmony_ci */ 5048c2ecf20Sopenharmony_ci p_pspoll = &reserved_page_packet[PSPOLL_PG * 128]; 5058c2ecf20Sopenharmony_ci SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000)); 5068c2ecf20Sopenharmony_ci SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid); 5078c2ecf20Sopenharmony_ci SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr); 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG); 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci /*-------------------------------------------------------- 5128c2ecf20Sopenharmony_ci * (3) null data 5138c2ecf20Sopenharmony_ci *-------------------------------------------------------- 5148c2ecf20Sopenharmony_ci */ 5158c2ecf20Sopenharmony_ci nullfunc = &reserved_page_packet[NULL_PG * 128]; 5168c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid); 5178c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr); 5188c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid); 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1rsvdpageloc, NULL_PG); 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_ci /*--------------------------------------------------------- 5238c2ecf20Sopenharmony_ci * (4) probe response 5248c2ecf20Sopenharmony_ci *--------------------------------------------------------- 5258c2ecf20Sopenharmony_ci */ 5268c2ecf20Sopenharmony_ci p_probersp = &reserved_page_packet[PROBERSP_PG * 128]; 5278c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid); 5288c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr); 5298c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid); 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1rsvdpageloc, PROBERSP_PG); 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci /*--------------------------------------------------------- 5348c2ecf20Sopenharmony_ci * (5) QoS Null 5358c2ecf20Sopenharmony_ci *--------------------------------------------------------- 5368c2ecf20Sopenharmony_ci */ 5378c2ecf20Sopenharmony_ci qosnull = &reserved_page_packet[QOS_NULL_PG * 128]; 5388c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS1(qosnull, mac->bssid); 5398c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS2(qosnull, mac->mac_addr); 5408c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS3(qosnull, mac->bssid); 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_ci SET_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(u1rsvdpageloc, QOS_NULL_PG); 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci /*--------------------------------------------------------- 5458c2ecf20Sopenharmony_ci * (5) QoS Null 5468c2ecf20Sopenharmony_ci *--------------------------------------------------------- 5478c2ecf20Sopenharmony_ci */ 5488c2ecf20Sopenharmony_ci btqosnull = &reserved_page_packet[BT_QOS_NULL_PG * 128]; 5498c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS1(btqosnull, mac->bssid); 5508c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS2(btqosnull, mac->mac_addr); 5518c2ecf20Sopenharmony_ci SET_80211_HDR_ADDRESS3(btqosnull, mac->bssid); 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci SET_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(u1rsvdpageloc, BT_QOS_NULL_PG); 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_ci totalpacketlen = TOTAL_RESERVED_PKT_LEN; 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, 5588c2ecf20Sopenharmony_ci "rtl8723be_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", 5598c2ecf20Sopenharmony_ci &reserved_page_packet[0], totalpacketlen); 5608c2ecf20Sopenharmony_ci RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 5618c2ecf20Sopenharmony_ci "rtl8723be_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", 5628c2ecf20Sopenharmony_ci u1rsvdpageloc, sizeof(u1rsvdpageloc)); 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci skb = dev_alloc_skb(totalpacketlen); 5658c2ecf20Sopenharmony_ci if (!skb) 5668c2ecf20Sopenharmony_ci return; 5678c2ecf20Sopenharmony_ci skb_put_data(skb, &reserved_page_packet, totalpacketlen); 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci rtstatus = rtl_cmd_send_packet(hw, skb); 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci if (rtstatus) 5728c2ecf20Sopenharmony_ci b_dlok = true; 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci if (b_dlok) { 5758c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_POWER, DBG_LOUD, 5768c2ecf20Sopenharmony_ci "Set RSVD page location to Fw.\n"); 5778c2ecf20Sopenharmony_ci RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, "H2C_RSVDPAGE:\n", 5788c2ecf20Sopenharmony_ci u1rsvdpageloc, sizeof(u1rsvdpageloc)); 5798c2ecf20Sopenharmony_ci rtl8723be_fill_h2c_cmd(hw, H2C_8723B_RSVDPAGE, 5808c2ecf20Sopenharmony_ci sizeof(u1rsvdpageloc), u1rsvdpageloc); 5818c2ecf20Sopenharmony_ci } else 5828c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_ERR, DBG_WARNING, 5838c2ecf20Sopenharmony_ci "Set RSVD page location to Fw FAIL!!!!!!.\n"); 5848c2ecf20Sopenharmony_ci} 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci/*Should check FW support p2p or not.*/ 5878c2ecf20Sopenharmony_cistatic void rtl8723be_set_p2p_ctw_period_cmd(struct ieee80211_hw *hw, 5888c2ecf20Sopenharmony_ci u8 ctwindow) 5898c2ecf20Sopenharmony_ci{ 5908c2ecf20Sopenharmony_ci u8 u1_ctwindow_period[1] = { ctwindow}; 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci rtl8723be_fill_h2c_cmd(hw, H2C_8723B_P2P_PS_CTW_CMD, 1, 5938c2ecf20Sopenharmony_ci u1_ctwindow_period); 5948c2ecf20Sopenharmony_ci} 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_civoid rtl8723be_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, 5978c2ecf20Sopenharmony_ci u8 p2p_ps_state) 5988c2ecf20Sopenharmony_ci{ 5998c2ecf20Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 6008c2ecf20Sopenharmony_ci struct rtl_ps_ctl *rtlps = rtl_psc(rtl_priv(hw)); 6018c2ecf20Sopenharmony_ci struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 6028c2ecf20Sopenharmony_ci struct rtl_p2p_ps_info *p2pinfo = &(rtlps->p2p_ps_info); 6038c2ecf20Sopenharmony_ci struct p2p_ps_offload_t *p2p_ps_offload = &rtlhal->p2p_ps_offload; 6048c2ecf20Sopenharmony_ci u8 i; 6058c2ecf20Sopenharmony_ci u16 ctwindow; 6068c2ecf20Sopenharmony_ci u32 start_time, tsf_low; 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_ci switch (p2p_ps_state) { 6098c2ecf20Sopenharmony_ci case P2P_PS_DISABLE: 6108c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_DISABLE\n"); 6118c2ecf20Sopenharmony_ci memset(p2p_ps_offload, 0, sizeof(*p2p_ps_offload)); 6128c2ecf20Sopenharmony_ci break; 6138c2ecf20Sopenharmony_ci case P2P_PS_ENABLE: 6148c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_ENABLE\n"); 6158c2ecf20Sopenharmony_ci /* update CTWindow value. */ 6168c2ecf20Sopenharmony_ci if (p2pinfo->ctwindow > 0) { 6178c2ecf20Sopenharmony_ci p2p_ps_offload->ctwindow_en = 1; 6188c2ecf20Sopenharmony_ci ctwindow = p2pinfo->ctwindow; 6198c2ecf20Sopenharmony_ci rtl8723be_set_p2p_ctw_period_cmd(hw, ctwindow); 6208c2ecf20Sopenharmony_ci } 6218c2ecf20Sopenharmony_ci /* hw only support 2 set of NoA */ 6228c2ecf20Sopenharmony_ci for (i = 0 ; i < p2pinfo->noa_num ; i++) { 6238c2ecf20Sopenharmony_ci /* To control the register setting 6248c2ecf20Sopenharmony_ci * for which NOA 6258c2ecf20Sopenharmony_ci */ 6268c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, 0x5cf, (i << 4)); 6278c2ecf20Sopenharmony_ci if (i == 0) 6288c2ecf20Sopenharmony_ci p2p_ps_offload->noa0_en = 1; 6298c2ecf20Sopenharmony_ci else 6308c2ecf20Sopenharmony_ci p2p_ps_offload->noa1_en = 1; 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_ci /* config P2P NoA Descriptor Register */ 6338c2ecf20Sopenharmony_ci rtl_write_dword(rtlpriv, 0x5E0, 6348c2ecf20Sopenharmony_ci p2pinfo->noa_duration[i]); 6358c2ecf20Sopenharmony_ci rtl_write_dword(rtlpriv, 0x5E4, 6368c2ecf20Sopenharmony_ci p2pinfo->noa_interval[i]); 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci /*Get Current TSF value */ 6398c2ecf20Sopenharmony_ci tsf_low = rtl_read_dword(rtlpriv, REG_TSFTR); 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci start_time = p2pinfo->noa_start_time[i]; 6428c2ecf20Sopenharmony_ci if (p2pinfo->noa_count_type[i] != 1) { 6438c2ecf20Sopenharmony_ci while (start_time <= (tsf_low + (50 * 1024))) { 6448c2ecf20Sopenharmony_ci start_time += p2pinfo->noa_interval[i]; 6458c2ecf20Sopenharmony_ci if (p2pinfo->noa_count_type[i] != 255) 6468c2ecf20Sopenharmony_ci p2pinfo->noa_count_type[i]--; 6478c2ecf20Sopenharmony_ci } 6488c2ecf20Sopenharmony_ci } 6498c2ecf20Sopenharmony_ci rtl_write_dword(rtlpriv, 0x5E8, start_time); 6508c2ecf20Sopenharmony_ci rtl_write_dword(rtlpriv, 0x5EC, 6518c2ecf20Sopenharmony_ci p2pinfo->noa_count_type[i]); 6528c2ecf20Sopenharmony_ci } 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci if ((p2pinfo->opp_ps == 1) || 6558c2ecf20Sopenharmony_ci (p2pinfo->noa_num > 0)) { 6568c2ecf20Sopenharmony_ci /* rst p2p circuit */ 6578c2ecf20Sopenharmony_ci rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, BIT(4)); 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci p2p_ps_offload->offload_en = 1; 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_ci if (P2P_ROLE_GO == rtlpriv->mac80211.p2p) { 6628c2ecf20Sopenharmony_ci p2p_ps_offload->role = 1; 6638c2ecf20Sopenharmony_ci p2p_ps_offload->allstasleep = 0; 6648c2ecf20Sopenharmony_ci } else { 6658c2ecf20Sopenharmony_ci p2p_ps_offload->role = 0; 6668c2ecf20Sopenharmony_ci } 6678c2ecf20Sopenharmony_ci p2p_ps_offload->discovery = 0; 6688c2ecf20Sopenharmony_ci } 6698c2ecf20Sopenharmony_ci break; 6708c2ecf20Sopenharmony_ci case P2P_PS_SCAN: 6718c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_SCAN\n"); 6728c2ecf20Sopenharmony_ci p2p_ps_offload->discovery = 1; 6738c2ecf20Sopenharmony_ci break; 6748c2ecf20Sopenharmony_ci case P2P_PS_SCAN_DONE: 6758c2ecf20Sopenharmony_ci rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_SCAN_DONE\n"); 6768c2ecf20Sopenharmony_ci p2p_ps_offload->discovery = 0; 6778c2ecf20Sopenharmony_ci p2pinfo->p2p_ps_state = P2P_PS_ENABLE; 6788c2ecf20Sopenharmony_ci break; 6798c2ecf20Sopenharmony_ci default: 6808c2ecf20Sopenharmony_ci break; 6818c2ecf20Sopenharmony_ci } 6828c2ecf20Sopenharmony_ci 6838c2ecf20Sopenharmony_ci rtl8723be_fill_h2c_cmd(hw, H2C_8723B_P2P_PS_OFFLOAD, 1, 6848c2ecf20Sopenharmony_ci (u8 *)p2p_ps_offload); 6858c2ecf20Sopenharmony_ci} 686