net: Add TX fifo to network interface

Network packets to be sent are placed to correct fifo that
is allocated to certain network interface.

Change-Id: Idd5eded42758c5bed2c18769122c38d9d03dc419
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-05-03 09:34:45 +03:00
commit e0e682eb66
4 changed files with 49 additions and 2 deletions

View file

@ -31,3 +31,11 @@ config NET_IFACE_MCAST_IPV6_ADDR_COUNT
config NET_IFACE_IPV6_PREFIX_COUNT
int "Max number of IPv6 prefixes assigned to network interface"
default 2
config NET_TX_STACK_SIZE
int "TX fiber stack size"
default 1024
help
Set the TX fiber stack size in bytes. The TX fiber is waiting
data from application. Each network interface will start one
TX fiber for sending network packets destined to it.

View file

@ -32,12 +32,12 @@
#include <string.h>
#include <errno.h>
/* Stacks for the rx fiber.
/* Stack for the rx fiber.
*/
#if !defined(CONFIG_NET_RX_STACK_SIZE)
#define CONFIG_NET_RX_STACK_SIZE 1024
#endif
static char __noinit __stack rx_fiber_stack[CONFIG_IP_RX_STACK_SIZE];
static char __noinit __stack rx_fiber_stack[CONFIG_NET_RX_STACK_SIZE];
static struct nano_fifo rx_queue;
static void net_rx_fiber(int unused1, int unused2)

View file

@ -15,12 +15,47 @@
*/
#include <init.h>
#include <nanokernel.h>
#include <sections.h>
#include <misc/sys_log.h>
#include <net/net_if.h>
/* net_if dedicated section limiters */
extern struct net_if __net_if_start[];
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)
{
SYS_LOG_DBG("Starting TX fiber (stack %d bytes)\n",
sizeof(tx_fiber_stack));
while (1) {
struct net_buf *buf;
/* Get next packet from application - wait if necessary */
buf = nano_fifo_get(&iface->tx_queue, TICKS_UNLIMITED);
SYS_LOG_DBG("Processing (buf %p, len %u) network packet\n",
buf, buf->len);
/* FIXME - Do something with the packet */
}
}
static inline void init_tx_queue(struct net_if *iface)
{
nano_fifo_init(&iface->tx_queue);
fiber_start(tx_fiber_stack, sizeof(tx_fiber_stack),
(nano_fiber_entry_t)net_if_tx_fiber, (int)iface, 0, 7, 0);
}
static int net_if_init(struct device *unused)
{
struct net_if_api *api;
@ -33,6 +68,7 @@ static int net_if_init(struct device *unused)
if (api && api->init) {
api->init(iface);
init_tx_queue(iface);
}
}