From 4137e7a01976a407f91317e0c7488680bc7020ff Mon Sep 17 00:00:00 2001 From: kimocoder Date: Sat, 24 Aug 2019 06:42:21 +0200 Subject: [PATCH] Cleanup in and around HAL --- hal/hal_com.c | 159 +++++++++++--------------------------------------- 1 file changed, 35 insertions(+), 124 deletions(-) diff --git a/hal/hal_com.c b/hal/hal_com.c index 3d18130..02e8652 100644 --- a/hal/hal_com.c +++ b/hal/hal_com.c @@ -1335,7 +1335,7 @@ void rtw_hal_c2h_pkt_pre_hdl(_adapter *adapter, u8 *buf, u16 len) } hdl_here = rtw_hal_c2h_id_handle_directly(adapter, id, seq, plen, payload) == _TRUE ? 1 : 0; - if (hdl_here) + if (hdl_here) ret = rtw_hal_c2h_handler(adapter, id, seq, plen, payload); else ret = rtw_c2h_packet_wk_cmd(adapter, buf, len); @@ -1655,7 +1655,7 @@ int c2h_defeature_dbg_hdl(_adapter *adapter, u8 *data, u8 len) RTW_PRINT("%s: 0x%02X\n", __func__, *(data + i)); ret = _SUCCESS; - + exit: return ret; } @@ -1899,9 +1899,9 @@ u8 rtw_hal_set_req_per_rpt_cmd(_adapter *adapter, u8 group_macid, SET_H2CCMD_REQ_PER_RPT_RPT_TYPE(cmd_buf, rpt_type); SET_H2CCMD_REQ_PER_RPT_MACID_BMAP(cmd_buf, macid_bitmap); - ret = rtw_hal_fill_h2c_cmd(adapter, - H2C_REQ_PER_RPT, - H2C_REQ_PER_RPT_LEN, + ret = rtw_hal_fill_h2c_cmd(adapter, + H2C_REQ_PER_RPT, + H2C_REQ_PER_RPT_LEN, cmd_buf); return ret; } @@ -3104,12 +3104,6 @@ void rtw_ap_multi_bcn_cfg(_adapter *adapter) if (IS_HARDWARE_TYPE_8821(adapter) || IS_HARDWARE_TYPE_8192E(adapter))/* select BCN on port 0 for DualBeacon*/ rtw_write8(adapter, REG_CCK_CHECK, rtw_read8(adapter, REG_CCK_CHECK) & (~BIT_BCN_PORT_SEL)); - /* Enable HW seq for BCN - * 0x4FC[0]: EN_HWSEQ / 0x4FC[1]: EN_HWSEQEXT */ - #ifdef CONFIG_RTL8822B - if (IS_HARDWARE_TYPE_8822B(adapter)) - rtw_write8(adapter, REG_DUMMY_PAGE4_V1_8822B, 0x01); - #endif } #endif @@ -3666,7 +3660,7 @@ void rtw_hal_rcr_set_chk_bssid(_adapter *adapter, u8 self_action) else if ((MSTATE_AP_NUM(&mstate) && adapter->registrypriv.wifi_spec) /* for 11n Logo 4.2.31/4.2.32 */ || MSTATE_MESH_NUM(&mstate) ) - rcr_new &= ~RCR_CBSSID_BCN; + rcr_new &= ~RCR_CBSSID_BCN; else rcr_new |= RCR_CBSSID_BCN; @@ -3756,10 +3750,6 @@ void hw_var_port_switch(_adapter *adapter) u8 bssid[6]; u8 macid_1[6]; u8 bssid_1[6]; -#if defined(CONFIG_RTL8192F) - u16 wlan_act_mask_ctrl = 0; - u16 en_port_mask = EN_PORT_0_FUNCTION | EN_PORT_1_FUNCTION; -#endif u8 hw_port; struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); @@ -3768,9 +3758,6 @@ void hw_var_port_switch(_adapter *adapter) msr = rtw_read8(adapter, MSR); bcn_ctrl = rtw_read8(adapter, REG_BCN_CTRL); bcn_ctrl_1 = rtw_read8(adapter, REG_BCN_CTRL_1); -#if defined(CONFIG_RTL8192F) - wlan_act_mask_ctrl = rtw_read16(adapter, REG_WLAN_ACT_MASK_CTRL_1); -#endif for (i = 0; i < 2; i++) atimwnd[i] = rtw_read8(adapter, REG_ATIMWND + i); @@ -3799,9 +3786,6 @@ void hw_var_port_switch(_adapter *adapter) "msr:0x%02x\n" "bcn_ctrl:0x%02x\n" "bcn_ctrl_1:0x%02x\n" -#if defined(CONFIG_RTL8192F) - "wlan_act_mask_ctrl:0x%02x\n" -#endif "atimwnd:0x%04x\n" "atimwnd_1:0x%04x\n" "tsftr:%llu\n" @@ -3814,9 +3798,6 @@ void hw_var_port_switch(_adapter *adapter) , msr , bcn_ctrl , bcn_ctrl_1 -#if defined(CONFIG_RTL8192F) - , wlan_act_mask_ctrl -#endif , *((u16 *)atimwnd) , *((u16 *)atimwnd_1) , *((u64 *)tsftr) @@ -3832,10 +3813,6 @@ void hw_var_port_switch(_adapter *adapter) rtw_write8(adapter, REG_BCN_CTRL, (bcn_ctrl & (~EN_BCN_FUNCTION)) | DIS_TSF_UDT); rtw_write8(adapter, REG_BCN_CTRL_1, (bcn_ctrl_1 & (~EN_BCN_FUNCTION)) | DIS_TSF_UDT); -#if defined(CONFIG_RTL8192F) - rtw_write16(adapter, REG_WLAN_ACT_MASK_CTRL_1, wlan_act_mask_ctrl & ~en_port_mask); -#endif - /* switch msr */ msr = (msr & 0xf0) | ((msr & 0x03) << 2) | ((msr & 0x0c) >> 2); rtw_write8(adapter, MSR, msr); @@ -3875,20 +3852,11 @@ void hw_var_port_switch(_adapter *adapter) rtw_write8(adapter, REG_BCN_CTRL, bcn_ctrl_1); rtw_write8(adapter, REG_BCN_CTRL_1, bcn_ctrl); -#if defined(CONFIG_RTL8192F) - /* if the setting of port0 and port1 are the same, it does not need to switch port setting*/ - if(((wlan_act_mask_ctrl & en_port_mask) != 0) && ((wlan_act_mask_ctrl & en_port_mask) - != (EN_PORT_0_FUNCTION | EN_PORT_1_FUNCTION))) - wlan_act_mask_ctrl ^= en_port_mask; - rtw_write16(adapter, REG_WLAN_ACT_MASK_CTRL_1, wlan_act_mask_ctrl); -#endif - if (adapter->iface_id == IFACE_ID0) iface = dvobj->padapters[IFACE_ID1]; else if (adapter->iface_id == IFACE_ID1) iface = dvobj->padapters[IFACE_ID0]; - if (adapter->hw_port == HW_PORT0) { adapter->hw_port = HW_PORT1; iface->hw_port = HW_PORT0; @@ -3905,9 +3873,6 @@ void hw_var_port_switch(_adapter *adapter) msr = rtw_read8(adapter, MSR); bcn_ctrl = rtw_read8(adapter, REG_BCN_CTRL); bcn_ctrl_1 = rtw_read8(adapter, REG_BCN_CTRL_1); -#if defined(CONFIG_RTL8192F) - wlan_act_mask_ctrl = rtw_read16(adapter, REG_WLAN_ACT_MASK_CTRL_1); -#endif for (i = 0; i < 2; i++) atimwnd[i] = rtw_read8(adapter, REG_ATIMWND + i); @@ -3935,9 +3900,6 @@ void hw_var_port_switch(_adapter *adapter) "msr:0x%02x\n" "bcn_ctrl:0x%02x\n" "bcn_ctrl_1:0x%02x\n" -#if defined(CONFIG_RTL8192F) - "wlan_act_mask_ctrl:0x%02x\n" -#endif "atimwnd:%u\n" "atimwnd_1:%u\n" "tsftr:%llu\n" @@ -3950,9 +3912,6 @@ void hw_var_port_switch(_adapter *adapter) , msr , bcn_ctrl , bcn_ctrl_1 -#if defined(CONFIG_RTL8192F) - , wlan_act_mask_ctrl -#endif , *((u16 *)atimwnd) , *((u16 *)atimwnd_1) , *((u64 *)tsftr) @@ -4185,7 +4144,6 @@ void rtw_set_p2p_ps_offload_cmd(_adapter *adapter, u8 p2p_ps_state) } } - switch (p2p_ps_state) { case P2P_PS_DISABLE: RTW_INFO("P2P_PS_DISABLE\n"); @@ -4201,7 +4159,6 @@ void rtw_set_p2p_ps_offload_cmd(_adapter *adapter, u8 p2p_ps_state) /*RTW_INFO("%s , ctwindow_length = %d\n" , __func__ , (&p2p_ps_para)->ctwindow_length);*/ } - if ((pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0)) { (&p2p_ps_para)->offload_en = 1; if (pwdinfo->role == P2P_ROLE_GO) { @@ -4325,28 +4282,6 @@ s32 rtw_hal_set_FwMediaStatusRpt_cmd(_adapter *adapter, bool opmode, bool miraca if (ret != _SUCCESS) goto exit; -#if defined(CONFIG_RTL8188E) - if (rtw_get_chip_type(adapter) == RTL8188E) { - HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter); - - /* 8188E FW doesn't set macid no link, driver does it by self */ - if (opmode) - rtw_hal_set_hwreg(adapter, HW_VAR_MACID_LINK, &macid); - else - rtw_hal_set_hwreg(adapter, HW_VAR_MACID_NOLINK, &macid); - - /* for 8188E RA */ -#if (RATE_ADAPTIVE_SUPPORT == 1) - if (hal_data->fw_ractrl == _FALSE) { - u8 max_macid; - - max_macid = rtw_search_max_mac_id(adapter); - rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, &max_macid); - } -#endif - } -#endif - #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) /* TODO: this should move to IOT issue area */ if (rtw_get_chip_type(adapter) == RTL8812 @@ -4437,9 +4372,6 @@ void rtw_hal_switch_gpio_wl_ctrl(_adapter *padapter, u8 index, u8 enable) void rtw_hal_set_output_gpio(_adapter *padapter, u8 index, u8 outputval) { -#if defined(CONFIG_RTL8192F) - rtw_hal_set_hwreg(padapter, HW_VAR_WOW_OUTPUT_GPIO, (u8 *)(&index)); -#else if (index <= 7) { /* config GPIO mode */ rtw_write8(padapter, REG_GPIO_PIN_CTRL + 3, @@ -4489,13 +4421,9 @@ void rtw_hal_set_output_gpio(_adapter *padapter, u8 index, u8 outputval) RTW_INFO("%s: invalid GPIO%d=%d\n", __FUNCTION__, index, outputval); } -#endif } void rtw_hal_set_input_gpio(_adapter *padapter, u8 index) { -#if defined(CONFIG_RTL8192F) - rtw_hal_set_hwreg(padapter, HW_VAR_WOW_INPUT_GPIO, (u8 *)(&index)); -#else if (index <= 7) { /* config GPIO mode */ rtw_write8(padapter, REG_GPIO_PIN_CTRL + 3, @@ -4526,7 +4454,6 @@ void rtw_hal_set_input_gpio(_adapter *padapter, u8 index) rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 2) & ~BIT(index)); } else RTW_INFO("%s: invalid GPIO%d\n", __func__, index); -#endif } #endif @@ -5359,11 +5286,11 @@ static u8 rtw_hal_set_wowlan_ctrl_cmd(_adapter *adapter, u8 enable, u8 change_un gpionum = WAKEUP_GPIO_IDX; sdio_wakeup_enable = 0; #endif /* CONFIG_GPIO_WAKEUP */ - - if(registry_par->suspend_type == FW_IPS_DISABLE_BBRF && + + if (registry_par->suspend_type == FW_IPS_DISABLE_BBRF && !check_fwstate(pmlmepriv, _FW_LINKED)) no_wake = 1; - + if (!ppwrpriv->wowlan_pno_enable && registry_par->wakeup_event & BIT(0) && !no_wake) magic_pkt = enable; @@ -5447,7 +5374,6 @@ static u8 rtw_hal_set_wowlan_ctrl_cmd(_adapter *adapter, u8 enable, u8 change_un #endif /* CONFIG_RTW_ONE_PIN_GPIO */ #endif /* CONFIG_DIS_UPHY */ - ret = rtw_hal_fill_h2c_cmd(adapter, H2C_WOWLAN, H2C_WOWLAN_LEN, @@ -5490,31 +5416,24 @@ static u8 rtw_hal_set_remote_wake_ctrl_cmd(_adapter *adapter, u8 enable) u1H2CRemoteWakeCtrlParm, 0); } #endif /* CONFIG_GTK_OL */ - + #ifdef CONFIG_IPV6 if (ppwrpriv->wowlan_ns_offload_en == _TRUE) { RTW_INFO("enable NS offload\n"); SET_H2CCMD_REMOTE_WAKE_CTRL_NDP_OFFLOAD_EN( u1H2CRemoteWakeCtrlParm, enable); } - + /* * filter NetBios name service pkt to avoid being waked-up * by this kind of unicast pkt this exceptional modification * is used for match competitor's behavior */ - + SET_H2CCMD_REMOTE_WAKE_CTRL_NBNS_FILTER_EN( u1H2CRemoteWakeCtrlParm, enable); #endif /*CONFIG_IPV6*/ - - #ifdef CONFIG_RTL8192F - if (IS_HARDWARE_TYPE_8192F(adapter)){ - SET_H2CCMD_REMOTE_WAKE_CTRL_FW_UNICAST_EN( - u1H2CRemoteWakeCtrlParm, enable); - } - #endif /* CONFIG_RTL8192F */ - + if ((psecuritypriv->dot11PrivacyAlgrthm == _AES_) || (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_) || (psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_)) { @@ -5524,12 +5443,12 @@ static u8 rtw_hal_set_remote_wake_ctrl_cmd(_adapter *adapter, u8 enable) SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_ACTION( u1H2CRemoteWakeCtrlParm, 1); } - + if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_ && psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) { SET_H2CCMD_REMOTE_WAKE_CTRL_TKIP_OFFLOAD_EN( u1H2CRemoteWakeCtrlParm, enable); - + if (IS_HARDWARE_TYPE_8188E(adapter) || IS_HARDWARE_TYPE_8812(adapter)) { SET_H2CCMD_REMOTE_WAKE_CTRL_TKIP_OFFLOAD_EN( @@ -5538,7 +5457,7 @@ static u8 rtw_hal_set_remote_wake_ctrl_cmd(_adapter *adapter, u8 enable) u1H2CRemoteWakeCtrlParm, 1); } } - + SET_H2CCMD_REMOTE_WAKE_CTRL_FW_PARSING_UNTIL_WAKEUP( u1H2CRemoteWakeCtrlParm, 1); } @@ -5550,7 +5469,7 @@ static u8 rtw_hal_set_remote_wake_ctrl_cmd(_adapter *adapter, u8 enable) u1H2CRemoteWakeCtrlParm, enable); } #endif - + #ifdef CONFIG_P2P_WOWLAN if (_TRUE == ppwrpriv->wowlan_p2p_mode) { RTW_INFO("P2P OFFLOAD ENABLE\n"); @@ -5562,7 +5481,6 @@ static u8 rtw_hal_set_remote_wake_ctrl_cmd(_adapter *adapter, u8 enable) #endif /* CONFIG_P2P_WOWLAN */ } - ret = rtw_hal_fill_h2c_cmd(adapter, H2C_REMOTE_WAKE_CTRL, H2C_REMOTE_WAKE_CTRL_LEN, @@ -5633,8 +5551,8 @@ void rtw_hal_set_fw_wow_related_cmd(_adapter *padapter, u8 enable) u16 media_status_rpt; u8 pkt_type = 0, no_wake = 0; u8 ret = _SUCCESS; - - if(pregistry->suspend_type == FW_IPS_DISABLE_BBRF && + + if (pregistry->suspend_type == FW_IPS_DISABLE_BBRF && !check_fwstate(pmlmepriv, _FW_LINKED)) no_wake = 1; @@ -5643,7 +5561,7 @@ void rtw_hal_set_fw_wow_related_cmd(_adapter *padapter, u8 enable) rtw_hal_set_wowlan_ctrl_cmd(padapter, enable, _FALSE); if (enable) { - if(!no_wake) + if (!no_wake) rtw_hal_set_global_info_cmd(padapter, psecpriv->dot118021XGrpPrivacy, psecpriv->dot11PrivacyAlgrthm); @@ -6709,7 +6627,6 @@ static void rtw_hal_construct_P2PNegoRsp(_adapter *padapter, u8 *pframe, u32 *pL /* 8. Device Info */ /* 9. Group ID ( Only GO ) */ - /* ToDo: */ /* P2P Status */ @@ -7004,7 +6921,6 @@ static void rtw_hal_construct_P2PInviteRsp(_adapter *padapter, u8 *pframe, u32 * #ifdef CONFIG_WFD u32 wfdielen = 0; #endif - /* struct xmit_frame *pmgntframe; */ /* struct pkt_attrib *pattrib; */ /* unsigned char *pframe; */ @@ -7019,7 +6935,6 @@ static void rtw_hal_construct_P2PInviteRsp(_adapter *padapter, u8 *pframe, u32 * u8 *dbgbuf = pframe; u8 dbgbufLen = 0, index = 0; - RTW_INFO("%s\n", __FUNCTION__); pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -7219,7 +7134,6 @@ static void rtw_hal_construct_P2PInviteRsp(_adapter *padapter, u8 *pframe, u32 * pframe += wfdielen; pktlen += wfdielen; #endif - *pLength = pktlen; #if 0 @@ -7235,7 +7149,6 @@ static void rtw_hal_construct_P2PInviteRsp(_adapter *padapter, u8 *pframe, u32 * #endif } - static void rtw_hal_construct_P2PProvisionDisRsp(_adapter *padapter, u8 *pframe, u32 *pLength) { unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; @@ -7549,7 +7462,6 @@ static void rtw_hal_construct_PSPoll(_adapter *padapter, *pLength = 16; } - #ifdef DBG_FW_DEBUG_MSG_PKT void rtw_hal_construct_fw_dbg_msg_pkt( PADAPTER padapter, @@ -11849,7 +11761,6 @@ void GetHwReg(_adapter *adapter, u8 variable, u8 *val) HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter); u64 val64; - switch (variable) { case HW_VAR_MAC_ADDR: rtw_hal_get_macaddr_port(adapter, val); @@ -11859,7 +11770,7 @@ void GetHwReg(_adapter *adapter, u8 variable, u8 *val) break; case HW_VAR_RF_TYPE: *((u8 *)val) = hal_data->rf_type; -#ifdef CONFIG_CUSTOMER01_SMART_ANTENNA +#ifdef CONFIG_CUSTOMER01_SMART_ANTENNA *((u8 *)val) = RF_1T1R; #endif break; @@ -12001,13 +11912,13 @@ u8 rtw_hal_query_txbfee_rf_num(_adapter *adapter) HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter); - if ((pregistrypriv->beamformee_rf_num) && (IS_HARDWARE_TYPE_8814AE(adapter) || IS_HARDWARE_TYPE_8814AU(adapter) || IS_HARDWARE_TYPE_8822BU(adapter) || IS_HARDWARE_TYPE_8821C(adapter))) + if ((pregistrypriv->beamformee_rf_num) && (IS_HARDWARE_TYPE_8814AE(adapter) || IS_HARDWARE_TYPE_8814AU(adapter))) return pregistrypriv->beamformee_rf_num; else if (IS_HARDWARE_TYPE_8814AE(adapter) || IS_HARDWARE_TYPE_8814AU(adapter)) { if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_BROADCOM) return 2; else - return 2;/*TODO: May be 3 in the future, by ChenYu. */ + return 2; /*TODO: May be 3 in the future, by ChenYu. */ } else return 1; @@ -13118,7 +13029,7 @@ void dm_DynamicUsbTxAgg(_adapter *padapter, u8 from_timer) if (IS_HARDWARE_TYPE_8822BU(padapter) || IS_HARDWARE_TYPE_8821CU(padapter)) rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, NULL); #else /* !RTW_HALMAC */ - if (IS_HARDWARE_TYPE_8821U(padapter)) { /* || IS_HARDWARE_TYPE_8192EU(padapter)) */ + if (IS_HARDWARE_TYPE_8821U(padapter)) { /* This AGG_PH_TH only for UsbRxAggMode == USB_RX_AGG_USB */ if ((pHalData->rxagg_mode == RX_AGG_USB) && (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE)) { if (pdvobjpriv->traffic_stat.cur_tx_tp > 2 && pdvobjpriv->traffic_stat.cur_rx_tp < 30) @@ -13770,7 +13681,7 @@ void update_IOT_info(_adapter *padapter) } } -#ifdef CONFIG_RTS_FULL_BW +#ifdef CONFIG_RTS_FULL_BW /* 8188E: not support full RTS BW feature(mac REG no define 480[5]) */ @@ -13788,27 +13699,27 @@ void rtw_set_rts_bw(_adapter *padapter) { station = NULL; station = macid_ctl->sta[i]; - if(station) { - + if (station) { + _adapter *sta_adapter =station->padapter; struct mlme_ext_priv *pmlmeext = &(sta_adapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - - if ( pmlmeinfo->state != WIFI_FW_NULL_STATE) { - if(_rtw_memcmp(macid_ctl->sta[i]->cmn.mac_addr, bc_addr, ETH_ALEN) != _TRUE) { - if ( macid_ctl->sta[i]->vendor_8812) { + + if (pmlmeinfo->state != WIFI_FW_NULL_STATE) { + if (_rtw_memcmp(macid_ctl->sta[i]->cmn.mac_addr, bc_addr, ETH_ALEN) != _TRUE) { + if (macid_ctl->sta[i]->vendor_8812) { connect_to_8812 = _TRUE; enable = 0; - } - } + } + } } } } - if(connect_to_8812) + if (connect_to_8812) break; } - + RTW_INFO("%s connect_to_8812=%d,enable=%u\n", __FUNCTION__,connect_to_8812,enable); rtw_hal_set_hwreg(padapter, HW_VAR_SET_RTS_BW, &enable); }