net: yaip: Initial commit for new IP stack

This is a placeholder that just compiles but does nothing else.

Change-Id: I9689fa26eb13bc23d29940938f7b3c11f32b2ff1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-04-29 15:52:09 +03:00
commit 75ae39518c
10 changed files with 548 additions and 367 deletions

View file

@ -1,11 +1,5 @@
/** @file
* @brief Network core definitions
*
* Definitions for networking support.
*/
/*
* Copyright (c) 2015 Intel Corporation
* 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.
@ -20,144 +14,8 @@
* limitations under the License.
*/
#ifndef __NET_CORE_H
#define __NET_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Network subsystem logging helpers */
#ifdef CONFIG_NETWORKING_WITH_LOGGING
#define NET_DBG(fmt, ...) printk("net: %s (%p): " fmt, __func__, \
sys_thread_self_get(), ##__VA_ARGS__)
#define NET_ERR(fmt, ...) printk("net: %s: " fmt, __func__, ##__VA_ARGS__)
#define NET_INFO(fmt, ...) printk("net: " fmt, ##__VA_ARGS__)
#define NET_PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__)
#if defined(CONFIG_NET_YAIP)
#include <net/yaip/net_core.h>
#else
#define NET_DBG(...)
#define NET_ERR(...)
#define NET_INFO(...)
#define NET_PRINT(...)
#endif /* CONFIG_NETWORKING_WITH_LOGGING */
enum net_tcp_type {
NET_TCP_TYPE_UNKNOWN = 0,
NET_TCP_TYPE_SERVER,
NET_TCP_TYPE_CLIENT,
};
struct net_buf;
struct net_context;
#include <misc/printk.h>
#include <string.h>
#include <net/net_socket.h>
/**
* @brief Initialize network stack. This is will be automatically called
* by the OS.
*
* @details No harm will happen if application calls this multiple times.
*
* @return 0 if ok, < 0 in case of error.
*/
int net_init(void);
struct net_driver {
/** How much headroom is needed for net transport headers */
size_t head_reserve;
/** Open the net transport */
int (*open)(void);
/** Send data to net. The send() function should return:
* 0 : If packet could not be sent. In this case buf should
* not be released.
* 1 : If the packet was sent successfully. In this case the buf
* should be released by either the send() or some other
* lower layer function.
* <0: If there is an error, the buf should not be released by
* send() function.
*/
int (*send)(struct net_buf *buf);
};
/**
* @brief Register a new network driver to the network stack.
*
* @details Only one network device can be registered at a time.
*
* @param drv Network driver.
*
* @return 0 if ok, < 0 in case of error.
*/
int net_register_driver(struct net_driver *drv);
/**
* @brief Unregister a previously registered network driver.
*
* @param drv Network driver.
*
* @details Networking will be disabled if there is no driver
* available.
*
*/
void net_unregister_driver(struct net_driver *drv);
/**
* @brief Set the MAC/EUI-64 address of the device.
*
* @details Network device driver should call this function to
* tell the used MAC or EUI-64 address to the IP stack.
*
* @param mac MAC or EUI-64 address
* @param len If len == 6, then the first parameter is interpreted
* to be the MAC address and the function sets the U/L bits etc.
* If the len == 8, then the value is used as is to generate the
* link local IPv6 address.
*
* @return 0 if ok, < 0 in case of error.
*/
int net_set_mac(uint8_t *mac, uint8_t len);
/**
* @brief Send a reply packet to the message originator.
*
* @details Application can call this function if it has received
* a network packet from peer. The application needs to write
* reply data into net_buf. The app can use ip_buf_appdata(buf) and
* ip_buf_appdatalen(buf) to set the application data and length.
*
* @param context Network context
* @param buf Network buffer containing the network data.
*
* @return 0 if ok, < 0 in case of error.
*/
int net_reply(struct net_context *context, struct net_buf *buf);
/* Called by driver when an IP packet has been received */
int net_recv(struct net_buf *buf);
void net_context_init(void);
/**
* @brief Get current status of the TCP connection.
*
* @details Application can call this to get the current status
* of TCP connection. The returned value maps to errno values.
* Value 0 means ok. For UDP context 0 is always returned.
*
* @param context Network context
*
* @return 0 if ok, < 0 connection status
*/
int net_context_get_connection_status(struct net_context *context);
#ifdef __cplusplus
}
#include <net/uip/net_core.h>
#endif
#endif /* __NET_CORE_H */

View file

@ -1,11 +1,5 @@
/** @file
* @brief IPv6 and IPv4 definitions
*
* Generic IPv6 and IPv4 address definitions.
*/
/*
* Copyright (c) 2015 Intel Corporation
* 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.
@ -20,100 +14,8 @@
* limitations under the License.
*/
#ifndef __NET_IP_H
#define __NET_IP_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#if defined(CONFIG_NET_YAIP)
#include <net/yaip/net_ip.h>
#else
#include <net/uip/net_ip.h>
#endif
/** Protocol families */
#define PF_UNSPEC 0 /* Unspecified. */
#define PF_INET 2 /* IP protocol family. */
#define PF_INET6 10 /* IP version 6. */
/** Address families. */
#define AF_UNSPEC PF_UNSPEC
#define AF_INET PF_INET
#define AF_INET6 PF_INET6
/** Protocol numbers from IANA */
enum ip_protocol {
IPPROTO_TCP = 6,
IPPROTO_UDP = 17,
IPPROTO_ICMPV6 = 58,
};
/** IPv6 address structure */
struct in6_addr {
union {
uint8_t u6_addr8[16];
uint16_t u6_addr16[8]; /* In big endian */
uint32_t u6_addr32[4]; /* In big endian */
} in6_u;
#define s6_addr in6_u.u6_addr8
#define s6_addr16 in6_u.u6_addr16
#define s6_addr32 in6_u.u6_addr32
};
/** IPv4 address */
struct in_addr {
union {
uint8_t u4_addr8[4];
uint16_t u4_addr16[2]; /* In big endian */
uint32_t u4_addr32[1]; /* In big endian */
} in4_u;
#define s4_addr in4_u.u4_addr8
#define s4_addr16 in4_u.u4_addr16
#define s4_addr32 in4_u.u4_addr32
#define s_addr s4_addr32
};
typedef unsigned short int sa_family_t;
struct net_addr {
sa_family_t family;
union {
struct in6_addr in6_addr;
struct in_addr in_addr;
};
};
#define IN6ADDR_ANY_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0 } } }
#define IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 1 } } }
#define INET6_ADDRSTRLEN 46
#define INADDR_ANY 0
/** IPv6/IPv4 network connection tuple */
struct net_tuple {
/** IPv6/IPv4 remote address */
struct net_addr *remote_addr;
/** IPv6/IPv4 local address */
struct net_addr *local_addr;
/** UDP/TCP remote port */
uint16_t remote_port;
/** UDP/TCP local port */
uint16_t local_port;
/** IP protocol */
enum ip_protocol ip_proto;
};
#if defined(CONFIG_NETWORKING_WITH_TCP)
enum tcp_event_type {
TCP_READ_EVENT = 1,
TCP_WRITE_EVENT,
};
#endif
#ifdef __cplusplus
}
#endif
#endif /* __NET_IP_H */

View file

@ -1,12 +1,5 @@
/** @file
* @brief Simple socket API
*
* Simple socket API for applications to connection establishment and
* disconnection.
*/
/*
* Copyright (c) 2015 Intel Corporation
* 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.
@ -21,113 +14,8 @@
* limitations under the License.
*/
#ifndef __NET_SOCKET_H
#define __NET_SOCKET_H
#include <stdint.h>
#include <net/net_ip.h>
#include <net/buf.h>
#ifdef __cplusplus
extern "C" {
#if defined(CONFIG_NET_YAIP)
#include <net/yaip/net_socket.h>
#else
#include <net/uip/net_socket.h>
#endif
/**
* @brief Get network context.
*
* @details Network context is used to define the connection
* 5-tuple (protocol, remote address, remote port, source
* address and source port).
*
* @param ip_proto Protocol to use. Currently only UDP is supported.
* @param remote_addr Remote IPv6/IPv4 address.
* @param remote_port Remote UDP/TCP port.
* @param local_addr Local IPv6/IPv4 address. If the local address is
* set to be anyaddr (all zeros), the IP stack will use the link
* local address defined for the system.
* @param local_port Local UDP/TCP port. If the local port is 0,
* then a random port will be allocated.
*
* @return Network context if successful, NULL otherwise.
*/
struct net_context *net_context_get(enum ip_protocol ip_proto,
const struct net_addr *remote_addr,
uint16_t remote_port,
struct net_addr *local_addr,
uint16_t local_port);
/**
* @brief Get network tuple.
*
* @details This function returns the used connection tuple.
*
* @param context Network context.
*
* @return Network tuple if successful, NULL otherwise.
*/
struct net_tuple *net_context_get_tuple(struct net_context *context);
/**
* @brief Release network context.
*
* @details Free the resources allocated for the context.
* All network listeners tied to this context are removed.
*
* @param context Network context.
*
*/
void net_context_put(struct net_context *context);
/**
* @brief Send data to network.
*
* @details Send user specified data to network. This
* requires that net_buf is tied to context. This means
* that the net_buf was allocated using net_buf_get().
*
* @param buf Network buffer.
*
* @return 0 if ok, <0 if error.
*/
int net_send(struct net_buf *buf);
/**
* @brief Receive data from network.
*
* @details Application uses this to get data from network
* connection. Caller can specify a timeout, if there is no
* data to return after a timeout, a NULL will be returned.
* Caller is responsible to release the returned net_buf.
*
* @param context Network context.
* @param timeout Timeout to wait. The value is in ticks.
* If TICKS_UNLIMITED (-1), wait forever.
* If TICKS_NONE (0), do not wait.
* If > 0, wait amount of ticks.
* The timeout is only available if kernel is compiled
* with CONFIG_NANO_TIMEOUTS. If CONFIG_NANO_TIMEOUT is not
* defined, then value > 0 means not to wait.
*
* @return Network buffer if successful, NULL otherwise.
*/
struct net_buf *net_receive(struct net_context *context,
int32_t timeout);
/**
* @brief Get the UDP connection pointer from net_context.
*
* @details This is only needed in special occacions when
* there is an existing UDP connection that application
* wants to attach to. Normally the connection information
* is not needed by application.
*
* @return UDP connection if it exists, NULL otherwise.
*/
struct simple_udp_connection *
net_context_get_udp_connection(struct net_context *context);
#ifdef __cplusplus
}
#endif
#endif /* __NET_SOCKET_H */

163
include/net/uip/net_core.h Normal file
View file

@ -0,0 +1,163 @@
/** @file
* @brief Network core definitions
*
* Definitions for networking support.
*/
/*
* Copyright (c) 2015 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.
*/
#ifndef __NET_CORE_H
#define __NET_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Network subsystem logging helpers */
#ifdef CONFIG_NETWORKING_WITH_LOGGING
#define NET_DBG(fmt, ...) printk("net: %s (%p): " fmt, __func__, \
sys_thread_self_get(), ##__VA_ARGS__)
#define NET_ERR(fmt, ...) printk("net: %s: " fmt, __func__, ##__VA_ARGS__)
#define NET_INFO(fmt, ...) printk("net: " fmt, ##__VA_ARGS__)
#define NET_PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__)
#else
#define NET_DBG(...)
#define NET_ERR(...)
#define NET_INFO(...)
#define NET_PRINT(...)
#endif /* CONFIG_NETWORKING_WITH_LOGGING */
enum net_tcp_type {
NET_TCP_TYPE_UNKNOWN = 0,
NET_TCP_TYPE_SERVER,
NET_TCP_TYPE_CLIENT,
};
struct net_buf;
struct net_context;
#include <misc/printk.h>
#include <string.h>
#include <net/net_socket.h>
/**
* @brief Initialize network stack. This is will be automatically called
* by the OS.
*
* @details No harm will happen if application calls this multiple times.
*
* @return 0 if ok, < 0 in case of error.
*/
int net_init(void);
struct net_driver {
/** How much headroom is needed for net transport headers */
size_t head_reserve;
/** Open the net transport */
int (*open)(void);
/** Send data to net. The send() function should return:
* 0 : If packet could not be sent. In this case buf should
* not be released.
* 1 : If the packet was sent successfully. In this case the buf
* should be released by either the send() or some other
* lower layer function.
* <0: If there is an error, the buf should not be released by
* send() function.
*/
int (*send)(struct net_buf *buf);
};
/**
* @brief Register a new network driver to the network stack.
*
* @details Only one network device can be registered at a time.
*
* @param drv Network driver.
*
* @return 0 if ok, < 0 in case of error.
*/
int net_register_driver(struct net_driver *drv);
/**
* @brief Unregister a previously registered network driver.
*
* @param drv Network driver.
*
* @details Networking will be disabled if there is no driver
* available.
*
*/
void net_unregister_driver(struct net_driver *drv);
/**
* @brief Set the MAC/EUI-64 address of the device.
*
* @details Network device driver should call this function to
* tell the used MAC or EUI-64 address to the IP stack.
*
* @param mac MAC or EUI-64 address
* @param len If len == 6, then the first parameter is interpreted
* to be the MAC address and the function sets the U/L bits etc.
* If the len == 8, then the value is used as is to generate the
* link local IPv6 address.
*
* @return 0 if ok, < 0 in case of error.
*/
int net_set_mac(uint8_t *mac, uint8_t len);
/**
* @brief Send a reply packet to the message originator.
*
* @details Application can call this function if it has received
* a network packet from peer. The application needs to write
* reply data into net_buf. The app can use ip_buf_appdata(buf) and
* ip_buf_appdatalen(buf) to set the application data and length.
*
* @param context Network context
* @param buf Network buffer containing the network data.
*
* @return 0 if ok, < 0 in case of error.
*/
int net_reply(struct net_context *context, struct net_buf *buf);
/* Called by driver when an IP packet has been received */
int net_recv(struct net_buf *buf);
void net_context_init(void);
/**
* @brief Get current status of the TCP connection.
*
* @details Application can call this to get the current status
* of TCP connection. The returned value maps to errno values.
* Value 0 means ok. For UDP context 0 is always returned.
*
* @param context Network context
*
* @return 0 if ok, < 0 connection status
*/
int net_context_get_connection_status(struct net_context *context);
#ifdef __cplusplus
}
#endif
#endif /* __NET_CORE_H */

119
include/net/uip/net_ip.h Normal file
View file

@ -0,0 +1,119 @@
/** @file
* @brief IPv6 and IPv4 definitions
*
* Generic IPv6 and IPv4 address definitions.
*/
/*
* Copyright (c) 2015 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.
*/
#ifndef __NET_IP_H
#define __NET_IP_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Protocol families */
#define PF_UNSPEC 0 /* Unspecified. */
#define PF_INET 2 /* IP protocol family. */
#define PF_INET6 10 /* IP version 6. */
/** Address families. */
#define AF_UNSPEC PF_UNSPEC
#define AF_INET PF_INET
#define AF_INET6 PF_INET6
/** Protocol numbers from IANA */
enum ip_protocol {
IPPROTO_TCP = 6,
IPPROTO_UDP = 17,
IPPROTO_ICMPV6 = 58,
};
/** IPv6 address structure */
struct in6_addr {
union {
uint8_t u6_addr8[16];
uint16_t u6_addr16[8]; /* In big endian */
uint32_t u6_addr32[4]; /* In big endian */
} in6_u;
#define s6_addr in6_u.u6_addr8
#define s6_addr16 in6_u.u6_addr16
#define s6_addr32 in6_u.u6_addr32
};
/** IPv4 address */
struct in_addr {
union {
uint8_t u4_addr8[4];
uint16_t u4_addr16[2]; /* In big endian */
uint32_t u4_addr32[1]; /* In big endian */
} in4_u;
#define s4_addr in4_u.u4_addr8
#define s4_addr16 in4_u.u4_addr16
#define s4_addr32 in4_u.u4_addr32
#define s_addr s4_addr32
};
typedef unsigned short int sa_family_t;
struct net_addr {
sa_family_t family;
union {
struct in6_addr in6_addr;
struct in_addr in_addr;
};
};
#define IN6ADDR_ANY_INIT { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0 } } }
#define IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 1 } } }
#define INET6_ADDRSTRLEN 46
#define INADDR_ANY 0
/** IPv6/IPv4 network connection tuple */
struct net_tuple {
/** IPv6/IPv4 remote address */
struct net_addr *remote_addr;
/** IPv6/IPv4 local address */
struct net_addr *local_addr;
/** UDP/TCP remote port */
uint16_t remote_port;
/** UDP/TCP local port */
uint16_t local_port;
/** IP protocol */
enum ip_protocol ip_proto;
};
#if defined(CONFIG_NETWORKING_WITH_TCP)
enum tcp_event_type {
TCP_READ_EVENT = 1,
TCP_WRITE_EVENT,
};
#endif
#ifdef __cplusplus
}
#endif
#endif /* __NET_IP_H */

View file

@ -0,0 +1,133 @@
/** @file
* @brief Simple socket API
*
* Simple socket API for applications to connection establishment and
* disconnection.
*/
/*
* Copyright (c) 2015 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.
*/
#ifndef __NET_SOCKET_H
#define __NET_SOCKET_H
#include <stdint.h>
#include <net/net_ip.h>
#include <net/buf.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get network context.
*
* @details Network context is used to define the connection
* 5-tuple (protocol, remote address, remote port, source
* address and source port).
*
* @param ip_proto Protocol to use. Currently only UDP is supported.
* @param remote_addr Remote IPv6/IPv4 address.
* @param remote_port Remote UDP/TCP port.
* @param local_addr Local IPv6/IPv4 address. If the local address is
* set to be anyaddr (all zeros), the IP stack will use the link
* local address defined for the system.
* @param local_port Local UDP/TCP port. If the local port is 0,
* then a random port will be allocated.
*
* @return Network context if successful, NULL otherwise.
*/
struct net_context *net_context_get(enum ip_protocol ip_proto,
const struct net_addr *remote_addr,
uint16_t remote_port,
struct net_addr *local_addr,
uint16_t local_port);
/**
* @brief Get network tuple.
*
* @details This function returns the used connection tuple.
*
* @param context Network context.
*
* @return Network tuple if successful, NULL otherwise.
*/
struct net_tuple *net_context_get_tuple(struct net_context *context);
/**
* @brief Release network context.
*
* @details Free the resources allocated for the context.
* All network listeners tied to this context are removed.
*
* @param context Network context.
*
*/
void net_context_put(struct net_context *context);
/**
* @brief Send data to network.
*
* @details Send user specified data to network. This
* requires that net_buf is tied to context. This means
* that the net_buf was allocated using net_buf_get().
*
* @param buf Network buffer.
*
* @return 0 if ok, <0 if error.
*/
int net_send(struct net_buf *buf);
/**
* @brief Receive data from network.
*
* @details Application uses this to get data from network
* connection. Caller can specify a timeout, if there is no
* data to return after a timeout, a NULL will be returned.
* Caller is responsible to release the returned net_buf.
*
* @param context Network context.
* @param timeout Timeout to wait. The value is in ticks.
* If TICKS_UNLIMITED (-1), wait forever.
* If TICKS_NONE (0), do not wait.
* If > 0, wait amount of ticks.
* The timeout is only available if kernel is compiled
* with CONFIG_NANO_TIMEOUTS. If CONFIG_NANO_TIMEOUT is not
* defined, then value > 0 means not to wait.
*
* @return Network buffer if successful, NULL otherwise.
*/
struct net_buf *net_receive(struct net_context *context,
int32_t timeout);
/**
* @brief Get the UDP connection pointer from net_context.
*
* @details This is only needed in special occacions when
* there is an existing UDP connection that application
* wants to attach to. Normally the connection information
* is not needed by application.
*
* @return UDP connection if it exists, NULL otherwise.
*/
struct simple_udp_connection *
net_context_get_udp_connection(struct net_context *context);
#ifdef __cplusplus
}
#endif
#endif /* __NET_SOCKET_H */

View file

@ -30,7 +30,24 @@ menuconfig NETWORKING
help
This option enabled generic networking support.
if NETWORKING
choice
prompt "IP stack"
depends on NETWORKING
help
Select what IP stack to use. The legacy stack is
Contiki based uIP stack.
default NET_UIP
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
config IP_BUF_RX_SIZE
int "Number of IP net buffers to use when receiving data"
@ -572,3 +589,9 @@ config NET_TESTING
testing with Qemu and slip.
endif
if NETWORKING && NET_YAIP
source "net/yaip/Kconfig"
endif

17
net/yaip/Kconfig Normal file
View file

@ -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.
#

2
net/yaip/Makefile Normal file
View file

@ -0,0 +1,2 @@
ccflags-y += -I${srctree}/net/ip
obj-y = net_core.o

76
net/yaip/net_core.c Normal file
View file

@ -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 <nanokernel.h>
#include <toolchain.h>
#include <sections.h>
#include <string.h>
#include <errno.h>
/* 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();
}