mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
feat(openthread): support alloc nat64 session from psram
This commit is contained in:
parent
aa67538038
commit
d7f69d03c0
@ -278,12 +278,20 @@ menu "OpenThread"
|
|||||||
help
|
help
|
||||||
Select this option to enable border router features in OpenThread.
|
Select this option to enable border router features in OpenThread.
|
||||||
|
|
||||||
config OPENTHREAD_PLATFORM_MSGPOOL_MANAGEMENT
|
menu "Thread Memory Allocation Config"
|
||||||
bool 'Allocate message pool buffer from PSRAM'
|
|
||||||
depends on OPENTHREAD_ENABLED && (SPIRAM_USE_CAPS_ALLOC || SPIRAM_USE_MALLOC)
|
depends on OPENTHREAD_ENABLED && (SPIRAM_USE_CAPS_ALLOC || SPIRAM_USE_MALLOC)
|
||||||
default n
|
config OPENTHREAD_MEM_ALLOC_EXTERNAL
|
||||||
help
|
bool 'Allocate memory from PSRAM'
|
||||||
If enabled, the message pool is managed by platform defined logic.
|
default y
|
||||||
|
help
|
||||||
|
Select this option to allocate buffer from PSRAM for Thread
|
||||||
|
|
||||||
|
config OPENTHREAD_PLATFORM_MSGPOOL_MANAGEMENT
|
||||||
|
bool 'Allocate message pool buffer from PSRAM'
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
If enabled, the message pool is managed by platform defined logic.
|
||||||
|
endmenu
|
||||||
|
|
||||||
config OPENTHREAD_NUM_MESSAGE_BUFFERS
|
config OPENTHREAD_NUM_MESSAGE_BUFFERS
|
||||||
int "The number of openthread message buffers"
|
int "The number of openthread message buffers"
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
#include <utility>
|
||||||
|
#include "common/new.hpp"
|
||||||
|
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
inline T *New(uint32_t alloc_caps, Args &&...args)
|
||||||
|
{
|
||||||
|
void *p = heap_caps_calloc(1, sizeof(T), alloc_caps);
|
||||||
|
if (p != nullptr) {
|
||||||
|
return new (p) T(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -84,7 +84,7 @@ void esp_openthread_platform_workflow_unregister(const char *name);
|
|||||||
* @brief Initializes the platform-specific support for the OpenThread stack.
|
* @brief Initializes the platform-specific support for the OpenThread stack.
|
||||||
*
|
*
|
||||||
* @note This function is not called by and will not call the OpenThread library.
|
* @note This function is not called by and will not call the OpenThread library.
|
||||||
* The user needs to call otInstanceInitSingle to intialize the OpenThread
|
* The user needs to call otInstanceInitSingle to initialize the OpenThread
|
||||||
* stack after calling this function.
|
* stack after calling this function.
|
||||||
*
|
*
|
||||||
* @param[in] init_config The initialization configuration.
|
* @param[in] init_config The initialization configuration.
|
||||||
@ -146,6 +146,15 @@ esp_err_t esp_openthread_platform_process(otInstance *instance, const esp_openth
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void esp_openthread_set_storage_name(const char *name);
|
void esp_openthread_set_storage_name(const char *name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the caps of memory allocation.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The caps of the memory.
|
||||||
|
*/
|
||||||
|
uint32_t esp_openthread_get_alloc_caps(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // end of extern "C"
|
} // end of extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
@ -204,3 +204,13 @@ esp_err_t esp_openthread_platform_process(otInstance *instance, const esp_openth
|
|||||||
}
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t esp_openthread_get_alloc_caps(void)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#if CONFIG_OPENTHREAD_PLATFORM_MALLOC_CAP_SPIRAM
|
||||||
|
(MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||||
|
#else
|
||||||
|
(MALLOC_CAP_DEFAULT | MALLOC_CAP_8BIT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user