Skip to content

Commit ec08e1c

Browse files
marwaiehm-stcarlescufi
authored andcommitted
drivers: ethernet: Modify RX thread creation and update KConfig
This change will allow users to configure the Ethernet RX thread according to their specific real-time requirements. Adding preemptive threading helps to reduce jitter and the impact of Ethernet traffic on real-time performance. Signed-off-by: IBEN EL HADJ MESSAOUD Marwa <marwa.ibenelhadjmessaoud-ext@st.com>
1 parent 1bea5fc commit ec08e1c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎drivers/ethernet/Kconfig.stm32_hal‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ config ETH_STM32_HAL_RX_THREAD_STACK_SIZE
4646
RX thread stack size
4747

4848
config ETH_STM32_HAL_RX_THREAD_PRIO
49-
int "RX thread priority"
49+
int "STM32 Ethernet RX Thread Priority"
5050
default 2
5151
help
52-
RX thread priority
52+
This option allows to configure the priority of the RX thread that
53+
handles incoming Ethernet packets.
54+
Switching between preemptive and cooperative scheduling can be done by
55+
NET_TC_THREAD_PREEMPTIVE.
56+
Preemptive scheduling can lead to more responsive handling of network traffic,
57+
especially under high load.
5358

5459
config ETH_STM32_HAL_USE_DTCM_FOR_DMA_BUFFER
5560
bool "Use DTCM for DMA buffers"

‎drivers/ethernet/eth_stm32_hal.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,9 @@ static void eth_iface_init(struct net_if *iface)
13311331
k_thread_create(&dev_data->rx_thread, dev_data->rx_thread_stack,
13321332
K_KERNEL_STACK_SIZEOF(dev_data->rx_thread_stack),
13331333
rx_thread, (void *) dev, NULL, NULL,
1334-
K_PRIO_COOP(CONFIG_ETH_STM32_HAL_RX_THREAD_PRIO),
1334+
IS_ENABLED(CONFIG_NET_TC_THREAD_PREEMPTIVE)
1335+
? K_PRIO_PREEMPT(CONFIG_ETH_STM32_HAL_RX_THREAD_PRIO)
1336+
: K_PRIO_COOP(CONFIG_ETH_STM32_HAL_RX_THREAD_PRIO),
13351337
0, K_NO_WAIT);
13361338

13371339
k_thread_name_set(&dev_data->rx_thread, "stm_eth");

0 commit comments

Comments
 (0)