net: Declare a macro to define stacks used by networking
The macro defines the stack as usual, but if user has enabled net shell (CONFIG_NET_SHELL), then additional information about the stack is stored in net_shell linker section. The information in the net_shell linker section is then used to print information about the stacks in the networking sub-system. Change-Id: Ic6e9f16a73a192b9a59d32a6d0070322382f98bd Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
0f8be63d8e
commit
8e84e36f14
5 changed files with 64 additions and 4 deletions
|
@ -173,6 +173,16 @@
|
|||
__net_if_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
#if defined(CONFIG_NET_SHELL)
|
||||
SECTION_DATA_PROLOGUE(net_stack, (OPTIONAL),)
|
||||
{
|
||||
__net_stack_start = .;
|
||||
*(".net_stack.*")
|
||||
KEEP(*(SORT_BY_NAME(".net_stack*")))
|
||||
__net_stack_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
#endif /* CONFIG_NET_SHELL */
|
||||
|
||||
SECTION_DATA_PROLOGUE(net_l2_data, (OPTIONAL),)
|
||||
{
|
||||
__net_l2_data_start = .;
|
||||
|
|
|
@ -95,6 +95,47 @@ int net_recv_data(struct net_if *iface, struct net_buf *buf);
|
|||
*/
|
||||
int net_send_data(struct net_buf *buf);
|
||||
|
||||
struct net_stack_info {
|
||||
unsigned char *stack;
|
||||
const char *pretty_name;
|
||||
const char *name;
|
||||
size_t orig_size;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_NET_SHELL)
|
||||
#define NET_STACK_GET_NAME(name, sfx) (__net_stack_##name##_##sfx)
|
||||
|
||||
#define NET_STACK_INFO_ADDR(_pretty, _name, _orig, _size, _addr, sfx) \
|
||||
static struct net_stack_info \
|
||||
(NET_STACK_GET_NAME(_name, sfx)) __used \
|
||||
__attribute__((__section__(".net_stack.data"))) = { \
|
||||
.stack = _addr, \
|
||||
.size = _size, \
|
||||
.orig_size = _orig, \
|
||||
.name = #_name, \
|
||||
.pretty_name = _pretty, \
|
||||
}
|
||||
|
||||
#define NET_STACK_INFO(_pretty_name, _name, _orig, _size) \
|
||||
NET_STACK_INFO_ADDR(_pretty_name, _name, _orig, _size, _name, 0)
|
||||
|
||||
#define NET_STACK_DEFINE(pretty_name, name, orig, size) \
|
||||
static unsigned char __noinit __stack name[size]; \
|
||||
NET_STACK_INFO(pretty_name, name, orig, size)
|
||||
|
||||
#else /* CONFIG_NET_SHELL */
|
||||
|
||||
#define NET_STACK_INFO(...)
|
||||
#define NET_STACK_INFO_ADDR(...)
|
||||
|
||||
#define NET_STACK_DEFINE(pretty_name, name, orig, size) \
|
||||
static unsigned char __noinit __stack name[size]
|
||||
|
||||
#endif /* CONFIG_NET_SHELL */
|
||||
|
||||
#define NET_STACK_DEFINE_EMBEDDED(name, size) unsigned char name[size]
|
||||
|
||||
/** @cond ignore */
|
||||
#if defined(CONFIG_INIT_STACKS)
|
||||
#include <offsets.h>
|
||||
|
|
|
@ -186,7 +186,7 @@ struct net_if {
|
|||
#ifndef CONFIG_NET_TX_STACK_SIZE
|
||||
#define CONFIG_NET_TX_STACK_SIZE 1024
|
||||
#endif
|
||||
char tx_stack[CONFIG_NET_TX_STACK_SIZE];
|
||||
NET_STACK_DEFINE_EMBEDDED(tx_stack, CONFIG_NET_TX_STACK_SIZE);
|
||||
|
||||
#if defined(CONFIG_NET_IPV6)
|
||||
#define NET_IF_MAX_IPV6_ADDR CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT
|
||||
|
@ -1086,7 +1086,14 @@ struct net_if_api {
|
|||
.l2 = &(NET_L2_GET_NAME(_l2)), \
|
||||
.l2_data = &(NET_L2_GET_DATA(dev_name, sfx)), \
|
||||
.mtu = _mtu, \
|
||||
}
|
||||
}; \
|
||||
NET_STACK_INFO_ADDR("TX", \
|
||||
dev_name, \
|
||||
CONFIG_NET_TX_STACK_SIZE, \
|
||||
CONFIG_NET_TX_STACK_SIZE, \
|
||||
NET_IF_GET(dev_name, sfx)->tx_stack, \
|
||||
sfx)
|
||||
|
||||
|
||||
/* Network device initialization macros */
|
||||
|
||||
|
|
|
@ -62,7 +62,9 @@
|
|||
#if !defined(CONFIG_NET_RX_STACK_SIZE)
|
||||
#define CONFIG_NET_RX_STACK_SIZE 1024
|
||||
#endif
|
||||
static char __noinit __stack rx_stack[CONFIG_NET_RX_STACK_SIZE];
|
||||
NET_STACK_DEFINE("RX", rx_stack, CONFIG_NET_RX_STACK_SIZE,
|
||||
CONFIG_NET_RX_STACK_SIZE);
|
||||
|
||||
static struct k_fifo rx_queue;
|
||||
static k_tid_t rx_tid;
|
||||
|
||||
|
|
|
@ -464,7 +464,7 @@ class SizeCalculator:
|
|||
"_k_sem_area", "_k_mutex_area", "_k_alert_area",
|
||||
"_k_fifo_area", "_k_lifo_area", "_k_stack_area",
|
||||
"_k_msgq_area", "_k_mbox_area", "_k_pipe_area",
|
||||
"net_if", "net_l2_data"]
|
||||
"net_if", "net_stack", "net_l2_data"]
|
||||
# These get copied into RAM only on non-XIP
|
||||
ro_sections = ["text", "ctors", "init_array", "reset",
|
||||
"rodata", "devconfig", "net_l2"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue