From 30834721df2c7dab6061b792bb003b950455a852 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 20 Nov 2015 17:53:03 -0600 Subject: [PATCH 01/17] Trivial changes for compliance with coding standard --- arch/arm/src/stm32/stm32_tim_lowerhalf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/src/stm32/stm32_tim_lowerhalf.c b/arch/arm/src/stm32/stm32_tim_lowerhalf.c index 75a1835c57f..fc759beeb12 100644 --- a/arch/arm/src/stm32/stm32_tim_lowerhalf.c +++ b/arch/arm/src/stm32/stm32_tim_lowerhalf.c @@ -519,12 +519,13 @@ static int stm32_tim14_interrupt(int irq, FAR void *context) static int stm32_timer_handler(struct stm32_lowerhalf_s *lower) { + uint32_t next_interval_us = 0; + bool ret; + STM32_TIM_ACKINT(lower->tim, 0); - uint32_t next_interval_us = 0; - bool ret = (*lower->handlerUsr)(&next_interval_us); - - if (ret == true) + ret = (*lower->handlerUsr)(&next_interval_us); + if (ret) { if (next_interval_us > 0) { From 9f98dfecb7e99eee329e1b0b7abd25c53bf392e4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 23 Nov 2015 11:59:33 -0600 Subject: [PATCH 02/17] sim: Eliminate a warning --- arch/sim/src/up_createstack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sim/src/up_createstack.c b/arch/sim/src/up_createstack.c index 72e50921bee..3e998090c12 100644 --- a/arch/sim/src/up_createstack.c +++ b/arch/sim/src/up_createstack.c @@ -102,7 +102,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) /* Move up to next even word boundary if necessary */ - size_t adj_stack_size = (stack_size + 3) & ~3; + size_t adj_stack_size = (stack_size + 3) & ~3; size_t adj_stack_words = adj_stack_size >> 2; /* Allocate the memory for the stack */ @@ -115,7 +115,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { /* This is the address of the last word in the allocation */ - size_t *adj_stack_ptr = &stack_alloc_ptr[adj_stack_words - 1]; + void *adj_stack_ptr = &stack_alloc_ptr[adj_stack_words - 1]; /* Save the values in the TCB */ From 076b05b460af84b1b456e588a44da5c0660832e7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 23 Nov 2015 12:16:35 -0600 Subject: [PATCH 03/17] In Kconfig of all CPUs with 16-bit address, force CONFIG_MM_SMALL=y --- arch/avr/Kconfig | 2 ++ arch/hc/Kconfig | 1 + arch/sh/Kconfig | 1 + arch/z80/Kconfig | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/arch/avr/Kconfig b/arch/avr/Kconfig index 473a2ed5888..6f9a85c9748 100644 --- a/arch/avr/Kconfig +++ b/arch/avr/Kconfig @@ -12,12 +12,14 @@ choice config ARCH_CHIP_ATMEGA bool "ATMega family" select ARCH_FAMILY_AVR + select MM_SMALL ---help--- Atmel ATMega family of 8-bit AVRs. config ARCH_CHIP_AT90USB bool "AT90USB family" select ARCH_FAMILY_AVR + select MM_SMALL ---help--- Atmel AT90USB family of 8-bit AVRs. diff --git a/arch/hc/Kconfig b/arch/hc/Kconfig index 53281389831..dedfeead2d1 100644 --- a/arch/hc/Kconfig +++ b/arch/hc/Kconfig @@ -12,6 +12,7 @@ choice config ARCH_CHIP_MCS92S12NEC64 bool "MCS92S12NEC64" select ARCH_HSC12 + select MM_SMALL ---help--- Motorola/Freescale MCS92S12NEC64 (M9S12) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 0df7b045d0e..48c76f3ca03 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -18,6 +18,7 @@ config ARCH_CHIP_SH7032 config ARCH_CHIP_M30262F8 bool "M30262F8" select ARCH_M16C + select MM_SMALL ---help--- Renesas M30262F8 (M16C) diff --git a/arch/z80/Kconfig b/arch/z80/Kconfig index 79692bae06b..2aee96fcf70 100644 --- a/arch/z80/Kconfig +++ b/arch/z80/Kconfig @@ -11,6 +11,7 @@ choice config ARCH_CHIP_Z80 bool "Classic z80" select ARCH_NOINTC + select MM_SMALL ---help--- Classic ZiLOG z80 chip @@ -378,6 +379,7 @@ config ARCH_CHIP_Z8F640X config ARCH_CHIP_Z180 bool + select MM_SMALL select ARCH_NOINTC select ARCH_HAVE_ADDRENV select ARCH_ADDRENV @@ -406,9 +408,11 @@ config ARCH_CHIP_Z8S180 config ARCH_CHIP_Z8 bool + select MM_SMALL config ARCH_CHIP_EZ80 bool + select MM_SMALL if EZ80_Z80MODE select HAVE_LOWSERIALINIT select ARCH_HAVE_PHY From edb1439d8f18ac79f8bd0ce6b92ff909bf8dc013 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 23 Nov 2015 12:44:59 -0600 Subject: [PATCH 04/17] Last change introduced warnings when CONFIG_SIM_M32=y; This fixes those warnings too --- arch/sim/include/types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/sim/include/types.h b/arch/sim/include/types.h index d8f734e3fcc..8edba08e931 100644 --- a/arch/sim/include/types.h +++ b/arch/sim/include/types.h @@ -76,14 +76,14 @@ typedef signed long long _int64_t; typedef unsigned long long _uint64_t; #define __INT64_DEFINED -#ifdef CONFIG_HOST_X86_64 -/* 32-bit build on 64-bit machine: A pointer is 8 bytes */ +#if defined(CONFIG_HOST_X86_64) && !defined(CONFIG_SIM_M32) +/* 63-bit build on 64-bit machine: A pointer is 8 bytes */ typedef signed long long _intptr_t; typedef unsigned long long _uintptr_t; #else -/* 32-bit build on 32-bit machine: A pointer is 4 bytes */ +/* 32-bit build on 32- or 64-bit machine: A pointer is 4 bytes */ typedef signed int _intptr_t; typedef unsigned int _uintptr_t; From d7c5ff98f43fd4ec88abe5e648c5ae34f710c339 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 23 Nov 2015 18:55:38 +0000 Subject: [PATCH 05/17] Fix a typo --- arch/sim/include/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sim/include/types.h b/arch/sim/include/types.h index 8edba08e931..24bae96b3fc 100644 --- a/arch/sim/include/types.h +++ b/arch/sim/include/types.h @@ -77,7 +77,7 @@ typedef unsigned long long _uint64_t; #define __INT64_DEFINED #if defined(CONFIG_HOST_X86_64) && !defined(CONFIG_SIM_M32) -/* 63-bit build on 64-bit machine: A pointer is 8 bytes */ +/* 64-bit build on 64-bit machine: A pointer is 8 bytes */ typedef signed long long _intptr_t; typedef unsigned long long _uintptr_t; From 641ca7932118ec5d6e6148905410ed94b116fa22 Mon Sep 17 00:00:00 2001 From: Ken Pettit Date: Wed, 25 Nov 2015 08:36:44 -0600 Subject: [PATCH 06/17] arch/sim/src: Add a special file system for use with simulator that supports access to the host file system from the simulation. From Ken Petit --- arch/sim/src/.gitignore | 1 + arch/sim/src/Makefile | 29 ++- arch/sim/src/nuttx-names.dat | 1 + arch/sim/src/up_hostfs.c | 386 +++++++++++++++++++++++++++++++++++ 4 files changed, 408 insertions(+), 9 deletions(-) create mode 100644 arch/sim/src/up_hostfs.c diff --git a/arch/sim/src/.gitignore b/arch/sim/src/.gitignore index ccd150a8eb0..e0d861c651e 100644 --- a/arch/sim/src/.gitignore +++ b/arch/sim/src/.gitignore @@ -3,6 +3,7 @@ /Cygwin-names.dat /Linux-names.dat /nuttx.rel +/hostfs.h /GNU /chip /board diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index db6575b5af9..2acbb1538f8 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -69,7 +69,7 @@ ifeq ($(CONFIG_DEV_CONSOLE),y) endif ifeq ($(CONFIG_LIB_BOARDCTL),y) -CSRCS += up_appinit.c + CSRCS += up_appinit.c endif ifeq ($(CONFIG_NX_LCDDRIVER),y) @@ -91,28 +91,38 @@ endif endif ifeq ($(CONFIG_ELF),y) -CSRCS += up_elf.c + CSRCS += up_elf.c endif ifeq ($(CONFIG_FS_FAT),y) -CSRCS += up_blockdevice.c up_deviceimage.c + CSRCS += up_blockdevice.c up_deviceimage.c endif ifeq ($(CONFIG_ARCH_ROMGETC),y) -CSRCS += up_romgetc.c + CSRCS += up_romgetc.c endif ifeq ($(CONFIG_NET_ETHERNET),y) -CSRCS += up_netdriver.c -HOSTCFLAGS += -DNETDEV_BUFSIZE=$(CONFIG_NET_ETH_MTU) + CSRCS += up_netdriver.c + HOSTCFLAGS += -DNETDEV_BUFSIZE=$(CONFIG_NET_ETH_MTU) ifneq ($(HOSTOS),Cygwin) -HOSTSRCS += up_tapdev.c up_netdev.c + HOSTSRCS += up_tapdev.c up_netdev.c else -HOSTSRCS += up_wpcap.c up_netdev.c -DRVLIB = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a + HOSTSRCS += up_wpcap.c up_netdev.c + DRVLIB = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a endif endif +ifeq ($(CONFIG_FS_HOSTFS),y) + HOSTSRCS += up_hostfs.c + +up_hostfs.c: hostfs.h + +hostfs.h: $(TOPDIR)/include/nuttx/fs/hostfs.h + @echo "CP: $<" + $(Q) cp $< $@ +endif + COBJS = $(CSRCS:.c=$(OBJEXT)) NUTTXOBJS = $(AOBJS) $(COBJS) @@ -260,6 +270,7 @@ distclean: clean fi $(call DELFILE, Make.dep) $(call DELFILE, .depend) + $(call DELFILE, hostfs.h) $(Q) rm -rf GNU -include Make.dep diff --git a/arch/sim/src/nuttx-names.dat b/arch/sim/src/nuttx-names.dat index de3062ce2f2..59ca8ea2ef5 100644 --- a/arch/sim/src/nuttx-names.dat +++ b/arch/sim/src/nuttx-names.dat @@ -29,6 +29,7 @@ poll NXpoll printf NXprintf pthread_create NXpthread_create read NXread +readdir NXreaddir realloc NXrealloc recv NXrecv recvfrom NXrecvfrom diff --git a/arch/sim/src/up_hostfs.c b/arch/sim/src/up_hostfs.c new file mode 100644 index 00000000000..bddcac43922 --- /dev/null +++ b/arch/sim/src/up_hostfs.c @@ -0,0 +1,386 @@ +/**************************************************************************** + * arch/sim/src/up_hostfs.c + * + * Copyright (C) 2015 Ken Pettit. All rights reserved. + * Author: Ken Pettit + * + * 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 + ****************************************************************************/ +#define _BSD_SOURCE + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "hostfs.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_open(const char *pathname, int flags, int mode) +{ + int mapflags; + + /* Perform flag mapping */ + + if ((flags & (HOSTFS_FLAG_RDOK | HOSTFS_FLAG_WROK)) == + (HOSTFS_FLAG_RDOK | HOSTFS_FLAG_WROK)) + { + mapflags = O_RDWR; + } + else if (flags & HOSTFS_FLAG_RDOK) + { + mapflags = O_RDONLY; + } + else if (flags & HOSTFS_FLAG_WROK) + { + mapflags = O_WRONLY; + } + + if (flags & HOSTFS_FLAG_APPEND) + { + mapflags |= O_APPEND; + } + + if (flags & HOSTFS_FLAG_CREAT) + { + mapflags |= O_CREAT; + } + + if (flags & HOSTFS_FLAG_EXCL) + { + mapflags |= O_EXCL; + } + + if (flags & HOSTFS_FLAG_TRUNC) + { + mapflags |= O_TRUNC; + } + + return open(pathname, mapflags, mode); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_close(int fd) +{ + /* Just call the close routine */ + + return close(fd); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +ssize_t host_read(int fd, void* buf, size_t count) +{ + /* Just call the read routine */ + + return read(fd, buf, count); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +ssize_t host_write(int fd, const void *buf, size_t count) +{ + /* Just call the write routine */ + + return write(fd, buf, count); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +off_t host_lseek(int fd, off_t offset, int whence) +{ + /* Just call the lseek routine */ + + return lseek(fd, offset, whence); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_ioctl(int fd, int request, unsigned long arg) +{ + /* Just call the ioctl routine */ + + return ioctl(fd, request, arg); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void host_sync(int fd) +{ + /* Just call the sync routine */ + + sync(); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_dup(int fd) +{ + return dup(fd); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void *host_opendir(const char *name) +{ + return (void *) opendir(name); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_readdir(void* dirp, struct host_dirent_s* entry) +{ + struct dirent *ent; + + /* Call the host's readdir routine */ + + ent = readdir(dirp); + + if (ent != NULL) + { + /* Copy the entry name */ + + strncpy(entry->d_name, ent->d_name, sizeof(entry->d_name)); + + /* Map the type */ + + entry->d_type = 0; + if (ent->d_type == DT_REG) + { + entry->d_type = HOSTFS_DTYPE_FILE; + } + else if (ent->d_type == DT_CHR) + { + entry->d_type = HOSTFS_DTYPE_CHR; + } + else if (ent->d_type == DT_BLK) + { + entry->d_type = HOSTFS_DTYPE_BLK; + } + else if (ent->d_type == DT_DIR) + { + entry->d_type = HOSTFS_DTYPE_DIRECTORY; + } + } + + if (ent) + { + return 0; + } + + return -ENOENT; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void host_rewinddir(void* dirp) +{ + /* Just call the rewinddir routine */ + + rewinddir(dirp); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_closedir(void* dirp) +{ + return closedir(dirp); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_statfs(const char *path, struct host_statfs_s *buf) +{ + int ret; + struct statfs host_buf; + + /* Call the host's statfs routine */ + + ret = statfs(path, &host_buf); + + /* Map the return values */ + + buf->f_type = host_buf.f_type; + buf->f_bsize = host_buf.f_bsize; + buf->f_blocks = host_buf.f_blocks; + buf->f_bfree = host_buf.f_bfree; + buf->f_bavail = host_buf.f_bavail; + buf->f_files = host_buf.f_files; + buf->f_ffree = host_buf.f_ffree; + buf->f_fsid = 0; + buf->f_namelen = host_buf.f_namelen; + buf->f_frsize = host_buf.f_frsize; + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_unlink(const char *pathname) +{ + return unlink(pathname); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_mkdir(const char *pathname, mode_t mode) +{ + /* Just call the host's mkdir routine */ + + return mkdir(pathname, mode); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_rmdir(const char *pathname) +{ + return rmdir(pathname); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_rename(const char *oldpath, const char *newpath) +{ + return rename(oldpath, newpath); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_stat(const char *path, struct host_stat_s *buf) +{ + struct stat host_buf; + int ret; + + /* Call the host's stat routine */ + + ret = stat(path, &host_buf); + + /* Now map the return values to the common struct */ + + buf->st_dev = host_buf.st_dev; /* ID of the device containing file */ + buf->st_ino = host_buf.st_ino;; /* inode number */ + buf->st_nlink = host_buf.st_nlink; /* number of hard links */ + buf->st_uid = host_buf.st_uid; /* user ID of owner */ + buf->st_gid = host_buf.st_gid; /* group ID of owner */ + buf->st_rdev = host_buf.st_rdev; /* device ID */ + buf->st_size = host_buf.st_size; /* total size, in bytes */ + buf->st_blksize = host_buf.st_blksize; /* blocksize for file system I/O */ + buf->st_blocks = host_buf.st_blocks; /* number of 512B blocks allocated */ + buf->st_atim = host_buf.st_atime; /* time of last access */ + buf->st_mtim = host_buf.st_mtime; /* time of last modification */ + buf->st_ctim = host_buf.st_ctime; /* time of last status change */ + + /* Map the mode bits */ + + buf->st_mode = host_buf.st_mode & 0xFFF; + if (S_ISREG(host_buf.st_mode)) + { + buf->st_mode |= HOST_ST_MODE_REG; + } + + if (S_ISDIR(host_buf.st_mode)) + { + buf->st_mode |= HOST_ST_MODE_DIR; + } + + if (S_ISCHR(host_buf.st_mode)) + { + buf->st_mode |= HOST_ST_MODE_CHR; + } + + if (S_ISBLK(host_buf.st_mode)) + { + buf->st_mode |= HOST_ST_MODE_BLK; + } + + if (S_ISFIFO(host_buf.st_mode)) + { + buf->st_mode |= HOST_ST_MODE_PIPE; + } + + if (S_ISLNK(host_buf.st_mode)) + { + buf->st_mode |= HOST_ST_MODE_LINK; + } + + return ret; +} From b1e17d88924f87316cb65ed65768481623e1de9c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 25 Nov 2015 12:51:07 -0600 Subject: [PATCH 07/17] Fix some conditional compilation. CONFIG_LIBC_LOCALTIME should be checked in most of the same places wehre CONFIG_TIME_EXTENDED is checked --- arch/arm/src/stm32/stm32_rtcc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/stm32/stm32_rtcc.c b/arch/arm/src/stm32/stm32_rtcc.c index 37aca70c51f..35020c84307 100644 --- a/arch/arm/src/stm32/stm32_rtcc.c +++ b/arch/arm/src/stm32/stm32_rtcc.c @@ -902,7 +902,7 @@ int up_rtc_getdatetime(FAR struct tm *tp) tmp = (dr & (RTC_DR_YU_MASK | RTC_DR_YT_MASK)) >> RTC_DR_YU_SHIFT; tp->tm_year = rtc_bcd2bin(tmp) + 100; -#if defined(CONFIG_TIME_EXTENDED) +#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) tmp = (dr & RTC_DR_WDU_MASK) >> RTC_DR_WDU_SHIFT; tp->tm_wday = tmp % 7; tp->tm_yday = tp->tm_mday + clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900)); @@ -1014,7 +1014,7 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp) dr = (rtc_bin2bcd(tp->tm_mday) << RTC_DR_DU_SHIFT) | ((rtc_bin2bcd(tp->tm_mon + 1)) << RTC_DR_MU_SHIFT) | -#if defined(CONFIG_TIME_EXTENDED) +#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED) ((tp->tm_wday == 0 ? 7 : (tp->tm_wday & 7)) << RTC_DR_WDU_SHIFT) | #endif ((rtc_bin2bcd(tp->tm_year - 100)) << RTC_DR_YU_SHIFT); From 14d7ede265c95c0734bd4f1d55f1a1a4133dc478 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 25 Nov 2015 17:10:41 -0600 Subject: [PATCH 08/17] All instances of up_initialize() should call loop_register() is CONFIG_DEV_LOOP=y --- arch/arm/src/common/up_initialize.c | 4 ++++ arch/avr/src/common/up_initialize.c | 4 ++++ arch/hc/src/common/up_initialize.c | 4 ++++ arch/mips/src/common/up_initialize.c | 4 ++++ arch/sh/src/common/up_initialize.c | 4 ++++ arch/sim/src/up_initialize.c | 4 ++++ arch/x86/src/common/up_initialize.c | 4 ++++ arch/z16/src/common/up_initialize.c | 4 ++++ arch/z80/src/common/up_initialize.c | 4 ++++ 9 files changed, 36 insertions(+) diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index 2cb332671b6..b6109e1c9bf 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -203,6 +204,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ /* Initialize the serial device driver */ diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index f44b421c6d0..f6273cb4e9b 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -235,6 +236,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ /* Initialize the serial device driver */ diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index 5628c3aaecd..6b2495f728d 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -159,6 +160,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ /* Initialize the serial device driver */ diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index 1274772249a..3588057b1de 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -161,6 +162,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ /* Initialize the serial device driver */ diff --git a/arch/sh/src/common/up_initialize.c b/arch/sh/src/common/up_initialize.c index f4e067489f8..3b19140ac08 100644 --- a/arch/sh/src/common/up_initialize.c +++ b/arch/sh/src/common/up_initialize.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -146,6 +147,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ /* Initialize the serial device driver */ diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index 667a618d491..4bf85707a00 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -149,6 +150,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ #if defined(USE_DEVCONSOLE) diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index 21d4eba7cb7..d395c2d654f 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -161,6 +162,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ /* Initialize the serial device driver */ diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index 747d448b0cb..2932c50f17c 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -165,6 +166,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ /* Initialize the serial device driver */ diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index 2bc7420c391..67aad82a37d 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -157,6 +158,9 @@ void up_initialize(void) devzero_register(); /* Standard /dev/zero */ #endif +#if defined(CONFIG_DEV_LOOP) + loop_register(); /* Standard /dev/loop */ +#endif #endif /* CONFIG_NFILE_DESCRIPTORS */ /* Initialize the serial device driver */ From f4e8f84887c2e63c84bac0dfe1f429bd8a06bed1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 25 Nov 2015 17:52:14 -0600 Subject: [PATCH 09/17] __KERNEL__ should be defined when compiler architecture specific logic --- arch/sim/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 2acbb1538f8..1ccca15bdf8 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -35,7 +35,7 @@ -include $(TOPDIR)/Make.defs -CFLAGS += -I$(TOPDIR)/sched +CFLAGS += -I$(TOPDIR)/sched -D__KERNEL__ ASRCS = From 4aa3dcb51a9911ea44f4c35922b287e727c30560 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 25 Nov 2015 18:05:36 -0600 Subject: [PATCH 10/17] __KERNEL__ should be defined when compiler architecture specific logic --- arch/arm/src/Makefile | 3 +++ arch/avr/src/Makefile | 3 +++ arch/hc/src/Makefile | 3 +++ arch/mips/src/Makefile | 3 +++ arch/sh/src/Makefile | 3 +++ arch/sim/src/Makefile | 2 +- arch/x86/src/Makefile | 3 +++ 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/Makefile b/arch/arm/src/Makefile index 728c29648f6..9b17c47e926 100644 --- a/arch/arm/src/Makefile +++ b/arch/arm/src/Makefile @@ -52,6 +52,9 @@ else # ARM9, ARM7TDMI ARCH_SUBDIR = arm endif +KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} +CFLAGS += $(KDEFINE) + ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src NUTTX = "$(TOPDIR)\nuttx$(EXEEXT)" diff --git a/arch/avr/src/Makefile b/arch/avr/src/Makefile index a3f288efb61..c18262032f9 100644 --- a/arch/avr/src/Makefile +++ b/arch/avr/src/Makefile @@ -71,6 +71,9 @@ CFLAGS += $(INCLUDES) CXXFLAGS += $(INCLUDES) AFLAGS += $(INCLUDES) +KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} +CFLAGS += $(KDEFINE) + HEAD_OBJ = $(HEAD_ASRC:.S=$(OBJEXT)) STARTUP_OBJS ?= $(HEAD_OBJ) diff --git a/arch/hc/src/Makefile b/arch/hc/src/Makefile index eaccee17463..07132303f2a 100644 --- a/arch/hc/src/Makefile +++ b/arch/hc/src/Makefile @@ -43,6 +43,9 @@ ifeq ($(CONFIG_ARCH_HCS12),y) ARCH_SUBDIR = hcs12 endif +KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} +CFLAGS += $(KDEFINE) + ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src NUTTX = "$(TOPDIR)\nuttx$(EXEEXT)" diff --git a/arch/mips/src/Makefile b/arch/mips/src/Makefile index aeb3238a0f0..0af6d9002a8 100644 --- a/arch/mips/src/Makefile +++ b/arch/mips/src/Makefile @@ -40,6 +40,9 @@ ifeq ($(CONFIG_ARCH_MIPS),y) ARCH_SUBDIR = mips32 endif +KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} +CFLAGS += $(KDEFINE) + ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src NUTTX = $(TOPDIR)\nuttx$(EXEEXT) diff --git a/arch/sh/src/Makefile b/arch/sh/src/Makefile index 280b843a1a4..767d2d24e19 100644 --- a/arch/sh/src/Makefile +++ b/arch/sh/src/Makefile @@ -36,6 +36,9 @@ -include $(TOPDIR)/Make.defs -include chip/Make.defs +KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} +CFLAGS += $(KDEFINE) + ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src NUTTX = $(TOPDIR)\nuttx$(EXEEXT) diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 1ccca15bdf8..6651e97a7a6 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -35,7 +35,7 @@ -include $(TOPDIR)/Make.defs -CFLAGS += -I$(TOPDIR)/sched -D__KERNEL__ +CFLAGS += -I$(TOPDIR)/sched -D__KERNEL__ ASRCS = diff --git a/arch/x86/src/Makefile b/arch/x86/src/Makefile index 0de6b7c0829..e58f592a4ca 100644 --- a/arch/x86/src/Makefile +++ b/arch/x86/src/Makefile @@ -40,6 +40,9 @@ ifeq ($(CONFIG_ARCH_I486),y) ARCH_SUBDIR = i486 endif +KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} +CFLAGS += $(KDEFINE) + ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src NUTTX = $(TOPDIR)\nuttx$(EXEEXT) From 22b4932a4fc3304640ffc230be5c10f658ba043e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 25 Nov 2015 18:06:56 -0600 Subject: [PATCH 11/17] __KERNEL__ should be defined when compiler architecture specific logic --- arch/z16/src/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/z16/src/Makefile b/arch/z16/src/Makefile index 02d9c6eb674..74e91dc75c9 100644 --- a/arch/z16/src/Makefile +++ b/arch/z16/src/Makefile @@ -55,6 +55,9 @@ INCLUDES = $(ARCHSTDINCLUDES) $(USRINCLUDES) CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(INCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) CPPFLAGS += -I$(ARCHSRCDIR) +KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} +CFLAGS += $(KDEFINE) + ifeq ($(CONFIG_WINDOWS_NATIVE),y) LDFLAGS += @"$(ARCHSRCDIR)/nuttx.linkcmd" else From 2afd4595e4a29f7a16143da73b7917adb1634eeb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 26 Nov 2015 06:59:35 -0600 Subject: [PATCH 12/17] Re-think how __KERNEL__ option is set in architecture Makefiles. Should be passed in EXTRADEFINES --- arch/arm/src/Makefile | 5 +++-- arch/avr/src/Makefile | 11 ++++------- arch/hc/src/Makefile | 5 +++-- arch/mips/src/Makefile | 5 +++-- arch/rgmp/src/Makefile | 4 +++- arch/sh/src/Makefile | 5 +++-- arch/sim/src/Makefile | 4 +++- arch/x86/src/Makefile | 5 +++-- arch/z16/src/Makefile | 5 +---- 9 files changed, 26 insertions(+), 23 deletions(-) diff --git a/arch/arm/src/Makefile b/arch/arm/src/Makefile index 9b17c47e926..f36e19f5712 100644 --- a/arch/arm/src/Makefile +++ b/arch/arm/src/Makefile @@ -52,8 +52,9 @@ else # ARM9, ARM7TDMI ARCH_SUBDIR = arm endif -KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} -CFLAGS += $(KDEFINE) +CPPFLAGS += $(EXTRADEFINES) +CFLAGS += $(EXTRADEFINES) +CXXFLAGS += $(EXTRADEFINES) ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src diff --git a/arch/avr/src/Makefile b/arch/avr/src/Makefile index c18262032f9..cba310af9b5 100644 --- a/arch/avr/src/Makefile +++ b/arch/avr/src/Makefile @@ -66,13 +66,10 @@ else endif endif -CPPFLAGS += $(INCLUDES) -CFLAGS += $(INCLUDES) -CXXFLAGS += $(INCLUDES) -AFLAGS += $(INCLUDES) - -KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} -CFLAGS += $(KDEFINE) +CPPFLAGS += $(INCLUDES) $(EXTRADEFINES) +CFLAGS += $(INCLUDES) $(EXTRADEFINES) +CXXFLAGS += $(INCLUDES) $(EXTRADEFINES) +AFLAGS += $(INCLUDES) $(EXTRADEFINES) HEAD_OBJ = $(HEAD_ASRC:.S=$(OBJEXT)) STARTUP_OBJS ?= $(HEAD_OBJ) diff --git a/arch/hc/src/Makefile b/arch/hc/src/Makefile index 07132303f2a..fb165188fe1 100644 --- a/arch/hc/src/Makefile +++ b/arch/hc/src/Makefile @@ -43,8 +43,9 @@ ifeq ($(CONFIG_ARCH_HCS12),y) ARCH_SUBDIR = hcs12 endif -KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} -CFLAGS += $(KDEFINE) +CPPFLAGS += $(EXTRADEFINES) +CFLAGS += $(EXTRADEFINES) +CXXFLAGS += $(EXTRADEFINES) ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src diff --git a/arch/mips/src/Makefile b/arch/mips/src/Makefile index 0af6d9002a8..a746fd22301 100644 --- a/arch/mips/src/Makefile +++ b/arch/mips/src/Makefile @@ -40,8 +40,9 @@ ifeq ($(CONFIG_ARCH_MIPS),y) ARCH_SUBDIR = mips32 endif -KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} -CFLAGS += $(KDEFINE) +CPPFLAGS += $(EXTRADEFINES) +CFLAGS += $(EXTRADEFINES) +CXXFLAGS += $(EXTRADEFINES) ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src diff --git a/arch/rgmp/src/Makefile b/arch/rgmp/src/Makefile index 09fb372f448..1fb3618d96f 100644 --- a/arch/rgmp/src/Makefile +++ b/arch/rgmp/src/Makefile @@ -39,7 +39,9 @@ include $(CONFIG_RGMP_SUBARCH)/Make.defs RGMP_ARCH_ASRCS := $(addprefix $(CONFIG_RGMP_SUBARCH)/,$(RGMP_ARCH_ASRCS)) RGMP_ARCH_CSRCS := $(addprefix $(CONFIG_RGMP_SUBARCH)/,$(RGMP_ARCH_CSRCS)) -CFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs +CPPFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES) +CFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES) +CXXFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES) ASRCS = $(RGMP_ARCH_ASRCS) CSRCS = nuttx.c cxx.c $(RGMP_ARCH_CSRCS) diff --git a/arch/sh/src/Makefile b/arch/sh/src/Makefile index 767d2d24e19..967818df2a8 100644 --- a/arch/sh/src/Makefile +++ b/arch/sh/src/Makefile @@ -36,8 +36,9 @@ -include $(TOPDIR)/Make.defs -include chip/Make.defs -KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} -CFLAGS += $(KDEFINE) +CPPFLAGS += $(EXTRADEFINES) +CFLAGS += $(EXTRADEFINES) +CXXFLAGS += $(EXTRADEFINES) ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 6651e97a7a6..b813e883fc2 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -35,7 +35,9 @@ -include $(TOPDIR)/Make.defs -CFLAGS += -I$(TOPDIR)/sched -D__KERNEL__ +CPPFLAGS += -I$(TOPDIR)/sched $(EXTRADEFINES) +CFLAGS += -I$(TOPDIR)/sched $(EXTRADEFINES) +CXXFLAGS += -I$(TOPDIR)/sched $(EXTRADEFINES) ASRCS = diff --git a/arch/x86/src/Makefile b/arch/x86/src/Makefile index e58f592a4ca..f38bcee148d 100644 --- a/arch/x86/src/Makefile +++ b/arch/x86/src/Makefile @@ -40,8 +40,9 @@ ifeq ($(CONFIG_ARCH_I486),y) ARCH_SUBDIR = i486 endif -KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} -CFLAGS += $(KDEFINE) +CPPFLAGS += $(EXTRADEFINES) +CFLAGS += $(EXTRADEFINES) +CXXFLAGS += $(EXTRADEFINES) ifeq ($(CONFIG_WINDOWS_NATIVE),y) ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src diff --git a/arch/z16/src/Makefile b/arch/z16/src/Makefile index 74e91dc75c9..f9bcc15fb85 100644 --- a/arch/z16/src/Makefile +++ b/arch/z16/src/Makefile @@ -53,10 +53,7 @@ endif INCLUDES = $(ARCHSTDINCLUDES) $(USRINCLUDES) CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(INCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -CPPFLAGS += -I$(ARCHSRCDIR) - -KDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __KERNEL__} -CFLAGS += $(KDEFINE) +CPPFLAGS += -I$(ARCHSRCDIR) $(EXTRADEFINES) ifeq ($(CONFIG_WINDOWS_NATIVE),y) LDFLAGS += @"$(ARCHSRCDIR)/nuttx.linkcmd" From e5e631e57f11c502bafe00c283e0593b10c317dd Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 26 Nov 2015 12:07:18 -0600 Subject: [PATCH 13/17] include/nuttx/net/netdev.h and several Ethernet drivers in arch/: Most network drivers to not support statistics. Those that do only support them when DEBUG is enabled. Each driver collects an architecture specific set of statistics and there is no mechanism in place to view those statistics. Thus, the driver feature was mostly useless. This change standardizes the driver statistics and puts the definition in the common network device structure defined in netdev.h where they can be accessed by network applications. All Ethernet drivers that collect statistics have been adapted to use these common statistics. --- arch/arm/src/kinetis/Kconfig | 1 + arch/arm/src/kinetis/kinetis_enet.c | 41 ++++-------- arch/arm/src/lpc17xx/Kconfig | 1 + arch/arm/src/lpc17xx/lpc17_ethernet.c | 83 +++++------------------- arch/arm/src/tiva/Kconfig | 2 + arch/arm/src/tiva/Make.defs | 2 +- arch/arm/src/tiva/lm3s_ethernet.c | 64 +++++------------- arch/mips/src/pic32mx/Kconfig | 1 + arch/mips/src/pic32mx/pic32mx-ethernet.c | 83 +++++------------------- arch/mips/src/pic32mz/Kconfig | 1 + arch/mips/src/pic32mz/pic32mz-ethernet.c | 83 +++++------------------- arch/z80/src/ez80/Kconfig | 1 + 12 files changed, 91 insertions(+), 272 deletions(-) diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig index 8db618f9190..f67fef3b94d 100644 --- a/arch/arm/src/kinetis/Kconfig +++ b/arch/arm/src/kinetis/Kconfig @@ -171,6 +171,7 @@ config KINETIS_ENET default n depends on ARCH_FAMILY_K60 select NET + select ARCH_HAVE_NETDEV_STATISTICS ---help--- Support Ethernet (K60 only) diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 50a24bd8c3e..47496a794e7 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/net/kinetis_enet.c * - * Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -149,22 +149,6 @@ /**************************************************************************** * Private Types ****************************************************************************/ -/* EMAC statistics (debug only) */ - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) -struct kinetis_statistics_s -{ - uint32_t rx_packets; /* Number of packets received */ - uint32_t tx_packets; /* Number of Tx packets queued */ - unit32_t tx_done; /* Number of packets completed */ - uint32_t tx_timeouts; /* Number of Tx timeout errors */ - uint32_t errors; /* Number of error interrupts */ -}; -# define EMAC_STAT(priv,name) priv->stats.name++ -#else -# define EMAC_STAT(priv,name) -#endif - /* The kinetis_driver_s encapsulates all state information for a single hardware * interface */ @@ -184,12 +168,6 @@ struct kinetis_driver_s struct net_driver_s dev; /* Interface understood by uIP */ - /* Statistics */ - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) - struct kinetis_statistics_s stats; -#endif - /* The DMA descriptors. A unaligned uint8_t is used to allocate the * memory; 16 is added to assure that we can meet the descriptor alignment * requirements. @@ -385,7 +363,7 @@ static int kinetis_transmit(FAR struct kinetis_driver_s *priv) /* Increment statistics */ - EMAC_STAT(priv, tx_packets); + NETDEV_TXPACKETS(&priv->dev); /* Setup the buffer descriptor for transmission: address=priv->dev.d_buf, * length=priv->dev.d_len @@ -516,7 +494,7 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv) { /* Update statistics */ - EMAC_STAT(priv, rx_packets); + NETDEV_RXPACKETS(&priv->dev); /* Copy the buffer pointer to priv->dev.d_buf. Set amount of data in * priv->dev.d_len @@ -553,6 +531,7 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv) if (BUF->type == HTONS(ETHTYPE_IP)) { nllvdbg("IPv4 frame\n"); + NETDEV_RXIPV4(&priv->dev); /* Handle ARP on input then give the IPv4 packet to the network * layer @@ -593,6 +572,7 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv) if (BUF->type == HTONS(ETHTYPE_IP6)) { nllvdbg("Iv6 frame\n"); + NETDEV_RXIPV6(&priv->dev); /* Give the IPv6 packet to the network layer */ @@ -629,6 +609,7 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv) #ifdef CONFIG_NET_ARP if (BUF->type == htons(ETHTYPE_ARP)) { + NETDEV_RXARP(&priv->dev); arp_arpin(&priv->dev); /* If the above function invocation resulted in data that should @@ -642,6 +623,10 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv) } } #endif + else + { + NETDEV_RXDROPPED(&priv->dev); + } } } @@ -682,7 +667,7 @@ static void kinetis_txdone(FAR struct kinetis_driver_s *priv) /* Update statistics */ - EMAC_STAT(priv, tx_done); + NETDEV_TXDONE(&priv->dev); } /* Are there other transmissions queued? */ @@ -765,7 +750,7 @@ static int kinetis_interrupt(int irq, FAR void *context) { /* An error has occurred, update statistics */ - EMAC_STAT(priv, errors); + NETDEV_ERRORS(&priv->dev); /* Reinitialize all buffers. */ @@ -804,7 +789,7 @@ static void kinetis_txtimeout(int argc, uint32_t arg, ...) /* Increment statistics and dump debug info */ - EMAC_STAT(priv, tx_timeout); + NETDEV_TXTIMEOUT(&priv->dev); /* Take the interface down and bring it back up. The is the most agressive * hardware reset. diff --git a/arch/arm/src/lpc17xx/Kconfig b/arch/arm/src/lpc17xx/Kconfig index 8ed2fd94510..dadbe8bae7a 100644 --- a/arch/arm/src/lpc17xx/Kconfig +++ b/arch/arm/src/lpc17xx/Kconfig @@ -139,6 +139,7 @@ config LPC17_ETHERNET bool "Ethernet" select NETDEVICES select ARCH_HAVE_PHY + select ARCH_HAVE_NETDEV_STATISTICS default n config LPC17_LCD diff --git a/arch/arm/src/lpc17xx/lpc17_ethernet.c b/arch/arm/src/lpc17xx/lpc17_ethernet.c index 41fe4e7f9f0..54574021bde 100644 --- a/arch/arm/src/lpc17xx/lpc17_ethernet.c +++ b/arch/arm/src/lpc17xx/lpc17_ethernet.c @@ -238,45 +238,6 @@ * Private Types ****************************************************************************/ -/* EMAC statistics (debug only) */ - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) -struct lpc17_statistics_s -{ -#ifdef ENABLE_WOL - uint32_t wol; /* Wake-up interrupts */ -#endif - uint32_t rx_finished; /* Rx finished interrupts */ - uint32_t rx_done; /* Rx done interrupts */ - uint32_t rx_ovrerrors; /* Number of Rx overrun error interrupts */ - uint32_t rx_errors; /* Number of Rx error interrupts (OR of other errors) */ - uint32_t rx_packets; /* Number of packets received (sum of the following): */ -#ifdef CONFIG_NET_IPv4 - uint32_t rx_ip; /* Number of Rx IPv4 packets received */ -#endif -#ifdef CONFIG_NET_IPv6 - uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */ -#endif - uint32_t rx_arp; /* Number of Rx ARP packets received */ - uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */ - uint32_t rx_pkterr; /* Number of dropped, error in Rx descriptor */ - uint32_t rx_pktsize; /* Number of dropped, too small or too big */ - uint32_t rx_fragment; /* Number of dropped, packet fragments */ - - uint32_t tx_packets; /* Number of Tx packets queued */ - uint32_t tx_pending; /* Number of Tx packets that had to wait for a TxDesc */ - uint32_t tx_unpend; /* Number of pending Tx packets that were sent */ - uint32_t tx_finished; /* Tx finished interrupts */ - uint32_t tx_done; /* Tx done interrupts */ - uint32_t tx_underrun; /* Number of Tx underrun error interrupts */ - uint32_t tx_errors; /* Number of Tx error inerrupts (OR of other errors) */ - uint32_t tx_timeouts; /* Number of Tx timeout errors */ -}; -# define EMAC_STAT(priv,name) priv->lp_stat.name++ -#else -# define EMAC_STAT(priv,name) -#endif - /* The lpc17_driver_s encapsulates all state information for a single hardware * interface */ @@ -309,10 +270,6 @@ struct lpc17_driver_s uint32_t status; #endif /* CONFIG_NET_NOINTS */ -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) - struct lpc17_statistics_s lp_stat; -#endif - /* This holds the information visible to the NuttX networking layer */ struct net_driver_s lp_dev; /* Interface understood by the network layer */ @@ -647,7 +604,7 @@ static int lpc17_transmit(struct lpc17_driver_s *priv) /* Increment statistics and dump the packet *if so configured) */ - EMAC_STAT(priv, tx_packets); + NETDEV_TXPACKETS(&priv->lp_dev); lpc17_dumppacket("Transmit packet", priv->lp_dev.d_buf, priv->lp_dev.d_len); @@ -826,7 +783,6 @@ static void lpc17_response(struct lpc17_driver_s *priv) priv->lp_txpending = true; priv->lp_inten &= ~ETH_RXINTS; lpc17_putreg(priv->lp_inten, LPC17_ETH_INTEN); - EMAC_STAT(priv, tx_pending); } } @@ -869,7 +825,7 @@ static void lpc17_rxdone_process(struct lpc17_driver_s *priv) { /* Update statistics */ - EMAC_STAT(priv, rx_packets); + NETDEV_RXPACKETS(&priv->lp_dev); /* Get the Rx status and packet length (-4+1) */ @@ -884,7 +840,7 @@ static void lpc17_rxdone_process(struct lpc17_driver_s *priv) { nlldbg("Error. considx: %08x prodidx: %08x rxstat: %08x\n", considx, prodidx, *rxstat); - EMAC_STAT(priv, rx_pkterr); + NETDEV_RXERRORS(&priv->lp_dev); } /* If the pktlen is greater then the buffer, then we cannot accept @@ -897,20 +853,20 @@ static void lpc17_rxdone_process(struct lpc17_driver_s *priv) { nlldbg("Too big. considx: %08x prodidx: %08x pktlen: %d rxstat: %08x\n", considx, prodidx, pktlen, *rxstat); - EMAC_STAT(priv, rx_pktsize); + NETDEV_RXERRORS(&priv->lp_dev); } else if ((*rxstat & RXSTAT_INFO_LASTFLAG) == 0) { nlldbg("Fragment. considx: %08x prodidx: %08x pktlen: %d rxstat: %08x\n", considx, prodidx, pktlen, *rxstat); - EMAC_STAT(priv, rx_fragment); + NETDEV_RXFRAGMENTS(&priv->lp_dev); fragment = true; } else if (fragment) { nlldbg("Last fragment. considx: %08x prodidx: %08x pktlen: %d rxstat: %08x\n", considx, prodidx, pktlen, *rxstat); - EMAC_STAT(priv, rx_fragment); + NETDEV_RXFRAGMENTS(&priv->lp_dev); fragment = false; } else @@ -952,12 +908,12 @@ static void lpc17_rxdone_process(struct lpc17_driver_s *priv) if (BUF->type == HTONS(ETHTYPE_IP)) { nllvdbg("IPv4 frame\n"); + NETDEV_RXIPV4(&priv->lp_dev); /* Handle ARP on input then give the IPv4 packet to the * network layer */ - EMAC_STAT(priv, rx_ip); arp_ipin(&priv->lp_dev); ipv4_input(&priv->lp_dev); @@ -994,10 +950,10 @@ static void lpc17_rxdone_process(struct lpc17_driver_s *priv) if (BUF->type == HTONS(ETHTYPE_IP6)) { nllvdbg("Iv6 frame\n"); + NETDEV_RXIPV6(&priv->lp_dev); /* Give the IPv6 packet to the network layer */ - EMAC_STAT(priv, rx_ipv6); ipv6_input(&priv->lp_dev); /* If the above function invocation resulted in data that @@ -1032,7 +988,7 @@ static void lpc17_rxdone_process(struct lpc17_driver_s *priv) #ifdef CONFIG_NET_ARP if (BUF->type == htons(ETHTYPE_ARP)) { - EMAC_STAT(priv, rx_arp); + NETDEV_RXARP(&priv->lp_dev); arp_arpin(&priv->lp_dev); /* If the above function invocation resulted in data that @@ -1050,7 +1006,7 @@ static void lpc17_rxdone_process(struct lpc17_driver_s *priv) { /* Unrecognized... drop it. */ - EMAC_STAT(priv, rx_dropped); + NETDEV_RXDROPPED(&priv->lp_dev); } } @@ -1104,7 +1060,6 @@ static void lpc17_txdone_process(struct lpc17_driver_s *priv) /* Clear the pending condition, send the packet, and restore Rx interrupts */ priv->lp_txpending = false; - EMAC_STAT(priv, tx_unpend); lpc17_transmit(priv); @@ -1229,7 +1184,6 @@ static int lpc17_interrupt(int irq, void *context) #ifdef CONFIG_NET_WOL if ((status & ETH_INT_WKUP) != 0) { - EMAC_STAT(priv, wol); # warning "Missing logic" } else @@ -1250,13 +1204,13 @@ static int lpc17_interrupt(int irq, void *context) if ((status & ETH_INT_RXOVR) != 0) { nlldbg("RX Overrun. status: %08x\n", status); - EMAC_STAT(priv, rx_ovrerrors); + NETDEV_RXERRORS(&priv->lp_dev); } if ((status & ETH_INT_TXUNR) != 0) { nlldbg("TX Underrun. status: %08x\n", status); - EMAC_STAT(priv, tx_underrun); + NETDEV_TXERRORS(&priv->lp_dev); } /* ifup() will reset the EMAC and bring it back up */ @@ -1277,7 +1231,7 @@ static int lpc17_interrupt(int irq, void *context) if ((status & ETH_INT_RXERR) != 0) { nlldbg("RX Error. status: %08x\n", status); - EMAC_STAT(priv, rx_errors); + NETDEV_RXERRORS(&priv->lp_dev); } /* RX FINISHED -- Triggered when all receive descriptors have @@ -1294,8 +1248,6 @@ static int lpc17_interrupt(int irq, void *context) if ((status & ETH_INT_RXFIN) != 0 || (status & ETH_INT_RXDONE) != 0) { - EMAC_STAT(priv, rx_done); - /* We have received at least one new incoming packet. */ #ifdef CONFIG_NET_NOINTS @@ -1331,9 +1283,10 @@ static int lpc17_interrupt(int irq, void *context) if ((status & ETH_INT_TXERR) != 0) { nlldbg("TX Error. status: %08x\n", status); - EMAC_STAT(priv, tx_errors); + NETDEV_TXERRORS(&priv->lp_dev); } +#if 0 /* TX FINISHED -- Triggered when all transmit descriptors have * been processed i.e. on the transition to the situation * where ProduceIndex == ConsumeIndex. @@ -1341,8 +1294,8 @@ static int lpc17_interrupt(int irq, void *context) if ((status & ETH_INT_TXFIN) != 0) { - EMAC_STAT(priv, tx_finished); } +#endif /* TX DONE -- Triggered when a descriptor has been transmitted * while the Interrupt bit in the Control field of the @@ -1351,7 +1304,7 @@ static int lpc17_interrupt(int irq, void *context) if ((status & ETH_INT_TXDONE) != 0) { - EMAC_STAT(priv, tx_done); + NETDEV_TXDONE(&priv->lp_dev); /* A packet transmission just completed */ /* Cancel the pending Tx timeout */ @@ -1422,7 +1375,7 @@ static void lpc17_txtimeout_process(FAR struct lpc17_driver_s *priv) { /* Increment statistics and dump debug info */ - EMAC_STAT(priv, tx_timeouts); + NETDEV_TXTIMEOUTS(&priv->lp_dev); if (priv->lp_ifup) { /* Then reset the hardware. ifup() will reset the interface, then bring diff --git a/arch/arm/src/tiva/Kconfig b/arch/arm/src/tiva/Kconfig index 8d82ab6c541..96b82a46913 100644 --- a/arch/arm/src/tiva/Kconfig +++ b/arch/arm/src/tiva/Kconfig @@ -532,7 +532,9 @@ config TIVA_TIMER7 config TIVA_ETHERNET bool "Ethernet" default n + depends on TIVA_HAVE_ETHERNET select NETDEVICES + select ARCH_HAVE_NETDEV_STATISTICS if ARCH_CHIP_LM3S || ARCH_CHIP_LM4F ---help--- This must be set (along with NET) to build the Stellaris Ethernet driver. diff --git a/arch/arm/src/tiva/Make.defs b/arch/arm/src/tiva/Make.defs index ff3cb347ffb..bd417ea9dcb 100644 --- a/arch/arm/src/tiva/Make.defs +++ b/arch/arm/src/tiva/Make.defs @@ -108,7 +108,7 @@ CHIP_CSRCS += tiva_adclow.c CHIP_CSRCS += tiva_adclib.c endif -ifeq ($(CONFIG_NET),y) +ifeq ($(CONFIG_TIVA_ETHERNET),y) ifeq ($(CONFIG_ARCH_CHIP_LM3S),y) CHIP_CSRCS += lm3s_ethernet.c endif diff --git a/arch/arm/src/tiva/lm3s_ethernet.c b/arch/arm/src/tiva/lm3s_ethernet.c index f37ed156172..d78ed573e49 100644 --- a/arch/arm/src/tiva/lm3s_ethernet.c +++ b/arch/arm/src/tiva/lm3s_ethernet.c @@ -169,34 +169,6 @@ * Private Types ****************************************************************************/ -/* EMAC statistics (debug only) */ - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) -struct tiva_statistics_s -{ - uint32_t rx_int; /* Number of Rx interrupts received */ - uint32_t rx_packets; /* Number of packets received (sum of the following): */ -#ifdef CONFIG_NET_IPv4 - uint32_t rx_ip; /* Number of Rx IPv4 packets received */ -#endif -#ifdef CONFIG_NET_IPv6 - uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */ -#endif - uint32_t rx_arp; /* Number of Rx ARP packets received */ - uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */ - uint32_t rx_pktsize; /* Number of dropped, too small or too big */ - uint32_t rx_errors; /* Number of Rx errors (reception error) */ - uint32_t rx_ovrerrors; /* Number of Rx FIFO overrun errors */ - uint32_t tx_int; /* Number of Tx interrupts received */ - uint32_t tx_packets; /* Number of Tx packets queued */ - uint32_t tx_errors; /* Number of Tx errors (transmission error) */ - uint32_t tx_timeouts; /* Number of Tx timeout errors */ -}; -# define EMAC_STAT(priv,name) priv->ld_stat.name++ -#else -# define EMAC_STAT(priv,name) -#endif - /* The tiva_driver_s encapsulates all state information for a single hardware * interface */ @@ -216,10 +188,6 @@ struct tiva_driver_s WDOG_ID ld_txpoll; /* TX poll timer */ WDOG_ID ld_txtimeout; /* TX timeout timer */ -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) - struct tiva_statistics_s ld_stat; -#endif - /* This holds the information visible to uIP/NuttX */ struct net_driver_s ld_dev; /* Interface understood by uIP */ @@ -518,7 +486,7 @@ static int tiva_transmit(struct tiva_driver_s *priv) { /* Increment statistics */ - EMAC_STAT(priv, tx_packets); + NETDEV_TXPACKETS(&priv->ld_dev); tiva_dumppacket("Transmit packet", priv->ld_dev.d_buf, priv->ld_dev.d_len); /* Transfer the packet into the Tx FIFO. The LS 16-bits of the first @@ -687,7 +655,7 @@ static void tiva_receive(struct tiva_driver_s *priv) { /* Update statistics */ - EMAC_STAT(priv, rx_packets); + NETDEV_RXPACKETS(&priv->ld_dev); /* Copy the data data from the hardware to priv->ld_dev.d_buf. Set * amount of data in priv->ld_dev.d_len @@ -720,7 +688,7 @@ static void tiva_receive(struct tiva_driver_s *priv) /* We will have to drop this packet */ nlldbg("Bad packet size dropped (%d)\n", pktlen); - EMAC_STAT(priv, rx_pktsize); + NETDEV_RXERRORS(&priv->ld_dev); /* The number of bytes and words left to read is pktlen - 4 (including, * the final, possibly partial word) because we've already read 4 bytes. @@ -804,12 +772,12 @@ static void tiva_receive(struct tiva_driver_s *priv) if (ETHBUF->type == HTONS(ETHTYPE_IP)) { nllvdbg("IPv4 frame\n"); + NETDEV_RXIPV4(&priv->ld_dev); /* Handle ARP on input then give the IPv4 packet to the network * layer */ - EMAC_STAT(priv, rx_ip); arp_ipin(&priv->ld_dev); ipv4_input(&priv->ld_dev); @@ -845,10 +813,10 @@ static void tiva_receive(struct tiva_driver_s *priv) if (ETHBUF->type == HTONS(ETHTYPE_IP6)) { nllvdbg("Iv6 frame\n"); + NETDEV_RXIPV6(&priv->ld_dev); /* Give the IPv6 packet to the network layer */ - EMAC_STAT(priv, rx_ipv6); arp_ipin(&priv->ld_dev); ipv6_input(&priv->ld_dev); @@ -884,7 +852,7 @@ static void tiva_receive(struct tiva_driver_s *priv) if (ETHBUF->type == htons(ETHTYPE_ARP)) { nllvdbg("ARP packet received (%02x)\n", ETHBUF->type); - EMAC_STAT(priv, rx_arp); + NETDEV_RXARP(&priv->ld_dev); arp_arpin(&priv->ld_dev); @@ -901,7 +869,7 @@ static void tiva_receive(struct tiva_driver_s *priv) #endif { nlldbg("Unsupported packet type dropped (%02x)\n", htons(ETHBUF->type)); - EMAC_STAT(priv, rx_dropped); + NETDEV_RXDROPPED(&priv->ld_dev); } } } @@ -981,20 +949,26 @@ static int tiva_interrupt(int irq, FAR void *context) /* Check for errors */ -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) +#if defined(CONFIG_NETDEV_STATISTICS) if ((ris & MAC_RIS_TXER) != 0) { - EMAC_STAT(priv, tx_errors); /* Number of Tx errors */ + /* Tx error */ + + NETDEV_TXERRORS(&priv->ld_dev); } if ((ris & MAC_RIS_FOV) != 0) { - EMAC_STAT(priv, rx_ovrerrors); /* Number of Rx FIFO overrun errors */ + /* Rx FIFO overrun */ + + NETDEV_RXERRORS(&priv->ld_dev); } if ((ris & MAC_RIS_RXER) != 0) { - EMAC_STAT(priv, rx_errors); /* Number of Rx errors */ + /* Rx error */ + + NETDEV_RXERRORS(&priv->ld_dev); } #endif @@ -1008,7 +982,6 @@ static int tiva_interrupt(int irq, FAR void *context) { /* Handle the incoming packet */ - EMAC_STAT(priv, rx_int); tiva_receive(priv); } @@ -1018,7 +991,6 @@ static int tiva_interrupt(int irq, FAR void *context) { /* Handle the complete of the transmission */ - EMAC_STAT(priv, tx_int); tiva_txdone(priv); } @@ -1054,7 +1026,7 @@ static void tiva_txtimeout(int argc, uint32_t arg, ...) /* Increment statistics */ nlldbg("Tx timeout\n"); - EMAC_STAT(priv, tx_timeouts); + NETDEV_TXTIMEOUTS(&priv->ld_dev); /* Then reset the hardware */ diff --git a/arch/mips/src/pic32mx/Kconfig b/arch/mips/src/pic32mx/Kconfig index 3a1e2307fc0..91e544de747 100644 --- a/arch/mips/src/pic32mx/Kconfig +++ b/arch/mips/src/pic32mx/Kconfig @@ -666,6 +666,7 @@ config PIC32MX_ETHERNET default n select NETDEVICES select ARCH_HAVE_PHY + select ARCH_HAVE_NETDEV_STATISTICS config PIC32MX_CTMU bool "Charge Time Measurement Unit (CMTU)" diff --git a/arch/mips/src/pic32mx/pic32mx-ethernet.c b/arch/mips/src/pic32mx/pic32mx-ethernet.c index fbc6634333b..4261730ef6e 100644 --- a/arch/mips/src/pic32mx/pic32mx-ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx-ethernet.c @@ -290,42 +290,6 @@ * Private Types ****************************************************************************/ -/* EMAC statistics (debug only) */ - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) -struct pic32mx_statistics_s -{ - uint32_t rx_done; /* Rx done interrupts */ - uint32_t rx_errors; /* Number of Rx error interrupts */ - uint32_t rx_ovflw; /* Number of Rx overflow error interrupts */ - uint32_t rx_bufna; /* Number of Rx buffer not available errors */ - uint32_t rx_buse; /* Number of Rx BVCI bus errors */ - uint32_t rx_packets; /* Number of packets received (sum of the following): */ -#ifdef CONFIG_NET_IPv4 - uint32_t rx_ip; /* Number of Rx IPv4 packets received */ -#endif -#ifdef CONFIG_NET_IPv6 - uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */ -#endif - uint32_t rx_arp; /* Number of Rx ARP packets received */ - uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */ - uint32_t rx_pkterr; /* Number of dropped, error in Rx descriptor */ - uint32_t rx_pktsize; /* Number of dropped, too small or too big */ - uint32_t rx_fragment; /* Number of dropped, packet fragments */ - uint32_t tx_done; /* Tx done interrupts */ - uint32_t tx_errors; /* Number of Tx error interrupts (OR of other errors) */ - uint32_t tx_abort; /* Number of Tx abort interrupts */ - uint32_t tx_buse; /* Number of Tx bus errors */ - uint32_t tx_packets; /* Number of Tx packets queued */ - uint32_t tx_pending; /* Number of Tx packets that had to wait for a TxDesc */ - uint32_t tx_unpend; /* Number of pending Tx packets that were sent */ - uint32_t tx_timeouts; /* Number of Tx timeout errors */ -}; -# define EMAC_STAT(priv,name) priv->pd_stat.name++ -#else -# define EMAC_STAT(priv,name) -#endif - /* The pic32mx_driver_s encapsulates all state information for a single hardware * interface */ @@ -356,10 +320,6 @@ struct pic32mx_driver_s sq_queue_t pd_freebuffers; /* The free buffer list */ -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) - struct pic32mx_statistics_s pd_stat; -#endif - /* This holds the information visible to uIP/NuttX */ struct net_driver_s pd_dev; /* Interface understood by uIP */ @@ -1051,7 +1011,7 @@ static int pic32mx_transmit(struct pic32mx_driver_s *priv) /* Increment statistics and dump the packet (if so configured) */ - EMAC_STAT(priv, tx_packets); + NETDEV_TXPACKETS(&priv->pd_dev); pic32mx_dumppacket("Transmit packet", priv->pd_dev.d_buf, priv->pd_dev.d_len); /* In order to transmit a message: @@ -1348,7 +1308,6 @@ static void pic32mx_response(struct pic32mx_driver_s *priv) priv->pd_txpending = true; priv->pd_inten &= ~ETH_RXINTS; pic32mx_putreg(priv->pd_inten, PIC32MX_ETH_IEN); - EMAC_STAT(priv, tx_pending); } } @@ -1397,7 +1356,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) /* Update statistics */ - EMAC_STAT(priv, rx_packets); + NETDEV_RXPACKETS(&priv->pd_dev); /* Get the packet length */ @@ -1408,7 +1367,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) if ((rxdesc->rsv2 & RXDESC_RSV2_OK) == 0) { nlldbg("ERROR. rsv1: %08x rsv2: %08x\n", rxdesc->rsv1, rxdesc->rsv2); - EMAC_STAT(priv, rx_pkterr); + NETDEV_RXERRORS(&priv->pd_dev); pic32mx_rxreturn(rxdesc); } @@ -1422,7 +1381,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) { nlldbg("Too big. packet length: %d rxdesc: %08x\n", priv->pd_dev.d_len, rxdesc->status); - EMAC_STAT(priv, rx_pktsize); + NETDEV_RXERRORS(&priv->pd_dev); pic32mx_rxreturn(rxdesc); } @@ -1432,7 +1391,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) (RXDESC_STATUS_EOP | RXDESC_STATUS_SOP)) { nlldbg("Fragment. packet length: %d rxdesc: %08x\n", priv->pd_dev.d_len, rxdesc->status); - EMAC_STAT(priv, rx_fragment); + NETDEV_RXFRAGMENTS(&priv->pd_dev); pic32mx_rxreturn(rxdesc); } else @@ -1470,12 +1429,12 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) if (BUF->type == HTONS(ETHTYPE_IP)) { nllvdbg("IPv4 frame\n"); + NETDEV_RXIPV4(&priv->pd_dev); /* Handle ARP on input then give the IPv4 packet to the network * layer */ - EMAC_STAT(priv, rx_ip); arp_ipin(&priv->pd_dev); ipv4_input(&priv->pd_dev); @@ -1512,10 +1471,10 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) if (BUF->type == HTONS(ETHTYPE_IP6)) { nllvdbg("Iv6 frame\n"); + NETDEV_RXIPV6(&priv->pd_dev); /* Give the IPv6 packet to the network layer */ - EMAC_STAT(priv, rx_ipv6); ipv6_input(&priv->pd_dev); /* If the above function invocation resulted in data that @@ -1552,7 +1511,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) { /* Handle the incoming ARP packet */ - EMAC_STAT(priv, rx_arp); + NETDEV_RXARP(&priv->pd_dev); arp_arpin(&priv->pd_dev); /* If the above function invocation resulted in data that @@ -1571,7 +1530,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) /* Unrecognized... drop it. */ nlldbg("Unrecognized packet type dropped: %04x\n", ntohs(BUF->type)); - EMAC_STAT(priv, rx_dropped); + NETDEV_RXDROPPED(&priv->pd_dev); } /* Discard any buffers still attached to the device structure */ @@ -1669,7 +1628,6 @@ static void pic32mx_txdone(struct pic32mx_driver_s *priv) /* Clear the pending condition, send the packet, and restore Rx interrupts */ priv->pd_txpending = false; - EMAC_STAT(priv, tx_unpend); pic32mx_transmit(priv); @@ -1733,9 +1691,8 @@ static int pic32mx_interrupt(int irq, void *context) if ((status & ETH_INT_RXOVFLW) != 0) { - nlldbg("RX Overrun. status: %08x\n", status); - EMAC_STAT(priv, rx_errors); - EMAC_STAT(priv, rx_ovflw); + nlldbg("RX Overrun. status: %08x\n", status); + NETDEV_RXERRORS(&priv->pd_dev); } /* RXBUFNA: Receive Buffer Not Available Interrupt. This bit is set by @@ -1746,8 +1703,7 @@ static int pic32mx_interrupt(int irq, void *context) if ((status & ETH_INT_RXBUFNA) != 0) { nlldbg("RX buffer descriptor overrun. status: %08x\n", status); - EMAC_STAT(priv, rx_errors); - EMAC_STAT(priv, rx_bufna); + NETDEV_RXERRORS(&priv->pd_dev); } /* RXBUSE: Receive BVCI Bus Error Interrupt. This bit is set when the @@ -1758,8 +1714,7 @@ static int pic32mx_interrupt(int irq, void *context) if ((status & ETH_INT_RXBUSE) != 0) { nlldbg("RX BVCI bus error. status: %08x\n", status); - EMAC_STAT(priv, rx_errors); - EMAC_STAT(priv, rx_buse); + NETDEV_RXERRORS(&priv->pd_dev); } /* Receive Normal Events **********************************************/ @@ -1781,8 +1736,6 @@ static int pic32mx_interrupt(int irq, void *context) if ((status & ETH_INT_RXDONE) != 0) { - EMAC_STAT(priv, rx_done); - /* We have received at least one new incoming packet. */ pic32mx_rxdone(priv); @@ -1804,8 +1757,7 @@ static int pic32mx_interrupt(int irq, void *context) if ((status & ETH_INT_TXABORT) != 0) { nlldbg("TX abort. status: %08x\n", status); - EMAC_STAT(priv, tx_errors); - EMAC_STAT(priv, tx_abort); + NETDEV_TXERRORS(&priv->pd_dev); } /* TXBUSE: Transmit BVCI Bus Error Interrupt. This bit is set when the @@ -1816,8 +1768,7 @@ static int pic32mx_interrupt(int irq, void *context) if ((status & ETH_INT_TXBUSE) != 0) { nlldbg("TX BVCI bus error. status: %08x\n", status); - EMAC_STAT(priv, tx_errors); - EMAC_STAT(priv, tx_buse); + NETDEV_TXERRORS(&priv->pd_dev); } /* TXDONE: Transmit Done Interrupt. This bit is set when the currently @@ -1829,7 +1780,7 @@ static int pic32mx_interrupt(int irq, void *context) if ((status & ETH_INT_TXDONE) != 0) { - EMAC_STAT(priv, tx_done); + NETDEV_TXDONE(&priv->pd_dev); /* A packet transmission just completed */ @@ -1889,7 +1840,7 @@ static void pic32mx_txtimeout(int argc, uint32_t arg, ...) /* Increment statistics and dump debug info */ - EMAC_STAT(priv, tx_timeouts); + NETDEV_TXTIMEOUTS(&priv->pd_dev); if (priv->pd_ifup) { /* Then reset the hardware. ifup() will reset the interface, then bring diff --git a/arch/mips/src/pic32mz/Kconfig b/arch/mips/src/pic32mz/Kconfig index 76db5f37dae..7a6cc7079fb 100644 --- a/arch/mips/src/pic32mz/Kconfig +++ b/arch/mips/src/pic32mz/Kconfig @@ -259,6 +259,7 @@ config PIC32MZ_ETHERNET default n select NETDEVICES select ARCH_HAVE_PHY + select ARCH_HAVE_NETDEV_STATISTICS config PIC32MZ_CTMU bool "Charge Time Measurement Unit (CMTU)" diff --git a/arch/mips/src/pic32mz/pic32mz-ethernet.c b/arch/mips/src/pic32mz/pic32mz-ethernet.c index 4445a580f86..e2f3e1e635b 100644 --- a/arch/mips/src/pic32mz/pic32mz-ethernet.c +++ b/arch/mips/src/pic32mz/pic32mz-ethernet.c @@ -308,42 +308,6 @@ * Private Types ****************************************************************************/ -/* EMAC statistics (debug only) */ - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) -struct pic32mz_statistics_s -{ - uint32_t rx_done; /* Rx done interrupts */ - uint32_t rx_errors; /* Number of Rx error interrupts */ - uint32_t rx_ovflw; /* Number of Rx overflow error interrupts */ - uint32_t rx_bufna; /* Number of Rx buffer not available errors */ - uint32_t rx_buse; /* Number of Rx BVCI bus errors */ - uint32_t rx_packets; /* Number of packets received (sum of the following): */ -#ifdef CONFIG_NET_IPv4 - uint32_t rx_ip; /* Number of Rx IPv4 packets received */ -#endif -#ifdef CONFIG_NET_IPv6 - uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */ -#endif - uint32_t rx_arp; /* Number of Rx ARP packets received */ - uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */ - uint32_t rx_pkterr; /* Number of dropped, error in Rx descriptor */ - uint32_t rx_pktsize; /* Number of dropped, too small or too big */ - uint32_t rx_fragment; /* Number of dropped, packet fragments */ - uint32_t tx_done; /* Tx done interrupts */ - uint32_t tx_errors; /* Number of Tx error interrupts (OR of other errors) */ - uint32_t tx_abort; /* Number of Tx abort interrupts */ - uint32_t tx_buse; /* Number of Tx bus errors */ - uint32_t tx_packets; /* Number of Tx packets queued */ - uint32_t tx_pending; /* Number of Tx packets that had to wait for a TxDesc */ - uint32_t tx_unpend; /* Number of pending Tx packets that were sent */ - uint32_t tx_timeouts; /* Number of Tx timeout errors */ -}; -# define EMAC_STAT(priv,name) priv->pd_stat.name++ -#else -# define EMAC_STAT(priv,name) -#endif - /* The pic32mz_driver_s encapsulates all state information for a single hardware * interface */ @@ -374,10 +338,6 @@ struct pic32mz_driver_s sq_queue_t pd_freebuffers; /* The free buffer list */ -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET) - struct pic32mz_statistics_s pd_stat; -#endif - /* This holds the information visible to uIP/NuttX */ struct net_driver_s pd_dev; /* Interface understood by uIP */ @@ -1069,7 +1029,7 @@ static int pic32mz_transmit(struct pic32mz_driver_s *priv) /* Increment statistics and dump the packet (if so configured) */ - EMAC_STAT(priv, tx_packets); + NETDEV_TXPACKETS(&priv->pd_dev); pic32mz_dumppacket("Transmit packet", priv->pd_dev.d_buf, priv->pd_dev.d_len); /* In order to transmit a message: @@ -1366,7 +1326,6 @@ static void pic32mz_response(struct pic32mz_driver_s *priv) priv->pd_txpending = true; priv->pd_inten &= ~ETH_RXINTS; pic32mz_putreg(priv->pd_inten, PIC32MZ_ETH_IEN); - EMAC_STAT(priv, tx_pending); } } @@ -1415,7 +1374,7 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv) /* Update statistics */ - EMAC_STAT(priv, rx_packets); + NETDEV_RXPACKETS(&priv->pd_dev); /* Get the packet length */ @@ -1426,7 +1385,7 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv) if ((rxdesc->rsv2 & RXDESC_RSV2_OK) == 0) { nlldbg("ERROR. rsv1: %08x rsv2: %08x\n", rxdesc->rsv1, rxdesc->rsv2); - EMAC_STAT(priv, rx_pkterr); + NETDEV_RXERRORS(&priv->pd_dev); pic32mz_rxreturn(rxdesc); } @@ -1439,7 +1398,7 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv) else if (priv->pd_dev.d_len > CONFIG_NET_ETH_MTU) { nlldbg("Too big. packet length: %d rxdesc: %08x\n", priv->pd_dev.d_len, rxdesc->status); - EMAC_STAT(priv, rx_pktsize); + NETDEV_RXERRORS(&priv->pd_dev); pic32mz_rxreturn(rxdesc); } @@ -1449,7 +1408,7 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv) (RXDESC_STATUS_EOP | RXDESC_STATUS_SOP)) { nlldbg("Fragment. packet length: %d rxdesc: %08x\n", priv->pd_dev.d_len, rxdesc->status); - EMAC_STAT(priv, rx_fragment); + NETDEV_RXFRAGMENTS(&priv->pd_dev); pic32mz_rxreturn(rxdesc); } else @@ -1487,12 +1446,12 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv) if (BUF->type == HTONS(ETHTYPE_IP)) { nllvdbg("IPv4 frame\n"); + NETDEV_RXIPV4(&priv->pd_dev); /* Handle ARP on input then give the IPv4 packet to the network * layer */ - EMAC_STAT(priv, rx_ip); arp_ipin(&priv->pd_dev); ipv4_input(&priv->pd_dev); @@ -1529,10 +1488,10 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv) if (BUF->type == HTONS(ETHTYPE_IP6)) { nllvdbg("Iv6 frame\n"); + NETDEV_RXIPV6(&priv->pd_dev); /* Give the IPv6 packet to the network layer */ - EMAC_STAT(priv, rx_ipv6); ipv6_input(&priv->pd_dev); /* If the above function invocation resulted in data that @@ -1569,7 +1528,7 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv) { /* Handle the incoming ARP packet */ - EMAC_STAT(priv, rx_arp); + NETDEV_RXARP(&priv->pd_dev); arp_arpin(&priv->pd_dev); /* If the above function invocation resulted in data that @@ -1588,7 +1547,7 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv) /* Unrecognized... drop it. */ nlldbg("Unrecognized packet type dropped: %04x\n", ntohs(BUF->type)); - EMAC_STAT(priv, rx_dropped); + NETDEV_RXDROPPED(&priv->pd_dev); } /* Discard any buffers still attached to the device structure */ @@ -1686,7 +1645,6 @@ static void pic32mz_txdone(struct pic32mz_driver_s *priv) /* Clear the pending condition, send the packet, and restore Rx interrupts */ priv->pd_txpending = false; - EMAC_STAT(priv, tx_unpend); pic32mz_transmit(priv); @@ -1750,9 +1708,8 @@ static int pic32mz_interrupt(int irq, void *context) if ((status & ETH_INT_RXOVFLW) != 0) { - nlldbg("RX Overrun. status: %08x\n", status); - EMAC_STAT(priv, rx_errors); - EMAC_STAT(priv, rx_ovflw); + nlldbg("RX Overrun. status: %08x\n", status); + NETDEV_RXERRORS(&priv->pd_dev); } /* RXBUFNA: Receive Buffer Not Available Interrupt. This bit is set by @@ -1763,8 +1720,7 @@ static int pic32mz_interrupt(int irq, void *context) if ((status & ETH_INT_RXBUFNA) != 0) { nlldbg("RX buffer descriptor overrun. status: %08x\n", status); - EMAC_STAT(priv, rx_errors); - EMAC_STAT(priv, rx_bufna); + NETDEV_RXERRORS(&priv->pd_dev); } /* RXBUSE: Receive BVCI Bus Error Interrupt. This bit is set when the @@ -1775,8 +1731,7 @@ static int pic32mz_interrupt(int irq, void *context) if ((status & ETH_INT_RXBUSE) != 0) { nlldbg("RX BVCI bus error. status: %08x\n", status); - EMAC_STAT(priv, rx_errors); - EMAC_STAT(priv, rx_buse); + NETDEV_RXERRORS(&priv->pd_dev); } /* Receive Normal Events **********************************************/ @@ -1798,8 +1753,6 @@ static int pic32mz_interrupt(int irq, void *context) if ((status & ETH_INT_RXDONE) != 0) { - EMAC_STAT(priv, rx_done); - /* We have received at least one new incoming packet. */ pic32mz_rxdone(priv); @@ -1821,8 +1774,7 @@ static int pic32mz_interrupt(int irq, void *context) if ((status & ETH_INT_TXABORT) != 0) { nlldbg("TX abort. status: %08x\n", status); - EMAC_STAT(priv, tx_errors); - EMAC_STAT(priv, tx_abort); + NETDEV_TXERRORS(&priv->pd_dev); } /* TXBUSE: Transmit BVCI Bus Error Interrupt. This bit is set when the @@ -1833,8 +1785,7 @@ static int pic32mz_interrupt(int irq, void *context) if ((status & ETH_INT_TXBUSE) != 0) { nlldbg("TX BVCI bus error. status: %08x\n", status); - EMAC_STAT(priv, tx_errors); - EMAC_STAT(priv, tx_buse); + NETDEV_TXERRORS(&priv->pd_dev); } /* TXDONE: Transmit Done Interrupt. This bit is set when the currently @@ -1846,7 +1797,7 @@ static int pic32mz_interrupt(int irq, void *context) if ((status & ETH_INT_TXDONE) != 0) { - EMAC_STAT(priv, tx_done); + NETDEV_TXDONE(&priv->pd_dev); /* A packet transmission just completed */ @@ -1906,7 +1857,7 @@ static void pic32mz_txtimeout(int argc, uint32_t arg, ...) /* Increment statistics and dump debug info */ - EMAC_STAT(priv, tx_timeouts); + NETDEV_TXTIMEOUTS(&priv->pd_dev); if (priv->pd_ifup) { /* Then reset the hardware. ifup() will reset the interface, then bring diff --git a/arch/z80/src/ez80/Kconfig b/arch/z80/src/ez80/Kconfig index 856a4722fb4..f3f457210ce 100644 --- a/arch/z80/src/ez80/Kconfig +++ b/arch/z80/src/ez80/Kconfig @@ -26,6 +26,7 @@ config EZ80_EMAC bool "Ethernet MAC" default n select ARCH_HAVE_PHY + select ARCH_HAVE_NETDEV_STATISTICS ---help--- Enables support for ez80 EMAC driver. From 8ce454a5840e9433b18a1727f26fd486dc8c1b64 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 26 Nov 2015 12:46:53 -0600 Subject: [PATCH 14/17] Remove some warnings; eliminate unused variables --- arch/arm/src/stm32/stm32_adc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c index 514e707cf30..903a216b6c6 100644 --- a/arch/arm/src/stm32/stm32_adc.c +++ b/arch/arm/src/stm32/stm32_adc.c @@ -819,12 +819,10 @@ static int adc_timinit(FAR struct stm32_dev_s *priv) { uint32_t prescaler; uint32_t reload; - uint32_t regval; uint32_t timclk; uint16_t clrbits = 0; uint16_t setbits = 0; - uint16_t cr1; uint16_t cr2; uint16_t ccmr1; uint16_t ccmr2; @@ -1060,7 +1058,7 @@ static int adc_timinit(FAR struct stm32_dev_s *priv) ccer &= ~ccenable; tim_putreg(priv, STM32_GTIM_CCER_OFFSET, ccer); - /* Fetch the CR2, CCMR1, and CCMR2 register (already have cr1 and ccer) */ + /* Fetch the CR2, CCMR1, and CCMR2 register (already have ccer) */ cr2 = tim_getreg(priv, STM32_GTIM_CR2_OFFSET); ccmr1 = tim_getreg(priv, STM32_GTIM_CCMR1_OFFSET); From 4d2299896e3b35aab386298aa0305dad628d1c3a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 27 Nov 2015 12:30:15 -0600 Subject: [PATCH 15/17] SAMV7: Add support to network device statistics to the Ethernet driver --- arch/arm/src/samv7/Kconfig | 1 + arch/arm/src/samv7/sam_emac.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/arm/src/samv7/Kconfig b/arch/arm/src/samv7/Kconfig index a0ab217067a..d4d1354d884 100644 --- a/arch/arm/src/samv7/Kconfig +++ b/arch/arm/src/samv7/Kconfig @@ -208,6 +208,7 @@ config SAMV7_EMAC bool default n select ARMV7M_DCACHE_WRITETHROUGH if ARMV7M_DCACHE + select ARCH_HAVE_NETDEV_STATISTICS ---help--- NOTE that write-through caching is automatically selected. This is to work around issues with the RX and TX descriptors with are 8-bytes diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index b7eab4a95ce..72b42c2205e 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -1364,6 +1364,8 @@ static int sam_transmit(struct sam_emac_s *priv, int qid) uint32_t status; uint16_t txhead; + NETDEV_TXPACKETS(&priv->dev); + /* Check parameter */ if (dev->d_len > EMAC_TX_UNITSIZE) @@ -1642,6 +1644,8 @@ static int sam_recvframe(struct sam_emac_s *priv, int qid) while ((rxdesc->addr & EMACRXD_ADDR_OWNER) != 0) { + NETDEV_RXFRAGMENTS(&priv->dev); + /* The start of frame bit indicates the beginning of a frame. Discard * any previous fragments. */ @@ -1722,6 +1726,7 @@ static int sam_recvframe(struct sam_emac_s *priv, int qid) } while (rxndx != xfrq->rxndx); + NETDEV_RXERRORS(&priv->dev); return -EIO; } @@ -1796,6 +1801,7 @@ static int sam_recvframe(struct sam_emac_s *priv, int qid) { nlldbg("ERROR: Buffer size %d; frame size %d\n", dev->d_len, pktlen); + NETDEV_RXERRORS(&priv->dev); return -E2BIG; } @@ -1876,6 +1882,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid) while (sam_recvframe(priv, qid) == OK) { sam_dumppacket("Received packet", dev->d_buf, dev->d_len); + NETDEV_RXPACKETS(&priv->dev); /* Check if the packet is a valid size for the network buffer * configuration (this should not happen) @@ -1884,6 +1891,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + NETDEV_RXERRORS(&priv->dev); continue; } @@ -1899,6 +1907,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid) if (BUF->type == HTONS(ETHTYPE_IP)) { nllvdbg("IPv4 frame\n"); + NETDEV_RXIPV4(&priv->dev); /* Handle ARP on input then give the IPv4 packet to the network * layer @@ -1939,6 +1948,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid) if (BUF->type == HTONS(ETHTYPE_IP6)) { nllvdbg("Iv6 frame\n"); + NETDEV_RXIPV6(&priv->dev); /* Give the IPv6 packet to the network layer */ @@ -1976,6 +1986,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid) if (BUF->type == htons(ETHTYPE_ARP)) { nllvdbg("ARP frame\n"); + NETDEV_RXARP(&priv->dev); /* Handle ARP packet */ @@ -1994,6 +2005,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid) #endif { nlldbg("DROPPED: Unknown type: %04x\n", BUF->type); + NETDEV_RXDROPPED(&priv->dev); } } } @@ -2052,6 +2064,8 @@ static void sam_txdone(struct sam_emac_s *priv, int qid) break; } + NETDEV_TXDONE(&priv->dev); + /* Process all buffers of the current transmitted frame */ while (tail != xfrq->txhead && @@ -2121,6 +2135,8 @@ static void sam_txerr_interrupt(FAR struct sam_emac_s *priv, int qid) uint32_t regval; uint16_t tail; + NETDEV_TXERRORS(&priv->dev); + /* Clear TXEN bit into the Network Configuration Register. This is a * workaround to recover from TX lockups that occur on sama5d3 gmac * (r1p24f2) when using scatter-gather. This issue has never been @@ -2360,6 +2376,7 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv, int qid) if ((tsr & EMAC_TSR_COL) != 0) { nlldbg("ERROR: Collision occurred TSR: %08x\n", tsr); + NETDEV_TXERRORS(&priv->dev); } /* Check Transmit Frame Corruption due to AHB error (TFC) */ @@ -2367,6 +2384,7 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv, int qid) if ((tsr & EMAC_TSR_TFC) != 0) { nlldbg("ERROR: Transmit Frame Corruption due to AHB error: %08x\n", tsr); + NETDEV_TXERRORS(&priv->dev); } /* Clear status */ @@ -2562,6 +2580,7 @@ static int sam_emac1_interrupt(int irq, void *context) static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) { nlldbg("Timeout!\n"); + NETDEV_TXTIMEOUTS(&priv->dev); /* Reset the hardware. Just take the interface down, then back up again. */ From e421258808e86735f901a90ae22fe89d4302f055 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 29 Nov 2015 13:54:03 -0600 Subject: [PATCH 16/17] Move sim/src/up_appinit.c to configs/sim/src where it really belongs --- arch/sim/src/Makefile | 4 --- arch/sim/src/up_appinit.c | 65 --------------------------------------- 2 files changed, 69 deletions(-) delete mode 100644 arch/sim/src/up_appinit.c diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index b813e883fc2..7bdfcf968f0 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -70,10 +70,6 @@ ifeq ($(CONFIG_DEV_CONSOLE),y) HOSTSRCS += up_simuart.c endif -ifeq ($(CONFIG_LIB_BOARDCTL),y) - CSRCS += up_appinit.c -endif - ifeq ($(CONFIG_NX_LCDDRIVER),y) CSRCS += board_lcd.c else diff --git a/arch/sim/src/up_appinit.c b/arch/sim/src/up_appinit.c deleted file mode 100644 index e1e9ff9701f..00000000000 --- a/arch/sim/src/up_appinit.c +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** - * arch/sim/src/up_appinit.c - * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. - * 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 - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_app_initialize - * - * Description: - * Perform application specific initialization. This function is never - * called directly from application code, but only indirectly via the - * (non-standard) boardctl() interface using the command BOARDIOC_INIT. - * - ****************************************************************************/ - -#ifdef CONFIG_LIB_BOARDCTL -int board_app_initialize(void) -{ - return 0; -} -#endif /* CONFIG_LIB_BOARDCTL */ From 5367c5993cca2ce961293962dd342479947ff698 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 30 Nov 2015 15:21:25 -0600 Subject: [PATCH 17/17] SAMV7: Add some conditional logic to handle the case where the board has no 32.768KHz crystal installed --- arch/arm/src/samv7/sam_clockconfig.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/samv7/sam_clockconfig.c b/arch/arm/src/samv7/sam_clockconfig.c index a15f06933ef..f45304ce3e7 100644 --- a/arch/arm/src/samv7/sam_clockconfig.c +++ b/arch/arm/src/samv7/sam_clockconfig.c @@ -131,7 +131,11 @@ static inline void sam_wdtsetup(void) static inline void sam_supcsetup(void) { - /* Check if the 32-kHz is already selected */ +#ifdef BOARD_HAVE_SLOWXTAL + /* Check if the 32-kHz is already selected. The slow clock defaults to + * the RC oscillator, but the software can enable the crystal oscillator + * and select it as the slow clock source. + */ if ((getreg32(SAM_SUPC_SR) & SUPC_SR_OSCSEL) == 0) { @@ -142,6 +146,7 @@ static inline void sam_supcsetup(void) (getreg32(SAM_SUPC_SR) & SUPC_SR_OSCSEL) == 0 && delay < UINT32_MAX; delay++); } +#endif } /****************************************************************************