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 <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2021-01-22 09:35:33 +01:00 committed by Jukka Rissanen
parent a8d3c8e142
commit a42d6c98d3

View file

@ -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;