This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e590c90da6d3003eef0861615916f17eaa52832e Author: raiden00pl <[email protected]> AuthorDate: Thu Oct 22 12:56:30 2026 +0200 wireless/ieee802154: bound the received frames of the MAC device The MAC character device queued every received data frame until it was read, an open device nobody reads took all IOBs. Keep at most CONFIG_IEEE802154_MACDEV_RXQUEUE frames and drop the rest. Assisted-by: Claude Code Signed-off-by: raiden00pl <[email protected]> --- wireless/ieee802154/Kconfig | 9 +++++++++ wireless/ieee802154/mac802154_device.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/wireless/ieee802154/Kconfig b/wireless/ieee802154/Kconfig index c1adbbb3e70..f73403622d9 100644 --- a/wireless/ieee802154/Kconfig +++ b/wireless/ieee802154/Kconfig @@ -101,6 +101,15 @@ config IEEE802154_MACDEV if IEEE802154_MACDEV +config IEEE802154_MACDEV_RXQUEUE + int "Received frames kept for read" + default 4 + range 1 255 + ---help--- + Number of received data frames the character driver keeps until + they are read. Each one holds an IOB, a frame received while the + queue is full is dropped. + config IEEE802154_MACDEV_RECVRPRIO int "Priority of frame receiver registered with the MAC layer" default 0 diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index 186a0946928..55f82f99ce5 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -107,6 +107,7 @@ struct mac802154_chardevice_s bool readpending; /* Is there a read using the semaphore? */ sem_t readsem; /* Signaling semaphore for waiting read */ sq_queue_t dataind_queue; + uint8_t ndataind; /* Frames in dataind_queue */ /* MAC Service notification information */ @@ -309,6 +310,8 @@ static int mac802154dev_close(FAR struct file *filep) ind = (FAR struct ieee802154_data_ind_s *) sq_remfirst(&dev->dataind_queue); } + + dev->ndataind = 0; } /* If there are now no open instances of the driver, purge the list of @@ -400,6 +403,7 @@ static ssize_t mac802154dev_read(FAR struct file *filep, FAR char *buffer, if (ind != NULL) { + dev->ndataind--; nxmutex_unlock(&dev->md_lock); break; } @@ -792,9 +796,19 @@ static int mac802154dev_rxframe(FAR struct mac802154_chardevice_s *dev, return -ENODEV; } + /* Drop the frame if the reader does not keep up */ + + if (dev->ndataind >= CONFIG_IEEE802154_MACDEV_RXQUEUE) + { + nxmutex_unlock(&dev->md_lock); + wlwarn("WARNING: RX queue full, dropping frame\n"); + return -ENOBUFS; + } + /* Push the indication onto the list */ sq_addlast((FAR sq_entry_t *)ind, &dev->dataind_queue); + dev->ndataind++; /* Check if there is a read waiting for data */
