[PATCH 1/1] Cleanup encryption implementation

Olof Johansson dev at skyshaper.net
Wed Jun 26 07:40:27 EDT 2013


This commit cleans up the encryption implementation by removing
unnecessary stuff like the en_state and the encrypt parameter.
---
 dxe.c     | 11 +----------
 main.c    | 24 ++++++++++--------------
 txrx.c    |  8 ++++++--
 txrx.h    |  2 +-
 wcn36xx.h |  6 ------
 5 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/dxe.c b/dxe.c
index 4de4cb1..d15a7b7 100644
--- a/dxe.c
+++ b/dxe.c
@@ -576,16 +576,7 @@ int wcn36xx_dxe_tx(struct wcn36xx *wcn,
 	}

 	wcn36xx_prepare_tx_bd(ctl->bd_cpu_addr, skb->len, header_len);
-	/* Do not encrypt NULL and MGMT frames */
-	if (!is_high && WCN36XX_BSS_KEY == wcn->en_state &&
-	    !ieee80211_is_nullfunc(hdr->frame_control)) {
-		wcn36xx_dbg(WCN36XX_DBG_DXE, "DXE Encription enabled");
-		wcn36xx_fill_tx_bd(wcn, ctl->bd_cpu_addr, broadcast, 0, hdr,
-				   tx_ack);
-	} else {
-		wcn36xx_fill_tx_bd(wcn, ctl->bd_cpu_addr, broadcast, 1, hdr,
-				   tx_ack);
-	}
+	wcn36xx_fill_tx_bd(wcn, ctl->bd_cpu_addr, broadcast, hdr, tx_ack);

 	ctl = ch->head_blk_ctl;
 	desc = ctl->desc;
diff --git a/main.c b/main.c
index de787f3..f770d84 100644
--- a/main.c
+++ b/main.c
@@ -382,14 +382,6 @@ static int wcn36xx_set_key(struct ieee80211_hw
*hw, enum set_key_cmd cmd,

 	switch (cmd) {
 	case SET_KEY:
-		/* Reconfigure bss with encrypt_type */
-		if (IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags)
-			wcn36xx_smd_config_bss(wcn,
-					       NL80211_IFTYPE_STATION,
-					       sta->addr,
-					       true,
-					       wcn->beacon_interval);
-
 		if (WCN36XX_HAL_ED_TKIP == wcn->encrypt_type) {
 			/*
 			 * Supplicant is sending key in the wrong order:
@@ -404,13 +396,20 @@ static int wcn36xx_set_key(struct ieee80211_hw
*hw, enum set_key_cmd cmd,
 		} else {
 			memcpy(key, key_conf->key, key_conf->keylen);
 		}
-		if (WCN36XX_STA_KEY == wcn->en_state) {
+
+		if (IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags) {
+			/* Reconfigure bss with encrypt_type */
+			wcn36xx_smd_config_bss(wcn,
+					       NL80211_IFTYPE_STATION,
+					       sta->addr,
+					       true,
+					       wcn->beacon_interval);
+
 			wcn36xx_smd_set_stakey(wcn,
 				wcn->encrypt_type,
 				key_conf->keyidx,
 				key_conf->keylen,
 				key);
-			wcn->en_state = WCN36XX_BSS_KEY;
 		} else {
 			wcn36xx_smd_set_bsskey(wcn,
 				wcn->encrypt_type,
@@ -420,11 +419,10 @@ static int wcn36xx_set_key(struct ieee80211_hw
*hw, enum set_key_cmd cmd,
 		}
 		break;
 	case DISABLE_KEY:
-		if (WCN36XX_BSS_KEY == wcn->en_state) {
+		if (!(IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags)) {
 			wcn36xx_smd_remove_bsskey(wcn,
 				wcn->encrypt_type,
 				key_conf->keyidx);
-			wcn->en_state = WCN36XX_STA_KEY;
 		} else {
 			/* do not remove key if disassociated */
 			if (wcn->aid)
@@ -559,7 +557,6 @@ static void wcn36xx_bss_info_changed(struct
ieee80211_hw *hw,
 				     bss_conf->aid);

 			wcn->aid = bss_conf->aid;
-			wcn->en_state = WCN36XX_STA_KEY;

 			rcu_read_lock();
 			sta = ieee80211_find_sta(vif, bss_conf->bssid);
@@ -582,7 +579,6 @@ static void wcn36xx_bss_info_changed(struct
ieee80211_hw *hw,
 				    vif->addr,
 				    bss_conf->aid);
 			wcn->aid = 0;
-			wcn->en_state = WCN36XX_STA_KEY;
 			wcn36xx_smd_delete_sta(wcn);
 			wcn36xx_smd_delete_bss(wcn);
 			wcn36xx_smd_set_link_st(wcn,
diff --git a/txrx.c b/txrx.c
index 9c3a4d1..a23cbd8 100644
--- a/txrx.c
+++ b/txrx.c
@@ -84,7 +84,7 @@ void wcn36xx_prepare_tx_bd(struct wcn36xx_tx_bd *bd,
u32 len, u32 header_len)
 	bd->pdu.mpdu_len = len;
 }
 void wcn36xx_fill_tx_bd(struct wcn36xx *wcn, struct wcn36xx_tx_bd *bd,
-			u8 broadcast, u8 encrypt, struct ieee80211_hdr *hdr,
+			u8 broadcast, struct ieee80211_hdr *hdr,
 			bool tx_compl)
 {
 	bd->dpu_rf = WCN36XX_BMU_WQ_TX;
@@ -119,17 +119,21 @@ void wcn36xx_fill_tx_bd(struct wcn36xx *wcn,
struct wcn36xx_tx_bd *bd,
 			wcn36xx_warn("frame control type unknown");
 	}

+	bd->dpu_ne = 0;
 	if (ieee80211_is_data(hdr->frame_control)) {
 		bd->dpu_sign = wcn->current_vif->ucast_dpu_signature;
 		bd->queue_id = 0;
 		bd->sta_index = wcn->current_vif->sta_index;
 		bd->dpu_desc_idx = wcn->current_vif->dpu_desc_index;
+		if(ieee80211_is_nullfunc(hdr->frame_control))
+			bd->dpu_ne = 1;
+
 	} else {
 		bd->sta_index = wcn->current_vif->self_sta_index;
 		bd->dpu_desc_idx = wcn->current_vif->self_dpu_desc_index;
+		bd->dpu_ne = 1;
 	}

-	bd->dpu_ne = encrypt;
 	bd->tx_comp = tx_compl;

 	buff_to_be((u32 *)bd, sizeof(*bd)/sizeof(u32));
diff --git a/txrx.h b/txrx.h
index 648c210..31bfbbb 100644
--- a/txrx.h
+++ b/txrx.h
@@ -151,6 +151,6 @@ struct wcn36xx_tx_bd {
 int  wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb);
 void wcn36xx_prepare_tx_bd(struct wcn36xx_tx_bd *bd, u32 len, u32 header_len);
 void wcn36xx_fill_tx_bd(struct wcn36xx *wcn, struct wcn36xx_tx_bd *bd,
-			u8 broadcast, u8 encrypt, struct ieee80211_hdr *hdr,
+			u8 broadcast, struct ieee80211_hdr *hdr,
 			bool tx_compl);
 #endif	/* _TXRX_H_ */
diff --git a/wcn36xx.h b/wcn36xx.h
index 0d0ed0c..6d1a24a 100644
--- a/wcn36xx.h
+++ b/wcn36xx.h
@@ -75,11 +75,6 @@ enum wcn36xx_debug_mask {
 			       buf, len, false);		\
 } while (0)

-enum wcn36xx_encryption_state {
-	WCN36XX_STA_KEY,
-	WCN36XX_BSS_KEY
-};
-
 static inline void buff_to_be(u32 *buf, size_t len)
 {
 	int i;
@@ -121,7 +116,6 @@ struct wcn36xx {
 	u8			fw_version;
 	u8			fw_minor;
 	u8			fw_major;
-	enum wcn36xx_encryption_state	en_state;

 	/* extra byte for the NULL termination */
 	u8			crm_version[WCN36XX_HAL_VERSION_LENGTH + 1];
-- 
1.8.2.2



More information about the wcn36xx mailing list