From 4e3e23eb187a61a9990198579d51b1e28a9d9a92 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 13 Jun 2016 17:50:11 +0300 Subject: [PATCH] net: Use net_buf APIs for getting net_buf elements from FIFO The net_buf API ensures that the frags pointer gets initialized properly. Using nano_fifo_get could mean that buf->frags is something else than NULL if there was more than one item in the FIFO. Change-Id: If65e85a7cbe82f562307dc781d48110c3be0472b Signed-off-by: Johan Hedberg --- net/ip/net_core.c | 10 ++++------ net/ip/net_driver_15_4.c | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/net/ip/net_core.c b/net/ip/net_core.c index 677ece843d7..cadf310530d 100644 --- a/net/ip/net_core.c +++ b/net/ip/net_core.c @@ -673,16 +673,14 @@ struct net_buf *net_receive(struct net_context *context, int32_t timeout) switch (timeout) { case TICKS_UNLIMITED: - buf = nano_fifo_get(rx_queue, TICKS_UNLIMITED); - break; case TICKS_NONE: - buf = nano_fifo_get(rx_queue, TICKS_NONE); + buf = net_buf_get_timeout(rx_queue, 0, timeout); break; default: #ifdef CONFIG_NANO_TIMEOUTS buf = buf_wait_timeout(rx_queue, timeout); #else /* CONFIG_NANO_TIMEOUTS */ - buf = nano_fifo_get(rx_queue, TICKS_NONE); + buf = net_buf_get_timeout(rx_queue, 0, TICKS_NONE); #endif break; } @@ -841,7 +839,7 @@ static void net_tx_fiber(void) int ret; /* Get next packet from application - wait if necessary */ - buf = nano_fifo_get(&netdev.tx_queue, TICKS_UNLIMITED); + buf = net_buf_get_timeout(&netdev.tx_queue, 0, TICKS_UNLIMITED); NET_DBG("Sending (buf %p, len %u) to IP stack\n", buf, buf->len); @@ -885,7 +883,7 @@ static void net_rx_fiber(void) sizeof(rx_fiber_stack)); while (1) { - buf = nano_fifo_get(&netdev.rx_queue, TICKS_UNLIMITED); + buf = net_buf_get_timeout(&netdev.rx_queue, 0, TICKS_UNLIMITED); /* Check stack usage (no-op if not enabled) */ net_analyze_stack("RX fiber", rx_fiber_stack, diff --git a/net/ip/net_driver_15_4.c b/net/ip/net_driver_15_4.c index c6f49cb6436..77bc2228531 100644 --- a/net/ip/net_driver_15_4.c +++ b/net/ip/net_driver_15_4.c @@ -106,7 +106,7 @@ static void net_rx_15_4_fiber(void) while (1) { /* Wait next packet from 15.4 stack */ - buf = nano_fifo_get(&rx_queue, TICKS_UNLIMITED); + buf = net_buf_get_timeout(&rx_queue, 0, TICKS_UNLIMITED); #if NET_MAC_CONF_STATS byte_count = uip_pkt_buflen(buf);