Browse Source

qcacmn: Add LMAC interface for WIFI POS component

This change adds implementation for interfacing with LMAC for
southbound request to WMI and northbount events from WMI.

Change-Id: Ia027ec704d99ef586b89bfadce4f174c3bcf8c17
CRs-Fixed: 2003488
Naveen Rawat 8 years ago
parent
commit
18ceca16b7

+ 18 - 1
target_if/core/src/target_if_main.c

@@ -33,6 +33,10 @@
 #include "target_if_p2p.h"
 #endif
 
+#ifdef WIFI_POS_CONVERGED
+#include "target_if_wifi_pos.h"
+#endif
+
 static struct target_if_ctx *g_target_if_ctx;
 
 struct target_if_ctx *target_if_get_ctx()
@@ -100,6 +104,19 @@ static void target_if_atf_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
 }
 #endif /* WLAN_ATF_ENABLE */
 
+#ifdef WIFI_POS_CONVERGED
+static void target_if_wifi_pos_tx_ops_register(
+			struct wlan_lmac_if_tx_ops *tx_ops)
+{
+	target_if_wifi_pos_register_tx_ops(tx_ops);
+}
+#else
+static void target_if_wifi_pos_tx_ops_register(
+			struct wlan_lmac_if_tx_ops *tx_ops)
+{
+}
+#endif
+
 static
 QDF_STATUS target_if_register_umac_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
 {
@@ -108,6 +125,7 @@ QDF_STATUS target_if_register_umac_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
 
 	target_if_atf_tx_ops_register(tx_ops);
 
+	target_if_wifi_pos_tx_ops_register(tx_ops);
 	/* Converged UMAC components to register their TX-ops here */
 	return QDF_STATUS_SUCCESS;
 }
@@ -141,7 +159,6 @@ QDF_STATUS target_if_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
 {
 	/* Converged UMAC components to register their TX-ops */
 	target_if_register_umac_tx_ops(tx_ops);
-
 	/* Components parallel to UMAC to register their TX-ops here */
 	target_if_pmo_register_tx_ops_req(tx_ops);
 

+ 87 - 0
target_if/wifi_pos/inc/target_if_wifi_pos.h

@@ -24,4 +24,91 @@
 #ifndef _WIFI_POS_TGT_IF_H_
 #define _WIFI_POS_TGT_IF_H_
 
+#include "qdf_types.h"
+#include "qdf_status.h"
+struct oem_data_req;
+struct oem_data_rsp;
+struct wlan_objmgr_psoc;
+struct wlan_soc_southbound_cb;
+struct wlan_lmac_if_tx_ops;
+struct wlan_lmac_if_rx_ops;
+
+#ifdef WIFI_POS_CONVERGED
+
+/**
+ * target_if_wifi_pos_get_txops: api to get tx ops
+ * @psoc: pointer to psoc object
+ *
+ * Return: tx ops
+ */
+struct wlan_lmac_if_wifi_pos_tx_ops *target_if_wifi_pos_get_txops(
+						struct wlan_objmgr_psoc *psoc);
+
+/**
+ * target_if_wifi_pos_get_rxops: api to get rx ops
+ * @psoc: pointer to psoc object
+ *
+ * Return: rx ops
+ */
+struct wlan_lmac_if_wifi_pos_rx_ops *target_if_wifi_pos_get_rxops(
+						struct wlan_objmgr_psoc *psoc);
+
+/**
+ * target_if_wifi_pos_register_events: function to register with wmi event
+ * @psoc: pointer to psoc object
+ *
+ * Return: status of operation
+ */
+QDF_STATUS target_if_wifi_pos_register_events(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * target_if_wifi_pos_deregister_events: function to deregister wmi event
+ * @psoc: pointer to psoc object
+ *
+ * Return: status of operation
+ */
+QDF_STATUS target_if_wifi_pos_deregister_events(struct wlan_objmgr_psoc *psoc);
+
+
+/**
+ * target_if_wifi_pos_register_tx_ops: function to register with lmac tx ops
+ * @tx_ops: lmac tx ops struct object
+ *
+ * Return: none
+ */
+void target_if_wifi_pos_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
+
+/**
+ * target_if_wifi_pos_register_rx_ops: function to register with lmac rx ops
+ * @rx_ops: lmac rx ops struct object
+ *
+ * Return: none
+ */
+void target_if_wifi_pos_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops);
+
+#else
+static inline struct wlan_lmac_if_wifi_pos_tx_ops *target_if_wifi_pos_get_txops(
+						struct wlan_objmgr_psoc *psoc)
+{
+	return NULL;
+}
+
+
+static inline struct wlan_lmac_if_wifi_pos_rx_ops *target_if_wifi_pos_get_rxops(
+						struct wlan_objmgr_psoc *psoc)
+{
+	return NULL;
+}
+
+static inline void target_if_wifi_pos_register_tx_ops(
+					struct wlan_lmac_if_tx_ops *tx_ops)
+{
+}
+
+static inline void target_if_wifi_pos_register_rx_ops(
+					struct wlan_lmac_if_rx_ops *rx_ops)
+{
+}
+#endif
+
 #endif /* _WIFI_POS_TGT_IF_H_ */

+ 213 - 0
target_if/wifi_pos/src/target_if_wifi_pos.c

@@ -30,4 +30,217 @@
  * This file defines the functions pertinent to wifi positioning component's
  * target if layer.
  */
+#include "../../../../umac/wifi_pos/src/wifi_pos_utils_i.h"
+#include "wmi_unified_api.h"
+#include "wlan_lmac_if_def.h"
+#include "target_if_wifi_pos.h"
+#include "../../../../umac/wifi_pos/src/wifi_pos_main_i.h"
+#include "target_if.h"
 
+/**
+ * wifi_pos_oem_rsp_ev_handler: handler registered with WMI_OEM_RESPONSE_EVENTID
+ * @scn: scn handle
+ * @data_buf: event buffer
+ * @data_len: event buffer length
+ *
+ * Return: status of operation
+ */
+static int wifi_pos_oem_rsp_ev_handler(ol_scn_t scn,
+					uint8_t *data_buf,
+					uint32_t data_len)
+{
+	struct oem_data_rsp *oem_rsp = NULL;
+	struct wlan_objmgr_psoc *psoc = NULL;
+	struct wlan_lmac_if_wifi_pos_rx_ops *wifi_pos_rx_ops = NULL;
+
+	/* this will be implemented later */
+	if (!wifi_pos_rx_ops || !wifi_pos_rx_ops->oem_rsp_event_rx) {
+		wifi_pos_err("lmac callbacks not registered");
+		return QDF_STATUS_NOT_INITIALIZED;
+	}
+
+	return wifi_pos_rx_ops->oem_rsp_event_rx(psoc, oem_rsp);
+}
+
+/**
+ * wifi_pos_oem_cap_ev_handler: handler registered with wmi_oem_cap_event_id
+ * @scn: scn handle
+ * @buf: event buffer
+ * @len: event buffer length
+ *
+ * Return: status of operation
+ */
+static int wifi_pos_oem_cap_ev_handler(ol_scn_t scn, uint8_t *buf, uint32_t len)
+{
+	/* TBD */
+	return 0;
+}
+
+/**
+ * wifi_pos_oem_meas_rpt_ev_handler: handler registered with
+ * wmi_oem_meas_report_event_id
+ * @scn: scn handle
+ * @buf: event buffer
+ * @len: event buffer length
+ *
+ * Return: status of operation
+ */
+static int wifi_pos_oem_meas_rpt_ev_handler(ol_scn_t scn, uint8_t *buf,
+					    uint32_t len)
+{
+	/* TBD */
+	return 0;
+}
+
+/**
+ * wifi_pos_oem_err_rpt_ev_handler: handler registered with
+ * wmi_oem_err_report_event_id
+ * @scn: scn handle
+ * @buf: event buffer
+ * @len: event buffer length
+ *
+ * Return: status of operation
+ */
+static int wifi_pos_oem_err_rpt_ev_handler(ol_scn_t scn, uint8_t *buf,
+					    uint32_t len)
+{
+	/* TBD */
+	return 0;
+}
+
+/**
+ * wifi_pos_oem_data_req() - start OEM data request to target
+ * @wma_handle: wma handle
+ * @req: start request params
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS wifi_pos_oem_data_req(struct wlan_objmgr_psoc *psoc,
+					struct oem_data_req *req)
+{
+	QDF_STATUS status;
+	void *wmi_hdl = GET_WMI_HDL_FROM_PSOC(psoc);
+
+	wifi_pos_debug("Send oem data req to target");
+
+	if (!req || !req->data) {
+		wifi_pos_err("oem_data_req is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (!wmi_hdl) {
+		wifi_pos_err(FL("WMA closed, can't send oem data req cmd"));
+		return QDF_STATUS_E_INVAL;
+	}
+
+	status = wmi_unified_start_oem_data_cmd(wmi_hdl, req->data_len,
+						req->data);
+
+	if (!QDF_IS_STATUS_SUCCESS(status))
+		wifi_pos_err("wmi cmd send failed");
+
+	return status;
+}
+
+void target_if_wifi_pos_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
+{
+	struct wlan_lmac_if_wifi_pos_tx_ops *wifi_pos_tx_ops;
+	wifi_pos_tx_ops = &tx_ops->wifi_pos_tx_ops;
+	wifi_pos_tx_ops->data_req_tx = wifi_pos_oem_data_req;
+}
+
+void target_if_wifi_pos_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+	struct wlan_lmac_if_wifi_pos_rx_ops *wifi_pos_rx_ops;
+	wifi_pos_rx_ops = &rx_ops->wifi_pos_rx_ops;
+	wifi_pos_rx_ops->oem_rsp_event_rx = wifi_pos_oem_rsp_handler;
+}
+
+inline struct wlan_lmac_if_wifi_pos_tx_ops *target_if_wifi_pos_get_txops(
+						struct wlan_objmgr_psoc *psoc)
+{
+	if (!psoc) {
+		wifi_pos_err("passed psoc is NULL");
+		return NULL;
+	}
+
+	return &psoc->soc_cb.tx_ops.wifi_pos_tx_ops;
+}
+
+inline struct wlan_lmac_if_wifi_pos_rx_ops *target_if_wifi_pos_get_rxops(
+						struct wlan_objmgr_psoc *psoc)
+{
+	if (!psoc) {
+		wifi_pos_err("passed psoc is NULL");
+		return NULL;
+	}
+
+	return &psoc->soc_cb.rx_ops.wifi_pos_rx_ops;
+}
+
+QDF_STATUS target_if_wifi_pos_register_events(struct wlan_objmgr_psoc *psoc)
+{
+	int ret;
+
+	if (!psoc || !psoc->tgt_if_handle) {
+		wifi_pos_err("psoc or psoc->tgt_if_handle is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	ret = wmi_unified_register_event_handler(psoc->tgt_if_handle,
+					WMI_OEM_RESPONSE_EVENTID,
+					wifi_pos_oem_rsp_ev_handler,
+					WMI_RX_UMAC_CTX);
+	if (ret) {
+		wifi_pos_err("register_event_handler failed: err %d", ret);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	ret = wmi_unified_register_event_handler(psoc->tgt_if_handle,
+					wmi_oem_cap_event_id,
+					wifi_pos_oem_cap_ev_handler,
+					WMI_RX_UMAC_CTX);
+	if (ret) {
+		wifi_pos_err("register_event_handler failed: err %d", ret);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	ret = wmi_unified_register_event_handler(psoc->tgt_if_handle,
+					wmi_oem_meas_report_event_id,
+					wifi_pos_oem_meas_rpt_ev_handler,
+					WMI_RX_UMAC_CTX);
+	if (ret) {
+		wifi_pos_err("register_event_handler failed: err %d", ret);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	ret = wmi_unified_register_event_handler(psoc->tgt_if_handle,
+					wmi_oem_report_event_id,
+					wifi_pos_oem_err_rpt_ev_handler,
+					WMI_RX_UMAC_CTX);
+	if (ret) {
+		wifi_pos_err("register_event_handler failed: err %d", ret);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS target_if_wifi_pos_deregister_events(struct wlan_objmgr_psoc *psoc)
+{
+	if (!psoc || !psoc->tgt_if_handle) {
+		wifi_pos_err("psoc or psoc->tgt_if_handle is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	wmi_unified_unregister_event_handler(psoc->tgt_if_handle,
+					WMI_OEM_RESPONSE_EVENTID);
+	wmi_unified_unregister_event_handler(psoc->tgt_if_handle,
+					wmi_oem_cap_event_id);
+	wmi_unified_unregister_event_handler(psoc->tgt_if_handle,
+					wmi_oem_meas_report_event_id);
+	wmi_unified_unregister_event_handler(psoc->tgt_if_handle,
+					wmi_oem_report_event_id);
+
+	return QDF_STATUS_SUCCESS;
+}

+ 36 - 0
umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h

@@ -31,6 +31,12 @@
 /* Number of dev type: Direct attach and Offload */
 #define MAX_DEV_TYPE 2
 
+#ifdef WIFI_POS_CONVERGED
+/* forward declarations */
+struct oem_data_req;
+struct oem_data_rsp;
+#endif /* WIFI_POS_CONVERGED */
+
 /**
  * struct wlan_lmac_if_mgmt_txrx_tx_ops - structure of tx function
  *                  pointers for mgmt txrx component
@@ -312,6 +318,18 @@ struct wlan_lmac_if_atf_tx_ops {
 };
 #endif
 
+#ifdef WIFI_POS_CONVERGED
+/*
+ * struct wlan_lmac_if_wifi_pos_tx_ops - structure of firmware tx function
+ * pointers for wifi_pos component
+ * @data_req_tx: function pointer to send wifi_pos req to firmware
+ */
+struct wlan_lmac_if_wifi_pos_tx_ops {
+	QDF_STATUS (*data_req_tx)(struct wlan_objmgr_psoc *psoc,
+				  struct oem_data_req *req);
+};
+#endif
+
 /**
  * struct wlan_lmac_if_tx_ops - south bound tx function pointers
  * @mgmt_txrx_tx_ops: mgmt txrx tx ops
@@ -339,6 +357,9 @@ struct wlan_lmac_if_tx_ops {
 #ifdef WLAN_ATF_ENABLE
 	struct wlan_lmac_if_atf_tx_ops atf_tx_ops;
 #endif
+#ifdef WIFI_POS_CONVERGED
+	struct wlan_lmac_if_wifi_pos_tx_ops wifi_pos_tx_ops;
+#endif
 };
 
 /**
@@ -506,6 +527,18 @@ struct wlan_lmac_if_atf_rx_ops {
 };
 #endif
 
+#ifdef WIFI_POS_CONVERGED
+/**
+ * struct wlan_lmac_if_wifi_pos_rx_ops - structure of rx function
+ * pointers for wifi_pos component
+ * @oem_rsp_event_rx: callback for WMI_OEM_RESPONSE_EVENTID
+ */
+struct wlan_lmac_if_wifi_pos_rx_ops {
+	int (*oem_rsp_event_rx)(struct wlan_objmgr_psoc *psoc,
+				struct oem_data_rsp *oem_rsp);
+};
+#endif
+
 /**
  * struct wlan_lmac_if_rx_ops - south bound rx function pointers
  * @arg1
@@ -531,6 +564,9 @@ struct wlan_lmac_if_rx_ops {
 #ifdef WLAN_ATF_ENABLE
 	struct wlan_lmac_if_atf_rx_ops atf_rx_ops;
 #endif
+#ifdef WIFI_POS_CONVERGED
+	struct wlan_lmac_if_wifi_pos_rx_ops wifi_pos_rx_ops;
+#endif
 };
 
 /* Function pointer to call legacy tx_ops registration in OL/WMA.

+ 19 - 0
umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c

@@ -25,6 +25,9 @@
 #ifdef WLAN_ATF_ENABLE
 #include "wlan_atf_tgt_api.h"
 #endif
+#ifdef WIFI_POS_CONVERGED
+#include "target_if_wifi_pos.h"
+#endif /* WIFI_POS_CONVERGED */
 
 /* Function pointer for OL/WMA specific UMAC tx_ops
  * registration.
@@ -90,6 +93,19 @@ wlan_lmac_if_atf_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
 }
 #endif
 
+#ifdef WIFI_POS_CONVERGED
+static void wlan_lmac_if_umac_rx_ops_register_wifi_pos(
+				struct wlan_lmac_if_rx_ops *rx_ops)
+{
+	target_if_wifi_pos_register_rx_ops(rx_ops);
+}
+#else
+static void wlan_lmac_if_umac_rx_ops_register_wifi_pos(
+				struct wlan_lmac_if_rx_ops *rx_ops)
+{
+}
+#endif /* WIFI_POS_CONVERGED */
+
 /**
  * wlan_lmac_if_umac_rx_ops_register() - UMAC rx handler register
  * @rx_ops: Pointer to rx_ops structure to be populated
@@ -129,6 +145,9 @@ wlan_lmac_if_umac_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
 	rx_ops->scan.scan_ev_handler = tgt_scan_event_handler;
 	wlan_lmac_if_atf_rx_ops_register(rx_ops);
 
+	/* wifi_pos rx ops */
+	wlan_lmac_if_umac_rx_ops_register_wifi_pos(rx_ops);
+
 	return QDF_STATUS_SUCCESS;
 }
 

+ 25 - 0
umac/wifi_pos/inc/wifi_pos_api.h

@@ -148,6 +148,22 @@ QDF_STATUS wifi_pos_init(void);
  */
 QDF_STATUS wifi_pos_deinit(void);
 
+/**
+ * wifi_pos_psoc_enable: psoc enable API for wifi positioning component
+ * @psoc: pointer to PSOC
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * wifi_pos_psoc_disable: psoc disable API for wifi positioning component
+ * @psoc: pointer to PSOC
+ *
+ * Return: status of operation
+ */
+QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc);
+
 /**
  * wifi_pos_set_oem_target_type: public API to set param in wifi_pos private
  * object
@@ -271,6 +287,15 @@ static inline QDF_STATUS wifi_pos_deinit(void)
 	return QDF_STATUS_SUCCESS;
 }
 
+static inline QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
 #endif
 
 #endif

+ 20 - 0
umac/wifi_pos/src/wifi_pos_api.c

@@ -84,6 +84,26 @@ QDF_STATUS wifi_pos_deinit(void)
 	return QDF_STATUS_SUCCESS;
 }
 
+QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc)
+{
+	QDF_STATUS status = target_if_wifi_pos_register_events(psoc);
+
+	if (QDF_IS_STATUS_ERROR(status))
+		wifi_pos_err("target_if_wifi_pos_register_events failed");
+
+	return status;
+}
+
+QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc)
+{
+	QDF_STATUS status = target_if_wifi_pos_deregister_events(psoc);
+
+	if (QDF_IS_STATUS_ERROR(status))
+		wifi_pos_err("target_if_wifi_pos_deregister_events failed");
+
+	return QDF_STATUS_SUCCESS;
+}
+
 void wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc *psoc, uint32_t val)
 {
 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =

+ 18 - 0
umac/wifi_pos/src/wifi_pos_main.c

@@ -177,6 +177,24 @@ QDF_STATUS  wifi_pos_psoc_obj_destroyed_notification(
 	return status;
 }
 
+int wifi_pos_oem_rsp_handler(struct wlan_objmgr_psoc *psoc,
+			     struct oem_data_rsp *oem_rsp)
+{
+	struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
+					wifi_pos_get_psoc_priv_obj(psoc);
+	/* handle oem event here */
+	if (oem_rsp->rsp_len > OEM_DATA_RSP_SIZE) {
+		wifi_pos_err("invalid length of Oem Data response");
+		return -EINVAL;
+	}
+
+	wifi_pos_debug("sending oem data rsp, len: %d to pid: %d",
+			oem_rsp->rsp_len, wifi_pos_obj->app_pid);
+	wifi_pos_obj->wifi_pos_send_rsp(psoc, ANI_MSG_OEM_DATA_RSP,
+					oem_rsp->rsp_len, oem_rsp->data);
+	return 0;
+}
+
 #ifdef UMAC_REG_COMPONENT
 /* enable this when regulatory component gets merged */
 static void get_ch_info(struct wlan_objmgr_psoc *psoc,

+ 11 - 0
umac/wifi_pos/src/wifi_pos_main_i.h

@@ -54,4 +54,15 @@ QDF_STATUS wifi_pos_psoc_obj_created_notification(
  */
 QDF_STATUS  wifi_pos_psoc_obj_destroyed_notification(
 				struct wlan_objmgr_psoc *psoc, void *arg_list);
+
+/**
+ * wifi_pos_oem_rsp_handler: lmac rx ops registered
+ * @psoc: pointer to psoc object
+ * @oem_rsp: response from firmware
+ *
+ * Return: status of operation
+ */
+int wifi_pos_oem_rsp_handler(struct wlan_objmgr_psoc *psoc,
+			     struct oem_data_rsp *oem_rsp);
+
 #endif