From 1829c13c8afb05306889b03ba9582ccb5071d29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Duda?= Date: Sun, 15 Jun 2025 22:26:20 +0200 Subject: [PATCH] net: openthread: Make Radio workqueue priority configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit makes the Radio workqueue priority configurable by the application. Additionally, the default priority has been adjusted to allow transmit operations to occur before the entire RX queue is processed. Signed-off-by: Ɓukasz Duda --- modules/openthread/Kconfig | 5 +++++ modules/openthread/platform/radio.c | 6 ++++-- tests/subsys/openthread/radio_stub.c | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/openthread/Kconfig b/modules/openthread/Kconfig index b44316d31cb..ff6d1afbb86 100644 --- a/modules/openthread/Kconfig +++ b/modules/openthread/Kconfig @@ -134,6 +134,11 @@ config OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE default 608 if MPU_STACK_GUARD && FPU_SHARING && CPU_CORTEX_M default 512 +config OPENTHREAD_RADIO_WORKQUEUE_PRIORITY + int "OpenThread radio transmit workqueue priority" + default 0 if OPENTHREAD_THREAD_PREEMPTIVE + default 7 + endmenu # "Zephyr optimizations" config OPENTHREAD_SHELL diff --git a/modules/openthread/platform/radio.c b/modules/openthread/platform/radio.c index 171fce1b667..91b417b0627 100644 --- a/modules/openthread/platform/radio.c +++ b/modules/openthread/platform/radio.c @@ -58,9 +58,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_OPENTHREAD_PLATFORM_LOG_LEVEL); #define FRAME_TYPE_ACK 0x02 #if defined(CONFIG_NET_TC_THREAD_COOPERATIVE) -#define OT_WORKER_PRIORITY K_PRIO_COOP(CONFIG_OPENTHREAD_THREAD_PRIORITY) +#define OT_WORKER_PRIORITY K_PRIO_COOP(CONFIG_OPENTHREAD_RADIO_WORKQUEUE_PRIORITY) #else -#define OT_WORKER_PRIORITY K_PRIO_PREEMPT(CONFIG_OPENTHREAD_THREAD_PRIORITY) +#define OT_WORKER_PRIORITY K_PRIO_PREEMPT(CONFIG_OPENTHREAD_RADIO_WORKQUEUE_PRIORITY) #endif #define CHANNEL_COUNT OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MAX - OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN + 1 @@ -622,6 +622,8 @@ static int run_tx_task(otInstance *aInstance) sState = OT_RADIO_STATE_TRANSMIT; k_work_submit_to_queue(&ot_work_q, &tx_job); + k_yield(); + return 0; } else { return -EBUSY; diff --git a/tests/subsys/openthread/radio_stub.c b/tests/subsys/openthread/radio_stub.c index e82bf76d872..2365b714c45 100644 --- a/tests/subsys/openthread/radio_stub.c +++ b/tests/subsys/openthread/radio_stub.c @@ -19,8 +19,8 @@ #define CONFIG_OPENTHREAD_PLATFORM_PKT_TXTIME 1 #endif -#define CONFIG_OPENTHREAD_THREAD_PRIORITY 5 -#define OT_WORKER_PRIORITY K_PRIO_COOP(CONFIG_OPENTHREAD_THREAD_PRIORITY) +#define CONFIG_OPENTHREAD_RADIO_WORKQUEUE_PRIORITY 5 +#define OT_WORKER_PRIORITY K_PRIO_COOP(CONFIG_OPENTHREAD_RADIO_WORKQUEUE_PRIORITY) #define CONFIG_NET_L2_OPENTHREAD 1 #define CONFIG_OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE 512 #define CONFIG_OPENTHREAD_DEFAULT_RX_SENSITIVITY -100