From 7889ebaf5e93a57bf52acedbcdb7fd3d376c678f Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 27 Sep 2016 15:45:09 +0300 Subject: [PATCH] net: Add L2 RAW channel hidden option L2 RAW channel allows to use some functions of IP stack for RAW access of network drivers. It is hidden from user and is selected by 2520 raw driver. Change-Id: I91dd09803052072dfddb7989d9d67c3a5840f89e Signed-off-by: Andrei Emeltchenko --- drivers/ieee802154/Kconfig | 1 + include/net/yaip/net_ip.h | 5 +++ net/Kconfig | 1 - net/Makefile | 4 +++ net/yaip/Kconfig | 73 +++++++++++++++++++++----------------- net/yaip/nbuf.c | 2 +- 6 files changed, 52 insertions(+), 34 deletions(-) diff --git a/drivers/ieee802154/Kconfig b/drivers/ieee802154/Kconfig index 86acc43bee1..e1d20517a49 100644 --- a/drivers/ieee802154/Kconfig +++ b/drivers/ieee802154/Kconfig @@ -48,6 +48,7 @@ config TI_CC2520 config TI_CC2520_RAW bool "TI CC2520 Driver RAW channel" + select NET_L2_RAW_CHANNEL default n help Enable TI_CC2520 driver with RAW channel diff --git a/include/net/yaip/net_ip.h b/include/net/yaip/net_ip.h index 3123de6623c..e131d0b6e82 100644 --- a/include/net/yaip/net_ip.h +++ b/include/net/yaip/net_ip.h @@ -130,7 +130,12 @@ struct sockaddr_in_ptr { #define NET_SOCKADDR_MAX_SIZE (sizeof(struct sockaddr_in)) #define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct sockaddr_in_ptr)) #else +#if !defined(CONFIG_NET_L2_RAW_CHANNEL) #error "Either IPv6 or IPv4 needs to be selected." +#else +#define NET_SOCKADDR_MAX_SIZE (sizeof(struct sockaddr_in6)) +#define NET_SOCKADDR_PTR_MAX_SIZE (sizeof(struct sockaddr_in6_ptr)) +#endif #endif struct sockaddr { diff --git a/net/Kconfig b/net/Kconfig index 3fa2301f1ed..d1a584b53ec 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -80,7 +80,6 @@ source "net/ip/Kconfig" source "net/yaip/Kconfig" - endif endmenu diff --git a/net/Makefile b/net/Makefile index c709c479112..14018204e3e 100644 --- a/net/Makefile +++ b/net/Makefile @@ -1,6 +1,10 @@ obj-$(CONFIG_NET_BUF) += buf.o ifeq ($(CONFIG_NET_YAIP),y) +ifeq ($(CONFIG_NET_L2_RAW_CHANNEL),y) +obj-y += yaip/nbuf.o +else obj-y += yaip/ +endif else obj-$(CONFIG_NETWORKING) += ip/ endif diff --git a/net/yaip/Kconfig b/net/yaip/Kconfig index e76d7598069..4428c3eafdb 100644 --- a/net/yaip/Kconfig +++ b/net/yaip/Kconfig @@ -19,6 +19,13 @@ menu "New IP stack [EXPERIMENTAL]" depends on NET_YAIP +# Hidden option +config NET_L2_RAW_CHANNEL + bool + default n + +if !NET_L2_RAW_CHANNEL + config NET_INIT_PRIO int default 90 @@ -110,38 +117,6 @@ config NET_RX_STACK_SIZE Set the RX fiber stack size in bytes. The RX fiber is waiting data from network. There is one RX fiber in the system. -config NET_NBUF_RX_COUNT - int "How many network receives can be pending at the same time" - default 2 - help - Each RX buffer will occupy smallish amount of memory. - See include/net/nbuf.h and the sizeof(struct nbuf) - -config NET_NBUF_TX_COUNT - int "How many network sends can be pending at the same time" - default 2 - help - Each TX buffer will occupy smallish amount of memory. - See include/net/nbuf.h and the sizeof(struct nbuf) - -config NET_NBUF_DATA_COUNT - int "How many network data buffers are allocated" - default 16 - help - Each data buffer will occupy CONFIG_NBUF_DATA_SIZE + smallish - header (sizeof(struct net_buf)) amount of data. - -config NET_NBUF_DATA_SIZE - int "Size of each network data fragment" - default 128 - help - This value tells what is the size of the data fragment that is - received from the network. - Example: For IEEE 802.15.4, the network packet is 127 bytes long, - which leaves in worst case 81 bytes for user data (MTU). - In order to be able to receive at least full IPv6 packet which - has a size of 1280 bytes, the one should allocate 16 fragments here. - config NET_MAX_CONTEXTS int "Number of network contexts to allocate" default 2 @@ -192,6 +167,40 @@ config NET_DEBUG_TRICKLE help Enables Trickle library output debug messages +endif # NET_L2_RAW_CHANNEL + +config NET_NBUF_RX_COUNT + int "How many network receives can be pending at the same time" + default 2 + help + Each RX buffer will occupy smallish amount of memory. + See include/net/nbuf.h and the sizeof(struct nbuf) + +config NET_NBUF_TX_COUNT + int "How many network sends can be pending at the same time" + default 2 + help + Each TX buffer will occupy smallish amount of memory. + See include/net/nbuf.h and the sizeof(struct nbuf) + +config NET_NBUF_DATA_COUNT + int "How many network data buffers are allocated" + default 16 + help + Each data buffer will occupy CONFIG_NBUF_DATA_SIZE + smallish + header (sizeof(struct net_buf)) amount of data. + +config NET_NBUF_DATA_SIZE + int "Size of each network data fragment" + default 128 + help + This value tells what is the size of the data fragment that is + received from the network. + Example: For IEEE 802.15.4, the network packet is 127 bytes long, + which leaves in worst case 81 bytes for user data (MTU). + In order to be able to receive at least full IPv6 packet which + has a size of 1280 bytes, the one should allocate 16 fragments here. + source "net/yaip/l2/Kconfig" source "net/yaip/Kconfig.mgmt" diff --git a/net/yaip/nbuf.c b/net/yaip/nbuf.c index 49d1f2b6f1b..3c04a76d8d8 100644 --- a/net/yaip/nbuf.c +++ b/net/yaip/nbuf.c @@ -56,7 +56,7 @@ #endif /* UDP */ #endif /* TCP */ -#if defined(CONFIG_NET_IPV6) +#if defined(CONFIG_NET_IPV6) || defined(CONFIG_NET_L2_RAW_CHANNEL) #define IP_PROTO_LEN NET_IPV6H_LEN #else #if defined(CONFIG_NET_IPV4)