Skip to content

Commit

Permalink
wl1271: Configure rate policies based on AP rates
Browse files Browse the repository at this point in the history
Configure the rate policies to the firmware based on the rates given by
the AP.

Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Reviewed-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Juuso Oikarinen authored and John W. Linville committed Oct 27, 2009
1 parent 545f1da commit 8a5a37a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
3 changes: 3 additions & 0 deletions drivers/net/wireless/wl12xx/wl1271.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ struct wl1271 {
/* Our association ID */
u16 aid;

/* The current band */
enum ieee80211_band band;

/* Default key (for WEP) */
u32 default_key;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/wl12xx/wl1271_acx.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
return 0;
}

int wl1271_acx_rate_policies(struct wl1271 *wl)
int wl1271_acx_rate_policies(struct wl1271 *wl, u32 enabled_rates)
{
struct acx_rate_policy *acx;
int ret = 0;
Expand All @@ -719,7 +719,7 @@ int wl1271_acx_rate_policies(struct wl1271 *wl)

/* configure one default (one-size-fits-all) rate class */
acx->rate_class_cnt = 1;
acx->rate_class[0].enabled_rates = ACX_RATE_MASK_ALL;
acx->rate_class[0].enabled_rates = enabled_rates;
acx->rate_class[0].short_retry_limit = ACX_RATE_RETRY_LIMIT;
acx->rate_class[0].long_retry_limit = ACX_RATE_RETRY_LIMIT;
acx->rate_class[0].aflags = 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/wl12xx/wl1271_acx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble);
int wl1271_acx_cts_protect(struct wl1271 *wl,
enum acx_ctsprotect_type ctsprotect);
int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats);
int wl1271_acx_rate_policies(struct wl1271 *wl);
int wl1271_acx_rate_policies(struct wl1271 *wl, u32 enabled_rates);
int wl1271_acx_ac_cfg(struct wl1271 *wl);
int wl1271_acx_tid_cfg(struct wl1271 *wl);
int wl1271_acx_frag_threshold(struct wl1271 *wl);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/wl12xx/wl1271_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ int wl1271_hw_init(struct wl1271 *wl)
goto out_free_memmap;

/* Configure TX rate classes */
ret = wl1271_acx_rate_policies(wl);
ret = wl1271_acx_rate_policies(wl, ACX_RATE_MASK_ALL);
if (ret < 0)
goto out_free_memmap;

Expand Down
31 changes: 31 additions & 0 deletions drivers/net/wireless/wl12xx/wl1271_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
wl->ssid_len = 0;
wl->listen_int = 1;
wl->bss_type = MAX_BSS_TYPE;
wl->band = IEEE80211_BAND_2GHZ;

wl->rx_counter = 0;
wl->elp = false;
Expand Down Expand Up @@ -727,6 +728,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)

mutex_lock(&wl->mutex);

wl->band = conf->channel->band;

ret = wl1271_ps_elp_wakeup(wl, false);
if (ret < 0)
goto out;
Expand Down Expand Up @@ -978,6 +981,22 @@ static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
return ret;
}

static u32 wl1271_enabled_rates_get(struct wl1271 *wl, u64 basic_rate_set)
{
struct ieee80211_supported_band *band;
u32 enabled_rates = 0;
int bit;

band = wl->hw->wiphy->bands[wl->band];
for (bit = 0; bit < band->n_bitrates; bit++) {
if (basic_rate_set & 0x1)
enabled_rates |= band->bitrates[bit].hw_value;
basic_rate_set >>= 1;
}

return enabled_rates;
}

static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_bss_conf *bss_conf,
Expand Down Expand Up @@ -1016,6 +1035,7 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
}
}
}

if (changed & BSS_CHANGED_ERP_SLOT) {
if (bss_conf->use_short_slot)
ret = wl1271_acx_slot(wl, SLOT_TIME_SHORT);
Expand Down Expand Up @@ -1045,6 +1065,16 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
}
}

if (changed & BSS_CHANGED_BASIC_RATES) {
u32 enabled_rates = wl1271_enabled_rates_get(
wl, bss_conf->basic_rates);
ret = wl1271_acx_rate_policies(wl, enabled_rates);
if (ret < 0) {
wl1271_warning("Set rate policies failed %d", ret);
goto out_sleep;
}
}

out_sleep:
wl1271_ps_elp_sleep(wl);

Expand Down Expand Up @@ -1239,6 +1269,7 @@ static int __devinit wl1271_probe(struct spi_device *spi)
wl->psm_requested = false;
wl->tx_queue_stopped = false;
wl->power_level = WL1271_DEFAULT_POWER_LEVEL;
wl->band = IEEE80211_BAND_2GHZ;

/* We use the default power on sleep time until we know which chip
* we're using */
Expand Down

0 comments on commit 8a5a37a

Please sign in to comment.