diff options
Diffstat (limited to 'net/mac80211/rc80211_pid_algo.c')
| -rw-r--r-- | net/mac80211/rc80211_pid_algo.c | 76 | 
1 files changed, 41 insertions, 35 deletions
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c index c339571632b..c5a607ca844 100644 --- a/net/mac80211/rc80211_pid_algo.c +++ b/net/mac80211/rc80211_pid_algo.c @@ -102,23 +102,23 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,  					 struct rc_pid_rateinfo *rinfo)  {  	struct ieee80211_sub_if_data *sdata; -	struct ieee80211_hw_mode *mode; +	struct ieee80211_supported_band *sband;  	int newidx;  	int maxrate;  	int back = (adj > 0) ? 1 : -1;  	sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); -	mode = local->oper_hw_mode; +	sband = local->hw.wiphy->bands[local->hw.conf.channel->band];  	maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1; -	newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate, -					       mode->num_rates); +	newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate_idx, +					       sband->n_bitrates); -	while (newidx != sta->txrate) { -		if (rate_supported(sta, mode, newidx) && +	while (newidx != sta->txrate_idx) { +		if (rate_supported(sta, sband->band, newidx) &&  		    (maxrate < 0 || newidx <= maxrate)) { -			sta->txrate = newidx; +			sta->txrate_idx = newidx;  			break;  		} @@ -128,7 +128,7 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,  #ifdef CONFIG_MAC80211_DEBUGFS  	rate_control_pid_event_rate_change(  		&((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events, -		newidx, mode->rates[newidx].rate); +		newidx, sband->bitrates[newidx].bitrate);  #endif  } @@ -155,7 +155,7 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,  {  	struct rc_pid_sta_info *spinfo = sta->rate_ctrl_priv;  	struct rc_pid_rateinfo *rinfo = pinfo->rinfo; -	struct ieee80211_hw_mode *mode; +	struct ieee80211_supported_band *sband;  	u32 pf;  	s32 err_avg;  	u32 err_prop; @@ -164,7 +164,7 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,  	int adj, i, j, tmp;  	unsigned long period; -	mode = local->oper_hw_mode; +	sband = local->hw.wiphy->bands[local->hw.conf.channel->band];  	spinfo = sta->rate_ctrl_priv;  	/* In case nothing happened during the previous control interval, turn @@ -190,18 +190,18 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,  	spinfo->tx_num_failed = 0;  	/* If we just switched rate, update the rate behaviour info. */ -	if (pinfo->oldrate != sta->txrate) { +	if (pinfo->oldrate != sta->txrate_idx) {  		i = rinfo[pinfo->oldrate].rev_index; -		j = rinfo[sta->txrate].rev_index; +		j = rinfo[sta->txrate_idx].rev_index;  		tmp = (pf - spinfo->last_pf);  		tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT);  		rinfo[j].diff = rinfo[i].diff + tmp; -		pinfo->oldrate = sta->txrate; +		pinfo->oldrate = sta->txrate_idx;  	} -	rate_control_pid_normalize(pinfo, mode->num_rates); +	rate_control_pid_normalize(pinfo, sband->n_bitrates);  	/* Compute the proportional, integral and derivative errors. */  	err_prop = (pinfo->target << RC_PID_ARITH_SHIFT) - pf; @@ -242,8 +242,10 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev,  	struct sta_info *sta;  	struct rc_pid_sta_info *spinfo;  	unsigned long period; +	struct ieee80211_supported_band *sband;  	sta = sta_info_get(local, hdr->addr1); +	sband = local->hw.wiphy->bands[local->hw.conf.channel->band];  	if (!sta)  		return; @@ -251,13 +253,13 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev,  	/* Don't update the state if we're not controlling the rate. */  	sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);  	if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { -		sta->txrate = sdata->bss->max_ratectrl_rateidx; +		sta->txrate_idx = sdata->bss->max_ratectrl_rateidx;  		return;  	}  	/* Ignore all frames that were sent with a different rate than the rate  	 * we currently advise mac80211 to use. */ -	if (status->control.rate != &local->oper_hw_mode->rates[sta->txrate]) +	if (status->control.tx_rate != &sband->bitrates[sta->txrate_idx])  		goto ignore;  	spinfo = sta->rate_ctrl_priv; @@ -304,7 +306,7 @@ ignore:  }  static void rate_control_pid_get_rate(void *priv, struct net_device *dev, -				      struct ieee80211_hw_mode *mode, +				      struct ieee80211_supported_band *sband,  				      struct sk_buff *skb,  				      struct rate_selection *sel)  { @@ -322,7 +324,7 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev,  	fc = le16_to_cpu(hdr->frame_control);  	if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||  	    is_multicast_ether_addr(hdr->addr1) || !sta) { -		sel->rate = rate_lowest(local, mode, sta); +		sel->rate = rate_lowest(local, sband, sta);  		if (sta)  			sta_info_put(sta);  		return; @@ -331,23 +333,23 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev,  	/* If a forced rate is in effect, select it. */  	sdata = IEEE80211_DEV_TO_SUB_IF(dev);  	if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) -		sta->txrate = sdata->bss->force_unicast_rateidx; +		sta->txrate_idx = sdata->bss->force_unicast_rateidx; -	rateidx = sta->txrate; +	rateidx = sta->txrate_idx; -	if (rateidx >= mode->num_rates) -		rateidx = mode->num_rates - 1; +	if (rateidx >= sband->n_bitrates) +		rateidx = sband->n_bitrates - 1; -	sta->last_txrate = rateidx; +	sta->last_txrate_idx = rateidx;  	sta_info_put(sta); -	sel->rate = &mode->rates[rateidx]; +	sel->rate = &sband->bitrates[rateidx];  #ifdef CONFIG_MAC80211_DEBUGFS  	rate_control_pid_event_tx_rate(  		&((struct rc_pid_sta_info *) sta->rate_ctrl_priv)->events, -		rateidx, mode->rates[rateidx].rate); +		rateidx, sband->bitrates[rateidx].bitrate);  #endif  } @@ -359,28 +361,32 @@ static void rate_control_pid_rate_init(void *priv, void *priv_sta,  	 * as we need to have IEEE 802.1X auth succeed immediately after assoc..  	 * Until that method is implemented, we will use the lowest supported  	 * rate as a workaround. */ -	sta->txrate = rate_lowest_index(local, local->oper_hw_mode, sta); +	struct ieee80211_supported_band *sband; + +	sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; +	sta->txrate_idx = rate_lowest_index(local, sband, sta);  }  static void *rate_control_pid_alloc(struct ieee80211_local *local)  {  	struct rc_pid_info *pinfo;  	struct rc_pid_rateinfo *rinfo; -	struct ieee80211_hw_mode *mode; +	struct ieee80211_supported_band *sband;  	int i, j, tmp;  	bool s;  #ifdef CONFIG_MAC80211_DEBUGFS  	struct rc_pid_debugfs_entries *de;  #endif +	sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; +  	pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC);  	if (!pinfo)  		return NULL; -	/* We can safely assume that oper_hw_mode won't change unless we get +	/* We can safely assume that sband won't change unless we get  	 * reinitialized. */ -	mode = local->oper_hw_mode; -	rinfo = kmalloc(sizeof(*rinfo) * mode->num_rates, GFP_ATOMIC); +	rinfo = kmalloc(sizeof(*rinfo) * sband->n_bitrates, GFP_ATOMIC);  	if (!rinfo) {  		kfree(pinfo);  		return NULL; @@ -389,7 +395,7 @@ static void *rate_control_pid_alloc(struct ieee80211_local *local)  	/* Sort the rates. This is optimized for the most common case (i.e.  	 * almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed  	 * mapping too. */ -	for (i = 0; i < mode->num_rates; i++) { +	for (i = 0; i < sband->n_bitrates; i++) {  		rinfo[i].index = i;  		rinfo[i].rev_index = i;  		if (pinfo->fast_start) @@ -397,11 +403,11 @@ static void *rate_control_pid_alloc(struct ieee80211_local *local)  		else  			rinfo[i].diff = i * pinfo->norm_offset;  	} -	for (i = 1; i < mode->num_rates; i++) { +	for (i = 1; i < sband->n_bitrates; i++) {  		s = 0; -		for (j = 0; j < mode->num_rates - i; j++) -			if (unlikely(mode->rates[rinfo[j].index].rate > -				     mode->rates[rinfo[j + 1].index].rate)) { +		for (j = 0; j < sband->n_bitrates - i; j++) +			if (unlikely(sband->bitrates[rinfo[j].index].bitrate > +				     sband->bitrates[rinfo[j + 1].index].bitrate)) {  				tmp = rinfo[j].index;  				rinfo[j].index = rinfo[j + 1].index;  				rinfo[j + 1].index = tmp;  |