This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 9ea015f26fb106f47e09f65bb08be5978706a4a7
Author: raiden00pl <[email protected]>
AuthorDate: Mon Nov 16 13:56:29 2026 +0100

    !arch/arm/stm32: use the netdev upper half in the m3m4 v1 Ethernet driver.
    
    Convert stm32_eth_m3m4_v1.c to the lower half API.  Frames are sent and
    received in place: each DMA descriptor owns one IOB and a frame spans
    several descriptors, so the static frame buffers are gone.  The frames
    are received in the interrupt work (NETDEV_RX_DIRECT).  The driver
    selects ARCH_HAVE_NETDEV_STATISTICS.
    
    BREAKING CHANGE: the RX/TX rings now take their buffers from the IOB
    pool. Configurations with too few IOBs fail to build, and a received
    frame is dropped when no IOB is free.  CONFIG_STM32_ETH_BUFSIZE is not
    used anymore, the buffers are IOBs.  Quick fix: set
    CONFIG_IOB_NBUFFERS=100 and CONFIG_IOB_THROTTLE=8.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: raiden00pl <[email protected]>
---
 arch/arm/src/common/stm32/Kconfig.periph           |    1 +
 arch/arm/src/common/stm32/stm32_eth_m3m4_v1.c      | 1533 +++++++++-----------
 boards/arm/stm32f1/cloudctrl/configs/nsh/defconfig |    2 +
 .../olimex-stm32-p107/configs/nsh/defconfig        |    2 +
 boards/arm/stm32f1/shenzhou/configs/nsh/defconfig  |    2 +
 boards/arm/stm32f1/shenzhou/configs/nxwm/defconfig |    2 +
 .../arm/stm32f1/shenzhou/configs/thttpd/defconfig  |    2 +
 .../stm32butterfly2/configs/nshnet/defconfig       |    2 +
 .../viewtool-stm32f107/configs/netnsh/defconfig    |    2 +-
 .../configs/tcpblaster/defconfig                   |    2 +-
 .../stm32f2/nucleo-f207zg/configs/netnsh/defconfig |    2 +
 .../olimex-stm32-p207/configs/nsh/defconfig        |    2 +
 .../stm32f2/stm3220g-eval/configs/dhcpd/defconfig  |    2 +
 .../stm3220g-eval/configs/nettest/defconfig        |    2 +
 .../stm32f2/stm3220g-eval/configs/nsh/defconfig    |    2 +
 .../stm32f2/stm3220g-eval/configs/nsh2/defconfig   |    2 +
 .../stm32f2/stm3220g-eval/configs/nxwm/defconfig   |    2 +
 .../stm3220g-eval/configs/telnetd/defconfig        |    2 +
 .../stm32f4/nucleo-f429zi/configs/netnsh/defconfig |    2 +
 .../stm32f4/nucleo-f429zi/configs/trace/defconfig  |    2 +
 .../olimex-stm32-e407/configs/discover/defconfig   |    2 +
 .../olimex-stm32-e407/configs/netnsh/defconfig     |    2 +
 .../olimex-stm32-e407/configs/telnetd/defconfig    |    2 +
 .../olimex-stm32-e407/configs/webserver/defconfig  |    2 +
 .../olimex-stm32-p407/configs/mqttc/defconfig      |    1 +
 .../stm32f4/stm3240g-eval/configs/dhcpd/defconfig  |    2 +
 .../stm3240g-eval/configs/discover/defconfig       |    2 +
 .../stm3240g-eval/configs/nettest/defconfig        |    2 +
 .../stm32f4/stm3240g-eval/configs/nsh/defconfig    |    2 +
 .../stm32f4/stm3240g-eval/configs/nsh2/defconfig   |    2 +
 .../stm32f4/stm3240g-eval/configs/nxterm/defconfig |    2 +
 .../stm32f4/stm3240g-eval/configs/nxwm/defconfig   |    2 +
 .../stm3240g-eval/configs/telnetd/defconfig        |    2 +
 .../stm3240g-eval/configs/webserver/defconfig      |    2 +
 .../stm32f4/stm3240g-eval/configs/xmlrpc/defconfig |    2 +
 .../stm32f4discovery/configs/ipv6/defconfig        |    1 +
 .../stm32f4discovery/configs/netnsh/defconfig      |    1 +
 37 files changed, 726 insertions(+), 875 deletions(-)

diff --git a/arch/arm/src/common/stm32/Kconfig.periph 
b/arch/arm/src/common/stm32/Kconfig.periph
index 1fa9720ee29..e40a232d25c 100644
--- a/arch/arm/src/common/stm32/Kconfig.periph
+++ b/arch/arm/src/common/stm32/Kconfig.periph
@@ -1119,6 +1119,7 @@ config STM32_ETHMAC
        select NETDEVICES
        select ARCH_HAVE_PHY
        select STM32_PHY_HAVE_POLLED if !STM32_COMMON_LEGACY
+       select ARCH_HAVE_NETDEV_STATISTICS
 
 # CORDIC peripherals
 
diff --git a/arch/arm/src/common/stm32/stm32_eth_m3m4_v1.c 
b/arch/arm/src/common/stm32/stm32_eth_m3m4_v1.c
index c725636dcf7..530564fdfcc 100644
--- a/arch/arm/src/common/stm32/stm32_eth_m3m4_v1.c
+++ b/arch/arm/src/common/stm32/stm32_eth_m3m4_v1.c
@@ -42,13 +42,14 @@
 
 #include <nuttx/arch.h>
 #include <nuttx/irq.h>
+#include <nuttx/mutex.h>
 #include <nuttx/queue.h>
 #include <nuttx/wdog.h>
 #include <nuttx/wqueue.h>
 #include <nuttx/net/phy.h>
 #include <nuttx/net/mii.h>
 #include <nuttx/net/ip.h>
-#include <nuttx/net/netdev.h>
+#include <nuttx/net/netdev_lowerhalf.h>
 #include <nuttx/spinlock.h>
 
 #if defined(CONFIG_NET_PKT)
@@ -227,44 +228,65 @@
 
 #undef CONFIG_STM32_ETH_HWCHECKSUM
 
-/* Add 4 to the configured buffer size to account for the 2 byte checksum
- * memory needed at the end of the maximum size packet.  Buffer sizes must
- * be an even multiple of 4, 8, or 16 bytes (depending on buswidth).  We
- * will use the 16-byte alignment in all cases.
+/* Each DMA buffer is one IOB.  The frame starts at netpkt_getdata(), the
+ * buffer size is a multiple of 4 bytes (the DMA bus width) and fills the
+ * IOB, so that the network does not need to pack the received buffers.
  */
 
-#define OPTIMAL_ETH_BUFSIZE ((CONFIG_NET_ETH_PKTSIZE + 4 + 15) & ~15)
-
-#ifndef CONFIG_STM32_ETH_BUFSIZE
-#  define CONFIG_STM32_ETH_BUFSIZE OPTIMAL_ETH_BUFSIZE
+#if CONFIG_NET_LL_GUARDSIZE < ETH_HDRLEN
+#  error "CONFIG_NET_LL_GUARDSIZE must be at least ETH_HDRLEN"
 #endif
 
-#if CONFIG_STM32_ETH_BUFSIZE > ETH_TDES1_TBS1_MASK
-#  error "CONFIG_STM32_ETH_BUFSIZE is too large"
-#endif
+/* The DMA ignores the low address bits of the RX buffers of the middle and
+ * the last segments of a frame: the buffers must be word aligned.
+ */
 
-#if (CONFIG_STM32_ETH_BUFSIZE & 15) != 0
-#  error "CONFIG_STM32_ETH_BUFSIZE must be aligned"
+#if (CONFIG_IOB_ALIGNMENT % 4) != 0 || \
+    ((CONFIG_NET_LL_GUARDSIZE - ETH_HDRLEN) % 4) != 0
+#  error "The Ethernet DMA buffers must be word aligned"
 #endif
 
-#if CONFIG_STM32_ETH_BUFSIZE != OPTIMAL_ETH_BUFSIZE
-#  warning "You using an incomplete/untested configuration"
+#define STM32_ETH_BUFSIZE \
+  ((CONFIG_IOB_BUFSIZE - (CONFIG_NET_LL_GUARDSIZE - ETH_HDRLEN)) & ~3)
+
+#if STM32_ETH_BUFSIZE > ETH_TDES1_TBS1_MASK
+#  error "CONFIG_IOB_BUFSIZE is too large"
 #endif
 
+/* DMA buffers of the largest frame, with the 4 byte CRC */
+
+#define STM32_ETH_NSEGS \
+  ((CONFIG_NET_ETH_PKTSIZE + 4 + STM32_ETH_BUFSIZE - 1) / STM32_ETH_BUFSIZE)
+
+/* Number of RX and TX frames.  The descriptor rings have STM32_ETH_NSEGS
+ * descriptors for each frame.
+ */
+
 #ifndef CONFIG_STM32_ETH_NRXDESC
 #  define CONFIG_STM32_ETH_NRXDESC 8
 #endif
 #ifndef CONFIG_STM32_ETH_NTXDESC
 #  define CONFIG_STM32_ETH_NTXDESC 4
 #endif
+
+#define STM32_ETH_NRXBUF  (CONFIG_STM32_ETH_NRXDESC * STM32_ETH_NSEGS)
+#define STM32_ETH_NTXBUF  (CONFIG_STM32_ETH_NTXDESC * STM32_ETH_NSEGS)
+
+/* IOBs held by the driver: the RX ring and the new IOBs of one received
+ * frame, and one packet for each TX frame.
+ */
+
+#define STM32_ETH_RXIOBS  (STM32_ETH_NRXBUF + STM32_ETH_NSEGS)
+#define STM32_ETH_TXPKTS  CONFIG_STM32_ETH_NTXDESC
+
+#if STM32_ETH_RXIOBS + STM32_ETH_TXPKTS > CONFIG_IOB_NBUFFERS
+#  error "CONFIG_IOB_NBUFFERS is too small for the Ethernet DMA rings"
+#endif
+
 #ifndef CONFIG_STM32_ETH_TXTIMEOUT
 #  define CONFIG_STM32_ETH_TXTIMEOUT 60
 #endif
 
-/* We need at least one more free buffer than transmit buffers */
-
-#define STM32_ETH_NFREEBUFFERS (CONFIG_STM32_ETH_NTXDESC+1)
-
 /* Extremely detailed register debug that you would normally never want
  * enabled.
  */
@@ -591,14 +613,6 @@
 
 #define ETH_DMAINT_ERROR_ENABLE (ETH_DMAINT_AIS | ETH_DMAINT_ABNORMAL)
 
-/* Helpers ******************************************************************/
-
-/* This is a helper pointer for accessing the contents of the Ethernet
- * header
- */
-
-#define BUF ((struct eth_hdr_s *)priv->dev.d_buf)
-
 /****************************************************************************
  * Private Types
  ****************************************************************************/
@@ -609,16 +623,16 @@
 
 struct stm32_ethmac_s
 {
+  /* This holds the information visible to the NuttX network */
+
+  struct netdev_lowerhalf_s dev;    /* Interface understood by the network */
+
   uint8_t              ifup    : 1; /* true:ifup false:ifdown */
   uint8_t              mbps100 : 1; /* 100MBps operation (vs 10 MBps) */
   uint8_t              fduplex : 1; /* Full (vs. half) duplex */
   struct wdog_s        txtimeout;   /* TX timeout timer */
   struct work_s        irqwork;     /* For deferring interrupt work to the 
work queue */
-  struct work_s        pollwork;    /* For deferring poll work to the work 
queue */
-
-  /* This holds the information visible to the NuttX network */
-
-  struct net_driver_s  dev;         /* Interface understood by the network */
+  mutex_t              lock;        /* Protects the descriptor rings */
 
   /* Used to track transmit and receive descriptors */
 
@@ -629,7 +643,13 @@ struct stm32_ethmac_s
   struct eth_rxdesc_s *rxcurr;      /* First RX descriptor of the segment */
   uint16_t             segments;    /* RX segment count */
   uint16_t             inflight;    /* Number of TX transfers "in_flight" */
-  sq_queue_t           freeb;       /* The free buffer list */
+
+  /* The packet of each RX descriptor, and the packet sent by each TX
+   * descriptor, held by the descriptor with the last segment.
+   */
+
+  netpkt_t            *rxpkt[STM32_ETH_NRXBUF];
+  netpkt_t            *txpkt[STM32_ETH_NTXBUF];
 
 #ifdef CONFIG_STM32_ETH_TIMESTAMP_RX
   uint32_t             rxtimelow;   /* Received packet timestamp subsecond */
@@ -640,7 +660,7 @@ struct stm32_ethmac_s
 
   /* Per-descriptor TX clone */
 
-  struct iob_s        *txmeta[CONFIG_STM32_ETH_NTXDESC];
+  struct iob_s        *txmeta[STM32_ETH_NTXBUF];
 #endif
 #if defined(CONFIG_STM32_ETH_PTP) && defined(CONFIG_PTP_CLOCK)
   struct ptp_lowerhalf_s ptp_lower; /* PTP hardware clock lower half */
@@ -653,18 +673,11 @@ struct stm32_ethmac_s
 
 /* Descriptor allocations */
 
-static struct eth_rxdesc_s g_rxtable[CONFIG_STM32_ETH_NRXDESC]
+static struct eth_rxdesc_s g_rxtable[STM32_ETH_NRXBUF]
   aligned_data(4);
-static struct eth_txdesc_s g_txtable[CONFIG_STM32_ETH_NTXDESC]
+static struct eth_txdesc_s g_txtable[STM32_ETH_NTXBUF]
   aligned_data(4);
 
-/* Buffer allocations */
-
-static uint8_t g_rxbuffer[CONFIG_STM32_ETH_NRXDESC *
-                          CONFIG_STM32_ETH_BUFSIZE] aligned_data(4);
-static uint8_t g_alloc[STM32_ETH_NFREEBUFFERS *
-                       CONFIG_STM32_ETH_BUFSIZE] aligned_data(4);
-
 static struct stm32_ethmac_s g_stm32ethmac[STM32_NETHERNET];
 
 #ifdef CONFIG_STM32_ETH_PTP_RTC_HIRES
@@ -689,19 +702,11 @@ static void stm32_checksetup(void);
 #  define stm32_checksetup()
 #endif
 
-/* Free buffer management */
-
-static void stm32_initbuffer(struct stm32_ethmac_s *priv, uint8_t *alloc);
-static inline uint8_t *stm32_allocbuffer(struct stm32_ethmac_s *priv);
-static inline void stm32_freebuffer(struct stm32_ethmac_s *priv,
-              uint8_t *buffer);
-static inline bool stm32_isfreebuffer(struct stm32_ethmac_s *priv);
-
 /* Common TX logic */
 
-static int  stm32_transmit(struct stm32_ethmac_s *priv);
-static int  stm32_txpoll(struct net_driver_s *dev);
-static void stm32_dopoll(struct stm32_ethmac_s *priv);
+static netpkt_t *stm32_txrepack(netpkt_t *pkt);
+static int  stm32_txiov(netpkt_t *pkt, struct iovec *iov);
+static int  stm32_transmit(struct netdev_lowerhalf_s *dev, netpkt_t *pkt);
 
 /* Interrupt handling */
 
@@ -712,9 +717,15 @@ static void stm32_disableint(struct stm32_ethmac_s *priv,
 
 static void stm32_freesegment(struct stm32_ethmac_s *priv,
               struct eth_rxdesc_s *rxfirst, int segments);
-static int  stm32_recvframe(struct stm32_ethmac_s *priv);
-static void stm32_receive(struct stm32_ethmac_s *priv);
-static void stm32_freeframe(struct stm32_ethmac_s *priv);
+static netpkt_t *stm32_rxframe(struct stm32_ethmac_s *priv,
+              struct eth_rxdesc_s *rxfirst,
+              struct eth_rxdesc_s *rxlast, int segments);
+static netpkt_t *stm32_receive(struct netdev_lowerhalf_s *dev);
+static int  stm32_freeframe(struct stm32_ethmac_s *priv);
+static int  stm32_txreap(struct stm32_ethmac_s *priv);
+#ifdef CONFIG_NET_NETPOLL
+static void stm32_txpoll(struct netdev_lowerhalf_s *dev);
+#endif
 static void stm32_txdone(struct stm32_ethmac_s *priv);
 #ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
 static void stm32_txtstamp_flush(struct stm32_ethmac_s *priv);
@@ -730,20 +741,20 @@ static void stm32_txtimeout_expiry(wdparm_t arg);
 
 /* NuttX callback functions */
 
-static int  stm32_ifup(struct net_driver_s *dev);
-static int  stm32_ifdown(struct net_driver_s *dev);
-
-static void stm32_txavail_work(void *arg);
-static int  stm32_txavail(struct net_driver_s *dev);
+static int  stm32_ifup(struct netdev_lowerhalf_s *lower);
+static int  stm32_ifdown(struct netdev_lowerhalf_s *lower);
+static int  stm32_down(struct stm32_ethmac_s *priv, bool freerx);
 
 #if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6)
-static int  stm32_addmac(struct net_driver_s *dev, const uint8_t *mac);
+static int  stm32_addmac(struct netdev_lowerhalf_s *dev,
+              const uint8_t *mac);
 #endif
 #ifdef CONFIG_NET_MCASTGROUP
-static int  stm32_rmmac(struct net_driver_s *dev, const uint8_t *mac);
+static int  stm32_rmmac(struct netdev_lowerhalf_s *dev,
+              const uint8_t *mac);
 #endif
 #ifdef CONFIG_NETDEV_IOCTL
-static int  stm32_ioctl(struct net_driver_s *dev, int cmd,
+static int  stm32_ioctl(struct netdev_lowerhalf_s *dev, int cmd,
               unsigned long arg);
 #endif
 
@@ -751,9 +762,8 @@ static int  stm32_ioctl(struct net_driver_s *dev, int cmd,
 
 static void stm32_txdescinit(struct stm32_ethmac_s *priv,
                              struct eth_txdesc_s *txtable);
-static void stm32_rxdescinit(struct stm32_ethmac_s *priv,
-                             struct eth_rxdesc_s *rxtable,
-                             uint8_t *rxbuffer);
+static int  stm32_rxdescinit(struct stm32_ethmac_s *priv,
+                             struct eth_rxdesc_s *rxtable);
 
 /* PHY Initialization */
 
@@ -801,8 +811,27 @@ static uint64_t stm32_eth_ptp_gettime(void);
 #endif
 
 #ifdef CONFIG_STM32_ETH_TIMESTAMP_RX
-static void stm32_eth_ptp_convert_rxtime(struct stm32_ethmac_s *priv);
+static void stm32_eth_ptp_convert_rxtime(struct stm32_ethmac_s *priv,
+                                         struct timespec *ts);
+#endif
+
+static const struct netdev_ops_s g_stm32_ops =
+{
+  .ifup     = stm32_ifup,
+  .ifdown   = stm32_ifdown,
+  .transmit = stm32_transmit,
+  .receive  = stm32_receive,
+#ifdef CONFIG_NET_MCASTGROUP
+  .addmac   = stm32_addmac,
+  .rmmac    = stm32_rmmac,
+#endif
+#ifdef CONFIG_NETDEV_IOCTL
+  .ioctl    = stm32_ioctl,
+#endif
+#ifdef CONFIG_NET_NETPOLL
+  .txpoll   = stm32_txpoll,
 #endif
+};
 
 /****************************************************************************
  * Private Functions
@@ -938,301 +967,262 @@ static void stm32_checksetup(void)
 #endif
 
 /****************************************************************************
- * Function: stm32_initbuffer
+ * Function: stm32_txrepack
  *
  * Description:
- *   Initialize the free buffer list.
+ *   Copy a packet that has more buffers than a TX frame can use to a new
+ *   packet with full buffers.  The old packet is freed on success.
  *
  * Input Parameters:
- *   priv  - Reference to the driver state structure
+ *   pkt - The packet to copy
  *
  * Returned Value:
- *   None
- *
- * Assumptions:
- *   Called during early driver initialization before Ethernet interrupts
- *   are enabled.
+ *   The new packet, or NULL on failure.
  *
  ****************************************************************************/
 
-static void stm32_initbuffer(struct stm32_ethmac_s *priv, uint8_t *alloc)
+static netpkt_t *stm32_txrepack(netpkt_t *pkt)
 {
-  uint8_t *buffer;
-  int i;
-
-  /* Initialize the head of the free buffer list */
-
-  sq_init(&priv->freeb);
-
-  /* Add all of the pre-allocated buffers to the free buffer list */
+  netpkt_t *copy;
 
-  for (i = 0, buffer = alloc;
-       i < STM32_ETH_NFREEBUFFERS;
-       i++, buffer += CONFIG_STM32_ETH_BUFSIZE)
+  copy = iob_tryalloc(false);
+  if (copy == NULL)
     {
-      sq_addlast((sq_entry_t *)buffer, &priv->freeb);
+      return NULL;
     }
-}
 
-/****************************************************************************
- * Function: stm32_allocbuffer
- *
- * Description:
- *   Allocate one buffer from the free buffer list.
- *
- * Input Parameters:
- *   priv  - Reference to the driver state structure
- *
- * Returned Value:
- *   Pointer to the allocated buffer on success; NULL on failure
- *
- * Assumptions:
- *   May or may not be called from an interrupt handler.  In either case,
- *   global interrupts are disabled, either explicitly or indirectly through
- *   interrupt handling logic.
- *
- ****************************************************************************/
+  iob_reserve(copy, CONFIG_NET_LL_GUARDSIZE);
+  if (iob_clone_partial(pkt, pkt->io_pktlen, 0, copy, 0, false, false) < 0)
+    {
+      iob_free_chain(copy);
+      return NULL;
+    }
 
-static inline uint8_t *stm32_allocbuffer(struct stm32_ethmac_s *priv)
-{
-  /* Allocate a buffer by returning the head of the free buffer list */
+  /* The Ethernet header is in front of the data of the first buffer */
 
-  return (uint8_t *)sq_remfirst(&priv->freeb);
+  memcpy(IOB_DATA(copy) - ETH_HDRLEN, IOB_DATA(pkt) - ETH_HDRLEN,
+         ETH_HDRLEN);
+  iob_free_chain(pkt);
+  return copy;
 }
 
 /****************************************************************************
- * Function: stm32_freebuffer
+ * Function: stm32_txiov
  *
  * Description:
- *   Return a buffer to the free buffer list.
+ *   Get the buffers of a packet, one for each TX descriptor.
  *
  * Input Parameters:
- *   priv  - Reference to the driver state structure
- *   buffer - A pointer to the buffer to be freed
+ *   pkt - The packet
+ *   iov - The STM32_ETH_NSEGS buffers
  *
  * Returned Value:
- *   None
- *
- * Assumptions:
- *   May or may not be called from an interrupt handler.  In either case,
- *   global interrupts are disabled, either explicitly or indirectly through
- *   interrupt handling logic.
+ *   The number of buffers, or -E2BIG if there are more than
+ *   STM32_ETH_NSEGS.
  *
  ****************************************************************************/
 
-static inline void stm32_freebuffer(struct stm32_ethmac_s *priv,
-                                    uint8_t *buffer)
+static int stm32_txiov(netpkt_t *pkt, struct iovec *iov)
 {
-  /* Free the buffer by adding it to the end of the free buffer list */
+  int n = 1;
 
-  sq_addlast((sq_entry_t *)buffer, &priv->freeb);
-}
+  iov[0].iov_base = IOB_DATA(pkt) - ETH_HDRLEN;
+  iov[0].iov_len  = pkt->io_len + ETH_HDRLEN;
 
-/****************************************************************************
- * Function: stm32_isfreebuffer
- *
- * Description:
- *   Return TRUE if the free buffer list is not empty.
- *
- * Input Parameters:
- *   priv  - Reference to the driver state structure
- *
- * Returned Value:
- *   True if there are one or more buffers in the free buffer list;
- *   false if the free buffer list is empty
- *
- * Assumptions:
- *   None.
- *
- ****************************************************************************/
+  for (pkt = pkt->io_flink; pkt != NULL; pkt = pkt->io_flink)
+    {
+      if (pkt->io_len == 0)
+        {
+          continue;
+        }
 
-static inline bool stm32_isfreebuffer(struct stm32_ethmac_s *priv)
-{
-  /* Return TRUE if the free buffer list is not empty */
+      if (n >= STM32_ETH_NSEGS)
+        {
+          return -E2BIG;
+        }
 
-  return !sq_empty(&priv->freeb);
+      iov[n].iov_base = IOB_DATA(pkt);
+      iov[n].iov_len  = pkt->io_len;
+      n++;
+    }
+
+  return n;
 }
 
 /****************************************************************************
  * Function: stm32_transmit
  *
  * Description:
- *   Start hardware transmission.  Called either from the txdone interrupt
- *   handling or from watchdog based polling.
+ *   NuttX Callback: start the hardware transmission of a packet.  The
+ *   buffers of the packet are sent in place, one TX descriptor each.  The
+ *   packet is held until the transmission is complete.
  *
  * Input Parameters:
- *   priv  - Reference to the driver state structure
+ *   dev - Reference to the lower half driver state structure
+ *   pkt - The packet to send
  *
  * Returned Value:
  *   OK on success; a negated errno on failure
  *
- * Assumptions:
- *   May or may not be called from an interrupt handler.  In either case,
- *   global interrupts are disabled, either explicitly or indirectly through
- *   interrupt handling logic.
- *
  ****************************************************************************/
 
-static int stm32_transmit(struct stm32_ethmac_s *priv)
+static int stm32_transmit(struct netdev_lowerhalf_s *dev, netpkt_t *pkt)
 {
+  struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)dev;
   struct eth_txdesc_s *txdesc;
   struct eth_txdesc_s *txfirst;
-
-  /* The internal (optimal) network buffer size may be configured to be
-   * larger than the Ethernet buffer size.
-   */
-
-#if OPTIMAL_ETH_BUFSIZE > CONFIG_STM32_ETH_BUFSIZE
-  uint8_t *buffer;
-  int bufcount;
-  int lastsize;
+  struct iovec iov[STM32_ETH_NSEGS];
+  uint32_t tdes0;
+  int nsegs;
+  int ret = OK;
   int i;
+#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
+  struct iob_s *clone = NULL;
 #endif
 
-  /* Verify that the hardware is ready to send another packet.  If we get
-   * here, then we are committed to sending a packet; Higher level logic
-   * must have assured that there is no transmission in progress.
+  /* A packet with too many buffers is copied to full buffers, which
+   * need at most STM32_ETH_NSEGS descriptors.
    */
 
-  txdesc  = priv->txhead;
-  txfirst = txdesc;
+  nsegs = stm32_txiov(pkt, iov);
 
-  ninfo("d_len: %d d_buf: %p txhead: %p tdes0: %08" PRIx32 "\n",
-        priv->dev.d_len, priv->dev.d_buf, txdesc, txdesc->tdes0);
+  nxmutex_lock(&priv->lock);
 
-  DEBUGASSERT(txdesc && (txdesc->tdes0 & ETH_TDES0_OWN) == 0);
-
-  /* Is the size to be sent greater than the size of the Ethernet buffer? */
-
-  DEBUGASSERT(priv->dev.d_len > 0 && priv->dev.d_buf != NULL);
-
-#if OPTIMAL_ETH_BUFSIZE > CONFIG_STM32_ETH_BUFSIZE
-  if (priv->dev.d_len > CONFIG_STM32_ETH_BUFSIZE)
+  if (!priv->ifup)
     {
-      /* Yes... how many buffers will be need to send the packet? */
-
-      bufcount = (priv->dev.d_len + (CONFIG_STM32_ETH_BUFSIZE - 1)) /
-                 CONFIG_STM32_ETH_BUFSIZE;
-      lastsize = priv->dev.d_len - (bufcount - 1) * CONFIG_STM32_ETH_BUFSIZE;
-
-      ninfo("bufcount: %d lastsize: %d\n", bufcount, lastsize);
-
-      /* Set the first segment bit in the first TX descriptor */
+      ret = -ENETDOWN;
+      goto errout;
+    }
 
-      txdesc->tdes0 |= ETH_TDES0_FS;
+  /* Free the completed frames, then check that the TX descriptors are
+   * free.  If not, -EBUSY: the upper half sends the packet again after
+   * netdev_lower_txdone().
+   *
+   * In a race condition, ETH_TDES0_OWN may be cleared BUT still
+   * not available because stm32_freeframe() has not yet run. If
+   * stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
+   * nullified.
+   */
 
-      /* Set up all but the last TX descriptor */
+  stm32_freeframe(priv);
 
-      buffer = priv->dev.d_buf;
+  txfirst = priv->txhead;
+  txdesc  = txfirst;
 
-      for (i = 0; i < bufcount; i++)
+  for (i = 0; i < (nsegs < 0 ? STM32_ETH_NSEGS : nsegs); i++)
+    {
+      if ((txdesc->tdes0 & ETH_TDES0_OWN) != 0 || txdesc->tdes2 != 0)
         {
-          /* This could be a normal event but the design does not handle it */
-
-          DEBUGASSERT((txdesc->tdes0 & ETH_TDES0_OWN) == 0);
-
-          /* Set the Buffer1 address pointer */
+          ret = -EBUSY;
+          goto errout;
+        }
 
-          txdesc->tdes2 = (uint32_t)buffer;
+      txdesc = (struct eth_txdesc_s *)txdesc->tdes3;
+    }
 
-          /* Set the buffer size in all TX descriptors */
+  /* Nothing can fail after the packet is copied: on failure the upper half
+   * frees the packet that it passed.
+   */
 
-          if (i == (bufcount - 1))
-            {
-              /* This is the last segment.  Set the last segment bit in the
-               * last TX descriptor and ask for an interrupt when this
-               * segment transfer completes.
-               */
+  if (nsegs < 0)
+    {
+      netpkt_t *copy = stm32_txrepack(pkt);
 
-              txdesc->tdes0 |= (ETH_TDES0_LS | ETH_TDES0_IC);
+      if (copy == NULL)
+        {
+          ret = -ENOMEM;
+          goto errout;
+        }
 
-              /* This segment is, most likely, of fractional buffersize */
+      pkt   = copy;
+      nsegs = stm32_txiov(pkt, iov);
+      DEBUGASSERT(nsegs > 0);
 
-              txdesc->tdes1  = lastsize;
-              buffer        += lastsize;
-            }
-          else
-            {
-              /* This is not the last segment.  We don't want an interrupt
-               * when this segment transfer completes.
-               */
+      txdesc = txfirst;
+      for (i = 0; i < nsegs; i++)
+        {
+          txdesc = (struct eth_txdesc_s *)txdesc->tdes3;
+        }
+    }
 
-              txdesc->tdes0 &= ~ETH_TDES0_IC;
+  priv->txhead = txdesc;
 
-              /* The size of the transfer is the whole buffer */
+  ninfo("len: %u nsegs: %d txhead: %p\n",
+        netpkt_getdatalen(dev, pkt), nsegs, txfirst);
 
-              txdesc->tdes1  = CONFIG_STM32_ETH_BUFSIZE;
-              buffer        += CONFIG_STM32_ETH_BUFSIZE;
+#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
+  if (pkt->io_conn != NULL)
+    {
+      clone = iob_tryalloc(false);
+      if (clone != NULL)
+        {
+          iob_reserve(clone, CONFIG_NET_LL_GUARDSIZE);
+          if (iob_clone_partial(pkt, pkt->io_pktlen, 0, clone, 0,
+                                false, false) < 0)
+            {
+              iob_free_chain(clone);
+              clone = NULL;
             }
+        }
 
-          /* Give the descriptor to DMA */
-
-          txdesc->tdes0 |= ETH_TDES0_OWN;
-          txdesc         = (struct eth_txdesc_s *)txdesc->tdes3;
+      if (clone == NULL)
+        {
+          nerr("ERROR: Failed to clone IOB for TX timestamp\n");
         }
     }
-  else
 #endif
-    {
-      /* The single descriptor is both the first and last segment.  And we do
-       * want an interrupt when the transfer completes.
-       */
 
-      txdesc->tdes0 |= (ETH_TDES0_FS | ETH_TDES0_LS | ETH_TDES0_IC);
+  /* Set up the descriptors of all segments, but give the first one to the
+   * DMA last, so that the DMA never sees an incomplete frame.
+   */
 
-#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
-      {
-        uint32_t txindex = txdesc - g_txtable;
-
-        priv->txmeta[txindex] = NULL;
-        if (priv->dev.d_iob != NULL && priv->dev.d_iob->io_conn != NULL)
-          {
-            struct iob_s *clone = netdev_iob_clone(&priv->dev, false);
-
-            if (clone != NULL)
-              {
-                clone->io_conn = priv->dev.d_iob->io_conn;
-                priv->txmeta[txindex] = clone;
-                txdesc->tdes0 |= ETH_TDES0_TTSE;
-              }
-            else
-              {
-                nerr("ERROR: Failed to clone IOB for TX timestamp\n");
-              }
-          }
-      }
+  txdesc = txfirst;
+  for (i = 0; i < nsegs; i++)
+    {
+      tdes0 = ETH_TDES0_TCH;
+#ifdef CHECKSUM_BY_HARDWARE
+      tdes0 |= ETH_TDES0_CIC_ALL;
 #endif
 
-      /* Set frame size */
-
-      DEBUGASSERT(priv->dev.d_len <= CONFIG_STM32_ETH_BUFSIZE);
-      txdesc->tdes1 = priv->dev.d_len;
+      if (i == 0)
+        {
+          tdes0 |= ETH_TDES0_FS;
+#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
+          if (clone != NULL)
+            {
+              tdes0 |= ETH_TDES0_TTSE;
+            }
+#endif
+        }
 
-      /* Set the Buffer1 address pointer */
+      if (i == nsegs - 1)
+        {
+          uint32_t txindex = txdesc - g_txtable;
 
-      txdesc->tdes2 = (uint32_t)priv->dev.d_buf;
+          /* This is the last segment.  Hold the packet here and ask for
+           * an interrupt when the transfer completes.
+           */
 
-      /* Set OWN bit of the TX descriptor tdes0.  This gives the buffer to
-       * Ethernet DMA
-       */
+          tdes0 |= ETH_TDES0_LS | ETH_TDES0_IC;
+          priv->txpkt[txindex] = pkt;
+#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
+          priv->txmeta[txindex] = clone;
+#endif
+        }
 
-      txdesc->tdes0 |= ETH_TDES0_OWN;
+      txdesc->tdes1 = iov[i].iov_len;
+      txdesc->tdes2 = (uint32_t)iov[i].iov_base;
 
-      /* Point to the next available TX descriptor */
+      if (i > 0)
+        {
+          tdes0 |= ETH_TDES0_OWN;
+        }
 
+      txdesc->tdes0 = tdes0;
       txdesc = (struct eth_txdesc_s *)txdesc->tdes3;
     }
 
-  /* Remember where we left off in the TX descriptor chain */
-
-  priv->txhead = txdesc;
-
-  /* Detach the buffer from priv->dev structure.  That buffer is now
-   * "in-flight".
-   */
-
-  priv->dev.d_buf = NULL;
-  priv->dev.d_len = 0;
+  txfirst->tdes0 |= ETH_TDES0_OWN;
 
   /* If there is no other TX buffer, in flight, then remember the location
    * of the TX descriptor.  This is the location to check for TX done events.
@@ -1251,16 +1241,6 @@ static int stm32_transmit(struct stm32_ethmac_s *priv)
   ninfo("txhead: %p txtail: %p inflight: %d\n",
         priv->txhead, priv->txtail, priv->inflight);
 
-  /* If all TX descriptors are in-flight, then we have to disable receive
-   * interrupts too. This is because receive events can trigger more
-   * un-stoppable transmit events.
-   */
-
-  if (priv->inflight >= CONFIG_STM32_ETH_NTXDESC)
-    {
-      stm32_disableint(priv, ETH_DMAINT_RI);
-    }
-
   /* Check if the TX Buffer unavailable flag is set */
 
   if ((stm32_getreg(STM32_ETH_DMASR) & ETH_DMAINT_TBUI) != 0)
@@ -1282,153 +1262,10 @@ static int stm32_transmit(struct stm32_ethmac_s *priv)
 
   wd_start(&priv->txtimeout, STM32_TXTIMEOUT,
            stm32_txtimeout_expiry, (wdparm_t)priv);
-  return OK;
-}
-
-/****************************************************************************
- * Function: stm32_txpoll
- *
- * Description:
- *   The transmitter is available, check if the network has any outgoing
- *   packets ready to send. This is a callback from devif_poll().
- *   devif_poll() may be called:
- *
- *   1. When the preceding TX packet send is complete,
- *   2. When the preceding TX packet send timesout and the interface is reset
- *   3. During normal TX polling
- *
- * Input Parameters:
- *   dev  - Reference to the NuttX driver state structure
- *
- * Returned Value:
- *   OK on success; a negated errno on failure
- *
- * Assumptions:
- *   May or may not be called from an interrupt handler.  In either case,
- *   global interrupts are disabled, either explicitly or indirectly through
- *   interrupt handling logic.
- *
- ****************************************************************************/
-
-static int stm32_txpoll(struct net_driver_s *dev)
-{
-  struct stm32_ethmac_s *priv =
-    (struct stm32_ethmac_s *)dev->d_private;
-
-  DEBUGASSERT(priv->dev.d_buf != NULL);
-
-  /* Send the packet */
-
-  stm32_transmit(priv);
-  DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
-
-  /* Check if the next TX descriptor is owned by the Ethernet DMA or
-   * CPU. We cannot perform the TX poll if we are unable to accept
-   * another packet for transmission.
-   *
-   * In a race condition, ETH_TDES0_OWN may be cleared BUT still
-   * not available because stm32_freeframe() has not yet run. If
-   * stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
-   * nullified (and inflight should be < CONFIG_STM32_ETH_NTXDESC).
-   */
-
-  if ((priv->txhead->tdes0 & ETH_TDES0_OWN) != 0 ||
-       priv->txhead->tdes2 != 0)
-    {
-      /* We have to terminate the poll if we have no more descriptors
-       * available for another transfer.
-       */
-
-      return -EBUSY;
-    }
-
-  /* We have the descriptor, we can continue the poll. Allocate a new
-   * buffer for the poll.
-   */
-
-  dev->d_buf = stm32_allocbuffer(priv);
-
-  /* We can't continue the poll if we have no buffers */
-
-  if (dev->d_buf == NULL)
-    {
-      /* Terminate the poll. */
-
-      return -ENOMEM;
-    }
-
-  /* If zero is returned, the polling will continue until all connections
-   * have been examined.
-   */
-
-  return 0;
-}
-
-/****************************************************************************
- * Function: stm32_dopoll
- *
- * Description:
- *   The function is called in order to perform an out-of-sequence TX poll.
- *   This is done:
- *
- *   1. After completion of a transmission (stm32_txdone),
- *   2. When new TX data is available (stm32_txavail_process), and
- *   3. After a TX timeout to restart the sending process
- *      (stm32_txtimeout_process).
- *
- * Input Parameters:
- *   priv  - Reference to the driver state structure
- *
- * Returned Value:
- *   None
- *
- * Assumptions:
- *   Global interrupts are disabled by interrupt handling logic.
- *
- ****************************************************************************/
-
-static void stm32_dopoll(struct stm32_ethmac_s *priv)
-{
-  struct net_driver_s *dev = &priv->dev;
-
-  /* Check if the next TX descriptor is owned by the Ethernet DMA or
-   * CPU.  We cannot perform the TX poll if we are unable to accept
-   * another packet for transmission.
-   *
-   * In a race condition, ETH_TDES0_OWN may be cleared BUT still
-   * not available because stm32_freeframe() has not yet run. If
-   * stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
-   * nullified (and inflight should be < CONFIG_STM32_ETH_NTXDESC).
-   */
 
-  if ((priv->txhead->tdes0 & ETH_TDES0_OWN) == 0 &&
-       priv->txhead->tdes2 == 0)
-    {
-      /* If we have the descriptor, then poll the network for new XMIT data.
-       * Allocate a buffer for the poll.
-       */
-
-      DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
-      dev->d_buf = stm32_allocbuffer(priv);
-
-      /* We can't poll if we have no buffers */
-
-      if (dev->d_buf)
-        {
-          devif_poll(dev, stm32_txpoll);
-
-          /* We will, most likely end up with a buffer to be freed.  But it
-           * might not be the same one that we allocated above.
-           */
-
-          if (dev->d_buf)
-            {
-              DEBUGASSERT(dev->d_len == 0);
-              stm32_freebuffer(priv, dev->d_buf);
-              dev->d_buf = NULL;
-            }
-        }
-    }
+errout:
+  nxmutex_unlock(&priv->lock);
+  return ret;
 }
 
 /****************************************************************************
@@ -1444,7 +1281,7 @@ static void stm32_dopoll(struct stm32_ethmac_s *priv)
  *   None
  *
  * Assumptions:
- *   Global interrupts are disabled by interrupt handling logic.
+ *   Called with priv->lock held.
  *
  ****************************************************************************/
 
@@ -1473,7 +1310,7 @@ static void stm32_enableint(struct stm32_ethmac_s *priv,
  *   None
  *
  * Assumptions:
- *   Global interrupts are disabled by interrupt handling logic.
+ *   Called with priv->lock held.
  *
  ****************************************************************************/
 
@@ -1513,7 +1350,7 @@ static void stm32_disableint(struct stm32_ethmac_s *priv,
  *   None
  *
  * Assumptions:
- *   Global interrupts are disabled by interrupt handling logic.
+ *   Called with priv->lock held.
  *
  ****************************************************************************/
 
@@ -1554,191 +1391,129 @@ static void stm32_freesegment(struct stm32_ethmac_s 
*priv,
 }
 
 /****************************************************************************
- * Function: stm32_recvframe
+ * Function: stm32_rxframe
  *
  * Description:
- *   The function is called when a frame is received using the DMA receive
- *   interrupt.  It scans the RX descriptors of the received frame.
- *
- *   NOTE: This function will silently discard any packets containing errors.
+ *   Take the buffers of a received frame from its RX descriptors and give
+ *   the descriptors new buffers.  If there are no new buffers, the frame is
+ *   dropped and the descriptors keep their buffers.
  *
  * Input Parameters:
- *   priv  - Reference to the driver state structure
+ *   priv     - Reference to the driver state structure
+ *   rxfirst  - The descriptor of the first segment
+ *   rxlast   - The descriptor of the last segment
+ *   segments - The number of segments
  *
  * Returned Value:
- *   OK if a packet was successfully returned; -EAGAIN if there are no
- *   further packets available
+ *   The packet of the frame, or NULL if it was dropped.
  *
  * Assumptions:
- *   Global interrupts are disabled by interrupt handling logic.
+ *   The descriptor ring lock is held.
  *
  ****************************************************************************/
 
-static int stm32_recvframe(struct stm32_ethmac_s *priv)
+static netpkt_t *stm32_rxframe(struct stm32_ethmac_s *priv,
+                               struct eth_rxdesc_s *rxfirst,
+                               struct eth_rxdesc_s *rxlast, int segments)
 {
+  struct netdev_lowerhalf_s *dev = &priv->dev;
   struct eth_rxdesc_s *rxdesc;
-  struct eth_rxdesc_s *rxcurr;
-  uint8_t *buffer;
+  netpkt_t *newpkt[STM32_ETH_NSEGS];
+  netpkt_t *head = NULL;
+  netpkt_t *tail = NULL;
+  unsigned int remain;
+  unsigned int len;
   int i;
 
-  ninfo("rxhead: %p rxcurr: %p segments: %d\n",
-        priv->rxhead, priv->rxcurr, priv->segments);
-
-  /* Check if there are free buffers.  We cannot receive new frames in this
-   * design unless there is at least one free buffer.
+  /* Get the Frame Length of the received packet: substruct 4 bytes of the
+   * CRC
    */
 
-  if (!stm32_isfreebuffer(priv))
-    {
-      nerr("ERROR: No free buffers\n");
-      return -ENOMEM;
-    }
+  len = ((rxlast->rdes0 & ETH_RDES0_FL_MASK) >> ETH_RDES0_FL_SHIFT) - 4;
 
-  /* Scan descriptors owned by the CPU.  Scan until:
-   *
-   *   1) We find a descriptor still owned by the DMA,
-   *   2) We have examined all of the RX descriptors, or
-   *   3) All of the TX descriptors are in flight.
-   *
-   * This last case is obscure.  It is due to that fact that each packet
-   * that we receive can generate an unstoppable transmission.  So we have
-   * to stop receiving when we can not longer transmit.  In this case, the
-   * transmit logic should also have disabled further RX interrupts.
+  /* Check if the packet is a valid size for the network buffer
+   * configuration.  A frame of this size has at most STM32_ETH_NSEGS
+   * segments.
    */
 
-  rxdesc = priv->rxhead;
-  for (i = 0;
-       (rxdesc->rdes0 & ETH_RDES0_OWN) == 0 &&
-        i < CONFIG_STM32_ETH_NRXDESC &&
-        priv->inflight < CONFIG_STM32_ETH_NTXDESC;
-       i++)
+  if (len > CONFIG_NET_ETH_PKTSIZE || len < ETH_HDRLEN ||
+      segments > STM32_ETH_NSEGS)
     {
-      /* Check if this is the first segment in the frame */
-
-      if ((rxdesc->rdes0 & ETH_RDES0_FS) != 0 &&
-          (rxdesc->rdes0 & ETH_RDES0_LS) == 0)
-        {
-          priv->rxcurr   = rxdesc;
-          priv->segments = 1;
-        }
-
-      /* Check if this is an intermediate segment in the frame */
-
-      else if (((rxdesc->rdes0 & ETH_RDES0_LS) == 0) &&
-               ((rxdesc->rdes0 & ETH_RDES0_FS) == 0))
-        {
-          priv->segments++;
-        }
-
-      /* Otherwise, it is the last segment in the frame */
+      nwarn("WARNING: DROPPED Too big: %u in %d segments\n", len, segments);
+      NETDEV_RXERRORS(&dev->netdev);
+      stm32_freesegment(priv, rxfirst, segments);
+      return NULL;
+    }
 
-      else
+  for (i = 0; i < segments; i++)
+    {
+      newpkt[i] = netpkt_alloc(dev, NETPKT_RX);
+      if (newpkt[i] == NULL)
         {
-          priv->segments++;
-
-          /* Check if there is only one segment in the frame */
-
-          if (priv->segments == 1)
+          while (i-- > 0)
             {
-              rxcurr = rxdesc;
+              netpkt_free(dev, newpkt[i], NETPKT_RX);
             }
-          else
-            {
-              rxcurr = priv->rxcurr;
-            }
-
-          ninfo("rxhead: %p rxcurr: %p segments: %d\n",
-              priv->rxhead, priv->rxcurr, priv->segments);
-
-          /* Check if any errors are reported in the frame */
-
-          if ((rxdesc->rdes0 & ETH_RDES0_ES) == 0)
-            {
-              struct net_driver_s *dev = &priv->dev;
-
-              /* Get the Frame Length of the received packet: substruct 4
-               * bytes of the CRC
-               */
-
-              dev->d_len = ((rxdesc->rdes0 & ETH_RDES0_FL_MASK) >>
-                            ETH_RDES0_FL_SHIFT) - 4;
-
-              if (priv->segments > 1 ||
-                  dev->d_len > CONFIG_STM32_ETH_BUFSIZE)
-                {
-                  /* The Frame is to big, it spans segments */
-
-                  nerr("ERROR: Dropped, RX descriptor Too big: %d in %d "
-                      "segments\n", dev->d_len, priv->segments);
-
-                  stm32_freesegment(priv, rxcurr, priv->segments);
-                }
-
-              else
-                {
-                  /* Get a buffer from the free list.  We don't even check if
-                   * this is successful because we already assure the free
-                   * list is not empty above.
-                   */
-
-                  buffer = stm32_allocbuffer(priv);
 
-                  /* Take the buffer from the RX descriptor of the first free
-                   * segment, put it into the network device structure, then
-                   * replace the buffer in the RX descriptor with the newly
-                   * allocated buffer.
-                   */
+          nwarn("WARNING: No free buffer, packet dropped\n");
+          NETDEV_RXDROPPED(&dev->netdev);
+          stm32_freesegment(priv, rxfirst, segments);
 
-                  DEBUGASSERT(dev->d_buf == NULL);
-                  dev->d_buf    = (uint8_t *)rxcurr->rdes2;
-                  rxcurr->rdes2 = (uint32_t)buffer;
+          return NULL;
+        }
+    }
 
-#ifdef CONFIG_STM32_ETH_TIMESTAMP_RX
-                  priv->rxtimelow = rxcurr->rdes6;
-                  priv->rxtimehigh = rxcurr->rdes7;
-#endif
+  /* Link the buffers of the segments.  The last segment can hold the CRC
+   * only.
+   */
 
-                  /* Return success, remembering where we should re-start
-                   * scanning and resetting the segment scanning logic
-                   */
+  remain = len;
+  rxdesc = rxfirst;
 
-                  priv->rxhead   = (struct eth_rxdesc_s *)rxdesc->rdes3;
-                  stm32_freesegment(priv, rxcurr, priv->segments);
+  for (i = 0; i < segments; i++)
+    {
+      uint32_t rxindex = rxdesc - g_rxtable;
+      netpkt_t *iob = priv->rxpkt[rxindex];
+      unsigned int seglen = MIN(remain, STM32_ETH_BUFSIZE);
 
-                  ninfo("rxhead: %p d_buf: %p d_len: %d\n",
-                        priv->rxhead, dev->d_buf, dev->d_len);
+      priv->rxpkt[rxindex] = newpkt[i];
+      rxdesc->rdes2 = (uint32_t)netpkt_getdata(dev, newpkt[i]);
 
-                  return OK;
-                }
-            }
-          else
-            {
-              /* Drop the frame that contains the errors, reset the segment
-               * scanning logic, and continue scanning with the next frame.
-               */
+      if (i == 0)
+        {
+          /* The Ethernet header is in front of the data of the packet */
 
-              nerr("ERROR: Dropped, RX descriptor errors: %08" PRIx32 "\n",
-                   rxdesc->rdes0);
-              stm32_freesegment(priv, rxcurr, priv->segments);
-            }
+          iob->io_len    = seglen - ETH_HDRLEN;
+          iob->io_pktlen = len - ETH_HDRLEN;
+          head           = iob;
+          tail           = iob;
+        }
+      else if (seglen > 0)
+        {
+          iob->io_offset  = CONFIG_NET_LL_GUARDSIZE - ETH_HDRLEN;
+          iob->io_len     = seglen;
+          tail->io_flink  = iob;
+          tail            = iob;
+        }
+      else
+        {
+          netpkt_free(dev, iob, NETPKT_RX);
         }
 
-      /* Try the next descriptor */
-
-      rxdesc = (struct eth_rxdesc_s *)rxdesc->rdes3;
+      remain -= seglen;
+      rxdesc  = (struct eth_rxdesc_s *)rxdesc->rdes3;
     }
 
-  /* We get here after all of the descriptors have been scanned or when
-   * rxdesc points to the first descriptor owned by the DMA. Remember
-   * where we left off.
-   */
-
-  priv->rxhead = rxdesc;
+#ifdef CONFIG_STM32_ETH_TIMESTAMP_RX
+  priv->rxtimelow  = rxlast->rdes6;
+  priv->rxtimehigh = rxlast->rdes7;
+  stm32_eth_ptp_convert_rxtime(priv, &head->io_time);
+#endif
 
-  ninfo("rxhead: %p rxcurr: %p segments: %d\n",
-        priv->rxhead, priv->rxcurr, priv->segments);
+  /* Give the descriptors with the new buffers back to the DMA */
 
-  return -EAGAIN;
+  stm32_freesegment(priv, rxfirst, segments);
+  return head;
 }
 
 /****************************************************************************
@@ -1755,26 +1530,43 @@ static int stm32_recvframe(struct stm32_ethmac_s *priv)
  *   None
  *
  * Assumptions:
- *   The network is locked.
+ *   Called without the network device lock, from stm32_receive().
  *
  ****************************************************************************/
 
 #ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
 static void stm32_txtstamp_flush(struct stm32_ethmac_s *priv)
 {
-  struct net_driver_s *dev = &priv->dev;
+  struct net_driver_s *dev = &priv->dev.netdev;
+  struct iob_s *saved_iob;
+  uint16_t saved_len;
+  struct iob_s *iob;
 
-  while (!IOB_QEMPTY(&priv->txtstampq))
+  for (; ; )
     {
-      struct iob_s *iob = iob_remove_queue(&priv->txtstampq);
+      nxmutex_lock(&priv->lock);
+      iob = iob_remove_queue(&priv->txtstampq);
+      nxmutex_unlock(&priv->lock);
+
+      if (iob == NULL)
+        {
+          break;
+        }
+
+      /* The TX path uses d_iob under the device lock too */
 
+      netdev_lock(dev);
+      saved_iob = dev->d_iob;
+      saved_len = dev->d_len;
       dev->d_iob = iob;
       dev->d_len = iob->io_pktlen;
 #ifdef CONFIG_NET_PKT
       pkt_input(dev);
 #endif
-      dev->d_iob = NULL;
-      dev->d_len = 0;
+      dev->d_iob = saved_iob;
+      dev->d_len = saved_len;
+      netdev_unlock(dev);
+
       iob->io_conn = NULL;
       iob_free_chain(iob);
     }
@@ -1785,22 +1577,25 @@ static void stm32_txtstamp_flush(struct stm32_ethmac_s 
*priv)
  * Function: stm32_receive
  *
  * Description:
- *   An interrupt was received indicating the availability of a new RX packet
+ *   NuttX Callback: take the next received frame from the RX descriptor
+ *   ring.
+ *
+ *   NOTE: This function will silently discard any packets containing errors.
  *
  * Input Parameters:
- *   priv  - Reference to the driver state structure
+ *   dev - Reference to the lower half driver state structure
  *
  * Returned Value:
- *   None
- *
- * Assumptions:
- *   Global interrupts are disabled by interrupt handling logic.
+ *   The received packet, or NULL if there is none.
  *
  ****************************************************************************/
 
-static void stm32_receive(struct stm32_ethmac_s *priv)
+static netpkt_t *stm32_receive(struct netdev_lowerhalf_s *dev)
 {
-  struct net_driver_s *dev = &priv->dev;
+  struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)dev;
+  struct eth_rxdesc_s *rxdesc;
+  netpkt_t *pkt = NULL;
+  int i;
 
 #ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
   /* Return any TX hardware timestamp loopback packets first */
@@ -1808,168 +1603,130 @@ static void stm32_receive(struct stm32_ethmac_s *priv)
   stm32_txtstamp_flush(priv);
 #endif
 
-  /* Loop while while stm32_recvframe() successfully retrieves valid
-   * Ethernet frames.
+  nxmutex_lock(&priv->lock);
+
+  ninfo("rxhead: %p rxcurr: %p segments: %d\n",
+        priv->rxhead, priv->rxcurr, priv->segments);
+
+  /* Scan descriptors owned by the CPU.  Scan until:
+   *
+   *   1) We find a descriptor still owned by the DMA,
+   *   2) We have examined all of the RX descriptors, or
+   *   3) We have a frame.
    */
 
-  while (stm32_recvframe(priv) == OK)
+  rxdesc = priv->rxhead;
+  for (i = 0;
+       priv->ifup && pkt == NULL &&
+       (rxdesc->rdes0 & ETH_RDES0_OWN) == 0 &&
+       i < STM32_ETH_NRXBUF;
+       i++)
     {
-      /* Check if the packet is a valid size for the network buffer
-       * configuration (this should not happen)
-       */
-
-      if (dev->d_len > CONFIG_NET_ETH_PKTSIZE)
-        {
-          nwarn("WARNING: DROPPED Too big: %d\n", dev->d_len);
+      struct eth_rxdesc_s *next = (struct eth_rxdesc_s *)rxdesc->rdes3;
 
-          /* Free dropped packet buffer */
+      /* Check if this is the first segment in the frame */
 
-          if (dev->d_buf)
+      if ((rxdesc->rdes0 & ETH_RDES0_FS) != 0)
+        {
+          if (priv->rxcurr != NULL)
             {
-              stm32_freebuffer(priv, dev->d_buf);
-              dev->d_buf = NULL;
-              dev->d_len = 0;
+              /* Drop the incomplete previous frame */
+
+              stm32_freesegment(priv, priv->rxcurr, priv->segments);
             }
 
-          continue;
+          priv->rxcurr   = rxdesc;
+          priv->segments = 1;
         }
-
-#ifdef CONFIG_STM32_ETH_TIMESTAMP_RX
-      /* Convert this frame's hardware RX timestamp before handing the
-       * frame to pkt_input() below. pkt_input() copies dev->d_rxtime
-       * into the packet socket's queued metadata immediately, so if
-       * the conversion ran after it, every packet would be tagged
-       * with the *previous* frame's timestamp instead of its own,
-       * introducing effectively random error on the order of the
-       * inter-frame interval into every RX timestamp.
-       */
-
-      stm32_eth_ptp_convert_rxtime(priv);
-#endif
-
-#ifdef CONFIG_NET_PKT
-      /* When packet sockets are enabled, feed the frame into the tap */
-
-      pkt_input(&priv->dev);
-#endif
-
-      /* We only accept IP packets of the configured type and ARP packets */
-
-#ifdef CONFIG_NET_IPv4
-      if (BUF->type == HTONS(ETHTYPE_IP))
+      else if (priv->rxcurr == NULL)
         {
-          ninfo("IPv4 frame\n");
-
-          /* Receive an IPv4 packet from the network device */
-
-          ipv4_input(&priv->dev);
+          /* A segment without its first segment, drop it */
 
-          /* If the above function invocation resulted in data that should be
-           * sent out on the network, d_len field will set to a value > 0.
-           */
-
-          if (priv->dev.d_len > 0)
-            {
-              /* And send the packet */
-
-              stm32_transmit(priv);
-            }
+          stm32_freesegment(priv, rxdesc, 1);
+          rxdesc = next;
+          continue;
         }
       else
-#endif
-#ifdef CONFIG_NET_IPv6
-      if (BUF->type == HTONS(ETHTYPE_IP6))
         {
-          ninfo("IPv6 frame\n");
-
-          /* Give the IPv6 packet to the network layer */
-
-          ipv6_input(&priv->dev);
+          priv->segments++;
+        }
 
-          /* If the above function invocation resulted in data that should be
-           * sent out on the network, d_len field will set to a value > 0.
-           */
+      if ((rxdesc->rdes0 & ETH_RDES0_LS) == 0)
+        {
+          /* The frame is longer than the whole ring, drop it */
 
-          if (priv->dev.d_len > 0)
+          if (priv->segments >= STM32_ETH_NRXBUF)
             {
-              /* And send the packet */
-
-              stm32_transmit(priv);
+              stm32_freesegment(priv, priv->rxcurr, priv->segments);
             }
+
+          rxdesc = next;
+          continue;
         }
-      else
-#endif
-#ifdef CONFIG_NET_ARP
-      if (BUF->type == HTONS(ETHTYPE_ARP))
-        {
-          ninfo("ARP frame\n");
 
-          /* Handle ARP packet */
+      ninfo("rxhead: %p rxcurr: %p segments: %d\n",
+            priv->rxhead, priv->rxcurr, priv->segments);
 
-          arp_input(&priv->dev);
+      /* Check if any errors are reported in the frame */
 
-          /* If the above function invocation resulted in data that should be
-           * sent out on the network, d_len field will set to a value > 0.
-           */
+      if ((rxdesc->rdes0 & ETH_RDES0_ES) == 0)
+        {
+          pkt = stm32_rxframe(priv, priv->rxcurr, rxdesc, priv->segments);
+        }
+      else if ((rxdesc->rdes0 & ETH_RDES0_DE) != 0)
+        {
+          /* The ring had no free descriptor for the rest of the frame */
 
-          if (priv->dev.d_len > 0)
-            {
-              stm32_transmit(priv);
-            }
+          NETDEV_RXDROPPED(&priv->dev.netdev);
+          stm32_freesegment(priv, priv->rxcurr, priv->segments);
         }
       else
-#endif
         {
-#ifdef CONFIG_NET_PKT
-          /* Frames that packet sockets consume directly (PTP, Ethertype
-           * 0x88f7, and IPv6) were already delivered via pkt_input()
-           * above, so they are not "unknown" and must not be logged as
-           * dropped.
+          /* Drop the frame that contains the errors, reset the segment
+           * scanning logic, and continue scanning with the next frame.
            */
 
-          if (BUF->type != HTONS(0x88f7) && BUF->type != HTONS(ETHTYPE_IP6))
-#endif
-            {
-              nerr("ERROR: Dropped, Unknown type: %04x\n", BUF->type);
-            }
+          nerr("ERROR: Dropped, RX descriptor errors: %08" PRIx32 "\n",
+               rxdesc->rdes0);
+          NETDEV_RXERRORS(&priv->dev.netdev);
+          stm32_freesegment(priv, priv->rxcurr, priv->segments);
         }
 
-      /* We are finished with the RX buffer.  NOTE:  If the buffer is
-       * reused for transmission, the dev->d_buf field will have been
-       * nullified.
-       */
+      rxdesc = next;
+    }
 
-      if (dev->d_buf)
-        {
-          /* Free the receive packet buffer */
+  /* Remember where we left off */
 
-          stm32_freebuffer(priv, dev->d_buf);
-          dev->d_buf = NULL;
-          dev->d_len = 0;
-        }
-    }
+  priv->rxhead = rxdesc;
+
+  ninfo("rxhead: %p rxcurr: %p segments: %d pkt: %p\n",
+        priv->rxhead, priv->rxcurr, priv->segments, pkt);
+
+  nxmutex_unlock(&priv->lock);
+  return pkt;
 }
 
 /****************************************************************************
  * Function: stm32_freeframe
  *
  * Description:
- *   Scans the TX descriptors and frees the buffers of completed transfers.
+ *   Scans the TX descriptors and frees the packets of completed transfers.
  *
  * Input Parameters:
  *   priv  - Reference to the driver state structure
  *
  * Returned Value:
- *   None.
+ *   The number of frames freed.
  *
  * Assumptions:
- *   Global interrupts are disabled by interrupt handling logic.
+ *   The descriptor ring lock is held.
  *
  ****************************************************************************/
 
-static void stm32_freeframe(struct stm32_ethmac_s *priv)
+static int stm32_freeframe(struct stm32_ethmac_s *priv)
 {
   struct eth_txdesc_s *txdesc;
+  int freed = 0;
 
   ninfo("txhead: %p txtail: %p inflight: %d\n",
         priv->txhead, priv->txtail, priv->inflight);
@@ -1993,15 +1750,6 @@ static void stm32_freeframe(struct stm32_ethmac_s *priv)
 
           DEBUGASSERT(txdesc->tdes2 != 0);
 
-          /* Check if this is the first segment of a TX frame. */
-
-          if ((txdesc->tdes0 & ETH_TDES0_FS) != 0)
-            {
-              /* Yes.. Free the buffer */
-
-              stm32_freebuffer(priv, (uint8_t *)txdesc->tdes2);
-            }
-
           /* In any event, make sure that TDES2 is nullified. */
 
           txdesc->tdes2 = 0;
@@ -2010,8 +1758,8 @@ static void stm32_freeframe(struct stm32_ethmac_s *priv)
 
           if ((txdesc->tdes0 & ETH_TDES0_LS) != 0)
             {
-#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
               uint32_t tail = txdesc - g_txtable;
+#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
               struct iob_s *clone = priv->txmeta[tail];
 
               priv->txmeta[tail] = NULL;
@@ -2033,16 +1781,15 @@ static void stm32_freeframe(struct stm32_ethmac_s *priv)
                 }
 #endif
 
-              /* Yes.. Decrement the number of frames "in-flight". */
+              /* Yes.. Free the packet of the frame */
 
-              priv->inflight--;
+              netpkt_free(&priv->dev, priv->txpkt[tail], NETPKT_TX);
+              priv->txpkt[tail] = NULL;
+              freed++;
 
-              /* If all of the TX descriptors were in-flight,
-               * then RX interrupts may have been disabled...
-               * we can re-enable them now.
-               */
+              /* Decrement the number of frames "in-flight". */
 
-              stm32_enableint(priv, ETH_DMAINT_RI);
+              priv->inflight--;
 
               /* If there are no more frames in-flight, then bail. */
 
@@ -2050,7 +1797,7 @@ static void stm32_freeframe(struct stm32_ethmac_s *priv)
                 {
                   priv->txtail   = NULL;
                   priv->inflight = 0;
-                  return;
+                  return freed;
                 }
             }
 
@@ -2068,39 +1815,32 @@ static void stm32_freeframe(struct stm32_ethmac_s *priv)
       ninfo("txhead: %p txtail: %p inflight: %d\n",
             priv->txhead, priv->txtail, priv->inflight);
     }
+
+  return freed;
 }
 
 /****************************************************************************
- * Function: stm32_txdone
+ * Function: stm32_txreap
  *
  * Description:
- *   An interrupt was received indicating that the last TX packet
- *   transfer(s) are complete.
+ *   Free the packets of completed transfers.  The TX timeout is cancelled
+ *   and the TX interrupts are disabled when no transfer is pending.
  *
  * Input Parameters:
- *   priv - Reference to the driver state structure
+ *   priv  - Reference to the driver state structure
  *
  * Returned Value:
- *   None
- *
- * Assumptions:
- *   Global interrupts are disabled by the watchdog logic.
+ *   The number of frames freed.
  *
  ****************************************************************************/
 
-static void stm32_txdone(struct stm32_ethmac_s *priv)
+static int stm32_txreap(struct stm32_ethmac_s *priv)
 {
-  DEBUGASSERT(priv->txtail != NULL);
+  int freed;
 
-  /* Scan the TX descriptor change, returning buffers to free list */
-
-  stm32_freeframe(priv);
-
-#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
-  /* Deliver any pending TX hardware timestamp loopback packets */
+  nxmutex_lock(&priv->lock);
 
-  stm32_txtstamp_flush(priv);
-#endif
+  freed = stm32_freeframe(priv);
 
   /* If no further xmits are pending, then cancel the TX timeout */
 
@@ -2115,9 +1855,71 @@ static void stm32_txdone(struct stm32_ethmac_s *priv)
       stm32_disableint(priv, ETH_DMAINT_TI);
     }
 
-  /* Then poll the network for new XMIT data */
+  nxmutex_unlock(&priv->lock);
+  return freed;
+}
+
+/****************************************************************************
+ * Function: stm32_txpoll
+ *
+ * Description:
+ *   NuttX Callback: free the packets of completed transfers for netpoll.
+ *   It must not block, so it skips the work when the lock is busy: the
+ *   holder frees the packets then.
+ *
+ * Input Parameters:
+ *   dev - Reference to the lower half driver state structure
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_NETPOLL
+static void stm32_txpoll(struct netdev_lowerhalf_s *dev)
+{
+  struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)dev;
+
+  if (nxmutex_trylock(&priv->lock) == OK)
+    {
+      stm32_freeframe(priv);
+      nxmutex_unlock(&priv->lock);
+    }
+}
+#endif
+
+/****************************************************************************
+ * Function: stm32_txdone
+ *
+ * Description:
+ *   An interrupt was received indicating that the last TX packet
+ *   transfer(s) are complete.
+ *
+ * Input Parameters:
+ *   priv - Reference to the driver state structure
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static void stm32_txdone(struct stm32_ethmac_s *priv)
+{
+  /* Scan the TX descriptor chain, then let the network send again */
+
+  if (stm32_txreap(priv) > 0)
+    {
+      netdev_lower_txdone(&priv->dev);
+    }
+
+#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
+  /* stm32_receive() delivers the TX timestamps */
 
-  stm32_dopoll(priv);
+  if (!IOB_QEMPTY(&priv->txtstampq))
+    {
+      netdev_lower_rxready(&priv->dev);
+    }
+#endif
 }
 
 /****************************************************************************
@@ -2146,8 +1948,6 @@ static void stm32_interrupt_work(void *arg)
 
   /* Process pending Ethernet interrupts */
 
-  net_lock();
-
   /* Get the DMA interrupt status bits (no MAC interrupts are expected) */
 
   dmasr = stm32_getreg(STM32_ETH_DMASR);
@@ -2162,8 +1962,8 @@ static void stm32_interrupt_work(void *arg)
 
   if ((dmasr & ETH_DMAINT_NIS) != 0)
     {
-      /* Yes.. Check if we received an incoming packet, if so, call
-       * stm32_receive()
+      /* Yes.. Check if we received an incoming packet, if so, let the
+       * upper half take it
        */
 
       if ((dmasr & ETH_DMAINT_RI) != 0)
@@ -2174,7 +1974,7 @@ static void stm32_interrupt_work(void *arg)
 
           /* Handle the received package */
 
-          stm32_receive(priv);
+          netdev_lower_rxready(&priv->dev);
         }
 
       /* Check if a packet transmission just completed.  If so, call
@@ -2232,13 +2032,10 @@ static void stm32_interrupt_work(void *arg)
            * everything will be restored.
            */
 
-          net_unlock();
           return;
         }
     }
 
-  net_unlock();
-
   /* Re-enable Ethernet interrupts at the NVIC */
 
   up_enable_irq(STM32_IRQ_ETH);
@@ -2319,16 +2116,23 @@ static void stm32_txtimeout_work(void *arg)
 {
   struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg;
 
-  /* Reset the hardware.  Just take the interface down, then back up again. */
+  /* Reset the hardware.  Just take the interface down, then back up again.
+   * The TX packets are freed, the RX packets are kept for the descriptors.
+   */
 
-  net_lock();
-  stm32_ifdown(&priv->dev);
-  stm32_ifup(&priv->dev);
+  NETDEV_TXTIMEOUTS(&priv->dev.netdev);
+  if (priv->ifup)
+    {
+      stm32_down(priv, false);
+      if (stm32_ifup(&priv->dev) < 0)
+        {
+          nerr("ERROR: Failed to bring the interface up again\n");
+        }
 
-  /* Then poll for new XMIT data */
+      /* Then let the network send again */
 
-  stm32_dopoll(priv);
-  net_unlock();
+      netdev_lower_txdone(&priv->dev);
+    }
 }
 
 /****************************************************************************
@@ -2389,10 +2193,10 @@ static void stm32_txtimeout_expiry(wdparm_t arg)
  *
  ****************************************************************************/
 
-static int stm32_ifup(struct net_driver_s *dev)
+static int stm32_ifup(struct netdev_lowerhalf_s *lower)
 {
-  struct stm32_ethmac_s *priv =
-    (struct stm32_ethmac_s *)dev->d_private;
+  struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)lower;
+  struct net_driver_s *dev = &priv->dev.netdev;
   int ret;
 
 #ifdef CONFIG_NET_IPv4
@@ -2409,9 +2213,11 @@ static int stm32_ifup(struct net_driver_s *dev)
 
   /* Configure the Ethernet interface for DMA operation. */
 
+  nxmutex_lock(&priv->lock);
   ret = stm32_ethconfig(priv);
   if (ret < 0)
     {
+      nxmutex_unlock(&priv->lock);
       return ret;
     }
 
@@ -2439,43 +2245,43 @@ static int stm32_ifup(struct net_driver_s *dev)
 
   priv->ifup = true;
   up_enable_irq(STM32_IRQ_ETH);
+  nxmutex_unlock(&priv->lock);
 
   stm32_checksetup();
-  netdev_carrier_on(dev);
+  netdev_lower_carrier_on(lower);
   return OK;
 }
 
 /****************************************************************************
- * Function: stm32_ifdown
+ * Function: stm32_down
  *
  * Description:
- *   NuttX Callback: Stop the interface.
+ *   Reset the hardware and free the TX packets.  The RX packets are freed
+ *   only if freerx is true, so that a reset does not need free IOBs to
+ *   bring the interface up again.
  *
  * Input Parameters:
- *   dev  - Reference to the NuttX driver state structure
+ *   priv   - Reference to the driver state structure
+ *   freerx - Free the RX packets too
  *
  * Returned Value:
  *   Returns zero on success; a negated errno value is returned on any
  *   failure.
  *
- * Assumptions:
- *
  ****************************************************************************/
 
-static int stm32_ifdown(struct net_driver_s *dev)
+static int stm32_down(struct stm32_ethmac_s *priv, bool freerx)
 {
-  struct stm32_ethmac_s *priv =
-    (struct stm32_ethmac_s *)dev->d_private;
+  struct netdev_lowerhalf_s *lower = &priv->dev;
   irqstate_t flags;
   int ret = OK;
-#ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
   int i;
-#endif
 
   ninfo("Taking the network down\n");
 
   /* Disable the Ethernet interrupt */
 
+  nxmutex_lock(&priv->lock);
   flags = enter_critical_section();
   up_disable_irq(STM32_IRQ_ETH);
 
@@ -2512,7 +2318,7 @@ static int stm32_ifdown(struct net_driver_s *dev)
   /* Drain any pending TX timestamp loopback packets and clones */
 
   iob_free_queue(&priv->txtstampq);
-  for (i = 0; i < CONFIG_STM32_ETH_NTXDESC; i++)
+  for (i = 0; i < STM32_ETH_NTXBUF; i++)
     {
       if (priv->txmeta[i] != NULL)
         {
@@ -2525,84 +2331,54 @@ static int stm32_ifdown(struct net_driver_s *dev)
   /* Mark the device "down" */
 
   priv->ifup = false;
-  netdev_carrier_off(dev);
   leave_critical_section(flags);
-  return ret;
-}
-
-/****************************************************************************
- * Function: stm32_txavail_work
- *
- * Description:
- *   Perform an out-of-cycle poll on the worker thread.
- *
- * Input Parameters:
- *   arg  - Reference to the NuttX driver state structure (cast to void*)
- *
- * Returned Value:
- *   None
- *
- * Assumptions:
- *   Called on the higher priority worker thread.
- *
- ****************************************************************************/
-
-static void stm32_txavail_work(void *arg)
-{
-  struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg;
-
-  ninfo("ifup: %d\n", priv->ifup);
 
-  /* Ignore the notification if the interface is not yet up */
+  /* Free the packets held by the descriptors */
 
-  net_lock();
-  if (priv->ifup)
+  for (i = 0; i < STM32_ETH_NTXBUF; i++)
     {
-      /* Poll the network for new XMIT data */
+      if (priv->txpkt[i] != NULL)
+        {
+          netpkt_free(lower, priv->txpkt[i], NETPKT_TX);
+          priv->txpkt[i] = NULL;
+        }
+    }
 
-      stm32_dopoll(priv);
+  for (i = 0; freerx && i < STM32_ETH_NRXBUF; i++)
+    {
+      if (priv->rxpkt[i] != NULL)
+        {
+          netpkt_free(lower, priv->rxpkt[i], NETPKT_RX);
+          priv->rxpkt[i] = NULL;
+        }
     }
 
-  net_unlock();
+  nxmutex_unlock(&priv->lock);
+
+  netdev_lower_carrier_off(lower);
+  return ret;
 }
 
 /****************************************************************************
- * Function: stm32_txavail
+ * Function: stm32_ifdown
  *
  * Description:
- *   Driver callback invoked when new TX data is available.  This is a
- *   stimulus perform an out-of-cycle poll and, thereby, reduce the TX
- *   latency.
+ *   NuttX Callback: Stop the interface.
  *
  * Input Parameters:
- *   dev  - Reference to the NuttX driver state structure
+ *   lower - Reference to the lower half driver state structure
  *
  * Returned Value:
- *   None
+ *   Returns zero on success; a negated errno value is returned on any
+ *   failure.
  *
  * Assumptions:
- *   Called in normal user mode
  *
  ****************************************************************************/
 
-static int stm32_txavail(struct net_driver_s *dev)
+static int stm32_ifdown(struct netdev_lowerhalf_s *lower)
 {
-  struct stm32_ethmac_s *priv =
-    (struct stm32_ethmac_s *)dev->d_private;
-
-  /* Is our single work structure available?  It may not be if there are
-   * pending interrupt actions and we will have to ignore the Tx
-   * availability action.
-   */
-
-  if (work_available(&priv->pollwork))
-    {
-      /* Schedule to serialize the poll on the worker thread. */
-
-      work_queue(ETHWORK, &priv->pollwork, stm32_txavail_work, priv, 0);
-    }
-
-  return OK;
+  return stm32_down((struct stm32_ethmac_s *)lower, true);
 }
 
 /****************************************************************************
@@ -2669,7 +2445,7 @@ static uint32_t stm32_calcethcrc(const uint8_t *data, 
size_t length)
  ****************************************************************************/
 
 #if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6)
-static int stm32_addmac(struct net_driver_s *dev, const uint8_t *mac)
+static int stm32_addmac(struct netdev_lowerhalf_s *dev, const uint8_t *mac)
 {
   uint32_t crc;
   uint32_t hashindex;
@@ -2726,7 +2502,7 @@ static int stm32_addmac(struct net_driver_s *dev, const 
uint8_t *mac)
  ****************************************************************************/
 
 #ifdef CONFIG_NET_MCASTGROUP
-static int stm32_rmmac(struct net_driver_s *dev, const uint8_t *mac)
+static int stm32_rmmac(struct netdev_lowerhalf_s *dev, const uint8_t *mac)
 {
   uint32_t crc;
   uint32_t hashindex;
@@ -2808,7 +2584,7 @@ static void stm32_txdescinit(struct stm32_ethmac_s *priv,
 
   /* Initialize each TX descriptor */
 
-  for (i = 0; i < CONFIG_STM32_ETH_NTXDESC; i++)
+  for (i = 0; i < STM32_ETH_NTXBUF; i++)
     {
       txdesc = &txtable[i];
 
@@ -2832,7 +2608,7 @@ static void stm32_txdescinit(struct stm32_ethmac_s *priv,
        * the Next Descriptor Polling Enable
        */
 
-      if (i < (CONFIG_STM32_ETH_NTXDESC - 1))
+      if (i < (STM32_ETH_NTXBUF - 1))
         {
           /* Set next descriptor address register with next descriptor base
            * address
@@ -2865,15 +2641,14 @@ static void stm32_txdescinit(struct stm32_ethmac_s 
*priv,
  *   priv  - Reference to the driver state structure
  *
  * Returned Value:
- *   None
+ *   Zero on success; -ENOMEM if no IOB is free.
  *
  * Assumptions:
  *
  ****************************************************************************/
 
-static void stm32_rxdescinit(struct stm32_ethmac_s *priv,
-                             struct eth_rxdesc_s *rxtable,
-                             uint8_t *rxbuffer)
+static int stm32_rxdescinit(struct stm32_ethmac_s *priv,
+                            struct eth_rxdesc_s *rxtable)
 {
   struct eth_rxdesc_s *rxdesc;
   int i;
@@ -2893,10 +2668,22 @@ static void stm32_rxdescinit(struct stm32_ethmac_s 
*priv,
 
   /* Initialize each TX descriptor */
 
-  for (i = 0; i < CONFIG_STM32_ETH_NRXDESC; i++)
+  for (i = 0; i < STM32_ETH_NRXBUF; i++)
     {
       rxdesc = &rxtable[i];
 
+      /* Each descriptor owns one packet */
+
+      if (priv->rxpkt[i] == NULL)
+        {
+          priv->rxpkt[i] = netpkt_alloc(&priv->dev, NETPKT_RX);
+          if (priv->rxpkt[i] == NULL)
+            {
+              nerr("ERROR: No RX buffers\n");
+              return -ENOMEM;
+            }
+        }
+
       /* Set Own bit of the RX descriptor rdes0 */
 
       rxdesc->rdes0 = ETH_RDES0_OWN;
@@ -2905,17 +2692,17 @@ static void stm32_rxdescinit(struct stm32_ethmac_s 
*priv,
        * RX desc receive interrupt
        */
 
-      rxdesc->rdes1 = ETH_RDES1_RCH | (uint32_t)CONFIG_STM32_ETH_BUFSIZE;
+      rxdesc->rdes1 = ETH_RDES1_RCH | (uint32_t)STM32_ETH_BUFSIZE;
 
       /* Set Buffer1 address pointer */
 
-      rxdesc->rdes2 = (uint32_t)&rxbuffer[i * CONFIG_STM32_ETH_BUFSIZE];
+      rxdesc->rdes2 = (uint32_t)netpkt_getdata(&priv->dev, priv->rxpkt[i]);
 
       /* Initialize the next descriptor with
        * the Next Descriptor Polling Enable
        */
 
-      if (i < (CONFIG_STM32_ETH_NRXDESC - 1))
+      if (i < (STM32_ETH_NRXBUF - 1))
         {
           /* Set next descriptor address register with next descriptor base
            * address
@@ -2936,6 +2723,7 @@ static void stm32_rxdescinit(struct stm32_ethmac_s *priv,
   /* Set Receive Descriptor List Address Register */
 
   stm32_putreg((uint32_t)rxtable, STM32_ETH_DMARDLAR);
+  return OK;
 }
 
 /****************************************************************************
@@ -2968,11 +2756,11 @@ static void stm32_rxdescinit(struct stm32_ethmac_s 
*priv,
  ****************************************************************************/
 
 #ifdef CONFIG_NETDEV_IOCTL
-static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
+static int stm32_ioctl(struct netdev_lowerhalf_s *dev, int cmd,
+                       unsigned long arg)
 {
 #if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT)
-  struct stm32_ethmac_s *priv =
-    (struct stm32_ethmac_s *)dev->d_private;
+  struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)dev;
 #endif
   int ret;
 
@@ -2985,7 +2773,8 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, 
unsigned long arg)
           struct mii_ioctl_notify_s *req =
         (struct mii_ioctl_notify_s *)((uintptr_t)arg);
 
-          ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
+          ret = phy_notify_subscribe(dev->netdev.d_ifname, req->pid,
+                                     &req->event);
           if (ret == OK)
             {
               /* Enable PHY link up/down interrupts */
@@ -4130,7 +3919,8 @@ static uint64_t stm32_eth_ptp_gettime(void)
  * value of CLOCK_REALTIME.
  */
 #ifdef CONFIG_STM32_ETH_TIMESTAMP_RX
-static void stm32_eth_ptp_convert_rxtime(struct stm32_ethmac_s *priv)
+static void stm32_eth_ptp_convert_rxtime(struct stm32_ethmac_s *priv,
+                                         struct timespec *ts)
 {
   uint64_t timestamp;
 
@@ -4146,8 +3936,8 @@ static void stm32_eth_ptp_convert_rxtime(struct 
stm32_ethmac_s *priv)
   if (timestamp == 0 || timestamp >= UINT64_MAX - 1)
     {
       nerr("Packet RX timestamp is invalid\n");
-      priv->dev.d_rxtime.tv_sec = 0;
-      priv->dev.d_rxtime.tv_nsec = 0;
+      ts->tv_sec = 0;
+      ts->tv_nsec = 0;
       return;
     }
 
@@ -4158,7 +3948,7 @@ static void stm32_eth_ptp_convert_rxtime(struct 
stm32_ethmac_s *priv)
    * therefore the physical PPS output) to the master.
    */
 
-  ptp_to_timespec(timestamp, &priv->dev.d_rxtime);
+  ptp_to_timespec(timestamp, ts);
 }
 #endif /* CONFIG_STM32_ETH_TIMESTAMP_RX */
 
@@ -4216,7 +4006,6 @@ static int stm32_ethreset(struct stm32_ethmac_s *priv)
 
   /* Wait for software reset to complete. The SR bit is cleared automatically
    * after the reset operation has completed in all core clock domains.
-   * Should take at most a few clock ticks of the 50 MHz domain.
    */
 
   retries = 10;
@@ -4347,7 +4136,7 @@ static int stm32_macconfig(struct stm32_ethmac_s *priv)
 
 static void stm32_macaddress(struct stm32_ethmac_s *priv)
 {
-  struct net_driver_s *dev = &priv->dev;
+  struct net_driver_s *dev = &priv->dev.netdev;
   uint32_t regval;
 
   ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -4507,17 +4296,17 @@ static int stm32_ethconfig(struct stm32_ethmac_s *priv)
       return ret;
     }
 
-  /* Initialize the free buffer list */
-
-  stm32_initbuffer(priv, g_alloc);
-
   /* Initialize TX Descriptors list: Chain Mode */
 
   stm32_txdescinit(priv, g_txtable);
 
   /* Initialize RX Descriptors list: Chain Mode  */
 
-  stm32_rxdescinit(priv, g_rxtable, g_rxbuffer);
+  ret = stm32_rxdescinit(priv, g_rxtable);
+  if (ret < 0)
+    {
+      return ret;
+    }
 
   /* Enable normal MAC operation */
 
@@ -4567,17 +4356,10 @@ int stm32_ethinitialize(int intf)
   /* Initialize the driver structure */
 
   memset(priv, 0, sizeof(struct stm32_ethmac_s));
-  priv->dev.d_ifup    = stm32_ifup;     /* I/F up (new IP address) callback */
-  priv->dev.d_ifdown  = stm32_ifdown;   /* I/F down callback */
-  priv->dev.d_txavail = stm32_txavail;  /* New TX data callback */
-#ifdef CONFIG_NET_MCASTGROUP
-  priv->dev.d_addmac  = stm32_addmac;   /* Add multicast MAC address */
-  priv->dev.d_rmmac   = stm32_rmmac;    /* Remove multicast MAC address */
-#endif
-#ifdef CONFIG_NETDEV_IOCTL
-  priv->dev.d_ioctl   = stm32_ioctl;    /* Support PHY ioctl() calls */
-#endif
-  priv->dev.d_private = g_stm32ethmac;  /* Used to recover private state from 
dev */
+  priv->dev.ops              = &g_stm32_ops;
+  priv->dev.rxtype           = NETDEV_RX_DIRECT; /* From the IRQ work */
+  priv->dev.priority         = ETHWORK;
+  nxmutex_init(&priv->lock);
 
   /* Configure GPIO pins to support Ethernet */
 
@@ -4592,9 +4374,9 @@ int stm32_ethinitialize(int intf)
       return -EAGAIN;
     }
 
-  /* Put the interface in the down state. */
+  /* Put the EMAC in its reset, non-operational state. */
 
-  ret = stm32_ifdown(&priv->dev);
+  ret = stm32_ethreset(priv);
   if (ret < 0)
     {
       nerr("ERROR: Initialization of Ethernet block failed: %d\n", ret);
@@ -4602,15 +4384,20 @@ int stm32_ethinitialize(int intf)
     }
 
 #ifdef CONFIG_STM32_ETH_TIMESTAMP_RX
-  priv->dev.d_features |= NETDEV_RX_STAMP;
+  priv->dev.netdev.d_features |= NETDEV_RX_STAMP;
 #endif
 #ifdef CONFIG_STM32_ETH_TIMESTAMP_TX
-  priv->dev.d_features |= NETDEV_TX_STAMP;
+  priv->dev.netdev.d_features |= NETDEV_TX_STAMP;
 #endif
 
   /* Register the device with the OS so that socket IOCTLs can be performed */
 
-  netdev_register(&priv->dev, NET_LL_ETHERNET);
+  ret = netdev_lower_register(&priv->dev, NET_LL_ETHERNET);
+  if (ret < 0)
+    {
+      nerr("ERROR: netdev_lower_register failed: %d\n", ret);
+      return ret;
+    }
 
 #if defined(CONFIG_STM32_ETH_PTP) && defined(CONFIG_PTP_CLOCK)
   /* Register the PTP clock character driver (/dev/ptp0) */
diff --git a/boards/arm/stm32f1/cloudctrl/configs/nsh/defconfig 
b/boards/arm/stm32f1/cloudctrl/configs/nsh/defconfig
index 35a72832e26..3401d1c4096 100644
--- a/boards/arm/stm32f1/cloudctrl/configs/nsh/defconfig
+++ b/boards/arm/stm32f1/cloudctrl/configs/nsh/defconfig
@@ -26,6 +26,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MMCSD=y
 CONFIG_MMCSD_SPICLOCK=12500000
diff --git a/boards/arm/stm32f1/olimex-stm32-p107/configs/nsh/defconfig 
b/boards/arm/stm32f1/olimex-stm32-p107/configs/nsh/defconfig
index 8b360b49552..fc1f0bd5be8 100644
--- a/boards/arm/stm32f1/olimex-stm32-p107/configs/nsh/defconfig
+++ b/boards/arm/stm32f1/olimex-stm32-p107/configs/nsh/defconfig
@@ -24,6 +24,8 @@ CONFIG_CAN=y
 CONFIG_ETH0_PHY_KS8721=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MMCSD=y
 CONFIG_MTD=y
 CONFIG_NET=y
diff --git a/boards/arm/stm32f1/shenzhou/configs/nsh/defconfig 
b/boards/arm/stm32f1/shenzhou/configs/nsh/defconfig
index cc6a676e941..b975ba1c0fd 100644
--- a/boards/arm/stm32f1/shenzhou/configs/nsh/defconfig
+++ b/boards/arm/stm32f1/shenzhou/configs/nsh/defconfig
@@ -25,6 +25,8 @@ CONFIG_FS_FAT=y
 CONFIG_HAVE_CXX=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MMCSD=y
 CONFIG_MMCSD_SPICLOCK=12500000
diff --git a/boards/arm/stm32f1/shenzhou/configs/nxwm/defconfig 
b/boards/arm/stm32f1/shenzhou/configs/nxwm/defconfig
index 39fd4cf05d0..8aa2d9276b1 100644
--- a/boards/arm/stm32f1/shenzhou/configs/nxwm/defconfig
+++ b/boards/arm/stm32f1/shenzhou/configs/nxwm/defconfig
@@ -34,6 +34,8 @@ CONFIG_INIT_STACKSIZE=1024
 CONFIG_INPUT=y
 CONFIG_INPUT_ADS7843E=y
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_NOGETRUN=y
diff --git a/boards/arm/stm32f1/shenzhou/configs/thttpd/defconfig 
b/boards/arm/stm32f1/shenzhou/configs/thttpd/defconfig
index 9d4170bfa9e..10ca4023b4b 100644
--- a/boards/arm/stm32f1/shenzhou/configs/thttpd/defconfig
+++ b/boards/arm/stm32f1/shenzhou/configs/thttpd/defconfig
@@ -27,6 +27,8 @@ CONFIG_FS_ROMFS=y
 CONFIG_HAVE_CXX=y
 CONFIG_INIT_ENTRYPOINT="thttp_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MTD=y
 CONFIG_MTD_W25=y
diff --git a/boards/arm/stm32f1/stm32butterfly2/configs/nshnet/defconfig 
b/boards/arm/stm32f1/stm32butterfly2/configs/nshnet/defconfig
index 4ffa586a44c..7f847d97bb6 100644
--- a/boards/arm/stm32f1/stm32butterfly2/configs/nshnet/defconfig
+++ b/boards/arm/stm32f1/stm32butterfly2/configs/nshnet/defconfig
@@ -36,6 +36,8 @@ CONFIG_FS_PROCFS=y
 CONFIG_FS_PROCFS_REGISTER=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LIBC_HOSTNAME="butterfly2"
 CONFIG_LIBC_STRERROR=y
 CONFIG_LIBC_STRERROR_SHORT=y
diff --git a/boards/arm/stm32f1/viewtool-stm32f107/configs/netnsh/defconfig 
b/boards/arm/stm32f1/viewtool-stm32f107/configs/netnsh/defconfig
index ff5671048b6..e06374789f6 100644
--- a/boards/arm/stm32f1/viewtool-stm32f107/configs/netnsh/defconfig
+++ b/boards/arm/stm32f1/viewtool-stm32f107/configs/netnsh/defconfig
@@ -22,7 +22,7 @@ CONFIG_FS_PROCFS=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
-CONFIG_IOB_NBUFFERS=24
+CONFIG_IOB_NBUFFERS=100
 CONFIG_LIBC_HOSTNAME="Viewtool-STM32F107"
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
diff --git a/boards/arm/stm32f1/viewtool-stm32f107/configs/tcpblaster/defconfig 
b/boards/arm/stm32f1/viewtool-stm32f107/configs/tcpblaster/defconfig
index 371d259e0da..8ea89a89d27 100644
--- a/boards/arm/stm32f1/viewtool-stm32f107/configs/tcpblaster/defconfig
+++ b/boards/arm/stm32f1/viewtool-stm32f107/configs/tcpblaster/defconfig
@@ -22,7 +22,7 @@ CONFIG_EXAMPLES_TCPBLASTER=y
 CONFIG_FS_PROCFS=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
-CONFIG_IOB_NBUFFERS=50
+CONFIG_IOB_NBUFFERS=100
 CONFIG_LIBC_HOSTNAME="Viewtool-STM32F107"
 CONFIG_LIBM=y
 CONFIG_NET=y
diff --git a/boards/arm/stm32f2/nucleo-f207zg/configs/netnsh/defconfig 
b/boards/arm/stm32f2/nucleo-f207zg/configs/netnsh/defconfig
index f835f96cc95..3c42983cce2 100644
--- a/boards/arm/stm32f2/nucleo-f207zg/configs/netnsh/defconfig
+++ b/boards/arm/stm32f2/nucleo-f207zg/configs/netnsh/defconfig
@@ -27,6 +27,8 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_IDLETHREAD_STACKSIZE=2048
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
diff --git a/boards/arm/stm32f2/olimex-stm32-p207/configs/nsh/defconfig 
b/boards/arm/stm32f2/olimex-stm32-p207/configs/nsh/defconfig
index d74bd22eb86..a76b1a51fad 100644
--- a/boards/arm/stm32f2/olimex-stm32-p207/configs/nsh/defconfig
+++ b/boards/arm/stm32f2/olimex-stm32-p207/configs/nsh/defconfig
@@ -30,6 +30,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
diff --git a/boards/arm/stm32f2/stm3220g-eval/configs/dhcpd/defconfig 
b/boards/arm/stm32f2/stm3220g-eval/configs/dhcpd/defconfig
index 4e83650fdf4..3fad9e367d0 100644
--- a/boards/arm/stm32f2/stm3220g-eval/configs/dhcpd/defconfig
+++ b/boards/arm/stm32f2/stm3220g-eval/configs/dhcpd/defconfig
@@ -27,6 +27,8 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="dhcpd_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETUTILS_DHCPD=y
diff --git a/boards/arm/stm32f2/stm3220g-eval/configs/nettest/defconfig 
b/boards/arm/stm32f2/stm3220g-eval/configs/nettest/defconfig
index 431b3151a62..741dd500ac0 100644
--- a/boards/arm/stm32f2/stm3220g-eval/configs/nettest/defconfig
+++ b/boards/arm/stm32f2/stm3220g-eval/configs/nettest/defconfig
@@ -28,6 +28,8 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="nettest_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_NET=y
 CONFIG_NETUTILS_NETLIB=y
 CONFIG_NET_MAX_LISTENPORTS=40
diff --git a/boards/arm/stm32f2/stm3220g-eval/configs/nsh/defconfig 
b/boards/arm/stm32f2/stm3220g-eval/configs/nsh/defconfig
index 26a63e10c07..572fe818a1d 100644
--- a/boards/arm/stm32f2/stm3220g-eval/configs/nsh/defconfig
+++ b/boards/arm/stm32f2/stm3220g-eval/configs/nsh/defconfig
@@ -29,6 +29,8 @@ CONFIG_I2C=y
 CONFIG_I2C_POLLED=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MMCSD=y
 CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
 CONFIG_MTD=y
diff --git a/boards/arm/stm32f2/stm3220g-eval/configs/nsh2/defconfig 
b/boards/arm/stm32f2/stm3220g-eval/configs/nsh2/defconfig
index 5dff42667f2..31f27c3217c 100644
--- a/boards/arm/stm32f2/stm3220g-eval/configs/nsh2/defconfig
+++ b/boards/arm/stm32f2/stm3220g-eval/configs/nsh2/defconfig
@@ -34,6 +34,8 @@ CONFIG_I2CTOOL_MINBUS=1
 CONFIG_I2C_POLLED=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MMCSD=y
 CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
diff --git a/boards/arm/stm32f2/stm3220g-eval/configs/nxwm/defconfig 
b/boards/arm/stm32f2/stm3220g-eval/configs/nxwm/defconfig
index 8a2c4444608..a328fc0eb71 100644
--- a/boards/arm/stm32f2/stm3220g-eval/configs/nxwm/defconfig
+++ b/boards/arm/stm32f2/stm3220g-eval/configs/nxwm/defconfig
@@ -35,6 +35,8 @@ CONFIG_INIT_ENTRYPOINT="nxwm_main"
 CONFIG_INPUT=y
 CONFIG_INPUT_STMPE811=y
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_NOGETRUN=y
diff --git a/boards/arm/stm32f2/stm3220g-eval/configs/telnetd/defconfig 
b/boards/arm/stm32f2/stm3220g-eval/configs/telnetd/defconfig
index 5d80ddff92c..7ea12d42878 100644
--- a/boards/arm/stm32f2/stm3220g-eval/configs/telnetd/defconfig
+++ b/boards/arm/stm32f2/stm3220g-eval/configs/telnetd/defconfig
@@ -28,6 +28,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="telnetd_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETUTILS_TELNETD=y
diff --git a/boards/arm/stm32f4/nucleo-f429zi/configs/netnsh/defconfig 
b/boards/arm/stm32f4/nucleo-f429zi/configs/netnsh/defconfig
index f73c7f82f5b..4fe2c783316 100644
--- a/boards/arm/stm32f4/nucleo-f429zi/configs/netnsh/defconfig
+++ b/boards/arm/stm32f4/nucleo-f429zi/configs/netnsh/defconfig
@@ -28,6 +28,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
diff --git a/boards/arm/stm32f4/nucleo-f429zi/configs/trace/defconfig 
b/boards/arm/stm32f4/nucleo-f429zi/configs/trace/defconfig
index 7d554179830..47918b6d6f3 100644
--- a/boards/arm/stm32f4/nucleo-f429zi/configs/trace/defconfig
+++ b/boards/arm/stm32f4/nucleo-f429zi/configs/trace/defconfig
@@ -28,6 +28,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
diff --git a/boards/arm/stm32f4/olimex-stm32-e407/configs/discover/defconfig 
b/boards/arm/stm32f4/olimex-stm32-e407/configs/discover/defconfig
index 67d4415b193..dcf65494182 100644
--- a/boards/arm/stm32f4/olimex-stm32-e407/configs/discover/defconfig
+++ b/boards/arm/stm32f4/olimex-stm32-e407/configs/discover/defconfig
@@ -29,6 +29,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="discover_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NET_ARP_IPIN=y
diff --git a/boards/arm/stm32f4/olimex-stm32-e407/configs/netnsh/defconfig 
b/boards/arm/stm32f4/olimex-stm32-e407/configs/netnsh/defconfig
index 40f0c41a88e..ce970d499df 100644
--- a/boards/arm/stm32f4/olimex-stm32-e407/configs/netnsh/defconfig
+++ b/boards/arm/stm32f4/olimex-stm32-e407/configs/netnsh/defconfig
@@ -25,6 +25,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
diff --git a/boards/arm/stm32f4/olimex-stm32-e407/configs/telnetd/defconfig 
b/boards/arm/stm32f4/olimex-stm32-e407/configs/telnetd/defconfig
index bd9d1caa9a8..dd620b29f70 100644
--- a/boards/arm/stm32f4/olimex-stm32-e407/configs/telnetd/defconfig
+++ b/boards/arm/stm32f4/olimex-stm32-e407/configs/telnetd/defconfig
@@ -31,6 +31,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="telnetd_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
diff --git a/boards/arm/stm32f4/olimex-stm32-e407/configs/webserver/defconfig 
b/boards/arm/stm32f4/olimex-stm32-e407/configs/webserver/defconfig
index 05748b1f5ee..8dd485d0441 100644
--- a/boards/arm/stm32f4/olimex-stm32-e407/configs/webserver/defconfig
+++ b/boards/arm/stm32f4/olimex-stm32-e407/configs/webserver/defconfig
@@ -27,6 +27,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="webserver_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
diff --git a/boards/arm/stm32f4/olimex-stm32-p407/configs/mqttc/defconfig 
b/boards/arm/stm32f4/olimex-stm32-p407/configs/mqttc/defconfig
index f2acbb04e7a..dec9dc6e2fa 100644
--- a/boards/arm/stm32f4/olimex-stm32-p407/configs/mqttc/defconfig
+++ b/boards/arm/stm32f4/olimex-stm32-p407/configs/mqttc/defconfig
@@ -28,6 +28,7 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
 CONFIG_LIBM=y
 CONFIG_LINE_MAX=64
 CONFIG_NET=y
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/dhcpd/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/dhcpd/defconfig
index f6c6f566907..f24738b2f92 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/dhcpd/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/dhcpd/defconfig
@@ -28,6 +28,8 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="dhcpd_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETUTILS_DHCPD=y
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/discover/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/discover/defconfig
index 616c7e441cb..239cb865e00 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/discover/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/discover/defconfig
@@ -29,6 +29,8 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_I2C=y
 CONFIG_I2C_POLLED=y
 CONFIG_INIT_ENTRYPOINT="discover_main"
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT_ENTRIES=4
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/nettest/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/nettest/defconfig
index 1f3385947f2..70ecf50bcfe 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/nettest/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/nettest/defconfig
@@ -29,6 +29,8 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="nettest_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETUTILS_NETLIB=y
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/nsh/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/nsh/defconfig
index 80a98d96abb..b3d73559aa9 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/nsh/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/nsh/defconfig
@@ -31,6 +31,8 @@ CONFIG_I2CTOOL_MINBUS=1
 CONFIG_I2C_POLLED=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/nsh2/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/nsh2/defconfig
index 005e9e04a08..96dd56e19e0 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/nsh2/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/nsh2/defconfig
@@ -35,6 +35,8 @@ CONFIG_I2CTOOL_MINBUS=1
 CONFIG_I2C_POLLED=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MMCSD=y
 CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/nxterm/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/nxterm/defconfig
index 25740c07a6c..0f94fa1bbb2 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/nxterm/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/nxterm/defconfig
@@ -36,6 +36,8 @@ CONFIG_I2CTOOL_MINBUS=1
 CONFIG_I2C_POLLED=y
 CONFIG_INIT_ENTRYPOINT="nxterm_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_NOGETRUN=y
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/nxwm/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/nxwm/defconfig
index 9104b7cd84a..769fdfa0168 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/nxwm/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/nxwm/defconfig
@@ -34,6 +34,8 @@ CONFIG_INIT_ENTRYPOINT="nxwm_main"
 CONFIG_INPUT=y
 CONFIG_INPUT_STMPE811=y
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LCD=y
 CONFIG_LCD_MAXCONTRAST=1
 CONFIG_LCD_NOGETRUN=y
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/telnetd/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/telnetd/defconfig
index fbe59922f17..3568285dc7d 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/telnetd/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/telnetd/defconfig
@@ -29,6 +29,8 @@ CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="telnetd_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETUTILS_TELNETD=y
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/webserver/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/webserver/defconfig
index 28c7c0ac956..0cc7300efc4 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/webserver/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/webserver/defconfig
@@ -29,6 +29,8 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_I2C=y
 CONFIG_I2C_POLLED=y
 CONFIG_INIT_ENTRYPOINT="webserver_main"
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_LINE_MAX=64
 CONFIG_MM_REGIONS=2
 CONFIG_MTD=y
diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/xmlrpc/defconfig 
b/boards/arm/stm32f4/stm3240g-eval/configs/xmlrpc/defconfig
index 530c00545a4..70495035345 100644
--- a/boards/arm/stm32f4/stm3240g-eval/configs/xmlrpc/defconfig
+++ b/boards/arm/stm32f4/stm3240g-eval/configs/xmlrpc/defconfig
@@ -29,6 +29,8 @@ CONFIG_I2C=y
 CONFIG_I2C_POLLED=y
 CONFIG_INIT_ENTRYPOINT="xmlrpc_main"
 CONFIG_INIT_STACKSIZE=4096
+CONFIG_IOB_NBUFFERS=100
+CONFIG_IOB_THROTTLE=8
 CONFIG_MM_REGIONS=2
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT_ENTRIES=4
diff --git a/boards/arm/stm32f4/stm32f4discovery/configs/ipv6/defconfig 
b/boards/arm/stm32f4/stm32f4discovery/configs/ipv6/defconfig
index 0a856c6e165..10032db210f 100644
--- a/boards/arm/stm32f4/stm32f4discovery/configs/ipv6/defconfig
+++ b/boards/arm/stm32f4/stm32f4discovery/configs/ipv6/defconfig
@@ -32,6 +32,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
 CONFIG_LIBC_HOSTNAME="STM32F4-Discovery"
 CONFIG_LINE_MAX=64
 CONFIG_MMCSD=y
diff --git a/boards/arm/stm32f4/stm32f4discovery/configs/netnsh/defconfig 
b/boards/arm/stm32f4/stm32f4discovery/configs/netnsh/defconfig
index e7e4cc4c095..5c3dfbc0bb3 100644
--- a/boards/arm/stm32f4/stm32f4discovery/configs/netnsh/defconfig
+++ b/boards/arm/stm32f4/stm32f4discovery/configs/netnsh/defconfig
@@ -33,6 +33,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_HOST_WINDOWS=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_NBUFFERS=100
 CONFIG_LIBC_HOSTNAME="STM32F4-Discovery"
 CONFIG_LINE_MAX=64
 CONFIG_MMCSD=y

Reply via email to