Skip to content

Commit

Permalink
nrf_wifi: Create dedicated memory pools for Wi-Fi
Browse files Browse the repository at this point in the history
Create dedicated memory pools for Wi-Fi data and
management paths. Introduce corresponding memory
allocation/deallocation calls.

Signed-off-by: Ravi Dondaputi <[email protected]>
  • Loading branch information
rado17 committed Sep 13, 2024
1 parent 56a4bd3 commit 08becd6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nrf_wifi/fw_if/umac_if/src/default/fmac_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void nrf_wifi_fmac_deinit_tx(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx)

tx_deinit(fmac_dev_ctx);

nrf_wifi_osal_mem_free(def_dev_ctx->tx_buf_info);
nrf_wifi_osal_data_mem_free(def_dev_ctx->tx_buf_info);
}

#endif /* CONFIG_NRF700X_DATA_TX */
Expand Down Expand Up @@ -182,7 +182,7 @@ static enum nrf_wifi_status nrf_wifi_fmac_deinit_rx(struct nrf_wifi_fmac_dev_ctx
}
}

nrf_wifi_osal_mem_free(def_dev_ctx->rx_buf_info);
nrf_wifi_osal_data_mem_free(def_dev_ctx->rx_buf_info);

def_dev_ctx->rx_buf_info = NULL;
out:
Expand Down
28 changes: 28 additions & 0 deletions nrf_wifi/os_if/inc/osal_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ void *nrf_wifi_osal_mem_alloc(size_t size);
*/
void *nrf_wifi_osal_mem_zalloc(size_t size);


/**
* @brief Allocated zero-initialized memory for data.
*
* @size: Size of the memory to be allocated in bytes.
*
* Allocates memory of @size bytes, zeroes it out and returns a pointer to the
* start of the memory allocated.
*
* @return: Pointer to start of allocated memory or NULL.
*/
void *nrf_wifi_osal_data_mem_zalloc(size_t size);


/**
* @brief Free previously allocated memory.
* @param buf Pointer to the memory to be freed.
Expand All @@ -77,6 +91,20 @@ void *nrf_wifi_osal_mem_zalloc(size_t size);
*/
void nrf_wifi_osal_mem_free(void *buf);


/**
* @brief Free previously allocated memory for data.
*
* @buf: Pointer to the memory to be freed.
*
* Free up memory which has been allocated using @nrf_wifi_osal_mem_alloc or
* @nrf_wifi_osal_mem_zalloc.
*
* @return: None.
*/
void nrf_wifi_osal_data_mem_free(void *buf);


/**
* @brief Copy contents from one memory location to another.
*
Expand Down
17 changes: 16 additions & 1 deletion nrf_wifi/os_if/inc/osal_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct nrf_wifi_osal_ops {
void *(*mem_alloc)(size_t size);

/**
* @brief Allocate zero-initialized memory.
* @brief Allocate zero-initialized memory for control messages.
*
* @param size The size of the memory to allocate.
* @return A pointer to the start of the allocated memory.
Expand All @@ -48,6 +48,21 @@ struct nrf_wifi_osal_ops {
*/
void (*mem_free)(void *buf);

/**
* @brief Allocate zero-initialized memory for data.
*
* @param size The size of the memory to allocate.
* @return A pointer to the start of the allocated memory.
*/
void *(*data_mem_zalloc)(size_t size);

/**
* @brief Free allocated memory.
*
* @param buf A pointer to the memory to free.
*/
void (*data_mem_free)(void *buf);

/**
* @brief Copy memory.
*
Expand Down
12 changes: 12 additions & 0 deletions nrf_wifi/os_if/src/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,24 @@ void *nrf_wifi_osal_mem_zalloc(size_t size)
}


void *nrf_wifi_osal_data_mem_zalloc(size_t size)
{
return opriv->ops->data_mem_zalloc(size);
}


void nrf_wifi_osal_mem_free(void *buf)
{
os_ops->mem_free(buf);
}


void nrf_wifi_osal_data_mem_free(void *buf)
{
opriv->ops->data_mem_free(buf);
}


void *nrf_wifi_osal_mem_cpy(void *dest,
const void *src,
size_t count)
Expand Down

0 comments on commit 08becd6

Please sign in to comment.