net: Network interface needs own TX fiber stack

Each network interface needs its own stack for TX fiber.

Change-Id: I9647c2b945a3d36bc77c00dad11badb0d5f851e5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-05-19 12:15:06 +03:00
commit 402996e374
2 changed files with 26 additions and 12 deletions

View file

@ -131,6 +131,12 @@ struct net_if {
/** Queue for outgoing packets from apps */ /** Queue for outgoing packets from apps */
struct nano_fifo tx_queue; struct nano_fifo tx_queue;
/** Stack for the TX fiber tied to this interface */
#ifndef CONFIG_NET_TX_STACK_SIZE
#define CONFIG_NET_TX_STACK_SIZE 1024
#endif
char tx_fiber_stack[CONFIG_NET_TX_STACK_SIZE];
#if defined(CONFIG_NET_IPV6) #if defined(CONFIG_NET_IPV6)
#define NET_IF_MAX_IPV6_ADDR CONFIG_NET_IFACE_UNICAST_IPV6_ADDR_COUNT #define NET_IF_MAX_IPV6_ADDR CONFIG_NET_IFACE_UNICAST_IPV6_ADDR_COUNT
#define NET_IF_MAX_IPV6_MADDR CONFIG_NET_IFACE_MCAST_IPV6_ADDR_COUNT #define NET_IF_MAX_IPV6_MADDR CONFIG_NET_IFACE_MCAST_IPV6_ADDR_COUNT

View file

@ -23,23 +23,22 @@
#include <nanokernel.h> #include <nanokernel.h>
#include <sections.h> #include <sections.h>
#include <string.h> #include <string.h>
#include <misc/sys_log.h>
#include <net/net_if.h>
#include <net/net_core.h> #include <net/net_core.h>
#include <net/nbuf.h>
#include <net/net_if.h>
#include "net_private.h"
/* net_if dedicated section limiters */ /* net_if dedicated section limiters */
extern struct net_if __net_if_start[]; extern struct net_if __net_if_start[];
extern struct net_if __net_if_end[]; extern struct net_if __net_if_end[];
/* Stack for the TX fiber */
#ifndef CONFIG_NET_TX_STACK_SIZE
#define CONFIG_NET_TX_STACK_SIZE 1024
#endif
static char __noinit __stack tx_fiber_stack[CONFIG_NET_TX_STACK_SIZE];
static void net_if_tx_fiber(struct net_if *iface) static void net_if_tx_fiber(struct net_if *iface)
{ {
NET_DBG("Starting TX fiber (stack %d bytes)", sizeof(tx_fiber_stack)); struct net_if_api *api = (struct net_if_api *)iface->dev->driver_api;
NET_DBG("Starting TX fiber (stack %d bytes) for driver %p",
sizeof(iface->tx_fiber_stack), api);
while (1) { while (1) {
struct net_buf *buf; struct net_buf *buf;
@ -48,9 +47,18 @@ static void net_if_tx_fiber(struct net_if *iface)
buf = nano_fifo_get(&iface->tx_queue, TICKS_UNLIMITED); buf = nano_fifo_get(&iface->tx_queue, TICKS_UNLIMITED);
NET_DBG("Processing (buf %p, len %u) network packet", NET_DBG("Processing (buf %p, len %u) network packet",
buf, buf->len); buf, net_buf_frags_len(buf->frags));
/* FIXME - Do something with the packet */ if (api && api->send) {
if (api->send(iface, buf) < 0) {
net_nbuf_unref(buf);
}
} else {
net_nbuf_unref(buf);
}
net_analyze_stack("TX fiber", iface->tx_fiber_stack,
sizeof(iface->tx_fiber_stack));
} }
} }
@ -58,7 +66,7 @@ static inline void init_tx_queue(struct net_if *iface)
{ {
nano_fifo_init(&iface->tx_queue); nano_fifo_init(&iface->tx_queue);
fiber_start(tx_fiber_stack, sizeof(tx_fiber_stack), fiber_start(iface->tx_fiber_stack, sizeof(iface->tx_fiber_stack),
(nano_fiber_entry_t)net_if_tx_fiber, (int)iface, 0, 7, 0); (nano_fiber_entry_t)net_if_tx_fiber, (int)iface, 0, 7, 0);
} }