Browse Source

qcacmn: Store default keyix in wlan_crypto_setkey for each peer

Store default keyix in crypto_priv for each peer.

Change-Id: Ieb77c390fddd667f99fd97c5ecdd4f3de61ae045
Sai Pratyusha Magam 3 năm trước cách đây
mục cha
commit
5d58a41518

+ 15 - 0
umac/cmn_services/crypto/inc/wlan_crypto_global_api.h

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2021 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -99,6 +100,20 @@ uint8_t wlan_crypto_is_htallowed(struct wlan_objmgr_vdev *vdev,
 QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
 					struct wlan_crypto_req_key *req_key);
 
+/**
+ * store_def_keyix_peer - called by wlan_crypto_setkey
+ *                   to store default key index for each peer in the vdev.
+ * @vdev: vdev
+ * @object: Peer object
+ * @arg: Argument passed by caller
+ *
+ * This function gets called from wlan_crypto_setkey
+ *
+ * Return: None
+ */
+void store_def_keyix_peer(struct wlan_objmgr_vdev *vdev, void *object,
+			  void *arg);
+
 /**
  * wlan_crypto_getkey - called by ucfg to get key
  * @vdev: vdev

+ 39 - 1
umac/cmn_services/crypto/src/wlan_crypto_global_api.c

@@ -915,6 +915,7 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
 					return QDF_STATUS_E_NOMEM;
 			}
 			key = crypto_priv->key[req_key->keyix];
+			crypto_priv->def_tx_keyid = req_key->keyix;
 		}
 		if (vdev_mode == QDF_STA_MODE) {
 			peer = wlan_objmgr_vdev_try_get_bsspeer(vdev,
@@ -1112,12 +1113,19 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
 
 	if ((req_key->flags & WLAN_CRYPTO_KEY_DEFAULT) &&
 	    (req_key->keyix != WLAN_CRYPTO_KEYIX_NONE) &&
-	    (!IS_MGMT_CIPHER(req_key->type))) {
+	    (!IS_MGMT_CIPHER(req_key->type)) && isbcast) {
 		/* default xmit key */
 		wlan_crypto_default_key(vdev,
 					req_key->macaddr,
 					req_key->keyix,
 					!isbcast);
+		/*Iterate through the peer list on this vdev
+		 *and store the keyix in the peer's crypto_priv
+		 */
+		wlan_objmgr_iterate_peerobj_list(vdev, store_def_keyix_peer,
+						 (void *)&req_key->keyix,
+						 WLAN_CRYPTO_ID);
+
 		}
 err:
 	if (peer)
@@ -1125,6 +1133,36 @@ err:
 	return status;
 }
 
+/**
+ * store_def_keyix_peer - store default keyix
+ * @vdev: vdev
+ * @object: Peer object
+ * @arg: Argument passed by caller
+ *
+ * This function gets called from wlan_crypto_setkey
+ *
+ * Return: None
+ */
+void store_def_keyix_peer(struct wlan_objmgr_vdev *vdev, void *object,
+			  void *arg)
+{
+	struct wlan_objmgr_peer *peer = NULL;
+	struct wlan_crypto_comp_priv *crypto_priv;
+	struct wlan_crypto_params *crypto_params;
+
+	uint16_t kid = *(uint16_t *)arg;
+
+	peer = (struct wlan_objmgr_peer *)object;
+	crypto_params = wlan_crypto_peer_get_comp_params(peer, &crypto_priv);
+	if (!crypto_priv) {
+		crypto_err("crypto_priv NULL");
+		return;
+	}
+	crypto_priv->def_tx_keyid = kid;
+}
+
+qdf_export_symbol(store_def_keyix_peer);
+
 /**
  * wlan_crypto_get_keytype - get keytype
  * @key: key