qcacld-3.0: Add INI item for 11AX HE params and configure on BSS start

Add INI params for 11AX HE OBSS_PD. Update code to set
these params on BSS start on station connection and SAP start.

Change-Id: I60ae2cae936558668dfb1059744a6e3891aaebd1
CRs-fixed: 2045431
diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h
index 2a65684..ef42465 100644
--- a/core/hdd/inc/wlan_hdd_cfg.h
+++ b/core/hdd/inc/wlan_hdd_cfg.h
@@ -9834,6 +9834,34 @@
 #define CFG_ENABLE_UL_OFDMA_MAX     (1)
 #define CFG_ENABLE_UL_OFDMA_DEFAULT (0)
 
+/*
+ * <ini>
+ * he_sta_obsspd- 11AX HE OBSS PD bit field
+ * @Min: 0
+ * @Max: uin32_t max
+ * @Default: 0x15b8c2ae
+ *
+ * 4 Byte value with each byte representing a signed value for following params:
+ * Param                   Bit position    Default
+ * OBSS_PD min (primary)   7:0             -82 (0xae)
+ * OBSS_PD max (primary)   15:8            -62 (0xc2)
+ * Secondary channel Ed    23:16           -72 (0xb8)
+ * TX_PWR(ref)             31:24           21  (0x15)
+ * This bit field value is directly applied to FW
+ *
+ * Related: NA
+ *
+ * Supported Feature: 11AX
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_HE_STA_OBSSPD_NAME    "he_sta_obsspd"
+#define CFG_HE_STA_OBSSPD_MIN     (0)
+#define CFG_HE_STA_OBSSPD_MAX     (0xffffffff)
+#define CFG_HE_STA_OBSSPD_DEFAULT (0x15b8c2ae)
+
 #endif /* WLAN_FEATURE_11AX */
 
 /**
@@ -10786,6 +10814,7 @@
 #ifdef WLAN_FEATURE_11AX
 	bool enable_ul_mimo;
 	bool enable_ul_ofdma;
+	uint32_t he_sta_obsspd;
 #endif
 	enum l1ss_sleep_allowed l1ss_sleep_allowed;
 	uint32_t arp_ac_category;
diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c
index b9c5fd4..6af9878 100644
--- a/core/hdd/src/wlan_hdd_cfg.c
+++ b/core/hdd/src/wlan_hdd_cfg.c
@@ -4269,6 +4269,13 @@
 		     CFG_ENABLE_UL_OFDMA_DEFAULT,
 		     CFG_ENABLE_UL_OFDMA_MIN,
 		     CFG_ENABLE_UL_OFDMA_MAX),
+
+	REG_VARIABLE(CFG_HE_STA_OBSSPD_NAME, WLAN_PARAM_HexInteger,
+		     struct hdd_config, he_sta_obsspd,
+		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+		     CFG_HE_STA_OBSSPD_DEFAULT,
+		     CFG_HE_STA_OBSSPD_MIN,
+		     CFG_HE_STA_OBSSPD_MAX),
 #endif
 
 	REG_VARIABLE(CFG_L1SS_SLEEP_ALLOWED_NAME, WLAN_PARAM_Integer,
diff --git a/core/hdd/src/wlan_hdd_he.c b/core/hdd/src/wlan_hdd_he.c
index b95c126..7edc012 100644
--- a/core/hdd/src/wlan_hdd_he.c
+++ b/core/hdd/src/wlan_hdd_he.c
@@ -258,6 +258,8 @@
 		hdd_ctx->config->enable_ul_mimo);
 	hdd_info("Name = [%s] Value = [%d]", CFG_ENABLE_UL_OFDMA_NAME,
 		hdd_ctx->config->enable_ul_ofdma);
+	hdd_info("Name = [%s] Value = [%d]", CFG_HE_STA_OBSSPD_NAME,
+		hdd_ctx->config->he_sta_obsspd);
 }
 
 int hdd_update_he_cap_in_cfg(hdd_context_t *hdd_ctx)
@@ -267,6 +269,11 @@
 	int ret;
 	struct hdd_config *config = hdd_ctx->config;
 
+	ret = hdd_he_set_wni_cfg(hdd_ctx, WNI_CFG_HE_STA_OBSSPD,
+				 config->he_sta_obsspd);
+	if (ret)
+		return ret;
+
 	status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_HE_UL_MUMIMO, &val);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("could not get WNI_CFG_HE_UL_MUMIMO");
diff --git a/core/mac/inc/wni_cfg.h b/core/mac/inc/wni_cfg.h
index 774a13d..6e16790 100644
--- a/core/mac/inc/wni_cfg.h
+++ b/core/mac/inc/wni_cfg.h
@@ -316,6 +316,7 @@
 	WNI_CFG_HE_MCS,
 	WNI_CFG_HE_PPET,
 	WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT,
+	WNI_CFG_HE_STA_OBSSPD,
 	/* Any new items to be added should be above this strictly */
 	CFG_PARAM_MAX_NUM
 };
diff --git a/core/mac/src/pe/include/lim_session.h b/core/mac/src/pe/include/lim_session.h
index 33d3fc3..2f404d3 100644
--- a/core/mac/src/pe/include/lim_session.h
+++ b/core/mac/src/pe/include/lim_session.h
@@ -507,6 +507,7 @@
 	bool he_capable;
 	tDot11fIEvendor_he_cap he_config;
 	tDot11fIEvendor_he_op he_op;
+	uint32_t he_sta_obsspd;
 #ifdef WLAN_FEATURE_11AX_BSS_COLOR
 	tDot11fIEbss_color_change he_bss_color_change;
 	struct bss_color_info bss_color_info[MAX_BSS_COLOR_VALUE];
diff --git a/core/mac/src/pe/lim/lim_assoc_utils.c b/core/mac/src/pe/lim/lim_assoc_utils.c
index 24fce1a..12bf8f4 100644
--- a/core/mac/src/pe/lim/lim_assoc_utils.c
+++ b/core/mac/src/pe/lim/lim_assoc_utils.c
@@ -3624,9 +3624,10 @@
 			pAddBssParams->ch_center_freq_seg1);
 
 	if (lim_is_session_he_capable(psessionEntry) &&
-			(pAssocRsp->vendor_he_cap.present))
+			(pAssocRsp->vendor_he_cap.present)) {
 		lim_add_bss_he_cap(pAddBssParams, pAssocRsp);
-
+		lim_add_bss_he_cfg(pAddBssParams, psessionEntry);
+	}
 	/*
 	 * Populate the STA-related parameters here
 	 * Note that the STA here refers to the AP
@@ -4164,9 +4165,10 @@
 	}
 
 	if (lim_is_session_he_capable(psessionEntry) &&
-	    pBeaconStruct->vendor_he_cap.present)
+	    pBeaconStruct->vendor_he_cap.present) {
 		lim_update_bss_he_capable(pMac, pAddBssParams);
-
+		lim_add_bss_he_cfg(pAddBssParams, psessionEntry);
+	}
 	pe_debug("vhtCapable %d vhtTxChannelWidthSet %d center_freq_seg0 - %d, center_freq_seg1 - %d",
 		pAddBssParams->vhtCapable, pAddBssParams->ch_width,
 		pAddBssParams->ch_center_freq_seg0,
diff --git a/core/mac/src/pe/lim/lim_utils.c b/core/mac/src/pe/lim/lim_utils.c
index c4b3c47..41391f1 100644
--- a/core/mac/src/pe/lim/lim_utils.c
+++ b/core/mac/src/pe/lim/lim_utils.c
@@ -7231,6 +7231,11 @@
 			     he_op, sizeof(*he_op));
 }
 
+void lim_add_bss_he_cfg(tpAddBssParams add_bss, tpPESession session)
+{
+	add_bss->he_sta_obsspd = session->he_sta_obsspd;
+}
+
 void lim_update_stads_he_caps(tpDphHashNode sta_ds, tpSirAssocRsp assoc_rsp,
 			      tpPESession session_entry)
 {
diff --git a/core/mac/src/pe/lim/lim_utils.h b/core/mac/src/pe/lim/lim_utils.h
index 1ea6222..56fe0f9 100644
--- a/core/mac/src/pe/lim/lim_utils.h
+++ b/core/mac/src/pe/lim/lim_utils.h
@@ -740,6 +740,15 @@
 void lim_add_bss_he_cap(tpAddBssParams add_bss, tpSirAssocRsp assoc_rsp);
 
 /**
+ * lim_add_bss_he_cfg() - Set HE config to BSS params
+ * @add_bss: pointer to add bss params
+ * @session: Pointer to Session entry struct
+ *
+ * Return: None
+ */
+void lim_add_bss_he_cfg(tpAddBssParams add_bss, tpPESession session);
+
+/**
  * lim_copy_bss_he_cap() - Copy HE capability into PE session from start bss
  * @session: pointer to PE session
  * @sme_start_bss_req: pointer to start BSS request
@@ -946,6 +955,11 @@
 	return;
 }
 
+static inline void lim_add_bss_he_cfg(tpAddBssParams add_bss,
+					 tpPESession session)
+{
+}
+
 static inline void lim_intersect_ap_he_caps(tpPESession session,
 		tpAddBssParams add_bss,	tSchBeaconStruct *pBeaconStruct,
 		tpSirAssocRsp assoc_rsp)
diff --git a/core/sme/inc/csr_internal.h b/core/sme/inc/csr_internal.h
index b0abd74..ded4457 100644
--- a/core/sme/inc/csr_internal.h
+++ b/core/sme/inc/csr_internal.h
@@ -947,6 +947,7 @@
 	struct sir_vht_config vht_config;
 #ifdef WLAN_FEATURE_11AX
 	tDot11fIEvendor_he_cap he_config;
+	uint32_t he_sta_obsspd;
 #endif
 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
 	csr_roam_offload_synch_params roamOffloadSynchParams;
diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c
index 185f625..1a33992 100644
--- a/core/sme/src/csr/csr_api_roam.c
+++ b/core/sme/src/csr/csr_api_roam.c
@@ -2330,6 +2330,8 @@
 	} else {
 		he_cap->ppe_threshold.present = false;
 	}
+	sme_cfg_get_int(mac_ctx, WNI_CFG_HE_STA_OBSSPD, &value);
+	session->he_sta_obsspd = value;
 }
 
 #else
diff --git a/core/wma/inc/wma_he.h b/core/wma/inc/wma_he.h
index 855a273..e9801a2 100644
--- a/core/wma/inc/wma_he.h
+++ b/core/wma/inc/wma_he.h
@@ -155,6 +155,17 @@
 void wma_vdev_set_he_bss_params(tp_wma_handle wma, uint8_t vdev_id,
 				struct wma_vdev_start_req *req);
 
+/**
+ * wma_vdev_set_he_config() - set HE Config in vdev start
+ * @wma: pointer to wma handle
+ * @vdev_id: VDEV id
+ * @add_bss: BSS params
+ *
+ * Return: None
+ */
+void wma_vdev_set_he_config(tp_wma_handle wma, uint8_t vdev_id,
+				tpAddBssParams add_bss);
+
 static inline bool wma_is_peer_he_capable(tpAddStaParams params)
 {
 	return params->he_capable;
@@ -281,6 +292,11 @@
 {
 }
 
+static inline void wma_vdev_set_he_config(tp_wma_handle wma, uint8_t vdev_id,
+					tpAddBssParams add_bss)
+{
+}
+
 static inline bool wma_is_peer_he_capable(tpAddStaParams params)
 {
 	return false;
diff --git a/core/wma/inc/wma_if.h b/core/wma/inc/wma_if.h
index 3f1236a..61a5caf 100644
--- a/core/wma/inc/wma_if.h
+++ b/core/wma/inc/wma_if.h
@@ -530,6 +530,7 @@
 	bool he_capable;
 	tDot11fIEvendor_he_cap he_config;
 	tDot11fIEvendor_he_op he_op;
+	uint32_t he_sta_obsspd;
 #endif
 	uint32_t cac_duration_ms;
 	uint32_t dfs_regdomain;
diff --git a/core/wma/src/wma_dev_if.c b/core/wma/src/wma_dev_if.c
index b1d6546..16f7f68 100644
--- a/core/wma/src/wma_dev_if.c
+++ b/core/wma/src/wma_dev_if.c
@@ -3178,7 +3178,6 @@
 				add_bss->llbCoexist, maxTxPower);
 
 	wma_vdev_set_he_bss_params(wma, vdev_id, &req);
-
 	return;
 
 peer_cleanup:
@@ -3588,6 +3587,8 @@
 
 	}
 send_bss_resp:
+
+	wma_vdev_set_he_config(wma, vdev_id, add_bss);
 	cdp_peer_find_by_addr(soc, pdev, add_bss->bssId,
 		&add_bss->staContext.staIdx);
 	add_bss->status = (add_bss->staContext.staIdx < 0) ?
diff --git a/core/wma/src/wma_he.c b/core/wma/src/wma_he.c
index db2ac9c..d4231f2 100644
--- a/core/wma/src/wma_he.c
+++ b/core/wma/src/wma_he.c
@@ -1086,6 +1086,24 @@
 		intr[vdev_id].he_ops = req->he_ops;
 }
 
+void wma_vdev_set_he_config(tp_wma_handle wma, uint8_t vdev_id,
+				tpAddBssParams add_bss)
+{
+	QDF_STATUS ret;
+	int8_t pd_min, pd_max, sec_ch_ed, tx_pwr;
+
+	ret = wma_vdev_set_param(wma->wmi_handle, vdev_id,
+				 WMI_VDEV_PARAM_OBSSPD, add_bss->he_sta_obsspd);
+	if (QDF_IS_STATUS_ERROR(ret))
+		WMA_LOGE(FL("Failed to set HE Config"));
+	pd_min = add_bss->he_sta_obsspd & 0xff,
+	pd_max = (add_bss->he_sta_obsspd & 0xff00) >> 8,
+	sec_ch_ed = (add_bss->he_sta_obsspd & 0xff0000) >> 16,
+	tx_pwr = (add_bss->he_sta_obsspd & 0xff000000) >> 24;
+	WMA_LOGI(FL("HE_STA_OBSSPD: PD_MIN: %d PD_MAX: %d SEC_CH_ED: %d TX_PWR: %d"),
+		 pd_min, pd_max, sec_ch_ed, tx_pwr);
+}
+
 void wma_update_vdev_he_capable(struct wma_vdev_start_req *req,
 		tpSwitchChannelParams params)
 {