Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3a97e93 authored by Larry Finger's avatar Larry Finger Committed by John W. Linville
Browse files

rtlwifi: Finish modifying core routines for new drivers



Addition of the new drivers and the update to a new version for the others
lead to changes in all the core routines.

Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent d3feae41
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -2,20 +2,16 @@
 *
 * Copyright(c) 2009-2012  Realtek Corporation.
 *
 * Tmis program is free software; you can redistribute it and/or modify it
 * 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.
 *
 * Tmis program is distributed in the hope that it will be useful, but WITHOUT
 * 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.
 *
 * You should have received a copy of the GNU General Public License along with
 * tmis program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * Tme full GNU General Public License is included in this distribution in the
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
+3 −7
Original line number Diff line number Diff line
@@ -2,20 +2,16 @@
 *
 * Copyright(c) 2009-2012  Realtek Corporation.
 *
 * Tmis program is free software; you can redistribute it and/or modify it
 * 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.
 *
 * Tmis program is distributed in the hope that it will be useful, but WITHOUT
 * 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.
 *
 * You should have received a copy of the GNU General Public License along with
 * tmis program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * Tme full GNU General Public License is included in this distribution in the
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
+58 −39
Original line number Diff line number Diff line
@@ -11,10 +11,6 @@
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
@@ -35,13 +31,13 @@
 *Finds the highest rate index we can use
 *if skb is special data like DHCP/EAPOL, we set should
 *it to lowest rate CCK_1M, otherwise we set rate to
 *CCK11M or OFDM_54M based on wireless mode.
 *highest rate based on wireless mode used for iwconfig
 *show Tx rate.
 */
static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv,
				  struct ieee80211_sta *sta,
				  struct sk_buff *skb, bool not_data)
{
	struct rtl_mac *rtlmac = rtl_mac(rtlpriv);
	struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
	struct rtl_phy *rtlphy = &(rtlpriv->phy);
	struct rtl_sta_info *sta_entry = NULL;
@@ -54,21 +50,13 @@ static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv,
	 *2.in rtl_get_tcb_desc when we check rate is
	 *      1M we will not use FW rate but user rate.
	 */
	if (rtlmac->opmode == NL80211_IFTYPE_AP ||
	    rtlmac->opmode == NL80211_IFTYPE_ADHOC ||
	    rtlmac->opmode == NL80211_IFTYPE_MESH_POINT) {

	if (sta) {
		sta_entry = (struct rtl_sta_info *)sta->drv_priv;
		wireless_mode = sta_entry->wireless_mode;
		} else {
			return 0;
		}
	} else {
		wireless_mode = rtlmac->mode;
	}

	if (rtl_is_special_data(rtlpriv->mac80211.hw, skb, true) ||
			not_data) {
	if (rtl_is_special_data(rtlpriv->mac80211.hw, skb, true) || not_data) {
		return 0;
	} else {
		if (rtlhal->current_bandtype == BAND_ON_2_4G) {
@@ -76,21 +64,27 @@ static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv,
				return B_MODE_MAX_RIX;
			} else if (wireless_mode == WIRELESS_MODE_G) {
				return G_MODE_MAX_RIX;
			} else {
			} else if (wireless_mode == WIRELESS_MODE_N_24G) {
				if (get_rf_type(rtlphy) != RF_2T2R)
					return N_MODE_MCS7_RIX;
				else
					return N_MODE_MCS15_RIX;
			} else if (wireless_mode == WIRELESS_MODE_AC_24G) {
				return AC_MODE_MCS9_RIX;
			}
			return 0;
		} else {
			if (wireless_mode == WIRELESS_MODE_A) {
				return A_MODE_MAX_RIX;
			} else {
			} else if (wireless_mode == WIRELESS_MODE_N_5G) {
				if (get_rf_type(rtlphy) != RF_2T2R)
					return N_MODE_MCS7_RIX;
				else
					return N_MODE_MCS15_RIX;
			} else if (wireless_mode == WIRELESS_MODE_AC_5G) {
				return AC_MODE_MCS9_RIX;
			}
			return 0;
		}
	}
}
@@ -103,35 +97,52 @@ static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv,
				    bool not_data)
{
	struct rtl_mac *mac = rtl_mac(rtlpriv);
	u8 sgi_20 = 0, sgi_40 = 0;
	struct rtl_sta_info *sta_entry = NULL;
	u8 wireless_mode = 0;
	u8 sgi_20 = 0, sgi_40 = 0, sgi_80 = 0;

	if (sta) {
		sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20;
		sgi_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
		sgi_80 = sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80;
		sta_entry = (struct rtl_sta_info *)sta->drv_priv;
		wireless_mode = sta_entry->wireless_mode;
	}
	rate->count = tries;
	rate->idx = rix >= 0x00 ? rix : 0x00;
	if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8812AE &&
	    wireless_mode == WIRELESS_MODE_AC_5G)
		rate->idx += 0x10;/*2NSS for 8812AE*/

	if (!not_data) {
		if (txrc->short_preamble)
			rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
		if (mac->opmode == NL80211_IFTYPE_AP ||
			mac->opmode == NL80211_IFTYPE_ADHOC) {
			if (sta && (sta->bandwidth >= IEEE80211_STA_RX_BW_40))
			if (sta && (sta->ht_cap.cap &
				    IEEE80211_HT_CAP_SUP_WIDTH_20_40))
				rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
			if (sta && (sta->vht_cap.vht_supported))
				rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;
		} else {
			if (mac->bw_40)
				rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
			if (mac->bw_80)
				rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;
		}
		if (sgi_20 || sgi_40)

		if (sgi_20 || sgi_40 || sgi_80)
			rate->flags |= IEEE80211_TX_RC_SHORT_GI;
		if (sta && sta->ht_cap.ht_supported)
		if (sta && sta->ht_cap.ht_supported &&
		    ((wireless_mode == WIRELESS_MODE_N_5G) ||
		     (wireless_mode == WIRELESS_MODE_N_24G)))
			rate->flags |= IEEE80211_TX_RC_MCS;
	}
}

static void rtl_get_rate(void *ppriv, struct ieee80211_sta *sta,
			 void *priv_sta, struct ieee80211_tx_rate_control *txrc)
			 void *priv_sta,
			 struct ieee80211_tx_rate_control *txrc)
{
	struct rtl_priv *rtlpriv = ppriv;
	struct sk_buff *skb = txrc->skb;
@@ -193,8 +204,8 @@ static void rtl_tx_status(void *ppriv,
	if (rtl_is_special_data(mac->hw, skb, true))
		return;

	if (is_multicast_ether_addr(ieee80211_get_DA(hdr))
	    || is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
	if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) ||
	    is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
		return;

	if (sta) {
@@ -208,8 +219,8 @@ static void rtl_tx_status(void *ppriv,
						       tid)) {
					sta_entry->tids[tid].agg.agg_state =
						RTL_AGG_PROGRESS;
					ieee80211_start_tx_ba_session(sta,
								 tid, 5000);
					ieee80211_start_tx_ba_session(sta, tid,
								      5000);
				}
			}
		}
@@ -223,8 +234,15 @@ static void rtl_rate_init(void *ppriv,
{
}

static void *rtl_rate_alloc(struct ieee80211_hw *hw,
		struct dentry *debugfsdir)
static void rtl_rate_update(void *ppriv,
			    struct ieee80211_supported_band *sband,
			    struct cfg80211_chan_def *chandef,
			    struct ieee80211_sta *sta, void *priv_sta,
			    u32 changed)
{
}

static void *rtl_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
{
	struct rtl_priv *rtlpriv = rtl_priv(hw);
	return rtlpriv;
@@ -260,13 +278,14 @@ static void rtl_rate_free_sta(void *rtlpriv,
	kfree(rate_priv);
}

static const struct rate_control_ops rtl_rate_ops = {
static struct rate_control_ops rtl_rate_ops = {
	.name = "rtl_rc",
	.alloc = rtl_rate_alloc,
	.free = rtl_rate_free,
	.alloc_sta = rtl_rate_alloc_sta,
	.free_sta = rtl_rate_free_sta,
	.rate_init = rtl_rate_init,
	.rate_update = rtl_rate_update,
	.tx_status = rtl_tx_status,
	.get_rate = rtl_get_rate,
};
+5 −4
Original line number Diff line number Diff line
@@ -11,10 +11,6 @@
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
@@ -38,10 +34,15 @@
#define N_MODE_MCS7_RIX 7
#define N_MODE_MCS15_RIX 15

#define AC_MODE_MCS7_RIX 7
#define AC_MODE_MCS8_RIX 8
#define AC_MODE_MCS9_RIX 9

struct rtl_rate_priv {
	u8 ht_cap;
};

int rtl_rate_control_register(void);
void rtl_rate_control_unregister(void);

#endif
+63 −45
Original line number Diff line number Diff line
@@ -11,10 +11,6 @@
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
@@ -59,26 +55,23 @@ static struct country_code_to_enum_rd allCountries[] = {
 */
#define RTL819x_2GHZ_CH12_13	\
	REG_RULE(2467-10, 2472+10, 40, 0, 20,\
		 NL80211_RRF_NO_IR)
	NL80211_RRF_PASSIVE_SCAN)

#define RTL819x_2GHZ_CH14	\
	REG_RULE(2484-10, 2484+10, 40, 0, 20, \
		 NL80211_RRF_NO_IR | NL80211_RRF_NO_OFDM)
	NL80211_RRF_PASSIVE_SCAN | \
	NL80211_RRF_NO_OFDM)


/* 5G chan 36 - chan 64*/
#define RTL819x_5GHZ_5150_5350	\
	REG_RULE(5150-10, 5350+10, 40, 0, 30, \
		 NL80211_RRF_NO_IR)

	REG_RULE(5150-10, 5350+10, 80, 0, 30, 0)
/* 5G chan 100 - chan 165*/
#define RTL819x_5GHZ_5470_5850	\
	REG_RULE(5470-10, 5850+10, 40, 0, 30, \
		 NL80211_RRF_NO_IR)

	REG_RULE(5470-10, 5850+10, 80, 0, 30, 0)
/* 5G chan 149 - chan 165*/
#define RTL819x_5GHZ_5725_5850	\
	REG_RULE(5725-10, 5850+10, 40, 0, 30, \
		 NL80211_RRF_NO_IR)
	REG_RULE(5725-10, 5850+10, 80, 0, 30, 0)

#define RTL819x_5GHZ_ALL	\
	(RTL819x_5GHZ_5150_5350, RTL819x_5GHZ_5470_5850)
@@ -143,7 +136,7 @@ static const struct ieee80211_regdomain rtl_regdom_14 = {

static bool _rtl_is_radar_freq(u16 center_freq)
{
	return (center_freq >= 5260 && center_freq <= 5700);
	return center_freq >= 5260 && center_freq <= 5700;
}

static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
@@ -169,10 +162,9 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
				continue;
			if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
				reg_rule = freq_reg_info(wiphy,
							 MHZ_TO_KHZ(ch->center_freq));
							 ch->center_freq);
				if (IS_ERR(reg_rule))
					continue;

				/*
				 *If 11d had a rule for this channel ensure
				 *we enable adhoc/beaconing if it allows us to
@@ -182,11 +174,16 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
				 *regulatory_hint().
				 */

				if (!(reg_rule->flags & NL80211_RRF_NO_IR))
					ch->flags &= ~IEEE80211_CHAN_NO_IR;
				if (!(reg_rule->flags & NL80211_RRF_NO_IBSS))
					ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
				if (!(reg_rule->flags &
				      NL80211_RRF_PASSIVE_SCAN))
					ch->flags &=
					    ~IEEE80211_CHAN_PASSIVE_SCAN;
			} else {
				if (ch->beacon_found)
					ch->flags &= ~IEEE80211_CHAN_NO_IR;
					ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
						   IEEE80211_CHAN_PASSIVE_SCAN);
			}
		}
	}
@@ -211,35 +208,35 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
	 */
	if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
		ch = &sband->channels[11];	/* CH 12 */
		if (ch->flags & IEEE80211_CHAN_NO_IR)
			ch->flags &= ~IEEE80211_CHAN_NO_IR;
		if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
			ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
		ch = &sband->channels[12];	/* CH 13 */
		if (ch->flags & IEEE80211_CHAN_NO_IR)
			ch->flags &= ~IEEE80211_CHAN_NO_IR;
		if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
			ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
		return;
	}

	/*
	 *If a country IE has been received check its rule for this
	 *If a country IE has been recieved check its rule for this
	 *channel first before enabling active scan. The passive scan
	 *would have been enforced by the initial processing of our
	 *custom regulatory domain.
	 */

	ch = &sband->channels[11];	/* CH 12 */
	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
	reg_rule = freq_reg_info(wiphy, ch->center_freq);
	if (!IS_ERR(reg_rule)) {
		if (!(reg_rule->flags & NL80211_RRF_NO_IR))
			if (ch->flags & IEEE80211_CHAN_NO_IR)
				ch->flags &= ~IEEE80211_CHAN_NO_IR;
		if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
			if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
				ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
	}

	ch = &sband->channels[12];	/* CH 13 */
	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
	reg_rule = freq_reg_info(wiphy, ch->center_freq);
	if (!IS_ERR(reg_rule)) {
		if (!(reg_rule->flags & NL80211_RRF_NO_IR))
			if (ch->flags & IEEE80211_CHAN_NO_IR)
				ch->flags &= ~IEEE80211_CHAN_NO_IR;
		if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
			if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
				ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
	}
}

@@ -276,7 +273,8 @@ static void _rtl_reg_apply_radar_flags(struct wiphy *wiphy)
		 */
		if (!(ch->flags & IEEE80211_CHAN_DISABLED))
			ch->flags |= IEEE80211_CHAN_RADAR |
				     IEEE80211_CHAN_NO_IR;
			    IEEE80211_CHAN_NO_IBSS |
			    IEEE80211_CHAN_PASSIVE_SCAN;
	}
}

@@ -289,7 +287,23 @@ static void _rtl_reg_apply_world_flags(struct wiphy *wiphy,
	return;
}

static void _rtl_reg_notifier_apply(struct wiphy *wiphy,
static void _rtl_dump_channel_map(struct wiphy *wiphy)
{
	enum ieee80211_band band;
	struct ieee80211_supported_band *sband;
	struct ieee80211_channel *ch;
	unsigned int i;

	for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
		if (!wiphy->bands[band])
			continue;
		sband = wiphy->bands[band];
		for (i = 0; i < sband->n_channels; i++)
			ch = &sband->channels[i];
	}
}

static int _rtl_reg_notifier_apply(struct wiphy *wiphy,
				   struct regulatory_request *request,
				   struct rtl_regulatory *reg)
{
@@ -305,6 +319,10 @@ static void _rtl_reg_notifier_apply(struct wiphy *wiphy,
		_rtl_reg_apply_world_flags(wiphy, request->initiator, reg);
		break;
	}

	_rtl_dump_channel_map(wiphy);

	return 0;
}

static const struct ieee80211_regdomain *_rtl_regdomain_select(
@@ -348,7 +366,6 @@ static int _rtl_regd_init_wiphy(struct rtl_regulatory *reg,
	wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
	wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG;
	wiphy->regulatory_flags &= ~REGULATORY_DISABLE_BEACON_HINTS;

	regd = _rtl_regdomain_select(reg);
	wiphy_apply_custom_regulatory(wiphy, regd);
	_rtl_reg_apply_radar_flags(wiphy);
@@ -382,7 +399,8 @@ int rtl_regd_init(struct ieee80211_hw *hw,
	rtlpriv->regd.country_code = rtlpriv->efuse.channel_plan;

	RT_TRACE(rtlpriv, COMP_REGD, DBG_TRACE,
		 "rtl: EEPROM regdomain: 0x%0x\n", rtlpriv->regd.country_code);
		 "rtl: EEPROM regdomain: 0x%0x\n",
		  rtlpriv->regd.country_code);

	if (rtlpriv->regd.country_code >= COUNTRY_CODE_MAX) {
		RT_TRACE(rtlpriv, COMP_REGD, DBG_DMESG,
Loading