diff --git a/iot_sim/Kbuild b/iot_sim/Kbuild new file mode 100644 index 0000000000..7e98265df2 --- /dev/null +++ b/iot_sim/Kbuild @@ -0,0 +1,150 @@ +ifeq ($(obj),) +obj := . +endif + +DEPTH := ../.. + +include $(obj)/$(DEPTH)/os/linux/Makefile-linux.common + +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/inc -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/obj_mgr/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/cmn_defs/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/utils/nlink/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/scan/dispatcher/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/cmn_defs/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/global_umac_dispatcher/lmac_if/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/scheduler/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/global_lmac_if/inc +INCS += -I$(obj)/$(DEPTH)/umac/scan +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/mgmt_txrx/dispatcher/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/regulatory/dispatcher/inc +INCS += -I$(obj)/$(DEPTH)/umac/son/dispatcher/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/dfs/dispatcher/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/os_if/linux/scan/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/target_if/direct_buf_rx/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/wbuff/inc +INCS += -I$(obj)/$(DEPTH)/cmn_dev/cfg/inc +INCS += -I$(obj)/$(DEPTH)/ini_cfg/inc/ +INCS += -I$(obj)/$(DEPTH)/component_dev/wmi/inc +INCS += -I$(obj)/$(DEPTH)/pld/inc +INCS += -I$(obj)/$(DEPTH)/component_dev/dp/inc + +ifeq ($(WLAN_CONV_CRYPTO_SUPPORTED), 1) +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/crypto/inc +INCS += -I$(obj)/$(DEPTH)/component_dev/crypto/inc +endif + +ifeq ($(WLAN_SUPPORT_GREEN_AP), 1) +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/green_ap/dispatcher/inc +endif + +#Start of offload related deifines +HOST_CMN_CONVG_SRC := $(DEPTH)/cmn_dev + +INCS += -I$(obj)/$(DEPTH)/include -I$(obj)/$(DEPTH)/umac/include \ + -I$(obj)/$(DEPTH)/umac/crypto \ + -I$(obj)/$(DEPTH)/umac/scan -I$(obj)/$(DEPTH)/umac/resmgr \ + -I$(obj)/$(DEPTH)/umac/pm -I$(obj)/$(DEPTH)/umac/txrx \ + -I$(obj)/$(DEPTH)/umac/acs -I$(obj)/$(DEPTH)/umac/txbf \ + -I$(obj)/$(DEPTH)/umac/wnm \ + -I$(obj)/$(DEPTH)/umac/tdls \ + -I$(obj)/$(DEPTH)/umac/rpt_placement \ + -I$(obj)/$(DEPTH)/umac/wifipos \ + -I$(obj)/$(DEPTH)/umac/wds -I$(obj)/$(DEPTH)/umac/ique \ + -I$(obj)/$(DEPTH)/umac/vi_dbg \ + -I$(obj)/$(DEPTH)/umac/smart_antenna \ + -I$(obj)/$(DEPTH)/umac/smart_ant \ + -I$(obj)/$(DEPTH)/umac/ald \ + -I$(obj)/$(DEPTH)/lmac/ath_pktlog \ + -I$(obj)/$(DEPTH)/os/linux/mem/ \ + -I$(obj)/$(DEPTH)/umac/base \ + -I$(obj)/$(DEPTH)/qca_ol \ + -I$(obj)/$(DEPTH)/cmn_dev/qdf/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/qdf/linux/src \ + -I$(obj)/$(DEPTH)/cmn_dev/qal/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/qal/linux/src \ + -I$(obj)/$(DEPTH)/cmn_dev/hif \ + -I$(obj)/$(DEPTH)/cmn_dev/hif/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/hif/src \ + -I$(obj)/$(DEPTH)/cmn_dev/hif/src/ce \ + -I$(obj)/$(DEPTH)/cmn_dev/hif/src/pcie \ + -I$(obj)/$(DEPTH)/cmn_dev/hif/src/snoc \ + -I$(obj)/$(DEPTH)/cmn_dev/hif/src/dispatcher \ + -I$(obj)/$(DEPTH)/cmn_dev/pld_stub/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/hal/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/hal/wifi3.0 \ + -I$(obj)/$(DEPTH)/cmn_dev/dp/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/dp/wifi3.0 \ + -I$(obj)/$(DEPTH)/cmn_dev/wlan_cfg \ + -I$(obj)/$(HOST_CMN_CONVG_SRC)/htc \ + -I$(obj)/$(DEPTH)/cmn_dev/wmi/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/obj_mgr/inc \ + -I$(obj)/$(HOST_CMN_CONVG_SRC)/scheduler/inc \ + -I$(obj)/$(HOST_CMN_CONVG_SRC)/init_deinit/dispatcher/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/global_umac_dispatcher/lmac_if/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/mgmt_txrx/dispatcher/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/target_if/init_deinit/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/global_lmac_if/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/os_if/linux \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/cmn_defs/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/target_if/core/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/scan/dispatcher/inc \ + -I$(obj)/$(DEPTH)/umac/scan \ + -I$(obj)/$(DEPTH)/cmn_dev/ol_if \ + -I$(obj)/$(DEPTH)/cmn_dev/target_if/scan/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/cmn_services/serialization/core/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/regulatory/dispatcher/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/target_if/regulatory/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/mlme/mlme_objmgr/dispatcher/inc/ \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/mlme/vdev_mgr/dispatcher/inc \ + -I$(obj)/$(DEPTH)/cmn_dev/umac/mlme/pdev_mgr/dispatcher/inc \ + -I$(obj)/$(DEPTH)/direct_attach/hal/linux \ + +#INCS += -I$(obj)/$(DEPTH)/cmn_dev/target_if/iot_sim +INCS += -I$(obj)/$(DEPTH)/cmn_dev/wmi/inc +#end of offload related defines + +ifeq ($(QCA_CFR_SUPPORT), 1) +ccflags-y+= -DWLAN_CFR_ENABLE=1 +INCS += -I$(obj)/$(DEPTH)/cmn_dev/umac/cfr/dispatcher/inc/ +INCS += -I$(obj)/$(DEPTH)/component_dev/umac/cfr/dispatcher/inc +INCS += -I$(obj)/$(DEPTH)/component_dev/qal/inc +endif + +INCS += -I$(obj)/$(DEPTH)/cmn_dev/iot_sim/core +INCS += -I$(obj)/$(DEPTH)/cmn_dev/iot_sim/dispatcher/inc + +obj-m += qca_iot_sim.o + +ccflags-y+= $(INCS) $(COPTS) + +ifeq ($(strip ${QCA_PARTNER_MAKE_F_SUPPORT}),1) +MOD_CFLAGS = -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(qca_iot_sim.mod)" -D"KBUILD_MODNAME=KBUILD_STR(qca_iot_sim)" +endif + +IOT_SIM_TIF_OBJS += + +IOT_SIM_CMN_OBJS += core/iot_sim_common.o \ + dispatcher/src/wlan_iot_sim_utils_api.o \ + dispatcher/src/wlan_iot_sim_tgt_api.o \ + core/iot_sim_module.o + +qca_iot_sim-objs += ${IOT_SIM_CMN_OBJS} \ + ${IOT_SIM_TIF_OBJS} + +ifeq ($(strip ${QCA_PARTNER_MAKE_F_SUPPORT}),1) +all: qca_iot_sim.ko + +qca_iot_sim.mod.o: qca_iot_sim.mod.c + ${CC} -c -o $@ ${ccflags-y} ${MOD_CFLAGS} $< + +qca_iot_sim.o: ${qca_iot_sim-objs} + $(LD) -m elf32btsmip -r -o qca_iot_sim.o $(qca_iot_sim-objs) + $(KERNELPATH)/scripts/mod/modpost qca_iot_sim.o + +qca_iot_sim.ko: qca_iot_sim.o qca_iot_sim.mod.o + $(LD) -o qca_iot_sim.ko qca_iot_sim.o qca_iot_sim.mod.o + +%.o: %.c + ${CC} -c -o $@ ${ccflags-y} $< +endif diff --git a/iot_sim/core/iot_sim_cmn_api_i.h b/iot_sim/core/iot_sim_cmn_api_i.h new file mode 100644 index 0000000000..0ee0010d5f --- /dev/null +++ b/iot_sim/core/iot_sim_cmn_api_i.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020, 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. + */ + +#ifndef _IOT_SIM_CMN_API_I_H_ +#define _IOT_SIM_CMN_API_I_H_ + +#include "iot_sim_defs_i.h" + +/* + * wlan_iot_sim_psoc_obj_create_handler() - handler for psoc object create + * @psoc: reference to global psoc object + * @arg: reference to argument provided during registration of handler + * + * This is a handler to indicate psoc object created. Hence iot_sim_context + * object can be created and attached to psoc component list. + * + * Return: QDF_STATUS_SUCCESS on success + * QDF_STATUS_E_FAILURE if psoc is null + * QDF_STATUS_E_NOMEM on failure of iot_sim object allocation + */ +QDF_STATUS wlan_iot_sim_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, + void *arg); + +/* + * wlan_iot_sim_psoc_obj_destroy_handler() - handler for psoc object delete + * @psoc: reference to global psoc object + * @arg: reference to argument provided during registration of handler + * + * This is a handler to indicate psoc object going to be deleted. + * Hence iot_sim_context object can be detached from psoc component list. + * Then iot_sim_context object can be deleted. + * + * Return: QDF_STATUS_SUCCESS on success + * QDF_STATUS_E_FAILURE on failure + */ +QDF_STATUS wlan_iot_sim_psoc_obj_destroy_handler(struct wlan_objmgr_psoc *psoc, + void *arg); + +/* + * iot_sim_get_ctx_from_pdev() - API to get iot_sim context object + * from pdev + * @pdev : Reference to psoc global object + * + * This API used to get iot sim context object from global psoc reference. + * Null check should be done before invoking this inline function. + * + * Return : Reference to iot_sim_context object + * + */ +static inline struct iot_sim_context * +iot_sim_get_ctx_from_psoc(struct wlan_objmgr_psoc *psoc) +{ + struct iot_sim_context *isc = NULL; + + if (psoc) { + isc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_IOT_SIM_COMP); + } + + return isc; +} + +#endif /* _IOT_SIM_CMN_API_I_H_ */ diff --git a/iot_sim/core/iot_sim_common.c b/iot_sim/core/iot_sim_common.c new file mode 100644 index 0000000000..06499adcd1 --- /dev/null +++ b/iot_sim/core/iot_sim_common.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2020, 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. + */ + +#include "iot_sim_cmn_api_i.h" +#include +#include + +QDF_STATUS +iot_sim_control_cmn(struct wlan_objmgr_psoc *psoc, wbuf_t wbuf) +{ + QDF_STATUS status = QDF_STATUS_E_FAILURE; + struct iot_sim_context *isc; + + if (!psoc) { + iot_sim_err("PDEV is NULL!"); + goto bad; + } + + isc = iot_sim_get_ctx_from_psoc(psoc); + if (!isc) { + iot_sim_err("iot_sim context is NULL!"); + goto bad; + } + + status = QDF_STATUS_SUCCESS; +bad: + return status; +} + +/** + * iot_sim_ctx_deinit() - De-initialize function pointers from iot_sim context + * @sc - Reference to iot_sim_context object + * + * Return: None + */ +static void +iot_sim_ctx_deinit(struct iot_sim_context *isc) +{ + if (isc) + isc->iot_sim_operation_handler = NULL; +} + +QDF_STATUS +wlan_iot_sim_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, void *arg) +{ + struct iot_sim_context *isc = NULL; + + if (!psoc) { + iot_sim_err("PSOC is NULL"); + return QDF_STATUS_E_NULL_VALUE; + } + + isc = (struct iot_sim_context *) + qdf_mem_malloc(sizeof(struct iot_sim_context)); + if (!isc) + return QDF_STATUS_E_NOMEM; + + isc->psoc_obj = psoc; + wlan_objmgr_psoc_component_obj_attach(psoc, WLAN_IOT_SIM_COMP, + (void *)isc, QDF_STATUS_SUCCESS); + + iot_sim_info("iot_sim component psoc object created"); + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS +wlan_iot_sim_psoc_obj_destroy_handler(struct wlan_objmgr_psoc *psoc, + void *arg) +{ + struct iot_sim_context *isc = NULL; + + if (!psoc) { + iot_sim_err("PSOC is NULL"); + return QDF_STATUS_E_NULL_VALUE; + } + + isc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_IOT_SIM_COMP); + if (isc) { + wlan_objmgr_psoc_component_obj_detach(psoc, + WLAN_IOT_SIM_COMP, + (void *)isc); + /* Deinitilise function pointers from iot_sim context */ + iot_sim_ctx_deinit(isc); + qdf_mem_free(isc); + } + iot_sim_info("iot_sim component psoc object destroyed"); + + return QDF_STATUS_SUCCESS; +} diff --git a/iot_sim/core/iot_sim_defs_i.h b/iot_sim/core/iot_sim_defs_i.h new file mode 100644 index 0000000000..fe1ff2b085 --- /dev/null +++ b/iot_sim/core/iot_sim_defs_i.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2020, 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. + */ + +#ifndef _IOT_SIM_DEFS_I_H_ +#define _IOT_SIM_DEFS_I_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define iot_sim_fatal(format, args...) \ + QDF_TRACE_FATAL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_err(format, args...) \ + QDF_TRACE_ERROR(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_warn(format, args...) \ + QDF_TRACE_WARN(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_info(format, args...) \ + QDF_TRACE_INFO(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_debug(format, args...) \ + QDF_TRACE_DEBUG(QDF_MODULE_ID_IOT_SIM, format, ## args) + +#define iot_sim_fatal_nofl(format, args...) \ + QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_err_nofl(format, args...) \ + QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_warn_nofl(format, args...) \ + QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_info_nofl(format, args...) \ + QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_debug_nofl(format, args...) \ + QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) + +#define iot_sim_fatal_rl(format, args...) \ + QDF_TRACE_FATAL_RL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_err_rl(format, args...) \ + QDF_TRACE_ERROR_RL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_warn_rl(format, args...) \ + QDF_TRACE_WARN_RL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_info_rl(format, args...) \ + QDF_TRACE_INFO_RL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_debug_rl(format, args...) \ + QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_IOT_SIM, format, ## args) + +#define iot_sim_fatal_rl_nofl(format, args...) \ + QDF_TRACE_FATAL_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_err_rl_nofl(format, args...) \ + QDF_TRACE_ERROR_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_warn_rl_nofl(format, args...) \ + QDF_TRACE_WARN_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_info_rl_nofl(format, args...) \ + QDF_TRACE_INFO_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) +#define iot_sim_debug_rl_nofl(format, args...) \ + QDF_TRACE_DEBUG_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args) + +#define N_FRAME_TYPE 0x4 +#define N_FRAME_SUBTYPE 0xF +#define MAX_SEQ 0x4 + +/* struct iot_sim_content - represent user content + * @len - Length of the content provided by user + * @offset - offset at which modification done in capture frame + * @frm_content - actual user data in hex + * @drop - frame marked for drop + * @delay_dur - duration of delay + */ +struct iot_sim_content { + uint16_t len; + uint16_t offset; + uint8_t *frm_content; + bool drop; + uint16_t delay_dur; +}; + +/* Per Peer iot_sim data per frame type/subtype */ +struct iot_sim_fb_array_peer { + struct qdf_mac_addr peer_addr; + struct iot_sim_content iot_sim_fb_array[N_FRAME_TYPE][N_FRAME_SUBTYPE]; + qdf_list_t p_list; +}; + +/** + * struct iot_sim_context - iot_sim psoc private object + * @psoc_obj:Reference to psoc global object + * @iot_sim_lock: spinlock for synchronization + * + * Call back functions + * @iot_sim_opertion_handler: iot sim operations handler + */ + +struct iot_sim_context { + struct wlan_objmgr_psoc *psoc_obj; + qdf_spinlock_t iot_sim_lock; + /* IOT_SIM Peer list */ + struct iot_sim_fb_arrary_peer *iot_sim_peer_list; + void *p_iot_sim_target_handle; + QDF_STATUS (*iot_sim_operation_handler)(struct wlan_objmgr_psoc *psoc, + wbuf_t wbuf); +}; + +#endif /* _IOT_SIM_DEFS_I_H_ */ diff --git a/iot_sim/core/iot_sim_module.c b/iot_sim/core/iot_sim_module.c new file mode 100644 index 0000000000..d616cb4c54 --- /dev/null +++ b/iot_sim/core/iot_sim_module.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020, 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. + */ + +#include +#include +#include +#include +#include "iot_sim_defs_i.h" +#include + +MODULE_LICENSE("Dual BSD/GPL"); + +/** + * iot_sim_init_module() - Initialize IOT Simulation module + * + * Return: None + */ + +static int __init iot_sim_init_module(void) +{ + wlan_iot_sim_init(); + iot_sim_info("qca_iot_sim module loaded"); + return 0; +} + +/** + * iot_sim_exit_module() - De-initialize and exit IOT Simulation module + * + * Return: None + */ +static void __exit iot_sim_exit_module(void) +{ + wlan_iot_sim_deinit(); + iot_sim_info("qca_iot_sim module unloaded"); +} + +module_init(iot_sim_init_module); +module_exit(iot_sim_exit_module); diff --git a/iot_sim/dispatcher/inc/wlan_iot_sim_tgt_api.h b/iot_sim/dispatcher/inc/wlan_iot_sim_tgt_api.h new file mode 100644 index 0000000000..05f4398e5e --- /dev/null +++ b/iot_sim/dispatcher/inc/wlan_iot_sim_tgt_api.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020, 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. + */ + +#ifndef _WLAN_IOT_SIM_TGT_API_H_ +#define _WLAN_IOT_SIM_TGT_API_H_ + +#include +#include +#include "../../core/iot_sim_cmn_api_i.h" + +#endif /* _WLAN_IOT_SIM_TGT_API_H_ */ diff --git a/iot_sim/dispatcher/inc/wlan_iot_sim_utils_api.h b/iot_sim/dispatcher/inc/wlan_iot_sim_utils_api.h new file mode 100644 index 0000000000..58c4abbe71 --- /dev/null +++ b/iot_sim/dispatcher/inc/wlan_iot_sim_utils_api.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2020, 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. + */ + +#ifndef _WLAN_IOT_SIM_UTILS_API_H_ +#define _WLAN_IOT_SIM_UTILS_API_H_ + +#include +#include + +/* Forward Declarations */ +struct wmi_iot_sim_cmd_ops; + +/* + * wlan_iot_sim_init() - API to init iot_sim component + * + * This API is invoked from dispatcher init during all component init. + * This API will register all required handlers for pdev and peer object + * create/delete notification. + * + * Return: SUCCESS, + * Failure + */ +QDF_STATUS wlan_iot_sim_init(void); + +/* + * wlan_iot_sim_deinit() - API to deinit iot_sim component + * + * This API is invoked from dispatcher deinit during all component deinit. + * This API will unregister all registered handlers for pdev and peer object + * create/delete notification. + * + * Return: SUCCESS, + * Failure + */ +QDF_STATUS wlan_iot_sim_deinit(void); + +/* + * wlan_register_wmi_iot_sim_cmd_ops() - Register operations related to wmi + * commands on iot_sim parameters + * @pdev - the physical device object + * @cmd_ops - pointer to the structure holding the operations + * related to wmi commands on iot_sim parameters + * + * API to register operations related to wmi commands on iot_sim parameters + * + * Return: None + */ +void +wlan_register_wmi_iot_sim_cmd_ops(struct wlan_objmgr_pdev *pdev, + struct wmi_iot_sim_cmd_ops *cmd_ops); + +#endif /* _WLAN_IOT_SIM_UTILS_API_H_*/ diff --git a/iot_sim/dispatcher/src/wlan_iot_sim_tgt_api.c b/iot_sim/dispatcher/src/wlan_iot_sim_tgt_api.c new file mode 100644 index 0000000000..04b721eae4 --- /dev/null +++ b/iot_sim/dispatcher/src/wlan_iot_sim_tgt_api.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020, 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. + */ + +#include +#include + +void * +tgt_get_target_handle(struct wlan_objmgr_psoc *psoc) +{ + struct iot_sim_context *isc; + + if (!psoc) { + iot_sim_err("psoc is NULL!"); + return NULL; + } + isc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_IOT_SIM_COMP); + if (!isc) { + iot_sim_err("psoc IOT_SIM object is NULL!"); + return NULL; + } + return isc->p_iot_sim_target_handle; +} diff --git a/iot_sim/dispatcher/src/wlan_iot_sim_utils_api.c b/iot_sim/dispatcher/src/wlan_iot_sim_utils_api.c new file mode 100644 index 0000000000..8ee908fe1e --- /dev/null +++ b/iot_sim/dispatcher/src/wlan_iot_sim_utils_api.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2020, 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. + */ + +#include +#include +#include "../../core/iot_sim_cmn_api_i.h" +#include + +QDF_STATUS +wlan_iot_sim_init(void) +{ + if (wlan_objmgr_register_psoc_create_handler( + WLAN_IOT_SIM_COMP, + wlan_iot_sim_psoc_obj_create_handler, + NULL) != + QDF_STATUS_SUCCESS) { + return QDF_STATUS_E_FAILURE; + } + if (wlan_objmgr_register_psoc_destroy_handler( + WLAN_IOT_SIM_COMP, + wlan_iot_sim_psoc_obj_destroy_handler, + NULL) != + QDF_STATUS_SUCCESS) { + return QDF_STATUS_E_FAILURE; + } + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS +wlan_iot_sim_deinit(void) +{ + if (wlan_objmgr_unregister_psoc_create_handler( + WLAN_IOT_SIM_COMP, + wlan_iot_sim_psoc_obj_create_handler, + NULL) != + QDF_STATUS_SUCCESS) { + return QDF_STATUS_E_FAILURE; + } + if (wlan_objmgr_unregister_psoc_destroy_handler( + WLAN_IOT_SIM_COMP, + wlan_iot_sim_psoc_obj_destroy_handler, + NULL) != + QDF_STATUS_SUCCESS) { + return QDF_STATUS_E_FAILURE; + } + + return QDF_STATUS_SUCCESS; +} diff --git a/qdf/inc/qdf_types.h b/qdf/inc/qdf_types.h index ece5de1635..840c09992f 100644 --- a/qdf/inc/qdf_types.h +++ b/qdf/inc/qdf_types.h @@ -387,6 +387,7 @@ typedef bool (*qdf_irqlocked_func_t)(void *); * @QDF_MODULE_ID_DCS: DCS module ID * @QDF_MODULE_ID_RPTR: Repeater module ID * @QDF_MODULE_ID_6GHZ: 6Ghz specific feature ID + * @QDF_MODULE_ID_IOT_SIM: IOT Simulation for rogue AP module ID * @QDF_MODULE_ID_ANY: anything * @QDF_MODULE_ID_MAX: Max place holder module ID */ @@ -512,6 +513,7 @@ typedef enum { QDF_MODULE_ID_DCS, QDF_MODULE_ID_RPTR, QDF_MODULE_ID_6GHZ, + QDF_MODULE_ID_IOT_SIM, QDF_MODULE_ID_ANY, QDF_MODULE_ID_MAX, } QDF_MODULE_ID; diff --git a/qdf/linux/src/qdf_trace.c b/qdf/linux/src/qdf_trace.c index cabea72a9c..cbfae78c3c 100644 --- a/qdf/linux/src/qdf_trace.c +++ b/qdf/linux/src/qdf_trace.c @@ -3162,6 +3162,7 @@ struct category_name_info g_qdf_category_name[MAX_SUPPORTED_CATEGORY] = { [QDF_MODULE_ID_PKT_CAPTURE] = {"pkt_capture"}, [QDF_MODULE_ID_RPTR] = {"RPTR"}, [QDF_MODULE_ID_6GHZ] = {"6GHZ"}, + [QDF_MODULE_ID_IOT_SIM] = {"IOT_SIM"}, }; qdf_export_symbol(g_qdf_category_name); @@ -3626,6 +3627,7 @@ static void set_default_trace_levels(struct category_info *cinfo) [QDF_MODULE_ID_PKT_CAPTURE] = QDF_TRACE_LEVEL_NONE, [QDF_MODULE_ID_RPTR] = QDF_TRACE_LEVEL_INFO, [QDF_MODULE_ID_6GHZ] = QDF_TRACE_LEVEL_ERROR, + [QDF_MODULE_ID_IOT_SIM] = QDF_TRACE_LEVEL_ERROR, }; for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { diff --git a/umac/cmn_services/inc/wlan_cmn.h b/umac/cmn_services/inc/wlan_cmn.h index 1ddde97deb..37f26c04a2 100644 --- a/umac/cmn_services/inc/wlan_cmn.h +++ b/umac/cmn_services/inc/wlan_cmn.h @@ -278,6 +278,7 @@ * @WLAN_UMAC_COMP_FTM_TIME_SYNC: WLAN FTM TIMESYNC * @WLAN_UMAC_COMP_PKT_CAPTURE: Packet capture component * @WLAN_UMAC_COMP_DCS: DCS + * @WLAN_IOT_SIM_COMP: IOT Simulation component * @WLAN_UMAC_COMP_ID_MAX: Maximum components in UMAC * * This id is static. @@ -321,6 +322,7 @@ enum wlan_umac_comp_id { WLAN_UMAC_COMP_FTM_TIME_SYNC = 34, WLAN_UMAC_COMP_PKT_CAPTURE = 35, WLAN_UMAC_COMP_DCS = 36, + WLAN_IOT_SIM_COMP = 37, WLAN_UMAC_COMP_ID_MAX, };