diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2016-06-01 10:35:00 +0300 |
---|---|---|
committer | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2016-07-13 14:06:24 +0000 |
commit | b375394369cb992779ffeece70800b42cf5987b9 (patch) | |
tree | db319fb83035c7bda6f64b46ea01d7f05ddeb511 /net | |
parent | d0daa978208f8b72a9aa56c228efdd4f94ecbf08 (diff) |
net: yaip: Make sure that RX is started before TX
The network stack initialization will need to make sure
that RX side is ready before TX side is started. So in
order to do that the TX init is called from RX fiber.
This is needed so that we can start to send network packets already
during the net_init(), like IPv6 neighbor solicitation messages
during duplicate address detection process.
Change-Id: I12fde3d388d9aab41daa93b1edc02f25b8c5511d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/yaip/net_core.c | 19 | ||||
-rw-r--r-- | net/yaip/net_if.c | 16 |
2 files changed, 21 insertions, 14 deletions
diff --git a/net/yaip/net_core.c b/net/yaip/net_core.c index ae1a53114..f24aacb44 100644 --- a/net/yaip/net_core.c +++ b/net/yaip/net_core.c @@ -313,13 +313,18 @@ static inline enum net_verdict process_data(struct net_buf *buf) return NET_DROP; } -static void net_rx_fiber(int unused1, int unused2) +static void net_rx_fiber(void) { struct net_buf *buf; NET_DBG("Starting RX fiber (stack %d bytes)", sizeof(rx_fiber_stack)); + /* Starting TX side. The ordering is important here and the TX + * can only be started when RX side is ready to receive packets. + */ + net_if_init(); + while (1) { buf = nano_fifo_get(&rx_queue, TICKS_UNLIMITED); @@ -349,7 +354,8 @@ static void init_rx_queue(void) nano_fifo_init(&rx_queue); rx_fiber_id = fiber_start(rx_fiber_stack, sizeof(rx_fiber_stack), - net_rx_fiber, 0, 0, 8, 0); + (nano_fiber_entry_t)net_rx_fiber, + 0, 0, 8, 0); } /* Called when data needs to be sent to network */ @@ -401,6 +407,7 @@ static int network_initialization(void) #if defined(CONFIG_NET_IPV6) net_icmpv6_init(); #endif + NET_DBG("Network L3 layer init done"); return 0; } @@ -417,17 +424,17 @@ static int net_init(struct device *unused) net_nbuf_init(); - init_rx_queue(); + net_context_init(); #ifdef CONFIG_NET_ARP net_arp_init(); #endif - net_if_init(); + network_initialization(); - net_context_init(); + init_rx_queue(); - return network_initialization(); + return 0; } SYS_INIT(net_init, NANOKERNEL, CONFIG_NET_INIT_PRIO); diff --git a/net/yaip/net_if.c b/net/yaip/net_if.c index 96e481005..a6357613e 100644 --- a/net/yaip/net_if.c +++ b/net/yaip/net_if.c @@ -38,8 +38,14 @@ static void net_if_tx_fiber(struct net_if *iface) { 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); + api = (struct net_if_api *) iface->dev->driver_api; + + NET_ASSERT(api && api->init && api->send); + + NET_DBG("Starting TX fiber (stack %d bytes) for driver %p queue %p", + sizeof(iface->tx_fiber_stack), api, &iface->tx_queue); + + api->init(iface); while (1) { struct net_buf *buf; @@ -457,15 +463,9 @@ struct net_if *net_if_get_default(void) void net_if_init(void) { - struct net_if_api *api; struct net_if *iface; for (iface = __net_if_start; iface != __net_if_end; iface++) { - api = (struct net_if_api *) iface->dev->driver_api; - - NET_ASSERT(api && api->init && api->send); - - api->init(iface); init_tx_queue(iface); #if defined(CONFIG_NET_IPV6) |