Skip to content

Commit cb31883

Browse files
ssharkscarlescufi
authored andcommitted
net: tcp: Make priority of TCP work queue configurable
The TCP work queue is handles all TCP transmission and maintenance tasks. Make it's priority configurable, so it can be configured to a lower priority than the lower level network layers to avoid it consuming all net_bufs before handing over execution to the lower layer network layers. Signed-off-by: Sjors Hettinga <[email protected]>
1 parent 71b132e commit cb31883

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

subsys/net/ip/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,22 @@ config NET_TCP_ISN_RFC6528
526526
RFC 6528 chapter 3. https://tools.ietf.org/html/rfc6528
527527
If this is not set, then sys_rand32_get() is used for ISN value.
528528

529+
config NET_TCP_WORKER_PRIO
530+
int "Priority of the TCP work queue"
531+
default 2
532+
depends on NET_TCP
533+
help
534+
Set the priority of the the TCP worker queue, that handles all
535+
transmission and maintenance within the TCP stack.
536+
Value 0 = highest priortity.
537+
When CONFIG_NET_TC_THREAD_COOPERATIVE = y, lowest priority is
538+
CONFIG_NUM_COOP_PRIORITIES-1 else lowest priority is
539+
CONFIG_NUM_PREEMPT_PRIORITIES-1.
540+
Make sure the priority is lower than lower layer TX threads to
541+
avoid the TCP stack consume all net_bufs before transferring
542+
execution to the lower layer network stack, with a high risk of
543+
running out of net_bufs.
544+
529545
config NET_TEST_PROTOCOL
530546
bool "JSON based test protocol (UDP)"
531547
help

subsys/net/ip/tcp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3547,9 +3547,9 @@ void net_tcp_init(void)
35473547
#endif
35483548

35493549
#if defined(CONFIG_NET_TC_THREAD_COOPERATIVE)
3550-
#define THREAD_PRIORITY K_PRIO_COOP(0)
3550+
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NET_TCP_WORKER_PRIO)
35513551
#else
3552-
#define THREAD_PRIORITY K_PRIO_PREEMPT(0)
3552+
#define THREAD_PRIORITY K_PRIO_PREEMPT(CONFIG_NET_TCP_WORKER_PRIO)
35533553
#endif
35543554

35553555
/* Use private workqueue in order not to block the system work queue.

0 commit comments

Comments
 (0)