qcacmn: Support for SWFDA Event & FD Frame tx

Add new WMI EVENT, SW FILS Discovery Alert Event, to get
firmware trigger to transmit FILS Discovery Frames.
Add WMI command to send FD frame buffer to firwmare.
Add WMI command to set FD period interval in mili seconds.

Change-Id: I8cb6279ec4431b9236bd32c548228a0dc6598664
CRs-Fixed: 2118098
diff --git a/umac/cmn_services/inc/wlan_cmn.h b/umac/cmn_services/inc/wlan_cmn.h
index b28b3d0..4ab2a1d 100644
--- a/umac/cmn_services/inc/wlan_cmn.h
+++ b/umac/cmn_services/inc/wlan_cmn.h
@@ -123,6 +123,7 @@
  * @WLAN_UMAC_COMP_DISA:          DISA encryption test
  * @WLAN_UMAC_COMP_GREEN_AP:      Green AP
  * @WLAN_UMAC_COMP_FTM:           FTM component
+ * @WLAN_UMAC_COMP_FD:            FILS Discovery
  *
  * @WLAN_UMAC_COMP_ID_MAX:        Maximum components in UMAC
  *
@@ -154,6 +155,7 @@
 	WLAN_UMAC_COMP_DISA,
 	WLAN_UMAC_COMP_GREEN_AP,
 	WLAN_UMAC_COMP_FTM,
+	WLAN_UMAC_COMP_FD,
 	WLAN_UMAC_COMP_ID_MAX,
 };
 
diff --git a/umac/cmn_services/mgmt_txrx/dispatcher/inc/wlan_mgmt_txrx_utils_api.h b/umac/cmn_services/mgmt_txrx/dispatcher/inc/wlan_mgmt_txrx_utils_api.h
index dcedf47..a806de4 100644
--- a/umac/cmn_services/mgmt_txrx/dispatcher/inc/wlan_mgmt_txrx_utils_api.h
+++ b/umac/cmn_services/mgmt_txrx/dispatcher/inc/wlan_mgmt_txrx_utils_api.h
@@ -753,6 +753,23 @@
 					  qdf_nbuf_t buf,
 					  enum wlan_umac_comp_id comp_id);
 
+#ifdef WLAN_SUPPORT_FILS
+/**
+ * wlan_mgmt_txrx_fd_action_frame_tx() - transmits mgmt. FD Action frame
+ * @vdev: vdev object
+ * @buf: buffer to be transmitted
+ * @comp_id: umac component id
+ *
+ * This function transmits the FILS Dicovery Action frame to
+ * southbound interface.
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success
+ */
+QDF_STATUS wlan_mgmt_txrx_fd_action_frame_tx(struct wlan_objmgr_vdev *vdev,
+					     qdf_nbuf_t buf,
+					     enum wlan_umac_comp_id comp_id);
+#endif /* WLAN_SUPPORT_FILS */
+
 /**
  * wlan_mgmt_txrx_register_rx_cb() - registers the rx cb for mgmt. frames
  * @psoc: psoc context
diff --git a/umac/cmn_services/mgmt_txrx/dispatcher/src/wlan_mgmt_txrx_utils_api.c b/umac/cmn_services/mgmt_txrx/dispatcher/src/wlan_mgmt_txrx_utils_api.c
index b9473a6..bda9619 100644
--- a/umac/cmn_services/mgmt_txrx/dispatcher/src/wlan_mgmt_txrx_utils_api.c
+++ b/umac/cmn_services/mgmt_txrx/dispatcher/src/wlan_mgmt_txrx_utils_api.c
@@ -479,6 +479,41 @@
 	return QDF_STATUS_SUCCESS;
 }
 
+#ifdef WLAN_SUPPORT_FILS
+QDF_STATUS
+wlan_mgmt_txrx_fd_action_frame_tx(struct wlan_objmgr_vdev *vdev,
+				  qdf_nbuf_t buf,
+				  enum wlan_umac_comp_id comp_id)
+{
+	struct wlan_objmgr_psoc *psoc;
+	uint32_t vdev_id;
+
+	if (!vdev) {
+		mgmt_txrx_err("Invalid vdev");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+	vdev_id = wlan_vdev_get_id(vdev);
+	psoc = wlan_vdev_get_psoc(vdev);
+	if (!psoc) {
+		mgmt_txrx_err("psoc unavailable for vdev %d", vdev_id);
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	if (!psoc->soc_cb.tx_ops.mgmt_txrx_tx_ops.fd_action_frame_send) {
+		mgmt_txrx_err("mgmt txrx txop to send fd action frame is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	if (psoc->soc_cb.tx_ops.mgmt_txrx_tx_ops.fd_action_frame_send(
+			vdev, buf)) {
+		mgmt_txrx_err("FD send fail for vdev %d", vdev_id);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+#endif /* WLAN_SUPPORT_FILS */
+
 /**
  * wlan_mgmt_txrx_create_rx_handler() - creates rx handler node for umac comp.
  * @mgmt_txrx_psoc_ctx: mgmt txrx context
diff --git a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
index 3c3da3a..01dbfdd 100644
--- a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
+++ b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_cmn.h
@@ -204,6 +204,7 @@
  * @WLAN_DIRECT_BUF_RX_ID:      Direct Buffer Receive operations
  * @WLAN_DISA_ID:               DISA (encryption test) operations
  * @WLAN_FTM_ID:                FTM module
+ * @WLAN_FD_ID:                 FILS Discovery
  * @WLAN_REF_ID_MAX:            Max id used to generate ref count tracking array
  */
  /* New value added to the enum must also be reflected in function
@@ -243,6 +244,7 @@
 	WLAN_DIRECT_BUF_RX_ID = 30,
 	WLAN_DISA_ID          = 31,
 	WLAN_FTM_ID           = 31,
+	WLAN_FD_ID            = 33,
 	WLAN_REF_ID_MAX,
 } wlan_objmgr_ref_dbgid;
 
@@ -289,6 +291,7 @@
 					"WLAN_DIRECT_BUF_RX_ID",
 					"WLAN_DISA_ID",
 					"WLAN_FTM_ID",
+					"WLAN_FD_ID",
 					"WLAN_REF_ID_MAX" };
 
 	return (char *)strings[id];
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 98ca158..59916f0 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
@@ -76,6 +76,7 @@
  *                  pointers for mgmt txrx component
  * @mgmt_tx_send: function pointer to transmit mgmt tx frame
  * @beacon_send:  function pointer to transmit beacon frame
+ * @fd_action_frame_send: function pointer to transmit FD action frame
  */
 struct wlan_lmac_if_mgmt_txrx_tx_ops {
 	QDF_STATUS (*mgmt_tx_send)(struct wlan_objmgr_vdev *vdev,
@@ -83,6 +84,8 @@
 			void *mgmt_tx_params);
 	QDF_STATUS (*beacon_send)(struct wlan_objmgr_vdev *vdev,
 			qdf_nbuf_t nbuf);
+	QDF_STATUS (*fd_action_frame_send)(struct wlan_objmgr_vdev *vdev,
+					   qdf_nbuf_t nbuf);
 };
 
 /**
@@ -263,6 +266,21 @@
 };
 #endif
 
+#ifdef WLAN_SUPPORT_FILS
+/**
+ * struct wlan_lmac_if_fd_tx_ops - FILS Discovery specific Tx function pointers
+ * @fd_vdev_config_fils:         Enable and configure FILS Discovery
+ * @fd_register_event_handler:   Register swfda WMI event handler
+ * @fd_unregister_event_handler: Un-register swfda WMI event handler
+ */
+struct wlan_lmac_if_fd_tx_ops {
+	QDF_STATUS (*fd_vdev_config_fils)(struct wlan_objmgr_vdev *vdev,
+					  uint32_t fd_period);
+	void (*fd_register_event_handler)(struct wlan_objmgr_psoc *psoc);
+	void (*fd_unregister_event_handler)(struct wlan_objmgr_psoc *psoc);
+};
+#endif
+
 #ifdef WLAN_SA_API_ENABLE
 
 /**
@@ -638,6 +656,10 @@
 #ifdef CONVERGED_TDLS_ENABLE
 	struct wlan_lmac_if_tdls_tx_ops tdls_tx_ops;
 #endif
+
+#ifdef WLAN_SUPPORT_FILS
+	struct wlan_lmac_if_fd_tx_ops fd_tx_ops;
+#endif
 	 struct wlan_lmac_if_mlme_tx_ops mops;
 	 struct wlan_lmac_if_target_tx_ops target_tx_ops;
 
@@ -827,6 +849,24 @@
 };
 #endif
 
+#ifdef WLAN_SUPPORT_FILS
+/**
+ * struct wlan_lmac_if_fd_rx_ops - FILS Discovery specific Rx function pointers
+ * @fd_alloc:               Allocate FD buffer
+ * @fd_stop:                Stop and free deferred FD buffer
+ * @fd_free:                Free FD frame buffer
+ * @fd_get_valid_fd_period: Get valid FD period
+ * @fd_swfda_handler:       SWFDA event handler
+ */
+struct wlan_lmac_if_fd_rx_ops {
+	void (*fd_alloc)(struct wlan_objmgr_vdev *vdev);
+	void (*fd_stop)(struct wlan_objmgr_vdev *vdev);
+	void (*fd_free)(struct wlan_objmgr_vdev *vdev);
+	uint32_t (*fd_get_valid_fd_period)(struct wlan_objmgr_vdev *vdev);
+	QDF_STATUS (*fd_swfda_handler)(struct wlan_objmgr_vdev *vdev);
+};
+#endif
+
 #ifdef WLAN_SA_API_ENABLE
 
 /**
@@ -1096,6 +1136,11 @@
 #ifdef CONVERGED_TDLS_ENABLE
 	struct wlan_lmac_if_tdls_rx_ops tdls_rx_ops;
 #endif
+
+#ifdef WLAN_SUPPORT_FILS
+	struct wlan_lmac_if_fd_rx_ops fd_rx_ops;
+#endif
+
 	struct wlan_lmac_if_mlme_rx_ops mops;
 
 #ifdef WLAN_SUPPORT_GREEN_AP
diff --git a/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c b/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
index b2670b8..245d57a 100644
--- a/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
+++ b/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c
@@ -58,6 +58,10 @@
 #endif
 #include <wlan_ftm_ucfg_api.h>
 
+#ifdef WLAN_SUPPORT_FILS
+#include <wlan_fd_tgt_api.h>
+#endif
+
 /* Function pointer for OL/WMA specific UMAC tx_ops
  * registration.
  */
@@ -122,6 +126,25 @@
 }
 #endif
 
+#ifdef WLAN_SUPPORT_FILS
+static void
+wlan_lmac_if_fd_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+	struct wlan_lmac_if_fd_rx_ops *fd_rx_ops = &rx_ops->fd_rx_ops;
+
+	fd_rx_ops->fd_alloc = tgt_fd_alloc;
+	fd_rx_ops->fd_stop = tgt_fd_stop;
+	fd_rx_ops->fd_free = tgt_fd_free;
+	fd_rx_ops->fd_get_valid_fd_period = tgt_fd_get_valid_fd_period;
+	fd_rx_ops->fd_swfda_handler = tgt_fd_swfda_handler;
+}
+#else
+static void
+wlan_lmac_if_fd_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+}
+#endif
+
 #ifdef WLAN_SA_API_ENABLE
 /**
  * wlan_lmac_if_sa_api_rx_ops_register() - Function to register SA_API RX ops.
@@ -406,6 +429,9 @@
 	/* FTM rx_ops */
 	wlan_lmac_if_umac_ftm_rx_ops_register(rx_ops);
 
+	/* FILS Discovery */
+	wlan_lmac_if_fd_rx_ops_register(rx_ops);
+
 	return QDF_STATUS_SUCCESS;
 }