diff --git a/CMakeLists.txt b/CMakeLists.txt index 7844fc4..2013b0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,9 @@ target_compile_definitions( $<$:NRF71_ON_IPC> $<$:NRF_WIFI_DYNAMIC_BANDWIDTH_SIGNALLING> $<$:NRF_WIFI_DYNAMIC_ED> + $<$:WIFI_NRF71> + $<$:SOFT_HPQM> + $<$:CMD_RX_BUFF> NRF_WIFI_MAX_PS_POLL_FAIL_CNT=${CONFIG_NRF_WIFI_MAX_PS_POLL_FAIL_CNT} NRF70_RX_NUM_BUFS=${CONFIG_NRF70_RX_NUM_BUFS} NRF70_MAX_TX_TOKENS=${CONFIG_NRF70_MAX_TX_TOKENS} @@ -119,10 +122,15 @@ target_include_directories( ${NRF_WIFI_DIR}/fw_if/umac_if/inc ${NRF_WIFI_DIR}/fw_load/mips/fw/inc ${NRF_WIFI_DIR}/hw_if/hal/inc - ${NRF_WIFI_DIR}/fw_if/umac_if/inc/fw ${NRF_WIFI_DIR}/fw_if/umac_if/inc/fw/stats ) +if(NOT CONFIG_WIFI_NRF71) +target_include_directories(nrf-wifi-osal PRIVATE + ${NRF_WIFI_DIR}/fw_if/umac_if/inc/fw +) +endif() + target_include_directories_ifdef(CONFIG_NRF70_SYSTEM_MODE nrf-wifi-osal PUBLIC @@ -159,14 +167,17 @@ target_sources(nrf-wifi-osal PRIVATE ${NRF_WIFI_DIR}/utils/src/queue.c ${NRF_WIFI_DIR}/utils/src/util.c ${NRF_WIFI_DIR}/hw_if/hal/src/common/hal_api_common.c - ${NRF_WIFI_DIR}/hw_if/hal/src/common/hal_fw_patch_loader.c ${NRF_WIFI_DIR}/bus_if/bal/src/bal.c ${NRF_WIFI_DIR}/bus_if/bus/qspi/src/qspi.c ${NRF_WIFI_DIR}/fw_if/umac_if/src/common/fmac_cmd_common.c ${NRF_WIFI_DIR}/fw_if/umac_if/src/common/fmac_api_common.c ${NRF_WIFI_DIR}/fw_if/umac_if/src/common/fmac_util.c ) - +if(NOT CONFIG_WIFI_NRF71) + target_sources(nrf-wifi-osal PRIVATE + ${NRF_WIFI_DIR}/hw_if/hal/src/common/hal_fw_patch_loader.c + ) +endif() if(NOT CONFIG_NRF71_ON_IPC) target_sources(nrf-wifi-osal PRIVATE ${NRF_WIFI_DIR}/hw_if/hal/src/common/hal_interrupt.c diff --git a/bus_if/bal/inc/bal_api.h b/bus_if/bal/inc/bal_api.h index 9b630d8..8b53d80 100644 --- a/bus_if/bal/inc/bal_api.h +++ b/bus_if/bal/inc/bal_api.h @@ -53,7 +53,7 @@ void nrf_wifi_bal_deinit(struct nrf_wifi_bal_priv *bpriv); * @return Pointer to the added device context. */ struct nrf_wifi_bal_dev_ctx *nrf_wifi_bal_dev_add(struct nrf_wifi_bal_priv *bpriv, - void *hal_dev_ctx); + void *hal_dev_ctx); /** * @brief Remove a device context from the BAL layer. @@ -99,8 +99,8 @@ unsigned int nrf_wifi_bal_read_word(void *ctx, unsigned long addr_offset); * @param val Value to write. */ void nrf_wifi_bal_write_word(void *ctx, - unsigned long addr_offset, - unsigned int val); + unsigned long addr_offset, + unsigned int val); /** * @brief Read a block of data from a specific address offset. @@ -111,9 +111,9 @@ void nrf_wifi_bal_write_word(void *ctx, * @param len Length of the data to read. */ void nrf_wifi_bal_read_block(void *ctx, - void *dest_addr, - unsigned long src_addr_offset, - size_t len); + void *dest_addr, + unsigned long src_addr_offset, + size_t len); /** * @brief Write a block of data to a specific address offset. @@ -124,9 +124,22 @@ void nrf_wifi_bal_read_block(void *ctx, * @param len Length of the data to write. */ void nrf_wifi_bal_write_block(void *ctx, - unsigned long dest_addr_offset, - const void *src_addr, - size_t len); + unsigned long dest_addr_offset, + const void *src_addr, + size_t len); +#ifdef WIFI_NRF71 +#ifdef INLINE_RX +unsigned long nrf_wifi_bal_dma_map_inline_rx(void *ctx, + unsigned long virt_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir); + +unsigned long nrf_wifi_bal_dma_unmap_inline_rx(void *ctx, + unsigned long phy_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir); +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ /** * @brief Map a virtual address to a physical address for DMA transfer. @@ -139,9 +152,9 @@ void nrf_wifi_bal_write_block(void *ctx, * @return The mapped physical address. */ unsigned long nrf_wifi_bal_dma_map(void *ctx, - unsigned long virt_addr, - size_t len, - enum nrf_wifi_osal_dma_dir dma_dir); + unsigned long virt_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir); /** * @brief Unmap a physical address for DMA transfer. @@ -152,9 +165,9 @@ unsigned long nrf_wifi_bal_dma_map(void *ctx, * @param dma_dir DMA direction. */ unsigned long nrf_wifi_bal_dma_unmap(void *ctx, - unsigned long phy_addr, - size_t len, - enum nrf_wifi_osal_dma_dir dma_dir); + unsigned long phy_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir); /** * @brief Enable bus access recording. diff --git a/bus_if/bal/inc/bal_ops.h b/bus_if/bal/inc/bal_ops.h index db119fc..337e59e 100644 --- a/bus_if/bal/inc/bal_ops.h +++ b/bus_if/bal/inc/bal_ops.h @@ -142,6 +142,19 @@ struct nrf_wifi_bal_ops { unsigned long phy_addr, size_t len, enum nrf_wifi_osal_dma_dir dma_dir); +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + unsigned long (*dma_map_inline_rx)(void *bus_dev_ctx, + unsigned long virt_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir); + + unsigned long (*dma_unmap_inline_rx)(void *bus_dev_ctx, + unsigned long phy_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir); +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ #if defined(NRF_WIFI_LOW_POWER) || defined(__DOXYGEN__) /** diff --git a/bus_if/bal/inc/bal_structs.h b/bus_if/bal/inc/bal_structs.h index 5885a2d..8efc356 100644 --- a/bus_if/bal/inc/bal_structs.h +++ b/bus_if/bal/inc/bal_structs.h @@ -23,6 +23,11 @@ struct nrf_wifi_bal_cfg_params { /** Base address of the packet RAM. */ unsigned long addr_pktram_base; +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + unsigned long addr_hostram_base_inline_rx; +#endif +#endif }; /** diff --git a/bus_if/bal/src/bal.c b/bus_if/bal/src/bal.c index b76c3a3..464b409 100644 --- a/bus_if/bal/src/bal.c +++ b/bus_if/bal/src/bal.c @@ -263,6 +263,45 @@ void nrf_wifi_bal_write_block(void *ctx, len); } +#ifdef WIFI_NRF71 +#ifdef INLINE_RX +unsigned long nrf_wifi_bal_dma_map_inline_rx(void *ctx, + unsigned long virt_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir) +{ + struct nrf_wifi_bal_dev_ctx *bal_dev_ctx = NULL; + unsigned long phy_addr = 0; + + bal_dev_ctx = (struct nrf_wifi_bal_dev_ctx *)ctx; + + phy_addr = bal_dev_ctx->bpriv->ops->dma_map_inline_rx( + bal_dev_ctx->bus_dev_ctx, + virt_addr, + len, + dma_dir); + return phy_addr; +} + +unsigned long nrf_wifi_bal_dma_unmap_inline_rx(void *ctx, + unsigned long phy_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir) +{ + struct nrf_wifi_bal_dev_ctx *bal_dev_ctx = NULL; + unsigned long virt_addr = 0; + + bal_dev_ctx = (struct nrf_wifi_bal_dev_ctx *)ctx; + + virt_addr = bal_dev_ctx->bpriv->ops->dma_unmap_inline_rx( + bal_dev_ctx->bus_dev_ctx, + phy_addr, + len, + dma_dir); + return virt_addr; +} +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ unsigned long nrf_wifi_bal_dma_map(void *ctx, unsigned long virt_addr, diff --git a/bus_if/bus/pcie/inc/pcie.h b/bus_if/bus/pcie/inc/pcie.h index 9eaf8d2..7456b4c 100644 --- a/bus_if/bus/pcie/inc/pcie.h +++ b/bus_if/bus/pcie/inc/pcie.h @@ -51,9 +51,9 @@ struct nrf_wifi_bus_pcie_dev_ctx { void *iomem_addr_base; unsigned long addr_pktram_base; -#ifdef SOC_WEZEN +#ifdef WIFI_NRF71 #ifdef INLINE_RX - unsigned long addr_hostram_base_inline_rx; + unsigned long addr_hostram_base_inline_rx; #endif #endif #ifdef DEBUG_MODE_SUPPORT diff --git a/bus_if/bus/pcie/src/pcie.c b/bus_if/bus/pcie/src/pcie.c index 2e33d73..309990d 100644 --- a/bus_if/bus/pcie/src/pcie.c +++ b/bus_if/bus/pcie/src/pcie.c @@ -28,7 +28,7 @@ int nrf_wifi_bus_pcie_irq_handler(void *data) } void *nrf_wifi_bus_pcie_dev_add(void *bus_priv, - void *bal_dev_ctx) + void *bal_dev_ctx) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; struct nrf_wifi_bus_pcie_priv *pcie_priv = NULL; @@ -79,13 +79,13 @@ void *nrf_wifi_bus_pcie_dev_add(void *bus_priv, pcie_dev_ctx->addr_pktram_base = pcie_priv->cfg_params.addr_pktram_base; #endif /* INLINE_BB_MODE */ #ifdef OFFLINE_MODE - pcie_dev_ctx->addr_pktram_base = ((unsigned long)pcie_dev_ctx->iomem_addr_base + - pcie_priv->cfg_params.addr_pktram_base); + pcie_dev_ctx->addr_pktram_base = + ((unsigned long)pcie_dev_ctx->iomem_addr_base + + pcie_priv->cfg_params.addr_pktram_base); #endif /* OFFLINE_MODE */ #ifdef INLINE_RX pcie_dev_ctx->addr_hostram_base_inline_rx = pcie_priv->cfg_params.addr_hostram_base_inline_rx; #endif - status = nrf_wifi_osal_bus_pcie_dev_intr_reg( pcie_dev_ctx->os_pcie_dev_ctx, pcie_dev_ctx, @@ -166,7 +166,7 @@ void nrf_wifi_bus_pcie_dev_deinit(void *bus_dev_ctx) } void *nrf_wifi_bus_pcie_init(void *params, - int (*intr_callbk_fn)(void *bal_dev_ctx)) + int (*intr_callbk_fn)(void *bal_dev_ctx)) { struct nrf_wifi_bus_pcie_priv *pcie_priv = NULL; @@ -181,10 +181,9 @@ void *nrf_wifi_bus_pcie_init(void *params, goto out; } - nrf_wifi_osal_mem_cpy( - &pcie_priv->cfg_params, - params, - sizeof(pcie_priv->cfg_params)); + nrf_wifi_osal_mem_cpy(&pcie_priv->cfg_params, + params, + sizeof(pcie_priv->cfg_params)); pcie_priv->intr_callbk_fn = intr_callbk_fn; @@ -201,8 +200,7 @@ void *nrf_wifi_bus_pcie_init(void *params, "%s: Unable to register PCIe driver", __func__); - nrf_wifi_osal_mem_free( - pcie_priv); + nrf_wifi_osal_mem_free(pcie_priv); pcie_priv = NULL; @@ -218,15 +216,13 @@ void nrf_wifi_bus_pcie_deinit(void *bus_priv) pcie_priv = bus_priv; - nrf_wifi_osal_bus_pcie_deinit( - pcie_priv->os_pcie_priv); + nrf_wifi_osal_bus_pcie_deinit(pcie_priv->os_pcie_priv); - nrf_wifi_osal_mem_free( - pcie_priv); + nrf_wifi_osal_mem_free(pcie_priv); } unsigned int nrf_wifi_bus_pcie_read_word(void *dev_ctx, - unsigned long addr_offset) + unsigned long addr_offset) { struct nrf_wifi_bus_pcie_dev_ctx *pcie_dev_ctx = NULL; void *mmap_addr = NULL; @@ -236,15 +232,14 @@ unsigned int nrf_wifi_bus_pcie_read_word(void *dev_ctx, mmap_addr = pcie_dev_ctx->iomem_addr_base + addr_offset; - val = nrf_wifi_osal_iomem_read_reg32( - mmap_addr); + val = nrf_wifi_osal_iomem_read_reg32(mmap_addr); return val; } void nrf_wifi_bus_pcie_write_word(void *dev_ctx, - unsigned long addr_offset, - unsigned int val) + unsigned long addr_offset, + unsigned int val) { struct nrf_wifi_bus_pcie_dev_ctx *pcie_dev_ctx = NULL; void *mmap_addr = NULL; @@ -253,15 +248,13 @@ void nrf_wifi_bus_pcie_write_word(void *dev_ctx, mmap_addr = pcie_dev_ctx->iomem_addr_base + addr_offset; - nrf_wifi_osal_iomem_write_reg32( - mmap_addr, - val); + nrf_wifi_osal_iomem_write_reg32(mmap_addr, val); } void nrf_wifi_bus_pcie_read_block(void *dev_ctx, - void *dest_addr, - unsigned long src_addr_offset, - size_t len) + void *dest_addr, + unsigned long src_addr_offset, + size_t len) { struct nrf_wifi_bus_pcie_dev_ctx *pcie_dev_ctx = NULL; void *mmap_addr = NULL; @@ -270,16 +263,13 @@ void nrf_wifi_bus_pcie_read_block(void *dev_ctx, mmap_addr = pcie_dev_ctx->iomem_addr_base + src_addr_offset; - nrf_wifi_osal_iomem_cpy_from( - dest_addr, - mmap_addr, - len); + nrf_wifi_osal_iomem_cpy_from(dest_addr, mmap_addr, len); } void nrf_wifi_bus_pcie_write_block(void *dev_ctx, - unsigned long dest_addr_offset, - const void *src_addr, - size_t len) + unsigned long dest_addr_offset, + const void *src_addr, + size_t len) { struct nrf_wifi_bus_pcie_dev_ctx *pcie_dev_ctx = NULL; void *mmap_addr = NULL; @@ -288,43 +278,53 @@ void nrf_wifi_bus_pcie_write_block(void *dev_ctx, mmap_addr = pcie_dev_ctx->iomem_addr_base + dest_addr_offset; - nrf_wifi_osal_iomem_cpy_to( - mmap_addr, - src_addr, - len); + nrf_wifi_osal_iomem_cpy_to(mmap_addr, src_addr, len); } -#ifdef SOC_WEZEN + +#ifdef WIFI_NRF71 #ifdef INLINE_RX unsigned long nrf_wifi_bus_pcie_dma_map_inline_rx(void *dev_ctx, - unsigned long virt_addr, - size_t len, - enum nrf_wifi_osal_dma_dir dma_dir) + unsigned long virt_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir) { struct nrf_wifi_bus_pcie_dev_ctx *pcie_dev_ctx = NULL; unsigned long phy_addr = 0; pcie_dev_ctx = (struct nrf_wifi_bus_pcie_dev_ctx *)dev_ctx; - phy_addr = SOC_HOST_DATA_RAM_BASE + (virt_addr - pcie_dev_ctx->addr_hostram_base_inline_rx); + + phy_addr = SOC_HOST_DATA_RAM_BASE + + (virt_addr - pcie_dev_ctx->addr_hostram_base_inline_rx); +#ifdef DDR_32_BIT_ADDR + phy_addr |= MEMORY_HOLE_BASE_ADDR; +#endif /* DDR_32_BIT_ADDR */ return phy_addr; } + unsigned long nrf_wifi_bus_pcie_dma_unmap_inline_rx(void *dev_ctx, - unsigned long phy_addr, - size_t len, - enum nrf_wifi_osal_dma_dir dma_dir) + unsigned long phy_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir) { struct nrf_wifi_bus_pcie_dev_ctx *pcie_dev_ctx = NULL; unsigned long virt_addr = 0; + pcie_dev_ctx = (struct nrf_wifi_bus_pcie_dev_ctx *)dev_ctx; - virt_addr = pcie_dev_ctx->addr_hostram_base_inline_rx + (phy_addr - SOC_HOST_DATA_RAM_BASE); +#ifdef DDR_32_BIT_ADDR + phy_addr &= ~MEMORY_HOLE_BASE_ADDR; +#endif /* DDR_32_BIT_ADDR */ + virt_addr = pcie_dev_ctx->addr_hostram_base_inline_rx + + (phy_addr - SOC_HOST_DATA_RAM_BASE); + return virt_addr; } -#endif -#endif +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ unsigned long nrf_wifi_bus_pcie_dma_map(void *dev_ctx, - unsigned long virt_addr, - size_t len, - enum nrf_wifi_osal_dma_dir dma_dir) + unsigned long virt_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir) { struct nrf_wifi_bus_pcie_dev_ctx *pcie_dev_ctx = NULL; unsigned long phy_addr = 0; @@ -333,25 +333,32 @@ unsigned long nrf_wifi_bus_pcie_dma_map(void *dev_ctx, #ifdef INLINE_MODE phy_addr = (unsigned long)nrf_wifi_osal_bus_pcie_dev_dma_map( - pcie_dev_ctx->os_pcie_dev_ctx, - (void *)virt_addr, - len, - dma_dir); + pcie_dev_ctx->os_pcie_dev_ctx, + (void *)virt_addr, + len, + dma_dir); +#ifdef DDR_32_BIT_ADDR + phy_addr |= MEMORY_HOLE_BASE_ADDR; +#endif /* DDR_32_BIT_ADDR */ #endif /* INLINE_MODE */ #ifdef INLINE_BB_MODE phy_addr = SOC_HOST_PKTRAM_BASE + (virt_addr - pcie_dev_ctx->addr_pktram_base); #endif /* INLINE_BB_MODE */ #ifdef OFFLINE_MODE - phy_addr = (unsigned long)pcie_dev_ctx->iomem_addr_base + (virt_addr - pcie_dev_ctx->addr_pktram_base); + phy_addr = (unsigned long)pcie_dev_ctx->iomem_addr_base + + (virt_addr - pcie_dev_ctx->addr_pktram_base); +#ifdef DDR_32_BIT_ADDR + phy_addr |= RPU_ADDR_DATA_RAM_START; +#endif /* DDR_32_BIT_ADDR */ #endif /* OFFLINE_MODE */ return phy_addr; } unsigned long nrf_wifi_bus_pcie_dma_unmap(void *dev_ctx, - unsigned long phy_addr, - size_t len, - enum nrf_wifi_osal_dma_dir dma_dir) + unsigned long phy_addr, + size_t len, + enum nrf_wifi_osal_dma_dir dma_dir) { struct nrf_wifi_bus_pcie_dev_ctx *pcie_dev_ctx = NULL; unsigned long virt_addr = 0; @@ -362,26 +369,29 @@ unsigned long nrf_wifi_bus_pcie_dma_unmap(void *dev_ctx, pcie_dev_ctx = (struct nrf_wifi_bus_pcie_dev_ctx *)dev_ctx; #ifdef INLINE_MODE - nrf_wifi_osal_bus_pcie_dev_dma_unmap( - pcie_dev_ctx->os_pcie_dev_ctx, - (void *)phy_addr, - len, - dma_dir); +#ifdef DDR_32_BIT_ADDR + phy_addr &= ~MEMORY_HOLE_BASE_ADDR; +#endif /* DDR_32_BIT_ADDR */ + nrf_wifi_osal_bus_pcie_dev_dma_unmap(pcie_dev_ctx->os_pcie_dev_ctx, + (void *)phy_addr, + len, + dma_dir); #endif /* INLINE_MODE */ #ifdef INLINE_BB_MODE virt_addr = pcie_dev_ctx->addr_pktram_base + (phy_addr - SOC_HOST_PKTRAM_BASE); #endif /* INLINE_BB_MODE */ #ifdef OFFLINE_MODE -#ifdef SOC_WEZEN - status = pal_rpu_addr_offset_get( - RPU_ADDR_DATA_RAM_START + phy_addr, - &virt_addr, - RPU_ADDR_DATA_RAM_START); +#ifdef WIFI_NRF71 +#ifdef DDR_32_BIT_ADDR + phy_addr &= ~RPU_ADDR_DATA_RAM_START; +#endif /* DDR_32_BIT_ADDR */ + status = pal_rpu_addr_offset_get(RPU_ADDR_DATA_RAM_START + phy_addr, + &virt_addr, + RPU_ADDR_DATA_RAM_START); #else - status = pal_rpu_addr_offset_get( - RPU_ADDR_PKTRAM_START + phy_addr, - &virt_addr, - RPU_ADDR_PKTRAM_START); + status = pal_rpu_addr_offset_get(RPU_ADDR_PKTRAM_START + phy_addr, + &virt_addr, + RPU_ADDR_PKTRAM_START); #endif if (status != NRF_WIFI_STATUS_SUCCESS) nrf_wifi_osal_log_err( @@ -400,13 +410,11 @@ void nrf_wifi_bus_pcie_rpu_ps_sleep(void *bus_dev_ctx) reg_addr = pal_rpu_ps_ctrl_reg_addr_get(); reg_val = nrf_wifi_bus_pcie_read_word(bus_dev_ctx, - reg_addr); + reg_addr); reg_val &= (~(1 << RPU_REG_BIT_PS_CTRL)); - nrf_wifi_bus_pcie_write_word(bus_dev_ctx, - reg_addr, - reg_val); + nrf_wifi_bus_pcie_write_word(bus_dev_ctx, reg_addr, reg_val); } void nrf_wifi_bus_pcie_rpu_ps_wake(void *bus_dev_ctx) @@ -418,9 +426,7 @@ void nrf_wifi_bus_pcie_rpu_ps_wake(void *bus_dev_ctx) reg_val = (1 << RPU_REG_BIT_PS_CTRL); - nrf_wifi_bal_write_word(bus_dev_ctx, - reg_addr, - reg_val); + nrf_wifi_bal_write_word(bus_dev_ctx, reg_addr, reg_val); } int nrf_wifi_bus_pcie_rpu_ps_status(void *bus_dev_ctx) @@ -429,8 +435,7 @@ int nrf_wifi_bus_pcie_rpu_ps_status(void *bus_dev_ctx) reg_addr = pal_rpu_ps_ctrl_reg_addr_get(); - return nrf_wifi_bus_pcie_read_word(bus_dev_ctx, - reg_addr); + return nrf_wifi_bus_pcie_read_word(bus_dev_ctx, reg_addr); } #endif /* NRF_WIFI_LOW_POWER */ @@ -447,7 +452,7 @@ struct nrf_wifi_bal_ops nrf_wifi_bus_pcie_ops = { .write_block = &nrf_wifi_bus_pcie_write_block, .dma_map = &nrf_wifi_bus_pcie_dma_map, .dma_unmap = &nrf_wifi_bus_pcie_dma_unmap, -#ifdef SOC_WEZEN +#ifdef WEZEN #ifdef INLINE_RX .dma_map_inline_rx = &nrf_wifi_bus_pcie_dma_map_inline_rx, .dma_unmap_inline_rx = &nrf_wifi_bus_pcie_dma_unmap_inline_rx, diff --git a/bus_if/bus/qspi/src/qspi.c b/bus_if/bus/qspi/src/qspi.c index 2c2bd36..56eae5d 100644 --- a/bus_if/bus/qspi/src/qspi.c +++ b/bus_if/bus/qspi/src/qspi.c @@ -252,6 +252,10 @@ static unsigned long nrf_wifi_bus_qspi_dma_map(void *dev_ctx, phy_addr = qspi_dev_ctx->host_addr_base + (virt_addr - qspi_dev_ctx->addr_pktram_base); +#ifdef WIFI_NRF71 + phy_addr |= RPU_ADDR_DATA_RAM_START; +#endif /* WIFI_NRF71 */ + return phy_addr; } @@ -266,6 +270,10 @@ static unsigned long nrf_wifi_bus_qspi_dma_unmap(void *dev_ctx, qspi_dev_ctx = (struct nrf_wifi_bus_qspi_dev_ctx *)dev_ctx; +#ifdef WIFI_NRF71 + phy_addr &= ~RPU_ADDR_DATA_RAM_START; +#endif /* WIFI_NRF71 */ + virt_addr = qspi_dev_ctx->addr_pktram_base + (phy_addr - qspi_dev_ctx->host_addr_base); return virt_addr; diff --git a/fw_if/umac_if/inc/common/fmac_api_common.h b/fw_if/umac_if/inc/common/fmac_api_common.h index fc278e0..d138751 100644 --- a/fw_if/umac_if/inc/common/fmac_api_common.h +++ b/fw_if/umac_if/inc/common/fmac_api_common.h @@ -17,11 +17,14 @@ #include "osal_api.h" #include "common/hal_api_common.h" -#include "host_rpu_sys_if.h" +#ifdef WIFI_NRF71 +#include "nrf71_wifi_ctrl.h" +#endif #include "fmac_cmd_common.h" #include "fmac_structs_common.h" - +#ifndef WIFI_NRF71 #include +#endif #define MIN(a, b) (((a) < (b)) ? (a) : (b)) diff --git a/fw_if/umac_if/inc/common/fmac_structs_common.h b/fw_if/umac_if/inc/common/fmac_structs_common.h index 2e02a09..48dcd95 100644 --- a/fw_if/umac_if/inc/common/fmac_structs_common.h +++ b/fw_if/umac_if/inc/common/fmac_structs_common.h @@ -17,7 +17,7 @@ #define __FMAC_STRUCTS_COMMON_H__ #include "osal_api.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #define NRF_WIFI_FW_CHUNK_ID_STR_LEN 16 @@ -98,16 +98,20 @@ struct nrf_wifi_fmac_fw_chunk_info { }; +#ifndef WIFI_NRF71 /** * @brief Structure to hold OTP region information. * */ struct nrf_wifi_fmac_otp_info { + /** OTP region information. */ + struct host_rpu_umac_info info; /** OTP region information. */ struct host_rpu_umac_info info; /** Flags indicating which OTP regions are valid. */ unsigned int flags; }; +#endif /* !WIFI_NRF71 */ /* Maximum number of channels supported in a regulatory * currently set to 42 as hardware supports 2.4GHz and 5GHz. diff --git a/fw_if/umac_if/inc/common/fmac_util.h b/fw_if/umac_if/inc/common/fmac_util.h index f1a8f91..c99732f 100644 --- a/fw_if/umac_if/inc/common/fmac_util.h +++ b/fw_if/umac_if/inc/common/fmac_util.h @@ -34,6 +34,7 @@ #define NRF_WIFI_FMAC_CIPHER_SUITE_TKIP 0x000FAC02 #define NRF_WIFI_FMAC_CIPHER_SUITE_CCMP 0x000FAC04 #define NRF_WIFI_FMAC_CIPHER_SUITE_CCMP_256 0x000FAC0A +#define NRF_WIFI_FMAC_CIPHER_SUITE_GCMP_256 0x000FAC09 #define NRF_WIFI_FMAC_CIPHER_SUITE_OPEN 0x0 #define NRF_WIFI_FMAC_CIPHER_SUITE_SMS4 0x00147201 diff --git a/fw_if/umac_if/inc/fw/host_rpu_common_if.h b/fw_if/umac_if/inc/fw/host_rpu_common_if.h index eaf036f..2a9e22c 100644 --- a/fw_if/umac_if/inc/fw/host_rpu_common_if.h +++ b/fw_if/umac_if/inc/fw/host_rpu_common_if.h @@ -24,6 +24,13 @@ #define NRF_WIFI_UMAC_VER_MAJ(version) (((version)&0x00FF0000) >> 16) #define NRF_WIFI_UMAC_VER_MIN(version) (((version)&0x0000FF00) >> 8) #define NRF_WIFI_UMAC_VER_EXTRA(version) (((version)&0x000000FF) >> 0) +#ifdef WIFI_NRF71 +#define RPU_MEM_UMAC_BOOT_SIG 0x20080000 +#define RPU_MEM_UMAC_VER 0x20080004 +#define RPU_MEM_UMAC_PEND_Q_BMP 0x20080008 +#define RPU_MEM_UMAC_CMD_ADDRESS 0x200807A8 +#define RPU_MEM_UMAC_EVENT_ADDRESS 0x20080E28 +#else /* WIFI_NRF71 */ #define RPU_MEM_UMAC_BOOT_SIG 0xB0000000 #define RPU_MEM_UMAC_VER 0xB0000004 #define RPU_MEM_UMAC_PEND_Q_BMP 0xB0004FBC @@ -31,9 +38,12 @@ #define RPU_MEM_UMAC_EVENT_ADDRESS 0xB0000E28 #define RPU_MEM_UMAC_PATCH_BIN 0x8008C000 #define RPU_MEM_UMAC_PATCH_BIMG 0x80099880 +#endif /*!WIFI_NRF71 */ #define NRF_WIFI_UMAC_BOOT_SIG 0x5A5A5A5A +#ifndef WIFI_NRF71 #define NRF_WIFI_UMAC_ROM_PATCH_OFFSET (RPU_MEM_UMAC_PATCH_BIMG - RPU_ADDR_UMAC_CORE_RET_START) +#endif /* WIFI_NRF71 */ #define NRF_WIFI_UMAC_BOOT_EXCP_VECT_0 0x3c1a8000 #define NRF_WIFI_UMAC_BOOT_EXCP_VECT_1 0x275a0000 #define NRF_WIFI_UMAC_BOOT_EXCP_VECT_2 0x03400008 diff --git a/fw_if/umac_if/inc/fw/host_rpu_sys_if.h b/fw_if/umac_if/inc/fw/host_rpu_sys_if.h index 647db2f..9b7ab46 100644 --- a/fw_if/umac_if/inc/fw/host_rpu_sys_if.h +++ b/fw_if/umac_if/inc/fw/host_rpu_sys_if.h @@ -224,6 +224,9 @@ enum rpu_ch_bw { * */ struct chan_params { +#ifdef WIFI_NRF71 + unsigned int op_band; +#endif /* WIFI_NRF71 */ /** Primary channel number */ unsigned int primary_num; /** Channel bandwidth */ @@ -340,7 +343,14 @@ struct umac_rx_dbg_params { unsigned int null_skb_pointer_from_lmac; /** Number of unexpected management packets received in coalesce event */ unsigned int unexpected_mgmt_pkt; - +#ifdef WIFI_NRF71 + /** Number of packets flushed from reorder buffer + * before going to sleep + */ + unsigned int reorder_flush_pkt_count; + /** Unprotected error data frames received in security mode */ + unsigned int unsecured_data_error; +#endif /* WIFI_NRF71 */ } __NRF_WIFI_PKD; /** @@ -847,7 +857,12 @@ enum op_band { /** All bands */ BAND_ALL, /** 2.4Ghz band */ - BAND_24G + BAND_24G, +#ifdef WIFI_NRF71 + BAND_5G, + /** 6 GHz band */ + BAND_6G +#endif /* WIFI_NRF71 */ }; /** @@ -1288,6 +1303,35 @@ enum UMAC_QUEUE_NUM { UMAC_AC_MAX_CNT }; +#ifdef WIFI_NRF71 +/** + * @brief This structure defines the raw tx parameters used in packet injector mode. + * + */ +struct nrf_wifi_raw_tx_pkt { + /* Queue number will be BK, BE, VI, VO and BCN refer @enum UMAC_QUEUE_NUM */ + unsigned char queue_num; + /* Descriptor identifier or token identifier */ + unsigned char desc_num; + /* Number of times a packet should be transmitted at each possible rate */ + unsigned char rate_retries; + /** refer see &enum rpu_tput_mode */ + unsigned char rate_flags; + /* rate: legacy rates: 1,2,55,11,6,9,12,18,24,36,48,54 + * 11N VHT HE : MCS index 0 to 7. + */ + unsigned char rate; + /* @aggregation: AGGR_DISABLE(0)/AGGR_ENABLE(1) */ + unsigned char aggregation; + /* @num_frames: Number of frames in this command */ + unsigned char num_frames; + /* Packet lengths of frames */ + unsigned short pkt_length[MAX_TX_AGG_SIZE]; + /* Starting Physical address of each frame in Ext-RAM after dma_mapping */ + unsigned int frame_ddr_pointer[MAX_TX_AGG_SIZE]; +} __NRF_WIFI_PKD; + +#else /** * @brief This structure defines the raw tx parameters used in packet injector mode. * @@ -1310,6 +1354,7 @@ struct nrf_wifi_raw_tx_pkt { /** Starting Physical address of each frame in Ext-RAM after dma_mapping. */ unsigned int frame_ddr_pointer; } __NRF_WIFI_PKD; +#endif /** * @brief This structure defines the command used to configure packet injector mode. diff --git a/fw_if/umac_if/inc/fw/host_rpu_umac_if.h b/fw_if/umac_if/inc/fw/host_rpu_umac_if.h index 6741f9f..40d8095 100644 --- a/fw_if/umac_if/inc/fw/host_rpu_umac_if.h +++ b/fw_if/umac_if/inc/fw/host_rpu_umac_if.h @@ -260,7 +260,11 @@ enum nrf_wifi_band { /** Around 5 GHz band (4.9 - 5.7 GHz) */ NRF_WIFI_BAND_5GHZ, /** Unused */ +#ifdef WIFI_NRF71 + NRF_WIFI_BAND_6GHZ, +#else NRF_WIFI_BAND_60GHZ, +#endif /* WIFI_NRF71 */ /** Invalid */ NRF_WIFI_BAND_INVALID }; @@ -683,8 +687,12 @@ struct nrf_wifi_channel { #define NRF_WIFI_SCAN_MAX_NUM_SSIDS 2 +#ifdef WIFI_NRF71 +#define NRF_WIFI_SCAN_MAX_NUM_FREQUENCIES 89 +#define MAX_NUM_CHANNELS 42 +#else /* WIFI_NRF71 */ #define NRF_WIFI_SCAN_MAX_NUM_FREQUENCIES 64 - +#endif /* !WIFI_NRF71 */ #define NRF_WIFI_SCAN_BAND_2GHZ (1 << 0) #define NRF_WIFI_SCAN_BAND_5GHZ (1 << 1) #define NRF_WIFI_SCAN_BAND_6GHZ (1 << 2) @@ -1530,6 +1538,9 @@ struct nrf_wifi_umac_cmd_key { struct nrf_wifi_umac_key_info key_info; /** MAC address associated with the key */ unsigned char mac_addr[NRF_WIFI_ETH_ADDR_LEN]; +#ifdef WIFI_NRF71 + unsigned char peerDBIndex; +#endif /* WIFI_NRF71 */ } __NRF_WIFI_PKD; /** @@ -1818,8 +1829,11 @@ struct nrf_wifi_ext_capability { } __NRF_WIFI_PKD; +#ifdef WIFI_NRF71 +#define NRF_WIFI_SUPPORTED_CHANNELS_MAX_LEN 89 +#else /* WIFI_NRF71 */ #define NRF_WIFI_SUPPORTED_CHANNELS_MAX_LEN 64 - +#endif /* !WIFI_NRF71 */ /** * @brief Supported channels. */ @@ -2959,8 +2973,10 @@ struct nrf_wifi_umac_event_power_save_info { unsigned int ps_timeout; /** Listen interval value */ unsigned short listen_interval; +#ifndef WIFI_NRF71 /** Power save exit strategy */ unsigned char ps_exit_strategy; +#endif /* !WIFI_NRF71 */ /** Number TWT flows */ unsigned char num_twt_flows; /** TWT info of each flow nrf_wifi_umac_config_twt_info */ diff --git a/fw_if/umac_if/inc/fw/lmac_if_common.h b/fw_if/umac_if/inc/fw/lmac_if_common.h index 18d5bcd..40d347f 100644 --- a/fw_if/umac_if/inc/fw/lmac_if_common.h +++ b/fw_if/umac_if/inc/fw/lmac_if_common.h @@ -18,8 +18,13 @@ #include "common/phy_rf_params_common.h" #include "common/pack_def.h" +#ifdef WIFI_NRF71 +#define RPU_MEM_LMAC_BOOT_SIG 0x28000300 +#define RPU_MEM_LMAC_VER 0x28000004 +#else /* WIFI_NRF71 */ #define RPU_MEM_LMAC_BOOT_SIG 0xB7000D50 #define RPU_MEM_LMAC_VER 0xB7000D54 +#endif /* !WIFI_NRF71 */ #define RPU_MEM_LMAC_PATCH_BIN 0x80043A80 #define RPU_MEM_LMAC_PATCH_BIMG 0x8004BC00 @@ -30,7 +35,9 @@ #define NRF_WIFI_LMAC_VER_EXTRA(ver) (ver & 0x000000FF) #define NRF_WIFI_LMAC_BOOT_SIG 0x5A5A5A5A +#ifndef WIFI_NRF71 #define NRF_WIFI_LMAC_ROM_PATCH_OFFSET (RPU_MEM_LMAC_PATCH_BIMG - RPU_ADDR_LMAC_CORE_RET_START) +#endif /* !WIFI_NRF71 */ #define NRF_WIFI_LMAC_BOOT_EXCP_VECT_0 0x3c1a8000 #define NRF_WIFI_LMAC_BOOT_EXCP_VECT_1 0x275a0000 #define NRF_WIFI_LMAC_BOOT_EXCP_VECT_2 0x03400008 diff --git a/fw_if/umac_if/inc/offload_raw_tx/fmac_api.h b/fw_if/umac_if/inc/offload_raw_tx/fmac_api.h index 671659e..ee56ad1 100644 --- a/fw_if/umac_if/inc/offload_raw_tx/fmac_api.h +++ b/fw_if/umac_if/inc/offload_raw_tx/fmac_api.h @@ -15,7 +15,6 @@ #ifndef __FMAC_API_H__ #define __FMAC_API_H__ -#include "host_rpu_sys_if.h" #include "common/fmac_api_common.h" #include "offload_raw_tx/fmac_structs.h" #include "util.h" diff --git a/fw_if/umac_if/inc/offload_raw_tx/fmac_structs.h b/fw_if/umac_if/inc/offload_raw_tx/fmac_structs.h index 27580b0..b3887bc 100644 --- a/fw_if/umac_if/inc/offload_raw_tx/fmac_structs.h +++ b/fw_if/umac_if/inc/offload_raw_tx/fmac_structs.h @@ -18,7 +18,7 @@ #ifndef __FMAC_STRUCTS_H__ #define __FMAC_STRUCTS_H__ -#include "host_rpu_sys_if.h" +#include "nrf71_wifi_ctrl.h" #include "common/fmac_structs_common.h" #define NRF_WIFI_FMAC_PARAMS_RECV_TIMEOUT 100 /* ms */ diff --git a/fw_if/umac_if/inc/radio_test/fmac_api.h b/fw_if/umac_if/inc/radio_test/fmac_api.h index 2a2b131..ef47996 100644 --- a/fw_if/umac_if/inc/radio_test/fmac_api.h +++ b/fw_if/umac_if/inc/radio_test/fmac_api.h @@ -17,9 +17,7 @@ #define __FMAC_API_RT_H__ #include "osal_api.h" -#include "host_rpu_umac_if.h" -#include "host_rpu_data_if.h" -#include "host_rpu_sys_if.h" +#include "nrf71_wifi_ctrl.h" #include "fmac_structs.h" #include "fmac_cmd.h" diff --git a/fw_if/umac_if/inc/radio_test/fmac_structs.h b/fw_if/umac_if/inc/radio_test/fmac_structs.h index 8199fc0..ecf29f4 100644 --- a/fw_if/umac_if/inc/radio_test/fmac_structs.h +++ b/fw_if/umac_if/inc/radio_test/fmac_structs.h @@ -19,7 +19,7 @@ #define __FMAC_STRUCTS_H__ #include "osal_api.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "radio_test/phy_rf_params.h" #include "common/fmac_structs_common.h" diff --git a/fw_if/umac_if/inc/system/fmac_ap.h b/fw_if/umac_if/inc/system/fmac_ap.h index 80cf508..fe64b72 100644 --- a/fw_if/umac_if/inc/system/fmac_ap.h +++ b/fw_if/umac_if/inc/system/fmac_ap.h @@ -12,7 +12,7 @@ #ifndef __FMAC_AP_H__ #define __FMAC_AP_H__ -#include "host_rpu_data_if.h" +#include "nrf71_wifi_ctrl.h" #include "system/fmac_structs.h" diff --git a/fw_if/umac_if/inc/system/fmac_api.h b/fw_if/umac_if/inc/system/fmac_api.h index 2b6ab70..6f344ca 100644 --- a/fw_if/umac_if/inc/system/fmac_api.h +++ b/fw_if/umac_if/inc/system/fmac_api.h @@ -17,9 +17,7 @@ #define __FMAC_API_H__ #include "osal_api.h" -#include "host_rpu_umac_if.h" -#include "host_rpu_data_if.h" -#include "host_rpu_sys_if.h" +#include "nrf71_wifi_ctrl.h" #include "system/fmac_structs.h" #include "system/fmac_cmd.h" @@ -1175,6 +1173,24 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_stats_get(struct nrf_wifi_fmac_dev_ctx *f enum rpu_op_mode op_mode, struct rpu_sys_op_stats *stats); +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF +/** + * @brief Configure Rx buffer to firmware. + * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. + * @param nrf_wifi_rx_buf RX buffer info. + * @param num_buffs Number of buffers. + * + * This function is used to send host Rx buffers to UMAC module + * + *@retval NRF_WIFI_STATUS_SUCCESS On success + *@retval NRF_WIFI_STATUS_FAIL On failure to execute command + */ +enum nrf_wifi_status nrf_wifi_fmac_prog_rx_buf_info(void *fmac_dev_ctx, + struct nrf_wifi_rx_buf *rx_buf, + unsigned int num_buffs); +#endif /* CMD_RX_BUFF*/ +#endif /* WIFI_NRF71 */ /** * @} */ diff --git a/fw_if/umac_if/inc/system/fmac_rx.h b/fw_if/umac_if/inc/system/fmac_rx.h index 59a587f..e00b6b9 100644 --- a/fw_if/umac_if/inc/system/fmac_rx.h +++ b/fw_if/umac_if/inc/system/fmac_rx.h @@ -12,7 +12,7 @@ #ifndef __FMAC_RX_H__ #define __FMAC_RX_H__ -#include "host_rpu_data_if.h" +#include "nrf71_wifi_ctrl.h" #include "system/fmac_structs.h" #define RX_BUF_HEADROOM 4 @@ -38,4 +38,10 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx void nrf_wifi_fmac_rx_tasklet(void *data); +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF +unsigned long nrf_wifi_fmac_get_rx_buf_map_addr(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, + unsigned int desc_id); +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ #endif /* __FMAC_RX_H__ */ diff --git a/fw_if/umac_if/inc/system/fmac_structs.h b/fw_if/umac_if/inc/system/fmac_structs.h index 9f2bbbc..5dc6284 100644 --- a/fw_if/umac_if/inc/system/fmac_structs.h +++ b/fw_if/umac_if/inc/system/fmac_structs.h @@ -17,7 +17,7 @@ #define __FMAC_STRUCTS_H__ #include "osal_api.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "common/fmac_structs_common.h" #define MAX_PEERS 5 @@ -449,6 +449,73 @@ struct raw_tx_stats { }; #endif /* NRF70_RAW_DATA_TX */ +#ifdef WIFI_NRF71 +#define MAX_NUM_SESSIONS 8 +#define WLAN_OPER_INVALID 10 +#define MAX_ENC_KEY_LEN 32 +#define MAX_MIC_KEY_LEN 16 +#define MICHAEL_LEN 8 +enum VIF_STATE { + VIF_INVALID, + VIF_VALID +}; + +enum keyState { + KEY_INVALID, + KEY_VALID +}; + +enum VIF_CONNECTED_STATE { + VIF_DISCONNECTED, + VIF_CONNECTED +}; + +enum VIF_IF_MODE { + VIF_BSS_STA, + VIF_IBSS, + VIF_AP +}; + +#define VIF_MIC_KEY_LEN_PER_VIF 0x40 +#define VIF_KEY_LEN_PER_VIF 0x80 +#define VIF_MIC_KEY_LEN_PER_KEYID 0x10 +#define VIF_KEY_LEN_PER_KEYID 0x20 +#define VIF_KEY_DB_OFFSET 0x1000 +#define PEER_MIC_KEY_LEN_8 0x08 +#define PEER_MIC_KEY_LEN_16 0x10 +#define PEER_UNICAST_KEY_LEN 0x20 +#define PEER_BCST_KEY_LEN 0x20 +#define PEER_ENC_KEY_LEN_16 0x10 +#define PEER_ENC_KEY_LEN_32 0x20 +#define PEER_KEY_TOTAL_LEN 0xf0 + +struct peerKeydataBase { + unsigned int keyValid; + unsigned int keyType; + unsigned int ucstCipherType; + unsigned int bcstCipherType; + unsigned int bcstKeyId; + unsigned char peerMacAddr[NRF_WIFI_ETH_ADDR_LEN]; + unsigned char vifMacAddr[NRF_WIFI_ETH_ADDR_LEN]; + unsigned char ucstKey[MAX_ENC_KEY_LEN]; + union { + struct { + unsigned char TxMicKey[MICHAEL_LEN]; + unsigned char RxMicKey[MICHAEL_LEN]; + } ucst; + unsigned char ucstWapiMicKey[MAX_MIC_KEY_LEN]; + }; + unsigned char bcstKey[MAX_ENC_KEY_LEN]; + union { + struct { + unsigned char TxMicKey[MICHAEL_LEN]; + unsigned char RxMicKey[MICHAEL_LEN]; + } bcst; + unsigned char bcstWapiMicKey[MAX_MIC_KEY_LEN]; + }; +}; +#endif /* WIFI_NRF71 */ + /** * @brief Structure to hold per device context information for the UMAC IF layer. * @@ -490,6 +557,10 @@ struct nrf_wifi_sys_fmac_dev_ctx { struct raw_tx_pkt_header raw_tx_config; struct raw_tx_stats raw_pkt_stats; #endif /* NRF70_RAW_DATA_TX */ +#ifdef WIFI_NRF71 + /* Peer key info */ + struct peerKeydataBase peerKeyDB[MAX_NUM_SESSIONS]; +#endif /* WIFI_NRF71 */ }; /** @@ -553,7 +624,6 @@ struct rpu_sys_op_stats { /** Firmware statistics. */ struct rpu_sys_fw_stats fw; }; - /** * @} */ diff --git a/fw_if/umac_if/inc/system/fmac_tx.h b/fw_if/umac_if/inc/system/fmac_tx.h index f6d4bc5..e19cba8 100644 --- a/fw_if/umac_if/inc/system/fmac_tx.h +++ b/fw_if/umac_if/inc/system/fmac_tx.h @@ -14,7 +14,7 @@ #ifndef __FMAC_TX_H__ #define __FMAC_TX_H__ -#include "host_rpu_data_if.h" +#include "nrf71_wifi_ctrl.h" #include "system/fmac_structs.h" /** diff --git a/fw_if/umac_if/src/common/fmac_api_common.c b/fw_if/umac_if/src/common/fmac_api_common.c index 2df9fec..41e6091 100644 --- a/fw_if/umac_if/src/common/fmac_api_common.c +++ b/fw_if/umac_if/src/common/fmac_api_common.c @@ -8,8 +8,9 @@ * @brief File containing API definitions for the * FMAC IF Layer of the Wi-Fi driver. */ - -#include "host_rpu_umac_if.h" +#ifdef WIFI_NRF71 +#include "nrf71_wifi_ctrl.h" +#endif #include "common/fmac_api_common.h" #include "common/fmac_util.h" #include "common/fmac_cmd_common.h" @@ -25,7 +26,7 @@ struct nrf_wifi_proc wifi_proc[] = { {RPU_PROC_TYPE_MCU_LMAC, "LMAC", true}, {RPU_PROC_TYPE_MCU_UMAC, "UMAC", true}, }; - +#ifndef WIFI_NRF71 static int nrf_wifi_patch_version_compat(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, const unsigned int version) { @@ -109,7 +110,7 @@ static int nrf_wifi_patch_feature_flags_compat(struct nrf_wifi_fmac_dev_ctx *fma return 0; } - +#endif /* WIFI_NRF71 */ void nrf_wifi_fmac_deinit(struct nrf_wifi_fmac_priv *fpriv) { @@ -126,7 +127,7 @@ void nrf_wifi_fmac_dev_rem(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) nrf_wifi_osal_mem_free(fmac_dev_ctx); } - +#ifndef WIFI_NRF71 enum nrf_wifi_status nrf_wifi_validate_fw_header(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, struct nrf70_fw_image_info *info) { @@ -232,7 +233,7 @@ enum nrf_wifi_status nrf_wifi_fmac_fw_parse(struct nrf_wifi_fmac_dev_ctx *fmac_d return NRF_WIFI_STATUS_SUCCESS; } - +#endif /* !WIFI_NRF71 */ enum nrf_wifi_status nrf_wifi_fmac_fw_reset(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; @@ -258,6 +259,7 @@ enum nrf_wifi_status nrf_wifi_fmac_fw_boot(struct nrf_wifi_fmac_dev_ctx *fmac_de int i = 0; for (i = 0; i < ARRAY_SIZE(wifi_proc); i++) { +#ifndef WIFI_NRF71 status = nrf_wifi_hal_fw_patch_boot(fmac_dev_ctx->hal_dev_ctx, wifi_proc[i].type, wifi_proc[i].is_patch_present); @@ -267,7 +269,7 @@ enum nrf_wifi_status nrf_wifi_fmac_fw_boot(struct nrf_wifi_fmac_dev_ctx *fmac_de __func__, wifi_proc[i].name); return NRF_WIFI_STATUS_FAIL; } - +#endif /* WIFI_NRF71 */ status = nrf_wifi_hal_fw_chk_boot(fmac_dev_ctx->hal_dev_ctx, wifi_proc[i].type); @@ -633,8 +635,8 @@ enum nrf_wifi_status nrf_wifi_fmac_set_reg(struct nrf_wifi_fmac_dev_ctx *fmac_de set_reg_cmd, sizeof(*set_reg_cmd)); if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: Failed to set regulatory information", - __func__); + nrf_wifi_osal_log_err("%s %u: Failed to set regulatory information", + __func__, __LINE__); goto out; } @@ -645,8 +647,8 @@ enum nrf_wifi_status nrf_wifi_fmac_set_reg(struct nrf_wifi_fmac_dev_ctx *fmac_de } if (!fmac_dev_ctx->reg_set_status) { - nrf_wifi_osal_log_err("%s: Failed to set regulatory information", - __func__); + nrf_wifi_osal_log_err("%s %u: Failed to set regulatory information", + __func__, __LINE__); status = NRF_WIFI_STATUS_FAIL; goto out; } diff --git a/fw_if/umac_if/src/common/fmac_cmd_common.c b/fw_if/umac_if/src/common/fmac_cmd_common.c index a7be244..14c4cde 100644 --- a/fw_if/umac_if/src/common/fmac_cmd_common.c +++ b/fw_if/umac_if/src/common/fmac_cmd_common.c @@ -9,7 +9,7 @@ * FMAC IF Layer of the Wi-Fi driver. */ -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "common/hal_api_common.h" #include "common/fmac_structs_common.h" #include "common/fmac_util.h" diff --git a/fw_if/umac_if/src/common/fmac_util.c b/fw_if/umac_if/src/common/fmac_util.c index 8fcf3a8..4fceda0 100644 --- a/fw_if/umac_if/src/common/fmac_util.c +++ b/fw_if/umac_if/src/common/fmac_util.c @@ -12,7 +12,7 @@ #include "osal_api.h" #include "common/fmac_api_common.h" #include "common/fmac_util.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" bool nrf_wifi_util_is_multicast_addr(const unsigned char *addr) { diff --git a/fw_if/umac_if/src/offload_raw_tx/fmac_api.c b/fw_if/umac_if/src/offload_raw_tx/fmac_api.c index c1cf67c..52d88a1 100644 --- a/fw_if/umac_if/src/offload_raw_tx/fmac_api.c +++ b/fw_if/umac_if/src/offload_raw_tx/fmac_api.c @@ -9,7 +9,7 @@ * FMAC IF Layer of the Wi-Fi driver. */ -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "offload_raw_tx/phy_rf_params.h" #include "offload_raw_tx/hal_api.h" #include "offload_raw_tx/fmac_api.h" diff --git a/fw_if/umac_if/src/offload_raw_tx/fmac_event.c b/fw_if/umac_if/src/offload_raw_tx/fmac_event.c index 6308922..2e1fd9b 100644 --- a/fw_if/umac_if/src/offload_raw_tx/fmac_event.c +++ b/fw_if/umac_if/src/offload_raw_tx/fmac_event.c @@ -10,7 +10,7 @@ */ #include "queue.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "common/hal_mem.h" #include "offload_raw_tx/fmac_structs.h" #include "common/fmac_util.h" diff --git a/fw_if/umac_if/src/radio_test/fmac_api.c b/fw_if/umac_if/src/radio_test/fmac_api.c index ece1200..27dee52 100644 --- a/fw_if/umac_if/src/radio_test/fmac_api.c +++ b/fw_if/umac_if/src/radio_test/fmac_api.c @@ -9,7 +9,7 @@ * FMAC IF Layer of the Wi-Fi driver. */ -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "radio_test/fmac_api.h" #include "radio_test/hal_api.h" #include "radio_test/fmac_structs.h" @@ -147,8 +147,15 @@ enum nrf_wifi_status nrf_wifi_rt_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fma unsigned char *country_code) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_fmac_otp_info otp_info; +#ifndef NRF71_ON_IPC +#ifdef WIFI_NRF71 + struct nrf_wifi_phy_rf_params phy_rf_params = { 0}; + int ret = -1; +#else /* WIFI_NRF71 */ + struct nrf_wifi_fmac_otp_info otp_info; struct nrf_wifi_phy_rf_params phy_rf_params; +#endif /* !WIFI_NRF71 */ +#endif /* !NRF71_ON_IPC */ if (!fmac_dev_ctx) { nrf_wifi_osal_log_err("%s: Invalid device context", @@ -175,6 +182,23 @@ enum nrf_wifi_status nrf_wifi_rt_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fma tx_pwr_ceil_params, sizeof(*tx_pwr_ceil_params)); +#ifndef NRF71_ON_IPC +#ifdef WIFI_NRF71 + nrf_wifi_osal_mem_set(&phy_rf_params, + 0x0, + sizeof(phy_rf_params)); + + ret = nrf_wifi_utils_hex_str_to_val( + (unsigned char *)&phy_rf_params.phy_params, + sizeof(phy_rf_params.phy_params), + NRF_WIFI_DEF_RF_PARAMS); + if (ret == -1) { + nrf_wifi_osal_log_err("%s: Initialization of RF params with default values failed", __func__); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } + +#else /* WIFI_NRF71 */ nrf_wifi_osal_mem_set(&otp_info, 0xFF, sizeof(otp_info)); @@ -197,6 +221,8 @@ enum nrf_wifi_status nrf_wifi_rt_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fma __func__); goto out; } +#endif /* !WIFI_NRF71 */ +#endif /* !NRF71_ON_IPC */ status = nrf_wifi_rt_fmac_fw_init(fmac_dev_ctx, &phy_rf_params, @@ -212,8 +238,6 @@ enum nrf_wifi_status nrf_wifi_rt_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fma country_code); if (status == NRF_WIFI_STATUS_FAIL) { - nrf_wifi_osal_log_err("%s: nrf_wifi_sys_fmac_fw_init failed", - __func__); goto out; } out: @@ -960,11 +984,16 @@ static int nrf_wifi_rt_fmac_phy_rf_params_init(struct nrf_wifi_phy_rf_params *pr unsigned char *str) { int ret = -1; +#ifndef WIFI_NRF71 unsigned int rf_param_offset = BAND_2G_LW_ED_BKF_DSSS_OFST - NRF_WIFI_RF_PARAMS_CONF_SIZE; +#endif /* !WIFI_NRF71 */ + /* Initilaize reserved bytes */ nrf_wifi_osal_mem_set(prf, 0x0, sizeof(prf)); + +#ifndef WIFI_NRF71 /* Initialize PD adjust values for MCS7. Currently these 4 bytes are not being used */ prf->pd_adjust_val.pd_adjt_lb_chan = PD_ADJUST_VAL; prf->pd_adjust_val.pd_adjt_hb_low_chan = PD_ADJUST_VAL; @@ -1062,6 +1091,7 @@ static int nrf_wifi_rt_fmac_phy_rf_params_init(struct nrf_wifi_phy_rf_params *pr prf->phy_params[rf_param_offset + 32] = NRF70_PCB_LOSS_5G_BAND2; prf->phy_params[rf_param_offset + 33] = NRF70_PCB_LOSS_5G_BAND3; +#endif /* !WIFI_NRF71 */ return(ret); } @@ -1076,8 +1106,11 @@ enum nrf_wifi_status nrf_wifi_rt_fmac_rf_params_get(struct nrf_wifi_fmac_dev_ctx /* If package_info is not written to OTP then the default value will be 0xFF. */ unsigned int package_info = 0xFFFFFFFF; struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params; + +#ifndef WIFI_NRF71 unsigned char backoff_2g_dsss = 0, backoff_2g_ofdm = 0; unsigned char backoff_5g_lowband = 0, backoff_5g_midband = 0, backoff_5g_highband = 0; +#endif /* !WIFI_NRF71 */ if (!fmac_dev_ctx || !phy_rf_params) { nrf_wifi_osal_log_err("%s: Invalid parameters", @@ -1125,7 +1158,13 @@ enum nrf_wifi_status nrf_wifi_rt_fmac_rf_params_get(struct nrf_wifi_fmac_dev_ctx ret = nrf_wifi_rt_fmac_phy_rf_params_init(phy_rf_params, package_info, - NRF_WIFI_RT_DEF_RF_PARAMS); +#ifdef WIFI_NRF71 + NRF_WIFI_DEF_RF_PARAMS +#else + + NRF_WIFI_RT_DEF_RF_PARAMS +#endif /* WIFI_NRF71 */ + ); if (ret == -1) { nrf_wifi_osal_log_err("%s: Initialization of RF params with default values failed", @@ -1133,6 +1172,8 @@ enum nrf_wifi_status nrf_wifi_rt_fmac_rf_params_get(struct nrf_wifi_fmac_dev_ctx status = NRF_WIFI_STATUS_FAIL; goto out; } + +#ifndef WIFI_NRF71 if (!(otp_info.flags & (~CALIB_XO_FLAG_MASK))) { nrf_wifi_osal_mem_cpy(&phy_rf_params->xo_offset.xo_freq_offset, (char *)otp_info.info.calib + OTP_OFF_CALIB_XO, @@ -1190,8 +1231,9 @@ enum nrf_wifi_status nrf_wifi_rt_fmac_rf_params_get(struct nrf_wifi_fmac_dev_ctx MIN(tx_pwr_ceil_params->max_pwr_5g_high_mcs0, phy_rf_params->max_pwr_ceil.max_hb_high_chan_mcs0_pwr) - backoff_5g_highband; #endif /* NRF70_2_4G_ONLY */ +#endif /* !WIFI_NRF71 */ status = NRF_WIFI_STATUS_SUCCESS; out: return status; -} \ No newline at end of file +} diff --git a/fw_if/umac_if/src/radio_test/fmac_cmd.c b/fw_if/umac_if/src/radio_test/fmac_cmd.c index e247d42..dad33da 100644 --- a/fw_if/umac_if/src/radio_test/fmac_cmd.c +++ b/fw_if/umac_if/src/radio_test/fmac_cmd.c @@ -11,6 +11,7 @@ #include "radio_test/fmac_cmd.h" #include "common/hal_api_common.h" +#include "nrf71_wifi_rf.h" enum nrf_wifi_status umac_cmd_rt_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, struct nrf_wifi_phy_rf_params *rf_params, @@ -52,7 +53,11 @@ enum nrf_wifi_status umac_cmd_rt_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx if (rf_params_valid) { nrf_wifi_osal_mem_cpy(umac_cmd_data->sys_params.rf_params, +#ifdef WIFI_NRF71 + rf_params->phy_params, +#else rf_params, +#endif /* WIFI_NRF71 */ NRF_WIFI_RF_PARAMS_SIZE); } @@ -101,11 +106,11 @@ enum nrf_wifi_status umac_cmd_rt_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx nrf_wifi_osal_mem_cpy(&umac_cmd_data->sys_params.rf_params[ANT_GAIN_2G_OFST], &tx_pwr_ctrl_params->ant_gain_2g, NUM_ANT_GAIN); - +#ifndef WIFI_NRF71 nrf_wifi_osal_mem_cpy(&umac_cmd_data->sys_params.rf_params[BAND_2G_LW_ED_BKF_DSSS_OFST], &tx_pwr_ctrl_params->band_edge_2g_lo_dss, NUM_EDGE_BACKOFF); - +#endif /* CONFIG_WIFI_NRF71*/ nrf_wifi_osal_mem_cpy(umac_cmd_data->country_code, country_code, NRF_WIFI_COUNTRY_CODE_LEN); diff --git a/fw_if/umac_if/src/radio_test/fmac_event.c b/fw_if/umac_if/src/radio_test/fmac_event.c index 181a898..6cc09b8 100644 --- a/fw_if/umac_if/src/radio_test/fmac_event.c +++ b/fw_if/umac_if/src/radio_test/fmac_event.c @@ -11,11 +11,13 @@ #include "queue.h" #include "radio_test/phy_rf_params.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "radio_test/fmac_structs.h" #include "common/hal_mem.h" #include "common/fmac_util.h" +#define RPU_MEM_RF_TEST_CAP_BASE 0xB0006000 + static enum nrf_wifi_status umac_event_rt_stats_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, void *event) { diff --git a/fw_if/umac_if/src/system/fmac_api.c b/fw_if/umac_if/src/system/fmac_api.c index 28d734e..052b177 100644 --- a/fw_if/umac_if/src/system/fmac_api.c +++ b/fw_if/umac_if/src/system/fmac_api.c @@ -9,8 +9,8 @@ * FMAC IF Layer of the Wi-Fi driver. */ -#include "host_rpu_umac_if.h" -#include "system/phy_rf_params.h" +#include "nrf71_wifi_ctrl.h" +#include "nrf71_wifi_rf.h" #include "system/fmac_api.h" #include "system/hal_api.h" #include "system/fmac_structs.h" @@ -24,7 +24,6 @@ #include "system/fmac_bb.h" #include "util.h" - static unsigned char nrf_wifi_fmac_vif_idx_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) { unsigned char i = 0; @@ -206,6 +205,13 @@ static enum nrf_wifi_status nrf_wifi_sys_fmac_fw_init(struct nrf_wifi_fmac_dev_c unsigned long start_time_us = 0; enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; struct nrf_wifi_sys_fmac_priv *sys_fpriv = NULL; +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF + struct nrf_wifi_rx_buf *rx_buf_ipc = NULL, *rx_buf_info_iter = NULL; + unsigned int desc_id = 0; + unsigned int buf_addr = 0; +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ sys_fpriv = wifi_fmac_priv(fmac_dev_ctx->fpriv); @@ -272,6 +278,40 @@ static enum nrf_wifi_status nrf_wifi_sys_fmac_fw_init(struct nrf_wifi_fmac_dev_c status = NRF_WIFI_STATUS_FAIL; goto out; } +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF + rx_buf_ipc = nrf_wifi_osal_mem_zalloc(sys_fpriv->num_rx_bufs * sizeof(struct nrf_wifi_rx_buf)); + rx_buf_info_iter = rx_buf_ipc; + for (desc_id = 0; desc_id < sys_fpriv->num_rx_bufs; desc_id++) { + buf_addr = (unsigned int) nrf_wifi_fmac_get_rx_buf_map_addr(fmac_dev_ctx, desc_id); + if (buf_addr) { + rx_buf_info_iter->skb_pointer = buf_addr; + rx_buf_info_iter->skb_desc_no = desc_id; + rx_buf_info_iter++; + } else { + nrf_wifi_osal_log_err("%s: UMAC rx buff not mapped\ + for desc_id = %d\n", desc_id, + __func__); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } + } + status = nrf_wifi_fmac_prog_rx_buf_info(fmac_dev_ctx, + rx_buf_ipc, + sys_fpriv->num_rx_bufs); + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: UMAC rx buff \ + programming failed \n", + __func__); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } else { + nrf_wifi_osal_log_dbg("%s Init rx buffs=%d programmed \n", + __func__, sys_fpriv->num_rx_bufs); + nrf_wifi_osal_mem_free(rx_buf_ipc); + } +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ status = NRF_WIFI_STATUS_SUCCESS; @@ -371,7 +411,6 @@ struct nrf_wifi_fmac_dev_ctx *nrf_wifi_sys_fmac_dev_add(struct nrf_wifi_fmac_pri return fmac_dev_ctx; } - enum nrf_wifi_status nrf_wifi_sys_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, #ifdef NRF_WIFI_LOW_POWER int sleep_type, @@ -386,9 +425,14 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fm { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; #ifndef NRF71_ON_IPC +#ifdef WIFI_NRF71 + struct nrf_wifi_phy_rf_params phy_rf_params = { 0}; + int ret = -1; +#else /* WIFI_NRF71 */ struct nrf_wifi_fmac_otp_info otp_info; -#endif /* !NRF71_ON_IPC */ struct nrf_wifi_phy_rf_params phy_rf_params; +#endif /* !WIFI_NRF71 */ +#endif /* !NRF71_ON_IPC */ if (!fmac_dev_ctx) { nrf_wifi_osal_log_err("%s: Invalid device context", @@ -416,6 +460,21 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fm } #ifndef NRF71_ON_IPC +#ifdef WIFI_NRF71 + nrf_wifi_osal_mem_set(&phy_rf_params, + 0x0, + sizeof(phy_rf_params)); + + ret = nrf_wifi_utils_hex_str_to_val( + (unsigned char *)&phy_rf_params.phy_params, + sizeof(phy_rf_params.phy_params), + NRF_WIFI_DEF_RF_PARAMS); + if (ret == -1) { + nrf_wifi_osal_log_err("%s: Initialization of RF params with default values failed", __func__); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } +#else /* WIFI_NRF71 */ nrf_wifi_osal_mem_set(&otp_info, 0xFF, sizeof(otp_info)); @@ -437,6 +496,7 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fm __func__); goto out; } +#endif /* !WIFI_NRF71 */ #endif /* !NRF71_ON_IPC */ status = nrf_wifi_sys_fmac_fw_init(fmac_dev_ctx, @@ -1045,6 +1105,255 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_disassoc(void *dev_ctx, return status; } +#ifdef WIFI_NRF71 +static void secure_crypto_reg_write(void *dev_ctx, + unsigned char *key, + unsigned int key_len, + unsigned int register_len, + unsigned long address_offset) +{ + struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + + fmac_dev_ctx = dev_ctx; + + status = hal_rpu_mem_write(fmac_dev_ctx->hal_dev_ctx, + RPU_ADDR_SECURERAM_REGION + address_offset, + key, + key_len); +} + +static void revMemCopy(unsigned char *dest, + unsigned char *src, + unsigned int size) +{ + unsigned int byteCnt = size; + + for (byteCnt = 0; byteCnt < size; byteCnt++) { + *(dest+byteCnt) = *(src+size-byteCnt - 1); + } +} + +static bool findValidPeerDBIndex(struct nrf_wifi_fmac_dev_ctx *dev_ctx, + struct nrf_wifi_umac_key_info *peer_key, + const char *mac_addr, + unsigned char if_idx, + unsigned char *peerDBIndex) +{ + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; + struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL; + bool peerKeyDbFound = 0; + unsigned char i, freeDB = 0xff; + struct peerKeydataBase *peerKeyDB = NULL; + + sys_dev_ctx = wifi_dev_priv(dev_ctx); + vif_ctx = sys_dev_ctx->vif_ctx[if_idx]; + + peerKeyDB = &sys_dev_ctx->peerKeyDB[0]; + + if (peer_key->key_type == NRF_WIFI_KEYTYPE_PAIRWISE) { + for (i = 0; i < MAX_PEERS; i++) { + if (nrf_wifi_util_ether_addr_equal(vif_ctx->mac_addr, + (peerKeyDB + i)->vifMacAddr) && + nrf_wifi_util_ether_addr_equal(mac_addr, + (peerKeyDB + i)->peerMacAddr) && + ((peerKeyDB + i)->keyValid == KEY_VALID)) { + peerKeyDbFound = 1; + *peerDBIndex = i; + break; + } + if ((peerKeyDB + i)->keyValid == KEY_INVALID && + (freeDB == 0xff)) { + freeDB = i; + } + } + if ((peerKeyDbFound == 0) && (freeDB < MAX_PEERS)) { + peerKeyDbFound = 1; + *peerDBIndex = freeDB; + nrf_wifi_osal_mem_cpy((peerKeyDB + freeDB)->peerMacAddr, + mac_addr, + NRF_WIFI_ETH_ADDR_LEN); + nrf_wifi_osal_mem_cpy((peerKeyDB + freeDB)->vifMacAddr, + vif_ctx->mac_addr, + NRF_WIFI_ETH_ADDR_LEN); + (peerKeyDB + freeDB)->keyValid = KEY_VALID; + } + + if (peerKeyDbFound) { + return 1; + } + } else { + if (vif_ctx->if_type == NRF_WIFI_IFTYPE_STATION) { + for (i = 0; i < MAX_PEERS; i++) { + if (nrf_wifi_util_ether_addr_equal( + vif_ctx->mac_addr, + (peerKeyDB + i)->vifMacAddr) && + nrf_wifi_util_ether_addr_equal( + vif_ctx->bssid, + (peerKeyDB + i)->peerMacAddr) && + ((peerKeyDB + i)->keyValid == KEY_VALID)) { + peerKeyDbFound = 1; + *peerDBIndex = i; + break; + } + if ((peerKeyDB + i)->keyValid == KEY_INVALID && + (freeDB == 0xff)) { + freeDB = i; + } + } + if ((peerKeyDbFound == 0) && (freeDB < MAX_PEERS)) { + peerKeyDbFound = 1; + *peerDBIndex = freeDB; + nrf_wifi_osal_mem_cpy( + (peerKeyDB + freeDB)->peerMacAddr, + vif_ctx->bssid, + NRF_WIFI_ETH_ADDR_LEN); + nrf_wifi_osal_mem_cpy( + (peerKeyDB + freeDB)->vifMacAddr, + vif_ctx->mac_addr, + NRF_WIFI_ETH_ADDR_LEN); + (peerKeyDB + freeDB)->keyValid = KEY_VALID; + } + if (peerKeyDbFound) { + return 1; + } + } + } + return 0; +} + +static bool program_peer_key(struct nrf_wifi_fmac_dev_ctx *dev_ctx, + struct nrf_wifi_umac_key_info *peer_key, + unsigned char if_idx, + const char *mac_addr, + unsigned char *peerDBIndex) +{ + unsigned char micKeyLen = 0, index = 0; + unsigned int validDB = 0; + unsigned char *ptr, *micptr; + unsigned long address_offset; + struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; + struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL; + struct peerKeydataBase *peerKeyDB = NULL; + + sys_dev_ctx = wifi_dev_priv(dev_ctx); + vif_ctx = sys_dev_ctx->vif_ctx[if_idx]; + + validDB = findValidPeerDBIndex(dev_ctx, + peer_key, mac_addr, if_idx, peerDBIndex); + + if (validDB) { + index = *peerDBIndex; + peerKeyDB = &sys_dev_ctx->peerKeyDB[index]; + /* UNICAST */ + if (peer_key->key_type == NRF_WIFI_KEYTYPE_PAIRWISE) { + switch (peer_key->cipher_suite) { + case NRF_WIFI_FMAC_CIPHER_SUITE_SMS4: + micKeyLen = PEER_MIC_KEY_LEN_16; + revMemCopy(peerKeyDB->ucstWapiMicKey, + peer_key->key.nrf_wifi_key, + PEER_MIC_KEY_LEN_16); + micptr = peerKeyDB->ucstWapiMicKey; + break; + case NRF_WIFI_FMAC_CIPHER_SUITE_TKIP: + micKeyLen = PEER_MIC_KEY_LEN_8; + revMemCopy(peerKeyDB->ucst.TxMicKey, + peer_key->key.nrf_wifi_key, + PEER_MIC_KEY_LEN_8); + revMemCopy(peerKeyDB->ucst.RxMicKey, + peer_key->key.nrf_wifi_key, + PEER_MIC_KEY_LEN_8); + micptr = peerKeyDB->ucst.TxMicKey; + break; + default: + micKeyLen = 0; + } + if ((peer_key->cipher_suite == + NRF_WIFI_FMAC_CIPHER_SUITE_CCMP_256) || + (peer_key->cipher_suite == + NRF_WIFI_FMAC_CIPHER_SUITE_GCMP_256)) { + revMemCopy(peerKeyDB->ucstKey, + peer_key->key.nrf_wifi_key, + PEER_ENC_KEY_LEN_32); + } else { + revMemCopy(peerKeyDB->ucstKey, + peer_key->key.nrf_wifi_key, + PEER_ENC_KEY_LEN_16); + } + if (micKeyLen) { + address_offset = index * (PEER_KEY_TOTAL_LEN); + secure_crypto_reg_write(dev_ctx, + micptr, + micKeyLen, + 4, + address_offset); + } else { + address_offset = index * (PEER_KEY_TOTAL_LEN) + + PEER_MIC_KEY_LEN_16; + ptr = peerKeyDB->ucstKey; + secure_crypto_reg_write(dev_ctx, + ptr, + 32, + 4, + address_offset); + } + } else if (peer_key->key_type == NRF_WIFI_KEYTYPE_GROUP) { + switch (peer_key->cipher_suite) { + case NRF_WIFI_FMAC_CIPHER_SUITE_SMS4: + micKeyLen = PEER_MIC_KEY_LEN_16; + revMemCopy(peerKeyDB->bcstWapiMicKey, + peer_key->key.nrf_wifi_key, + PEER_ENC_KEY_LEN_16); + micptr = peerKeyDB->bcstWapiMicKey; + break; + case NRF_WIFI_FMAC_CIPHER_SUITE_TKIP: + micKeyLen = PEER_MIC_KEY_LEN_8; + revMemCopy(peerKeyDB->bcst.RxMicKey, + peer_key->key.nrf_wifi_key, + PEER_MIC_KEY_LEN_8); + micptr = peerKeyDB->bcst.RxMicKey; + break; + default: + micKeyLen = 0; + break; + } + if ((peer_key->cipher_suite == + NRF_WIFI_FMAC_CIPHER_SUITE_CCMP_256) || + (peer_key->cipher_suite == + NRF_WIFI_FMAC_CIPHER_SUITE_GCMP_256)) { + revMemCopy(peerKeyDB->bcstKey, + peer_key->key.nrf_wifi_key, + PEER_ENC_KEY_LEN_32); + } else { + revMemCopy(peerKeyDB->bcstKey, + peer_key->key.nrf_wifi_key, + PEER_ENC_KEY_LEN_16); + } + if (micKeyLen) { + address_offset = index * (PEER_KEY_TOTAL_LEN) + + PEER_MIC_KEY_LEN_16 + PEER_UNICAST_KEY_LEN + + (peer_key->key_idx * PEER_MIC_KEY_LEN_16); + + secure_crypto_reg_write(dev_ctx, + micptr, + micKeyLen, + 4, + address_offset); + } else { + ptr = peerKeyDB->bcstKey; + address_offset = index * (PEER_KEY_TOTAL_LEN) + + PEER_MIC_KEY_LEN_16 + PEER_UNICAST_KEY_LEN + + (4 * PEER_MIC_KEY_LEN_16) + + (peer_key->key_idx * PEER_BCST_KEY_LEN); + + secure_crypto_reg_write(dev_ctx, + ptr, 32, 4, address_offset); + } + } + } + return validDB; +} +#endif /* WIFI_NRF71 */ enum nrf_wifi_status nrf_wifi_sys_fmac_add_key(void *dev_ctx, unsigned char if_idx, @@ -1057,7 +1366,9 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_add_key(void *dev_ctx, struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL; int peer_id = -1; - +#ifdef WIFI_NRF71 + bool validDB = 0; +#endif /* WIFI_NRF71 */ fmac_dev_ctx = dev_ctx; if (fmac_dev_ctx->op_mode != NRF_WIFI_OP_MODE_SYS) { @@ -1124,6 +1435,18 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_add_key(void *dev_ctx, key_cmd->key_info.valid_fields |= NRF_WIFI_CIPHER_SUITE_VALID; key_cmd->key_info.valid_fields |= NRF_WIFI_KEY_TYPE_VALID; +#ifdef WIFI_NRF71 + validDB = program_peer_key(fmac_dev_ctx, + key_info, if_idx, mac_addr, &key_cmd->peerDBIndex); + + if (!validDB) { + nrf_wifi_osal_log_err("%s: Not able to store program key %d", + __func__, + key_info->key_type); + goto out; + } +#endif /* WIFI_NRF71 */ + status = umac_cmd_cfg(fmac_dev_ctx, key_cmd, sizeof(*key_cmd)); @@ -1146,6 +1469,10 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_del_key(void *dev_ctx, struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL; struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; +#ifdef WIFI_NRF71 + struct peerKeydataBase *peerKeyDB = NULL; + unsigned int i, peerKeyDbFound = 0, peerDBIndex; +#endif /* WIFI_NRF71 */ fmac_dev_ctx = dev_ctx; @@ -1190,6 +1517,48 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_del_key(void *dev_ctx, vif_ctx->groupwise_cipher = 0; } +#ifdef WIFI_NRF71 + peerKeyDB = &sys_dev_ctx->peerKeyDB[0]; + + for (i = 0; i < MAX_PEERS; i++) { + /* If Peer mac address is available(Mostly in AP case) */ + if (mac_addr) { + if (nrf_wifi_util_ether_addr_equal( + vif_ctx->mac_addr, + (peerKeyDB + i)->vifMacAddr) && + nrf_wifi_util_ether_addr_equal(mac_addr, + (peerKeyDB + i)->peerMacAddr) && + ((peerKeyDB + i)->keyValid == KEY_VALID)) { + peerKeyDbFound = 1; + } + } else { + if (nrf_wifi_util_ether_addr_equal(vif_ctx->mac_addr, + (peerKeyDB + i)->vifMacAddr) && + ((peerKeyDB + i)->keyValid == KEY_VALID)) { + peerKeyDbFound = 1; + } + } + if (peerKeyDbFound) { + peerDBIndex = i; + break; + } + } + + if (peerKeyDbFound) { + peerKeyDB = &sys_dev_ctx->peerKeyDB[peerDBIndex]; + if (key_info->key_type == NRF_WIFI_KEYTYPE_PAIRWISE) { + peerKeyDB->ucstCipherType = WLAN_OPER_INVALID; + } else { + peerKeyDB->bcstCipherType = WLAN_OPER_INVALID; + } + } + + if ((peerKeyDB->ucstCipherType == WLAN_OPER_INVALID) && + (peerKeyDB->bcstCipherType == WLAN_OPER_INVALID)) { + peerKeyDB->keyValid = KEY_INVALID; + } +#endif /* WIFI_NRF71 */ + status = umac_cmd_cfg(fmac_dev_ctx, key_cmd, sizeof(*key_cmd)); @@ -1210,6 +1579,9 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_set_key(void *dev_ctx, enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; struct nrf_wifi_umac_cmd_set_key *set_key_cmd = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; +#ifdef WIFI_NRF71 + unsigned long address_offset; +#endif /* WIFI_NRF71 */ fmac_dev_ctx = dev_ctx; @@ -1236,6 +1608,18 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_set_key(void *dev_ctx, sizeof(set_key_cmd->key_info)); set_key_cmd->key_info.valid_fields |= NRF_WIFI_KEY_IDX_VALID; +#ifdef WIFI_NRF71 + address_offset = (VIF_KEY_DB_OFFSET + (if_idx * + (VIF_MIC_KEY_LEN_PER_VIF + VIF_KEY_LEN_PER_VIF)) + + VIF_MIC_KEY_LEN_PER_VIF + + key_info->key_idx * (VIF_KEY_LEN_PER_KEYID)); + + secure_crypto_reg_write(fmac_dev_ctx, + key_info->key.nrf_wifi_key, + key_info->key.nrf_wifi_key_len, + 4, + address_offset); +#endif /* WIFI_NRF71 */ status = umac_cmd_cfg(fmac_dev_ctx, set_key_cmd, @@ -3405,11 +3789,14 @@ static int nrf_wifi_sys_fmac_phy_rf_params_init(struct nrf_wifi_phy_rf_params *p unsigned char *str) { int ret = -1; +#ifndef WIFI_NRF71 unsigned int rf_param_offset = BAND_2G_LW_ED_BKF_DSSS_OFST - NRF_WIFI_RF_PARAMS_CONF_SIZE; +#endif /* !WIFI_NRF71 */ /* Initilaize reserved bytes */ nrf_wifi_osal_mem_set(prf, 0x0, sizeof(prf)); +#ifndef WIFI_NRF71 /* Initialize PD adjust values for MCS7. Currently these 4 bytes are not being used */ prf->pd_adjust_val.pd_adjt_lb_chan = PD_ADJUST_VAL; prf->pd_adjust_val.pd_adjt_hb_low_chan = PD_ADJUST_VAL; @@ -3530,7 +3917,7 @@ static int nrf_wifi_sys_fmac_phy_rf_params_init(struct nrf_wifi_phy_rf_params *p prf->phy_params[rf_param_offset + 31] = NRF70_PCB_LOSS_5G_BAND1; prf->phy_params[rf_param_offset + 32] = NRF70_PCB_LOSS_5G_BAND2; prf->phy_params[rf_param_offset + 33] = NRF70_PCB_LOSS_5G_BAND3; - +#endif /* !WIFI_NRF71 */ return(ret); } @@ -3545,9 +3932,10 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_rf_params_get(struct nrf_wifi_fmac_dev_ct /* If package_info is not written to OTP then the default value will be 0xFF. */ unsigned int package_info = 0xFFFFFFFF; struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params; +#ifndef WIFI_NRF71 unsigned char backoff_2g_dsss = 0, backoff_2g_ofdm = 0; unsigned char backoff_5g_lowband = 0, backoff_5g_midband = 0, backoff_5g_highband = 0; - +#endif /* !WIFI_NRF71 */ if (!fmac_dev_ctx || !phy_rf_params) { nrf_wifi_osal_log_err("%s: Invalid parameters", __func__); @@ -3594,19 +3982,23 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_rf_params_get(struct nrf_wifi_fmac_dev_ct ret = nrf_wifi_sys_fmac_phy_rf_params_init(phy_rf_params, package_info, - NRF_WIFI_SYS_DEF_RF_PARAMS); - +#ifndef WIFI_NRF71 + NRF_WIFI_SYS_DEF_RF_PARAMS +#else + NRF_WIFI_DEF_RF_PARAMS +#endif /*! WIFI_NRF71 */ + ); if (ret == -1) { nrf_wifi_osal_log_err("%s: Initialization of RF params with default values failed", __func__); status = NRF_WIFI_STATUS_FAIL; goto out; } +#ifndef WIFI_NRF71 if (!(otp_info.flags & (~CALIB_XO_FLAG_MASK))) { nrf_wifi_osal_mem_cpy(&phy_rf_params->xo_offset.xo_freq_offset, (char *)otp_info.info.calib + OTP_OFF_CALIB_XO, OTP_SZ_CALIB_XO); - } ft_prog_ver = (ft_prog_ver & FT_PROG_VER_MASK) >> 16; @@ -3659,7 +4051,7 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_rf_params_get(struct nrf_wifi_fmac_dev_ct MIN(tx_pwr_ceil_params->max_pwr_5g_high_mcs0, phy_rf_params->max_pwr_ceil.max_hb_high_chan_mcs0_pwr) - backoff_5g_highband; #endif /* NRF70_2_4G_ONLY */ - +#endif /* !WIFI_NRF71 */ status = NRF_WIFI_STATUS_SUCCESS; out: return status; @@ -3907,3 +4299,79 @@ enum nrf_wifi_status nrf_wifi_sys_fmac_get_host_rpu_ps_ctrl_state(void *dev_ctx, } #endif /* NRF_WIFI_LOW_POWER */ #endif /* NRF70_UTIL */ + +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF +#define MAX_BUFS_PER_CMD 32 +enum nrf_wifi_status nrf_wifi_fmac_prog_rx_buf_info(void *dev_ctx, + struct nrf_wifi_rx_buf *rx_buf, + unsigned int rx_buf_nums) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_cmd_rx_buf_info *rx_buf_cmd = NULL; + struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; + struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + struct nrf_wifi_rx_buf *remained_buf = NULL, *rx_buf_iter = NULL; + int i = 0, remained_buf_cnt = 0, counter = 0, rx_buff_prog_cnt = 0; + fmac_dev_ctx = dev_ctx; + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + if (rx_buf_nums > MAX_BUFS_PER_CMD) { + rx_buff_prog_cnt = MAX_BUFS_PER_CMD; + remained_buf_cnt = rx_buf_nums % MAX_BUFS_PER_CMD; + counter = rx_buf_nums / MAX_BUFS_PER_CMD; + } else { + rx_buff_prog_cnt = rx_buf_nums; + counter = 1; + } + rx_buf_iter = rx_buf; + for (i = 0; i < counter; i++) { + rx_buf_cmd = nrf_wifi_osal_mem_zalloc(sizeof(*rx_buf_cmd) + + rx_buff_prog_cnt * sizeof(struct nrf_wifi_rx_buf)); + if (!rx_buf_cmd) { + nrf_wifi_osal_log_err("%s: Unable to allocate memory\n", + __func__); + goto out; + } + + rx_buf_cmd->umac_hdr.cmd_evnt = NRF_WIFI_UMAC_CMD_CONFIG_RX_BUF; + nrf_wifi_osal_mem_cpy(&rx_buf_cmd->info, + rx_buf, + rx_buff_prog_cnt * sizeof(struct nrf_wifi_rx_buf)); + + rx_buf_cmd->rx_buf_num = rx_buff_prog_cnt; + + status = umac_cmd_cfg(fmac_dev_ctx, + rx_buf_cmd, + sizeof(*rx_buf_cmd) + rx_buff_prog_cnt * sizeof(struct nrf_wifi_rx_buf)); + if (rx_buf_cmd) { + nrf_wifi_osal_mem_free(rx_buf_cmd); + } + } + if (remained_buf_cnt > 0) { + rx_buf_cmd = nrf_wifi_osal_mem_zalloc(sizeof(*rx_buf_cmd) + + remained_buf_cnt * sizeof(struct nrf_wifi_rx_buf)); + if (!rx_buf_cmd) { + nrf_wifi_osal_log_err("%s: Unable to allocate memory\n", + __func__); + goto out; + } + + rx_buf_cmd->umac_hdr.cmd_evnt = NRF_WIFI_UMAC_CMD_CONFIG_RX_BUF; + nrf_wifi_osal_mem_cpy(&rx_buf_cmd->info, + rx_buf + (MAX_BUFS_PER_CMD), + remained_buf_cnt * sizeof(struct nrf_wifi_rx_buf)); + + rx_buf_cmd->rx_buf_num = remained_buf_cnt; + + status = umac_cmd_cfg(fmac_dev_ctx, + rx_buf_cmd, + sizeof(*rx_buf_cmd) + remained_buf_cnt * sizeof(struct nrf_wifi_rx_buf)); + if (rx_buf_cmd) { + nrf_wifi_osal_mem_free(rx_buf_cmd); + } + } +out: + return status; +} +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ diff --git a/fw_if/umac_if/src/system/fmac_cmd.c b/fw_if/umac_if/src/system/fmac_cmd.c index 4f0b588..2d3bf59 100644 --- a/fw_if/umac_if/src/system/fmac_cmd.c +++ b/fw_if/umac_if/src/system/fmac_cmd.c @@ -9,6 +9,7 @@ * system mode in the FMAC IF Layer of the Wi-Fi driver. */ +#include "nrf71_wifi_rf.h" #include "system/fmac_structs.h" #include "system/fmac_cmd.h" #include "common/fmac_util.h" @@ -58,11 +59,14 @@ enum nrf_wifi_status umac_cmd_sys_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ct if (rf_params_valid) { nrf_wifi_osal_mem_cpy(umac_cmd_data->sys_params.rf_params, +#ifdef WIFI_NRF71 + rf_params->phy_params, +#else rf_params, +#endif /* WIFI_NRF71 */ NRF_WIFI_RF_PARAMS_SIZE); } - umac_cmd_data->sys_params.phy_calib = phy_calib; umac_cmd_data->sys_params.hw_bringup_time = HW_DELAY; umac_cmd_data->sys_params.sw_bringup_time = SW_DELAY; @@ -117,18 +121,18 @@ enum nrf_wifi_status umac_cmd_sys_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ct umac_cmd_data->op_band = op_band; - nrf_wifi_osal_mem_cpy(&umac_cmd_data->sys_params.rf_params[PCB_LOSS_BYTE_2G_OFST], - &board_params->pcb_loss_2g, - NUM_PCB_LOSS_OFFSET); - nrf_wifi_osal_mem_cpy(&umac_cmd_data->sys_params.rf_params[ANT_GAIN_2G_OFST], &tx_pwr_ctrl_params->ant_gain_2g, NUM_ANT_GAIN); +#ifndef WIFI_NRF71 + nrf_wifi_osal_mem_cpy(&umac_cmd_data->sys_params.rf_params[PCB_LOSS_BYTE_2G_OFST], + &board_params->pcb_loss_2g, + NUM_PCB_LOSS_OFFSET); nrf_wifi_osal_mem_cpy(&umac_cmd_data->sys_params.rf_params[BAND_2G_LW_ED_BKF_DSSS_OFST], &tx_pwr_ctrl_params->band_edge_2g_lo_dss, NUM_EDGE_BACKOFF); - +#endif /* !WIFI_NRF71 */ nrf_wifi_osal_mem_cpy(umac_cmd_data->country_code, country_code, NRF_WIFI_COUNTRY_CODE_LEN); @@ -158,25 +162,26 @@ enum nrf_wifi_status umac_cmd_sys_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ct umac_cmd_data->coex_disable_ptiwin_for_wifi_scan = 0; #endif /* NRF_WIFI_COEX_DISABLE_PRIORITY_WINDOW_FOR_SCAN */ +#ifndef WIFI_NRF71 #ifdef WIFI_MGMT_RAW_SCAN_RESULTS umac_cmd_data->raw_scan_enable = 1; #else umac_cmd_data->raw_scan_enable = 0; #endif /* WIFI_MGMT_RAW_SCAN_RESULTS */ - +#endif /* !WIFI_NRF71 */ umac_cmd_data->max_ps_poll_fail_cnt = NRF_WIFI_MAX_PS_POLL_FAIL_CNT; - #ifdef NRF_WIFI_RX_STBC_HT - umac_cmd_data->stbc_enable_in_ht = 1; - #endif /* NRF_WIFI_RX_STBC_HT */ +#ifdef NRF_WIFI_RX_STBC_HT + umac_cmd_data->stbc_enable_in_ht = 1; +#endif /* NRF_WIFI_RX_STBC_HT */ - #ifdef NRF_WIFI_DYNAMIC_BANDWIDTH_SIGNALLING - umac_cmd_data->dbs_war_ctrl = 1; - #endif /* NRF_WIFI_DYNAMIC_BANDWIDTH_SIGNALLING */ +#ifdef NRF_WIFI_DYNAMIC_BANDWIDTH_SIGNALLING + umac_cmd_data->dbs_war_ctrl = 1; +#endif /* NRF_WIFI_DYNAMIC_BANDWIDTH_SIGNALLING */ - #ifdef NRF_WIFI_DYNAMIC_ED - umac_cmd_data->dynamic_ed = 1; - #endif /* NRF_WIFI_DYNAMIC_ED */ +#ifdef NRF_WIFI_DYNAMIC_ED + umac_cmd_data->dynamic_ed = 1; +#endif /* NRF_WIFI_DYNAMIC_ED */ status = nrf_wifi_hal_ctrl_cmd_send(fmac_dev_ctx->hal_dev_ctx, umac_cmd, diff --git a/fw_if/umac_if/src/system/fmac_event.c b/fw_if/umac_if/src/system/fmac_event.c index a9d5792..f72e816 100644 --- a/fw_if/umac_if/src/system/fmac_event.c +++ b/fw_if/umac_if/src/system/fmac_event.c @@ -11,7 +11,7 @@ */ #include "queue.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "common/hal_mem.h" #include "system/fmac_rx.h" #include "system/fmac_tx.h" diff --git a/fw_if/umac_if/src/system/fmac_peer.c b/fw_if/umac_if/src/system/fmac_peer.c index 19147b5..2bf2ff9 100644 --- a/fw_if/umac_if/src/system/fmac_peer.c +++ b/fw_if/umac_if/src/system/fmac_peer.c @@ -11,7 +11,7 @@ #include "common/hal_mem.h" #include "system/fmac_peer.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "common/fmac_util.h" int nrf_wifi_fmac_peer_get_id(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, @@ -82,7 +82,11 @@ int nrf_wifi_fmac_peer_add(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, if (vif_ctx->if_type == NRF_WIFI_IFTYPE_AP) { hal_rpu_mem_write(fmac_dev_ctx->hal_dev_ctx, (RPU_MEM_UMAC_PEND_Q_BMP + +#ifndef WIFI_NRF71 sizeof(struct sap_client_pend_frames_bitmap) * i), +#else + sizeof(struct sap_pend_frames_bitmap) * i), +#endif peer->ra_addr, NRF_WIFI_FMAC_ETH_ADDR_LEN); } @@ -123,7 +127,11 @@ void nrf_wifi_fmac_peer_remove(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, if (vif_ctx->if_type == NRF_WIFI_IFTYPE_AP) { hal_rpu_mem_write(fmac_dev_ctx->hal_dev_ctx, (RPU_MEM_UMAC_PEND_Q_BMP + +#ifdef WIFI_NRF71 + (sizeof(struct sap_pend_frames_bitmap) * peer_id)), +#else (sizeof(struct sap_client_pend_frames_bitmap) * peer_id)), +#endif peer->ra_addr, NRF_WIFI_FMAC_ETH_ADDR_LEN); } @@ -164,7 +172,11 @@ void nrf_wifi_fmac_peers_flush(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, if (vif_ctx->if_type == NRF_WIFI_IFTYPE_AP) { hal_rpu_mem_write(fmac_dev_ctx->hal_dev_ctx, (RPU_MEM_UMAC_PEND_Q_BMP + +#ifdef WIFI_NRF71 + sizeof(struct sap_pend_frames_bitmap) * i), +#else sizeof(struct sap_client_pend_frames_bitmap) * i), +#endif peer->ra_addr, NRF_WIFI_FMAC_ETH_ADDR_LEN); } diff --git a/fw_if/umac_if/src/system/fmac_vif.c b/fw_if/umac_if/src/system/fmac_vif.c index 3119c5f..76fbb8c 100644 --- a/fw_if/umac_if/src/system/fmac_vif.c +++ b/fw_if/umac_if/src/system/fmac_vif.c @@ -10,7 +10,7 @@ */ #include "system/fmac_vif.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #include "common/fmac_util.h" diff --git a/fw_if/umac_if/src/system/rx.c b/fw_if/umac_if/src/system/rx.c index 8cb1bc1..4497701 100644 --- a/fw_if/umac_if/src/system/rx.c +++ b/fw_if/umac_if/src/system/rx.c @@ -13,6 +13,11 @@ #include "system/fmac_rx.h" #include "common/fmac_util.h" #include "system/fmac_promisc.h" +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF +#include "system/fmac_api.h" +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ static enum nrf_wifi_status nrf_wifi_fmac_map_desc_to_pool(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, @@ -164,7 +169,45 @@ static void nrf_wifi_convert_to_eth(void *nwb, } } #endif /* NRF70_STA_MODE */ - +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF +unsigned long nrf_wifi_fmac_get_rx_buf_map_addr(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, + unsigned int desc_id) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_sys_fmac_dev_ctx *def_dev_ctx = NULL; + struct nrf_wifi_fmac_priv_def *def_priv = NULL; + struct nrf_wifi_fmac_buf_map_info *rx_buf_info = NULL; + struct nrf_wifi_fmac_rx_pool_map_info pool_info; + unsigned long nwb_data = 0; + unsigned long phy_addr = 0; + + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv); + status = nrf_wifi_fmac_map_desc_to_pool(fmac_dev_ctx, + desc_id, + &pool_info); + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: nrf_wifi_fmac_map_desc_to_pool failed\n", + __func__); + goto out; + } + rx_buf_info = &def_dev_ctx->rx_buf_info[desc_id]; + if (rx_buf_info->mapped) { + phy_addr = nrf_wifi_hal_get_buf_map_rx(fmac_dev_ctx->hal_dev_ctx, + pool_info.pool_id, + pool_info.buf_id); + return phy_addr; + } else { + nrf_wifi_osal_log_err("%s: rx buffer not mapped for desc_id= %d\n", + __func__, + desc_id); + } +out: + return 0; +} +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ enum nrf_wifi_status nrf_wifi_fmac_rx_cmd_send(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, enum nrf_wifi_fmac_rx_cmd_type cmd_type, unsigned int desc_id) @@ -245,12 +288,23 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_cmd_send(struct nrf_wifi_fmac_dev_ctx *fma #else rx_cmd.addr = (unsigned int)nwb_data; #endif /* NRF71_ON_IPC */ +#ifdef WIFI_NRF71 +#ifndef CMD_RX_BUFF + status = nrf_wifi_hal_data_cmd_send(fmac_dev_ctx->hal_dev_ctx, + NRF_WIFI_HAL_MSG_TYPE_CMD_DATA_RX, + &rx_cmd, + sizeof(rx_cmd), + desc_id, + pool_info.pool_id); +#endif /* !CMD_RX_BUFF */ +#else status = nrf_wifi_sys_hal_data_cmd_send(fmac_dev_ctx->hal_dev_ctx, NRF_WIFI_HAL_MSG_TYPE_CMD_DATA_RX, &rx_cmd, sizeof(rx_cmd), desc_id, pool_info.pool_id); +#endif /* WIFI_NRF71 */ } else if (cmd_type == NRF_WIFI_FMAC_RX_CMD_TYPE_DEINIT) { #ifndef NRF71_ON_IPC /* TODO: Need to initialize a command and send it to LMAC @@ -359,7 +413,12 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx #endif /* NRF70_STA_MODE */ struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL; struct nrf_wifi_sys_fmac_priv *sys_fpriv = NULL; - +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF + unsigned int buf_addr = 0; + struct nrf_wifi_rx_buf *rx_buf_ipc = NULL, *rx_buf_info_iter = NULL; +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ sys_dev_ctx = wifi_dev_priv(fmac_dev_ctx); sys_fpriv = wifi_fmac_priv(fmac_dev_ctx->fpriv); @@ -372,7 +431,12 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx } #endif /* NRF70_STA_MODE */ num_pkts = config->rx_pkt_cnt; - +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF + rx_buf_ipc = nrf_wifi_osal_mem_zalloc(num_pkts * sizeof(struct nrf_wifi_rx_buf)); + rx_buf_info_iter = rx_buf_ipc; +#endif /* CMD_RX_BUFF */ +#endif /* NRF_WIFI71 */ for (i = 0; i < num_pkts; i++) { desc_id = config->rx_buff_info[i].descriptor_id; pkt_len = config->rx_buff_info[i].rx_pkt_len; @@ -548,8 +612,43 @@ enum nrf_wifi_status nrf_wifi_fmac_rx_event_process(struct nrf_wifi_fmac_dev_ctx __func__); continue; } +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF + buf_addr = (unsigned int) nrf_wifi_fmac_get_rx_buf_map_addr(fmac_dev_ctx, desc_id); + if (buf_addr) { + rx_buf_info_iter->skb_pointer = buf_addr; + rx_buf_info_iter->skb_desc_no = desc_id; + rx_buf_info_iter++; + } else { + nrf_wifi_osal_log_err("%s: UMAC rx buff not mapped\ + for desc_id = %d\n", desc_id, + __func__); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ } - +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF + status = nrf_wifi_fmac_prog_rx_buf_info(fmac_dev_ctx, + rx_buf_ipc, + num_pkts); + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: UMAC rx buff\ + programming failed \n", + __func__); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } else { + nrf_wifi_osal_log_dbg("%s: UMAC rx buff refill\ + programmed for num_buffs= %d \n", + __func__, num_pkts); + nrf_wifi_osal_mem_free(rx_buf_ipc); + } +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ +out: /* A single failure returns failure for the entire event */ return status; } diff --git a/fw_if/umac_if/src/system/tx.c b/fw_if/umac_if/src/system/tx.c index a6b0a2f..c69f4e6 100644 --- a/fw_if/umac_if/src/system/tx.c +++ b/fw_if/umac_if/src/system/tx.c @@ -241,11 +241,19 @@ static enum nrf_wifi_status update_pend_q_bmp(struct nrf_wifi_fmac_dev_ctx *fmac if (vif_ctx->if_type == NRF_WIFI_IFTYPE_AP && peer_id < MAX_PEERS) { +#ifdef WIFI_NRF71 + const unsigned int bitmap_offset = offsetof(struct sap_pend_frames_bitmap, + pend_frames_bitmap); + const unsigned char *rpu_addr = (unsigned char *)RPU_MEM_UMAC_PEND_Q_BMP + + (sizeof(struct sap_pend_frames_bitmap) * peer_id) + + bitmap_offset; +#else const unsigned int bitmap_offset = offsetof(struct sap_client_pend_frames_bitmap, pend_frames_bitmap); const unsigned char *rpu_addr = (unsigned char *)RPU_MEM_UMAC_PEND_Q_BMP + (sizeof(struct sap_client_pend_frames_bitmap) * peer_id) + bitmap_offset; +#endif bmp = &sys_dev_ctx->tx_config.peers[peer_id].pend_q_bmp; pend_pkt_q = sys_dev_ctx->tx_config.data_pending_txq[peer_id][ac]; @@ -685,8 +693,15 @@ enum nrf_wifi_status rawtx_cmd_prep_callbk_fn(void *callbk_data, tx_buf_info->nwb = nwb; tx_buf_info->mapped = true; +#ifdef WIFI_NRF71 + config->raw_tx_info.frame_ddr_pointer[0] = (unsigned long long)phy_addr; + config->raw_tx_info.pkt_length[0] = buf_len; + config->raw_tx_info.num_frames = 1; + config->raw_tx_info.aggregation = 0; +#else config->raw_tx_info.frame_ddr_pointer = (unsigned long long)phy_addr; config->raw_tx_info.pkt_length = buf_len; +#endif #else tx_buf_info->nwb = nwb; tx_buf_info->mapped = true; @@ -819,7 +834,14 @@ enum nrf_wifi_status rawtx_cmd_prepare(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ct config->sys_head.len = sizeof(*config); config->if_index = vif_id; config->raw_tx_info.desc_num = desc; + +#ifdef WIFI_NRF71 + config->raw_tx_info.num_frames = 1; + config->raw_tx_info.aggregation = 0; + config->raw_tx_info.pkt_length[0] = len; +#else config->raw_tx_info.pkt_length = len; +#endif /* Check first packet in queue for per-packet raw TX config */ void *first_nwb = nrf_wifi_utils_list_peek(txq); diff --git a/hw_if/hal/inc/common/hal_api_common.h b/hw_if/hal/inc/common/hal_api_common.h index 8710f0a..96f65f5 100644 --- a/hw_if/hal/inc/common/hal_api_common.h +++ b/hw_if/hal/inc/common/hal_api_common.h @@ -236,4 +236,11 @@ enum nrf_wifi_status hal_rpu_msg_post(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, enum NRF_WIFI_HAL_MSG_TYPE msg_type, unsigned int queue_id, unsigned int msg_addr); +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF +unsigned long nrf_wifi_hal_get_buf_map_rx(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int pool_id, + unsigned int buf_id); +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ #endif /* __HAL_API_COMMON_H__ */ diff --git a/hw_if/hal/inc/common/hal_mem.h b/hw_if/hal/inc/common/hal_mem.h index 41b83d5..7f3dee3 100644 --- a/hw_if/hal/inc/common/hal_mem.h +++ b/hw_if/hal/inc/common/hal_mem.h @@ -20,6 +20,14 @@ * Enum defining the types of RPU memory. */ enum HAL_RPU_MEM_TYPE { +#ifdef WIFI_NRF71 + HAL_RPU_MEM_TYPE_RAM_0, + HAL_RPU_MEM_TYPE_RAM_1, + HAL_RPU_MEM_TYPE_ROM_0, + HAL_RPU_MEM_TYPE_ROM_1, + HAL_RPU_MEM_TYPE_DATA_RAM, + HAL_RPU_MEM_TYPE_CODE_RAM, +#else /* WIFI_NRF71 */ /** GRAM memory type */ HAL_RPU_MEM_TYPE_GRAM, /** PKTRAM memory type */ @@ -31,6 +39,7 @@ enum HAL_RPU_MEM_TYPE { /** Core SCRATCH memory type */ HAL_RPU_MEM_TYPE_CORE_SCRATCH, /** Maximum number of memory types */ +#endif /* !WIFI_NRF71 */ HAL_RPU_MEM_TYPE_MAX }; @@ -79,6 +88,31 @@ enum nrf_wifi_status hal_rpu_mem_write(struct nrf_wifi_hal_dev_ctx *hal_ctx, unsigned int rpu_mem_addr, void *host_addr, unsigned int len); +#ifdef WIFI_NRF71 +/** + * @brief Write to the RPU Code memory. + * + * This function writes a specified number of bytes to the RPU code memory + * from the host memory. + * + * @param hal_ctx Pointer to HAL context. + * @param rpu_mem_addr Absolute value of the RPU code memory address where the + * contents are to be written. + * @param host_addr Pointer to the host memory from where the contents are + * to be copied to the RPU memory. + * @param len The length (in bytes) of the contents to be copied to + * the RPU memory. + * + * @return Status + * - Pass: NRF_WIFI_STATUS_SUCCESS + * - Error: NRF_WIFI_STATUS_FAIL + */ +enum nrf_wifi_status hal_rpu_mem_code_write( + struct nrf_wifi_hal_dev_ctx *hal_ctx, + unsigned int rpu_mem_addr, + void *host_addr, + unsigned int len); +#endif /* WIFI_NRF71 */ /** * @brief Clear contents of RPU memory. diff --git a/hw_if/hal/inc/common/hal_structs_common.h b/hw_if/hal/inc/common/hal_structs_common.h index 550c490..21b4ef2 100644 --- a/hw_if/hal/inc/common/hal_structs_common.h +++ b/hw_if/hal/inc/common/hal_structs_common.h @@ -13,8 +13,16 @@ #ifndef __HAL_STRUCTS_COMMON_H__ #define __HAL_STRUCTS_COMMON_H__ +#ifdef WIFI_NRF71 +#include "nrf71_wifi_ctrl.h" +#ifndef CMD_RX_BUFF +#include "common/rpu_if.h" +#endif /* !CMD_RX_BUF */ +#else #include "lmac_if_common.h" #include "host_rpu_common_if.h" +#endif /* WIFI_NRF71 */ + #include "osal_api.h" #include "bal_api.h" @@ -116,8 +124,18 @@ enum NRF_WIFI_HAL_STATUS { * @brief Structure to hold RPU information. */ struct nrf_wifi_hal_info { +#ifdef WIFI_NRF71 +#ifdef SOFT_HPQM + struct soft_hpqm_info *soft_hpq; +#ifndef CMD_RX_BUFF + /** Host RPU HPQM information */ + struct host_rpu_hpqm_info hpqm_info; +#endif /* CMD_RX_BUFF */ +#endif /* SOFT_HPQM */ +#else /** Host RPU HPQM information */ struct host_rpu_hpqm_info hpqm_info; +#endif /* WIFI_NRF71 */ /** RX command base */ unsigned int rx_cmd_base; /** TX command base */ @@ -195,6 +213,11 @@ struct nrf_wifi_hal_priv { struct nrf_wifi_hal_cfg_params cfg_params; /** PKTRAM base address */ unsigned long addr_pktram_base; +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + unsigned long hostram_addr_base_inline_rx; +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ }; /** @@ -293,6 +316,11 @@ struct nrf_wifi_hal_dev_ctx { void *recovery_tasklet; /** Recovery lock */ void *lock_recovery; +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + unsigned long addr_rpu_host_ram_base; +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ }; /** diff --git a/hw_if/hal/inc/common/pal.h b/hw_if/hal/inc/common/pal.h index 4108fa9..eb26ca7 100644 --- a/hw_if/hal/inc/common/pal.h +++ b/hw_if/hal/inc/common/pal.h @@ -27,18 +27,38 @@ #define PCIE_BAR_OFFSET_WLAN_RPU 0x0 #define PCIE_DMA_MASK 0xFFFFFFFF - +#ifndef WIFI_NRF71 #define SOC_MMAP_ADDR_OFFSET_PKTRAM_HOST_VIEW 0x0C0000 #define SOC_MMAP_ADDR_OFFSET_PKTRAM_RPU_VIEW 0x380000 +#define SOC_MMAP_ADDR_OFFSET_GDRAM_PKD 0x200000 +#endif /* !WIFI_NRF71 */ #ifdef RPU_CONFIG_72 #define SOC_MMAP_ADDR_OFFSET_GRAM_PKD 0xC00000 #define SOC_MMAP_ADDR_OFFSET_SYSBUS 0xE00000 #define SOC_MMAP_ADDR_OFFSET_PBUS 0xE40000 #else +#ifdef WIFI_NRF71 +#define SOC_MMAP_ADDR_OFFSET_WIFI_MCU_REGS 0x000000 +#define SOC_MMAP_ADDR_OFFSET_RAM0_PKD 0x100000 +#define SOC_MMAP_ADDR_OFFSET_RAM1_PKD 0x180000 +#define SOC_MMAP_ADDR_OFFSET_ROM0_PKD 0x100000 +#define SOC_MMAP_ADDR_OFFSET_ROM1_PKD 0x180000 +#define SOC_MMAP_ADDR_OFFSET_DATA_RAM_PKD 0x200000 +#define SOC_MMAP_ADDR_OFFSET_CODE_RAM_PKD 0x300000 +#define SOC_MMAP_ADDR_OFFSET_BELLBOARD_WIFI 0x384000 +#define SOC_MMAP_ADDR_OFFSET_BELLBOARD_APP 0x388000 +#define SOC_MMAP_ADDR_OFFSET_FPGA_REGS 0x3A0000 +#define SOC_MMAP_ADDR_OFFSET_GRTC 0x392000 +#define SOC_MMAP_ADDR_OFFSET_WICR_REGS 0x3B0000 +#define SOC_MMAP_ADDR_OFFSET_SECURERAM 0x3e0000 +#define SOC_MMAP_ADDR_OFFSET_ROM_ACCESS_FPGA_REG 0x3A1048 +//#define SOC_MMAP_ADDR_OFFSET_WICR 0x3BB004 +#else /* WIFI_NRF71 */ #define SOC_MMAP_ADDR_OFFSET_GRAM_PKD 0x80000 #define SOC_MMAP_ADDR_OFFSET_SYSBUS 0x00000 #define SOC_MMAP_ADDR_OFFSET_PBUS 0x40000 +#endif /* !WIFI_NRF71 */ static const unsigned int SOC_MMAP_ADDR_OFFSETS_MCU[] = { 0x100000, @@ -54,6 +74,13 @@ static const unsigned int SOC_MMAP_ADDR_OFFSETS_MCU[] = { #define NRF_WIFI_FW_UMAC_PATCH_LOC_PRI "img/wlan/nrf_wifi_umac_patch_pri.bimg" #define NRF_WIFI_FW_UMAC_PATCH_LOC_SEC "img/wlan/nrf_wifi_umac_patch_sec.bin" +#ifdef WIFI_NRF71 +#define RPU_DATA_RAM_SIZE (RPU_ADDR_DATA_RAM_END - RPU_ADDR_DATA_RAM_START + 1) +#ifdef INLINE_RX +#define SOC_HOST_DATA_RAM_BASE 0x02C00000 +#define SOC_HOST_DATA_RAM_LEN (4 * 1024 * 1024) +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ enum nrf_wifi_fw_type { NRF_WIFI_FW_TYPE_LMAC_PATCH, NRF_WIFI_FW_TYPE_UMAC_PATCH, @@ -66,8 +93,14 @@ enum nrf_wifi_fw_subtype { NRF_WIFI_FW_SUBTYPE_MAX }; +#ifdef WIFI_NRF71 +unsigned long pal_rpu_rom_access_reg_addr_get(void); +unsigned long pal_rpu_wicr_reg_offset_get(void); +#else /* WIFI_NRF71 */ bool pal_check_rpu_mcu_regions(enum RPU_PROC_TYPE proc, unsigned int addr_val); +#endif /* !WIFI_NRF71 */ +#ifndef WIFI_NRF71 static inline enum RPU_MCU_ADDR_REGIONS pal_mem_type_to_region(enum HAL_RPU_MEM_TYPE mem_type) { switch (mem_type) { @@ -81,12 +114,12 @@ static inline enum RPU_MCU_ADDR_REGIONS pal_mem_type_to_region(enum HAL_RPU_MEM_ return RPU_MCU_ADDR_REGION_MAX; } } +#endif /* !WIFI_NRF71 */ enum nrf_wifi_status pal_rpu_addr_offset_get(unsigned int rpu_addr, unsigned long *addr_offset, enum RPU_PROC_TYPE proc); - #ifdef NRF_WIFI_LOW_POWER unsigned long pal_rpu_ps_ctrl_reg_addr_get(void); #endif /* NRF_WIFI_LOW_POWER */ diff --git a/hw_if/hal/inc/common/phy_rf_params_common.h b/hw_if/hal/inc/common/phy_rf_params_common.h index fb7e857..1fec354 100644 --- a/hw_if/hal/inc/common/phy_rf_params_common.h +++ b/hw_if/hal/inc/common/phy_rf_params_common.h @@ -12,6 +12,7 @@ #define _PHY_RF_PARAMS_COMMON_H_ #include "pack_def.h" +#ifndef WIFI_NRF71 #define NRF_WIFI_RF_PARAMS_SIZE 200 #define NRF_WIFI_RF_PARAMS_CONF_SIZE 42 #define NUM_PCB_LOSS_OFFSET 4 @@ -23,12 +24,13 @@ #else #define NRF_WIFI_PHY_CALIB_FLAG_TXDC 2 #endif + #define NRF_WIFI_PHY_CALIB_FLAG_TXPOW 0 #define NRF_WIFI_PHY_CALIB_FLAG_TXIQ 8 #define NRF_WIFI_PHY_CALIB_FLAG_RXIQ 16 #define NRF_WIFI_PHY_CALIB_FLAG_DPD 32 -#define NRF_WIFI_PHY_CALIB_FLAG_ENHANCED_TXDC 64 +#define NRF_WIFI_PHY_CALIB_FLAG_ENHANCED_TXDC 64 #define NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXDC (1<<16) #ifdef NRF70_PASSIVE_SCAN_ONLY /* Disable TX DC Calibration for passive scan alone mode */ @@ -318,6 +320,7 @@ struct nrf_wifi_temp_volt_depend_params { * first 42 bytes of RF parameters. */ struct nrf_wifi_phy_rf_params { + unsigned char phy_params[NRF_WIFI_RF_PARAMS_SIZE]; unsigned char reserved[6]; struct nrf_wifi_xo_freq_offset xo_offset; struct nrf_wifi_pd_adst_val pd_adjust_val; @@ -489,5 +492,5 @@ enum ft_prog_ver { #define FT_PROG_VER3_5G_LOW_OFDM_TXCEIL_BKOFF 0 #define FT_PROG_VER3_5G_MID_OFDM_TXCEIL_BKOFF 0 #define FT_PROG_VER3_5G_HIGH_OFDM_TXCEIL_BKOFF 0 - +#endif /* WIFI_NRF71 */ #endif /* _PHY_RF_PARAMS_COMMON_H_ */ diff --git a/hw_if/hal/inc/common/rpu_if.h b/hw_if/hal/inc/common/rpu_if.h index 11d8397..959d08a 100644 --- a/hw_if/hal/inc/common/rpu_if.h +++ b/hw_if/hal/inc/common/rpu_if.h @@ -8,89 +8,127 @@ * @brief Common structures and definitions for RPU interface. */ + #ifndef __RPU_IF_H__ #define __RPU_IF_H__ #include "pack_def.h" +#include "nrf71_wifi_common.h" + +#ifdef DDR_32_BIT_ADDR +#define MEMORY_HOLE_BASE_ADDR 0xC0000000 +#endif /* DDR_32_BIT_ADDR */ + +#define NRF_WIFI_UMAC_VER(version) (((version)&0xFF000000) >> 24) +#define NRF_WIFI_UMAC_VER_MAJ(version) (((version)&0x00FF0000) >> 16) +#define NRF_WIFI_UMAC_VER_MIN(version) (((version)&0x0000FF00) >> 8) +#define NRF_WIFI_UMAC_VER_EXTRA(version) (((version)&0x000000FF) >> 0) +#define RPU_MEM_UMAC_BOOT_SIG 0x20080000 +#define RPU_MEM_UMAC_VER 0x20080004 +#define RPU_MEM_UMAC_PEND_Q_BMP 0x20080008 +#define RPU_MEM_TX_CMD_BASE 0x20080024 +#define RPU_MEM_DATA_RAM_BASE 0x20085000 +#define RPU_DATA_CMD_SIZE_MAX_TX 148 +#define RPU_EVENT_COMMON_SIZE_MAX 128 -/* Beginning address of the global RAM */ -#define RPU_ADDR_GRAM_START 0xB7000000 -/* Ending address of the global RAM */ -#define RPU_ADDR_GRAM_END 0xB70101FF -/* Beginning address of the system bus register space */ -#define RPU_ADDR_SBUS_START 0xA4000000 -/* Ending address of the system bus register space */ -#define RPU_ADDR_SBUS_END 0xA4007FFF -/* Beginning address of the peripheral bus register space */ -#define RPU_ADDR_PBUS_START 0xA5000000 -/* Ending address of the peripheral bus register space */ -#define RPU_ADDR_PBUS_END 0xA503FFFF -/* Beginning address of the MIPS boot exception vector registers */ -#define RPU_ADDR_BEV_START 0xBFC00000 -/* Ending address of the MIPS boot exception vector registers */ -#define RPU_ADDR_BEV_END 0xBFCFFFFF -/* Beginning address of the packet RAM */ -#define RPU_ADDR_PKTRAM_START 0xB0000000 -/* Ending address of the packet RAM */ -#define RPU_ADDR_PKTRAM_END 0xB0030FFF - -/* Starting address of the LMAC MCU (MCU) retention RAM */ +#define NRF_WIFI_UMAC_BOOT_SIG 0x5A5A5A5A +#define NRF_WIFI_UMAC_ROM_PATCH_OFFSET (RPU_MEM_UMAC_PATCH_BIMG - RPU_ADDR_UMAC_CORE_RET_START) +#define NRF_WIFI_UMAC_BOOT_EXCP_VECT_0 0x3c1a8000 +#define NRF_WIFI_UMAC_BOOT_EXCP_VECT_1 0x275a0000 +#define NRF_WIFI_UMAC_BOOT_EXCP_VECT_2 0x03400008 +#define NRF_WIFI_UMAC_BOOT_EXCP_VECT_3 0x00000000 + +/*#define RPU_DATA_RAMA_OFFSET 0x200000*/ +#define RPU_ADDR_ACTUAL_DATA_RAM_START 0x20000000 +#define RPU_ADDR_ACTUAL_DATA_RAM_END 0x200FFFFF +#define RPU_ADDR_DATA_RAM_START 0x20080000 +#define RPU_ADDR_DATA_RAM_END 0x200E0000 + +#define RPU_ADDR_RAM0_ROM0_REGION 0x28000000 +#define RPU_ADDR_RAM1_ROM1_REGION 0x28100000 + +/*#define RPU_RAM0_OFFSET 0x100000*/ +#define RPU_ADDR_RAM0_REGION 0x28000000 +#define RPU_ADDR_RAM0_START 0x28000000 +#define RPU_ADDR_RAM0_END 0x2807FFFF + +/*#define RPU_RAM1_OFFSET 0x180000*/ +#define RPU_ADDR_RAM1_REGION 0x28100000 +#define RPU_ADDR_RAM1_START 0x28100000 +#define RPU_ADDR_RAM1_END 0x2817FFFF + +/*#define RPU_ROM0_OFFSET 0x100000*/ +#define RPU_ADDR_ROM0_REGION 0x28080000 +#define RPU_ADDR_ROM0_START 0x28080000 +#define RPU_ADDR_ROM0_END 0x280FFFFF + +/*#define RPU_ROM1_OFFSET 0x180000*/ +#define RPU_ADDR_ROM1_REGION 0x28180000 +#define RPU_ADDR_ROM1_START 0x28180000 +#define RPU_ADDR_ROM1_END 0x281FFFFF + +/*#define RPU_WIFI_MCU_REGS_OFFSET 0x000000*/ +#define RPU_ADDR_WIFI_MCU_REGS_REGION 0x48000000 +#define RPU_ADDR_WIFI_MCU_REGS_START 0x48000000 +#define RPU_ADDR_WIFI_MCU_REGS_END 0x480FFFFF + +/*#define RPU_CODE_RAM_REGS_OFFSET 0x300000*/ +#define RPU_ADDR_CODE_RAM_REGION 0x00200000 +#define RPU_ADDR_CODE_RAM_START 0x00280000 +#define RPU_ADDR_CODE_RAM_END 0x002FFFFF + +/*#define RPU_SECURERAM_REGS_OFFSET 0x3e0000*/ +#define RPU_ADDR_SECURERAM_REGION 0x28400000 +#define RPU_ADDR_SECURERAM_START 0x28400000 +#define RPU_ADDR_SECURERAM_END 0x2841FFFB + +/*#define RPU_FPGA_REGS_OFFSET 0x3A0000*/ +#define RPU_ADDR_FPGA_REGS_REGION 0x80000000 +#define RPU_ADDR_FPGA_REGS_START 0x80000000 +#define RPU_ADDR_FPGA_REGS_END 0x8000FFFF + +/*#define RPU_BELLBOARD_APP_REGS_OFFSET 0x388000*/ +#define RPU_ADDR_BELLBOARD_GRTC_REGION 0x40000000 +#define RPU_ADDR_BELLBOARD_APP_REGION 0x40078000 +#define RPU_ADDR_BELLBOARD_APP_START 0x40078000 +#define RPU_ADDR_BELLBOARD_APP_END 0x40079FFF + +/*#define RPU_BELLBOARD_WIFI_REGS_OFFSET 0x38C000*/ +#define RPU_ADDR_BELLBOARD_WIFI_REGION 0x40074000 +#define RPU_ADDR_BELLBOARD_WIFI_START 0x40074000 +#define RPU_ADDR_BELLBOARD_WIFI_END 0x40075FFF + + +#define RPU_ADDR_GRTC_REGION 0x400E2000 +#define RPU_ADDR_GRTC_START 0x400E2000 +#define RPU_ADDR_GRTC_END 0x400E3FFF + +#define RPU_ADDR_WICR_REGS_REGION 0x00F00000 +#define RPU_ADDR_WICR_REGS_START 0x00FF0000 +#define RPU_ADDR_WICR_REGS_END 0x00FFFFFF + +/* Needed for calculatating sleep controller address */ #define RPU_ADDR_LMAC_CORE_RET_START 0x80040000 -/* Starting address of the UMAC MCU (MCU2) retention RAM */ #define RPU_ADDR_UMAC_CORE_RET_START 0x80080000 -/** - * @brief Regions in the MCU local memory. - * - * The MCU local memory in the nRF70 is divided into three regions: - * - ROM : Read-only memory region. - * - RETENTION : Retention memory region. - * - SCRATCH : Scratch memory region. - */ enum RPU_MCU_ADDR_REGIONS { RPU_MCU_ADDR_REGION_ROM = 0, RPU_MCU_ADDR_REGION_RETENTION, RPU_MCU_ADDR_REGION_SCRATCH, RPU_MCU_ADDR_REGION_MAX, + }; -/** - * @brief Address limits of each MCU local memory region. - * - * A MCU local memory region is defined by its: - * - Start address, and - * - End address. - */ struct rpu_addr_region { unsigned int start; unsigned int end; }; -/** - * @brief Address map of the MCU memory. - * - * The MCU memory map consists of three regions: - * - ROM : Read-only memory region. - * - RETENTION : Retention memory region. - * - SCRATCH : Scratch memory region. - */ struct rpu_addr_map { struct rpu_addr_region regions[RPU_MCU_ADDR_REGION_MAX]; }; -/** - * @brief Memory map of the MCUs in the RPU. - * - * The RPU consists of two MCUs: - * - MCU: For the LMAC. - * - MCU2 : For the UMAC. - * - * Each MCU memory consists of three regions: - * - ROM : Read-only memory region. - * - RETENTION : Retention memory region. - * - SCRATCH : Scratch memory region. - */ static const struct rpu_addr_map RPU_ADDR_MAP_MCU[] = { - /* MCU - LMAC */ + /* MCU1 - LMAC */ { { {0x80000000, 0x80033FFF}, @@ -107,297 +145,136 @@ static const struct rpu_addr_map RPU_ADDR_MAP_MCU[] = { } }, }; - -/* Number of boot exception vectors for each MCU */ -#define RPU_MCU_MAX_BOOT_VECTORS 4 - -/** - * @brief Boot vector definition for a MCU in nRF70. - * - * The boot vectors for the MCUs in the nRF70 are defined by their: - * - Address, and - * - Value. - */ -struct rpu_mcu_boot_vector { - unsigned int addr; - unsigned int val; -}; - -/** - * @brief Boot vectors for the MCUs in nRF70. - * - * The boot vectors for the MCUs in nRF70. - */ -struct rpu_mcu_boot_vectors { - struct rpu_mcu_boot_vector vectors[RPU_MCU_MAX_BOOT_VECTORS]; -}; - -/* Base mask for the nRF70 memory map */ -#define RPU_ADDR_MASK_BASE 0xFF000000 -/* Offset mask for the nRF70 memory map */ -#define RPU_ADDR_MASK_OFFSET 0x00FFFFFF -/* Offset mask for the boot exception vector */ +#define RPU_ADDR_MASK_BASE 0xFFF00000 +#define RPU_ADDR_BELLBOARD_GRTC_MASK_BASE 0xFFFFF000 +#define RPU_ADDR_MASK_OFFSET 0x000FFFFF +#define RPU_BELLBOARD_GRTC_ADDR_MASK_OFFSET 0x00000FFF +#define RPU_ADDR_RAM_ROM_MASK_OFFSET 0x000FFFFF +#define RPU_WICR_ADDR_MASK_OFFSET 0x0000FFFF #define RPU_ADDR_MASK_BEV_OFFSET 0x000FFFFF +#define RPU_MEM_RX_CMD_BASE 0x28000308 +#define WEZEN_RPU_REG_INT_FROM_MCU_CTRL 0x40078300 +#define WEZEN_RPU_REG_INT_FROM_MCU_CLR 0x40078100 +#define GRTC_CLKCFG_ADDR 0x400E2718 +#define GRTC_CLKCFG_VAL 0x10001 +#define GRTC_MODE_ADDR 0x400E2510 +#define GRTC_MODE_VAL 0x2 +#define GRTC_TASKS_START_ADDR 0x400E2060 +#define GRTC_TASKS_START_VAL 0x1 +#define VPR0_CPURUN_ADDR 0x48000800 +#define VPR0_CPURUN_VAL 0x1 +#define VPR0_INITPC_ADDR 0x48000808 +#define WEZEN_RPU_REG_INT_TO_WIFICORE_BELLBOARD_TASKS_TRIGGER 0x40074008 +#define RPU_REG_BIT_ROM_ACCESS_DISABLE 0 +#define RPU_REG_BIT_ROM_ACCESS_ENABLE 1 +#define ROM_ACCESS_REG_ADDR 0x80001048 +#define RPU_REG_WICR_ADDR_ROM1_START 0x00FFB004 +#define RPU_REG_WICR_ADDR_VPR0_PATCH_ADDR 0x00FFB008 +#define RPU_REG_WICR_ADDR_VPR1_PATCH_ADDR 0x00FFB00C + -/* Address of the nRF70 interrupt register */ -#define RPU_REG_INT_FROM_RPU_CTRL 0xA4000400 -/* Control bit for enabling/disabling of nRF70 interrupts */ -#define RPU_REG_BIT_INT_FROM_RPU_CTRL 17 - -/* Address of the nRF70 IRQ register */ -#define RPU_REG_INT_TO_MCU_CTRL 0xA4000480 - -/* Address of the nRF70 interrupt ack register */ -#define RPU_REG_INT_FROM_MCU_ACK 0xA4000488 -/* Bit to set to ack nRF70 interrupt */ -#define RPU_REG_BIT_INT_FROM_MCU_ACK 31 - -/* Address of the nRF70 UMAC MCU interrupt enable register */ -#define RPU_REG_INT_FROM_MCU_CTRL 0xA4000494 -/* Bit to set to enable UMAC MCU interrupts */ -#define RPU_REG_BIT_INT_FROM_MCU_CTRL 31 - -/* Address of the nRF70 register which points to LMAC patch memory address */ -#define RPU_REG_UCC_SLEEP_CTRL_DATA_0 0xA4002C2C -/* Address of the nRF70 register which points to UMAC patch memory address */ -#define RPU_REG_UCC_SLEEP_CTRL_DATA_1 0xA4002C30 -/* Address of the register to soft reset the LMAC MCU */ -#define RPU_REG_MIPS_MCU_CONTROL 0xA4000000 -/* Address of the register to soft reset the UMAC MCU */ -#define RPU_REG_MIPS_MCU2_CONTROL 0xA4000100 - -/* Address of the nRF70 interrupt status register */ -#define RPU_REG_MIPS_MCU_UCCP_INT_STATUS 0xA4000004 -/* Bit to check for watchdog interrupt */ -#define RPU_REG_BIT_MIPS_WATCHDOG_INT_STATUS 1 - -/* Address of the nRF70 watchdog timer register */ -#define RPU_REG_MIPS_MCU_TIMER 0xA400004C /* 24 bit timer@core clock ticks*/ -/* Default watchdog timer value */ -#define RPU_REG_MIPS_MCU_TIMER_RESET_VAL 0xFFFFFF - -/* Address of the nRF70 watchdog interrupt clear register */ -#define RPU_REG_MIPS_MCU_UCCP_INT_CLEAR 0xA400000C -/* Bit to clear the watchdog interrupt */ -#define RPU_REG_BIT_MIPS_WATCHDOG_INT_CLEAR 1 - -/* Registers to control indirect access to LMAC MCU local memory */ -/* The MCU local memory address needs to be programmed to the control register */ -#define RPU_REG_MIPS_MCU_SYS_CORE_MEM_CTRL 0xA4000030 -/* The data to be written to the MCU local memory needs to be programmed to the data register */ -#define RPU_REG_MIPS_MCU_SYS_CORE_MEM_WDATA 0xA4000034 - -/* Boot exception vector registers for the LMAC MCU */ -#define RPU_REG_MIPS_MCU_BOOT_EXCP_INSTR_0 0xA4000050 -#define RPU_REG_MIPS_MCU_BOOT_EXCP_INSTR_1 0xA4000054 -#define RPU_REG_MIPS_MCU_BOOT_EXCP_INSTR_2 0xA4000058 -#define RPU_REG_MIPS_MCU_BOOT_EXCP_INSTR_3 0xA400005C - -/* Registers to control indirect access to LMAC MCU local memory */ -/* The MCU local memory address needs to be programmed to the control register */ -#define RPU_REG_MIPS_MCU2_SYS_CORE_MEM_CTRL 0xA4000130 -/* The data to be written to the MCU local memory needs to be programmed to the data register */ -#define RPU_REG_MIPS_MCU2_SYS_CORE_MEM_WDATA 0xA4000134 -/* Boot exception vector registers for the LMAC MCU */ -#define RPU_REG_MIPS_MCU2_BOOT_EXCP_INSTR_0 0xA4000150 -#define RPU_REG_MIPS_MCU2_BOOT_EXCP_INSTR_1 0xA4000154 -#define RPU_REG_MIPS_MCU2_BOOT_EXCP_INSTR_2 0xA4000158 -#define RPU_REG_MIPS_MCU2_BOOT_EXCP_INSTR_3 0xA400015C - -/* Bit which controls the power state of the nRF70 */ -#define RPU_REG_BIT_PS_CTRL 0 -/* Bit which indicates hardware bus ready state of the nRF70 */ -#define RPU_REG_BIT_PS_STATE 1 -/* Bit which indicates the firmware readiness of the nRF70 */ -#define RPU_REG_BIT_READY_STATE 2 -/* Address which has information about the RX command base */ -#define RPU_MEM_RX_CMD_BASE 0xB7000D58 - -/* Address which has information about the host port queue manager (HPQM) */ -#define RPU_MEM_HPQ_INFO 0xB0000024 -/* Address which has information about the TX command base */ -#define RPU_MEM_TX_CMD_BASE 0xB00000B8 - -/* Address which has OTP location containing the factory test program version */ -#define RPU_MEM_OTP_FT_PROG_VERSION 0xB0004FD8 -/* Address which has the OTP flags */ -#define RPU_MEM_OTP_INFO_FLAGS 0xB0004FDC -/* Address which has the OTP package type */ -#define RPU_MEM_OTP_PACKAGE_TYPE 0xB0004FD4 - -/* Base address of the area where TX/RX packet buffers can be programmed for transmission/reception */ -#define RPU_MEM_PKT_BASE 0xB0005000 -/* Magic value to indicate start of the command counter synchronization between host and nRF70 */ #define RPU_CMD_START_MAGIC 0xDEAD -/* Maximum size of the RX data command */ -#define RPU_DATA_CMD_SIZE_MAX_RX 8 -/* Maximum size of the TX data command */ -#define RPU_DATA_CMD_SIZE_MAX_TX 148 -/* Maximum size of the most common events */ -#define RPU_EVENT_COMMON_SIZE_MAX 128 -/* Maximum event size */ +#define RPU_REG_BIT_HARDRST_CTRL 8 + +/*Event pool*/ +#define EVENT_POOL_NUM_ELEMS (7) #define MAX_EVENT_POOL_LEN 1000 -/* Maximum number of RX queues */ -#define MAX_NUM_OF_RX_QUEUES 3 - -/* Packet RAM size in the nRF70 */ -#define RPU_PKTRAM_SIZE (RPU_ADDR_PKTRAM_END - RPU_MEM_PKT_BASE + 1) - -/* Base address of the area where ADC output IQ samples are stored */ -#define RPU_MEM_RF_TEST_CAP_BASE 0xB0006000 - -/* OTP address offsets (word offsets) */ -#define REGION_PROTECT 64 -#define PRODTEST_FT_PROGVERSION 29 -#define PRODTEST_TRIM0 32 -#define PRODTEST_TRIM1 33 -#define PRODTEST_TRIM2 34 -#define PRODTEST_TRIM3 35 -#define PRODTEST_TRIM4 36 -#define PRODTEST_TRIM5 37 -#define PRODTEST_TRIM6 38 -#define PRODTEST_TRIM7 39 -#define PRODTEST_TRIM8 40 -#define PRODTEST_TRIM9 41 -#define PRODTEST_TRIM10 42 -#define PRODTEST_TRIM11 43 -#define PRODTEST_TRIM12 44 -#define PRODTEST_TRIM13 45 -#define PRODTEST_TRIM14 46 -#define INFO_PART 48 -#define INFO_VARIANT 49 -#define INFO_UUID 52 -#define QSPI_KEY 68 -#define MAC0_ADDR 72 -#define MAC1_ADDR 74 -#define CALIB_XO 76 -#define REGION_DEFAULTS 85 -#define PRODRETEST_PROGVERSION 86 -#define PRODRETEST_TRIM0 87 -#define PRODRETEST_TRIM1 88 -#define PRODRETEST_TRIM2 89 -#define PRODRETEST_TRIM3 90 -#define PRODRETEST_TRIM4 91 -#define PRODRETEST_TRIM5 92 -#define PRODRETEST_TRIM6 93 -#define PRODRETEST_TRIM7 94 -#define PRODRETEST_TRIM8 95 -#define PRODRETEST_TRIM9 96 -#define PRODRETEST_TRIM10 97 -#define PRODRETEST_TRIM11 98 -#define PRODRETEST_TRIM12 99 -#define PRODRETEST_TRIM13 100 -#define PRODRETEST_TRIM14 101 -#define OTP_MAX_WORD_LEN 128 -#define QSPI_KEY_LENGTH_BYTES 16 -#define RETRIM_LEN 15 - -/* Size of XO calibration value stored in the OTP field CALIB_XO */ -#define OTP_SZ_CALIB_XO 1 - -/* Byte offsets of XO calib value in CALIB_XO field in the OTP */ -#define OTP_OFF_CALIB_XO 0 - -/* Masks to program bit fields in REGION_DEFAULTS field in the OTP */ -#define QSPI_KEY_FLAG_MASK ~(1U<<0) -#define MAC0_ADDR_FLAG_MASK ~(1U<<1) -#define MAC1_ADDR_FLAG_MASK ~(1U<<2) -#define CALIB_XO_FLAG_MASK ~(1U<<3) - -/* RF register address to facilitate OTP access */ -#define OTP_VOLTCTRL_ADDR 0x19004 -/* Voltage value to be written into the above RF register for OTP write access */ -#define OTP_VOLTCTRL_2V5 0x3b -/* Voltage value to be written into the above RF register for OTP read access */ -#define OTP_VOLTCTRL_1V8 0xb - -#define OTP_POLL_ADDR 0x01B804 -#define OTP_WR_DONE 0x1 -#define OTP_READ_VALID 0x2 -#define OTP_READY 0x4 - - -#define OTP_RWSBMODE_ADDR 0x01B800 -#define OTP_READ_MODE 0x1 -#define OTP_BYTE_WRITE_MODE 0x42 - - -#define OTP_RDENABLE_ADDR 0x01B810 -#define OTP_READREG_ADDR 0x01B814 - -#define OTP_WRENABLE_ADDR 0x01B808 -#define OTP_WRITEREG_ADDR 0x01B80C - -#define OTP_TIMING_REG1_ADDR 0x01B820 -#define OTP_TIMING_REG1_VAL 0x0 -#define OTP_TIMING_REG2_ADDR 0x01B824 -#define OTP_TIMING_REG2_VAL 0x030D8B - -#define OTP_FRESH_FROM_FAB 0xFFFFFFFF -#define OTP_PROGRAMMED 0x00000000 -#define OTP_ENABLE_PATTERN 0x50FA50FA -#define OTP_INVALID 0xDEADBEEF - -#define FT_PROG_VER_MASK 0xF0000 + +#define RAM0_START_ADDR 0x28000300 +#define RPU_MEM_LMAC_BOOT_SIG (RAM0_START_ADDR + 0x0) +#define RPU_MEM_LMAC_VER 0x4 +#define RPU_MEM_LMAC_PATCH_BIN 0x80046000 +#define RPU_MEM_LMAC_PATCH_BIMG 0x80047000 + +#define NRF_WIFI_LMAC_VER(ver) ((ver & 0xFF000000) >> 24) +#define NRF_WIFI_LMAC_VER_MAJ(ver) ((ver & 0x00FF0000) >> 16) +#define NRF_WIFI_LMAC_VER_MIN(ver) ((ver & 0x0000FF00) >> 8) +#define NRF_WIFI_LMAC_VER_EXTRA(ver) (ver & 0x000000FF) + +#define NRF_WIFI_LMAC_BOOT_SIG 0x5A5A5A5A +#define NRF_WIFI_LMAC_ROM_PATCH_OFFSET (RPU_MEM_LMAC_PATCH_BIMG -\ + RPU_ADDR_MCU1_CORE_RET_START) +#define NRF_WIFI_LMAC_BOOT_EXCP_VECT_0 0x3c1a8000 +#define NRF_WIFI_LMAC_BOOT_EXCP_VECT_1 0x275a0000 +#define NRF_WIFI_LMAC_BOOT_EXCP_VECT_2 0x03400008 +#define NRF_WIFI_LMAC_BOOT_EXCP_VECT_3 0x00000000 /** - * @brief RX buffer related information to be passed to nRF70. + * struct host_rpu_rx_buf_info - RX buffer related information to be passed to + * the RPU. + * @addr: Address in the host memory where the RX buffer is located. * - * This structure encapsulates the information to be passed to nRF70 for - * buffers which the nRf70 will use to pass the received frames. + * This structure encapsulates the information to be passed to the RPU for + * buffers which the RPU will use to pass the received frames. */ + struct host_rpu_rx_buf_info { - /** Address in the host memory where the RX buffer is located. */ unsigned int addr; } __NRF_WIFI_PKD; /** - * @brief Hostport Queue (HPQ) information. + * @brief This structure represents the bitmap of STA (Station) pending frames in + * SoftAP power save mode. * - * This structure encapsulates the information which represents a HPQ. */ -struct host_rpu_hpq { - /** HPQ address where the host can post the address of a message intended for the RPU. */ - unsigned int enqueue_addr; - /** HPQ address where the host can get the address of a message intended for the host. */ - unsigned int dequeue_addr; + +struct sap_pend_frames_bitmap { + /** STA MAC address */ + unsigned char mac_addr[6]; + /** Pending frames bitmap for each access category */ + unsigned char pend_frames_bitmap; } __NRF_WIFI_PKD; /** - * @brief Information about Hostport Queues (HPQ) to be used - * for exchanging information between the Host and RPU. + * @brief This structure represents the information related to UMAC. * - * Hostport queue information passed by the RPU to the host, which the host can - * use, to communicate with the RPU. */ -struct host_rpu_hpqm_info { - /** Queue which the RPU uses to inform the host about events. */ - struct host_rpu_hpq event_busy_queue; - /** Queue on which the consumed events are pushed so that RPU can reuse them. */ - struct host_rpu_hpq event_avl_queue; - /** Queue used by the host to push commands to the RPU. */ - struct host_rpu_hpq cmd_busy_queue; - /** Queue which RPU uses to inform host about command buffers which can be used to - * push commands to the RPU. - */ - struct host_rpu_hpq cmd_avl_queue; - /** Queue used by the host to push RX buffers to the RPU. */ - struct host_rpu_hpq rx_buf_busy_queue[MAX_NUM_OF_RX_QUEUES]; +struct host_rpu_umac_if_info { + /** Boot status signature */ + unsigned int boot_status; + /** UMAC version */ + unsigned int version; + /** @ref sap_pend_frames_bitmap */ + struct sap_pend_frames_bitmap sap_bitmap[NRF_WIFI_MAX_SAP_CLIENTS]; } __NRF_WIFI_PKD; -/** - * @brief Common header included in each command/event. - * This structure encapsulates the common information included at the start of - * each command/event exchanged with the RPU. - */ -struct host_rpu_msg_hdr { - /** Length of the message. */ - unsigned int len; - /** Flag to indicate whether the recipient is expected to resubmit the - * cmd/event address back to the trasmitting entity. - */ - unsigned int resubmit; -} __NRF_WIFI_PKD; +#ifdef SOFT_HPQM + +#define HOST_RPU_SOFTHPQM_INFO_START 0x200844b4 +#define HOST_RPU_CMD_BUFFERS 4 +#define HOST_RPU_EVENT_BUFFERS 7 +#define HOST_RPU_TX_DESC 12 + +struct soft_hpqm_info { + volatile unsigned int host_cmd_free_index; + volatile unsigned int rpu_cmd_busy_index; + volatile unsigned int host_event_busy_index; + volatile unsigned int rpu_event_free_index; + volatile unsigned int host_tx_cmd_busy_index; + volatile unsigned int rpu_tx_cmd_busy_index; + volatile unsigned int host_tx_done_busy_index; + volatile unsigned int rpu_tx_done_busy_index; + volatile unsigned int cmd_free_buffs[HOST_RPU_CMD_BUFFERS]; + volatile unsigned int cmd_busy_buffs[HOST_RPU_CMD_BUFFERS]; + volatile unsigned int event_free_buffs[HOST_RPU_EVENT_BUFFERS]; + volatile unsigned int event_busy_buffs[HOST_RPU_EVENT_BUFFERS]; + volatile unsigned int tx_cmd_buffs[HOST_RPU_TX_DESC]; + volatile unsigned int tx_done_buffs[HOST_RPU_TX_DESC]; +}; + +#endif /* SOFT_HPQM */ + + + +#ifdef ASICBUILD + #define NRF_WIFI_ASICBUILD_RF_PARAMS "0000000000002A00000000030303036060606060606060600000000050EC000000000000000000000000007077003F032424001000002800323500000CF008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF08080808040A140100000000A1A10178000000080050003B020726181818181A120A140E0600" +#elif defined(C0_CHIP) + #define NRF_WIFI_C0_RF_PARAMS "0000000000001C00000000000000004030303838383838380000000050EC000000000000000000000000214365003F032424001000002800323500000CF008007D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF08080808040A140100000000A1A10178000000680150003B0207262D2D28281A120A140E0600" +#else /* Simulator and Emulator */ + #define NRF_WIFI_PLAYOUT_RF_PARAMS "0000000000001C00000000000000005050505050505050500000000050EC000000000000000000000000214365003F032424001000002800323500000000080A7D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF08080808040A120100000000A1A101A0000000280050003B0207260F0F0F0F1A120A140E0600" +#endif + + #endif /* __RPU_IF_H__ */ diff --git a/hw_if/hal/inc/radio_test/phy_rf_params.h b/hw_if/hal/inc/radio_test/phy_rf_params.h index 178a0db..8bed9e6 100644 --- a/hw_if/hal/inc/radio_test/phy_rf_params.h +++ b/hw_if/hal/inc/radio_test/phy_rf_params.h @@ -12,7 +12,12 @@ #define _PHY_RF_PARAMS_RT_H_ #include "common/phy_rf_params_common.h" +#ifdef WIFI_NRF71 +/* Current working phy_rf_params */ +#define NRF_WIFI_RT_DEF_RF_PARAMS "0000000000001C00000000000000004030303838383838380000000050EC000000000000000000000000214365003F032424001000002800323500000CF008007D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF08080808040A140100000000A1A10178000000680150003B0207262D2D28281A120A140E0600" +#else /* WIFI_NRF71 */ #define NRF_WIFI_RT_DEF_RF_PARAMS "007077003F032424001000002800323500000C0008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A10178000000080050003B020726181818181A120A140E0600" +#endif /* !WIFI_NRF71 */ #define MAX_TX_PWR_SYS_TEST 30 #define MAX_TX_PWR_RADIO_TEST 24 @@ -23,6 +28,7 @@ #define VBAT_OFFSET_MILLIVOLT (2500) #define VBAT_SCALING_FACTOR (70) +#ifndef WIFI_NRF71 enum nrf_wifi_rf_test { NRF_WIFI_RF_TEST_RX_ADC_CAP, @@ -170,5 +176,5 @@ struct nrf_wifi_rf_get_xo_value { /* Optimal XO value computed. */ unsigned char xo_value; } __NRF_WIFI_PKD; - +#endif #endif /* _PHY_RF_PARAMS_RT_H_ */ diff --git a/hw_if/hal/inc/system/phy_rf_params.h b/hw_if/hal/inc/system/phy_rf_params.h index 6a4ae46..dc0a463 100644 --- a/hw_if/hal/inc/system/phy_rf_params.h +++ b/hw_if/hal/inc/system/phy_rf_params.h @@ -12,6 +12,10 @@ #define _PHY_RF_PARAMS_SYS_H_ #include "common/phy_rf_params_common.h" +#ifdef WIFI_NRF71 +/* Currnet working phy_rf_params */ +#define NRF_WIFI_SYS_DEF_RF_PARAMS "0000000000001C00000000000000004030303838383838380000000050EC000000000000000000000000214365003F032424001000002800323500000CF008007D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF08080808040A140100000000A1A10178000000680150003B0207262D2D28281A120A140E0600" +#else /* WIFI_NRF71 */ #define NRF_WIFI_SYS_DEF_RF_PARAMS "007077003F032424001000002800323500000CF008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A10178000000080050003B020726181818181A120A140E0600" - +#endif /* !WIFI_NRF71 */ #endif /* _PHY_RF_PARAMS_SYS_H_ */ diff --git a/hw_if/hal/src/common/hal_api_common.c b/hw_if/hal/src/common/hal_api_common.c index a6f53ec..d38aa1e 100644 --- a/hw_if/hal/src/common/hal_api_common.c +++ b/hw_if/hal/src/common/hal_api_common.c @@ -17,8 +17,195 @@ #ifndef NRF71_ON_IPC #include "common/hal_interrupt.h" #include "common/pal.h" +#ifdef WIFI_NRF71 +#include "nrf71_wifi_ctrl.h" +#endif /* WIFI_NRF71 */ #endif /* !NRF71_ON_IPC */ +#ifdef WIFI_NRF71 +#ifdef RPU_HARD_RESET_SUPPORT +static enum nrf_wifi_status hal_rpu_hard_rst( + struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + enum RPU_PROC_TYPE proc) +{ + unsigned long hard_rst_reg_offset = 0; + unsigned int hard_rst_val = 0; + enum HAL_RPU_MEM_TYPE mem_type = HAL_RPU_MEM_TYPE_MAX; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + + hal_dev_ctx->curr_proc = proc; +#ifdef WIFI_NRF71 + if (proc == RPU_PROC_TYPE_MCU_LMAC) { + hard_rst_reg_offset = pal_rpu_hard_rst_reg_offset_get(); + hard_rst_val = (1 << RPU_REG_BIT_HARDRST_CTRL); + + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + hard_rst_reg_offset, + hard_rst_val); + + nrf_wifi_osal_sleep_ms(500); + status = NRF_WIFI_STATUS_SUCCESS; + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_RAM_0); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of RAM_0 failed\n", + __func__); + + goto out; + } + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_DATA_RAM); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of DATA_RAM failed\n", + __func__); + + goto out; + } + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_ROM_0); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of ROM_O failed\n", + __func__); + + goto out; + } + } else if (proc == RPU_PROC_TYPE_MCU_UMAC) { + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_RAM_1); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of RAM_1 failed\n", + __func__); + + goto out; + } + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_CODE_RAM); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of CODE_RAM failed\n", + __func__); + + goto out; + } + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_ROM_1); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of ROM_1 failed\n", + __func__); + + goto out; + } + status = NRF_WIFI_STATUS_SUCCESS; + } +#else + if (proc == RPU_PROC_TYPE_MCU_LMAC) { + hard_rst_reg_offset = pal_rpu_hard_rst_reg_offset_get(); + hard_rst_val = (1 << RPU_REG_BIT_HARDRST_CTRL); + + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + hard_rst_reg_offset, + hard_rst_val); + + nrf_wifi_osal_sleep_ms(500); + status = NRF_WIFI_STATUS_SUCCESS; + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_RAM_0); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of RAM_0 failed", + __func__); + goto out; + } + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_DATA_RAM); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of DATA_RAM failed", + __func__); + goto out; + } + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_ROM_0); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of ROM_O failed", + __func__); + goto out; + } + } else if (proc == RPU_PROC_TYPE_MCU_UMAC) { + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_RAM_1); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of RAM_1 failed", + __func__); + goto out; + } + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_CODE_RAM); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of CODE_RAM failed", + __func__); + goto out; + } + + status = hal_rpu_mem_clr(hal_dev_ctx, + proc, + HAL_RPU_MEM_TYPE_ROM_1); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Clearing of ROM_1 failed", + __func__); + goto out; + } + + status = NRF_WIFI_STATUS_SUCCESS; + } +#endif +out: + if (status == NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_info("%s: Hard reset done for MCU %d", + __func__, + proc); + } else { + nrf_wifi_osal_log_err("%s: Hard reset failed for MCU%d", + __func__, + proc); + } + + return status; +} +#endif /* RPU_HARD_RESET_SUPPORT */ +#endif /* WIFI_NRF71 */ + #ifndef NRF71_ON_IPC #ifdef NRF_WIFI_LOW_POWER #ifdef NRF_WIFI_RPU_RECOVERY @@ -220,6 +407,68 @@ enum nrf_wifi_status nrf_wifi_hal_get_rpu_ps_state( #endif /* NRF_WIFI_LOW_POWER */ +#ifdef SOFT_HPQM +static bool hal_rpu_soft_hpq_is_empty(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned int val = 0; + unsigned int current_index = 0; + + status = hal_rpu_mem_read(hal_dev_ctx, + ¤t_index, + &hal_dev_ctx->rpu_info.soft_hpq->host_cmd_free_index, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from the host_event_busy_index = %x address failed, val (0x%X)\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_cmd_free_index, + current_index); + return true; + } + + status = hal_rpu_mem_read(hal_dev_ctx, + &val, + &hal_dev_ctx->rpu_info.soft_hpq->cmd_free_buffs[current_index], + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from dequeue address failed, val (0x%X)\n", + __func__, + val); + return true; + } + if (val) { + return false; + } + + return true; +} + +static enum nrf_wifi_status hal_rpu_ready(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + enum NRF_WIFI_HAL_MSG_TYPE msg_type) +{ + bool is_empty = false; + unsigned int *cmd_free_buffs = NULL; + + if (msg_type == NRF_WIFI_HAL_MSG_TYPE_CMD_CTRL) { + /* Check if any command pointers are available to post a message */ + is_empty = hal_rpu_soft_hpq_is_empty(hal_dev_ctx); + + if (is_empty == true) { + return NRF_WIFI_STATUS_FAIL; + } + } else { + nrf_wifi_osal_log_err("%s: Invalid msg type %d\n", + __func__, + msg_type); + + return NRF_WIFI_STATUS_FAIL; + } + + return NRF_WIFI_STATUS_SUCCESS; +} +#else static bool hal_rpu_hpq_is_empty(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, struct host_rpu_hpq *hpq) { @@ -271,7 +520,7 @@ static enum nrf_wifi_status hal_rpu_ready(struct nrf_wifi_hal_dev_ctx *hal_dev_c return NRF_WIFI_STATUS_SUCCESS; } - +#endif /* SOFT_HPQM */ static enum nrf_wifi_status hal_rpu_ready_wait(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, enum NRF_WIFI_HAL_MSG_TYPE msg_type) @@ -300,10 +549,15 @@ static enum nrf_wifi_status hal_rpu_msg_trigger(struct nrf_wifi_hal_dev_ctx *hal { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; +#ifdef WIFI_NRF71 + status = hal_rpu_reg_write(hal_dev_ctx, + WEZEN_RPU_REG_INT_TO_WIFICORE_BELLBOARD_TASKS_TRIGGER, + 1); +#else /* WIFI_NRF71 */ status = hal_rpu_reg_write(hal_dev_ctx, RPU_REG_INT_TO_MCU_CTRL, (hal_dev_ctx->num_cmds | 0x7fff0000)); - +#endif /* !WIFI_NRF71 */ if (status != NRF_WIFI_STATUS_SUCCESS) { nrf_wifi_osal_log_err("%s: Writing to MCU cmd register failed", __func__); @@ -315,7 +569,207 @@ static enum nrf_wifi_status hal_rpu_msg_trigger(struct nrf_wifi_hal_dev_ctx *hal return status; } +#ifdef SOFT_HPQM +enum nrf_wifi_status hal_rpu_msg_post(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + enum NRF_WIFI_HAL_MSG_TYPE msg_type, + unsigned int queue_id, + unsigned int msg_addr) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct host_rpu_hpq *busy_queue = NULL; + unsigned int current_index = 0; + if (queue_id >= MAX_NUM_OF_RX_QUEUES) { + nrf_wifi_osal_log_err("%s: Invalid queue_id (%d)\n", + __func__, + queue_id); + goto out; + } + + if (msg_type == NRF_WIFI_HAL_MSG_TYPE_CMD_CTRL) { + status = hal_rpu_mem_read(hal_dev_ctx, + ¤t_index, + &hal_dev_ctx->rpu_info.soft_hpq->host_cmd_free_index, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from the host_cmd_free_index = %x address failed, val (0x%X)\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_cmd_free_index, + current_index); + goto out; + } + + + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->cmd_busy_buffs[current_index], + msg_addr, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to cmd_busy_buffs[index=%d] address = %x failed msg_addr = %x\n", + __func__, + current_index, + &hal_dev_ctx->rpu_info.soft_hpq->cmd_busy_buffs[current_index], + msg_addr); + goto out; + } + + current_index++; + if (current_index == HOST_RPU_CMD_BUFFERS) + current_index = 0; + + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->host_cmd_free_index, + current_index, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to host_cmd_free_index = %x failed for val =%d\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_cmd_free_index, + current_index); + goto out; + } + } else if (msg_type == NRF_WIFI_HAL_MSG_TYPE_CMD_DATA_TX) { + status = hal_rpu_mem_read(hal_dev_ctx, + ¤t_index, + &hal_dev_ctx->rpu_info.soft_hpq->host_tx_cmd_busy_index, + sizeof (unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from the host_event_busy_index = %x address failed, val (0x%X)\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_tx_cmd_busy_index, + current_index); + goto out; + } + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->tx_cmd_buffs[current_index], + msg_addr, + sizeof(unsigned int)); + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to tx_cmd_buffs[index=%d] address = %x failed val=%x\n", + __func__, + current_index, + &hal_dev_ctx->rpu_info.soft_hpq->tx_cmd_buffs[current_index], + msg_addr); + goto out; + } + + current_index++; + if (current_index == HOST_RPU_TX_DESC) + current_index = 0; + + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->host_tx_cmd_busy_index, + current_index, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to host_cmd_free_index = %x failed for val =%d\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_tx_cmd_busy_index, + current_index); + goto out; + } + } else if (msg_type == NRF_WIFI_HAL_MSG_TYPE_CMD_DATA_RX) { +#ifndef CMD_RX_BUFF + busy_queue = &hal_dev_ctx->rpu_info.hpqm_info.rx_buf_busy_queue[queue_id]; +#endif + } else { + nrf_wifi_osal_log_err("%s: Invalid msg_type (%d)\n", + __func__, + msg_type); + goto out; + } + + if (msg_type != NRF_WIFI_HAL_MSG_TYPE_CMD_DATA_RX) { + /* Indicate to the RPU that the information has been posted */ + status = hal_rpu_msg_trigger(hal_dev_ctx); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Posting command to RPU failed\n", + __func__); + goto out; + } + } +out: + return status; +} + +static enum nrf_wifi_status hal_rpu_msg_get_addr(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + enum NRF_WIFI_HAL_MSG_TYPE msg_type, + unsigned int *msg_addr) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned int val = 0; + unsigned int current_index = 0; + + if (msg_type == NRF_WIFI_HAL_MSG_TYPE_CMD_CTRL) { + status = hal_rpu_mem_read(hal_dev_ctx, + ¤t_index, + &hal_dev_ctx->rpu_info.soft_hpq->host_cmd_free_index, + sizeof (unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from the host_event_busy_index = %x address failed, val (0x%X)\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_cmd_free_index, + current_index); + goto out; + } + + status = hal_rpu_mem_read(hal_dev_ctx, + &val, + &hal_dev_ctx->rpu_info.soft_hpq->cmd_free_buffs[current_index], + sizeof (unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from the cmd_free_buffs[%d] = %x address failed, val (0x%X)\n", + __func__, + current_index, + &hal_dev_ctx->rpu_info.soft_hpq->cmd_free_buffs[current_index], + val); + goto out; + } + } else { + nrf_wifi_osal_log_err("%s: Invalid msg type %d\n", + __func__, + msg_type); + return NRF_WIFI_STATUS_FAIL; + } + + + if (!val) { + nrf_wifi_osal_log_err("%s:No valid content avaialble in the expected index \n", + __func__, + current_index); + *msg_addr = 0; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } else { + /* Valid address has been read. So write back 0 to same index address at cmd_free_buffs*/ + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->cmd_free_buffs[current_index], + 0x0, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Write to address %xfailed, val (0x%X)\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->cmd_free_buffs[current_index], + 0x0); + return true; + } + + *msg_addr = val; /* Assign the address read from cmd_free_buffs current_index */ + status = NRF_WIFI_STATUS_SUCCESS; + } +out: + return status; +} +#else enum nrf_wifi_status hal_rpu_msg_post(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, enum NRF_WIFI_HAL_MSG_TYPE msg_type, unsigned int queue_id, @@ -401,6 +855,7 @@ static enum nrf_wifi_status hal_rpu_msg_get_addr(struct nrf_wifi_hal_dev_ctx *ha out: return status; } +#endif /*SOFT_HPQM */ #endif /* !NRF71_ON_IPC */ static enum nrf_wifi_status hal_rpu_msg_write(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, @@ -748,6 +1203,10 @@ enum nrf_wifi_status nrf_wifi_hal_dev_init(struct nrf_wifi_hal_dev_ctx *hal_dev_ } #ifndef NRF71_ON_IPC +#ifdef SOFT_HPQM + hal_dev_ctx->rpu_info.soft_hpq = (struct soft_hpqm_info *)HOST_RPU_SOFTHPQM_INFO_START; + +#else /* Read the HPQM info for all the queues provided by the RPU * (like command, event, RX buf queues etc) */ @@ -755,6 +1214,7 @@ enum nrf_wifi_status nrf_wifi_hal_dev_init(struct nrf_wifi_hal_dev_ctx *hal_dev_ &hal_dev_ctx->rpu_info.hpqm_info, RPU_MEM_HPQ_INFO, sizeof(hal_dev_ctx->rpu_info.hpqm_info)); +#endif /*SOFT_HPQM */ if (status != NRF_WIFI_STATUS_SUCCESS) { nrf_wifi_osal_log_err("%s: Failed to get the HPQ info", @@ -886,7 +1346,51 @@ static int nrf_wifi_hal_poll_reg(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, return status; } +#ifdef WIFI_NRF71 +#ifdef HOST_FW_HEX_LOAD_SUPPORT +enum nrf_wifi_status nrf_wifi_hal_set_initpc(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int rpu_reg_addr, + unsigned int init_pc_addr) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + status = hal_rpu_reg_write(hal_dev_ctx, + rpu_reg_addr, + init_pc_addr); + return status; +} +enum nrf_wifi_status nrf_wifi_hal_set_grtc(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int rpu_reg_addr, + unsigned int val) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + status = hal_rpu_reg_write(hal_dev_ctx, + rpu_reg_addr, + val); + return status; +} +enum nrf_wifi_status nrf_wifi_hal_cpu_run(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int rpu_reg_addr, + unsigned int val) { + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + status = hal_rpu_reg_write(hal_dev_ctx, + rpu_reg_addr, + val); + return status; +} +enum nrf_wifi_status nrf_wifi_hal_set_wicr(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int rpu_reg_addr, + unsigned int val) { + + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + + status = hal_rpu_reg_write(hal_dev_ctx, + rpu_reg_addr, + val); + return status; +} +#endif +#else /* WIFI_NRF71*/ /* Perform MIPS reset */ enum nrf_wifi_status nrf_wifi_hal_proc_reset(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, enum RPU_PROC_TYPE rpu_proc) @@ -964,6 +1468,7 @@ enum nrf_wifi_status nrf_wifi_hal_proc_reset(struct nrf_wifi_hal_dev_ctx *hal_de hal_dev_ctx->curr_proc = RPU_PROC_TYPE_MCU_LMAC; return status; } +#endif /* !WIFI_NRF71 */ #ifndef NRF71_ON_IPC #define MCU_FW_BOOT_TIMEOUT_MS 1000 @@ -1058,7 +1563,12 @@ nrf_wifi_hal_init(struct nrf_wifi_hal_cfg_params *cfg_params, hpriv->rpu_recovery_callbk_fn = rpu_recovery_callbk_fn; #ifndef NRF71_ON_IPC - status = pal_rpu_addr_offset_get(RPU_ADDR_PKTRAM_START, + status = pal_rpu_addr_offset_get( +#ifdef WIFI_NRF71 + RPU_ADDR_DATA_RAM_START, +#else /* WIFI_NRF71 */ + RPU_ADDR_PKTRAM_START, +#endif /* !WIFI_NRF71 */ &hpriv->addr_pktram_base, RPU_PROC_TYPE_MAX); @@ -1069,7 +1579,16 @@ nrf_wifi_hal_init(struct nrf_wifi_hal_cfg_params *cfg_params, } bal_cfg_params.addr_pktram_base = hpriv->addr_pktram_base; - +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + hpriv->hostram_addr_base_inline_rx = + (unsigned long)nrf_wifi_osal_iomem_mmap_inline_rx( + SOC_HOST_DATA_RAM_BASE, + SOC_HOST_DATA_RAM_LEN); + bal_cfg_params.addr_hostram_base_inline_rx = + hpriv->hostram_addr_base_inline_rx; +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ hpriv->bpriv = nrf_wifi_bal_init(&bal_cfg_params, &nrf_wifi_hal_irq_handler); @@ -1093,11 +1612,16 @@ nrf_wifi_hal_init(struct nrf_wifi_hal_cfg_params *cfg_params, void nrf_wifi_hal_deinit(struct nrf_wifi_hal_priv *hpriv) { nrf_wifi_bal_deinit(hpriv->bpriv); - +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + nrf_wifi_osal_iomem_unmap_inline_rx(hpriv->hostram_addr_base_inline_rx); +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ nrf_wifi_osal_mem_free(hpriv); } #ifndef NRF71_ON_IPC +#ifndef WIFI_NRF71 enum nrf_wifi_status nrf_wifi_hal_otp_info_get(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, struct host_rpu_umac_info *otp_info, unsigned int *otp_flags) @@ -1185,6 +1709,7 @@ enum nrf_wifi_status nrf_wifi_hal_otp_pack_info_get(struct nrf_wifi_hal_dev_ctx out: return status; } +#endif /* !WIFI_NRF71 */ #endif /* !NRF71_ON_IPC */ void nrf_wifi_hal_enable(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx) diff --git a/hw_if/hal/src/common/hal_fw_patch_loader.c b/hw_if/hal/src/common/hal_fw_patch_loader.c index 1e67e8f..87421bb 100644 --- a/hw_if/hal/src/common/hal_fw_patch_loader.c +++ b/hw_if/hal/src/common/hal_fw_patch_loader.c @@ -9,11 +9,9 @@ * HAL Layer of the Wi-Fi driver. */ -#include "host_rpu_common_if.h" +#include "nrf71_wifi_common.h" #include "common/hal_fw_patch_loader.h" #include "common/hal_mem.h" -#include "lmac_if_common.h" -#include "host_rpu_common_if.h" /* To reduce HEAP maximum usage */ #define MAX_PATCH_CHUNK_SIZE 8192 diff --git a/hw_if/hal/src/common/hal_interrupt.c b/hw_if/hal/src/common/hal_interrupt.c index 15284e7..951c320 100644 --- a/hw_if/hal/src/common/hal_interrupt.c +++ b/hw_if/hal/src/common/hal_interrupt.c @@ -19,6 +19,11 @@ enum nrf_wifi_status hal_rpu_irq_enable(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; +#ifdef WIFI_NRF71 + status = hal_rpu_reg_write(hal_dev_ctx, + WEZEN_RPU_REG_INT_FROM_MCU_CTRL, + 1); +#else /* WIFI_NRF71 */ unsigned int val = 0; /* First enable the blockwise interrupt for the relevant block in the @@ -53,6 +58,7 @@ enum nrf_wifi_status hal_rpu_irq_enable(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx RPU_REG_INT_FROM_MCU_CTRL, val); +#endif /* !WIFI_NRF71 */ if (status != NRF_WIFI_STATUS_SUCCESS) { nrf_wifi_osal_log_err("%s:Enabling MCU interrupt failed", __func__); @@ -67,6 +73,11 @@ enum nrf_wifi_status hal_rpu_irq_enable(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx enum nrf_wifi_status hal_rpu_irq_disable(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; +#ifdef WIFI_NRF71 + status = hal_rpu_reg_write(hal_dev_ctx, + WEZEN_RPU_REG_INT_FROM_MCU_CTRL, + 0); +#else /* WIFI_NRF71 */ unsigned int val = 0; status = hal_rpu_reg_read(hal_dev_ctx, @@ -97,6 +108,7 @@ enum nrf_wifi_status hal_rpu_irq_disable(struct nrf_wifi_hal_dev_ctx *hal_dev_ct RPU_REG_INT_FROM_MCU_CTRL, val); +#endif /* !WIFI_NRF71 */ if (status != NRF_WIFI_STATUS_SUCCESS) { nrf_wifi_osal_log_err("%s: Disabling MCU interrupt failed", __func__); @@ -112,17 +124,21 @@ static enum nrf_wifi_status hal_rpu_irq_ack(struct nrf_wifi_hal_dev_ctx *hal_dev { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; unsigned int val = 0; - +#ifdef WIFI_NRF71 + status = hal_rpu_reg_write(hal_dev_ctx, + WEZEN_RPU_REG_INT_FROM_MCU_CLR, + val); +#else /* WIFI_NRF71 */ val = (1 << RPU_REG_BIT_INT_FROM_MCU_ACK); status = hal_rpu_reg_write(hal_dev_ctx, RPU_REG_INT_FROM_MCU_ACK, val); - +#endif /* !WIFI_NRF71 */ return status; } - +#ifndef WIFI_NRF71 static bool hal_rpu_irq_wdog_chk(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; @@ -201,12 +217,60 @@ static enum nrf_wifi_status hal_rpu_irq_wdog_rearm(struct nrf_wifi_hal_dev_ctx * out: return status; } - +#endif /* !WIFI_NRF71 */ static enum nrf_wifi_status hal_rpu_event_free(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, unsigned int event_addr) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; +#ifdef SOFT_HPQM + unsigned int current_index = 0; + + status = hal_rpu_mem_read(hal_dev_ctx, + ¤t_index, + &hal_dev_ctx->rpu_info.soft_hpq->host_event_busy_index, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from the host_event_busy_index = %x address failed, val (0x%X)\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_event_busy_index, + current_index); + goto out; + } + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->event_free_buffs[current_index], + event_addr, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to event_freebuffs[index=%d] address = %x failed for event_addr= %x\n", + __func__, + current_index, + &hal_dev_ctx->rpu_info.soft_hpq->event_free_buffs[current_index], + event_addr); + goto out; + } + + current_index++; + + if (current_index == HOST_RPU_EVENT_BUFFERS) + current_index = 0; + + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->host_event_busy_index, + current_index, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to host_event_busy_index address = %x failed for val =%d\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_event_busy_index, + current_index); + goto out; + } + +#else status = hal_rpu_hpq_enqueue(hal_dev_ctx, &hal_dev_ctx->rpu_info.hpqm_info.event_avl_queue, @@ -217,7 +281,7 @@ static enum nrf_wifi_status hal_rpu_event_free(struct nrf_wifi_hal_dev_ctx *hal_ __func__); goto out; } - +#endif /* SOFT_HPQM */ out: return status; } @@ -441,7 +505,120 @@ static unsigned int hal_rpu_event_get_all(struct nrf_wifi_hal_dev_ctx *hal_dev_c while (1) { event_addr = 0; +#ifdef SOFT_HPQM + unsigned int desc_no = 0; + unsigned int current_index = 0; + + status = hal_rpu_mem_read(hal_dev_ctx, + ¤t_index, + &hal_dev_ctx->rpu_info.soft_hpq->host_event_busy_index, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from the host_event_busy_index = %x address failed, val (0x%X)\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_event_busy_index, + current_index); + goto out; + } + status = hal_rpu_mem_read(hal_dev_ctx, + &event_addr, + &hal_dev_ctx->rpu_info.soft_hpq->event_busy_buffs[current_index], + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from event_busy_buffs[%d]= %x address failed, val (0x%X)\n", + __func__, + current_index, + hal_dev_ctx->rpu_info.soft_hpq->event_busy_buffs[current_index], + event_addr); + goto out; + } + + if (!event_addr) { + for (desc_no = 0; desc_no < HOST_RPU_TX_DESC; desc_no++) { + /* There is no control events pending. Now check tx_done event */ + status = hal_rpu_mem_read(hal_dev_ctx, + ¤t_index, + &hal_dev_ctx->rpu_info.soft_hpq->host_tx_done_busy_index, + sizeof (unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from the host_tx_done_busy_index = %x address failed, val (0x%X)\n", + __func__, + &hal_dev_ctx->rpu_info.soft_hpq->host_tx_done_busy_index, + current_index); + goto out; + } + + status = hal_rpu_mem_read(hal_dev_ctx, + &event_addr, + &hal_dev_ctx->rpu_info.soft_hpq->tx_done_buffs[current_index], + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Read from tx_done_buffs[%d] = %x address failed, val (0x%X)\n", + __func__, + current_index, + &hal_dev_ctx->rpu_info.soft_hpq->tx_done_buffs[current_index], + event_addr); + goto out; + } + + if (!event_addr) { + continue; + } else { + /* Set the content to 0 */ + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->tx_done_buffs[current_index], + 0x0, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to tx_done_buffs[%d] = %x address failed \n", + __func__, + current_index, + &hal_dev_ctx->rpu_info.soft_hpq->tx_done_buffs[current_index]); + goto out; + } + + current_index++; + + if (current_index == HOST_RPU_TX_DESC) + current_index = 0; + + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->host_tx_done_busy_index, + current_index, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing %d to host_tx_done_busy_index = %x address failed \n", + __func__, + current_index, + &hal_dev_ctx->rpu_info.soft_hpq->host_tx_done_busy_index); + goto out; + } + break; + } + } + } else { + /* Set the content to 0 */ + status = hal_rpu_mem_write(hal_dev_ctx, + &hal_dev_ctx->rpu_info.soft_hpq->event_busy_buffs[current_index], + 0x0, + sizeof(unsigned int)); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to event_busy_buffs[%d] = %x address failed \n", + __func__, + current_index, + &hal_dev_ctx->rpu_info.soft_hpq->event_busy_buffs[current_index]); + goto out; + } + } +#else /* First get the event address */ status = hal_rpu_hpq_dequeue(hal_dev_ctx, &hal_dev_ctx->rpu_info.hpqm_info.event_busy_queue, @@ -453,6 +630,7 @@ static unsigned int hal_rpu_event_get_all(struct nrf_wifi_hal_dev_ctx *hal_dev_c goto out; } +#endif /* SOFT_HPQM */ /* No more events to read. Sometimes when low power mode is enabled * we see a wrong address, but it work after a while, so, add a * check for that. @@ -504,6 +682,7 @@ static inline bool is_rpu_recovery_needed(struct nrf_wifi_hal_dev_ctx *hal_dev_c } #endif /* NRF_WIFI_RPU_RECOVERY */ +#ifndef WIFI_NRF71 static enum nrf_wifi_status hal_rpu_process_wdog(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, bool *do_rpu_recovery) { @@ -556,6 +735,7 @@ static enum nrf_wifi_status hal_rpu_process_wdog(struct nrf_wifi_hal_dev_ctx *ha return nrf_wifi_status; } +#endif /* !WIFI_NRF71 */ enum nrf_wifi_status hal_rpu_irq_process(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, bool *do_rpu_recovery) @@ -563,7 +743,17 @@ enum nrf_wifi_status hal_rpu_irq_process(struct nrf_wifi_hal_dev_ctx *hal_dev_ct enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; unsigned int num_events = 0; + /* We had an issue in fpga setup where even before host completes + * reading of the all the events firmware was pushing an event. + * So handle this acking the irq first and then processing teh events. + */ + status = hal_rpu_irq_ack(hal_dev_ctx); + if (status == NRF_WIFI_STATUS_FAIL) { + nrf_wifi_osal_log_err("%s: hal_rpu_irq_ack failed\n", + __func__); + goto out; + } /* Get all the events in the queue. It is possible that there are no * events in the queue. This is a valid scenario as per our present * design (as discussed with LMAC team), since the RPU will raise @@ -577,6 +767,7 @@ enum nrf_wifi_status hal_rpu_irq_process(struct nrf_wifi_hal_dev_ctx *hal_dev_ct */ num_events = hal_rpu_event_get_all(hal_dev_ctx); +#ifndef WIFI_NRF71 if (hal_rpu_irq_wdog_chk(hal_dev_ctx)) { #ifdef NRF_WIFI_RPU_RECOVERY hal_dev_ctx->wdt_irq_received++; @@ -601,7 +792,7 @@ enum nrf_wifi_status hal_rpu_irq_process(struct nrf_wifi_hal_dev_ctx *hal_dev_ct goto out; } } - +#endif /* !WIFI_NRF71 */ if (!num_events) { status = NRF_WIFI_STATUS_SUCCESS; goto out; diff --git a/hw_if/hal/src/common/hal_mem.c b/hw_if/hal/src/common/hal_mem.c index e55a54f..987793a 100644 --- a/hw_if/hal/src/common/hal_mem.c +++ b/hw_if/hal/src/common/hal_mem.c @@ -17,16 +17,73 @@ static bool hal_rpu_is_mem_ram(enum RPU_PROC_TYPE proc, unsigned int addr_val) { +#ifdef WIFI_NRF71 + if (((addr_val >= RPU_ADDR_RAM0_START) && + (addr_val <= RPU_ADDR_RAM0_END)) || + ((addr_val >= RPU_ADDR_RAM1_START) && + (addr_val <= RPU_ADDR_RAM1_END)) || + ((addr_val >= RPU_ADDR_ACTUAL_DATA_RAM_START) && + (addr_val <= RPU_ADDR_ACTUAL_DATA_RAM_END)) || + ((addr_val >= RPU_ADDR_DATA_RAM_START) && + (addr_val <= RPU_ADDR_DATA_RAM_END)) || + ((addr_val >= RPU_ADDR_CODE_RAM_START) && + (addr_val <= RPU_ADDR_CODE_RAM_END))) { + return true; +#else /* WIFI_NRF71 */ if (((addr_val >= RPU_ADDR_GRAM_START) && (addr_val <= RPU_ADDR_GRAM_END)) || ((addr_val >= RPU_ADDR_PKTRAM_START) && (addr_val <= RPU_ADDR_PKTRAM_END))) { return true; +#endif /* !WIFI_NRF71 */ + } else { + return false; + } +} + +#ifdef WIFI_NRF71 +static bool hal_rpu_is_mem_rom(enum RPU_PROC_TYPE proc, unsigned int addr_val) +{ + if (((addr_val >= RPU_ADDR_ROM0_START) && + (addr_val <= RPU_ADDR_ROM0_END)) || + ((addr_val >= RPU_ADDR_ROM1_START) && + (addr_val <= RPU_ADDR_ROM1_END))) { + return true; } else { return false; } } +static bool hal_rpu_is_mem_secure_ram(unsigned int addr_val) +{ + if ((addr_val >= RPU_ADDR_SECURERAM_START) && + (addr_val <= RPU_ADDR_SECURERAM_END)) { + return true; + } else { + return false; + } +} + +static bool hal_rpu_is_mem_code_ram(unsigned int addr_val) +{ + if ((addr_val >= RPU_ADDR_CODE_RAM_START) && + (addr_val <= RPU_ADDR_CODE_RAM_END)) { + return true; + } else { + return false; + } +} + +static bool hal_rpu_is_mem_data_ram(unsigned int addr_val) +{ + if ((addr_val >= RPU_ADDR_ACTUAL_DATA_RAM_START) && + (addr_val <= RPU_ADDR_ACTUAL_DATA_RAM_END)) { + return true; + } else { + return false; + } +} +#else /* WIFI_NRF71 */ static bool hal_rpu_is_mem_bev(unsigned int addr_val) { @@ -50,25 +107,36 @@ static bool hal_rpu_is_mem_core_indirect(enum RPU_PROC_TYPE proc, { return ((addr_val & 0xFF000000) == RPU_MCU_CORE_INDIRECT_BASE); } - +#endif /* !WIFI_NRF71 */ static bool hal_rpu_is_mem_readable(enum RPU_PROC_TYPE proc, unsigned int addr) { +#ifdef WIFI_NRF71 + return hal_rpu_is_mem_ram(proc, addr); +#else /* WIFI_NRF71 */ return hal_rpu_is_mem_ram(proc, addr) || hal_rpu_is_mem_core_direct(proc, addr); +#endif /* !WIFI_NRF71 */ } static bool hal_rpu_is_mem_writable(enum RPU_PROC_TYPE proc, unsigned int addr) { +#ifdef WIFI_NRF71 + if (hal_rpu_is_mem_ram(proc, addr) || + hal_rpu_is_mem_rom(proc, addr) || + hal_rpu_is_mem_secure_ram(addr)) { + return true; + } +#else /* WIFI_NRF71 */ if (hal_rpu_is_mem_ram(proc, addr) || hal_rpu_is_mem_core_indirect(proc, addr) || hal_rpu_is_mem_core_direct(proc, addr) || hal_rpu_is_mem_bev(addr)) { return true; } - +#endif /* !WIFI_NRF71 */ return false; } @@ -83,7 +151,9 @@ static enum nrf_wifi_status rpu_mem_read_ram(struct nrf_wifi_hal_dev_ctx *hal_de #ifdef NRF_WIFI_LOW_POWER unsigned long flags = 0; #endif /* NRF_WIFI_LOW_POWER */ - +#ifdef WIFI_NRF71 + unsigned long fpga_reg_addr_offset = 0; +#endif status = pal_rpu_addr_offset_get(ram_addr_val, &addr_offset, hal_dev_ctx->curr_proc); @@ -106,11 +176,45 @@ static enum nrf_wifi_status rpu_mem_read_ram(struct nrf_wifi_hal_dev_ctx *hal_de goto out; } #endif /* NRF_WIFI_LOW_POWER */ +#ifdef WIFI_NRF71 + /* First set the SOC_MMAP_ADDR_OFFSET_ROM_ACCESS_FPGA_REG to 0 + * for RAM access + */ + status = pal_rpu_addr_offset_get(ROM_ACCESS_REG_ADDR, + &fpga_reg_addr_offset, + hal_dev_ctx->curr_proc); + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: pal_rpu_addr_offset_get failed\n", + __func__); + return status; + } - nrf_wifi_bal_read_block(hal_dev_ctx->bal_dev_ctx, - src_addr, - addr_offset, - len); + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + fpga_reg_addr_offset, + RPU_REG_BIT_ROM_ACCESS_DISABLE); + + if (len == 4) { + *((unsigned int *)src_addr) = nrf_wifi_bal_read_word( + hal_dev_ctx->bal_dev_ctx, + addr_offset); + + if (*((unsigned int *)src_addr) == 0xFFFFFFFF) { + nrf_wifi_osal_log_err("%s: Error !! Value read at addr_offset = %lx is = %X\n", + __func__, + addr_offset, + *((unsigned int *)src_addr)); + status = NRF_WIFI_STATUS_FAIL; + goto out1; + } + } else { +#endif /* WIFI_NRF71 */ + nrf_wifi_bal_read_block(hal_dev_ctx->bal_dev_ctx, + src_addr, + addr_offset, + len); +#ifdef WIFI_NRF71 + } +#endif /* WIFI_NRF71 */ status = NRF_WIFI_STATUS_SUCCESS; @@ -119,10 +223,65 @@ static enum nrf_wifi_status rpu_mem_read_ram(struct nrf_wifi_hal_dev_ctx *hal_de nrf_wifi_osal_spinlock_irq_rel(hal_dev_ctx->rpu_ps_lock, &flags); #endif /* NRF_WIFI_LOW_POWER */ - +#ifdef WIFI_NRF71 +out1: +#endif /* WIFI_NRF71 */ return status; } +#ifdef WIFI_NRF71 +static enum nrf_wifi_status rpu_mem_write_rom( + struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int rom_addr_val, + void *src_addr, + unsigned int len) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned long addr_offset = 0; + unsigned long fpga_reg_addr_offset = 0; + + status = pal_rpu_addr_offset_get(rom_addr_val, + &addr_offset, + hal_dev_ctx->curr_proc); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: pal_rpu_addr_offset_get failed", + __func__); + return status; + } + + /* First set the SOC_MMAP_ADDR_OFFSET_ROM_ACCESS_FPGA_REG to 1 + * for ROM access + */ + status = pal_rpu_addr_offset_get(ROM_ACCESS_REG_ADDR, + &fpga_reg_addr_offset, + hal_dev_ctx->curr_proc); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: pal_rpu_addr_offset_get failed", + __func__); + return status; + } + + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + fpga_reg_addr_offset, + RPU_REG_BIT_ROM_ACCESS_ENABLE); + + if (len == 4) { + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + addr_offset, + (unsigned int)src_addr); + } else { + nrf_wifi_bal_write_block(hal_dev_ctx->bal_dev_ctx, + addr_offset, + src_addr, + len); + } + + status = NRF_WIFI_STATUS_SUCCESS; + return status; +} +#endif /* WIFI_NRF71 */ static enum nrf_wifi_status rpu_mem_write_ram(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, unsigned int ram_addr_val, @@ -174,7 +333,213 @@ static enum nrf_wifi_status rpu_mem_write_ram(struct nrf_wifi_hal_dev_ctx *hal_d return status; } +#ifdef WIFI_NRF71 +static enum nrf_wifi_status rpu_mem_write_code_ram( + struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int code_ram_addr_val, + void *src_addr, + unsigned int len) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned long addr_offset = 0; + + if (code_ram_addr_val % 4 != 0) { + nrf_wifi_osal_log_err("%s: Address not multiple of 4 bytes\n", + __func__); + goto out; + } + + status = pal_rpu_addr_offset_get(code_ram_addr_val, + &addr_offset, + hal_dev_ctx->curr_proc); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: pal_rpu_addr_offset_get failed\n", + __func__); + goto out; + } + + if (len == 4) { + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + addr_offset, + (unsigned int)src_addr); + } else { + nrf_wifi_bal_write_block(hal_dev_ctx->bal_dev_ctx, + addr_offset, + src_addr, + len); + } + + status = NRF_WIFI_STATUS_SUCCESS; +out: + return status; +} + +static enum nrf_wifi_status rpu_mem_write_data_ram( + struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int data_ram_addr_val, + void *src_addr, + unsigned int len) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned long addr_offset = 0; + + status = pal_rpu_addr_offset_get(data_ram_addr_val, + &addr_offset, + hal_dev_ctx->curr_proc); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: pal_rpu_addr_offset_get failed", + __func__); + goto out; + } + + if (len == 4) { + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + addr_offset, + (unsigned int)src_addr); + } else { + nrf_wifi_bal_write_block(hal_dev_ctx->bal_dev_ctx, + addr_offset, + src_addr, + len); + } + + status = NRF_WIFI_STATUS_SUCCESS; +out: + return status; +} + + +static enum nrf_wifi_status rpu_mem_read_code_ram( + struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + void *src_addr, + unsigned int code_ram_addr_val, + unsigned int len) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned long addr_offset = 0; + + status = pal_rpu_addr_offset_get(code_ram_addr_val, + &addr_offset, + hal_dev_ctx->curr_proc); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: pal_rpu_addr_offset_get failed\n", + __func__); + return status; + } + if (len == 4) { + *((unsigned int *)src_addr) = nrf_wifi_bal_read_word( + hal_dev_ctx->bal_dev_ctx, + addr_offset); + + if (*((unsigned int *)src_addr) == 0xFFFFFFFF) { + nrf_wifi_osal_log_err("%s: Error !! Value read at addr_offset = %lx is = %X\n", + __func__, + addr_offset, + *((unsigned int *)src_addr)); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } + } else { + nrf_wifi_bal_read_block(hal_dev_ctx->bal_dev_ctx, + src_addr, + addr_offset, + len); + } + status = NRF_WIFI_STATUS_SUCCESS; +out: + return status; +} + +static enum nrf_wifi_status rpu_mem_read_data_ram( + struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + void *src_addr, + unsigned int data_ram_addr_val, + unsigned int len) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned long addr_offset = 0; + + status = pal_rpu_addr_offset_get(data_ram_addr_val, + &addr_offset, + hal_dev_ctx->curr_proc); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: pal_rpu_addr_offset_get failed\n", + __func__); + return status; + } + + if (len == 4) { + *((unsigned int *)src_addr) = nrf_wifi_bal_read_word( + hal_dev_ctx->bal_dev_ctx, + addr_offset); + if (*((unsigned int *)src_addr) == 0xFFFFFFFF) { + nrf_wifi_osal_log_err("%s: Error !! Value read at addr_offset = %lx is = %X\n", + __func__, + addr_offset, + *((unsigned int *)src_addr)); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } + } else { + nrf_wifi_bal_read_block(hal_dev_ctx->bal_dev_ctx, + src_addr, + addr_offset, + len); + } + + status = NRF_WIFI_STATUS_SUCCESS; +out: + return status; +} + +static enum nrf_wifi_status rpu_mem_write_secure_ram( + struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int secure_ram_addr_val, + void *src_addr, + unsigned int len) +{ + int status = NRF_WIFI_STATUS_FAIL; + unsigned int addr = 0; + unsigned int data = 0; + unsigned int i = 0; + if ((secure_ram_addr_val < RPU_ADDR_SECURERAM_START) || + (secure_ram_addr_val > RPU_ADDR_SECURERAM_END)) { + nrf_wifi_osal_log_err("%s: Address not in range\n", + __func__); + goto out; + } + for (i = 0; i < (len / sizeof(int)); i++) { + addr = secure_ram_addr_val + (i * sizeof(int)); + data = *((unsigned int *)src_addr + i); + status = hal_rpu_reg_write(hal_dev_ctx, + addr, + data); + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to secure ram failed\n", + __func__); + goto out; + } + } + if (len % sizeof(int)) { + data = *((unsigned int *)src_addr + i); + status = hal_rpu_reg_write(hal_dev_ctx, + addr, + data); + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: Writing to secure ram failed\n",\ + __func__); + goto out; + } + } +out: + return status; +} +#else /* WIFI_NRF71 */ static enum nrf_wifi_status rpu_mem_write_core(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, unsigned int core_addr_val, void *src_addr, @@ -309,7 +674,7 @@ static enum nrf_wifi_status rpu_mem_write_bev(struct nrf_wifi_hal_dev_ctx *hal_d out: return status; } - +#endif /* !WIFI_NRF71 */ enum nrf_wifi_status hal_rpu_mem_read(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, void *src_addr, @@ -334,11 +699,26 @@ enum nrf_wifi_status hal_rpu_mem_read(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, rpu_mem_addr_val); goto out; } - - status = rpu_mem_read_ram(hal_dev_ctx, - src_addr, - rpu_mem_addr_val, - len); +#ifdef WIFI_NRF71 + if (hal_rpu_is_mem_data_ram(rpu_mem_addr_val)) { + status = rpu_mem_read_data_ram(hal_dev_ctx, + src_addr, + rpu_mem_addr_val, + len); + } else if (hal_rpu_is_mem_code_ram(rpu_mem_addr_val)) { + status = rpu_mem_read_code_ram(hal_dev_ctx, + src_addr, + rpu_mem_addr_val, + len); + } else { +#endif /* WIFI_NRF71 */ + status = rpu_mem_read_ram(hal_dev_ctx, + src_addr, + rpu_mem_addr_val, + len); +#ifdef WIFI_NRF71 + } +#endif /* WIFI_NRF71 */ out: return status; } @@ -354,13 +734,13 @@ enum nrf_wifi_status hal_rpu_mem_write(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, if (!hal_dev_ctx) { return status; } - +#ifndef WIFI_NRF71 if (!src_addr) { nrf_wifi_osal_log_err("%s: Invalid params", __func__); return status; } - +#endif /* !WIFI_NRF71 */ if (!hal_rpu_is_mem_writable(hal_dev_ctx->curr_proc, rpu_mem_addr_val)) { nrf_wifi_osal_log_err("%s: Invalid memory address 0x%X", @@ -369,6 +749,35 @@ enum nrf_wifi_status hal_rpu_mem_write(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, return status; } +#ifdef WIFI_NRF71 + if (hal_rpu_is_mem_code_ram(rpu_mem_addr_val)) { + status = rpu_mem_write_code_ram(hal_dev_ctx, + rpu_mem_addr_val, + src_addr, + len); + } else if (hal_rpu_is_mem_data_ram(rpu_mem_addr_val)) { + status = rpu_mem_write_data_ram(hal_dev_ctx, + rpu_mem_addr_val, + src_addr, + len); + } else if (hal_rpu_is_mem_rom(hal_dev_ctx->curr_proc, + rpu_mem_addr_val)) { + status = rpu_mem_write_rom(hal_dev_ctx, + rpu_mem_addr_val, + src_addr, + len); + } else if (hal_rpu_is_mem_secure_ram(rpu_mem_addr_val)) { + status = rpu_mem_write_secure_ram(hal_dev_ctx, + rpu_mem_addr_val, + src_addr, + len); + } else if (hal_rpu_is_mem_ram(hal_dev_ctx->curr_proc, + rpu_mem_addr_val)) { + status = rpu_mem_write_ram(hal_dev_ctx, + rpu_mem_addr_val, + src_addr, + len); +#else if (hal_rpu_is_mem_core_indirect(hal_dev_ctx->curr_proc, rpu_mem_addr_val)) { status = rpu_mem_write_core(hal_dev_ctx, @@ -386,6 +795,7 @@ enum nrf_wifi_status hal_rpu_mem_write(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, rpu_mem_addr_val, src_addr, len); +#endif /* WIFI_NRF71 */ } else { nrf_wifi_osal_log_err("%s: Invalid memory address 0x%X", __func__, @@ -407,12 +817,43 @@ enum nrf_wifi_status hal_rpu_mem_clr(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, unsigned int start_addr = 0; unsigned int end_addr = 0; unsigned int mem_val = 0; +#ifdef WIFI_NRF71 + unsigned long fpga_reg_addr_offset = 0; +#else /* WIFI_NRF71 */ enum RPU_MCU_ADDR_REGIONS mcu_region = pal_mem_type_to_region(mem_type); +#endif /* !WIFI_NRF71 */ if (!hal_dev_ctx) { goto out; } +#ifdef WIFI_NRF71 + if (mem_type == HAL_RPU_MEM_TYPE_RAM_0) { + start_addr = RPU_ADDR_RAM0_START; + end_addr = RPU_ADDR_RAM0_END; + } else if (mem_type == HAL_RPU_MEM_TYPE_ROM_0) { + start_addr = RPU_ADDR_ROM0_START; + end_addr = RPU_ADDR_ROM0_END; + } else if (mem_type == HAL_RPU_MEM_TYPE_DATA_RAM) { + start_addr = RPU_ADDR_DATA_RAM_START; + end_addr = RPU_ADDR_DATA_RAM_END; + } else if (mem_type == HAL_RPU_MEM_TYPE_RAM_1) { + start_addr = RPU_ADDR_RAM1_START; + end_addr = RPU_ADDR_RAM1_END; + } else if (mem_type == HAL_RPU_MEM_TYPE_ROM_1) { + start_addr = RPU_ADDR_ROM1_START; + end_addr = RPU_ADDR_ROM1_END; + } else if (mem_type == HAL_RPU_MEM_TYPE_CODE_RAM) { + start_addr = RPU_ADDR_CODE_RAM_START; + end_addr = RPU_ADDR_CODE_RAM_END; + } else { + nrf_wifi_osal_log_err("%s: Invalid mem_type(%d)\n", + __func__, + mem_type); + goto out; + } + +#else /* WIFI_NRF71 */ if (mem_type == HAL_RPU_MEM_TYPE_GRAM) { start_addr = RPU_ADDR_GRAM_START; end_addr = RPU_ADDR_GRAM_END; @@ -431,7 +872,28 @@ enum nrf_wifi_status hal_rpu_mem_clr(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, mem_type); goto out; } +#endif /* !WIFI_NRF71 */ +#ifdef WIFI_NRF71 + if (mem_type == HAL_RPU_MEM_TYPE_ROM_0 || + mem_type == HAL_RPU_MEM_TYPE_ROM_1) { + /* First set the SOC_MMAP_ADDR_OFFSET_ROM_ACCESS_FPGA_REG to 1 + * for ROM access + */ + status = pal_rpu_addr_offset_get(ROM_ACCESS_REG_ADDR, + &fpga_reg_addr_offset, + hal_dev_ctx->curr_proc); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + nrf_wifi_osal_log_err("%s: pal_rpu_addr_offset_get failed", __func__); + goto out; + } + + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + fpga_reg_addr_offset, + RPU_REG_BIT_ROM_ACCESS_ENABLE); + } +#endif /* WIFI_NRF71 */ for (mem_addr = start_addr; mem_addr <= end_addr; mem_addr += sizeof(mem_val)) { @@ -446,9 +908,15 @@ enum nrf_wifi_status hal_rpu_mem_clr(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, goto out; } } +#ifdef WIFI_NRF71 + if (mem_type == HAL_RPU_MEM_TYPE_ROM_0 || + mem_type == HAL_RPU_MEM_TYPE_ROM_1) { - - + nrf_wifi_bal_write_word(hal_dev_ctx->bal_dev_ctx, + fpga_reg_addr_offset, + RPU_REG_BIT_ROM_ACCESS_ENABLE); + } +#endif /* WIFI_NRF71 */ status = NRF_WIFI_STATUS_SUCCESS; out: return status; diff --git a/hw_if/hal/src/common/hal_reg.c b/hw_if/hal/src/common/hal_reg.c index 5918716..851ba14 100644 --- a/hw_if/hal/src/common/hal_reg.c +++ b/hw_if/hal/src/common/hal_reg.c @@ -17,9 +17,16 @@ static bool hal_rpu_is_reg(unsigned int addr_val) { unsigned int addr_base = (addr_val & RPU_ADDR_MASK_BASE); - +#ifdef WIFI_NRF71 + if ((addr_base == RPU_ADDR_WIFI_MCU_REGS_REGION) || + (addr_base == RPU_ADDR_BELLBOARD_GRTC_REGION) || + (addr_base == RPU_ADDR_SECURERAM_REGION) || + (addr_base == RPU_ADDR_FPGA_REGS_REGION) || + (addr_base == RPU_ADDR_WICR_REGS_REGION)) { +#else /* WIFI_NRF71 */ if ((addr_base == RPU_ADDR_SBUS_START) || (addr_base == RPU_ADDR_PBUS_START)) { +#endif /* !WIFI_NRF71 */ return true; } else { return false; diff --git a/hw_if/hal/src/common/hpqm.c b/hw_if/hal/src/common/hpqm.c index cc18637..71437a0 100644 --- a/hw_if/hal/src/common/hpqm.c +++ b/hw_if/hal/src/common/hpqm.c @@ -13,6 +13,7 @@ #include "common/hal_mem.h" #include "common/hal_common.h" +#ifndef SOFT_HPQM enum nrf_wifi_status hal_rpu_hpq_enqueue(struct nrf_wifi_hal_dev_ctx *hal_ctx, struct host_rpu_hpq *hpq, unsigned int val) @@ -67,3 +68,4 @@ enum nrf_wifi_status hal_rpu_hpq_dequeue(struct nrf_wifi_hal_dev_ctx *hal_ctx, out: return status; } +#endif diff --git a/hw_if/hal/src/common/pal.c b/hw_if/hal/src/common/pal.c index c44e8bf..daab3ca 100644 --- a/hw_if/hal/src/common/pal.c +++ b/hw_if/hal/src/common/pal.c @@ -39,6 +39,68 @@ enum nrf_wifi_status pal_rpu_addr_offset_get(unsigned int rpu_addr, unsigned int addr_base = (rpu_addr & RPU_ADDR_MASK_BASE); unsigned long region_offset = 0; +#ifdef WIFI_NRF71 + unsigned int bellboard_grtc_addr_base = 0; + + if (addr_base == RPU_ADDR_WIFI_MCU_REGS_START) { + region_offset = SOC_MMAP_ADDR_OFFSET_WIFI_MCU_REGS; + } else if ((rpu_addr >= RPU_ADDR_RAM0_START) && + (rpu_addr <= RPU_ADDR_RAM0_END)) { + region_offset = SOC_MMAP_ADDR_OFFSET_RAM0_PKD; + *addr = region_offset + ((rpu_addr - + RPU_ADDR_RAM0_START) & RPU_ADDR_RAM_ROM_MASK_OFFSET); + status = NRF_WIFI_STATUS_SUCCESS; + goto out; + } else if ((rpu_addr >= RPU_ADDR_RAM1_START) && + (rpu_addr <= RPU_ADDR_RAM1_END)) { + region_offset = SOC_MMAP_ADDR_OFFSET_RAM1_PKD; + *addr = region_offset + ((rpu_addr - + RPU_ADDR_RAM1_START) & RPU_ADDR_RAM_ROM_MASK_OFFSET); + status = NRF_WIFI_STATUS_SUCCESS; + goto out; + } else if ((rpu_addr >= RPU_ADDR_ROM0_START) && + (rpu_addr <= RPU_ADDR_ROM0_END)) { + region_offset = SOC_MMAP_ADDR_OFFSET_ROM0_PKD; + *addr = region_offset + ((rpu_addr - + RPU_ADDR_ROM0_START) & RPU_ADDR_RAM_ROM_MASK_OFFSET); + status = NRF_WIFI_STATUS_SUCCESS; + goto out; + } else if ((rpu_addr >= RPU_ADDR_ROM1_START) && + (rpu_addr <= RPU_ADDR_ROM1_END)) { + region_offset = SOC_MMAP_ADDR_OFFSET_ROM1_PKD; + *addr = region_offset + ((rpu_addr - + RPU_ADDR_ROM1_START) & RPU_ADDR_RAM_ROM_MASK_OFFSET); + status = NRF_WIFI_STATUS_SUCCESS; + goto out; + } else if ((rpu_addr >= RPU_ADDR_DATA_RAM_START) && + (rpu_addr <= RPU_ADDR_DATA_RAM_END)) { + region_offset = SOC_MMAP_ADDR_OFFSET_DATA_RAM_PKD; + } else if ((rpu_addr >= RPU_ADDR_ACTUAL_DATA_RAM_START) && + (rpu_addr <= RPU_ADDR_ACTUAL_DATA_RAM_END)) { + region_offset = SOC_MMAP_ADDR_OFFSET_DATA_RAM_PKD; + } else if ((rpu_addr >= RPU_ADDR_CODE_RAM_START) && + (rpu_addr <= RPU_ADDR_CODE_RAM_END)) { + region_offset = SOC_MMAP_ADDR_OFFSET_CODE_RAM_PKD; + } else if (addr_base == RPU_ADDR_BELLBOARD_GRTC_REGION) { + bellboard_grtc_addr_base = + (rpu_addr & RPU_ADDR_BELLBOARD_GRTC_MASK_BASE); + if (bellboard_grtc_addr_base == + RPU_ADDR_BELLBOARD_APP_REGION) { + region_offset = SOC_MMAP_ADDR_OFFSET_BELLBOARD_APP; + } else if (bellboard_grtc_addr_base == + RPU_ADDR_BELLBOARD_WIFI_REGION) { + region_offset = SOC_MMAP_ADDR_OFFSET_BELLBOARD_WIFI; + } else if (bellboard_grtc_addr_base == + RPU_ADDR_GRTC_REGION) { + region_offset = SOC_MMAP_ADDR_OFFSET_GRTC; + } + } else if (addr_base == RPU_ADDR_FPGA_REGS_REGION) { + region_offset = SOC_MMAP_ADDR_OFFSET_FPGA_REGS; + } else if (addr_base == RPU_ADDR_WICR_REGS_REGION) { + region_offset = SOC_MMAP_ADDR_OFFSET_WICR_REGS; + } else if (addr_base == RPU_ADDR_SECURERAM_REGION) { + region_offset = SOC_MMAP_ADDR_OFFSET_SECURERAM; +#else /* WIFI_NRF71 */ if (addr_base == RPU_ADDR_SBUS_START) { region_offset = SOC_MMAP_ADDR_OFFSET_SYSBUS; } else if ((rpu_addr >= RPU_ADDR_GRAM_START) && @@ -50,6 +112,7 @@ enum nrf_wifi_status pal_rpu_addr_offset_get(unsigned int rpu_addr, region_offset = SOC_MMAP_ADDR_OFFSET_PKTRAM_HOST_VIEW; } else if (pal_check_rpu_mcu_regions(proc, rpu_addr)) { region_offset = SOC_MMAP_ADDR_OFFSETS_MCU[proc]; +#endif /* !WIFI_NRF71 */ } else { nrf_wifi_osal_log_err("%s: Invalid rpu_addr 0x%X", __func__, @@ -58,13 +121,36 @@ enum nrf_wifi_status pal_rpu_addr_offset_get(unsigned int rpu_addr, } *addr = region_offset + (rpu_addr & RPU_ADDR_MASK_OFFSET); +#ifdef WIFI_NRF71 + if (addr_base == RPU_ADDR_BELLBOARD_GRTC_REGION) { + *addr = region_offset + + (rpu_addr & RPU_BELLBOARD_GRTC_ADDR_MASK_OFFSET); + } else if (addr_base == RPU_ADDR_CODE_RAM_REGION) { + *addr = region_offset + ((rpu_addr - + RPU_ADDR_CODE_RAM_START) & RPU_ADDR_MASK_OFFSET); + } else if (addr_base == RPU_ADDR_WICR_REGS_REGION) { + *addr = region_offset + (rpu_addr & RPU_WICR_ADDR_MASK_OFFSET); + } +#endif /* WIFI_NRF71 */ status = NRF_WIFI_STATUS_SUCCESS; out: return status; } +#ifdef WIFI_NRF71 +unsigned long pal_rpu_rom_access_reg_addr_get(void) +{ + return SOC_MMAP_ADDR_OFFSET_ROM_ACCESS_FPGA_REG; +} +#ifdef RPU_HARD_RESET_SUPPORT +unsigned long pal_rpu_hard_rst_reg_offset_get(void) +{ + return SOC_MMAP_ADDR_OFFSET_HARDRESET; +} +#endif /* RPU_HARD_RESET_SUPPORT */ +#endif /* WIFI_NRF71 */ #ifdef NRF_WIFI_LOW_POWER unsigned long pal_rpu_ps_ctrl_reg_addr_get(void) diff --git a/hw_if/hal/src/system/hal_api.c b/hw_if/hal/src/system/hal_api.c index 2106c39..37a7265 100644 --- a/hw_if/hal/src/system/hal_api.c +++ b/hw_if/hal/src/system/hal_api.c @@ -27,7 +27,12 @@ nrf_wifi_sys_hal_rpu_pktram_buf_map_init(struct nrf_wifi_hal_dev_ctx *hal_dev_ct enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; unsigned int pool_idx = 0; - status = pal_rpu_addr_offset_get(RPU_MEM_PKT_BASE, + status = pal_rpu_addr_offset_get( +#ifdef WIFI_NRF71 + RPU_MEM_DATA_RAM_BASE, +#else /* WIFI_NRF71 */ + RPU_MEM_PKT_BASE, +#endif /* !WIFI_NRF71 */ &hal_dev_ctx->addr_rpu_pktram_base, hal_dev_ctx->curr_proc); @@ -39,9 +44,15 @@ nrf_wifi_sys_hal_rpu_pktram_buf_map_init(struct nrf_wifi_hal_dev_ctx *hal_dev_ct hal_dev_ctx->addr_rpu_pktram_base_tx = hal_dev_ctx->addr_rpu_pktram_base; +#ifdef WIFI_NRF71 + hal_dev_ctx->addr_rpu_pktram_base_rx_pool[0] = + (hal_dev_ctx->addr_rpu_pktram_base + RPU_DATA_RAM_SIZE) - + (CONFIG_NRF70_RX_NUM_BUFS * CONFIG_NRF70_RX_MAX_DATA_SIZE); +#else /* WIFI_NRF71 */ hal_dev_ctx->addr_rpu_pktram_base_rx_pool[0] = (hal_dev_ctx->addr_rpu_pktram_base + RPU_PKTRAM_SIZE) - (NRF70_RX_NUM_BUFS * NRF70_RX_MAX_DATA_SIZE); +#endif /* !WIFI_NRF71 */ for (pool_idx = 1; pool_idx < MAX_NUM_OF_RX_QUEUES; pool_idx++) { hal_dev_ctx->addr_rpu_pktram_base_rx_pool[pool_idx] = @@ -55,6 +66,26 @@ nrf_wifi_sys_hal_rpu_pktram_buf_map_init(struct nrf_wifi_hal_dev_ctx *hal_dev_ct return status; } +#ifdef WIFI_NRF71 +#ifdef CMD_RX_BUFF +unsigned long nrf_wifi_hal_get_buf_map_rx(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx, + unsigned int pool_id, + unsigned int buf_id) +{ + struct nrf_wifi_hal_buf_map_info *rx_buf_info = NULL; + rx_buf_info = &hal_dev_ctx->rx_buf_info[pool_id][buf_id]; + if (rx_buf_info->mapped) { + return rx_buf_info->phy_addr; + } else { + nrf_wifi_osal_log_err("%s: Rx buffer not mapped for pool_id = %d, buf_id=%d\n", + __func__, + pool_id, + buf_id); + } +} +#endif /* CMD_RX_BUFF */ +#endif /* WIFI_NRF71 */ + static enum nrf_wifi_status hal_rpu_recovery(struct nrf_wifi_hal_dev_ctx *hal_dev_ctx) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; @@ -134,20 +165,51 @@ unsigned long nrf_wifi_sys_hal_buf_map_rx(struct nrf_wifi_hal_dev_ctx *hal_dev_c bounce_buf_addr = hal_dev_ctx->addr_rpu_pktram_base_rx_pool[pool_id] + (buf_id * buf_len); - - rpu_addr = RPU_MEM_PKT_BASE + (bounce_buf_addr - hal_dev_ctx->addr_rpu_pktram_base); - +#ifdef WIFI_NRF71 + rpu_addr = RPU_MEM_DATA_RAM_BASE + + (bounce_buf_addr - hal_dev_ctx->addr_rpu_pktram_base); +#ifdef INLINE_RX + nrf_wifi_osal_mem_cpy((void *)bounce_buf_addr, + (void *)buf, + hal_dev_ctx->hpriv->cfg_params.rx_buf_headroom_sz); +#else /* INLINE_RX */ + rpu_addr = RPU_MEM_DATA_RAM_BASE + + (bounce_buf_addr - hal_dev_ctx->addr_rpu_pktram_base); hal_rpu_mem_write(hal_dev_ctx, (unsigned int)rpu_addr, (void *)buf, hal_dev_ctx->hpriv->cfg_params.rx_buf_headroom_sz); +#endif /* !INLINE_RX */ +#else /* WIFI_NRF71 */ + rpu_addr = RPU_MEM_PKT_BASE + + (bounce_buf_addr - hal_dev_ctx->addr_rpu_pktram_base); + hal_rpu_mem_write(hal_dev_ctx, + (unsigned int)rpu_addr, + (void *)buf, + hal_dev_ctx->hpriv->cfg_params.rx_buf_headroom_sz); +#endif /* !WIFI_NRF71 */ addr_to_map = bounce_buf_addr + hal_dev_ctx->hpriv->cfg_params.rx_buf_headroom_sz; +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + rx_buf_info->phy_addr = nrf_wifi_bal_dma_map_inline_rx( + hal_dev_ctx->bal_dev_ctx, + addr_to_map, + buf_len, + NRF_WIFI_OSAL_DMA_DIR_FROM_DEV); +#else /* INLINE_RX */ rx_buf_info->phy_addr = nrf_wifi_bal_dma_map(hal_dev_ctx->bal_dev_ctx, - addr_to_map, - buf_len, - NRF_WIFI_OSAL_DMA_DIR_FROM_DEV); + addr_to_map, + buf_len, + NRF_WIFI_OSAL_DMA_DIR_FROM_DEV); +#endif /* !INLINE_RX */ +#else /* WIFI_NRF71 */ + rx_buf_info->phy_addr = nrf_wifi_bal_dma_map(hal_dev_ctx->bal_dev_ctx, + addr_to_map, + buf_len, + NRF_WIFI_OSAL_DMA_DIR_FROM_DEV); +#endif /* !WIFI_NRF71 */ if (!rx_buf_info->phy_addr) { nrf_wifi_osal_log_err("%s: DMA map failed", @@ -182,25 +244,52 @@ unsigned long nrf_wifi_sys_hal_buf_unmap_rx(struct nrf_wifi_hal_dev_ctx *hal_dev goto out; } +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + unmapped_addr = nrf_wifi_bal_dma_unmap_inline_rx( + hal_dev_ctx->bal_dev_ctx, + rx_buf_info->phy_addr, + rx_buf_info->buf_len, + NRF_WIFI_OSAL_DMA_DIR_FROM_DEV); +#else /* INLINE_RX */ unmapped_addr = nrf_wifi_bal_dma_unmap(hal_dev_ctx->bal_dev_ctx, rx_buf_info->phy_addr, rx_buf_info->buf_len, NRF_WIFI_OSAL_DMA_DIR_FROM_DEV); - rpu_addr = RPU_MEM_PKT_BASE + (unmapped_addr - hal_dev_ctx->addr_rpu_pktram_base); - + rpu_addr = RPU_MEM_DATA_RAM_BASE + + (unmapped_addr - hal_dev_ctx->addr_rpu_pktram_base); +#endif /* !INLINE_RX */ +#else /* WIFI_NRF71 */ + rpu_addr = RPU_MEM_PKT_BASE + + (unmapped_addr - hal_dev_ctx->addr_rpu_pktram_base); +#endif /* !WIFI_NRF71 */ if (data_len) { if (!unmapped_addr) { nrf_wifi_osal_log_err("%s: DMA unmap failed", __func__); goto out; } - +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + nrf_wifi_osal_mem_cpy((void *)(rx_buf_info->virt_addr + + hal_dev_ctx->hpriv->cfg_params.rx_buf_headroom_sz), + (void *)unmapped_addr, + data_len); +#else /* INLINE_RX */ hal_rpu_mem_read(hal_dev_ctx, - (void *)(rx_buf_info->virt_addr + - hal_dev_ctx->hpriv->cfg_params.rx_buf_headroom_sz), - (unsigned int)rpu_addr, - data_len); + (void *)(rx_buf_info->virt_addr + + hal_dev_ctx->hpriv->cfg_params.rx_buf_headroom_sz), + (unsigned int)rpu_addr, + data_len); +#endif /* !INLINE_RX */ +#else /* WIFI_NRF71 */ + hal_rpu_mem_read(hal_dev_ctx, + (void *)(rx_buf_info->virt_addr + + hal_dev_ctx->hpriv->cfg_params.rx_buf_headroom_sz), + (unsigned int)rpu_addr, + data_len); +#endif /* !WIFI_NRF71 */ } virt_addr = rx_buf_info->virt_addr; @@ -258,15 +347,19 @@ unsigned long nrf_wifi_sys_hal_buf_map_tx(struct nrf_wifi_hal_dev_ctx *hal_dev_c hal_dev_ctx->tx_frame_offset += (bounce_buf_addr - hal_dev_ctx->tx_frame_offset) + buf_len + hal_dev_ctx->hpriv->cfg_params.tx_buf_headroom_sz; - - rpu_addr = RPU_MEM_PKT_BASE + (bounce_buf_addr - hal_dev_ctx->addr_rpu_pktram_base); - +#ifdef WIFI_NRF71 + rpu_addr = RPU_MEM_DATA_RAM_BASE + + (bounce_buf_addr - hal_dev_ctx->addr_rpu_pktram_base); +#else /* WIFI_NRF71 */ + rpu_addr = RPU_MEM_PKT_BASE + + (bounce_buf_addr - hal_dev_ctx->addr_rpu_pktram_base); +#endif /* !WIFI_NRF71 */ nrf_wifi_osal_log_dbg("%s: bounce_buf_addr: 0x%lx, rpu_addr: 0x%lx, buf_len: %d off:%d", - __func__, - bounce_buf_addr, - rpu_addr, - buf_len, - hal_dev_ctx->tx_frame_offset); + __func__, + bounce_buf_addr, + rpu_addr, + buf_len, + hal_dev_ctx->tx_frame_offset); hal_rpu_mem_write(hal_dev_ctx, (unsigned int)rpu_addr, @@ -364,12 +457,13 @@ enum nrf_wifi_status nrf_wifi_sys_hal_data_cmd_send(struct nrf_wifi_hal_dev_ctx addr = addr_base + (max_cmd_size * desc_id); host_addr = addr; +#ifndef WIFI_NRF71 /* This is a indrect write to core memory */ if (cmd_type == NRF_WIFI_HAL_MSG_TYPE_CMD_DATA_RX) { host_addr &= RPU_ADDR_MASK_OFFSET; host_addr |= RPU_MCU_CORE_INDIRECT_BASE; } - +#endif /* !WIFI_NRF71 */ /* Copy the information to the suggested address */ status = hal_rpu_mem_write(hal_dev_ctx, host_addr, diff --git a/os_if/inc/osal_api.h b/os_if/inc/osal_api.h index 6a3e026..28d6d6e 100644 --- a/os_if/inc/osal_api.h +++ b/os_if/inc/osal_api.h @@ -125,7 +125,6 @@ void *nrf_wifi_osal_mem_set(void *start, int val, size_t size); - /** * @brief Memory map IO memory into CPU space. * @param addr Address of the IO memory to be mapped. @@ -1344,4 +1343,13 @@ int nrf_wifi_osal_ipc_send_msg(unsigned int msg_type, unsigned int msg_len); #endif /* NRF71_ON_IPC */ +#ifdef WIFI_NRF71 +#ifdef INLINE_RX +void *nrf_wifi_osal_iomem_mmap_inline_rx(struct nrf_wifi_osal_priv *opriv, + unsigned long addr, + unsigned long size); +void nrf_wifi_osal_iomem_unmap_inline_rx(struct nrf_wifi_osal_priv *opriv, + volatile void *addr); +#endif +#endif #endif /* __OSAL_API_H__ */ diff --git a/os_if/inc/osal_ops.h b/os_if/inc/osal_ops.h index c5f2a93..c85904c 100644 --- a/os_if/inc/osal_ops.h +++ b/os_if/inc/osal_ops.h @@ -93,7 +93,12 @@ struct nrf_wifi_osal_ops { * than addr2, a positive value if addr1 is greater than addr2. */ int (*mem_cmp)(const void *addr1, const void *addr2, size_t size); - +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + void *(*iomem_mmap_inline_rx)(unsigned long addr, unsigned long size); + void (*iomem_unmap_inline_rx)(void *addr); +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ /** * @brief Map IO memory into CPU space. * @@ -643,10 +648,10 @@ struct nrf_wifi_osal_ops { * @return A pointer to the initialized PCIe bus. */ void *(*bus_pcie_init)(const char *dev_name, - unsigned int vendor_id, - unsigned int sub_vendor_id, - unsigned int device_id, - unsigned int sub_device_id); + unsigned int vendor_id, + unsigned int sub_vendor_id, + unsigned int device_id, + unsigned int sub_device_id); /** * @brief Deinitialize the PCIe bus. @@ -663,7 +668,7 @@ struct nrf_wifi_osal_ops { * @return A pointer to the added PCIe device. */ void *(*bus_pcie_dev_add)(void *pcie_priv, - void *osal_pcie_dev_ctx); + void *osal_pcie_dev_ctx); /** * @brief Remove a PCIe device from the bus. @@ -716,9 +721,9 @@ struct nrf_wifi_osal_ops { * @return A pointer to the mapped DMA buffer. */ void *(*bus_pcie_dev_dma_map)(void *os_pcie_dev_ctx, - void *virt_addr, - size_t size, - enum nrf_wifi_osal_dma_dir dir); + void *virt_addr, + size_t size, + enum nrf_wifi_osal_dma_dir dir); /** * @brief Unmap a DMA buffer for a PCIe device. @@ -729,9 +734,9 @@ struct nrf_wifi_osal_ops { * @param dir The direction of the DMA transfer. */ void (*bus_pcie_dev_dma_unmap)(void *os_pcie_dev_ctx, - void *dma_addr, - size_t size, - enum nrf_wifi_osal_dma_dir dir); + void *dma_addr, + size_t size, + enum nrf_wifi_osal_dma_dir dir); /** * @brief Get the host mapping of a PCIe device. @@ -741,7 +746,12 @@ struct nrf_wifi_osal_ops { */ void (*bus_pcie_dev_host_map_get)(void *os_pcie_dev_ctx, struct nrf_wifi_osal_host_map *host_map); - +#ifdef WIFI_NRF71 +#ifdef INLINE_RX + void (*bus_pcie_dev_host_map_get_inline_rx)(void *os_pcie_dev_ctx, + struct nrf_wifi_osal_host_map *host_map); +#endif /*INLINE_RX */ +#endif /* WIFI_NRF71 */ /** * @brief Initialize the QSPI bus. * @@ -764,7 +774,7 @@ struct nrf_wifi_osal_ops { * @return A pointer to the added QSPI device. */ void *(*bus_qspi_dev_add)(void *qspi_priv, - void *osal_qspi_dev_ctx); + void *osal_qspi_dev_ctx); /** * @brief Remove a QSPI device from the bus. @@ -838,7 +848,7 @@ struct nrf_wifi_osal_ops { * @return A pointer to the added SPI device. */ void *(*bus_spi_dev_add)(void *spi_priv, - void *osal_spi_dev_ctx); + void *osal_spi_dev_ctx); /** * @brief Remove a SPI device from the bus. @@ -913,8 +923,8 @@ struct nrf_wifi_osal_ops { * @param data The data to be passed to the callback function. */ void (*timer_init)(void *timer, - void (*callback)(unsigned long), - unsigned long data); + void (*callback)(unsigned long), + unsigned long data); /** * @brief Schedule a timer. @@ -965,9 +975,9 @@ struct nrf_wifi_osal_ops { * @param assert_msg The error message to display. */ void (*assert)(int test_val, - int val, - enum nrf_wifi_assert_op_type op, - char *assert_msg); + int val, + enum nrf_wifi_assert_op_type op, + char *assert_msg); /** * @brief Get the length of a string. diff --git a/os_if/src/osal.c b/os_if/src/osal.c index 47c2249..3f1f4cc 100644 --- a/os_if/src/osal.c +++ b/os_if/src/osal.c @@ -84,6 +84,21 @@ int nrf_wifi_osal_mem_cmp(const void *addr1, size); } +#ifdef WIFI_NRF71 +#ifdef INLINE_RX +void *nrf_wifi_osal_iomem_mmap_inline_rx(unsigned long addr, + unsigned long size) +{ + return os_ops->iomem_mmap_inline_rx(addr, + size); +} + +void nrf_wifi_osal_iomem_unmap_inline_rx(void *addr) +{ + os_ops->iomem_unmap_inline_rx(addr); +} +#endif /* INLINE_RX */ +#endif /* WIFI_NRF71 */ void *nrf_wifi_osal_iomem_mmap(unsigned long addr, unsigned long size) diff --git a/utils/inc/util.h b/utils/inc/util.h index c64ea89..8c75651 100644 --- a/utils/inc/util.h +++ b/utils/inc/util.h @@ -13,7 +13,7 @@ #define __UTIL_H__ #include "osal_api.h" -#include "host_rpu_umac_if.h" +#include "nrf71_wifi_ctrl.h" #ifndef ARRAY_SIZE #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) diff --git a/utils/src/util.c b/utils/src/util.c index a4e3ae9..e1a3160 100644 --- a/utils/src/util.c +++ b/utils/src/util.c @@ -10,7 +10,11 @@ */ #include +#ifdef WIFI_NRF71 +#include +#else #include "host_rpu_data_if.h" +#endif int nrf_wifi_utils_hex_str_to_val(unsigned char *hex_arr, unsigned int hex_arr_sz,