Commit 5f704d18 authored by Arik Nemtsov's avatar Arik Nemtsov Committed by Luciano Coelho

wl12xx: use wiphy values for setting rts, frag thresholds on init

Use the wiphy RTS and fragmentation thresholds for initializing the FW
when possible. This mitigates a bug where previously set values are
forgotten after interface down/up.

Add checks before settings these values to ensure they are valid. Use
default values when invalid thresholds are configured.

Update the default RTS threshold to the maximum value given by the
specification.
Signed-off-by: default avatarArik Nemtsov <arik@wizery.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent 801f870b
...@@ -325,12 +325,19 @@ int wl1271_acx_service_period_timeout(struct wl1271 *wl) ...@@ -325,12 +325,19 @@ int wl1271_acx_service_period_timeout(struct wl1271 *wl)
return ret; return ret;
} }
int wl1271_acx_rts_threshold(struct wl1271 *wl, u16 rts_threshold) int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold)
{ {
struct acx_rts_threshold *rts; struct acx_rts_threshold *rts;
int ret; int ret;
wl1271_debug(DEBUG_ACX, "acx rts threshold"); /*
* If the RTS threshold is not configured or out of range, use the
* default value.
*/
if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
rts_threshold = wl->conf.rx.rts_threshold;
wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
rts = kzalloc(sizeof(*rts), GFP_KERNEL); rts = kzalloc(sizeof(*rts), GFP_KERNEL);
if (!rts) { if (!rts) {
...@@ -338,7 +345,7 @@ int wl1271_acx_rts_threshold(struct wl1271 *wl, u16 rts_threshold) ...@@ -338,7 +345,7 @@ int wl1271_acx_rts_threshold(struct wl1271 *wl, u16 rts_threshold)
goto out; goto out;
} }
rts->threshold = cpu_to_le16(rts_threshold); rts->threshold = cpu_to_le16((u16)rts_threshold);
ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts)); ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
if (ret < 0) { if (ret < 0) {
...@@ -928,12 +935,19 @@ int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type, ...@@ -928,12 +935,19 @@ int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
return ret; return ret;
} }
int wl1271_acx_frag_threshold(struct wl1271 *wl, u16 frag_threshold) int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
{ {
struct acx_frag_threshold *acx; struct acx_frag_threshold *acx;
int ret = 0; int ret = 0;
wl1271_debug(DEBUG_ACX, "acx frag threshold"); /*
* If the fragmentation is not configured or out of range, use the
* default value.
*/
if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
frag_threshold = wl->conf.tx.frag_threshold;
wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
acx = kzalloc(sizeof(*acx), GFP_KERNEL); acx = kzalloc(sizeof(*acx), GFP_KERNEL);
...@@ -942,7 +956,7 @@ int wl1271_acx_frag_threshold(struct wl1271 *wl, u16 frag_threshold) ...@@ -942,7 +956,7 @@ int wl1271_acx_frag_threshold(struct wl1271 *wl, u16 frag_threshold)
goto out; goto out;
} }
acx->frag_threshold = cpu_to_le16(frag_threshold); acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx)); ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
if (ret < 0) { if (ret < 0) {
wl1271_warning("Setting of frag threshold failed: %d", ret); wl1271_warning("Setting of frag threshold failed: %d", ret);
......
...@@ -1333,7 +1333,7 @@ int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time); ...@@ -1333,7 +1333,7 @@ int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time);
int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable, int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable,
void *mc_list, u32 mc_list_len); void *mc_list, u32 mc_list_len);
int wl1271_acx_service_period_timeout(struct wl1271 *wl); int wl1271_acx_service_period_timeout(struct wl1271 *wl);
int wl1271_acx_rts_threshold(struct wl1271 *wl, u16 rts_threshold); int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold);
int wl1271_acx_dco_itrim_params(struct wl1271 *wl); int wl1271_acx_dco_itrim_params(struct wl1271 *wl);
int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter); int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter);
int wl1271_acx_beacon_filter_table(struct wl1271 *wl); int wl1271_acx_beacon_filter_table(struct wl1271 *wl);
...@@ -1357,7 +1357,7 @@ int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, ...@@ -1357,7 +1357,7 @@ int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type, int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
u8 tsid, u8 ps_scheme, u8 ack_policy, u8 tsid, u8 ps_scheme, u8 ack_policy,
u32 apsd_conf0, u32 apsd_conf1); u32 apsd_conf0, u32 apsd_conf1);
int wl1271_acx_frag_threshold(struct wl1271 *wl, u16 frag_threshold); int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold);
int wl1271_acx_tx_config_options(struct wl1271 *wl); int wl1271_acx_tx_config_options(struct wl1271 *wl);
int wl1271_acx_ap_mem_cfg(struct wl1271 *wl); int wl1271_acx_ap_mem_cfg(struct wl1271 *wl);
int wl1271_acx_sta_mem_cfg(struct wl1271 *wl); int wl1271_acx_sta_mem_cfg(struct wl1271 *wl);
......
...@@ -258,7 +258,7 @@ int wl1271_init_phy_config(struct wl1271 *wl) ...@@ -258,7 +258,7 @@ int wl1271_init_phy_config(struct wl1271 *wl)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold); ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -614,7 +614,7 @@ int wl1271_hw_init(struct wl1271 *wl) ...@@ -614,7 +614,7 @@ int wl1271_hw_init(struct wl1271 *wl)
goto out_free_memmap; goto out_free_memmap;
/* Default fragmentation threshold */ /* Default fragmentation threshold */
ret = wl1271_acx_frag_threshold(wl, wl->conf.tx.frag_threshold); ret = wl1271_acx_frag_threshold(wl, wl->hw->wiphy->frag_threshold);
if (ret < 0) if (ret < 0)
goto out_free_memmap; goto out_free_memmap;
......
...@@ -163,7 +163,7 @@ static struct conf_drv_settings default_conf = { ...@@ -163,7 +163,7 @@ static struct conf_drv_settings default_conf = {
.packet_detection_threshold = 0, .packet_detection_threshold = 0,
.ps_poll_timeout = 15, .ps_poll_timeout = 15,
.upsd_timeout = 15, .upsd_timeout = 15,
.rts_threshold = 2347, .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD,
.rx_cca_threshold = 0, .rx_cca_threshold = 0,
.irq_blk_threshold = 0xFFFF, .irq_blk_threshold = 0xFFFF,
.irq_pkt_threshold = 0, .irq_pkt_threshold = 0,
...@@ -2360,7 +2360,7 @@ static int wl1271_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value) ...@@ -2360,7 +2360,7 @@ static int wl1271_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = wl1271_acx_frag_threshold(wl, (u16)value); ret = wl1271_acx_frag_threshold(wl, value);
if (ret < 0) if (ret < 0)
wl1271_warning("wl1271_op_set_frag_threshold failed: %d", ret); wl1271_warning("wl1271_op_set_frag_threshold failed: %d", ret);
...@@ -2388,7 +2388,7 @@ static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) ...@@ -2388,7 +2388,7 @@ static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = wl1271_acx_rts_threshold(wl, (u16) value); ret = wl1271_acx_rts_threshold(wl, value);
if (ret < 0) if (ret < 0)
wl1271_warning("wl1271_op_set_rts_threshold failed: %d", ret); wl1271_warning("wl1271_op_set_rts_threshold failed: %d", ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment