Prechádzať zdrojové kódy

qcacld-3.0: Statically allocate DPH hash table

DPH hash table is allocated for each session of depth equal to
max possible peers. This memory chunk goes upto 33KB in size and
may fail. Instead allocate the memory from BSS segment so that
run-time allocation is not needed.

Change-Id: I56d6adb7934faef1940ab8515fed30646f536ab2
CRs-fixed: 2149563
Naveen Rawat 7 rokov pred
rodič
commit
b0c5b6b6a0

+ 2 - 2
core/hdd/inc/wlan_hdd_cfg.h

@@ -7460,8 +7460,8 @@ enum hdd_link_speed_rpt_type {
 
 #define CFG_SAP_MAX_NO_PEERS                       "gSoftApMaxPeers"
 #define CFG_SAP_MAX_NO_PEERS_MIN                   (1)
-#define CFG_SAP_MAX_NO_PEERS_MAX                   (32)
-#define CFG_SAP_MAX_NO_PEERS_DEFAULT               (32)
+#define CFG_SAP_MAX_NO_PEERS_MAX                   (SIR_SAP_MAX_NUM_PEERS)
+#define CFG_SAP_MAX_NO_PEERS_DEFAULT               (SIR_SAP_MAX_NUM_PEERS)
 
 /*
  * <ini>

+ 5 - 0
core/mac/inc/sir_api.h

@@ -59,6 +59,8 @@ typedef struct sAniSirGlobal *tpAniSirGlobal;
 #include <dot11f.h>
 #include "wlan_policy_mgr_api.h"
 
+#define SIR_MAX_SUPPORTED_BSS 5
+
 #define OFFSET_OF(structType, fldName)   (&((structType *)0)->fldName)
 
 /* / Max supported channel list */
@@ -130,6 +132,9 @@ typedef uint8_t tSirVersionString[SIR_VERSION_STRING_LEN];
 /* Maximum peer station number query one time */
 #define MAX_PEER_STA 12
 
+/* Maximum number of peers for SAP */
+#define SIR_SAP_MAX_NUM_PEERS 32
+
 /**
  * enum sir_conn_update_reason: Reason for conc connection update
  * @SIR_UPDATE_REASON_SET_OPER_CHAN: Set probable operating channel

+ 15 - 14
core/mac/src/pe/lim/lim_session.c

@@ -47,6 +47,10 @@
 #include "sch_api.h"
 #include "lim_send_messages.h"
 
+
+static struct sDphHashNode
+	g_dph_node_array[SIR_MAX_SUPPORTED_BSS][SIR_SAP_MAX_NUM_PEERS + 1];
+
 /*--------------------------------------------------------------------------
 
    \brief pe_init_beacon_params() - Initialize the beaconParams structure
@@ -427,17 +431,7 @@ pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId,
 		return NULL;
 	}
 
-	session_ptr->dph.dphHashTable.pDphNodeArray =
-		qdf_mem_malloc(sizeof(tDphHashNode) * (numSta + 1));
-	if (NULL == session_ptr->dph.dphHashTable.pDphNodeArray) {
-		pe_err("memory allocate failed!");
-		qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
-		session_ptr->dph.dphHashTable.
-		pHashTable = NULL;
-		return NULL;
-	}
-
-
+	session_ptr->dph.dphHashTable.pDphNodeArray = g_dph_node_array[i];
 	session_ptr->dph.dphHashTable.size = numSta + 1;
 	dph_hash_table_class_init(pMac, &session_ptr->dph.dphHashTable);
 	session_ptr->gpLimPeerIdxpool = qdf_mem_malloc(
@@ -446,7 +440,9 @@ pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId,
 	if (NULL == session_ptr->gpLimPeerIdxpool) {
 		pe_err("memory allocate failed!");
 		qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
-		qdf_mem_free(session_ptr->dph.dphHashTable.pDphNodeArray);
+		qdf_mem_zero(session_ptr->dph.dphHashTable.pDphNodeArray,
+			sizeof(struct sDphHashNode) *
+			(SIR_SAP_MAX_NUM_PEERS + 1));
 		session_ptr->dph.dphHashTable.pHashTable = NULL;
 		session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
 		return NULL;
@@ -501,7 +497,10 @@ pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId,
 		    || (NULL == session_ptr->pSchBeaconFrameEnd)) {
 			pe_err("memory allocate failed!");
 			qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
-			qdf_mem_free(session_ptr->dph.dphHashTable.pDphNodeArray);
+			qdf_mem_zero(
+				session_ptr->dph.dphHashTable.pDphNodeArray,
+				sizeof(struct sDphHashNode) *
+				(SIR_SAP_MAX_NUM_PEERS + 1));
 			qdf_mem_free(session_ptr->gpLimPeerIdxpool);
 			qdf_mem_free(session_ptr->pSchProbeRspTemplate);
 			qdf_mem_free(session_ptr->pSchBeaconFrameBegin);
@@ -737,7 +736,9 @@ void pe_delete_session(tpAniSirGlobal mac_ctx, tpPESession session)
 	}
 
 	if (session->dph.dphHashTable.pDphNodeArray != NULL) {
-		qdf_mem_free(session->dph.dphHashTable.pDphNodeArray);
+		qdf_mem_zero(session->dph.dphHashTable.pDphNodeArray,
+			sizeof(struct sDphHashNode) *
+			(SIR_SAP_MAX_NUM_PEERS + 1));
 		session->dph.dphHashTable.pDphNodeArray = NULL;
 	}
 

+ 1 - 1
core/sme/inc/csr_internal.h

@@ -53,7 +53,7 @@
 /* session ID invalid */
 #define CSR_SESSION_ID_INVALID    0xFF
 /* No of sessions to be supported, and a session is for Infra, IBSS or BT-AMP */
-#define CSR_ROAM_SESSION_MAX      5
+#define CSR_ROAM_SESSION_MAX      SIR_MAX_SUPPORTED_BSS
 #define CSR_IS_SESSION_VALID(pMac, sessionId) \
 	(((sessionId) < CSR_ROAM_SESSION_MAX) && \
 	 ((pMac)->roam.roamSession[(sessionId)].sessionActive))

+ 1 - 1
core/wma/inc/wma.h

@@ -88,7 +88,7 @@
 #else
 #define WMA_MAX_SUPPORTED_STAS    12
 #endif
-#define WMA_MAX_SUPPORTED_BSS     5
+#define WMA_MAX_SUPPORTED_BSS     SIR_MAX_SUPPORTED_BSS
 
 #define WMA_MAX_MGMT_MPDU_LEN 2000