qcacld-3.0: Add new vendor command to get link properties

qcacld-2.0 to qcacld-3.0 propagation

Add support in driver for a new vendor command to get
the link properties nss, rate flags and operating
frequency.

Change-Id: Ie3b8d5b2c3886055d303441c5d8b2f2a0a2719bd
CRs-Fixed: 834199
diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h
index 4af7214..bae0b4c 100644
--- a/core/mac/inc/sir_api.h
+++ b/core/mac/inc/sir_api.h
@@ -1034,6 +1034,9 @@
 	bool tdls_prohibited;
 	bool tdls_chan_swit_prohibited;
 #endif
+	uint8_t nss;
+	uint32_t max_rate_flags;
+
 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
 	tSirSmeHTProfile HTProfile;
 #endif
@@ -1057,7 +1060,10 @@
 	uint32_t info;
 	uint32_t reg_info_1;
 	uint32_t reg_info_2;
+	uint8_t nss;
+	uint32_t rate_flags;
 } tSirSmeChanInfo, *tpSirSmeChanInfo;
+
 /* / Definition for Association indication from peer */
 /* / MAC ---> */
 typedef struct sSirSmeAssocInd {
diff --git a/core/mac/src/include/dph_global.h b/core/mac/src/include/dph_global.h
index ae590db..abeacf4 100644
--- a/core/mac/src/include/dph_global.h
+++ b/core/mac/src/include/dph_global.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2014 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -238,6 +238,8 @@
 	/* key installed for this STA or not in the firmware */
 	uint8_t is_key_installed;
 	uint8_t is_disassoc_deauth_in_progress;
+
+	uint8_t nss;
 	/*
 	 * When a station with already an existing dph entry tries to
 	 * associate again, the old dph entry will be zeroed out except
diff --git a/core/mac/src/pe/lim/lim_process_assoc_req_frame.c b/core/mac/src/pe/lim/lim_process_assoc_req_frame.c
index 02b0923..8e23a4e 100644
--- a/core/mac/src/pe/lim/lim_process_assoc_req_frame.c
+++ b/core/mac/src/pe/lim/lim_process_assoc_req_frame.c
@@ -1929,6 +1929,9 @@
 			(session_entry->maxTxPower << 16);
 		assoc_ind->chan_info.reg_info_2 =
 			(session_entry->maxTxPower << 8);
+		assoc_ind->chan_info.nss = sta_ds->nss;
+		assoc_ind->chan_info.rate_flags =
+			lim_get_max_rate_flags(mac_ctx, sta_ds);
 		/* updates VHT information in assoc indication */
 		lim_fill_assoc_ind_vht_info(mac_ctx, session_entry, assoc_req,
 			assoc_ind);
diff --git a/core/mac/src/pe/lim/lim_process_assoc_rsp_frame.c b/core/mac/src/pe/lim/lim_process_assoc_rsp_frame.c
index 24caac9..c11cecc 100644
--- a/core/mac/src/pe/lim/lim_process_assoc_rsp_frame.c
+++ b/core/mac/src/pe/lim/lim_process_assoc_rsp_frame.c
@@ -61,6 +61,7 @@
  * @mac_ctx: Pointer to Global MAC structure
  * @sta_ds: Station Descriptor in DPH
  * @assoc_rsp: Pointer to Association Response Structure
+ * @session_entry : PE session Entry
  *
  * This function is called to Update the HT capabilities in
  * Station Descriptor (dph) Details from
@@ -69,20 +70,27 @@
  * Return: None
  */
 static void lim_update_stads_htcap(tpAniSirGlobal mac_ctx,
-	tpDphHashNode sta_ds, tpSirAssocRsp assoc_rsp)
+		tpDphHashNode sta_ds, tpSirAssocRsp assoc_rsp,
+		tpPESession session_entry)
 {
 	uint16_t highest_rxrate = 0;
 	tDot11fIEHTCaps *ht_caps;
+	uint32_t shortgi_20mhz_support;
+	uint32_t shortgi_40mhz_support;
 
 	ht_caps = &assoc_rsp->HTCaps;
 	sta_ds->mlmStaContext.htCapability = assoc_rsp->HTCaps.present;
 	if (assoc_rsp->HTCaps.present) {
 		sta_ds->htGreenfield =
 			(uint8_t) ht_caps->greenField;
-		sta_ds->htSupportedChannelWidthSet =
-			(uint8_t) (ht_caps->supportedChannelWidthSet ?
-		assoc_rsp->HTInfo.recommendedTxWidthSet :
-		ht_caps->supportedChannelWidthSet);
+		if (session_entry->htSupportedChannelWidthSet) {
+			sta_ds->htSupportedChannelWidthSet =
+				(uint8_t) (ht_caps->supportedChannelWidthSet ?
+				assoc_rsp->HTInfo.recommendedTxWidthSet :
+				ht_caps->supportedChannelWidthSet);
+		} else
+			sta_ds->htSupportedChannelWidthSet =
+				eHT_CHANNEL_WIDTH_20MHZ;
 		sta_ds->htLsigTXOPProtection =
 			(uint8_t) ht_caps->lsigTXOPProtection;
 		sta_ds->htMIMOPSState =
@@ -92,10 +100,6 @@
 		sta_ds->htAMpduDensity = ht_caps->mpduDensity;
 		sta_ds->htDsssCckRate40MHzSupport =
 			(uint8_t) ht_caps->dsssCckMode40MHz;
-		sta_ds->htShortGI20Mhz =
-			(uint8_t) ht_caps->shortGI20MHz;
-		sta_ds->htShortGI40Mhz =
-			(uint8_t) ht_caps->shortGI40MHz;
 		sta_ds->htMaxRxAMpduFactor =
 			ht_caps->maxRxAMPDUFactor;
 		lim_fill_rx_highest_supported_rate(mac_ctx, &highest_rxrate,
@@ -115,6 +119,39 @@
 		 * For now, it is IMMEDIATE BA only on ALL TID's
 		 */
 		sta_ds->baPolicyFlag = 0xFF;
+
+		/* Check if we have support for gShortGI20Mhz and
+		 * gShortGI40Mhz from ini file
+		 */
+		if (eSIR_SUCCESS == wlan_cfg_get_int(mac_ctx,
+						WNI_CFG_SHORT_GI_20MHZ,
+						&shortgi_20mhz_support)) {
+			if (true == shortgi_20mhz_support)
+				sta_ds->htShortGI20Mhz =
+				      (uint8_t)assoc_rsp->HTCaps.shortGI20MHz;
+			else
+				sta_ds->htShortGI20Mhz = false;
+		} else {
+			lim_log(mac_ctx, LOGE,
+				FL("could not retrieve shortGI 20Mhz CFG, setting value to default"));
+			sta_ds->htShortGI20Mhz =
+				WNI_CFG_SHORT_GI_20MHZ_STADEF;
+		}
+
+		if (eSIR_SUCCESS == wlan_cfg_get_int(mac_ctx,
+						WNI_CFG_SHORT_GI_40MHZ,
+						&shortgi_40mhz_support)) {
+			if (true == shortgi_40mhz_support)
+				sta_ds->htShortGI40Mhz =
+				      (uint8_t)assoc_rsp->HTCaps.shortGI40MHz;
+			else
+				sta_ds->htShortGI40Mhz = false;
+		} else {
+			lim_log(mac_ctx, LOGE,
+				FL("could not retrieve shortGI 40Mhz CFG,setting value to default"));
+			sta_ds->htShortGI40Mhz =
+				WNI_CFG_SHORT_GI_40MHZ_STADEF;
+		}
 	}
 }
 
@@ -150,7 +187,8 @@
 
 	/* Update HT Capabilites only when the self mode supports HT */
 	if (IS_DOT11_MODE_HT(session_entry->dot11mode))
-		lim_update_stads_htcap(mac_ctx, sta_ds, assoc_rsp);
+		lim_update_stads_htcap(mac_ctx, sta_ds, assoc_rsp,
+				       session_entry);
 
 #ifdef WLAN_FEATURE_11AC
 	if (assoc_rsp->VHTCaps.present)
diff --git a/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c b/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c
index 366b79e..41282b7 100644
--- a/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c
+++ b/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c
@@ -1762,9 +1762,11 @@
 		sta_ds =
 			dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
 				&session_entry->dph.dphHashTable);
-		if (NULL != sta_ds)
+		if (NULL != sta_ds) {
 			sta_ds->mlmStaContext.mlmState =
 				eLIM_MLM_LINK_ESTABLISHED_STATE;
+			sta_ds->nss = add_sta_params->nss;
+		}
 		else
 			lim_log(mac_ctx, LOGW,
 				FL("Fail to get DPH Hash Entry for AID - %d"),
@@ -2258,6 +2260,7 @@
 	}
 	pStaDs->bssId = pAddStaParams->bssIdx;
 	pStaDs->staIndex = pAddStaParams->staIdx;
+	pStaDs->nss = pAddStaParams->nss;
 	/* if the AssocRsp frame is not acknowledged, then keep alive timer will take care of the state */
 	pStaDs->valid = 1;
 	pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ASSOC_CNF_STATE;
diff --git a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
index 10a7032..bde6cba 100644
--- a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
+++ b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
@@ -168,6 +168,55 @@
 
 
 /**
+ * lim_get_max_rate_flags() - Get rate flags
+ * @mac_ctx: Pointer to global MAC structure
+ * @sta_ds: Pointer to station ds structure
+ *
+ * This function is called to get the rate flags for a connection
+ * from the station ds structure depending on the ht and the vht
+ * channel width supported.
+ *
+ * Return: Returns the populated rate_flags
+ */
+uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
+{
+	uint32_t rate_flags = 0;
+
+	if (sta_ds == NULL) {
+		lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
+		return rate_flags;
+	}
+
+	if (!sta_ds->mlmStaContext.htCapability &&
+	    !sta_ds->mlmStaContext.vhtCapability) {
+		rate_flags |= eHAL_TX_RATE_LEGACY;
+	} else {
+		if (sta_ds->mlmStaContext.vhtCapability) {
+			if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
+				sta_ds->vhtSupportedChannelWidthSet) {
+				rate_flags |= eHAL_TX_RATE_VHT80;
+			} else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
+					sta_ds->vhtSupportedChannelWidthSet) {
+				if (sta_ds->htSupportedChannelWidthSet)
+					rate_flags |= eHAL_TX_RATE_VHT40;
+				else
+					rate_flags |= eHAL_TX_RATE_VHT20;
+			}
+		} else if (sta_ds->mlmStaContext.htCapability) {
+			if (sta_ds->htSupportedChannelWidthSet)
+				rate_flags |= eHAL_TX_RATE_HT40;
+			else
+				rate_flags |= eHAL_TX_RATE_HT20;
+		}
+	}
+
+	if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
+		rate_flags |= eHAL_TX_RATE_SGI;
+
+	return rate_flags;
+}
+
+/**
  * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
  * @mac_ctx          Pointer to Global MAC structure
  * @status           Resume link status
@@ -430,6 +479,9 @@
 				sme_join_rsp->tdls_chan_swit_prohibited =
 				   session_entry->tdls_chan_swit_prohibited;
 #endif
+				sme_join_rsp->nss = sta_ds->nss;
+				sme_join_rsp->max_rate_flags =
+					lim_get_max_rate_flags(mac_ctx, sta_ds);
 			}
 		}
 		sme_join_rsp->beaconLength = 0;
diff --git a/core/mac/src/pe/lim/lim_utils.h b/core/mac/src/pe/lim/lim_utils.h
index f551109..cd9d6a1 100644
--- a/core/mac/src/pe/lim/lim_utils.h
+++ b/core/mac/src/pe/lim/lim_utils.h
@@ -444,6 +444,7 @@
 bool lim_is_noa_insert_reqd(tpAniSirGlobal pMac);
 bool lim_isconnected_on_dfs_channel(uint8_t currentChannel);
 uint8_t lim_get_current_operating_channel(tpAniSirGlobal pMac);
+uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds);
 
 #ifdef WLAN_FEATURE_11AC
 bool lim_check_vht_op_mode_change(tpAniSirGlobal pMac,