Просмотр исходного кода

qcacld-3.0: Use mlo aid assign/release API for mlo sap

For mlo sap, aid is managed by mlo manager.
Use mlo aid assign/release API for mlo sap.

Change-Id: Ib61c67f6bf5e9235adbe550c24f9bce3f3b306bb
CRs-Fixed: 2976361
bings 4 лет назад
Родитель
Сommit
f503eccd42
3 измененных файлов с 282 добавлено и 53 удалено
  1. 205 37
      core/mac/src/pe/lim/lim_aid_mgmt.c
  2. 8 16
      core/mac/src/pe/lim/lim_session.c
  3. 69 0
      core/mac/src/pe/lim/lim_utils.h

+ 205 - 37
core/mac/src/pe/lim/lim_aid_mgmt.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2016, 2018-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2016, 2018-2021 The Linux Foundation. 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
@@ -36,24 +36,23 @@
 #include "lim_ft_defs.h"
 #include "lim_session.h"
 #include "lim_session_utils.h"
+#include <wlan_mlo_mgr_ap.h>
+#include <wlan_mlo_mgr_peer.h>
 
 #define LIM_START_PEER_IDX   1
 
 /**
- * lim_init_peer_idxpool() -- initializes peer index pool
- * @mac: mac context
- * @pe_session: session entry
+ * lim_init_peer_idxpool_legacy() - init aid pool for non MLO SAP
+ * @mac: Pointer to Global MAC structure
+ * @pe_session: pe session
  *
- * This function is called while starting a BSS at AP
- * to initialize AID pool.
- *
- * Return: None
+ * Return: Void
  */
-
-void lim_init_peer_idxpool(struct mac_context *mac, struct pe_session *pe_session)
+static void lim_init_peer_idxpool_legacy(struct mac_context *mac,
+					 struct pe_session *pe_session)
 {
 	uint8_t i;
-	uint8_t maxAssocSta = mac->lim.max_sta_of_pe_session;
+	uint8_t max_assoc_sta = mac->lim.max_sta_of_pe_session;
 
 	pe_session->gpLimPeerIdxpool[0] = 0;
 
@@ -72,13 +71,115 @@ void lim_init_peer_idxpool(struct mac_context *mac, struct pe_session *pe_sessio
 		pe_session->freePeerIdxHead = LIM_START_PEER_IDX;
 	}
 
-	for (i = pe_session->freePeerIdxHead; i < maxAssocSta; i++) {
+	for (i = pe_session->freePeerIdxHead; i < max_assoc_sta; i++)
 		pe_session->gpLimPeerIdxpool[i] = i + 1;
-	}
+
 	pe_session->gpLimPeerIdxpool[i] = 0;
 
 	pe_session->freePeerIdxTail = i;
+}
+
+void lim_init_peer_idxpool(struct mac_context *mac,
+			   struct pe_session *pe_session)
+{
+	if (!wlan_vdev_mlme_is_mlo_ap(pe_session->vdev))
+		lim_init_peer_idxpool_legacy(mac, pe_session);
+}
+
+/**
+ * lim_create_peer_idxpool_legacy() - AID pool creation for non-MLO AP
+ * @pe_session: pe session
+ * @idx_pool_size: aid pool size
+ *
+ * Return: true if pool is created successfully
+ */
+static bool lim_create_peer_idxpool_legacy(struct pe_session *pe_session,
+					   uint8_t idx_pool_size)
+{
+	pe_session->gpLimPeerIdxpool = qdf_mem_malloc(
+		sizeof(*pe_session->gpLimPeerIdxpool) * idx_pool_size);
+	if (!pe_session->gpLimPeerIdxpool)
+		return false;
+
+	pe_session->freePeerIdxHead = 0;
+	pe_session->freePeerIdxTail = 0;
+
+	return true;
+}
+
+bool lim_create_peer_idxpool(struct pe_session *pe_session,
+			     uint8_t idx_pool_size)
+{
+	pe_session->gLimNumOfCurrentSTAs = 0;
+	if (!wlan_vdev_mlme_is_mlo_ap(pe_session->vdev))
+		return lim_create_peer_idxpool_legacy(pe_session,
+						      idx_pool_size);
+
+	return true;
+}
+
+/**
+ * lim_free_peer_idxpool_legacy() - Free the non-MLO AP aid pool
+ * @pe_session: pe session
+ *
+ * Return: Void
+ */
+static void lim_free_peer_idxpool_legacy(struct pe_session *pe_session)
+{
+	if (pe_session->gpLimPeerIdxpool) {
+		qdf_mem_free(pe_session->gpLimPeerIdxpool);
+		pe_session->gpLimPeerIdxpool = NULL;
+	}
+}
+
+void lim_free_peer_idxpool(struct pe_session *pe_session)
+{
+	if (!wlan_vdev_mlme_is_mlo_ap(pe_session->vdev))
+		lim_free_peer_idxpool_legacy(pe_session);
+}
+
+/**
+ * lim_assign_peer_idx_mlo() - trigger mlo api to allocate an AID for a STA
+ * @pe_session: pe session
+ *
+ * Return: peer_idx - assigned AID for STA
+ */
+#ifdef WLAN_FEATURE_11BE_MLO
+static uint16_t lim_assign_peer_idx_mlo(struct pe_session *pe_session)
+{
+	return mlme_get_aid(pe_session->vdev);
+}
+#else
+static uint16_t lim_assign_peer_idx_mlo(struct pe_session *pe_session)
+{
+	return 0;               /* no more free peer index */
+}
+#endif
+
+/**
+ * lim_assign_peer_idx_legacy() - non-MLO AP allocates an AID for a STA
+ * @mac: Pointer to Global MAC structure
+ * @pe_session: pe session
+ *
+ * Return: peer_idx - assigned AID for STA
+ */
+static uint16_t lim_assign_peer_idx_legacy(struct mac_context *mac,
+					   struct pe_session *pe_session)
+{
+	uint16_t peer_id;
+
+	/* return head of free list */
+
+	if (pe_session->freePeerIdxHead) {
+		peer_id = pe_session->freePeerIdxHead;
+		pe_session->freePeerIdxHead =
+		    pe_session->gpLimPeerIdxpool[pe_session->freePeerIdxHead];
+		if (pe_session->freePeerIdxHead == 0)
+			pe_session->freePeerIdxTail = 0;
+		return peer_id;
+	}
 
+	return 0;               /* no more free peer index */
 }
 
 /**
@@ -101,9 +202,10 @@ void lim_init_peer_idxpool(struct mac_context *mac, struct pe_session *pe_sessio
  * @return peerIdx  - assigned peer Station IDx for STA
  */
 
-uint16_t lim_assign_peer_idx(struct mac_context *mac, struct pe_session *pe_session)
+uint16_t lim_assign_peer_idx(struct mac_context *mac,
+			     struct pe_session *pe_session)
 {
-	uint16_t peerId;
+	uint16_t peer_id;
 
 	/* make sure we haven't exceeded the configurable limit on associations */
 	/* This count is global to ensure that it doesn't exceed the hardware limits. */
@@ -113,20 +215,82 @@ uint16_t lim_assign_peer_idx(struct mac_context *mac, struct pe_session *pe_sess
 		return 0;
 	}
 
-	/* return head of free list */
+	if (wlan_vdev_mlme_is_mlo_ap(pe_session->vdev))
+		peer_id = lim_assign_peer_idx_mlo(pe_session);
+	else
+		peer_id = lim_assign_peer_idx_legacy(mac, pe_session);
 
-	if (pe_session->freePeerIdxHead) {
-		peerId = pe_session->freePeerIdxHead;
-		pe_session->freePeerIdxHead =
-			pe_session->gpLimPeerIdxpool[pe_session->
-							freePeerIdxHead];
-		if (pe_session->freePeerIdxHead == 0)
-			pe_session->freePeerIdxTail = 0;
+	if (peer_id)
 		pe_session->gLimNumOfCurrentSTAs++;
-		return peerId;
+
+	return peer_id;
+}
+
+#ifdef WLAN_FEATURE_11BE_MLO
+uint16_t lim_assign_mlo_conn_idx(struct mac_context *mac,
+				 struct pe_session *pe_session,
+				 uint16_t partner_peer_idx)
+{
+	uint16_t peer_id;
+
+	if (pe_get_current_stas_count(mac) >=
+	    mac->mlme_cfg->sap_cfg.assoc_sta_limit) {
+		/* too many associations already active */
+		return 0;
 	}
 
-	return 0;               /* no more free peer index */
+	if (partner_peer_idx)
+		peer_id = partner_peer_idx;
+	else
+		peer_id = mlo_get_aid(pe_session->vdev);
+
+	if (peer_id)
+		pe_session->gLimNumOfCurrentSTAs++;
+
+	return peer_id;
+}
+
+/**
+ * lim_release_peer_idx_mlo() - trigger mlo api to release aid
+ * @peer_idx: aid to free
+ * @pe_session: pe session
+ *
+ * Return: Void
+ */
+static void lim_release_peer_idx_mlo(uint16_t peer_idx,
+				     struct pe_session *pe_session)
+{
+	return mlme_free_aid(pe_session->vdev, peer_idx);
+}
+#else
+static void lim_release_peer_idx_mlo(uint16_t peer_idx,
+				     struct pe_session *pe_session)
+{
+}
+#endif
+
+/**
+ * lim_release_peer_idx_legacy() - non-MLO AP releases an AID
+ * @mac: Pointer to Global MAC structure
+ * @peer_idx: aid to free
+ * @pe_session: pe session
+ *
+ * Return: Void
+ */
+static void lim_release_peer_idx_legacy(struct mac_context *mac,
+					uint16_t peer_idx,
+					struct pe_session *pe_session)
+{
+	/* insert at tail of free list */
+	if (pe_session->freePeerIdxTail) {
+		pe_session->gpLimPeerIdxpool[pe_session->freePeerIdxTail] =
+			(uint8_t)peer_idx;
+		pe_session->freePeerIdxTail = (uint8_t)peer_idx;
+	} else {
+		pe_session->freePeerIdxTail =
+			pe_session->freePeerIdxHead = (uint8_t)peer_idx;
+	}
+	pe_session->gpLimPeerIdxpool[(uint8_t)peer_idx] = 0;
 }
 
 /**
@@ -151,20 +315,24 @@ uint16_t lim_assign_peer_idx(struct mac_context *mac, struct pe_session *pe_sess
  */
 
 void
-lim_release_peer_idx(struct mac_context *mac, uint16_t peerIdx,
+lim_release_peer_idx(struct mac_context *mac, uint16_t peer_idx,
 		     struct pe_session *pe_session)
 {
 	pe_session->gLimNumOfCurrentSTAs--;
 
-	/* insert at tail of free list */
-	if (pe_session->freePeerIdxTail) {
-		pe_session->gpLimPeerIdxpool[pe_session->
-						freePeerIdxTail] =
-			(uint8_t) peerIdx;
-		pe_session->freePeerIdxTail = (uint8_t) peerIdx;
-	} else {
-		pe_session->freePeerIdxTail =
-			pe_session->freePeerIdxHead = (uint8_t) peerIdx;
-	}
-	pe_session->gpLimPeerIdxpool[(uint8_t) peerIdx] = 0;
+	if (wlan_vdev_mlme_is_mlo_ap(pe_session->vdev))
+		lim_release_peer_idx_mlo(peer_idx, pe_session);
+	else
+		lim_release_peer_idx_legacy(mac, peer_idx, pe_session);
+}
+
+#ifdef WLAN_FEATURE_11BE_MLO
+void
+lim_release_mlo_conn_idx(struct mac_context *mac, uint16_t peer_idx,
+			 struct pe_session *session)
+{
+	session->gLimNumOfCurrentSTAs--;
+	if (wlan_mlo_get_mlpeer_by_aid(session->vdev->mlo_dev_ctx, peer_idx))
+		mlo_free_aid(session->vdev, peer_idx);
 }
+#endif

+ 8 - 16
core/mac/src/pe/lim/lim_session.c

@@ -567,15 +567,7 @@ struct pe_session *pe_create_session(struct mac_context *mac,
 					pe_get_session_dph_node_array(i);
 	session_ptr->dph.dphHashTable.size = numSta + 1;
 	dph_hash_table_init(mac, &session_ptr->dph.dphHashTable);
-	session_ptr->gpLimPeerIdxpool = qdf_mem_malloc(
-		sizeof(*(session_ptr->gpLimPeerIdxpool)) *
-		lim_get_peer_idxpool_size(numSta, bssType));
-	if (!session_ptr->gpLimPeerIdxpool)
-		goto free_dp_hash_table;
-
-	session_ptr->freePeerIdxHead = 0;
-	session_ptr->freePeerIdxTail = 0;
-	session_ptr->gLimNumOfCurrentSTAs = 0;
+
 	/* Copy the BSSID to the session table */
 	sir_copy_mac_addr(session_ptr->bssId, bssid);
 	if (bssType == eSIR_MONITOR_MODE)
@@ -645,6 +637,11 @@ struct pe_session *pe_create_session(struct mac_context *mac,
 		 *sessionId, session_ptr->opmode, vdev_id,
 		 QDF_MAC_ADDR_REF(bssid), numSta);
 
+	if (!lim_create_peer_idxpool(
+		session_ptr,
+		lim_get_peer_idxpool_size(numSta, bssType)))
+		goto free_session_attrs;
+
 	if (eSIR_INFRASTRUCTURE_MODE == bssType)
 		lim_ft_open(mac, &mac->lim.gpSession[i]);
 
@@ -689,17 +686,15 @@ struct pe_session *pe_create_session(struct mac_context *mac,
 	return &mac->lim.gpSession[i];
 
 free_session_attrs:
-	qdf_mem_free(session_ptr->gpLimPeerIdxpool);
+	lim_free_peer_idxpool(session_ptr);
 	qdf_mem_free(session_ptr->pSchProbeRspTemplate);
 	qdf_mem_free(session_ptr->pSchBeaconFrameBegin);
 	qdf_mem_free(session_ptr->pSchBeaconFrameEnd);
 
-	session_ptr->gpLimPeerIdxpool = NULL;
 	session_ptr->pSchProbeRspTemplate = NULL;
 	session_ptr->pSchBeaconFrameBegin = NULL;
 	session_ptr->pSchBeaconFrameEnd = NULL;
 
-free_dp_hash_table:
 	qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
 	qdf_mem_zero(session_ptr->dph.dphHashTable.pDphNodeArray,
 		     sizeof(struct sDphHashNode) * (SIR_SAP_MAX_NUM_PEERS + 1));
@@ -912,10 +907,7 @@ void pe_delete_session(struct mac_context *mac_ctx, struct pe_session *session)
 		session->dph.dphHashTable.pDphNodeArray = NULL;
 	}
 
-	if (session->gpLimPeerIdxpool) {
-		qdf_mem_free(session->gpLimPeerIdxpool);
-		session->gpLimPeerIdxpool = NULL;
-	}
+	lim_free_peer_idxpool(session);
 
 	if (session->beacon) {
 		qdf_mem_free(session->beacon);

+ 69 - 0
core/mac/src/pe/lim/lim_utils.h

@@ -191,9 +191,78 @@ void lim_calculate_tpc(struct mac_context *mac,
 		       bool ctry_code_match);
 
 /* AID pool management functions */
+
+/**
+ * lim_init_peer_idxpool() -- initializes peer index pool
+ * @mac: mac context
+ * @pe_session: session entry
+ *
+ * This function is called while starting a BSS at AP
+ * to initialize AID pool.
+ *
+ * Return: None
+ */
 void lim_init_peer_idxpool(struct mac_context *, struct pe_session *);
 uint16_t lim_assign_peer_idx(struct mac_context *, struct pe_session *);
 
+/**
+ * lim_create_peer_idxpool() - api to create aid pool
+ * @pe_session: pe session
+ * @idx_pool_size: aid pool size
+ *
+ * Return: true if pool is created successfully
+ */
+bool lim_create_peer_idxpool(struct pe_session *pe_session,
+			     uint8_t idx_pool_size);
+
+/**
+ * lim_free_peer_idxpool() - api to free aid pool
+ * @pe_session: pe session
+ *
+ * Return: Void
+ */
+void lim_free_peer_idxpool(struct pe_session *pe_session);
+
+#ifdef WLAN_FEATURE_11BE_MLO
+/**
+ * lim_assign_mlo_conn_idx() - api to assign mlo peer station index with given
+ *                             partner peer station index
+ * @mac: mac context
+ * @pe_session: session entry
+ * @partner_peer_idx: partner peer station index
+ *
+ * Return: peer station index
+ */
+uint16_t lim_assign_mlo_conn_idx(struct mac_context *mac,
+				 struct pe_session *pe_session,
+				 uint16_t partner_peer_idx);
+
+/**
+ * lim_release_mlo_conn_idx() - api to release mlo peer AID
+ * @mac: mac context
+ * @peer_idx: given aid
+ * @pe_session: session entry
+ *
+ * Return: Void
+ */
+void
+lim_release_mlo_conn_idx(struct mac_context *mac, uint16_t peer_idx,
+			 struct pe_session *pe_session);
+#else
+static inline uint16_t lim_assign_mlo_conn_idx(struct mac_context *mac,
+					       struct pe_session *pe_session,
+					       uint16_t partner_peer_idx)
+{
+	return 0;
+}
+
+static inline void
+lim_release_mlo_conn_idx(struct mac_context *mac, uint16_t peer_idx,
+			 struct pe_session *pe_session)
+{
+}
+#endif
+
 void lim_enable_overlap11g_protection(struct mac_context *mac,
 		tpUpdateBeaconParams pBeaconParams,
 		tpSirMacMgmtHdr pMh,