diff options
author | Arik Nemtsov <arik@wizery.com> | 2012-11-28 04:42:48 -0500 |
---|---|---|
committer | Luciano Coelho <coelho@ti.com> | 2012-12-11 05:37:24 -0500 |
commit | 2fd8a3bb49400a4a0fe9d9cd9d49019e7a46403e (patch) | |
tree | a0a16e8953895b47b7d8e34fccaf87eb0daf5d8e /drivers/net/wireless/ti/wl18xx/main.c | |
parent | 0b70078c38fd1c8d69cf52b93e8c3bdd719a2394 (diff) |
wl18xx: count HW block spare based correctly on keys
We have no idea how many VIFs there are requiring a special spare, we
know just about the number of keys set. Rename the counter appropriately
and toggle it whenever a special key is added/removed.
Previously this was only changed once, since it was toggled whenever
the actual spare was changed.
Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/ti/wl18xx/main.c')
-rw-r--r-- | drivers/net/wireless/ti/wl18xx/main.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c index ec331e9e0b74..6b57686c5b0d 100644 --- a/drivers/net/wireless/ti/wl18xx/main.c +++ b/drivers/net/wireless/ti/wl18xx/main.c | |||
@@ -1021,7 +1021,7 @@ static int wl18xx_hw_init(struct wl1271 *wl) | |||
1021 | 1021 | ||
1022 | /* (re)init private structures. Relevant on recovery as well. */ | 1022 | /* (re)init private structures. Relevant on recovery as well. */ |
1023 | priv->last_fw_rls_idx = 0; | 1023 | priv->last_fw_rls_idx = 0; |
1024 | priv->extra_spare_vif_count = 0; | 1024 | priv->extra_spare_key_count = 0; |
1025 | 1025 | ||
1026 | /* set the default amount of spare blocks in the bitmap */ | 1026 | /* set the default amount of spare blocks in the bitmap */ |
1027 | ret = wl18xx_set_host_cfg_bitmap(wl, WL18XX_TX_HW_BLOCK_SPARE); | 1027 | ret = wl18xx_set_host_cfg_bitmap(wl, WL18XX_TX_HW_BLOCK_SPARE); |
@@ -1285,8 +1285,8 @@ static int wl18xx_get_spare_blocks(struct wl1271 *wl, bool is_gem) | |||
1285 | { | 1285 | { |
1286 | struct wl18xx_priv *priv = wl->priv; | 1286 | struct wl18xx_priv *priv = wl->priv; |
1287 | 1287 | ||
1288 | /* If we have VIFs requiring extra spare, indulge them */ | 1288 | /* If we have keys requiring extra spare, indulge them */ |
1289 | if (priv->extra_spare_vif_count) | 1289 | if (priv->extra_spare_key_count) |
1290 | return WL18XX_TX_HW_EXTRA_BLOCK_SPARE; | 1290 | return WL18XX_TX_HW_EXTRA_BLOCK_SPARE; |
1291 | 1291 | ||
1292 | return WL18XX_TX_HW_BLOCK_SPARE; | 1292 | return WL18XX_TX_HW_BLOCK_SPARE; |
@@ -1298,42 +1298,48 @@ static int wl18xx_set_key(struct wl1271 *wl, enum set_key_cmd cmd, | |||
1298 | struct ieee80211_key_conf *key_conf) | 1298 | struct ieee80211_key_conf *key_conf) |
1299 | { | 1299 | { |
1300 | struct wl18xx_priv *priv = wl->priv; | 1300 | struct wl18xx_priv *priv = wl->priv; |
1301 | bool change_spare = false; | 1301 | bool change_spare = false, special_enc; |
1302 | int ret; | 1302 | int ret; |
1303 | 1303 | ||
1304 | wl1271_debug(DEBUG_CRYPT, "extra spare keys before: %d", | ||
1305 | priv->extra_spare_key_count); | ||
1306 | |||
1307 | special_enc = key_conf->cipher == WL1271_CIPHER_SUITE_GEM || | ||
1308 | key_conf->cipher == WLAN_CIPHER_SUITE_TKIP; | ||
1309 | |||
1310 | ret = wlcore_set_key(wl, cmd, vif, sta, key_conf); | ||
1311 | if (ret < 0) | ||
1312 | goto out; | ||
1313 | |||
1304 | /* | 1314 | /* |
1305 | * when adding the first or removing the last GEM/TKIP interface, | 1315 | * when adding the first or removing the last GEM/TKIP key, |
1306 | * we have to adjust the number of spare blocks. | 1316 | * we have to adjust the number of spare blocks. |
1307 | */ | 1317 | */ |
1308 | change_spare = (key_conf->cipher == WL1271_CIPHER_SUITE_GEM || | 1318 | if (special_enc) { |
1309 | key_conf->cipher == WLAN_CIPHER_SUITE_TKIP) && | 1319 | if (cmd == SET_KEY) { |
1310 | ((priv->extra_spare_vif_count == 0 && cmd == SET_KEY) || | 1320 | /* first key */ |
1311 | (priv->extra_spare_vif_count == 1 && cmd == DISABLE_KEY)); | 1321 | change_spare = (priv->extra_spare_key_count == 0); |
1322 | priv->extra_spare_key_count++; | ||
1323 | } else if (cmd == DISABLE_KEY) { | ||
1324 | /* last key */ | ||
1325 | change_spare = (priv->extra_spare_key_count == 1); | ||
1326 | priv->extra_spare_key_count--; | ||
1327 | } | ||
1328 | } | ||
1312 | 1329 | ||
1313 | /* no need to change spare - just regular set_key */ | 1330 | wl1271_debug(DEBUG_CRYPT, "extra spare keys after: %d", |
1314 | if (!change_spare) | 1331 | priv->extra_spare_key_count); |
1315 | return wlcore_set_key(wl, cmd, vif, sta, key_conf); | ||
1316 | 1332 | ||
1317 | ret = wlcore_set_key(wl, cmd, vif, sta, key_conf); | 1333 | if (!change_spare) |
1318 | if (ret < 0) | ||
1319 | goto out; | 1334 | goto out; |
1320 | 1335 | ||
1321 | /* key is now set, change the spare blocks */ | 1336 | /* key is now set, change the spare blocks */ |
1322 | if (cmd == SET_KEY) { | 1337 | if (priv->extra_spare_key_count) |
1323 | ret = wl18xx_set_host_cfg_bitmap(wl, | 1338 | ret = wl18xx_set_host_cfg_bitmap(wl, |
1324 | WL18XX_TX_HW_EXTRA_BLOCK_SPARE); | 1339 | WL18XX_TX_HW_EXTRA_BLOCK_SPARE); |
1325 | if (ret < 0) | 1340 | else |
1326 | goto out; | ||
1327 | |||
1328 | priv->extra_spare_vif_count++; | ||
1329 | } else { | ||
1330 | ret = wl18xx_set_host_cfg_bitmap(wl, | 1341 | ret = wl18xx_set_host_cfg_bitmap(wl, |
1331 | WL18XX_TX_HW_BLOCK_SPARE); | 1342 | WL18XX_TX_HW_BLOCK_SPARE); |
1332 | if (ret < 0) | ||
1333 | goto out; | ||
1334 | |||
1335 | priv->extra_spare_vif_count--; | ||
1336 | } | ||
1337 | 1343 | ||
1338 | out: | 1344 | out: |
1339 | return ret; | 1345 | return ret; |