[PATCH 1/6] Implement remove_key

Eugene Krasnikov k.eugene.e at gmail.com
Fri Jun 14 04:49:18 EDT 2013


Remove all keys when disassociating

Signed-off-by: Eugene Krasnikov <k.eugene.e at gmail.com>
---
 hal.h  | 18 ++++++++---------
 main.c | 69 ++++++++++++++++++++++++++++++++++++++++--------------------------
 smd.c  | 32 +++++++++++++++++++++++++++++++
 smd.h  |  7 +++++++
 4 files changed, 90 insertions(+), 36 deletions(-)

diff --git a/hal.h b/hal.h
index 087914d..269af25 100644
--- a/hal.h
+++ b/hal.h
@@ -1874,7 +1874,7 @@ struct wcn36xx_hal_set_sta_key_rsp_msg {
 	u32 status;
 } __packed;
 
-struct remove_bss_key_req_msg {
+struct wcn36xx_hal_remove_bss_key_req_msg {
 	struct wcn36xx_hal_msg_header header;
 
 	/* BSS Index of the BSS */
@@ -1884,24 +1884,24 @@ struct remove_bss_key_req_msg {
 	enum ani_ed_type enc_type;
 
 	/* Key Id */
-	u8 id;
+	u8 key_id;
 
 	/* STATIC/DYNAMIC. Used in Nullifying in Key Descriptors for
 	 * Static/Dynamic keys */
 	enum ani_wep_type wep_type;
-};
+} __packed;
 
-struct remove_bss_key_rsp_msg {
+struct wcn36xx_hal_remove_bss_key_rsp_msg {
 	struct wcn36xx_hal_msg_header header;
 
 	/* success or failure */
 	u32 status;
-};
+} __packed;
 
 /*
  * This is used by PE to Remove the key information on a given station.
  */
-struct remove_sta_key_req_msg {
+struct wcn36xx_hal_remove_sta_key_req_msg {
 	struct wcn36xx_hal_msg_header header;
 
 	/* STA Index */
@@ -1917,15 +1917,15 @@ struct remove_sta_key_req_msg {
 	 * of WEP, the same key is used for both broadcast and unicast. */
 	u8 unicast;
 
-};
+} __packed;
 
-struct remove_sta_key_rsp_msg {
+struct wcn36xx_hal_remove_sta_key_rsp_msg {
 	struct wcn36xx_hal_msg_header header;
 
 	/*success or failure */
 	u32 status;
 
-};
+} __packed;
 
 #ifdef FEATURE_OEM_DATA_SUPPORT
 
diff --git a/main.c b/main.c
index b685371..7f73abf 100644
--- a/main.c
+++ b/main.c
@@ -217,21 +217,50 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 			 key_conf->key,
 			 key_conf->keylen);
 
+	switch (key_conf->cipher) {
+	case WLAN_CIPHER_SUITE_CCMP:
+		enc_type = WCN36XX_HAL_ED_CCMP;
+		break;
+	case WLAN_CIPHER_SUITE_TKIP:
+		enc_type = WCN36XX_HAL_ED_TKIP;
+		break;
+	default:
+		wcn36xx_error("Unsupported key type 0x%x",
+			      key_conf->cipher);
+		ret = -EOPNOTSUPP;
+		goto out;
+		break;
+	}
+
 	switch (cmd) {
 	case SET_KEY:
-		switch (key_conf->cipher) {
-		case WLAN_CIPHER_SUITE_CCMP:
-			enc_type = WCN36XX_HAL_ED_CCMP;
-			break;
-		case WLAN_CIPHER_SUITE_TKIP:
-			enc_type = WCN36XX_HAL_ED_TKIP;
-			break;
-		default:
-			wcn36xx_error("Unsupported key type 0x%x",
-				      key_conf->cipher);
-			ret = -EOPNOTSUPP;
-			goto out;
-			break;
+		if (WCN36XX_STA_KEY == wcn->en_state) {
+			wcn36xx_smd_set_stakey(wcn,
+				enc_type,
+				key_conf->keyidx,
+				key_conf->keylen,
+				key_conf->key);
+			wcn->en_state = WCN36XX_BSS_KEY;
+		} else {
+			wcn36xx_smd_set_bsskey(wcn,
+				enc_type,
+				key_conf->keyidx,
+				key_conf->keylen,
+				key_conf->key);
+		}
+		break;
+	case DISABLE_KEY:
+		if (WCN36XX_BSS_KEY == wcn->en_state) {
+			wcn36xx_smd_remove_bsskey(wcn,
+				enc_type,
+				key_conf->keyidx);
+			wcn->en_state = WCN36XX_STA_KEY;
+		} else {
+			/* do not remove key if disassociated */
+			if (wcn->aid)
+				wcn36xx_smd_remove_stakey(wcn,
+							  enc_type,
+							  key_conf->keyidx);
 		}
 		break;
 	default:
@@ -241,20 +270,6 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 		break;
 	}
 
-	if (WCN36XX_STA_KEY == wcn->en_state) {
-		wcn36xx_smd_set_stakey(wcn,
-			enc_type,
-			key_conf->keyidx,
-			key_conf->keylen,
-			key_conf->key);
-		wcn->en_state = WCN36XX_BSS_KEY;
-	} else {
-		wcn36xx_smd_set_bsskey(wcn,
-			enc_type,
-			key_conf->keyidx,
-			key_conf->keylen,
-			key_conf->key);
-	}
 out:
 	return ret;
 }
diff --git a/smd.c b/smd.c
index c83481e..dea7959 100644
--- a/smd.c
+++ b/smd.c
@@ -989,6 +989,36 @@ int wcn36xx_smd_set_bsskey(struct wcn36xx *wcn,
 	return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
 }
 
+int wcn36xx_smd_remove_stakey(struct wcn36xx *wcn,
+			      enum ani_ed_type enc_type,
+			      u8 keyidx)
+{
+	struct wcn36xx_hal_remove_sta_key_req_msg msg_body;
+
+	INIT_HAL_MSG(msg_body, WCN36XX_HAL_RMV_STAKEY_REQ);
+	msg_body.sta_idx = wcn->current_vif->sta_index;
+	msg_body.enc_type = enc_type;
+	msg_body.key_id = keyidx;
+
+	PREPARE_HAL_BUF(wcn->smd_buf, msg_body);
+
+	return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
+}
+int wcn36xx_smd_remove_bsskey(struct wcn36xx *wcn,
+			      enum ani_ed_type enc_type,
+			      u8 keyidx)
+{
+	struct wcn36xx_hal_remove_bss_key_req_msg msg_body;
+
+	INIT_HAL_MSG(msg_body, WCN36XX_HAL_RMV_BSSKEY_REQ);
+	msg_body.bss_idx = 0;
+	msg_body.enc_type = enc_type;
+	msg_body.key_id = keyidx;
+
+	PREPARE_HAL_BUF(wcn->smd_buf, msg_body);
+
+	return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
+}
 static void wcn36xx_smd_notify(void *data, unsigned event)
 {
 	struct wcn36xx *wcn = (struct wcn36xx *)data;
@@ -1058,6 +1088,8 @@ static void wcn36xx_smd_rsp_process(struct wcn36xx *wcn, void *buf, size_t len)
 	case WCN36XX_HAL_UPDATE_PROBE_RSP_TEMPLATE_RSP:
 	case WCN36XX_HAL_SET_BSSKEY_RSP:
 	case WCN36XX_HAL_SET_STAKEY_RSP:
+	case WCN36XX_HAL_RMV_STAKEY_RSP:
+	case WCN36XX_HAL_RMV_BSSKEY_RSP:
 		if (wcn36xx_smd_rsp_status_check(buf, len)) {
 			wcn36xx_warn("error response from hal request %d",
 				     msg_header->msg_type);
diff --git a/smd.h b/smd.h
index 97c8edc..052104a 100644
--- a/smd.h
+++ b/smd.h
@@ -83,6 +83,13 @@ int wcn36xx_smd_set_bsskey(struct wcn36xx *wcn,
 			   u8 keyidx,
 			   u8 keylen,
 			   u8 *key);
+int wcn36xx_smd_remove_stakey(struct wcn36xx *wcn,
+			      enum ani_ed_type enc_type,
+			      u8 keyidx);
+int wcn36xx_smd_remove_bsskey(struct wcn36xx *wcn,
+			      enum ani_ed_type enc_type,
+			      u8 keyidx);
+
 /* WCN36XX configuration parameters */
 struct wcn36xx_fw_cfg {
 	u16		id;
-- 
1.7.11.3




More information about the wcn36xx mailing list