qcacmn: Enable Fils Discovery frame sending in 6GHz SAP

To enhance visibility of 6GHz AP, 6G only AP shall send
Fils Discovery frame periodically in one beacon interval.

Change-Id: I51487380fca10418d2260dc2612e2adcf6cbb93b
CRs-Fixed: 2562434
diff --git a/target_if/mlme/vdev_mgr/src/target_if_vdev_mgr_tx_ops.c b/target_if/mlme/vdev_mgr/src/target_if_vdev_mgr_tx_ops.c
index 8675379..13e934f 100644
--- a/target_if/mlme/vdev_mgr/src/target_if_vdev_mgr_tx_ops.c
+++ b/target_if/mlme/vdev_mgr/src/target_if_vdev_mgr_tx_ops.c
@@ -1062,6 +1062,43 @@
 	return status;
 }
 
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
+static QDF_STATUS target_if_vdev_mgr_fils_enable_send(
+					struct wlan_objmgr_vdev *vdev,
+					struct config_fils_params *param)
+{
+	QDF_STATUS status;
+	struct wmi_unified *wmi_handle;
+
+	if (!vdev || !param) {
+		mlme_err("Invalid input");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	wmi_handle = target_if_vdev_mgr_wmi_handle_get(vdev);
+	if (!wmi_handle) {
+		mlme_err("Failed to get WMI handle!");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_vdev_fils_enable_cmd_send(wmi_handle, param);
+
+	return status;
+}
+
+static void target_if_vdev_register_tx_fils(
+		struct wlan_lmac_if_mlme_tx_ops *mlme_tx_ops)
+{
+	mlme_tx_ops->vdev_fils_enable_send =
+		target_if_vdev_mgr_fils_enable_send;
+}
+#else
+static void target_if_vdev_register_tx_fils(
+		struct wlan_lmac_if_mlme_tx_ops *mlme_tx_ops)
+{
+}
+#endif
+
 QDF_STATUS
 target_if_vdev_mgr_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
 {
@@ -1116,6 +1153,7 @@
 			target_if_vdev_mgr_rsp_timer_mod;
 	mlme_tx_ops->peer_delete_all_send =
 			target_if_vdev_mgr_peer_delete_all_send;
+	target_if_vdev_register_tx_fils(mlme_tx_ops);
 
 	return QDF_STATUS_SUCCESS;
 }
diff --git a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
index 3cf2c18..32b2751 100644
--- a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
+++ b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h
@@ -262,6 +262,10 @@
 				      struct beacon_params *param);
 	QDF_STATUS (*beacon_tmpl_send)(struct wlan_objmgr_vdev *vdev,
 				       struct beacon_tmpl_params *param);
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
+	QDF_STATUS (*vdev_fils_enable_send)(struct wlan_objmgr_vdev *vdev,
+					    struct config_fils_params *param);
+#endif
 	QDF_STATUS (*vdev_bcn_miss_offload_send)(struct wlan_objmgr_vdev *vdev);
 	QDF_STATUS (*vdev_sta_ps_param_send)(struct wlan_objmgr_vdev *vdev,
 					     struct sta_ps_params *param);
diff --git a/umac/mlme/vdev_mgr/core/src/vdev_mgr_ops.c b/umac/mlme/vdev_mgr/core/src/vdev_mgr_ops.c
index 86b1c4c..bc5912c 100644
--- a/umac/mlme/vdev_mgr/core/src/vdev_mgr_ops.c
+++ b/umac/mlme/vdev_mgr/core/src/vdev_mgr_ops.c
@@ -343,6 +343,7 @@
 	struct beacon_tmpl_params bcn_tmpl_param = {0};
 	enum QDF_OPMODE opmode;
 	struct wlan_objmgr_vdev *vdev;
+	struct config_fils_params fils_param = {0};
 
 	if (!mlme_obj) {
 		mlme_err("VDEV_MLME is NULL");
@@ -370,6 +371,17 @@
 		return status;
 
 	status = tgt_vdev_mgr_up_send(mlme_obj, &param);
+	if (QDF_IS_STATUS_ERROR(status))
+		return status;
+
+	if (opmode == QDF_SAP_MODE && mlme_obj->vdev->vdev_mlme.des_chan &&
+	    WLAN_REG_IS_6GHZ_CHAN_FREQ(
+			mlme_obj->vdev->vdev_mlme.des_chan->ch_freq)) {
+		fils_param.vdev_id = wlan_vdev_get_id(mlme_obj->vdev);
+		fils_param.fd_period = DEFAULT_FILS_DISCOVERY_PERIOD;
+		status = tgt_vdev_mgr_fils_enable_send(mlme_obj,
+						       &fils_param);
+	}
 
 	return status;
 }
diff --git a/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mgr_tgt_if_tx_api.h b/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mgr_tgt_if_tx_api.h
index a0c8438..ddca045 100644
--- a/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mgr_tgt_if_tx_api.h
+++ b/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mgr_tgt_if_tx_api.h
@@ -221,6 +221,33 @@
 				struct vdev_mlme_obj *mlme_obj,
 				struct beacon_tmpl_params *param);
 
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
+/**
+ * tgt_vdev_mgr_fils_enable_send()- API to send fils enable command
+ * @mlme_obj: pointer to vdev_mlme_obj
+ * @param: pointer to config_fils_params struct
+ *
+ * Return: QDF_STATUS - Success or Failure
+ */
+QDF_STATUS tgt_vdev_mgr_fils_enable_send(
+				struct vdev_mlme_obj *mlme_obj,
+				struct config_fils_params *param);
+#else
+/**
+ * tgt_vdev_mgr_fils_enable_send()- API to send fils enable command
+ * @mlme_obj: pointer to vdev_mlme_obj
+ * @param: pointer to config_fils_params struct
+ *
+ * Return: QDF_STATUS - Success or Failure
+ */
+static inline QDF_STATUS tgt_vdev_mgr_fils_enable_send(
+				struct vdev_mlme_obj *mlme_obj,
+				struct config_fils_params *param)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif
+
 /**
  * tgt_vdev_mgr_multiple_vdev_restart_send() – API to send multiple vdev
  * restart
diff --git a/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mgr_tgt_if_tx_defs.h b/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mgr_tgt_if_tx_defs.h
index 9be9189..abc84f9 100644
--- a/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mgr_tgt_if_tx_defs.h
+++ b/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mgr_tgt_if_tx_defs.h
@@ -267,6 +267,21 @@
 	uint8_t peer_mac[QDF_MAC_ADDR_SIZE];
 };
 
+/* Default FILS DISCOVERY sent in period of 20TU */
+#define DEFAULT_FILS_DISCOVERY_PERIOD 20
+
+/**
+ * struct config_fils_params - FILS config params
+ * @vdev_id:  vdev id
+ * @fd_period:  0 - Disabled, non-zero - Period in ms (mili seconds)
+ * @send_prb_rsp_frame: send broadcast prb resp frame
+ */
+struct config_fils_params {
+	uint8_t vdev_id;
+	uint32_t fd_period;
+	uint32_t send_prb_rsp_frame: 1;
+};
+
 /**
  * struct config_ratemask_params - ratemask config parameters
  * @vdev_id: vdev id
diff --git a/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mgr_tgt_if_tx_api.c b/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mgr_tgt_if_tx_api.c
index bd6bc25..9a7bbe5 100644
--- a/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mgr_tgt_if_tx_api.c
+++ b/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mgr_tgt_if_tx_api.c
@@ -479,6 +479,33 @@
 	return QDF_STATUS_SUCCESS;
 }
 
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
+QDF_STATUS tgt_vdev_mgr_fils_enable_send(
+				struct vdev_mlme_obj *mlme_obj,
+				struct config_fils_params *param)
+{
+	QDF_STATUS status;
+	struct wlan_lmac_if_mlme_tx_ops *txops;
+	struct wlan_objmgr_vdev *vdev;
+	uint8_t vdev_id;
+
+	vdev = mlme_obj->vdev;
+	vdev_id = wlan_vdev_get_id(vdev);
+	txops = wlan_vdev_mlme_get_lmac_txops(vdev);
+	if (!txops || !txops->vdev_fils_enable_send) {
+		mlme_err("VDEV_%d: No Tx Ops fils Enable", vdev_id);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = txops->vdev_fils_enable_send(vdev, param);
+	if (QDF_IS_STATUS_ERROR(status))
+		mlme_err("VDEV_%d: Tx Ops fils Enable Error : %d",
+			 vdev_id, status);
+
+	return status;
+}
+#endif
+
 QDF_STATUS tgt_vdev_mgr_multiple_vdev_restart_send(
 				struct wlan_objmgr_pdev *pdev,
 				struct multiple_vdev_restart_params *param)
diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h
index 98f77f2..ddb4ee4 100644
--- a/wmi/inc/wmi_unified_api.h
+++ b/wmi/inc/wmi_unified_api.h
@@ -1900,6 +1900,19 @@
 			wmi_unified_t wmi_handle,
 			struct vdev_spectral_enable_params *param);
 
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
+/**
+ *  wmi_unified_vdev_fils_enable_cmd_send() - WMI send fils enable command
+ *  @param wmi_handle: handle to WMI.
+ *  @param config_fils_params: fils enable parameters
+ *
+ *  Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
+ */
+QDF_STATUS
+wmi_unified_vdev_fils_enable_cmd_send(struct wmi_unified *wmi_handle,
+				      struct config_fils_params *param);
+#endif
+
 /**
  *  wmi_unified_bss_chan_info_request_cmd_send() - WMI bss chan info
  *  request function
diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h
index 254e002..0d3584b 100644
--- a/wmi/inc/wmi_unified_param.h
+++ b/wmi/inc/wmi_unified_param.h
@@ -2792,16 +2792,6 @@
 };
 
 /**
- * struct config_fils_params - FILS config params
- * @vdev_id:  vdev id
- * @fd_period:  0 - Disabled, non-zero - Period in ms (mili seconds)
- */
-struct config_fils_params {
-	uint8_t vdev_id;
-	uint32_t fd_period;
-};
-
-/**
  * struct peer_add_wds_entry_params - WDS peer entry add params
  * @dest_addr: Pointer to destination macaddr
  * @peer_addr: Pointer to peer mac addr
diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h
index a487cd2..504cd1b 100644
--- a/wmi/inc/wmi_unified_priv.h
+++ b/wmi/inc/wmi_unified_priv.h
@@ -1890,10 +1890,11 @@
 		struct wmi_obss_detection_cfg_param *obss_cfg_param);
 QDF_STATUS (*extract_obss_detection_info)(uint8_t *evt_buf,
 					  struct wmi_obss_detect_info *info);
-
-#ifdef WLAN_SUPPORT_FILS
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
 QDF_STATUS (*send_vdev_fils_enable_cmd)(wmi_unified_t wmi_handle,
 					struct config_fils_params *param);
+#endif
+#ifdef WLAN_SUPPORT_FILS
 QDF_STATUS (*extract_swfda_vdev_id)(wmi_unified_t wmi_handle, void *evt_buf,
 				    uint32_t *vdev_id);
 QDF_STATUS (*send_fils_discovery_send_cmd)(wmi_unified_t wmi_handle,
diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c
index 160fcf1..422e5d7 100644
--- a/wmi/src/wmi_unified_api.c
+++ b/wmi/src/wmi_unified_api.c
@@ -2655,6 +2655,19 @@
 	return QDF_STATUS_E_FAILURE;
 }
 
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
+QDF_STATUS
+wmi_unified_vdev_fils_enable_cmd_send(struct wmi_unified *wmi_handle,
+				      struct config_fils_params *param)
+{
+	if (wmi_handle->ops->send_vdev_fils_enable_cmd)
+		return wmi_handle->ops->send_vdev_fils_enable_cmd(
+							wmi_handle, param);
+
+	return QDF_STATUS_E_FAILURE;
+}
+#endif
+
 #ifdef WLAN_SUPPORT_GREEN_AP
 QDF_STATUS wmi_extract_green_ap_egap_status_info(
 	wmi_unified_t wmi_handle, uint8_t *evt_buf,
diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c
index f0f4f32..71a8bb6 100644
--- a/wmi/src/wmi_unified_tlv.c
+++ b/wmi/src/wmi_unified_tlv.c
@@ -12132,6 +12132,42 @@
 		extract_obss_color_collision_info_tlv;
 }
 
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
+static QDF_STATUS
+send_vdev_fils_enable_cmd_send(struct wmi_unified *wmi_handle,
+			       struct config_fils_params *param)
+{
+	wmi_buf_t buf;
+	wmi_enable_fils_cmd_fixed_param *cmd;
+	uint8_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
+
+	buf = wmi_buf_alloc(wmi_handle, len);
+	if (!buf)
+		return QDF_STATUS_E_NOMEM;
+
+	cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(
+			buf);
+	WMITLV_SET_HDR(&cmd->tlv_header,
+		       WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
+		       WMITLV_GET_STRUCT_TLVLEN
+		       (wmi_enable_fils_cmd_fixed_param));
+	cmd->vdev_id = param->vdev_id;
+	cmd->fd_period = param->fd_period;
+	WMI_LOGD("%s: vdev id: %d fd_period: %d",
+		 __func__, cmd->vdev_id, cmd->fd_period);
+	wmi_mtrace(WMI_ENABLE_FILS_CMDID, cmd->vdev_id, cmd->fd_period);
+	if (wmi_unified_cmd_send(wmi_handle, buf, len,
+				 WMI_ENABLE_FILS_CMDID)) {
+		WMI_LOGE("%s: Sending FILS cmd failed, vdev_id: %d",
+			 __func__, param->vdev_id);
+		wmi_buf_free(buf);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+#endif
+
 #ifdef WLAN_CFR_ENABLE
 /**
  * extract_cfr_peer_tx_event_param_tlv() - Extract peer cfr tx event params
@@ -12619,6 +12655,9 @@
 	.extract_pdev_utf_event = extract_pdev_utf_event_tlv,
 	.wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
 	.extract_fips_event_data = extract_fips_event_data_tlv,
+#if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ)
+	.send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_send,
+#endif
 #ifdef WLAN_FEATURE_DISA
 	.extract_encrypt_decrypt_resp_event =
 				extract_encrypt_decrypt_resp_event_tlv,