Browse Source

qcacld-3.0: Allocate proper size for the lim peer idx pool

In station role, peer idx pool's index 1 is reserved for BSS.
for TDLS the index should start from 2.

Thus for station role if number of supported peer is n, the peer
idx pool size should be n + 2

Thus set peer idx pool size to n + 2 if TDLS is enabled.

Change-Id: Ie1afb16bb4a7fb914142d27080dfa257bc9ffeac
CRs-Fixed: 2044524
Abhishek Singh 8 years ago
parent
commit
478886090e
1 changed files with 37 additions and 1 deletions
  1. 37 1
      core/mac/src/pe/lim/lim_session.c

+ 37 - 1
core/mac/src/pe/lim/lim_session.c

@@ -267,6 +267,40 @@ pe_init_pmf_comeback_timer(tpAniSirGlobal mac_ctx,
 }
 #endif
 
+/**
+ * lim_get_peer_idxpool_size: get number of peer idx pool size
+ * @num_sta: Max number of STA
+ * @bss_type: BSS type
+ *
+ * The peer index start from 1 and thus index 0 is not used, so
+ * add 1 to the max sta. For STA if TDLS is enabled add 2 as
+ * index 1 is reserved for peer BSS.
+ *
+ * Return: number of peer idx pool size
+ */
+#ifdef FEATURE_WLAN_TDLS
+static inline uint8_t
+lim_get_peer_idxpool_size(uint16_t num_sta, tSirBssType bss_type)
+{
+	/*
+	 * In station role, index 1 is reserved for peer
+	 * corresponding to AP. For TDLS the index should
+	 * start from 2
+	 */
+	if (bss_type == eSIR_INFRASTRUCTURE_MODE)
+		return num_sta + 2;
+	else
+		return num_sta + 1;
+
+}
+#else
+static inline uint8_t
+lim_get_peer_idxpool_size(uint16_t num_sta, tSirBssType bss_type)
+{
+	return num_sta + 1;
+}
+#endif
+
 /**
  * pe_create_session() creates a new PE session given the BSSID
  * @param pMac:        pointer to global adapter context
@@ -320,10 +354,12 @@ pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId,
 		return NULL;
 	}
 
+
 	session_ptr->dph.dphHashTable.size = numSta + 1;
 	dph_hash_table_class_init(pMac, &session_ptr->dph.dphHashTable);
 	session_ptr->gpLimPeerIdxpool = qdf_mem_malloc(
-		sizeof(*(session_ptr->gpLimPeerIdxpool)) * (numSta + 1));
+		sizeof(*(session_ptr->gpLimPeerIdxpool)) *
+		lim_get_peer_idxpool_size(numSta, bssType));
 	if (NULL == session_ptr->gpLimPeerIdxpool) {
 		pe_err("memory allocate failed!");
 		qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);