Commit 48e93e40 authored by Eliad Peller's avatar Eliad Peller Committed by Luciano Coelho

wl12xx: move tx_security_seq into wlvif

The last security seq num has to be saved across reconfigs.
Add a new "persistent" struct into wlvif, which won't get
deleted on wl12xx_init_vif_data()
Signed-off-by: default avatarEliad Peller <eliad@wizery.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent 4b730b6a
...@@ -346,7 +346,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, ...@@ -346,7 +346,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
DRIVER_STATE_PRINT_INT(tx_results_count); DRIVER_STATE_PRINT_INT(tx_results_count);
DRIVER_STATE_PRINT_LHEX(flags); DRIVER_STATE_PRINT_LHEX(flags);
DRIVER_STATE_PRINT_INT(tx_blocks_freed); DRIVER_STATE_PRINT_INT(tx_blocks_freed);
DRIVER_STATE_PRINT_INT(tx_security_last_seq_lsb);
DRIVER_STATE_PRINT_INT(rx_counter); DRIVER_STATE_PRINT_INT(rx_counter);
DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(state);
DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(channel);
......
...@@ -1206,6 +1206,7 @@ static void wl1271_recovery_work(struct work_struct *work) ...@@ -1206,6 +1206,7 @@ static void wl1271_recovery_work(struct work_struct *work)
{ {
struct wl1271 *wl = struct wl1271 *wl =
container_of(work, struct wl1271, recovery_work); container_of(work, struct wl1271, recovery_work);
struct wl12xx_vif *wlvif;
mutex_lock(&wl->mutex); mutex_lock(&wl->mutex);
...@@ -1227,9 +1228,12 @@ static void wl1271_recovery_work(struct work_struct *work) ...@@ -1227,9 +1228,12 @@ static void wl1271_recovery_work(struct work_struct *work)
* in the firmware during recovery. This doens't hurt if the network is * in the firmware during recovery. This doens't hurt if the network is
* not encrypted. * not encrypted.
*/ */
if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || wl12xx_for_each_wlvif(wl, wlvif) {
test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) ||
wl->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING; test_bit(WL1271_FLAG_AP_STARTED, &wl->flags))
wlvif->tx_security_seq +=
WL1271_TX_SQN_POST_RECOVERY_PADDING;
}
/* Prevent spurious TX during FW restart */ /* Prevent spurious TX during FW restart */
ieee80211_stop_queues(wl->hw); ieee80211_stop_queues(wl->hw);
...@@ -1910,8 +1914,8 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) ...@@ -1910,8 +1914,8 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif)
{ {
struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
/* make sure wlvif is zeroed */ /* clear everything but the persistent data */
memset(wlvif, 0, sizeof(*wlvif)); memset(wlvif, 0, offsetof(struct wl12xx_vif, persistent));
switch (ieee80211_vif_type_p2p(vif)) { switch (ieee80211_vif_type_p2p(vif)) {
case NL80211_IFTYPE_P2P_CLIENT: case NL80211_IFTYPE_P2P_CLIENT:
...@@ -2297,8 +2301,8 @@ static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) ...@@ -2297,8 +2301,8 @@ static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif)
goto out; goto out;
/* reset TX security counters on a clean disconnect */ /* reset TX security counters on a clean disconnect */
wl->tx_security_last_seq_lsb = 0; wlvif->tx_security_last_seq_lsb = 0;
wl->tx_security_seq = 0; wlvif->tx_security_seq = 0;
out: out:
return ret; return ret;
...@@ -2870,20 +2874,20 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -2870,20 +2874,20 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
key_type = KEY_TKIP; key_type = KEY_TKIP;
key_conf->hw_key_idx = key_conf->keyidx; key_conf->hw_key_idx = key_conf->keyidx;
tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq);
tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq);
break; break;
case WLAN_CIPHER_SUITE_CCMP: case WLAN_CIPHER_SUITE_CCMP:
key_type = KEY_AES; key_type = KEY_AES;
key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq);
tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq);
break; break;
case WL1271_CIPHER_SUITE_GEM: case WL1271_CIPHER_SUITE_GEM:
key_type = KEY_GEM; key_type = KEY_GEM;
tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq);
tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq);
break; break;
default: default:
wl1271_error("Unknown key algo 0x%x", key_conf->cipher); wl1271_error("Unknown key algo 0x%x", key_conf->cipher);
...@@ -4923,8 +4927,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) ...@@ -4923,8 +4927,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
wl->quirks = 0; wl->quirks = 0;
wl->platform_quirks = 0; wl->platform_quirks = 0;
wl->sched_scanning = false; wl->sched_scanning = false;
wl->tx_security_seq = 0;
wl->tx_security_last_seq_lsb = 0;
wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT;
wl->system_hlid = WL12XX_SYSTEM_HLID; wl->system_hlid = WL12XX_SYSTEM_HLID;
wl->active_sta_count = 0; wl->active_sta_count = 0;
......
...@@ -755,6 +755,8 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, ...@@ -755,6 +755,8 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
struct wl1271_tx_hw_res_descr *result) struct wl1271_tx_hw_res_descr *result)
{ {
struct ieee80211_tx_info *info; struct ieee80211_tx_info *info;
struct ieee80211_vif *vif;
struct wl12xx_vif *wlvif;
struct sk_buff *skb; struct sk_buff *skb;
int id = result->id; int id = result->id;
int rate = -1; int rate = -1;
...@@ -774,6 +776,10 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, ...@@ -774,6 +776,10 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
return; return;
} }
/* info->control is valid as long as we don't update info->status */
vif = info->control.vif;
wlvif = wl12xx_vif_to_data(vif);
/* update the TX status info */ /* update the TX status info */
if (result->status == TX_SUCCESS) { if (result->status == TX_SUCCESS) {
if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
...@@ -801,14 +807,14 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, ...@@ -801,14 +807,14 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP || info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP ||
info->control.hw_key->cipher == WL1271_CIPHER_SUITE_GEM)) { info->control.hw_key->cipher == WL1271_CIPHER_SUITE_GEM)) {
u8 fw_lsb = result->tx_security_sequence_number_lsb; u8 fw_lsb = result->tx_security_sequence_number_lsb;
u8 cur_lsb = wl->tx_security_last_seq_lsb; u8 cur_lsb = wlvif->tx_security_last_seq_lsb;
/* /*
* update security sequence number, taking care of potential * update security sequence number, taking care of potential
* wrap-around * wrap-around
*/ */
wl->tx_security_seq += (fw_lsb - cur_lsb + 256) % 256; wlvif->tx_security_seq += (fw_lsb - cur_lsb) & 0xff;
wl->tx_security_last_seq_lsb = fw_lsb; wlvif->tx_security_last_seq_lsb = fw_lsb;
} }
/* remove private header from packet */ /* remove private header from packet */
......
...@@ -437,17 +437,6 @@ struct wl1271 { ...@@ -437,17 +437,6 @@ struct wl1271 {
struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS]; struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS];
int tx_frames_cnt; int tx_frames_cnt;
/*
* Security sequence number
* bits 0-15: lower 16 bits part of sequence number
* bits 16-47: higher 32 bits part of sequence number
* bits 48-63: not in use
*/
u64 tx_security_seq;
/* 8 bits of the last sequence number in use */
u8 tx_security_last_seq_lsb;
/* FW Rx counter */ /* FW Rx counter */
u32 rx_counter; u32 rx_counter;
...@@ -645,6 +634,25 @@ struct wl12xx_vif { ...@@ -645,6 +634,25 @@ struct wl12xx_vif {
/* RX BA constraint value */ /* RX BA constraint value */
bool ba_support; bool ba_support;
bool ba_allowed; bool ba_allowed;
/*
* This struct must be last!
* data that has to be saved acrossed reconfigs (e.g. recovery)
* should be declared in this struct.
*/
struct {
u8 persistent[0];
/*
* Security sequence number
* bits 0-15: lower 16 bits part of sequence number
* bits 16-47: higher 32 bits part of sequence number
* bits 48-63: not in use
*/
u64 tx_security_seq;
/* 8 bits of the last sequence number in use */
u8 tx_security_last_seq_lsb;
};
}; };
static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif)
......
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