net: use kernel stacks

These threads don't run in user mode, save some memory if
userspace is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-07-31 12:45:25 -07:00 committed by Anas Nashif
commit c0d3ed0d1c
8 changed files with 20 additions and 20 deletions

View file

@ -98,7 +98,7 @@ static sys_slist_t mcast_monitor_callbacks;
#define CONFIG_NET_PKT_TIMESTAMP_STACK_SIZE 1024 #define CONFIG_NET_PKT_TIMESTAMP_STACK_SIZE 1024
#endif #endif
K_THREAD_STACK_DEFINE(tx_ts_stack, CONFIG_NET_PKT_TIMESTAMP_STACK_SIZE); K_KERNEL_STACK_DEFINE(tx_ts_stack, CONFIG_NET_PKT_TIMESTAMP_STACK_SIZE);
K_FIFO_DEFINE(tx_ts_queue); K_FIFO_DEFINE(tx_ts_queue);
static struct k_thread tx_thread_ts; static struct k_thread tx_thread_ts;
@ -3767,7 +3767,7 @@ void net_if_init(void)
#if defined(CONFIG_NET_PKT_TIMESTAMP_THREAD) #if defined(CONFIG_NET_PKT_TIMESTAMP_THREAD)
k_thread_create(&tx_thread_ts, tx_ts_stack, k_thread_create(&tx_thread_ts, tx_ts_stack,
K_THREAD_STACK_SIZEOF(tx_ts_stack), K_KERNEL_STACK_SIZEOF(tx_ts_stack),
(k_thread_entry_t)net_tx_ts_thread, (k_thread_entry_t)net_tx_ts_thread,
NULL, NULL, NULL, K_PRIO_COOP(1), 0, K_NO_WAIT); NULL, NULL, NULL, K_PRIO_COOP(1), 0, K_NO_WAIT);
k_thread_name_set(&tx_thread_ts, "tx_tstamp"); k_thread_name_set(&tx_thread_ts, "tx_tstamp");

View file

@ -36,7 +36,7 @@ struct mgmt_event_wait {
static K_SEM_DEFINE(network_event, 0, UINT_MAX); static K_SEM_DEFINE(network_event, 0, UINT_MAX);
static K_SEM_DEFINE(net_mgmt_lock, 1, 1); static K_SEM_DEFINE(net_mgmt_lock, 1, 1);
K_THREAD_STACK_DEFINE(mgmt_stack, CONFIG_NET_MGMT_EVENT_STACK_SIZE); K_KERNEL_STACK_DEFINE(mgmt_stack, CONFIG_NET_MGMT_EVENT_STACK_SIZE);
static struct k_thread mgmt_thread_data; static struct k_thread mgmt_thread_data;
static struct mgmt_event_entry events[CONFIG_NET_MGMT_EVENT_QUEUE_SIZE]; static struct mgmt_event_entry events[CONFIG_NET_MGMT_EVENT_QUEUE_SIZE];
static uint32_t global_event_mask; static uint32_t global_event_mask;
@ -387,7 +387,7 @@ void net_mgmt_event_init(void)
sizeof(struct mgmt_event_entry)); sizeof(struct mgmt_event_entry));
k_thread_create(&mgmt_thread_data, mgmt_stack, k_thread_create(&mgmt_thread_data, mgmt_stack,
K_THREAD_STACK_SIZEOF(mgmt_stack), K_KERNEL_STACK_SIZEOF(mgmt_stack),
(k_thread_entry_t)mgmt_thread, NULL, NULL, NULL, (k_thread_entry_t)mgmt_thread, NULL, NULL, NULL,
K_PRIO_COOP(CONFIG_NET_MGMT_EVENT_THREAD_PRIO), 0, K_PRIO_COOP(CONFIG_NET_MGMT_EVENT_THREAD_PRIO), 0,
K_NO_WAIT); K_NO_WAIT);

View file

@ -19,11 +19,11 @@ LOG_MODULE_REGISTER(net_tc, CONFIG_NET_TC_LOG_LEVEL);
#include "net_tc_mapping.h" #include "net_tc_mapping.h"
/* Stacks for TX work queue */ /* Stacks for TX work queue */
K_THREAD_STACK_ARRAY_DEFINE(tx_stack, NET_TC_TX_COUNT, K_KERNEL_STACK_ARRAY_DEFINE(tx_stack, NET_TC_TX_COUNT,
CONFIG_NET_TX_STACK_SIZE); CONFIG_NET_TX_STACK_SIZE);
/* Stacks for RX work queue */ /* Stacks for RX work queue */
K_THREAD_STACK_ARRAY_DEFINE(rx_stack, NET_TC_RX_COUNT, K_KERNEL_STACK_ARRAY_DEFINE(rx_stack, NET_TC_RX_COUNT,
CONFIG_NET_RX_STACK_SIZE); CONFIG_NET_RX_STACK_SIZE);
static struct net_traffic_class tx_classes[NET_TC_TX_COUNT]; static struct net_traffic_class tx_classes[NET_TC_TX_COUNT];
@ -235,12 +235,12 @@ void net_tc_tx_init(void)
NET_DBG("[%d] Starting TX queue %p stack size %zd " NET_DBG("[%d] Starting TX queue %p stack size %zd "
"prio %d (%d)", i, "prio %d (%d)", i,
&tx_classes[i].work_q.queue, &tx_classes[i].work_q.queue,
K_THREAD_STACK_SIZEOF(tx_stack[i]), K_KERNEL_STACK_SIZEOF(tx_stack[i]),
thread_priority, K_PRIO_COOP(thread_priority)); thread_priority, K_PRIO_COOP(thread_priority));
k_work_q_start(&tx_classes[i].work_q, k_work_q_start(&tx_classes[i].work_q,
tx_stack[i], tx_stack[i],
K_THREAD_STACK_SIZEOF(tx_stack[i]), K_KERNEL_STACK_SIZEOF(tx_stack[i]),
K_PRIO_COOP(thread_priority)); K_PRIO_COOP(thread_priority));
k_thread_name_set(&tx_classes[i].work_q.thread, "tx_workq"); k_thread_name_set(&tx_classes[i].work_q.thread, "tx_workq");
} }
@ -265,12 +265,12 @@ void net_tc_rx_init(void)
NET_DBG("[%d] Starting RX queue %p stack size %zd " NET_DBG("[%d] Starting RX queue %p stack size %zd "
"prio %d (%d)", i, "prio %d (%d)", i,
&rx_classes[i].work_q.queue, &rx_classes[i].work_q.queue,
K_THREAD_STACK_SIZEOF(rx_stack[i]), K_KERNEL_STACK_SIZEOF(rx_stack[i]),
thread_priority, K_PRIO_COOP(thread_priority)); thread_priority, K_PRIO_COOP(thread_priority));
k_work_q_start(&rx_classes[i].work_q, k_work_q_start(&rx_classes[i].work_q,
rx_stack[i], rx_stack[i],
K_THREAD_STACK_SIZEOF(rx_stack[i]), K_KERNEL_STACK_SIZEOF(rx_stack[i]),
K_PRIO_COOP(thread_priority)); K_PRIO_COOP(thread_priority));
k_thread_name_set(&rx_classes[i].work_q.thread, "rx_workq"); k_thread_name_set(&rx_classes[i].work_q.thread, "rx_workq");
} }

View file

@ -37,7 +37,7 @@ extern uint16_t net_calc_chksum(struct net_pkt *pkt, uint8_t proto);
static struct canbus_l2_ctx l2_ctx; static struct canbus_l2_ctx l2_ctx;
static struct k_work_q net_canbus_workq; static struct k_work_q net_canbus_workq;
K_THREAD_STACK_DEFINE(net_canbus_stack, 512); K_KERNEL_STACK_DEFINE(net_canbus_stack, 512);
char *net_sprint_addr(sa_family_t af, const void *addr); char *net_sprint_addr(sa_family_t af, const void *addr);
@ -1735,7 +1735,7 @@ void net_6locan_init(struct net_if *iface)
thread_priority = 6; thread_priority = 6;
k_work_q_start(&net_canbus_workq, net_canbus_stack, k_work_q_start(&net_canbus_workq, net_canbus_stack,
K_THREAD_STACK_SIZEOF(net_canbus_stack), K_KERNEL_STACK_SIZEOF(net_canbus_stack),
K_PRIO_COOP(thread_priority)); K_PRIO_COOP(thread_priority));
k_thread_name_set(&net_canbus_workq.thread, "isotp_work"); k_thread_name_set(&net_canbus_workq.thread, "isotp_work");
NET_DBG("Workq started. Thread ID: %p", &net_canbus_workq.thread); NET_DBG("Workq started. Thread ID: %p", &net_canbus_workq.thread);

View file

@ -31,7 +31,7 @@ LOG_MODULE_REGISTER(net_gptp, CONFIG_NET_GPTP_LOG_LEVEL);
#error Maximum number of ports exceeded. (Max is 32). #error Maximum number of ports exceeded. (Max is 32).
#endif #endif
K_THREAD_STACK_DEFINE(gptp_stack, NET_GPTP_STACK_SIZE); K_KERNEL_STACK_DEFINE(gptp_stack, NET_GPTP_STACK_SIZE);
K_FIFO_DEFINE(gptp_rx_queue); K_FIFO_DEFINE(gptp_rx_queue);
static k_tid_t tid; static k_tid_t tid;
@ -909,7 +909,7 @@ static void init_ports(void)
gptp_init_state_machine(); gptp_init_state_machine();
tid = k_thread_create(&gptp_thread_data, gptp_stack, tid = k_thread_create(&gptp_thread_data, gptp_stack,
K_THREAD_STACK_SIZEOF(gptp_stack), K_KERNEL_STACK_SIZEOF(gptp_stack),
(k_thread_entry_t)gptp_thread, (k_thread_entry_t)gptp_thread,
NULL, NULL, NULL, K_PRIO_COOP(5), 0, K_NO_WAIT); NULL, NULL, NULL, K_PRIO_COOP(5), 0, K_NO_WAIT);
k_thread_name_set(&gptp_thread_data, "gptp"); k_thread_name_set(&gptp_thread_data, "gptp");

View file

@ -94,7 +94,7 @@ extern void platformShellInit(otInstance *aInstance);
K_SEM_DEFINE(ot_sem, 0, 1); K_SEM_DEFINE(ot_sem, 0, 1);
K_THREAD_STACK_DEFINE(ot_stack_area, OT_STACK_SIZE); K_KERNEL_STACK_DEFINE(ot_stack_area, OT_STACK_SIZE);
static struct k_thread ot_thread_data; static struct k_thread ot_thread_data;
static k_tid_t ot_tid; static k_tid_t ot_tid;
static struct net_linkaddr *ll_addr; static struct net_linkaddr *ll_addr;
@ -452,7 +452,7 @@ static int openthread_init(struct net_if *iface)
net_mgmt_add_event_callback(&ip6_addr_cb); net_mgmt_add_event_callback(&ip6_addr_cb);
ot_tid = k_thread_create(&ot_thread_data, ot_stack_area, ot_tid = k_thread_create(&ot_thread_data, ot_stack_area,
K_THREAD_STACK_SIZEOF(ot_stack_area), K_KERNEL_STACK_SIZEOF(ot_stack_area),
openthread_process, openthread_process,
ot_context, NULL, NULL, ot_context, NULL, NULL,
OT_PRIORITY, 0, K_NO_WAIT); OT_PRIORITY, 0, K_NO_WAIT);

View file

@ -123,7 +123,7 @@ static sys_slist_t engine_obj_inst_list;
static sys_slist_t engine_observer_list; static sys_slist_t engine_observer_list;
static sys_slist_t engine_service_list; static sys_slist_t engine_service_list;
static K_THREAD_STACK_DEFINE(engine_thread_stack, static K_KERNEL_STACK_DEFINE(engine_thread_stack,
CONFIG_LWM2M_ENGINE_STACK_SIZE); CONFIG_LWM2M_ENGINE_STACK_SIZE);
static struct k_thread engine_thread_data; static struct k_thread engine_thread_data;
@ -4525,7 +4525,7 @@ static int lwm2m_engine_init(struct device *dev)
/* start sock receive thread */ /* start sock receive thread */
k_thread_create(&engine_thread_data, k_thread_create(&engine_thread_data,
&engine_thread_stack[0], &engine_thread_stack[0],
K_THREAD_STACK_SIZEOF(engine_thread_stack), K_KERNEL_STACK_SIZEOF(engine_thread_stack),
(k_thread_entry_t) socket_receive_loop, (k_thread_entry_t) socket_receive_loop,
NULL, NULL, NULL, NULL, NULL, NULL,
/* Lowest priority cooperative thread */ /* Lowest priority cooperative thread */

View file

@ -82,7 +82,7 @@ static uint8_t energy_detection_channel;
static int16_t energy_detected_value; static int16_t energy_detected_value;
ATOMIC_DEFINE(pending_events, PENDING_EVENT_COUNT); ATOMIC_DEFINE(pending_events, PENDING_EVENT_COUNT);
K_THREAD_STACK_DEFINE(ot_task_stack, OT_WORKER_STACK_SIZE); K_KERNEL_STACK_DEFINE(ot_task_stack, OT_WORKER_STACK_SIZE);
static struct k_work_q ot_work_q; static struct k_work_q ot_work_q;
static otError tx_result; static otError tx_result;
@ -195,7 +195,7 @@ void platformRadioInit(void)
} }
k_work_q_start(&ot_work_q, ot_task_stack, k_work_q_start(&ot_work_q, ot_task_stack,
K_THREAD_STACK_SIZEOF(ot_task_stack), K_KERNEL_STACK_SIZEOF(ot_task_stack),
OT_WORKER_PRIORITY); OT_WORKER_PRIORITY);
if ((radio_api->get_capabilities(radio_dev) & if ((radio_api->get_capabilities(radio_dev) &