net: Adjust the thread priorities

If networking pre-emptive thread priorities are enabled,
then use the proper macro to enable them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-10-07 14:18:56 +03:00 committed by Jukka Rissanen
parent 6e54f5462c
commit f02fd19706
6 changed files with 29 additions and 8 deletions

View file

@ -29,6 +29,7 @@ config NET_MGMT_EVENT_STACK_SIZE
config NET_MGMT_EVENT_THREAD_PRIO
int "Inner thread priority (use with care)"
default -1 if NET_TC_THREAD_COOPERATIVE
default 7
help
Set the network management event core's inner thread priority.

View file

@ -389,8 +389,7 @@ void net_mgmt_event_init(void)
k_thread_create(&mgmt_thread_data, mgmt_stack,
K_KERNEL_STACK_SIZEOF(mgmt_stack),
(k_thread_entry_t)mgmt_thread, NULL, NULL, NULL,
K_PRIO_COOP(CONFIG_NET_MGMT_EVENT_THREAD_PRIO), 0,
K_NO_WAIT);
CONFIG_NET_MGMT_EVENT_THREAD_PRIO, 0, K_NO_WAIT);
k_thread_name_set(&mgmt_thread_data, "net_mgmt");
NET_DBG("Net MGMT initialized: queue of %u entries, stack size of %u",

View file

@ -1708,7 +1708,7 @@ dad_err:
void net_6locan_init(struct net_if *iface)
{
struct canbus_net_ctx *ctx = net_if_l2_data(iface);
uint8_t thread_priority;
int thread_priority;
int i;
NET_DBG("Init CAN net interface");
@ -1732,11 +1732,15 @@ void net_6locan_init(struct net_if *iface)
/* This work queue should have precedence over the tx stream
* TODO thread_priority = tx_tc2thread(NET_TC_TX_COUNT -1) - 1;
*/
thread_priority = 6;
if (IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)) {
thread_priority = K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1);
} else {
thread_priority = K_PRIO_PREEMPT(6);
}
k_work_q_start(&net_canbus_workq, net_canbus_stack,
K_KERNEL_STACK_SIZEOF(net_canbus_stack),
K_PRIO_COOP(thread_priority));
thread_priority);
k_thread_name_set(&net_canbus_workq.thread, "isotp_work");
NET_DBG("Workq started. Thread ID: %p", &net_canbus_workq.thread);
}

View file

@ -16,6 +16,12 @@ LOG_MODULE_REGISTER(conn_mgr, CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL);
#include <conn_mgr.h>
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(7)
#endif
uint16_t iface_states[CONN_MGR_IFACE_MAX];
K_SEM_DEFINE(conn_mgr_lock, 1, UINT_MAX);
@ -172,7 +178,7 @@ static void conn_mgr_handler(void)
K_THREAD_DEFINE(conn_mgr, CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE,
(k_thread_entry_t)conn_mgr_handler, NULL, NULL, NULL,
K_PRIO_COOP(2), 0, 0);
THREAD_PRIORITY, 0, 0);
void net_conn_mgr_resend_status(void)
{

View file

@ -49,6 +49,13 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include "lwm2m_rd_client.h"
#endif
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
/* Lowest priority cooperative thread */
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(CONFIG_NUM_PREEMPT_PRIORITIES - 1)
#endif
#define ENGINE_UPDATE_INTERVAL_MS 500
#define OBSERVE_COUNTER_START 0U
@ -4516,8 +4523,7 @@ static int lwm2m_engine_init(const struct device *dev)
K_KERNEL_STACK_SIZEOF(engine_thread_stack),
(k_thread_entry_t) socket_receive_loop,
NULL, NULL, NULL,
/* Lowest priority cooperative thread */
K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1),
THREAD_PRIORITY,
0, K_NO_WAIT);
k_thread_name_set(&engine_thread_data, "lwm2m-sock-recv");
LOG_DBG("LWM2M engine socket receive thread started");

View file

@ -45,7 +45,12 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_OPENTHREAD_L2_LOG_LEVEL);
#define FRAME_TYPE_ACK 0x02
#define OT_WORKER_STACK_SIZE 512
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define OT_WORKER_PRIORITY K_PRIO_COOP(CONFIG_OPENTHREAD_THREAD_PRIORITY)
#else
#define OT_WORKER_PRIORITY K_PRIO_PREEMPT(CONFIG_OPENTHREAD_THREAD_PRIORITY)
#endif
enum pending_events {
PENDING_EVENT_FRAME_TO_SEND, /* There is a tx frame to send */