Переглянути джерело

qcacld-3.0: Optimize SAP beacon handling for protection

Currently SAP beacon callback loops through PE sessions to check
if the beacon's channel matches any active SAP channel and then
invokes sch_beacon_process_for_ap API. In sch_beacon_process_for_ap
we again loop through all the PE sessions to identify the session
where the SAP is active.

Optimize this by looping only once through all PE sessions in
lim_handle_sap_beacon and invoke sch_beacon_process_for_ap with
the SAP session's session_id.

Change-Id: Ia74e17845de161508b6c8efff6aca82cf4d9c961
CRs-Fixed: 2226237
Vignesh Viswanathan 7 роки тому
батько
коміт
5ce817eb54

+ 1 - 0
core/mac/src/pe/include/sch_api.h

@@ -109,6 +109,7 @@ int sch_gen_timing_advert_frame(tpAniSirGlobal pMac, tSirMacAddr self_addr,
  * Return: None
  */
 void sch_beacon_process_for_ap(tpAniSirGlobal mac_ctx,
+					uint8_t session_id,
 					uint8_t *rx_pkt_info,
 					tSchBeaconStruct *bcn);
 

+ 78 - 43
core/mac/src/pe/lim/lim_process_message_queue.c

@@ -766,16 +766,81 @@ static void lim_fill_sap_bcn_pkt_meta(struct scan_cache_entry *scan_entry,
 	rx_pkt->pkt_buf = NULL;
 }
 
+/*
+ * lim_allocate_and_get_bcn() - Allocate and get the bcn frame pkt and structure
+ * @mac_ctx: pointer to global mac_ctx
+ * @pkt: pointer to the pkt to be allocated
+ * @rx_pkt_info: pointer to the allocated pkt meta
+ * @bcn: pointer to the beacon struct
+ * @scan_entry: pointer to the scan cache entry from scan module
+ *
+ * Allocates a cds_pkt for beacon frame in scan cache entry,
+ * fills the essential pkt_meta elements and converts the
+ * pkt to beacon strcut.
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS lim_allocate_and_get_bcn(tpAniSirGlobal mac_ctx,
+				cds_pkt_t *pkt,
+				uint8_t *rx_pkt_info,
+				tSchBeaconStruct *bcn,
+				struct scan_cache_entry *scan_entry)
+{
+	QDF_STATUS status;
+
+	pkt = qdf_mem_malloc(sizeof(*pkt));
+	if (!pkt) {
+		pe_err("Failed to allocate pkt");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	status = wma_ds_peek_rx_packet_info(pkt, (void *)&rx_pkt_info, false);
+	if (!QDF_IS_STATUS_SUCCESS(status)) {
+		pe_err("Failed to get Rx Pkt meta");
+		goto free;
+	}
+
+	bcn = qdf_mem_malloc(sizeof(tSchBeaconStruct));
+	if (!bcn) {
+		pe_err("Failed to allocate bcn struct");
+		goto free;
+	}
+
+	lim_fill_sap_bcn_pkt_meta(scan_entry, pkt);
+
+	/* Convert the beacon frame into a structure */
+	if (sir_convert_beacon_frame2_struct(mac_ctx,
+	    (uint8_t *) rx_pkt_info,
+	    bcn) != eSIR_SUCCESS) {
+		pe_err_rl("beacon parsing failed");
+		goto free;
+	}
+
+	return QDF_STATUS_SUCCESS;
+
+free:
+	if (pkt) {
+		qdf_mem_free(pkt);
+		pkt = NULL;
+	}
+
+	if (bcn) {
+		qdf_mem_free(bcn);
+		bcn = NULL;
+	}
+
+	return QDF_STATUS_E_FAILURE;
+}
+
 void lim_handle_sap_beacon(struct wlan_objmgr_pdev *pdev,
 				struct scan_cache_entry *scan_entry)
 {
 	tpAniSirGlobal mac_ctx;
 	cds_pkt_t *pkt = NULL;
-	struct mgmt_beacon_probe_filter *filter;
 	tSchBeaconStruct *bcn = NULL;
-	bool allow_frame = false;
-	QDF_STATUS qdf_status;
-	uint8_t *rx_pkt_info;
+	struct mgmt_beacon_probe_filter *filter;
+	QDF_STATUS status;
+	uint8_t *rx_pkt_info = NULL;
 	int session_id;
 
 	if (!scan_entry) {
@@ -797,51 +862,21 @@ void lim_handle_sap_beacon(struct wlan_objmgr_pdev *pdev,
 	if (!filter->num_sap_sessions) {
 		return;
 	}
-
-	for (session_id = 0; session_id < SIR_MAX_SUPPORTED_BSS; session_id++) {
+	for (session_id = 0; session_id < mac_ctx->lim.maxBssId; session_id++) {
 		if (filter->sap_channel[session_id] &&
 		    (filter->sap_channel[session_id] ==
 		    scan_entry->channel.chan_idx)) {
-			allow_frame = true;
-			break;
+			if (!pkt) {
+				status = lim_allocate_and_get_bcn(mac_ctx, pkt,
+						rx_pkt_info, bcn, scan_entry);
+				if (!QDF_IS_STATUS_SUCCESS(status))
+					return;
+			}
+			sch_beacon_process_for_ap(mac_ctx, session_id,
+						  rx_pkt_info, bcn);
 		}
 	}
 
-	if (!allow_frame)
-		return;
-
-	pkt = qdf_mem_malloc(sizeof(*pkt));
-	if (!pkt) {
-		pe_err("Failed to allocate rx packet");
-		goto free;
-	}
-
-	lim_fill_sap_bcn_pkt_meta(scan_entry, pkt);
-
-	qdf_status =
-		wma_ds_peek_rx_packet_info(pkt, (void *)&rx_pkt_info, false);
-
-	if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-		pe_err("Failed to peek rx pkt info");
-		goto free;
-	}
-
-	bcn = qdf_mem_malloc(sizeof(tSchBeaconStruct));
-	if (!bcn) {
-		pe_err("Failed to allocate bcn struct");
-		goto free;
-	}
-
-	/* Convert the beacon frame into a structure */
-	if (sir_convert_beacon_frame2_struct(mac_ctx, (uint8_t *) rx_pkt_info,
-		bcn) != eSIR_SUCCESS) {
-		pe_err_rl("beacon parsing failed");
-		goto free;
-	}
-
-	sch_beacon_process_for_ap(mac_ctx, rx_pkt_info, bcn);
-
-free:
 	/*
 	 * Free only the pkt memory we allocated and not the pkt->pkt_buf.
 	 * The actual SKB buffer is freed in the scan module from where

+ 31 - 36
core/mac/src/pe/sch/sch_beacon_process.c

@@ -1006,55 +1006,50 @@ static void  sch_check_bss_color_ie(tpAniSirGlobal mac_ctx,
 #endif
 
 void sch_beacon_process_for_ap(tpAniSirGlobal mac_ctx,
+				uint8_t session_id,
 				uint8_t *rx_pkt_info,
 				tSchBeaconStruct *bcn)
 {
-	uint8_t i;
-	tpPESession ap_session = NULL;
+	tpPESession ap_session;
 	tUpdateBeaconParams bcn_prm;
 
 	if (!bcn || !rx_pkt_info) {
-		pe_err_rl("bcn %pK or rx_pkt_info %pK NULL",
+		pe_err_rl("bcn %pK or rx_pkt_info %pKis NULL",
 			  bcn, rx_pkt_info);
 		return;
 	}
 
+	ap_session = pe_find_session_by_session_id(mac_ctx, session_id);
+	if (!ap_session)
+		return;
+
+	if (!LIM_IS_AP_ROLE(ap_session))
+		return;
+
 	qdf_mem_zero(&bcn_prm, sizeof(tUpdateBeaconParams));
 	bcn_prm.paramChangeBitmap = 0;
 
-	if (bcn->ssidPresent)
-		bcn->ssId.ssId[bcn->ssId.length] = 0;
-
-	for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
-		ap_session = pe_find_session_by_session_id(mac_ctx, i);
-		if (!ap_session)
-			continue;
-
-		if (!LIM_IS_AP_ROLE(ap_session))
-			continue;
-
-		bcn_prm.bssIdx = ap_session->bssIdx;
-
-		if (!ap_session->is_session_obss_color_collision_det_enabled)
-			sch_check_bss_color_ie(mac_ctx, ap_session,
-						bcn, &bcn_prm);
-
-		if ((ap_session->gLimProtectionControl !=
-		     WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE) &&
-		    !ap_session->is_session_obss_offload_enabled)
-			ap_beacon_process(mac_ctx, rx_pkt_info,
-						bcn, &bcn_prm, ap_session);
-
-		if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
-		    && bcn_prm.paramChangeBitmap) {
-			/* Update the bcn and apply the new settings to HAL */
-			sch_set_fixed_beacon_fields(mac_ctx, ap_session);
-			pe_debug("Beacon for PE session[%d] got changed",
-			       ap_session->peSessionId);
-			pe_debug("sending beacon param change bitmap: 0x%x",
-			       bcn_prm.paramChangeBitmap);
-			lim_send_beacon_params(mac_ctx, &bcn_prm, ap_session);
-		}
+	bcn_prm.bssIdx = ap_session->bssIdx;
+
+	if (!ap_session->is_session_obss_color_collision_det_enabled)
+		sch_check_bss_color_ie(mac_ctx, ap_session,
+					bcn, &bcn_prm);
+
+	if ((ap_session->gLimProtectionControl !=
+	     WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE) &&
+	    !ap_session->is_session_obss_offload_enabled)
+		ap_beacon_process(mac_ctx, rx_pkt_info,
+					bcn, &bcn_prm, ap_session);
+
+	if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
+	    && bcn_prm.paramChangeBitmap) {
+		/* Update the bcn and apply the new settings to HAL */
+		sch_set_fixed_beacon_fields(mac_ctx, ap_session);
+		pe_debug("Beacon for PE session[%d] got changed",
+		       ap_session->peSessionId);
+		pe_debug("sending beacon param change bitmap: 0x%x",
+		       bcn_prm.paramChangeBitmap);
+		lim_send_beacon_params(mac_ctx, &bcn_prm, ap_session);
 	}
 }