From a3b88f53c4896e0167e3bcc3f3830e9838f1c08b Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Fri, 29 Apr 2016 15:52:09 +0300 Subject: [PATCH] net: Initial commit for the new IP stack This is a placeholder that compiles but does nothing else. Change-Id: I9689fa26eb13bc23d29940938f7b3c11f32b2ff1 Signed-off-by: Jukka Rissanen --- include/net/net_core.h | 4 +++ include/net/net_ip.h | 4 +++ include/net/net_socket.h | 4 +++ net/ip/Kconfig | 9 +++++ net/yaip/Kconfig | 17 +++++++++ net/yaip/Makefile | 2 ++ net/yaip/net_core.c | 76 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 116 insertions(+) create mode 100644 net/yaip/Kconfig create mode 100644 net/yaip/Makefile create mode 100644 net/yaip/net_core.c diff --git a/include/net/net_core.h b/include/net/net_core.h index 6fd48eec48..940caece9d 100644 --- a/include/net/net_core.h +++ b/include/net/net_core.h @@ -14,4 +14,8 @@ * limitations under the License. */ +#if defined(CONFIG_NET_YAIP) +#include +#else #include +#endif diff --git a/include/net/net_ip.h b/include/net/net_ip.h index 323db0169d..5365cbd460 100644 --- a/include/net/net_ip.h +++ b/include/net/net_ip.h @@ -14,4 +14,8 @@ * limitations under the License. */ +#if defined(CONFIG_NET_YAIP) +#include +#else #include +#endif diff --git a/include/net/net_socket.h b/include/net/net_socket.h index f7316df302..21b931a5dd 100644 --- a/include/net/net_socket.h +++ b/include/net/net_socket.h @@ -14,4 +14,8 @@ * limitations under the License. */ +#if defined(CONFIG_NET_YAIP) +#include +#else #include +#endif diff --git a/net/ip/Kconfig b/net/ip/Kconfig index 5b57608c04..e17fefbddc 100644 --- a/net/ip/Kconfig +++ b/net/ip/Kconfig @@ -41,6 +41,11 @@ config NET_UIP bool "uIP" help Choose this if unsure. + +config NET_YAIP + bool "New IP stack [EXPERIMENTAL]" + help + New IP stack. endchoice if NETWORKING && NET_UIP @@ -604,6 +609,10 @@ endif if NETWORKING +if NET_YAIP +source "net/yaip/Kconfig" +endif + source "net/ip/Kconfig.debug" endif diff --git a/net/yaip/Kconfig b/net/yaip/Kconfig new file mode 100644 index 0000000000..eb66aef08f --- /dev/null +++ b/net/yaip/Kconfig @@ -0,0 +1,17 @@ +# Kconfig.yaip - Yet another IP stack config + +# +# Copyright (c) 2016 Intel Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/net/yaip/Makefile b/net/yaip/Makefile new file mode 100644 index 0000000000..767191c9d4 --- /dev/null +++ b/net/yaip/Makefile @@ -0,0 +1,2 @@ +ccflags-y += -I${srctree}/net/ip +obj-y = net_core.o diff --git a/net/yaip/net_core.c b/net/yaip/net_core.c new file mode 100644 index 0000000000..c8303663b0 --- /dev/null +++ b/net/yaip/net_core.c @@ -0,0 +1,76 @@ +/** @file + * @brief Network initialization + * + * Initialize the network IP stack. Create two fibers, one for reading data + * from applications (Tx fiber) and one for reading data from IP stack + * and passing that data to applications (Rx fiber). + */ + +/* + * Copyright (c) 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef CONFIG_NETWORKING_WITH_LOGGING +#define DEBUG 1 +#endif + +#include +#include +#include +#include +#include + +/* Stacks 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 struct nano_fifo rx_queue; + +static void net_rx_fiber(int unused1, int unused2) +{ + while (0) { + /* FIXME - implementation missing */ + } +} + +static void init_rx_queue(void) +{ + nano_fifo_init(&rx_queue); + + fiber_start(rx_fiber_stack, sizeof(rx_fiber_stack), + net_rx_fiber, 0, 0, 7, 0); +} + +static int network_initialization(void) +{ + + return 0; +} + +int net_init(void) +{ + static uint8_t initialized; + + if (initialized) + return -EALREADY; + + initialized = 1; + + init_rx_queue(); + + return network_initialization(); +}