From 70404ed0dc1c4b617258cfe686c0411974d6ab8d Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Fri, 16 Aug 2019 22:42:25 +0000 Subject: [PATCH] Merged in antmerlino/nuttx/iobinstrumentation (pull request #1001) Iobinstrumentation * mm/iob: Introduces producer/consumer id to every iob call. This is so that the calls can be instrumented to monitor the IOB resources. * iob instrumentation - Merges producer/consumer enumeration for simpler IOB user. * fs/procfs: Starts adding support for /proc/iobinfo * fs/procfs: Finishes first pass of simple IOB user stastics and /proc/iobinfo entry Approved-by: Gregory Nutt --- drivers/syslog/syslog_stream.c | 4 +- .../ieee802154/mrf24j40/mrf24j40_interrupt.c | 2 +- drivers/wireless/ieee802154/xbee/xbee.c | 19 +- drivers/wireless/ieee802154/xbee/xbee_mac.c | 2 +- .../wireless/ieee802154/xbee/xbee_netdev.c | 4 +- .../wireless/spirit/drivers/spirit_netdev.c | 18 +- fs/procfs/Kconfig | 5 + fs/procfs/Make.defs | 3 +- fs/procfs/fs_procfs.c | 5 + fs/procfs/fs_procfsiobinfo.c | 426 ++++++++++++++++++ include/nuttx/mm/iob.h | 133 +++++- include/nuttx/net/net.h | 7 +- mm/iob/Make.defs | 2 +- mm/iob/iob.h | 40 ++ mm/iob/iob_alloc.c | 36 +- mm/iob/iob_clone.c | 5 +- mm/iob/iob_contig.c | 5 +- mm/iob/iob_copyin.c | 17 +- mm/iob/iob_free.c | 8 +- mm/iob/iob_free_chain.c | 4 +- mm/iob/iob_free_queue.c | 5 +- mm/iob/iob_pack.c | 7 +- mm/iob/iob_statistics.c | 136 ++++++ mm/iob/iob_test.c | 16 +- mm/iob/iob_trimhead.c | 5 +- mm/iob/iob_trimhead_queue.c | 5 +- mm/iob/iob_trimtail.c | 5 +- net/bluetooth/bluetooth_conn.c | 2 +- net/bluetooth/bluetooth_input.c | 4 +- net/bluetooth/bluetooth_recvfrom.c | 2 +- net/bluetooth/bluetooth_sendto.c | 2 +- net/icmp/icmp_input.c | 13 +- net/icmp/icmp_recvfrom.c | 4 +- net/icmp/icmp_sendto.c | 4 +- net/icmp/icmp_sockif.c | 2 +- net/icmpv6/icmpv6_input.c | 13 +- net/icmpv6/icmpv6_recvfrom.c | 4 +- net/icmpv6/icmpv6_sendto.c | 4 +- net/icmpv6/icmpv6_sockif.c | 2 +- net/ieee802154/ieee802154_conn.c | 2 +- net/ieee802154/ieee802154_input.c | 4 +- net/ieee802154/ieee802154_recvfrom.c | 2 +- net/ieee802154/ieee802154_sendto.c | 2 +- net/inet/inet_recvfrom.c | 7 +- net/ipforward/ipfwd_forward.c | 2 +- net/ipforward/ipv4_forward.c | 6 +- net/ipforward/ipv6_forward.c | 6 +- net/sixlowpan/sixlowpan_framelist.c | 4 +- net/sixlowpan/sixlowpan_input.c | 2 +- net/tcp/tcp.h | 9 +- net/tcp/tcp_callback.c | 9 +- net/tcp/tcp_conn.c | 2 +- net/tcp/tcp_wrbuffer.c | 6 +- net/udp/udp_callback.c | 17 +- net/udp/udp_conn.c | 2 +- net/udp/udp_psock_sendto_buffered.c | 6 +- net/udp/udp_wrbuffer.c | 4 +- net/utils/net_lock.c | 6 +- wireless/bluetooth/bt_buf.c | 4 +- wireless/bluetooth/bt_netdev.c | 2 +- wireless/ieee802154/mac802154.c | 11 +- wireless/ieee802154/mac802154_assoc.c | 10 +- wireless/ieee802154/mac802154_device.c | 6 +- wireless/ieee802154/mac802154_netdev.c | 4 +- 64 files changed, 945 insertions(+), 170 deletions(-) create mode 100644 fs/procfs/fs_procfsiobinfo.c create mode 100644 mm/iob/iob_statistics.c diff --git a/drivers/syslog/syslog_stream.c b/drivers/syslog/syslog_stream.c index 6f323be0967..e48f0927ac1 100644 --- a/drivers/syslog/syslog_stream.c +++ b/drivers/syslog/syslog_stream.c @@ -225,7 +225,7 @@ void syslogstream_create(FAR struct lib_syslogstream_s *stream) #ifdef CONFIG_SYSLOG_BUFFER /* Allocate an IOB */ - iob = iob_tryalloc(true); + iob = iob_tryalloc(true, IOBUSER_SYSLOG); stream->iob = iob; if (iob != NULL) @@ -269,7 +269,7 @@ void syslogstream_destroy(FAR struct lib_syslogstream_s *stream) /* Free the IOB */ - iob_free(stream->iob); + iob_free(stream->iob, IOBUSER_SYSLOG); stream->iob = NULL; } } diff --git a/drivers/wireless/ieee802154/mrf24j40/mrf24j40_interrupt.c b/drivers/wireless/ieee802154/mrf24j40/mrf24j40_interrupt.c index d73fa6e8bbc..9ce7b43fd8d 100644 --- a/drivers/wireless/ieee802154/mrf24j40/mrf24j40_interrupt.c +++ b/drivers/wireless/ieee802154/mrf24j40/mrf24j40_interrupt.c @@ -244,7 +244,7 @@ static void mrf24j40_irqwork_rx(FAR struct mrf24j40_radio_s *dev) /* Allocate an IOB to put the frame into */ - ind->frame = iob_alloc(false); + ind->frame = iob_alloc(false, IOBUSER_WIRELESS_RAD802154); ind->frame->io_flink = NULL; ind->frame->io_len = 0; ind->frame->io_pktlen = 0; diff --git a/drivers/wireless/ieee802154/xbee/xbee.c b/drivers/wireless/ieee802154/xbee/xbee.c index e38812b2077..39d91d965c2 100644 --- a/drivers/wireless/ieee802154/xbee/xbee.c +++ b/drivers/wireless/ieee802154/xbee/xbee.c @@ -180,7 +180,7 @@ static void xbee_attnworker(FAR void *arg) /* Allocate an IOB for the incoming data. */ - iob = iob_alloc(false); + iob = iob_alloc(false, IOBUSER_WIRELESS_RAD802154); iob->io_flink = NULL; iob->io_len = 0; iob->io_offset = 0; @@ -276,7 +276,9 @@ static void xbee_attnworker(FAR void *arg) * processing. */ - iob->io_flink = iob_tryalloc(false); + iob->io_flink = + iob_tryalloc(false, IOBUSER_WIRELESS_RAD802154); + iob = iob->io_flink; if (iob != NULL) @@ -340,7 +342,7 @@ static void xbee_attnworker(FAR void *arg) wlwarn("Partial API frame clocked in. Dropping!\n"); } - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_RAD802154); } } @@ -784,7 +786,7 @@ static void xbee_process_apiframes(FAR struct xbee_priv_s *priv, nextframe = frame->io_flink; frame->io_flink = NULL; - iob_free(frame); + iob_free(frame, IOBUSER_WIRELESS_RAD802154); frame = nextframe; } } @@ -1004,7 +1006,8 @@ static void xbee_notify_worker(FAR void *arg) if (dispose) { - iob_free(primitive->u.dataind.frame); + iob_free(primitive->u.dataind.frame, + IOBUSER_WIRELESS_RAD802154); ieee802154_primitive_free(primitive); } } @@ -1302,7 +1305,7 @@ void xbee_send_apiframe(FAR struct xbee_priv_s *priv, * If we can't allocate an IOB, then we have to just drop the incoming data. */ - iob = iob_tryalloc(false); + iob = iob_tryalloc(false, IOBUSER_WIRELESS_RAD802154); iob->io_flink = NULL; iob->io_len = 0; iob->io_offset = 0; @@ -1392,7 +1395,7 @@ void xbee_send_apiframe(FAR struct xbee_priv_s *priv, * processing. */ - iob->io_flink = iob_tryalloc(false); + iob->io_flink = iob_tryalloc(false, IOBUSER_WIRELESS_RAD802154); iob = iob->io_flink; if (iob != NULL) @@ -1450,7 +1453,7 @@ void xbee_send_apiframe(FAR struct xbee_priv_s *priv, wlwarn("Partial API frame clocked in. Dropping!\n"); } - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_RAD802154); } } diff --git a/drivers/wireless/ieee802154/xbee/xbee_mac.c b/drivers/wireless/ieee802154/xbee/xbee_mac.c index 95f9801cea1..dce3eb96b22 100644 --- a/drivers/wireless/ieee802154/xbee/xbee_mac.c +++ b/drivers/wireless/ieee802154/xbee/xbee_mac.c @@ -416,7 +416,7 @@ int xbee_req_data(XBEEHANDLE xbee, while (!priv->txdone); nxsem_post(&priv->tx_sem); - iob_free(frame); + iob_free(frame, IOBUSER_WIRELESS_MAC802154); return OK; } diff --git a/drivers/wireless/ieee802154/xbee/xbee_netdev.c b/drivers/wireless/ieee802154/xbee/xbee_netdev.c index 7e516eb7ec2..4b37acbcfcb 100644 --- a/drivers/wireless/ieee802154/xbee/xbee_netdev.c +++ b/drivers/wireless/ieee802154/xbee/xbee_netdev.c @@ -1208,13 +1208,13 @@ static int xbeenet_req_data(FAR struct radio_driver_s *netdev, { wlerr("ERROR: xbeemac_req_data failed: %d\n", ret); - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_RAD802154); for (iob = framelist; iob != NULL; iob = framelist) { /* Remove the IOB from the queue and free */ framelist = iob->io_flink; - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_RAD802154); } NETDEV_TXERRORS(&priv->xd_dev.r_dev); diff --git a/drivers/wireless/spirit/drivers/spirit_netdev.c b/drivers/wireless/spirit/drivers/spirit_netdev.c index 3766af4c593..d437b51f439 100644 --- a/drivers/wireless/spirit/drivers/spirit_netdev.c +++ b/drivers/wireless/spirit/drivers/spirit_netdev.c @@ -715,7 +715,7 @@ static void spirit_free_txhead(FAR struct spirit_driver_s *priv) /* Free the IOB contained in the metadata container */ - iob_free(pktmeta->pm_iob); + iob_free(pktmeta->pm_iob, IOBUSER_WIRELESS_PACKETRADIO); /* Then free the meta data container itself */ @@ -1175,7 +1175,7 @@ static void spirit_interrupt_work(FAR void *arg) if (priv->rxbuffer != NULL) { - iob_free(priv->rxbuffer); + iob_free(priv->rxbuffer, IOBUSER_WIRELESS_PACKETRADIO); priv->rxbuffer = NULL; } #endif @@ -1329,7 +1329,7 @@ static void spirit_interrupt_work(FAR void *arg) if (priv->rxbuffer == NULL) { - priv->rxbuffer = iob_alloc(0); + priv->rxbuffer = iob_alloc(false, IOBUSER_WIRELESS_PACKETRADIO); } if (priv->rxbuffer != NULL) @@ -1404,7 +1404,7 @@ static void spirit_interrupt_work(FAR void *arg) { /* Allocate an I/O buffer to hold the received packet. */ - iob = iob_alloc(0); + iob = iob_alloc(false, IOBUSER_WIRELESS_PACKETRADIO); } if (iob == NULL) @@ -1444,7 +1444,7 @@ static void spirit_interrupt_work(FAR void *arg) { wlerr("ERROR: Failed to allocate metadata... dropping\n"); NETDEV_RXDROPPED(&priv->radio.r_dev); - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_PACKETRADIO); } else { @@ -1525,7 +1525,7 @@ static void spirit_interrupt_work(FAR void *arg) { /* If not, then allocate one now. */ - priv->rxbuffer = iob_alloc(0); + priv->rxbuffer = iob_alloc(false, IOBUSER_WIRELESS_PACKETRADIO); iob = priv->rxbuffer; offset = 0; } @@ -1553,7 +1553,7 @@ static void spirit_interrupt_work(FAR void *arg) /* Free the IOB */ priv->rxbuffer = NULL; - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_PACKETRADIO); } else { @@ -1614,7 +1614,7 @@ static void spirit_interrupt_work(FAR void *arg) if (priv->rxbuffer != NULL) { - iob_free(priv->rxbuffer); + iob_free(priv->rxbuffer, IOBUSER_WIRELESS_PACKETRADIO); priv->rxbuffer = NULL; } #endif @@ -2357,7 +2357,7 @@ static int spirit_req_data(FAR struct radio_driver_s *netdev, { wlerr("ERROR: Failed to allocate metadata... dropping\n"); NETDEV_RXDROPPED(&priv->radio.r_dev); - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_PACKETRADIO); continue; } diff --git a/fs/procfs/Kconfig b/fs/procfs/Kconfig index b07c1a3a9da..ff90e7b9ad4 100644 --- a/fs/procfs/Kconfig +++ b/fs/procfs/Kconfig @@ -96,6 +96,11 @@ config FS_PROCFS_INCLUDE_PROGMEM default n depends on ARCH_HAVE_PROGMEM && !FS_PROCFS_EXCLUDE_MEMINFO +config FS_PROCFS_EXCLUDE_IOBINFO + bool "Exclude iobinfo" + depends on MM_IOB + default n + config FS_PROCFS_EXCLUDE_MOUNTS bool "Exclude mounts" default n diff --git a/fs/procfs/Make.defs b/fs/procfs/Make.defs index c728d56fe4b..5a244bf44cb 100644 --- a/fs/procfs/Make.defs +++ b/fs/procfs/Make.defs @@ -38,7 +38,8 @@ ifeq ($(CONFIG_FS_PROCFS),y) ASRCS += CSRCS += fs_procfs.c fs_procfsutil.c fs_procfsproc.c fs_procfsuptime.c -CSRCS += fs_procfscpuload.c fs_procfsmeminfo.c fs_procfsversion.c +CSRCS += fs_procfscpuload.c fs_procfsmeminfo.c fs_procfsiobinfo.c +CSRCS += fs_procfsversion.c ifeq ($(CONFIG_SCHED_CRITMONITOR),y) CSRCS += fs_procfscritmon.c diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index 4db3f51a295..15ac59400f3 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -81,6 +81,7 @@ extern const struct procfs_operations irq_operations; extern const struct procfs_operations cpuload_operations; extern const struct procfs_operations critmon_operations; extern const struct procfs_operations meminfo_operations; +extern const struct procfs_operations iobinfo_operations; extern const struct procfs_operations module_operations; extern const struct procfs_operations uptime_operations; extern const struct procfs_operations version_operations; @@ -139,6 +140,10 @@ static const struct procfs_entry_s g_procfs_entries[] = { "meminfo", &meminfo_operations, PROCFS_FILE_TYPE }, #endif +#if defined(CONFIG_MM_IOB) && !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) + { "iobinfo", &iobinfo_operations, PROCFS_FILE_TYPE }, +#endif + #if defined(CONFIG_MODULE) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE) { "modules", &module_operations, PROCFS_FILE_TYPE }, #endif diff --git a/fs/procfs/fs_procfsiobinfo.c b/fs/procfs/fs_procfsiobinfo.c new file mode 100644 index 00000000000..7536e890f3c --- /dev/null +++ b/fs/procfs/fs_procfsiobinfo.c @@ -0,0 +1,426 @@ +/**************************************************************************** + * fs/procfs/fs_procfsiobinfo.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Anthony Merlino + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \ + defined(CONFIG_MM_IOB) && !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Determines the size of an intermediate buffer that must be large enough + * to handle the longest line generated by this logic. + */ + +#define IOBINFO_LINELEN 80 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* This structure describes one open "file" */ + +struct iobinfo_file_s +{ + struct procfs_file_s base; /* Base open file structure */ + unsigned int linesize; /* Number of valid characters in line[] */ + char line[IOBINFO_LINELEN]; /* Pre-allocated buffer for formatted lines */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* File system methods */ + +static int iobinfo_open(FAR struct file *filep, FAR const char *relpath, + int oflags, mode_t mode); +static int iobinfo_close(FAR struct file *filep); +static ssize_t iobinfo_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static int iobinfo_dup(FAR const struct file *oldp, + FAR struct file *newp); +static int iobinfo_stat(FAR const char *relpath, FAR struct stat *buf); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* CAUTION: The order of these entries and the preprocessor logic must match + * logic found in the enum iob_user_e declaration found in iob.h + */ + +static const char* g_iob_user_names[] = +{ +#ifdef CONFIG_SYSLOG_BUFFER + "syslog", +#endif +#ifdef CONFIG_IOB_UNITTEST + "unittest", +#endif +#ifdef CONFIG_NET_6LOWPAN + "sixlowpan", +#endif +#ifdef CONFIG_NET_ICMP_SOCKET + "icmp_sock", +#endif +#ifdef CONFIG_NET_ICMPv6_SOCKET + "icmpv6_sock", +#endif +#ifdef CONFIG_NET_UDP + "udp_sock", +#endif +#ifdef CONFIG_NET_TCP + "tcp_sock", +#endif +#ifdef CONFIG_NET_IEEE802154 + "ieee802154_sock", +#endif +#ifdef CONFIG_NET_BLUETOOTH + "bluetooth_sock", +#endif +#ifdef CONFIG_NET_UDP_READAHEAD + "udp_readahead", +#endif +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS + "udp_writebuffer", +#endif +#ifdef CONFIG_NET_TCP_READAHEAD + "tcp_readahead", +#endif +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS + "tcp_writebuffer", +#endif +#ifdef CONFIG_NET_IPFORWARD + "ipforward", +#endif +#ifdef CONFIG_WIRELESS_IEEE802154 + "rad802154", +#endif +#ifdef CONFIG_IEEE802154_MAC + "mac802154", +#endif +#ifdef CONFIG_IEEE802154_MACDEV + "mac802154_macdev", +#endif +#ifdef CONFIG_IEEE802154_NETDEV + "mac802154_netdev", +#endif + #ifdef CONFIG_WL_SPIRIT + "packetradio", +#endif +#ifdef CONFIG_WIRELESS_BLUETOOTH + "bluetooth", +#endif + "global", +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* See fs_mount.c -- this structure is explicitly externed there. + * We use the old-fashioned kind of initializers so that this will compile + * with any compiler. + */ + +const struct procfs_operations iobinfo_operations = +{ + iobinfo_open, /* open */ + iobinfo_close, /* close */ + iobinfo_read, /* read */ + NULL, /* write */ + iobinfo_dup, /* dup */ + NULL, /* opendir */ + NULL, /* closedir */ + NULL, /* readdir */ + NULL, /* rewinddir */ + iobinfo_stat /* stat */ +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: iobinfo_open + ****************************************************************************/ + +static int iobinfo_open(FAR struct file *filep, FAR const char *relpath, + int oflags, mode_t mode) +{ + FAR struct iobinfo_file_s *procfile; + + finfo("Open '%s'\n", relpath); + + /* PROCFS is read-only. Any attempt to open with any kind of write + * access is not permitted. + * + * REVISIT: Write-able proc files could be quite useful. + */ + + if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) + { + ferr("ERROR: Only O_RDONLY supported\n"); + return -EACCES; + } + + /* "iobinfo" is the only acceptable value for the relpath */ + + if (strcmp(relpath, "iobinfo") != 0) + { + ferr("ERROR: relpath is '%s'\n", relpath); + return -ENOENT; + } + + /* Allocate a container to hold the file attributes */ + + procfile = (FAR struct iobinfo_file_s *) + kmm_zalloc(sizeof(struct iobinfo_file_s)); + if (!procfile) + { + ferr("ERROR: Failed to allocate file attributes\n"); + return -ENOMEM; + } + + /* Save the attributes as the open-specific state in filep->f_priv */ + + filep->f_priv = (FAR void *)procfile; + return OK; +} + +/**************************************************************************** + * Name: iobinfo_close + ****************************************************************************/ + +static int iobinfo_close(FAR struct file *filep) +{ + FAR struct iobinfo_file_s *procfile; + + /* Recover our private data from the struct file instance */ + + procfile = (FAR struct iobinfo_file_s *)filep->f_priv; + DEBUGASSERT(procfile); + + /* Release the file attributes structure */ + + kmm_free(procfile); + filep->f_priv = NULL; + return OK; +} + +/**************************************************************************** + * Name: iobinfo_read + ****************************************************************************/ + +static ssize_t iobinfo_read(FAR struct file *filep, FAR char *buffer, + size_t buflen) +{ + FAR struct iobinfo_file_s *iobfile; + FAR struct iob_userstats_s *userstats; + size_t linesize; + size_t copysize; + size_t totalsize; + off_t offset; + + finfo("buffer=%p buflen=%d\n", buffer, (int)buflen); + + DEBUGASSERT(filep != NULL && buffer != NULL && buflen > 0); + offset = filep->f_pos; + + /* Recover our private data from the struct file instance */ + + iobfile = (FAR struct iobinfo_file_s *)filep->f_priv; + DEBUGASSERT(iobfile); + + /* The first line is the headers */ + + linesize = snprintf(iobfile->line, IOBINFO_LINELEN, + " TOTAL TOTAL\n"); + + copysize = procfs_memcpy(iobfile->line, linesize, buffer, buflen, + &offset); + totalsize = copysize; + + if (totalsize < buflen) + { + buffer += copysize; + buflen -= copysize; + + linesize = snprintf(iobfile->line, IOBINFO_LINELEN, + " USER CONSUMED PRODUCED\n"); + + copysize = procfs_memcpy(iobfile->line, linesize, buffer, buflen, + &offset); + totalsize += copysize; + } + + /* Loop through each IOB user printing the usage statistics */ + + for (int i = 0; i < IOBUSER_GLOBAL; i++) + { + if (totalsize < buflen) + { + buffer += copysize; + buflen -= copysize; + + userstats = iob_getuserstats(i); + linesize = snprintf(iobfile->line, IOBINFO_LINELEN, + "%-16s%16lu%16lu\n", + g_iob_user_names[i], + (unsigned long)userstats->totalconsumed, + (unsigned long)userstats->totalproduced); + + copysize = procfs_memcpy(iobfile->line, linesize, buffer, buflen, + &offset); + totalsize += copysize; + } + } + + if (totalsize < buflen) + { + buffer += copysize; + buflen -= copysize; + + userstats = iob_getuserstats(IOBUSER_GLOBAL); + linesize = snprintf(iobfile->line, IOBINFO_LINELEN, + "\n%-16s%16lu%16lu\n", + g_iob_user_names[IOBUSER_GLOBAL], + (unsigned long)userstats->totalconsumed, + (unsigned long)userstats->totalproduced); + + copysize = procfs_memcpy(iobfile->line, linesize, buffer, buflen, + &offset); + totalsize += copysize; + } + + /* Update the file offset */ + + filep->f_pos += totalsize; + return totalsize; +} + +/**************************************************************************** + * Name: iobinfo_dup + * + * Description: + * Duplicate open file data in the new file structure. + * + ****************************************************************************/ + +static int iobinfo_dup(FAR const struct file *oldp, FAR struct file *newp) +{ + FAR struct iobinfo_file_s *oldattr; + FAR struct iobinfo_file_s *newattr; + + finfo("Dup %p->%p\n", oldp, newp); + + /* Recover our private data from the old struct file instance */ + + oldattr = (FAR struct iobinfo_file_s *)oldp->f_priv; + DEBUGASSERT(oldattr); + + /* Allocate a new container to hold the task and attribute selection */ + + newattr = (FAR struct iobinfo_file_s *) + kmm_malloc(sizeof(struct iobinfo_file_s)); + if (!newattr) + { + ferr("ERROR: Failed to allocate file attributes\n"); + return -ENOMEM; + } + + /* The copy the file attributes from the old attributes to the new */ + + memcpy(newattr, oldattr, sizeof(struct iobinfo_file_s)); + + /* Save the new attributes in the new file structure */ + + newp->f_priv = (FAR void *)newattr; + return OK; +} + +/**************************************************************************** + * Name: iobinfo_stat + * + * Description: Return information about a file or directory + * + ****************************************************************************/ + +static int iobinfo_stat(FAR const char *relpath, FAR struct stat *buf) +{ + /* "iobinfo" is the only acceptable value for the relpath */ + + if (strcmp(relpath, "iobinfo") != 0) + { + ferr("ERROR: relpath is '%s'\n", relpath); + return -ENOENT; + } + + /* "iobinfo" is the name for a read-only file */ + + memset(buf, 0, sizeof(struct stat)); + buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; + return OK; +} + +#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS && + * CONFIG_MM_IOB && !CONFIG_FS_PROCFS_EXCLUDE_IOBINFO */ diff --git a/include/nuttx/mm/iob.h b/include/nuttx/mm/iob.h index 0954c0e8525..ab2ee37a668 100644 --- a/include/nuttx/mm/iob.h +++ b/include/nuttx/mm/iob.h @@ -152,6 +152,84 @@ struct iob_queue_s }; #endif /* CONFIG_IOB_NCHAINS > 0 */ +/* NOTE: When you change any logic here, you must change the logic in + * fs/procfs/fs_procfsiobinfo.c as it depends on having matching sequential + * logic. + */ + +enum iob_user_e +{ + IOBUSER_UNKNOWN = -1, +#ifdef CONFIG_SYSLOG_BUFFER + IOBUSER_SYSLOG, +#endif +#ifdef CONFIG_IOB_UNITTEST + IOBUSER_UNITTEST, +#endif +#ifdef CONFIG_NET_6LOWPAN + IOBUSER_NET_6LOWPAN, +#endif +#ifdef CONFIG_NET_ICMP_SOCKET + IOBUSER_NET_SOCK_ICMP, +#endif +#ifdef CONFIG_NET_ICMPv6_SOCKET + IOBUSER_NET_SOCK_ICMPv6, +#endif +#ifdef CONFIG_NET_UDP + IOBUSER_NET_SOCK_UDP, +#endif +#ifdef CONFIG_NET_TCP + IOBUSER_NET_SOCK_TCP, +#endif +#ifdef CONFIG_NET_IEEE802154 + IOBUSER_NET_SOCK_IEEE802154, +#endif +#ifdef CONFIG_NET_BLUETOOTH + IOBUSER_NET_SOCK_BLUETOOTH, +#endif +#ifdef CONFIG_NET_UDP_READAHEAD + IOBUSER_NET_UDP_READAHEAD, +#endif +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS + IOBUSER_NET_UDP_WRITEBUFFER, +#endif +#ifdef CONFIG_NET_TCP_READAHEAD + IOBUSER_NET_TCP_READAHEAD, +#endif +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS + IOBUSER_NET_TCP_WRITEBUFFER, +#endif +#ifdef CONFIG_NET_IPFORWARD + IOBUSER_NET_IPFORWARD, +#endif +#ifdef CONFIG_WIRELESS_IEEE802154 + IOBUSER_WIRELESS_RAD802154, +#endif +#ifdef CONFIG_IEEE802154_MAC + IOBUSER_WIRELESS_MAC802154, +#endif +#ifdef CONFIG_IEEE802154_MACDEV + IOBUSER_WIRELESS_MAC802154_CHARDEV, +#endif +#ifdef CONFIG_IEEE802154_NETDEV + IOBUSER_WIRELESS_MAC802154_NETDEV, +#endif + #ifdef CONFIG_WL_SPIRIT + IOBUSER_WIRELESS_PACKETRADIO, +#endif +#ifdef CONFIG_WIRELESS_BLUETOOTH + IOBUSER_WIRELESS_BLUETOOTH, +#endif + IOBUSER_GLOBAL, + IOBUSER_NENTRIES /* MUST BE LAST ENTRY */ +}; + +struct iob_userstats_s +{ + int totalconsumed; + int totalproduced; +}; + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ @@ -174,7 +252,7 @@ void iob_initialize(void); * ****************************************************************************/ -FAR struct iob_s *iob_alloc(bool throttled); +FAR struct iob_s *iob_alloc(bool throttled, enum iob_user_e consumerid); /**************************************************************************** * Name: iob_tryalloc @@ -185,7 +263,7 @@ FAR struct iob_s *iob_alloc(bool throttled); * ****************************************************************************/ -FAR struct iob_s *iob_tryalloc(bool throttled); +FAR struct iob_s *iob_tryalloc(bool throttled, enum iob_user_e consumerid); /**************************************************************************** * Name: iob_navail @@ -216,7 +294,8 @@ int iob_qentry_navail(void); * ****************************************************************************/ -FAR struct iob_s *iob_free(FAR struct iob_s *iob); +FAR struct iob_s *iob_free(FAR struct iob_s *iob, + enum iob_user_e producerid); /**************************************************************************** * Name: iob_notifier_setup @@ -281,7 +360,7 @@ int iob_notifier_teardown(int key); * ****************************************************************************/ -void iob_free_chain(FAR struct iob_s *iob); +void iob_free_chain(FAR struct iob_s *iob, enum iob_user_e producerid); /**************************************************************************** * Name: iob_add_queue @@ -352,7 +431,8 @@ FAR struct iob_s *iob_peek_queue(FAR struct iob_queue_s *iobq); ****************************************************************************/ #if CONFIG_IOB_NCHAINS > 0 -void iob_free_queue(FAR struct iob_queue_s *qhead); +void iob_free_queue(FAR struct iob_queue_s *qhead, + enum iob_user_e producerid); #endif /* CONFIG_IOB_NCHAINS > 0 */ /**************************************************************************** @@ -365,7 +445,8 @@ void iob_free_queue(FAR struct iob_queue_s *qhead); ****************************************************************************/ int iob_copyin(FAR struct iob_s *iob, FAR const uint8_t *src, - unsigned int len, unsigned int offset, bool throttled); + unsigned int len, unsigned int offset, bool throttled, + enum iob_user_e consumerid); /**************************************************************************** * Name: iob_trycopyin @@ -378,7 +459,8 @@ int iob_copyin(FAR struct iob_s *iob, FAR const uint8_t *src, ****************************************************************************/ int iob_trycopyin(FAR struct iob_s *iob, FAR const uint8_t *src, - unsigned int len, unsigned int offset, bool throttled); + unsigned int len, unsigned int offset, bool throttled, + enum iob_user_e consumerid); /**************************************************************************** * Name: iob_copyout @@ -400,7 +482,8 @@ int iob_copyout(FAR uint8_t *dest, FAR const struct iob_s *iob, * ****************************************************************************/ -int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled); +int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled, + enum iob_user_e consumerid); /**************************************************************************** * Name: iob_concat @@ -421,7 +504,8 @@ void iob_concat(FAR struct iob_s *iob1, FAR struct iob_s *iob2); * ****************************************************************************/ -FAR struct iob_s *iob_trimhead(FAR struct iob_s *iob, unsigned int trimlen); +FAR struct iob_s *iob_trimhead(FAR struct iob_s *iob, unsigned int trimlen, + enum iob_user_e producerid); /**************************************************************************** * Name: iob_trimhead_queue @@ -441,7 +525,8 @@ FAR struct iob_s *iob_trimhead(FAR struct iob_s *iob, unsigned int trimlen); #if CONFIG_IOB_NCHAINS > 0 FAR struct iob_s *iob_trimhead_queue(FAR struct iob_queue_s *qhead, - unsigned int trimlen); + unsigned int trimlen, + enum iob_user_e producerid); #endif /**************************************************************************** @@ -454,7 +539,8 @@ FAR struct iob_s *iob_trimhead_queue(FAR struct iob_queue_s *qhead, * ****************************************************************************/ -FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen); +FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen, + enum iob_user_e producerid); /**************************************************************************** * Name: iob_pack @@ -466,7 +552,8 @@ FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen); * ****************************************************************************/ -FAR struct iob_s *iob_pack(FAR struct iob_s *iob); +FAR struct iob_s *iob_pack(FAR struct iob_s *iob, + enum iob_user_e producerid); /**************************************************************************** * Name: iob_contig @@ -477,7 +564,8 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob); * ****************************************************************************/ -int iob_contig(FAR struct iob_s *iob, unsigned int len); +int iob_contig(FAR struct iob_s *iob, unsigned int len, + enum iob_user_e producerid); /**************************************************************************** * Name: iob_dump @@ -494,6 +582,25 @@ void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len, # define iob_dump(wrb) #endif +/**************************************************************************** + * Name: iob_getuserstats + * + * Description: + * Return a reference to the IOB usage statitics for the IOB consumer/producer + * + * Input Parameters: + * userid - id representing the IOB producer/consumer + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \ + !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) +FAR struct iob_userstats_s * iob_getuserstats(enum iob_user_e userid); +#endif + #endif /* CONFIG_MM_IOB */ #endif /* _INCLUDE_NUTTX_MM_IOB_H */ diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index 6ce11f4b7d0..3d467a7e4dd 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -50,6 +50,10 @@ #include #include +#ifdef CONFIG_MM_IOB +# include +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -394,8 +398,7 @@ int net_lockedwait(sem_t *sem); ****************************************************************************/ #ifdef CONFIG_MM_IOB -struct iob_s; /* Forward reference */ -FAR struct iob_s *net_ioballoc(bool throttled); +FAR struct iob_s *net_ioballoc(bool throttled, enum iob_user_e consumerid); #endif /**************************************************************************** diff --git a/mm/iob/Make.defs b/mm/iob/Make.defs index 7b4add3e1d0..a2747bace27 100644 --- a/mm/iob/Make.defs +++ b/mm/iob/Make.defs @@ -41,7 +41,7 @@ CSRCS += iob_add_queue.c iob_alloc.c iob_alloc_qentry.c iob_clone.c CSRCS += iob_concat.c iob_copyin.c iob_copyout.c iob_contig.c iob_free.c CSRCS += iob_free_chain.c iob_free_qentry.c iob_free_queue.c CSRCS += iob_initialize.c iob_pack.c iob_peek_queue.c iob_remove_queue.c -CSRCS += iob_trimhead.c iob_trimhead_queue.c iob_trimtail.c +CSRCS += iob_statistics.c iob_trimhead.c iob_trimhead_queue.c iob_trimtail.c CSRCS += iob_navail.c ifeq ($(CONFIG_IOB_NOTIFIER),y) diff --git a/mm/iob/iob.h b/mm/iob/iob.h index ad640d3037b..fb68e870f73 100644 --- a/mm/iob/iob.h +++ b/mm/iob/iob.h @@ -178,5 +178,45 @@ FAR struct iob_qentry_s *iob_free_qentry(FAR struct iob_qentry_s *iobq); void iob_notifier_signal(void); #endif +/**************************************************************************** + * Name: iob_stats_onalloc + * + * Description: + * An IOB has just been allocated for the consumer. This is a hook for the + * IOB statistics to be updated when /proc/iobinfo is enabled. + * + * Input Parameters: + * consumerid - id representing who is consuming the IOB + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \ + defined(CONFIG_MM_IOB) && !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) +void iob_stats_onalloc(enum iob_user_e consumerid); +#endif + +/**************************************************************************** + * Name: iob_stats_onfree + * + * Description: + * An IOB has just been freed by the producer. This is a hook for the + * IOB statistics to be updated when /proc/iobinfo is enabled. + * + * Input Parameters: + * consumerid - id representing who is consuming the IOB + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \ + defined(CONFIG_MM_IOB) && !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) +void iob_stats_onfree(enum iob_user_e producerid); +#endif + #endif /* CONFIG_MM_IOB */ #endif /* __MM_IOB_IOB_H */ diff --git a/mm/iob/iob_alloc.c b/mm/iob/iob_alloc.c index b662bb41f0a..d6f41403833 100644 --- a/mm/iob/iob_alloc.c +++ b/mm/iob/iob_alloc.c @@ -63,7 +63,7 @@ * ****************************************************************************/ -static FAR struct iob_s *iob_alloc_committed(void) +static FAR struct iob_s *iob_alloc_committed(enum iob_user_e consumerid) { FAR struct iob_s *iob = NULL; irqstate_t flags; @@ -89,6 +89,11 @@ static FAR struct iob_s *iob_alloc_committed(void) iob->io_len = 0; /* Length of the data in the entry */ iob->io_offset = 0; /* Offset to the beginning of data */ iob->io_pktlen = 0; /* Total length of the packet */ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \ + defined(CONFIG_MM_IOB) && !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) + iob_stats_onalloc(consumerid); +#endif } leave_critical_section(flags); @@ -104,7 +109,8 @@ static FAR struct iob_s *iob_alloc_committed(void) * ****************************************************************************/ -static FAR struct iob_s *iob_allocwait(bool throttled) +static FAR struct iob_s *iob_allocwait(bool throttled, + enum iob_user_e consumerid) { FAR struct iob_s *iob; irqstate_t flags; @@ -131,7 +137,7 @@ static FAR struct iob_s *iob_allocwait(bool throttled) * decremented atomically. */ - iob = iob_tryalloc(throttled); + iob = iob_tryalloc(throttled, consumerid); while (ret == OK && iob == NULL) { /* If not successful, then the semaphore count was less than or equal @@ -165,7 +171,7 @@ static FAR struct iob_s *iob_allocwait(bool throttled) * freed and we hold a count for one IOB. */ - iob = iob_alloc_committed(); + iob = iob_alloc_committed(consumerid); if (iob == NULL) { /* We need release our count so that it is available to @@ -175,8 +181,14 @@ static FAR struct iob_s *iob_allocwait(bool throttled) */ nxsem_post(sem); - iob = iob_tryalloc(throttled); + iob = iob_tryalloc(throttled, consumerid); } + + /* REVISIT: I think this logic should be moved inside of + * iob_alloc_committed, so that it can exist inside of the critical + * section along with all other sem count changes. + */ + #if CONFIG_IOB_THROTTLE > 0 else { @@ -209,7 +221,7 @@ static FAR struct iob_s *iob_allocwait(bool throttled) * ****************************************************************************/ -FAR struct iob_s *iob_alloc(bool throttled) +FAR struct iob_s *iob_alloc(bool throttled, enum iob_user_e consumerid) { /* Were we called from the interrupt level? */ @@ -217,13 +229,13 @@ FAR struct iob_s *iob_alloc(bool throttled) { /* Yes, then try to allocate an I/O buffer without waiting */ - return iob_tryalloc(throttled); + return iob_tryalloc(throttled, consumerid); } else { /* Then allocate an I/O buffer, waiting as necessary */ - return iob_allocwait(throttled); + return iob_allocwait(throttled, consumerid); } } @@ -236,7 +248,7 @@ FAR struct iob_s *iob_alloc(bool throttled) * ****************************************************************************/ -FAR struct iob_s *iob_tryalloc(bool throttled) +FAR struct iob_s *iob_tryalloc(bool throttled, enum iob_user_e consumerid) { FAR struct iob_s *iob; irqstate_t flags; @@ -292,6 +304,12 @@ FAR struct iob_s *iob_tryalloc(bool throttled) g_throttle_sem.semcount--; DEBUGASSERT(g_throttle_sem.semcount >= -CONFIG_IOB_THROTTLE); #endif + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \ + defined(CONFIG_MM_IOB) && !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) + iob_stats_onalloc(consumerid); +#endif + leave_critical_section(flags); /* Put the I/O buffer in a known state */ diff --git a/mm/iob/iob_clone.c b/mm/iob/iob_clone.c index 529de70bc6a..c5e0563ad7a 100644 --- a/mm/iob/iob_clone.c +++ b/mm/iob/iob_clone.c @@ -68,7 +68,8 @@ * ****************************************************************************/ -int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled) +int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled, + enum iob_user_e consumerid) { FAR uint8_t *src; FAR uint8_t *dest; @@ -158,7 +159,7 @@ int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled) * destination I/O buffer chain. */ - next = iob_alloc(throttled); + next = iob_alloc(throttled, consumerid); if (!next) { ioberr("ERROR: Failed to allocate an I/O buffer/n"); diff --git a/mm/iob/iob_contig.c b/mm/iob/iob_contig.c index 2e77127ed5e..25a404eb1dd 100644 --- a/mm/iob/iob_contig.c +++ b/mm/iob/iob_contig.c @@ -69,7 +69,8 @@ * ****************************************************************************/ -int iob_contig(FAR struct iob_s *iob, unsigned int len) +int iob_contig(FAR struct iob_s *iob, unsigned int len, + enum iob_user_e producerid) { FAR struct iob_s *next; unsigned int ncopy; @@ -134,7 +135,7 @@ int iob_contig(FAR struct iob_s *iob, unsigned int len) if (next->io_len == 0) { - iob->io_flink = iob_free(next); + iob->io_flink = iob_free(next, producerid); } } while (len > iob->io_len); diff --git a/mm/iob/iob_copyin.c b/mm/iob/iob_copyin.c index 02887f1b943..f4187274ebe 100644 --- a/mm/iob/iob_copyin.c +++ b/mm/iob/iob_copyin.c @@ -67,7 +67,8 @@ static int iob_copyin_internal(FAR struct iob_s *iob, FAR const uint8_t *src, unsigned int len, unsigned int offset, - bool throttled, bool can_block) + bool throttled, bool can_block, + enum iob_user_e consumerid) { FAR struct iob_s *head = iob; FAR struct iob_s *next; @@ -189,11 +190,11 @@ static int iob_copyin_internal(FAR struct iob_s *iob, FAR const uint8_t *src, if (can_block) { - next = iob_alloc(throttled); + next = iob_alloc(throttled, consumerid); } else { - next = iob_tryalloc(throttled); + next = iob_tryalloc(throttled, consumerid); } if (next == NULL) @@ -229,9 +230,10 @@ static int iob_copyin_internal(FAR struct iob_s *iob, FAR const uint8_t *src, ****************************************************************************/ int iob_copyin(FAR struct iob_s *iob, FAR const uint8_t *src, - unsigned int len, unsigned int offset, bool throttled) + unsigned int len, unsigned int offset, bool throttled, + enum iob_user_e consumerid) { - return iob_copyin_internal(iob, src, len, offset, throttled, true); + return iob_copyin_internal(iob, src, len, offset, throttled, true, consumerid); } /**************************************************************************** @@ -245,7 +247,8 @@ int iob_copyin(FAR struct iob_s *iob, FAR const uint8_t *src, ****************************************************************************/ int iob_trycopyin(FAR struct iob_s *iob, FAR const uint8_t *src, - unsigned int len, unsigned int offset, bool throttled) + unsigned int len, unsigned int offset, bool throttled, + enum iob_user_e consumerid) { - return iob_copyin_internal(iob, src, len, offset, throttled, false); + return iob_copyin_internal(iob, src, len, offset, throttled, false, consumerid); } diff --git a/mm/iob/iob_free.c b/mm/iob/iob_free.c index c288ec660a5..fdee7cfaa64 100644 --- a/mm/iob/iob_free.c +++ b/mm/iob/iob_free.c @@ -87,7 +87,8 @@ * ****************************************************************************/ -FAR struct iob_s *iob_free(FAR struct iob_s *iob) +FAR struct iob_s *iob_free(FAR struct iob_s *iob, + enum iob_user_e producerid) { FAR struct iob_s *next = iob->io_flink; irqstate_t flags; @@ -162,6 +163,11 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob) nxsem_post(&g_iob_sem); DEBUGASSERT(g_iob_sem.semcount <= CONFIG_IOB_NBUFFERS); +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \ + defined(CONFIG_MM_IOB) && !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) + iob_stats_onfree(producerid); +#endif + #if CONFIG_IOB_THROTTLE > 0 nxsem_post(&g_throttle_sem); DEBUGASSERT(g_throttle_sem.semcount <= (CONFIG_IOB_NBUFFERS - CONFIG_IOB_THROTTLE)); diff --git a/mm/iob/iob_free_chain.c b/mm/iob/iob_free_chain.c index d27a64dc155..264a1bb156c 100644 --- a/mm/iob/iob_free_chain.c +++ b/mm/iob/iob_free_chain.c @@ -57,7 +57,7 @@ * ****************************************************************************/ -void iob_free_chain(FAR struct iob_s *iob) +void iob_free_chain(FAR struct iob_s *iob, enum iob_user_e producerid) { FAR struct iob_s *next; @@ -65,6 +65,6 @@ void iob_free_chain(FAR struct iob_s *iob) for (; iob; iob = next) { - next = iob_free(iob); + next = iob_free(iob, producerid); } } diff --git a/mm/iob/iob_free_queue.c b/mm/iob/iob_free_queue.c index dc436230e8d..0bf14febdc6 100644 --- a/mm/iob/iob_free_queue.c +++ b/mm/iob/iob_free_queue.c @@ -67,7 +67,8 @@ * ****************************************************************************/ -void iob_free_queue(FAR struct iob_queue_s *qhead) +void iob_free_queue(FAR struct iob_queue_s *qhead, + enum iob_user_e producerid) { FAR struct iob_qentry_s *iobq; FAR struct iob_qentry_s *nextq; @@ -99,7 +100,7 @@ void iob_free_queue(FAR struct iob_queue_s *qhead) /* Free the I/O chain */ - iob_free_chain(iob); + iob_free_chain(iob, producerid); } } diff --git a/mm/iob/iob_pack.c b/mm/iob/iob_pack.c index 011652c99d5..b14dcb2e51e 100644 --- a/mm/iob/iob_pack.c +++ b/mm/iob/iob_pack.c @@ -59,7 +59,8 @@ * ****************************************************************************/ -FAR struct iob_s *iob_pack(FAR struct iob_s *iob) +FAR struct iob_s *iob_pack(FAR struct iob_s *iob, + enum iob_user_e producerid) { FAR struct iob_s *head; FAR struct iob_s *next; @@ -70,7 +71,7 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob) while (iob->io_len <= 0) { - iob = iob_free(iob); + iob = iob_free(iob, producerid); if (iob == NULL) { return NULL; @@ -132,7 +133,7 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob) { /* Yes.. free the next entry in I/O buffer chain */ - next = iob_free(next); + next = iob_free(next, producerid); iob->io_flink = next; } } diff --git a/mm/iob/iob_statistics.c b/mm/iob/iob_statistics.c new file mode 100644 index 00000000000..460331117e8 --- /dev/null +++ b/mm/iob/iob_statistics.c @@ -0,0 +1,136 @@ +/**************************************************************************** + * net/procfs/netdev_statistics.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Anthony Merlino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \ + !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +struct iob_userstats_s g_iobuserstats[IOBUSER_NENTRIES]; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: iob_stats_onalloc + * + * Description: + * An IOB has just been allocated for the consumer. This is a hook for the + * IOB statistics to be updated when /proc/iobinfo is enabled. + * + * Input Parameters: + * consumerid - id representing who is consuming the IOB + * + * Returned Value: + * None. + * + ****************************************************************************/ + +void iob_stats_onalloc(enum iob_user_e consumerid) +{ + DEBUGASSERT(consumerid < IOBUSER_NENTRIES); + g_iobuserstats[consumerid].totalconsumed++; + + /* Increment the global statistic as well */ + + g_iobuserstats[IOBUSER_GLOBAL].totalconsumed++; +} + +/**************************************************************************** + * Name: iob_stats_onfree + * + * Description: + * An IOB has just been freed by the producer. This is a hook for the + * IOB statistics to be updated when /proc/iobinfo is enabled. + * + * Input Parameters: + * consumerid - id representing who is consuming the IOB + * + * Returned Value: + * None. + * + ****************************************************************************/ + +void iob_stats_onfree(enum iob_user_e producerid) +{ + DEBUGASSERT(producerid < IOBUSER_NENTRIES); + g_iobuserstats[producerid].totalproduced++; + + /* Increment the global statistic as well */ + + g_iobuserstats[IOBUSER_GLOBAL].totalproduced++; + +} + +/**************************************************************************** + * Name: iob_getuserstats + * + * Description: + * Return a reference to the IOB usage statitics for the IOB consumer/producer + * + * Input Parameters: + * userid - id representing the IOB producer/consumer + * + * Returned Value: + * None. + * + ****************************************************************************/ + +FAR struct iob_userstats_s * iob_getuserstats(enum iob_user_e userid) +{ + DEBUGASSERT(userid < IOBUSER_NENTRIES); + return &g_iobuserstats[userid]; +} + +#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS && + * !CONFIG_FS_PROCFS_EXCLUDE_IOBINFO */ diff --git a/mm/iob/iob_test.c b/mm/iob/iob_test.c index b3b2ff9a453..87396307ab5 100644 --- a/mm/iob/iob_test.c +++ b/mm/iob/iob_test.c @@ -109,7 +109,7 @@ int main(int argc, char **argv) int i; iob_initialize(); - iob = iob_alloc(false); + iob = iob_alloc(false, IOBUSER_UNITTEST); for (i = 0; i < 4096; i++) { @@ -117,11 +117,11 @@ int main(int argc, char **argv) } memset(buffer2, 0xff, 4096); - iob_copyin(iob, buffer2, 47, 0, false); + iob_copyin(iob, buffer2, 47, 0, false, IOBUSER_UNITTEST); printf("Copy IN: 47, offset 0\n"); dump_chain(iob); - iob_copyin(iob, buffer1, 4096, 47, false); + iob_copyin(iob, buffer1, 4096, 47, false, IOBUSER_UNITTEST); printf("Copy IN: 4096, offset 47\n"); dump_chain(iob); @@ -133,11 +133,11 @@ int main(int argc, char **argv) fprintf(stderr, "Buffer1 does not match buffer2\n"); } - iob = iob_trimhead(iob, 47); + iob = iob_trimhead(iob, 47, IOBUSER_UNITTEST); printf("Trim: 47 from the beginning of the list\n"); dump_chain(iob); - iob = iob_trimtail(iob, 493); + iob = iob_trimtail(iob, 493, IOBUSER_UNITTEST); printf("Trim: 493 from the end of the list\n"); dump_chain(iob); @@ -149,7 +149,7 @@ int main(int argc, char **argv) fprintf(stderr, "Buffer1 does not match buffer2\n"); } - iob = iob_trimhead(iob, 1362); + iob = iob_trimhead(iob, 1362, IOBUSER_UNITTEST); printf("Trim: 1362 from the beginning of the list\n"); dump_chain(iob); @@ -161,7 +161,7 @@ int main(int argc, char **argv) fprintf(stderr, "Buffer1 does not match buffer2\n"); } - iob = iob_pack(iob); + iob = iob_pack(iob, IOBUSER_UNITTEST); printf("Packed\n"); dump_chain(iob); @@ -173,7 +173,7 @@ int main(int argc, char **argv) fprintf(stderr, "Buffer1 does not match buffer2\n"); } - while (iob) iob = iob_free(iob); + while (iob) iob = iob_free(iob, IOBUSER_UNITTEST); return EXIT_SUCCESS; } diff --git a/mm/iob/iob_trimhead.c b/mm/iob/iob_trimhead.c index 0373c5dd8fa..90865bfc0b2 100644 --- a/mm/iob/iob_trimhead.c +++ b/mm/iob/iob_trimhead.c @@ -67,7 +67,8 @@ * ****************************************************************************/ -FAR struct iob_s *iob_trimhead(FAR struct iob_s *iob, unsigned int trimlen) +FAR struct iob_s *iob_trimhead(FAR struct iob_s *iob, unsigned int trimlen, + enum iob_user_e producerid) { uint16_t pktlen; @@ -114,7 +115,7 @@ FAR struct iob_s *iob_trimhead(FAR struct iob_s *iob, unsigned int trimlen) /* Free this entry and set the next I/O buffer as the head */ iobinfo("iob=%p: Freeing\n", iob); - (void)iob_free(iob); + (void)iob_free(iob, producerid); iob = next; } else diff --git a/mm/iob/iob_trimhead_queue.c b/mm/iob/iob_trimhead_queue.c index 2177720da74..6b147429357 100644 --- a/mm/iob/iob_trimhead_queue.c +++ b/mm/iob/iob_trimhead_queue.c @@ -78,7 +78,8 @@ ****************************************************************************/ FAR struct iob_s *iob_trimhead_queue(FAR struct iob_queue_s *qhead, - unsigned int trimlen) + unsigned int trimlen, + enum iob_user_e producerid) { FAR struct iob_qentry_s *qentry; FAR struct iob_s *iob = NULL; @@ -95,7 +96,7 @@ FAR struct iob_s *iob_trimhead_queue(FAR struct iob_queue_s *qhead, { /* Trim the I/Buffer chain and update the queue head */ - iob = iob_trimhead(iob, trimlen); + iob = iob_trimhead(iob, trimlen, producerid); qentry->qe_head = iob; } } diff --git a/mm/iob/iob_trimtail.c b/mm/iob/iob_trimtail.c index 1e2804f4c5d..f1c7fa3c341 100644 --- a/mm/iob/iob_trimtail.c +++ b/mm/iob/iob_trimtail.c @@ -58,7 +58,8 @@ * ****************************************************************************/ -FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen) +FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen, + enum iob_user_e producerid) { FAR struct iob_s *entry; FAR struct iob_s *penultimate; @@ -105,7 +106,7 @@ FAR struct iob_s *iob_trimtail(FAR struct iob_s *iob, unsigned int trimlen) /* Free the last, empty buffer in the list */ - iob_free(last); + iob_free(last, producerid); /* There should be a buffer before this one */ diff --git a/net/bluetooth/bluetooth_conn.c b/net/bluetooth/bluetooth_conn.c index 501f9916f30..372cdbb9a87 100644 --- a/net/bluetooth/bluetooth_conn.c +++ b/net/bluetooth/bluetooth_conn.c @@ -182,7 +182,7 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn) if (container->bn_iob) { - iob_free(container->bn_iob); + iob_free(container->bn_iob, IOBUSER_NET_SOCK_BLUETOOTH); } /* And free the container itself */ diff --git a/net/bluetooth/bluetooth_input.c b/net/bluetooth/bluetooth_input.c index f19a9a88163..607ec38fff0 100644 --- a/net/bluetooth/bluetooth_input.c +++ b/net/bluetooth/bluetooth_input.c @@ -166,7 +166,7 @@ static int bluetooth_queue_frame(FAR struct bluetooth_conn_s *conn, /* Free both the IOB and the container */ - iob_free(container->bn_iob); + iob_free(container->bn_iob, IOBUSER_NET_SOCK_BLUETOOTH); bluetooth_container_free(container); } else @@ -267,7 +267,7 @@ int bluetooth_input(FAR struct radio_driver_s *radio, if (ret < 0) { nerr("ERROR: Failed to queue frame: %d\n", ret); - iob_free(frame); + iob_free(frame, IOBUSER_NET_SOCK_BLUETOOTH); } } diff --git a/net/bluetooth/bluetooth_recvfrom.c b/net/bluetooth/bluetooth_recvfrom.c index 4e3eecdd20b..90b79b52696 100644 --- a/net/bluetooth/bluetooth_recvfrom.c +++ b/net/bluetooth/bluetooth_recvfrom.c @@ -198,7 +198,7 @@ static ssize_t bluetooth_recvfrom_rxqueue(FAR struct radio_driver_s *radio, /* Free both the IOB and the container */ - iob_free(iob); + iob_free(iob, IOBUSER_NET_SOCK_BLUETOOTH); bluetooth_container_free(container); } diff --git a/net/bluetooth/bluetooth_sendto.c b/net/bluetooth/bluetooth_sendto.c index 49633ef9289..d87b62b59b2 100644 --- a/net/bluetooth/bluetooth_sendto.c +++ b/net/bluetooth/bluetooth_sendto.c @@ -159,7 +159,7 @@ static uint16_t bluetooth_sendto_eventhandler(FAR struct net_driver_s *dev, /* Allocate an IOB to hold the frame data */ - iob = net_ioballoc(false); + iob = net_ioballoc(false, IOBUSER_NET_SOCK_BLUETOOTH); if (iob == NULL) { nwarn("WARNING: Failed to allocate IOB\n"); diff --git a/net/icmp/icmp_input.c b/net/icmp/icmp_input.c index 246876bdfa8..50d95530261 100644 --- a/net/icmp/icmp_input.c +++ b/net/icmp/icmp_input.c @@ -112,7 +112,7 @@ static uint16_t icmp_datahandler(FAR struct net_driver_s *dev, * packet. */ - iob = iob_tryalloc(true); + iob = iob_tryalloc(true, IOBUSER_NET_SOCK_ICMP); if (iob == NULL) { nerr("ERROR: Failed to create new I/O buffer chain\n"); @@ -135,7 +135,8 @@ static uint16_t icmp_datahandler(FAR struct net_driver_s *dev, */ addrsize = sizeof(struct sockaddr_in); - ret = iob_trycopyin(iob, &addrsize, sizeof(uint8_t), 0, true); + ret = iob_trycopyin(iob, &addrsize, sizeof(uint8_t), 0, true, + IOBUSER_NET_SOCK_ICMP); if (ret < 0) { /* On a failure, iob_trycopyin return a negated error value but does @@ -149,7 +150,8 @@ static uint16_t icmp_datahandler(FAR struct net_driver_s *dev, offset = sizeof(uint8_t); ret = iob_trycopyin(iob, (FAR const uint8_t *)&inaddr, - sizeof(struct sockaddr_in), offset, true); + sizeof(struct sockaddr_in), offset, true, + IOBUSER_NET_SOCK_ICMP); if (ret < 0) { /* On a failure, iob_trycopyin return a negated error value but does @@ -165,7 +167,8 @@ static uint16_t icmp_datahandler(FAR struct net_driver_s *dev, /* Copy the new ICMP reply into the I/O buffer chain (without waiting) */ buflen = ICMPSIZE; - ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPBUF, buflen, offset, true); + ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPBUF, buflen, offset, true, + IOBUSER_NET_SOCK_ICMP); if (ret < 0) { /* On a failure, iob_copyin return a negated error value but does @@ -192,7 +195,7 @@ static uint16_t icmp_datahandler(FAR struct net_driver_s *dev, return buflen; drop_with_chain: - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_SOCK_ICMP); drop: dev->d_len = 0; diff --git a/net/icmp/icmp_recvfrom.c b/net/icmp/icmp_recvfrom.c index 4870ab277f7..c7c1f0ca51f 100644 --- a/net/icmp/icmp_recvfrom.c +++ b/net/icmp/icmp_recvfrom.c @@ -365,7 +365,7 @@ out: /* And free the I/O buffer chain */ - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_SOCK_ICMP); } return ret; @@ -541,7 +541,7 @@ errout: conn->nreqs = 0; conn->dev = NULL; - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_SOCK_ICMP); } return ret; diff --git a/net/icmp/icmp_sendto.c b/net/icmp/icmp_sendto.c index bbb1ced5be4..e5e94b81773 100644 --- a/net/icmp/icmp_sendto.c +++ b/net/icmp/icmp_sendto.c @@ -420,7 +420,7 @@ ssize_t icmp_sendto(FAR struct socket *psock, FAR const void *buf, size_t len, conn->nreqs = 0; conn->dev = NULL; - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_SOCK_ICMP); } #ifdef CONFIG_NET_ARP_SEND @@ -507,7 +507,7 @@ errout: conn->nreqs = 0; conn->dev = NULL; - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_SOCK_ICMP); return ret; } diff --git a/net/icmp/icmp_sockif.c b/net/icmp/icmp_sockif.c index 74a9450631c..47c1d4d91bb 100644 --- a/net/icmp/icmp_sockif.c +++ b/net/icmp/icmp_sockif.c @@ -527,7 +527,7 @@ static int icmp_close(FAR struct socket *psock) { /* Yes... free any read-ahead data */ - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_SOCK_ICMP); /* Then free the connection structure */ diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index fec38b977ff..b396804c72e 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -122,7 +122,7 @@ static uint16_t icmpv6_datahandler(FAR struct net_driver_s *dev, * packet. */ - iob = iob_tryalloc(true); + iob = iob_tryalloc(true, IOBUSER_NET_SOCK_ICMPv6); if (iob == NULL) { nerr("ERROR: Failed to create new I/O buffer chain\n"); @@ -142,7 +142,8 @@ static uint16_t icmpv6_datahandler(FAR struct net_driver_s *dev, */ addrsize = sizeof(struct sockaddr_in6); - ret = iob_trycopyin(iob, &addrsize, sizeof(uint8_t), 0, true); + ret = iob_trycopyin(iob, &addrsize, sizeof(uint8_t), 0, true, + IOBUSER_NET_SOCK_ICMPv6); if (ret < 0) { /* On a failure, iob_trycopyin return a negated error value but does @@ -156,7 +157,8 @@ static uint16_t icmpv6_datahandler(FAR struct net_driver_s *dev, offset = sizeof(uint8_t); ret = iob_trycopyin(iob, (FAR const uint8_t *)&inaddr, - sizeof(struct sockaddr_in6), offset, true); + sizeof(struct sockaddr_in6), offset, true, + IOBUSER_NET_SOCK_ICMPv6); if (ret < 0) { /* On a failure, iob_trycopyin return a negated error value but does @@ -174,7 +176,8 @@ static uint16_t icmpv6_datahandler(FAR struct net_driver_s *dev, buflen = ICMPv6SIZE; icmpv6 = ICMPv6BUF; - ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPv6REPLY, buflen, offset, true); + ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPv6REPLY, buflen, offset, true, + IOBUSER_NET_SOCK_ICMPv6); if (ret < 0) { /* On a failure, iob_copyin return a negated error value but does @@ -201,7 +204,7 @@ static uint16_t icmpv6_datahandler(FAR struct net_driver_s *dev, return buflen; drop_with_chain: - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_SOCK_ICMPv6); drop: dev->d_len = 0; diff --git a/net/icmpv6/icmpv6_recvfrom.c b/net/icmpv6/icmpv6_recvfrom.c index 26b4533995d..5bf5d56f368 100644 --- a/net/icmpv6/icmpv6_recvfrom.c +++ b/net/icmpv6/icmpv6_recvfrom.c @@ -372,7 +372,7 @@ out: /* And free the I/O buffer chain */ - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_SOCK_ICMPv6); } return ret; @@ -552,7 +552,7 @@ errout: conn->nreqs = 0; conn->dev = NULL; - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_SOCK_ICMPv6); } return ret; diff --git a/net/icmpv6/icmpv6_sendto.c b/net/icmpv6/icmpv6_sendto.c index dc4b8cc7e74..f682304d36e 100644 --- a/net/icmpv6/icmpv6_sendto.c +++ b/net/icmpv6/icmpv6_sendto.c @@ -412,7 +412,7 @@ ssize_t icmpv6_sendto(FAR struct socket *psock, FAR const void *buf, size_t len, conn->nreqs = 0; conn->dev = NULL; - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_SOCK_ICMPv6); } #ifdef CONFIG_NET_ICMPv6_NEIGHBOR @@ -501,7 +501,7 @@ errout: conn->nreqs = 0; conn->dev = NULL; - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_SOCK_ICMPv6); return ret; } diff --git a/net/icmpv6/icmpv6_sockif.c b/net/icmpv6/icmpv6_sockif.c index b163eeb82d7..1a21749b43c 100644 --- a/net/icmpv6/icmpv6_sockif.c +++ b/net/icmpv6/icmpv6_sockif.c @@ -527,7 +527,7 @@ static int icmpv6_close(FAR struct socket *psock) { /* Yes... free any read-ahead data */ - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_SOCK_ICMPv6); /* Then free the connection structure */ diff --git a/net/ieee802154/ieee802154_conn.c b/net/ieee802154/ieee802154_conn.c index 924f0f9e93d..4ae52f505f6 100644 --- a/net/ieee802154/ieee802154_conn.c +++ b/net/ieee802154/ieee802154_conn.c @@ -176,7 +176,7 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn) if (container->ic_iob) { - iob_free(container->ic_iob); + iob_free(container->ic_iob, IOBUSER_NET_SOCK_IEEE802154); } /* And free the container itself */ diff --git a/net/ieee802154/ieee802154_input.c b/net/ieee802154/ieee802154_input.c index 1baec513e4e..945ec0f4feb 100644 --- a/net/ieee802154/ieee802154_input.c +++ b/net/ieee802154/ieee802154_input.c @@ -177,7 +177,7 @@ static int ieee802154_queue_frame(FAR struct ieee802154_conn_s *conn, /* Free both the IOB and the container */ iob_free(container->ic_iob); - ieee802154_container_free(container); + ieee802154_container_free(container, IOBUSER_NET_SOCK_IEEE802154); } else { @@ -277,7 +277,7 @@ int ieee802154_input(FAR struct radio_driver_s *radio, if (ret < 0) { nerr("ERROR: Failed to queue frame: %d\n", ret); - iob_free(frame); + iob_free(frame, IOBUSER_NET_SOCK_IEEE802154); } } diff --git a/net/ieee802154/ieee802154_recvfrom.c b/net/ieee802154/ieee802154_recvfrom.c index e7a780273f6..8d3367c33f4 100644 --- a/net/ieee802154/ieee802154_recvfrom.c +++ b/net/ieee802154/ieee802154_recvfrom.c @@ -195,7 +195,7 @@ static ssize_t ieee802154_recvfrom_rxqueue(FAR struct radio_driver_s *radio, /* Free both the IOB and the container */ - iob_free(iob); + iob_free(iob, IOBUSER_NET_SOCK_IEEE802154); ieee802154_container_free(container); } diff --git a/net/ieee802154/ieee802154_sendto.c b/net/ieee802154/ieee802154_sendto.c index a6e381552ad..e57d52e7596 100644 --- a/net/ieee802154/ieee802154_sendto.c +++ b/net/ieee802154/ieee802154_sendto.c @@ -347,7 +347,7 @@ static uint16_t ieee802154_sendto_eventhandler(FAR struct net_driver_s *dev, /* Allocate an IOB to hold the frame data */ - iob = net_ioballoc(false); + iob = net_ioballoc(false, IOBUSER_NET_SOCK_IEEE802154); if (iob == NULL) { nwarn("WARNING: Failed to allocate IOB\n"); diff --git a/net/inet/inet_recvfrom.c b/net/inet/inet_recvfrom.c index 310c5109153..0d379d5eca6 100644 --- a/net/inet/inet_recvfrom.c +++ b/net/inet/inet_recvfrom.c @@ -359,7 +359,7 @@ static inline void inet_tcp_readahead(struct inet_recvfrom_s *pstate) /* And free the I/O buffer chain */ - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_TCP_READAHEAD); } else { @@ -368,7 +368,8 @@ static inline void inet_tcp_readahead(struct inet_recvfrom_s *pstate) * buffer queue). */ - (void)iob_trimhead_queue(&conn->readahead, recvlen); + (void)iob_trimhead_queue(&conn->readahead, recvlen, + IOBUSER_NET_TCP_READAHEAD); } } } @@ -457,7 +458,7 @@ out: /* And free the I/O buffer chain */ - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_UDP_READAHEAD); } } #endif diff --git a/net/ipforward/ipfwd_forward.c b/net/ipforward/ipfwd_forward.c index 6fd9b65edbb..771b45cbab5 100644 --- a/net/ipforward/ipfwd_forward.c +++ b/net/ipforward/ipfwd_forward.c @@ -290,7 +290,7 @@ static uint16_t ipfwd_eventhandler(FAR struct net_driver_s *dev, FAR void *conn, if (fwd->f_iob != NULL) { - iob_free_chain(fwd->f_iob); + iob_free_chain(fwd->f_iob, IOBUSER_NET_IPFORWARD); } /* And release the forwarding state structure */ diff --git a/net/ipforward/ipv4_forward.c b/net/ipforward/ipv4_forward.c index a6ae056642d..ce9dd16af68 100644 --- a/net/ipforward/ipv4_forward.c +++ b/net/ipforward/ipv4_forward.c @@ -273,7 +273,7 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, * where waiting for an IOB is a good idea */ - fwd->f_iob = iob_tryalloc(false); + fwd->f_iob = iob_tryalloc(false, IOBUSER_NET_IPFORWARD); if (fwd->f_iob == NULL) { nwarn("WARNING: iob_tryalloc() failed\n"); @@ -291,7 +291,7 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, */ ret = iob_trycopyin(fwd->f_iob, (FAR const uint8_t *)ipv4, - dev->d_len, 0, false); + dev->d_len, 0, false, IOBUSER_NET_IPFORWARD); if (ret < 0) { nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); @@ -323,7 +323,7 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, errout_with_iobchain: if (fwd != NULL && fwd->f_iob != NULL) { - iob_free_chain(fwd->f_iob); + iob_free_chain(fwd->f_iob, IOBUSER_NET_IPFORWARD); } errout_with_fwd: diff --git a/net/ipforward/ipv6_forward.c b/net/ipforward/ipv6_forward.c index f59e88e5cf9..61daba254d9 100644 --- a/net/ipforward/ipv6_forward.c +++ b/net/ipforward/ipv6_forward.c @@ -423,7 +423,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, * waiting for an IOB is a good idea */ - fwd->f_iob = iob_tryalloc(false); + fwd->f_iob = iob_tryalloc(false, IOBUSER_NET_IPFORWARD); if (fwd->f_iob == NULL) { nwarn("WARNING: iob_tryalloc() failed\n"); @@ -441,7 +441,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, */ ret = iob_trycopyin(fwd->f_iob, (FAR const uint8_t *)ipv6, - dev->d_len, 0, false); + dev->d_len, 0, false, IOBUSER_NET_IPFORWARD); if (ret < 0) { nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); @@ -474,7 +474,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, errout_with_iobchain: if (fwd != NULL && fwd->f_iob != NULL) { - iob_free_chain(fwd->f_iob); + iob_free_chain(fwd->f_iob, IOBUSER_NET_IPFORWARD); } errout_with_fwd: diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index f88e258206f..07670c89a2f 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -410,7 +410,7 @@ int sixlowpan_queue_frames(FAR struct radio_driver_s *radio, * necessary. */ - iob = net_ioballoc(false); + iob = net_ioballoc(false, IOBUSER_NET_6LOWPAN); DEBUGASSERT(iob != NULL); /* Initialize the IOB */ @@ -634,7 +634,7 @@ int sixlowpan_queue_frames(FAR struct radio_driver_s *radio, * necessary. */ - iob = net_ioballoc(false); + iob = net_ioballoc(false, IOBUSER_NET_6LOWPAN); DEBUGASSERT(iob != NULL); /* Initialize the IOB */ diff --git a/net/sixlowpan/sixlowpan_input.c b/net/sixlowpan/sixlowpan_input.c index 00f0845723f..099cdb1c70f 100644 --- a/net/sixlowpan/sixlowpan_input.c +++ b/net/sixlowpan/sixlowpan_input.c @@ -752,7 +752,7 @@ int sixlowpan_input(FAR struct radio_driver_s *radio, if (ret >= 0) { - iob_free(iob); + iob_free(iob, IOBUSER_NET_6LOWPAN); } /* Was the frame successfully processed? Is the packet in d_buf fully diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 2350ac40202..67f668b32fe 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -88,12 +88,15 @@ # define TCP_WBIOB(wrb) ((wrb)->wb_iob) # define TCP_WBCOPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0)) # define TCP_WBCOPYIN(wrb,src,n) \ - (iob_copyin((wrb)->wb_iob,src,(n),0,false)) + (iob_copyin((wrb)->wb_iob,src,(n),0,false,\ + IOBUSER_NET_TCP_WRITEBUFFER)) # define TCP_WBTRYCOPYIN(wrb,src,n) \ - (iob_trycopyin((wrb)->wb_iob,src,(n),0,false)) + (iob_trycopyin((wrb)->wb_iob,src,(n),0,false,\ + IOBUSER_NET_TCP_WRITEBUFFER)) # define TCP_WBTRIM(wrb,n) \ - do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0) + do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n),\ + IOBUSER_NET_TCP_WRITEBUFFER); } while (0) #ifdef CONFIG_DEBUG_FEATURES # define TCP_WBDUMP(msg,wrb,len,offset) \ diff --git a/net/tcp/tcp_callback.c b/net/tcp/tcp_callback.c index e72876fce4c..d04a2c93b42 100644 --- a/net/tcp/tcp_callback.c +++ b/net/tcp/tcp_callback.c @@ -253,7 +253,7 @@ uint16_t tcp_datahandler(FAR struct tcp_conn_s *conn, FAR uint8_t *buffer, * packet. */ - iob = iob_tryalloc(true); + iob = iob_tryalloc(true, IOBUSER_NET_TCP_READAHEAD); if (iob == NULL) { nerr("ERROR: Failed to create new I/O buffer chain\n"); @@ -262,7 +262,8 @@ uint16_t tcp_datahandler(FAR struct tcp_conn_s *conn, FAR uint8_t *buffer, /* Copy the new appdata into the I/O buffer chain (without waiting) */ - ret = iob_trycopyin(iob, buffer, buflen, 0, true); + ret = iob_trycopyin(iob, buffer, buflen, 0, true, + IOBUSER_NET_TCP_READAHEAD); if (ret < 0) { /* On a failure, iob_copyin return a negated error value but does @@ -270,7 +271,7 @@ uint16_t tcp_datahandler(FAR struct tcp_conn_s *conn, FAR uint8_t *buffer, */ nerr("ERROR: Failed to add data to the I/O buffer chain: %d\n", ret); - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_TCP_READAHEAD); return 0; } @@ -282,7 +283,7 @@ uint16_t tcp_datahandler(FAR struct tcp_conn_s *conn, FAR uint8_t *buffer, if (ret < 0) { nerr("ERROR: Failed to queue the I/O buffer chain: %d\n", ret); - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_TCP_READAHEAD); return 0; } diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index 1b0be8e8293..115176f3152 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -778,7 +778,7 @@ void tcp_free(FAR struct tcp_conn_s *conn) #ifdef CONFIG_NET_TCP_READAHEAD /* Release any read-ahead buffers attached to the connection */ - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_TCP_READAHEAD); #endif #ifdef CONFIG_NET_TCP_WRITE_BUFFERS diff --git a/net/tcp/tcp_wrbuffer.c b/net/tcp/tcp_wrbuffer.c index 8f600fb3725..285d13e2681 100644 --- a/net/tcp/tcp_wrbuffer.c +++ b/net/tcp/tcp_wrbuffer.c @@ -161,7 +161,7 @@ FAR struct tcp_wrbuffer_s *tcp_wrbuffer_alloc(void) /* Now get the first I/O buffer for the write buffer structure */ - wrb->wb_iob = net_ioballoc(false); + wrb->wb_iob = net_ioballoc(false, IOBUSER_NET_TCP_WRITEBUFFER); /* Did we get an IOB? We should always get one except under some really * weird error conditions. @@ -226,7 +226,7 @@ FAR struct tcp_wrbuffer_s *tcp_wrbuffer_tryalloc(void) /* Now get the first I/O buffer for the write buffer structure */ - wrb->wb_iob = iob_tryalloc(false); + wrb->wb_iob = iob_tryalloc(false, IOBUSER_NET_TCP_WRITEBUFFER); if (!wrb->wb_iob) { nerr("ERROR: Failed to allocate I/O buffer\n"); @@ -260,7 +260,7 @@ void tcp_wrbuffer_release(FAR struct tcp_wrbuffer_s *wrb) if (wrb->wb_iob != NULL) { - iob_free_chain(wrb->wb_iob); + iob_free_chain(wrb->wb_iob, IOBUSER_NET_TCP_WRITEBUFFER); } /* Then free the write buffer structure */ diff --git a/net/udp/udp_callback.c b/net/udp/udp_callback.c index 743839cb9a2..2f11037dc8e 100644 --- a/net/udp/udp_callback.c +++ b/net/udp/udp_callback.c @@ -100,7 +100,7 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con * We will not wait for an I/O buffer to become available in this context. */ - iob = iob_tryalloc(true); + iob = iob_tryalloc(true, IOBUSER_NET_UDP_READAHEAD); if (iob == NULL) { nerr("ERROR: Failed to create new I/O buffer chain\n"); @@ -176,7 +176,7 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con */ ret = iob_trycopyin(iob, (FAR const uint8_t *)&src_addr_size, - sizeof(uint8_t), 0, true); + sizeof(uint8_t), 0, true, IOBUSER_NET_UDP_READAHEAD); if (ret < 0) { /* On a failure, iob_trycopyin return a negated error value but does @@ -184,12 +184,12 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con */ nerr("ERROR: Failed to add data to the I/O buffer chain: %d\n", ret); - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_UDP_READAHEAD); return 0; } ret = iob_trycopyin(iob, (FAR const uint8_t *)src_addr, src_addr_size, - sizeof(uint8_t), true); + sizeof(uint8_t), true, IOBUSER_NET_UDP_READAHEAD); if (ret < 0) { /* On a failure, iob_trycopyin return a negated error value but does @@ -197,7 +197,7 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con */ nerr("ERROR: Failed to add data to the I/O buffer chain: %d\n", ret); - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_UDP_READAHEAD); return 0; } @@ -206,7 +206,8 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con /* Copy the new appdata into the I/O buffer chain */ ret = iob_trycopyin(iob, buffer, buflen, - src_addr_size + sizeof(uint8_t), true); + src_addr_size + sizeof(uint8_t), true, + IOBUSER_NET_UDP_READAHEAD); if (ret < 0) { /* On a failure, iob_trycopyin return a negated error value but @@ -215,7 +216,7 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con nerr("ERROR: Failed to add data to the I/O buffer chain: %d\n", ret); - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_UDP_READAHEAD); return 0; } } @@ -226,7 +227,7 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con if (ret < 0) { nerr("ERROR: Failed to queue the I/O buffer chain: %d\n", ret); - (void)iob_free_chain(iob); + (void)iob_free_chain(iob, IOBUSER_NET_UDP_READAHEAD); return 0; } diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index f8dec4b1a83..acaf5a89b1c 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -633,7 +633,7 @@ void udp_free(FAR struct udp_conn_s *conn) #ifdef CONFIG_NET_UDP_READAHEAD /* Release any read-ahead buffers attached to the connection */ - iob_free_queue(&conn->readahead); + iob_free_queue(&conn->readahead, IOBUSER_NET_UDP_READAHEAD); #endif #ifdef CONFIG_NET_UDP_WRITE_BUFFERS diff --git a/net/udp/udp_psock_sendto_buffered.c b/net/udp/udp_psock_sendto_buffered.c index f95467a5750..369b63bb056 100644 --- a/net/udp/udp_psock_sendto_buffered.c +++ b/net/udp/udp_psock_sendto_buffered.c @@ -827,11 +827,13 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, if (_SS_ISNONBLOCK(psock->s_flags)) { - ret = iob_trycopyin(wrb->wb_iob, (FAR uint8_t *)buf, len, 0, false); + ret = iob_trycopyin(wrb->wb_iob, (FAR uint8_t *)buf, len, 0, false, + IOBUSER_NET_SOCK_UDP); } else { - ret = iob_copyin(wrb->wb_iob, (FAR uint8_t *)buf, len, 0, false); + ret = iob_copyin(wrb->wb_iob, (FAR uint8_t *)buf, len, 0, false, + IOBUSER_NET_SOCK_UDP); } if (ret < 0) diff --git a/net/udp/udp_wrbuffer.c b/net/udp/udp_wrbuffer.c index 987db2044a6..399da0de7ea 100644 --- a/net/udp/udp_wrbuffer.c +++ b/net/udp/udp_wrbuffer.c @@ -158,7 +158,7 @@ FAR struct udp_wrbuffer_s *udp_wrbuffer_alloc(void) /* Now get the first I/O buffer for the write buffer structure */ - wrb->wb_iob = net_ioballoc(false); + wrb->wb_iob = net_ioballoc(false, IOBUSER_NET_UDP_WRITEBUFFER); if (!wrb->wb_iob) { nerr("ERROR: Failed to allocate I/O buffer\n"); @@ -190,7 +190,7 @@ void udp_wrbuffer_release(FAR struct udp_wrbuffer_s *wrb) * buffer chain first, then the write buffer structure. */ - iob_free_chain(wrb->wb_iob); + iob_free_chain(wrb->wb_iob, IOBUSER_NET_UDP_WRITEBUFFER); /* Then free the write buffer structure */ diff --git a/net/utils/net_lock.c b/net/utils/net_lock.c index 0b5146a0f5d..2b372f407e8 100644 --- a/net/utils/net_lock.c +++ b/net/utils/net_lock.c @@ -392,11 +392,11 @@ int net_lockedwait(sem_t *sem) ****************************************************************************/ #ifdef CONFIG_MM_IOB -FAR struct iob_s *net_ioballoc(bool throttled) +FAR struct iob_s *net_ioballoc(bool throttled, enum iob_user_e consumerid) { FAR struct iob_s *iob; - iob = iob_tryalloc(throttled); + iob = iob_tryalloc(throttled, consumerid); if (iob == NULL) { irqstate_t flags; @@ -409,7 +409,7 @@ FAR struct iob_s *net_ioballoc(bool throttled) flags = enter_critical_section(); blresult = net_breaklock(&count); - iob = iob_alloc(throttled); + iob = iob_alloc(throttled, consumerid); if (blresult >= 0) { net_restorelock(count); diff --git a/wireless/bluetooth/bt_buf.c b/wireless/bluetooth/bt_buf.c index a67b286aad3..e5ba9c05250 100644 --- a/wireless/bluetooth/bt_buf.c +++ b/wireless/bluetooth/bt_buf.c @@ -348,7 +348,7 @@ FAR struct bt_buf_s *bt_buf_alloc(enum bt_buf_type_e type, * available buffers. */ - buf->frame = iob_alloc(false); + buf->frame = iob_alloc(false, IOBUSER_WIRELESS_BLUETOOTH); if (!buf->frame) { wlerr("ERROR: Failed to allocate an IOB\n"); @@ -407,7 +407,7 @@ void bt_buf_release(FAR struct bt_buf_s *buf) if (buf->frame != NULL) { - iob_free(buf->frame); + iob_free(buf->frame, IOBUSER_WIRELESS_BLUETOOTH); buf->frame = NULL; } diff --git a/wireless/bluetooth/bt_netdev.c b/wireless/bluetooth/bt_netdev.c index 6ba24f42f6e..3f9536673b8 100644 --- a/wireless/bluetooth/bt_netdev.c +++ b/wireless/bluetooth/bt_netdev.c @@ -420,7 +420,7 @@ drop: if (ret < 0) { - iob_free(frame); + iob_free(frame, IOBUSER_WIRELESS_BLUETOOTH); /* Increment statistics */ diff --git a/wireless/ieee802154/mac802154.c b/wireless/ieee802154/mac802154.c index a5f65757f65..f05489947f8 100644 --- a/wireless/ieee802154/mac802154.c +++ b/wireless/ieee802154/mac802154.c @@ -262,7 +262,7 @@ void mac802154_createdatareq(FAR struct ieee802154_privmac_s *priv, /* Allocate an IOB to put the frame in */ - iob = iob_alloc(false); + iob = iob_alloc(false, IOBUSER_WIRELESS_MAC802154); DEBUGASSERT(iob != NULL); iob->io_flink = NULL; @@ -437,7 +437,8 @@ static void mac802154_notify_worker(FAR void *arg) if (dispose) { - iob_free(primitive->u.dataind.frame); + iob_free(primitive->u.dataind.frame, + IOBUSER_WIRELESS_MAC802154); ieee802154_primitive_free(primitive); } } @@ -768,7 +769,7 @@ static void mac802154_purge_worker(FAR void *arg) /* Free the IOB, the notification, and the tx descriptor */ - iob_free(txdesc->frame); + iob_free(txdesc->frame, IOBUSER_WIRELESS_MAC802154); ieee802154_primitive_free((FAR struct ieee802154_primitive_s *) txdesc->conf); mac802154_txdesc_free(priv, txdesc); @@ -1009,7 +1010,7 @@ static void mac802154_txdone_worker(FAR void *arg) /* Free the IOB and the tx descriptor */ - iob_free(txdesc->frame); + iob_free(txdesc->frame, IOBUSER_WIRELESS_MAC802154); mac802154_txdesc_free(priv, txdesc); } @@ -1547,7 +1548,7 @@ static void mac802154_rxdatareq(FAR struct ieee802154_privmac_s *priv, /* Allocate an IOB to put the frame in */ - iob = iob_alloc(false); + iob = iob_alloc(false, IOBUSER_WIRELESS_MAC802154); DEBUGASSERT(iob != NULL); iob->io_flink = NULL; diff --git a/wireless/ieee802154/mac802154_assoc.c b/wireless/ieee802154/mac802154_assoc.c index 6e09bf22e9c..9f71db29c8d 100644 --- a/wireless/ieee802154/mac802154_assoc.c +++ b/wireless/ieee802154/mac802154_assoc.c @@ -146,7 +146,7 @@ int mac802154_req_associate(MACHANDLE mac, /* Allocate an IOB to put the frame in */ - iob = iob_alloc(false); + iob = iob_alloc(false, IOBUSER_WIRELESS_MAC802154); DEBUGASSERT(iob != NULL); iob->io_flink = NULL; @@ -159,7 +159,7 @@ int mac802154_req_associate(MACHANDLE mac, ret = mac802154_txdesc_alloc(priv, &txdesc, true); if (ret < 0) { - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_MAC802154); mac802154_unlock(priv) mac802154_givesem(&priv->opsem); return ret; @@ -333,7 +333,7 @@ int mac802154_resp_associate(MACHANDLE mac, /* Allocate an IOB to put the frame in */ - iob = iob_alloc(false); + iob = iob_alloc(false, IOBUSER_WIRELESS_MAC802154); DEBUGASSERT(iob != NULL); iob->io_flink = NULL; @@ -407,7 +407,7 @@ int mac802154_resp_associate(MACHANDLE mac, ret = mac802154_lock(priv, true); if (ret < 0) { - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_MAC802154); return ret; } @@ -416,7 +416,7 @@ int mac802154_resp_associate(MACHANDLE mac, ret = mac802154_txdesc_alloc(priv, &txdesc, true); if (ret < 0) { - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_MAC802154); mac802154_unlock(priv) return ret; } diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index 63aef4c5031..861b751dbb6 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -496,7 +496,7 @@ static ssize_t mac802154dev_read(FAR struct file *filep, FAR char *buffer, /* Free the IOB */ - iob_free(ind->frame); + iob_free(ind->frame, IOBUSER_WIRELESS_MAC802154_CHARDEV); /* Deallocate the data indication */ @@ -542,7 +542,7 @@ static ssize_t mac802154dev_write(FAR struct file *filep, /* Allocate an IOB to put the frame in */ - iob = iob_alloc(false); + iob = iob_alloc(false, IOBUSER_WIRELESS_MAC802154_CHARDEV); DEBUGASSERT(iob != NULL); iob->io_flink = NULL; @@ -571,7 +571,7 @@ static ssize_t mac802154dev_write(FAR struct file *filep, ret = mac802154_req_data(dev->md_mac, &tx->meta, iob); if (ret < 0) { - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_MAC802154_CHARDEV); wlerr("ERROR: req_data failed %d\n", ret); return ret; } diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index 2c4191e6c80..98eea0d0e23 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -1213,13 +1213,13 @@ static int macnet_req_data(FAR struct radio_driver_s *netdev, { wlerr("ERROR: mac802154_req_data failed: %d\n", ret); - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_MAC802154_NETDEV); for (iob = framelist; iob != NULL; iob = framelist) { /* Remove the IOB from the queue and free */ framelist = iob->io_flink; - iob_free(iob); + iob_free(iob, IOBUSER_WIRELESS_MAC802154_NETDEV); } NETDEV_TXERRORS(&priv->md_dev.r_dev);