diff --git a/Makefile b/Makefile index b64edaf..01ec855 100755 --- a/Makefile +++ b/Makefile @@ -111,7 +111,7 @@ CONFIG_RTW_SDIO_PM_KEEP_POWER = y ###################### MP HW TX MODE FOR VHT ####################### CONFIG_MP_VHT_HW_TX_MODE = n ###################### Platform Related ####################### -CONFIG_PLATFORM_ARM_NV_NANO = n +CONFIG_PLATFORM_ARM_NV_NANO = n CONFIG_PLATFORM_I386_PC = y CONFIG_PLATFORM_ARM_RPI = n CONFIG_PLATFORM_ANDROID_X86 = n @@ -1199,7 +1199,7 @@ endif ifeq ($(CONFIG_LED_CONTROL), y) EXTRA_CFLAGS += -DCONFIG_LED_CONTROL ifeq ($(CONFIG_RTL8822B), y) -EXTRA_CFLAGS += -DCONFIG_SW_LED +EXTRA_CFLAGS += -DCONFIG_SW_LED endif ifeq ($(CONFIG_LED_ENABLE), y) EXTRA_CFLAGS += -DCONFIG_LED_ENABLE diff --git a/README.md b/README.md index 2877da9..ee6c49e 100644 --- a/README.md +++ b/README.md @@ -138,8 +138,8 @@ EOF $ iwconfig wlx74ee2ae24062 IEEE 802.11an ESSID:"borg" Nickname:"" - Mode:Master Frequency:5.18 GHz Access Point: 74:EE:2A:E2:40:62 - Bit Rate:144.4 Mb/s Sensitivity:0/0 + Mode:Master Frequency:5.18 GHz Access Point: 74:EE:2A:E2:40:62 + Bit Rate:144.4 Mb/s Sensitivity:0/0 Retry:off RTS thr:off Fragment thr:off Power Management:off Link Quality=0/100 Signal level=-100 dBm Noise level=0 dBm diff --git a/core/efuse/rtw_efuse.c b/core/efuse/rtw_efuse.c index 44d8ac4..59b3464 100644 --- a/core/efuse/rtw_efuse.c +++ b/core/efuse/rtw_efuse.c @@ -931,7 +931,7 @@ void EFUSE_GetEfuseDefinition(PADAPTER adapter, u8 efusetype, u8 type, void *out *(u16 *)out = (u16)v32; return; - case TYPE_EFUSE_REAL_CONTENT_LEN: + case TYPE_EFUSE_REAL_CONTENT_LEN: rtw_halmac_get_physical_efuse_size(d, &v32); *(u16 *)out = (u16)v32; return; @@ -1035,7 +1035,7 @@ u8 rtw_efuse_bt_access(PADAPTER adapter, u8 write, u16 addr, u16 cnts, u8 *data) if (efuse) { err = rtw_halmac_read_bt_physical_efuse_map(d, efuse, size); - + if (err == -1) { RTW_ERR("%s: rtw_halmac_read_bt_physical_efuse_map fail!\n", __FUNCTION__); rtw_mfree(efuse, size); @@ -1309,7 +1309,7 @@ VOID hal_ReadEFuse_BT_logic_map( if (rtw_efuse_bt_access(padapter, _FALSE, 0, EFUSE_BT_REAL_CONTENT_LEN, phyefuse)) dump_buf(phyefuse, EFUSE_BT_REAL_BANK_CONTENT_LEN); - + total = BANK_NUM; for (bank = 1; bank <= total; bank++) { /* 8723d Max bake 0~2 */ eFuse_Addr = 0; @@ -1472,7 +1472,7 @@ static u8 hal_EfusePgPacketWrite2ByteHeader( /* RTW_INFO("%s: pg_header=0x%x\n", __FUNCTION__, pg_header); */ do { - + rtw_efuse_bt_access(padapter, _TRUE, efuse_addr, 1, &pg_header); rtw_efuse_bt_access(padapter, _FALSE, efuse_addr, 1, &tmp_header); @@ -1680,7 +1680,7 @@ u8 efuse_OneByteRead(struct _ADAPTER *a, u16 addr, u8 *data, u8 bPseudoTest) } return ret; - + } static u16 @@ -3093,7 +3093,7 @@ u8 rtw_efuse_file_read(PADAPTER padapter, u8 *filepatch, u8 *buf, u32 len) while ((j < len) && (i < count)) { if (ptmpbuf[i] == '\0') break; - + ptr = strpbrk(&ptmpbuf[i], " \t\n\r"); if (ptr) { if (ptr == &ptmpbuf[i]) { diff --git a/core/mesh/rtw_mesh.c b/core/mesh/rtw_mesh.c index 95d0f15..63a6954 100644 --- a/core/mesh/rtw_mesh.c +++ b/core/mesh/rtw_mesh.c @@ -198,7 +198,7 @@ int rtw_bss_is_candidate_mesh_peer(WLAN_BSSID_EX *self, WLAN_BSSID_EX *target, u /* BSSBasicRateSet */ for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { if (target->SupportedRates[i] == 0) - break; + break; if (target->SupportedRates[i] & 0x80) { u8 match = 0; @@ -208,7 +208,7 @@ int rtw_bss_is_candidate_mesh_peer(WLAN_BSSID_EX *self, WLAN_BSSID_EX *target, u match = rtw_is_basic_rate_ofdm(target->SupportedRates[i]); else match = rtw_is_basic_rate_mix(target->SupportedRates[i]); - } else { + } else { for (j = 0; j < NDIS_802_11_LENGTH_RATES_EX; j++) { if (self->SupportedRates[j] == 0) break; @@ -796,7 +796,7 @@ void rtw_mesh_peer_status_chk(_adapter *adapter) if (rtw_mesh_cto_mgate_required(adapter)) { flush = 1; goto flush_add; - } + } } } else { SET_CTO_MGATE_CONF_DISABLED(plink); @@ -953,7 +953,7 @@ exit: } /* - * this function is called under off channel candidate is required + * this function is called under off channel candidate is required * the channel with maximum candidate count is selected */ u8 rtw_mesh_select_operating_ch(_adapter *adapter) @@ -1191,7 +1191,7 @@ void rtw_mesh_sae_check_frames(_adapter *adapter, const u8 *buf, u32 len, u8 tx, #ifdef CONFIG_RTW_MESH_AEK static int rtw_mpm_ampe_dec(_adapter *adapter, struct mesh_plink_ent *plink , u8 *fhead, size_t flen, u8* fbody, u8 *mic_ie, u8 *ampe_buf) -{ +{ int ret = _FAIL, verify_ret; const u8 *aad[] = {adapter_mac_addr(adapter), plink->addr, fbody}; const size_t aad_len[] = {ETH_ALEN, ETH_ALEN, mic_ie - fbody}; @@ -1317,7 +1317,7 @@ static int rtw_mpm_tx_ies_sync_bss(_adapter *adapter, struct mesh_plink_ent *pli pos = BSS_EX_TLV_IES(network); while (left >= 2) { u8 id, elen; - + id = *pos++; elen = *pos++; left -= 2; @@ -1359,7 +1359,7 @@ static int rtw_mpm_tx_ies_sync_bss(_adapter *adapter, struct mesh_plink_ent *pli pos = BSS_EX_TLV_IES(network); while (left >= 2) { u8 id, elen; - + id = *pos++; elen = *pos++; left -= 2; @@ -1729,7 +1729,7 @@ bypass_sync_bss: plink->rx_conf_ies = ies; plink->rx_conf_ies_len = ies_len; } - #ifdef CONFIG_RTW_MESH_DRIVER_AID + #ifdef CONFIG_RTW_MESH_DRIVER_AID else { plink->tx_conf_ies = ies; plink->tx_conf_ies_len = ies_len; @@ -2433,7 +2433,7 @@ int rtw_mesh_peer_establish(_adapter *adapter, struct mesh_plink_ent *plink, str if (rtw_ap_parse_sta_supported_rates(adapter, sta, tlv_ies, tlv_ieslen) != _STATS_SUCCESSFUL_) goto exit; - + if (rtw_ap_parse_sta_security_ie(adapter, sta, &elems) != _STATS_SUCCESSFUL_) goto exit; @@ -3082,11 +3082,11 @@ void rtw_mesh_init_mesh_info(_adapter *adapter) _rtw_memset(minfo, 0, sizeof(struct rtw_mesh_info)); rtw_mesh_plink_ctl_init(adapter); - + minfo->last_preq = rtw_get_current_time(); /* minfo->last_sn_update = rtw_get_current_time(); */ minfo->next_perr = rtw_get_current_time(); - + ATOMIC_SET(&minfo->mpaths, 0); rtw_mesh_pathtbl_init(adapter); @@ -3099,7 +3099,7 @@ void rtw_mesh_init_mesh_info(_adapter *adapter) _rtw_init_listhead(&minfo->preq_queue.list); _rtw_spinlock_init(&minfo->mesh_preq_queue_lock); - + rtw_init_timer(&adapter->mesh_path_timer, adapter, rtw_ieee80211_mesh_path_timer, adapter); rtw_init_timer(&adapter->mesh_path_root_timer, adapter, rtw_ieee80211_mesh_path_root_timer, adapter); rtw_init_timer(&adapter->mesh_atlm_param_req_timer, adapter, rtw_mesh_atlm_param_req_timer, adapter); @@ -3260,7 +3260,7 @@ static bool rtw_mesh_data_bmc_to_uc(_adapter *adapter sta = LIST_CONTAINOR(list, struct sta_info, asoc_list); list = get_next(list); - + stainfo_offset = rtw_stainfo_offset(stapriv, sta); if (stainfo_offset_valid(stainfo_offset)) b2u_sta_id[b2u_sta_num++] = stainfo_offset; @@ -3342,7 +3342,7 @@ int rtw_mesh_addr_resolve(_adapter *adapter, struct xmit_frame *xframe, _pkt *pk res = _FAIL; goto exit; } - + xframe->pkt = pkt; #if CONFIG_RTW_MESH_DATA_BMC_TO_UC _rtw_init_listhead(b2u_list); @@ -3350,9 +3350,9 @@ int rtw_mesh_addr_resolve(_adapter *adapter, struct xmit_frame *xframe, _pkt *pk is_da_mcast = IS_MCAST(etherhdr.h_dest); if (!is_da_mcast) { - struct sta_info *next_hop; + struct sta_info *next_hop; bool mpp_lookup = 1; - + mpath = rtw_mesh_path_lookup(adapter, etherhdr.h_dest); if (mpath) { mpp_lookup = 0; @@ -3452,7 +3452,7 @@ s8 rtw_mesh_tx_set_whdr_mctrl_len(u8 mesh_frame_mode, struct pkt_attrib *attrib) RTW_WARN("Invalid mesh frame mode:%u\n", mesh_frame_mode); ret = -1; break; - } + } return ret; } @@ -3538,7 +3538,7 @@ u8 rtw_mesh_tx_build_whdr(_adapter *adapter, struct pkt_attrib *attrib RTW_WARN("Invalid mesh frame mode\n"); break; } - + return 0; } @@ -3681,7 +3681,7 @@ int rtw_mesh_rx_data_validate_mctrl(_adapter *adapter, union recv_frame *rframe } else *mctrl_len = mlen; - return ret; + return ret; } inline int rtw_mesh_rx_validate_mctrl_non_amsdu(_adapter *adapter, union recv_frame *rframe) @@ -3766,7 +3766,7 @@ int rtw_mesh_rx_msdu_act_check(union recv_frame *rframe struct rtw_mesh_info *minfo = &adapter->mesh_info; struct rx_pkt_attrib *rattrib = &rframe->u.hdr.attrib; struct rtw_mesh_path *mppath; - u8 is_mda_bmc = IS_MCAST(mda); + u8 is_mda_bmc = IS_MCAST(mda); u8 is_mda_self = !is_mda_bmc && _rtw_memcmp(mda, adapter_mac_addr(adapter), ETH_ALEN); struct xmit_frame *xframe; struct pkt_attrib *xattrib; diff --git a/core/mesh/rtw_mesh.h b/core/mesh/rtw_mesh.h index 73694f8..ad2d986 100644 --- a/core/mesh/rtw_mesh.h +++ b/core/mesh/rtw_mesh.h @@ -376,7 +376,7 @@ struct rtw_mesh_info { systime next_perr; /* Last used Path Discovery ID */ u32 preq_id; - + ATOMIC_T mpaths; struct rtw_mesh_table *mesh_paths; struct rtw_mesh_table *mpp_paths; diff --git a/core/mesh/rtw_mesh_hwmp.c b/core/mesh/rtw_mesh_hwmp.c index f64aa3d..6dfa701 100644 --- a/core/mesh/rtw_mesh_hwmp.c +++ b/core/mesh/rtw_mesh_hwmp.c @@ -210,7 +210,7 @@ static int rtw_mesh_path_sel_frame_tx(enum rtw_mpath_frame_type mpath_action, u8 const u8 *originator_addr, u32 originator_sn, u8 target_flags, const u8 *target, u32 target_sn, const u8 *da, u8 hopcount, u8 ttl, - u32 lifetime, u32 metric, u32 preq_id, + u32 lifetime, u32 metric, u32 preq_id, _adapter *adapter) { struct xmit_priv *pxmitpriv = &(adapter->xmitpriv); @@ -390,7 +390,7 @@ int rtw_mesh_path_error_tx(_adapter *adapter, dump_mgntframe(adapter, pmgntframe); RTW_HWMP_DBG("TX PERR toward "MAC_FMT", ra = "MAC_FMT"\n", MAC_ARG(target), MAC_ARG(ra)); - + return 0; } @@ -616,7 +616,7 @@ void rtw_ieee80211s_update_metric(_adapter *adapter, u8 mac_id, sta->metrics.total_pkt = total_pkt; rtw_ewma_err_rate_add(&sta->metrics.err_rate, per); - if (rtw_ewma_err_rate_read(&sta->metrics.err_rate) > + if (rtw_ewma_err_rate_read(&sta->metrics.err_rate) > RTW_LINK_FAIL_THRESH) rtw_mesh_plink_broken(sta); } @@ -1018,7 +1018,7 @@ static void rtw_hwmp_rann_frame_process(_adapter *adapter, _rtw_memcpy(path->add_chk_rann_snd_addr, path->rann_snd_addr, ETH_ALEN); preq_node_flag |= RTW_PREQ_Q_F_CHK; - + } #endif rtw_mesh_queue_preq(path, preq_node_flag); @@ -1159,7 +1159,7 @@ static u32 rtw_hwmp_route_info_get(_adapter *adapter, rtw_mesh_path_activate(path); #ifdef CONFIG_RTW_MESH_ADD_ROOT_CHK if (path->is_root && (action == RTW_MPATH_PREP)) { - _rtw_memcpy(path->rann_snd_addr, + _rtw_memcpy(path->rann_snd_addr, mgmt->addr2, ETH_ALEN); path->rann_metric = new_metric; } diff --git a/core/mesh/rtw_mesh_pathtbl.c b/core/mesh/rtw_mesh_pathtbl.c index 40c6d4a..1e5f836 100644 --- a/core/mesh/rtw_mesh_pathtbl.c +++ b/core/mesh/rtw_mesh_pathtbl.c @@ -829,7 +829,7 @@ static void rtw_table_flush_by_iface(struct rtw_mesh_table *tbl) if (!tbl) return; - + ret = rtw_rhashtable_walk_enter(&tbl->rhead, &iter); if (ret) return; diff --git a/core/mesh/rtw_mesh_pathtbl.h b/core/mesh/rtw_mesh_pathtbl.h index 7f5a26b..497c0c0 100644 --- a/core/mesh/rtw_mesh_pathtbl.h +++ b/core/mesh/rtw_mesh_pathtbl.h @@ -42,7 +42,7 @@ * With this flag, It will try the last used rann_snd_addr * @RTW_MESH_PATH_PEER_AKA: only used toward a peer, only used in active keep * alive mechanism. PREQ's da = path dst - * + * * RTW_MESH_PATH_RESOLVED is used by the mesh path timer to * decide when to stop or cancel the mesh path discovery. */ diff --git a/core/rtw_ap.c b/core/rtw_ap.c index 88c4291..1aebe07 100644 --- a/core/rtw_ap.c +++ b/core/rtw_ap.c @@ -59,7 +59,7 @@ u8 rtw_set_tim_ie(u8 dtim_cnt, u8 dtim_period if (tim_bmp[i]) break; n1 = i & 0xFE; - + /* find the last nonzero octet in tim_bitmap, except octet 0 */ for (i = tim_bmp_len - 1; i > 0; i--) if (tim_bmp[i]) @@ -359,7 +359,7 @@ static void rtw_check_restore_rf18(_adapter *padapter) struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); u32 reg; u8 union_ch = 0, union_bw = 0, union_offset = 0, setchbw = _FALSE; - + reg = rtw_hal_read_rfreg(padapter, 0, 0x18, 0x3FF); if ((reg & 0xFF) == 0) setchbw = _TRUE; @@ -1515,7 +1515,7 @@ static void rtw_ap_check_scan(_adapter *padapter) if (_FALSE == ATOMIC_READ(&pmlmepriv->olbc_ht)) ATOMIC_SET(&pmlmepriv->olbc_ht, _TRUE); - + if (padapter->registrypriv.wifi_spec) RTW_INFO("%s: %s is a/b/g ap\n", __func__, pnetwork->network.Ssid.Ssid); } @@ -1732,7 +1732,7 @@ chbw_decision: #ifdef CONFIG_MCC_MODE if (MCC_EN(padapter)) { - /* + /* * due to check under rtw_ap_chbw_decision * if under MCC mode, means req channel setting is the same as current channel setting * if not under MCC mode, mean req channel setting is not the same as current channel setting @@ -2044,7 +2044,7 @@ int rtw_check_beacon_data(_adapter *padapter, u8 *pbuf, int len) pbss_network->IELength = pbss_network->IELength - *(p+1) - 2; ret_rm = rtw_ies_remove_ie(ie , &len, _BEACON_IE_OFFSET_, _ERPINFO_IE_,NULL,0); RTW_DBG("%s, remove_ie of ERP_IE=%d\n", __FUNCTION__, ret_rm); - } else + } else ERP_IE_handler(padapter, (PNDIS_802_11_VARIABLE_IEs)p); } @@ -2075,7 +2075,7 @@ int rtw_check_beacon_data(_adapter *padapter, u8 *pbuf, int len) psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher; /* - Kernel < v5.1, the auth_type set as NL80211_AUTHTYPE_AUTOMATIC + Kernel < v5.1, the auth_type set as NL80211_AUTHTYPE_AUTOMATIC in cfg80211_rtw_start_ap(). if the AKM SAE in the RSN IE, we have to update the auth_type for SAE in rtw_check_beacon_data(). @@ -4704,7 +4704,7 @@ u8 rtw_ap_chbw_decision(_adapter *adapter, u8 ifbmp, u8 excl_ifbmp rtw_hal_set_mcc_setting_disconnect(adapter); } - } + } } #endif /* CONFIG_MCC_MODE */ @@ -4827,7 +4827,7 @@ u8 rtw_ap_chbw_decision(_adapter *adapter, u8 ifbmp, u8 excl_ifbmp u8 tmp_ch = dec_ch[i]; u8 tmp_bw = dec_bw[i]; u8 tmp_offset = dec_offset[i]; - + rtw_adjust_chbw(adapter, tmp_ch, &tmp_bw, &tmp_offset); rtw_get_offset_by_chbw(tmp_ch, tmp_bw, &tmp_offset); @@ -5256,7 +5256,7 @@ u16 rtw_ap_parse_sta_security_ie(_adapter *adapter, struct sta_info *sta, struct sta->flags |= WLAN_STA_MFP; } else #endif - if ((sec->mfp_opt == MFP_REQUIRED && mfp_opt == MFP_NO) || mfp_opt == MFP_INVALID) + if ((sec->mfp_opt == MFP_REQUIRED && mfp_opt == MFP_NO) || mfp_opt == MFP_INVALID) status = WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION; else if (sec->mfp_opt >= MFP_OPTIONAL && mfp_opt >= MFP_OPTIONAL) sta->flags |= WLAN_STA_MFP; diff --git a/core/rtw_btcoex.c b/core/rtw_btcoex.c index d5b89bd..28e5600 100644 --- a/core/rtw_btcoex.c +++ b/core/rtw_btcoex.c @@ -506,7 +506,7 @@ u8 rtw_btcoex_get_ant_div_cfg(PADAPTER padapter) PHAL_DATA_TYPE pHalData; pHalData = GET_HAL_DATA(padapter); - + return (pHalData->AntDivCfg == 0) ? _FALSE : _TRUE; } diff --git a/core/rtw_chplan.c b/core/rtw_chplan.c index 86777b1..e090434 100644 --- a/core/rtw_chplan.c +++ b/core/rtw_chplan.c @@ -1,1184 +1,1184 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2018 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - *****************************************************************************/ -#define _RTW_CHPLAN_C_ - -#include - -#define RTW_DOMAIN_MAP_VER "35e" -#define RTW_COUNTRY_MAP_VER "18" - -#ifdef LEGACY_CHANNEL_PLAN_REF -/******************************************************** -ChannelPlan definitions -*********************************************************/ -static RT_CHANNEL_PLAN legacy_channel_plan[] = { - /* 0x00, RTW_CHPLAN_FCC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165}, 32}, - /* 0x01, RTW_CHPLAN_IC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165}, 31}, - /* 0x02, RTW_CHPLAN_ETSI */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 32}, - /* 0x03, RTW_CHPLAN_SPAIN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, - /* 0x04, RTW_CHPLAN_FRANCE */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, - /* 0x05, RTW_CHPLAN_MKK */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, - /* 0x06, RTW_CHPLAN_MKK1 */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, - /* 0x07, RTW_CHPLAN_ISRAEL */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, - /* 0x08, RTW_CHPLAN_TELEC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, - /* 0x09, RTW_CHPLAN_GLOBAL_DOAMIN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}, - /* 0x0A, RTW_CHPLAN_WORLD_WIDE_13 */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, - /* 0x0B, RTW_CHPLAN_TAIWAN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165}, 26}, - /* 0x0C, RTW_CHPLAN_CHINA */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 149, 153, 157, 161, 165}, 18}, - /* 0x0D, RTW_CHPLAN_SINGAPORE_INDIA_MEXICO */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24}, - /* 0x0E, RTW_CHPLAN_KOREA */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161, 165}, 31}, - /* 0x0F, RTW_CHPLAN_TURKEY */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64}, 19}, - /* 0x10, RTW_CHPLAN_JAPAN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 32}, - /* 0x11, RTW_CHPLAN_FCC_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 149, 153, 157, 161, 165}, 20}, - /* 0x12, RTW_CHPLAN_JAPAN_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48}, 17}, - /* 0x13, RTW_CHPLAN_WORLD_WIDE_5G */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165}, 37}, - /* 0x14, RTW_CHPLAN_TAIWAN_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 56, 60, 64, 149, 153, 157, 161, 165}, 19}, -}; -#endif - -enum rtw_rd_2g { - RTW_RD_2G_NULL = 0, - RTW_RD_2G_WORLD = 1, /* Worldwird 13 */ - RTW_RD_2G_ETSI1 = 2, /* Europe */ - RTW_RD_2G_FCC1 = 3, /* US */ - RTW_RD_2G_MKK1 = 4, /* Japan */ - RTW_RD_2G_ETSI2 = 5, /* France */ - RTW_RD_2G_GLOBAL = 6, /* Global domain */ - RTW_RD_2G_MKK2 = 7, /* Japan */ - RTW_RD_2G_FCC2 = 8, /* US */ - RTW_RD_2G_IC1 = 9, /* Canada */ - RTW_RD_2G_WORLD1 = 10, /* Worldwide 11 */ - RTW_RD_2G_KCC1 = 11, /* Korea */ - - RTW_RD_2G_MAX, -}; - -enum rtw_rd_5g { - RTW_RD_5G_NULL = 0, /* */ - RTW_RD_5G_ETSI1 = 1, /* Europe */ - RTW_RD_5G_ETSI2 = 2, /* Australia, New Zealand */ - RTW_RD_5G_ETSI3 = 3, /* Russia */ - RTW_RD_5G_FCC1 = 4, /* US */ - RTW_RD_5G_FCC2 = 5, /* FCC w/o DFS Channels */ - RTW_RD_5G_FCC3 = 6, /* Bolivia, Chile, El Salvador, Venezuela */ - RTW_RD_5G_FCC4 = 7, /* Venezuela */ - RTW_RD_5G_FCC5 = 8, /* China */ - RTW_RD_5G_FCC6 = 9, /* */ - RTW_RD_5G_FCC7 = 10, /* US(w/o Weather radar) */ - RTW_RD_5G_IC1 = 11, /* Canada(w/o Weather radar) */ - RTW_RD_5G_KCC1 = 12, /* Korea */ - RTW_RD_5G_MKK1 = 13, /* Japan */ - RTW_RD_5G_MKK2 = 14, /* Japan (W52, W53) */ - RTW_RD_5G_MKK3 = 15, /* Japan (W56) */ - RTW_RD_5G_NCC1 = 16, /* Taiwan, (w/o Weather radar) */ - RTW_RD_5G_NCC2 = 17, /* Taiwan, Band2, Band4 */ - RTW_RD_5G_NCC3 = 18, /* Taiwan w/o DFS, Band4 only */ - RTW_RD_5G_ETSI4 = 19, /* Europe w/o DFS, Band1 only */ - RTW_RD_5G_ETSI5 = 20, /* Australia, New Zealand(w/o Weather radar) */ - RTW_RD_5G_FCC8 = 21, /* Latin America */ - RTW_RD_5G_ETSI6 = 22, /* Israel, Bahrain, Egypt, India, China, Malaysia */ - RTW_RD_5G_ETSI7 = 23, /* China */ - RTW_RD_5G_ETSI8 = 24, /* Jordan */ - RTW_RD_5G_ETSI9 = 25, /* Lebanon */ - RTW_RD_5G_ETSI10 = 26, /* Qatar */ - RTW_RD_5G_ETSI11 = 27, /* Russia */ - RTW_RD_5G_NCC4 = 28, /* Taiwan, (w/o Weather radar) */ - RTW_RD_5G_ETSI12 = 29, /* Indonesia */ - RTW_RD_5G_FCC9 = 30, /* (w/o Weather radar) */ - RTW_RD_5G_ETSI13 = 31, /* (w/o Weather radar) */ - RTW_RD_5G_FCC10 = 32, /* Argentina(w/o Weather radar) */ - RTW_RD_5G_MKK4 = 33, /* Japan (W52) */ - RTW_RD_5G_ETSI14 = 34, /* Russia */ - RTW_RD_5G_FCC11 = 35, /* US(include CH144) */ - RTW_RD_5G_ETSI15 = 36, /* Malaysia */ - RTW_RD_5G_MKK5 = 37, /* Japan */ - RTW_RD_5G_ETSI16 = 38, /* Europe */ - RTW_RD_5G_ETSI17 = 39, /* Europe */ - RTW_RD_5G_FCC12 = 40, /* FCC */ - RTW_RD_5G_FCC13 = 41, /* FCC */ - RTW_RD_5G_FCC14 = 42, /* FCC w/o Weather radar(w/o 5600~5650MHz) */ - RTW_RD_5G_FCC15 = 43, /* FCC w/o Band3 */ - RTW_RD_5G_FCC16 = 44, /* FCC w/o Band3 */ - RTW_RD_5G_ETSI18 = 45, /* ETSI w/o DFS Band2&3 */ - RTW_RD_5G_ETSI19 = 46, /* Europe */ - RTW_RD_5G_FCC17 = 47, /* FCC w/o Weather radar(w/o 5600~5650MHz) */ - RTW_RD_5G_ETSI20 = 48, /* Europe */ - RTW_RD_5G_IC2 = 49, /* Canada(w/o Weather radar), include ch144 */ - RTW_RD_5G_ETSI21 = 50, /* Australia, New Zealand(w/o Weather radar) */ - RTW_RD_5G_FCC18 = 51, /* */ - RTW_RD_5G_WORLD = 52, /* Worldwide */ - RTW_RD_5G_CHILE1 = 53, /* Chile */ - RTW_RD_5G_ACMA1 = 54, /* Australia, New Zealand (w/o Weather radar) (w/o Ch120~Ch128) */ - RTW_RD_5G_WORLD1 = 55, /* 5G Worldwide Band1&2 */ - RTW_RD_5G_CHILE2 = 56, /* Chile (Band2,Band3) */ - RTW_RD_5G_KCC2 = 57, /* Korea (New standard) */ - - /* === Below are driver defined for legacy channel plan compatible, DON'T assign index ==== */ - RTW_RD_5G_OLD_FCC1, - RTW_RD_5G_OLD_NCC1, - RTW_RD_5G_OLD_KCC1, - - RTW_RD_5G_MAX, -}; - -struct ch_list_t { - u8 *len_ch; -}; - -#define CH_LIST_ENT(_len, arg...) \ - {.len_ch = (u8[_len + 1]) {_len, ##arg}, } - -#define CH_LIST_LEN(_ch_list) (_ch_list.len_ch[0]) -#define CH_LIST_CH(_ch_list, _i) (_ch_list.len_ch[_i + 1]) - -struct chplan_ent_t { - u8 rd_2g; -#ifdef CONFIG_IEEE80211_BAND_5GHZ - u8 rd_5g; -#endif - u8 regd; /* value of REGULATION_TXPWR_LMT */ -}; - -#ifdef CONFIG_IEEE80211_BAND_5GHZ -#define CHPLAN_ENT(i2g, i5g, regd) {i2g, i5g, regd} -#else -#define CHPLAN_ENT(i2g, i5g, regd) {i2g, regd} -#endif - -static struct ch_list_t RTW_ChannelPlan2G[] = { - /* 0, RTW_RD_2G_NULL */ CH_LIST_ENT(0), - /* 1, RTW_RD_2G_WORLD */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), - /* 2, RTW_RD_2G_ETSI1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), - /* 3, RTW_RD_2G_FCC1 */ CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), - /* 4, RTW_RD_2G_MKK1 */ CH_LIST_ENT(14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), - /* 5, RTW_RD_2G_ETSI2 */ CH_LIST_ENT(4, 10, 11, 12, 13), - /* 6, RTW_RD_2G_GLOBAL */ CH_LIST_ENT(14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), - /* 7, RTW_RD_2G_MKK2 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), - /* 8, RTW_RD_2G_FCC2 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), - /* 9, RTW_RD_2G_IC1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), - /* 10, RTW_RD_2G_WORLD1 */ CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), - /* 11, RTW_RD_2G_KCC1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), -}; - -#ifdef CONFIG_IEEE80211_BAND_5GHZ -static struct ch_list_t RTW_ChannelPlan5G[] = { - /* 0, RTW_RD_5G_NULL */ CH_LIST_ENT(0), - /* 1, RTW_RD_5G_ETSI1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140), - /* 2, RTW_RD_5G_ETSI2 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - /* 3, RTW_RD_5G_ETSI3 */ CH_LIST_ENT(22, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 149, 153, 157, 161, 165), - /* 4, RTW_RD_5G_FCC1 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - /* 5, RTW_RD_5G_FCC2 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165), - /* 6, RTW_RD_5G_FCC3 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165), - /* 7, RTW_RD_5G_FCC4 */ CH_LIST_ENT(12, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161), - /* 8, RTW_RD_5G_FCC5 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165), - /* 9, RTW_RD_5G_FCC6 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64), - /* 10, RTW_RD_5G_FCC7 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 11, RTW_RD_5G_IC1 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 12, RTW_RD_5G_KCC1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161), - /* 13, RTW_RD_5G_MKK1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140), - /* 14, RTW_RD_5G_MKK2 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64), - /* 15, RTW_RD_5G_MKK3 */ CH_LIST_ENT(11, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140), - /* 16, RTW_RD_5G_NCC1 */ CH_LIST_ENT(16, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 17, RTW_RD_5G_NCC2 */ CH_LIST_ENT(8, 56, 60, 64, 149, 153, 157, 161, 165), - /* 18, RTW_RD_5G_NCC3 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165), - /* 19, RTW_RD_5G_ETSI4 */ CH_LIST_ENT(4, 36, 40, 44, 48), - /* 20, RTW_RD_5G_ETSI5 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 21, RTW_RD_5G_FCC8 */ CH_LIST_ENT(4, 149, 153, 157, 161), - /* 22, RTW_RD_5G_ETSI6 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64), - /* 23, RTW_RD_5G_ETSI7 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165), - /* 24, RTW_RD_5G_ETSI8 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165), - /* 25, RTW_RD_5G_ETSI9 */ CH_LIST_ENT(11, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140), - /* 26, RTW_RD_5G_ETSI10 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165), - /* 27, RTW_RD_5G_ETSI11 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140, 149, 153, 157, 161, 165), - /* 28, RTW_RD_5G_NCC4 */ CH_LIST_ENT(17, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 29, RTW_RD_5G_ETSI12 */ CH_LIST_ENT(4, 149, 153, 157, 161), - /* 30, RTW_RD_5G_FCC9 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 31, RTW_RD_5G_ETSI13 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140), - /* 32, RTW_RD_5G_FCC10 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161), - /* 33, RTW_RD_5G_MKK4 */ CH_LIST_ENT(4, 36, 40, 44, 48), - /* 34, RTW_RD_5G_ETSI14 */ CH_LIST_ENT(11, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140), - /* 35, RTW_RD_5G_FCC11 */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165), - /* 36, RTW_RD_5G_ETSI15 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 149, 153, 157, 161, 165), - /* 37, RTW_RD_5G_MKK5 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - /* 38, RTW_RD_5G_ETSI16 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - /* 39, RTW_RD_5G_ETSI17 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - /* 40, RTW_RD_5G_FCC12*/ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - /* 41, RTW_RD_5G_FCC13 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - /* 42, RTW_RD_5G_FCC14 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 43, RTW_RD_5G_FCC15 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165), - /* 44, RTW_RD_5G_FCC16 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165), - /* 45, RTW_RD_5G_ETSI18 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165), - /* 46, RTW_RD_5G_ETSI19 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - /* 47, RTW_RD_5G_FCC17 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140), - /* 48, RTW_RD_5G_ETSI20 */ CH_LIST_ENT(9, 52, 56, 60, 64, 149, 153, 157, 161, 165), - /* 49, RTW_RD_5G_IC2 */ CH_LIST_ENT(22, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 144, 149, 153, 157, 161, 165), - /* 50, RTW_RD_5G_ETSI21 */ CH_LIST_ENT(13, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 51, RTW_RD_5G_FCC18 */ CH_LIST_ENT(8, 100, 104, 108, 112, 116, 132, 136, 140), - /* 52, RTW_RD_5G_WORLD */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165), - /* 53, RTW_RD_5G_CHILE1 */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165), - /* 54, RTW_RD_5G_ACMA1 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), - /* 55, RTW_RD_5G_WORLD1 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64), - /* 56, RTW_RD_5G_CHILE2 */ CH_LIST_ENT(16, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144), - /* 57, RTW_RD_5G_KCC2 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), - - /* === Below are driver defined for legacy channel plan compatible, NO static index assigned ==== */ - /* RTW_RD_5G_OLD_FCC1 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165), - /* RTW_RD_5G_OLD_NCC1 */ CH_LIST_ENT(15, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165), - /* RTW_RD_5G_OLD_KCC1 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161, 165), -}; -#endif /* CONFIG_IEEE80211_BAND_5GHZ */ - -static struct chplan_ent_t RTW_ChannelPlanMap[RTW_CHPLAN_MAX] = { - /* ===== 0x00 ~ 0x1F, legacy channel plan ===== */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_KCC1, TXPWR_LMT_FCC), /* 0x00, RTW_CHPLAN_FCC */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_FCC1, TXPWR_LMT_FCC), /* 0x01, RTW_CHPLAN_IC */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x02, RTW_CHPLAN_ETSI */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x03, RTW_CHPLAN_SPAIN */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x04, RTW_CHPLAN_FRANCE */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x05, RTW_CHPLAN_MKK */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x06, RTW_CHPLAN_MKK1 */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC6, TXPWR_LMT_ETSI), /* 0x07, RTW_CHPLAN_ISRAEL */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_FCC6, TXPWR_LMT_MKK), /* 0x08, RTW_CHPLAN_TELEC */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x09, RTW_CHPLAN_GLOBAL_DOAMIN */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x0A, RTW_CHPLAN_WORLD_WIDE_13 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_NCC1, TXPWR_LMT_FCC), /* 0x0B, RTW_CHPLAN_TAIWAN */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC5, TXPWR_LMT_ETSI), /* 0x0C, RTW_CHPLAN_CHINA */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC3, TXPWR_LMT_WW), /* 0x0D, RTW_CHPLAN_SINGAPORE_INDIA_MEXICO */ /* ETSI:Singapore, India. FCC:Mexico => WW */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_KCC1, TXPWR_LMT_ETSI), /* 0x0E, RTW_CHPLAN_KOREA */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC6, TXPWR_LMT_ETSI), /* 0x0F, RTW_CHPLAN_TURKEY */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_MKK), /* 0x10, RTW_CHPLAN_JAPAN */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x11, RTW_CHPLAN_FCC_NO_DFS */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC7, TXPWR_LMT_MKK), /* 0x12, RTW_CHPLAN_JAPAN_NO_DFS */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC1, TXPWR_LMT_WW), /* 0x13, RTW_CHPLAN_WORLD_WIDE_5G */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC2, TXPWR_LMT_FCC), /* 0x14, RTW_CHPLAN_TAIWAN_NO_DFS */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC7, TXPWR_LMT_ETSI), /* 0x15, RTW_CHPLAN_ETSI_NO_DFS */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NCC1, TXPWR_LMT_ETSI), /* 0x16, RTW_CHPLAN_KOREA_NO_DFS */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_FCC7, TXPWR_LMT_MKK), /* 0x17, RTW_CHPLAN_JAPAN_NO_DFS */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_FCC5, TXPWR_LMT_ETSI), /* 0x18, RTW_CHPLAN_PAKISTAN_NO_DFS */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x19, RTW_CHPLAN_TAIWAN2_NO_DFS */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1A, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1B, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1C, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1D, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1E, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_FCC1, TXPWR_LMT_WW), /* 0x1F, RTW_CHPLAN_WORLD_WIDE_ONLY_5G */ - - /* ===== 0x20 ~ 0x7F, new channel plan ===== */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x20, RTW_CHPLAN_WORLD_NULL */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x21, RTW_CHPLAN_ETSI1_NULL */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NULL, TXPWR_LMT_FCC), /* 0x22, RTW_CHPLAN_FCC1_NULL */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x23, RTW_CHPLAN_MKK1_NULL */ - CHPLAN_ENT(RTW_RD_2G_ETSI2, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x24, RTW_CHPLAN_ETSI2_NULL */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC1, TXPWR_LMT_FCC), /* 0x25, RTW_CHPLAN_FCC1_FCC1 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x26, RTW_CHPLAN_WORLD_ETSI1 */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK1, TXPWR_LMT_MKK), /* 0x27, RTW_CHPLAN_MKK1_MKK1 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_KCC1, TXPWR_LMT_KCC), /* 0x28, RTW_CHPLAN_WORLD_KCC1 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x29, RTW_CHPLAN_WORLD_FCC2 */ - CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_NULL, TXPWR_LMT_FCC), /* 0x2A, RTW_CHPLAN_FCC2_NULL */ - CHPLAN_ENT(RTW_RD_2G_IC1, RTW_RD_5G_IC2, TXPWR_LMT_IC), /* 0x2B, RTW_CHPLAN_IC1_IC2 */ - CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x2C, RTW_CHPLAN_MKK2_NULL */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_CHILE1, TXPWR_LMT_CHILE), /* 0x2D, RTW_CHPLAN_WORLD_CHILE1 */ - CHPLAN_ENT(RTW_RD_2G_WORLD1, RTW_RD_5G_WORLD1, TXPWR_LMT_WW), /* 0x2E, RTW_CHPLAN_WORLD1_WORLD1 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_CHILE2, TXPWR_LMT_CHILE), /* 0x2F, RTW_CHPLAN_WORLD_CHILE2 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC3, TXPWR_LMT_FCC), /* 0x30, RTW_CHPLAN_WORLD_FCC3 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC4, TXPWR_LMT_FCC), /* 0x31, RTW_CHPLAN_WORLD_FCC4 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x32, RTW_CHPLAN_WORLD_FCC5 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC6, TXPWR_LMT_FCC), /* 0x33, RTW_CHPLAN_WORLD_FCC6 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x34, RTW_CHPLAN_FCC1_FCC7 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI2, TXPWR_LMT_ETSI), /* 0x35, RTW_CHPLAN_WORLD_ETSI2 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI3, TXPWR_LMT_ETSI), /* 0x36, RTW_CHPLAN_WORLD_ETSI3 */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK2, TXPWR_LMT_MKK), /* 0x37, RTW_CHPLAN_MKK1_MKK2 */ - CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK3, TXPWR_LMT_MKK), /* 0x38, RTW_CHPLAN_MKK1_MKK3 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC1, TXPWR_LMT_FCC), /* 0x39, RTW_CHPLAN_FCC1_NCC1 */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x3A, RTW_CHPLAN_ETSI1_ETSI1 */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ACMA1, TXPWR_LMT_ACMA), /* 0x3B, RTW_CHPLAN_ETSI1_ACMA1 */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI6, TXPWR_LMT_ETSI), /* 0x3C, RTW_CHPLAN_ETSI1_ETSI6 */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI12, TXPWR_LMT_ETSI), /* 0x3D, RTW_CHPLAN_ETSI1_ETSI12 */ - CHPLAN_ENT(RTW_RD_2G_KCC1, RTW_RD_5G_KCC2, TXPWR_LMT_KCC), /* 0x3E, RTW_CHPLAN_KCC1_KCC2 */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x3F, */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC2, TXPWR_LMT_FCC), /* 0x40, RTW_CHPLAN_FCC1_NCC2 */ - CHPLAN_ENT(RTW_RD_2G_GLOBAL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x41, RTW_CHPLAN_GLOBAL_NULL */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI4, TXPWR_LMT_ETSI), /* 0x42, RTW_CHPLAN_ETSI1_ETSI4 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x43, RTW_CHPLAN_FCC1_FCC2 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC3, TXPWR_LMT_FCC), /* 0x44, RTW_CHPLAN_FCC1_NCC3 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ACMA1, TXPWR_LMT_ACMA), /* 0x45, RTW_CHPLAN_WORLD_ACMA1 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC8, TXPWR_LMT_FCC), /* 0x46, RTW_CHPLAN_FCC1_FCC8 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI6, TXPWR_LMT_ETSI), /* 0x47, RTW_CHPLAN_WORLD_ETSI6 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI7, TXPWR_LMT_ETSI), /* 0x48, RTW_CHPLAN_WORLD_ETSI7 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI8, TXPWR_LMT_ETSI), /* 0x49, RTW_CHPLAN_WORLD_ETSI8 */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4A, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4B, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4C, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4D, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4E, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4F, */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI9, TXPWR_LMT_ETSI), /* 0x50, RTW_CHPLAN_WORLD_ETSI9 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI10, TXPWR_LMT_ETSI), /* 0x51, RTW_CHPLAN_WORLD_ETSI10 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI11, TXPWR_LMT_ETSI), /* 0x52, RTW_CHPLAN_WORLD_ETSI11 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC4, TXPWR_LMT_FCC), /* 0x53, RTW_CHPLAN_FCC1_NCC4 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI12, TXPWR_LMT_ETSI), /* 0x54, RTW_CHPLAN_WORLD_ETSI12 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC9, TXPWR_LMT_FCC), /* 0x55, RTW_CHPLAN_FCC1_FCC9 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI13, TXPWR_LMT_ETSI), /* 0x56, RTW_CHPLAN_WORLD_ETSI13 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC10, TXPWR_LMT_FCC), /* 0x57, RTW_CHPLAN_FCC1_FCC10 */ - CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK4, TXPWR_LMT_MKK), /* 0x58, RTW_CHPLAN_MKK2_MKK4 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI14, TXPWR_LMT_ETSI), /* 0x59, RTW_CHPLAN_WORLD_ETSI14 */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5A, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5B, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5C, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5D, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5E, */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5F, */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x60, RTW_CHPLAN_FCC1_FCC5 */ - CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x61, RTW_CHPLAN_FCC2_FCC7 */ - CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC1, TXPWR_LMT_FCC), /* 0x62, RTW_CHPLAN_FCC2_FCC1 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI15, TXPWR_LMT_ETSI), /* 0x63, RTW_CHPLAN_WORLD_ETSI15 */ - CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK5, TXPWR_LMT_MKK), /* 0x64, RTW_CHPLAN_MKK2_MKK5 */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI16, TXPWR_LMT_ETSI), /* 0x65, RTW_CHPLAN_ETSI1_ETSI16 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC14, TXPWR_LMT_FCC), /* 0x66, RTW_CHPLAN_FCC1_FCC14 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x67, RTW_CHPLAN_FCC1_FCC12 */ - CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC14, TXPWR_LMT_FCC), /* 0x68, RTW_CHPLAN_FCC2_FCC14 */ - CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x69, RTW_CHPLAN_FCC2_FCC12 */ - CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI17, TXPWR_LMT_ETSI), /* 0x6A, RTW_CHPLAN_ETSI1_ETSI17 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC16, TXPWR_LMT_FCC), /* 0x6B, RTW_CHPLAN_WORLD_FCC16 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC13, TXPWR_LMT_FCC), /* 0x6C, RTW_CHPLAN_WORLD_FCC13 */ - CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC15, TXPWR_LMT_FCC), /* 0x6D, RTW_CHPLAN_FCC2_FCC15 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x6E, RTW_CHPLAN_WORLD_FCC12 */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI8, TXPWR_LMT_ETSI), /* 0x6F, RTW_CHPLAN_NULL_ETSI8 */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI18, TXPWR_LMT_ETSI), /* 0x70, RTW_CHPLAN_NULL_ETSI18 */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI17, TXPWR_LMT_ETSI), /* 0x71, RTW_CHPLAN_NULL_ETSI17 */ - CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI19, TXPWR_LMT_ETSI), /* 0x72, RTW_CHPLAN_NULL_ETSI19 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x73, RTW_CHPLAN_WORLD_FCC7 */ - CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC17, TXPWR_LMT_FCC), /* 0x74, RTW_CHPLAN_FCC2_FCC17 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI20, TXPWR_LMT_ETSI), /* 0x75, RTW_CHPLAN_WORLD_ETSI20 */ - CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC11, TXPWR_LMT_FCC), /* 0x76, RTW_CHPLAN_FCC2_FCC11 */ - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI21, TXPWR_LMT_ETSI), /* 0x77, RTW_CHPLAN_WORLD_ETSI21 */ - CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC18, TXPWR_LMT_FCC), /* 0x78, RTW_CHPLAN_FCC1_FCC18 */ - CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK1, TXPWR_LMT_MKK), /* 0x79, RTW_CHPLAN_MKK2_MKK1 */ -}; - -static struct chplan_ent_t RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = - CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC1, TXPWR_LMT_FCC); /* 0x7F, Realtek Define */ - -u8 rtw_chplan_get_default_regd(u8 id) -{ - u8 regd; - - if (id == RTW_CHPLAN_REALTEK_DEFINE) - regd = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.regd; - else - regd = RTW_ChannelPlanMap[id].regd; - - return regd; -} - -bool rtw_chplan_is_empty(u8 id) -{ - struct chplan_ent_t *chplan_map; - - if (id == RTW_CHPLAN_REALTEK_DEFINE) - chplan_map = &RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE; - else - chplan_map = &RTW_ChannelPlanMap[id]; - - if (chplan_map->rd_2g == RTW_RD_2G_NULL - #ifdef CONFIG_IEEE80211_BAND_5GHZ - && chplan_map->rd_5g == RTW_RD_5G_NULL - #endif - ) - return _TRUE; - - return _FALSE; -} - -bool rtw_regsty_is_excl_chs(struct registry_priv *regsty, u8 ch) -{ - int i; - - for (i = 0; i < MAX_CHANNEL_NUM; i++) { - if (regsty->excl_chs[i] == 0) - break; - if (regsty->excl_chs[i] == ch) - return _TRUE; - } - return _FALSE; -} - -inline static u8 rtw_rd_5g_band1_passive(u8 rtw_rd_5g) -{ - u8 passive = 0; - - switch (rtw_rd_5g) { - case RTW_RD_5G_FCC13: - case RTW_RD_5G_FCC16: - case RTW_RD_5G_ETSI18: - case RTW_RD_5G_ETSI19: - case RTW_RD_5G_WORLD: - case RTW_RD_5G_WORLD1: - passive = 1; - }; - - return passive; -} - -inline static u8 rtw_rd_5g_band4_passive(u8 rtw_rd_5g) -{ - u8 passive = 0; - - switch (rtw_rd_5g) { - case RTW_RD_5G_MKK5: - case RTW_RD_5G_ETSI16: - case RTW_RD_5G_ETSI18: - case RTW_RD_5G_ETSI19: - case RTW_RD_5G_WORLD: - passive = 1; - }; - - return passive; -} - -u8 init_channel_set(_adapter *padapter, u8 ChannelPlan, RT_CHANNEL_INFO *channel_set) -{ - struct registry_priv *regsty = adapter_to_regsty(padapter); - u8 index, chanset_size = 0; - u8 b5GBand = _FALSE, b2_4GBand = _FALSE; - u8 rd_2g = 0, rd_5g = 0; -#ifdef CONFIG_DFS_MASTER - int i; -#endif - - if (!rtw_is_channel_plan_valid(ChannelPlan)) { - RTW_ERR("ChannelPlan ID 0x%02X error !!!!!\n", ChannelPlan); - return chanset_size; - } - - _rtw_memset(channel_set, 0, sizeof(RT_CHANNEL_INFO) * MAX_CHANNEL_NUM); - - if (IsSupported24G(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_2G)) - b2_4GBand = _TRUE; - - if (is_supported_5g(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_5G)) - b5GBand = _TRUE; - - if (b2_4GBand == _FALSE && b5GBand == _FALSE) { - RTW_WARN("HW band_cap has no intersection with SW wireless_mode setting\n"); - return chanset_size; - } - - if (b2_4GBand) { - if (ChannelPlan == RTW_CHPLAN_REALTEK_DEFINE) - rd_2g = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.rd_2g; - else - rd_2g = RTW_ChannelPlanMap[ChannelPlan].rd_2g; - - for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan2G[rd_2g]); index++) { - if (rtw_regsty_is_excl_chs(regsty, CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index)) == _TRUE) - continue; - - if (chanset_size >= MAX_CHANNEL_NUM) { - RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM); - break; - } - - channel_set[chanset_size].ChannelNum = CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index); - - if (ChannelPlan == RTW_CHPLAN_GLOBAL_DOAMIN - || rd_2g == RTW_RD_2G_GLOBAL - ) { - /* Channel 1~11 is active, and 12~14 is passive */ - if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14)) - channel_set[chanset_size].ScanType = SCAN_PASSIVE; - } else if (ChannelPlan == RTW_CHPLAN_WORLD_WIDE_13 - || ChannelPlan == RTW_CHPLAN_WORLD_WIDE_5G - || rd_2g == RTW_RD_2G_WORLD - ) { - /* channel 12~13, passive scan */ - if (channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - else - channel_set[chanset_size].ScanType = SCAN_PASSIVE; - } else - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - - chanset_size++; - } - } - -#ifdef CONFIG_IEEE80211_BAND_5GHZ - if (b5GBand) { - if (ChannelPlan == RTW_CHPLAN_REALTEK_DEFINE) - rd_5g = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.rd_5g; - else - rd_5g = RTW_ChannelPlanMap[ChannelPlan].rd_5g; - - for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan5G[rd_5g]); index++) { - if (rtw_regsty_is_excl_chs(regsty, CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index)) == _TRUE) - continue; - #ifndef CONFIG_DFS - if (rtw_is_dfs_ch(CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index))) - continue; - #endif - - if (chanset_size >= MAX_CHANNEL_NUM) { - RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM); - break; - } - - channel_set[chanset_size].ChannelNum = CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index); - - if ((ChannelPlan == RTW_CHPLAN_WORLD_WIDE_5G) /* all channels passive */ - || (rtw_is_5g_band1(channel_set[chanset_size].ChannelNum) - && rtw_rd_5g_band1_passive(rd_5g)) /* band1 passive */ - || (rtw_is_5g_band4(channel_set[chanset_size].ChannelNum) - && rtw_rd_5g_band4_passive(rd_5g)) /* band4 passive */ - || (rtw_is_dfs_ch(channel_set[chanset_size].ChannelNum)) /* DFS channel(band2, 3) passive */ - ) - channel_set[chanset_size].ScanType = SCAN_PASSIVE; - else - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - - chanset_size++; - } - } - - #ifdef CONFIG_DFS_MASTER - for (i = 0; i < chanset_size; i++) - channel_set[i].non_ocp_end_time = rtw_get_current_time(); - #endif -#endif /* CONFIG_IEEE80211_BAND_5GHZ */ - - if (chanset_size) - RTW_INFO(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, ch num:%d\n" - , FUNC_ADPT_ARG(padapter), ChannelPlan, chanset_size); - else - RTW_WARN(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, final chset has no channel\n" - , FUNC_ADPT_ARG(padapter), ChannelPlan); - - return chanset_size; -} - -#ifdef CONFIG_80211AC_VHT -#define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val) , .en_11ac = (_val) -#else -#define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val) -#endif - -#if RTW_DEF_MODULE_REGULATORY_CERT -#define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val) , .def_module_flags = (_val) -#else -#define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val) -#endif - -/* has def_module_flags specified, used by common map and HAL dfference map */ -#define COUNTRY_CHPLAN_ENT(_alpha2, _chplan, _en_11ac, _def_module_flags) \ - {.alpha2 = (_alpha2), .chplan = (_chplan) \ - COUNTRY_CHPLAN_ASSIGN_EN_11AC(_en_11ac) \ - COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_def_module_flags) \ - } - -#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP - -#include "../platform/custom_country_chplan.h" - -#elif RTW_DEF_MODULE_REGULATORY_CERT - -/* leave def_module_flags empty, def_module_flags check is done on country_chplan_map */ -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821AE_HMC_M2) /* 2013 certify */ -static const struct country_chplan RTL8821AE_HMC_M2_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */ - COUNTRY_CHPLAN_ENT("CL", 0x30, 1, 0), /* Chile */ - COUNTRY_CHPLAN_ENT("CN", 0x51, 1, 0), /* China */ - COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ - COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ - COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ - COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ - COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ - COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ - COUNTRY_CHPLAN_ENT("MY", 0x47, 1, 0), /* Malaysia */ - COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ - COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ - COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ - COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ - COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ - COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ - COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */ - COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821AU) /* 2014 certify */ -static const struct country_chplan RTL8821AU_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */ - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ - COUNTRY_CHPLAN_ENT("RU", 0x59, 0, 0), /* Russia(fac/gost), Kaliningrad */ - COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ - COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */ - COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8812AENF_NGFF) /* 2014 certify */ -static const struct country_chplan RTL8812AENF_NGFF_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ - COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8812AEBT_HMC) /* 2013 certify */ -static const struct country_chplan RTL8812AEBT_HMC_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */ - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ - COUNTRY_CHPLAN_ENT("RU", 0x59, 0, 0), /* Russia(fac/gost), Kaliningrad */ - COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ - COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */ - COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8188EE_HMC_M2) /* 2012 certify */ -static const struct country_chplan RTL8188EE_HMC_M2_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */ - COUNTRY_CHPLAN_ENT("BB", 0x34, 1, 0), /* Barbados */ - COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */ - COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ - COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ - COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ - COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ - COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ - COUNTRY_CHPLAN_ENT("HT", 0x34, 1, 0), /* Haiti */ - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ - COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ - COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ - COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ - COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ - COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ - COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ - COUNTRY_CHPLAN_ENT("SC", 0x34, 1, 0), /* Seychelles */ - COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ - COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ - COUNTRY_CHPLAN_ENT("VC", 0x34, 1, 0), /* Saint Vincent and the Grenadines */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723BE_HMC_M2) /* 2013 certify */ -static const struct country_chplan RTL8723BE_HMC_M2_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */ - COUNTRY_CHPLAN_ENT("BS", 0x34, 1, 0), /* Bahamas */ - COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */ - COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ - COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ - COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ - COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ - COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ - COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ - COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ - COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ - COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ - COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ - COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ - COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ - COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723BS_NGFF1216) /* 2014 certify */ -static const struct country_chplan RTL8723BS_NGFF1216_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("BB", 0x34, 1, 0), /* Barbados */ - COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */ - COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ - COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ - COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ - COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ - COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ - COUNTRY_CHPLAN_ENT("HT", 0x34, 1, 0), /* Haiti */ - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ - COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ - COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ - COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ - COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ - COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ - COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ - COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ - COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8192EEBT_HMC_M2) /* 2013 certify */ -static const struct country_chplan RTL8192EEBT_HMC_M2_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */ - COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */ - COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ - COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ - COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ - COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ - COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ - COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ - COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ - COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ - COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ - COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ - COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ - COUNTRY_CHPLAN_ENT("SC", 0x34, 1, 0), /* Seychelles */ - COUNTRY_CHPLAN_ENT("ST", 0x34, 1, 0), /* Sao Tome and Principe */ - COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ - COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723DE_NGFF1630) /* 2016 certify */ -static const struct country_chplan RTL8723DE_NGFF1630_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("CA", 0x2A, 1, 0), /* Canada */ - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ - COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8822BE) /* 2016 certify */ -static const struct country_chplan RTL8822BE_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ -}; -#endif - -#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821CE) /* 2016 certify */ -static const struct country_chplan RTL8821CE_country_chplan_exc_map[] = { - COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ -}; -#endif - -/** - * rtw_def_module_get_chplan_from_country - - * @country_code: string of country code - * @return: - * Return NULL for case referring to common map - */ -static const struct country_chplan *rtw_def_module_get_chplan_from_country(const char *country_code) -{ - const struct country_chplan *ent = NULL; - const struct country_chplan *hal_map = NULL; - u16 hal_map_sz = 0; - int i; - - /* TODO: runtime selection for multi driver */ -#if (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AE_HMC_M2) - hal_map = RTL8821AE_HMC_M2_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8821AE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AU) - hal_map = RTL8821AU_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8821AU_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AENF_NGFF) - hal_map = RTL8812AENF_NGFF_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8812AENF_NGFF_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AEBT_HMC) - hal_map = RTL8812AEBT_HMC_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8812AEBT_HMC_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8188EE_HMC_M2) - hal_map = RTL8188EE_HMC_M2_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8188EE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BE_HMC_M2) - hal_map = RTL8723BE_HMC_M2_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8723BE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BS_NGFF1216) - hal_map = RTL8723BS_NGFF1216_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8723BS_NGFF1216_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8192EEBT_HMC_M2) - hal_map = RTL8192EEBT_HMC_M2_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8192EEBT_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723DE_NGFF1630) - hal_map = RTL8723DE_NGFF1630_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8723DE_NGFF1630_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8822BE) - hal_map = RTL8822BE_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8822BE_country_chplan_exc_map) / sizeof(struct country_chplan); -#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821CE) - hal_map = RTL8821CE_country_chplan_exc_map; - hal_map_sz = sizeof(RTL8821CE_country_chplan_exc_map) / sizeof(struct country_chplan); -#endif - - if (hal_map == NULL || hal_map_sz == 0) - goto exit; - - for (i = 0; i < hal_map_sz; i++) { - if (strncmp(country_code, hal_map[i].alpha2, 2) == 0) { - ent = &hal_map[i]; - break; - } - } - -exit: - return ent; -} -#endif /* CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP or RTW_DEF_MODULE_REGULATORY_CERT */ - -static const struct country_chplan country_chplan_map[] = { - COUNTRY_CHPLAN_ENT("AD", 0x26, 1, 0x000), /* Andorra */ - COUNTRY_CHPLAN_ENT("AE", 0x26, 1, 0x7FB), /* United Arab Emirates */ - COUNTRY_CHPLAN_ENT("AF", 0x42, 1, 0x000), /* Afghanistan */ - COUNTRY_CHPLAN_ENT("AG", 0x26, 1, 0x000), /* Antigua & Barbuda */ - COUNTRY_CHPLAN_ENT("AI", 0x26, 1, 0x000), /* Anguilla(UK) */ - COUNTRY_CHPLAN_ENT("AL", 0x26, 1, 0x7F1), /* Albania */ - COUNTRY_CHPLAN_ENT("AM", 0x26, 1, 0x6B0), /* Armenia */ - COUNTRY_CHPLAN_ENT("AN", 0x26, 1, 0x7F1), /* Netherlands Antilles */ - COUNTRY_CHPLAN_ENT("AO", 0x47, 1, 0x6E0), /* Angola */ - COUNTRY_CHPLAN_ENT("AQ", 0x26, 1, 0x000), /* Antarctica */ - COUNTRY_CHPLAN_ENT("AR", 0x61, 1, 0x7F3), /* Argentina */ - COUNTRY_CHPLAN_ENT("AS", 0x76, 1, 0x000), /* American Samoa */ - COUNTRY_CHPLAN_ENT("AT", 0x26, 1, 0x7FB), /* Austria */ - COUNTRY_CHPLAN_ENT("AU", 0x45, 1, 0x7FB), /* Australia */ - COUNTRY_CHPLAN_ENT("AW", 0x76, 1, 0x0B0), /* Aruba */ - COUNTRY_CHPLAN_ENT("AZ", 0x26, 1, 0x7F1), /* Azerbaijan */ - COUNTRY_CHPLAN_ENT("BA", 0x26, 1, 0x7F1), /* Bosnia & Herzegovina */ - COUNTRY_CHPLAN_ENT("BB", 0x76, 1, 0x650), /* Barbados */ - COUNTRY_CHPLAN_ENT("BD", 0x26, 1, 0x7F1), /* Bangladesh */ - COUNTRY_CHPLAN_ENT("BE", 0x26, 1, 0x7FB), /* Belgium */ - COUNTRY_CHPLAN_ENT("BF", 0x26, 1, 0x6B0), /* Burkina Faso */ - COUNTRY_CHPLAN_ENT("BG", 0x26, 1, 0x7F1), /* Bulgaria */ - COUNTRY_CHPLAN_ENT("BH", 0x47, 1, 0x7F1), /* Bahrain */ - COUNTRY_CHPLAN_ENT("BI", 0x26, 1, 0x6B0), /* Burundi */ - COUNTRY_CHPLAN_ENT("BJ", 0x26, 1, 0x6B0), /* Benin */ - COUNTRY_CHPLAN_ENT("BN", 0x47, 1, 0x610), /* Brunei */ - COUNTRY_CHPLAN_ENT("BO", 0x73, 1, 0x7F1), /* Bolivia */ - COUNTRY_CHPLAN_ENT("BR", 0x62, 1, 0x7F1), /* Brazil */ - COUNTRY_CHPLAN_ENT("BS", 0x76, 1, 0x620), /* Bahamas */ - COUNTRY_CHPLAN_ENT("BW", 0x26, 1, 0x6F1), /* Botswana */ - COUNTRY_CHPLAN_ENT("BY", 0x26, 1, 0x7F1), /* Belarus */ - COUNTRY_CHPLAN_ENT("BZ", 0x76, 1, 0x000), /* Belize */ - COUNTRY_CHPLAN_ENT("CA", 0x2B, 1, 0x7FB), /* Canada */ - COUNTRY_CHPLAN_ENT("CC", 0x26, 1, 0x000), /* Cocos (Keeling) Islands (Australia) */ - COUNTRY_CHPLAN_ENT("CD", 0x26, 1, 0x6B0), /* Congo, Republic of the */ - COUNTRY_CHPLAN_ENT("CF", 0x26, 1, 0x6B0), /* Central African Republic */ - COUNTRY_CHPLAN_ENT("CG", 0x26, 1, 0x6B0), /* Congo, Democratic Republic of the. Zaire */ - COUNTRY_CHPLAN_ENT("CH", 0x26, 1, 0x7FB), /* Switzerland */ - COUNTRY_CHPLAN_ENT("CI", 0x26, 1, 0x7F1), /* Cote d'Ivoire */ - COUNTRY_CHPLAN_ENT("CK", 0x26, 1, 0x000), /* Cook Islands */ - COUNTRY_CHPLAN_ENT("CL", 0x2D, 1, 0x7F1), /* Chile */ - COUNTRY_CHPLAN_ENT("CM", 0x26, 1, 0x6B0), /* Cameroon */ - COUNTRY_CHPLAN_ENT("CN", 0x48, 1, 0x7FB), /* China */ - COUNTRY_CHPLAN_ENT("CO", 0x76, 1, 0x7F1), /* Colombia */ - COUNTRY_CHPLAN_ENT("CR", 0x76, 1, 0x7F1), /* Costa Rica */ - COUNTRY_CHPLAN_ENT("CV", 0x26, 1, 0x6B0), /* Cape Verde */ - COUNTRY_CHPLAN_ENT("CX", 0x45, 1, 0x000), /* Christmas Island (Australia) */ - COUNTRY_CHPLAN_ENT("CY", 0x26, 1, 0x7FB), /* Cyprus */ - COUNTRY_CHPLAN_ENT("CZ", 0x26, 1, 0x7FB), /* Czech Republic */ - COUNTRY_CHPLAN_ENT("DE", 0x26, 1, 0x7FB), /* Germany */ - COUNTRY_CHPLAN_ENT("DJ", 0x26, 1, 0x680), /* Djibouti */ - COUNTRY_CHPLAN_ENT("DK", 0x26, 1, 0x7FB), /* Denmark */ - COUNTRY_CHPLAN_ENT("DM", 0x76, 1, 0x000), /* Dominica */ - COUNTRY_CHPLAN_ENT("DO", 0x76, 1, 0x7F1), /* Dominican Republic */ - COUNTRY_CHPLAN_ENT("DZ", 0x26, 1, 0x7F1), /* Algeria */ - COUNTRY_CHPLAN_ENT("EC", 0x76, 1, 0x7F1), /* Ecuador */ - COUNTRY_CHPLAN_ENT("EE", 0x26, 1, 0x7FB), /* Estonia */ - COUNTRY_CHPLAN_ENT("EG", 0x47, 1, 0x7F1), /* Egypt */ - COUNTRY_CHPLAN_ENT("EH", 0x47, 1, 0x680), /* Western Sahara */ - COUNTRY_CHPLAN_ENT("ER", 0x26, 1, 0x000), /* Eritrea */ - COUNTRY_CHPLAN_ENT("ES", 0x26, 1, 0x7FB), /* Spain, Canary Islands, Ceuta, Melilla */ - COUNTRY_CHPLAN_ENT("ET", 0x26, 1, 0x4B0), /* Ethiopia */ - COUNTRY_CHPLAN_ENT("FI", 0x26, 1, 0x7FB), /* Finland */ - COUNTRY_CHPLAN_ENT("FJ", 0x76, 1, 0x600), /* Fiji */ - COUNTRY_CHPLAN_ENT("FK", 0x26, 1, 0x000), /* Falkland Islands (Islas Malvinas) (UK) */ - COUNTRY_CHPLAN_ENT("FM", 0x76, 1, 0x000), /* Micronesia, Federated States of (USA) */ - COUNTRY_CHPLAN_ENT("FO", 0x26, 1, 0x000), /* Faroe Islands (Denmark) */ - COUNTRY_CHPLAN_ENT("FR", 0x26, 1, 0x7FB), /* France */ - COUNTRY_CHPLAN_ENT("GA", 0x26, 1, 0x6B0), /* Gabon */ - COUNTRY_CHPLAN_ENT("GB", 0x26, 1, 0x7FB), /* Great Britain (United Kingdom; England) */ - COUNTRY_CHPLAN_ENT("GD", 0x34, 1, 0x0B0), /* Grenada */ - COUNTRY_CHPLAN_ENT("GE", 0x26, 1, 0x600), /* Georgia */ - COUNTRY_CHPLAN_ENT("GF", 0x26, 1, 0x080), /* French Guiana */ - COUNTRY_CHPLAN_ENT("GG", 0x26, 1, 0x000), /* Guernsey (UK) */ - COUNTRY_CHPLAN_ENT("GH", 0x26, 1, 0x7F1), /* Ghana */ - COUNTRY_CHPLAN_ENT("GI", 0x26, 1, 0x600), /* Gibraltar (UK) */ - COUNTRY_CHPLAN_ENT("GL", 0x26, 1, 0x600), /* Greenland (Denmark) */ - COUNTRY_CHPLAN_ENT("GM", 0x26, 1, 0x6B0), /* Gambia */ - COUNTRY_CHPLAN_ENT("GN", 0x26, 1, 0x610), /* Guinea */ - COUNTRY_CHPLAN_ENT("GP", 0x26, 1, 0x600), /* Guadeloupe (France) */ - COUNTRY_CHPLAN_ENT("GQ", 0x26, 1, 0x6B0), /* Equatorial Guinea */ - COUNTRY_CHPLAN_ENT("GR", 0x26, 1, 0x7FB), /* Greece */ - COUNTRY_CHPLAN_ENT("GS", 0x26, 1, 0x000), /* South Georgia and the Sandwich Islands (UK) */ - COUNTRY_CHPLAN_ENT("GT", 0x61, 1, 0x7F1), /* Guatemala */ - COUNTRY_CHPLAN_ENT("GU", 0x76, 1, 0x600), /* Guam (USA) */ - COUNTRY_CHPLAN_ENT("GW", 0x26, 1, 0x6B0), /* Guinea-Bissau */ - COUNTRY_CHPLAN_ENT("GY", 0x44, 1, 0x000), /* Guyana */ - COUNTRY_CHPLAN_ENT("HK", 0x26, 1, 0x7FB), /* Hong Kong */ - COUNTRY_CHPLAN_ENT("HM", 0x45, 1, 0x000), /* Heard and McDonald Islands (Australia) */ - COUNTRY_CHPLAN_ENT("HN", 0x32, 1, 0x7F1), /* Honduras */ - COUNTRY_CHPLAN_ENT("HR", 0x26, 1, 0x7F9), /* Croatia */ - COUNTRY_CHPLAN_ENT("HT", 0x76, 1, 0x650), /* Haiti */ - COUNTRY_CHPLAN_ENT("HU", 0x26, 1, 0x7FB), /* Hungary */ - COUNTRY_CHPLAN_ENT("ID", 0x3D, 0, 0x7F3), /* Indonesia */ - COUNTRY_CHPLAN_ENT("IE", 0x26, 1, 0x7FB), /* Ireland */ - COUNTRY_CHPLAN_ENT("IL", 0x47, 1, 0x7F1), /* Israel */ - COUNTRY_CHPLAN_ENT("IM", 0x26, 1, 0x000), /* Isle of Man (UK) */ - COUNTRY_CHPLAN_ENT("IN", 0x48, 1, 0x7F1), /* India */ - COUNTRY_CHPLAN_ENT("IQ", 0x26, 1, 0x000), /* Iraq */ - COUNTRY_CHPLAN_ENT("IR", 0x26, 0, 0x000), /* Iran */ - COUNTRY_CHPLAN_ENT("IS", 0x26, 1, 0x7FB), /* Iceland */ - COUNTRY_CHPLAN_ENT("IT", 0x26, 1, 0x7FB), /* Italy */ - COUNTRY_CHPLAN_ENT("JE", 0x26, 1, 0x000), /* Jersey (UK) */ - COUNTRY_CHPLAN_ENT("JM", 0x51, 1, 0x7F1), /* Jamaica */ - COUNTRY_CHPLAN_ENT("JO", 0x49, 1, 0x7FB), /* Jordan */ - COUNTRY_CHPLAN_ENT("JP", 0x27, 1, 0x7FF), /* Japan- Telec */ - COUNTRY_CHPLAN_ENT("KE", 0x47, 1, 0x7F9), /* Kenya */ - COUNTRY_CHPLAN_ENT("KG", 0x26, 1, 0x7F1), /* Kyrgyzstan */ - COUNTRY_CHPLAN_ENT("KH", 0x26, 1, 0x7F1), /* Cambodia */ - COUNTRY_CHPLAN_ENT("KI", 0x26, 1, 0x000), /* Kiribati */ - COUNTRY_CHPLAN_ENT("KN", 0x76, 1, 0x000), /* Saint Kitts and Nevis */ - COUNTRY_CHPLAN_ENT("KR", 0x3E, 1, 0x7FB), /* South Korea */ - COUNTRY_CHPLAN_ENT("KW", 0x47, 1, 0x7FB), /* Kuwait */ - COUNTRY_CHPLAN_ENT("KY", 0x76, 1, 0x000), /* Cayman Islands (UK) */ - COUNTRY_CHPLAN_ENT("KZ", 0x26, 1, 0x700), /* Kazakhstan */ - COUNTRY_CHPLAN_ENT("LA", 0x26, 1, 0x000), /* Laos */ - COUNTRY_CHPLAN_ENT("LB", 0x26, 1, 0x7F1), /* Lebanon */ - COUNTRY_CHPLAN_ENT("LC", 0x76, 1, 0x000), /* Saint Lucia */ - COUNTRY_CHPLAN_ENT("LI", 0x26, 1, 0x7FB), /* Liechtenstein */ - COUNTRY_CHPLAN_ENT("LK", 0x26, 1, 0x7F1), /* Sri Lanka */ - COUNTRY_CHPLAN_ENT("LR", 0x26, 1, 0x6B0), /* Liberia */ - COUNTRY_CHPLAN_ENT("LS", 0x26, 1, 0x7F1), /* Lesotho */ - COUNTRY_CHPLAN_ENT("LT", 0x26, 1, 0x7FB), /* Lithuania */ - COUNTRY_CHPLAN_ENT("LU", 0x26, 1, 0x7FB), /* Luxembourg */ - COUNTRY_CHPLAN_ENT("LV", 0x26, 1, 0x7FB), /* Latvia */ - COUNTRY_CHPLAN_ENT("LY", 0x26, 1, 0x000), /* Libya */ - COUNTRY_CHPLAN_ENT("MA", 0x47, 1, 0x7F1), /* Morocco */ - COUNTRY_CHPLAN_ENT("MC", 0x26, 1, 0x7FB), /* Monaco */ - COUNTRY_CHPLAN_ENT("MD", 0x26, 1, 0x7F1), /* Moldova */ - COUNTRY_CHPLAN_ENT("ME", 0x26, 1, 0x7F1), /* Montenegro */ - COUNTRY_CHPLAN_ENT("MF", 0x76, 1, 0x000), /* Saint Martin */ - COUNTRY_CHPLAN_ENT("MG", 0x26, 1, 0x620), /* Madagascar */ - COUNTRY_CHPLAN_ENT("MH", 0x76, 1, 0x000), /* Marshall Islands (USA) */ - COUNTRY_CHPLAN_ENT("MK", 0x26, 1, 0x7F1), /* Republic of Macedonia (FYROM) */ - COUNTRY_CHPLAN_ENT("ML", 0x26, 1, 0x6B0), /* Mali */ - COUNTRY_CHPLAN_ENT("MM", 0x26, 1, 0x000), /* Burma (Myanmar) */ - COUNTRY_CHPLAN_ENT("MN", 0x26, 1, 0x000), /* Mongolia */ - COUNTRY_CHPLAN_ENT("MO", 0x26, 1, 0x600), /* Macau */ - COUNTRY_CHPLAN_ENT("MP", 0x76, 1, 0x000), /* Northern Mariana Islands (USA) */ - COUNTRY_CHPLAN_ENT("MQ", 0x26, 1, 0x640), /* Martinique (France) */ - COUNTRY_CHPLAN_ENT("MR", 0x26, 1, 0x6A0), /* Mauritania */ - COUNTRY_CHPLAN_ENT("MS", 0x26, 1, 0x000), /* Montserrat (UK) */ - COUNTRY_CHPLAN_ENT("MT", 0x26, 1, 0x7FB), /* Malta */ - COUNTRY_CHPLAN_ENT("MU", 0x26, 1, 0x6B0), /* Mauritius */ - COUNTRY_CHPLAN_ENT("MV", 0x47, 1, 0x000), /* Maldives */ - COUNTRY_CHPLAN_ENT("MW", 0x26, 1, 0x6B0), /* Malawi */ - COUNTRY_CHPLAN_ENT("MX", 0x61, 1, 0x7F1), /* Mexico */ - COUNTRY_CHPLAN_ENT("MY", 0x63, 1, 0x7F1), /* Malaysia */ - COUNTRY_CHPLAN_ENT("MZ", 0x26, 1, 0x7F1), /* Mozambique */ - COUNTRY_CHPLAN_ENT("NA", 0x26, 1, 0x700), /* Namibia */ - COUNTRY_CHPLAN_ENT("NC", 0x26, 1, 0x000), /* New Caledonia */ - COUNTRY_CHPLAN_ENT("NE", 0x26, 1, 0x6B0), /* Niger */ - COUNTRY_CHPLAN_ENT("NF", 0x45, 1, 0x000), /* Norfolk Island (Australia) */ - COUNTRY_CHPLAN_ENT("NG", 0x75, 1, 0x7F9), /* Nigeria */ - COUNTRY_CHPLAN_ENT("NI", 0x76, 1, 0x7F1), /* Nicaragua */ - COUNTRY_CHPLAN_ENT("NL", 0x26, 1, 0x7FB), /* Netherlands */ - COUNTRY_CHPLAN_ENT("NO", 0x26, 1, 0x7FB), /* Norway */ - COUNTRY_CHPLAN_ENT("NP", 0x47, 1, 0x6F0), /* Nepal */ - COUNTRY_CHPLAN_ENT("NR", 0x26, 1, 0x000), /* Nauru */ - COUNTRY_CHPLAN_ENT("NU", 0x45, 1, 0x000), /* Niue */ - COUNTRY_CHPLAN_ENT("NZ", 0x45, 1, 0x7FB), /* New Zealand */ - COUNTRY_CHPLAN_ENT("OM", 0x26, 1, 0x7F9), /* Oman */ - COUNTRY_CHPLAN_ENT("PA", 0x76, 1, 0x7F1), /* Panama */ - COUNTRY_CHPLAN_ENT("PE", 0x76, 1, 0x7F1), /* Peru */ - COUNTRY_CHPLAN_ENT("PF", 0x26, 1, 0x000), /* French Polynesia (France) */ - COUNTRY_CHPLAN_ENT("PG", 0x26, 1, 0x7F1), /* Papua New Guinea */ - COUNTRY_CHPLAN_ENT("PH", 0x26, 1, 0x7F1), /* Philippines */ - COUNTRY_CHPLAN_ENT("PK", 0x51, 1, 0x7F1), /* Pakistan */ - COUNTRY_CHPLAN_ENT("PL", 0x26, 1, 0x7FB), /* Poland */ - COUNTRY_CHPLAN_ENT("PM", 0x26, 1, 0x000), /* Saint Pierre and Miquelon (France) */ - COUNTRY_CHPLAN_ENT("PR", 0x76, 1, 0x7F1), /* Puerto Rico */ - COUNTRY_CHPLAN_ENT("PT", 0x26, 1, 0x7FB), /* Portugal */ - COUNTRY_CHPLAN_ENT("PW", 0x76, 1, 0x000), /* Palau */ - COUNTRY_CHPLAN_ENT("PY", 0x76, 1, 0x7F1), /* Paraguay */ - COUNTRY_CHPLAN_ENT("QA", 0x51, 1, 0x7F9), /* Qatar */ - COUNTRY_CHPLAN_ENT("RE", 0x26, 1, 0x000), /* Reunion (France) */ - COUNTRY_CHPLAN_ENT("RO", 0x26, 1, 0x7F1), /* Romania */ - COUNTRY_CHPLAN_ENT("RS", 0x26, 1, 0x7F1), /* Serbia, Kosovo */ - COUNTRY_CHPLAN_ENT("RU", 0x59, 1, 0x7FB), /* Russia(fac/gost), Kaliningrad */ - COUNTRY_CHPLAN_ENT("RW", 0x26, 1, 0x0B0), /* Rwanda */ - COUNTRY_CHPLAN_ENT("SA", 0x26, 1, 0x7FB), /* Saudi Arabia */ - COUNTRY_CHPLAN_ENT("SB", 0x26, 1, 0x000), /* Solomon Islands */ - COUNTRY_CHPLAN_ENT("SC", 0x76, 1, 0x690), /* Seychelles */ - COUNTRY_CHPLAN_ENT("SE", 0x26, 1, 0x7FB), /* Sweden */ - COUNTRY_CHPLAN_ENT("SG", 0x26, 1, 0x7FB), /* Singapore */ - COUNTRY_CHPLAN_ENT("SH", 0x26, 1, 0x000), /* Saint Helena (UK) */ - COUNTRY_CHPLAN_ENT("SI", 0x26, 1, 0x7FB), /* Slovenia */ - COUNTRY_CHPLAN_ENT("SJ", 0x26, 1, 0x000), /* Svalbard (Norway) */ - COUNTRY_CHPLAN_ENT("SK", 0x26, 1, 0x7FB), /* Slovakia */ - COUNTRY_CHPLAN_ENT("SL", 0x26, 1, 0x6B0), /* Sierra Leone */ - COUNTRY_CHPLAN_ENT("SM", 0x26, 1, 0x000), /* San Marino */ - COUNTRY_CHPLAN_ENT("SN", 0x26, 1, 0x7F1), /* Senegal */ - COUNTRY_CHPLAN_ENT("SO", 0x26, 1, 0x000), /* Somalia */ - COUNTRY_CHPLAN_ENT("SR", 0x74, 1, 0x000), /* Suriname */ - COUNTRY_CHPLAN_ENT("ST", 0x76, 1, 0x680), /* Sao Tome and Principe */ - COUNTRY_CHPLAN_ENT("SV", 0x30, 1, 0x7F1), /* El Salvador */ - COUNTRY_CHPLAN_ENT("SX", 0x76, 1, 0x000), /* Sint Marteen */ - COUNTRY_CHPLAN_ENT("SZ", 0x26, 1, 0x020), /* Swaziland */ - COUNTRY_CHPLAN_ENT("TC", 0x26, 1, 0x000), /* Turks and Caicos Islands (UK) */ - COUNTRY_CHPLAN_ENT("TD", 0x26, 1, 0x6B0), /* Chad */ - COUNTRY_CHPLAN_ENT("TF", 0x26, 1, 0x680), /* French Southern and Antarctic Lands (FR Southern Territories) */ - COUNTRY_CHPLAN_ENT("TG", 0x26, 1, 0x6B0), /* Togo */ - COUNTRY_CHPLAN_ENT("TH", 0x26, 1, 0x7F1), /* Thailand */ - COUNTRY_CHPLAN_ENT("TJ", 0x26, 1, 0x640), /* Tajikistan */ - COUNTRY_CHPLAN_ENT("TK", 0x45, 1, 0x000), /* Tokelau */ - COUNTRY_CHPLAN_ENT("TM", 0x26, 1, 0x000), /* Turkmenistan */ - COUNTRY_CHPLAN_ENT("TN", 0x47, 1, 0x7F1), /* Tunisia */ - COUNTRY_CHPLAN_ENT("TO", 0x26, 1, 0x000), /* Tonga */ - COUNTRY_CHPLAN_ENT("TR", 0x26, 1, 0x7F1), /* Turkey, Northern Cyprus */ - COUNTRY_CHPLAN_ENT("TT", 0x42, 1, 0x3F1), /* Trinidad & Tobago */ - COUNTRY_CHPLAN_ENT("TW", 0x76, 1, 0x7FF), /* Taiwan */ - COUNTRY_CHPLAN_ENT("TZ", 0x26, 1, 0x6F0), /* Tanzania */ - COUNTRY_CHPLAN_ENT("UA", 0x36, 1, 0x7FB), /* Ukraine */ - COUNTRY_CHPLAN_ENT("UG", 0x26, 1, 0x6F1), /* Uganda */ - COUNTRY_CHPLAN_ENT("US", 0x76, 1, 0x7FF), /* United States of America (USA) */ - COUNTRY_CHPLAN_ENT("UY", 0x30, 1, 0x7F1), /* Uruguay */ - COUNTRY_CHPLAN_ENT("UZ", 0x47, 1, 0x6F0), /* Uzbekistan */ - COUNTRY_CHPLAN_ENT("VA", 0x26, 1, 0x000), /* Holy See (Vatican City) */ - COUNTRY_CHPLAN_ENT("VC", 0x76, 1, 0x010), /* Saint Vincent and the Grenadines */ - COUNTRY_CHPLAN_ENT("VE", 0x30, 1, 0x7F1), /* Venezuela */ - COUNTRY_CHPLAN_ENT("VI", 0x76, 1, 0x000), /* United States Virgin Islands (USA) */ - COUNTRY_CHPLAN_ENT("VN", 0x26, 1, 0x7F1), /* Vietnam */ - COUNTRY_CHPLAN_ENT("VU", 0x26, 1, 0x000), /* Vanuatu */ - COUNTRY_CHPLAN_ENT("WF", 0x26, 1, 0x000), /* Wallis and Futuna (France) */ - COUNTRY_CHPLAN_ENT("WS", 0x76, 1, 0x000), /* Samoa */ - COUNTRY_CHPLAN_ENT("YE", 0x26, 1, 0x040), /* Yemen */ - COUNTRY_CHPLAN_ENT("YT", 0x26, 1, 0x680), /* Mayotte (France) */ - COUNTRY_CHPLAN_ENT("ZA", 0x26, 1, 0x7F1), /* South Africa */ - COUNTRY_CHPLAN_ENT("ZM", 0x26, 1, 0x6B0), /* Zambia */ - COUNTRY_CHPLAN_ENT("ZW", 0x26, 1, 0x7F1), /* Zimbabwe */ -}; - -/* -* rtw_get_chplan_from_country - -* @country_code: string of country code -* -* Return pointer of struct country_chplan entry or NULL when unsupported country_code is given -*/ -const struct country_chplan *rtw_get_chplan_from_country(const char *country_code) -{ -#if RTW_DEF_MODULE_REGULATORY_CERT - const struct country_chplan *exc_ent = NULL; -#endif - const struct country_chplan *ent = NULL; - const struct country_chplan *map = NULL; - u16 map_sz = 0; - char code[2]; - int i; - - code[0] = alpha_to_upper(country_code[0]); - code[1] = alpha_to_upper(country_code[1]); - -#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP - map = CUSTOMIZED_country_chplan_map; - map_sz = sizeof(CUSTOMIZED_country_chplan_map) / sizeof(struct country_chplan); -#else - #if RTW_DEF_MODULE_REGULATORY_CERT - exc_ent = rtw_def_module_get_chplan_from_country(code); - #endif - map = country_chplan_map; - map_sz = sizeof(country_chplan_map) / sizeof(struct country_chplan); -#endif - - for (i = 0; i < map_sz; i++) { - if (strncmp(code, map[i].alpha2, 2) == 0) { - ent = &map[i]; - break; - } - } - - #if RTW_DEF_MODULE_REGULATORY_CERT - if (!ent || !(COUNTRY_CHPLAN_DEF_MODULE_FALGS(ent) & RTW_DEF_MODULE_REGULATORY_CERT)) - exc_ent = ent = NULL; - if (exc_ent) - ent = exc_ent; - #endif - - return ent; -} - -void dump_country_chplan(void *sel, const struct country_chplan *ent) -{ - RTW_PRINT_SEL(sel, "\"%c%c\", 0x%02X%s\n" - , ent->alpha2[0], ent->alpha2[1], ent->chplan - , COUNTRY_CHPLAN_EN_11AC(ent) ? " ac" : "" - ); -} - -void dump_country_chplan_map(void *sel) -{ - const struct country_chplan *ent; - u8 code[2]; - -#if RTW_DEF_MODULE_REGULATORY_CERT - RTW_PRINT_SEL(sel, "RTW_DEF_MODULE_REGULATORY_CERT:0x%x\n", RTW_DEF_MODULE_REGULATORY_CERT); -#endif -#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP - RTW_PRINT_SEL(sel, "CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP\n"); -#endif - - for (code[0] = 'A'; code[0] <= 'Z'; code[0]++) { - for (code[1] = 'A'; code[1] <= 'Z'; code[1]++) { - ent = rtw_get_chplan_from_country(code); - if (!ent) - continue; - - dump_country_chplan(sel, ent); - } - } -} - -void dump_chplan_id_list(void *sel) -{ - u8 first = 1; - int i; - - for (i = 0; i < RTW_CHPLAN_MAX; i++) { - if (!rtw_is_channel_plan_valid(i)) - continue; - - if (first) { - RTW_PRINT_SEL(sel, "0x%02X ", i); - first = 0; - } else - _RTW_PRINT_SEL(sel, "0x%02X ", i); - } - - _RTW_PRINT_SEL(sel, "0x7F\n"); -} - -void dump_chplan_test(void *sel) -{ - int i, j; - - /* check invalid channel */ - for (i = 0; i < RTW_RD_2G_MAX; i++) { - for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan2G[i]); j++) { - if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan2G[i], j)) == 0) - RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan2G[i], j), i, j); - } - } - -#ifdef CONFIG_IEEE80211_BAND_5GHZ - for (i = 0; i < RTW_RD_5G_MAX; i++) { - for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan5G[i]); j++) { - if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan5G[i], j)) == 0) - RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan5G[i], j), i, j); - } - } -#endif -} - -void dump_chplan_ver(void *sel) -{ - RTW_PRINT_SEL(sel, "%s-%s\n", RTW_DOMAIN_MAP_VER, RTW_COUNTRY_MAP_VER); -} +/****************************************************************************** + * + * Copyright(c) 2007 - 2018 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + *****************************************************************************/ +#define _RTW_CHPLAN_C_ + +#include + +#define RTW_DOMAIN_MAP_VER "35e" +#define RTW_COUNTRY_MAP_VER "18" + +#ifdef LEGACY_CHANNEL_PLAN_REF +/******************************************************** +ChannelPlan definitions +*********************************************************/ +static RT_CHANNEL_PLAN legacy_channel_plan[] = { + /* 0x00, RTW_CHPLAN_FCC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165}, 32}, + /* 0x01, RTW_CHPLAN_IC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165}, 31}, + /* 0x02, RTW_CHPLAN_ETSI */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 32}, + /* 0x03, RTW_CHPLAN_SPAIN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + /* 0x04, RTW_CHPLAN_FRANCE */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + /* 0x05, RTW_CHPLAN_MKK */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + /* 0x06, RTW_CHPLAN_MKK1 */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + /* 0x07, RTW_CHPLAN_ISRAEL */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, + /* 0x08, RTW_CHPLAN_TELEC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, + /* 0x09, RTW_CHPLAN_GLOBAL_DOAMIN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}, + /* 0x0A, RTW_CHPLAN_WORLD_WIDE_13 */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + /* 0x0B, RTW_CHPLAN_TAIWAN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165}, 26}, + /* 0x0C, RTW_CHPLAN_CHINA */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 149, 153, 157, 161, 165}, 18}, + /* 0x0D, RTW_CHPLAN_SINGAPORE_INDIA_MEXICO */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24}, + /* 0x0E, RTW_CHPLAN_KOREA */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161, 165}, 31}, + /* 0x0F, RTW_CHPLAN_TURKEY */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64}, 19}, + /* 0x10, RTW_CHPLAN_JAPAN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 32}, + /* 0x11, RTW_CHPLAN_FCC_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 149, 153, 157, 161, 165}, 20}, + /* 0x12, RTW_CHPLAN_JAPAN_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48}, 17}, + /* 0x13, RTW_CHPLAN_WORLD_WIDE_5G */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165}, 37}, + /* 0x14, RTW_CHPLAN_TAIWAN_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 56, 60, 64, 149, 153, 157, 161, 165}, 19}, +}; +#endif + +enum rtw_rd_2g { + RTW_RD_2G_NULL = 0, + RTW_RD_2G_WORLD = 1, /* Worldwird 13 */ + RTW_RD_2G_ETSI1 = 2, /* Europe */ + RTW_RD_2G_FCC1 = 3, /* US */ + RTW_RD_2G_MKK1 = 4, /* Japan */ + RTW_RD_2G_ETSI2 = 5, /* France */ + RTW_RD_2G_GLOBAL = 6, /* Global domain */ + RTW_RD_2G_MKK2 = 7, /* Japan */ + RTW_RD_2G_FCC2 = 8, /* US */ + RTW_RD_2G_IC1 = 9, /* Canada */ + RTW_RD_2G_WORLD1 = 10, /* Worldwide 11 */ + RTW_RD_2G_KCC1 = 11, /* Korea */ + + RTW_RD_2G_MAX, +}; + +enum rtw_rd_5g { + RTW_RD_5G_NULL = 0, /* */ + RTW_RD_5G_ETSI1 = 1, /* Europe */ + RTW_RD_5G_ETSI2 = 2, /* Australia, New Zealand */ + RTW_RD_5G_ETSI3 = 3, /* Russia */ + RTW_RD_5G_FCC1 = 4, /* US */ + RTW_RD_5G_FCC2 = 5, /* FCC w/o DFS Channels */ + RTW_RD_5G_FCC3 = 6, /* Bolivia, Chile, El Salvador, Venezuela */ + RTW_RD_5G_FCC4 = 7, /* Venezuela */ + RTW_RD_5G_FCC5 = 8, /* China */ + RTW_RD_5G_FCC6 = 9, /* */ + RTW_RD_5G_FCC7 = 10, /* US(w/o Weather radar) */ + RTW_RD_5G_IC1 = 11, /* Canada(w/o Weather radar) */ + RTW_RD_5G_KCC1 = 12, /* Korea */ + RTW_RD_5G_MKK1 = 13, /* Japan */ + RTW_RD_5G_MKK2 = 14, /* Japan (W52, W53) */ + RTW_RD_5G_MKK3 = 15, /* Japan (W56) */ + RTW_RD_5G_NCC1 = 16, /* Taiwan, (w/o Weather radar) */ + RTW_RD_5G_NCC2 = 17, /* Taiwan, Band2, Band4 */ + RTW_RD_5G_NCC3 = 18, /* Taiwan w/o DFS, Band4 only */ + RTW_RD_5G_ETSI4 = 19, /* Europe w/o DFS, Band1 only */ + RTW_RD_5G_ETSI5 = 20, /* Australia, New Zealand(w/o Weather radar) */ + RTW_RD_5G_FCC8 = 21, /* Latin America */ + RTW_RD_5G_ETSI6 = 22, /* Israel, Bahrain, Egypt, India, China, Malaysia */ + RTW_RD_5G_ETSI7 = 23, /* China */ + RTW_RD_5G_ETSI8 = 24, /* Jordan */ + RTW_RD_5G_ETSI9 = 25, /* Lebanon */ + RTW_RD_5G_ETSI10 = 26, /* Qatar */ + RTW_RD_5G_ETSI11 = 27, /* Russia */ + RTW_RD_5G_NCC4 = 28, /* Taiwan, (w/o Weather radar) */ + RTW_RD_5G_ETSI12 = 29, /* Indonesia */ + RTW_RD_5G_FCC9 = 30, /* (w/o Weather radar) */ + RTW_RD_5G_ETSI13 = 31, /* (w/o Weather radar) */ + RTW_RD_5G_FCC10 = 32, /* Argentina(w/o Weather radar) */ + RTW_RD_5G_MKK4 = 33, /* Japan (W52) */ + RTW_RD_5G_ETSI14 = 34, /* Russia */ + RTW_RD_5G_FCC11 = 35, /* US(include CH144) */ + RTW_RD_5G_ETSI15 = 36, /* Malaysia */ + RTW_RD_5G_MKK5 = 37, /* Japan */ + RTW_RD_5G_ETSI16 = 38, /* Europe */ + RTW_RD_5G_ETSI17 = 39, /* Europe */ + RTW_RD_5G_FCC12 = 40, /* FCC */ + RTW_RD_5G_FCC13 = 41, /* FCC */ + RTW_RD_5G_FCC14 = 42, /* FCC w/o Weather radar(w/o 5600~5650MHz) */ + RTW_RD_5G_FCC15 = 43, /* FCC w/o Band3 */ + RTW_RD_5G_FCC16 = 44, /* FCC w/o Band3 */ + RTW_RD_5G_ETSI18 = 45, /* ETSI w/o DFS Band2&3 */ + RTW_RD_5G_ETSI19 = 46, /* Europe */ + RTW_RD_5G_FCC17 = 47, /* FCC w/o Weather radar(w/o 5600~5650MHz) */ + RTW_RD_5G_ETSI20 = 48, /* Europe */ + RTW_RD_5G_IC2 = 49, /* Canada(w/o Weather radar), include ch144 */ + RTW_RD_5G_ETSI21 = 50, /* Australia, New Zealand(w/o Weather radar) */ + RTW_RD_5G_FCC18 = 51, /* */ + RTW_RD_5G_WORLD = 52, /* Worldwide */ + RTW_RD_5G_CHILE1 = 53, /* Chile */ + RTW_RD_5G_ACMA1 = 54, /* Australia, New Zealand (w/o Weather radar) (w/o Ch120~Ch128) */ + RTW_RD_5G_WORLD1 = 55, /* 5G Worldwide Band1&2 */ + RTW_RD_5G_CHILE2 = 56, /* Chile (Band2,Band3) */ + RTW_RD_5G_KCC2 = 57, /* Korea (New standard) */ + + /* === Below are driver defined for legacy channel plan compatible, DON'T assign index ==== */ + RTW_RD_5G_OLD_FCC1, + RTW_RD_5G_OLD_NCC1, + RTW_RD_5G_OLD_KCC1, + + RTW_RD_5G_MAX, +}; + +struct ch_list_t { + u8 *len_ch; +}; + +#define CH_LIST_ENT(_len, arg...) \ + {.len_ch = (u8[_len + 1]) {_len, ##arg}, } + +#define CH_LIST_LEN(_ch_list) (_ch_list.len_ch[0]) +#define CH_LIST_CH(_ch_list, _i) (_ch_list.len_ch[_i + 1]) + +struct chplan_ent_t { + u8 rd_2g; +#ifdef CONFIG_IEEE80211_BAND_5GHZ + u8 rd_5g; +#endif + u8 regd; /* value of REGULATION_TXPWR_LMT */ +}; + +#ifdef CONFIG_IEEE80211_BAND_5GHZ +#define CHPLAN_ENT(i2g, i5g, regd) {i2g, i5g, regd} +#else +#define CHPLAN_ENT(i2g, i5g, regd) {i2g, regd} +#endif + +static struct ch_list_t RTW_ChannelPlan2G[] = { + /* 0, RTW_RD_2G_NULL */ CH_LIST_ENT(0), + /* 1, RTW_RD_2G_WORLD */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), + /* 2, RTW_RD_2G_ETSI1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), + /* 3, RTW_RD_2G_FCC1 */ CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), + /* 4, RTW_RD_2G_MKK1 */ CH_LIST_ENT(14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), + /* 5, RTW_RD_2G_ETSI2 */ CH_LIST_ENT(4, 10, 11, 12, 13), + /* 6, RTW_RD_2G_GLOBAL */ CH_LIST_ENT(14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), + /* 7, RTW_RD_2G_MKK2 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), + /* 8, RTW_RD_2G_FCC2 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), + /* 9, RTW_RD_2G_IC1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), + /* 10, RTW_RD_2G_WORLD1 */ CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), + /* 11, RTW_RD_2G_KCC1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), +}; + +#ifdef CONFIG_IEEE80211_BAND_5GHZ +static struct ch_list_t RTW_ChannelPlan5G[] = { + /* 0, RTW_RD_5G_NULL */ CH_LIST_ENT(0), + /* 1, RTW_RD_5G_ETSI1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140), + /* 2, RTW_RD_5G_ETSI2 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + /* 3, RTW_RD_5G_ETSI3 */ CH_LIST_ENT(22, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 149, 153, 157, 161, 165), + /* 4, RTW_RD_5G_FCC1 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + /* 5, RTW_RD_5G_FCC2 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165), + /* 6, RTW_RD_5G_FCC3 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165), + /* 7, RTW_RD_5G_FCC4 */ CH_LIST_ENT(12, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161), + /* 8, RTW_RD_5G_FCC5 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165), + /* 9, RTW_RD_5G_FCC6 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64), + /* 10, RTW_RD_5G_FCC7 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 11, RTW_RD_5G_IC1 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 12, RTW_RD_5G_KCC1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161), + /* 13, RTW_RD_5G_MKK1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140), + /* 14, RTW_RD_5G_MKK2 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64), + /* 15, RTW_RD_5G_MKK3 */ CH_LIST_ENT(11, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140), + /* 16, RTW_RD_5G_NCC1 */ CH_LIST_ENT(16, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 17, RTW_RD_5G_NCC2 */ CH_LIST_ENT(8, 56, 60, 64, 149, 153, 157, 161, 165), + /* 18, RTW_RD_5G_NCC3 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165), + /* 19, RTW_RD_5G_ETSI4 */ CH_LIST_ENT(4, 36, 40, 44, 48), + /* 20, RTW_RD_5G_ETSI5 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 21, RTW_RD_5G_FCC8 */ CH_LIST_ENT(4, 149, 153, 157, 161), + /* 22, RTW_RD_5G_ETSI6 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64), + /* 23, RTW_RD_5G_ETSI7 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165), + /* 24, RTW_RD_5G_ETSI8 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165), + /* 25, RTW_RD_5G_ETSI9 */ CH_LIST_ENT(11, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140), + /* 26, RTW_RD_5G_ETSI10 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165), + /* 27, RTW_RD_5G_ETSI11 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140, 149, 153, 157, 161, 165), + /* 28, RTW_RD_5G_NCC4 */ CH_LIST_ENT(17, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 29, RTW_RD_5G_ETSI12 */ CH_LIST_ENT(4, 149, 153, 157, 161), + /* 30, RTW_RD_5G_FCC9 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 31, RTW_RD_5G_ETSI13 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140), + /* 32, RTW_RD_5G_FCC10 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161), + /* 33, RTW_RD_5G_MKK4 */ CH_LIST_ENT(4, 36, 40, 44, 48), + /* 34, RTW_RD_5G_ETSI14 */ CH_LIST_ENT(11, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140), + /* 35, RTW_RD_5G_FCC11 */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165), + /* 36, RTW_RD_5G_ETSI15 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 149, 153, 157, 161, 165), + /* 37, RTW_RD_5G_MKK5 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + /* 38, RTW_RD_5G_ETSI16 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + /* 39, RTW_RD_5G_ETSI17 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + /* 40, RTW_RD_5G_FCC12*/ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + /* 41, RTW_RD_5G_FCC13 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + /* 42, RTW_RD_5G_FCC14 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 43, RTW_RD_5G_FCC15 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165), + /* 44, RTW_RD_5G_FCC16 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165), + /* 45, RTW_RD_5G_ETSI18 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165), + /* 46, RTW_RD_5G_ETSI19 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + /* 47, RTW_RD_5G_FCC17 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140), + /* 48, RTW_RD_5G_ETSI20 */ CH_LIST_ENT(9, 52, 56, 60, 64, 149, 153, 157, 161, 165), + /* 49, RTW_RD_5G_IC2 */ CH_LIST_ENT(22, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 144, 149, 153, 157, 161, 165), + /* 50, RTW_RD_5G_ETSI21 */ CH_LIST_ENT(13, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 51, RTW_RD_5G_FCC18 */ CH_LIST_ENT(8, 100, 104, 108, 112, 116, 132, 136, 140), + /* 52, RTW_RD_5G_WORLD */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165), + /* 53, RTW_RD_5G_CHILE1 */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165), + /* 54, RTW_RD_5G_ACMA1 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165), + /* 55, RTW_RD_5G_WORLD1 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64), + /* 56, RTW_RD_5G_CHILE2 */ CH_LIST_ENT(16, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144), + /* 57, RTW_RD_5G_KCC2 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165), + + /* === Below are driver defined for legacy channel plan compatible, NO static index assigned ==== */ + /* RTW_RD_5G_OLD_FCC1 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165), + /* RTW_RD_5G_OLD_NCC1 */ CH_LIST_ENT(15, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165), + /* RTW_RD_5G_OLD_KCC1 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161, 165), +}; +#endif /* CONFIG_IEEE80211_BAND_5GHZ */ + +static struct chplan_ent_t RTW_ChannelPlanMap[RTW_CHPLAN_MAX] = { + /* ===== 0x00 ~ 0x1F, legacy channel plan ===== */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_KCC1, TXPWR_LMT_FCC), /* 0x00, RTW_CHPLAN_FCC */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_FCC1, TXPWR_LMT_FCC), /* 0x01, RTW_CHPLAN_IC */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x02, RTW_CHPLAN_ETSI */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x03, RTW_CHPLAN_SPAIN */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x04, RTW_CHPLAN_FRANCE */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x05, RTW_CHPLAN_MKK */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x06, RTW_CHPLAN_MKK1 */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC6, TXPWR_LMT_ETSI), /* 0x07, RTW_CHPLAN_ISRAEL */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_FCC6, TXPWR_LMT_MKK), /* 0x08, RTW_CHPLAN_TELEC */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x09, RTW_CHPLAN_GLOBAL_DOAMIN */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x0A, RTW_CHPLAN_WORLD_WIDE_13 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_NCC1, TXPWR_LMT_FCC), /* 0x0B, RTW_CHPLAN_TAIWAN */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC5, TXPWR_LMT_ETSI), /* 0x0C, RTW_CHPLAN_CHINA */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC3, TXPWR_LMT_WW), /* 0x0D, RTW_CHPLAN_SINGAPORE_INDIA_MEXICO */ /* ETSI:Singapore, India. FCC:Mexico => WW */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_KCC1, TXPWR_LMT_ETSI), /* 0x0E, RTW_CHPLAN_KOREA */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC6, TXPWR_LMT_ETSI), /* 0x0F, RTW_CHPLAN_TURKEY */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_MKK), /* 0x10, RTW_CHPLAN_JAPAN */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x11, RTW_CHPLAN_FCC_NO_DFS */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC7, TXPWR_LMT_MKK), /* 0x12, RTW_CHPLAN_JAPAN_NO_DFS */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC1, TXPWR_LMT_WW), /* 0x13, RTW_CHPLAN_WORLD_WIDE_5G */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC2, TXPWR_LMT_FCC), /* 0x14, RTW_CHPLAN_TAIWAN_NO_DFS */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC7, TXPWR_LMT_ETSI), /* 0x15, RTW_CHPLAN_ETSI_NO_DFS */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NCC1, TXPWR_LMT_ETSI), /* 0x16, RTW_CHPLAN_KOREA_NO_DFS */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_FCC7, TXPWR_LMT_MKK), /* 0x17, RTW_CHPLAN_JAPAN_NO_DFS */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_FCC5, TXPWR_LMT_ETSI), /* 0x18, RTW_CHPLAN_PAKISTAN_NO_DFS */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x19, RTW_CHPLAN_TAIWAN2_NO_DFS */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1A, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1B, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1C, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1D, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1E, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_FCC1, TXPWR_LMT_WW), /* 0x1F, RTW_CHPLAN_WORLD_WIDE_ONLY_5G */ + + /* ===== 0x20 ~ 0x7F, new channel plan ===== */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x20, RTW_CHPLAN_WORLD_NULL */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x21, RTW_CHPLAN_ETSI1_NULL */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NULL, TXPWR_LMT_FCC), /* 0x22, RTW_CHPLAN_FCC1_NULL */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x23, RTW_CHPLAN_MKK1_NULL */ + CHPLAN_ENT(RTW_RD_2G_ETSI2, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x24, RTW_CHPLAN_ETSI2_NULL */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC1, TXPWR_LMT_FCC), /* 0x25, RTW_CHPLAN_FCC1_FCC1 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x26, RTW_CHPLAN_WORLD_ETSI1 */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK1, TXPWR_LMT_MKK), /* 0x27, RTW_CHPLAN_MKK1_MKK1 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_KCC1, TXPWR_LMT_KCC), /* 0x28, RTW_CHPLAN_WORLD_KCC1 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x29, RTW_CHPLAN_WORLD_FCC2 */ + CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_NULL, TXPWR_LMT_FCC), /* 0x2A, RTW_CHPLAN_FCC2_NULL */ + CHPLAN_ENT(RTW_RD_2G_IC1, RTW_RD_5G_IC2, TXPWR_LMT_IC), /* 0x2B, RTW_CHPLAN_IC1_IC2 */ + CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x2C, RTW_CHPLAN_MKK2_NULL */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_CHILE1, TXPWR_LMT_CHILE), /* 0x2D, RTW_CHPLAN_WORLD_CHILE1 */ + CHPLAN_ENT(RTW_RD_2G_WORLD1, RTW_RD_5G_WORLD1, TXPWR_LMT_WW), /* 0x2E, RTW_CHPLAN_WORLD1_WORLD1 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_CHILE2, TXPWR_LMT_CHILE), /* 0x2F, RTW_CHPLAN_WORLD_CHILE2 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC3, TXPWR_LMT_FCC), /* 0x30, RTW_CHPLAN_WORLD_FCC3 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC4, TXPWR_LMT_FCC), /* 0x31, RTW_CHPLAN_WORLD_FCC4 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x32, RTW_CHPLAN_WORLD_FCC5 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC6, TXPWR_LMT_FCC), /* 0x33, RTW_CHPLAN_WORLD_FCC6 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x34, RTW_CHPLAN_FCC1_FCC7 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI2, TXPWR_LMT_ETSI), /* 0x35, RTW_CHPLAN_WORLD_ETSI2 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI3, TXPWR_LMT_ETSI), /* 0x36, RTW_CHPLAN_WORLD_ETSI3 */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK2, TXPWR_LMT_MKK), /* 0x37, RTW_CHPLAN_MKK1_MKK2 */ + CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK3, TXPWR_LMT_MKK), /* 0x38, RTW_CHPLAN_MKK1_MKK3 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC1, TXPWR_LMT_FCC), /* 0x39, RTW_CHPLAN_FCC1_NCC1 */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x3A, RTW_CHPLAN_ETSI1_ETSI1 */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ACMA1, TXPWR_LMT_ACMA), /* 0x3B, RTW_CHPLAN_ETSI1_ACMA1 */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI6, TXPWR_LMT_ETSI), /* 0x3C, RTW_CHPLAN_ETSI1_ETSI6 */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI12, TXPWR_LMT_ETSI), /* 0x3D, RTW_CHPLAN_ETSI1_ETSI12 */ + CHPLAN_ENT(RTW_RD_2G_KCC1, RTW_RD_5G_KCC2, TXPWR_LMT_KCC), /* 0x3E, RTW_CHPLAN_KCC1_KCC2 */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x3F, */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC2, TXPWR_LMT_FCC), /* 0x40, RTW_CHPLAN_FCC1_NCC2 */ + CHPLAN_ENT(RTW_RD_2G_GLOBAL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x41, RTW_CHPLAN_GLOBAL_NULL */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI4, TXPWR_LMT_ETSI), /* 0x42, RTW_CHPLAN_ETSI1_ETSI4 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x43, RTW_CHPLAN_FCC1_FCC2 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC3, TXPWR_LMT_FCC), /* 0x44, RTW_CHPLAN_FCC1_NCC3 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ACMA1, TXPWR_LMT_ACMA), /* 0x45, RTW_CHPLAN_WORLD_ACMA1 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC8, TXPWR_LMT_FCC), /* 0x46, RTW_CHPLAN_FCC1_FCC8 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI6, TXPWR_LMT_ETSI), /* 0x47, RTW_CHPLAN_WORLD_ETSI6 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI7, TXPWR_LMT_ETSI), /* 0x48, RTW_CHPLAN_WORLD_ETSI7 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI8, TXPWR_LMT_ETSI), /* 0x49, RTW_CHPLAN_WORLD_ETSI8 */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4A, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4B, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4C, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4D, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4E, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4F, */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI9, TXPWR_LMT_ETSI), /* 0x50, RTW_CHPLAN_WORLD_ETSI9 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI10, TXPWR_LMT_ETSI), /* 0x51, RTW_CHPLAN_WORLD_ETSI10 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI11, TXPWR_LMT_ETSI), /* 0x52, RTW_CHPLAN_WORLD_ETSI11 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC4, TXPWR_LMT_FCC), /* 0x53, RTW_CHPLAN_FCC1_NCC4 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI12, TXPWR_LMT_ETSI), /* 0x54, RTW_CHPLAN_WORLD_ETSI12 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC9, TXPWR_LMT_FCC), /* 0x55, RTW_CHPLAN_FCC1_FCC9 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI13, TXPWR_LMT_ETSI), /* 0x56, RTW_CHPLAN_WORLD_ETSI13 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC10, TXPWR_LMT_FCC), /* 0x57, RTW_CHPLAN_FCC1_FCC10 */ + CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK4, TXPWR_LMT_MKK), /* 0x58, RTW_CHPLAN_MKK2_MKK4 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI14, TXPWR_LMT_ETSI), /* 0x59, RTW_CHPLAN_WORLD_ETSI14 */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5A, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5B, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5C, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5D, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5E, */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5F, */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x60, RTW_CHPLAN_FCC1_FCC5 */ + CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x61, RTW_CHPLAN_FCC2_FCC7 */ + CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC1, TXPWR_LMT_FCC), /* 0x62, RTW_CHPLAN_FCC2_FCC1 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI15, TXPWR_LMT_ETSI), /* 0x63, RTW_CHPLAN_WORLD_ETSI15 */ + CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK5, TXPWR_LMT_MKK), /* 0x64, RTW_CHPLAN_MKK2_MKK5 */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI16, TXPWR_LMT_ETSI), /* 0x65, RTW_CHPLAN_ETSI1_ETSI16 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC14, TXPWR_LMT_FCC), /* 0x66, RTW_CHPLAN_FCC1_FCC14 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x67, RTW_CHPLAN_FCC1_FCC12 */ + CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC14, TXPWR_LMT_FCC), /* 0x68, RTW_CHPLAN_FCC2_FCC14 */ + CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x69, RTW_CHPLAN_FCC2_FCC12 */ + CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI17, TXPWR_LMT_ETSI), /* 0x6A, RTW_CHPLAN_ETSI1_ETSI17 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC16, TXPWR_LMT_FCC), /* 0x6B, RTW_CHPLAN_WORLD_FCC16 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC13, TXPWR_LMT_FCC), /* 0x6C, RTW_CHPLAN_WORLD_FCC13 */ + CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC15, TXPWR_LMT_FCC), /* 0x6D, RTW_CHPLAN_FCC2_FCC15 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x6E, RTW_CHPLAN_WORLD_FCC12 */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI8, TXPWR_LMT_ETSI), /* 0x6F, RTW_CHPLAN_NULL_ETSI8 */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI18, TXPWR_LMT_ETSI), /* 0x70, RTW_CHPLAN_NULL_ETSI18 */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI17, TXPWR_LMT_ETSI), /* 0x71, RTW_CHPLAN_NULL_ETSI17 */ + CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI19, TXPWR_LMT_ETSI), /* 0x72, RTW_CHPLAN_NULL_ETSI19 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x73, RTW_CHPLAN_WORLD_FCC7 */ + CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC17, TXPWR_LMT_FCC), /* 0x74, RTW_CHPLAN_FCC2_FCC17 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI20, TXPWR_LMT_ETSI), /* 0x75, RTW_CHPLAN_WORLD_ETSI20 */ + CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC11, TXPWR_LMT_FCC), /* 0x76, RTW_CHPLAN_FCC2_FCC11 */ + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI21, TXPWR_LMT_ETSI), /* 0x77, RTW_CHPLAN_WORLD_ETSI21 */ + CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC18, TXPWR_LMT_FCC), /* 0x78, RTW_CHPLAN_FCC1_FCC18 */ + CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK1, TXPWR_LMT_MKK), /* 0x79, RTW_CHPLAN_MKK2_MKK1 */ +}; + +static struct chplan_ent_t RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = + CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC1, TXPWR_LMT_FCC); /* 0x7F, Realtek Define */ + +u8 rtw_chplan_get_default_regd(u8 id) +{ + u8 regd; + + if (id == RTW_CHPLAN_REALTEK_DEFINE) + regd = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.regd; + else + regd = RTW_ChannelPlanMap[id].regd; + + return regd; +} + +bool rtw_chplan_is_empty(u8 id) +{ + struct chplan_ent_t *chplan_map; + + if (id == RTW_CHPLAN_REALTEK_DEFINE) + chplan_map = &RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE; + else + chplan_map = &RTW_ChannelPlanMap[id]; + + if (chplan_map->rd_2g == RTW_RD_2G_NULL + #ifdef CONFIG_IEEE80211_BAND_5GHZ + && chplan_map->rd_5g == RTW_RD_5G_NULL + #endif + ) + return _TRUE; + + return _FALSE; +} + +bool rtw_regsty_is_excl_chs(struct registry_priv *regsty, u8 ch) +{ + int i; + + for (i = 0; i < MAX_CHANNEL_NUM; i++) { + if (regsty->excl_chs[i] == 0) + break; + if (regsty->excl_chs[i] == ch) + return _TRUE; + } + return _FALSE; +} + +inline static u8 rtw_rd_5g_band1_passive(u8 rtw_rd_5g) +{ + u8 passive = 0; + + switch (rtw_rd_5g) { + case RTW_RD_5G_FCC13: + case RTW_RD_5G_FCC16: + case RTW_RD_5G_ETSI18: + case RTW_RD_5G_ETSI19: + case RTW_RD_5G_WORLD: + case RTW_RD_5G_WORLD1: + passive = 1; + }; + + return passive; +} + +inline static u8 rtw_rd_5g_band4_passive(u8 rtw_rd_5g) +{ + u8 passive = 0; + + switch (rtw_rd_5g) { + case RTW_RD_5G_MKK5: + case RTW_RD_5G_ETSI16: + case RTW_RD_5G_ETSI18: + case RTW_RD_5G_ETSI19: + case RTW_RD_5G_WORLD: + passive = 1; + }; + + return passive; +} + +u8 init_channel_set(_adapter *padapter, u8 ChannelPlan, RT_CHANNEL_INFO *channel_set) +{ + struct registry_priv *regsty = adapter_to_regsty(padapter); + u8 index, chanset_size = 0; + u8 b5GBand = _FALSE, b2_4GBand = _FALSE; + u8 rd_2g = 0, rd_5g = 0; +#ifdef CONFIG_DFS_MASTER + int i; +#endif + + if (!rtw_is_channel_plan_valid(ChannelPlan)) { + RTW_ERR("ChannelPlan ID 0x%02X error !!!!!\n", ChannelPlan); + return chanset_size; + } + + _rtw_memset(channel_set, 0, sizeof(RT_CHANNEL_INFO) * MAX_CHANNEL_NUM); + + if (IsSupported24G(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_2G)) + b2_4GBand = _TRUE; + + if (is_supported_5g(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_5G)) + b5GBand = _TRUE; + + if (b2_4GBand == _FALSE && b5GBand == _FALSE) { + RTW_WARN("HW band_cap has no intersection with SW wireless_mode setting\n"); + return chanset_size; + } + + if (b2_4GBand) { + if (ChannelPlan == RTW_CHPLAN_REALTEK_DEFINE) + rd_2g = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.rd_2g; + else + rd_2g = RTW_ChannelPlanMap[ChannelPlan].rd_2g; + + for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan2G[rd_2g]); index++) { + if (rtw_regsty_is_excl_chs(regsty, CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index)) == _TRUE) + continue; + + if (chanset_size >= MAX_CHANNEL_NUM) { + RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM); + break; + } + + channel_set[chanset_size].ChannelNum = CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index); + + if (ChannelPlan == RTW_CHPLAN_GLOBAL_DOAMIN + || rd_2g == RTW_RD_2G_GLOBAL + ) { + /* Channel 1~11 is active, and 12~14 is passive */ + if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14)) + channel_set[chanset_size].ScanType = SCAN_PASSIVE; + } else if (ChannelPlan == RTW_CHPLAN_WORLD_WIDE_13 + || ChannelPlan == RTW_CHPLAN_WORLD_WIDE_5G + || rd_2g == RTW_RD_2G_WORLD + ) { + /* channel 12~13, passive scan */ + if (channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else + channel_set[chanset_size].ScanType = SCAN_PASSIVE; + } else + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + + chanset_size++; + } + } + +#ifdef CONFIG_IEEE80211_BAND_5GHZ + if (b5GBand) { + if (ChannelPlan == RTW_CHPLAN_REALTEK_DEFINE) + rd_5g = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.rd_5g; + else + rd_5g = RTW_ChannelPlanMap[ChannelPlan].rd_5g; + + for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan5G[rd_5g]); index++) { + if (rtw_regsty_is_excl_chs(regsty, CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index)) == _TRUE) + continue; + #ifndef CONFIG_DFS + if (rtw_is_dfs_ch(CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index))) + continue; + #endif + + if (chanset_size >= MAX_CHANNEL_NUM) { + RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM); + break; + } + + channel_set[chanset_size].ChannelNum = CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index); + + if ((ChannelPlan == RTW_CHPLAN_WORLD_WIDE_5G) /* all channels passive */ + || (rtw_is_5g_band1(channel_set[chanset_size].ChannelNum) + && rtw_rd_5g_band1_passive(rd_5g)) /* band1 passive */ + || (rtw_is_5g_band4(channel_set[chanset_size].ChannelNum) + && rtw_rd_5g_band4_passive(rd_5g)) /* band4 passive */ + || (rtw_is_dfs_ch(channel_set[chanset_size].ChannelNum)) /* DFS channel(band2, 3) passive */ + ) + channel_set[chanset_size].ScanType = SCAN_PASSIVE; + else + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + + chanset_size++; + } + } + + #ifdef CONFIG_DFS_MASTER + for (i = 0; i < chanset_size; i++) + channel_set[i].non_ocp_end_time = rtw_get_current_time(); + #endif +#endif /* CONFIG_IEEE80211_BAND_5GHZ */ + + if (chanset_size) + RTW_INFO(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, ch num:%d\n" + , FUNC_ADPT_ARG(padapter), ChannelPlan, chanset_size); + else + RTW_WARN(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, final chset has no channel\n" + , FUNC_ADPT_ARG(padapter), ChannelPlan); + + return chanset_size; +} + +#ifdef CONFIG_80211AC_VHT +#define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val) , .en_11ac = (_val) +#else +#define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val) +#endif + +#if RTW_DEF_MODULE_REGULATORY_CERT +#define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val) , .def_module_flags = (_val) +#else +#define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val) +#endif + +/* has def_module_flags specified, used by common map and HAL dfference map */ +#define COUNTRY_CHPLAN_ENT(_alpha2, _chplan, _en_11ac, _def_module_flags) \ + {.alpha2 = (_alpha2), .chplan = (_chplan) \ + COUNTRY_CHPLAN_ASSIGN_EN_11AC(_en_11ac) \ + COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_def_module_flags) \ + } + +#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP + +#include "../platform/custom_country_chplan.h" + +#elif RTW_DEF_MODULE_REGULATORY_CERT + +/* leave def_module_flags empty, def_module_flags check is done on country_chplan_map */ +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821AE_HMC_M2) /* 2013 certify */ +static const struct country_chplan RTL8821AE_HMC_M2_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */ + COUNTRY_CHPLAN_ENT("CL", 0x30, 1, 0), /* Chile */ + COUNTRY_CHPLAN_ENT("CN", 0x51, 1, 0), /* China */ + COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ + COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ + COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ + COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ + COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ + COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ + COUNTRY_CHPLAN_ENT("MY", 0x47, 1, 0), /* Malaysia */ + COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ + COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ + COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ + COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ + COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ + COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ + COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */ + COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821AU) /* 2014 certify */ +static const struct country_chplan RTL8821AU_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */ + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ + COUNTRY_CHPLAN_ENT("RU", 0x59, 0, 0), /* Russia(fac/gost), Kaliningrad */ + COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ + COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */ + COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8812AENF_NGFF) /* 2014 certify */ +static const struct country_chplan RTL8812AENF_NGFF_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ + COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8812AEBT_HMC) /* 2013 certify */ +static const struct country_chplan RTL8812AEBT_HMC_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */ + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ + COUNTRY_CHPLAN_ENT("RU", 0x59, 0, 0), /* Russia(fac/gost), Kaliningrad */ + COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ + COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */ + COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8188EE_HMC_M2) /* 2012 certify */ +static const struct country_chplan RTL8188EE_HMC_M2_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */ + COUNTRY_CHPLAN_ENT("BB", 0x34, 1, 0), /* Barbados */ + COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */ + COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ + COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ + COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ + COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ + COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ + COUNTRY_CHPLAN_ENT("HT", 0x34, 1, 0), /* Haiti */ + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ + COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ + COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ + COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ + COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ + COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ + COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ + COUNTRY_CHPLAN_ENT("SC", 0x34, 1, 0), /* Seychelles */ + COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ + COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ + COUNTRY_CHPLAN_ENT("VC", 0x34, 1, 0), /* Saint Vincent and the Grenadines */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723BE_HMC_M2) /* 2013 certify */ +static const struct country_chplan RTL8723BE_HMC_M2_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */ + COUNTRY_CHPLAN_ENT("BS", 0x34, 1, 0), /* Bahamas */ + COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */ + COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ + COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ + COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ + COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ + COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ + COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ + COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ + COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ + COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ + COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ + COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ + COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ + COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723BS_NGFF1216) /* 2014 certify */ +static const struct country_chplan RTL8723BS_NGFF1216_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("BB", 0x34, 1, 0), /* Barbados */ + COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */ + COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ + COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ + COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ + COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ + COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ + COUNTRY_CHPLAN_ENT("HT", 0x34, 1, 0), /* Haiti */ + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ + COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ + COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ + COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ + COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ + COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ + COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ + COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ + COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8192EEBT_HMC_M2) /* 2013 certify */ +static const struct country_chplan RTL8192EEBT_HMC_M2_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */ + COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */ + COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */ + COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */ + COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */ + COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */ + COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */ + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ + COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ + COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */ + COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */ + COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */ + COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */ + COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */ + COUNTRY_CHPLAN_ENT("SC", 0x34, 1, 0), /* Seychelles */ + COUNTRY_CHPLAN_ENT("ST", 0x34, 1, 0), /* Sao Tome and Principe */ + COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */ + COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723DE_NGFF1630) /* 2016 certify */ +static const struct country_chplan RTL8723DE_NGFF1630_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("CA", 0x2A, 1, 0), /* Canada */ + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ + COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8822BE) /* 2016 certify */ +static const struct country_chplan RTL8822BE_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ +}; +#endif + +#if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821CE) /* 2016 certify */ +static const struct country_chplan RTL8821CE_country_chplan_exc_map[] = { + COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */ +}; +#endif + +/** + * rtw_def_module_get_chplan_from_country - + * @country_code: string of country code + * @return: + * Return NULL for case referring to common map + */ +static const struct country_chplan *rtw_def_module_get_chplan_from_country(const char *country_code) +{ + const struct country_chplan *ent = NULL; + const struct country_chplan *hal_map = NULL; + u16 hal_map_sz = 0; + int i; + + /* TODO: runtime selection for multi driver */ +#if (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AE_HMC_M2) + hal_map = RTL8821AE_HMC_M2_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8821AE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AU) + hal_map = RTL8821AU_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8821AU_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AENF_NGFF) + hal_map = RTL8812AENF_NGFF_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8812AENF_NGFF_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AEBT_HMC) + hal_map = RTL8812AEBT_HMC_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8812AEBT_HMC_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8188EE_HMC_M2) + hal_map = RTL8188EE_HMC_M2_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8188EE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BE_HMC_M2) + hal_map = RTL8723BE_HMC_M2_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8723BE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BS_NGFF1216) + hal_map = RTL8723BS_NGFF1216_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8723BS_NGFF1216_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8192EEBT_HMC_M2) + hal_map = RTL8192EEBT_HMC_M2_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8192EEBT_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723DE_NGFF1630) + hal_map = RTL8723DE_NGFF1630_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8723DE_NGFF1630_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8822BE) + hal_map = RTL8822BE_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8822BE_country_chplan_exc_map) / sizeof(struct country_chplan); +#elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821CE) + hal_map = RTL8821CE_country_chplan_exc_map; + hal_map_sz = sizeof(RTL8821CE_country_chplan_exc_map) / sizeof(struct country_chplan); +#endif + + if (hal_map == NULL || hal_map_sz == 0) + goto exit; + + for (i = 0; i < hal_map_sz; i++) { + if (strncmp(country_code, hal_map[i].alpha2, 2) == 0) { + ent = &hal_map[i]; + break; + } + } + +exit: + return ent; +} +#endif /* CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP or RTW_DEF_MODULE_REGULATORY_CERT */ + +static const struct country_chplan country_chplan_map[] = { + COUNTRY_CHPLAN_ENT("AD", 0x26, 1, 0x000), /* Andorra */ + COUNTRY_CHPLAN_ENT("AE", 0x26, 1, 0x7FB), /* United Arab Emirates */ + COUNTRY_CHPLAN_ENT("AF", 0x42, 1, 0x000), /* Afghanistan */ + COUNTRY_CHPLAN_ENT("AG", 0x26, 1, 0x000), /* Antigua & Barbuda */ + COUNTRY_CHPLAN_ENT("AI", 0x26, 1, 0x000), /* Anguilla(UK) */ + COUNTRY_CHPLAN_ENT("AL", 0x26, 1, 0x7F1), /* Albania */ + COUNTRY_CHPLAN_ENT("AM", 0x26, 1, 0x6B0), /* Armenia */ + COUNTRY_CHPLAN_ENT("AN", 0x26, 1, 0x7F1), /* Netherlands Antilles */ + COUNTRY_CHPLAN_ENT("AO", 0x47, 1, 0x6E0), /* Angola */ + COUNTRY_CHPLAN_ENT("AQ", 0x26, 1, 0x000), /* Antarctica */ + COUNTRY_CHPLAN_ENT("AR", 0x61, 1, 0x7F3), /* Argentina */ + COUNTRY_CHPLAN_ENT("AS", 0x76, 1, 0x000), /* American Samoa */ + COUNTRY_CHPLAN_ENT("AT", 0x26, 1, 0x7FB), /* Austria */ + COUNTRY_CHPLAN_ENT("AU", 0x45, 1, 0x7FB), /* Australia */ + COUNTRY_CHPLAN_ENT("AW", 0x76, 1, 0x0B0), /* Aruba */ + COUNTRY_CHPLAN_ENT("AZ", 0x26, 1, 0x7F1), /* Azerbaijan */ + COUNTRY_CHPLAN_ENT("BA", 0x26, 1, 0x7F1), /* Bosnia & Herzegovina */ + COUNTRY_CHPLAN_ENT("BB", 0x76, 1, 0x650), /* Barbados */ + COUNTRY_CHPLAN_ENT("BD", 0x26, 1, 0x7F1), /* Bangladesh */ + COUNTRY_CHPLAN_ENT("BE", 0x26, 1, 0x7FB), /* Belgium */ + COUNTRY_CHPLAN_ENT("BF", 0x26, 1, 0x6B0), /* Burkina Faso */ + COUNTRY_CHPLAN_ENT("BG", 0x26, 1, 0x7F1), /* Bulgaria */ + COUNTRY_CHPLAN_ENT("BH", 0x47, 1, 0x7F1), /* Bahrain */ + COUNTRY_CHPLAN_ENT("BI", 0x26, 1, 0x6B0), /* Burundi */ + COUNTRY_CHPLAN_ENT("BJ", 0x26, 1, 0x6B0), /* Benin */ + COUNTRY_CHPLAN_ENT("BN", 0x47, 1, 0x610), /* Brunei */ + COUNTRY_CHPLAN_ENT("BO", 0x73, 1, 0x7F1), /* Bolivia */ + COUNTRY_CHPLAN_ENT("BR", 0x62, 1, 0x7F1), /* Brazil */ + COUNTRY_CHPLAN_ENT("BS", 0x76, 1, 0x620), /* Bahamas */ + COUNTRY_CHPLAN_ENT("BW", 0x26, 1, 0x6F1), /* Botswana */ + COUNTRY_CHPLAN_ENT("BY", 0x26, 1, 0x7F1), /* Belarus */ + COUNTRY_CHPLAN_ENT("BZ", 0x76, 1, 0x000), /* Belize */ + COUNTRY_CHPLAN_ENT("CA", 0x2B, 1, 0x7FB), /* Canada */ + COUNTRY_CHPLAN_ENT("CC", 0x26, 1, 0x000), /* Cocos (Keeling) Islands (Australia) */ + COUNTRY_CHPLAN_ENT("CD", 0x26, 1, 0x6B0), /* Congo, Republic of the */ + COUNTRY_CHPLAN_ENT("CF", 0x26, 1, 0x6B0), /* Central African Republic */ + COUNTRY_CHPLAN_ENT("CG", 0x26, 1, 0x6B0), /* Congo, Democratic Republic of the. Zaire */ + COUNTRY_CHPLAN_ENT("CH", 0x26, 1, 0x7FB), /* Switzerland */ + COUNTRY_CHPLAN_ENT("CI", 0x26, 1, 0x7F1), /* Cote d'Ivoire */ + COUNTRY_CHPLAN_ENT("CK", 0x26, 1, 0x000), /* Cook Islands */ + COUNTRY_CHPLAN_ENT("CL", 0x2D, 1, 0x7F1), /* Chile */ + COUNTRY_CHPLAN_ENT("CM", 0x26, 1, 0x6B0), /* Cameroon */ + COUNTRY_CHPLAN_ENT("CN", 0x48, 1, 0x7FB), /* China */ + COUNTRY_CHPLAN_ENT("CO", 0x76, 1, 0x7F1), /* Colombia */ + COUNTRY_CHPLAN_ENT("CR", 0x76, 1, 0x7F1), /* Costa Rica */ + COUNTRY_CHPLAN_ENT("CV", 0x26, 1, 0x6B0), /* Cape Verde */ + COUNTRY_CHPLAN_ENT("CX", 0x45, 1, 0x000), /* Christmas Island (Australia) */ + COUNTRY_CHPLAN_ENT("CY", 0x26, 1, 0x7FB), /* Cyprus */ + COUNTRY_CHPLAN_ENT("CZ", 0x26, 1, 0x7FB), /* Czech Republic */ + COUNTRY_CHPLAN_ENT("DE", 0x26, 1, 0x7FB), /* Germany */ + COUNTRY_CHPLAN_ENT("DJ", 0x26, 1, 0x680), /* Djibouti */ + COUNTRY_CHPLAN_ENT("DK", 0x26, 1, 0x7FB), /* Denmark */ + COUNTRY_CHPLAN_ENT("DM", 0x76, 1, 0x000), /* Dominica */ + COUNTRY_CHPLAN_ENT("DO", 0x76, 1, 0x7F1), /* Dominican Republic */ + COUNTRY_CHPLAN_ENT("DZ", 0x26, 1, 0x7F1), /* Algeria */ + COUNTRY_CHPLAN_ENT("EC", 0x76, 1, 0x7F1), /* Ecuador */ + COUNTRY_CHPLAN_ENT("EE", 0x26, 1, 0x7FB), /* Estonia */ + COUNTRY_CHPLAN_ENT("EG", 0x47, 1, 0x7F1), /* Egypt */ + COUNTRY_CHPLAN_ENT("EH", 0x47, 1, 0x680), /* Western Sahara */ + COUNTRY_CHPLAN_ENT("ER", 0x26, 1, 0x000), /* Eritrea */ + COUNTRY_CHPLAN_ENT("ES", 0x26, 1, 0x7FB), /* Spain, Canary Islands, Ceuta, Melilla */ + COUNTRY_CHPLAN_ENT("ET", 0x26, 1, 0x4B0), /* Ethiopia */ + COUNTRY_CHPLAN_ENT("FI", 0x26, 1, 0x7FB), /* Finland */ + COUNTRY_CHPLAN_ENT("FJ", 0x76, 1, 0x600), /* Fiji */ + COUNTRY_CHPLAN_ENT("FK", 0x26, 1, 0x000), /* Falkland Islands (Islas Malvinas) (UK) */ + COUNTRY_CHPLAN_ENT("FM", 0x76, 1, 0x000), /* Micronesia, Federated States of (USA) */ + COUNTRY_CHPLAN_ENT("FO", 0x26, 1, 0x000), /* Faroe Islands (Denmark) */ + COUNTRY_CHPLAN_ENT("FR", 0x26, 1, 0x7FB), /* France */ + COUNTRY_CHPLAN_ENT("GA", 0x26, 1, 0x6B0), /* Gabon */ + COUNTRY_CHPLAN_ENT("GB", 0x26, 1, 0x7FB), /* Great Britain (United Kingdom; England) */ + COUNTRY_CHPLAN_ENT("GD", 0x34, 1, 0x0B0), /* Grenada */ + COUNTRY_CHPLAN_ENT("GE", 0x26, 1, 0x600), /* Georgia */ + COUNTRY_CHPLAN_ENT("GF", 0x26, 1, 0x080), /* French Guiana */ + COUNTRY_CHPLAN_ENT("GG", 0x26, 1, 0x000), /* Guernsey (UK) */ + COUNTRY_CHPLAN_ENT("GH", 0x26, 1, 0x7F1), /* Ghana */ + COUNTRY_CHPLAN_ENT("GI", 0x26, 1, 0x600), /* Gibraltar (UK) */ + COUNTRY_CHPLAN_ENT("GL", 0x26, 1, 0x600), /* Greenland (Denmark) */ + COUNTRY_CHPLAN_ENT("GM", 0x26, 1, 0x6B0), /* Gambia */ + COUNTRY_CHPLAN_ENT("GN", 0x26, 1, 0x610), /* Guinea */ + COUNTRY_CHPLAN_ENT("GP", 0x26, 1, 0x600), /* Guadeloupe (France) */ + COUNTRY_CHPLAN_ENT("GQ", 0x26, 1, 0x6B0), /* Equatorial Guinea */ + COUNTRY_CHPLAN_ENT("GR", 0x26, 1, 0x7FB), /* Greece */ + COUNTRY_CHPLAN_ENT("GS", 0x26, 1, 0x000), /* South Georgia and the Sandwich Islands (UK) */ + COUNTRY_CHPLAN_ENT("GT", 0x61, 1, 0x7F1), /* Guatemala */ + COUNTRY_CHPLAN_ENT("GU", 0x76, 1, 0x600), /* Guam (USA) */ + COUNTRY_CHPLAN_ENT("GW", 0x26, 1, 0x6B0), /* Guinea-Bissau */ + COUNTRY_CHPLAN_ENT("GY", 0x44, 1, 0x000), /* Guyana */ + COUNTRY_CHPLAN_ENT("HK", 0x26, 1, 0x7FB), /* Hong Kong */ + COUNTRY_CHPLAN_ENT("HM", 0x45, 1, 0x000), /* Heard and McDonald Islands (Australia) */ + COUNTRY_CHPLAN_ENT("HN", 0x32, 1, 0x7F1), /* Honduras */ + COUNTRY_CHPLAN_ENT("HR", 0x26, 1, 0x7F9), /* Croatia */ + COUNTRY_CHPLAN_ENT("HT", 0x76, 1, 0x650), /* Haiti */ + COUNTRY_CHPLAN_ENT("HU", 0x26, 1, 0x7FB), /* Hungary */ + COUNTRY_CHPLAN_ENT("ID", 0x3D, 0, 0x7F3), /* Indonesia */ + COUNTRY_CHPLAN_ENT("IE", 0x26, 1, 0x7FB), /* Ireland */ + COUNTRY_CHPLAN_ENT("IL", 0x47, 1, 0x7F1), /* Israel */ + COUNTRY_CHPLAN_ENT("IM", 0x26, 1, 0x000), /* Isle of Man (UK) */ + COUNTRY_CHPLAN_ENT("IN", 0x48, 1, 0x7F1), /* India */ + COUNTRY_CHPLAN_ENT("IQ", 0x26, 1, 0x000), /* Iraq */ + COUNTRY_CHPLAN_ENT("IR", 0x26, 0, 0x000), /* Iran */ + COUNTRY_CHPLAN_ENT("IS", 0x26, 1, 0x7FB), /* Iceland */ + COUNTRY_CHPLAN_ENT("IT", 0x26, 1, 0x7FB), /* Italy */ + COUNTRY_CHPLAN_ENT("JE", 0x26, 1, 0x000), /* Jersey (UK) */ + COUNTRY_CHPLAN_ENT("JM", 0x51, 1, 0x7F1), /* Jamaica */ + COUNTRY_CHPLAN_ENT("JO", 0x49, 1, 0x7FB), /* Jordan */ + COUNTRY_CHPLAN_ENT("JP", 0x27, 1, 0x7FF), /* Japan- Telec */ + COUNTRY_CHPLAN_ENT("KE", 0x47, 1, 0x7F9), /* Kenya */ + COUNTRY_CHPLAN_ENT("KG", 0x26, 1, 0x7F1), /* Kyrgyzstan */ + COUNTRY_CHPLAN_ENT("KH", 0x26, 1, 0x7F1), /* Cambodia */ + COUNTRY_CHPLAN_ENT("KI", 0x26, 1, 0x000), /* Kiribati */ + COUNTRY_CHPLAN_ENT("KN", 0x76, 1, 0x000), /* Saint Kitts and Nevis */ + COUNTRY_CHPLAN_ENT("KR", 0x3E, 1, 0x7FB), /* South Korea */ + COUNTRY_CHPLAN_ENT("KW", 0x47, 1, 0x7FB), /* Kuwait */ + COUNTRY_CHPLAN_ENT("KY", 0x76, 1, 0x000), /* Cayman Islands (UK) */ + COUNTRY_CHPLAN_ENT("KZ", 0x26, 1, 0x700), /* Kazakhstan */ + COUNTRY_CHPLAN_ENT("LA", 0x26, 1, 0x000), /* Laos */ + COUNTRY_CHPLAN_ENT("LB", 0x26, 1, 0x7F1), /* Lebanon */ + COUNTRY_CHPLAN_ENT("LC", 0x76, 1, 0x000), /* Saint Lucia */ + COUNTRY_CHPLAN_ENT("LI", 0x26, 1, 0x7FB), /* Liechtenstein */ + COUNTRY_CHPLAN_ENT("LK", 0x26, 1, 0x7F1), /* Sri Lanka */ + COUNTRY_CHPLAN_ENT("LR", 0x26, 1, 0x6B0), /* Liberia */ + COUNTRY_CHPLAN_ENT("LS", 0x26, 1, 0x7F1), /* Lesotho */ + COUNTRY_CHPLAN_ENT("LT", 0x26, 1, 0x7FB), /* Lithuania */ + COUNTRY_CHPLAN_ENT("LU", 0x26, 1, 0x7FB), /* Luxembourg */ + COUNTRY_CHPLAN_ENT("LV", 0x26, 1, 0x7FB), /* Latvia */ + COUNTRY_CHPLAN_ENT("LY", 0x26, 1, 0x000), /* Libya */ + COUNTRY_CHPLAN_ENT("MA", 0x47, 1, 0x7F1), /* Morocco */ + COUNTRY_CHPLAN_ENT("MC", 0x26, 1, 0x7FB), /* Monaco */ + COUNTRY_CHPLAN_ENT("MD", 0x26, 1, 0x7F1), /* Moldova */ + COUNTRY_CHPLAN_ENT("ME", 0x26, 1, 0x7F1), /* Montenegro */ + COUNTRY_CHPLAN_ENT("MF", 0x76, 1, 0x000), /* Saint Martin */ + COUNTRY_CHPLAN_ENT("MG", 0x26, 1, 0x620), /* Madagascar */ + COUNTRY_CHPLAN_ENT("MH", 0x76, 1, 0x000), /* Marshall Islands (USA) */ + COUNTRY_CHPLAN_ENT("MK", 0x26, 1, 0x7F1), /* Republic of Macedonia (FYROM) */ + COUNTRY_CHPLAN_ENT("ML", 0x26, 1, 0x6B0), /* Mali */ + COUNTRY_CHPLAN_ENT("MM", 0x26, 1, 0x000), /* Burma (Myanmar) */ + COUNTRY_CHPLAN_ENT("MN", 0x26, 1, 0x000), /* Mongolia */ + COUNTRY_CHPLAN_ENT("MO", 0x26, 1, 0x600), /* Macau */ + COUNTRY_CHPLAN_ENT("MP", 0x76, 1, 0x000), /* Northern Mariana Islands (USA) */ + COUNTRY_CHPLAN_ENT("MQ", 0x26, 1, 0x640), /* Martinique (France) */ + COUNTRY_CHPLAN_ENT("MR", 0x26, 1, 0x6A0), /* Mauritania */ + COUNTRY_CHPLAN_ENT("MS", 0x26, 1, 0x000), /* Montserrat (UK) */ + COUNTRY_CHPLAN_ENT("MT", 0x26, 1, 0x7FB), /* Malta */ + COUNTRY_CHPLAN_ENT("MU", 0x26, 1, 0x6B0), /* Mauritius */ + COUNTRY_CHPLAN_ENT("MV", 0x47, 1, 0x000), /* Maldives */ + COUNTRY_CHPLAN_ENT("MW", 0x26, 1, 0x6B0), /* Malawi */ + COUNTRY_CHPLAN_ENT("MX", 0x61, 1, 0x7F1), /* Mexico */ + COUNTRY_CHPLAN_ENT("MY", 0x63, 1, 0x7F1), /* Malaysia */ + COUNTRY_CHPLAN_ENT("MZ", 0x26, 1, 0x7F1), /* Mozambique */ + COUNTRY_CHPLAN_ENT("NA", 0x26, 1, 0x700), /* Namibia */ + COUNTRY_CHPLAN_ENT("NC", 0x26, 1, 0x000), /* New Caledonia */ + COUNTRY_CHPLAN_ENT("NE", 0x26, 1, 0x6B0), /* Niger */ + COUNTRY_CHPLAN_ENT("NF", 0x45, 1, 0x000), /* Norfolk Island (Australia) */ + COUNTRY_CHPLAN_ENT("NG", 0x75, 1, 0x7F9), /* Nigeria */ + COUNTRY_CHPLAN_ENT("NI", 0x76, 1, 0x7F1), /* Nicaragua */ + COUNTRY_CHPLAN_ENT("NL", 0x26, 1, 0x7FB), /* Netherlands */ + COUNTRY_CHPLAN_ENT("NO", 0x26, 1, 0x7FB), /* Norway */ + COUNTRY_CHPLAN_ENT("NP", 0x47, 1, 0x6F0), /* Nepal */ + COUNTRY_CHPLAN_ENT("NR", 0x26, 1, 0x000), /* Nauru */ + COUNTRY_CHPLAN_ENT("NU", 0x45, 1, 0x000), /* Niue */ + COUNTRY_CHPLAN_ENT("NZ", 0x45, 1, 0x7FB), /* New Zealand */ + COUNTRY_CHPLAN_ENT("OM", 0x26, 1, 0x7F9), /* Oman */ + COUNTRY_CHPLAN_ENT("PA", 0x76, 1, 0x7F1), /* Panama */ + COUNTRY_CHPLAN_ENT("PE", 0x76, 1, 0x7F1), /* Peru */ + COUNTRY_CHPLAN_ENT("PF", 0x26, 1, 0x000), /* French Polynesia (France) */ + COUNTRY_CHPLAN_ENT("PG", 0x26, 1, 0x7F1), /* Papua New Guinea */ + COUNTRY_CHPLAN_ENT("PH", 0x26, 1, 0x7F1), /* Philippines */ + COUNTRY_CHPLAN_ENT("PK", 0x51, 1, 0x7F1), /* Pakistan */ + COUNTRY_CHPLAN_ENT("PL", 0x26, 1, 0x7FB), /* Poland */ + COUNTRY_CHPLAN_ENT("PM", 0x26, 1, 0x000), /* Saint Pierre and Miquelon (France) */ + COUNTRY_CHPLAN_ENT("PR", 0x76, 1, 0x7F1), /* Puerto Rico */ + COUNTRY_CHPLAN_ENT("PT", 0x26, 1, 0x7FB), /* Portugal */ + COUNTRY_CHPLAN_ENT("PW", 0x76, 1, 0x000), /* Palau */ + COUNTRY_CHPLAN_ENT("PY", 0x76, 1, 0x7F1), /* Paraguay */ + COUNTRY_CHPLAN_ENT("QA", 0x51, 1, 0x7F9), /* Qatar */ + COUNTRY_CHPLAN_ENT("RE", 0x26, 1, 0x000), /* Reunion (France) */ + COUNTRY_CHPLAN_ENT("RO", 0x26, 1, 0x7F1), /* Romania */ + COUNTRY_CHPLAN_ENT("RS", 0x26, 1, 0x7F1), /* Serbia, Kosovo */ + COUNTRY_CHPLAN_ENT("RU", 0x59, 1, 0x7FB), /* Russia(fac/gost), Kaliningrad */ + COUNTRY_CHPLAN_ENT("RW", 0x26, 1, 0x0B0), /* Rwanda */ + COUNTRY_CHPLAN_ENT("SA", 0x26, 1, 0x7FB), /* Saudi Arabia */ + COUNTRY_CHPLAN_ENT("SB", 0x26, 1, 0x000), /* Solomon Islands */ + COUNTRY_CHPLAN_ENT("SC", 0x76, 1, 0x690), /* Seychelles */ + COUNTRY_CHPLAN_ENT("SE", 0x26, 1, 0x7FB), /* Sweden */ + COUNTRY_CHPLAN_ENT("SG", 0x26, 1, 0x7FB), /* Singapore */ + COUNTRY_CHPLAN_ENT("SH", 0x26, 1, 0x000), /* Saint Helena (UK) */ + COUNTRY_CHPLAN_ENT("SI", 0x26, 1, 0x7FB), /* Slovenia */ + COUNTRY_CHPLAN_ENT("SJ", 0x26, 1, 0x000), /* Svalbard (Norway) */ + COUNTRY_CHPLAN_ENT("SK", 0x26, 1, 0x7FB), /* Slovakia */ + COUNTRY_CHPLAN_ENT("SL", 0x26, 1, 0x6B0), /* Sierra Leone */ + COUNTRY_CHPLAN_ENT("SM", 0x26, 1, 0x000), /* San Marino */ + COUNTRY_CHPLAN_ENT("SN", 0x26, 1, 0x7F1), /* Senegal */ + COUNTRY_CHPLAN_ENT("SO", 0x26, 1, 0x000), /* Somalia */ + COUNTRY_CHPLAN_ENT("SR", 0x74, 1, 0x000), /* Suriname */ + COUNTRY_CHPLAN_ENT("ST", 0x76, 1, 0x680), /* Sao Tome and Principe */ + COUNTRY_CHPLAN_ENT("SV", 0x30, 1, 0x7F1), /* El Salvador */ + COUNTRY_CHPLAN_ENT("SX", 0x76, 1, 0x000), /* Sint Marteen */ + COUNTRY_CHPLAN_ENT("SZ", 0x26, 1, 0x020), /* Swaziland */ + COUNTRY_CHPLAN_ENT("TC", 0x26, 1, 0x000), /* Turks and Caicos Islands (UK) */ + COUNTRY_CHPLAN_ENT("TD", 0x26, 1, 0x6B0), /* Chad */ + COUNTRY_CHPLAN_ENT("TF", 0x26, 1, 0x680), /* French Southern and Antarctic Lands (FR Southern Territories) */ + COUNTRY_CHPLAN_ENT("TG", 0x26, 1, 0x6B0), /* Togo */ + COUNTRY_CHPLAN_ENT("TH", 0x26, 1, 0x7F1), /* Thailand */ + COUNTRY_CHPLAN_ENT("TJ", 0x26, 1, 0x640), /* Tajikistan */ + COUNTRY_CHPLAN_ENT("TK", 0x45, 1, 0x000), /* Tokelau */ + COUNTRY_CHPLAN_ENT("TM", 0x26, 1, 0x000), /* Turkmenistan */ + COUNTRY_CHPLAN_ENT("TN", 0x47, 1, 0x7F1), /* Tunisia */ + COUNTRY_CHPLAN_ENT("TO", 0x26, 1, 0x000), /* Tonga */ + COUNTRY_CHPLAN_ENT("TR", 0x26, 1, 0x7F1), /* Turkey, Northern Cyprus */ + COUNTRY_CHPLAN_ENT("TT", 0x42, 1, 0x3F1), /* Trinidad & Tobago */ + COUNTRY_CHPLAN_ENT("TW", 0x76, 1, 0x7FF), /* Taiwan */ + COUNTRY_CHPLAN_ENT("TZ", 0x26, 1, 0x6F0), /* Tanzania */ + COUNTRY_CHPLAN_ENT("UA", 0x36, 1, 0x7FB), /* Ukraine */ + COUNTRY_CHPLAN_ENT("UG", 0x26, 1, 0x6F1), /* Uganda */ + COUNTRY_CHPLAN_ENT("US", 0x76, 1, 0x7FF), /* United States of America (USA) */ + COUNTRY_CHPLAN_ENT("UY", 0x30, 1, 0x7F1), /* Uruguay */ + COUNTRY_CHPLAN_ENT("UZ", 0x47, 1, 0x6F0), /* Uzbekistan */ + COUNTRY_CHPLAN_ENT("VA", 0x26, 1, 0x000), /* Holy See (Vatican City) */ + COUNTRY_CHPLAN_ENT("VC", 0x76, 1, 0x010), /* Saint Vincent and the Grenadines */ + COUNTRY_CHPLAN_ENT("VE", 0x30, 1, 0x7F1), /* Venezuela */ + COUNTRY_CHPLAN_ENT("VI", 0x76, 1, 0x000), /* United States Virgin Islands (USA) */ + COUNTRY_CHPLAN_ENT("VN", 0x26, 1, 0x7F1), /* Vietnam */ + COUNTRY_CHPLAN_ENT("VU", 0x26, 1, 0x000), /* Vanuatu */ + COUNTRY_CHPLAN_ENT("WF", 0x26, 1, 0x000), /* Wallis and Futuna (France) */ + COUNTRY_CHPLAN_ENT("WS", 0x76, 1, 0x000), /* Samoa */ + COUNTRY_CHPLAN_ENT("YE", 0x26, 1, 0x040), /* Yemen */ + COUNTRY_CHPLAN_ENT("YT", 0x26, 1, 0x680), /* Mayotte (France) */ + COUNTRY_CHPLAN_ENT("ZA", 0x26, 1, 0x7F1), /* South Africa */ + COUNTRY_CHPLAN_ENT("ZM", 0x26, 1, 0x6B0), /* Zambia */ + COUNTRY_CHPLAN_ENT("ZW", 0x26, 1, 0x7F1), /* Zimbabwe */ +}; + +/* +* rtw_get_chplan_from_country - +* @country_code: string of country code +* +* Return pointer of struct country_chplan entry or NULL when unsupported country_code is given +*/ +const struct country_chplan *rtw_get_chplan_from_country(const char *country_code) +{ +#if RTW_DEF_MODULE_REGULATORY_CERT + const struct country_chplan *exc_ent = NULL; +#endif + const struct country_chplan *ent = NULL; + const struct country_chplan *map = NULL; + u16 map_sz = 0; + char code[2]; + int i; + + code[0] = alpha_to_upper(country_code[0]); + code[1] = alpha_to_upper(country_code[1]); + +#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP + map = CUSTOMIZED_country_chplan_map; + map_sz = sizeof(CUSTOMIZED_country_chplan_map) / sizeof(struct country_chplan); +#else + #if RTW_DEF_MODULE_REGULATORY_CERT + exc_ent = rtw_def_module_get_chplan_from_country(code); + #endif + map = country_chplan_map; + map_sz = sizeof(country_chplan_map) / sizeof(struct country_chplan); +#endif + + for (i = 0; i < map_sz; i++) { + if (strncmp(code, map[i].alpha2, 2) == 0) { + ent = &map[i]; + break; + } + } + + #if RTW_DEF_MODULE_REGULATORY_CERT + if (!ent || !(COUNTRY_CHPLAN_DEF_MODULE_FALGS(ent) & RTW_DEF_MODULE_REGULATORY_CERT)) + exc_ent = ent = NULL; + if (exc_ent) + ent = exc_ent; + #endif + + return ent; +} + +void dump_country_chplan(void *sel, const struct country_chplan *ent) +{ + RTW_PRINT_SEL(sel, "\"%c%c\", 0x%02X%s\n" + , ent->alpha2[0], ent->alpha2[1], ent->chplan + , COUNTRY_CHPLAN_EN_11AC(ent) ? " ac" : "" + ); +} + +void dump_country_chplan_map(void *sel) +{ + const struct country_chplan *ent; + u8 code[2]; + +#if RTW_DEF_MODULE_REGULATORY_CERT + RTW_PRINT_SEL(sel, "RTW_DEF_MODULE_REGULATORY_CERT:0x%x\n", RTW_DEF_MODULE_REGULATORY_CERT); +#endif +#ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP + RTW_PRINT_SEL(sel, "CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP\n"); +#endif + + for (code[0] = 'A'; code[0] <= 'Z'; code[0]++) { + for (code[1] = 'A'; code[1] <= 'Z'; code[1]++) { + ent = rtw_get_chplan_from_country(code); + if (!ent) + continue; + + dump_country_chplan(sel, ent); + } + } +} + +void dump_chplan_id_list(void *sel) +{ + u8 first = 1; + int i; + + for (i = 0; i < RTW_CHPLAN_MAX; i++) { + if (!rtw_is_channel_plan_valid(i)) + continue; + + if (first) { + RTW_PRINT_SEL(sel, "0x%02X ", i); + first = 0; + } else + _RTW_PRINT_SEL(sel, "0x%02X ", i); + } + + _RTW_PRINT_SEL(sel, "0x7F\n"); +} + +void dump_chplan_test(void *sel) +{ + int i, j; + + /* check invalid channel */ + for (i = 0; i < RTW_RD_2G_MAX; i++) { + for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan2G[i]); j++) { + if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan2G[i], j)) == 0) + RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan2G[i], j), i, j); + } + } + +#ifdef CONFIG_IEEE80211_BAND_5GHZ + for (i = 0; i < RTW_RD_5G_MAX; i++) { + for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan5G[i]); j++) { + if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan5G[i], j)) == 0) + RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan5G[i], j), i, j); + } + } +#endif +} + +void dump_chplan_ver(void *sel) +{ + RTW_PRINT_SEL(sel, "%s-%s\n", RTW_DOMAIN_MAP_VER, RTW_COUNTRY_MAP_VER); +} diff --git a/core/rtw_chplan.h b/core/rtw_chplan.h index c819f71..232cbcd 100644 --- a/core/rtw_chplan.h +++ b/core/rtw_chplan.h @@ -1,179 +1,179 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2018 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - *****************************************************************************/ -#ifndef __RTW_CHPLAN_H__ -#define __RTW_CHPLAN_H__ - -enum rtw_chplan_id { - /* ===== 0x00 ~ 0x1F, legacy channel plan ===== */ - RTW_CHPLAN_FCC = 0x00, - RTW_CHPLAN_IC = 0x01, - RTW_CHPLAN_ETSI = 0x02, - RTW_CHPLAN_SPAIN = 0x03, - RTW_CHPLAN_FRANCE = 0x04, - RTW_CHPLAN_MKK = 0x05, - RTW_CHPLAN_MKK1 = 0x06, - RTW_CHPLAN_ISRAEL = 0x07, - RTW_CHPLAN_TELEC = 0x08, - RTW_CHPLAN_GLOBAL_DOAMIN = 0x09, - RTW_CHPLAN_WORLD_WIDE_13 = 0x0A, - RTW_CHPLAN_TAIWAN = 0x0B, - RTW_CHPLAN_CHINA = 0x0C, - RTW_CHPLAN_SINGAPORE_INDIA_MEXICO = 0x0D, - RTW_CHPLAN_KOREA = 0x0E, - RTW_CHPLAN_TURKEY = 0x0F, - RTW_CHPLAN_JAPAN = 0x10, - RTW_CHPLAN_FCC_NO_DFS = 0x11, - RTW_CHPLAN_JAPAN_NO_DFS = 0x12, - RTW_CHPLAN_WORLD_WIDE_5G = 0x13, - RTW_CHPLAN_TAIWAN_NO_DFS = 0x14, - - /* ===== 0x20 ~ 0x7F, new channel plan ===== */ - RTW_CHPLAN_WORLD_NULL = 0x20, - RTW_CHPLAN_ETSI1_NULL = 0x21, - RTW_CHPLAN_FCC1_NULL = 0x22, - RTW_CHPLAN_MKK1_NULL = 0x23, - RTW_CHPLAN_ETSI2_NULL = 0x24, - RTW_CHPLAN_FCC1_FCC1 = 0x25, - RTW_CHPLAN_WORLD_ETSI1 = 0x26, - RTW_CHPLAN_MKK1_MKK1 = 0x27, - RTW_CHPLAN_WORLD_KCC1 = 0x28, - RTW_CHPLAN_WORLD_FCC2 = 0x29, - RTW_CHPLAN_FCC2_NULL = 0x2A, - RTW_CHPLAN_IC1_IC2 = 0x2B, - RTW_CHPLAN_MKK2_NULL = 0x2C, - RTW_CHPLAN_WORLD_CHILE1= 0x2D, - RTW_CHPLAN_WORLD1_WORLD1 = 0x2E, - RTW_CHPLAN_WORLD_CHILE2 = 0x2F, - RTW_CHPLAN_WORLD_FCC3 = 0x30, - RTW_CHPLAN_WORLD_FCC4 = 0x31, - RTW_CHPLAN_WORLD_FCC5 = 0x32, - RTW_CHPLAN_WORLD_FCC6 = 0x33, - RTW_CHPLAN_FCC1_FCC7 = 0x34, - RTW_CHPLAN_WORLD_ETSI2 = 0x35, - RTW_CHPLAN_WORLD_ETSI3 = 0x36, - RTW_CHPLAN_MKK1_MKK2 = 0x37, - RTW_CHPLAN_MKK1_MKK3 = 0x38, - RTW_CHPLAN_FCC1_NCC1 = 0x39, - RTW_CHPLAN_ETSI1_ETSI1 = 0x3A, - RTW_CHPLAN_ETSI1_ACMA1 = 0x3B, - RTW_CHPLAN_ETSI1_ETSI6 = 0x3C, - RTW_CHPLAN_ETSI1_ETSI12 = 0x3D, - RTW_CHPLAN_KCC1_KCC2 = 0x3E, - RTW_CHPLAN_FCC1_NCC2 = 0x40, - RTW_CHPLAN_GLOBAL_NULL = 0x41, - RTW_CHPLAN_ETSI1_ETSI4 = 0x42, - RTW_CHPLAN_FCC1_FCC2 = 0x43, - RTW_CHPLAN_FCC1_NCC3 = 0x44, - RTW_CHPLAN_WORLD_ACMA1 = 0x45, - RTW_CHPLAN_FCC1_FCC8 = 0x46, - RTW_CHPLAN_WORLD_ETSI6 = 0x47, - RTW_CHPLAN_WORLD_ETSI7 = 0x48, - RTW_CHPLAN_WORLD_ETSI8 = 0x49, - RTW_CHPLAN_WORLD_ETSI9 = 0x50, - RTW_CHPLAN_WORLD_ETSI10 = 0x51, - RTW_CHPLAN_WORLD_ETSI11 = 0x52, - RTW_CHPLAN_FCC1_NCC4 = 0x53, - RTW_CHPLAN_WORLD_ETSI12 = 0x54, - RTW_CHPLAN_FCC1_FCC9 = 0x55, - RTW_CHPLAN_WORLD_ETSI13 = 0x56, - RTW_CHPLAN_FCC1_FCC10 = 0x57, - RTW_CHPLAN_MKK2_MKK4 = 0x58, - RTW_CHPLAN_WORLD_ETSI14 = 0x59, - RTW_CHPLAN_FCC1_FCC5 = 0x60, - RTW_CHPLAN_FCC2_FCC7 = 0x61, - RTW_CHPLAN_FCC2_FCC1 = 0x62, - RTW_CHPLAN_WORLD_ETSI15 = 0x63, - RTW_CHPLAN_MKK2_MKK5 = 0x64, - RTW_CHPLAN_ETSI1_ETSI16 = 0x65, - RTW_CHPLAN_FCC1_FCC14 = 0x66, - RTW_CHPLAN_FCC1_FCC12 = 0x67, - RTW_CHPLAN_FCC2_FCC14 = 0x68, - RTW_CHPLAN_FCC2_FCC12 = 0x69, - RTW_CHPLAN_ETSI1_ETSI17 = 0x6A, - RTW_CHPLAN_WORLD_FCC16 = 0x6B, - RTW_CHPLAN_WORLD_FCC13 = 0x6C, - RTW_CHPLAN_FCC2_FCC15 = 0x6D, - RTW_CHPLAN_WORLD_FCC12 = 0x6E, - RTW_CHPLAN_NULL_ETSI8 = 0x6F, - RTW_CHPLAN_NULL_ETSI18 = 0x70, - RTW_CHPLAN_NULL_ETSI17 = 0x71, - RTW_CHPLAN_NULL_ETSI19 = 0x72, - RTW_CHPLAN_WORLD_FCC7 = 0x73, - RTW_CHPLAN_FCC2_FCC17 = 0x74, - RTW_CHPLAN_WORLD_ETSI20 = 0x75, - RTW_CHPLAN_FCC2_FCC11 = 0x76, - RTW_CHPLAN_WORLD_ETSI21 = 0x77, - RTW_CHPLAN_FCC1_FCC18 = 0x78, - RTW_CHPLAN_MKK2_MKK1 = 0x79, - - RTW_CHPLAN_MAX, - RTW_CHPLAN_REALTEK_DEFINE = 0x7F, - RTW_CHPLAN_UNSPECIFIED = 0xFF, -}; - -u8 rtw_chplan_get_default_regd(u8 id); -bool rtw_chplan_is_empty(u8 id); -#define rtw_is_channel_plan_valid(chplan) (((chplan) < RTW_CHPLAN_MAX || (chplan) == RTW_CHPLAN_REALTEK_DEFINE) && !rtw_chplan_is_empty(chplan)) -#define rtw_is_legacy_channel_plan(chplan) ((chplan) < 0x20) - -struct _RT_CHANNEL_INFO; -u8 init_channel_set(_adapter *padapter, u8 ChannelPlan, struct _RT_CHANNEL_INFO *channel_set); - -#define IS_ALPHA2_NO_SPECIFIED(_alpha2) ((*((u16 *)(_alpha2))) == 0xFFFF) - -#define RTW_MODULE_RTL8821AE_HMC_M2 BIT0 /* RTL8821AE(HMC + M.2) */ -#define RTW_MODULE_RTL8821AU BIT1 /* RTL8821AU */ -#define RTW_MODULE_RTL8812AENF_NGFF BIT2 /* RTL8812AENF(8812AE+8761)_NGFF */ -#define RTW_MODULE_RTL8812AEBT_HMC BIT3 /* RTL8812AEBT(8812AE+8761)_HMC */ -#define RTW_MODULE_RTL8188EE_HMC_M2 BIT4 /* RTL8188EE(HMC + M.2) */ -#define RTW_MODULE_RTL8723BE_HMC_M2 BIT5 /* RTL8723BE(HMC + M.2) */ -#define RTW_MODULE_RTL8723BS_NGFF1216 BIT6 /* RTL8723BS(NGFF1216) */ -#define RTW_MODULE_RTL8192EEBT_HMC_M2 BIT7 /* RTL8192EEBT(8192EE+8761AU)_(HMC + M.2) */ -#define RTW_MODULE_RTL8723DE_NGFF1630 BIT8 /* RTL8723DE(NGFF1630) */ -#define RTW_MODULE_RTL8822BE BIT9 /* RTL8822BE */ -#define RTW_MODULE_RTL8821CE BIT10 /* RTL8821CE */ - -struct country_chplan { - char alpha2[2]; - u8 chplan; -#ifdef CONFIG_80211AC_VHT - u8 en_11ac; -#endif -#if RTW_DEF_MODULE_REGULATORY_CERT - u16 def_module_flags; /* RTW_MODULE_RTLXXX */ -#endif -}; - -#ifdef CONFIG_80211AC_VHT -#define COUNTRY_CHPLAN_EN_11AC(_ent) ((_ent)->en_11ac) -#else -#define COUNTRY_CHPLAN_EN_11AC(_ent) 0 -#endif - -#if RTW_DEF_MODULE_REGULATORY_CERT -#define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) ((_ent)->def_module_flags) -#else -#define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) 0 -#endif - -const struct country_chplan *rtw_get_chplan_from_country(const char *country_code); - -void dump_country_chplan(void *sel, const struct country_chplan *ent); -void dump_country_chplan_map(void *sel); -void dump_chplan_id_list(void *sel); -void dump_chplan_test(void *sel); -void dump_chplan_ver(void *sel); - -#endif /* __RTW_CHPLAN_H__ */ +/****************************************************************************** + * + * Copyright(c) 2007 - 2018 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + *****************************************************************************/ +#ifndef __RTW_CHPLAN_H__ +#define __RTW_CHPLAN_H__ + +enum rtw_chplan_id { + /* ===== 0x00 ~ 0x1F, legacy channel plan ===== */ + RTW_CHPLAN_FCC = 0x00, + RTW_CHPLAN_IC = 0x01, + RTW_CHPLAN_ETSI = 0x02, + RTW_CHPLAN_SPAIN = 0x03, + RTW_CHPLAN_FRANCE = 0x04, + RTW_CHPLAN_MKK = 0x05, + RTW_CHPLAN_MKK1 = 0x06, + RTW_CHPLAN_ISRAEL = 0x07, + RTW_CHPLAN_TELEC = 0x08, + RTW_CHPLAN_GLOBAL_DOAMIN = 0x09, + RTW_CHPLAN_WORLD_WIDE_13 = 0x0A, + RTW_CHPLAN_TAIWAN = 0x0B, + RTW_CHPLAN_CHINA = 0x0C, + RTW_CHPLAN_SINGAPORE_INDIA_MEXICO = 0x0D, + RTW_CHPLAN_KOREA = 0x0E, + RTW_CHPLAN_TURKEY = 0x0F, + RTW_CHPLAN_JAPAN = 0x10, + RTW_CHPLAN_FCC_NO_DFS = 0x11, + RTW_CHPLAN_JAPAN_NO_DFS = 0x12, + RTW_CHPLAN_WORLD_WIDE_5G = 0x13, + RTW_CHPLAN_TAIWAN_NO_DFS = 0x14, + + /* ===== 0x20 ~ 0x7F, new channel plan ===== */ + RTW_CHPLAN_WORLD_NULL = 0x20, + RTW_CHPLAN_ETSI1_NULL = 0x21, + RTW_CHPLAN_FCC1_NULL = 0x22, + RTW_CHPLAN_MKK1_NULL = 0x23, + RTW_CHPLAN_ETSI2_NULL = 0x24, + RTW_CHPLAN_FCC1_FCC1 = 0x25, + RTW_CHPLAN_WORLD_ETSI1 = 0x26, + RTW_CHPLAN_MKK1_MKK1 = 0x27, + RTW_CHPLAN_WORLD_KCC1 = 0x28, + RTW_CHPLAN_WORLD_FCC2 = 0x29, + RTW_CHPLAN_FCC2_NULL = 0x2A, + RTW_CHPLAN_IC1_IC2 = 0x2B, + RTW_CHPLAN_MKK2_NULL = 0x2C, + RTW_CHPLAN_WORLD_CHILE1= 0x2D, + RTW_CHPLAN_WORLD1_WORLD1 = 0x2E, + RTW_CHPLAN_WORLD_CHILE2 = 0x2F, + RTW_CHPLAN_WORLD_FCC3 = 0x30, + RTW_CHPLAN_WORLD_FCC4 = 0x31, + RTW_CHPLAN_WORLD_FCC5 = 0x32, + RTW_CHPLAN_WORLD_FCC6 = 0x33, + RTW_CHPLAN_FCC1_FCC7 = 0x34, + RTW_CHPLAN_WORLD_ETSI2 = 0x35, + RTW_CHPLAN_WORLD_ETSI3 = 0x36, + RTW_CHPLAN_MKK1_MKK2 = 0x37, + RTW_CHPLAN_MKK1_MKK3 = 0x38, + RTW_CHPLAN_FCC1_NCC1 = 0x39, + RTW_CHPLAN_ETSI1_ETSI1 = 0x3A, + RTW_CHPLAN_ETSI1_ACMA1 = 0x3B, + RTW_CHPLAN_ETSI1_ETSI6 = 0x3C, + RTW_CHPLAN_ETSI1_ETSI12 = 0x3D, + RTW_CHPLAN_KCC1_KCC2 = 0x3E, + RTW_CHPLAN_FCC1_NCC2 = 0x40, + RTW_CHPLAN_GLOBAL_NULL = 0x41, + RTW_CHPLAN_ETSI1_ETSI4 = 0x42, + RTW_CHPLAN_FCC1_FCC2 = 0x43, + RTW_CHPLAN_FCC1_NCC3 = 0x44, + RTW_CHPLAN_WORLD_ACMA1 = 0x45, + RTW_CHPLAN_FCC1_FCC8 = 0x46, + RTW_CHPLAN_WORLD_ETSI6 = 0x47, + RTW_CHPLAN_WORLD_ETSI7 = 0x48, + RTW_CHPLAN_WORLD_ETSI8 = 0x49, + RTW_CHPLAN_WORLD_ETSI9 = 0x50, + RTW_CHPLAN_WORLD_ETSI10 = 0x51, + RTW_CHPLAN_WORLD_ETSI11 = 0x52, + RTW_CHPLAN_FCC1_NCC4 = 0x53, + RTW_CHPLAN_WORLD_ETSI12 = 0x54, + RTW_CHPLAN_FCC1_FCC9 = 0x55, + RTW_CHPLAN_WORLD_ETSI13 = 0x56, + RTW_CHPLAN_FCC1_FCC10 = 0x57, + RTW_CHPLAN_MKK2_MKK4 = 0x58, + RTW_CHPLAN_WORLD_ETSI14 = 0x59, + RTW_CHPLAN_FCC1_FCC5 = 0x60, + RTW_CHPLAN_FCC2_FCC7 = 0x61, + RTW_CHPLAN_FCC2_FCC1 = 0x62, + RTW_CHPLAN_WORLD_ETSI15 = 0x63, + RTW_CHPLAN_MKK2_MKK5 = 0x64, + RTW_CHPLAN_ETSI1_ETSI16 = 0x65, + RTW_CHPLAN_FCC1_FCC14 = 0x66, + RTW_CHPLAN_FCC1_FCC12 = 0x67, + RTW_CHPLAN_FCC2_FCC14 = 0x68, + RTW_CHPLAN_FCC2_FCC12 = 0x69, + RTW_CHPLAN_ETSI1_ETSI17 = 0x6A, + RTW_CHPLAN_WORLD_FCC16 = 0x6B, + RTW_CHPLAN_WORLD_FCC13 = 0x6C, + RTW_CHPLAN_FCC2_FCC15 = 0x6D, + RTW_CHPLAN_WORLD_FCC12 = 0x6E, + RTW_CHPLAN_NULL_ETSI8 = 0x6F, + RTW_CHPLAN_NULL_ETSI18 = 0x70, + RTW_CHPLAN_NULL_ETSI17 = 0x71, + RTW_CHPLAN_NULL_ETSI19 = 0x72, + RTW_CHPLAN_WORLD_FCC7 = 0x73, + RTW_CHPLAN_FCC2_FCC17 = 0x74, + RTW_CHPLAN_WORLD_ETSI20 = 0x75, + RTW_CHPLAN_FCC2_FCC11 = 0x76, + RTW_CHPLAN_WORLD_ETSI21 = 0x77, + RTW_CHPLAN_FCC1_FCC18 = 0x78, + RTW_CHPLAN_MKK2_MKK1 = 0x79, + + RTW_CHPLAN_MAX, + RTW_CHPLAN_REALTEK_DEFINE = 0x7F, + RTW_CHPLAN_UNSPECIFIED = 0xFF, +}; + +u8 rtw_chplan_get_default_regd(u8 id); +bool rtw_chplan_is_empty(u8 id); +#define rtw_is_channel_plan_valid(chplan) (((chplan) < RTW_CHPLAN_MAX || (chplan) == RTW_CHPLAN_REALTEK_DEFINE) && !rtw_chplan_is_empty(chplan)) +#define rtw_is_legacy_channel_plan(chplan) ((chplan) < 0x20) + +struct _RT_CHANNEL_INFO; +u8 init_channel_set(_adapter *padapter, u8 ChannelPlan, struct _RT_CHANNEL_INFO *channel_set); + +#define IS_ALPHA2_NO_SPECIFIED(_alpha2) ((*((u16 *)(_alpha2))) == 0xFFFF) + +#define RTW_MODULE_RTL8821AE_HMC_M2 BIT0 /* RTL8821AE(HMC + M.2) */ +#define RTW_MODULE_RTL8821AU BIT1 /* RTL8821AU */ +#define RTW_MODULE_RTL8812AENF_NGFF BIT2 /* RTL8812AENF(8812AE+8761)_NGFF */ +#define RTW_MODULE_RTL8812AEBT_HMC BIT3 /* RTL8812AEBT(8812AE+8761)_HMC */ +#define RTW_MODULE_RTL8188EE_HMC_M2 BIT4 /* RTL8188EE(HMC + M.2) */ +#define RTW_MODULE_RTL8723BE_HMC_M2 BIT5 /* RTL8723BE(HMC + M.2) */ +#define RTW_MODULE_RTL8723BS_NGFF1216 BIT6 /* RTL8723BS(NGFF1216) */ +#define RTW_MODULE_RTL8192EEBT_HMC_M2 BIT7 /* RTL8192EEBT(8192EE+8761AU)_(HMC + M.2) */ +#define RTW_MODULE_RTL8723DE_NGFF1630 BIT8 /* RTL8723DE(NGFF1630) */ +#define RTW_MODULE_RTL8822BE BIT9 /* RTL8822BE */ +#define RTW_MODULE_RTL8821CE BIT10 /* RTL8821CE */ + +struct country_chplan { + char alpha2[2]; + u8 chplan; +#ifdef CONFIG_80211AC_VHT + u8 en_11ac; +#endif +#if RTW_DEF_MODULE_REGULATORY_CERT + u16 def_module_flags; /* RTW_MODULE_RTLXXX */ +#endif +}; + +#ifdef CONFIG_80211AC_VHT +#define COUNTRY_CHPLAN_EN_11AC(_ent) ((_ent)->en_11ac) +#else +#define COUNTRY_CHPLAN_EN_11AC(_ent) 0 +#endif + +#if RTW_DEF_MODULE_REGULATORY_CERT +#define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) ((_ent)->def_module_flags) +#else +#define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) 0 +#endif + +const struct country_chplan *rtw_get_chplan_from_country(const char *country_code); + +void dump_country_chplan(void *sel, const struct country_chplan *ent); +void dump_country_chplan_map(void *sel); +void dump_chplan_id_list(void *sel); +void dump_chplan_test(void *sel); +void dump_chplan_ver(void *sel); + +#endif /* __RTW_CHPLAN_H__ */ diff --git a/core/rtw_cmd.c b/core/rtw_cmd.c index 5be5617..79e6369 100644 --- a/core/rtw_cmd.c +++ b/core/rtw_cmd.c @@ -1329,13 +1329,13 @@ static void rtw_ft_validate_akm_type(_adapter *padapter, /*IEEE802.11-2012 Std. Table 8-101-AKM suite selectors*/ if (rtw_ft_valid_akm(padapter, psecuritypriv->rsn_akm_suite_type)) { - ptmp = rtw_get_ie(&pnetwork->network.IEs[12], + ptmp = rtw_get_ie(&pnetwork->network.IEs[12], _MDIE_, &tmp_len, (pnetwork->network.IELength-12)); if (ptmp) { pft_roam->mdid = *(u16 *)(ptmp+2); pft_roam->ft_cap = *(ptmp+4); - RTW_INFO("FT: target " MAC_FMT " mdid=(0x%2x), capacity=(0x%2x)\n", + RTW_INFO("FT: target " MAC_FMT " mdid=(0x%2x), capacity=(0x%2x)\n", MAC_ARG(pnetwork->network.MacAddress), pft_roam->mdid, pft_roam->ft_cap); rtw_ft_set_flags(padapter, RTW_FT_PEER_EN); @@ -1350,7 +1350,7 @@ static void rtw_ft_validate_akm_type(_adapter *padapter, /* It could be a non-FT connection */ rtw_ft_clr_flags(padapter, (RTW_FT_PEER_EN|RTW_FT_PEER_OTD_EN)); rtw_ft_reset_status(padapter); - } + } } #endif @@ -1470,9 +1470,9 @@ u8 rtw_joinbss_cmd(_adapter *padapter, struct wlan_network *pnetwork) pqospriv->qos_option = 0; if (pregistrypriv->wmm_enable) { -#ifdef CONFIG_WMMPS_STA +#ifdef CONFIG_WMMPS_STA rtw_uapsd_use_default_setting(padapter); -#endif /* CONFIG_WMMPS_STA */ +#endif /* CONFIG_WMMPS_STA */ tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength, psecnetwork->IELength); if (psecnetwork->IELength != tmp_len) { @@ -2922,7 +2922,7 @@ u8 _lps_chk_by_tp(_adapter *adapter, u8 from_timer) #endif static u8 _lps_chk_by_pkt_cnts(_adapter *padapter, u8 from_timer, u8 bBusyTraffic) -{ +{ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); u8 bEnterPS = _FALSE; @@ -3203,7 +3203,7 @@ static void dynamic_update_bcn_check(_adapter *padapter) if (_FALSE != ATOMIC_READ(&pmlmepriv->olbc) && _FALSE != ATOMIC_READ(&pmlmepriv->olbc_ht)) { - + if (rtw_ht_operation_update(padapter) > 0) { update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, _FALSE); update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, _TRUE); @@ -3827,7 +3827,7 @@ inline u8 p2p_cancel_roch_cmd(_adapter *adapter, u64 cookie, struct wireless_dev #endif /* CONFIG_IOCTL_CFG80211 */ #endif /* CONFIG_P2P */ -#ifdef CONFIG_IOCTL_CFG80211 +#ifdef CONFIG_IOCTL_CFG80211 inline u8 rtw_mgnt_tx_cmd(_adapter *adapter, u8 tx_ch, u8 no_cck, const u8 *buf, size_t len, int wait_ack, u8 flags) { struct cmd_obj *cmdobj; @@ -4013,7 +4013,7 @@ void rtw_dfs_ch_switch_hdl(struct dvobj_priv *dvobj) if (ifbmp_s) { _adapter *iface; int i; - + for (i = 0; i < dvobj->iface_nums; i++) { iface = dvobj->padapters[i]; if (!iface || !(ifbmp_s & BIT(iface->iface_id))) @@ -5345,7 +5345,7 @@ static s32 rtw_req_per_cmd_hdl(_adapter *adapter) } /* group_macid: always be 0 in NIC, so only pass macid_bitmap.m0 - * rpt_type: 0 includes all info in 1, use 0 for now + * rpt_type: 0 includes all info in 1, use 0 for now * macid_bitmap: pass m0 only for NIC */ ret = rtw_hal_set_req_per_rpt_cmd(adapter, 0, 0, req_macid_bmp.m0); diff --git a/core/rtw_debug.c b/core/rtw_debug.c index 62e9261..ccc1397 100644 --- a/core/rtw_debug.c +++ b/core/rtw_debug.c @@ -139,7 +139,7 @@ void dump_drv_cfg(void *sel) #ifdef CONFIG_RTW_TPT_MODE RTW_PRINT_SEL(sel, "CONFIG_RTW_TPT_MODE\n"); -#endif +#endif #ifdef CONFIG_USB_HCI #ifdef CONFIG_SUPPORT_USB_INT @@ -1803,7 +1803,7 @@ ssize_t proc_set_rate_ctl(struct file *file, const char __user *buffer, size_t c if ((fix_rate == 0) || (fix_rate == 0xFF)) en = 0; - + if (macid != 255) { RTW_INFO("Call phydm_fw_fix_rate()--en[%d] mac_id[%d] bw[%d] fix_rate[%d]\n", en, macid, bw, fix_rate); phydm_fw_fix_rate(dm, en, macid, bw, fix_rate); @@ -2695,7 +2695,7 @@ int proc_get_rx_signal(struct seq_file *m, void *v) RTW_PRINT_SEL(m, "rx_rate = %s\n", HDATA_RATE(odm->rx_rate)); return 0; - } else + } else #endif { /* RTW_PRINT_SEL(m, "rxpwdb:%d\n", padapter->recvpriv.rxpwdb); */ @@ -4916,21 +4916,21 @@ ssize_t proc_set_ps_info(struct file *file, const char __user *buffer, size_t co RTW_INFO("%s: back to original LPS/IPS Mode\n", __FUNCTION__); rtw_pm_set_lps(adapter, adapter->registrypriv.power_mgnt); - + rtw_pm_set_ips(adapter, adapter->registrypriv.ips_mode); goto exit; } - - if (mode == 1) { + + if (mode == 1) { /* LPS */ - RTW_INFO("%s: LPS: %s, en=%d\n", __FUNCTION__, (en == 0) ? "disable":"enable", en); + RTW_INFO("%s: LPS: %s, en=%d\n", __FUNCTION__, (en == 0) ? "disable":"enable", en); if (rtw_pm_set_lps(adapter, en) != 0 ) RTW_ERR("%s: invalid parameter, mode=%d, level=%d\n", __FUNCTION__, mode, en); - + } else if (mode == 2) { /* IPS */ - RTW_INFO("%s: IPS: %s, en=%d\n", __FUNCTION__, (en == 0) ? "disable":"enable", en); + RTW_INFO("%s: IPS: %s, en=%d\n", __FUNCTION__, (en == 0) ? "disable":"enable", en); if (rtw_pm_set_ips(adapter, en) != 0 ) RTW_ERR("%s: invalid parameter, mode=%d, level=%d\n", __FUNCTION__, mode, en); } else diff --git a/core/rtw_ieee80211.c b/core/rtw_ieee80211.c index 93169ff..2c609ed 100644 --- a/core/rtw_ieee80211.c +++ b/core/rtw_ieee80211.c @@ -427,7 +427,7 @@ int rtw_remove_ie_g_rate(u8 *ie, uint *ie_len, uint offset, u8 eid) while (1) { tem_target_ie=rtw_get_ie(start,eid,&temp_target_ielen,search_len); - + /*if(tem_target_ie) RTW_INFO("%s, tem_target_ie=%u\n", __FUNCTION__,*tem_target_ie);*/ if (tem_target_ie && temp_target_ielen) { @@ -441,7 +441,7 @@ int rtw_remove_ie_g_rate(u8 *ie, uint *ie_len, uint offset, u8 eid) target_ielen=cck_rate_size;/*discount g mode rate 6, 9 12,18Mbps,id , length*/ *(tem_target_ie+1)=target_ielen;/*set new length to Supposrted Rates*/ target_ie=tem_target_ie+target_ielen + 2;/*set target ie to address of rate 6Mbps */ - + _rtw_memmove(target_ie, remain_ies, remain_len); *ie_len = *ie_len - rm_size; ret = rm_size; diff --git a/core/rtw_ioctl_set.c b/core/rtw_ioctl_set.c index d32a014..1bb72b1 100644 --- a/core/rtw_ioctl_set.c +++ b/core/rtw_ioctl_set.c @@ -817,7 +817,7 @@ u16 rtw_get_cur_max_rate(_adapter *adapter) else #endif /* CONFIG_80211N_HT */ { - /*station mode show :station && ap support rate; softap :show ap support rate*/ + /*station mode show :station && ap support rate; softap :show ap support rate*/ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) get_rate_set(adapter, sta_bssrate, &sta_bssrate_len);/*get sta rate and length*/ @@ -839,7 +839,7 @@ u16 rtw_get_cur_max_rate(_adapter *adapter) } } } else { - + if (rate > max_rate) max_rate = rate; diff --git a/core/rtw_mlme.c b/core/rtw_mlme.c index a3567a2..cc83c14 100644 --- a/core/rtw_mlme.c +++ b/core/rtw_mlme.c @@ -139,7 +139,7 @@ sint _rtw_init_mlme_priv(_adapter *padapter) #if defined(CONFIG_RTW_WNM) || defined(CONFIG_RTW_80211K) rtw_roam_nb_info_init(padapter); pmlmepriv->ch_cnt = 0; -#endif +#endif #endif rtw_init_mlme_timer(padapter); @@ -698,8 +698,8 @@ int is_same_network(WLAN_BSSID_EX *src, WLAN_BSSID_EX *dst, u8 feature) return _TRUE; #endif - /* Wi-Fi driver doesn't consider the situation of BCN and ProbRsp sent from the same hidden AP, - * it considers these two packets are sent from different AP. + /* Wi-Fi driver doesn't consider the situation of BCN and ProbRsp sent from the same hidden AP, + * it considers these two packets are sent from different AP. * Therefore, the scan queue may store two scan results of the same hidden AP, likes below. * * index bssid ch RSSI SdBm Noise age flag ssid @@ -712,11 +712,11 @@ int is_same_network(WLAN_BSSID_EX *src, WLAN_BSSID_EX *dst, u8 feature) * It means the scan queue will not store two scan results of the same hidden AP, it only store ProbRsp. * For customer request. */ - + if (((_rtw_memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == _TRUE) && ((s_cap & WLAN_CAPABILITY_IBSS) == (d_cap & WLAN_CAPABILITY_IBSS)) && ((s_cap & WLAN_CAPABILITY_BSS) == (d_cap & WLAN_CAPABILITY_BSS))) { - if ((src->Ssid.SsidLength == dst->Ssid.SsidLength) && + if ((src->Ssid.SsidLength == dst->Ssid.SsidLength) && (((_rtw_memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == _TRUE) || //Case of normal AP (is_all_null(src->Ssid.Ssid, src->Ssid.SsidLength) == _TRUE || is_all_null(dst->Ssid.Ssid, dst->Ssid.SsidLength) == _TRUE))) //Case of hidden AP return _TRUE; @@ -993,7 +993,7 @@ bool rtw_update_scanned_network(_adapter *adapter, WLAN_BSSID_EX *target) plist = get_next(plist); continue; } - + #ifdef CONFIG_RSSI_PRIORITY if ((choice == NULL) || (pnetwork->network.PhyInfo.SignalStrength < choice->network.PhyInfo.SignalStrength)) #ifdef CONFIG_RTW_MESH @@ -2657,10 +2657,10 @@ u8 rtw_ft_chk_roaming_candidate( /*The candidate don't support over-the-DS*/ if (rtw_ft_valid_otd_candidate(padapter, pmdie)) { RTW_INFO("FT: ignore the candidate(" - MAC_FMT ") for over-the-DS\n", + MAC_FMT ") for over-the-DS\n", MAC_ARG(competitor->network.MacAddress)); rtw_ft_clr_flags(padapter, RTW_FT_PEER_OTD_EN); - return _FALSE; + return _FALSE; } return _TRUE; @@ -2736,7 +2736,7 @@ err_2: void rtw_roam_nb_info_init(_adapter *padapter) { struct roam_nb_info *pnb = &(padapter->mlmepriv.nb_info); - + _rtw_memset(&pnb->nb_rpt, 0, sizeof(pnb->nb_rpt)); _rtw_memset(&pnb->nb_rpt_ch_list, 0, sizeof(pnb->nb_rpt_ch_list)); _rtw_memset(&pnb->roam_target_addr, 0, ETH_ALEN); @@ -2746,8 +2746,8 @@ void rtw_roam_nb_info_init(_adapter *padapter) pnb->nb_rpt_is_same = _TRUE; pnb->last_nb_rpt_entries = 0; #ifdef CONFIG_RTW_WNM - rtw_init_timer(&pnb->roam_scan_timer, - padapter, rtw_wnm_roam_scan_hdl, + rtw_init_timer(&pnb->roam_scan_timer, + padapter, rtw_wnm_roam_scan_hdl, padapter); #endif } @@ -2775,7 +2775,7 @@ u8 rtw_roam_nb_scan_list_set( rtw_init_sitesurvey_parm(padapter, pparm); if (rtw_roam_busy_scan(padapter, pnb)) { pparm->ch_num = 1; - pparm->ch[pmlmepriv->ch_cnt].hw_value = + pparm->ch[pmlmepriv->ch_cnt].hw_value = pnb->nb_rpt_ch_list[pmlmepriv->ch_cnt].hw_value; pmlmepriv->ch_cnt++; ret = _TRUE; @@ -2794,7 +2794,7 @@ u8 rtw_roam_nb_scan_list_set( } pmlmepriv->nb_info.nb_rpt_valid = _FALSE; - pmlmepriv->ch_cnt = 0; + pmlmepriv->ch_cnt = 0; ret = _TRUE; set_bssid_list: @@ -3139,7 +3139,7 @@ void rtw_scan_timeout_handler(void *ctx) void rtw_mlme_reset_auto_scan_int(_adapter *adapter, u8 *reason) { #if defined(CONFIG_RTW_MESH) && defined(CONFIG_DFS_MASTER) -#if CONFIG_RTW_MESH_OFFCH_CAND +#if CONFIG_RTW_MESH_OFFCH_CAND struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter); #endif #endif @@ -3253,7 +3253,7 @@ void rtw_drv_scan_by_self(_adapter *padapter, u8 reason) } #if defined(CONFIG_RTW_WNM) || defined(CONFIG_RTW_80211K) - if ((reason == RTW_AUTO_SCAN_REASON_ROAM) + if ((reason == RTW_AUTO_SCAN_REASON_ROAM) && (rtw_roam_nb_scan_list_set(padapter, &parm))) goto exit; #endif @@ -3483,7 +3483,7 @@ static void collect_traffic_statistics(_adapter *padapter) dynamic_napi_th_chk (padapter); #endif /* CONFIG_RTW_NAPI_DYNAMIC */ #endif - + } void rtw_dynamic_check_timer_handlder(void *ctx) @@ -3617,10 +3617,10 @@ static int rtw_check_roaming_candidate(struct mlme_priv *mlme goto exit; #if defined(CONFIG_RTW_80211R) && defined(CONFIG_RTW_WNM) - if (rtw_wnm_btm_diff_bss(adapter) && + if (rtw_wnm_btm_diff_bss(adapter) && rtw_wnm_btm_roam_candidate(adapter, competitor)) { goto update; - } + } #endif if (competitor->network.Rssi - mlme->cur_network_scanned->network.Rssi < mlme->roam_rssi_diff_th) @@ -4064,9 +4064,9 @@ exit: /* * rtw_uapsd_use_default_setting * This function is used for setting default uapsd max sp length to uapsd_max_sp_len - * in qos_priv data structure from registry. In additional, it will also map default uapsd - * ac to each uapsd TID, delivery-enabled and trigger-enabled of corresponding TID. - * + * in qos_priv data structure from registry. In additional, it will also map default uapsd + * ac to each uapsd TID, delivery-enabled and trigger-enabled of corresponding TID. + * * Arguments: * @padapter: _adapter pointer. * @@ -4081,7 +4081,7 @@ void rtw_uapsd_use_default_setting(_adapter *padapter) if (pregistrypriv->uapsd_ac_enable != 0) { pqospriv->uapsd_max_sp_len = pregistrypriv->uapsd_max_sp_len; - + CLEAR_FLAGS(pqospriv->uapsd_tid); CLEAR_FLAGS(pqospriv->uapsd_tid_delivery_enabled); CLEAR_FLAGS(pqospriv->uapsd_tid_trigger_enabled); @@ -4097,7 +4097,7 @@ void rtw_uapsd_use_default_setting(_adapter *padapter) } /* check the uapsd setting of AC_VI from registry then map these setting to each TID if necessary */ - if(TEST_FLAG(pregistrypriv->uapsd_ac_enable, DRV_CFG_UAPSD_VI)) { + if(TEST_FLAG(pregistrypriv->uapsd_ac_enable, DRV_CFG_UAPSD_VI)) { SET_FLAG(pqospriv->uapsd_tid, WMM_TID5); SET_FLAG(pqospriv->uapsd_tid_delivery_enabled, WMM_TID5); SET_FLAG(pqospriv->uapsd_tid_trigger_enabled, WMM_TID5); @@ -4126,7 +4126,7 @@ void rtw_uapsd_use_default_setting(_adapter *padapter) SET_FLAG(pqospriv->uapsd_tid_trigger_enabled, WMM_TID0); } - RTW_INFO("[WMMPS] UAPSD MAX SP Len = 0x%02x, UAPSD TID enabled = 0x%02x\n", + RTW_INFO("[WMMPS] UAPSD MAX SP Len = 0x%02x, UAPSD TID enabled = 0x%02x\n", pqospriv->uapsd_max_sp_len, (u8)pqospriv->uapsd_tid); } @@ -4136,18 +4136,18 @@ void rtw_uapsd_use_default_setting(_adapter *padapter) * rtw_is_wmmps_mode * This function is used for checking whether Driver and an AP support uapsd function or not. * If both of them support uapsd function, it will return true. Otherwise returns false. - * + * * Arguments: * @padapter: _adapter pointer. * * Auther: Arvin Liu * Date: 2017/06/12 */ -bool rtw_is_wmmps_mode(_adapter *padapter) +bool rtw_is_wmmps_mode(_adapter *padapter) { struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct qos_priv *pqospriv = &pmlmepriv->qospriv; - + if ((pqospriv->uapsd_ap_supported) && ((pqospriv->uapsd_tid & BIT_MASK_TID_TC) != 0)) return _TRUE; @@ -4190,16 +4190,16 @@ int rtw_restruct_wmm_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, u #ifdef CONFIG_WMMPS_STA switch(pqospriv->uapsd_max_sp_len) { - case NO_LIMIT: + case NO_LIMIT: /* do nothing */ break; - case TWO_MSDU: + case TWO_MSDU: SET_FLAG(qos_info, BIT5); break; - case FOUR_MSDU: + case FOUR_MSDU: SET_FLAG(qos_info, BIT6); - break; - case SIX_MSDU: + break; + case SIX_MSDU: SET_FLAG(qos_info, BIT5); SET_FLAG(qos_info, BIT6); break; @@ -4221,7 +4221,7 @@ int rtw_restruct_wmm_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, u if((TEST_FLAG(pqospriv->uapsd_tid, WMM_TID3)) && (TEST_FLAG(pqospriv->uapsd_tid, WMM_TID0))) SET_FLAG(qos_info, WMM_IE_UAPSD_BE); #endif /* CONFIG_WMMPS_STA */ - + out_ie[initial_out_len + 8] = qos_info; break; @@ -4332,7 +4332,7 @@ int rtw_rsn_sync_pmkid(_adapter *adapter, u8 *ie, uint ie_len, int i_ent) + 2 + 16 * info.pmkid_cnt + (info.gmcs ? 4 : 0) ; - + ie[1] = (u8)(ie_len - 2); exit: @@ -4898,7 +4898,7 @@ void rtw_update_ht_cap(_adapter *padapter, u8 *pie, uint ie_len, u8 channel) phtpriv->ampdu_enable = _TRUE; } else phtpriv->ampdu_enable = _TRUE; - } + } /* check Max Rx A-MPDU Size */ diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index bfdc807..9acfbe6 100755 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -1763,17 +1763,17 @@ static void rtw_check_legacy_ap(_adapter *padapter, u8 *pframe, u32 len) if (!padapter->registrypriv.wifi_spec) return; - + if(!MLME_IS_AP(padapter)) return; - + if (pmlmeext->bstart_bss == _TRUE) { int left; unsigned char *pos; struct rtw_ieee802_11_elems elems; #ifdef CONFIG_80211N_HT - u16 cur_op_mode; + u16 cur_op_mode; #endif /* checking IEs */ left = len - sizeof(struct rtw_ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_; @@ -1794,7 +1794,7 @@ static void rtw_check_legacy_ap(_adapter *padapter, u8 *pframe, u32 len) ATOMIC_SET(&pmlmepriv->olbc, _TRUE); ATOMIC_SET(&pmlmepriv->olbc_ht, _TRUE); } - + } } @@ -2720,7 +2720,7 @@ void rtw_roam_nb_discover(_adapter *padapter, u8 bfroce) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta; u8 nb_req_issue = _FALSE; @@ -2734,11 +2734,11 @@ void rtw_roam_nb_discover(_adapter *padapter, u8 bfroce) psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); if (!psta) return; - + if (bfroce || (!pmlmepriv->nb_info.nb_rpt_is_same)) nb_req_issue = _TRUE; - - if (nb_req_issue && (psta->rm_en_cap[0] & RTW_RRM_NB_RPT_EN)) + + if (nb_req_issue && (psta->rm_en_cap[0] & RTW_RRM_NB_RPT_EN)) rm_add_nb_req(padapter, psta); } #endif @@ -2790,7 +2790,7 @@ unsigned int OnAssocRsp(_adapter *padapter, union recv_frame *precv_frame) /* AID */ res = pmlmeinfo->aid = (int)(le16_to_cpu(*(unsigned short *)(pframe + WLAN_HDR_A3_LEN + 4)) & 0x3fff); - + /* check aid value */ if (res < 1 || res > 2007) { RTW_INFO("assoc reject, aid: %d\n", res); @@ -3193,7 +3193,7 @@ unsigned int on_action_wnm(_adapter *adapter, union recv_frame *rframe) u8 *frame = rframe->u.hdr.rx_data; u32 frame_len = rframe->u.hdr.len; u8 *frame_body = (u8 *)(frame + sizeof(struct rtw_ieee80211_hdr_3addr)); - u32 frame_body_len = frame_len - sizeof(struct rtw_ieee80211_hdr_3addr); + u32 frame_body_len = frame_len - sizeof(struct rtw_ieee80211_hdr_3addr); u8 category, action; int cnt = 0; char msg[16]; @@ -3217,7 +3217,7 @@ unsigned int on_action_wnm(_adapter *adapter, union recv_frame *rframe) } ret = _SUCCESS; break; -#endif +#endif default: #ifdef CONFIG_IOCTL_CFG80211 cnt += sprintf((msg + cnt), "ACT_WNM %u", action); @@ -3264,12 +3264,12 @@ u8 rtw_rx_ampdu_size(_adapter *adapter) max_rx_ampdu_factor = (HT_CAP_AMPDU_FACTOR)adapter->driver_rx_ampdu_factor; else rtw_hal_get_def_var(adapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); - + /* In Maximum A-MPDU Length Exponent subfield of A-MPDU Parameters field of HT Capabilities element, the unit of max_rx_ampdu_factor are octets. 8K, 16K, 32K, 64K is right. But the buffer size subfield of Block Ack Parameter Set field in ADDBA action frame indicates - the number of buffers available for this particular TID. Each buffer is equal to max. size of - MSDU or AMSDU. + the number of buffers available for this particular TID. Each buffer is equal to max. size of + MSDU or AMSDU. The size variable means how many MSDUs or AMSDUs, it's not Kbytes. */ if (MAX_AMPDU_FACTOR_64K == max_rx_ampdu_factor) @@ -6636,7 +6636,7 @@ exit: #if defined(CONFIG_RTW_WNM) || defined(CONFIG_RTW_80211K) static u8 rtw_wnm_nb_elem_parsing( - u8* pdata, u32 data_len, u8 from_btm, + u8* pdata, u32 data_len, u8 from_btm, u32 *nb_rpt_num, u8 *nb_rpt_is_same, struct roam_nb_info *pnb, struct wnm_btm_cant *pcandidates) { @@ -6659,7 +6659,7 @@ static u8 rtw_wnm_nb_elem_parsing( subelem_len = (u32)*(pdata+1); for (i=0; i < RTW_MAX_NB_RPT_NUM; i++) { - if (((ptr + 7) > pend) || (elem_len < subelem_len)) + if (((ptr + 7) > pend) || (elem_len < subelem_len)) break; if (*ptr != 0x34) { @@ -6668,10 +6668,10 @@ static u8 rtw_wnm_nb_elem_parsing( break; } - pie = (struct nb_rpt_hdr *)ptr; + pie = (struct nb_rpt_hdr *)ptr; if (from_btm) { - op = rtw_get_ie((u8 *)(ptr+15), - WNM_BTM_CAND_PREF_SUBEID, + op = rtw_get_ie((u8 *)(ptr+15), + WNM_BTM_CAND_PREF_SUBEID, &op_len, (subelem_len - 15)); } @@ -6690,28 +6690,28 @@ static u8 rtw_wnm_nb_elem_parsing( RTW_DBG("WNM: preference check bssid("MAC_FMT ") ,bss_info(0x%04X), reg_class(0x%02X), ch(%d)," " phy_type(0x%02X), preference(0x%02X)\n", - MAC_ARG(pcandidate->nb_rpt.bssid), pcandidate->nb_rpt.bss_info, - pcandidate->nb_rpt.reg_class, pcandidate->nb_rpt.ch_num, + MAC_ARG(pcandidate->nb_rpt.bssid), pcandidate->nb_rpt.bss_info, + pcandidate->nb_rpt.reg_class, pcandidate->nb_rpt.ch_num, pcandidate->nb_rpt.phy_type, pcandidate->preference); } else { if (_rtw_memcmp(&pnb->nb_rpt[i], pie, sizeof(struct nb_rpt_hdr)) == _FALSE) *nb_rpt_is_same = _FALSE; _rtw_memcpy(&pnb->nb_rpt[i], pie, sizeof(struct nb_rpt_hdr)); } - nb_rpt_entries++; - } + nb_rpt_entries++; + } - if (from_btm) - pnb->preference_en = (bfound)?_TRUE:_FALSE; + if (from_btm) + pnb->preference_en = (bfound)?_TRUE:_FALSE; *nb_rpt_num = nb_rpt_entries; return ret; -} +} /* selection sorting based on preference value * IN : nb_rpt_entries - candidate num * IN/OUT : pcandidates - candidate list - * return : TRUE - means pcandidates is updated. + * return : TRUE - means pcandidates is updated. */ static u8 rtw_wnm_candidates_sorting( u32 nb_rpt_entries, struct wnm_btm_cant *pcandidates) @@ -6739,13 +6739,13 @@ static u8 rtw_wnm_candidates_sorting( _rtw_memcpy((pcandidates+i), (pcandidates+pos), sizeof(struct wnm_btm_cant)); _rtw_memcpy((pcandidates+pos), &swap, sizeof(struct wnm_btm_cant)); } - } + } return updated; -} +} static void rtw_wnm_nb_info_update( - u32 nb_rpt_entries, u8 from_btm, - struct roam_nb_info *pnb, struct wnm_btm_cant *pcandidates, + u32 nb_rpt_entries, u8 from_btm, + struct roam_nb_info *pnb, struct wnm_btm_cant *pcandidates, u8 *nb_rpt_is_same) { u8 is_found; @@ -6766,10 +6766,10 @@ static void rtw_wnm_nb_info_update( _rtw_memcpy(&pnb->nb_rpt[i], &pcand->nb_rpt, sizeof(struct nb_rpt_hdr)); } - RTW_DBG("WNM: bssid(" MAC_FMT + RTW_DBG("WNM: bssid(" MAC_FMT ") , bss_info(0x%04X), reg_class(0x%02X), ch_num(%d), phy_type(0x%02X)\n", - MAC_ARG(pnb->nb_rpt[i].bssid), pnb->nb_rpt[i].bss_info, - pnb->nb_rpt[i].reg_class, pnb->nb_rpt[i].ch_num, + MAC_ARG(pnb->nb_rpt[i].bssid), pnb->nb_rpt[i].bss_info, + pnb->nb_rpt[i].reg_class, pnb->nb_rpt[i].ch_num, pnb->nb_rpt[i].phy_type); if (pnb->nb_rpt[i].ch_num == 0) @@ -6781,7 +6781,7 @@ static void rtw_wnm_nb_info_update( break; } } - + if (!is_found) { pnb->nb_rpt_ch_list[pnb->nb_rpt_ch_list_num].hw_value = pnb->nb_rpt[i].ch_num; pnb->nb_rpt_ch_list_num++; @@ -6799,7 +6799,7 @@ static void rtw_wnm_btm_candidate_select(_adapter *padapter) for (i = 0; i < pnb->last_nb_rpt_entries; i++) { pnetwork = rtw_find_network( - &(pmlmepriv->scanned_queue), + &(pmlmepriv->scanned_queue), pnb->nb_rpt[i].bssid); if (pnetwork) { @@ -6816,7 +6816,7 @@ static void rtw_wnm_btm_candidate_select(_adapter *padapter) , MAC_ARG(pnetwork->network.MacAddress) , pnetwork->network.Configuration.DSConfig , (int)pnetwork->network.Rssi); - } else + } else _rtw_memset(pnb->roam_target_addr,0, ETH_ALEN); } @@ -6827,20 +6827,20 @@ u32 rtw_wnm_btm_candidates_survey( struct wnm_btm_cant *pcandidate_list = NULL; u8 nb_rpt_is_same = _TRUE; u32 ret = _FAIL; - u32 nb_rpt_entries = 0; + u32 nb_rpt_entries = 0; if (from_btm) { u32 mlen = sizeof(struct wnm_btm_cant) * RTW_MAX_NB_RPT_NUM; pcandidate_list = (struct wnm_btm_cant *)rtw_malloc(mlen); - if (pcandidate_list == NULL) - goto exit; + if (pcandidate_list == NULL) + goto exit; } /*clean the status set last time*/ _rtw_memset(&pnb->nb_rpt_ch_list, 0, sizeof(pnb->nb_rpt_ch_list)); pnb->nb_rpt_valid = _FALSE; if (!rtw_wnm_nb_elem_parsing( - pframe, elem_len, from_btm, + pframe, elem_len, from_btm, &nb_rpt_entries, &nb_rpt_is_same, pnb, pcandidate_list)) goto exit; @@ -6850,11 +6850,11 @@ u32 rtw_wnm_btm_candidates_survey( rtw_wnm_candidates_sorting(nb_rpt_entries, pcandidate_list); rtw_wnm_nb_info_update( - nb_rpt_entries, from_btm, + nb_rpt_entries, from_btm, pnb, pcandidate_list, &nb_rpt_is_same); } - RTW_INFO("nb_rpt_is_same = %d, nb_rpt_entries = %d, last_nb_rpt_entries = %d\n", + RTW_INFO("nb_rpt_is_same = %d, nb_rpt_entries = %d, last_nb_rpt_entries = %d\n", nb_rpt_is_same, nb_rpt_entries, pnb->last_nb_rpt_entries); if ((nb_rpt_is_same == _TRUE) && (nb_rpt_entries == pnb->last_nb_rpt_entries)) pnb->nb_rpt_is_same = _TRUE; @@ -6865,14 +6865,14 @@ u32 rtw_wnm_btm_candidates_survey( if ((from_btm) && (nb_rpt_entries != 0)) rtw_wnm_btm_candidate_select(padapter); - + pnb->nb_rpt_valid = _TRUE; ret = _SUCCESS; exit: if (from_btm && pcandidate_list) rtw_mfree((u8 *)pcandidate_list, sizeof(struct wnm_btm_cant) * RTW_MAX_NB_RPT_NUM); - + return ret; } #endif @@ -6980,21 +6980,21 @@ u8 rtw_wmn_btm_rsp_reason_decision(_adapter *padapter, u8* req_mode) /* Accept */ reason = 0; goto under_survey; - } + } #endif if (((*req_mode) & DISASSOC_IMMINENT) == 0) { /* Reject - Unspecified reject reason */ reason = 1; goto candidate_remove; - } + } if (precvpriv->signal_strength_data.avg_val >= pmlmepriv->roam_rssi_threshold) { reason = 1; goto candidate_remove; } -under_survey: +under_survey: if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { RTW_INFO("%s reject due to _FW_UNDER_SURVEY\n", __func__); reason = 1; @@ -7021,14 +7021,14 @@ static u32 rtw_wnm_btm_candidates_offset_get(u8* pframe) /* BSS Termination Duration check */ if (wnm_btm_bss_term_inc(pframe)) { offset += 12; - pos += offset; - } + pos += offset; + } /* Session Information URL check*/ if (wnm_btm_ess_disassoc_im(pframe)) { /*URL length field + URL variable length*/ offset = 1 + *(pframe + offset); - pos += offset; + pos += offset; } offset = (pos - pframe); @@ -7048,8 +7048,8 @@ static void rtw_wnm_btm_req_hdr_parsing(u8* pframe, struct btm_req_hdr *phdr) phdr->disassoc_timer = wnm_btm_disassoc_timer(pframe); phdr->validity_interval = wnm_btm_valid_interval(pframe); if (wnm_btm_bss_term_inc(pframe)) { - _rtw_memcpy(&phdr->term_duration, - wnm_btm_term_duration_offset(pframe), + _rtw_memcpy(&phdr->term_duration, + wnm_btm_term_duration_offset(pframe), sizeof(struct btm_term_duration)); } @@ -7065,9 +7065,9 @@ void rtw_wnm_roam_scan_hdl(void *ctx) _adapter *padapter = (_adapter *)ctx; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - if (rtw_is_scan_deny(padapter)) + if (rtw_is_scan_deny(padapter)) RTW_INFO("WNM: roam scan would abort by scan_deny!\n"); - + pmlmepriv->need_to_roam = _TRUE; rtw_drv_scan_by_self(padapter, RTW_AUTO_SCAN_REASON_ROAM); } @@ -7099,10 +7099,10 @@ void rtw_wnm_process_btm_req(_adapter *padapter, u8* pframe, u32 frame_len) elem_len = (frame_len - offset); rtw_wnm_btm_candidates_survey(padapter, ptr, elem_len, _TRUE); reason = rtw_wmn_btm_rsp_reason_decision(padapter, &pframe[3]); - rtw_wnm_issue_action(padapter, + rtw_wnm_issue_action(padapter, RTW_WLAN_ACTION_WNM_BTM_RSP, reason); - if (reason == 0) + if (reason == 0) rtw_wnm_roam_scan(padapter); } @@ -7139,7 +7139,7 @@ void rtw_wnm_issue_action(_adapter *padapter, u8 action, u8 reason) if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) return ; - + pattrib = &(pmgntframe->attrib); update_mgntframe_attrib(padapter, pattrib); _rtw_memset(pmgntframe->buf_addr, 0, (WLANHDR_OFFSET + TXDESC_OFFSET)); @@ -7177,19 +7177,19 @@ void rtw_wnm_issue_action(_adapter *padapter, u8 action, u8 reason) pframe = rtw_set_fixed_ie(pframe, 1, &(reason), &(pattrib->pktlen)); pframe = rtw_set_fixed_ie(pframe, 1, &(termination_delay), &(pattrib->pktlen)); if (!is_zero_mac_addr(pmlmepriv->nb_info.roam_target_addr)) { - pframe = rtw_set_fixed_ie(pframe, 6, + pframe = rtw_set_fixed_ie(pframe, 6, pmlmepriv->nb_info.roam_target_addr, &(pattrib->pktlen)); } - RTW_INFO("WNM: RTW_WLAN_ACTION_WNM_BTM_RSP sent. reason = %d\n", reason); - break; + RTW_INFO("WNM: RTW_WLAN_ACTION_WNM_BTM_RSP sent. reason = %d\n", reason); + break; default: goto exit; - } - + } + pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); -exit: +exit: return; } #endif @@ -8010,7 +8010,7 @@ void issue_beacon(_adapter *padapter, int timeout_ms) pattrib->pktlen += rtw_build_vendor_ie(padapter , &pframe , WIFI_BEACON_VENDOR_IE_BIT); #endif -#ifdef CONFIG_RTL8812A +#ifdef CONFIG_RTL8812A pframe = rtw_hal_set_8812a_vendor_ie(padapter, pframe, &pattrib->pktlen ); #endif/*CONFIG_RTL8812A*/ @@ -8361,7 +8361,7 @@ void issue_probersp(_adapter *padapter, unsigned char *da, u8 is_valid_p2p_probe } #endif /* CONFIG_AUTO_AP_MODE */ -#ifdef CONFIG_RTL8812A +#ifdef CONFIG_RTL8812A pframe = rtw_hal_set_8812a_vendor_ie(padapter, pframe, &pattrib->pktlen); #endif/*CONFIG_RTL8812A*/ @@ -8495,7 +8495,7 @@ int _issue_probereq(_adapter *padapter, const NDIS_802_11_SSID *pssid, const u8 pattrib->pktlen += rtw_build_vendor_ie(padapter , &pframe , WIFI_PROBEREQ_VENDOR_IE_BIT); #endif -#ifdef CONFIG_RTL8812A +#ifdef CONFIG_RTL8812A pframe = rtw_hal_set_8812a_vendor_ie(padapter, pframe, &pattrib->pktlen ); #endif/*CONFIG_RTL8812A*/ @@ -8936,7 +8936,7 @@ void issue_asocrsp(_adapter *padapter, unsigned short status, struct sta_info *p pattrib->pktlen += rtw_build_vendor_ie(padapter , &pframe , WIFI_ASSOCRESP_VENDOR_IE_BIT); #endif -#ifdef CONFIG_RTL8812A +#ifdef CONFIG_RTL8812A pframe = rtw_hal_set_8812a_vendor_ie(padapter, pframe, &pattrib->pktlen ); #endif/*CONFIG_RTL8812A*/ @@ -9414,7 +9414,7 @@ void _issue_assocreq(_adapter *padapter, u8 is_reassoc) /* OWE */ { u32 owe_ie_len; - + owe_ie_len = rtw_append_assoc_req_owe_ie(padapter, pframe); pframe += owe_ie_len; pattrib->pktlen += owe_ie_len; @@ -9427,7 +9427,7 @@ void _issue_assocreq(_adapter *padapter, u8 is_reassoc) pattrib->pktlen += rtw_build_vendor_ie(padapter , &pframe , WIFI_ASSOCREQ_VENDOR_IE_BIT); #endif -#ifdef CONFIG_RTL8812A +#ifdef CONFIG_RTL8812A pframe = rtw_hal_set_8812a_vendor_ie(padapter, pframe, &pattrib->pktlen ); #endif/*CONFIG_RTL8812A*/ @@ -10813,7 +10813,7 @@ unsigned int send_beacon(_adapter *padapter) #endif /* CONFIG_PCI_BCN_POLLING is for pci interface beacon polling mode */ -#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)|| defined(CONFIG_PCI_BCN_POLLING) +#if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)|| defined(CONFIG_PCI_BCN_POLLING) u8 bxmitok = _FALSE; int issue = 0; int poll = 0; @@ -10847,14 +10847,14 @@ unsigned int send_beacon(_adapter *padapter) rtw_hal_set_hwreg(padapter, HW_VAR_BCN_HEAD_SEL, &vap_id); #endif do { - #if defined(CONFIG_PCI_BCN_POLLING) + #if defined(CONFIG_PCI_BCN_POLLING) issue_beacon(padapter, 0); #else issue_beacon(padapter, 100); #endif issue++; do { - #if defined(CONFIG_PCI_BCN_POLLING) + #if defined(CONFIG_PCI_BCN_POLLING) rtw_msleep_os(1); #else rtw_yield_os(); @@ -10862,7 +10862,7 @@ unsigned int send_beacon(_adapter *padapter) rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); poll++; } while ((poll % 10) != 0 && _FALSE == bxmitok && !RTW_CANNOT_RUN(padapter)); - #if defined(CONFIG_PCI_BCN_POLLING) + #if defined(CONFIG_PCI_BCN_POLLING) rtw_hal_unmap_beacon_icf(padapter); #endif } while (bxmitok == _FALSE && (issue < 100) && !RTW_CANNOT_RUN(padapter)); @@ -12584,9 +12584,9 @@ void rtw_delba_check(_adapter *padapter, struct sta_info *psta, u8 from_timer) */ if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_BROADCOM) { for (i = 0; i < TID_NUM ; i++) { - if ((psta->recvreorder_ctrl[i].enable) && - (sta_rx_data_qos_pkts(psta, i) == sta_last_rx_data_qos_pkts(psta, i)) ) { - if (_TRUE == rtw_inc_and_chk_continual_no_rx_packet(psta, i)) { + if ((psta->recvreorder_ctrl[i].enable) && + (sta_rx_data_qos_pkts(psta, i) == sta_last_rx_data_qos_pkts(psta, i)) ) { + if (_TRUE == rtw_inc_and_chk_continual_no_rx_packet(psta, i)) { /* send a DELBA frame to the peer STA with the Reason Code field set to TIMEOUT */ if (!from_timer) ret = issue_del_ba_ex(padapter, psta->cmn.mac_addr, i, 39, 0, 3, 1); @@ -12596,7 +12596,7 @@ void rtw_delba_check(_adapter *padapter, struct sta_info *psta, u8 from_timer) if (ret != _FAIL) psta->recvreorder_ctrl[i].ampdu_size = RX_AMPDU_SIZE_INVALID; rtw_reset_continual_no_rx_packet(psta, i); - } + } } else { /* The inactivity timer is reset when MPDUs to the TID is received. */ rtw_reset_continual_no_rx_packet(psta, i); @@ -12877,7 +12877,7 @@ void linked_status_chk(_adapter *padapter, u8 from_timer) is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE); #endif -#ifdef CONFIG_ISSUE_DELBA_WHEN_NO_TRAFFIC +#ifdef CONFIG_ISSUE_DELBA_WHEN_NO_TRAFFIC /*issue delba when ap does not tx data packet that is Broadcom ap */ rtw_delba_check(padapter, psta, from_timer); #endif @@ -12894,7 +12894,7 @@ void linked_status_chk(_adapter *padapter, u8 from_timer) u8 union_ch = 0, union_bw = 0, union_offset = 0; u8 switch_channel_by_drv = _TRUE; - + #ifdef CONFIG_MCC_MODE if (MCC_EN(padapter)) { /* driver doesn't switch channel under MCC */ @@ -13279,7 +13279,7 @@ void rtw_ft_update_bcn(_adapter *padapter, union recv_frame *precv_frame) uint len = precv_frame->u.hdr.len; WLAN_BSSID_EX *pbss; - if (rtw_ft_chk_status(padapter,RTW_FT_ASSOCIATED_STA) + if (rtw_ft_chk_status(padapter,RTW_FT_ASSOCIATED_STA) && (pmlmepriv->ft_roam.ft_updated_bcn == _FALSE)) { pbss = (WLAN_BSSID_EX*)rtw_malloc(sizeof(WLAN_BSSID_EX)); if (pbss) { @@ -13287,7 +13287,7 @@ void rtw_ft_update_bcn(_adapter *padapter, union recv_frame *precv_frame) struct beacon_keys recv_beacon; update_network(&(pmlmepriv->cur_network.network), pbss, padapter, _TRUE); - + /* update bcn keys */ if (rtw_get_bcn_keys(padapter, pframe, len, &recv_beacon) == _TRUE) { RTW_INFO("%s: beacon keys ready\n", __func__); @@ -13305,7 +13305,7 @@ void rtw_ft_update_bcn(_adapter *padapter, union recv_frame *precv_frame) } /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe+sizeof(struct rtw_ieee80211_hdr_3addr), (len - sizeof(struct rtw_ieee80211_hdr_3addr))); @@ -13343,26 +13343,26 @@ void rtw_ft_start_clnt_join(_adapter *padapter) } u8 rtw_ft_update_rsnie( - _adapter *padapter, u8 bwrite, + _adapter *padapter, u8 bwrite, struct pkt_attrib *pattrib, u8 **pframe) { struct ft_roam_info *pft_roam = &(padapter->mlmepriv.ft_roam); u8 *pie; u32 len; - pie = rtw_get_ie(pft_roam->updated_ft_ies, EID_WPA2, &len, + pie = rtw_get_ie(pft_roam->updated_ft_ies, EID_WPA2, &len, pft_roam->updated_ft_ies_len); if (!bwrite) return (pie)?_SUCCESS:_FAIL; - + if (pie) { - *pframe = rtw_set_ie(((u8 *)*pframe), EID_WPA2, len, + *pframe = rtw_set_ie(((u8 *)*pframe), EID_WPA2, len, pie+2, &(pattrib->pktlen)); } else return _FAIL; - return _SUCCESS; + return _SUCCESS; } static u8 rtw_ft_update_mdie( @@ -13373,10 +13373,10 @@ static u8 rtw_ft_update_mdie( u32 len = 3; if (rtw_ft_roam(padapter)) { - if ((pie = rtw_get_ie(pft_roam->updated_ft_ies, _MDIE_, + if ((pie = rtw_get_ie(pft_roam->updated_ft_ies, _MDIE_, &len, pft_roam->updated_ft_ies_len))) { pie = (pie + 2); /* ignore md-id & length */ - } else + } else return _FAIL; } else { *((u16 *)&mdie[0]) = pft_roam->mdid; @@ -13385,7 +13385,7 @@ static u8 rtw_ft_update_mdie( } *pframe = rtw_set_ie(((u8 *)*pframe), _MDIE_, len , pie, &(pattrib->pktlen)); - return _SUCCESS; + return _SUCCESS; } static u8 rtw_ft_update_ftie( @@ -13395,17 +13395,17 @@ static u8 rtw_ft_update_ftie( u8 *pie; u32 len; - if ((pie = rtw_get_ie(pft_roam->updated_ft_ies, _FTIE_, &len, + if ((pie = rtw_get_ie(pft_roam->updated_ft_ies, _FTIE_, &len, pft_roam->updated_ft_ies_len)) != NULL) { - *pframe = rtw_set_ie(*pframe, _FTIE_, len , + *pframe = rtw_set_ie(*pframe, _FTIE_, len , (pie+2), &(pattrib->pktlen)); } else return _FAIL; - return _SUCCESS; + return _SUCCESS; } -void rtw_ft_build_auth_req_ies(_adapter *padapter, +void rtw_ft_build_auth_req_ies(_adapter *padapter, struct pkt_attrib *pattrib, u8 **pframe) { u8 ftie_append = _TRUE; @@ -13422,7 +13422,7 @@ void rtw_ft_build_auth_req_ies(_adapter *padapter, rtw_ft_update_ftie(padapter, pattrib, pframe); } -void rtw_ft_build_assoc_req_ies(_adapter *padapter, +void rtw_ft_build_assoc_req_ies(_adapter *padapter, u8 is_reassoc, struct pkt_attrib *pattrib, u8 **pframe) { if (!pattrib || !(*pframe)) @@ -13435,7 +13435,7 @@ void rtw_ft_build_assoc_req_ies(_adapter *padapter, return; if (rtw_ft_update_rsnie(padapter, _FALSE, pattrib, pframe)) - rtw_ft_update_ftie(padapter, pattrib, pframe); + rtw_ft_update_ftie(padapter, pattrib, pframe); } u8 rtw_ft_update_auth_rsp_ies(_adapter *padapter, u8 *pframe, u32 len) @@ -13455,8 +13455,8 @@ u8 rtw_ft_update_auth_rsp_ies(_adapter *padapter, u8 *pframe, u32 len) if (!pframe || !len) return _FAIL; - - rtw_buf_update(&pmlmepriv->auth_rsp, + + rtw_buf_update(&pmlmepriv->auth_rsp, &pmlmepriv->auth_rsp_len, pframe, len); pft_roam->ft_event.ies = (pmlmepriv->auth_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6); @@ -13469,7 +13469,7 @@ u8 rtw_ft_update_auth_rsp_ies(_adapter *padapter, u8 *pframe, u32 len) _rtw_memcpy(target_ap_addr, pmlmepriv->assoc_bssid, ETH_ALEN); rtw_ft_report_reassoc_evt(padapter, target_ap_addr); - return ret; + return ret; } static void rtw_ft_start_clnt_action(_adapter *padapter, u8 *pTargetAddr) @@ -13642,7 +13642,7 @@ void rtw_ft_link_timer_hdl(void *ctx) rtw_ft_issue_action_req(padapter, (u8 *)pmlmepriv->roam_network->network.MacAddress); _set_timer(&pmlmeext->ft_link_timer, REASSOC_TO); } else { - pft_roam->ft_req_retry_cnt = 0; + pft_roam->ft_req_retry_cnt = 0; if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) rtw_ft_set_status(padapter, RTW_FT_ASSOCIATED_STA); else @@ -13664,11 +13664,11 @@ void rtw_ft_roam_status_reset(_adapter *padapter) { struct ft_roam_info *pft_roam = &(padapter->mlmepriv.ft_roam); - if ((rtw_to_roam(padapter) > 0) && + if ((rtw_to_roam(padapter) > 0) && (!rtw_ft_chk_status(padapter, RTW_FT_REQUESTED_STA))) { rtw_ft_reset_status(padapter); - } - + } + padapter->mlmepriv.ft_roam.ft_updated_bcn = _FALSE; } #endif @@ -14359,7 +14359,7 @@ u32 rtw_scan_timeout_decision(_adapter *padapter) struct ss_res *ss = &pmlmeext->sitesurvey_res; if (is_supported_5g(padapter->registrypriv.wireless_mode) - && IsSupported24G(padapter->registrypriv.wireless_mode)) + && IsSupported24G(padapter->registrypriv.wireless_mode)) max_chan_num = MAX_CHANNEL_NUM;/* dual band */ else max_chan_num = MAX_CHANNEL_NUM_2G;/*single band*/ @@ -16586,7 +16586,7 @@ u8 tdls_hdl(_adapter *padapter, unsigned char *pbuf) pchsw_info->ch_offset, (pchsw_info->ch_offset) ? CHANNEL_WIDTH_40 : CHANNEL_WIDTH_20, ptdls_sta->ch_switch_time) == _SUCCESS) { pchsw_info->ch_sw_state &= ~(TDLS_PEER_AT_OFF_STATE); if (pchsw_info->ch_sw_state & TDLS_CH_SW_INITIATOR_STATE) { - if (issue_nulldata_to_TDLS_peer_STA(ptdls_sta->padapter, ptdls_sta->cmn.mac_addr, 0, 1, + if (issue_nulldata_to_TDLS_peer_STA(ptdls_sta->padapter, ptdls_sta->cmn.mac_addr, 0, 1, (padapter->registrypriv.wifi_spec == 0) ? 3 : 0) == _FAIL) rtw_tdls_cmd(padapter, ptdls_sta->cmn.mac_addr, TDLS_CH_SW_TO_BASE_CHNL); } diff --git a/core/rtw_pwrctrl.c b/core/rtw_pwrctrl.c index ddb70ee..16e2184 100644 --- a/core/rtw_pwrctrl.c +++ b/core/rtw_pwrctrl.c @@ -94,7 +94,7 @@ void _ips_enter(_adapter *padapter) if (pwrpriv->ips_mode == IPS_LEVEL_2) pwrpriv->bkeepfwalive = _TRUE; -#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS pwrpriv->pwr_saving_start_time = rtw_get_current_time(); #endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ @@ -133,8 +133,8 @@ int _ips_leave(_adapter *padapter) result = rtw_ips_pwr_up(padapter); if (result == _SUCCESS) pwrpriv->rf_pwrstate = rf_on; - -#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS + +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS pwrpriv->pwr_saving_time += rtw_get_passing_time_ms(pwrpriv->pwr_saving_start_time); #endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ @@ -751,7 +751,7 @@ void rtw_set_fw_config_32k(PADAPTER padapter, u8 enable) int cnt = 0; systime start_time; if (enable){ - + /* H2C done, enter 32k */ if (val8 == 0) { /* ser rpwm to enter 32k */ @@ -888,7 +888,7 @@ void rtw_leave_lps_and_chk(_adapter *padapter, u8 ps_mode) #ifdef CONFIG_LPS_ACK _exit_critical_mutex(&pwrpriv->lps_ack_mutex, NULL); #endif /* CONFIG_LPS_ACK */ - + } void rtw_set_ps_mode(PADAPTER padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode, const char *msg) @@ -899,7 +899,7 @@ void rtw_set_ps_mode(PADAPTER padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode struct dvobj_priv *psdpriv = padapter->dvobj; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; #endif -#ifdef CONFIG_WMMPS_STA +#ifdef CONFIG_WMMPS_STA struct registry_priv *pregistrypriv = &padapter->registrypriv; #endif #ifdef CONFIG_P2P @@ -927,7 +927,7 @@ void rtw_set_ps_mode(PADAPTER padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode return; #ifndef CONFIG_BT_COEXIST -#ifdef CONFIG_WMMPS_STA +#ifdef CONFIG_WMMPS_STA if (!rtw_is_wmmps_mode(padapter)) #endif /* CONFIG_WMMPS_STA */ if ((pwrpriv->smart_ps == smart_ps) && @@ -1111,11 +1111,11 @@ void rtw_set_ps_mode(PADAPTER padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode } #endif -#ifdef CONFIG_WMMPS_STA +#ifdef CONFIG_WMMPS_STA pwrpriv->wmm_smart_ps = pregistrypriv->wmm_smart_ps; #endif /* CONFIG_WMMPS_STA */ - - + + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); #ifdef CONFIG_WOWLAN @@ -1224,10 +1224,10 @@ void LPS_Enter(PADAPTER padapter, const char *msg) if (rtw_is_wmmps_mode(padapter)) msg = "WMMPS_IDLE"; #endif /* CONFIG_WMMPS_STA */ - + sprintf(buf, "WIFI-%s", msg); pwrpriv->bpower_saving = _TRUE; - + #ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS pwrpriv->pwr_saving_start_time = rtw_get_current_time(); #endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ @@ -1272,11 +1272,11 @@ void LPS_Leave(PADAPTER padapter, const char *msg) if (rtw_is_wmmps_mode(padapter)) msg = "WMMPS_BUSY"; #endif /* CONFIG_WMMPS_STA */ - + sprintf(buf, "WIFI-%s", msg); rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, buf); -#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS +#ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS pwrpriv->pwr_saving_time += rtw_get_passing_time_ms(pwrpriv->pwr_saving_start_time); #endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */ } diff --git a/core/rtw_recv.c b/core/rtw_recv.c index ee8b706..f3159e7 100755 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -2922,7 +2922,7 @@ static int rtw_recv_indicatepkt_check(union recv_frame *rframe, u8 *ehdr_pos, u3 RTW_INFO("0x%x ",ehdr_pos[i+ETHERNET_HEADER_SIZE]); RTW_INFO("\n"); } - + } } } @@ -4871,7 +4871,7 @@ void rx_query_phy_status( precvframe->u.hdr.psta = psta; rx_process_phy_info(padapter, precvframe); } - } else + } else #endif { if (psta) diff --git a/core/rtw_rf.c b/core/rtw_rf.c index f5cc458..1ab3c30 100644 --- a/core/rtw_rf.c +++ b/core/rtw_rf.c @@ -1225,7 +1225,7 @@ s8 rtw_rf_get_kfree_tx_gain_offset(_adapter *padapter, u8 path, u8 ch) kfree_offset = kfree_data->bb_gain[bb_gain_sel][path]; if (IS_HARDWARE_TYPE_8723D(padapter)) RTW_INFO("%s path:%s, ch:%u, bb_gain_sel:%d, kfree_offset:%d\n" - , __func__, (path == 0)?"S1":"S0", + , __func__, (path == 0)?"S1":"S0", ch, bb_gain_sel, kfree_offset); else RTW_INFO("%s path:%u, ch:%u, bb_gain_sel:%d, kfree_offset:%d\n" @@ -1256,7 +1256,7 @@ void rtw_rf_set_tx_gain_offset(_adapter *adapter, u8 path, s8 offset) target_path = path; RTW_INFO("kfree gain_offset 0x55:0x%x ", rtw_hal_read_rfreg(adapter, target_path, 0x55, 0xffffffff)); } - + switch (rtw_get_chip_type(adapter)) { #ifdef CONFIG_RTL8723D case RTL8723D: @@ -1311,7 +1311,7 @@ void rtw_rf_set_tx_gain_offset(_adapter *adapter, u8 path, s8 offset) rtw_warn_on(1); break; } - + if (IS_HARDWARE_TYPE_8723D(adapter)) { if (path == PPG_8723D_S1) val32 = rtw_hal_read_rfreg(adapter, target_path, 0x55, 0xffffffff); diff --git a/core/rtw_rm.c b/core/rtw_rm.c index 6576597..cd6d78f 100644 --- a/core/rtw_rm.c +++ b/core/rtw_rm.c @@ -1879,7 +1879,7 @@ int retrieve_radio_meas_result(struct rm_obj *prm) /* IPI 0~10 */ for (i=0;i<11;i++) prm->p.ipi[i] = hal_data->acs.nhm[ch][i]; - + #else val8 = 0; prm->p.anpi = val8; @@ -2285,7 +2285,7 @@ static void rm_dbg_add_meas(_adapter *padapter, char *s) if (prm->q.action_code == RM_ACT_RADIO_MEAS_REQ) sprintf(pstr(s), "\nAdd rmid=%x, meas_type=%s ok\n", prm->rmid, rm_type_req_name(prm->q.m_type)); - else if (prm->q.action_code == RM_ACT_NB_REP_REQ) + else if (prm->q.action_code == RM_ACT_NB_REP_REQ) sprintf(pstr(s), "\nAdd rmid=%x, meas_type=bcn_req ok\n", prm->rmid); diff --git a/core/rtw_tdls.c b/core/rtw_tdls.c index 4cb3892..e4b20d3 100644 --- a/core/rtw_tdls.c +++ b/core/rtw_tdls.c @@ -940,7 +940,7 @@ void rtw_tdls_set_ch_sw_oper_control(_adapter *padapter, u8 enable) } else pHalData->ch_switch_offload = _FALSE; - + if (ATOMIC_READ(&padapter->tdlsinfo.chsw_info.chsw_on) != enable) ATOMIC_SET(&padapter->tdlsinfo.chsw_info.chsw_on, enable); @@ -1869,7 +1869,7 @@ sint On_TDLS_Setup_Req(_adapter *padapter, union recv_frame *precv_frame, struct ptdls_sta = rtw_alloc_stainfo(pstapriv, psa); if (ptdls_sta == NULL) goto exit; - + ptdlsinfo->sta_cnt++; } else { diff --git a/core/rtw_wlan_util.c b/core/rtw_wlan_util.c index 9512249..1503937 100644 --- a/core/rtw_wlan_util.c +++ b/core/rtw_wlan_util.c @@ -1543,7 +1543,7 @@ void WMMOnAssocRsp(_adapter *padapter) #ifdef CONFIG_WMMPS_STA struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct qos_priv *pqospriv = &pmlmepriv->qospriv; -#endif /* CONFIG_WMMPS_STA */ +#endif /* CONFIG_WMMPS_STA */ acm_mask = 0; @@ -1669,7 +1669,7 @@ void WMMOnAssocRsp(_adapter *padapter) pxmitpriv->wmm_para_seq[i] = inx[i]; RTW_INFO("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]); } - + #ifdef CONFIG_WMMPS_STA /* if AP supports UAPSD function, driver must set each uapsd TID to coresponding mac register 0x693 */ if (pmlmeinfo->WMM_param.QoS_info & AP_SUPPORTED_UAPSD) { @@ -2317,11 +2317,11 @@ inline bool match_ranges(u16 EID, u32 value) /* * rtw_validate_value: validate the IE contain. * - * Input : + * Input : * EID : Element ID * p : IE buffer (without EID & length) * len : IE length - * return: + * return: * _TRUE : All Values are validated. * _FALSE : At least one value is NOT validated. */ @@ -2348,7 +2348,7 @@ bool rtw_validate_value(u16 EID, u8 *p, u16 len) inline bool hidden_ssid_ap(WLAN_BSSID_EX *snetwork) { - return ((snetwork->Ssid.SsidLength == 0) || + return ((snetwork->Ssid.SsidLength == 0) || is_all_null(snetwork->Ssid.Ssid, snetwork->Ssid.SsidLength) == _TRUE); } @@ -2386,7 +2386,7 @@ void rtw_absorb_ssid_ifneed(_adapter *padapter, WLAN_BSSID_EX *bssid, u8 *pframe ie_offset = _FIXED_IE_LENGTH_; } } - + _enter_critical_bh(&padapter->mlmepriv.scanned_queue.lock, &irqL); scanned = _rtw_find_network(&padapter->mlmepriv.scanned_queue, mac); if (!scanned) { @@ -3167,7 +3167,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) void get_assoc_AP_Vendor(char *vendor, u8 assoc_AP_vendor) { switch (assoc_AP_vendor) { - + case HT_IOT_PEER_UNKNOWN: sprintf(vendor, "%s", "unknown"); break; @@ -3229,7 +3229,7 @@ void rtw_parse_sta_vendor_ie_8812(_adapter *adapter, struct sta_info *sta, u8 *t RTW_INFO("\n"); if(*(p+6) != 2) goto exit; - + if(*(p+8) == RT_HT_CAP_USE_JAGUAR_BCUT) sta->vendor_8812 = TRUE; else if (*(p+8) == RT_HT_CAP_USE_JAGUAR_CCUT) @@ -3456,7 +3456,7 @@ int rtw_ies_get_supported_rate(u8 *ies, uint ies_len, u8 *rate_set, u8 *rate_num {IEEE80211_OFDM_RATE_48MB, _FALSE, _FALSE}, {IEEE80211_OFDM_RATE_54MB, _FALSE, _FALSE}, }; - + if (!rate_set || !rate_num) return _FALSE; diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index 4bbba82..588ee2d 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -881,9 +881,9 @@ static void update_attrib_vcs_info(_adapter *padapter, struct xmit_frame *pxmitf #ifdef CONFIG_WMMPS_STA /* * update_attrib_trigger_frame_info - * For Station mode, if a specific TID of driver setting and an AP support uapsd function, the data + * For Station mode, if a specific TID of driver setting and an AP support uapsd function, the data * frame with corresponding TID will be a trigger frame when driver is in wmm power saving mode. - * + * * Arguments: * @padapter: _adapter pointer. * @pattrib: pkt_attrib pointer. @@ -893,7 +893,7 @@ static void update_attrib_vcs_info(_adapter *padapter, struct xmit_frame *pxmitf */ static void update_attrib_trigger_frame_info(_adapter *padapter, struct pkt_attrib *pattrib) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); + struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); struct qos_priv *pqospriv = &pmlmepriv->qospriv; u8 trigger_frame_en = 0; @@ -1575,7 +1575,7 @@ get_sta_info: #ifdef CONFIG_WMMPS_STA update_attrib_trigger_frame_info(padapter, pattrib); -#endif /* CONFIG_WMMPS_STA */ +#endif /* CONFIG_WMMPS_STA */ /* pattrib->priority = 5; */ /* force to used VI queue, for testing */ pattrib->hw_ssn_sel = pxmitpriv->hw_ssn_seq_no; @@ -1878,7 +1878,7 @@ s32 rtw_make_wlanhdr(_adapter *padapter , u8 *hdr, struct pkt_attrib *pattrib) /* TBD: temporary set (rspi, eosp) = (0, 1) which means End MPSP */ set_rspi(qc, 0); SetEOSP(qc, 1); - + set_mctrl_present(qc, 1); } #endif diff --git a/hal/efuse/efuse_mask.h b/hal/efuse/efuse_mask.h index f6059e4..347a448 100644 --- a/hal/efuse/efuse_mask.h +++ b/hal/efuse/efuse_mask.h @@ -62,11 +62,11 @@ #if defined(CONFIG_RTL8821C) #include "rtl8821c/HalEfuseMask8821C_USB.h" #endif - + #if defined(CONFIG_RTL8710B) #include "rtl8710b/HalEfuseMask8710B_USB.h" #endif - + #if defined(CONFIG_RTL8192F) #include "rtl8192f/HalEfuseMask8192F_USB.h" #endif diff --git a/hal/hal_btcoex.c b/hal/hal_btcoex.c index 39bb165..6a861bb 100644 --- a/hal/hal_btcoex.c +++ b/hal/hal_btcoex.c @@ -643,7 +643,7 @@ struct btc_wifi_link_info halbtcoutsrc_getwifilinkinfo(PBTC_COEXIST pBtCoexist) iface = dvobj->padapters[i]; if (!iface) continue; - + mlmeext = &iface->mlmeextpriv; if (MLME_IS_GO(iface)) { wifi_link_info.link_mode = BTC_LINK_ONLY_GO; @@ -681,7 +681,7 @@ struct btc_wifi_link_info halbtcoutsrc_getwifilinkinfo(PBTC_COEXIST pBtCoexist) wifi_link_info.link_mode = BTC_LINK_NONE; } else if (n_assoc_iface == 1) { /* by pass */ - } else if (n_assoc_iface == 2) { + } else if (n_assoc_iface == 2) { if (sta_iface && p2p_iface) { u8 band_sta = sta_iface->mlmeextpriv.cur_channel > 14 ? BAND_ON_5G : BAND_ON_2_4G; u8 band_p2p = p2p_iface->mlmeextpriv.cur_channel > 14 ? BAND_ON_5G : BAND_ON_2_4G; @@ -1242,7 +1242,7 @@ u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf) #ifdef CONFIG_P2P { struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - + *pU1Tmp = pwdinfo->operating_channel; } #else @@ -1321,7 +1321,7 @@ u16 halbtcoutsrc_LnaConstrainLvl(void *pBtcContext, u8 *lna_constrain_level) ret = _btmpoper_cmd(pBtCoexist, BT_OP_SET_BT_LANCONSTRAIN_LEVEL, 0, lna_constrain_level, 1); _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL); - } else { + } else { ret = BT_STATUS_NOT_IMPLEMENT; RTW_INFO("%s halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == FALSE\n", __func__); } @@ -1886,7 +1886,7 @@ void halbtcoutsrc_DisplayWifiStatus(PBTC_COEXIST pBtCoexist) pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Link/ Roam/ Scan", bLink, bRoam, bScan); - CL_PRINTF(cliBuf); + CL_PRINTF(cliBuf); pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_IQK_TOTAL, &iqk_cnt_total); pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_IQK_OK, &iqk_cnt_ok); @@ -1895,7 +1895,7 @@ void halbtcoutsrc_DisplayWifiStatus(PBTC_COEXIST pBtCoexist) "IQK All/ OK/ Fail/AutoLoad/FWDL", iqk_cnt_total, iqk_cnt_ok, iqk_cnt_fail, ((halbtcoutsrc_is_autoload_fail(pBtCoexist) == _TRUE) ? "fail":"ok"), ((halbtcoutsrc_is_fw_ready(pBtCoexist) == _TRUE) ? "ok":"fail")); CL_PRINTF(cliBuf); - + if (wifiLinkStatus & WIFI_STA_CONNECTED) { CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "IOT Peer", GLBtcIotPeerString[padapter->mlmeextpriv.mlmext_info.assoc_AP_vendor]); CL_PRINTF(cliBuf); @@ -2198,7 +2198,7 @@ halbtcoutsrc_SetBtTRXMASK( bStatus = NDBG_SetBtTRXMASK(Adapter, 2, bt_trx_mask, &btCanTx); } - + if (bStatus) return TRUE; else @@ -2244,7 +2244,7 @@ u16 halbtcoutsrc_GetBtReg_with_status(void *pBtcContext, u8 RegType, u32 RegAddr u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr) { u32 regVal; - + return (BT_STATUS_BT_OP_SUCCESS == halbtcoutsrc_GetBtReg_with_status(pBtcContext, RegType, RegAddr, ®Val)) ? regVal : 0xffffffff; } @@ -2441,7 +2441,7 @@ u32 halbtcoutsrc_GetBleScanParaFromBt(void *pBtcContext, u8 scanType) _irqL irqL; u8 op_code; u8 status; - + buf[0] = scanType; _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL); @@ -3422,7 +3422,7 @@ void EXhalbtcoutsrc_connect_notify(PBTC_COEXIST pBtCoexist, u8 assoType) pBtCoexist->statistics.cnt_connect_notify++; if (pBtCoexist->manual_control) return; - + /* All notify is called in cmd thread, don't need to leave low power again * halbtcoutsrc_LeaveLowPower(pBtCoexist); */ if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) { @@ -3684,7 +3684,7 @@ void EXhalbtcoutsrc_specific_packet_notify(PBTC_COEXIST pBtCoexist, u8 pktType) /* compatible for 8812A */ if (hal->current_band_type == BAND_ON_5G) packetType &= ~BTC_5G_BAND; - + if (pBtCoexist->board_info.btdm_ant_num == 2) ex_halbtc8812a2ant_specific_packet_notify(pBtCoexist, packetType); else if (pBtCoexist->board_info.btdm_ant_num == 1) @@ -4565,7 +4565,7 @@ void EXhalbtcoutsrc_switchband_notify(struct btc_coexist *pBtCoexist, u8 type) { if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) return; - + if(pBtCoexist->manual_control) return; @@ -4735,7 +4735,7 @@ u8 EXhalbtcoutsrc_rate_id_to_btc_rate_id(u8 rate_id) case DESC_RATEMCS31: btc_rate_id = BTC_MCS_31; break; - + case DESC_RATEVHTSS1MCS0: btc_rate_id = BTC_VHT_1SS_MCS_0; break; @@ -4860,7 +4860,7 @@ u8 EXhalbtcoutsrc_rate_id_to_btc_rate_id(u8 rate_id) btc_rate_id = BTC_VHT_4SS_MCS_9; break; } - + return btc_rate_id; } @@ -5052,7 +5052,7 @@ void hal_btcoex_ConnectNotify(PADAPTER padapter, u8 action) else assoType = BTC_ASSOCIATE_FINISH; } - + EXhalbtcoutsrc_connect_notify(&GLBtCoexist, assoType); } @@ -5208,7 +5208,7 @@ u8 hal_btcoex_IsBtControlLps(PADAPTER padapter) { if (GLBtCoexist.bdontenterLPS == _TRUE) return _TRUE; - + if (hal_btcoex_IsBtExist(padapter) == _FALSE) return _FALSE; @@ -5225,7 +5225,7 @@ u8 hal_btcoex_IsLpsOn(PADAPTER padapter) { if (GLBtCoexist.bdontenterLPS == _TRUE) return _FALSE; - + if (hal_btcoex_IsBtExist(padapter) == _FALSE) return _FALSE; diff --git a/hal/hal_com.c b/hal/hal_com.c index de6744f..bc664df 100644 --- a/hal/hal_com.c +++ b/hal/hal_com.c @@ -1340,7 +1340,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); @@ -1660,7 +1660,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; } @@ -1904,9 +1904,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; } @@ -2030,7 +2030,7 @@ int c2h_lps_status_rpt(PADAPTER adapter, u8 *data, u8 len) if (DBG_LPS_STATUS_RPT) RTW_INFO("=== [C2H LPS Action(%d)] LPS Status Code:%d ===\n", action, status_code); - + break; default: RTW_INFO("UnKnown Action(%d) for C2H LPS RPT\n", action); @@ -3152,7 +3152,7 @@ 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 + /* Enable HW seq for BCN * 0x4FC[0]: EN_HWSEQ / 0x4FC[1]: EN_HWSEQEXT */ #ifdef CONFIG_RTL8822B if (IS_HARDWARE_TYPE_8822B(adapter)) @@ -3714,7 +3714,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; @@ -4617,7 +4617,7 @@ void rtw_hal_set_FwAoacRsvdPage_cmd(PADAPTER padapter, PRSVDPAGE_LOC rsvdpageloc } #ifdef CONFIG_PNO_SUPPORT else { -#ifndef RTW_HALMAC +#ifndef RTW_HALMAC if (!pwrpriv->wowlan_in_resume) { RTW_INFO("NLO_INFO=%d\n", rsvdpageloc->LocPNOInfo); _rtw_memset(&u1H2CAoacRsvdPageParm, 0, @@ -5404,11 +5404,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 && !check_fwstate(pmlmepriv, _FW_LINKED)) no_wake = 1; - + if (!ppwrpriv->wowlan_pno_enable && registry_par->wakeup_event & BIT(0) && !no_wake) magic_pkt = enable; @@ -5535,31 +5535,31 @@ 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_)) { @@ -5569,12 +5569,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( @@ -5583,7 +5583,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); } @@ -5595,7 +5595,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"); @@ -5701,7 +5701,7 @@ 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 && !check_fwstate(pmlmepriv, _FW_LINKED)) no_wake = 1; @@ -9744,7 +9744,7 @@ static void rtw_hal_wow_enable(_adapter *adapter) if(pwrctl->wowlan_pno_enable) rtw_halmac_pno_scanoffload(adapter->dvobj, 1); #endif - + #ifdef CONFIG_GTK_OL_DBG dump_sec_cam(RTW_DBGDUMP, adapter); dump_sec_cam_cache(RTW_DBGDUMP, adapter); @@ -9829,7 +9829,7 @@ static void rtw_hal_wow_disable(_adapter *adapter) u8 val8; RTW_PRINT("%s, WOWLAN_DISABLE\n", __func__); - + if(registry_par->suspend_type == FW_IPS_DISABLE_BBRF && !check_fwstate(pmlmepriv, _FW_LINKED) && !pwrctl->wowlan_pno_enable) { @@ -9841,7 +9841,7 @@ static void rtw_hal_wow_disable(_adapter *adapter) if(pwrctl->wowlan_pno_enable) rtw_halmac_pno_scanoffload(adapter->dvobj, 0); #endif - + if (!pwrctl->wowlan_pno_enable) { psta = rtw_get_stainfo(&adapter->stapriv, get_bssid(pmlmepriv)); if (psta != NULL) @@ -10589,7 +10589,7 @@ static void _rtw_hal_set_fw_rsvd_page(_adapter *adapter, bool finished, u8 *page /*======== Qos null data * 1 page ======== */ if (pwrctl->wowlan_mode == _FALSE || - pwrctl->wowlan_in_resume == _TRUE) {/*Normal mode*/ + pwrctl->wowlan_in_resume == _TRUE) {/*Normal mode*/ if (MLME_IS_STA(sta_iface) || (nr_assoc_if == 0)) { RsvdPageLoc.LocQosNull = TotalPageNum; RTW_INFO("LocQosNull: %d\n", RsvdPageLoc.LocQosNull); @@ -11577,7 +11577,7 @@ void rtw_hal_update_uapsd_tid(_adapter *adapter) struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct qos_priv *pqospriv = &pmlmepriv->qospriv; - /* write complement of pqospriv->uapsd_tid to mac register 0x693 because + /* write complement of pqospriv->uapsd_tid to mac register 0x693 because it's designed for "0" represents "enable" and "1" represents "disable" */ rtw_write8(adapter, REG_WMMPS_UAPSD_TID, (u8)(~pqospriv->uapsd_tid)); } @@ -11945,7 +11945,7 @@ u8 SetHwReg(_adapter *adapter, u8 variable, u8 *val) break; #endif/*CONFIG_RTS_FULL_BW*/ #if defined(CONFIG_PCI_HCI) - case HW_VAR_ENSWBCN: + case HW_VAR_ENSWBCN: if (*val == _TRUE) { rtw_write8(adapter, REG_CR + 1, rtw_read8(adapter, REG_CR + 1) | BIT(0)); @@ -11980,7 +11980,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; @@ -12911,7 +12911,7 @@ u32 Hal_readPGDataFromConfigFile(PADAPTER padapter) if (maplen < 256 || maplen > EEPROM_MAX_SIZE) { RTW_ERR("eFuse length error :%d\n", maplen); return _FALSE; - } + } ret = rtw_read_efuse_from_file(EFUSE_MAP_PATH, hal_data->efuse_eeprom_data, maplen); @@ -13890,7 +13890,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]) */ @@ -13909,18 +13909,18 @@ void rtw_set_rts_bw(_adapter *padapter) { station = NULL; station = macid_ctl->sta[i]; 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) { connect_to_8812 = _TRUE; enable = 0; - } - } + } + } } } } @@ -13928,7 +13928,7 @@ void rtw_set_rts_bw(_adapter *padapter) { 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); } @@ -14411,8 +14411,8 @@ void hw_var_set_opmode_mbid(_adapter *Adapter, u8 mode) rtw_hw_client_port_release(Adapter); #endif #if defined(CONFIG_RTL8192F) - rtw_write16(Adapter, REG_WLAN_ACT_MASK_CTRL_1, rtw_read16(Adapter, - REG_WLAN_ACT_MASK_CTRL_1) | EN_PORT_0_FUNCTION); + rtw_write16(Adapter, REG_WLAN_ACT_MASK_CTRL_1, rtw_read16(Adapter, + REG_WLAN_ACT_MASK_CTRL_1) | EN_PORT_0_FUNCTION); #endif } #endif @@ -14525,7 +14525,7 @@ void rtw_dump_phy_cap_by_hal(void *sel, _adapter *adapter) phy_cap = _FALSE; rtw_hal_get_def_var(adapter, HAL_DEF_RX_LDPC, (u8 *)&phy_cap); RTW_PRINT_SEL(sel, "[HAL] LDPC Rx : %s\n\n", (_TRUE == phy_cap) ? "Supported" : "N/A"); - + #ifdef CONFIG_BEAMFORMING phy_cap = _FALSE; rtw_hal_get_def_var(adapter, HAL_DEF_EXPLICIT_BEAMFORMER, (u8 *)&phy_cap); @@ -14747,7 +14747,7 @@ u8 * rtw_hal_set_8812a_vendor_ie(_adapter *padapter , u8 *pframe ,uint *frlen ) else vendor_info[6] = RT_HT_CAP_USE_JAGUAR_BCUT; pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_,vender_len,vendor_info , frlen); - + return pframe; } #endif /*CONFIG_RTL8812A*/ diff --git a/hal/hal_com_c2h.h b/hal/hal_com_c2h.h index 75c8bb8..bacec38 100644 --- a/hal/hal_com_c2h.h +++ b/hal/hal_com_c2h.h @@ -18,7 +18,7 @@ #define C2H_TYPE_REG 0 #define C2H_TYPE_PKT 1 -/* +/* * C2H event format: * Fields TRIGGER PAYLOAD SEQ PLEN ID * BITS [127:120] [119:16] [15:8] [7:4] [3:0] @@ -32,7 +32,7 @@ #define SET_C2H_PLEN(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)), 4, 4, _val) #define SET_C2H_SEQ(_c2h, _val) SET_BITS_TO_LE_1BYTE(((u8*)(_c2h)) + 1 , 0, 8, _val) -/* +/* * C2H event format: * Fields TRIGGER PLEN PAYLOAD SEQ ID * BITS [127:120] [119:112] [111:16] [15:8] [7:0] diff --git a/hal/hal_dm.c b/hal/hal_dm.c index dbb42d7..44d6182 100644 --- a/hal/hal_dm.c +++ b/hal/hal_dm.c @@ -463,20 +463,20 @@ struct turbo_edca_setting{ static struct turbo_edca_setting rtw_turbo_edca[TURBO_EDCA_MODE_NUM] = { TURBO_EDCA_ENT(0xa42b, 0xa42b), /* mode 0 */ TURBO_EDCA_ENT(0x431c, 0x431c), /* mode 1 */ - TURBO_EDCA_ENT(0x4319, 0x4319), /* mode 2 */ - + TURBO_EDCA_ENT(0x4319, 0x4319), /* mode 2 */ + TURBO_EDCA_ENT(0x5ea42b, 0x5ea42b), /* mode 3 */ TURBO_EDCA_ENT(0x5e431c, 0x5e431c), /* mode 4 */ - TURBO_EDCA_ENT(0x5e4319, 0x5e4319), /* mode 5 */ - + TURBO_EDCA_ENT(0x5e4319, 0x5e4319), /* mode 5 */ + TURBO_EDCA_ENT(0x6ea42b, 0x6ea42b), /* mode 6 */ TURBO_EDCA_ENT(0x6e431c, 0x6e431c), /* mode 7 */ TURBO_EDCA_ENT(0x6e4319, 0x6e4319), /* mode 8 */ - + TURBO_EDCA_ENT(0x5ea42b, 0xa42b), /* mode 9 */ TURBO_EDCA_ENT(0x5e431c, 0x431c), /* mode 10 */ TURBO_EDCA_ENT(0x5e4319, 0x4319), /* mode 11 */ - + TURBO_EDCA_ENT(0x6ea42b, 0xa42b), /* mode 12 */ TURBO_EDCA_ENT(0x6e431c, 0x431c), /* mode 13 */ TURBO_EDCA_ENT(0x6e4319, 0x4319), /* mode 14 */ @@ -493,18 +493,18 @@ static struct turbo_edca_setting rtw_turbo_edca[TURBO_EDCA_MODE_NUM] = { /* { UL, DL } */ TURBO_EDCA_ENT(0x5e431c, 0x431c), /* mode 0 */ - TURBO_EDCA_ENT(0x431c, 0x431c), /* mode 1 */ - + TURBO_EDCA_ENT(0x431c, 0x431c), /* mode 1 */ + TURBO_EDCA_ENT(0x5e431c, 0x5e431c), /* mode 2 */ TURBO_EDCA_ENT(0x5ea42b, 0x5ea42b), /* mode 3 */ - + TURBO_EDCA_ENT(0x5ea42b, 0x431c), /* mode 4 */ - + TURBO_EDCA_ENT(0x6ea42b, 0x6ea42b), /* mode 5 */ TURBO_EDCA_ENT(0xa42b, 0xa42b), /* mode 6 */ - + TURBO_EDCA_ENT(0x5e431c, 0xa42b), /* mode 7 */ }; #endif @@ -640,15 +640,15 @@ void rtw_hal_turbo_edca(_adapter *adapter) EDCA_BE_DL = 0x00431c; #ifdef CONFIG_RTW_TPT_MODE - if ( dvobj->tpt_mode > 0 ) { + if ( dvobj->tpt_mode > 0 ) { EDCA_BE_UL = dvobj->edca_be_ul; EDCA_BE_DL = dvobj->edca_be_dl; } #endif /* CONFIG_RTW_TPT_MODE */ /* keep this condition at last check */ - if (hal_data->dis_turboedca == 2) { - + if (hal_data->dis_turboedca == 2) { + if (hal_data->edca_param_mode < TURBO_EDCA_MODE_NUM) { struct turbo_edca_setting param; @@ -657,12 +657,12 @@ void rtw_hal_turbo_edca(_adapter *adapter) EDCA_BE_UL = param.edca_ul; EDCA_BE_DL = param.edca_dl; - + } else { - + EDCA_BE_UL = hal_data->edca_param_mode; EDCA_BE_DL = hal_data->edca_param_mode; - } + } } if (traffic_index == DOWN_LINK) @@ -680,7 +680,7 @@ void rtw_hal_turbo_edca(_adapter *adapter) struct sta_info *psta; struct macid_ctl_t *macid_ctl = dvobj_to_macidctl(dvobj); u8 mac_id, role, current_rate_id; - + /* search all used & connect2AP macid */ for (mac_id = 0; mac_id < macid_ctl->num; mac_id++) { if (rtw_macid_is_used(macid_ctl, mac_id)) { @@ -725,7 +725,7 @@ void rtw_hal_turbo_edca(_adapter *adapter) #endif if ( edca_param != hal_data->ac_param_be) { - + rtw_hal_set_hwreg(adapter, HW_VAR_AC_PARAM_BE, (u8 *)(&edca_param)); RTW_INFO("Turbo EDCA =0x%x\n", edca_param); @@ -1191,7 +1191,7 @@ void dump_sta_traffic(void *sel, _adapter *adapter, struct sta_info *psta) else _RTW_PRINT_SEL(sel, "Tx : %d(Kbps) ", psta->sta_stats.tx_tp_kbits); - if (rx_tp_mbips) + if (rx_tp_mbips) _RTW_PRINT_SEL(sel, "Rx : %d(Mbps) ", rx_tp_mbips); else _RTW_PRINT_SEL(sel, "Rx : %d(Kbps) ", psta->sta_stats.rx_tp_kbits); @@ -1211,7 +1211,7 @@ void dump_sta_traffic(void *sel, _adapter *adapter, struct sta_info *psta) else _RTW_PRINT_SEL(sel, "Tx : %d(Kbps) ", psta->sta_stats.smooth_tx_tp_kbits); - if (rx_tp_mbips) + if (rx_tp_mbips) _RTW_PRINT_SEL(sel, "Rx : %d(Mbps) ", rx_tp_mbips); else _RTW_PRINT_SEL(sel, "Rx : %d(Kbps) ", psta->sta_stats.smooth_rx_tp_kbits); @@ -1359,7 +1359,7 @@ static u8 _rtw_phydm_rfk_condition_check(_adapter *adapter, u8 is_scaning, u8 if #ifdef CONFIG_MCC_MODE /*not in MCC State*/ - if (MCC_EN(adapter) && + if (MCC_EN(adapter) && rtw_hal_check_mcc_status(adapter, MCC_STATUS_DOING_MCC)) { rfk_allowed = _FALSE; if (0) @@ -1461,15 +1461,15 @@ void rtw_dyn_soml_config(_adapter *adapter) RTW_INFO("dyn_soml_en = 1\n"); } else { if (adapter->registrypriv.dyn_soml_en == 2) { - rtw_dyn_soml_para_set(adapter, - adapter->registrypriv.dyn_soml_train_num, - adapter->registrypriv.dyn_soml_interval, + rtw_dyn_soml_para_set(adapter, + adapter->registrypriv.dyn_soml_train_num, + adapter->registrypriv.dyn_soml_interval, adapter->registrypriv.dyn_soml_period, adapter->registrypriv.dyn_soml_delay); RTW_INFO("dyn_soml_en = 2\n"); RTW_INFO("dyn_soml_en, param = %d, %d, %d, %d\n", adapter->registrypriv.dyn_soml_train_num, - adapter->registrypriv.dyn_soml_interval, + adapter->registrypriv.dyn_soml_interval, adapter->registrypriv.dyn_soml_period, adapter->registrypriv.dyn_soml_delay); } else if (adapter->registrypriv.dyn_soml_en == 0) { diff --git a/hal/hal_dm_acs.h b/hal/hal_dm_acs.h index 871c144..f18c15b 100644 --- a/hal/hal_dm_acs.h +++ b/hal/hal_dm_acs.h @@ -41,7 +41,7 @@ enum NHM_PID { nhm.mntr_time = time;\ } while (0) - + #define init_acs_clm(clm, time) \ init_clm_param(clm, CLM_ACS, CLM_LV_2, time) @@ -50,7 +50,7 @@ enum NHM_PID { #define init_11K_high_nhm(nhm, time) \ init_nhm_param(nhm, NHM_EXCLUDE_TXON, NHM_EXCLUDE_CCA, NHM_CNT_ALL, IEEE_11K_HIGH, NHM_LV_2, time) - + #define init_11K_low_nhm(nhm, time) \ init_nhm_param(nhm, NHM_EXCLUDE_TXON, NHM_EXCLUDE_CCA, NHM_CNT_ALL, IEEE_11K_LOW, NHM_LV_2, time) diff --git a/hal/hal_halmac.c b/hal/hal_halmac.c index 0b74ecb..1143d4d 100644 --- a/hal/hal_halmac.c +++ b/hal/hal_halmac.c @@ -2603,7 +2603,7 @@ int rtw_halmac_poweron(struct dvobj_priv *d) addr = 0x3F3; v8 = rtw_read8(a, addr); RTW_PRINT("%s: 0x%X = 0x%02x\n", __FUNCTION__, addr, v8); - + /* are we in pcie debug mode? */ if (!(v8 & BIT(2))) { RTW_PRINT("%s: Enable pcie debug mode\n", __FUNCTION__); diff --git a/hal/hal_hci/hal_usb.c b/hal/hal_hci/hal_usb.c index 20dc07b..0b5e756 100644 --- a/hal/hal_hci/hal_usb.c +++ b/hal/hal_hci/hal_usb.c @@ -333,7 +333,7 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr & 0x0000ffff); len = 1; - + /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) if(wvalue >= 0x0000 && wvalue < 0x0100) @@ -363,7 +363,7 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr & 0x0000ffff); len = 2; - + /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) if(wvalue >= 0x0000 && wvalue < 0x0100) @@ -394,7 +394,7 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr & 0x0000ffff); len = 4; - + /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) if(wvalue >= 0x0000 && wvalue < 0x0100) @@ -426,7 +426,7 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) wvalue = (u16)(addr & 0x0000ffff); len = 1; data = val; - + /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) if(wvalue >= 0x0000 && wvalue < 0x0100) diff --git a/hal/hal_intf.c b/hal/hal_intf.c index 071f7cd..341aebe 100644 --- a/hal/hal_intf.c +++ b/hal/hal_intf.c @@ -84,7 +84,7 @@ static void rtw_init_wireless_mode(_adapter *padapter) struct hal_spec_t *hal_spec = GET_HAL_SPEC(padapter); if(hal_spec->proto_cap & PROTO_CAP_11B) proto_wireless_mode |= WIRELESS_11B; - + if(hal_spec->proto_cap & PROTO_CAP_11G) proto_wireless_mode |= WIRELESS_11G; #ifdef CONFIG_80211AC_VHT @@ -103,7 +103,7 @@ static void rtw_init_wireless_mode(_adapter *padapter) #endif #ifdef CONFIG_80211AC_VHT - if(hal_spec->proto_cap & PROTO_CAP_11AC) + if(hal_spec->proto_cap & PROTO_CAP_11AC) proto_wireless_mode |= WIRELESS_11AC; #endif padapter->registrypriv.wireless_mode &= proto_wireless_mode; @@ -119,7 +119,7 @@ void rtw_hal_def_value_init(_adapter *padapter) padapter->hal_func.init_default_value(padapter); rtw_init_hal_com_default_value(padapter); - + #ifdef CONFIG_FW_MULTI_PORT_SUPPORT adapter_to_dvobj(padapter)->dft.port_id = 0xFF; adapter_to_dvobj(padapter)->dft.mac_id = 0xFF; diff --git a/hal/hal_mcc.c b/hal/hal_mcc.c index 179d4d5..bad0131 100644 --- a/hal/hal_mcc.c +++ b/hal/hal_mcc.c @@ -64,7 +64,7 @@ static void dump_iqk_val_table(PADAPTER padapter) ); } } - } + } RTW_INFO("=============================================\n"); #endif @@ -96,7 +96,7 @@ static void rtw_hal_mcc_build_p2p_noa_attr(PADAPTER padapter, u8 *ie, u32 *ie_le /* attrute ID(1 byte) */ p2p_noa_attr_ie[p2p_noa_attr_len] = P2P_ATTR_NOA; p2p_noa_attr_len = p2p_noa_attr_len + 1; - + /* attrute length(2 bytes) length = noa_desc_num*13 + 2 */ RTW_PUT_LE16(p2p_noa_attr_ie + p2p_noa_attr_len, (noa_desc_num * 13 + 2)); p2p_noa_attr_len = p2p_noa_attr_len + 2; @@ -153,7 +153,7 @@ static void rtw_hal_mcc_update_go_p2p_ie(PADAPTER padapter) else { /* has noa attribut, modify it */ u32 noa_duration = 0; - + /* update index */ pos = pmccadapriv->p2p_go_noa_ie + pmccadapriv->p2p_go_noa_ie_len - 15; /* 0~255 */ @@ -277,7 +277,7 @@ static void rtw_hal_mcc_update_policy_table(PADAPTER adapter) mcc_switch_channel_policy_table[mcc_policy_idx][MCC_START_TIME_OFFSET_IDX] = new_starttime_offset; - + } @@ -314,7 +314,7 @@ static void rtw_hal_config_mcc_switch_channel_setting(PADAPTER padapter) } -static void rtw_hal_mcc_assign_tx_threshold(PADAPTER padapter) +static void rtw_hal_mcc_assign_tx_threshold(PADAPTER padapter) { struct registry_priv *preg = &padapter->registrypriv; struct mcc_adapter_priv *pmccadapriv = &padapter->mcc_adapterpriv; @@ -458,7 +458,7 @@ static void rtw_hal_config_mcc_role_setting(PADAPTER padapter, u8 order) phead = &pstapriv->asoc_list; plist = get_next(phead); pmccadapriv->mcc_macid_bitmap = 0; - + while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) { psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -584,7 +584,7 @@ static u8 rtw_hal_mcc_check_start_time_is_valid(PADAPTER padapter, u8 case_num, u8 intersection = _FALSE; u8 min_start_time = 5; u8 max_start_time = 95; - + duration_0 = mccobjpriv->iface[0]->mcc_adapterpriv.mcc_duration; duration_1 = mccobjpriv->iface[1]->mcc_adapterpriv.mcc_duration; @@ -687,7 +687,7 @@ static void rtw_hal_mcc_decide_duration(PADAPTER padapter) iface_order1 = mccobjpriv->iface[1]; mccadapriv_order0 = &iface_order0->mcc_adapterpriv; mccadapriv_order1 = &iface_order1->mcc_adapterpriv; - + if (mccobjpriv->duration == 0) { /* default */ duration = 30;/*(%)*/ @@ -746,7 +746,7 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat u8 valid = _FALSE; u8 case_num = 1; u8 i = 0; - + /* query TSF */ rtw_hal_mcc_rqt_tsf(padapter, tsf); @@ -816,7 +816,7 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat rtw_hal_mcc_decide_duration(padapter); if (tsfdiff <= 50) { - + /* RX TBTT 0 */ case_num = 1; valid = rtw_hal_mcc_check_start_time_is_valid(padapter, case_num, tsfdiff, @@ -824,7 +824,7 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat if (valid) goto valid_result; - + /* RX TBTT 1 */ case_num = 2; valid = rtw_hal_mcc_check_start_time_is_valid(padapter, case_num, tsfdiff, @@ -832,7 +832,7 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat if (valid) goto valid_result; - + /* RX TBTT 2 */ case_num = 3; valid = rtw_hal_mcc_check_start_time_is_valid(padapter, case_num, tsfdiff, @@ -857,8 +857,8 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat if (valid) goto valid_result; - - + + /* RX TBTT 1 */ case_num = 5; valid = rtw_hal_mcc_check_start_time_is_valid(padapter, case_num, tsfdiff, @@ -867,7 +867,7 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat if (valid) goto valid_result; - + /* RX TBTT 2 */ case_num = 6; valid = rtw_hal_mcc_check_start_time_is_valid(padapter, case_num, tsfdiff, @@ -883,7 +883,7 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat } } - + valid_result: RTW_INFO("********************\n"); @@ -893,7 +893,7 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat __func__, upper_bound_0, lower_bound_0); RTW_INFO("%s: upper_bound_1:%d, lower_bound_1:%d\n", __func__, upper_bound_1, lower_bound_1); - + for (i = 0; i < dvobj->iface_nums; i++) { iface = dvobj->padapters[i]; if (iface == NULL) @@ -922,7 +922,7 @@ static u8 rtw_hal_mcc_update_timing_parameters(PADAPTER padapter, u8 force_updat FUNC_ADPT_ARG(iface), pmccadapriv->mgmt_queue_macid, pmccadapriv->mcc_macid_bitmap); RTW_INFO("********************\n"); } - + } exit: return need_update; @@ -1181,7 +1181,7 @@ u8 rtw_hal_dl_mcc_fw_rsvd_page(_adapter *adapter, u8 *pframe, u16 *index, i, pmccobjpriv->mcc_pwr_idx_rsvd_page[i]); total_rate_offset = start; - + for (path = RF_PATH_A; path < hal->NumTotalRFPath; ++path) { total_rate = 0; /* PATH A for 0~63 byte, PATH B for 64~127 byte*/ @@ -1223,7 +1223,7 @@ u8 rtw_hal_dl_mcc_fw_rsvd_page(_adapter *adapter, u8 *pframe, u16 *index, ADPT_ARG(iface), rf_path_char(path), ch_width_str(bw), center_ch, MGN_RATE_STR(rates[j]), power_index); - + shift = rate % 4; power_index_4bytes |= ((power_index & 0xff) << (shift * 8)); if (shift == 3) { @@ -1233,7 +1233,7 @@ u8 rtw_hal_dl_mcc_fw_rsvd_page(_adapter *adapter, u8 *pframe, u16 *index, total_rate++; } #endif - + } } @@ -1344,7 +1344,7 @@ u8 rtw_hal_dl_mcc_fw_rsvd_page(_adapter *adapter, u8 *pframe, u16 *index, RTW_INFO("TXPWR("ADPT_FMT"): [%c][%s]ch:%u, %s, pwr_idx:%u\n", ADPT_ARG(iface), rf_path_char(path), ch_width_str(bw), center_ch, MGN_RATE_STR(rates[j]), power_index); - + shift = rate % 4; power_index_4bytes |= ((power_index & 0xff) << (shift * 8)); if (shift == 3) { @@ -1427,7 +1427,7 @@ u8 rtw_hal_dl_mcc_fw_rsvd_page(_adapter *adapter, u8 *pframe, u16 *index, } #endif } - + } /* total rate store in offset 0 */ *total_rate_offset = total_rate; @@ -1523,7 +1523,7 @@ static void rtw_hal_set_mcc_time_setting_cmd(PADAPTER padapter) u8 fw_eable = 1; u8 swchannel_early_time = MCC_SWCH_FW_EARLY_TIME; u8 starting_ap_num = DEV_AP_STARTING_NUM(dvobj); - u8 ap_num = DEV_AP_NUM(dvobj); + u8 ap_num = DEV_AP_NUM(dvobj); if (starting_ap_num == 0 && ap_num == 0) /* For STA+GC/STA+STA, TSF of GC/STA does not need to sync from TSF of other STA/GC */ @@ -1548,7 +1548,7 @@ static void rtw_hal_set_mcc_time_setting_cmd(PADAPTER padapter) tsf_bsae_port = rtw_hal_get_port(order1_iface); tsf_sync_port = rtw_hal_get_port(order0_iface); - + /* FW set enable */ SET_H2CCMD_MCC_TIME_SETTING_FW_EN(cmd, fw_eable); /* TSF Sync offset */ @@ -1683,7 +1683,7 @@ static void rtw_hal_set_mcc_macid_cmd(PADAPTER padapter) pmccadapriv = &iface->mcc_adapterpriv; if (pmccadapriv->role == MCC_ROLE_MAX) continue; - + order = pmccadapriv->order; bitmap = pmccadapriv->mcc_macid_bitmap; @@ -2215,7 +2215,7 @@ static void rtw_hal_mcc_start_posthdl(PADAPTER padapter) mccadapriv = &iface->mcc_adapterpriv; if (mccadapriv->role == MCC_ROLE_MAX) continue; - + mccadapriv->mcc_tx_bytes_from_kernel = 0; mccadapriv->mcc_last_tx_bytes_from_kernel = 0; mccadapriv->mcc_tx_bytes_to_port = 0; @@ -2426,12 +2426,12 @@ static void rtw_hal_mcc_update_noa_start_time_hdl(PADAPTER padapter, u8 buflen, u8 policy_idx = pmccobjpriv->policy_index; u8 noa_tsf_sync_offset = mcc_switch_channel_policy_table[policy_idx][MCC_TSF_SYNC_OFFSET_IDX]; u8 noa_start_time_offset = mcc_switch_channel_policy_table[policy_idx][MCC_START_TIME_OFFSET_IDX]; - + for (i = 0; i < pdvobjpriv->iface_nums; i++) { iface = pdvobjpriv->padapters[i]; if (iface == NULL) continue; - + pmccadapriv = &iface->mcc_adapterpriv; if (pmccadapriv->role == MCC_ROLE_MAX) continue; @@ -2518,7 +2518,7 @@ void rtw_hal_mcc_c2h_handler(PADAPTER padapter, u8 buflen, u8 *tmpBuf) if (0) RTW_INFO("%d,order:%d,TSF:0x%llx\n", tmpBuf[0], tmpBuf[1], RTW_GET_LE64(tmpBuf + 2)); - + switch (pmccobjpriv->mcc_c2h_status) { case MCC_RPT_SUCCESS: _enter_critical_bh(&pmccobjpriv->mcc_lock, &irqL); @@ -2566,12 +2566,12 @@ void rtw_hal_mcc_c2h_handler(PADAPTER padapter, u8 buflen, u8 *tmpBuf) } void rtw_hal_mcc_update_parameter(PADAPTER padapter, u8 force_update) -{ +{ struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); struct mcc_obj_priv *mccobjpriv = &(dvobj->mcc_objpriv); u8 cmd[H2C_MCC_TIME_SETTING_LEN] = {0}; u8 swchannel_early_time = MCC_SWCH_FW_EARLY_TIME; - u8 ap_num = DEV_AP_NUM(dvobj); + u8 ap_num = DEV_AP_NUM(dvobj); if (ap_num == 0) { u8 need_update = _FALSE; @@ -2581,7 +2581,7 @@ void rtw_hal_mcc_update_parameter(PADAPTER padapter, u8 force_update) if (need_update == _FALSE) return; - + start_time_offset = mccobjpriv->start_time; interval = mccobjpriv->interval; duration = mccobjpriv->iface[0]->mcc_adapterpriv.mcc_duration; @@ -2626,11 +2626,11 @@ void rtw_hal_mcc_update_parameter(PADAPTER padapter, u8 force_update) iface = dvobj->padapters[i]; if (iface == NULL) continue; - + mccadapriv = &iface->mcc_adapterpriv; if (mccadapriv->role == MCC_ROLE_MAX) continue; - + if (mccadapriv->role == MCC_ROLE_GO) rtw_hal_mcc_update_go_p2p_ie(iface); } @@ -2672,7 +2672,7 @@ void rtw_hal_mcc_sw_status_check(PADAPTER padapter) u8 noa_enable = _FALSE; u8 i = 0; _irqL irqL; - u8 ap_num = DEV_AP_NUM(dvobj); + u8 ap_num = DEV_AP_NUM(dvobj); /* #define MCC_RESTART 1 */ @@ -2692,12 +2692,12 @@ void rtw_hal_mcc_sw_status_check(PADAPTER padapter) mccadapriv = &iface->mcc_adapterpriv; if (mccadapriv->role == MCC_ROLE_MAX) continue; - + if (iface->wdinfo.p2p_ps_mode == P2P_PS_NOA) { noa_enable = _TRUE; break; } - } + } if (!noa_enable && ap_num == 0) rtw_hal_mcc_update_parameter(padapter, _FALSE); @@ -2780,7 +2780,7 @@ u8 rtw_hal_mcc_change_scan_flag(PADAPTER padapter, u8 *ch, u8 *bw, u8 *offset) /* disable PS_ANNC & TX_RESUME for all interface */ /* ToDo: TX_RESUME by interface in SCAN_BACKING_OP */ mlmeext = &padapter->mlmeextpriv; - + flags = mlmeext_scan_backop_flags(mlmeext); if (mlmeext_chk_scan_backop_flags(mlmeext, SS_BACKOP_PS_ANNC)) flags &= ~SS_BACKOP_PS_ANNC; @@ -2809,7 +2809,7 @@ u8 rtw_hal_mcc_change_scan_flag(PADAPTER padapter, u8 *ch, u8 *bw, u8 *offset) /* bypass non-linked/non-linking interface/scan interface */ continue; } - + if (back_op) { *ch = mlmeext->cur_channel; *bw = mlmeext->cur_bwmode; @@ -2965,7 +2965,7 @@ u8 rtw_hal_set_mcc_setting_scan_complete(PADAPTER padapter) if (rtw_hal_check_mcc_status(padapter, MCC_STATUS_NEED_MCC)) { rtw_hal_mcc_assign_scan_flag(padapter, 1); - ret = rtw_hal_set_mcc_setting(padapter, MCC_SETCMD_STATUS_START_SCAN_DONE); + ret = rtw_hal_set_mcc_setting(padapter, MCC_SETCMD_STATUS_START_SCAN_DONE); } _exit_critical_mutex(&pmccobjpriv->mcc_mutex, NULL); } @@ -3179,7 +3179,7 @@ void rtw_hal_dump_mcc_info(void *sel, struct dvobj_priv *dvobj) } } RTW_PRINT_SEL(sel, "------------------------------------------\n"); - RTW_PRINT_SEL(sel, "policy index:%d\n", mccobjpriv->policy_index); + RTW_PRINT_SEL(sel, "policy index:%d\n", mccobjpriv->policy_index); RTW_PRINT_SEL(sel, "------------------------------------------\n"); RTW_PRINT_SEL(sel, "define data:\n"); RTW_PRINT_SEL(sel, "ap target tx TP(BW:20M):%d Mbps\n", MCC_AP_BW20_TARGET_TX_TP); @@ -3281,7 +3281,7 @@ u8 *rtw_hal_mcc_append_go_p2p_ie(PADAPTER padapter, u8 *pframe, u32 *len) if (!MCC_EN(padapter)) return pframe; - + if (!rtw_hal_check_mcc_status(padapter, MCC_STATUS_DOING_MCC)) return pframe; @@ -3433,7 +3433,7 @@ u8 rtw_set_mcc_duration_hdl(PADAPTER adapter, u8 type, const u8 *val) rtw_hal_mcc_update_policy_table(adapter); } - /* only update sw parameter under MCC + /* only update sw parameter under MCC it will be force update during */ if (noa_enable) goto exit; @@ -3452,7 +3452,7 @@ u8 rtw_set_mcc_duration_cmd(_adapter *adapter, u8 type, u8 val) u8 *mcc_duration = NULL; u8 res = _FAIL; - + cmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); if (cmdobj == NULL) goto exit; diff --git a/hal/led/hal_led.c b/hal/led/hal_led.c index 95d3daa..d693ac6 100644 --- a/hal/led/hal_led.c +++ b/hal/led/hal_led.c @@ -102,7 +102,7 @@ void rtw_sw_led_blink_uc_trx_only(LED_DATA *led) led->BlinkingLedState = RTW_LED_OFF; else led->BlinkingLedState = RTW_LED_ON; - + if (bStopBlinking) { led->CurrLedState = RTW_LED_OFF; led->bLedBlinkInProgress = _FALSE; @@ -225,7 +225,7 @@ void rtw_led_set_iface_en_mask(_adapter *adapter, u8 mask) void rtw_led_set_ctl_en_mask(_adapter *adapter, u32 ctl_mask) { struct led_priv *ledpriv = adapter_to_led(adapter); - + #if CONFIG_RTW_SW_LED_TRX_DA_CLASSIFY if (ctl_mask & BIT(LED_CTL_TX)) ctl_mask |= BIT(LED_CTL_UC_TX) | BIT(LED_CTL_BMC_TX); diff --git a/hal/phydm/ap_makefile.mk b/hal/phydm/ap_makefile.mk index def4490..9296b53 100644 --- a/hal/phydm/ap_makefile.mk +++ b/hal/phydm/ap_makefile.mk @@ -98,7 +98,7 @@ ifeq ($(CONFIG_WLAN_HAL_8822CE),y) _PHYDM_FILES += phydm/halrf/rtl8822c/halrf_8822c.o _PHYDM_FILES += phydm/halrf/rtl8822c/halrf_iqk_8822c.o _PHYDM_FILES += phydm/halrf/rtl8822c/halrf_dpk_8822c.o - _PHYDM_FILES += phydm/halrf/rtl8822c/halrf_rfk_init_8822c.o + _PHYDM_FILES += phydm/halrf/rtl8822c/halrf_rfk_init_8822c.o ifeq ($(CONFIG_RTL_ODM_WLAN_DRIVER),y) _PHYDM_FILES += \ phydm/rtl8822c/halhwimg8822c_bb.o\ diff --git a/hal/phydm/halrf/halphyrf_iot.c b/hal/phydm/halrf/halphyrf_iot.c index 8145fc9..07192ef 100644 --- a/hal/phydm/halrf/halphyrf_iot.c +++ b/hal/phydm/halrf/halphyrf_iot.c @@ -500,7 +500,7 @@ odm_reset_iqk_result( u8 odm_get_right_chnl_place_for_iqk(u8 chnl) { - + } void @@ -508,7 +508,7 @@ odm_iq_calibrate( struct dm_struct *dm ) { - + } void phydm_rf_init(void *dm_void) @@ -516,7 +516,7 @@ void phydm_rf_init(void *dm_void) struct dm_struct *dm = (struct dm_struct *)dm_void; odm_txpowertracking_init(dm); - + odm_clear_txpowertracking_state(dm); } diff --git a/hal/phydm/halrf/halphyrf_win.c b/hal/phydm/halrf/halphyrf_win.c index 7970278..f9ba9d1 100644 --- a/hal/phydm/halrf/halphyrf_win.c +++ b/hal/phydm/halrf/halphyrf_win.c @@ -783,7 +783,7 @@ odm_iq_calibrate( { void *adapter = dm->adapter; struct dm_iqk_info *iqk_info = &dm->IQK_info; - + RF_DBG(dm, DBG_RF_IQK, "=>%s\n",__FUNCTION__); #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) diff --git a/hal/phydm/halrf/halrf.c b/hal/phydm/halrf/halrf.c index 56572a1..b6ba47f 100644 --- a/hal/phydm/halrf/halrf.c +++ b/hal/phydm/halrf/halrf.c @@ -1935,7 +1935,7 @@ void halrf_dpk_track(void *dm_void) #if (RTL8822C_SUPPORT == 1) case ODM_RTL8822C: dpk_track_8822c(dm); - break; + break; #endif #if (RTL8195B_SUPPORT == 1) @@ -1961,7 +1961,7 @@ void halrf_dpk_track(void *dm_void) #if (RTL8198F_SUPPORT == 1) case ODM_RTL8198F: dpk_track_8198f(dm); - break; + break; #endif #endif @@ -2003,7 +2003,7 @@ void halrf_dpk_reload(void *dm_void) case ODM_RTL8198F: if (dpk_info->dpk_path_ok > 0) dpk_reload_8198f(dm); - break; + break; #endif #endif diff --git a/hal/phydm/halrf/halrf_powertracking_ap.c b/hal/phydm/halrf/halrf_powertracking_ap.c index cafd92f..9151a3a 100644 --- a/hal/phydm/halrf/halrf_powertracking_ap.c +++ b/hal/phydm/halrf/halrf_powertracking_ap.c @@ -1032,7 +1032,7 @@ odm_txpowertracking_thermal_meter_init( void *adapter = dm->adapter; HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter)); struct dm_priv *pdmpriv = &hal_data->dmpriv; - + pdmpriv->is_txpowertracking = true; pdmpriv->tx_powercount = 0; pdmpriv->is_txpowertracking_init = false; diff --git a/hal/phydm/halrf/halrf_powertracking_ce.c b/hal/phydm/halrf/halrf_powertracking_ce.c index 55ec7bf..ae06515 100644 --- a/hal/phydm/halrf/halrf_powertracking_ce.c +++ b/hal/phydm/halrf/halrf_powertracking_ce.c @@ -806,7 +806,7 @@ void odm_txpowertracking_check_ce(void *dm_void) dm->rf_calibrate_info.tm_trigger = 1; return; } - + if (dm->support_ic_type & (ODM_RTL8822C | ODM_RTL8814B)) return; diff --git a/hal/phydm/halrf/halrf_powertracking_win.c b/hal/phydm/halrf/halrf_powertracking_win.c index bad28f5..20e7bee 100644 --- a/hal/phydm/halrf/halrf_powertracking_win.c +++ b/hal/phydm/halrf/halrf_powertracking_win.c @@ -530,8 +530,8 @@ get_swing_index( u32 bb_swing, table_value; if (dm->support_ic_type == ODM_RTL8188E || dm->support_ic_type == ODM_RTL8723B || - dm->support_ic_type == ODM_RTL8192E || dm->support_ic_type == ODM_RTL8188F || - dm->support_ic_type == ODM_RTL8703B || dm->support_ic_type == ODM_RTL8723D || + dm->support_ic_type == ODM_RTL8192E || dm->support_ic_type == ODM_RTL8188F || + dm->support_ic_type == ODM_RTL8703B || dm->support_ic_type == ODM_RTL8723D || dm->support_ic_type == ODM_RTL8192F || dm->support_ic_type == ODM_RTL8710B || dm->support_ic_type == ODM_RTL8821) { bb_swing = odm_get_bb_reg(dm, REG_OFDM_0_XA_TX_IQ_IMBALANCE, 0xFFC00000); @@ -674,11 +674,11 @@ odm_txpowertracking_thermal_meter_init( cali_info->default_ofdm_index = 28; /*OFDM: -1dB*/ cali_info->default_cck_index = 28; /*CCK: -6dB*/ /* JJ ADD 20161014 */ - } else if (dm->support_ic_type == ODM_RTL8710B) { + } else if (dm->support_ic_type == ODM_RTL8710B) { cali_info->default_ofdm_index = 28; /*OFDM: -1dB*/ cali_info->default_cck_index = 28; /*CCK: -6dB*/ /*Winnita add 20170828*/ - } else if (dm->support_ic_type == ODM_RTL8192F) { + } else if (dm->support_ic_type == ODM_RTL8192F) { cali_info->default_ofdm_index = 30; /*OFDM: 0dB*/ cali_info->default_cck_index = 28; /*CCK: -6dB*/ } else { diff --git a/hal/phydm/halrf/halrf_psd.c b/hal/phydm/halrf/halrf_psd.c index 8c2f874..dd68d26 100644 --- a/hal/phydm/halrf/halrf_psd.c +++ b/hal/phydm/halrf/halrf_psd.c @@ -127,7 +127,7 @@ void halrf_psd( psd->buf_size = 256; mode = average >> 16; - + if (mode == 1) average_tmp = average & 0xffff; else if (mode == 2) @@ -284,7 +284,7 @@ void halrf_iqk_psd( psd->buf_size = 256; mode = average >> 16; - + if (mode == 1) average_tmp = average & 0xffff; else if (mode == 2) { diff --git a/hal/phydm/phydm.mk b/hal/phydm/phydm.mk index a05df64..f19430e 100644 --- a/hal/phydm/phydm.mk +++ b/hal/phydm/phydm.mk @@ -40,7 +40,7 @@ _PHYDM_FILES := hal/phydm/phydm_debug.o \ hal/phydm/halrf/halrf_powertracking_ce.o\ hal/phydm/halrf/halrf_powertracking.o\ hal/phydm/halrf/halrf_kfree.o - + ifeq ($(CONFIG_RTL8188E), y) RTL871X = rtl8188e _PHYDM_FILES += hal/phydm/$(RTL871X)/halhwimg8188e_mac.o\ @@ -189,7 +189,7 @@ _PHYDM_FILES += hal/phydm/$(RTL871X)/halhwimg8192f_bb.o\ hal/phydm/$(RTL871X)/phydm_hal_api8192f.o\ hal/phydm/$(RTL871X)/phydm_regconfig8192f.o\ hal/phydm/$(RTL871X)/phydm_rtl8192f.o\ - hal/phydm/halrf/$(RTL871X)/halrf_8192f.o + hal/phydm/halrf/$(RTL871X)/halrf_8192f.o endif ifeq ($(CONFIG_RTL8198F), y) diff --git a/hal/phydm/phydm_debug.c b/hal/phydm/phydm_debug.c index 5d63ea4..3714383 100644 --- a/hal/phydm/phydm_debug.c +++ b/hal/phydm/phydm_debug.c @@ -2201,7 +2201,7 @@ void phydm_basic_dbg_message(void *dm_void) /*if (!(dm->debug_components & DBG_CMN))*/ /* return; */ - + if (dm->cmn_dbg_msg_cnt >= dm->cmn_dbg_msg_period) { dm->cmn_dbg_msg_cnt = PHYDM_WATCH_DOG_PERIOD; diff --git a/hal/phydm/phydm_dig.c b/hal/phydm/phydm_dig.c index eea6dce..01c19f3 100644 --- a/hal/phydm/phydm_dig.c +++ b/hal/phydm/phydm_dig.c @@ -135,7 +135,7 @@ void phydm_dig_damping_chk(void *dm_void) switch (igi_bitmap_4bit) { case 0x5: - /*@ 4b'0101 + /*@ 4b'0101 * IGI:[3]down(0x24)->[2]up(0x26)->[1]down(0x24)->[0]up(0x26)->[new](Lock @ 0x26) * FA: [3] >high1 ->[2] [1] >high1 ->[0] [new] rssi, dtp->sta_tx_high_power_lvl); - if (dtp->sta_tx_high_power_lvl == tx_high_pwr_level_unchange + if (dtp->sta_tx_high_power_lvl == tx_high_pwr_level_unchange || dtp->sta_tx_high_power_lvl == dtp->sta_last_dtp_lvl) { dtp->sta_tx_high_power_lvl = dtp->sta_last_dtp_lvl; PHYDM_DBG(dm, DBG_DYN_TXPWR, diff --git a/hal/phydm/phydm_features_win.h b/hal/phydm/phydm_features_win.h index 8d2d131..9074482 100644 --- a/hal/phydm/phydm_features_win.h +++ b/hal/phydm/phydm_features_win.h @@ -120,11 +120,11 @@ /*#define CONFIG_HL_SMART_ANTENNA_TYPE1*/ #define CONFIG_FAT_PATCH #endif - + #if (RTL8822B_SUPPORT) /*#define CONFIG_HL_SMART_ANTENNA_TYPE2*/ #endif - + #if (defined(CONFIG_HL_SMART_ANTENNA_TYPE1) || defined(CONFIG_HL_SMART_ANTENNA_TYPE2)) #define CONFIG_HL_SMART_ANTENNA #endif diff --git a/hal/phydm/phydm_mp.c b/hal/phydm/phydm_mp.c index 7d964f5..5112e24 100644 --- a/hal/phydm/phydm_mp.c +++ b/hal/phydm/phydm_mp.c @@ -272,7 +272,7 @@ void phydm_mp_set_single_carrier(void *dm_void, boolean is_single_carrier) odm_set_bb_reg(dm, R_0x100, 0x100, 0x0); odm_set_bb_reg(dm, R_0x100, 0x100, 0x1); } - } + } } void phydm_mp_reset_rx_counters_phy(void *dm_void) { @@ -306,9 +306,9 @@ void phydm_mp_get_tx_ok(void *dm_void, u32 rate_index) void phydm_mp_get_rx_ok(void *dm_void) { struct dm_struct *dm = (struct dm_struct *)dm_void; - struct phydm_mp *mp = &dm->dm_mp_table; + struct phydm_mp *mp = &dm->dm_mp_table; - u32 cck_ok = 0, ofdm_ok = 0, ht_ok = 0, vht_ok = 0; + u32 cck_ok = 0, ofdm_ok = 0, ht_ok = 0, vht_ok = 0; u32 cck_err = 0, ofdm_err = 0, ht_err = 0, vht_err = 0; if (dm->support_ic_type & ODM_IC_JGR3_SERIES) { @@ -316,7 +316,7 @@ void phydm_mp_get_rx_ok(void *dm_void) ofdm_ok = odm_get_bb_reg(dm, R_0x2c14, 0xffff); ht_ok = odm_get_bb_reg(dm, R_0x2c10, 0xffff); vht_ok = odm_get_bb_reg(dm, R_0x2c0c, 0xffff); - + cck_err = odm_get_bb_reg(dm, R_0x2c04, 0xffff0000); ofdm_err = odm_get_bb_reg(dm, R_0x2c14, 0xffff0000); ht_err = odm_get_bb_reg(dm, R_0x2c10, 0xffff0000); @@ -326,7 +326,7 @@ void phydm_mp_get_rx_ok(void *dm_void) ofdm_ok = odm_get_bb_reg(dm, R_0xf14, 0x3FFF); ht_ok = odm_get_bb_reg(dm, R_0xf10, 0x3FFF); vht_ok = odm_get_bb_reg(dm, R_0xf0c, 0x3FFF); - + cck_err = odm_get_bb_reg(dm, R_0xf04, 0x3FFF0000); ofdm_err = odm_get_bb_reg(dm, R_0xf14, 0x3FFF0000); ht_err = odm_get_bb_reg(dm, R_0xf10, 0x3FFF0000); @@ -335,7 +335,7 @@ void phydm_mp_get_rx_ok(void *dm_void) cck_ok = odm_get_bb_reg(dm, R_0xf88, MASKDWORD); ofdm_ok = odm_get_bb_reg(dm, R_0xf94, 0xffff); ht_ok = odm_get_bb_reg(dm, R_0xf90, 0xffff); - + cck_err = odm_get_bb_reg(dm, R_0xf84, MASKDWORD); ofdm_err = odm_get_bb_reg(dm, R_0xf94, 0xffff0000); ht_err = odm_get_bb_reg(dm, R_0xf90, 0xffff0000); diff --git a/hal/phydm/phydm_mp.h b/hal/phydm/phydm_mp.h index 40088c6..ee030bb 100644 --- a/hal/phydm/phydm_mp.h +++ b/hal/phydm/phydm_mp.h @@ -60,7 +60,7 @@ struct phydm_mp { * 1 ============================================================ */ enum TX_MODE_OFDM { - OFDM_OFF = 0, + OFDM_OFF = 0, OFDM_CONT_TX = 1, OFDM_SINGLE_CARRIER = 2, OFDM_SINGLE_TONE = 4, diff --git a/hal/phydm/phydm_regtable.h b/hal/phydm/phydm_regtable.h index cf2226c..9d1b6a8 100644 --- a/hal/phydm/phydm_regtable.h +++ b/hal/phydm/phydm_regtable.h @@ -267,7 +267,7 @@ #define R_0x3a44 0x3a44 #define R_0x3a48 0x3a48 #define R_0x3a4c 0x3a4c -#define R_0x3a50 0x3a50 +#define R_0x3a50 0x3a50 #define R_0x3a54 0x3a54 #define R_0x3a58 0x3a58 #define R_0x3a5c 0x3a5c diff --git a/hal/phydm/rtl8822b/phydm_rtl8822b.c b/hal/phydm/rtl8822b/phydm_rtl8822b.c index 714832e..ad8f22e 100644 --- a/hal/phydm/rtl8822b/phydm_rtl8822b.c +++ b/hal/phydm/rtl8822b/phydm_rtl8822b.c @@ -507,7 +507,7 @@ void phydm_set_weighting_mcc(u8 b_equal_weighting, void *dm_void, u8 port) mcc_dm->mcc_reg_id[4] = 0x4; mcc_dm->mcc_dm_reg[4] = 0x81b; mcc_dm->mcc_dm_val[4][port] = val_0x81b; - + } void phydm_dyn_ant_dec_mcc(u8 port, u8 rssi_in, void *dm_void) { @@ -573,11 +573,11 @@ u8 phydm_check(void *dm_void) mcc_macid = mcc_dm->sta_macid[i][j]; p_entry = dm->phydm_sta_info[mcc_macid]; if (p_entry == NULL) { - PHYDM_DBG(dm, DBG_COMP_MCC, "Pentry == NULL(mac=%d)\n", + PHYDM_DBG(dm, DBG_COMP_MCC, "Pentry == NULL(mac=%d)\n", mcc_dm->sta_macid[i][j]); return _FAIL; } - PHYDM_DBG(dm, DBG_COMP_MCC, "undecorated_smoothed_pwdb=%d\n", + PHYDM_DBG(dm, DBG_COMP_MCC, "undecorated_smoothed_pwdb=%d\n", p_entry->rssi_stat.rssi); if (p_entry->rssi_stat.rssi < rssi_tmp_min[i]) rssi_tmp_min[i] = p_entry->rssi_stat.rssi; @@ -615,7 +615,7 @@ void phydm_mcc_h2ccmd(void *dm_void) u8 h2c_mcc[H2C_MAX_LENGTH]; if (mcc_dm->mcc_rf_channel[0] == 0xff && mcc_dm->mcc_rf_channel[1] == 0xff) { - PHYDM_DBG(dm, DBG_COMP_MCC, "MCC channel Error\n"); + PHYDM_DBG(dm, DBG_COMP_MCC, "MCC channel Error\n"); return; } /* Set Channel number */ @@ -655,8 +655,8 @@ void phydm_mcc_h2ccmd(void *dm_void) h2c_mcc[5], h2c_mcc[6]); } } - - + + } void phydm_mcc_ctrl(void *dm_void) @@ -716,7 +716,7 @@ void phydm_mcc_switch(void *dm_void) } /* Set IGI*/ phydm_mcc_igi_cal(dm); - + /* Set Antenna Gain*/ #if (RTL8822B_SUPPORT == 1) phydm_dynamic_ant_weighting_mcc_8822b(dm); @@ -760,7 +760,7 @@ phydm_pw_sat_8822b( odm_set_bb_reg(dm, 0x830, MASKDWORD, 0x79a0eaaa); odm_set_bb_reg(dm, 0xe58, BIT(20), 0x1); - + odm_set_bb_reg(dm, 0xcb0, (MASKBYTE2 | MASKLWORD), 0x177717); odm_set_bb_reg(dm, 0xeb0, (MASKBYTE2 | MASKLWORD), diff --git a/hal/rtl8822b/rtl8822b_cmd.c b/hal/rtl8822b/rtl8822b_cmd.c index 87ba58c..8e9815d 100644 --- a/hal/rtl8822b/rtl8822b_cmd.c +++ b/hal/rtl8822b/rtl8822b_cmd.c @@ -125,7 +125,7 @@ void rtl8822b_set_FwPwrMode_cmd(PADAPTER adapter, u8 psmode) #ifdef CONFIG_WMMPS_STA struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); struct qos_priv *pqospriv = &pmlmepriv->qospriv; -#endif /* CONFIG_WMMPS_STA */ +#endif /* CONFIG_WMMPS_STA */ u8 h2c[RTW_HALMAC_H2C_MAX_SIZE] = {0}; u8 PowerState = 0, awake_intvl = 1, rlbm = 0; u8 allQueueUAPSD = 0; @@ -143,7 +143,7 @@ void rtl8822b_set_FwPwrMode_cmd(PADAPTER adapter, u8 psmode) psmode == PS_MODE_ACTIVE ? pwrpriv->current_lps_hw_port_id : hw_port); if (psmode == PS_MODE_MIN || psmode == PS_MODE_MAX) { -#ifdef CONFIG_WMMPS_STA +#ifdef CONFIG_WMMPS_STA if (rtw_is_wmmps_mode(adapter)) { mode = 2; @@ -156,8 +156,8 @@ void rtl8822b_set_FwPwrMode_cmd(PADAPTER adapter, u8 psmode) #endif /* CONFIG_WMMPS_STA */ { mode = 1; -#ifdef CONFIG_WMMPS_STA - /* For WMMPS test case, the station must retain sleep mode to capture buffered data on LPS mechanism */ +#ifdef CONFIG_WMMPS_STA + /* For WMMPS test case, the station must retain sleep mode to capture buffered data on LPS mechanism */ if ((pqospriv->uapsd_tid & BIT_MASK_TID_TC) != 0) smart_ps = 0; else @@ -222,7 +222,7 @@ void rtl8822b_set_FwPwrMode_cmd(PADAPTER adapter, u8 psmode) else fw_psmode_str = "UNSPECIFIED"; - RTW_INFO(FUNC_ADPT_FMT": fw ps mode = %s, drv ps mode = %d, rlbm = %d , smart_ps = %d, allQueueUAPSD = %d\n", + RTW_INFO(FUNC_ADPT_FMT": fw ps mode = %s, drv ps mode = %d, rlbm = %d , smart_ps = %d, allQueueUAPSD = %d\n", FUNC_ADPT_ARG(adapter), fw_psmode_str, psmode, rlbm, smart_ps, allQueueUAPSD); SET_PWR_MODE_SET_CMD_ID(h2c, CMD_ID_SET_PWR_MODE); @@ -274,7 +274,7 @@ void rtl8822b_set_BcnEarly_C2H_Rpt_cmd(PADAPTER padapter, u8 enable) SET_PWR_MODE_SET_RLBM(u1H2CSetPwrMode, 1); SET_PWR_MODE_SET_BCN_EARLY_RPT(u1H2CSetPwrMode, enable); SET_PWR_MODE_SET_PWR_STATE(u1H2CSetPwrMode, 0x0C); - + rtw_halmac_send_h2c(adapter_to_dvobj(padapter), u1H2CSetPwrMode); } #endif @@ -406,7 +406,7 @@ C2HTxRPTHandler_8822b( RTW_WARN("%s,%d: No gotc2h!\n", __FUNCTION__, __LINE__); return; } - + adapter_ognl = rtw_get_iface_by_id(GET_PRIMARY_ADAPTER(Adapter), pstapriv->c2h_adapter_id); if(!adapter_ognl) { RTW_WARN("%s: No adapter!\n", __FUNCTION__); @@ -452,7 +452,7 @@ C2HSPC_STAT_8822b( RTW_WARN("%s, %d: No gotc2h!\n", __FUNCTION__, __LINE__); return; } - + adapter_ognl = rtw_get_iface_by_id(GET_PRIMARY_ADAPTER(Adapter), pstapriv->c2h_adapter_id); if(!adapter_ognl) { RTW_WARN("%s: No adapter!\n", __FUNCTION__); diff --git a/hal/rtl8822b/rtl8822b_halinit.c b/hal/rtl8822b/rtl8822b_halinit.c index 2fca820..279c322 100644 --- a/hal/rtl8822b/rtl8822b_halinit.c +++ b/hal/rtl8822b/rtl8822b_halinit.c @@ -160,7 +160,7 @@ u8 rtl8822b_hal_init(PADAPTER adapter) return _FALSE; } - + RTW_INFO("%s Download Firmware from %s success\n", __FUNCTION__, (fw_bin) ? "file" : "array"); RTW_INFO("%s FW Version:%d SubVersion:%d FW size:%d\n", "NIC", diff --git a/hal/rtl8822b/rtl8822b_ops.c b/hal/rtl8822b/rtl8822b_ops.c index f8e18b0..df188d5 100644 --- a/hal/rtl8822b/rtl8822b_ops.c +++ b/hal/rtl8822b/rtl8822b_ops.c @@ -1395,7 +1395,7 @@ static void hw_var_set_bcn_func(PADAPTER adapter, u8 enable) val8 |= BIT_EN_BCN_TRXRPT_V1_8822B; rtw_write8(adapter, REG_FWHW_TXQ_CTRL_8822B, val8); - + switch (adapter->hw_port) { case HW_PORT0: val8 = BIT_EN_BCN_FUNCTION_8822B | BIT_P0_EN_TXBCN_RPT_8822B; @@ -3035,7 +3035,7 @@ u8 rtl8822b_gethaldefvar(PADAPTER adapter, HAL_DEF_VARIABLE variable, void *pval /* support 1T STBC under 2TX */ case HAL_DEF_TX_STBC: -#ifdef CONFIG_ALPHA_SMART_ANTENNA +#ifdef CONFIG_ALPHA_SMART_ANTENNA *(u8 *)pval = 0; #else if (hal->rf_type == RF_1T2R || hal->rf_type == RF_1T1R) @@ -3394,7 +3394,7 @@ void rtl8822b_fill_txdesc_mgnt_bf(struct xmit_frame *frame, u8 *desc) /*SET_TX_DESC_MACID_8822B(desc, pattrib->mac_id);*/ /* ad-hoc mode */ /*SET_TX_DESC_G_ID_8822B(desc, 63);*/ /* - * partial AID of 1st STA, at infrastructure mode, either SU or MU; + * partial AID of 1st STA, at infrastructure mode, either SU or MU; * MACID, at ad-hoc mode * * For WMAC to restore the received CSI report of STA1. @@ -3596,7 +3596,7 @@ static void fill_default_txdesc(struct xmit_frame *pxmitframe, u8 *pbuf) SET_TX_DESC_DATA_SHORT_8822B(pbuf, 1); #ifdef CONFIG_IP_R_MONITOR if((pattrib->ether_type == ETH_P_ARP) && - (IsSupportedTxOFDM(adapter->registrypriv.wireless_mode))) + (IsSupportedTxOFDM(adapter->registrypriv.wireless_mode))) SET_TX_DESC_DATARATE_8822B(pbuf, MRateToHwRate(IEEE80211_OFDM_RATE_6MB)); else #endif/*CONFIG_IP_R_MONITOR*/ diff --git a/hal/rtl8822b/usb/rtl8822bu_ops.c b/hal/rtl8822b/usb/rtl8822bu_ops.c index 7cfc69c..9274fef 100644 --- a/hal/rtl8822b/usb/rtl8822bu_ops.c +++ b/hal/rtl8822b/usb/rtl8822bu_ops.c @@ -23,7 +23,7 @@ #ifdef CONFIG_SUPPORT_USB_INT static void rtl8822bu_interrupt_handler(PADAPTER padapter, u16 pkt_len, u8 *pbuf) -{ +{ } #endif /* CONFIG_SUPPORT_USB_INT */ @@ -216,7 +216,7 @@ static void read_ledsetting(PADAPTER adapter) #ifdef CONFIG_RTW_SW_LED PHAL_DATA_TYPE hal; - + hal = GET_HAL_DATA(adapter); ledpriv->bRegUseLed = _TRUE; @@ -237,7 +237,7 @@ static void read_ledsetting(PADAPTER adapter) #endif /* CONFIG_RTW_SW_LED */ } #endif /* CONFIG_RTW_LED */ - + /* * Description: diff --git a/hal/rtl8822b/usb/rtl8822bu_xmit.c b/hal/rtl8822b/usb/rtl8822bu_xmit.c index 6fff3a2..1d19170 100644 --- a/hal/rtl8822b/usb/rtl8822bu_xmit.c +++ b/hal/rtl8822b/usb/rtl8822bu_xmit.c @@ -203,7 +203,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag #ifdef CONFIG_WMMPS_STA if (pattrib->trigger_frame) SET_TX_DESC_TRI_FRAME_8822B (ptxdesc, 1); -#endif /* CONFIG_WMMPS_STA */ +#endif /* CONFIG_WMMPS_STA */ } else { /* @@ -436,7 +436,7 @@ static s32 rtw_dump_xframe(PADAPTER padapter, struct xmit_frame *pxmitframe) /* download rsvd page or fw */ inner_ret = rtw_write_port(padapter, ff_hwaddr, w_sz, (unsigned char *)pxmitbuf); else - enqueue_pending_xmitbuf(pxmitpriv, pxmitbuf); + enqueue_pending_xmitbuf(pxmitpriv, pxmitbuf); #else inner_ret = rtw_write_port(padapter, ff_hwaddr, w_sz, (unsigned char *)pxmitbuf); #endif @@ -745,7 +745,7 @@ agg_end: /* download rsvd page or fw */ rtw_write_port(padapter, ff_hwaddr, pbuf_tail, (u8 *)pxmitbuf); else - enqueue_pending_xmitbuf(pxmitpriv, pxmitbuf); + enqueue_pending_xmitbuf(pxmitpriv, pxmitbuf); #else rtw_write_port(padapter, ff_hwaddr, pbuf_tail, (u8 *)pxmitbuf); #endif diff --git a/ifcfg-wlan0 b/ifcfg-wlan0 index 20dcbec..7ecb7ae 100644 --- a/ifcfg-wlan0 +++ b/ifcfg-wlan0 @@ -1,4 +1,4 @@ -#DHCP client -DEVICE=wlan0 -BOOTPROTO=dhcp +#DHCP client +DEVICE=wlan0 +BOOTPROTO=dhcp ONBOOT=yes \ No newline at end of file diff --git a/include/Hal8192FPhyCfg.h b/include/Hal8192FPhyCfg.h index db396d4..a143e01 100644 --- a/include/Hal8192FPhyCfg.h +++ b/include/Hal8192FPhyCfg.h @@ -102,7 +102,7 @@ PHY_GetTxPowerIndex_8192F( ); VOID -PHY_GetTxPowerLevel8192F( +PHY_GetTxPowerLevel8192F( IN PADAPTER Adapter, OUT s32 *powerlevel ); diff --git a/include/Hal8192FPwrSeq.h b/include/Hal8192FPwrSeq.h index 2b0bdc7..ff565fd 100644 --- a/include/Hal8192FPwrSeq.h +++ b/include/Hal8192FPwrSeq.h @@ -48,7 +48,7 @@ #define RTL8192F_TRANS_CARDEMU_TO_PDN_STEPS 4 #define RTL8192F_TRANS_PDN_TO_CARDEMU_STEPS 1 #define RTL8192F_TRANS_ACT_TO_LPS_STEPS 13 -#define RTL8192F_TRANS_LPS_TO_ACT_STEPS 11 +#define RTL8192F_TRANS_LPS_TO_ACT_STEPS 11 #define RTL8192F_TRANS_END_STEPS 1 @@ -94,7 +94,7 @@ {0x001C, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT7, 0},/*Register Lock Enable*/\ {0x0077, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, (BIT7|BIT6), 0x3},/*set HCI Power sequence state delay time:0*/ - + #define RTL8192F_TRANS_ACT_TO_CARDEMU \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, // comments here*/ \ @@ -128,7 +128,7 @@ {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,PWR_BASEADDR_SDIO,PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT4, 0}, /*0x23[4] = 1b'0 12H LDO enter normal mode*/ \ {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ - + #define RTL8192F_TRANS_CARDEMU_TO_CARDDIS \ /* format */ \ @@ -200,7 +200,7 @@ {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, 0xFF, 0xFF}, /*. 0x100[7:0] = 0xFF enable WMAC TRX*/\ {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT1|BIT0, BIT1|BIT0}, /*. 0x02[1:0] = 2b'11 enable BB macro*/\ {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, 0xFF, 0}, /*. 0x522 = 0*/ - + #define RTL8192F_TRANS_END \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, // comments here*/ \ diff --git a/include/Hal8710BPwrSeq.h b/include/Hal8710BPwrSeq.h index 31ad29c..4c71b77 100644 --- a/include/Hal8710BPwrSeq.h +++ b/include/Hal8710BPwrSeq.h @@ -46,7 +46,7 @@ #define RTL8710B_TRANS_CARDEMU_TO_PDN_STEPS 15 #define RTL8710B_TRANS_PDN_TO_CARDEMU_STEPS 15 #define RTL8710B_TRANS_ACT_TO_LPS_STEPS 15 -#define RTL8710B_TRANS_LPS_TO_ACT_STEPS 15 +#define RTL8710B_TRANS_LPS_TO_ACT_STEPS 15 #define RTL8710B_TRANS_ACT_TO_SWLPS_STEPS 22 #define RTL8710B_TRANS_SWLPS_TO_ACT_STEPS 15 #define RTL8710B_TRANS_END_STEPS 1 @@ -59,9 +59,9 @@ {0x0004, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT0, 1},\ {0x0056, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, 0xFF, 0x0E},\ {0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT0, 1},\ - {0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_POLLING, BIT0, 0},/**/ + {0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_POLLING, BIT0, 0},/**/ + - #define RTL8710B_TRANS_ACT_TO_CARDEMU \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, // comments here*/ \ @@ -91,7 +91,7 @@ {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,PWR_BASEADDR_SDIO,PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT4, 0}, /*0x23[4] = 1b'0 12H LDO enter normal mode*/ \ {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ - + #define RTL8710B_TRANS_CARDEMU_TO_CARDDIS \ /* format */ \ @@ -130,7 +130,7 @@ {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, 0xFF, 0x03},/*Reset MAC TRX*/ \ {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT1, 0},/*check if removed later*/ \ {0x0093, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, 0xFF, 0x00},/*When driver enter Sus/ Disable, enable LOP for BT*/ \ - {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT5, BIT5},/*Respond TxOK to scheduler*/ + {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT5, BIT5},/*Respond TxOK to scheduler*/ #define RTL8710B_TRANS_LPS_TO_ACT \ @@ -147,7 +147,7 @@ {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, 0xFF, 0xFF}, /*. 0x100[7:0] = 0xFF enable WMAC TRX*/\ {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, BIT1|BIT0, BIT1|BIT0}, /*. 0x02[1:0] = 2b'11 enable BB macro*/\ {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,PWR_BASEADDR_MAC,PWR_CMD_WRITE, 0xFF, 0}, /*. 0x522 = 0*/ - + #define RTL8710B_TRANS_END \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, // comments here*/ \ diff --git a/include/cmn_info/rtw_sta_info.h b/include/cmn_info/rtw_sta_info.h index 6910098..73e4095 100644 --- a/include/cmn_info/rtw_sta_info.h +++ b/include/cmn_info/rtw_sta_info.h @@ -189,7 +189,7 @@ struct dtp_info { }; struct cmn_sta_info { - u16 dm_ctrl; /*[Driver]*/ + u16 dm_ctrl; /*[Driver]*/ enum channel_width bw_mode; /*[Driver] max support BW*/ u8 mac_id; /*[Driver]*/ u8 mac_addr[6]; /*[Driver]*/ diff --git a/include/drv_conf.h b/include/drv_conf.h index acd98dc..8d6a040 100755 --- a/include/drv_conf.h +++ b/include/drv_conf.h @@ -475,11 +475,11 @@ #endif #endif -#define CONFIG_RTW_TPT_MODE +#define CONFIG_RTW_TPT_MODE #ifdef CONFIG_PCI_BCN_POLLING #define CONFIG_BCN_ICF -#endif +#endif #ifndef CONFIG_PCI_MSI #define CONFIG_RTW_PCI_MSI_DISABLE diff --git a/include/drv_types.h b/include/drv_types.h index c2f65fc..7ab6e7e 100644 --- a/include/drv_types.h +++ b/include/drv_types.h @@ -1112,7 +1112,7 @@ struct dvobj_priv { _timer txbcn_timer; #endif _timer dynamic_chk_timer; /* dynamic/periodic check timer */ - + #ifdef CONFIG_RTW_NAPI_DYNAMIC u8 en_napi_dynamic; #endif /* CONFIG_RTW_NAPI_DYNAMIC */ @@ -1258,8 +1258,8 @@ struct dvobj_priv { u8 tpt_mode; /* RTK T/P Testing Mode, 0:default mode */ u32 edca_be_ul; u32 edca_be_dl; -#endif - /* also for RTK T/P Testing Mode */ +#endif + /* also for RTK T/P Testing Mode */ u8 scan_deny; }; diff --git a/include/hal_com_h2c.h b/include/hal_com_h2c.h index adff210..6b56615 100644 --- a/include/hal_com_h2c.h +++ b/include/hal_com_h2c.h @@ -401,7 +401,7 @@ s32 rtw_hal_customer_str_write(_adapter *adapter, const u8 *cs); #define SET_H2CCMD_MCC_CTRL_V2_PRIMARY_CH(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 4, __Value) #define SET_H2CCMD_MCC_CTRL_V2_BW(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 4, 4, __Value) #define SET_H2CCMD_MCC_CTRL_V2_DURATION(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value) -#define SET_H2CCMD_MCC_CTRL_V2_ROLE(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 3, __Value) +#define SET_H2CCMD_MCC_CTRL_V2_ROLE(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 3, __Value) #define SET_H2CCMD_MCC_CTRL_V2_INCURCH(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 3, 1, __Value) #define SET_H2CCMD_MCC_CTRL_V2_DIS_SW_RETRY(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 4, 1, __Value) #define SET_H2CCMD_MCC_CTRL_V2_DISTXNULL(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 5, 1, __Value) diff --git a/include/hal_data.h b/include/hal_data.h index 28c81df..5a7425d 100755 --- a/include/hal_data.h +++ b/include/hal_data.h @@ -397,7 +397,7 @@ typedef struct hal_com_data { u16 ForcedDataRate; /* Force Data Rate. 0: Auto, 0x02: 1M ~ 0x6C: 54M. */ u8 bDumpRxPkt; u8 bDumpTxPkt; - u8 dis_turboedca; /* 1: disable turboedca, + u8 dis_turboedca; /* 1: disable turboedca, 2: disable turboedca and setting EDCA parameter based on the input parameter*/ u32 edca_param_mode; diff --git a/include/hal_intf.h b/include/hal_intf.h index 1859940..4afd001 100644 --- a/include/hal_intf.h +++ b/include/hal_intf.h @@ -373,7 +373,7 @@ struct hal_ops { void (*write_syson_reg)(_adapter *padapter, u32 RegAddr, u32 BitMask, u32 Data); #endif void (*read_wmmedca_reg)(_adapter *padapter, u16 *vo_params, u16 *vi_params, u16 *be_params, u16 *bk_params); - + #ifdef CONFIG_HOSTAPD_MLME s32(*hostap_mgnt_xmit_entry)(_adapter *padapter, _pkt *pkt); #endif @@ -583,9 +583,9 @@ typedef enum _HARDWARE_TYPE { #define IS_HARDWARE_TYPE_8192FS(_Adapter)\ (rtw_get_hw_type(_Adapter) == HARDWARE_TYPE_RTL8192FS) #define IS_HARDWARE_TYPE_8192FU(_Adapter)\ - (rtw_get_hw_type(_Adapter) == HARDWARE_TYPE_RTL8192FU) + (rtw_get_hw_type(_Adapter) == HARDWARE_TYPE_RTL8192FU) #define IS_HARDWARE_TYPE_8192FE(_Adapter)\ - (rtw_get_hw_type(_Adapter) == HARDWARE_TYPE_RTL8192FE) + (rtw_get_hw_type(_Adapter) == HARDWARE_TYPE_RTL8192FE) #define IS_HARDWARE_TYPE_8192F(_Adapter)\ (IS_HARDWARE_TYPE_8192FS(_Adapter) ||\ IS_HARDWARE_TYPE_8192FU(_Adapter) ||\ diff --git a/include/ieee80211.h b/include/ieee80211.h index 92dd317..3b5ce8f 100644 --- a/include/ieee80211.h +++ b/include/ieee80211.h @@ -741,7 +741,7 @@ struct ieee80211_snap_hdr { #define WLAN_REASON_MESH_MAX_PEERS 53 #define WLAN_REASON_MESH_CONFIG 54 #define WLAN_REASON_MESH_CLOSE 55 -#define WLAN_REASON_MESH_MAX_RETRIES 56 +#define WLAN_REASON_MESH_MAX_RETRIES 56 #define WLAN_REASON_MESH_CONFIRM_TIMEOUT 57 #define WLAN_REASON_MESH_INVALID_GTK 58 #define WLAN_REASON_MESH_INCONSISTENT_PARAM 59 diff --git a/include/osdep_service_bsd.h b/include/osdep_service_bsd.h index 4773f05..19b365e 100644 --- a/include/osdep_service_bsd.h +++ b/include/osdep_service_bsd.h @@ -12,653 +12,653 @@ * more details. * *****************************************************************************/ -#ifndef __OSDEP_BSD_SERVICE_H_ -#define __OSDEP_BSD_SERVICE_H_ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include "usbdevs.h" - -#define USB_DEBUG_VAR rum_debug -#include - -#if 1 //Baron porting from linux, it's all temp solution, needs to check again -#include -#include /* XXX for PCPU_GET */ -// typedef struct semaphore _sema; - typedef struct sema _sema; -// typedef spinlock_t _lock; - typedef struct mtx _lock; - typedef struct mtx _mutex; - typedef struct rtw_timer_list _timer; - struct list_head { - struct list_head *next, *prev; - }; - struct __queue { - struct list_head queue; - _lock lock; - }; - - typedef struct mbuf _pkt; - typedef struct mbuf _buffer; - - typedef struct __queue _queue; - typedef struct list_head _list; - typedef int _OS_STATUS; - //typedef u32 _irqL; - typedef unsigned long _irqL; - typedef struct ifnet * _nic_hdl; - - typedef pid_t _thread_hdl_; -// typedef struct thread _thread_hdl_; - typedef void thread_return; - typedef void* thread_context; - - typedef void timer_hdl_return; - typedef void* timer_hdl_context; - typedef struct work_struct _workitem; - -#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -/* emulate a modern version */ -#define LINUX_VERSION_CODE KERNEL_VERSION(2, 6, 35) - -#define WIRELESS_EXT -1 -#define HZ hz -#define spin_lock_irqsave mtx_lock_irqsave -#define spin_lock_bh mtx_lock_irqsave -#define mtx_lock_irqsave(lock, x) mtx_lock(lock)//{local_irq_save((x)); mtx_lock_spin((lock));} -//#define IFT_RTW 0xf9 //ifnet allocate type for RTW -#define free_netdev if_free -#define LIST_CONTAINOR(ptr, type, member) \ - ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member))) -#define container_of(p,t,n) (t*)((p)-&(((t*)0)->n)) -/* - * Linux timers are emulated using FreeBSD callout functions - * (and taskqueue functionality). - * - * Currently no timer stats functionality. - * - * See (linux_compat) processes.c - * - */ -struct rtw_timer_list { +#ifndef __OSDEP_BSD_SERVICE_H_ +#define __OSDEP_BSD_SERVICE_H_ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include "usbdevs.h" + +#define USB_DEBUG_VAR rum_debug +#include + +#if 1 //Baron porting from linux, it's all temp solution, needs to check again +#include +#include /* XXX for PCPU_GET */ +// typedef struct semaphore _sema; + typedef struct sema _sema; +// typedef spinlock_t _lock; + typedef struct mtx _lock; + typedef struct mtx _mutex; + typedef struct rtw_timer_list _timer; + struct list_head { + struct list_head *next, *prev; + }; + struct __queue { + struct list_head queue; + _lock lock; + }; + + typedef struct mbuf _pkt; + typedef struct mbuf _buffer; + + typedef struct __queue _queue; + typedef struct list_head _list; + typedef int _OS_STATUS; + //typedef u32 _irqL; + typedef unsigned long _irqL; + typedef struct ifnet * _nic_hdl; + + typedef pid_t _thread_hdl_; +// typedef struct thread _thread_hdl_; + typedef void thread_return; + typedef void* thread_context; + + typedef void timer_hdl_return; + typedef void* timer_hdl_context; + typedef struct work_struct _workitem; + +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +/* emulate a modern version */ +#define LINUX_VERSION_CODE KERNEL_VERSION(2, 6, 35) + +#define WIRELESS_EXT -1 +#define HZ hz +#define spin_lock_irqsave mtx_lock_irqsave +#define spin_lock_bh mtx_lock_irqsave +#define mtx_lock_irqsave(lock, x) mtx_lock(lock)//{local_irq_save((x)); mtx_lock_spin((lock));} +//#define IFT_RTW 0xf9 //ifnet allocate type for RTW +#define free_netdev if_free +#define LIST_CONTAINOR(ptr, type, member) \ + ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member))) +#define container_of(p,t,n) (t*)((p)-&(((t*)0)->n)) +/* + * Linux timers are emulated using FreeBSD callout functions + * (and taskqueue functionality). + * + * Currently no timer stats functionality. + * + * See (linux_compat) processes.c + * + */ +struct rtw_timer_list { struct callout callout; void (*function)(void *); void *arg; }; - -struct workqueue_struct; -struct work_struct; -typedef void (*work_func_t)(struct work_struct *work); -/* Values for the state of an item of work (work_struct) */ -typedef enum work_state { - WORK_STATE_UNSET = 0, - WORK_STATE_CALLOUT_PENDING = 1, - WORK_STATE_TASK_PENDING = 2, - WORK_STATE_WORK_CANCELLED = 3 -} work_state_t; - -struct work_struct { - struct task task; /* FreeBSD task */ - work_state_t state; /* the pending or otherwise state of work. */ - work_func_t func; -}; -#define spin_unlock_irqrestore mtx_unlock_irqrestore -#define spin_unlock_bh mtx_unlock_irqrestore -#define mtx_unlock_irqrestore(lock,x) mtx_unlock(lock); -extern void _rtw_spinlock_init(_lock *plock); - -//modify private structure to match freebsd -#define BITS_PER_LONG 32 -union ktime { - s64 tv64; -#if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR) - struct { -#ifdef __BIG_ENDIAN - s32 sec, nsec; -#else - s32 nsec, sec; -#endif - } tv; -#endif -}; -#define kmemcheck_bitfield_begin(name) -#define kmemcheck_bitfield_end(name) -#define CHECKSUM_NONE 0 -typedef unsigned char *sk_buff_data_t; -typedef union ktime ktime_t; /* Kill this */ - -void rtw_mtx_lock(_lock *plock); - -void rtw_mtx_unlock(_lock *plock); - -/** - * struct sk_buff - socket buffer - * @next: Next buffer in list - * @prev: Previous buffer in list - * @sk: Socket we are owned by - * @tstamp: Time we arrived - * @dev: Device we arrived on/are leaving by - * @transport_header: Transport layer header - * @network_header: Network layer header - * @mac_header: Link layer header - * @_skb_refdst: destination entry (with norefcount bit) - * @sp: the security path, used for xfrm - * @cb: Control buffer. Free for use by every layer. Put private vars here - * @len: Length of actual data - * @data_len: Data length - * @mac_len: Length of link layer header - * @hdr_len: writable header length of cloned skb - * @csum: Checksum (must include start/offset pair) - * @csum_start: Offset from skb->head where checksumming should start - * @csum_offset: Offset from csum_start where checksum should be stored - * @local_df: allow local fragmentation - * @cloned: Head may be cloned (check refcnt to be sure) - * @nohdr: Payload reference only, must not modify header - * @pkt_type: Packet class - * @fclone: skbuff clone status - * @ip_summed: Driver fed us an IP checksum - * @priority: Packet queueing priority - * @users: User count - see {datagram,tcp}.c - * @protocol: Packet protocol from driver - * @truesize: Buffer size - * @head: Head of buffer - * @data: Data head pointer - * @tail: Tail pointer - * @end: End pointer - * @destructor: Destruct function - * @mark: Generic packet mark - * @nfct: Associated connection, if any - * @ipvs_property: skbuff is owned by ipvs - * @peeked: this packet has been seen already, so stats have been - * done for it, don't do them again - * @nf_trace: netfilter packet trace flag - * @nfctinfo: Relationship of this skb to the connection - * @nfct_reasm: netfilter conntrack re-assembly pointer - * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c - * @skb_iif: ifindex of device we arrived on - * @rxhash: the packet hash computed on receive - * @queue_mapping: Queue mapping for multiqueue devices - * @tc_index: Traffic control index - * @tc_verd: traffic control verdict - * @ndisc_nodetype: router type (from link layer) - * @dma_cookie: a cookie to one of several possible DMA operations - * done by skb DMA functions - * @secmark: security marking - * @vlan_tci: vlan tag control information - */ - -struct sk_buff { - /* These two members must be first. */ - struct sk_buff *next; - struct sk_buff *prev; - - ktime_t tstamp; - - struct sock *sk; - //struct net_device *dev; - struct ifnet *dev; - - /* - * This is the control buffer. It is free to use for every - * layer. Please put your private variables there. If you - * want to keep them across layers you have to do a skb_clone() - * first. This is owned by whoever has the skb queued ATM. - */ - char cb[48] __aligned(8); - - unsigned long _skb_refdst; -#ifdef CONFIG_XFRM - struct sec_path *sp; -#endif - unsigned int len, - data_len; - u16 mac_len, - hdr_len; - union { - u32 csum; - struct { - u16 csum_start; - u16 csum_offset; - }smbol2; - }smbol1; - u32 priority; - kmemcheck_bitfield_begin(flags1); - u8 local_df:1, - cloned:1, - ip_summed:2, - nohdr:1, - nfctinfo:3; - u8 pkt_type:3, - fclone:2, - ipvs_property:1, - peeked:1, - nf_trace:1; - kmemcheck_bitfield_end(flags1); - u16 protocol; - - void (*destructor)(struct sk_buff *skb); -#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) - struct nf_conntrack *nfct; - struct sk_buff *nfct_reasm; -#endif -#ifdef CONFIG_BRIDGE_NETFILTER - struct nf_bridge_info *nf_bridge; -#endif - - int skb_iif; -#ifdef CONFIG_NET_SCHED - u16 tc_index; /* traffic control index */ -#ifdef CONFIG_NET_CLS_ACT - u16 tc_verd; /* traffic control verdict */ -#endif -#endif - - u32 rxhash; - - kmemcheck_bitfield_begin(flags2); - u16 queue_mapping:16; -#ifdef CONFIG_IPV6_NDISC_NODETYPE - u8 ndisc_nodetype:2, - deliver_no_wcard:1; -#else - u8 deliver_no_wcard:1; -#endif - kmemcheck_bitfield_end(flags2); - - /* 0/14 bit hole */ - -#ifdef CONFIG_NET_DMA - dma_cookie_t dma_cookie; -#endif -#ifdef CONFIG_NETWORK_SECMARK - u32 secmark; -#endif - union { - u32 mark; - u32 dropcount; - }symbol3; - - u16 vlan_tci; - - sk_buff_data_t transport_header; - sk_buff_data_t network_header; - sk_buff_data_t mac_header; - /* These elements must be at the end, see alloc_skb() for details. */ - sk_buff_data_t tail; - sk_buff_data_t end; - unsigned char *head, - *data; - unsigned int truesize; - atomic_t users; -}; -struct sk_buff_head { - /* These two members must be first. */ - struct sk_buff *next; - struct sk_buff *prev; - - u32 qlen; - _lock lock; -}; -#define skb_tail_pointer(skb) skb->tail -static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len) -{ - unsigned char *tmp = skb_tail_pointer(skb); - //SKB_LINEAR_ASSERT(skb); - skb->tail += len; - skb->len += len; - return tmp; -} - -static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len) -{ - skb->len -= len; - if(skb->len < skb->data_len) - printf("%s(),%d,error!\n",__FUNCTION__,__LINE__); - return skb->data += len; -} -static inline unsigned char *skb_pull(struct sk_buff *skb, unsigned int len) -{ - #ifdef PLATFORM_FREEBSD - return __skb_pull(skb, len); - #else - return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); - #endif //PLATFORM_FREEBSD -} -static inline u32 skb_queue_len(const struct sk_buff_head *list_) -{ - return list_->qlen; -} -static inline void __skb_insert(struct sk_buff *newsk, - struct sk_buff *prev, struct sk_buff *next, - struct sk_buff_head *list) -{ - newsk->next = next; - newsk->prev = prev; - next->prev = prev->next = newsk; - list->qlen++; -} -static inline void __skb_queue_before(struct sk_buff_head *list, - struct sk_buff *next, - struct sk_buff *newsk) -{ - __skb_insert(newsk, next->prev, next, list); -} -static inline void skb_queue_tail(struct sk_buff_head *list, - struct sk_buff *newsk) -{ - mtx_lock(&list->lock); - __skb_queue_before(list, (struct sk_buff *)list, newsk); - mtx_unlock(&list->lock); -} -static inline struct sk_buff *skb_peek(struct sk_buff_head *list_) -{ - struct sk_buff *list = ((struct sk_buff *)list_)->next; - if (list == (struct sk_buff *)list_) - list = NULL; - return list; -} -static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) -{ - struct sk_buff *next, *prev; - - list->qlen--; - next = skb->next; - prev = skb->prev; - skb->next = skb->prev = NULL; - next->prev = prev; - prev->next = next; -} - -static inline struct sk_buff *skb_dequeue(struct sk_buff_head *list) -{ - mtx_lock(&list->lock); - - struct sk_buff *skb = skb_peek(list); - if (skb) - __skb_unlink(skb, list); - - mtx_unlock(&list->lock); - - return skb; -} -static inline void skb_reserve(struct sk_buff *skb, int len) -{ - skb->data += len; - skb->tail += len; -} -static inline void __skb_queue_head_init(struct sk_buff_head *list) -{ - list->prev = list->next = (struct sk_buff *)list; - list->qlen = 0; -} -/* - * This function creates a split out lock class for each invocation; - * this is needed for now since a whole lot of users of the skb-queue - * infrastructure in drivers have different locking usage (in hardirq) - * than the networking core (in softirq only). In the long run either the - * network layer or drivers should need annotation to consolidate the - * main types of usage into 3 classes. - */ -static inline void skb_queue_head_init(struct sk_buff_head *list) -{ - _rtw_spinlock_init(&list->lock); - __skb_queue_head_init(list); -} -unsigned long copy_from_user(void *to, const void *from, unsigned long n); -unsigned long copy_to_user(void *to, const void *from, unsigned long n); -struct sk_buff * dev_alloc_skb(unsigned int size); -struct sk_buff *skb_clone(const struct sk_buff *skb); -void dev_kfree_skb_any(struct sk_buff *skb); -#endif //Baron porting from linux, it's all temp solution, needs to check again - - -#if 1 // kenny add Linux compatibility code for Linux USB driver -#include - -#define __init // __attribute ((constructor)) -#define __exit // __attribute ((destructor)) - -/* - * Definitions for module_init and module_exit macros. - * - * These macros will use the SYSINIT framework to call a specified - * function (with no arguments) on module loading or unloading. - * - */ - -void module_init_exit_wrapper(void *arg); - -#define module_init(initfn) \ - SYSINIT(mod_init_ ## initfn, \ - SI_SUB_KLD, SI_ORDER_FIRST, \ - module_init_exit_wrapper, initfn) - -#define module_exit(exitfn) \ - SYSUNINIT(mod_exit_ ## exitfn, \ - SI_SUB_KLD, SI_ORDER_ANY, \ - module_init_exit_wrapper, exitfn) - -/* - * The usb_register and usb_deregister functions are used to register - * usb drivers with the usb subsystem. - */ -int usb_register(struct usb_driver *driver); -int usb_deregister(struct usb_driver *driver); - -/* - * usb_get_dev and usb_put_dev - increment/decrement the reference count - * of the usb device structure. - * - * Original body of usb_get_dev: - * - * if (dev) - * get_device(&dev->dev); - * return dev; - * - * Reference counts are not currently used in this compatibility - * layer. So these functions will do nothing. - */ -static inline struct usb_device * -usb_get_dev(struct usb_device *dev) -{ - return dev; -} - -static inline void -usb_put_dev(struct usb_device *dev) -{ - return; -} - - -// rtw_usb_compat_linux -int rtw_usb_submit_urb(struct urb *urb, uint16_t mem_flags); -int rtw_usb_unlink_urb(struct urb *urb); -int rtw_usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe); -int rtw_usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *uhe, - uint8_t request, uint8_t requesttype, - uint16_t value, uint16_t index, void *data, - uint16_t size, usb_timeout_t timeout); -int rtw_usb_set_interface(struct usb_device *dev, uint8_t iface_no, uint8_t alt_index); -int rtw_usb_setup_endpoint(struct usb_device *dev, - struct usb_host_endpoint *uhe, usb_size_t bufsize); -struct urb *rtw_usb_alloc_urb(uint16_t iso_packets, uint16_t mem_flags); -struct usb_host_endpoint *rtw_usb_find_host_endpoint(struct usb_device *dev, uint8_t type, uint8_t ep); -struct usb_host_interface *rtw_usb_altnum_to_altsetting(const struct usb_interface *intf, uint8_t alt_index); -struct usb_interface *rtw_usb_ifnum_to_if(struct usb_device *dev, uint8_t iface_no); -void *rtw_usbd_get_intfdata(struct usb_interface *intf); -void rtw_usb_linux_register(void *arg); -void rtw_usb_linux_deregister(void *arg); -void rtw_usb_linux_free_device(struct usb_device *dev); -void rtw_usb_free_urb(struct urb *urb); -void rtw_usb_init_urb(struct urb *urb); -void rtw_usb_kill_urb(struct urb *urb); -void rtw_usb_set_intfdata(struct usb_interface *intf, void *data); -void rtw_usb_fill_bulk_urb(struct urb *urb, struct usb_device *udev, - struct usb_host_endpoint *uhe, void *buf, - int length, usb_complete_t callback, void *arg); -int rtw_usb_bulk_msg(struct usb_device *udev, struct usb_host_endpoint *uhe, - void *data, int len, uint16_t *pactlen, usb_timeout_t timeout); -void *usb_get_intfdata(struct usb_interface *intf); -int usb_linux_init_endpoints(struct usb_device *udev); - - - -typedef struct urb * PURB; - -typedef unsigned gfp_t; -#define __GFP_WAIT ((gfp_t)0x10u) /* Can wait and reschedule? */ -#define __GFP_HIGH ((gfp_t)0x20u) /* Should access emergency pools? */ -#define __GFP_IO ((gfp_t)0x40u) /* Can start physical IO? */ -#define __GFP_FS ((gfp_t)0x80u) /* Can call down to low-level FS? */ -#define __GFP_COLD ((gfp_t)0x100u) /* Cache-cold page required */ -#define __GFP_NOWARN ((gfp_t)0x200u) /* Suppress page allocation failure warning */ -#define __GFP_REPEAT ((gfp_t)0x400u) /* Retry the allocation. Might fail */ -#define __GFP_NOFAIL ((gfp_t)0x800u) /* Retry for ever. Cannot fail */ -#define __GFP_NORETRY ((gfp_t)0x1000u)/* Do not retry. Might fail */ -#define __GFP_NO_GROW ((gfp_t)0x2000u)/* Slab internal usage */ -#define __GFP_COMP ((gfp_t)0x4000u)/* Add compound page metadata */ -#define __GFP_ZERO ((gfp_t)0x8000u)/* Return zeroed page on success */ -#define __GFP_NOMEMALLOC ((gfp_t)0x10000u) /* Don't use emergency reserves */ -#define __GFP_HARDWALL ((gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */ - -/* This equals 0, but use constants in case they ever change */ -#define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH) -/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ -#define GFP_ATOMIC (__GFP_HIGH) -#define GFP_NOIO (__GFP_WAIT) -#define GFP_NOFS (__GFP_WAIT | __GFP_IO) -#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) -#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL) -#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \ - __GFP_HIGHMEM) - - -#endif // kenny add Linux compatibility code for Linux USB - -__inline static _list *get_next(_list *list) -{ - return list->next; -} - -__inline static _list *get_list_head(_queue *queue) -{ - return (&(queue->queue)); -} - - -#define LIST_CONTAINOR(ptr, type, member) \ - ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member))) - - -__inline static void _enter_critical(_lock *plock, _irqL *pirqL) -{ - spin_lock_irqsave(plock, *pirqL); -} - -__inline static void _exit_critical(_lock *plock, _irqL *pirqL) -{ - spin_unlock_irqrestore(plock, *pirqL); -} - -__inline static void _enter_critical_ex(_lock *plock, _irqL *pirqL) -{ - spin_lock_irqsave(plock, *pirqL); -} - -__inline static void _exit_critical_ex(_lock *plock, _irqL *pirqL) -{ - spin_unlock_irqrestore(plock, *pirqL); -} - -__inline static void _enter_critical_bh(_lock *plock, _irqL *pirqL) -{ - spin_lock_bh(plock, *pirqL); -} - -__inline static void _exit_critical_bh(_lock *plock, _irqL *pirqL) -{ - spin_unlock_bh(plock, *pirqL); -} - -__inline static void _enter_critical_mutex(_mutex *pmutex, _irqL *pirqL) -{ - - mtx_lock(pmutex); - -} - - -__inline static void _exit_critical_mutex(_mutex *pmutex, _irqL *pirqL) -{ - - mtx_unlock(pmutex); - -} -static inline void __list_del(struct list_head * prev, struct list_head * next) -{ - next->prev = prev; - prev->next = next; -} -static inline void INIT_LIST_HEAD(struct list_head *list) -{ - list->next = list; - list->prev = list; -} -__inline static void rtw_list_delete(_list *plist) -{ - __list_del(plist->prev, plist->next); - INIT_LIST_HEAD(plist); -} - + +struct workqueue_struct; +struct work_struct; +typedef void (*work_func_t)(struct work_struct *work); +/* Values for the state of an item of work (work_struct) */ +typedef enum work_state { + WORK_STATE_UNSET = 0, + WORK_STATE_CALLOUT_PENDING = 1, + WORK_STATE_TASK_PENDING = 2, + WORK_STATE_WORK_CANCELLED = 3 +} work_state_t; + +struct work_struct { + struct task task; /* FreeBSD task */ + work_state_t state; /* the pending or otherwise state of work. */ + work_func_t func; +}; +#define spin_unlock_irqrestore mtx_unlock_irqrestore +#define spin_unlock_bh mtx_unlock_irqrestore +#define mtx_unlock_irqrestore(lock,x) mtx_unlock(lock); +extern void _rtw_spinlock_init(_lock *plock); + +//modify private structure to match freebsd +#define BITS_PER_LONG 32 +union ktime { + s64 tv64; +#if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR) + struct { +#ifdef __BIG_ENDIAN + s32 sec, nsec; +#else + s32 nsec, sec; +#endif + } tv; +#endif +}; +#define kmemcheck_bitfield_begin(name) +#define kmemcheck_bitfield_end(name) +#define CHECKSUM_NONE 0 +typedef unsigned char *sk_buff_data_t; +typedef union ktime ktime_t; /* Kill this */ + +void rtw_mtx_lock(_lock *plock); + +void rtw_mtx_unlock(_lock *plock); + +/** + * struct sk_buff - socket buffer + * @next: Next buffer in list + * @prev: Previous buffer in list + * @sk: Socket we are owned by + * @tstamp: Time we arrived + * @dev: Device we arrived on/are leaving by + * @transport_header: Transport layer header + * @network_header: Network layer header + * @mac_header: Link layer header + * @_skb_refdst: destination entry (with norefcount bit) + * @sp: the security path, used for xfrm + * @cb: Control buffer. Free for use by every layer. Put private vars here + * @len: Length of actual data + * @data_len: Data length + * @mac_len: Length of link layer header + * @hdr_len: writable header length of cloned skb + * @csum: Checksum (must include start/offset pair) + * @csum_start: Offset from skb->head where checksumming should start + * @csum_offset: Offset from csum_start where checksum should be stored + * @local_df: allow local fragmentation + * @cloned: Head may be cloned (check refcnt to be sure) + * @nohdr: Payload reference only, must not modify header + * @pkt_type: Packet class + * @fclone: skbuff clone status + * @ip_summed: Driver fed us an IP checksum + * @priority: Packet queueing priority + * @users: User count - see {datagram,tcp}.c + * @protocol: Packet protocol from driver + * @truesize: Buffer size + * @head: Head of buffer + * @data: Data head pointer + * @tail: Tail pointer + * @end: End pointer + * @destructor: Destruct function + * @mark: Generic packet mark + * @nfct: Associated connection, if any + * @ipvs_property: skbuff is owned by ipvs + * @peeked: this packet has been seen already, so stats have been + * done for it, don't do them again + * @nf_trace: netfilter packet trace flag + * @nfctinfo: Relationship of this skb to the connection + * @nfct_reasm: netfilter conntrack re-assembly pointer + * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c + * @skb_iif: ifindex of device we arrived on + * @rxhash: the packet hash computed on receive + * @queue_mapping: Queue mapping for multiqueue devices + * @tc_index: Traffic control index + * @tc_verd: traffic control verdict + * @ndisc_nodetype: router type (from link layer) + * @dma_cookie: a cookie to one of several possible DMA operations + * done by skb DMA functions + * @secmark: security marking + * @vlan_tci: vlan tag control information + */ + +struct sk_buff { + /* These two members must be first. */ + struct sk_buff *next; + struct sk_buff *prev; + + ktime_t tstamp; + + struct sock *sk; + //struct net_device *dev; + struct ifnet *dev; + + /* + * This is the control buffer. It is free to use for every + * layer. Please put your private variables there. If you + * want to keep them across layers you have to do a skb_clone() + * first. This is owned by whoever has the skb queued ATM. + */ + char cb[48] __aligned(8); + + unsigned long _skb_refdst; +#ifdef CONFIG_XFRM + struct sec_path *sp; +#endif + unsigned int len, + data_len; + u16 mac_len, + hdr_len; + union { + u32 csum; + struct { + u16 csum_start; + u16 csum_offset; + }smbol2; + }smbol1; + u32 priority; + kmemcheck_bitfield_begin(flags1); + u8 local_df:1, + cloned:1, + ip_summed:2, + nohdr:1, + nfctinfo:3; + u8 pkt_type:3, + fclone:2, + ipvs_property:1, + peeked:1, + nf_trace:1; + kmemcheck_bitfield_end(flags1); + u16 protocol; + + void (*destructor)(struct sk_buff *skb); +#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) + struct nf_conntrack *nfct; + struct sk_buff *nfct_reasm; +#endif +#ifdef CONFIG_BRIDGE_NETFILTER + struct nf_bridge_info *nf_bridge; +#endif + + int skb_iif; +#ifdef CONFIG_NET_SCHED + u16 tc_index; /* traffic control index */ +#ifdef CONFIG_NET_CLS_ACT + u16 tc_verd; /* traffic control verdict */ +#endif +#endif + + u32 rxhash; + + kmemcheck_bitfield_begin(flags2); + u16 queue_mapping:16; +#ifdef CONFIG_IPV6_NDISC_NODETYPE + u8 ndisc_nodetype:2, + deliver_no_wcard:1; +#else + u8 deliver_no_wcard:1; +#endif + kmemcheck_bitfield_end(flags2); + + /* 0/14 bit hole */ + +#ifdef CONFIG_NET_DMA + dma_cookie_t dma_cookie; +#endif +#ifdef CONFIG_NETWORK_SECMARK + u32 secmark; +#endif + union { + u32 mark; + u32 dropcount; + }symbol3; + + u16 vlan_tci; + + sk_buff_data_t transport_header; + sk_buff_data_t network_header; + sk_buff_data_t mac_header; + /* These elements must be at the end, see alloc_skb() for details. */ + sk_buff_data_t tail; + sk_buff_data_t end; + unsigned char *head, + *data; + unsigned int truesize; + atomic_t users; +}; +struct sk_buff_head { + /* These two members must be first. */ + struct sk_buff *next; + struct sk_buff *prev; + + u32 qlen; + _lock lock; +}; +#define skb_tail_pointer(skb) skb->tail +static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len) +{ + unsigned char *tmp = skb_tail_pointer(skb); + //SKB_LINEAR_ASSERT(skb); + skb->tail += len; + skb->len += len; + return tmp; +} + +static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len) +{ + skb->len -= len; + if(skb->len < skb->data_len) + printf("%s(),%d,error!\n",__FUNCTION__,__LINE__); + return skb->data += len; +} +static inline unsigned char *skb_pull(struct sk_buff *skb, unsigned int len) +{ + #ifdef PLATFORM_FREEBSD + return __skb_pull(skb, len); + #else + return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); + #endif //PLATFORM_FREEBSD +} +static inline u32 skb_queue_len(const struct sk_buff_head *list_) +{ + return list_->qlen; +} +static inline void __skb_insert(struct sk_buff *newsk, + struct sk_buff *prev, struct sk_buff *next, + struct sk_buff_head *list) +{ + newsk->next = next; + newsk->prev = prev; + next->prev = prev->next = newsk; + list->qlen++; +} +static inline void __skb_queue_before(struct sk_buff_head *list, + struct sk_buff *next, + struct sk_buff *newsk) +{ + __skb_insert(newsk, next->prev, next, list); +} +static inline void skb_queue_tail(struct sk_buff_head *list, + struct sk_buff *newsk) +{ + mtx_lock(&list->lock); + __skb_queue_before(list, (struct sk_buff *)list, newsk); + mtx_unlock(&list->lock); +} +static inline struct sk_buff *skb_peek(struct sk_buff_head *list_) +{ + struct sk_buff *list = ((struct sk_buff *)list_)->next; + if (list == (struct sk_buff *)list_) + list = NULL; + return list; +} +static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) +{ + struct sk_buff *next, *prev; + + list->qlen--; + next = skb->next; + prev = skb->prev; + skb->next = skb->prev = NULL; + next->prev = prev; + prev->next = next; +} + +static inline struct sk_buff *skb_dequeue(struct sk_buff_head *list) +{ + mtx_lock(&list->lock); + + struct sk_buff *skb = skb_peek(list); + if (skb) + __skb_unlink(skb, list); + + mtx_unlock(&list->lock); + + return skb; +} +static inline void skb_reserve(struct sk_buff *skb, int len) +{ + skb->data += len; + skb->tail += len; +} +static inline void __skb_queue_head_init(struct sk_buff_head *list) +{ + list->prev = list->next = (struct sk_buff *)list; + list->qlen = 0; +} +/* + * This function creates a split out lock class for each invocation; + * this is needed for now since a whole lot of users of the skb-queue + * infrastructure in drivers have different locking usage (in hardirq) + * than the networking core (in softirq only). In the long run either the + * network layer or drivers should need annotation to consolidate the + * main types of usage into 3 classes. + */ +static inline void skb_queue_head_init(struct sk_buff_head *list) +{ + _rtw_spinlock_init(&list->lock); + __skb_queue_head_init(list); +} +unsigned long copy_from_user(void *to, const void *from, unsigned long n); +unsigned long copy_to_user(void *to, const void *from, unsigned long n); +struct sk_buff * dev_alloc_skb(unsigned int size); +struct sk_buff *skb_clone(const struct sk_buff *skb); +void dev_kfree_skb_any(struct sk_buff *skb); +#endif //Baron porting from linux, it's all temp solution, needs to check again + + +#if 1 // kenny add Linux compatibility code for Linux USB driver +#include + +#define __init // __attribute ((constructor)) +#define __exit // __attribute ((destructor)) + +/* + * Definitions for module_init and module_exit macros. + * + * These macros will use the SYSINIT framework to call a specified + * function (with no arguments) on module loading or unloading. + * + */ + +void module_init_exit_wrapper(void *arg); + +#define module_init(initfn) \ + SYSINIT(mod_init_ ## initfn, \ + SI_SUB_KLD, SI_ORDER_FIRST, \ + module_init_exit_wrapper, initfn) + +#define module_exit(exitfn) \ + SYSUNINIT(mod_exit_ ## exitfn, \ + SI_SUB_KLD, SI_ORDER_ANY, \ + module_init_exit_wrapper, exitfn) + +/* + * The usb_register and usb_deregister functions are used to register + * usb drivers with the usb subsystem. + */ +int usb_register(struct usb_driver *driver); +int usb_deregister(struct usb_driver *driver); + +/* + * usb_get_dev and usb_put_dev - increment/decrement the reference count + * of the usb device structure. + * + * Original body of usb_get_dev: + * + * if (dev) + * get_device(&dev->dev); + * return dev; + * + * Reference counts are not currently used in this compatibility + * layer. So these functions will do nothing. + */ +static inline struct usb_device * +usb_get_dev(struct usb_device *dev) +{ + return dev; +} + +static inline void +usb_put_dev(struct usb_device *dev) +{ + return; +} + + +// rtw_usb_compat_linux +int rtw_usb_submit_urb(struct urb *urb, uint16_t mem_flags); +int rtw_usb_unlink_urb(struct urb *urb); +int rtw_usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe); +int rtw_usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *uhe, + uint8_t request, uint8_t requesttype, + uint16_t value, uint16_t index, void *data, + uint16_t size, usb_timeout_t timeout); +int rtw_usb_set_interface(struct usb_device *dev, uint8_t iface_no, uint8_t alt_index); +int rtw_usb_setup_endpoint(struct usb_device *dev, + struct usb_host_endpoint *uhe, usb_size_t bufsize); +struct urb *rtw_usb_alloc_urb(uint16_t iso_packets, uint16_t mem_flags); +struct usb_host_endpoint *rtw_usb_find_host_endpoint(struct usb_device *dev, uint8_t type, uint8_t ep); +struct usb_host_interface *rtw_usb_altnum_to_altsetting(const struct usb_interface *intf, uint8_t alt_index); +struct usb_interface *rtw_usb_ifnum_to_if(struct usb_device *dev, uint8_t iface_no); +void *rtw_usbd_get_intfdata(struct usb_interface *intf); +void rtw_usb_linux_register(void *arg); +void rtw_usb_linux_deregister(void *arg); +void rtw_usb_linux_free_device(struct usb_device *dev); +void rtw_usb_free_urb(struct urb *urb); +void rtw_usb_init_urb(struct urb *urb); +void rtw_usb_kill_urb(struct urb *urb); +void rtw_usb_set_intfdata(struct usb_interface *intf, void *data); +void rtw_usb_fill_bulk_urb(struct urb *urb, struct usb_device *udev, + struct usb_host_endpoint *uhe, void *buf, + int length, usb_complete_t callback, void *arg); +int rtw_usb_bulk_msg(struct usb_device *udev, struct usb_host_endpoint *uhe, + void *data, int len, uint16_t *pactlen, usb_timeout_t timeout); +void *usb_get_intfdata(struct usb_interface *intf); +int usb_linux_init_endpoints(struct usb_device *udev); + + + +typedef struct urb * PURB; + +typedef unsigned gfp_t; +#define __GFP_WAIT ((gfp_t)0x10u) /* Can wait and reschedule? */ +#define __GFP_HIGH ((gfp_t)0x20u) /* Should access emergency pools? */ +#define __GFP_IO ((gfp_t)0x40u) /* Can start physical IO? */ +#define __GFP_FS ((gfp_t)0x80u) /* Can call down to low-level FS? */ +#define __GFP_COLD ((gfp_t)0x100u) /* Cache-cold page required */ +#define __GFP_NOWARN ((gfp_t)0x200u) /* Suppress page allocation failure warning */ +#define __GFP_REPEAT ((gfp_t)0x400u) /* Retry the allocation. Might fail */ +#define __GFP_NOFAIL ((gfp_t)0x800u) /* Retry for ever. Cannot fail */ +#define __GFP_NORETRY ((gfp_t)0x1000u)/* Do not retry. Might fail */ +#define __GFP_NO_GROW ((gfp_t)0x2000u)/* Slab internal usage */ +#define __GFP_COMP ((gfp_t)0x4000u)/* Add compound page metadata */ +#define __GFP_ZERO ((gfp_t)0x8000u)/* Return zeroed page on success */ +#define __GFP_NOMEMALLOC ((gfp_t)0x10000u) /* Don't use emergency reserves */ +#define __GFP_HARDWALL ((gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */ + +/* This equals 0, but use constants in case they ever change */ +#define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH) +/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ +#define GFP_ATOMIC (__GFP_HIGH) +#define GFP_NOIO (__GFP_WAIT) +#define GFP_NOFS (__GFP_WAIT | __GFP_IO) +#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) +#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL) +#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \ + __GFP_HIGHMEM) + + +#endif // kenny add Linux compatibility code for Linux USB + +__inline static _list *get_next(_list *list) +{ + return list->next; +} + +__inline static _list *get_list_head(_queue *queue) +{ + return (&(queue->queue)); +} + + +#define LIST_CONTAINOR(ptr, type, member) \ + ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member))) + + +__inline static void _enter_critical(_lock *plock, _irqL *pirqL) +{ + spin_lock_irqsave(plock, *pirqL); +} + +__inline static void _exit_critical(_lock *plock, _irqL *pirqL) +{ + spin_unlock_irqrestore(plock, *pirqL); +} + +__inline static void _enter_critical_ex(_lock *plock, _irqL *pirqL) +{ + spin_lock_irqsave(plock, *pirqL); +} + +__inline static void _exit_critical_ex(_lock *plock, _irqL *pirqL) +{ + spin_unlock_irqrestore(plock, *pirqL); +} + +__inline static void _enter_critical_bh(_lock *plock, _irqL *pirqL) +{ + spin_lock_bh(plock, *pirqL); +} + +__inline static void _exit_critical_bh(_lock *plock, _irqL *pirqL) +{ + spin_unlock_bh(plock, *pirqL); +} + +__inline static void _enter_critical_mutex(_mutex *pmutex, _irqL *pirqL) +{ + + mtx_lock(pmutex); + +} + + +__inline static void _exit_critical_mutex(_mutex *pmutex, _irqL *pirqL) +{ + + mtx_unlock(pmutex); + +} +static inline void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} +static inline void INIT_LIST_HEAD(struct list_head *list) +{ + list->next = list; + list->prev = list; +} +__inline static void rtw_list_delete(_list *plist) +{ + __list_del(plist->prev, plist->next); + INIT_LIST_HEAD(plist); +} + static inline void timer_hdl(void *ctx) { _timer *timer = (_timer *)ctx; @@ -690,67 +690,67 @@ static inline void _init_timer(_timer *ptimer, _nic_hdl padapter, void *pfunc, v callout_init(&ptimer->callout, CALLOUT_MPSAFE); } -__inline static void _set_timer(_timer *ptimer,u32 delay_time) -{ +__inline static void _set_timer(_timer *ptimer,u32 delay_time) +{ if (ptimer->function && ptimer->arg) { - rtw_mtx_lock(NULL); + rtw_mtx_lock(NULL); callout_reset(&ptimer->callout, delay_time, timer_hdl, ptimer); - rtw_mtx_unlock(NULL); - } -} - -__inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled) -{ - rtw_mtx_lock(NULL); - callout_drain(&ptimer->callout); - rtw_mtx_unlock(NULL); + rtw_mtx_unlock(NULL); + } +} + +__inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled) +{ + rtw_mtx_lock(NULL); + callout_drain(&ptimer->callout); + rtw_mtx_unlock(NULL); *bcancelled = 1; /* assume an pending timer to be canceled */ -} - -__inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx) -{ - printf("%s Not implement yet! \n",__FUNCTION__); -} - -__inline static void _set_workitem(_workitem *pwork) -{ - printf("%s Not implement yet! \n",__FUNCTION__); -// schedule_work(pwork); -} - -// -// Global Mutex: can only be used at PASSIVE level. -// - -#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ -{ \ -} - -#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ -{ \ -} - -#define ATOMIC_INIT(i) { (i) } - -static __inline void thread_enter(char *name); - -//Atomic integer operations -typedef uint32_t ATOMIC_T ; - -#define rtw_netdev_priv(netdev) (((struct ifnet *)netdev)->if_softc) - -#define rtw_free_netdev(netdev) if_free((netdev)) - -#define NDEV_FMT "%s" -#define NDEV_ARG(ndev) "" -#define ADPT_FMT "%s" -#define ADPT_ARG(adapter) "" -#define FUNC_NDEV_FMT "%s" -#define FUNC_NDEV_ARG(ndev) __func__ -#define FUNC_ADPT_FMT "%s" -#define FUNC_ADPT_ARG(adapter) __func__ - -#define STRUCT_PACKED - -#endif - +} + +__inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx) +{ + printf("%s Not implement yet! \n",__FUNCTION__); +} + +__inline static void _set_workitem(_workitem *pwork) +{ + printf("%s Not implement yet! \n",__FUNCTION__); +// schedule_work(pwork); +} + +// +// Global Mutex: can only be used at PASSIVE level. +// + +#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ +} + +#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ +} + +#define ATOMIC_INIT(i) { (i) } + +static __inline void thread_enter(char *name); + +//Atomic integer operations +typedef uint32_t ATOMIC_T ; + +#define rtw_netdev_priv(netdev) (((struct ifnet *)netdev)->if_softc) + +#define rtw_free_netdev(netdev) if_free((netdev)) + +#define NDEV_FMT "%s" +#define NDEV_ARG(ndev) "" +#define ADPT_FMT "%s" +#define ADPT_ARG(adapter) "" +#define FUNC_NDEV_FMT "%s" +#define FUNC_NDEV_ARG(ndev) __func__ +#define FUNC_ADPT_FMT "%s" +#define FUNC_ADPT_ARG(adapter) __func__ + +#define STRUCT_PACKED + +#endif + diff --git a/include/osdep_service_ce.h b/include/osdep_service_ce.h index a406d62..ce4013d 100644 --- a/include/osdep_service_ce.h +++ b/include/osdep_service_ce.h @@ -12,113 +12,113 @@ * more details. * *****************************************************************************/ - -#ifndef __OSDEP_CE_SERVICE_H_ -#define __OSDEP_CE_SERVICE_H_ - - -#include -#include - -#ifdef CONFIG_SDIO_HCI -#include "SDCardDDK.h" -#endif - -#ifdef CONFIG_USB_HCI -#include -#endif - -typedef HANDLE _sema; -typedef LIST_ENTRY _list; -typedef NDIS_STATUS _OS_STATUS; - -typedef NDIS_SPIN_LOCK _lock; - -typedef HANDLE _rwlock; //Mutex - -typedef u32 _irqL; - -typedef NDIS_HANDLE _nic_hdl; - + +#ifndef __OSDEP_CE_SERVICE_H_ +#define __OSDEP_CE_SERVICE_H_ + + +#include +#include + +#ifdef CONFIG_SDIO_HCI +#include "SDCardDDK.h" +#endif + +#ifdef CONFIG_USB_HCI +#include +#endif + +typedef HANDLE _sema; +typedef LIST_ENTRY _list; +typedef NDIS_STATUS _OS_STATUS; + +typedef NDIS_SPIN_LOCK _lock; + +typedef HANDLE _rwlock; //Mutex + +typedef u32 _irqL; + +typedef NDIS_HANDLE _nic_hdl; + struct rtw_timer_list { NDIS_MINIPORT_TIMER ndis_timer; void (*function)(void *); void *arg; }; - -struct __queue { - LIST_ENTRY queue; - _lock lock; -}; - -typedef NDIS_PACKET _pkt; -typedef NDIS_BUFFER _buffer; -typedef struct __queue _queue; - -typedef HANDLE _thread_hdl_; -typedef DWORD thread_return; -typedef void* thread_context; -typedef NDIS_WORK_ITEM _workitem; - - -#define SEMA_UPBND (0x7FFFFFFF) //8192 - -__inline static _list *get_prev(_list *list) -{ - return list->Blink; -} - -__inline static _list *get_next(_list *list) -{ - return list->Flink; -} - -__inline static _list *get_list_head(_queue *queue) -{ - return (&(queue->queue)); -} - -#define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member) - -__inline static void _enter_critical(_lock *plock, _irqL *pirqL) -{ - NdisAcquireSpinLock(plock); -} - -__inline static void _exit_critical(_lock *plock, _irqL *pirqL) -{ - NdisReleaseSpinLock(plock); -} - -__inline static _enter_critical_ex(_lock *plock, _irqL *pirqL) -{ - NdisDprAcquireSpinLock(plock); -} - -__inline static _exit_critical_ex(_lock *plock, _irqL *pirqL) -{ - NdisDprReleaseSpinLock(plock); -} - - -__inline static void _enter_hwio_critical(_rwlock *prwlock, _irqL *pirqL) -{ - WaitForSingleObject(*prwlock, INFINITE ); - -} - -__inline static void _exit_hwio_critical(_rwlock *prwlock, _irqL *pirqL) -{ - ReleaseMutex(*prwlock); -} - -__inline static void rtw_list_delete(_list *plist) -{ - RemoveEntryList(plist); - InitializeListHead(plist); -} - +struct __queue { + LIST_ENTRY queue; + _lock lock; +}; + +typedef NDIS_PACKET _pkt; +typedef NDIS_BUFFER _buffer; +typedef struct __queue _queue; + +typedef HANDLE _thread_hdl_; +typedef DWORD thread_return; +typedef void* thread_context; +typedef NDIS_WORK_ITEM _workitem; + + + +#define SEMA_UPBND (0x7FFFFFFF) //8192 + +__inline static _list *get_prev(_list *list) +{ + return list->Blink; +} + +__inline static _list *get_next(_list *list) +{ + return list->Flink; +} + +__inline static _list *get_list_head(_queue *queue) +{ + return (&(queue->queue)); +} + +#define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member) + +__inline static void _enter_critical(_lock *plock, _irqL *pirqL) +{ + NdisAcquireSpinLock(plock); +} + +__inline static void _exit_critical(_lock *plock, _irqL *pirqL) +{ + NdisReleaseSpinLock(plock); +} + +__inline static _enter_critical_ex(_lock *plock, _irqL *pirqL) +{ + NdisDprAcquireSpinLock(plock); +} + +__inline static _exit_critical_ex(_lock *plock, _irqL *pirqL) +{ + NdisDprReleaseSpinLock(plock); +} + + +__inline static void _enter_hwio_critical(_rwlock *prwlock, _irqL *pirqL) +{ + WaitForSingleObject(*prwlock, INFINITE ); + +} + +__inline static void _exit_hwio_critical(_rwlock *prwlock, _irqL *pirqL) +{ + ReleaseMutex(*prwlock); +} + +__inline static void rtw_list_delete(_list *plist) +{ + RemoveEntryList(plist); + InitializeListHead(plist); +} + static inline void timer_hdl( IN PVOID SystemSpecific1, IN PVOID FunctionContext, @@ -146,55 +146,55 @@ static inline void _cancel_timer(_timer *ptimer, u8 *bcancelled) { NdisMCancelTimer(ptimer, bcancelled); } - -__inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx) -{ - - NdisInitializeWorkItem(pwork, pfunc, cntx); -} - -__inline static void _set_workitem(_workitem *pwork) -{ - NdisScheduleWorkItem(pwork); -} - -#define ATOMIC_INIT(i) { (i) } - -// -// Global Mutex: can only be used at PASSIVE level. -// - -#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ -{ \ - while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\ - { \ - NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \ - NdisMSleep(10000); \ - } \ -} - -#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ -{ \ - NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \ -} - -// limitation of path length -#define PATH_LENGTH_MAX MAX_PATH - -//Atomic integer operations -#define ATOMIC_T LONG - -#define NDEV_FMT "%s" -#define NDEV_ARG(ndev) "" -#define ADPT_FMT "%s" -#define ADPT_ARG(adapter) "" -#define FUNC_NDEV_FMT "%s" -#define FUNC_NDEV_ARG(ndev) __func__ -#define FUNC_ADPT_FMT "%s" -#define FUNC_ADPT_ARG(adapter) __func__ - -#define STRUCT_PACKED - - -#endif - + +__inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx) +{ + + NdisInitializeWorkItem(pwork, pfunc, cntx); +} + +__inline static void _set_workitem(_workitem *pwork) +{ + NdisScheduleWorkItem(pwork); +} + +#define ATOMIC_INIT(i) { (i) } + +// +// Global Mutex: can only be used at PASSIVE level. +// + +#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ + while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\ + { \ + NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \ + NdisMSleep(10000); \ + } \ +} + +#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ + NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \ +} + +// limitation of path length +#define PATH_LENGTH_MAX MAX_PATH + +//Atomic integer operations +#define ATOMIC_T LONG + +#define NDEV_FMT "%s" +#define NDEV_ARG(ndev) "" +#define ADPT_FMT "%s" +#define ADPT_ARG(adapter) "" +#define FUNC_NDEV_FMT "%s" +#define FUNC_NDEV_ARG(ndev) __func__ +#define FUNC_ADPT_FMT "%s" +#define FUNC_ADPT_ARG(adapter) __func__ + +#define STRUCT_PACKED + + +#endif + diff --git a/include/osdep_service_xp.h b/include/osdep_service_xp.h index 71dc1cd..fc44780 100644 --- a/include/osdep_service_xp.h +++ b/include/osdep_service_xp.h @@ -12,122 +12,122 @@ * more details. * *****************************************************************************/ -#ifndef __OSDEP_LINUX_SERVICE_H_ -#define __OSDEP_LINUX_SERVICE_H_ - - #include - #include - #include - #include - -#ifdef CONFIG_USB_HCI - #include - #include - #include -#endif - - typedef KSEMAPHORE _sema; - typedef LIST_ENTRY _list; - typedef NDIS_STATUS _OS_STATUS; - - - typedef NDIS_SPIN_LOCK _lock; - - typedef KMUTEX _mutex; - - typedef KIRQL _irqL; - - // USB_PIPE for WINCE , but handle can be use just integer under windows - typedef NDIS_HANDLE _nic_hdl; - +#ifndef __OSDEP_LINUX_SERVICE_H_ +#define __OSDEP_LINUX_SERVICE_H_ + + #include + #include + #include + #include + +#ifdef CONFIG_USB_HCI + #include + #include + #include +#endif + + typedef KSEMAPHORE _sema; + typedef LIST_ENTRY _list; + typedef NDIS_STATUS _OS_STATUS; + + + typedef NDIS_SPIN_LOCK _lock; + + typedef KMUTEX _mutex; + + typedef KIRQL _irqL; + + // USB_PIPE for WINCE , but handle can be use just integer under windows + typedef NDIS_HANDLE _nic_hdl; + struct rtw_timer_list { NDIS_MINIPORT_TIMER ndis_timer; void (*function)(void *); void *arg; }; - - struct __queue { - LIST_ENTRY queue; - _lock lock; - }; - - typedef NDIS_PACKET _pkt; - typedef NDIS_BUFFER _buffer; - typedef struct __queue _queue; - - typedef PKTHREAD _thread_hdl_; - typedef void thread_return; - typedef void* thread_context; - - typedef NDIS_WORK_ITEM _workitem; - - - #define HZ 10000000 - #define SEMA_UPBND (0x7FFFFFFF) //8192 - -__inline static _list *get_next(_list *list) -{ - return list->Flink; -} - -__inline static _list *get_list_head(_queue *queue) -{ - return (&(queue->queue)); -} - - -#define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member) - - -__inline static _enter_critical(_lock *plock, _irqL *pirqL) -{ - NdisAcquireSpinLock(plock); -} - -__inline static _exit_critical(_lock *plock, _irqL *pirqL) -{ - NdisReleaseSpinLock(plock); -} - - -__inline static _enter_critical_ex(_lock *plock, _irqL *pirqL) -{ - NdisDprAcquireSpinLock(plock); -} - -__inline static _exit_critical_ex(_lock *plock, _irqL *pirqL) -{ - NdisDprReleaseSpinLock(plock); -} - -__inline static void _enter_critical_bh(_lock *plock, _irqL *pirqL) -{ - NdisDprAcquireSpinLock(plock); -} - -__inline static void _exit_critical_bh(_lock *plock, _irqL *pirqL) -{ - NdisDprReleaseSpinLock(plock); -} - -__inline static _enter_critical_mutex(_mutex *pmutex, _irqL *pirqL) -{ - KeWaitForSingleObject(pmutex, Executive, KernelMode, FALSE, NULL); -} - - -__inline static _exit_critical_mutex(_mutex *pmutex, _irqL *pirqL) -{ - KeReleaseMutex(pmutex, FALSE); -} - - -__inline static void rtw_list_delete(_list *plist) -{ - RemoveEntryList(plist); - InitializeListHead(plist); -} - + + struct __queue { + LIST_ENTRY queue; + _lock lock; + }; + + typedef NDIS_PACKET _pkt; + typedef NDIS_BUFFER _buffer; + typedef struct __queue _queue; + + typedef PKTHREAD _thread_hdl_; + typedef void thread_return; + typedef void* thread_context; + + typedef NDIS_WORK_ITEM _workitem; + + + #define HZ 10000000 + #define SEMA_UPBND (0x7FFFFFFF) //8192 + +__inline static _list *get_next(_list *list) +{ + return list->Flink; +} + +__inline static _list *get_list_head(_queue *queue) +{ + return (&(queue->queue)); +} + + +#define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member) + + +__inline static _enter_critical(_lock *plock, _irqL *pirqL) +{ + NdisAcquireSpinLock(plock); +} + +__inline static _exit_critical(_lock *plock, _irqL *pirqL) +{ + NdisReleaseSpinLock(plock); +} + + +__inline static _enter_critical_ex(_lock *plock, _irqL *pirqL) +{ + NdisDprAcquireSpinLock(plock); +} + +__inline static _exit_critical_ex(_lock *plock, _irqL *pirqL) +{ + NdisDprReleaseSpinLock(plock); +} + +__inline static void _enter_critical_bh(_lock *plock, _irqL *pirqL) +{ + NdisDprAcquireSpinLock(plock); +} + +__inline static void _exit_critical_bh(_lock *plock, _irqL *pirqL) +{ + NdisDprReleaseSpinLock(plock); +} + +__inline static _enter_critical_mutex(_mutex *pmutex, _irqL *pirqL) +{ + KeWaitForSingleObject(pmutex, Executive, KernelMode, FALSE, NULL); +} + + +__inline static _exit_critical_mutex(_mutex *pmutex, _irqL *pirqL) +{ + KeReleaseMutex(pmutex, FALSE); +} + + +__inline static void rtw_list_delete(_list *plist) +{ + RemoveEntryList(plist); + InitializeListHead(plist); +} + static inline void timer_hdl( IN PVOID SystemSpecific1, IN PVOID FunctionContext, @@ -155,56 +155,56 @@ static inline void _cancel_timer(_timer *ptimer, u8 *bcancelled) { NdisMCancelTimer(ptimer, bcancelled); } - -__inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx) -{ - - NdisInitializeWorkItem(pwork, pfunc, cntx); -} - -__inline static void _set_workitem(_workitem *pwork) -{ - NdisScheduleWorkItem(pwork); -} - - -#define ATOMIC_INIT(i) { (i) } - -// -// Global Mutex: can only be used at PASSIVE level. -// - -#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ -{ \ - while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\ - { \ - NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \ - NdisMSleep(10000); \ - } \ -} - -#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ -{ \ - NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \ -} - -// limitation of path length -#define PATH_LENGTH_MAX MAX_PATH - -//Atomic integer operations -#define ATOMIC_T LONG - - -#define NDEV_FMT "%s" -#define NDEV_ARG(ndev) "" -#define ADPT_FMT "%s" -#define ADPT_ARG(adapter) "" -#define FUNC_NDEV_FMT "%s" -#define FUNC_NDEV_ARG(ndev) __func__ -#define FUNC_ADPT_FMT "%s" -#define FUNC_ADPT_ARG(adapter) __func__ - -#define STRUCT_PACKED - -#endif - + +__inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx) +{ + + NdisInitializeWorkItem(pwork, pfunc, cntx); +} + +__inline static void _set_workitem(_workitem *pwork) +{ + NdisScheduleWorkItem(pwork); +} + + +#define ATOMIC_INIT(i) { (i) } + +// +// Global Mutex: can only be used at PASSIVE level. +// + +#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ + while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\ + { \ + NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \ + NdisMSleep(10000); \ + } \ +} + +#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ + NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \ +} + +// limitation of path length +#define PATH_LENGTH_MAX MAX_PATH + +//Atomic integer operations +#define ATOMIC_T LONG + + +#define NDEV_FMT "%s" +#define NDEV_ARG(ndev) "" +#define ADPT_FMT "%s" +#define ADPT_ARG(adapter) "" +#define FUNC_NDEV_FMT "%s" +#define FUNC_NDEV_ARG(ndev) __func__ +#define FUNC_ADPT_FMT "%s" +#define FUNC_ADPT_ARG(adapter) __func__ + +#define STRUCT_PACKED + +#endif + diff --git a/include/rtl8192f_cmd.h b/include/rtl8192f_cmd.h index fedfd7f..baca793 100644 --- a/include/rtl8192f_cmd.h +++ b/include/rtl8192f_cmd.h @@ -25,32 +25,32 @@ enum h2c_cmd_8192F { H2C_8192F_MEDIA_STATUS_RPT = 0x01, H2C_8192F_SCAN_ENABLE = 0x02, H2C_8192F_KEEP_ALIVE = 0x03, - H2C_8192F_DISCON_DECISION = 0x04, - H2C_8192F_PSD_OFFLOAD = 0x05, - H2C_8192F_AP_OFFLOAD = 0x08, - H2C_8192F_BCN_RSVDPAGE = 0x09, - H2C_8192F_PROBERSP_RSVDPAGE = 0x0A, - H2C_8192F_FCS_RSVDPAGE = 0x10, - H2C_8192F_FCS_INFO = 0x11, + H2C_8192F_DISCON_DECISION = 0x04, + H2C_8192F_PSD_OFFLOAD = 0x05, + H2C_8192F_AP_OFFLOAD = 0x08, + H2C_8192F_BCN_RSVDPAGE = 0x09, + H2C_8192F_PROBERSP_RSVDPAGE = 0x0A, + H2C_8192F_FCS_RSVDPAGE = 0x10, + H2C_8192F_FCS_INFO = 0x11, H2C_8192F_AP_WOW_GPIO_CTRL = 0x13, /* PoweSave Class: 001 */ H2C_8192F_SET_PWR_MODE = 0x20, H2C_8192F_PS_TUNING_PARA = 0x21, H2C_8192F_PS_TUNING_PARA2 = 0x22, - H2C_8192F_P2P_LPS_PARAM = 0x23, - H2C_8192F_P2P_PS_OFFLOAD = 0x24, - H2C_8192F_PS_SCAN_ENABLE = 0x25, + H2C_8192F_P2P_LPS_PARAM = 0x23, + H2C_8192F_P2P_PS_OFFLOAD = 0x24, + H2C_8192F_PS_SCAN_ENABLE = 0x25, H2C_8192F_SAP_PS_ = 0x26, H2C_8192F_INACTIVE_PS_ = 0x27,/* Inactive_PS */ H2C_8192F_FWLPS_IN_IPS_ = 0x28, /* Dynamic Mechanism Class: 010 */ - H2C_8192F_MACID_CFG = 0x40, - H2C_8192F_TXBF = 0x41, - H2C_8192F_RSSI_SETTING = 0x42, - H2C_8192F_AP_REQ_TXRPT = 0x43, - H2C_8192F_INIT_RATE_COLLECT = 0x44, + H2C_8192F_MACID_CFG = 0x40, + H2C_8192F_TXBF = 0x41, + H2C_8192F_RSSI_SETTING = 0x42, + H2C_8192F_AP_REQ_TXRPT = 0x43, + H2C_8192F_INIT_RATE_COLLECT = 0x44, H2C_8192F_RA_PARA_ADJUST = 0x46, /* BT Class: 011 */ @@ -70,13 +70,13 @@ enum h2c_cmd_8192F { /* WOWLAN Class: 100 */ H2C_8192F_WOWLAN = 0x80, H2C_8192F_REMOTE_WAKE_CTRL = 0x81, - H2C_8192F_AOAC_GLOBAL_INFO = 0x82, - H2C_8192F_AOAC_RSVD_PAGE = 0x83, + H2C_8192F_AOAC_GLOBAL_INFO = 0x82, + H2C_8192F_AOAC_RSVD_PAGE = 0x83, H2C_8192F_AOAC_RSVD_PAGE2 = 0x84, H2C_8192F_D0_SCAN_OFFLOAD_CTRL = 0x85, H2C_8192F_D0_SCAN_OFFLOAD_INFO = 0x86, H2C_8192F_CHNL_SWITCH_OFFLOAD = 0x87, - H2C_8192F_P2P_OFFLOAD_RSVD_PAGE = 0x8A, + H2C_8192F_P2P_OFFLOAD_RSVD_PAGE = 0x8A, H2C_8192F_P2P_OFFLOAD = 0x8B, H2C_8192F_RESET_TSF = 0xC0, diff --git a/include/rtl8192f_spec.h b/include/rtl8192f_spec.h index 54d3ae0..9b5383a 100644 --- a/include/rtl8192f_spec.h +++ b/include/rtl8192f_spec.h @@ -320,7 +320,7 @@ #define REG_USTIME_TSF_8192F 0x055C #define REG_BCN_MAX_ERR_8192F 0x055D #define REG_RXTSF_OFFSET_CCK_8192F 0x055E -#define REG_RXTSF_OFFSET_OFDM_8192F 0x055F +#define REG_RXTSF_OFFSET_OFDM_8192F 0x055F #define REG_TSFTR_8192F 0x0560 #define REG_CTWND_8192F 0x0572 #define REG_SECONDARY_CCA_CTRL_8192F 0x0577 @@ -526,7 +526,7 @@ /*mac queue info*/ #define QUEUE_TOTAL_NUM 20/*reg414h : 0~f ac queue 0x10~0x13MGQ HIQ BCNQ CMDQ*/ -#define QUEUE_ACQ_NUM 16 +#define QUEUE_ACQ_NUM 16 #define QUEUE_INDEX_MGQ 0x10 #define QUEUE_INDEX_HIQ 0x11 #define QUEUE_INDEX_BCNQ 0x12 diff --git a/include/rtl8710b_hal.h b/include/rtl8710b_hal.h index b01dab0..3e70fb7 100644 --- a/include/rtl8710b_hal.h +++ b/include/rtl8710b_hal.h @@ -175,10 +175,10 @@ typedef struct _RT_8710B_FIRMWARE_HDR { #define PACKAGE_QFN32_S 0 #define PACKAGE_QFN48M_S 1 //definiton 8188GU Dongle Package, Efuse Physical Address 0xF8 = 0xFE #define PACKAGE_QFN48_S 2 -#define PACKAGE_QFN64_S 3 -#define PACKAGE_QFN32_U 4 +#define PACKAGE_QFN64_S 3 +#define PACKAGE_QFN32_U 4 #define PACKAGE_QFN48M_U 5 //definiton 8188GU Dongle Package, Efuse Physical Address 0xF8 = 0xEE -#define PACKAGE_QFN48_U 6 +#define PACKAGE_QFN48_U 6 #define PACKAGE_QFN68_U 7 typedef enum _PACKAGE_TYPE_E diff --git a/include/rtl8710b_spec.h b/include/rtl8710b_spec.h index 309c3ee..78c5745 100644 --- a/include/rtl8710b_spec.h +++ b/include/rtl8710b_spec.h @@ -417,9 +417,9 @@ /* **************************************************************************** * 8723 Regsiter Bit and Content definition * **************************************************************************** */ - + /* ----------------------------------------------------- - * REG_SYS_SYSTEM_CFG0 + * REG_SYS_SYSTEM_CFG0 * ----------------------------------------------------- */ #define BIT_RTL_ID_8710B BIT(16) @@ -431,18 +431,18 @@ #define BIT_GET_VENDOR_ID_8710B(x) (((x) >> BIT_SHIFT_VENDOR_ID_8710B) & BIT_MASK_VENDOR_ID_8710B) /* ----------------------------------------------------- - * REG_SYS_SYSTEM_CFG1 + * REG_SYS_SYSTEM_CFG1 * ----------------------------------------------------- */ #define BIT_SPSLDO_SEL_8710B BIT(25) /* ----------------------------------------------------- - * REG_SYS_SYSTEM_CFG2 + * REG_SYS_SYSTEM_CFG2 * ----------------------------------------------------- */ #define BIT_MASK_RF_RL_ID_8710B 0xf #define BIT_GET_RF_RL_ID_8710B(x) ((x) & BIT_MASK_RF_RL_ID_8710B) /* ----------------------------------------------------- - * REG_SYS_SYSTEM_CFG2 + * REG_SYS_SYSTEM_CFG2 * ----------------------------------------------------- */ #define BIT_EERPOMSEL_8710B BIT(4) #define BIT_AUTOLOAD_SUS_8710B BIT(5) diff --git a/include/rtl8821c_spec.h b/include/rtl8821c_spec.h index 949f349..91b69b8 100644 --- a/include/rtl8821c_spec.h +++ b/include/rtl8821c_spec.h @@ -115,15 +115,15 @@ /* RFE */ #define rA_RFE_Pinmux_Jaguar 0xCB0 /* hal_mp.c */ #define rB_RFE_Pinmux_Jaguar 0xEB0 /* Path_B RFE control pinmux */ -#define rA_RFE_Inv_Jaguar 0xCB4 /* Path_A RFE cotrol */ +#define rA_RFE_Inv_Jaguar 0xCB4 /* Path_A RFE cotrol */ #define rB_RFE_Inv_Jaguar 0xEB4 /* Path_B RFE control */ -#define rA_RFE_Jaguar 0xCB8 /* Path_A RFE cotrol */ +#define rA_RFE_Jaguar 0xCB8 /* Path_A RFE cotrol */ #define rB_RFE_Jaguar 0xEB8 /* Path_B RFE control */ #define rA_RFE_Inverse_Jaguar 0xCBC /* Path_A RFE control inverse */ #define rB_RFE_Inverse_Jaguar 0xEBC /* Path_B RFE control inverse */ #define r_ANTSEL_SW_Jaguar 0x900 /* ANTSEL SW Control */ #define bMask_RFEInv_Jaguar 0x3FF00000 -#define bMask_AntselPathFollow_Jaguar 0x00030000 +#define bMask_AntselPathFollow_Jaguar 0x00030000 #define rOFDM1_LSTF 0xD00 #define rOFDM1_TRxPathEnable 0xD04 /* hal_mp.c */ diff --git a/include/rtl8822b_hal.h b/include/rtl8822b_hal.h index 68ad970..e4ebdbc 100644 --- a/include/rtl8822b_hal.h +++ b/include/rtl8822b_hal.h @@ -153,9 +153,9 @@ /* RFE */ #define rA_RFE_Pinmux_Jaguar 0xCB0 /* hal_mp.c */ #define rB_RFE_Pinmux_Jaguar 0xEB0 /* Path_B RFE control pinmux */ -#define rA_RFE_Inv_Jaguar 0xCB4 /* Path_A RFE cotrol */ +#define rA_RFE_Inv_Jaguar 0xCB4 /* Path_A RFE cotrol */ #define rB_RFE_Inv_Jaguar 0xEB4 /* Path_B RFE control */ -#define rA_RFE_Jaguar 0xCB8 /* Path_A RFE cotrol */ +#define rA_RFE_Jaguar 0xCB8 /* Path_A RFE cotrol */ #define rB_RFE_Jaguar 0xEB8 /* Path_B RFE control */ #define rA_RFE_Inverse_Jaguar 0xCBC /* Path_A RFE control inverse */ #define rB_RFE_Inverse_Jaguar 0xEBC /* Path_B RFE control inverse */ diff --git a/include/rtw_cmd.h b/include/rtw_cmd.h index d51a7a5..4e36bdb 100644 --- a/include/rtw_cmd.h +++ b/include/rtw_cmd.h @@ -213,7 +213,7 @@ u8 p2p_cancel_roch_cmd(_adapter *adapter, u64 cookie, struct wireless_dev *wdev, #endif /* CONFIG_IOCTL_CFG80211 */ #endif /* CONFIG_P2P */ -#ifdef CONFIG_IOCTL_CFG80211 +#ifdef CONFIG_IOCTL_CFG80211 u8 rtw_mgnt_tx_cmd(_adapter *adapter, u8 tx_ch, u8 no_cck, const u8 *buf, size_t len, int wait_ack, u8 flags); struct mgnt_tx_parm { u8 tx_ch; diff --git a/include/rtw_debug.h b/include/rtw_debug.h index 754ded9..d5ed2c1 100644 --- a/include/rtw_debug.h +++ b/include/rtw_debug.h @@ -506,7 +506,7 @@ ssize_t proc_set_new_bcn_max(struct file *file, const char __user *buffer, size_ #ifdef CONFIG_POWER_SAVING int proc_get_ps_info(struct seq_file *m, void *v); ssize_t proc_set_ps_info(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data); -#ifdef CONFIG_WMMPS_STA +#ifdef CONFIG_WMMPS_STA int proc_get_wmmps_info(struct seq_file *m, void *v); ssize_t proc_set_wmmps_info(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data); #endif /* CONFIG_WMMPS_STA */ diff --git a/include/rtw_mlme.h b/include/rtw_mlme.h index cdac712..72888b0 100644 --- a/include/rtw_mlme.h +++ b/include/rtw_mlme.h @@ -607,7 +607,7 @@ enum rtw_ft_capability { #define rtw_ft_roam(a) \ ((rtw_to_roam(a) > 0) && rtw_ft_chk_flags(a, RTW_FT_PEER_EN)) - + #define rtw_ft_valid_akm(a, t) \ ((rtw_ft_chk_flags(a, RTW_FT_EN)) && \ (((t) == 3) || ((t) == 4))) @@ -620,7 +620,7 @@ enum rtw_ft_capability { ((rtw_ft_chk_flags(a, RTW_FT_OTD_EN)) \ && ((a)->mlmepriv.ft_roam.ft_roam_on_expired == _FALSE) \ && ((a)->mlmepriv.ft_roam.ft_cap & 0x01)) - + #define rtw_ft_otd_roam(a) \ rtw_ft_chk_flags(a, RTW_FT_PEER_OTD_EN) @@ -633,7 +633,7 @@ enum rtw_ft_capability { struct ft_roam_info { u16 mdid; - u8 ft_cap; + u8 ft_cap; /*b0: FT over DS, b1: Resource Req Protocol Cap, b2~b7: Reserved*/ u8 updated_ft_ies[RTW_FT_MAX_IE_SZ]; u16 updated_ft_ies_len; @@ -644,7 +644,7 @@ struct ft_roam_info { u8 ft_flags; u32 ft_status; u32 ft_req_retry_cnt; - bool ft_updated_bcn; + bool ft_updated_bcn; }; #endif @@ -695,7 +695,7 @@ struct nb_rpt_hdr { u32 bss_info; u8 reg_class; u8 ch_num; - u8 phy_type; + u8 phy_type; }; /*IEEE Std 80211v, Figure 7-95e2¡XBSS Termination Duration subelement field format */ @@ -1072,7 +1072,7 @@ void rtw_sta_timeout_event_callback(_adapter *adapter, u8 *pbuf); #endif /* CONFIG_IEEE80211W */ #ifdef CONFIG_RTW_80211R void rtw_ft_info_init(struct ft_roam_info *pft); -u8 rtw_ft_chk_roaming_candidate(_adapter *padapter, +u8 rtw_ft_chk_roaming_candidate(_adapter *padapter, struct wlan_network *competitor); void rtw_ft_update_stainfo(_adapter *padapter, WLAN_BSSID_EX *pnetwork); void rtw_ft_reassoc_event_callback(_adapter *padapter, u8 *pbuf); diff --git a/include/rtw_mlme_ext.h b/include/rtw_mlme_ext.h index 931a11c..778af49 100644 --- a/include/rtw_mlme_ext.h +++ b/include/rtw_mlme_ext.h @@ -982,11 +982,11 @@ unsigned int OnAction_p2p(_adapter *padapter, union recv_frame *precv_frame); #ifdef CONFIG_RTW_80211R void rtw_ft_update_bcn(_adapter *padapter, union recv_frame *precv_frame); void rtw_ft_start_clnt_join(_adapter *padapter); -u8 rtw_ft_update_rsnie(_adapter *padapter, u8 bwrite, +u8 rtw_ft_update_rsnie(_adapter *padapter, u8 bwrite, struct pkt_attrib *pattrib, u8 **pframe); -void rtw_ft_build_auth_req_ies(_adapter *padapter, +void rtw_ft_build_auth_req_ies(_adapter *padapter, struct pkt_attrib *pattrib, u8 **pframe); -void rtw_ft_build_assoc_req_ies(_adapter *padapter, +void rtw_ft_build_assoc_req_ies(_adapter *padapter, u8 is_reassoc, struct pkt_attrib *pattrib, u8 **pframe); u8 rtw_ft_update_auth_rsp_ies(_adapter *padapter, u8 *pframe, u32 len); void rtw_ft_start_roam(_adapter *padapter, u8 *pTargetAddr); diff --git a/include/rtw_pwrctrl.h b/include/rtw_pwrctrl.h index c43d577..00e9212 100644 --- a/include/rtw_pwrctrl.h +++ b/include/rtw_pwrctrl.h @@ -339,7 +339,7 @@ struct pwrctrl_priv { #ifdef CONFIG_WMMPS_STA u8 wmm_smart_ps; -#endif /* CONFIG_WMMPS_STA */ +#endif /* CONFIG_WMMPS_STA */ u32 alives; _workitem cpwm_event; diff --git a/include/rtw_qos.h b/include/rtw_qos.h index 8e1d013..cf2e8c0 100644 --- a/include/rtw_qos.h +++ b/include/rtw_qos.h @@ -58,7 +58,7 @@ struct qos_priv { u8 uapsd_tid_trigger_enabled; /* declare uapsd_ap_supported to record whether the connected ap supports uapsd or not */ u8 uapsd_ap_supported; -#endif /* CONFIG_WMMPS_STA */ +#endif /* CONFIG_WMMPS_STA */ }; diff --git a/include/rtw_recv.h b/include/rtw_recv.h index 55fab54..3d9c319 100644 --- a/include/rtw_recv.h +++ b/include/rtw_recv.h @@ -410,7 +410,7 @@ struct recv_priv { struct sk_buff_head rx_skb_queue; #ifdef CONFIG_RTW_NAPI struct sk_buff_head rx_napi_skb_queue; -#endif +#endif #ifdef CONFIG_RX_INDICATE_QUEUE struct task rx_indicate_tasklet; struct ifqueue rx_indicate_queue; diff --git a/include/rtw_rm_fsm.h b/include/rtw_rm_fsm.h index ba903a9..6a0a06f 100644 --- a/include/rtw_rm_fsm.h +++ b/include/rtw_rm_fsm.h @@ -267,7 +267,7 @@ struct data_buf { struct rm_obj { - /* aid << 16 + /* aid << 16 |diag_token << 8 |B(1) 1/0:All_AID/UNIC |B(0) 1/0:RM_MASTER/RM_SLAVE */ diff --git a/include/rtw_xmit.h b/include/rtw_xmit.h index 6c718d5..6cc9b9f 100644 --- a/include/rtw_xmit.h +++ b/include/rtw_xmit.h @@ -467,7 +467,7 @@ struct pkt_attrib { #ifdef CONFIG_WMMPS_STA u8 trigger_frame; #endif /* CONFIG_WMMPS_STA */ - + struct sta_info *psta; u8 rtsen; @@ -1034,7 +1034,7 @@ extern void rtw_amsdu_set_timer_status(_adapter *padapter, u8 priority, u8 statu extern void rtw_amsdu_set_timer(_adapter *padapter, u8 priority); extern void rtw_amsdu_cancel_timer(_adapter *padapter, u8 priority); -extern s32 rtw_xmitframe_coalesce_amsdu(_adapter *padapter, struct xmit_frame *pxmitframe, struct xmit_frame *pxmitframe_queue); +extern s32 rtw_xmitframe_coalesce_amsdu(_adapter *padapter, struct xmit_frame *pxmitframe, struct xmit_frame *pxmitframe_queue); extern s32 check_amsdu(struct xmit_frame *pxmitframe); extern s32 check_amsdu_tx_support(_adapter *padapter); extern struct xmit_frame *rtw_get_xframe(struct xmit_priv *pxmitpriv, int *num_frame); diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 7ea9c14..4715e84 100755 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -82,7 +82,7 @@ #endif /* - * In the current design of Wi-Fi driver, it will return success to the system (e.g. supplicant) + * In the current design of Wi-Fi driver, it will return success to the system (e.g. supplicant) * when Wi-Fi driver decides to abort the scan request in the scan flow by default. * Defining this flag makes Wi-Fi driver to return -EBUSY to the system if Wi-Fi driver is too busy to do the scan. */ @@ -323,7 +323,7 @@ static u8 rtw_chbw_to_cfg80211_chan_def(struct wiphy *wiphy, struct cfg80211_cha if (!chan) goto exit; - if (bw == CHANNEL_WIDTH_20) + if (bw == CHANNEL_WIDTH_20) chdef->width = ht ? NL80211_CHAN_WIDTH_20 : NL80211_CHAN_WIDTH_20_NOHT; else if (bw == CHANNEL_WIDTH_40) chdef->width = NL80211_CHAN_WIDTH_40; @@ -357,7 +357,7 @@ static void rtw_get_chbw_from_cfg80211_chan_def(struct cfg80211_chan_def *chdef, rtw_warn_on(1); *ch = 0; return; - } + } switch (chdef->width) { case NL80211_CHAN_WIDTH_20_NOHT: @@ -1621,8 +1621,8 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param _rtw_memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); _rtw_memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); padapter->securitypriv.binstallGrpkey = _TRUE; - if (param->u.crypt.idx < 4) - _rtw_memcpy(padapter->securitypriv.iv_seq[param->u.crypt.idx], param->u.crypt.seq, 8); + if (param->u.crypt.idx < 4) + _rtw_memcpy(padapter->securitypriv.iv_seq[param->u.crypt.idx], param->u.crypt.seq, 8); padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1, _TRUE); @@ -1870,7 +1870,7 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) || (MLME_IS_STA(adapter) && !pairwise) #endif - ) { + ) { /* WEP key, TX GTK/IGTK, RX GTK/IGTK(for STA mode) */ if (is_wep_enc(sec->dot118021XGrpPrivacy)) { if (keyid >= WEP_KEYS) @@ -1959,7 +1959,7 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev } ret = 0; - + exit: RTW_INFO(FUNC_NDEV_FMT GET_KEY_PARAM_FMT_S @@ -5695,7 +5695,7 @@ release_plink_ctl: if (del_sta) { u8 sta_addr[ETH_ALEN]; u8 updated = _FALSE; - + _rtw_memcpy(sta_addr, del_sta->cmn.mac_addr, ETH_ALEN); updated = ap_free_sta(adapter, del_sta, 0, 0, 1); rtw_mesh_expire_peer(stapriv->padapter, sta_addr); @@ -5780,7 +5780,7 @@ static int cfg80211_rtw_dump_station(struct wiphy *wiphy, struct net_device *nde else _rtw_memcpy(mac, plink->addr, ETH_ALEN); #endif - + sinfo->filled = 0; if (psta) { @@ -7872,7 +7872,7 @@ void dump_mesh_config(void *sel, const struct mesh_config *conf) RTW_PRINT_SEL(sel, "path_refresh_time:%u\n", conf->path_refresh_time); RTW_PRINT_SEL(sel, "min_discovery_timeout:%u\n", conf->min_discovery_timeout); RTW_PRINT_SEL(sel, "dot11MeshHWMPactivePathTimeout:%u\n", conf->dot11MeshHWMPactivePathTimeout); - RTW_PRINT_SEL(sel, "dot11MeshHWMPpreqMinInterval:%u\n", conf->dot11MeshHWMPpreqMinInterval); + RTW_PRINT_SEL(sel, "dot11MeshHWMPpreqMinInterval:%u\n", conf->dot11MeshHWMPpreqMinInterval); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) RTW_PRINT_SEL(sel, "dot11MeshHWMPperrMinInterval:%u\n", conf->dot11MeshHWMPperrMinInterval); #endif @@ -7887,11 +7887,11 @@ void dump_mesh_config(void *sel, const struct mesh_config *conf) RTW_PRINT_SEL(sel, "dot11MeshForwarding:%d\n", conf->dot11MeshForwarding); RTW_PRINT_SEL(sel, "rssi_threshold:%d\n", conf->rssi_threshold); #endif - + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)) RTW_PRINT_SEL(sel, "ht_opmode:0x%04x\n", conf->ht_opmode); #endif - + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) RTW_PRINT_SEL(sel, "dot11MeshHWMPactivePathToRootTimeout:%u\n", conf->dot11MeshHWMPactivePathToRootTimeout); RTW_PRINT_SEL(sel, "dot11MeshHWMProotInterval:%u\n", conf->dot11MeshHWMProotInterval); @@ -7902,7 +7902,7 @@ void dump_mesh_config(void *sel, const struct mesh_config *conf) RTW_PRINT_SEL(sel, "power_mode:%s\n", nl80211_mesh_power_mode_str(conf->power_mode)); RTW_PRINT_SEL(sel, "dot11MeshAwakeWindowDuration:%u\n", conf->dot11MeshAwakeWindowDuration); #endif - + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) RTW_PRINT_SEL(sel, "plink_timeout:%u\n", conf->plink_timeout); #endif @@ -8038,14 +8038,14 @@ static void rtw_cfg80211_mesh_cfg_set(_adapter *adapter, const struct mesh_confi if (chk_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)); #endif #endif - + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) if (chk_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask)) mcfg->dot11MeshHWMPactivePathToRootTimeout = conf->dot11MeshHWMPactivePathToRootTimeout; if (chk_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask)) mcfg->dot11MeshHWMProotInterval = conf->dot11MeshHWMProotInterval; if (chk_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask)) - mcfg->dot11MeshHWMPconfirmationInterval = conf->dot11MeshHWMPconfirmationInterval; + mcfg->dot11MeshHWMPconfirmationInterval = conf->dot11MeshHWMPconfirmationInterval; #endif #if 0 /* TBD */ @@ -8103,7 +8103,7 @@ u8 *rtw_cfg80211_construct_mesh_beacon_ies(struct wiphy *wiphy, _adapter *adapte #endif if (!ch) goto exit; - + #if defined(CONFIG_80211AC_VHT) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) vht = ht && ch > 14 && bw >= CHANNEL_WIDTH_80; /* VHT40/VHT20? */ #endif @@ -8428,7 +8428,7 @@ static int cfg80211_rtw_join_mesh(struct wiphy *wiphy, struct net_device *dev, ret = -EINVAL; goto exit; } - + rtw_mesh_work(&adapter->mesh_work); exit: @@ -8509,7 +8509,7 @@ static int cfg80211_rtw_del_mpath(struct wiphy *wiphy, struct net_device *dev } } else { rtw_mesh_path_flush_by_iface(adapter); - } + } exit: return ret; @@ -8816,13 +8816,13 @@ int cfg80211_rtw_resume(struct wiphy *wiphy) { //rtw_sitesurvey_cmd(padapter, NULL); rtw_sitesurvey_cmd(padapter, &parm); _exit_critical_bh(&pmlmepriv->lock, &irqL); - + for (PNOWakeupScanWaitCnt = 0; PNOWakeupScanWaitCnt < 10; PNOWakeupScanWaitCnt++) { if(check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == _FALSE) break; rtw_msleep_os(1000); } - + _enter_critical_bh(&pmlmepriv->lock, &irqL); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) @@ -8835,7 +8835,7 @@ int cfg80211_rtw_resume(struct wiphy *wiphy) { } RTW_DBG("<== %s\n",__func__); return 0; - + } #endif /* CONFIG_PNO_SUPPORT */ @@ -9729,7 +9729,7 @@ int rtw_hostapd_acs_dump_survey(struct wiphy *wiphy, struct net_device *netdev, #elif defined(CONFIG_RTW_ACS) && defined(CONFIG_BACKGROUND_NOISE_MONITOR) rtw_cfg80211_set_survey_info_with_clm(padapter, idx, info); #else - RTW_ERR("%s: unknown acs operation!\n", __func__); + RTW_ERR("%s: unknown acs operation!\n", __func__); #endif return ret; diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index af89009..00284e3 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -88,7 +88,7 @@ MODULE_PARM_DESC(rtw_lps_level, "The default LPS level"); module_param(rtw_lps_chk_by_tp, int, 0644); -/* LPS: +/* LPS: * rtw_smart_ps = 0 => TX: pwr bit = 1, RX: PS_Poll * rtw_smart_ps = 1 => TX: pwr bit = 0, RX: PS_Poll * rtw_smart_ps = 2 => TX: pwr bit = 0, RX: NullData with pwr bit = 0 @@ -97,8 +97,8 @@ int rtw_smart_ps = 2; int rtw_max_bss_cnt = 0; module_param(rtw_max_bss_cnt, int, 0644); -#ifdef CONFIG_WMMPS_STA -/* WMMPS: +#ifdef CONFIG_WMMPS_STA +/* WMMPS: * rtw_smart_ps = 0 => Only for fw test * rtw_smart_ps = 1 => Refer to Beacon's TIM Bitmap * rtw_smart_ps = 2 => Don't refer to Beacon's TIM Bitmap @@ -2181,7 +2181,7 @@ struct dvobj_priv *devobj_init(void) pdvobj->tpt_mode = 0; pdvobj->edca_be_ul = 0x5ea42b; pdvobj->edca_be_dl = 0x00a42b; -#endif +#endif pdvobj->scan_deny = _FALSE; return pdvobj; @@ -3296,7 +3296,7 @@ int _netdev_open(struct net_device *pnetdev) } #endif /*CONFIG_AUTOSUSPEND*/ - if (!rtw_is_hw_init_completed(padapter)) { // ips + if (!rtw_is_hw_init_completed(padapter)) { // ips rtw_clr_surprise_removed(padapter); rtw_clr_drv_stopped(padapter); RTW_ENABLE_FUNC(padapter, DF_RX_BIT); @@ -3318,7 +3318,7 @@ int _netdev_open(struct net_device *pnetdev) { #ifdef CONFIG_BT_COEXIST_SOCKET_TRX _adapter *prim_adpt = GET_PRIMARY_ADAPTER(padapter); - + if (prim_adpt && (_TRUE == prim_adpt->EEPROMBluetoothCoexist)) { rtw_btcoex_init_socket(prim_adpt); prim_adpt->coex_info.BtMgnt.ExtConfig.HCIExtensionVer = 0x04; @@ -3705,7 +3705,7 @@ int _pm_netdev_open(_adapter *padapter) } #endif /*CONFIG_AUTOSUSPEND*/ - if (!rtw_is_hw_init_completed(padapter)) { // ips + if (!rtw_is_hw_init_completed(padapter)) { // ips rtw_clr_surprise_removed(padapter); rtw_clr_drv_stopped(padapter); status = rtw_hal_init(padapter); @@ -4805,7 +4805,7 @@ int rtw_resume_process_wow(_adapter *padapter) rtw_mi_start_drv_threads(padapter); rtw_mi_intf_start(padapter); - + if(registry_par->suspend_type == FW_IPS_DISABLE_BBRF && !check_fwstate(pmlmepriv, _FW_LINKED)) { if (!rtw_is_surprise_removed(padapter)) { rtw_hal_deinit(padapter); diff --git a/os_dep/linux/recv_linux.c b/os_dep/linux/recv_linux.c index 2f7b3e3..6bd2e09 100644 --- a/os_dep/linux/recv_linux.c +++ b/os_dep/linux/recv_linux.c @@ -404,7 +404,7 @@ void dynamic_napi_th_chk (_adapter *adapter) if (adapter->registrypriv.en_napi) { struct dvobj_priv *dvobj; struct registry_priv *registry; - + dvobj = adapter_to_dvobj(adapter); registry = &adapter->registrypriv; if (dvobj->traffic_stat.cur_rx_tp > registry->napi_threshold) @@ -520,7 +520,7 @@ void rtw_os_recv_indicate_pkt(_adapter *padapter, _pkt *pkt, union recv_frame *r #ifdef CONFIG_RTW_NAPI #ifdef CONFIG_RTW_NAPI_DYNAMIC if (!skb_queue_empty(&precvpriv->rx_napi_skb_queue) - && !adapter_to_dvobj(padapter)->en_napi_dynamic + && !adapter_to_dvobj(padapter)->en_napi_dynamic ) napi_recv(padapter, RTL_NAPI_WEIGHT); #endif diff --git a/os_dep/linux/rhashtable.c b/os_dep/linux/rhashtable.c index af9c9ae..0163a4b 100644 --- a/os_dep/linux/rhashtable.c +++ b/os_dep/linux/rhashtable.c @@ -1,844 +1,844 @@ -/* - * Resizable, Scalable, Concurrent Hash Table - * - * Copyright (c) 2015 Herbert Xu - * Copyright (c) 2014-2015 Thomas Graf - * Copyright (c) 2008-2014 Patrick McHardy - * - * Code partially derived from nft_hash - * Rewritten with rehash code from br_multicast plus single list - * pointer as suggested by Josh Triplett - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define HASH_DEFAULT_SIZE 64UL -#define HASH_MIN_SIZE 4U -#define BUCKET_LOCKS_PER_CPU 128UL - -static u32 head_hashfn(struct rhashtable *ht, - const struct bucket_table *tbl, - const struct rhash_head *he) -{ - return rht_head_hashfn(ht, tbl, he, ht->p); -} - -#ifdef CONFIG_PROVE_LOCKING -#define ASSERT_RHT_MUTEX(HT) BUG_ON(!lockdep_rht_mutex_is_held(HT)) - -int lockdep_rht_mutex_is_held(struct rhashtable *ht) -{ - return (debug_locks) ? lockdep_is_held(&ht->mutex) : 1; -} - -int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, u32 hash) -{ - spinlock_t *lock = rht_bucket_lock(tbl, hash); - - return (debug_locks) ? lockdep_is_held(lock) : 1; -} -#else -#define ASSERT_RHT_MUTEX(HT) -#endif - - -static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl, - gfp_t gfp) -{ - unsigned int i, size; -#if defined(CONFIG_PROVE_LOCKING) - unsigned int nr_pcpus = 2; -#else - unsigned int nr_pcpus = num_possible_cpus(); -#endif - - nr_pcpus = min_t(unsigned int, nr_pcpus, 32UL); - size = roundup_pow_of_two(nr_pcpus * ht->p.locks_mul); - - /* Never allocate more than 0.5 locks per bucket */ - size = min_t(unsigned int, size, tbl->size >> 1); - - if (sizeof(spinlock_t) != 0) { -#ifdef CONFIG_NUMA - if (size * sizeof(spinlock_t) > PAGE_SIZE && - gfp == GFP_KERNEL) - tbl->locks = vmalloc(size * sizeof(spinlock_t)); - else -#endif - tbl->locks = kmalloc_array(size, sizeof(spinlock_t), - gfp); - if (!tbl->locks) - return -ENOMEM; - for (i = 0; i < size; i++) - spin_lock_init(&tbl->locks[i]); - } - tbl->locks_mask = size - 1; - - return 0; -} - -static void bucket_table_free(const struct bucket_table *tbl) -{ - if (tbl) - kvfree(tbl->locks); - - kvfree(tbl); -} - -static void bucket_table_free_rcu(struct rcu_head *head) -{ - bucket_table_free(container_of(head, struct bucket_table, rcu)); -} - -static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, - size_t nbuckets, - gfp_t gfp) -{ - struct bucket_table *tbl = NULL; - size_t size; - int i; - - size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]); - if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER) || - gfp != GFP_KERNEL) - tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY); - if (tbl == NULL && gfp == GFP_KERNEL) - tbl = vzalloc(size); - if (tbl == NULL) - return NULL; - - tbl->size = nbuckets; - - if (alloc_bucket_locks(ht, tbl, gfp) < 0) { - bucket_table_free(tbl); - return NULL; - } - - INIT_LIST_HEAD(&tbl->walkers); - - get_random_bytes(&tbl->hash_rnd, sizeof(tbl->hash_rnd)); - - for (i = 0; i < nbuckets; i++) - INIT_RHT_NULLS_HEAD(tbl->buckets[i], ht, i); - - return tbl; -} - -static struct bucket_table *rhashtable_last_table(struct rhashtable *ht, - struct bucket_table *tbl) -{ - struct bucket_table *new_tbl; - - do { - new_tbl = tbl; - tbl = rht_dereference_rcu(tbl->future_tbl, ht); - } while (tbl); - - return new_tbl; -} - -static int rhashtable_rehash_one(struct rhashtable *ht, unsigned int old_hash) -{ - struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); - struct bucket_table *new_tbl = rhashtable_last_table(ht, - rht_dereference_rcu(old_tbl->future_tbl, ht)); - struct rhash_head __rcu **pprev = &old_tbl->buckets[old_hash]; - int err = -ENOENT; - struct rhash_head *head, *next, *entry; - spinlock_t *new_bucket_lock; - unsigned int new_hash; - - rht_for_each(entry, old_tbl, old_hash) { - err = 0; - next = rht_dereference_bucket(entry->next, old_tbl, old_hash); - - if (rht_is_a_nulls(next)) - break; - - pprev = &entry->next; - } - - if (err) - goto out; - - new_hash = head_hashfn(ht, new_tbl, entry); - - new_bucket_lock = rht_bucket_lock(new_tbl, new_hash); - - spin_lock_nested(new_bucket_lock, SINGLE_DEPTH_NESTING); - head = rht_dereference_bucket(new_tbl->buckets[new_hash], - new_tbl, new_hash); - - RCU_INIT_POINTER(entry->next, head); - - rcu_assign_pointer(new_tbl->buckets[new_hash], entry); - spin_unlock(new_bucket_lock); - - rcu_assign_pointer(*pprev, next); - -out: - return err; -} - -static void rhashtable_rehash_chain(struct rhashtable *ht, - unsigned int old_hash) -{ - struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); - spinlock_t *old_bucket_lock; - - old_bucket_lock = rht_bucket_lock(old_tbl, old_hash); - - spin_lock_bh(old_bucket_lock); - while (!rhashtable_rehash_one(ht, old_hash)) - ; - old_tbl->rehash++; - spin_unlock_bh(old_bucket_lock); -} - -static int rhashtable_rehash_attach(struct rhashtable *ht, - struct bucket_table *old_tbl, - struct bucket_table *new_tbl) -{ - /* Protect future_tbl using the first bucket lock. */ - spin_lock_bh(old_tbl->locks); - - /* Did somebody beat us to it? */ - if (rcu_access_pointer(old_tbl->future_tbl)) { - spin_unlock_bh(old_tbl->locks); - return -EEXIST; - } - - /* Make insertions go into the new, empty table right away. Deletions - * and lookups will be attempted in both tables until we synchronize. - */ - rcu_assign_pointer(old_tbl->future_tbl, new_tbl); - - /* Ensure the new table is visible to readers. */ - smp_wmb(); - - spin_unlock_bh(old_tbl->locks); - - return 0; -} - -static int rhashtable_rehash_table(struct rhashtable *ht) -{ - struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); - struct bucket_table *new_tbl; - struct rhashtable_walker *walker; - unsigned int old_hash; - - new_tbl = rht_dereference(old_tbl->future_tbl, ht); - if (!new_tbl) - return 0; - - for (old_hash = 0; old_hash < old_tbl->size; old_hash++) - rhashtable_rehash_chain(ht, old_hash); - - /* Publish the new table pointer. */ - rcu_assign_pointer(ht->tbl, new_tbl); - - spin_lock(&ht->lock); - list_for_each_entry(walker, &old_tbl->walkers, list) - walker->tbl = NULL; - spin_unlock(&ht->lock); - - /* Wait for readers. All new readers will see the new - * table, and thus no references to the old table will - * remain. - */ - call_rcu(&old_tbl->rcu, bucket_table_free_rcu); - - return rht_dereference(new_tbl->future_tbl, ht) ? -EAGAIN : 0; -} - -/** - * rhashtable_expand - Expand hash table while allowing concurrent lookups - * @ht: the hash table to expand - * - * A secondary bucket array is allocated and the hash entries are migrated. - * - * This function may only be called in a context where it is safe to call - * synchronize_rcu(), e.g. not within a rcu_read_lock() section. - * - * The caller must ensure that no concurrent resizing occurs by holding - * ht->mutex. - * - * It is valid to have concurrent insertions and deletions protected by per - * bucket locks or concurrent RCU protected lookups and traversals. - */ -static int rhashtable_expand(struct rhashtable *ht) -{ - struct bucket_table *new_tbl, *old_tbl = rht_dereference(ht->tbl, ht); - int err; - - ASSERT_RHT_MUTEX(ht); - - old_tbl = rhashtable_last_table(ht, old_tbl); - - new_tbl = bucket_table_alloc(ht, old_tbl->size * 2, GFP_KERNEL); - if (new_tbl == NULL) - return -ENOMEM; - - err = rhashtable_rehash_attach(ht, old_tbl, new_tbl); - if (err) - bucket_table_free(new_tbl); - - return err; -} - -/** - * rhashtable_shrink - Shrink hash table while allowing concurrent lookups - * @ht: the hash table to shrink - * - * This function shrinks the hash table to fit, i.e., the smallest - * size would not cause it to expand right away automatically. - * - * The caller must ensure that no concurrent resizing occurs by holding - * ht->mutex. - * - * The caller must ensure that no concurrent table mutations take place. - * It is however valid to have concurrent lookups if they are RCU protected. - * - * It is valid to have concurrent insertions and deletions protected by per - * bucket locks or concurrent RCU protected lookups and traversals. - */ -static int rhashtable_shrink(struct rhashtable *ht) -{ - struct bucket_table *new_tbl, *old_tbl = rht_dereference(ht->tbl, ht); - unsigned int size; - int err; - - ASSERT_RHT_MUTEX(ht); - - size = roundup_pow_of_two(atomic_read(&ht->nelems) * 3 / 2); - if (size < ht->p.min_size) - size = ht->p.min_size; - - if (old_tbl->size <= size) - return 0; - - if (rht_dereference(old_tbl->future_tbl, ht)) - return -EEXIST; - - new_tbl = bucket_table_alloc(ht, size, GFP_KERNEL); - if (new_tbl == NULL) - return -ENOMEM; - - err = rhashtable_rehash_attach(ht, old_tbl, new_tbl); - if (err) - bucket_table_free(new_tbl); - - return err; -} - -static void rht_deferred_worker(struct work_struct *work) -{ - struct rhashtable *ht; - struct bucket_table *tbl; - int err = 0; - - ht = container_of(work, struct rhashtable, run_work); - mutex_lock(&ht->mutex); - - tbl = rht_dereference(ht->tbl, ht); - tbl = rhashtable_last_table(ht, tbl); - - if (rht_grow_above_75(ht, tbl)) - rhashtable_expand(ht); - else if (ht->p.automatic_shrinking && rht_shrink_below_30(ht, tbl)) - rhashtable_shrink(ht); - - err = rhashtable_rehash_table(ht); - - mutex_unlock(&ht->mutex); - - if (err) - schedule_work(&ht->run_work); -} - -static bool rhashtable_check_elasticity(struct rhashtable *ht, - struct bucket_table *tbl, - unsigned int hash) -{ - unsigned int elasticity = ht->elasticity; - struct rhash_head *head; - - rht_for_each(head, tbl, hash) - if (!--elasticity) - return true; - - return false; -} - -int rhashtable_insert_rehash(struct rhashtable *ht, - struct bucket_table *tbl) -{ - struct bucket_table *old_tbl; - struct bucket_table *new_tbl; - unsigned int size; - int err; - - old_tbl = rht_dereference_rcu(ht->tbl, ht); - - size = tbl->size; - - err = -EBUSY; - - if (rht_grow_above_75(ht, tbl)) - size *= 2; - /* Do not schedule more than one rehash */ - else if (old_tbl != tbl) - goto fail; - - err = -ENOMEM; - - new_tbl = bucket_table_alloc(ht, size, GFP_ATOMIC); - if (new_tbl == NULL) - goto fail; - - err = rhashtable_rehash_attach(ht, tbl, new_tbl); - if (err) { - bucket_table_free(new_tbl); - if (err == -EEXIST) - err = 0; - } else - schedule_work(&ht->run_work); - - return err; - -fail: - /* Do not fail the insert if someone else did a rehash. */ - if (likely(rcu_dereference_raw(tbl->future_tbl))) - return 0; - - /* Schedule async rehash to retry allocation in process context. */ - if (err == -ENOMEM) - schedule_work(&ht->run_work); - - return err; -} - -struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht, - const void *key, - struct rhash_head *obj, - struct bucket_table *tbl) -{ - struct rhash_head *head; - unsigned int hash; - int err; - - tbl = rhashtable_last_table(ht, tbl); - hash = head_hashfn(ht, tbl, obj); - spin_lock_nested(rht_bucket_lock(tbl, hash), SINGLE_DEPTH_NESTING); - - err = -EEXIST; - if (key && rhashtable_lookup_fast(ht, key, ht->p)) - goto exit; - - err = -E2BIG; - if (unlikely(rht_grow_above_max(ht, tbl))) - goto exit; - - err = -EAGAIN; - if (rhashtable_check_elasticity(ht, tbl, hash) || - rht_grow_above_100(ht, tbl)) - goto exit; - - err = 0; - - head = rht_dereference_bucket(tbl->buckets[hash], tbl, hash); - - RCU_INIT_POINTER(obj->next, head); - - rcu_assign_pointer(tbl->buckets[hash], obj); - - atomic_inc(&ht->nelems); - -exit: - spin_unlock(rht_bucket_lock(tbl, hash)); - - if (err == 0) - return NULL; - else if (err == -EAGAIN) - return tbl; - else - return ERR_PTR(err); -} - -/** - * rhashtable_walk_init - Initialise an iterator - * @ht: Table to walk over - * @iter: Hash table Iterator - * - * This function prepares a hash table walk. - * - * Note that if you restart a walk after rhashtable_walk_stop you - * may see the same object twice. Also, you may miss objects if - * there are removals in between rhashtable_walk_stop and the next - * call to rhashtable_walk_start. - * - * For a completely stable walk you should construct your own data - * structure outside the hash table. - * - * This function may sleep so you must not call it from interrupt - * context or with spin locks held. - * - * You must call rhashtable_walk_exit if this function returns - * successfully. - */ -int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter) -{ - iter->ht = ht; - iter->p = NULL; - iter->slot = 0; - iter->skip = 0; - - iter->walker = kmalloc(sizeof(*iter->walker), GFP_KERNEL); - if (!iter->walker) - return -ENOMEM; - - spin_lock(&ht->lock); - iter->walker->tbl = - rcu_dereference_protected(ht->tbl, lockdep_is_held(&ht->lock)); - list_add(&iter->walker->list, &iter->walker->tbl->walkers); - spin_unlock(&ht->lock); - - return 0; -} - -/** - * rhashtable_walk_exit - Free an iterator - * @iter: Hash table Iterator - * - * This function frees resources allocated by rhashtable_walk_init. - */ -void rhashtable_walk_exit(struct rhashtable_iter *iter) -{ - spin_lock(&iter->ht->lock); - if (iter->walker->tbl) - list_del(&iter->walker->list); - spin_unlock(&iter->ht->lock); - kfree(iter->walker); -} - -/** - * rhashtable_walk_start - Start a hash table walk - * @iter: Hash table iterator - * - * Start a hash table walk. Note that we take the RCU lock in all - * cases including when we return an error. So you must always call - * rhashtable_walk_stop to clean up. - * - * Returns zero if successful. - * - * Returns -EAGAIN if resize event occured. Note that the iterator - * will rewind back to the beginning and you may use it immediately - * by calling rhashtable_walk_next. - */ -int rhashtable_walk_start(struct rhashtable_iter *iter) - __acquires(RCU) -{ - struct rhashtable *ht = iter->ht; - - rcu_read_lock(); - - spin_lock(&ht->lock); - if (iter->walker->tbl) - list_del(&iter->walker->list); - spin_unlock(&ht->lock); - - if (!iter->walker->tbl) { - iter->walker->tbl = rht_dereference_rcu(ht->tbl, ht); - return -EAGAIN; - } - - return 0; -} - -/** - * rhashtable_walk_next - Return the next object and advance the iterator - * @iter: Hash table iterator - * - * Note that you must call rhashtable_walk_stop when you are finished - * with the walk. - * - * Returns the next object or NULL when the end of the table is reached. - * - * Returns -EAGAIN if resize event occured. Note that the iterator - * will rewind back to the beginning and you may continue to use it. - */ -void *rhashtable_walk_next(struct rhashtable_iter *iter) -{ - struct bucket_table *tbl = iter->walker->tbl; - struct rhashtable *ht = iter->ht; - struct rhash_head *p = iter->p; - - if (p) { - p = rht_dereference_bucket_rcu(p->next, tbl, iter->slot); - goto next; - } - - for (; iter->slot < tbl->size; iter->slot++) { - int skip = iter->skip; - - rht_for_each_rcu(p, tbl, iter->slot) { - if (!skip) - break; - skip--; - } - -next: - if (!rht_is_a_nulls(p)) { - iter->skip++; - iter->p = p; - return rht_obj(ht, p); - } - - iter->skip = 0; - } - - iter->p = NULL; - - /* Ensure we see any new tables. */ - smp_rmb(); - - iter->walker->tbl = rht_dereference_rcu(tbl->future_tbl, ht); - if (iter->walker->tbl) { - iter->slot = 0; - iter->skip = 0; - return ERR_PTR(-EAGAIN); - } - - return NULL; -} - -/** - * rhashtable_walk_stop - Finish a hash table walk - * @iter: Hash table iterator - * - * Finish a hash table walk. - */ -void rhashtable_walk_stop(struct rhashtable_iter *iter) - __releases(RCU) -{ - struct rhashtable *ht; - struct bucket_table *tbl = iter->walker->tbl; - - if (!tbl) - goto out; - - ht = iter->ht; - - spin_lock(&ht->lock); - if (tbl->rehash < tbl->size) - list_add(&iter->walker->list, &tbl->walkers); - else - iter->walker->tbl = NULL; - spin_unlock(&ht->lock); - - iter->p = NULL; - -out: - rcu_read_unlock(); -} - -static size_t rounded_hashtable_size(const struct rhashtable_params *params) -{ - return max(roundup_pow_of_two(params->nelem_hint * 4 / 3), - (unsigned long)params->min_size); -} - -static u32 rhashtable_jhash2(const void *key, u32 length, u32 seed) -{ - return jhash2(key, length, seed); -} - -/** - * rhashtable_init - initialize a new hash table - * @ht: hash table to be initialized - * @params: configuration parameters - * - * Initializes a new hash table based on the provided configuration - * parameters. A table can be configured either with a variable or - * fixed length key: - * - * Configuration Example 1: Fixed length keys - * struct test_obj { - * int key; - * void * my_member; - * struct rhash_head node; - * }; - * - * struct rhashtable_params params = { - * .head_offset = offsetof(struct test_obj, node), - * .key_offset = offsetof(struct test_obj, key), - * .key_len = sizeof(int), - * .hashfn = jhash, - * .nulls_base = (1U << RHT_BASE_SHIFT), - * }; - * - * Configuration Example 2: Variable length keys - * struct test_obj { - * [...] - * struct rhash_head node; - * }; - * - * u32 my_hash_fn(const void *data, u32 len, u32 seed) - * { - * struct test_obj *obj = data; - * - * return [... hash ...]; - * } - * - * struct rhashtable_params params = { - * .head_offset = offsetof(struct test_obj, node), - * .hashfn = jhash, - * .obj_hashfn = my_hash_fn, - * }; - */ -int rhashtable_init(struct rhashtable *ht, - const struct rhashtable_params *params) -{ - struct bucket_table *tbl; - size_t size; - - size = HASH_DEFAULT_SIZE; - - if ((!params->key_len && !params->obj_hashfn) || - (params->obj_hashfn && !params->obj_cmpfn)) - return -EINVAL; - - if (params->nulls_base && params->nulls_base < (1U << RHT_BASE_SHIFT)) - return -EINVAL; - - memset(ht, 0, sizeof(*ht)); - mutex_init(&ht->mutex); - spin_lock_init(&ht->lock); - memcpy(&ht->p, params, sizeof(*params)); - - if (params->min_size) - ht->p.min_size = roundup_pow_of_two(params->min_size); - - if (params->max_size) - ht->p.max_size = rounddown_pow_of_two(params->max_size); - - if (params->insecure_max_entries) - ht->p.insecure_max_entries = - rounddown_pow_of_two(params->insecure_max_entries); - else - ht->p.insecure_max_entries = ht->p.max_size * 2; - - ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE); - - if (params->nelem_hint) - size = rounded_hashtable_size(&ht->p); - - /* The maximum (not average) chain length grows with the - * size of the hash table, at a rate of (log N)/(log log N). - * The value of 16 is selected so that even if the hash - * table grew to 2^32 you would not expect the maximum - * chain length to exceed it unless we are under attack - * (or extremely unlucky). - * - * As this limit is only to detect attacks, we don't need - * to set it to a lower value as you'd need the chain - * length to vastly exceed 16 to have any real effect - * on the system. - */ - if (!params->insecure_elasticity) - ht->elasticity = 16; - - if (params->locks_mul) - ht->p.locks_mul = roundup_pow_of_two(params->locks_mul); - else - ht->p.locks_mul = BUCKET_LOCKS_PER_CPU; - - ht->key_len = ht->p.key_len; - if (!params->hashfn) { - ht->p.hashfn = jhash; - - if (!(ht->key_len & (sizeof(u32) - 1))) { - ht->key_len /= sizeof(u32); - ht->p.hashfn = rhashtable_jhash2; - } - } - - tbl = bucket_table_alloc(ht, size, GFP_KERNEL); - if (tbl == NULL) - return -ENOMEM; - - atomic_set(&ht->nelems, 0); - - RCU_INIT_POINTER(ht->tbl, tbl); - - INIT_WORK(&ht->run_work, rht_deferred_worker); - - return 0; -} - -/** - * rhashtable_free_and_destroy - free elements and destroy hash table - * @ht: the hash table to destroy - * @free_fn: callback to release resources of element - * @arg: pointer passed to free_fn - * - * Stops an eventual async resize. If defined, invokes free_fn for each - * element to releasal resources. Please note that RCU protected - * readers may still be accessing the elements. Releasing of resources - * must occur in a compatible manner. Then frees the bucket array. - * - * This function will eventually sleep to wait for an async resize - * to complete. The caller is responsible that no further write operations - * occurs in parallel. - */ -void rhashtable_free_and_destroy(struct rhashtable *ht, - void (*free_fn)(void *ptr, void *arg), - void *arg) -{ - const struct bucket_table *tbl; - unsigned int i; - - cancel_work_sync(&ht->run_work); - - mutex_lock(&ht->mutex); - tbl = rht_dereference(ht->tbl, ht); - if (free_fn) { - for (i = 0; i < tbl->size; i++) { - struct rhash_head *pos, *next; - - for (pos = rht_dereference(tbl->buckets[i], ht), - next = !rht_is_a_nulls(pos) ? - rht_dereference(pos->next, ht) : NULL; - !rht_is_a_nulls(pos); - pos = next, - next = !rht_is_a_nulls(pos) ? - rht_dereference(pos->next, ht) : NULL) - free_fn(rht_obj(ht, pos), arg); - } - } - - bucket_table_free(tbl); - mutex_unlock(&ht->mutex); -} - -void rhashtable_destroy(struct rhashtable *ht) -{ - return rhashtable_free_and_destroy(ht, NULL, NULL); -} - +/* + * Resizable, Scalable, Concurrent Hash Table + * + * Copyright (c) 2015 Herbert Xu + * Copyright (c) 2014-2015 Thomas Graf + * Copyright (c) 2008-2014 Patrick McHardy + * + * Code partially derived from nft_hash + * Rewritten with rehash code from br_multicast plus single list + * pointer as suggested by Josh Triplett + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define HASH_DEFAULT_SIZE 64UL +#define HASH_MIN_SIZE 4U +#define BUCKET_LOCKS_PER_CPU 128UL + +static u32 head_hashfn(struct rhashtable *ht, + const struct bucket_table *tbl, + const struct rhash_head *he) +{ + return rht_head_hashfn(ht, tbl, he, ht->p); +} + +#ifdef CONFIG_PROVE_LOCKING +#define ASSERT_RHT_MUTEX(HT) BUG_ON(!lockdep_rht_mutex_is_held(HT)) + +int lockdep_rht_mutex_is_held(struct rhashtable *ht) +{ + return (debug_locks) ? lockdep_is_held(&ht->mutex) : 1; +} + +int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, u32 hash) +{ + spinlock_t *lock = rht_bucket_lock(tbl, hash); + + return (debug_locks) ? lockdep_is_held(lock) : 1; +} +#else +#define ASSERT_RHT_MUTEX(HT) +#endif + + +static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl, + gfp_t gfp) +{ + unsigned int i, size; +#if defined(CONFIG_PROVE_LOCKING) + unsigned int nr_pcpus = 2; +#else + unsigned int nr_pcpus = num_possible_cpus(); +#endif + + nr_pcpus = min_t(unsigned int, nr_pcpus, 32UL); + size = roundup_pow_of_two(nr_pcpus * ht->p.locks_mul); + + /* Never allocate more than 0.5 locks per bucket */ + size = min_t(unsigned int, size, tbl->size >> 1); + + if (sizeof(spinlock_t) != 0) { +#ifdef CONFIG_NUMA + if (size * sizeof(spinlock_t) > PAGE_SIZE && + gfp == GFP_KERNEL) + tbl->locks = vmalloc(size * sizeof(spinlock_t)); + else +#endif + tbl->locks = kmalloc_array(size, sizeof(spinlock_t), + gfp); + if (!tbl->locks) + return -ENOMEM; + for (i = 0; i < size; i++) + spin_lock_init(&tbl->locks[i]); + } + tbl->locks_mask = size - 1; + + return 0; +} + +static void bucket_table_free(const struct bucket_table *tbl) +{ + if (tbl) + kvfree(tbl->locks); + + kvfree(tbl); +} + +static void bucket_table_free_rcu(struct rcu_head *head) +{ + bucket_table_free(container_of(head, struct bucket_table, rcu)); +} + +static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, + size_t nbuckets, + gfp_t gfp) +{ + struct bucket_table *tbl = NULL; + size_t size; + int i; + + size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]); + if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER) || + gfp != GFP_KERNEL) + tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY); + if (tbl == NULL && gfp == GFP_KERNEL) + tbl = vzalloc(size); + if (tbl == NULL) + return NULL; + + tbl->size = nbuckets; + + if (alloc_bucket_locks(ht, tbl, gfp) < 0) { + bucket_table_free(tbl); + return NULL; + } + + INIT_LIST_HEAD(&tbl->walkers); + + get_random_bytes(&tbl->hash_rnd, sizeof(tbl->hash_rnd)); + + for (i = 0; i < nbuckets; i++) + INIT_RHT_NULLS_HEAD(tbl->buckets[i], ht, i); + + return tbl; +} + +static struct bucket_table *rhashtable_last_table(struct rhashtable *ht, + struct bucket_table *tbl) +{ + struct bucket_table *new_tbl; + + do { + new_tbl = tbl; + tbl = rht_dereference_rcu(tbl->future_tbl, ht); + } while (tbl); + + return new_tbl; +} + +static int rhashtable_rehash_one(struct rhashtable *ht, unsigned int old_hash) +{ + struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); + struct bucket_table *new_tbl = rhashtable_last_table(ht, + rht_dereference_rcu(old_tbl->future_tbl, ht)); + struct rhash_head __rcu **pprev = &old_tbl->buckets[old_hash]; + int err = -ENOENT; + struct rhash_head *head, *next, *entry; + spinlock_t *new_bucket_lock; + unsigned int new_hash; + + rht_for_each(entry, old_tbl, old_hash) { + err = 0; + next = rht_dereference_bucket(entry->next, old_tbl, old_hash); + + if (rht_is_a_nulls(next)) + break; + + pprev = &entry->next; + } + + if (err) + goto out; + + new_hash = head_hashfn(ht, new_tbl, entry); + + new_bucket_lock = rht_bucket_lock(new_tbl, new_hash); + + spin_lock_nested(new_bucket_lock, SINGLE_DEPTH_NESTING); + head = rht_dereference_bucket(new_tbl->buckets[new_hash], + new_tbl, new_hash); + + RCU_INIT_POINTER(entry->next, head); + + rcu_assign_pointer(new_tbl->buckets[new_hash], entry); + spin_unlock(new_bucket_lock); + + rcu_assign_pointer(*pprev, next); + +out: + return err; +} + +static void rhashtable_rehash_chain(struct rhashtable *ht, + unsigned int old_hash) +{ + struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); + spinlock_t *old_bucket_lock; + + old_bucket_lock = rht_bucket_lock(old_tbl, old_hash); + + spin_lock_bh(old_bucket_lock); + while (!rhashtable_rehash_one(ht, old_hash)) + ; + old_tbl->rehash++; + spin_unlock_bh(old_bucket_lock); +} + +static int rhashtable_rehash_attach(struct rhashtable *ht, + struct bucket_table *old_tbl, + struct bucket_table *new_tbl) +{ + /* Protect future_tbl using the first bucket lock. */ + spin_lock_bh(old_tbl->locks); + + /* Did somebody beat us to it? */ + if (rcu_access_pointer(old_tbl->future_tbl)) { + spin_unlock_bh(old_tbl->locks); + return -EEXIST; + } + + /* Make insertions go into the new, empty table right away. Deletions + * and lookups will be attempted in both tables until we synchronize. + */ + rcu_assign_pointer(old_tbl->future_tbl, new_tbl); + + /* Ensure the new table is visible to readers. */ + smp_wmb(); + + spin_unlock_bh(old_tbl->locks); + + return 0; +} + +static int rhashtable_rehash_table(struct rhashtable *ht) +{ + struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht); + struct bucket_table *new_tbl; + struct rhashtable_walker *walker; + unsigned int old_hash; + + new_tbl = rht_dereference(old_tbl->future_tbl, ht); + if (!new_tbl) + return 0; + + for (old_hash = 0; old_hash < old_tbl->size; old_hash++) + rhashtable_rehash_chain(ht, old_hash); + + /* Publish the new table pointer. */ + rcu_assign_pointer(ht->tbl, new_tbl); + + spin_lock(&ht->lock); + list_for_each_entry(walker, &old_tbl->walkers, list) + walker->tbl = NULL; + spin_unlock(&ht->lock); + + /* Wait for readers. All new readers will see the new + * table, and thus no references to the old table will + * remain. + */ + call_rcu(&old_tbl->rcu, bucket_table_free_rcu); + + return rht_dereference(new_tbl->future_tbl, ht) ? -EAGAIN : 0; +} + +/** + * rhashtable_expand - Expand hash table while allowing concurrent lookups + * @ht: the hash table to expand + * + * A secondary bucket array is allocated and the hash entries are migrated. + * + * This function may only be called in a context where it is safe to call + * synchronize_rcu(), e.g. not within a rcu_read_lock() section. + * + * The caller must ensure that no concurrent resizing occurs by holding + * ht->mutex. + * + * It is valid to have concurrent insertions and deletions protected by per + * bucket locks or concurrent RCU protected lookups and traversals. + */ +static int rhashtable_expand(struct rhashtable *ht) +{ + struct bucket_table *new_tbl, *old_tbl = rht_dereference(ht->tbl, ht); + int err; + + ASSERT_RHT_MUTEX(ht); + + old_tbl = rhashtable_last_table(ht, old_tbl); + + new_tbl = bucket_table_alloc(ht, old_tbl->size * 2, GFP_KERNEL); + if (new_tbl == NULL) + return -ENOMEM; + + err = rhashtable_rehash_attach(ht, old_tbl, new_tbl); + if (err) + bucket_table_free(new_tbl); + + return err; +} + +/** + * rhashtable_shrink - Shrink hash table while allowing concurrent lookups + * @ht: the hash table to shrink + * + * This function shrinks the hash table to fit, i.e., the smallest + * size would not cause it to expand right away automatically. + * + * The caller must ensure that no concurrent resizing occurs by holding + * ht->mutex. + * + * The caller must ensure that no concurrent table mutations take place. + * It is however valid to have concurrent lookups if they are RCU protected. + * + * It is valid to have concurrent insertions and deletions protected by per + * bucket locks or concurrent RCU protected lookups and traversals. + */ +static int rhashtable_shrink(struct rhashtable *ht) +{ + struct bucket_table *new_tbl, *old_tbl = rht_dereference(ht->tbl, ht); + unsigned int size; + int err; + + ASSERT_RHT_MUTEX(ht); + + size = roundup_pow_of_two(atomic_read(&ht->nelems) * 3 / 2); + if (size < ht->p.min_size) + size = ht->p.min_size; + + if (old_tbl->size <= size) + return 0; + + if (rht_dereference(old_tbl->future_tbl, ht)) + return -EEXIST; + + new_tbl = bucket_table_alloc(ht, size, GFP_KERNEL); + if (new_tbl == NULL) + return -ENOMEM; + + err = rhashtable_rehash_attach(ht, old_tbl, new_tbl); + if (err) + bucket_table_free(new_tbl); + + return err; +} + +static void rht_deferred_worker(struct work_struct *work) +{ + struct rhashtable *ht; + struct bucket_table *tbl; + int err = 0; + + ht = container_of(work, struct rhashtable, run_work); + mutex_lock(&ht->mutex); + + tbl = rht_dereference(ht->tbl, ht); + tbl = rhashtable_last_table(ht, tbl); + + if (rht_grow_above_75(ht, tbl)) + rhashtable_expand(ht); + else if (ht->p.automatic_shrinking && rht_shrink_below_30(ht, tbl)) + rhashtable_shrink(ht); + + err = rhashtable_rehash_table(ht); + + mutex_unlock(&ht->mutex); + + if (err) + schedule_work(&ht->run_work); +} + +static bool rhashtable_check_elasticity(struct rhashtable *ht, + struct bucket_table *tbl, + unsigned int hash) +{ + unsigned int elasticity = ht->elasticity; + struct rhash_head *head; + + rht_for_each(head, tbl, hash) + if (!--elasticity) + return true; + + return false; +} + +int rhashtable_insert_rehash(struct rhashtable *ht, + struct bucket_table *tbl) +{ + struct bucket_table *old_tbl; + struct bucket_table *new_tbl; + unsigned int size; + int err; + + old_tbl = rht_dereference_rcu(ht->tbl, ht); + + size = tbl->size; + + err = -EBUSY; + + if (rht_grow_above_75(ht, tbl)) + size *= 2; + /* Do not schedule more than one rehash */ + else if (old_tbl != tbl) + goto fail; + + err = -ENOMEM; + + new_tbl = bucket_table_alloc(ht, size, GFP_ATOMIC); + if (new_tbl == NULL) + goto fail; + + err = rhashtable_rehash_attach(ht, tbl, new_tbl); + if (err) { + bucket_table_free(new_tbl); + if (err == -EEXIST) + err = 0; + } else + schedule_work(&ht->run_work); + + return err; + +fail: + /* Do not fail the insert if someone else did a rehash. */ + if (likely(rcu_dereference_raw(tbl->future_tbl))) + return 0; + + /* Schedule async rehash to retry allocation in process context. */ + if (err == -ENOMEM) + schedule_work(&ht->run_work); + + return err; +} + +struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht, + const void *key, + struct rhash_head *obj, + struct bucket_table *tbl) +{ + struct rhash_head *head; + unsigned int hash; + int err; + + tbl = rhashtable_last_table(ht, tbl); + hash = head_hashfn(ht, tbl, obj); + spin_lock_nested(rht_bucket_lock(tbl, hash), SINGLE_DEPTH_NESTING); + + err = -EEXIST; + if (key && rhashtable_lookup_fast(ht, key, ht->p)) + goto exit; + + err = -E2BIG; + if (unlikely(rht_grow_above_max(ht, tbl))) + goto exit; + + err = -EAGAIN; + if (rhashtable_check_elasticity(ht, tbl, hash) || + rht_grow_above_100(ht, tbl)) + goto exit; + + err = 0; + + head = rht_dereference_bucket(tbl->buckets[hash], tbl, hash); + + RCU_INIT_POINTER(obj->next, head); + + rcu_assign_pointer(tbl->buckets[hash], obj); + + atomic_inc(&ht->nelems); + +exit: + spin_unlock(rht_bucket_lock(tbl, hash)); + + if (err == 0) + return NULL; + else if (err == -EAGAIN) + return tbl; + else + return ERR_PTR(err); +} + +/** + * rhashtable_walk_init - Initialise an iterator + * @ht: Table to walk over + * @iter: Hash table Iterator + * + * This function prepares a hash table walk. + * + * Note that if you restart a walk after rhashtable_walk_stop you + * may see the same object twice. Also, you may miss objects if + * there are removals in between rhashtable_walk_stop and the next + * call to rhashtable_walk_start. + * + * For a completely stable walk you should construct your own data + * structure outside the hash table. + * + * This function may sleep so you must not call it from interrupt + * context or with spin locks held. + * + * You must call rhashtable_walk_exit if this function returns + * successfully. + */ +int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter) +{ + iter->ht = ht; + iter->p = NULL; + iter->slot = 0; + iter->skip = 0; + + iter->walker = kmalloc(sizeof(*iter->walker), GFP_KERNEL); + if (!iter->walker) + return -ENOMEM; + + spin_lock(&ht->lock); + iter->walker->tbl = + rcu_dereference_protected(ht->tbl, lockdep_is_held(&ht->lock)); + list_add(&iter->walker->list, &iter->walker->tbl->walkers); + spin_unlock(&ht->lock); + + return 0; +} + +/** + * rhashtable_walk_exit - Free an iterator + * @iter: Hash table Iterator + * + * This function frees resources allocated by rhashtable_walk_init. + */ +void rhashtable_walk_exit(struct rhashtable_iter *iter) +{ + spin_lock(&iter->ht->lock); + if (iter->walker->tbl) + list_del(&iter->walker->list); + spin_unlock(&iter->ht->lock); + kfree(iter->walker); +} + +/** + * rhashtable_walk_start - Start a hash table walk + * @iter: Hash table iterator + * + * Start a hash table walk. Note that we take the RCU lock in all + * cases including when we return an error. So you must always call + * rhashtable_walk_stop to clean up. + * + * Returns zero if successful. + * + * Returns -EAGAIN if resize event occured. Note that the iterator + * will rewind back to the beginning and you may use it immediately + * by calling rhashtable_walk_next. + */ +int rhashtable_walk_start(struct rhashtable_iter *iter) + __acquires(RCU) +{ + struct rhashtable *ht = iter->ht; + + rcu_read_lock(); + + spin_lock(&ht->lock); + if (iter->walker->tbl) + list_del(&iter->walker->list); + spin_unlock(&ht->lock); + + if (!iter->walker->tbl) { + iter->walker->tbl = rht_dereference_rcu(ht->tbl, ht); + return -EAGAIN; + } + + return 0; +} + +/** + * rhashtable_walk_next - Return the next object and advance the iterator + * @iter: Hash table iterator + * + * Note that you must call rhashtable_walk_stop when you are finished + * with the walk. + * + * Returns the next object or NULL when the end of the table is reached. + * + * Returns -EAGAIN if resize event occured. Note that the iterator + * will rewind back to the beginning and you may continue to use it. + */ +void *rhashtable_walk_next(struct rhashtable_iter *iter) +{ + struct bucket_table *tbl = iter->walker->tbl; + struct rhashtable *ht = iter->ht; + struct rhash_head *p = iter->p; + + if (p) { + p = rht_dereference_bucket_rcu(p->next, tbl, iter->slot); + goto next; + } + + for (; iter->slot < tbl->size; iter->slot++) { + int skip = iter->skip; + + rht_for_each_rcu(p, tbl, iter->slot) { + if (!skip) + break; + skip--; + } + +next: + if (!rht_is_a_nulls(p)) { + iter->skip++; + iter->p = p; + return rht_obj(ht, p); + } + + iter->skip = 0; + } + + iter->p = NULL; + + /* Ensure we see any new tables. */ + smp_rmb(); + + iter->walker->tbl = rht_dereference_rcu(tbl->future_tbl, ht); + if (iter->walker->tbl) { + iter->slot = 0; + iter->skip = 0; + return ERR_PTR(-EAGAIN); + } + + return NULL; +} + +/** + * rhashtable_walk_stop - Finish a hash table walk + * @iter: Hash table iterator + * + * Finish a hash table walk. + */ +void rhashtable_walk_stop(struct rhashtable_iter *iter) + __releases(RCU) +{ + struct rhashtable *ht; + struct bucket_table *tbl = iter->walker->tbl; + + if (!tbl) + goto out; + + ht = iter->ht; + + spin_lock(&ht->lock); + if (tbl->rehash < tbl->size) + list_add(&iter->walker->list, &tbl->walkers); + else + iter->walker->tbl = NULL; + spin_unlock(&ht->lock); + + iter->p = NULL; + +out: + rcu_read_unlock(); +} + +static size_t rounded_hashtable_size(const struct rhashtable_params *params) +{ + return max(roundup_pow_of_two(params->nelem_hint * 4 / 3), + (unsigned long)params->min_size); +} + +static u32 rhashtable_jhash2(const void *key, u32 length, u32 seed) +{ + return jhash2(key, length, seed); +} + +/** + * rhashtable_init - initialize a new hash table + * @ht: hash table to be initialized + * @params: configuration parameters + * + * Initializes a new hash table based on the provided configuration + * parameters. A table can be configured either with a variable or + * fixed length key: + * + * Configuration Example 1: Fixed length keys + * struct test_obj { + * int key; + * void * my_member; + * struct rhash_head node; + * }; + * + * struct rhashtable_params params = { + * .head_offset = offsetof(struct test_obj, node), + * .key_offset = offsetof(struct test_obj, key), + * .key_len = sizeof(int), + * .hashfn = jhash, + * .nulls_base = (1U << RHT_BASE_SHIFT), + * }; + * + * Configuration Example 2: Variable length keys + * struct test_obj { + * [...] + * struct rhash_head node; + * }; + * + * u32 my_hash_fn(const void *data, u32 len, u32 seed) + * { + * struct test_obj *obj = data; + * + * return [... hash ...]; + * } + * + * struct rhashtable_params params = { + * .head_offset = offsetof(struct test_obj, node), + * .hashfn = jhash, + * .obj_hashfn = my_hash_fn, + * }; + */ +int rhashtable_init(struct rhashtable *ht, + const struct rhashtable_params *params) +{ + struct bucket_table *tbl; + size_t size; + + size = HASH_DEFAULT_SIZE; + + if ((!params->key_len && !params->obj_hashfn) || + (params->obj_hashfn && !params->obj_cmpfn)) + return -EINVAL; + + if (params->nulls_base && params->nulls_base < (1U << RHT_BASE_SHIFT)) + return -EINVAL; + + memset(ht, 0, sizeof(*ht)); + mutex_init(&ht->mutex); + spin_lock_init(&ht->lock); + memcpy(&ht->p, params, sizeof(*params)); + + if (params->min_size) + ht->p.min_size = roundup_pow_of_two(params->min_size); + + if (params->max_size) + ht->p.max_size = rounddown_pow_of_two(params->max_size); + + if (params->insecure_max_entries) + ht->p.insecure_max_entries = + rounddown_pow_of_two(params->insecure_max_entries); + else + ht->p.insecure_max_entries = ht->p.max_size * 2; + + ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE); + + if (params->nelem_hint) + size = rounded_hashtable_size(&ht->p); + + /* The maximum (not average) chain length grows with the + * size of the hash table, at a rate of (log N)/(log log N). + * The value of 16 is selected so that even if the hash + * table grew to 2^32 you would not expect the maximum + * chain length to exceed it unless we are under attack + * (or extremely unlucky). + * + * As this limit is only to detect attacks, we don't need + * to set it to a lower value as you'd need the chain + * length to vastly exceed 16 to have any real effect + * on the system. + */ + if (!params->insecure_elasticity) + ht->elasticity = 16; + + if (params->locks_mul) + ht->p.locks_mul = roundup_pow_of_two(params->locks_mul); + else + ht->p.locks_mul = BUCKET_LOCKS_PER_CPU; + + ht->key_len = ht->p.key_len; + if (!params->hashfn) { + ht->p.hashfn = jhash; + + if (!(ht->key_len & (sizeof(u32) - 1))) { + ht->key_len /= sizeof(u32); + ht->p.hashfn = rhashtable_jhash2; + } + } + + tbl = bucket_table_alloc(ht, size, GFP_KERNEL); + if (tbl == NULL) + return -ENOMEM; + + atomic_set(&ht->nelems, 0); + + RCU_INIT_POINTER(ht->tbl, tbl); + + INIT_WORK(&ht->run_work, rht_deferred_worker); + + return 0; +} + +/** + * rhashtable_free_and_destroy - free elements and destroy hash table + * @ht: the hash table to destroy + * @free_fn: callback to release resources of element + * @arg: pointer passed to free_fn + * + * Stops an eventual async resize. If defined, invokes free_fn for each + * element to releasal resources. Please note that RCU protected + * readers may still be accessing the elements. Releasing of resources + * must occur in a compatible manner. Then frees the bucket array. + * + * This function will eventually sleep to wait for an async resize + * to complete. The caller is responsible that no further write operations + * occurs in parallel. + */ +void rhashtable_free_and_destroy(struct rhashtable *ht, + void (*free_fn)(void *ptr, void *arg), + void *arg) +{ + const struct bucket_table *tbl; + unsigned int i; + + cancel_work_sync(&ht->run_work); + + mutex_lock(&ht->mutex); + tbl = rht_dereference(ht->tbl, ht); + if (free_fn) { + for (i = 0; i < tbl->size; i++) { + struct rhash_head *pos, *next; + + for (pos = rht_dereference(tbl->buckets[i], ht), + next = !rht_is_a_nulls(pos) ? + rht_dereference(pos->next, ht) : NULL; + !rht_is_a_nulls(pos); + pos = next, + next = !rht_is_a_nulls(pos) ? + rht_dereference(pos->next, ht) : NULL) + free_fn(rht_obj(ht, pos), arg); + } + } + + bucket_table_free(tbl); + mutex_unlock(&ht->mutex); +} + +void rhashtable_destroy(struct rhashtable *ht) +{ + return rhashtable_free_and_destroy(ht, NULL, NULL); +} + diff --git a/os_dep/linux/rhashtable.h b/os_dep/linux/rhashtable.h index a6db325..b47107f 100644 --- a/os_dep/linux/rhashtable.h +++ b/os_dep/linux/rhashtable.h @@ -1,827 +1,827 @@ -/* - * Resizable, Scalable, Concurrent Hash Table - * - * Copyright (c) 2015 Herbert Xu - * Copyright (c) 2014-2015 Thomas Graf - * Copyright (c) 2008-2014 Patrick McHardy - * - * Code partially derived from nft_hash - * Rewritten with rehash code from br_multicast plus single list - * pointer as suggested by Josh Triplett - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef _LINUX_RHASHTABLE_H -#define _LINUX_RHASHTABLE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * The end of the chain is marked with a special nulls marks which has - * the following format: - * - * +-------+-----------------------------------------------------+-+ - * | Base | Hash |1| - * +-------+-----------------------------------------------------+-+ - * - * Base (4 bits) : Reserved to distinguish between multiple tables. - * Specified via &struct rhashtable_params.nulls_base. - * Hash (27 bits): Full hash (unmasked) of first element added to bucket - * 1 (1 bit) : Nulls marker (always set) - * - * The remaining bits of the next pointer remain unused for now. - */ -#define RHT_BASE_BITS 4 -#define RHT_HASH_BITS 27 -#define RHT_BASE_SHIFT RHT_HASH_BITS - -/* Base bits plus 1 bit for nulls marker */ -#define RHT_HASH_RESERVED_SPACE (RHT_BASE_BITS + 1) - -struct rhash_head { - struct rhash_head __rcu *next; -}; - -/** - * struct bucket_table - Table of hash buckets - * @size: Number of hash buckets - * @rehash: Current bucket being rehashed - * @hash_rnd: Random seed to fold into hash - * @locks_mask: Mask to apply before accessing locks[] - * @locks: Array of spinlocks protecting individual buckets - * @walkers: List of active walkers - * @rcu: RCU structure for freeing the table - * @future_tbl: Table under construction during rehashing - * @buckets: size * hash buckets - */ -struct bucket_table { - unsigned int size; - unsigned int rehash; - u32 hash_rnd; - unsigned int locks_mask; - spinlock_t *locks; - struct list_head walkers; - struct rcu_head rcu; - - struct bucket_table __rcu *future_tbl; - - struct rhash_head __rcu *buckets[] ____cacheline_aligned_in_smp; -}; - -/** - * struct rhashtable_compare_arg - Key for the function rhashtable_compare - * @ht: Hash table - * @key: Key to compare against - */ -struct rhashtable_compare_arg { - struct rhashtable *ht; - const void *key; -}; - -typedef u32 (*rht_hashfn_t)(const void *data, u32 len, u32 seed); -typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 len, u32 seed); -typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *arg, - const void *obj); - -struct rhashtable; - -/** - * struct rhashtable_params - Hash table construction parameters - * @nelem_hint: Hint on number of elements, should be 75% of desired size - * @key_len: Length of key - * @key_offset: Offset of key in struct to be hashed - * @head_offset: Offset of rhash_head in struct to be hashed - * @insecure_max_entries: Maximum number of entries (may be exceeded) - * @max_size: Maximum size while expanding - * @min_size: Minimum size while shrinking - * @nulls_base: Base value to generate nulls marker - * @insecure_elasticity: Set to true to disable chain length checks - * @automatic_shrinking: Enable automatic shrinking of tables - * @locks_mul: Number of bucket locks to allocate per cpu (default: 128) - * @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash) - * @obj_hashfn: Function to hash object - * @obj_cmpfn: Function to compare key with object - */ -struct rhashtable_params { - size_t nelem_hint; - size_t key_len; - size_t key_offset; - size_t head_offset; - unsigned int insecure_max_entries; - unsigned int max_size; - unsigned int min_size; - u32 nulls_base; - bool insecure_elasticity; - bool automatic_shrinking; - size_t locks_mul; - rht_hashfn_t hashfn; - rht_obj_hashfn_t obj_hashfn; - rht_obj_cmpfn_t obj_cmpfn; -}; - -/** - * struct rhashtable - Hash table handle - * @tbl: Bucket table - * @nelems: Number of elements in table - * @key_len: Key length for hashfn - * @elasticity: Maximum chain length before rehash - * @p: Configuration parameters - * @run_work: Deferred worker to expand/shrink asynchronously - * @mutex: Mutex to protect current/future table swapping - * @lock: Spin lock to protect walker list - */ -struct rhashtable { - struct bucket_table __rcu *tbl; - atomic_t nelems; - unsigned int key_len; - unsigned int elasticity; - struct rhashtable_params p; - struct work_struct run_work; - struct mutex mutex; - spinlock_t lock; -}; - -/** - * struct rhashtable_walker - Hash table walker - * @list: List entry on list of walkers - * @tbl: The table that we were walking over - */ -struct rhashtable_walker { - struct list_head list; - struct bucket_table *tbl; -}; - -/** - * struct rhashtable_iter - Hash table iterator, fits into netlink cb - * @ht: Table to iterate through - * @p: Current pointer - * @walker: Associated rhashtable walker - * @slot: Current slot - * @skip: Number of entries to skip in slot - */ -struct rhashtable_iter { - struct rhashtable *ht; - struct rhash_head *p; - struct rhashtable_walker *walker; - unsigned int slot; - unsigned int skip; -}; - -static inline unsigned long rht_marker(const struct rhashtable *ht, u32 hash) -{ - return NULLS_MARKER(ht->p.nulls_base + hash); -} - -#define INIT_RHT_NULLS_HEAD(ptr, ht, hash) \ - ((ptr) = (typeof(ptr)) rht_marker(ht, hash)) - -static inline bool rht_is_a_nulls(const struct rhash_head *ptr) -{ - return ((unsigned long) ptr & 1); -} - -static inline unsigned long rht_get_nulls_value(const struct rhash_head *ptr) -{ - return ((unsigned long) ptr) >> 1; -} - -static inline void *rht_obj(const struct rhashtable *ht, - const struct rhash_head *he) -{ - return (char *)he - ht->p.head_offset; -} - -static inline unsigned int rht_bucket_index(const struct bucket_table *tbl, - unsigned int hash) -{ - return (hash >> RHT_HASH_RESERVED_SPACE) & (tbl->size - 1); -} - -static inline unsigned int rht_key_hashfn( - struct rhashtable *ht, const struct bucket_table *tbl, - const void *key, const struct rhashtable_params params) -{ - unsigned int hash; - - /* params must be equal to ht->p if it isn't constant. */ - if (!__builtin_constant_p(params.key_len)) - hash = ht->p.hashfn(key, ht->key_len, tbl->hash_rnd); - else if (params.key_len) { - unsigned int key_len = params.key_len; - - if (params.hashfn) - hash = params.hashfn(key, key_len, tbl->hash_rnd); - else if (key_len & (sizeof(u32) - 1)) - hash = jhash(key, key_len, tbl->hash_rnd); - else - hash = jhash2(key, key_len / sizeof(u32), - tbl->hash_rnd); - } else { - unsigned int key_len = ht->p.key_len; - - if (params.hashfn) - hash = params.hashfn(key, key_len, tbl->hash_rnd); - else - hash = jhash(key, key_len, tbl->hash_rnd); - } - - return rht_bucket_index(tbl, hash); -} - -static inline unsigned int rht_head_hashfn( - struct rhashtable *ht, const struct bucket_table *tbl, - const struct rhash_head *he, const struct rhashtable_params params) -{ - const char *ptr = rht_obj(ht, he); - - return likely(params.obj_hashfn) ? - rht_bucket_index(tbl, params.obj_hashfn(ptr, params.key_len ?: - ht->p.key_len, - tbl->hash_rnd)) : - rht_key_hashfn(ht, tbl, ptr + params.key_offset, params); -} - -/** - * rht_grow_above_75 - returns true if nelems > 0.75 * table-size - * @ht: hash table - * @tbl: current table - */ -static inline bool rht_grow_above_75(const struct rhashtable *ht, - const struct bucket_table *tbl) -{ - /* Expand table when exceeding 75% load */ - return atomic_read(&ht->nelems) > (tbl->size / 4 * 3) && - (!ht->p.max_size || tbl->size < ht->p.max_size); -} - -/** - * rht_shrink_below_30 - returns true if nelems < 0.3 * table-size - * @ht: hash table - * @tbl: current table - */ -static inline bool rht_shrink_below_30(const struct rhashtable *ht, - const struct bucket_table *tbl) -{ - /* Shrink table beneath 30% load */ - return atomic_read(&ht->nelems) < (tbl->size * 3 / 10) && - tbl->size > ht->p.min_size; -} - -/** - * rht_grow_above_100 - returns true if nelems > table-size - * @ht: hash table - * @tbl: current table - */ -static inline bool rht_grow_above_100(const struct rhashtable *ht, - const struct bucket_table *tbl) -{ - return atomic_read(&ht->nelems) > tbl->size && - (!ht->p.max_size || tbl->size < ht->p.max_size); -} - -/** - * rht_grow_above_max - returns true if table is above maximum - * @ht: hash table - * @tbl: current table - */ -static inline bool rht_grow_above_max(const struct rhashtable *ht, - const struct bucket_table *tbl) -{ - return ht->p.insecure_max_entries && - atomic_read(&ht->nelems) >= ht->p.insecure_max_entries; -} - -/* The bucket lock is selected based on the hash and protects mutations - * on a group of hash buckets. - * - * A maximum of tbl->size/2 bucket locks is allocated. This ensures that - * a single lock always covers both buckets which may both contains - * entries which link to the same bucket of the old table during resizing. - * This allows to simplify the locking as locking the bucket in both - * tables during resize always guarantee protection. - * - * IMPORTANT: When holding the bucket lock of both the old and new table - * during expansions and shrinking, the old bucket lock must always be - * acquired first. - */ -static inline spinlock_t *rht_bucket_lock(const struct bucket_table *tbl, - unsigned int hash) -{ - return &tbl->locks[hash & tbl->locks_mask]; -} - -#ifdef CONFIG_PROVE_LOCKING -int lockdep_rht_mutex_is_held(struct rhashtable *ht); -int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, u32 hash); -#else -static inline int lockdep_rht_mutex_is_held(struct rhashtable *ht) -{ - return 1; -} - -static inline int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, - u32 hash) -{ - return 1; -} -#endif /* CONFIG_PROVE_LOCKING */ - -int rhashtable_init(struct rhashtable *ht, - const struct rhashtable_params *params); - -struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht, - const void *key, - struct rhash_head *obj, - struct bucket_table *old_tbl); -int rhashtable_insert_rehash(struct rhashtable *ht, struct bucket_table *tbl); - -int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter); -void rhashtable_walk_exit(struct rhashtable_iter *iter); -int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU); -void *rhashtable_walk_next(struct rhashtable_iter *iter); -void rhashtable_walk_stop(struct rhashtable_iter *iter) __releases(RCU); - -void rhashtable_free_and_destroy(struct rhashtable *ht, - void (*free_fn)(void *ptr, void *arg), - void *arg); -void rhashtable_destroy(struct rhashtable *ht); - -#define rht_dereference(p, ht) \ - rcu_dereference_protected(p, lockdep_rht_mutex_is_held(ht)) - -#define rht_dereference_rcu(p, ht) \ - rcu_dereference_check(p, lockdep_rht_mutex_is_held(ht)) - -#define rht_dereference_bucket(p, tbl, hash) \ - rcu_dereference_protected(p, lockdep_rht_bucket_is_held(tbl, hash)) - -#define rht_dereference_bucket_rcu(p, tbl, hash) \ - rcu_dereference_check(p, lockdep_rht_bucket_is_held(tbl, hash)) - -#define rht_entry(tpos, pos, member) \ - ({ tpos = container_of(pos, typeof(*tpos), member); 1; }) - -/** - * rht_for_each_continue - continue iterating over hash chain - * @pos: the &struct rhash_head to use as a loop cursor. - * @head: the previous &struct rhash_head to continue from - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - */ -#define rht_for_each_continue(pos, head, tbl, hash) \ - for (pos = rht_dereference_bucket(head, tbl, hash); \ - !rht_is_a_nulls(pos); \ - pos = rht_dereference_bucket((pos)->next, tbl, hash)) - -/** - * rht_for_each - iterate over hash chain - * @pos: the &struct rhash_head to use as a loop cursor. - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - */ -#define rht_for_each(pos, tbl, hash) \ - rht_for_each_continue(pos, (tbl)->buckets[hash], tbl, hash) - -/** - * rht_for_each_entry_continue - continue iterating over hash chain - * @tpos: the type * to use as a loop cursor. - * @pos: the &struct rhash_head to use as a loop cursor. - * @head: the previous &struct rhash_head to continue from - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - * @member: name of the &struct rhash_head within the hashable struct. - */ -#define rht_for_each_entry_continue(tpos, pos, head, tbl, hash, member) \ - for (pos = rht_dereference_bucket(head, tbl, hash); \ - (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ - pos = rht_dereference_bucket((pos)->next, tbl, hash)) - -/** - * rht_for_each_entry - iterate over hash chain of given type - * @tpos: the type * to use as a loop cursor. - * @pos: the &struct rhash_head to use as a loop cursor. - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - * @member: name of the &struct rhash_head within the hashable struct. - */ -#define rht_for_each_entry(tpos, pos, tbl, hash, member) \ - rht_for_each_entry_continue(tpos, pos, (tbl)->buckets[hash], \ - tbl, hash, member) - -/** - * rht_for_each_entry_safe - safely iterate over hash chain of given type - * @tpos: the type * to use as a loop cursor. - * @pos: the &struct rhash_head to use as a loop cursor. - * @next: the &struct rhash_head to use as next in loop cursor. - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - * @member: name of the &struct rhash_head within the hashable struct. - * - * This hash chain list-traversal primitive allows for the looped code to - * remove the loop cursor from the list. - */ -#define rht_for_each_entry_safe(tpos, pos, next, tbl, hash, member) \ - for (pos = rht_dereference_bucket((tbl)->buckets[hash], tbl, hash), \ - next = !rht_is_a_nulls(pos) ? \ - rht_dereference_bucket(pos->next, tbl, hash) : NULL; \ - (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ - pos = next, \ - next = !rht_is_a_nulls(pos) ? \ - rht_dereference_bucket(pos->next, tbl, hash) : NULL) - -/** - * rht_for_each_rcu_continue - continue iterating over rcu hash chain - * @pos: the &struct rhash_head to use as a loop cursor. - * @head: the previous &struct rhash_head to continue from - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - * - * This hash chain list-traversal primitive may safely run concurrently with - * the _rcu mutation primitives such as rhashtable_insert() as long as the - * traversal is guarded by rcu_read_lock(). - */ -#define rht_for_each_rcu_continue(pos, head, tbl, hash) \ - for (({barrier(); }), \ - pos = rht_dereference_bucket_rcu(head, tbl, hash); \ - !rht_is_a_nulls(pos); \ - pos = rcu_dereference_raw(pos->next)) - -/** - * rht_for_each_rcu - iterate over rcu hash chain - * @pos: the &struct rhash_head to use as a loop cursor. - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - * - * This hash chain list-traversal primitive may safely run concurrently with - * the _rcu mutation primitives such as rhashtable_insert() as long as the - * traversal is guarded by rcu_read_lock(). - */ -#define rht_for_each_rcu(pos, tbl, hash) \ - rht_for_each_rcu_continue(pos, (tbl)->buckets[hash], tbl, hash) - -/** - * rht_for_each_entry_rcu_continue - continue iterating over rcu hash chain - * @tpos: the type * to use as a loop cursor. - * @pos: the &struct rhash_head to use as a loop cursor. - * @head: the previous &struct rhash_head to continue from - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - * @member: name of the &struct rhash_head within the hashable struct. - * - * This hash chain list-traversal primitive may safely run concurrently with - * the _rcu mutation primitives such as rhashtable_insert() as long as the - * traversal is guarded by rcu_read_lock(). - */ -#define rht_for_each_entry_rcu_continue(tpos, pos, head, tbl, hash, member) \ - for (({barrier(); }), \ - pos = rht_dereference_bucket_rcu(head, tbl, hash); \ - (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ - pos = rht_dereference_bucket_rcu(pos->next, tbl, hash)) - -/** - * rht_for_each_entry_rcu - iterate over rcu hash chain of given type - * @tpos: the type * to use as a loop cursor. - * @pos: the &struct rhash_head to use as a loop cursor. - * @tbl: the &struct bucket_table - * @hash: the hash value / bucket index - * @member: name of the &struct rhash_head within the hashable struct. - * - * This hash chain list-traversal primitive may safely run concurrently with - * the _rcu mutation primitives such as rhashtable_insert() as long as the - * traversal is guarded by rcu_read_lock(). - */ -#define rht_for_each_entry_rcu(tpos, pos, tbl, hash, member) \ - rht_for_each_entry_rcu_continue(tpos, pos, (tbl)->buckets[hash],\ - tbl, hash, member) - -static inline int rhashtable_compare(struct rhashtable_compare_arg *arg, - const void *obj) -{ - struct rhashtable *ht = arg->ht; - const char *ptr = obj; - - return memcmp(ptr + ht->p.key_offset, arg->key, ht->p.key_len); -} - -/** - * rhashtable_lookup_fast - search hash table, inlined version - * @ht: hash table - * @key: the pointer to the key - * @params: hash table parameters - * - * Computes the hash value for the key and traverses the bucket chain looking - * for a entry with an identical key. The first matching entry is returned. - * - * Returns the first entry on which the compare function returned true. - */ -static inline void *rhashtable_lookup_fast( - struct rhashtable *ht, const void *key, - const struct rhashtable_params params) -{ - struct rhashtable_compare_arg arg = { - .ht = ht, - .key = key, - }; - const struct bucket_table *tbl; - struct rhash_head *he; - unsigned int hash; - - rcu_read_lock(); - - tbl = rht_dereference_rcu(ht->tbl, ht); -restart: - hash = rht_key_hashfn(ht, tbl, key, params); - rht_for_each_rcu(he, tbl, hash) { - if (params.obj_cmpfn ? - params.obj_cmpfn(&arg, rht_obj(ht, he)) : - rhashtable_compare(&arg, rht_obj(ht, he))) - continue; - rcu_read_unlock(); - return rht_obj(ht, he); - } - - /* Ensure we see any new tables. */ - smp_rmb(); - - tbl = rht_dereference_rcu(tbl->future_tbl, ht); - if (unlikely(tbl)) - goto restart; - rcu_read_unlock(); - - return NULL; -} - -/* Internal function, please use rhashtable_insert_fast() instead */ -static inline int __rhashtable_insert_fast( - struct rhashtable *ht, const void *key, struct rhash_head *obj, - const struct rhashtable_params params) -{ - struct rhashtable_compare_arg arg = { - .ht = ht, - .key = key, - }; - struct bucket_table *tbl, *new_tbl; - struct rhash_head *head; - spinlock_t *lock; - unsigned int elasticity; - unsigned int hash; - int err; - -restart: - rcu_read_lock(); - - tbl = rht_dereference_rcu(ht->tbl, ht); - - /* All insertions must grab the oldest table containing - * the hashed bucket that is yet to be rehashed. - */ - for (;;) { - hash = rht_head_hashfn(ht, tbl, obj, params); - lock = rht_bucket_lock(tbl, hash); - spin_lock_bh(lock); - - if (tbl->rehash <= hash) - break; - - spin_unlock_bh(lock); - tbl = rht_dereference_rcu(tbl->future_tbl, ht); - } - - new_tbl = rht_dereference_rcu(tbl->future_tbl, ht); - if (unlikely(new_tbl)) { - tbl = rhashtable_insert_slow(ht, key, obj, new_tbl); - if (!IS_ERR_OR_NULL(tbl)) - goto slow_path; - - err = PTR_ERR(tbl); - goto out; - } - - err = -E2BIG; - if (unlikely(rht_grow_above_max(ht, tbl))) - goto out; - - if (unlikely(rht_grow_above_100(ht, tbl))) { -slow_path: - spin_unlock_bh(lock); - err = rhashtable_insert_rehash(ht, tbl); - rcu_read_unlock(); - if (err) - return err; - - goto restart; - } - - err = -EEXIST; - elasticity = ht->elasticity; - rht_for_each(head, tbl, hash) { - if (key && - unlikely(!(params.obj_cmpfn ? - params.obj_cmpfn(&arg, rht_obj(ht, head)) : - rhashtable_compare(&arg, rht_obj(ht, head))))) - goto out; - if (!--elasticity) - goto slow_path; - } - - err = 0; - - head = rht_dereference_bucket(tbl->buckets[hash], tbl, hash); - - RCU_INIT_POINTER(obj->next, head); - - rcu_assign_pointer(tbl->buckets[hash], obj); - - atomic_inc(&ht->nelems); - if (rht_grow_above_75(ht, tbl)) - schedule_work(&ht->run_work); - -out: - spin_unlock_bh(lock); - rcu_read_unlock(); - - return err; -} - -/** - * rhashtable_insert_fast - insert object into hash table - * @ht: hash table - * @obj: pointer to hash head inside object - * @params: hash table parameters - * - * Will take a per bucket spinlock to protect against mutual mutations - * on the same bucket. Multiple insertions may occur in parallel unless - * they map to the same bucket lock. - * - * It is safe to call this function from atomic context. - * - * Will trigger an automatic deferred table resizing if the size grows - * beyond the watermark indicated by grow_decision() which can be passed - * to rhashtable_init(). - */ -static inline int rhashtable_insert_fast( - struct rhashtable *ht, struct rhash_head *obj, - const struct rhashtable_params params) -{ - return __rhashtable_insert_fast(ht, NULL, obj, params); -} - -/** - * rhashtable_lookup_insert_fast - lookup and insert object into hash table - * @ht: hash table - * @obj: pointer to hash head inside object - * @params: hash table parameters - * - * Locks down the bucket chain in both the old and new table if a resize - * is in progress to ensure that writers can't remove from the old table - * and can't insert to the new table during the atomic operation of search - * and insertion. Searches for duplicates in both the old and new table if - * a resize is in progress. - * - * This lookup function may only be used for fixed key hash table (key_len - * parameter set). It will BUG() if used inappropriately. - * - * It is safe to call this function from atomic context. - * - * Will trigger an automatic deferred table resizing if the size grows - * beyond the watermark indicated by grow_decision() which can be passed - * to rhashtable_init(). - */ -static inline int rhashtable_lookup_insert_fast( - struct rhashtable *ht, struct rhash_head *obj, - const struct rhashtable_params params) -{ - const char *key = rht_obj(ht, obj); - - BUG_ON(ht->p.obj_hashfn); - - return __rhashtable_insert_fast(ht, key + ht->p.key_offset, obj, - params); -} - -/** - * rhashtable_lookup_insert_key - search and insert object to hash table - * with explicit key - * @ht: hash table - * @key: key - * @obj: pointer to hash head inside object - * @params: hash table parameters - * - * Locks down the bucket chain in both the old and new table if a resize - * is in progress to ensure that writers can't remove from the old table - * and can't insert to the new table during the atomic operation of search - * and insertion. Searches for duplicates in both the old and new table if - * a resize is in progress. - * - * Lookups may occur in parallel with hashtable mutations and resizing. - * - * Will trigger an automatic deferred table resizing if the size grows - * beyond the watermark indicated by grow_decision() which can be passed - * to rhashtable_init(). - * - * Returns zero on success. - */ -static inline int rhashtable_lookup_insert_key( - struct rhashtable *ht, const void *key, struct rhash_head *obj, - const struct rhashtable_params params) -{ - BUG_ON(!ht->p.obj_hashfn || !key); - - return __rhashtable_insert_fast(ht, key, obj, params); -} - -/* Internal function, please use rhashtable_remove_fast() instead */ -static inline int __rhashtable_remove_fast( - struct rhashtable *ht, struct bucket_table *tbl, - struct rhash_head *obj, const struct rhashtable_params params) -{ - struct rhash_head __rcu **pprev; - struct rhash_head *he; - spinlock_t * lock; - unsigned int hash; - int err = -ENOENT; - - hash = rht_head_hashfn(ht, tbl, obj, params); - lock = rht_bucket_lock(tbl, hash); - - spin_lock_bh(lock); - - pprev = &tbl->buckets[hash]; - rht_for_each(he, tbl, hash) { - if (he != obj) { - pprev = &he->next; - continue; - } - - rcu_assign_pointer(*pprev, obj->next); - err = 0; - break; - } - - spin_unlock_bh(lock); - - return err; -} - -/** - * rhashtable_remove_fast - remove object from hash table - * @ht: hash table - * @obj: pointer to hash head inside object - * @params: hash table parameters - * - * Since the hash chain is single linked, the removal operation needs to - * walk the bucket chain upon removal. The removal operation is thus - * considerable slow if the hash table is not correctly sized. - * - * Will automatically shrink the table via rhashtable_expand() if the - * shrink_decision function specified at rhashtable_init() returns true. - * - * Returns zero on success, -ENOENT if the entry could not be found. - */ -static inline int rhashtable_remove_fast( - struct rhashtable *ht, struct rhash_head *obj, - const struct rhashtable_params params) -{ - struct bucket_table *tbl; - int err; - - rcu_read_lock(); - - tbl = rht_dereference_rcu(ht->tbl, ht); - - /* Because we have already taken (and released) the bucket - * lock in old_tbl, if we find that future_tbl is not yet - * visible then that guarantees the entry to still be in - * the old tbl if it exists. - */ - while ((err = __rhashtable_remove_fast(ht, tbl, obj, params)) && - (tbl = rht_dereference_rcu(tbl->future_tbl, ht))) - ; - - if (err) - goto out; - - atomic_dec(&ht->nelems); - if (unlikely(ht->p.automatic_shrinking && - rht_shrink_below_30(ht, tbl))) - schedule_work(&ht->run_work); - -out: - rcu_read_unlock(); - - return err; -} - -#endif /* _LINUX_RHASHTABLE_H */ - +/* + * Resizable, Scalable, Concurrent Hash Table + * + * Copyright (c) 2015 Herbert Xu + * Copyright (c) 2014-2015 Thomas Graf + * Copyright (c) 2008-2014 Patrick McHardy + * + * Code partially derived from nft_hash + * Rewritten with rehash code from br_multicast plus single list + * pointer as suggested by Josh Triplett + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _LINUX_RHASHTABLE_H +#define _LINUX_RHASHTABLE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * The end of the chain is marked with a special nulls marks which has + * the following format: + * + * +-------+-----------------------------------------------------+-+ + * | Base | Hash |1| + * +-------+-----------------------------------------------------+-+ + * + * Base (4 bits) : Reserved to distinguish between multiple tables. + * Specified via &struct rhashtable_params.nulls_base. + * Hash (27 bits): Full hash (unmasked) of first element added to bucket + * 1 (1 bit) : Nulls marker (always set) + * + * The remaining bits of the next pointer remain unused for now. + */ +#define RHT_BASE_BITS 4 +#define RHT_HASH_BITS 27 +#define RHT_BASE_SHIFT RHT_HASH_BITS + +/* Base bits plus 1 bit for nulls marker */ +#define RHT_HASH_RESERVED_SPACE (RHT_BASE_BITS + 1) + +struct rhash_head { + struct rhash_head __rcu *next; +}; + +/** + * struct bucket_table - Table of hash buckets + * @size: Number of hash buckets + * @rehash: Current bucket being rehashed + * @hash_rnd: Random seed to fold into hash + * @locks_mask: Mask to apply before accessing locks[] + * @locks: Array of spinlocks protecting individual buckets + * @walkers: List of active walkers + * @rcu: RCU structure for freeing the table + * @future_tbl: Table under construction during rehashing + * @buckets: size * hash buckets + */ +struct bucket_table { + unsigned int size; + unsigned int rehash; + u32 hash_rnd; + unsigned int locks_mask; + spinlock_t *locks; + struct list_head walkers; + struct rcu_head rcu; + + struct bucket_table __rcu *future_tbl; + + struct rhash_head __rcu *buckets[] ____cacheline_aligned_in_smp; +}; + +/** + * struct rhashtable_compare_arg - Key for the function rhashtable_compare + * @ht: Hash table + * @key: Key to compare against + */ +struct rhashtable_compare_arg { + struct rhashtable *ht; + const void *key; +}; + +typedef u32 (*rht_hashfn_t)(const void *data, u32 len, u32 seed); +typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 len, u32 seed); +typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *arg, + const void *obj); + +struct rhashtable; + +/** + * struct rhashtable_params - Hash table construction parameters + * @nelem_hint: Hint on number of elements, should be 75% of desired size + * @key_len: Length of key + * @key_offset: Offset of key in struct to be hashed + * @head_offset: Offset of rhash_head in struct to be hashed + * @insecure_max_entries: Maximum number of entries (may be exceeded) + * @max_size: Maximum size while expanding + * @min_size: Minimum size while shrinking + * @nulls_base: Base value to generate nulls marker + * @insecure_elasticity: Set to true to disable chain length checks + * @automatic_shrinking: Enable automatic shrinking of tables + * @locks_mul: Number of bucket locks to allocate per cpu (default: 128) + * @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash) + * @obj_hashfn: Function to hash object + * @obj_cmpfn: Function to compare key with object + */ +struct rhashtable_params { + size_t nelem_hint; + size_t key_len; + size_t key_offset; + size_t head_offset; + unsigned int insecure_max_entries; + unsigned int max_size; + unsigned int min_size; + u32 nulls_base; + bool insecure_elasticity; + bool automatic_shrinking; + size_t locks_mul; + rht_hashfn_t hashfn; + rht_obj_hashfn_t obj_hashfn; + rht_obj_cmpfn_t obj_cmpfn; +}; + +/** + * struct rhashtable - Hash table handle + * @tbl: Bucket table + * @nelems: Number of elements in table + * @key_len: Key length for hashfn + * @elasticity: Maximum chain length before rehash + * @p: Configuration parameters + * @run_work: Deferred worker to expand/shrink asynchronously + * @mutex: Mutex to protect current/future table swapping + * @lock: Spin lock to protect walker list + */ +struct rhashtable { + struct bucket_table __rcu *tbl; + atomic_t nelems; + unsigned int key_len; + unsigned int elasticity; + struct rhashtable_params p; + struct work_struct run_work; + struct mutex mutex; + spinlock_t lock; +}; + +/** + * struct rhashtable_walker - Hash table walker + * @list: List entry on list of walkers + * @tbl: The table that we were walking over + */ +struct rhashtable_walker { + struct list_head list; + struct bucket_table *tbl; +}; + +/** + * struct rhashtable_iter - Hash table iterator, fits into netlink cb + * @ht: Table to iterate through + * @p: Current pointer + * @walker: Associated rhashtable walker + * @slot: Current slot + * @skip: Number of entries to skip in slot + */ +struct rhashtable_iter { + struct rhashtable *ht; + struct rhash_head *p; + struct rhashtable_walker *walker; + unsigned int slot; + unsigned int skip; +}; + +static inline unsigned long rht_marker(const struct rhashtable *ht, u32 hash) +{ + return NULLS_MARKER(ht->p.nulls_base + hash); +} + +#define INIT_RHT_NULLS_HEAD(ptr, ht, hash) \ + ((ptr) = (typeof(ptr)) rht_marker(ht, hash)) + +static inline bool rht_is_a_nulls(const struct rhash_head *ptr) +{ + return ((unsigned long) ptr & 1); +} + +static inline unsigned long rht_get_nulls_value(const struct rhash_head *ptr) +{ + return ((unsigned long) ptr) >> 1; +} + +static inline void *rht_obj(const struct rhashtable *ht, + const struct rhash_head *he) +{ + return (char *)he - ht->p.head_offset; +} + +static inline unsigned int rht_bucket_index(const struct bucket_table *tbl, + unsigned int hash) +{ + return (hash >> RHT_HASH_RESERVED_SPACE) & (tbl->size - 1); +} + +static inline unsigned int rht_key_hashfn( + struct rhashtable *ht, const struct bucket_table *tbl, + const void *key, const struct rhashtable_params params) +{ + unsigned int hash; + + /* params must be equal to ht->p if it isn't constant. */ + if (!__builtin_constant_p(params.key_len)) + hash = ht->p.hashfn(key, ht->key_len, tbl->hash_rnd); + else if (params.key_len) { + unsigned int key_len = params.key_len; + + if (params.hashfn) + hash = params.hashfn(key, key_len, tbl->hash_rnd); + else if (key_len & (sizeof(u32) - 1)) + hash = jhash(key, key_len, tbl->hash_rnd); + else + hash = jhash2(key, key_len / sizeof(u32), + tbl->hash_rnd); + } else { + unsigned int key_len = ht->p.key_len; + + if (params.hashfn) + hash = params.hashfn(key, key_len, tbl->hash_rnd); + else + hash = jhash(key, key_len, tbl->hash_rnd); + } + + return rht_bucket_index(tbl, hash); +} + +static inline unsigned int rht_head_hashfn( + struct rhashtable *ht, const struct bucket_table *tbl, + const struct rhash_head *he, const struct rhashtable_params params) +{ + const char *ptr = rht_obj(ht, he); + + return likely(params.obj_hashfn) ? + rht_bucket_index(tbl, params.obj_hashfn(ptr, params.key_len ?: + ht->p.key_len, + tbl->hash_rnd)) : + rht_key_hashfn(ht, tbl, ptr + params.key_offset, params); +} + +/** + * rht_grow_above_75 - returns true if nelems > 0.75 * table-size + * @ht: hash table + * @tbl: current table + */ +static inline bool rht_grow_above_75(const struct rhashtable *ht, + const struct bucket_table *tbl) +{ + /* Expand table when exceeding 75% load */ + return atomic_read(&ht->nelems) > (tbl->size / 4 * 3) && + (!ht->p.max_size || tbl->size < ht->p.max_size); +} + +/** + * rht_shrink_below_30 - returns true if nelems < 0.3 * table-size + * @ht: hash table + * @tbl: current table + */ +static inline bool rht_shrink_below_30(const struct rhashtable *ht, + const struct bucket_table *tbl) +{ + /* Shrink table beneath 30% load */ + return atomic_read(&ht->nelems) < (tbl->size * 3 / 10) && + tbl->size > ht->p.min_size; +} + +/** + * rht_grow_above_100 - returns true if nelems > table-size + * @ht: hash table + * @tbl: current table + */ +static inline bool rht_grow_above_100(const struct rhashtable *ht, + const struct bucket_table *tbl) +{ + return atomic_read(&ht->nelems) > tbl->size && + (!ht->p.max_size || tbl->size < ht->p.max_size); +} + +/** + * rht_grow_above_max - returns true if table is above maximum + * @ht: hash table + * @tbl: current table + */ +static inline bool rht_grow_above_max(const struct rhashtable *ht, + const struct bucket_table *tbl) +{ + return ht->p.insecure_max_entries && + atomic_read(&ht->nelems) >= ht->p.insecure_max_entries; +} + +/* The bucket lock is selected based on the hash and protects mutations + * on a group of hash buckets. + * + * A maximum of tbl->size/2 bucket locks is allocated. This ensures that + * a single lock always covers both buckets which may both contains + * entries which link to the same bucket of the old table during resizing. + * This allows to simplify the locking as locking the bucket in both + * tables during resize always guarantee protection. + * + * IMPORTANT: When holding the bucket lock of both the old and new table + * during expansions and shrinking, the old bucket lock must always be + * acquired first. + */ +static inline spinlock_t *rht_bucket_lock(const struct bucket_table *tbl, + unsigned int hash) +{ + return &tbl->locks[hash & tbl->locks_mask]; +} + +#ifdef CONFIG_PROVE_LOCKING +int lockdep_rht_mutex_is_held(struct rhashtable *ht); +int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, u32 hash); +#else +static inline int lockdep_rht_mutex_is_held(struct rhashtable *ht) +{ + return 1; +} + +static inline int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, + u32 hash) +{ + return 1; +} +#endif /* CONFIG_PROVE_LOCKING */ + +int rhashtable_init(struct rhashtable *ht, + const struct rhashtable_params *params); + +struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht, + const void *key, + struct rhash_head *obj, + struct bucket_table *old_tbl); +int rhashtable_insert_rehash(struct rhashtable *ht, struct bucket_table *tbl); + +int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter); +void rhashtable_walk_exit(struct rhashtable_iter *iter); +int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU); +void *rhashtable_walk_next(struct rhashtable_iter *iter); +void rhashtable_walk_stop(struct rhashtable_iter *iter) __releases(RCU); + +void rhashtable_free_and_destroy(struct rhashtable *ht, + void (*free_fn)(void *ptr, void *arg), + void *arg); +void rhashtable_destroy(struct rhashtable *ht); + +#define rht_dereference(p, ht) \ + rcu_dereference_protected(p, lockdep_rht_mutex_is_held(ht)) + +#define rht_dereference_rcu(p, ht) \ + rcu_dereference_check(p, lockdep_rht_mutex_is_held(ht)) + +#define rht_dereference_bucket(p, tbl, hash) \ + rcu_dereference_protected(p, lockdep_rht_bucket_is_held(tbl, hash)) + +#define rht_dereference_bucket_rcu(p, tbl, hash) \ + rcu_dereference_check(p, lockdep_rht_bucket_is_held(tbl, hash)) + +#define rht_entry(tpos, pos, member) \ + ({ tpos = container_of(pos, typeof(*tpos), member); 1; }) + +/** + * rht_for_each_continue - continue iterating over hash chain + * @pos: the &struct rhash_head to use as a loop cursor. + * @head: the previous &struct rhash_head to continue from + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + */ +#define rht_for_each_continue(pos, head, tbl, hash) \ + for (pos = rht_dereference_bucket(head, tbl, hash); \ + !rht_is_a_nulls(pos); \ + pos = rht_dereference_bucket((pos)->next, tbl, hash)) + +/** + * rht_for_each - iterate over hash chain + * @pos: the &struct rhash_head to use as a loop cursor. + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + */ +#define rht_for_each(pos, tbl, hash) \ + rht_for_each_continue(pos, (tbl)->buckets[hash], tbl, hash) + +/** + * rht_for_each_entry_continue - continue iterating over hash chain + * @tpos: the type * to use as a loop cursor. + * @pos: the &struct rhash_head to use as a loop cursor. + * @head: the previous &struct rhash_head to continue from + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + * @member: name of the &struct rhash_head within the hashable struct. + */ +#define rht_for_each_entry_continue(tpos, pos, head, tbl, hash, member) \ + for (pos = rht_dereference_bucket(head, tbl, hash); \ + (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ + pos = rht_dereference_bucket((pos)->next, tbl, hash)) + +/** + * rht_for_each_entry - iterate over hash chain of given type + * @tpos: the type * to use as a loop cursor. + * @pos: the &struct rhash_head to use as a loop cursor. + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + * @member: name of the &struct rhash_head within the hashable struct. + */ +#define rht_for_each_entry(tpos, pos, tbl, hash, member) \ + rht_for_each_entry_continue(tpos, pos, (tbl)->buckets[hash], \ + tbl, hash, member) + +/** + * rht_for_each_entry_safe - safely iterate over hash chain of given type + * @tpos: the type * to use as a loop cursor. + * @pos: the &struct rhash_head to use as a loop cursor. + * @next: the &struct rhash_head to use as next in loop cursor. + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + * @member: name of the &struct rhash_head within the hashable struct. + * + * This hash chain list-traversal primitive allows for the looped code to + * remove the loop cursor from the list. + */ +#define rht_for_each_entry_safe(tpos, pos, next, tbl, hash, member) \ + for (pos = rht_dereference_bucket((tbl)->buckets[hash], tbl, hash), \ + next = !rht_is_a_nulls(pos) ? \ + rht_dereference_bucket(pos->next, tbl, hash) : NULL; \ + (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ + pos = next, \ + next = !rht_is_a_nulls(pos) ? \ + rht_dereference_bucket(pos->next, tbl, hash) : NULL) + +/** + * rht_for_each_rcu_continue - continue iterating over rcu hash chain + * @pos: the &struct rhash_head to use as a loop cursor. + * @head: the previous &struct rhash_head to continue from + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + * + * This hash chain list-traversal primitive may safely run concurrently with + * the _rcu mutation primitives such as rhashtable_insert() as long as the + * traversal is guarded by rcu_read_lock(). + */ +#define rht_for_each_rcu_continue(pos, head, tbl, hash) \ + for (({barrier(); }), \ + pos = rht_dereference_bucket_rcu(head, tbl, hash); \ + !rht_is_a_nulls(pos); \ + pos = rcu_dereference_raw(pos->next)) + +/** + * rht_for_each_rcu - iterate over rcu hash chain + * @pos: the &struct rhash_head to use as a loop cursor. + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + * + * This hash chain list-traversal primitive may safely run concurrently with + * the _rcu mutation primitives such as rhashtable_insert() as long as the + * traversal is guarded by rcu_read_lock(). + */ +#define rht_for_each_rcu(pos, tbl, hash) \ + rht_for_each_rcu_continue(pos, (tbl)->buckets[hash], tbl, hash) + +/** + * rht_for_each_entry_rcu_continue - continue iterating over rcu hash chain + * @tpos: the type * to use as a loop cursor. + * @pos: the &struct rhash_head to use as a loop cursor. + * @head: the previous &struct rhash_head to continue from + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + * @member: name of the &struct rhash_head within the hashable struct. + * + * This hash chain list-traversal primitive may safely run concurrently with + * the _rcu mutation primitives such as rhashtable_insert() as long as the + * traversal is guarded by rcu_read_lock(). + */ +#define rht_for_each_entry_rcu_continue(tpos, pos, head, tbl, hash, member) \ + for (({barrier(); }), \ + pos = rht_dereference_bucket_rcu(head, tbl, hash); \ + (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ + pos = rht_dereference_bucket_rcu(pos->next, tbl, hash)) + +/** + * rht_for_each_entry_rcu - iterate over rcu hash chain of given type + * @tpos: the type * to use as a loop cursor. + * @pos: the &struct rhash_head to use as a loop cursor. + * @tbl: the &struct bucket_table + * @hash: the hash value / bucket index + * @member: name of the &struct rhash_head within the hashable struct. + * + * This hash chain list-traversal primitive may safely run concurrently with + * the _rcu mutation primitives such as rhashtable_insert() as long as the + * traversal is guarded by rcu_read_lock(). + */ +#define rht_for_each_entry_rcu(tpos, pos, tbl, hash, member) \ + rht_for_each_entry_rcu_continue(tpos, pos, (tbl)->buckets[hash],\ + tbl, hash, member) + +static inline int rhashtable_compare(struct rhashtable_compare_arg *arg, + const void *obj) +{ + struct rhashtable *ht = arg->ht; + const char *ptr = obj; + + return memcmp(ptr + ht->p.key_offset, arg->key, ht->p.key_len); +} + +/** + * rhashtable_lookup_fast - search hash table, inlined version + * @ht: hash table + * @key: the pointer to the key + * @params: hash table parameters + * + * Computes the hash value for the key and traverses the bucket chain looking + * for a entry with an identical key. The first matching entry is returned. + * + * Returns the first entry on which the compare function returned true. + */ +static inline void *rhashtable_lookup_fast( + struct rhashtable *ht, const void *key, + const struct rhashtable_params params) +{ + struct rhashtable_compare_arg arg = { + .ht = ht, + .key = key, + }; + const struct bucket_table *tbl; + struct rhash_head *he; + unsigned int hash; + + rcu_read_lock(); + + tbl = rht_dereference_rcu(ht->tbl, ht); +restart: + hash = rht_key_hashfn(ht, tbl, key, params); + rht_for_each_rcu(he, tbl, hash) { + if (params.obj_cmpfn ? + params.obj_cmpfn(&arg, rht_obj(ht, he)) : + rhashtable_compare(&arg, rht_obj(ht, he))) + continue; + rcu_read_unlock(); + return rht_obj(ht, he); + } + + /* Ensure we see any new tables. */ + smp_rmb(); + + tbl = rht_dereference_rcu(tbl->future_tbl, ht); + if (unlikely(tbl)) + goto restart; + rcu_read_unlock(); + + return NULL; +} + +/* Internal function, please use rhashtable_insert_fast() instead */ +static inline int __rhashtable_insert_fast( + struct rhashtable *ht, const void *key, struct rhash_head *obj, + const struct rhashtable_params params) +{ + struct rhashtable_compare_arg arg = { + .ht = ht, + .key = key, + }; + struct bucket_table *tbl, *new_tbl; + struct rhash_head *head; + spinlock_t *lock; + unsigned int elasticity; + unsigned int hash; + int err; + +restart: + rcu_read_lock(); + + tbl = rht_dereference_rcu(ht->tbl, ht); + + /* All insertions must grab the oldest table containing + * the hashed bucket that is yet to be rehashed. + */ + for (;;) { + hash = rht_head_hashfn(ht, tbl, obj, params); + lock = rht_bucket_lock(tbl, hash); + spin_lock_bh(lock); + + if (tbl->rehash <= hash) + break; + + spin_unlock_bh(lock); + tbl = rht_dereference_rcu(tbl->future_tbl, ht); + } + + new_tbl = rht_dereference_rcu(tbl->future_tbl, ht); + if (unlikely(new_tbl)) { + tbl = rhashtable_insert_slow(ht, key, obj, new_tbl); + if (!IS_ERR_OR_NULL(tbl)) + goto slow_path; + + err = PTR_ERR(tbl); + goto out; + } + + err = -E2BIG; + if (unlikely(rht_grow_above_max(ht, tbl))) + goto out; + + if (unlikely(rht_grow_above_100(ht, tbl))) { +slow_path: + spin_unlock_bh(lock); + err = rhashtable_insert_rehash(ht, tbl); + rcu_read_unlock(); + if (err) + return err; + + goto restart; + } + + err = -EEXIST; + elasticity = ht->elasticity; + rht_for_each(head, tbl, hash) { + if (key && + unlikely(!(params.obj_cmpfn ? + params.obj_cmpfn(&arg, rht_obj(ht, head)) : + rhashtable_compare(&arg, rht_obj(ht, head))))) + goto out; + if (!--elasticity) + goto slow_path; + } + + err = 0; + + head = rht_dereference_bucket(tbl->buckets[hash], tbl, hash); + + RCU_INIT_POINTER(obj->next, head); + + rcu_assign_pointer(tbl->buckets[hash], obj); + + atomic_inc(&ht->nelems); + if (rht_grow_above_75(ht, tbl)) + schedule_work(&ht->run_work); + +out: + spin_unlock_bh(lock); + rcu_read_unlock(); + + return err; +} + +/** + * rhashtable_insert_fast - insert object into hash table + * @ht: hash table + * @obj: pointer to hash head inside object + * @params: hash table parameters + * + * Will take a per bucket spinlock to protect against mutual mutations + * on the same bucket. Multiple insertions may occur in parallel unless + * they map to the same bucket lock. + * + * It is safe to call this function from atomic context. + * + * Will trigger an automatic deferred table resizing if the size grows + * beyond the watermark indicated by grow_decision() which can be passed + * to rhashtable_init(). + */ +static inline int rhashtable_insert_fast( + struct rhashtable *ht, struct rhash_head *obj, + const struct rhashtable_params params) +{ + return __rhashtable_insert_fast(ht, NULL, obj, params); +} + +/** + * rhashtable_lookup_insert_fast - lookup and insert object into hash table + * @ht: hash table + * @obj: pointer to hash head inside object + * @params: hash table parameters + * + * Locks down the bucket chain in both the old and new table if a resize + * is in progress to ensure that writers can't remove from the old table + * and can't insert to the new table during the atomic operation of search + * and insertion. Searches for duplicates in both the old and new table if + * a resize is in progress. + * + * This lookup function may only be used for fixed key hash table (key_len + * parameter set). It will BUG() if used inappropriately. + * + * It is safe to call this function from atomic context. + * + * Will trigger an automatic deferred table resizing if the size grows + * beyond the watermark indicated by grow_decision() which can be passed + * to rhashtable_init(). + */ +static inline int rhashtable_lookup_insert_fast( + struct rhashtable *ht, struct rhash_head *obj, + const struct rhashtable_params params) +{ + const char *key = rht_obj(ht, obj); + + BUG_ON(ht->p.obj_hashfn); + + return __rhashtable_insert_fast(ht, key + ht->p.key_offset, obj, + params); +} + +/** + * rhashtable_lookup_insert_key - search and insert object to hash table + * with explicit key + * @ht: hash table + * @key: key + * @obj: pointer to hash head inside object + * @params: hash table parameters + * + * Locks down the bucket chain in both the old and new table if a resize + * is in progress to ensure that writers can't remove from the old table + * and can't insert to the new table during the atomic operation of search + * and insertion. Searches for duplicates in both the old and new table if + * a resize is in progress. + * + * Lookups may occur in parallel with hashtable mutations and resizing. + * + * Will trigger an automatic deferred table resizing if the size grows + * beyond the watermark indicated by grow_decision() which can be passed + * to rhashtable_init(). + * + * Returns zero on success. + */ +static inline int rhashtable_lookup_insert_key( + struct rhashtable *ht, const void *key, struct rhash_head *obj, + const struct rhashtable_params params) +{ + BUG_ON(!ht->p.obj_hashfn || !key); + + return __rhashtable_insert_fast(ht, key, obj, params); +} + +/* Internal function, please use rhashtable_remove_fast() instead */ +static inline int __rhashtable_remove_fast( + struct rhashtable *ht, struct bucket_table *tbl, + struct rhash_head *obj, const struct rhashtable_params params) +{ + struct rhash_head __rcu **pprev; + struct rhash_head *he; + spinlock_t * lock; + unsigned int hash; + int err = -ENOENT; + + hash = rht_head_hashfn(ht, tbl, obj, params); + lock = rht_bucket_lock(tbl, hash); + + spin_lock_bh(lock); + + pprev = &tbl->buckets[hash]; + rht_for_each(he, tbl, hash) { + if (he != obj) { + pprev = &he->next; + continue; + } + + rcu_assign_pointer(*pprev, obj->next); + err = 0; + break; + } + + spin_unlock_bh(lock); + + return err; +} + +/** + * rhashtable_remove_fast - remove object from hash table + * @ht: hash table + * @obj: pointer to hash head inside object + * @params: hash table parameters + * + * Since the hash chain is single linked, the removal operation needs to + * walk the bucket chain upon removal. The removal operation is thus + * considerable slow if the hash table is not correctly sized. + * + * Will automatically shrink the table via rhashtable_expand() if the + * shrink_decision function specified at rhashtable_init() returns true. + * + * Returns zero on success, -ENOENT if the entry could not be found. + */ +static inline int rhashtable_remove_fast( + struct rhashtable *ht, struct rhash_head *obj, + const struct rhashtable_params params) +{ + struct bucket_table *tbl; + int err; + + rcu_read_lock(); + + tbl = rht_dereference_rcu(ht->tbl, ht); + + /* Because we have already taken (and released) the bucket + * lock in old_tbl, if we find that future_tbl is not yet + * visible then that guarantees the entry to still be in + * the old tbl if it exists. + */ + while ((err = __rhashtable_remove_fast(ht, tbl, obj, params)) && + (tbl = rht_dereference_rcu(tbl->future_tbl, ht))) + ; + + if (err) + goto out; + + atomic_dec(&ht->nelems); + if (unlikely(ht->p.automatic_shrinking && + rht_shrink_below_30(ht, tbl))) + schedule_work(&ht->run_work); + +out: + rcu_read_unlock(); + + return err; +} + +#endif /* _LINUX_RHASHTABLE_H */ + diff --git a/os_dep/linux/rtw_android.c b/os_dep/linux/rtw_android.c index e468574..52ae5a6 100644 --- a/os_dep/linux/rtw_android.c +++ b/os_dep/linux/rtw_android.c @@ -656,7 +656,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) ret = -EFAULT; goto exit; } - + command = rtw_zmalloc(priv_cmd.total_len+1); if (!command) { RTW_INFO("%s: failed to allocate memory\n", __FUNCTION__); @@ -935,7 +935,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) bytes_written = rtw_android_set_aek(net, command, priv_cmd.total_len); break; #endif - + case ANDROID_WIFI_CMD_EXT_AUTH_STATUS: { rtw_set_external_auth_status(padapter, command + strlen("EXT_AUTH_STATUS "), diff --git a/os_dep/linux/rtw_cfgvendor.c b/os_dep/linux/rtw_cfgvendor.c index d906163..1e0e169 100644 --- a/os_dep/linux/rtw_cfgvendor.c +++ b/os_dep/linux/rtw_cfgvendor.c @@ -1152,7 +1152,7 @@ static void LinkLayerStats(_adapter *padapter) u32 ps_time, trx_total_time; u64 tx_bytes, rx_bytes, trx_total_bytes = 0; u64 tmp = 0; - + RTW_DBG("%s adapter type : %u\n", __func__, padapter->adapter_type); tx_bytes = 0; @@ -1169,7 +1169,7 @@ static void LinkLayerStats(_adapter *padapter) pwrpriv->pwr_saving_time += rtw_get_passing_time_ms(pwrpriv->pwr_saving_start_time); pwrpriv->pwr_saving_start_time = rtw_get_current_time(); } - } else { + } else { #ifdef CONFIG_IPS if ( pwrpriv->bpower_saving == _TRUE ) { pwrpriv->pwr_saving_time += rtw_get_passing_time_ms(pwrpriv->pwr_saving_start_time); @@ -1187,7 +1187,7 @@ static void LinkLayerStats(_adapter *padapter) ps_time = pwrpriv->on_time; tx_bytes = pdvobjpriv->traffic_stat.last_tx_bytes; - rx_bytes = pdvobjpriv->traffic_stat.last_rx_bytes; + rx_bytes = pdvobjpriv->traffic_stat.last_rx_bytes; trx_total_bytes = tx_bytes + rx_bytes; trx_total_time = pwrpriv->on_time - ps_time; @@ -1206,30 +1206,30 @@ static void LinkLayerStats(_adapter *padapter) tmp = (rx_bytes * trx_total_time); tmp = rtw_division64(tmp, trx_total_bytes); - pwrpriv->rx_time = tmp; + pwrpriv->rx_time = tmp; } - + } else { pwrpriv->on_time = 0; pwrpriv->tx_time = 0; - pwrpriv->rx_time = 0; + pwrpriv->rx_time = 0; } #ifdef CONFIG_RTW_WIFI_HAL_DEBUG RTW_INFO("- tx_bytes : %llu rx_bytes : %llu total bytes : %llu\n", tx_bytes, rx_bytes, trx_total_bytes); RTW_INFO("- netif_up = %s, on_time : %u ms\n", padapter->netif_up ? "1":"0", pwrpriv->on_time); RTW_INFO("- pwr_saving_time : %u (%u) ms\n", pwrpriv->pwr_saving_time, ps_time); - RTW_INFO("- trx_total_time : %u ms\n", trx_total_time); + RTW_INFO("- trx_total_time : %u ms\n", trx_total_time); RTW_INFO("- tx_time : %u ms\n", pwrpriv->tx_time); - RTW_INFO("- rx_time : %u ms\n", pwrpriv->rx_time); + RTW_INFO("- rx_time : %u ms\n", pwrpriv->rx_time); #endif /* CONFIG_RTW_WIFI_HAL_DEBUG */ } #define DUMMY_TIME_STATICS 99 -static int rtw_cfgvendor_lstats_get_info(struct wiphy *wiphy, +static int rtw_cfgvendor_lstats_get_info(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -1250,8 +1250,8 @@ static int rtw_cfgvendor_lstats_get_info(struct wiphy *wiphy, radio->radio = 1; /* to get on_time, tx_time, rx_time */ - LinkLayerStats(padapter); - + LinkLayerStats(padapter); + radio->on_time = pwrpriv->on_time; radio->tx_time = pwrpriv->tx_time; radio->rx_time = pwrpriv->rx_time; @@ -1270,9 +1270,9 @@ static int rtw_cfgvendor_lstats_get_info(struct wiphy *wiphy, RTW_INFO("radio->tx_time : %u ms\n", (radio->tx_time)); RTW_INFO("radio->rx_time : %u ms\n", (radio->rx_time)); #endif /* CONFIG_RTW_WIFI_HAL_DEBUG */ - + RTW_DBG(FUNC_NDEV_FMT" %s\n", FUNC_NDEV_ARG(wdev_to_ndev(wdev)), (char*)data); - err = rtw_cfgvendor_send_cmd_reply(wiphy, wdev_to_ndev(wdev), + err = rtw_cfgvendor_send_cmd_reply(wiphy, wdev_to_ndev(wdev), output, sizeof(wifi_iface_stat) + sizeof(wifi_radio_stat_internal)); if (unlikely(err)) RTW_ERR(FUNC_NDEV_FMT"Vendor Command reply failed ret:%d \n" @@ -1280,14 +1280,14 @@ static int rtw_cfgvendor_lstats_get_info(struct wiphy *wiphy, rtw_mfree(output, sizeof(wifi_iface_stat) + sizeof(wifi_radio_stat_internal)); return err; } -static int rtw_cfgvendor_lstats_set_info(struct wiphy *wiphy, +static int rtw_cfgvendor_lstats_set_info(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; RTW_INFO("%s\n", __func__); return err; } -static int rtw_cfgvendor_lstats_clear_info(struct wiphy *wiphy, +static int rtw_cfgvendor_lstats_clear_info(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { int err = 0; @@ -1665,7 +1665,7 @@ static int rtw_cfgvendor_set_rand_mac_oui(struct wiphy *wiphy, static int rtw_cfgvendor_set_nodfs_flag(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { - int err = 0; + int err = 0; int type; u32 nodfs = 0; _adapter *padapter = GET_PRIMARY_ADAPTER(wiphy_to_adapter(wiphy)); @@ -1681,7 +1681,7 @@ static int rtw_cfgvendor_set_nodfs_flag(struct wiphy *wiphy, } RTW_INFO("%s nodfs=%d, err=%d\n", __func__, nodfs, err); - + return err; } @@ -1719,7 +1719,7 @@ static int rtw_cfgvendor_set_country(struct wiphy *wiphy, static int rtw_cfgvendor_set_nd_offload(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { - int err = 0; + int err = 0; int type; u8 nd_en = 0; _adapter *padapter = GET_PRIMARY_ADAPTER(wiphy_to_adapter(wiphy)); @@ -1735,7 +1735,7 @@ static int rtw_cfgvendor_set_nd_offload(struct wiphy *wiphy, } RTW_INFO("%s nd_en=%d, err=%d\n", __func__, nd_en, err); - + return err; } #endif /* CONFIG_RTW_WIFI_HAL */ @@ -1949,7 +1949,7 @@ static const struct wiphy_vendor_command rtw_vendor_cmds[] = { }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, .doit = rtw_cfgvendor_logger_get_rx_pkt_fates - }, + }, #endif /* CONFIG_RTW_CFGVENDOR_WIFI_LOGGER */ #ifdef CONFIG_RTW_WIFI_HAL #ifdef CONFIG_RTW_CFGVENDOR_RANDOM_MAC_OUI diff --git a/os_dep/linux/rtw_cfgvendor.h b/os_dep/linux/rtw_cfgvendor.h index af423fc..ffb576e 100644 --- a/os_dep/linux/rtw_cfgvendor.h +++ b/os_dep/linux/rtw_cfgvendor.h @@ -122,7 +122,7 @@ enum rtw_vendor_subcmd { APF_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START, APF_SUBCMD_SET_FILTER, - + LOGGER_START_LOGGING = ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START, LOGGER_TRIGGER_MEM_DUMP, LOGGER_GET_MEM_DUMP, diff --git a/os_dep/linux/rtw_proc.c b/os_dep/linux/rtw_proc.c index c968cca..42de17a 100644 --- a/os_dep/linux/rtw_proc.c +++ b/os_dep/linux/rtw_proc.c @@ -1033,15 +1033,15 @@ static int proc_get_turboedca_ctrl(struct seq_file *m, void *v) u32 edca_param; if (hal_data->dis_turboedca == 0) - RTW_PRINT_SEL(m, "Turbo-EDCA : %s\n", "Enable"); - else + RTW_PRINT_SEL(m, "Turbo-EDCA : %s\n", "Enable"); + else RTW_PRINT_SEL(m, "Turbo-EDCA : %s, mode=%d, edca_param_mode=0x%x\n", "Disable", hal_data->dis_turboedca, hal_data->edca_param_mode); rtw_hal_get_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&edca_param)); _RTW_PRINT_SEL(m, "PARAM_BE:0x%x\n", edca_param); - + } return 0; @@ -1072,28 +1072,28 @@ static ssize_t proc_set_turboedca_ctrl(struct file *file, const char __user *buf } /* 0: enable turboedca, - 1: disable turboedca, + 1: disable turboedca, 2: disable turboedca and setting EDCA parameter based on the input parameter - > 2 : currently reset to 0 */ - - if (mode > 2) + > 2 : currently reset to 0 */ + + if (mode > 2) mode = 0; hal_data->dis_turboedca = mode; - + hal_data->edca_param_mode = 0; /* init. value */ RTW_INFO("dis_turboedca mode = 0x%x\n", hal_data->dis_turboedca); - + if (num == 2) { - hal_data->edca_param_mode = param_mode; + hal_data->edca_param_mode = param_mode; RTW_INFO("param_mode = 0x%x\n", param_mode); } - + } - + return count; } @@ -1269,7 +1269,7 @@ ssize_t proc_set_macaddr_acl(struct file *file, const char __user *buffer, size_ #define MAC_ACL_CMD_DEL 2 #define MAC_ACL_CMD_CLR 3 #define MAC_ACL_CMD_NUM 4 - + static const char * const mac_acl_cmd_str[] = { "mode", "add", @@ -1371,7 +1371,7 @@ ssize_t proc_set_macaddr_acl(struct file *file, const char __user *buffer, size_ } else if (!is_bcast) rtw_acl_add_sta(adapter, period, addr); } - + c = strsep(&next, " \t"); } } @@ -2036,7 +2036,7 @@ static void rtw_set_tx_bw_mode(struct _ADAPTER *adapter, u8 bw_mode) ) { /* RA mask update needed */ update = _TRUE; - } + } adapter->driver_tx_bw_mode = bw_mode; if (update == _TRUE) { @@ -3093,7 +3093,7 @@ static ssize_t proc_set_napi_th(struct file *file, const char __user *buffer, si for (i = 0; i < dvobj->iface_nums; i++) { iface = dvobj->padapters[i]; - if (iface) { + if (iface) { if (buffer && !copy_from_user(tmp, buffer, count)) { registry = &iface->registrypriv; num = sscanf(tmp, "%d", &thrshld); @@ -3615,7 +3615,7 @@ static void tpt_mode_default(struct _ADAPTER *adapter) dvobj->scan_deny = _FALSE; /* 2. back to original LPS mode */ -#ifdef CONFIG_LPS +#ifdef CONFIG_LPS rtw_pm_set_lps(adapter, adapter->registrypriv.power_mgnt); #endif @@ -3630,13 +3630,13 @@ static void rtw_tpt_mode(struct _ADAPTER *adapter) if (dvobj->tpt_mode > 0) { - /* when enable each tpt mode + /* when enable each tpt mode 1. scan deny 2. disable LPS */ - + dvobj->scan_deny = _TRUE; -#ifdef CONFIG_LPS +#ifdef CONFIG_LPS rtw_pm_set_lps(adapter, PS_MODE_ACTIVE); #endif @@ -3647,9 +3647,9 @@ static void rtw_tpt_mode(struct _ADAPTER *adapter) tpt_mode_default(adapter); break; case 1: /* High TP*/ - /*tpt_mode1(adapter);*/ + /*tpt_mode1(adapter);*/ dvobj->edca_be_ul = 0x5e431c; - dvobj->edca_be_dl = 0x00431c; + dvobj->edca_be_dl = 0x00431c; break; case 2: /* noise */ /* tpt_mode2(adapter); */ @@ -3673,7 +3673,7 @@ static void rtw_tpt_mode(struct _ADAPTER *adapter) rtw_set_tx_bw_mode(adapter, 0x20); /* for 2.4g, fixed tx_bw_mode to 20Mhz */ break; default: /* default mode */ - tpt_mode_default(adapter); + tpt_mode_default(adapter); break; } @@ -3706,7 +3706,7 @@ static ssize_t proc_set_tpt_mode(struct file *file, const char __user *buffer, } if (mode > MAX_TPT_MODE_NUM ) - mode = 0; + mode = 0; RTW_PRINT("%s: previous mode = %d\n", __FUNCTION__, dvobj->tpt_mode); @@ -3976,7 +3976,7 @@ const struct rtw_proc_hdl adapter_proc_hdls[] = { RTW_PROC_HDL_SSEQ("ps_info", proc_get_ps_info, proc_set_ps_info), #ifdef CONFIG_WMMPS_STA RTW_PROC_HDL_SSEQ("wmmps_info", proc_get_wmmps_info, proc_set_wmmps_info), -#endif /* CONFIG_WMMPS_STA */ +#endif /* CONFIG_WMMPS_STA */ #endif #ifdef CONFIG_TDLS RTW_PROC_HDL_SSEQ("tdls_info", proc_get_tdls_info, NULL), diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index d190e12..062f614 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -272,7 +272,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = { {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xC82A, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8821CU */ {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xC82B, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8821CU */ {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xC811, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8811CU */ - {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x8811, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8811CU */ + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x8811, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8811CU */ /*=== Customer ID ===*/ #endif @@ -1100,7 +1100,7 @@ static int rtw_resume(struct usb_interface *pusb_intf) #ifdef CONFIG_AUTOSUSPEND if (pwrpriv->bInternalAutoSuspend) ret = rtw_resume_process(padapter); - else + else #endif { if (pwrpriv->wowlan_mode || pwrpriv->wowlan_ap_mode) { diff --git a/os_dep/linux/xmit_linux.c b/os_dep/linux/xmit_linux.c index ebbf1f0..1872b52 100644 --- a/os_dep/linux/xmit_linux.c +++ b/os_dep/linux/xmit_linux.c @@ -65,7 +65,7 @@ sint rtw_endofpktfile(struct pkt_file *pfile) void rtw_set_tx_chksum_offload(_pkt *pkt, struct pkt_attrib *pattrib) { -#ifdef CONFIG_TX_CSUM_OFFLOAD +#ifdef CONFIG_TX_CSUM_OFFLOAD struct sk_buff *skb = (struct sk_buff *)pkt; struct iphdr *iph = NULL; struct ipv6hdr *i6ph = NULL; @@ -305,12 +305,12 @@ void rtw_os_xmit_schedule(_adapter *padapter) tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); _exit_critical_bh(&pxmitpriv->lock, &irqL); - + #if defined(CONFIG_PCI_HCI) && defined(CONFIG_XMIT_THREAD_MODE) if (_rtw_queue_empty(&padapter->xmitpriv.pending_xmitbuf_queue) == _FALSE) _rtw_up_sema(&padapter->xmitpriv.xmit_sema); #endif - + #endif } @@ -451,7 +451,7 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev) #ifdef CONFIG_TX_MCAST2UNI extern int rtw_mc2u_disable; #endif /* CONFIG_TX_MCAST2UNI */ -#ifdef CONFIG_TX_CSUM_OFFLOAD +#ifdef CONFIG_TX_CSUM_OFFLOAD struct sk_buff *skb = pkt; struct sk_buff *segs, *nskb; netdev_features_t features = padapter->pnetdev->features; diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 35013ed..14f7b80 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2817,7 +2817,7 @@ int map_readN(const struct map_t *map, u16 offset, u16 len, u8 *buf) else c_len = seg->sa + seg->len - offset; } - + _rtw_memcpy(c_dst, c_src, c_len); } @@ -3001,7 +3001,7 @@ void dump_blacklist(void *sel, _queue *blist, const char *title) if (rtw_end_of_queue_search(head, list) == _FALSE) { if (title) RTW_PRINT_SEL(sel, "%s:\n", title); - + while (rtw_end_of_queue_search(head, list) == _FALSE) { ent = LIST_CONTAINOR(list, struct blacklist_ent, list); list = get_next(list); diff --git a/runwpa b/runwpa index f825e8b..7d77dea 100644 --- a/runwpa +++ b/runwpa @@ -1,17 +1,17 @@ #!/bin/bash -if [ "`which iwconfig`" = "" ] ; then +if [ "`which iwconfig`" = "" ] ; then echo "WARNING:Wireless tool not exist!" echo " Please install it!" exit else if [ `uname -r | cut -d. -f2` -eq 4 ]; then - wpa_supplicant -D ipw -c wpa1.conf -i wlan0 + wpa_supplicant -D ipw -c wpa1.conf -i wlan0 else if [ `iwconfig -v |awk '{print $4}' | head -n 1` -lt 18 ] ; then - wpa_supplicant -D ipw -c wpa1.conf -i wlan0 - else - wpa_supplicant -D wext -c wpa1.conf -i wlan0 + wpa_supplicant -D ipw -c wpa1.conf -i wlan0 + else + wpa_supplicant -D wext -c wpa1.conf -i wlan0 fi fi