Browse Source

qcacld-3.0: Fill peer's unicast cipher from vdev during roaming

During roaming update the peer unicast cipher from vdev crypto params.

Change-Id: Ie5f8cb951c405b50c607d416f4c6e37446048257
CRs-Fixed: 2889865
gaurank kathpalia 4 years ago
parent
commit
a7a5ac82fc
4 changed files with 23 additions and 113 deletions
  1. 5 1
      core/hdd/src/wlan_hdd_cfg80211.c
  2. 4 3
      core/wma/inc/wma.h
  3. 7 33
      core/wma/src/wma_features.c
  4. 7 76
      core/wma/src/wma_scan_roam.c

+ 5 - 1
core/hdd/src/wlan_hdd_cfg80211.c

@@ -17726,6 +17726,7 @@ static int __wlan_hdd_cfg80211_add_key(struct wiphy *wiphy,
 	bool ft_mode = false;
 	enum wlan_crypto_cipher_type cipher;
 	int errno;
+	int32_t cipher_cap, ucast_cipher = 0;
 	struct qdf_mac_addr mac_address;
 
 	hdd_enter();
@@ -17777,12 +17778,15 @@ static int __wlan_hdd_cfg80211_add_key(struct wiphy *wiphy,
 					WLAN_CRYPTO_KEY_TYPE_UNICAST :
 					WLAN_CRYPTO_KEY_TYPE_GROUP),
 					mac_address.bytes, params);
+	cipher_cap = wlan_crypto_get_param(vdev, WLAN_CRYPTO_PARAM_CIPHER_CAP);
 	hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_ID);
 	if (errno)
 		return errno;
 	cipher = osif_nl_to_crypto_cipher_type(params->cipher);
+	QDF_SET_PARAM(ucast_cipher, cipher);
 	if (pairwise)
-		wma_set_peer_ucast_cipher(mac_address.bytes, cipher);
+		wma_set_peer_ucast_cipher(mac_address.bytes,
+					  ucast_cipher, cipher_cap);
 
 	switch (adapter->device_mode) {
 	case QDF_SAP_MODE:

+ 4 - 3
core/wma/inc/wma.h

@@ -2333,12 +2333,13 @@ struct wlan_objmgr_psoc *wma_get_psoc_from_scn_handle(void *scn_handle);
 /**
  * wma_set_peer_ucast_cipher() - Update unicast cipher fof the peer
  * @mac_addr: peer mac address
- * @cipher: peer cipher type
+ * @cipher: peer cipher bits
+ * @cipher_cap: cipher cap
  *
  * Return: None
  */
-void wma_set_peer_ucast_cipher(uint8_t *mac_addr,
-			       enum wlan_crypto_cipher_type cipher);
+void wma_set_peer_ucast_cipher(uint8_t *mac_addr, int32_t cipher,
+			       int32_t cipher_cap);
 
 /**
  * wma_update_set_key() - Update WMA layer for set key

+ 7 - 33
core/wma/src/wma_features.c

@@ -5090,36 +5090,14 @@ static void wma_send_set_key_rsp(uint8_t vdev_id, bool pairwise,
 	}
 }
 
-static uint32_t wma_cipher_to_cap(enum wlan_crypto_cipher_type cipher)
-{
-	switch (cipher) {
-	case WLAN_CRYPTO_CIPHER_WEP:  return WLAN_CRYPTO_CAP_WEP;
-	case WLAN_CRYPTO_CIPHER_WEP_40:  return WLAN_CRYPTO_CAP_WEP;
-	case WLAN_CRYPTO_CIPHER_WEP_104:  return WLAN_CRYPTO_CAP_WEP;
-	case WLAN_CRYPTO_CIPHER_AES_OCB:  return WLAN_CRYPTO_CAP_AES;
-	case WLAN_CRYPTO_CIPHER_AES_CCM:  return WLAN_CRYPTO_CAP_AES;
-	case WLAN_CRYPTO_CIPHER_AES_CCM_256:  return WLAN_CRYPTO_CAP_AES;
-	case WLAN_CRYPTO_CIPHER_AES_GCM:  return WLAN_CRYPTO_CAP_AES;
-	case WLAN_CRYPTO_CIPHER_AES_GCM_256:  return WLAN_CRYPTO_CAP_AES;
-	case WLAN_CRYPTO_CIPHER_CKIP: return WLAN_CRYPTO_CAP_CKIP;
-	case WLAN_CRYPTO_CIPHER_TKIP: return WLAN_CRYPTO_CAP_TKIP_MIC;
-	case WLAN_CRYPTO_CIPHER_WAPI_SMS4: return WLAN_CRYPTO_CAP_WAPI_SMS4;
-	case WLAN_CRYPTO_CIPHER_WAPI_GCM4: return WLAN_CRYPTO_CAP_WAPI_GCM4;
-	case WLAN_CRYPTO_CIPHER_FILS_AEAD: return WLAN_CRYPTO_CAP_FILS_AEAD;
-	default: return 0;
-	}
-}
-
-void wma_set_peer_ucast_cipher(uint8_t *mac_addr,
-			       enum wlan_crypto_cipher_type cipher)
-{
-	int32_t set_val = 0, cipher_cap;
+void wma_set_peer_ucast_cipher(uint8_t *mac_addr, int32_t uc_cipher,
+			       int32_t cipher_cap)
+{
 	struct wlan_objmgr_peer *peer;
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 
 	if (!wma)
 		return;
-
 	peer = wlan_objmgr_get_peer(wma->psoc,
 				    wlan_objmgr_pdev_get_pdev_id(wma->pdev),
 				    mac_addr, WLAN_LEGACY_WMA_ID);
@@ -5128,19 +5106,15 @@ void wma_set_peer_ucast_cipher(uint8_t *mac_addr,
 			QDF_MAC_ADDR_REF(mac_addr));
 		return;
 	}
-	cipher_cap = wma_cipher_to_cap(cipher);
-	MLME_SET_BIT(set_val, cipher_cap);
+
 	wlan_crypto_set_peer_param(peer, WLAN_CRYPTO_PARAM_CIPHER_CAP,
-				   set_val);
-	set_val = 0;
-	MLME_SET_BIT(set_val, cipher);
+				   cipher_cap);
 	wlan_crypto_set_peer_param(peer, WLAN_CRYPTO_PARAM_UCAST_CIPHER,
-				   set_val);
+				   uc_cipher);
 	wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_WMA_ID);
 
 	wma_debug("Set unicast cipher %x and cap %x for "QDF_MAC_ADDR_FMT,
-		  1 << cipher, 1 << cipher_cap,
-		  QDF_MAC_ADDR_REF(mac_addr));
+		  uc_cipher, cipher_cap, QDF_MAC_ADDR_REF(mac_addr));
 }
 
 void wma_update_set_key(uint8_t session_id, bool pairwise,

+ 7 - 76
core/wma/src/wma_scan_roam.c

@@ -879,72 +879,6 @@ static int wma_fill_roam_synch_buffer(tp_wma_handle wma,
 	return 0;
 }
 
-static void wma_update_roamed_peer_unicast_cipher(tp_wma_handle wma,
-						  uint32_t uc_cipher,
-						  uint32_t cipher_cap,
-						  uint8_t *peer_mac)
-{
-	struct wlan_objmgr_peer *peer;
-
-	if (!peer_mac) {
-		wma_err("wma ctx or peer mac is NULL");
-		return;
-	}
-
-	peer = wlan_objmgr_get_peer(wma->psoc,
-				    wlan_objmgr_pdev_get_pdev_id(wma->pdev),
-				    peer_mac, WLAN_LEGACY_WMA_ID);
-	if (!peer) {
-		wma_err("Peer of peer_mac "QDF_MAC_ADDR_FMT" not found",
-			QDF_MAC_ADDR_REF(peer_mac));
-		return;
-	}
-	wlan_crypto_set_peer_param(peer, WLAN_CRYPTO_PARAM_CIPHER_CAP,
-				   cipher_cap);
-	wlan_crypto_set_peer_param(peer, WLAN_CRYPTO_PARAM_UCAST_CIPHER,
-				   uc_cipher);
-
-	wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_WMA_ID);
-
-	wma_debug("Set unicast cipher %x and cap %x for "QDF_MAC_ADDR_FMT,
-		  uc_cipher, cipher_cap, QDF_MAC_ADDR_REF(peer_mac));
-}
-
-static void wma_get_peer_uc_cipher(tp_wma_handle wma, uint8_t *peer_mac,
-				   uint32_t *uc_cipher, uint32_t *cipher_cap)
-{
-	int32_t cipher, cap;
-	struct wlan_objmgr_peer *peer;
-
-	if (!peer_mac) {
-		wma_err("wma ctx or peer_mac is NULL");
-		return;
-	}
-	peer = wlan_objmgr_get_peer(wma->psoc,
-				    wlan_objmgr_pdev_get_pdev_id(wma->pdev),
-				    peer_mac, WLAN_LEGACY_WMA_ID);
-	if (!peer) {
-		wma_err("Peer of peer_mac "QDF_MAC_ADDR_FMT" not found",
-			 QDF_MAC_ADDR_REF(peer_mac));
-		return;
-	}
-
-	cipher = wlan_crypto_get_peer_param(peer,
-					    WLAN_CRYPTO_PARAM_UCAST_CIPHER);
-	cap = wlan_crypto_get_peer_param(peer, WLAN_CRYPTO_PARAM_CIPHER_CAP);
-	wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_WMA_ID);
-
-	if (cipher < 0 || cap < 0) {
-		wma_err("Invalid mgmt cipher");
-		return;
-	}
-
-	if (uc_cipher)
-		*uc_cipher = cipher;
-	if (cipher_cap)
-		*cipher_cap = cap;
-}
-
 /**
  * wma_roam_update_vdev() - Update the STA and BSS
  * @wma: Global WMA Handle
@@ -962,8 +896,8 @@ wma_roam_update_vdev(tp_wma_handle wma,
 {
 	tDeleteStaParams *del_sta_params;
 	tAddStaParams *add_sta_params;
-	uint32_t uc_cipher = 0, cipher_cap = 0;
 	uint8_t vdev_id, *bssid;
+	int32_t uc_cipher, cipher_cap;
 
 	vdev_id = roam_synch_ind_ptr->roamed_vdev_id;
 	wma->interfaces[vdev_id].nss = roam_synch_ind_ptr->nss;
@@ -995,21 +929,18 @@ wma_roam_update_vdev(tp_wma_handle wma,
 		return;
 	}
 
-	/*
-	 * Get uc cipher of old peer to update new peer as it doesnt
-	 * change in roaming
-	 */
-	wma_get_peer_uc_cipher(wma, bssid,
-			       &uc_cipher, &cipher_cap);
-
 	wma_delete_sta(wma, del_sta_params);
 	wma_delete_bss(wma, vdev_id);
 	wma_create_peer(wma, roam_synch_ind_ptr->bssid.bytes,
 			WMI_PEER_TYPE_DEFAULT, vdev_id);
 
 	/* Update new peer's uc cipher */
-	wma_update_roamed_peer_unicast_cipher(wma, uc_cipher, cipher_cap,
-					      roam_synch_ind_ptr->bssid.bytes);
+	uc_cipher = wlan_crypto_get_param(wma->interfaces[vdev_id].vdev,
+					   WLAN_CRYPTO_PARAM_UCAST_CIPHER);
+	cipher_cap = wlan_crypto_get_param(wma->interfaces[vdev_id].vdev,
+					   WLAN_CRYPTO_PARAM_CIPHER_CAP);
+	wma_set_peer_ucast_cipher(roam_synch_ind_ptr->bssid.bytes, uc_cipher,
+				  cipher_cap);
 	wma_add_bss_lfr3(wma, roam_synch_ind_ptr->add_bss_params);
 	wma_add_sta(wma, add_sta_params);
 	qdf_mem_copy(bssid, roam_synch_ind_ptr->bssid.bytes,