Jelajahi Sumber

qcacld-3.0: Move two cfg api to lim

Move below two used cfg api to lim, since legacy cfg will be cleanup.
- cfg_get_capability_info
- cfg_get_regulatory_max_transmit_power

Change-Id: Ifdf96ed61366aeaec13ea466dd5c515e9538261a
CRs-Fixed: 2383216
Wu Gao 6 tahun lalu
induk
melakukan
5c3d94b076

+ 2 - 4
core/mac/src/pe/lim/lim_assoc_utils.c

@@ -34,7 +34,6 @@
 #include "sir_common.h"
 
 #include "wni_cfg.h"
-#include "cfg_api.h"
 #include "cfg_ucfg_api.h"
 
 #include "sch_api.h"
@@ -4686,9 +4685,8 @@ QDF_STATUS lim_is_dot11h_power_capabilities_in_range(struct mac_context *mac,
 	int8_t localMaxTxPower;
 	uint8_t local_pwr_constraint;
 
-	localMaxTxPower =
-		cfg_get_regulatory_max_transmit_power(mac,
-						      pe_session->currentOperChannel);
+	localMaxTxPower = lim_get_regulatory_max_transmit_power(
+					mac, pe_session->currentOperChannel);
 
 	local_pwr_constraint = mac->mlme_cfg->power.local_power_constraint;
 	localMaxTxPower -= (int8_t)local_pwr_constraint;

+ 1 - 1
core/mac/src/pe/lim/lim_ft.c

@@ -657,7 +657,7 @@ void lim_fill_ft_session(struct mac_context *mac,
 		ft_session->shortSlotTimeSupported = true;
 	}
 
-	regMax = cfg_get_regulatory_max_transmit_power(mac,
+	regMax = lim_get_regulatory_max_transmit_power(mac,
 						       ft_session->
 						       currentOperChannel);
 	localPowerConstraint = regMax;

+ 2 - 2
core/mac/src/pe/lim/lim_process_assoc_req_frame.c

@@ -24,7 +24,6 @@
 #include "ani_global.h"
 #include "wni_cfg.h"
 #include "sir_api.h"
-#include "cfg_api.h"
 #include "cfg_ucfg_api.h"
 
 #include "sch_api.h"
@@ -292,7 +291,8 @@ static bool lim_chk_capab(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
 {
 	uint16_t temp;
 
-	if (cfg_get_capability_info(mac_ctx, &temp, session) != QDF_STATUS_SUCCESS) {
+	if (lim_get_capability_info(mac_ctx, &temp, session) !=
+	    QDF_STATUS_SUCCESS) {
 		pe_err("could not retrieve Capabilities");
 		return false;
 	}

+ 2 - 3
core/mac/src/pe/lim/lim_process_assoc_rsp_frame.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -31,7 +31,6 @@
 #include "wni_api.h"
 #include "wni_cfg.h"
 #include "ani_global.h"
-#include "cfg_api.h"
 #include "sch_api.h"
 
 #include "utils_api.h"
@@ -684,7 +683,7 @@ lim_process_assoc_rsp_frame(struct mac_context *mac_ctx,
 		return;
 	}
 
-	if (cfg_get_capability_info(mac_ctx, &caps, session_entry)
+	if (lim_get_capability_info(mac_ctx, &caps, session_entry)
 		!= QDF_STATUS_SUCCESS) {
 		qdf_mem_free(assoc_rsp);
 		qdf_mem_free(beacon);

+ 1 - 2
core/mac/src/pe/lim/lim_process_mlm_host_roam.c

@@ -26,7 +26,6 @@
 #include "ani_global.h"
 #include "sir_api.h"
 #include "sir_params.h"
-#include "cfg_api.h"
 
 #include "sch_api.h"
 #include "utils_api.h"
@@ -608,7 +607,7 @@ void lim_process_mlm_ft_reassoc_req(struct mac_context *mac,
 	qdf_mem_copy(reassoc_req->peerMacAddr,
 		     session->bssId, sizeof(tSirMacAddr));
 
-	if (cfg_get_capability_info(mac, &caps, session) !=
+	if (lim_get_capability_info(mac, &caps, session) !=
 			QDF_STATUS_SUCCESS) {
 		/**
 		 * Could not get Capabilities value

+ 1 - 2
core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c

@@ -18,7 +18,6 @@
 
 #include "wni_api.h"
 #include "wni_cfg.h"
-#include "cfg_api.h"
 #include "sir_api.h"
 #include "sch_api.h"
 #include "utils_api.h"
@@ -351,7 +350,7 @@ static void lim_send_mlm_assoc_req(struct mac_context *mac_ctx,
 	val = sizeof(tSirMacAddr);
 	sir_copy_mac_addr(assoc_req->peerMacAddr, session_entry->bssId);
 
-	if (cfg_get_capability_info(mac_ctx, &caps, session_entry)
+	if (lim_get_capability_info(mac_ctx, &caps, session_entry)
 			!= QDF_STATUS_SUCCESS)
 		/* Could not get Capabilities value from CFG.*/
 		pe_err("could not retrieve Capabilities value");

+ 7 - 8
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -30,7 +30,6 @@
 #include "cds_api.h"
 #include "wni_api.h"
 #include "wni_cfg.h"
-#include "cfg_api.h"
 #include "sir_api.h"
 #include "sch_api.h"
 #include "utils_api.h"
@@ -710,7 +709,7 @@ __lim_handle_sme_start_bss_request(struct mac_context *mac_ctx, uint32_t *msg_bu
 		session->gLimPhyMode = sme_start_bss_req->nwType;
 
 		session->maxTxPower =
-			cfg_get_regulatory_max_transmit_power(mac_ctx,
+			lim_get_regulatory_max_transmit_power(mac_ctx,
 				session->currentOperChannel);
 		/* Store the dot 11 mode in to the session Table */
 		session->dot11mode = sme_start_bss_req->dot11mode;
@@ -1623,7 +1622,7 @@ __lim_process_sme_join_req(struct mac_context *mac_ctx, uint32_t *msg_buf)
 		session->limCurrentBssCaps =
 			session->pLimJoinReq->bssDescription.capabilityInfo;
 
-		reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
+		reg_max = lim_get_regulatory_max_transmit_power(mac_ctx,
 				session->currentOperChannel);
 		local_power_constraint = reg_max;
 
@@ -1940,7 +1939,7 @@ static void __lim_process_sme_reassoc_req(struct mac_context *mac_ctx,
 
 	session_entry->limReassocBssCaps =
 		session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
-	reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
+	reg_max = lim_get_regulatory_max_transmit_power(mac_ctx,
 			session_entry->currentOperChannel);
 	local_pwr_constraint = reg_max;
 
@@ -1975,8 +1974,8 @@ static void __lim_process_sme_reassoc_req(struct mac_context *mac_ctx,
 	qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
 		     session_entry->limReAssocbssId, sizeof(tSirMacAddr));
 
-	if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
-			QDF_STATUS_SUCCESS)
+	if (lim_get_capability_info(mac_ctx, &caps, session_entry) !=
+	    QDF_STATUS_SUCCESS)
 		pe_err("could not retrieve Capabilities value");
 
 	lim_update_caps_info_for_bss(mac_ctx, &caps,
@@ -5247,8 +5246,8 @@ static void lim_process_sme_channel_change_request(struct mac_context *mac_ctx,
 	}
 	ch_change_req = (tpSirChanChangeRequest)msg_buf;
 
-	max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
-			ch_change_req->targetChannel);
+	max_tx_pwr = lim_get_regulatory_max_transmit_power(
+				mac_ctx, ch_change_req->targetChannel);
 
 	if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
 			(max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {

+ 6 - 5
core/mac/src/pe/lim/lim_process_tdls.c

@@ -53,7 +53,6 @@
 #include "sir_api.h"
 #include "ani_global.h"
 #include "sir_mac_prot_def.h"
-#include "cfg_api.h"
 #include "utils_api.h"
 #include "lim_types.h"
 #include "lim_utils.h"
@@ -821,8 +820,8 @@ static QDF_STATUS lim_send_tdls_dis_rsp_frame(struct mac_context *mac,
 				  &tdlsDisRsp.LinkIdentifier,
 				  peer_mac, TDLS_RESPONDER);
 
-	if (cfg_get_capability_info(mac, &caps, pe_session)
-		!= QDF_STATUS_SUCCESS) {
+	if (lim_get_capability_info(mac, &caps, pe_session) !=
+	    QDF_STATUS_SUCCESS) {
 		/*
 		 * Could not get Capabilities value
 		 * from CFG. Log error.
@@ -1130,7 +1129,8 @@ QDF_STATUS lim_send_tdls_link_setup_req_frame(struct mac_context *mac,
 				  &tdlsSetupReq.LinkIdentifier, peer_mac,
 				  TDLS_INITIATOR);
 
-	if (cfg_get_capability_info(mac, &caps, pe_session) != QDF_STATUS_SUCCESS) {
+	if (lim_get_capability_info(mac, &caps, pe_session) !=
+	    QDF_STATUS_SUCCESS) {
 		/*
 		 * Could not get Capabilities value
 		 * from CFG. Log error.
@@ -1589,7 +1589,8 @@ static QDF_STATUS lim_send_tdls_setup_rsp_frame(struct mac_context *mac,
 				  &tdlsSetupRsp.LinkIdentifier, peer_mac,
 				  TDLS_RESPONDER);
 
-	if (cfg_get_capability_info(mac, &caps, pe_session) != QDF_STATUS_SUCCESS) {
+	if (lim_get_capability_info(mac, &caps, pe_session) !=
+	    QDF_STATUS_SUCCESS) {
 		/*
 		 * Could not get Capabilities value
 		 * from CFG. Log error.

+ 1 - 2
core/mac/src/pe/lim/lim_send_sme_rsp_messages.c

@@ -34,7 +34,6 @@
 
 #include "wni_cfg.h"
 #include "sys_def.h"
-#include "cfg_api.h"
 
 #include "sch_api.h"
 #include "utils_api.h"
@@ -599,7 +598,7 @@ lim_send_sme_start_bss_rsp(struct mac_context *mac,
 				beaconInterval;
 			pSirSmeRsp->bssType = pe_session->bssType;
 
-			if (cfg_get_capability_info
+			if (lim_get_capability_info
 				    (mac, &pSirSmeRsp->bssDescription.capabilityInfo,
 				    pe_session)
 			    != QDF_STATUS_SUCCESS)

+ 159 - 0
core/mac/src/pe/lim/lim_utils.c

@@ -8283,3 +8283,162 @@ void lim_ndi_mlme_vdev_up_transition(struct pe_session *session)
 {
 }
 #endif
+
+/**
+ * lim_get_dot11d_transmit_power() - regulatory max transmit power
+ * @mac: pointer to mac data
+ * @channel: channel number
+ *
+ * Return:  int8_t - power
+ */
+static int8_t
+lim_get_dot11d_transmit_power(struct mac_context *mac, uint8_t channel)
+{
+	uint32_t cfg_length = 0;
+	int8_t max_tx_pwr = 0;
+	uint8_t *country_info = NULL;
+	uint8_t count = 0;
+	uint8_t first_channel;
+	uint8_t maxChannels;
+
+	if (WLAN_REG_IS_5GHZ_CH(channel))
+		cfg_length = mac->mlme_cfg->power.max_tx_power_5.len;
+	else if (WLAN_REG_IS_24GHZ_CH(channel))
+		cfg_length = mac->mlme_cfg->power.max_tx_power_24.len;
+	else
+		return max_tx_pwr;
+
+	country_info = qdf_mem_malloc(cfg_length);
+	if (!country_info)
+		goto error;
+
+	if (WLAN_REG_IS_5GHZ_CH(channel)) {
+		qdf_mem_copy(country_info,
+			     mac->mlme_cfg->power.max_tx_power_5.data,
+			     cfg_length);
+	} else if (WLAN_REG_IS_24GHZ_CH(channel)) {
+		qdf_mem_copy(country_info,
+			     mac->mlme_cfg->power.max_tx_power_24.data,
+			     cfg_length);
+	}
+
+	/* Identify the channel and maxtxpower */
+	while (count <= (cfg_length - (sizeof(tSirMacChanInfo)))) {
+		first_channel = country_info[count++];
+		maxChannels = country_info[count++];
+		max_tx_pwr = country_info[count++];
+
+		if ((channel >= first_channel) &&
+		    (channel < (first_channel + maxChannels))) {
+			break;
+		}
+	}
+
+error:
+	if (country_info)
+		qdf_mem_free(country_info);
+
+	return max_tx_pwr;
+}
+
+int8_t lim_get_regulatory_max_transmit_power(struct mac_context *mac,
+					     uint8_t channel)
+{
+	return lim_get_dot11d_transmit_power(mac, channel);
+}
+
+QDF_STATUS lim_get_capability_info(struct mac_context *mac, uint16_t *pcap,
+				   struct pe_session *pe_session)
+{
+	uint32_t val = 0;
+	tpSirMacCapabilityInfo pcap_info;
+
+	*pcap = 0;
+	pcap_info = (tpSirMacCapabilityInfo)pcap;
+
+	if (LIM_IS_IBSS_ROLE(pe_session))
+		pcap_info->ibss = 1;     /* IBSS bit */
+	else if (LIM_IS_AP_ROLE(pe_session) ||
+		LIM_IS_STA_ROLE(pe_session))
+		pcap_info->ess = 1;      /* ESS bit */
+	else if (LIM_IS_P2P_DEVICE_ROLE(pe_session) ||
+		LIM_IS_NDI_ROLE(pe_session)) {
+		pcap_info->ess = 0;
+		pcap_info->ibss = 0;
+	} else
+		pe_warn("can't get capability, role is UNKNOWN!!");
+
+	if (LIM_IS_AP_ROLE(pe_session)) {
+		val = pe_session->privacy;
+	} else {
+		/* PRIVACY bit */
+		val = mac->mlme_cfg->wep_params.is_privacy_enabled;
+	}
+	if (val)
+		pcap_info->privacy = 1;
+
+	/* Short preamble bit */
+	if (mac->mlme_cfg->ht_caps.short_preamble)
+		pcap_info->shortPreamble =
+			mac->mlme_cfg->ht_caps.short_preamble;
+
+	/* PBCC bit */
+	pcap_info->pbcc = 0;
+
+	/* Channel agility bit */
+	pcap_info->channelAgility = 0;
+	/* If STA/AP operating in 11B mode, don't set rest of the
+	 * capability info bits.
+	 */
+	if (pe_session->dot11mode == WNI_CFG_DOT11_MODE_11B)
+		return QDF_STATUS_SUCCESS;
+
+	/* Short slot time bit */
+	if (LIM_IS_AP_ROLE(pe_session)) {
+		pcap_info->shortSlotTime = pe_session->shortSlotTimeSupported;
+	} else {
+		/* When in STA mode, we need to check if short slot is
+		 * enabled as well as check if the current operating
+		 * mode is short slot time and then decide whether to
+		 * enable short slot or not. It is safe to check both
+		 * cfg values to determine short slot value in this
+		 * funcn since this funcn is always used after assoc
+		 * when these cfg values are already set based on
+		 * peer's capability. Even in case of IBSS, its value
+		 * is set to correct value either in delBSS as part of
+		 * deleting the previous IBSS or in start BSS as part
+		 * of coalescing
+		 */
+		if (mac->mlme_cfg->feature_flags.enable_short_slot_time_11g) {
+			pcap_info->shortSlotTime =
+				pe_session->shortSlotTimeSupported;
+		}
+	}
+
+	/* Spectrum Management bit */
+	if (!LIM_IS_IBSS_ROLE(pe_session) && pe_session->lim11hEnable) {
+		if (mac->mlme_cfg->gen.enabled_11h)
+			pcap_info->spectrumMgt = 1;
+	}
+	/* QoS bit */
+	if (mac->mlme_cfg->wmm_params.qos_enabled)
+		pcap_info->qos = 1;
+
+	/* APSD bit */
+	if (mac->mlme_cfg->scoring.apsd_enabled)
+		pcap_info->apsd = 1;
+
+	pcap_info->rrm = mac->rrm.rrmSmeContext.rrmConfig.rrm_enabled;
+	pe_debug("RRM: %d", pcap_info->rrm);
+	/* DSSS-OFDM */
+	/* FIXME : no config defined yet. */
+
+	/* Block ack bit */
+	val = mac->mlme_cfg->feature_flags.enable_block_ack;
+	pcap_info->delayedBA =
+		(uint16_t) ((val >> WNI_CFG_BLOCK_ACK_ENABLED_DELAYED) & 1);
+	pcap_info->immediateBA =
+		(uint16_t) ((val >> WNI_CFG_BLOCK_ACK_ENABLED_IMMEDIATE) & 1);
+
+	return QDF_STATUS_SUCCESS;
+}

+ 24 - 1
core/mac/src/pe/lim/lim_utils.h

@@ -30,7 +30,6 @@
 
 #include "sir_api.h"
 #include "sir_debug.h"
-#include "cfg_api.h"
 
 #include "lim_types.h"
 #include "lim_scan_result_utils.h"
@@ -1687,4 +1686,28 @@ static inline void lim_copy_set_key_req_mac_addr(struct qdf_mac_addr *dst,
 {
 }
 #endif
+
+/**
+ * lim_get_regulatory_max_transmit_power() - Get regulatory max transmit
+ * power on given channel
+ * @mac:     pointer to mac data
+ * @channel: channel number
+ *
+ * Return:  int8_t - power
+ */
+int8_t lim_get_regulatory_max_transmit_power(struct mac_context *mac,
+					     uint8_t channel);
+
+/**
+ * lim_get_capability_info() - Get capability information
+ * @mac:        pointer to mac data
+ * @pcap:       pointer to return capability information
+ * @pe_session: pointer to pe session
+ *
+ * Return:  SUCCESS on successful get capability information
+ *         FAILURE, if it fails due to any
+ */
+QDF_STATUS lim_get_capability_info(struct mac_context *mac, uint16_t *pCap,
+				   struct pe_session *pe_session);
+
 #endif /* __LIM_UTILS_H */

+ 2 - 3
core/mac/src/pe/sch/sch_beacon_process.c

@@ -31,7 +31,6 @@
 #include "cds_api.h"
 #include "wni_cfg.h"
 
-#include "cfg_api.h"
 #include "cfg_ucfg_api.h"
 #include "lim_api.h"
 #include "utils_api.h"
@@ -867,8 +866,8 @@ static void __sch_beacon_process_for_session(struct mac_context *mac_ctx,
 					rx_pkt_info, session, &bssIdx,
 					&beaconParams, &sendProbeReq, pMh);
 	/* Obtain the Max Tx power for the current regulatory  */
-	regMax = cfg_get_regulatory_max_transmit_power(mac_ctx,
-					session->currentOperChannel);
+	regMax = lim_get_regulatory_max_transmit_power(
+				mac_ctx, session->currentOperChannel);
 
 	local_constraint = regMax;
 

+ 3 - 4
core/mac/src/sys/legacy/src/utils/src/parser_api.c

@@ -30,7 +30,6 @@
 #include "sir_api.h"
 #include "ani_global.h"
 #include "parser_api.h"
-#include "cfg_api.h"
 #include "lim_utils.h"
 #include "utils_parser.h"
 #include "lim_ser_des_utils.h"
@@ -154,7 +153,7 @@ populate_dot11f_capabilities(struct mac_context *mac,
 	uint16_t cfg;
 	QDF_STATUS nSirStatus;
 
-	nSirStatus = cfg_get_capability_info(mac, &cfg, pe_session);
+	nSirStatus = lim_get_capability_info(mac, &cfg, pe_session);
 	if (QDF_STATUS_SUCCESS != nSirStatus) {
 		pe_err("Failed to retrieve the Capabilities bitfield from CFG status: %d",
 			   nSirStatus);
@@ -1642,8 +1641,8 @@ populate_dot11f_tpc_report(struct mac_context *mac,
 			nSirStatus);
 		return QDF_STATUS_E_FAILURE;
 	}
-	tx_power = cfg_get_regulatory_max_transmit_power(mac,
-				pe_session->currentOperChannel);
+	tx_power = lim_get_regulatory_max_transmit_power(
+				mac, pe_session->currentOperChannel);
 	pDot11f->tx_power = tx_power;
 	pDot11f->link_margin = 0;
 	pDot11f->present = 1;