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

Commit 37eb0b16 authored by Jouni Malinen's avatar Jouni Malinen Committed by John W. Linville
Browse files

cfg80211/mac80211: Use more generic bitrate mask for rate control



Extend struct cfg80211_bitrate_mask to actually use a bitfield mask
instead of just a single fixed or maximum rate index. This change
itself does not modify the behavior (except for debugfs files), but it
prepares cfg80211 and mac80211 for a new nl80211 command for setting
which rates can be used in TX rate control.

Since frames are now going through the rate control algorithm
unconditionally, the internal IEEE80211_TX_INTFL_RCALGO flag can now
be removed. The RC implementations can use the rate_idx_mask value to
optimize their behavior if only a single rate is enabled.

The old max_rate_idx in struct ieee80211_tx_rate_control is maintained
(but commented as deprecated) for backwards compatibility with existing
RC implementations. Once these implementations have been updated to
use the more generic rate_idx_mask, the max_rate_idx value can be
removed.

Signed-off-by: default avatarJouni Malinen <jouni.malinen@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e00cfce0
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -857,20 +857,11 @@ enum tx_power_setting {
 * cfg80211_bitrate_mask - masks for bitrate control
 */
struct cfg80211_bitrate_mask {
/*
 * As discussed in Berlin, this struct really
 * should look like this:

	struct {
		u32 legacy;
		u8 mcs[IEEE80211_HT_MCS_MASK_LEN];
		/* TODO: add support for masking MCS rates; e.g.: */
		/* u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; */
	} control[IEEE80211_NUM_BANDS];

 * Since we can always fix in-kernel users, let's keep
 * it simpler for now:
 */
	u32 fixed;   /* fixed bitrate, 0 == not fixed */
	u32 maxrate; /* in kbps, 0 == no limit */
};
/**
 * struct cfg80211_pmksa - PMK Security Association
+4 −4
Original line number Diff line number Diff line
@@ -255,9 +255,6 @@ struct ieee80211_bss_conf {
 * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: internal to mac80211, can be
 *	set by rate control algorithms to indicate probe rate, will
 *	be cleared for fragmented frames (except on the last fragment)
 * @IEEE80211_TX_INTFL_RCALGO: mac80211 internal flag, do not test or
 *	set this flag in the driver; indicates that the rate control
 *	algorithm was used and should be notified of TX status
 * @IEEE80211_TX_INTFL_NEED_TXPROCESSING: completely internal to mac80211,
 *	used to indicate that a pending frame requires TX processing before
 *	it can be sent out.
@@ -287,7 +284,6 @@ enum mac80211_tx_control_flags {
	IEEE80211_TX_STAT_AMPDU			= BIT(10),
	IEEE80211_TX_STAT_AMPDU_NO_BACK		= BIT(11),
	IEEE80211_TX_CTL_RATE_CTRL_PROBE	= BIT(12),
	IEEE80211_TX_INTFL_RCALGO		= BIT(13),
	IEEE80211_TX_INTFL_NEED_TXPROCESSING	= BIT(14),
	IEEE80211_TX_INTFL_RETRIED		= BIT(15),
	IEEE80211_TX_INTFL_DONT_ENCRYPT		= BIT(16),
@@ -2297,6 +2293,9 @@ enum rate_control_changed {
 * @short_preamble: whether mac80211 will request short-preamble transmission
 *	if the selected rate supports it
 * @max_rate_idx: user-requested maximum rate (not MCS for now)
 *	(deprecated; this will be removed once drivers get updated to use
 *	rate_idx_mask)
 * @rate_idx_mask: user-requested rate mask (not MCS for now)
 * @skb: the skb that will be transmitted, the control information in it needs
 *	to be filled in
 * @ap: whether this frame is sent out in AP mode
@@ -2309,6 +2308,7 @@ struct ieee80211_tx_rate_control {
	struct ieee80211_tx_rate reported_rate;
	bool rts, short_preamble;
	u8 max_rate_idx;
	u32 rate_idx_mask;
	bool ap;
};

+3 −29
Original line number Diff line number Diff line
@@ -1406,8 +1406,6 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
	int i;
	u32 target_rate;
	struct ieee80211_supported_band *sband;

	/*
	 * This _could_ be supported by providing a hook for
@@ -1417,37 +1415,13 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
	if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL)
		return -EOPNOTSUPP;

	sband = local->hw.wiphy->bands[local->hw.conf.channel->band];

	/*
	 * target_rate = -1, rate->fixed = 0 means auto only, so use all rates
	 * target_rate = X, rate->fixed = 1 means only rate X
	 * target_rate = X, rate->fixed = 0 means all rates <= X
	 */
	sdata->max_ratectrl_rateidx = -1;
	sdata->force_unicast_rateidx = -1;

	if (mask->fixed)
		target_rate = mask->fixed / 100;
	else if (mask->maxrate)
		target_rate = mask->maxrate / 100;
	else
		return 0;

	for (i = 0; i< sband->n_bitrates; i++) {
		if (target_rate != sband->bitrates[i].bitrate)
			continue;
	for (i = 0; i < IEEE80211_NUM_BANDS; i++)
		sdata->rc_rateidx_mask[i] = mask->control[i].legacy;

		/* requested bitrate found */
		sdata->max_ratectrl_rateidx = i;
		if (mask->fixed)
			sdata->force_unicast_rateidx = i;
	return 0;
}

	return -EINVAL;
}

static int ieee80211_remain_on_channel(struct wiphy *wiphy,
				       struct net_device *dev,
				       struct ieee80211_channel *chan,
+12 −10
Original line number Diff line number Diff line
@@ -127,8 +127,10 @@ __IEEE80211_IF_FILE(name, ieee80211_if_write_##name)

/* common attributes */
IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
IEEE80211_IF_FILE(force_unicast_rateidx, force_unicast_rateidx, DEC);
IEEE80211_IF_FILE(max_ratectrl_rateidx, max_ratectrl_rateidx, DEC);
IEEE80211_IF_FILE(rc_rateidx_mask_2ghz, rc_rateidx_mask[IEEE80211_BAND_2GHZ],
		  HEX);
IEEE80211_IF_FILE(rc_rateidx_mask_5ghz, rc_rateidx_mask[IEEE80211_BAND_5GHZ],
		  HEX);

/* STA attributes */
IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC);
@@ -264,8 +266,8 @@ IEEE80211_IF_FILE(dot11MeshHWMPRootMode,
static void add_sta_files(struct ieee80211_sub_if_data *sdata)
{
	DEBUGFS_ADD(drop_unencrypted, sta);
	DEBUGFS_ADD(force_unicast_rateidx, sta);
	DEBUGFS_ADD(max_ratectrl_rateidx, sta);
	DEBUGFS_ADD(rc_rateidx_mask_2ghz, sta);
	DEBUGFS_ADD(rc_rateidx_mask_5ghz, sta);

	DEBUGFS_ADD(bssid, sta);
	DEBUGFS_ADD(aid, sta);
@@ -275,8 +277,8 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata)
static void add_ap_files(struct ieee80211_sub_if_data *sdata)
{
	DEBUGFS_ADD(drop_unencrypted, ap);
	DEBUGFS_ADD(force_unicast_rateidx, ap);
	DEBUGFS_ADD(max_ratectrl_rateidx, ap);
	DEBUGFS_ADD(rc_rateidx_mask_2ghz, ap);
	DEBUGFS_ADD(rc_rateidx_mask_5ghz, ap);

	DEBUGFS_ADD(num_sta_ps, ap);
	DEBUGFS_ADD(dtim_count, ap);
@@ -286,8 +288,8 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata)
static void add_wds_files(struct ieee80211_sub_if_data *sdata)
{
	DEBUGFS_ADD(drop_unencrypted, wds);
	DEBUGFS_ADD(force_unicast_rateidx, wds);
	DEBUGFS_ADD(max_ratectrl_rateidx, wds);
	DEBUGFS_ADD(rc_rateidx_mask_2ghz, wds);
	DEBUGFS_ADD(rc_rateidx_mask_5ghz, wds);

	DEBUGFS_ADD(peer, wds);
}
@@ -295,8 +297,8 @@ static void add_wds_files(struct ieee80211_sub_if_data *sdata)
static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
{
	DEBUGFS_ADD(drop_unencrypted, vlan);
	DEBUGFS_ADD(force_unicast_rateidx, vlan);
	DEBUGFS_ADD(max_ratectrl_rateidx, vlan);
	DEBUGFS_ADD(rc_rateidx_mask_2ghz, vlan);
	DEBUGFS_ADD(rc_rateidx_mask_5ghz, vlan);
}

static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
+2 −2
Original line number Diff line number Diff line
@@ -494,8 +494,8 @@ struct ieee80211_sub_if_data {
	 */
	struct ieee80211_if_ap *bss;

	int force_unicast_rateidx; /* forced TX rateidx for unicast frames */
	int max_ratectrl_rateidx; /* max TX rateidx for rate control */
	/* bitmap of allowed (non-MCS) rate indexes for rate control */
	u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];

	union {
		struct ieee80211_if_ap ap;
Loading