diff --git a/Kbuild b/Kbuild index c0b561713c..902d5647d4 100644 --- a/Kbuild +++ b/Kbuild @@ -506,7 +506,7 @@ ifeq ($(CONFIG_MPC_UT_FRAMEWORK),y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_conc_ut.o endif -ifeq ($(CONFIG_WLAN_FEATURE_DISA),y) +ifeq ($(CONFIG_WLAN_FEATURE_DISA), y) HDD_OBJS += $(HDD_SRC_DIR)/wlan_hdd_disa.o endif @@ -963,6 +963,19 @@ PMO_OBJS := $(PMO_DIR)/core/src/wlan_pmo_main.o \ $(PMO_DIR)/dispatcher/src/wlan_pmo_tgt_hw_filter.o \ $(PMO_DIR)/dispatcher/src/wlan_pmo_tgt_pkt_filter.o +########## DISA (ENCRYPTION TEST) ########## + +DISA_DIR := components/disa +DISA_INC := -I$(WLAN_ROOT)/$(DISA_DIR)/core/inc \ + -I$(WLAN_ROOT)/$(DISA_DIR)/dispatcher/inc + +ifeq ($(CONFIG_WLAN_FEATURE_DISA), y) +DISA_OBJS := $(DISA_DIR)/core/src/wlan_disa_main.o \ + $(DISA_DIR)/dispatcher/src/wlan_disa_obj_mgmt_api.o \ + $(DISA_DIR)/dispatcher/src/wlan_disa_tgt_api.o \ + $(DISA_DIR)/dispatcher/src/wlan_disa_ucfg_api.o +endif + ########## CLD TARGET_IF ####### CLD_TARGET_IF_DIR := components/target_if @@ -981,6 +994,11 @@ CLD_TARGET_IF_OBJ := $(CLD_TARGET_IF_DIR)/pmo/src/target_if_pmo_arp.o \ $(CLD_TARGET_IF_DIR)/pmo/src/target_if_pmo_suspend_resume.o \ $(CLD_TARGET_IF_DIR)/pmo/src/target_if_pmo_wow.o \ +ifeq ($(CONFIG_WLAN_FEATURE_DISA), y) +CLD_TARGET_IF_INC += -I$(WLAN_ROOT)/$(CLD_TARGET_IF_DIR)/disa/inc +CLD_TARGET_IF_OBJ += $(CLD_TARGET_IF_DIR)/disa/src/target_if_disa.o +endif + ############## UMAC P2P ########### P2P_DIR := umac/p2p P2P_CORE_DIR := $(P2P_DIR)/core @@ -1551,6 +1569,10 @@ ifeq ($(BUILD_DIAG_VERSION), 1) INCS += $(HOST_DIAG_LOG_INC) endif +ifeq ($(CONFIG_WLAN_FEATURE_DISA), y) +INCS += $(DISA_INC) +endif + INCS += $(UMAC_DISP_INC) INCS += $(UMAC_SCAN_INC) INCS += $(UMAC_TARGET_SCAN_INC) @@ -1612,6 +1634,10 @@ ifeq ($(BUILD_DIAG_VERSION), 1) OBJS += $(HOST_DIAG_LOG_OBJS) endif +ifeq ($(CONFIG_WLAN_FEATURE_DISA), y) +OBJS += $(DISA_OBJS) +endif + OBJS += $(UMAC_DISP_OBJS) OBJS += $(UMAC_SCAN_OBJS) OBJS += $(UMAC_COMMON_OBJS) @@ -2216,7 +2242,7 @@ ifeq ($(CONFIG_WLAN_OFFLOAD_PACKETS),y) CDEFINES += -DWLAN_FEATURE_OFFLOAD_PACKETS endif -ifeq ($(CONFIG_WLAN_FEATURE_DISA),y) +ifeq ($(CONFIG_WLAN_FEATURE_DISA), y) CDEFINES += -DWLAN_FEATURE_DISA endif diff --git a/components/disa/core/inc/wlan_disa_main.h b/components/disa/core/inc/wlan_disa_main.h new file mode 100644 index 0000000000..0125b0cc6d --- /dev/null +++ b/components/disa/core/inc/wlan_disa_main.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018 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: declare various api which shall be used by + * DISA user configuration and target interface + */ + +#ifndef _WLAN_DISA_MAIN_H_ +#define _WLAN_DISA_MAIN_H_ + +#include "wlan_disa_public_struct.h" +#include "wlan_disa_obj_mgmt_public_struct.h" +#include "wlan_disa_priv.h" +#include "wlan_disa_objmgr.h" + +#define disa_log(level, args...) QDF_TRACE(QDF_MODULE_ID_DISA, level, ## args) +#define disa_logfl(level, format, args...) disa_log(level, FL(format), ## args) + +#define disa_fatal(format, args...) \ + disa_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args) +#define disa_err(format, args...) \ + disa_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args) +#define disa_warn(format, args...) \ + disa_logfl(QDF_TRACE_LEVEL_WARN, format, ## args) +#define disa_info(format, args...) \ + disa_logfl(QDF_TRACE_LEVEL_INFO, format, ## args) +#define disa_debug(format, args...) \ + disa_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args) + +#define DISA_ENTER() disa_debug("enter") +#define DISA_EXIT() disa_debug("exit") + +/** + * disa_allocate_ctx() - Api to allocate disa ctx + * + * Helper function to allocate disa ctx + * + * Return: Success or failure. + */ +QDF_STATUS disa_allocate_ctx(void); + +/** + * disa_free_ctx() - to free disa context + * + * Helper function to free disa context + * + * Return: None. + */ +void disa_free_ctx(void); + +/** + * disa_get_context() - to get disa context + * + * Helper function to get disa context + * + * Return: disa context. + */ +struct wlan_disa_ctx *disa_get_context(void); + +/** + * disa_core_encrypt_decrypt_req() - Form encrypt/decrypt request + * @psoc: objmgr psoc object + * @req: DISA encrypt/decrypt request parameters + * + * Return: QDF status success or failure + */ +QDF_STATUS disa_core_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req, + encrypt_decrypt_resp_callback cb, + void *cookie); + +/** + * disa_core_encrypt_decrypt_resp() - Collect encrypt/decrypt request resp + * @psoc: objmgr psoc object + * @resp: DISA encrypt/decrypt request response parameters + * + * Return: QDF status success or failure + */ +QDF_STATUS disa_core_encrypt_decrypt_resp(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_resp_params *resp); +#endif /* end of _WLAN_DISA_MAIN_H_ */ diff --git a/components/disa/core/inc/wlan_disa_objmgr.h b/components/disa/core/inc/wlan_disa_objmgr.h new file mode 100644 index 0000000000..6fcb0b7854 --- /dev/null +++ b/components/disa/core/inc/wlan_disa_objmgr.h @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2018 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 file contains various object manager related wrappers and helpers + */ + +#ifndef _WLAN_DISA_OBJMGR_H +#define _WLAN_DISA_OBJMGR_H + +#include "wlan_cmn.h" +#include "wlan_objmgr_cmn.h" +#include "wlan_objmgr_vdev_obj.h" +#include "wlan_objmgr_pdev_obj.h" +#include "wlan_objmgr_psoc_obj.h" +#include "wlan_disa_obj_mgmt_public_struct.h" + +/* Get/Put Ref */ + +/** + * disa_psoc_get_ref() - DISA wrapper to increment ref count, if allowed + * @psoc: PSOC object + * + * DISA wrapper to increment ref count after checking valid object state + * + * Return: SUCCESS/FAILURE + */ +static inline QDF_STATUS disa_psoc_get_ref(struct wlan_objmgr_psoc *psoc) +{ + return wlan_objmgr_psoc_try_get_ref(psoc, WLAN_DISA_ID); +} + +/** + * disa_psoc_put_ref() - DISA wrapper to decrement ref count + * @psoc: PSOC object + * + * DISA wrapper to decrement ref count of psoc + * + * Return: SUCCESS/FAILURE + */ +static inline void disa_psoc_put_ref(struct wlan_objmgr_psoc *psoc) +{ + return wlan_objmgr_psoc_release_ref(psoc, WLAN_DISA_ID); +} + +/* Private Data */ + +/** + * disa_psoc_get_priv_nolock(): DISA wrapper to retrieve component object + * @psoc: Psoc pointer + * + * DISA wrapper used to get the component private object pointer + * + * Return: Component private object + */ +static inline void *disa_psoc_get_priv_nolock(struct wlan_objmgr_psoc *psoc) +{ + return wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_UMAC_COMP_DISA); +} + +/* Ids */ +static inline uint8_t +disa_vdev_get_id(struct wlan_objmgr_vdev *vdev) +{ + uint8_t vdev_id; + + vdev_id = wlan_vdev_get_id(vdev); + QDF_BUG(vdev_id < WLAN_UMAC_PSOC_MAX_VDEVS); + + return vdev_id; +} + +/* Tree Navigation */ + +/** + * !PLEASE READ! + * + * The following are objmgr navigation helpers for traversing objmgr object + * trees. + * + * Objmgr ensures parents of an objmgr object cannot be freed while a valid + * reference to one of its children is held. Based on this fact, all of these + * navigation helpers make the following assumptions to ensure safe usage: + * + * 1) The caller must hold a valid reference to the input objmgr object! + * E.g. Use disa_[peer|vdev|pdev|psoc]_get_ref() on the input objmgr + * object before using these APIs + * 2) Given assumption #1, the caller does not need to hold a reference to the + * parents of the input objmgr object + * 3) Given assumption #1, parents of the input objmgr object cannot be null + * 4) Given assumption #1, private contexts of any parent of the input objmgr + * object cannot be null + * + * These characteristics remove the need for most sanity checks when dealing + * with objmgr objects. However, please note that if you ever walk the tree + * from parent to child, references must be acquired all the way down! + * + * Example #1: + * + * psoc = disa_vdev_get_psoc(vdev); + * if (!psoc) + * // this is dead code + * + * Example #2: + * + * psoc_priv = disa_psoc_get_priv(psoc); + * if (!psoc_priv) + * // this is dead code + * + * Example #3: + * + * status = disa_psoc_get_ref(psoc); + * + * ... + * + * psoc = disa_vdev_get_psoc(vdev); + * + * // the next line is redundant, don't do it! + * status = disa_psoc_get_ref(psoc); + */ + +/* Tree Navigation: psoc */ +static inline struct disa_psoc_priv_obj * +disa_psoc_get_priv(struct wlan_objmgr_psoc *psoc) +{ + struct disa_psoc_priv_obj *psoc_priv; + + psoc_priv = disa_psoc_get_priv_nolock(psoc); + QDF_BUG(psoc_priv); + + return psoc_priv; +} + +static inline struct wlan_objmgr_vdev * +disa_psoc_get_vdev(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) +{ + struct wlan_objmgr_vdev *vdev; + + QDF_BUG(vdev_id < WLAN_UMAC_PSOC_MAX_VDEVS); + if (vdev_id >= WLAN_UMAC_PSOC_MAX_VDEVS) + return NULL; + + wlan_psoc_obj_lock(psoc); + vdev = psoc->soc_objmgr.wlan_vdev_list[vdev_id]; + wlan_psoc_obj_unlock(psoc); + + return vdev; +} + +/* Tree Navigation: pdev */ +static inline struct wlan_objmgr_psoc * +disa_pdev_get_psoc(struct wlan_objmgr_pdev *pdev) +{ + struct wlan_objmgr_psoc *psoc; + + psoc = wlan_pdev_get_psoc(pdev); + QDF_BUG(psoc); + + return psoc; +} + +/* Tree Navigation: vdev */ +static inline struct wlan_objmgr_pdev * +disa_vdev_get_pdev(struct wlan_objmgr_vdev *vdev) +{ + struct wlan_objmgr_pdev *pdev; + + pdev = wlan_vdev_get_pdev(vdev); + QDF_BUG(pdev); + + return pdev; +} + +static inline struct wlan_objmgr_psoc * +disa_vdev_get_psoc(struct wlan_objmgr_vdev *vdev) +{ + return disa_pdev_get_psoc(disa_vdev_get_pdev(vdev)); +} + +#endif /* _WLAN_DISA_OBJMGR_H */ diff --git a/components/disa/core/inc/wlan_disa_priv.h b/components/disa/core/inc/wlan_disa_priv.h new file mode 100644 index 0000000000..2ab76fa5a1 --- /dev/null +++ b/components/disa/core/inc/wlan_disa_priv.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018 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: Declare various struct, macros which are used privately in DISA + * component. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + +#ifndef _WLAN_DISA_PRIV_STRUCT_H_ +#define _WLAN_DISA_PRIV_STRUCT_H_ + +#include "wlan_disa_public_struct.h" + +/** + * struct disa_psoc_priv_obj -psoc specific user configuration required for disa + * + * @disa_rx_ops: rx operations for disa + * @disa_tx_ops: tx operations for disa + * @disa_psoc_lock: spin lock for disa psoc priv ctx + */ +struct disa_psoc_priv_obj { + struct wlan_disa_rx_ops disa_rx_ops; + struct wlan_disa_tx_ops disa_tx_ops; + qdf_spinlock_t lock; +}; + +/** + * struct wlan_disa_ctx - disa context for single command + * + * @callback: hdd callback for disa encrypt/decrypt resp + * @callback_context: context for the callback + * @lock: spin lock for disa context + */ +struct wlan_disa_ctx { + encrypt_decrypt_resp_callback callback; + void *callback_context; + qdf_spinlock_t lock; +}; + +#endif /* end of _WLAN_DISA_PRIV_STRUCT_H_ */ diff --git a/components/disa/core/src/wlan_disa_main.c b/components/disa/core/src/wlan_disa_main.c new file mode 100644 index 0000000000..9ace362023 --- /dev/null +++ b/components/disa/core/src/wlan_disa_main.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018 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: Implement various api / helper function which shall be used for + * DISA user and target interface. + */ + +#include "wlan_disa_main.h" +#include "wlan_disa_obj_mgmt_public_struct.h" +#include "wlan_disa_tgt_api.h" + +static struct wlan_disa_ctx *gp_disa_ctx; + +QDF_STATUS disa_allocate_ctx(void) +{ + return QDF_STATUS_SUCCESS; +} + +void disa_free_ctx(void) +{ +} + +struct wlan_disa_ctx *disa_get_context(void) +{ + return gp_disa_ctx; +} + +QDF_STATUS disa_core_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req, + encrypt_decrypt_resp_callback cb, + void *cookie) +{ + return tgt_disa_encrypt_decrypt_req(psoc, req); +} + +QDF_STATUS disa_core_encrypt_decrypt_resp(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_resp_params *resp) +{ + return QDF_STATUS_SUCCESS; +} diff --git a/components/disa/dispatcher/inc/wlan_disa_obj_mgmt_api.h b/components/disa/dispatcher/inc/wlan_disa_obj_mgmt_api.h new file mode 100644 index 0000000000..f8ecd174d1 --- /dev/null +++ b/components/disa/dispatcher/inc/wlan_disa_obj_mgmt_api.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2018 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: declare utility API related to the disa component + * called by other components + */ + +#ifndef _WLAN_DISA_OBJ_MGMT_API_H_ +#define _WLAN_DISA_OBJ_MGMT_API_H_ + +#include "wlan_disa_obj_mgmt_public_struct.h" + +/** + * disa_init() - register disa notification handlers. + * + * This function registers disa related notification handlers. + * + * Return: QDF_STATUS_SUCCESS - in case of success else return error + */ +QDF_STATUS disa_init(void); + +/** + * disa_deinit() - unregister disa notification handlers. + * + * This function unregisters disa related notification handlers. + * + * Return: QDF_STATUS_SUCCESS - in case of success else return error + */ +QDF_STATUS disa_deinit(void); + +/** + * disa_psoc_object_created_notification(): disa psoc create handler + * @psoc: psoc which is going to created by objmgr + * @arg: argument for psoc create handler + * + * Attach psoc private object, register rx/tx ops and event handlers + * + * Return QDF_STATUS status in case of success else return error + */ +QDF_STATUS disa_psoc_object_created_notification( + struct wlan_objmgr_psoc *psoc, void *arg); + +/** + * disa_psoc_object_destroyed_notification(): disa psoc destroy handler + * @psoc: objmgr object corresponding to psoc which is going to be destroyed + * @arg: argument for psoc destroy handler + * + * Detach and free psoc private object, unregister event handlers + * + * Return QDF_STATUS status in case of success else return error + */ +QDF_STATUS disa_psoc_object_destroyed_notification( + struct wlan_objmgr_psoc *psoc, void *arg); + +/** + * disa_psoc_enable() - Trigger psoc enable for DISA + * @psoc: objmgr psoc object + * + * Return: QDF status success or failure + */ +QDF_STATUS disa_psoc_enable(struct wlan_objmgr_psoc *psoc); + +/** + * disa_psoc_disable() - Trigger psoc disable for DISA + * @psoc: objmgr psoc object + * + * Return: QDF status success or failure + */ +QDF_STATUS disa_psoc_disable(struct wlan_objmgr_psoc *psoc); +#endif /* end of _WLAN_DISA_OBJ_MGMT_API_H_ */ diff --git a/components/disa/dispatcher/inc/wlan_disa_obj_mgmt_public_struct.h b/components/disa/dispatcher/inc/wlan_disa_obj_mgmt_public_struct.h new file mode 100644 index 0000000000..1716689903 --- /dev/null +++ b/components/disa/dispatcher/inc/wlan_disa_obj_mgmt_public_struct.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018 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: Declare various struct, macros which are used for object mgmt in disa. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + +#ifndef _WLAN_DISA_OBJ_MGMT_PUBLIC_STRUCT_H_ +#define _WLAN_DISA_OBJ_MGMT_PUBLIC_STRUCT_H_ + +#include "wlan_disa_public_struct.h" +#include "wlan_objmgr_cmn.h" +#include "wlan_objmgr_psoc_obj.h" + +/** + * struct wlan_disa_tx_ops - structure of tx operation function + * pointers for disa component + * @disa_encrypt_decrypt_req: send encrypt/decrypt request + * @disa_register_ev_handlers: register disa event handlers + * @disa_unregister_ev_handlers: unregister disa event handlers + */ +struct wlan_disa_tx_ops { + QDF_STATUS (*disa_encrypt_decrypt_req)(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req); + QDF_STATUS (*disa_register_ev_handlers)(struct wlan_objmgr_psoc *psoc); + QDF_STATUS (*disa_unregister_ev_handlers) + (struct wlan_objmgr_psoc *psoc); +}; + +/** + * struct wlan_disa_rx_ops - structure of rx operation function + * pointers for disa component + * @encrypt_decrypt_msg_resp: send response of encrypt/decrypt request + */ +struct wlan_disa_rx_ops { + QDF_STATUS (*encrypt_decrypt_msg_resp)(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_resp_params *resp); +}; +#endif /* end of _WLAN_DISA_OBJ_MGMT_PUBLIC_STRUCT_H_ */ diff --git a/components/disa/dispatcher/inc/wlan_disa_public_struct.h b/components/disa/dispatcher/inc/wlan_disa_public_struct.h new file mode 100644 index 0000000000..020518255e --- /dev/null +++ b/components/disa/dispatcher/inc/wlan_disa_public_struct.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2018 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: Declare various struct, macros which shall be used in the DISA + * component. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + +#ifndef _WLAN_DISA_PUBLIC_STRUCT_H_ +#define _WLAN_DISA_PUBLIC_STRUCT_H_ + +#include +#include + +#define MAC_MAX_KEY_LENGTH 32 +#define MAC_PN_LENGTH 8 +#define MAX_MAC_HEADER_LEN 32 +#define MIN_MAC_HEADER_LEN 24 + +/** + * struct disa_encrypt_decrypt_req_params - disa encrypt request + * @vdev_id: virtual device id + * @key_flag: This indicates firmware to encrypt/decrypt payload + * see ENCRYPT_DECRYPT_FLAG + * @key_idx: Index used in storing key + * @key_cipher: cipher used for encryption/decryption + * Eg: see WMI_CIPHER_AES_CCM for CCMP + * @key_len: length of key data + * @key_txmic_len: length of Tx MIC + * @key_rxmic_len: length of Rx MIC + * @key_data: Key + * @pn: packet number + * @mac_header: MAC header + * @data_len: length of data + * @data: pointer to payload + */ +struct disa_encrypt_decrypt_req_params { + uint32_t vdev_id; + uint8_t key_flag; + uint32_t key_idx; + uint32_t key_cipher; + uint32_t key_len; + uint32_t key_txmic_len; + uint32_t key_rxmic_len; + uint8_t key_data[MAC_MAX_KEY_LENGTH]; + uint8_t pn[MAC_PN_LENGTH]; + uint8_t mac_header[MAX_MAC_HEADER_LEN]; + uint32_t data_len; + uint8_t *data; +}; + +/** + * struct disa_encrypt_decrypt_resp_params - disa encrypt response + * @vdev_id: vdev id + * @status: status + * @data_length: data length + * @data: data pointer + */ +struct disa_encrypt_decrypt_resp_params { + uint32_t vdev_id; + int32_t status; + uint32_t data_len; + uint8_t *data; +}; + +typedef void (*encrypt_decrypt_resp_callback)(void *cookie, + struct disa_encrypt_decrypt_resp_params *resp) ; +#endif /* end of _WLAN_DISA_PUBLIC_STRUCT_H_ */ + diff --git a/components/disa/dispatcher/inc/wlan_disa_tgt_api.h b/components/disa/dispatcher/inc/wlan_disa_tgt_api.h new file mode 100644 index 0000000000..9d07863b59 --- /dev/null +++ b/components/disa/dispatcher/inc/wlan_disa_tgt_api.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 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: Declare public API for disa to interact with target/WMI + */ + +#ifndef _WLAN_DISA_TGT_API_H_ +#define _WLAN_DISA_TGT_API_H_ + +#include "wlan_disa_obj_mgmt_public_struct.h" +#include "wlan_disa_public_struct.h" + +#define GET_DISA_TX_OPS_FROM_VDEV(vedv) \ + (disa_psoc_get_priv(psoc)->disa_tx_ops) + +/** + * tgt_disa_encrypt_decrypt_req() - send encrypt/decrypt request to target if + * @psoc: objmgr psoc object + * @req: encrypt/decrypt parameters + * + * Return: QDF_STATUS + */ +QDF_STATUS tgt_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req); + +/** + * tgt_disa_encrypt_decrypt_resp() - receive encrypt/decrypt response + * from target if + * @psoc: objmgr psoc object + * @resp: encrypt/decrypt response containing results + * + * Return: QDF_STATUS + */ +QDF_STATUS tgt_disa_encrypt_decrypt_resp(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_resp_params *resp); + +/** + * tgt_disa_register_ev_handlers() - API to register disa event handlers + * @psoc: objmgr psoc object + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS tgt_disa_register_ev_handlers(struct wlan_objmgr_psoc *psoc); + +/** + * tgt_disa_unregister_ev_handlers() - API to unregister disa event handlers + * @psoc: objmgr psoc object + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS tgt_disa_unregister_ev_handlers(struct wlan_objmgr_psoc *psoc); + +#endif /* end of _WLAN_DISA_TGT_API_H_ */ diff --git a/components/disa/dispatcher/inc/wlan_disa_ucfg_api.h b/components/disa/dispatcher/inc/wlan_disa_ucfg_api.h new file mode 100644 index 0000000000..e69f52f5e7 --- /dev/null +++ b/components/disa/dispatcher/inc/wlan_disa_ucfg_api.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 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: Declare public API related to the disa called by north bound HDD/OSIF + */ + +#ifndef _WLAN_DISA_UCFG_API_H_ +#define _WLAN_DISA_UCFG_API_H_ + +#include "wlan_disa_public_struct.h" +#include "wlan_disa_obj_mgmt_api.h" + +/** + * ucfg_disa_encrypt_decrypt_req() - Send encrypt/decrypt request to the DISA + * core + * @psoc: objmgr psoc object + * @req: DISA encrypt/decrypt request parameters + * @cb: Response callback for the encrypt/decrypt request + * @cookie: Cookie to pass to the response callback + * + * Return: QDF status success or failure + */ +QDF_STATUS ucfg_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req, + encrypt_decrypt_resp_callback cb, + void *cookie); + + +#endif /* end of _WLAN_DISA_UCFG_API_H_ */ diff --git a/components/disa/dispatcher/src/wlan_disa_obj_mgmt_api.c b/components/disa/dispatcher/src/wlan_disa_obj_mgmt_api.c new file mode 100644 index 0000000000..67bdaf210f --- /dev/null +++ b/components/disa/dispatcher/src/wlan_disa_obj_mgmt_api.c @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2018 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: define utility API related to the DISA component + * called by other components + */ + +#include "wlan_disa_obj_mgmt_api.h" +#include "wlan_disa_main.h" +#include "target_if_disa.h" +#include "wlan_disa_tgt_api.h" + +/** + * disa_init() - register disa notification handlers. + * + * This function registers disa related notification handlers and + * allocates disa context. + * + * Return: QDF_STATUS_SUCCESS - in case of success else return error + */ +QDF_STATUS disa_init(void) +{ + QDF_STATUS status; + + DISA_ENTER(); + + if (disa_allocate_ctx() != QDF_STATUS_SUCCESS) { + disa_err("unable to allocate disa ctx"); + status = QDF_STATUS_E_FAULT; + goto out; + } + + status = wlan_objmgr_register_psoc_create_handler( + WLAN_UMAC_COMP_DISA, + disa_psoc_object_created_notification, + NULL); + if (status != QDF_STATUS_SUCCESS) { + disa_err("unable to register psoc create handler"); + goto err_free_ctx; + } + + status = wlan_objmgr_register_psoc_destroy_handler( + WLAN_UMAC_COMP_DISA, + disa_psoc_object_destroyed_notification, + NULL); + if (status != QDF_STATUS_SUCCESS) { + disa_err("unable to register psoc destroy handler"); + wlan_objmgr_unregister_psoc_create_handler( + WLAN_UMAC_COMP_DISA, + disa_psoc_object_created_notification, + NULL); + } else { + goto out; + } + +err_free_ctx: + disa_free_ctx(); +out: + DISA_EXIT(); + + return status; +} + +/** + * disa_deinit() - unregister disa notification handlers. + * + * This function unregisters disa related notification handlers and + * frees disa context. + * + * Return: QDF_STATUS_SUCCESS - in case of success else return error + */ +QDF_STATUS disa_deinit(void) +{ + QDF_STATUS status; + + DISA_ENTER(); + status = wlan_objmgr_unregister_psoc_destroy_handler( + WLAN_UMAC_COMP_DISA, + disa_psoc_object_destroyed_notification, + NULL); + if (status != QDF_STATUS_SUCCESS) + disa_err("unable to unregister psoc create handle"); + + status = wlan_objmgr_unregister_psoc_create_handler( + WLAN_UMAC_COMP_DISA, + disa_psoc_object_created_notification, + NULL); + if (status != QDF_STATUS_SUCCESS) + disa_err("unable to unregister psoc create handle"); + + disa_free_ctx(); + DISA_EXIT(); + + return status; +} + +/** + * disa_psoc_object_created_notification(): disa psoc create handler + * @psoc: psoc which is going to created by objmgr + * @arg: argument for psoc create handler + * + * Attach psoc private object, register rx/tx ops and event handlers + * + * Return QDF_STATUS status in case of success else return error + */ +QDF_STATUS disa_psoc_object_created_notification( + struct wlan_objmgr_psoc *psoc, void *arg) +{ + struct disa_psoc_priv_obj *disa_priv; + QDF_STATUS status; + + DISA_ENTER(); + + disa_priv = qdf_mem_malloc(sizeof(*disa_priv)); + if (disa_priv == NULL) { + disa_err("Failed to allocate disa_priv"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + status = wlan_objmgr_psoc_component_obj_attach(psoc, + WLAN_UMAC_COMP_DISA, + (void *)disa_priv, QDF_STATUS_SUCCESS); + if (status != QDF_STATUS_SUCCESS) { + disa_err("Failed to attach disa_priv with psoc"); + qdf_mem_free(disa_priv); + goto out; + } + + qdf_spinlock_create(&disa_priv->lock); + target_if_disa_register_tx_ops(&disa_priv->disa_tx_ops); + +out: + DISA_EXIT(); + + return status; +} + +/** + * disa_psoc_object_destroyed_notification(): disa psoc destroy handler + * @psoc: objmgr object corresponding to psoc which is going to be destroyed + * @arg: argument for psoc destroy handler + * + * Detach and free psoc private object, unregister event handlers + * + * Return QDF_STATUS status in case of success else return error + */ +QDF_STATUS disa_psoc_object_destroyed_notification( + struct wlan_objmgr_psoc *psoc, void *arg) +{ + struct disa_psoc_priv_obj *disa_priv = NULL; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + DISA_ENTER(); + + disa_priv = disa_psoc_get_priv(psoc); + + status = wlan_objmgr_psoc_component_obj_detach(psoc, + WLAN_UMAC_COMP_DISA, + (void *)disa_priv); + + if (status != QDF_STATUS_SUCCESS) + disa_err("Failed to detach disa_priv with psoc"); + + qdf_spinlock_destroy(&disa_priv->lock); + qdf_mem_free(disa_priv); + DISA_EXIT(); + + return status; +} + +/** + * disa_psoc_enable() - Trigger psoc enable for DISA + * @psoc: objmgr psoc object + * + * Return: QDF status success or failure + */ +QDF_STATUS disa_psoc_enable(struct wlan_objmgr_psoc *psoc) +{ + return tgt_disa_register_ev_handlers(psoc); + +} + +/** + * disa_psoc_disable() - Trigger psoc disable for DISA + * @psoc: objmgr psoc object + * + * Return: QDF status success or failure + */ +QDF_STATUS disa_psoc_disable(struct wlan_objmgr_psoc *psoc) +{ + return tgt_disa_unregister_ev_handlers(psoc); + +} + diff --git a/components/disa/dispatcher/src/wlan_disa_tgt_api.c b/components/disa/dispatcher/src/wlan_disa_tgt_api.c new file mode 100644 index 0000000000..331e740042 --- /dev/null +++ b/components/disa/dispatcher/src/wlan_disa_tgt_api.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018 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: Implements public API for disa to interact with target/WMI + */ + +#include "wlan_disa_tgt_api.h" +#include "wlan_disa_main.h" +#include "wlan_disa_public_struct.h" + +/** + * tgt_disa_encrypt_decrypt_req() - send encrypt/decrypt request to target if + * @psoc: objmgr psoc object + * @req: encrypt/decrypt parameters + * + * Return: QDF_STATUS + */ +QDF_STATUS tgt_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req) +{ + return QDF_STATUS_SUCCESS; +} + +/** + * tgt_disa_encrypt_decrypt_resp() - receive encrypt/decrypt response + * from target if + * @psoc: objmgr psoc object + * @resp: encrypt/decrypt response containing results + * + * Return: QDF_STATUS + */ +QDF_STATUS tgt_disa_encrypt_decrypt_resp(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_resp_params *resp) +{ + return QDF_STATUS_SUCCESS; +} + +/** + * tgt_disa_register_ev_handlers() - API to register disa event handlers + * @psoc: objmgr psoc object + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS tgt_disa_register_ev_handlers(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} + +/** + * tgt_disa_unregister_ev_handlers() - API to unregister disa event handlers + * @psoc: objmgr psoc object + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS tgt_disa_unregister_ev_handlers(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} + diff --git a/components/disa/dispatcher/src/wlan_disa_ucfg_api.c b/components/disa/dispatcher/src/wlan_disa_ucfg_api.c new file mode 100644 index 0000000000..e93c707ad8 --- /dev/null +++ b/components/disa/dispatcher/src/wlan_disa_ucfg_api.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 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: public API related to the disa called by north bound HDD/OSIF + */ + +#include "wlan_disa_ucfg_api.h" +#include "wlan_disa_main.h" + +/** + * ucfg_disa_encrypt_decrypt_req() - Send encrypt/decrypt request to the DISA + * core + * @psoc: objmgr psoc object + * @req: DISA encrypt/decrypt request parameters + * + * Return: QDF status success or failure + */ +QDF_STATUS ucfg_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req, + encrypt_decrypt_resp_callback cb, + void *cookie) +{ + return disa_core_encrypt_decrypt_req(psoc, req, cb, cookie); +} + + diff --git a/components/target_if/disa/inc/target_if_disa.h b/components/target_if/disa/inc/target_if_disa.h new file mode 100644 index 0000000000..a2a757112c --- /dev/null +++ b/components/target_if/disa/inc/target_if_disa.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018 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: Declare various api/struct which shall be used + * by disa component for wmi cmd (tx path) and + * event (rx) handling. + */ + +#ifndef _TARGET_IF_DISA_H_ +#define _TARGET_IF_DISA_H_ + +#include "target_if.h" +#include +#include +#include +#include "wlan_disa_tgt_api.h" +#include "wlan_disa_obj_mgmt_public_struct.h" + +/** + * target_if_disa_encrypt_decrypt_req() - Send encrypt/decrypt request to + * target. + * @psoc: objmgr psoc handle + * @req: Encrypt/decrypt request params + * + * Return: QDF status + */ +QDF_STATUS target_if_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req); + +/** + * target_if_encrypt_decrypt_event_handler() - Collect encrypt/decrypt request + * event from the target and pass on the data to tgt api of DISA. + * @scn_handle: target handle + * @data: event data + * @data_len: data length + * + * Return: QDF status + */ +int target_if_encrypt_decrypt_event_handler(ol_scn_t scn_handle, uint8_t *data, + uint32_t data_len); + +/** + * target_if_disa_register_tx_ops() - Register DISA component TX OPS + * @tx_ops: DISA if transmit ops + * + * Return: None + */ +void target_if_disa_register_tx_ops(struct wlan_disa_tx_ops *tx_ops); + +/** + * target_if_disa_register_ev_handler() - Register disa event handlers. + * @psoc:objmgr psoc handle + * + * Return: QDF status + */ +QDF_STATUS +target_if_disa_register_ev_handlers(struct wlan_objmgr_psoc *psoc); + +/** + * target_if_disa_register_ev_handler() - Unregister disa event handlers. + * @psoc:objmgr psoc handle + * + * Return: QDF status + */ +QDF_STATUS +target_if_disa_unregister_ev_handlers(struct wlan_objmgr_psoc *psoc); +#endif + diff --git a/components/target_if/disa/src/target_if_disa.c b/components/target_if/disa/src/target_if_disa.c new file mode 100644 index 0000000000..9f3face1bc --- /dev/null +++ b/components/target_if/disa/src/target_if_disa.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018 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: Target interface file for disa component to + * Implement api's which shall be used by disa component + * in target if internally. + */ + +#include "target_if_disa.h" +#include "wlan_disa_tgt_api.h" +#include "wlan_disa_public_struct.h" + +int +target_if_encrypt_decrypt_event_handler(ol_scn_t scn_handle, uint8_t *data, + uint32_t data_len) +{ + return 0; +} + +QDF_STATUS +target_if_disa_register_ev_handlers(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS +target_if_disa_unregister_ev_handlers(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS +target_if_disa_encrypt_decrypt_req(struct wlan_objmgr_psoc *psoc, + struct disa_encrypt_decrypt_req_params *req) +{ + return QDF_STATUS_SUCCESS; +} + + +void target_if_disa_register_tx_ops(struct wlan_disa_tx_ops *disa_tx_ops) +{ +} diff --git a/core/cds/src/cds_api.c b/core/cds/src/cds_api.c index 81e6cf5de5..b68ff68850 100644 --- a/core/cds/src/cds_api.c +++ b/core/cds/src/cds_api.c @@ -955,6 +955,9 @@ QDF_STATUS cds_enable(struct wlan_objmgr_psoc *psoc) dispatcher_psoc_enable(psoc); + /* Trigger psoc enable for CLD components */ + hdd_component_psoc_enable(psoc); + return QDF_STATUS_SUCCESS; err_soc_target_detach: @@ -1016,8 +1019,11 @@ QDF_STATUS cds_disable(struct wlan_objmgr_psoc *psoc) * wma_stop() does target PDEV suspend. */ - if (psoc) + /* Trigger psoc disable for CLD components */ + if (psoc) { + hdd_component_psoc_disable(psoc); dispatcher_psoc_disable(psoc); + } qdf_status = wma_stop(HAL_STOP_TYPE_RF_KILL); diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index af22d40486..5a5993cba0 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -2880,6 +2880,20 @@ uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score); struct hdd_station_info *hdd_get_stainfo(struct hdd_station_info *astainfo, struct qdf_mac_addr mac_addr); +/** + * hdd_component_psoc_enable() - Trigger psoc enable for CLD Components + * + * Return: None + */ +void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc); + +/** + * hdd_component_psoc_disable() - Trigger psoc disable for CLD Components + * + * Return: None + */ +void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc); + int hdd_driver_memdump_init(void); void hdd_driver_memdump_deinit(void); diff --git a/core/hdd/src/wlan_hdd_disa.c b/core/hdd/src/wlan_hdd_disa.c index 3ff53bf15b..e80fe0b1a3 100644 --- a/core/hdd/src/wlan_hdd_disa.c +++ b/core/hdd/src/wlan_hdd_disa.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2018 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 @@ -24,6 +24,7 @@ */ #include "wlan_hdd_disa.h" +#include "wlan_disa_ucfg_api.h" #include "wlan_hdd_request_manager.h" #include "sme_api.h" #include @@ -40,26 +41,26 @@ */ struct hdd_encrypt_decrypt_msg_context { int status; - struct encrypt_decrypt_req_params request; - struct sir_encrypt_decrypt_rsp_params response; + struct disa_encrypt_decrypt_req_params request; + struct disa_encrypt_decrypt_resp_params response; }; /** * hdd_encrypt_decrypt_msg_cb () - encrypt/decrypt response message handler * @cookie: hdd request cookie - * @encrypt_decrypt_rsp_params: encrypt/decrypt response parameters + * @resp: encrypt/decrypt response parameters * * Return: none */ static void hdd_encrypt_decrypt_msg_cb(void *cookie, - struct sir_encrypt_decrypt_rsp_params *encrypt_decrypt_rsp_params) + struct disa_encrypt_decrypt_resp_params *resp) { struct hdd_request *request; struct hdd_encrypt_decrypt_msg_context *context; ENTER(); - if (!encrypt_decrypt_rsp_params) { + if (!resp) { hdd_err("rsp params is NULL"); return; } @@ -72,28 +73,28 @@ static void hdd_encrypt_decrypt_msg_cb(void *cookie, print_hex_dump(KERN_INFO, "Data in hdd_encrypt_decrypt_msg_cb: ", DUMP_PREFIX_NONE, 16, 1, - encrypt_decrypt_rsp_params->data, - encrypt_decrypt_rsp_params->data_length, 0); + resp->data, + resp->data_len, 0); hdd_debug("vdev_id: %d status:%d data_length: %d", - encrypt_decrypt_rsp_params->vdev_id, - encrypt_decrypt_rsp_params->status, - encrypt_decrypt_rsp_params->data_length); + resp->vdev_id, + resp->status, + resp->data_len); context = hdd_request_priv(request); - context->response = *encrypt_decrypt_rsp_params; + context->response = *resp; context->status = 0; - if (encrypt_decrypt_rsp_params->data_length) { + if (resp->data_len) { context->response.data = qdf_mem_malloc(sizeof(uint8_t) * - encrypt_decrypt_rsp_params->data_length); + resp->data_len); if (!context->response.data) { hdd_err("memory allocation failed"); context->status = -ENOMEM; } else { qdf_mem_copy(context->response.data, - encrypt_decrypt_rsp_params->data, - encrypt_decrypt_rsp_params->data_length); + resp->data, + resp->data_len); } } else { /* make sure we don't have a rogue pointer */ @@ -105,7 +106,6 @@ static void hdd_encrypt_decrypt_msg_cb(void *cookie, EXIT(); } - /** * hdd_post_encrypt_decrypt_msg_rsp () - send encrypt/decrypt data to user space * @encrypt_decrypt_rsp_params: encrypt/decrypt response parameters @@ -113,14 +113,14 @@ static void hdd_encrypt_decrypt_msg_cb(void *cookie, * Return: none */ static int hdd_post_encrypt_decrypt_msg_rsp(struct hdd_context *hdd_ctx, - struct sir_encrypt_decrypt_rsp_params *encrypt_decrypt_rsp_params) + struct disa_encrypt_decrypt_resp_params *resp) { struct sk_buff *skb; uint32_t nl_buf_len; ENTER(); - nl_buf_len = encrypt_decrypt_rsp_params->data_length + NLA_HDRLEN; + nl_buf_len = resp->data_len + NLA_HDRLEN; skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, nl_buf_len); if (!skb) { @@ -128,10 +128,9 @@ static int hdd_post_encrypt_decrypt_msg_rsp(struct hdd_context *hdd_ctx, return -ENOMEM; } - if (encrypt_decrypt_rsp_params->data_length) { + if (resp->data_len) { if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_ENCRYPTION_TEST_DATA, - encrypt_decrypt_rsp_params->data_length, - encrypt_decrypt_rsp_params->data)) { + resp->data_len, resp->data)) { hdd_err("put fail"); goto nla_put_failure; } @@ -150,10 +149,10 @@ static const struct nla_policy encrypt_decrypt_policy[QCA_WLAN_VENDOR_ATTR_ENCRYPTION_TEST_MAX + 1] = { [QCA_WLAN_VENDOR_ATTR_ENCRYPTION_TEST_NEEDS_DECRYPTION] = { .type = NLA_FLAG}, - [QCA_WLAN_VENDOR_ATTR_ENCRYPTION_TEST_KEYID] = { - .type = NLA_U8}, [QCA_WLAN_VENDOR_ATTR_ENCRYPTION_TEST_CIPHER] = { .type = NLA_U32}, + [QCA_WLAN_VENDOR_ATTR_ENCRYPTION_TEST_KEYID] = { + .type = NLA_U8}, }; /** @@ -166,11 +165,12 @@ encrypt_decrypt_policy[QCA_WLAN_VENDOR_ATTR_ENCRYPTION_TEST_MAX + 1] = { * Return: 0 on success, negative errno on failure */ -static int hdd_fill_encrypt_decrypt_params(struct encrypt_decrypt_req_params - *encrypt_decrypt_params, - struct hdd_adapter *adapter, - const void *data, - int data_len) +static int +hdd_fill_encrypt_decrypt_params(struct disa_encrypt_decrypt_req_params + *encrypt_decrypt_params, + struct hdd_adapter *adapter, + const void *data, + int data_len) { struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ENCRYPTION_TEST_MAX + 1]; uint8_t len, mac_hdr_len; @@ -381,11 +381,11 @@ static int hdd_encrypt_decrypt_msg(struct hdd_adapter *adapter, goto cleanup; cookie = hdd_request_cookie(request); - qdf_status = sme_encrypt_decrypt_msg(hdd_ctx->hHal, - &context->request, - hdd_encrypt_decrypt_msg_cb, - cookie); + qdf_status = ucfg_disa_encrypt_decrypt_req(hdd_ctx->hdd_psoc, + &context->request, + hdd_encrypt_decrypt_msg_cb, + cookie); if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { hdd_err("Unable to post encrypt/decrypt message"); diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 494f047a3c..dd3b2ebc18 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -130,6 +130,10 @@ #include #include "wlan_hdd_sysfs.h" +#ifdef WLAN_FEATURE_DISA +#include "wlan_disa_ucfg_api.h" +#endif + #ifdef CNSS_GENL #include #endif @@ -11538,6 +11542,9 @@ static void wlan_hdd_state_ctrl_param_destroy(void) static void component_init(void) { pmo_init(); +#ifdef WLAN_FEATURE_DISA + disa_init(); +#endif } /** @@ -11548,6 +11555,23 @@ static void component_init(void) static void component_deinit(void) { pmo_deinit(); +#ifdef WLAN_FEATURE_DISA + disa_deinit(); +#endif +} + +void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) +{ +#ifdef WLAN_FEATURE_DISA + disa_psoc_enable(psoc); +#endif +} + +void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) +{ +#ifdef WLAN_FEATURE_DISA + disa_psoc_disable(psoc); +#endif } /**