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 <gnutt@nuttx.org>
This commit is contained in:
parent
f5f302cff5
commit
70404ed0dc
64 changed files with 945 additions and 170 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
426
fs/procfs/fs_procfsiobinfo.c
Normal file
426
fs/procfs/fs_procfsiobinfo.c
Normal file
|
@ -0,0 +1,426 @@
|
|||
/****************************************************************************
|
||||
* fs/procfs/fs_procfsiobinfo.c
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/pgalloc.h>
|
||||
#include <nuttx/progmem.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/procfs.h>
|
||||
|
||||
#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 */
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
#include <stdarg.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#ifdef CONFIG_MM_IOB
|
||||
# include <nuttx/mm/iob.h>
|
||||
#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
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -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)
|
||||
|
|
40
mm/iob/iob.h
40
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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
136
mm/iob/iob_statistics.c
Normal file
136
mm/iob/iob_statistics.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
/****************************************************************************
|
||||
* net/procfs/netdev_statistics.c
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeeaero.com>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <debug.h>
|
||||
|
||||
#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 */
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) \
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -420,7 +420,7 @@ drop:
|
|||
|
||||
if (ret < 0)
|
||||
{
|
||||
iob_free(frame);
|
||||
iob_free(frame, IOBUSER_WIRELESS_BLUETOOTH);
|
||||
|
||||
/* Increment statistics */
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue