qcacmn: Add support for target interface for components

Add support for target interface for components.

Change-Id: Id9d642a3369aa881a56a54ff99af135c3feb6584
CRs-Fixed: 2002100
This commit is contained in:
Mukul Sharma 2017-01-20 21:03:03 +05:30 committed by Amar Singhal
parent 4e411106c5
commit 4c303439a7
2 changed files with 212 additions and 0 deletions

View File

@ -0,0 +1,117 @@
/*
* Copyright (c) 2017 The Linux Foundation. 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 target interface shall be used
* to communicate with target using WMI.
*/
#ifndef _WLAN_TARGET_IF_H_
#define _WLAN_TARGET_IF_H_
#include "qdf_types.h"
#include "qdf_util.h"
#include "wlan_objmgr_psoc_obj.h"
/* ASCII "TGT\0" */
#define TGT_MAGIC 0x54575400
#define target_if_log(level, args...) \
QDF_TRACE(QDF_MODULE_ID_TARGET_IF, level, ## args)
#define target_if_logfl(level, format, args...) \
target_if_log(level, FL(format), ## args)
#define target_if_fatal(format, args...) \
target_if_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args)
#define target_if_err(format, args...) \
target_if_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args)
#define target_if_warn(format, args...) \
target_if_logfl(QDF_TRACE_LEVEL_WARN, format, ## args)
#define target_if_info(format, args...) \
target_if_logfl(QDF_TRACE_LEVEL_INFO, format, ## args)
#define target_if_debug(format, args...) \
target_if_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args)
#define TARGET_IF_ENTER() target_if_logfl(QDF_TRACE_LEVEL_INFO, "enter")
#define TARGET_IF_EXIT() target_if_logfl(QDF_TRACE_LEVEL_INFO, "exit")
#define GET_WMI_HDL_FROM_PSOC(psoc) (psoc->tgt_if_handle)
typedef struct wlan_objmgr_psoc *(*get_psoc_handle_callback)(
void *scn_handle);
/**
* struct target_if_ctx - target_interface context
* @magic: magic for target if ctx
* @get_wmi_handle: function pointer to get wmi handle
* @lock: spin lock for protecting the ctx
*/
struct target_if_ctx {
uint32_t magic;
get_psoc_handle_callback get_psoc_hdl_cb;
qdf_spinlock_t lock;
};
/**
* target_if_open() - target_if open
* @get_wmi_handle: function pointer to get wmi handle
*
*
* Return: QDF_STATUS
*/
QDF_STATUS target_if_open(get_psoc_handle_callback psoc_hdl_cb);
/**
* target_if_close() - Close target_if
* @scn_handle: scn handle
*
* Return: QDF_STATUS_SUCCESS - in case of success
*/
QDF_STATUS target_if_close(void);
/**
* wlan_get_tgt_if_ctx() -Get target if ctx
*
* Return: target if ctx
*/
struct target_if_ctx *target_if_get_ctx(void);
/**
* target_if_get_psoc_from_scn_hdl() - get psoc from scn handle
* @scn_handle: scn handle
*
* This API is generally used while processing wmi event.
* In wmi event SCN handle will be passed by wmi hence
* using this API we can get psoc from scn handle.
*
* Return: index for matching scn handle
*/
struct wlan_objmgr_psoc *target_if_get_psoc_from_scn_hdl(void *scn_handle);
/** target_if_register_tx_ops() - register tx_ops
* @tx_ops: tx_ops structure
*
* This function is to be used by components to populate
* the OL function pointers (tx_ops) required by the component
* for UMAC-LMAC interaction, with the appropriate handler
*
* Return: QDF STATUS
*/
QDF_STATUS target_if_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
#endif

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 2017 The Linux Foundation. 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: API for interacting with target interface.
*
*/
#include "target_if.h"
static struct target_if_ctx *g_target_if_ctx;
struct target_if_ctx *target_if_get_ctx()
{
return g_target_if_ctx;
}
struct wlan_objmgr_psoc *target_if_get_psoc_from_scn_hdl(void *scn_handle)
{
struct wlan_objmgr_psoc *psoc;
qdf_spin_lock_bh(&g_target_if_ctx->lock);
if (scn_handle && g_target_if_ctx->get_psoc_hdl_cb)
psoc = g_target_if_ctx->get_psoc_hdl_cb(scn_handle);
else
psoc = NULL;
qdf_spin_unlock_bh(&g_target_if_ctx->lock);
return psoc;
}
EXPORT_SYMBOL(target_if_get_psoc_from_scn_hdl);
QDF_STATUS target_if_open(get_psoc_handle_callback psoc_hdl_cb)
{
g_target_if_ctx = qdf_mem_malloc(sizeof(*g_target_if_ctx));
if (!g_target_if_ctx) {
target_if_err("Cannot allocate target if ctx");
QDF_ASSERT(0);
return QDF_STATUS_E_NOMEM;
}
qdf_spinlock_create(&g_target_if_ctx->lock);
qdf_spin_lock_bh(&g_target_if_ctx->lock);
g_target_if_ctx->magic = TGT_MAGIC;
g_target_if_ctx->get_psoc_hdl_cb = psoc_hdl_cb;
qdf_spin_unlock_bh(&g_target_if_ctx->lock);
return QDF_STATUS_SUCCESS;
}
EXPORT_SYMBOL(target_if_open);
QDF_STATUS target_if_close(void)
{
if (!g_target_if_ctx) {
QDF_ASSERT(0);
target_if_err("target if ctx is null");
return QDF_STATUS_E_INVAL;
}
qdf_spin_lock_bh(&g_target_if_ctx->lock);
g_target_if_ctx->magic = 0;
g_target_if_ctx->get_psoc_hdl_cb = NULL;
qdf_spin_unlock_bh(&g_target_if_ctx->lock);
qdf_spinlock_destroy(&g_target_if_ctx->lock);
qdf_mem_free(g_target_if_ctx);
g_target_if_ctx = NULL;
return QDF_STATUS_SUCCESS;
}
EXPORT_SYMBOL(target_if_close);
QDF_STATUS target_if_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
{
return QDF_STATUS_SUCCESS;
}
EXPORT_SYMBOL(target_if_register_tx_ops);