qcacmn: Add mbssid information to scan entry

Add MBSSID information to scan entry.

Change-Id: Icf1a61f37db4991c5ad8f8e5dc2d5f55252c98aa
CRs-Fixed: 2399996
diff --git a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h
index f22d9fd..7bc5276 100644
--- a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h
+++ b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h
@@ -268,6 +268,18 @@
 };
 
 /**
+ * struct scan_mbssid_info - Scan mbssid information
+ * @profile_num: profile number
+ * @profile_count: total profile count
+ * @trans_bssid: TX BSSID address
+ */
+struct scan_mbssid_info {
+	uint8_t profile_num;
+	uint8_t profile_count;
+	uint8_t trans_bssid[QDF_MAC_ADDR_SIZE];
+};
+
+/**
  * struct scan_cache_entry: structure containing scan entry
  * @frm_subtype: updated from beacon/probe
  * @bssid: bssid
@@ -291,6 +303,7 @@
  * @rssi_timestamp: boottime in microsec when RSSI was updated
  * @hidden_ssid_timestamp: boottime in microsec when hidden
  *                         ssid was received
+ * @mbssid_info: Multi bssid information
  * @channel: channel info on which AP is present
  * @channel_mismatch: if channel received in metadata
  *                    doesnot match the one in beacon
@@ -330,6 +343,7 @@
 	qdf_time_t scan_entry_time;
 	qdf_time_t rssi_timestamp;
 	qdf_time_t hidden_ssid_timestamp;
+	struct scan_mbssid_info mbssid_info;
 	struct channel_info channel;
 	bool channel_mismatch;
 	struct mlme_info mlme_info;
diff --git a/umac/scan/dispatcher/src/wlan_scan_utils_api.c b/umac/scan/dispatcher/src/wlan_scan_utils_api.c
index 2bf43b8..74f9cf2 100644
--- a/umac/scan/dispatcher/src/wlan_scan_utils_api.c
+++ b/umac/scan/dispatcher/src/wlan_scan_utils_api.c
@@ -982,6 +982,7 @@
 			 uint8_t *frame, qdf_size_t frame_len,
 			 uint32_t frm_subtype,
 			 struct mgmt_rx_event_params *rx_param,
+			 struct scan_mbssid_info *mbssid_info,
 			 qdf_list_t *scan_list)
 {
 	struct wlan_frame_hdr *hdr;
@@ -1105,7 +1106,8 @@
 		scan_entry->hidden_ssid_timestamp =
 			scan_entry->scan_entry_time;
 	}
-
+	qdf_mem_copy(&scan_entry->mbssid_info, mbssid_info,
+		     sizeof(scan_entry->mbssid_info));
 	if (WLAN_CHAN_IS_5GHZ(scan_entry->channel.chan_idx))
 		scan_entry->phy_mode = util_scan_get_phymode_5g(scan_entry);
 	else
@@ -1285,6 +1287,7 @@
 {
 	struct wlan_bcn_frame *bcn;
 	struct wlan_frame_hdr *hdr;
+	struct scan_mbssid_info mbssid_info;
 	QDF_STATUS status;
 	uint8_t *pos, *subelement, *mbssid_end_pos;
 	uint8_t *tmp, *mbssid_index_ie;
@@ -1317,6 +1320,7 @@
 		if (!tmp)
 			break;
 
+		mbssid_info.profile_count = 1 << tmp[2];
 		mbssid_end_pos = tmp + tmp[1] + 2;
 		/* Skip Element ID, Len, MaxBSSID Indicator */
 		if (tmp[1] < 4)
@@ -1349,7 +1353,9 @@
 				/* No valid Multiple BSSID-Index element */
 				continue;
 			}
-
+			qdf_mem_copy(&mbssid_info.trans_bssid, bssid,
+				     QDF_MAC_ADDR_SIZE);
+			mbssid_info.profile_num = mbssid_index_ie[2];
 			util_gen_new_bssid(bssid, tmp[2], mbssid_index_ie[2],
 					   new_bssid);
 			new_ie_len = util_gen_new_ie(ie, ielen, subelement + 2,
@@ -1383,7 +1389,9 @@
 			status = util_scan_gen_scan_entry(pdev, new_frame,
 							  new_frame_len,
 							  frm_subtype,
-							  rx_param, scan_list);
+							  rx_param,
+							  &mbssid_info,
+							  scan_list);
 			if (QDF_IS_STATUS_ERROR(status)) {
 				qdf_mem_free(new_frame);
 				scm_err("failed to generate a scan entry");
@@ -1419,17 +1427,30 @@
 			     qdf_list_t *scan_list)
 {
 	struct wlan_bcn_frame *bcn;
+	struct wlan_frame_hdr *hdr;
+	uint8_t *mbssid_ie = NULL;
 	uint32_t ie_len = 0;
 	QDF_STATUS status;
+	struct scan_mbssid_info mbssid_info = { 0 };
 
+	hdr = (struct wlan_frame_hdr *)frame;
 	bcn = (struct wlan_bcn_frame *)
 			   (frame + sizeof(struct wlan_frame_hdr));
 	ie_len = (uint16_t)(frame_len -
 		sizeof(struct wlan_frame_hdr) -
 		offsetof(struct wlan_bcn_frame, ie));
 
+	mbssid_ie = util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID,
+				      (uint8_t *)&bcn->ie, ie_len);
+	if (mbssid_ie) {
+		qdf_mem_copy(&mbssid_info.trans_bssid,
+			     hdr->i_addr3, QDF_MAC_ADDR_SIZE);
+		mbssid_info.profile_count = 1 << mbssid_ie[2];
+	}
+
 	status = util_scan_gen_scan_entry(pdev, frame, frame_len,
 					  frm_subtype, rx_param,
+					  &mbssid_info,
 					  scan_list);
 
 	/*
@@ -1437,8 +1458,7 @@
 	 * scan component will create a new entry for
 	 * each BSSID found in the MBSSID
 	 */
-	if (util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID,
-			      (uint8_t *)&bcn->ie, ie_len))
+	if (mbssid_ie)
 		status = util_scan_parse_mbssid(pdev, frame, frame_len,
 						frm_subtype, rx_param,
 						scan_list);