diff options
Diffstat (limited to 'drivers/net/wireless/rtlwifi/rtl8192cu/hw.c')
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 134 |
1 files changed, 100 insertions, 34 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index 3d0498e69c8c..189ba124a8c6 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | |||
@@ -1973,26 +1973,35 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) | |||
1973 | } | 1973 | } |
1974 | } | 1974 | } |
1975 | 1975 | ||
1976 | void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw, | 1976 | static void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw, |
1977 | struct ieee80211_sta *sta, | 1977 | struct ieee80211_sta *sta) |
1978 | u8 rssi_level) | ||
1979 | { | 1978 | { |
1980 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 1979 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
1981 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | 1980 | struct rtl_phy *rtlphy = &(rtlpriv->phy); |
1982 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 1981 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
1983 | u32 ratr_value = (u32) mac->basic_rates; | 1982 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); |
1984 | u8 *mcsrate = mac->mcs; | 1983 | u32 ratr_value; |
1985 | u8 ratr_index = 0; | 1984 | u8 ratr_index = 0; |
1986 | u8 nmode = mac->ht_enable; | 1985 | u8 nmode = mac->ht_enable; |
1987 | u8 mimo_ps = 1; | 1986 | u8 mimo_ps = IEEE80211_SMPS_OFF; |
1988 | u16 shortgi_rate = 0; | 1987 | u16 shortgi_rate; |
1989 | u32 tmp_ratr_value = 0; | 1988 | u32 tmp_ratr_value; |
1990 | u8 curtxbw_40mhz = mac->bw_40; | 1989 | u8 curtxbw_40mhz = mac->bw_40; |
1991 | u8 curshortgi_40mhz = mac->sgi_40; | 1990 | u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? |
1992 | u8 curshortgi_20mhz = mac->sgi_20; | 1991 | 1 : 0; |
1992 | u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ? | ||
1993 | 1 : 0; | ||
1993 | enum wireless_mode wirelessmode = mac->mode; | 1994 | enum wireless_mode wirelessmode = mac->mode; |
1994 | 1995 | ||
1995 | ratr_value |= ((*(u16 *) (mcsrate))) << 12; | 1996 | if (rtlhal->current_bandtype == BAND_ON_5G) |
1997 | ratr_value = sta->supp_rates[1] << 4; | ||
1998 | else | ||
1999 | ratr_value = sta->supp_rates[0]; | ||
2000 | if (mac->opmode == NL80211_IFTYPE_ADHOC) | ||
2001 | ratr_value = 0xfff; | ||
2002 | |||
2003 | ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 | | ||
2004 | sta->ht_cap.mcs.rx_mask[0] << 12); | ||
1996 | switch (wirelessmode) { | 2005 | switch (wirelessmode) { |
1997 | case WIRELESS_MODE_B: | 2006 | case WIRELESS_MODE_B: |
1998 | if (ratr_value & 0x0000000c) | 2007 | if (ratr_value & 0x0000000c) |
@@ -2006,7 +2015,7 @@ void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw, | |||
2006 | case WIRELESS_MODE_N_24G: | 2015 | case WIRELESS_MODE_N_24G: |
2007 | case WIRELESS_MODE_N_5G: | 2016 | case WIRELESS_MODE_N_5G: |
2008 | nmode = 1; | 2017 | nmode = 1; |
2009 | if (mimo_ps == 0) { | 2018 | if (mimo_ps == IEEE80211_SMPS_STATIC) { |
2010 | ratr_value &= 0x0007F005; | 2019 | ratr_value &= 0x0007F005; |
2011 | } else { | 2020 | } else { |
2012 | u32 ratr_mask; | 2021 | u32 ratr_mask; |
@@ -2016,8 +2025,7 @@ void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw, | |||
2016 | ratr_mask = 0x000ff005; | 2025 | ratr_mask = 0x000ff005; |
2017 | else | 2026 | else |
2018 | ratr_mask = 0x0f0ff005; | 2027 | ratr_mask = 0x0f0ff005; |
2019 | if (curtxbw_40mhz) | 2028 | |
2020 | ratr_mask |= 0x00000010; | ||
2021 | ratr_value &= ratr_mask; | 2029 | ratr_value &= ratr_mask; |
2022 | } | 2030 | } |
2023 | break; | 2031 | break; |
@@ -2026,41 +2034,74 @@ void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw, | |||
2026 | ratr_value &= 0x000ff0ff; | 2034 | ratr_value &= 0x000ff0ff; |
2027 | else | 2035 | else |
2028 | ratr_value &= 0x0f0ff0ff; | 2036 | ratr_value &= 0x0f0ff0ff; |
2037 | |||
2029 | break; | 2038 | break; |
2030 | } | 2039 | } |
2040 | |||
2031 | ratr_value &= 0x0FFFFFFF; | 2041 | ratr_value &= 0x0FFFFFFF; |
2032 | if (nmode && ((curtxbw_40mhz && curshortgi_40mhz) || | 2042 | |
2033 | (!curtxbw_40mhz && curshortgi_20mhz))) { | 2043 | if (nmode && ((curtxbw_40mhz && |
2044 | curshortgi_40mhz) || (!curtxbw_40mhz && | ||
2045 | curshortgi_20mhz))) { | ||
2046 | |||
2034 | ratr_value |= 0x10000000; | 2047 | ratr_value |= 0x10000000; |
2035 | tmp_ratr_value = (ratr_value >> 12); | 2048 | tmp_ratr_value = (ratr_value >> 12); |
2049 | |||
2036 | for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) { | 2050 | for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) { |
2037 | if ((1 << shortgi_rate) & tmp_ratr_value) | 2051 | if ((1 << shortgi_rate) & tmp_ratr_value) |
2038 | break; | 2052 | break; |
2039 | } | 2053 | } |
2054 | |||
2040 | shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) | | 2055 | shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) | |
2041 | (shortgi_rate << 4) | (shortgi_rate); | 2056 | (shortgi_rate << 4) | (shortgi_rate); |
2042 | } | 2057 | } |
2058 | |||
2043 | rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); | 2059 | rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); |
2060 | |||
2061 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n", | ||
2062 | rtl_read_dword(rtlpriv, REG_ARFR0)); | ||
2044 | } | 2063 | } |
2045 | 2064 | ||
2046 | void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | 2065 | static void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, |
2066 | struct ieee80211_sta *sta, | ||
2067 | u8 rssi_level) | ||
2047 | { | 2068 | { |
2048 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 2069 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
2049 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | 2070 | struct rtl_phy *rtlphy = &(rtlpriv->phy); |
2050 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 2071 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
2051 | u32 ratr_bitmap = (u32) mac->basic_rates; | 2072 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); |
2052 | u8 *p_mcsrate = mac->mcs; | 2073 | struct rtl_sta_info *sta_entry = NULL; |
2053 | u8 ratr_index = 0; | 2074 | u32 ratr_bitmap; |
2054 | u8 curtxbw_40mhz = mac->bw_40; | 2075 | u8 ratr_index; |
2055 | u8 curshortgi_40mhz = mac->sgi_40; | 2076 | u8 curtxbw_40mhz = (sta->bandwidth >= IEEE80211_STA_RX_BW_40) ? 1 : 0; |
2056 | u8 curshortgi_20mhz = mac->sgi_20; | 2077 | u8 curshortgi_40mhz = curtxbw_40mhz && |
2057 | enum wireless_mode wirelessmode = mac->mode; | 2078 | (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? |
2079 | 1 : 0; | ||
2080 | u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ? | ||
2081 | 1 : 0; | ||
2082 | enum wireless_mode wirelessmode = 0; | ||
2058 | bool shortgi = false; | 2083 | bool shortgi = false; |
2059 | u8 rate_mask[5]; | 2084 | u8 rate_mask[5]; |
2060 | u8 macid = 0; | 2085 | u8 macid = 0; |
2061 | u8 mimops = 1; | 2086 | u8 mimo_ps = IEEE80211_SMPS_OFF; |
2062 | 2087 | ||
2063 | ratr_bitmap |= (p_mcsrate[1] << 20) | (p_mcsrate[0] << 12); | 2088 | sta_entry = (struct rtl_sta_info *) sta->drv_priv; |
2089 | wirelessmode = sta_entry->wireless_mode; | ||
2090 | if (mac->opmode == NL80211_IFTYPE_STATION || | ||
2091 | mac->opmode == NL80211_IFTYPE_MESH_POINT) | ||
2092 | curtxbw_40mhz = mac->bw_40; | ||
2093 | else if (mac->opmode == NL80211_IFTYPE_AP || | ||
2094 | mac->opmode == NL80211_IFTYPE_ADHOC) | ||
2095 | macid = sta->aid + 1; | ||
2096 | |||
2097 | if (rtlhal->current_bandtype == BAND_ON_5G) | ||
2098 | ratr_bitmap = sta->supp_rates[1] << 4; | ||
2099 | else | ||
2100 | ratr_bitmap = sta->supp_rates[0]; | ||
2101 | if (mac->opmode == NL80211_IFTYPE_ADHOC) | ||
2102 | ratr_bitmap = 0xfff; | ||
2103 | ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 | | ||
2104 | sta->ht_cap.mcs.rx_mask[0] << 12); | ||
2064 | switch (wirelessmode) { | 2105 | switch (wirelessmode) { |
2065 | case WIRELESS_MODE_B: | 2106 | case WIRELESS_MODE_B: |
2066 | ratr_index = RATR_INX_WIRELESS_B; | 2107 | ratr_index = RATR_INX_WIRELESS_B; |
@@ -2071,6 +2112,7 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
2071 | break; | 2112 | break; |
2072 | case WIRELESS_MODE_G: | 2113 | case WIRELESS_MODE_G: |
2073 | ratr_index = RATR_INX_WIRELESS_GB; | 2114 | ratr_index = RATR_INX_WIRELESS_GB; |
2115 | |||
2074 | if (rssi_level == 1) | 2116 | if (rssi_level == 1) |
2075 | ratr_bitmap &= 0x00000f00; | 2117 | ratr_bitmap &= 0x00000f00; |
2076 | else if (rssi_level == 2) | 2118 | else if (rssi_level == 2) |
@@ -2085,7 +2127,8 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
2085 | case WIRELESS_MODE_N_24G: | 2127 | case WIRELESS_MODE_N_24G: |
2086 | case WIRELESS_MODE_N_5G: | 2128 | case WIRELESS_MODE_N_5G: |
2087 | ratr_index = RATR_INX_WIRELESS_NGB; | 2129 | ratr_index = RATR_INX_WIRELESS_NGB; |
2088 | if (mimops == 0) { | 2130 | |
2131 | if (mimo_ps == IEEE80211_SMPS_STATIC) { | ||
2089 | if (rssi_level == 1) | 2132 | if (rssi_level == 1) |
2090 | ratr_bitmap &= 0x00070000; | 2133 | ratr_bitmap &= 0x00070000; |
2091 | else if (rssi_level == 2) | 2134 | else if (rssi_level == 2) |
@@ -2128,8 +2171,10 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
2128 | } | 2171 | } |
2129 | } | 2172 | } |
2130 | } | 2173 | } |
2174 | |||
2131 | if ((curtxbw_40mhz && curshortgi_40mhz) || | 2175 | if ((curtxbw_40mhz && curshortgi_40mhz) || |
2132 | (!curtxbw_40mhz && curshortgi_20mhz)) { | 2176 | (!curtxbw_40mhz && curshortgi_20mhz)) { |
2177 | |||
2133 | if (macid == 0) | 2178 | if (macid == 0) |
2134 | shortgi = true; | 2179 | shortgi = true; |
2135 | else if (macid == 1) | 2180 | else if (macid == 1) |
@@ -2138,21 +2183,42 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) | |||
2138 | break; | 2183 | break; |
2139 | default: | 2184 | default: |
2140 | ratr_index = RATR_INX_WIRELESS_NGB; | 2185 | ratr_index = RATR_INX_WIRELESS_NGB; |
2186 | |||
2141 | if (rtlphy->rf_type == RF_1T2R) | 2187 | if (rtlphy->rf_type == RF_1T2R) |
2142 | ratr_bitmap &= 0x000ff0ff; | 2188 | ratr_bitmap &= 0x000ff0ff; |
2143 | else | 2189 | else |
2144 | ratr_bitmap &= 0x0f0ff0ff; | 2190 | ratr_bitmap &= 0x0f0ff0ff; |
2145 | break; | 2191 | break; |
2146 | } | 2192 | } |
2147 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "ratr_bitmap :%x\n", | 2193 | sta_entry->ratr_index = ratr_index; |
2148 | ratr_bitmap); | 2194 | |
2149 | *(u32 *)&rate_mask = ((ratr_bitmap & 0x0fffffff) | | 2195 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, |
2150 | ratr_index << 28); | 2196 | "ratr_bitmap :%x\n", ratr_bitmap); |
2197 | *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) | | ||
2198 | (ratr_index << 28); | ||
2151 | rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80; | 2199 | rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80; |
2152 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, | 2200 | RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, |
2153 | "Rate_index:%x, ratr_val:%x, %5phC\n", | 2201 | "Rate_index:%x, ratr_val:%x, %5phC\n", |
2154 | ratr_index, ratr_bitmap, rate_mask); | 2202 | ratr_index, ratr_bitmap, rate_mask); |
2155 | rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask); | 2203 | memcpy(rtlpriv->rate_mask, rate_mask, 5); |
2204 | /* rtl92c_fill_h2c_cmd() does USB I/O and will result in a | ||
2205 | * "scheduled while atomic" if called directly */ | ||
2206 | schedule_work(&rtlpriv->works.fill_h2c_cmd); | ||
2207 | |||
2208 | if (macid != 0) | ||
2209 | sta_entry->ratr_index = ratr_index; | ||
2210 | } | ||
2211 | |||
2212 | void rtl92cu_update_hal_rate_tbl(struct ieee80211_hw *hw, | ||
2213 | struct ieee80211_sta *sta, | ||
2214 | u8 rssi_level) | ||
2215 | { | ||
2216 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
2217 | |||
2218 | if (rtlpriv->dm.useramask) | ||
2219 | rtl92cu_update_hal_rate_mask(hw, sta, rssi_level); | ||
2220 | else | ||
2221 | rtl92cu_update_hal_rate_table(hw, sta); | ||
2156 | } | 2222 | } |
2157 | 2223 | ||
2158 | void rtl92cu_update_channel_access_setting(struct ieee80211_hw *hw) | 2224 | void rtl92cu_update_channel_access_setting(struct ieee80211_hw *hw) |