123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- /*
- * Copyright (c) 2017-2018, 2020 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021, 2023 Qualcomm Innovation Center, Inc. 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
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
- /**
- * DOC: This file defines the important dispatcher APIs pertinent to
- * wifi positioning.
- */
- #include <wlan_lmac_if_def.h>
- #include "wifi_pos_utils_i.h"
- #include "wifi_pos_api.h"
- #include "wifi_pos_ucfg_i.h"
- #include "wlan_ptt_sock_svc.h"
- #ifndef CNSS_GENL
- #include <wlan_objmgr_psoc_obj.h>
- #include "wifi_pos_main_i.h"
- #endif
- #ifndef CNSS_GENL
- QDF_STATUS ucfg_wifi_psoc_get_pdev_id_by_dev_name(
- char *dev_name, uint8_t *pdev_id,
- struct wlan_objmgr_psoc **psoc)
- {
- struct wlan_objmgr_psoc *tmp_psoc = wifi_pos_get_psoc();
- struct wifi_pos_psoc_priv_obj *wifi_pos_psoc_obj;
- if (!tmp_psoc) {
- wifi_pos_err("psoc is null");
- return QDF_STATUS_E_NULL_VALUE;
- }
- wifi_pos_psoc_obj = wifi_pos_get_psoc_priv_obj(tmp_psoc);
- if (!wifi_pos_psoc_obj) {
- wifi_pos_err("wifi_pos_psoc_obj is null");
- return QDF_STATUS_E_NULL_VALUE;
- }
- if (!wifi_pos_psoc_obj->wifi_pos_get_pdev_id_by_dev_name) {
- wifi_pos_err("wifi_pos_get_pdev_id_by_dev_name is null");
- return QDF_STATUS_E_NULL_VALUE;
- }
- return wifi_pos_psoc_obj->wifi_pos_get_pdev_id_by_dev_name(
- dev_name, pdev_id, psoc);
- }
- #ifdef WLAN_RTT_MEASUREMENT_NOTIFICATION
- QDF_STATUS ucfg_wifi_pos_measurement_request_notification(
- struct wlan_objmgr_pdev *pdev,
- struct wifi_pos_req_msg *req)
- {
- struct wlan_objmgr_psoc *psoc = wifi_pos_get_psoc();
- struct wifi_pos_psoc_priv_obj *wifi_pos_psoc_obj;
- struct wlan_lmac_if_wifi_pos_tx_ops *tx_ops;
- struct rtt_channel_info chinfo = {0};
- if (!psoc) {
- wifi_pos_err("psoc is null");
- return QDF_STATUS_E_NULL_VALUE;
- }
- wifi_pos_psoc_obj = wifi_pos_get_psoc_priv_obj(psoc);
- if (!wifi_pos_psoc_obj) {
- wifi_pos_err("wifi_pos_psoc_obj is null");
- return QDF_STATUS_E_NULL_VALUE;
- }
- if (!wifi_pos_psoc_obj->wifi_pos_measurement_request_notification) {
- wifi_pos_debug("wifi_pos_measurement_request_notification is not registered");
- return QDF_STATUS_SUCCESS;
- }
- tx_ops = wifi_pos_get_tx_ops(psoc);
- if (!tx_ops) {
- wifi_pos_err("tx_ops null");
- return QDF_STATUS_E_NULL_VALUE;
- }
- if (!tx_ops->wifi_pos_parse_measreq_chan_info) {
- wifi_pos_err("wifi_pos_parse_measreq_chan_info is null");
- return QDF_STATUS_E_NULL_VALUE;
- }
- tx_ops->wifi_pos_parse_measreq_chan_info(pdev, req->buf_len, req->buf,
- &chinfo);
- if (!chinfo.freq) {
- wifi_pos_debug("Not a measurement request buffer, proceed");
- return QDF_STATUS_SUCCESS;
- }
- return wifi_pos_psoc_obj->wifi_pos_measurement_request_notification(
- pdev, &chinfo);
- }
- #endif /* WLAN_RTT_MEASUREMENT_NOTIFICATION */
- #endif
- QDF_STATUS ucfg_wifi_pos_process_req(struct wlan_objmgr_psoc *psoc,
- struct wifi_pos_req_msg *req,
- wifi_pos_send_rsp_handler send_rsp_cb)
- {
- uint8_t err;
- uint32_t app_pid;
- bool is_app_registered;
- struct wifi_pos_psoc_priv_obj *wifi_pos_psoc_obj;
- wifi_pos_debug("enter");
- wifi_pos_psoc_obj = wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
- if (!wifi_pos_psoc_obj) {
- wifi_pos_err("wifi_pos_psoc_obj is null");
- return QDF_STATUS_E_NULL_VALUE;
- }
- qdf_spin_lock_bh(&wifi_pos_psoc_obj->wifi_pos_lock);
- wifi_pos_psoc_obj->wifi_pos_send_rsp = send_rsp_cb;
- is_app_registered = wifi_pos_psoc_obj->is_app_registered;
- app_pid = wifi_pos_psoc_obj->app_pid;
- wifi_pos_psoc_obj->rsp_version = req->rsp_version;
- qdf_spin_unlock_bh(&wifi_pos_psoc_obj->wifi_pos_lock);
- if (!wifi_pos_psoc_obj->wifi_pos_req_handler) {
- wifi_pos_err("wifi_pos_psoc_obj->wifi_pos_req_handler is null");
- err = OEM_ERR_NULL_CONTEXT;
- send_rsp_cb(psoc, app_pid, WIFI_POS_CMD_ERROR, sizeof(err),
- &err);
- return QDF_STATUS_E_NULL_VALUE;
- }
- if (req->msg_type != WIFI_POS_CMD_REGISTRATION &&
- (!is_app_registered || app_pid != req->pid)) {
- wifi_pos_err("requesting app is not registered, app_registered: %d, requesting pid: %d, stored pid: %d",
- is_app_registered, req->pid, app_pid);
- err = OEM_ERR_APP_NOT_REGISTERED;
- send_rsp_cb(psoc, app_pid, WIFI_POS_CMD_ERROR, sizeof(err),
- &err);
- return QDF_STATUS_E_INVAL;
- }
- return wifi_pos_psoc_obj->wifi_pos_req_handler(psoc, req);
- }
- uint32_t ucfg_wifi_pos_get_ftm_cap(struct wlan_objmgr_psoc *psoc)
- {
- uint32_t val = 0;
- struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
- wifi_pos_get_psoc_priv_obj(psoc);
- if (!wifi_pos_psoc) {
- wifi_pos_alert("unable to get wifi_pos psoc obj");
- return val;
- }
- qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
- val = wifi_pos_psoc->fine_time_meas_cap;
- qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
- return val;
- }
- void ucfg_wifi_pos_set_ftm_cap(struct wlan_objmgr_psoc *psoc, uint32_t val)
- {
- struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
- wifi_pos_get_psoc_priv_obj(psoc);
- if (!wifi_pos_psoc) {
- wifi_pos_alert("unable to get wifi_pos psoc obj");
- return;
- }
- qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
- wifi_pos_psoc->fine_time_meas_cap = val;
- qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
- }
- void ucfg_wifi_pos_set_oem_6g_supported(struct wlan_objmgr_psoc *psoc,
- bool val)
- {
- struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
- wifi_pos_get_psoc_priv_obj(psoc);
- if (!wifi_pos_psoc) {
- wifi_pos_alert("unable to get wifi_pos psoc obj");
- return;
- }
- qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
- wifi_pos_psoc->oem_6g_support_disable = val;
- qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
- }
- bool ucfg_wifi_pos_is_nl_rsp(struct wlan_objmgr_psoc *psoc)
- {
- uint32_t val = 0;
- struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = NULL;
- struct wlan_objmgr_psoc *tmp_psoc = wifi_pos_get_psoc();
- if (tmp_psoc)
- wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(tmp_psoc);
- if (!wifi_pos_psoc) {
- wifi_pos_alert("unable to get wifi_pos psoc obj");
- return false;
- }
- qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
- val = wifi_pos_psoc->rsp_version;
- qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
- if (val == WIFI_POS_RSP_V2_NL)
- return true;
- else
- return false;
- }
|