diff --git a/Kbuild b/Kbuild index fa89a9930105..ebe30aa6a668 100644 --- a/Kbuild +++ b/Kbuild @@ -3642,6 +3642,8 @@ ccflags-y += -DDP_RX_BUFFER_POOL_ALLOC_THRES=$(CONFIG_DP_RX_BUFFER_POOL_ALLOC_TH endif endif +ccflags-$(CONFIG_GET_DRIVER_MODE) += -DFEATURE_GET_DRIVER_MODE + KBUILD_CPPFLAGS += $(cppflags-y) # Currently, for versions of gcc which support it, the kernel Makefile diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 888ff9245b61..74a9f731c0d1 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -16614,6 +16614,11 @@ int hdd_driver_load(void) goto param_destroy; } + /* driver mode pass to cnss2 platform driver*/ + errno = pld_set_mode(con_mode); + if (errno) + hdd_err("Failed to set mode in PLD; errno:%d", errno); + hdd_driver_mode_change_register(); osif_driver_sync_register(driver_sync); diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index 22407634a154..ec9faa7f8a91 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -435,6 +435,15 @@ struct pld_driver_ops { int pld_init(void); void pld_deinit(void); +/** + * pld_set_mode() - set driver mode in PLD module + * @mode: driver mode + * + * Return: 0 for success + * Non zero failure code for errors + */ +int pld_set_mode(u8 mode); + int pld_register_driver(struct pld_driver_ops *ops); void pld_unregister_driver(void); diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index 2aeb8312eba4..70eb1e95c48a 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -117,6 +117,15 @@ void pld_deinit(void) pld_ctx = NULL; } +int pld_set_mode(u8 mode) +{ + if (!pld_ctx) + return -ENOMEM; + + pld_ctx->mode = mode; + return 0; +} + /** * pld_get_global_context() - Get global context of PLD * diff --git a/core/pld/src/pld_internal.h b/core/pld/src/pld_internal.h index 78b394e74e14..0974197c23bc 100644 --- a/core/pld/src/pld_internal.h +++ b/core/pld/src/pld_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2018-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 @@ -33,6 +33,7 @@ struct pld_context { spinlock_t pld_lock; struct list_head dev_list; uint32_t pld_driver_state; + uint8_t mode; }; struct pld_context *pld_get_global_context(void); diff --git a/core/pld/src/pld_pcie.c b/core/pld/src/pld_pcie.c index d3a17dff765b..8132f4f42069 100644 --- a/core/pld/src/pld_pcie.c +++ b/core/pld/src/pld_pcie.c @@ -352,6 +352,50 @@ static int pld_pcie_runtime_resume(struct pci_dev *pdev) return -ENODEV; } #endif + +#ifdef FEATURE_GET_DRIVER_MODE +/** + * pld_pcie_get_mode() - Get current WLAN driver mode + * + * This function is to get current driver mode + * + * Return: mission mode or ftm mode + */ +static +enum cnss_driver_mode pld_pcie_get_mode(void) +{ + struct pld_context *pld_ctx = pld_get_global_context(); + enum cnss_driver_mode cnss_mode = CNSS_MISSION; + + if (!pld_ctx) + return cnss_mode; + + switch (pld_ctx->mode) { + case QDF_GLOBAL_MISSION_MODE: + cnss_mode = CNSS_MISSION; + break; + case QDF_GLOBAL_WALTEST_MODE: + cnss_mode = CNSS_WALTEST; + break; + case QDF_GLOBAL_FTM_MODE: + cnss_mode = CNSS_FTM; + break; + case QDF_GLOBAL_COLDBOOT_CALIB_MODE: + cnss_mode = CNSS_CALIBRATION; + break; + case QDF_GLOBAL_EPPING_MODE: + cnss_mode = CNSS_EPPING; + break; + case QDF_GLOBAL_QVIT_MODE: + cnss_mode = CNSS_QVIT; + break; + default: + cnss_mode = CNSS_MISSION; + break; + } + return cnss_mode; +} +#endif #endif #ifdef CONFIG_PM @@ -593,6 +637,9 @@ struct cnss_wlan_driver pld_pcie_ops = { #ifdef FEATURE_RUNTIME_PM .runtime_ops = &runtime_pm_ops, #endif +#ifdef FEATURE_GET_DRIVER_MODE + .get_driver_mode = pld_pcie_get_mode, +#endif }; /**