From a42d6c98d3ae717cfaf851630bf28dc28dd55d40 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Fri, 22 Jan 2021 09:35:33 +0100 Subject: [PATCH] drivers: ieee802154_nrf5: Block on net_pkt allocation in the RX path Currently, if no net_pkt's are available, the radio driver RX thread drops the 802.15.4 frame silently. This causes undesired behaviour, where we can drop the packet which has already been acknowledged at the 802.15.4 level. Fix this, by blocking the RX thread if no net_pkt is avaliable. The packets received while the RX thread is blocked will be accumulated in the underlying nRF 802.15.4 driver, and eventually when it runs out of internal buffers before the thread is unblocked, it'll stop acknowledging the incoming frames. Signed-off-by: Robert Lubos --- drivers/ieee802154/ieee802154_nrf5.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index 93342174f55..76db636aa7b 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -133,12 +133,14 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3) LOG_DBG("Frame received"); + /* Block the RX thread until net_pkt is available, so that we + * don't drop already ACKed frame in case of temporary net_pkt + * scarcity. The nRF 802154 radio driver will accumulate any + * incoming frames until it runs out of internal buffers (and + * thus stops acknowledging consecutive frames). + */ pkt = net_pkt_rx_alloc_with_buffer(nrf5_radio->iface, pkt_len, - AF_UNSPEC, 0, K_NO_WAIT); - if (!pkt) { - LOG_ERR("No pkt available"); - goto drop; - } + AF_UNSPEC, 0, K_FOREVER); if (net_pkt_write(pkt, rx_frame->psdu + 1, pkt_len)) { goto drop;