Eliminate CONFIG_NO_NOINTS. Lots of files changed -> lots of testing needed.

This commit is contained in:
Gregory Nutt
2016-12-03 16:28:19 -06:00
parent bdb8275824
commit 7467329a98
180 changed files with 1481 additions and 5157 deletions
+1 -4
View File
@@ -9,12 +9,9 @@ config NETDEV_LOOPBACK
bool
default n if !NET_LOOPBACK
default y if NET_LOOPBACK
select NET_NOINTS
select ARCH_HAVE_NETDEV_STATISTICS
---help---
Add support for the local network loopback device, lo. Any additional
networking devices that are enabled must be compatible with
CONFIG_NET_NOINTS.
Add support for the local network loopback device, lo.
if NETDEV_LOOPBACK
+68 -228
View File
@@ -65,11 +65,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wdog.h>
#ifdef CONFIG_NET_NOINTS
# include <nuttx/wqueue.h>
#endif
#include <nuttx/wqueue.h>
#include <nuttx/net/arp.h>
#include <nuttx/net/netdev.h>
@@ -84,13 +80,12 @@
* is required.
*/
#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE)
#if !defined(CONFIG_SCHED_WORKQUEUE)
# error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE)
#endif
#else
/* Use the low priority work queue if possible */
/* Use the low priority work queue if possible */
#if defined(CONFIG_SCHED_WORKQUEUE)
# if defined(CONFIG_DM9X_HPWORK)
# define ETHWORK HPWORK
# elif defined(CONFIG_DM9X_LPWORK)
@@ -326,9 +321,7 @@ struct dm9x_driver_s
uint8_t ncrxpackets; /* Number of continuous rx packets */
WDOG_ID dm_txpoll; /* TX poll timer */
WDOG_ID dm_txtimeout; /* TX timeout timer */
#ifdef CONFIG_NET_NOINTS
struct work_s dm_work; /* For deferring work to the work queue */
#endif
/* Mode-dependent function to move data in 8/16/32 I/O modes */
@@ -391,24 +384,15 @@ static int dm9x_txpoll(struct net_driver_s *dev);
static void dm9x_receive(struct dm9x_driver_s *priv);
static void dm9x_txdone(struct dm9x_driver_s *priv);
static inline void dm9x_interrupt_process(FAR struct dm9x_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void dm9x_interrupt_work(FAR void *arg);
#endif
static int dm9x_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */
static inline void dm9x_txtimeout_process(FAR struct dm9x_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void dm9x_txtimeout_work(FAR void *arg);
#endif
static void dm9x_txtimeout_expiry(int argc, uint32_t arg, ...);
static inline void dm9x_poll_process(FAR struct dm9x_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void dm9x_poll_work(FAR void *arg);
#endif
static void dm9x_poll_expiry(int argc, uint32_t arg, ...);
/* NuttX callback functions */
@@ -416,10 +400,7 @@ static void dm9x_poll_expiry(int argc, uint32_t arg, ...);
static int dm9x_ifup(struct net_driver_s *dev);
static int dm9x_ifdown(struct net_driver_s *dev);
static inline void dm9x_txavail_process(FAR struct dm9x_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void dm9x_txavail_work(FAR void *arg);
#endif
static int dm9x_txavail(struct net_driver_s *dev);
#ifdef CONFIG_NET_IGMP
@@ -1122,29 +1103,33 @@ static void dm9x_txdone(struct dm9x_driver_s *priv)
}
/****************************************************************************
* Function: dm9x_interrupt_process
* Function: dm9x_interrupt_work
*
* Description:
* Interrupt processing. This may be performed either within the interrupt
* handler or on the worker thread, depending upon the configuration
* Perform interrupt related work from the worker thread
*
* Parameters:
* priv - Reference to the driver state structure
* arg - The argument passed when work_queue() was called.
*
* Returned Value:
* None
* OK on success
*
* Assumptions:
* The network is locked.
*
****************************************************************************/
static inline void dm9x_interrupt_process(FAR struct dm9x_driver_s *priv)
static void dm9x_interrupt_work(FAR void *arg)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg;
uint8_t isr;
uint8_t save;
int i;
/* Process pending Ethernet interrupts */
net_lock();
/* Save previous register address */
save = (uint8_t)DM9X_INDEX;
@@ -1229,42 +1214,12 @@ static inline void dm9x_interrupt_process(FAR struct dm9x_driver_s *priv)
/* Restore previous register address */
DM9X_INDEX = save;
}
/****************************************************************************
* Function: dm9x_interrupt_work
*
* Description:
* Perform interrupt related work from the worker thread
*
* Parameters:
* arg - The argument passed when work_queue() was called.
*
* Returned Value:
* OK on success
*
* Assumptions:
* The network is locked.
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void dm9x_interrupt_work(FAR void *arg)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg;
net_lock_t state;
/* Process pending Ethernet interrupts */
state = net_lock();
dm9x_interrupt_process(priv);
net_unlock(state);
net_unlock();
/* Re-enable Ethernet interrupts */
up_enable_irq(CONFIG_DM9X_IRQ);
}
#endif
/****************************************************************************
* Function: dm9x_interrupt
@@ -1290,8 +1245,6 @@ static int dm9x_interrupt(int irq, FAR void *context)
#else
# error "Additional logic needed to support multiple interfaces"
#endif
#ifdef CONFIG_NET_NOINTS
uint8_t isr;
/* Disable further Ethernet interrupts. Because Ethernet interrupts are
@@ -1321,56 +1274,9 @@ static int dm9x_interrupt(int irq, FAR void *context)
/* Schedule to perform the interrupt processing on the worker thread. */
work_queue(ETHWORK, &priv->dm_work, dm9x_interrupt_work, priv, 0);
#else
/* Process the interrupt now */
dm9x_interrupt_process(priv);
#endif
return OK;
}
/****************************************************************************
* Function: dm9x_txtimeout_process
*
* Description:
* Process a TX timeout. Called from the either the watchdog timer
* expiration logic or from the worker thread, depending upon the
* configuration. The timeout means that the last TX never completed.
* Reset the hardware and start again.
*
* Parameters:
* priv - Reference to the driver state structure
*
* Returned Value:
* None
*
****************************************************************************/
static inline void dm9x_txtimeout_process(FAR struct dm9x_driver_s *priv)
{
nerr("ERROR: TX timeout\n");
/* Increment statistics and dump debug info */
NETDEV_TXTIMEOUTS(priv->dm_dev);
ninfo(" TX packet count: %d\n", priv->dm_ntxpending);
ninfo(" TX read pointer address: 0x%02x:%02x\n",
getreg(DM9X_TRPAH), getreg(DM9X_TRPAL));
ninfo(" Memory data write address: 0x%02x:%02x (DM9010)\n",
getreg(DM9X_MDWAH), getreg(DM9X_MDWAL));
/* Then reset the DM90x0 */
dm9x_reset(priv);
/* Then poll the network for new XMIT data */
(void)devif_poll(&priv->dm_dev, dm9x_txpoll);
}
/****************************************************************************
* Function: dm9x_txtimeout_work
*
@@ -1388,19 +1294,32 @@ static inline void dm9x_txtimeout_process(FAR struct dm9x_driver_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void dm9x_txtimeout_work(FAR void *arg)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg;
net_lock_t state;
/* Process pending Ethernet interrupts */
nerr("ERROR: TX timeout\n");
state = net_lock();
dm9x_txtimeout_process(priv);
net_unlock(state);
/* Increment statistics and dump debug info */
net_lock();
NETDEV_TXTIMEOUTS(priv->dm_dev);
ninfo(" TX packet count: %d\n", priv->dm_ntxpending);
ninfo(" TX read pointer address: 0x%02x:%02x\n",
getreg(DM9X_TRPAH), getreg(DM9X_TRPAL));
ninfo(" Memory data write address: 0x%02x:%02x (DM9010)\n",
getreg(DM9X_MDWAH), getreg(DM9X_MDWAL));
/* Then reset the DM90x0 */
dm9x_reset(priv);
/* Then poll the network for new XMIT data */
(void)devif_poll(&priv->dm_dev, dm9x_txpoll);
net_unlock();
}
#endif
/****************************************************************************
* Function: dm9x_txtimeout_expiry
@@ -1425,7 +1344,6 @@ static void dm9x_txtimeout_expiry(int argc, wdparm_t arg, ...)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg;
#ifdef CONFIG_NET_NOINTS
/* Disable further Ethernet interrupts. This will prevent some race
* conditions with interrupt work. There is still a potential race
* condition with interrupt work that is already queued and in progress.
@@ -1442,32 +1360,33 @@ static void dm9x_txtimeout_expiry(int argc, wdparm_t arg, ...)
/* Schedule to perform the TX timeout processing on the worker thread. */
work_queue(ETHWORK, &priv->dm_work, dm9x_txtimeout_work, priv, 0);
#else
/* Process the timeout now */
dm9x_txtimeout_process(priv);
#endif
}
/****************************************************************************
* Function: dm9x_poll_process
* Function: dm9x_poll_work
*
* Description:
* Perform the periodic poll. This may be called either from watchdog
* timer logic or from the worker thread, depending upon the configuration.
* Perform periodic polling from the worker thread
*
* Parameters:
* priv - Reference to the driver state structure
* arg - The argument passed when work_queue() as called.
*
* Returned Value:
* None
* OK on success
*
* Assumptions:
* The network is locked.
*
****************************************************************************/
static inline void dm9x_poll_process(FAR struct dm9x_driver_s *priv)
static void dm9x_poll_work(FAR void *arg)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg;
/* Perform the poll */
net_lock();
/* If the number of contiguous RX packets exceeds a threshold, reset the counter and
* re-enable RX interrupts
*/
@@ -1493,39 +1412,9 @@ static inline void dm9x_poll_process(FAR struct dm9x_driver_s *priv)
(void)wd_start(priv->dm_txpoll, DM9X_WDDELAY, dm9x_poll_expiry, 1,
(wdparm_t)priv);
net_unlock();
}
/****************************************************************************
* Function: dm9x_poll_work
*
* Description:
* Perform periodic polling from the worker thread
*
* Parameters:
* arg - The argument passed when work_queue() as called.
*
* Returned Value:
* OK on success
*
* Assumptions:
* The network is locked.
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void dm9x_poll_work(FAR void *arg)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg;
net_lock_t state;
/* Perform the poll */
state = net_lock();
dm9x_poll_process(priv);
net_unlock(state);
}
#endif
/****************************************************************************
* Function: dm9x_poll_expiry
*
@@ -1548,7 +1437,6 @@ static void dm9x_poll_expiry(int argc, wdparm_t arg, ...)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg;
#ifdef CONFIG_NET_NOINTS
/* Is our single work structure available? It may not be if there are
* pending interrupt actions.
*/
@@ -1567,12 +1455,6 @@ static void dm9x_poll_expiry(int argc, wdparm_t arg, ...)
(void)wd_start(priv->dm_txpoll, DM9X_WDDELAY, dm9x_poll_expiry, 1, arg);
}
#else
/* Process the interrupt now */
dm9x_poll_process(priv);
#endif
}
/****************************************************************************
@@ -1732,45 +1614,6 @@ static int dm9x_ifdown(struct net_driver_s *dev)
return OK;
}
/****************************************************************************
* Function: dm9x_txavail_process
*
* Description:
* Perform an out-of-cycle poll.
*
* Parameters:
* dev - Reference to the NuttX driver state structure
*
* Returned Value:
* None
*
* Assumptions:
* Called in normal user mode
*
****************************************************************************/
static inline void dm9x_txavail_process(FAR struct dm9x_driver_s *priv)
{
ninfo("Polling\n");
/* Ignore the notification if the interface is not yet up */
if (priv->dm_bifup)
{
/* Check if there is room in the DM90x0 to hold another packet. In 100M
* mode, that can be 2 packets, otherwise it is a single packet.
*/
if (priv->dm_ntxpending < 1 || (priv->dm_b100M && priv->dm_ntxpending < 2))
{
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->dm_dev, dm9x_txpoll);
}
}
}
/****************************************************************************
* Function: dm9x_txavail_work
*
@@ -1788,19 +1631,32 @@ static inline void dm9x_txavail_process(FAR struct dm9x_driver_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void dm9x_txavail_work(FAR void *arg)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg;
net_lock_t state;
/* Perform the poll */
ninfo("Polling\n");
state = net_lock();
dm9x_txavail_process(priv);
net_unlock(state);
/* Ignore the notification if the interface is not yet up */
net_lock();
if (priv->dm_bifup)
{
/* Check if there is room in the DM90x0 to hold another packet. In 100M
* mode, that can be 2 packets, otherwise it is a single packet.
*/
if (priv->dm_ntxpending < 1 || (priv->dm_b100M && priv->dm_ntxpending < 2))
{
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->dm_dev, dm9x_txpoll);
}
}
net_unlock();
}
#endif
/****************************************************************************
* Function: dm9x_txavail
@@ -1825,7 +1681,6 @@ static int dm9x_txavail(FAR struct net_driver_s *dev)
{
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private;
#ifdef CONFIG_NET_NOINTS
/* 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.
@@ -1838,21 +1693,6 @@ static int dm9x_txavail(FAR struct net_driver_s *dev)
work_queue(ETHWORK, &priv->dm_work, dm9x_txavail_work, priv, 0);
}
#else
irqstate_t flags;
/* Disable interrupts because this function may be called from interrupt
* level processing.
*/
flags = enter_critical_section();
/* Perform the out-of-cycle poll now */
dm9x_txavail_process(priv);
leave_critical_section(flags);
#endif
return OK;
}
+6 -15
View File
@@ -135,12 +135,6 @@
# define enc_dumppacket(m,a,n)
#endif
/* The ENC28J60 will not do interrupt level processing */
#ifndef CONFIG_NET_NOINTS
# warning "CONFIG_NET_NOINTS should be set"
#endif
/* Low-level register debug */
#if !defined(CONFIG_DEBUG_FEATURES) || !defined(CONFIG_DEBUG_NET)
@@ -1629,14 +1623,13 @@ static void enc_pktif(FAR struct enc_driver_s *priv)
static void enc_irqworker(FAR void *arg)
{
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
net_lock_t lock;
uint8_t eir;
DEBUGASSERT(priv);
/* Get exclusive access to both the network and the SPI bus. */
lock = net_lock();
net_lock();
enc_lock(priv);
/* Disable further interrupts by clearing the global interrupt enable bit.
@@ -1827,7 +1820,7 @@ static void enc_irqworker(FAR void *arg)
/* Release lock on the SPI bus and the network */
enc_unlock(priv);
net_unlock(lock);
net_unlock();
}
/****************************************************************************
@@ -1889,7 +1882,6 @@ static int enc_interrupt(int irq, FAR void *context)
static void enc_toworker(FAR void *arg)
{
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
net_lock_t lock;
int ret;
nerr("ERROR: Tx timeout\n");
@@ -1897,7 +1889,7 @@ static void enc_toworker(FAR void *arg)
/* Get exclusive access to the network */
lock = net_lock();
net_lock();
/* Increment statistics and dump debug info */
@@ -1919,7 +1911,7 @@ static void enc_toworker(FAR void *arg)
/* Release lock on the network */
net_unlock(lock);
net_unlock();
}
/****************************************************************************
@@ -1983,13 +1975,12 @@ static void enc_txtimeout(int argc, uint32_t arg, ...)
static void enc_pollworker(FAR void *arg)
{
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
net_lock_t lock;
DEBUGASSERT(priv);
/* Get exclusive access to both the network and the SPI bus. */
lock = net_lock();
net_lock();
enc_lock(priv);
/* Verify that the hardware is ready to send another packet. The driver
@@ -2011,7 +2002,7 @@ static void enc_pollworker(FAR void *arg)
/* Release lock on the SPI bus and the network */
enc_unlock(priv);
net_unlock(lock);
net_unlock();
/* Setup the watchdog poll timer again */
+6 -15
View File
@@ -140,12 +140,6 @@
# define enc_dumppacket(m,a,n)
#endif
/* The ENCX24J600 will not do interrupt level processing */
#ifndef CONFIG_NET_NOINTS
# warning "CONFIG_NET_NOINTS should be set"
#endif
/* Low-level register debug */
#if !defined(CONFIG_DEBUG_FEATURES) || !defined(CONFIG_DEBUG_NET)
@@ -1841,14 +1835,13 @@ static void enc_rxabtif(FAR struct enc_driver_s *priv)
static void enc_irqworker(FAR void *arg)
{
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
net_lock_t lock;
uint16_t eir;
DEBUGASSERT(priv);
/* Get exclusive access to both the network and the SPI bus. */
lock = net_lock();
net_lock();
enc_lock(priv);
/* A good practice is for the host controller to clear the Global Interrupt
@@ -1992,7 +1985,7 @@ static void enc_irqworker(FAR void *arg)
/* Release lock on the SPI bus and the network */
enc_unlock(priv);
net_unlock(lock);
net_unlock();
}
/****************************************************************************
@@ -2054,7 +2047,6 @@ static int enc_interrupt(int irq, FAR void *context)
static void enc_toworker(FAR void *arg)
{
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
net_lock_t lock;
int ret;
nerr("ERROR: Tx timeout\n");
@@ -2062,7 +2054,7 @@ static void enc_toworker(FAR void *arg)
/* Get exclusive access to the network. */
lock = net_lock();
net_lock();
/* Increment statistics and dump debug info */
@@ -2084,7 +2076,7 @@ static void enc_toworker(FAR void *arg)
/* Release the network */
net_unlock(lock);
net_unlock();
}
/****************************************************************************
@@ -2148,13 +2140,12 @@ static void enc_txtimeout(int argc, uint32_t arg, ...)
static void enc_pollworker(FAR void *arg)
{
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
net_lock_t lock;
DEBUGASSERT(priv);
/* Get exclusive access to both the network and the SPI bus. */
lock = net_lock();
net_lock();
enc_lock(priv);
/* Verify that the hardware is ready to send another packet. The driver
@@ -2176,7 +2167,7 @@ static void enc_pollworker(FAR void *arg)
/* Release lock on the SPI bus and the network */
enc_unlock(priv);
net_unlock(lock);
net_unlock();
/* Setup the watchdog poll timer again */
+58 -226
View File
@@ -56,11 +56,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wdog.h>
#ifdef CONFIG_NET_NOINTS
# include <nuttx/wqueue.h>
#endif
#include <nuttx/wqueue.h>
#include <nuttx/net/arp.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/ftmac100.h>
@@ -76,13 +72,12 @@
* is required.
*/
#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE)
#if !defined(CONFIG_SCHED_WORKQUEUE)
# error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE)
#endif
#else
/* Use the low priority work queue if possible */
/* Use the low priority work queue if possible */
#if defined(CONFIG_SCHED_WORKQUEUE)
# if defined(CONFIG_FTMAC100_HPWORK)
# define FTMAWORK HPWORK
# elif defined(CONFIG_FTMAC100_LPWORK)
@@ -178,10 +173,8 @@ struct ftmac100_driver_s
bool ft_bifup; /* true:ifup false:ifdown */
WDOG_ID ft_txpoll; /* TX poll timer */
WDOG_ID ft_txtimeout; /* TX timeout timer */
#ifdef CONFIG_NET_NOINTS
unsigned int status; /* Last ISR status */
struct work_s ft_work; /* For deferring work to the work queue */
#endif
/* This holds the information visible to the NuttX network */
@@ -215,35 +208,26 @@ static int ftmac100_txpoll(struct net_driver_s *dev);
static void ftmac100_reset(FAR struct ftmac100_driver_s *priv);
static void ftmac100_receive(FAR struct ftmac100_driver_s *priv);
static void ftmac100_txdone(FAR struct ftmac100_driver_s *priv);
static inline void ftmac100_interrupt_process(FAR struct ftmac100_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void ftmac100_interrupt_work(FAR void *arg);
#endif
static int ftmac100_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */
static inline void ftmac100_txtimeout_process(FAR struct ftmac100_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void ftmac100_txtimeout_work(FAR void *arg);
#endif
static void ftmac100_txtimeout_expiry(int argc, uint32_t arg, ...);
static inline void ftmac100_poll_process(FAR struct ftmac100_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void ftmac100_poll_work(FAR void *arg);
#endif
static void ftmac100_poll_expiry(int argc, uint32_t arg, ...);
/* NuttX callback functions */
static int ftmac100_ifup(FAR struct net_driver_s *dev);
static int ftmac100_ifdown(FAR struct net_driver_s *dev);
static inline void ftmac100_txavail_process(FAR struct ftmac100_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void ftmac100_txavail_work(FAR void *arg);
#endif
static int ftmac100_txavail(FAR struct net_driver_s *dev);
#if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6)
static int ftmac100_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
#ifdef CONFIG_NET_IGMP
@@ -873,34 +857,33 @@ static void ftmac100_txdone(FAR struct ftmac100_driver_s *priv)
}
/****************************************************************************
* Function: ftmac100_interrupt_process
* Function: ftmac100_interrupt_work
*
* Description:
* Interrupt processing. This may be performed either within the interrupt
* handler or on the worker thread, depending upon the configuration
* Perform interrupt related work from the worker thread
*
* Parameters:
* priv - Reference to the driver state structure
* arg - The argument passed when work_queue() was called.
*
* Returned Value:
* None
* OK on success
*
* Assumptions:
* Ethernet interrupts are disabled
*
****************************************************************************/
static inline void ftmac100_interrupt_process(FAR struct ftmac100_driver_s *priv)
static void ftmac100_interrupt_work(FAR void *arg)
{
FAR struct ftmac100_driver_s *priv = (FAR struct ftmac100_driver_s *)arg;
FAR struct ftmac100_register_s *iobase = (FAR struct ftmac100_register_s *)priv->iobase;
unsigned int status;
unsigned int phycr;
#ifdef CONFIG_NET_NOINTS
/* Process pending Ethernet interrupts */
net_lock();
status = priv->status;
#else
status = getreg32 (&iobase->isr);
#endif
ninfo("status=%08x(%08x) BASE=%p ISR=%p PHYCR=%p\n",
status, getreg32(&iobase->isr), iobase, &iobase->isr, &iobase->phycr);
@@ -970,47 +953,12 @@ out:
putreg32 (INT_MASK_ALL_ENABLED, &iobase->imr);
ninfo("ISR-done\n");
}
/****************************************************************************
* Function: ftmac100_interrupt_work
*
* Description:
* Perform interrupt related work from the worker thread
*
* Parameters:
* arg - The argument passed when work_queue() was called.
*
* Returned Value:
* OK on success
*
* Assumptions:
* Ethernet interrupts are disabled
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void ftmac100_interrupt_work(FAR void *arg)
{
FAR struct ftmac100_driver_s *priv = (FAR struct ftmac100_driver_s *)arg;
net_lock_t state;
//irqstate_t flags;
/* Process pending Ethernet interrupts */
state = net_lock();
//flags = enter_critical_section();
ftmac100_interrupt_process(priv);
//leave_critical_section(flags);
net_unlock(state);
net_unlock();
/* Re-enable Ethernet interrupts */
up_enable_irq(CONFIG_FTMAC100_IRQ);
}
#endif
/****************************************************************************
* Function: ftmac100_interrupt
@@ -1034,17 +982,12 @@ static int ftmac100_interrupt(int irq, FAR void *context)
FAR struct ftmac100_driver_s *priv = &g_ftmac100[0];
FAR struct ftmac100_register_s *iobase = (FAR struct ftmac100_register_s *)priv->iobase;
#ifdef CONFIG_NET_NOINTS
irqstate_t flags;
/* Disable further Ethernet interrupts. Because Ethernet interrupts are
* also disabled if the TX timeout event occurs, there can be no race
* condition here.
*/
flags = enter_critical_section();
priv->status = getreg32 (&iobase->isr);
priv->status = getreg32(&iobase->isr);
up_disable_irq(CONFIG_FTMAC100_IRQ);
@@ -1073,45 +1016,9 @@ static int ftmac100_interrupt(int irq, FAR void *context)
work_queue(FTMAWORK, &priv->ft_work, ftmac100_interrupt_work, priv, 0);
leave_critical_section(flags);
#else
/* Process the interrupt now */
putreg32 (INT_MASK_ALL_DISABLED, &iobase->imr);
ftmac100_interrupt_process(priv);
#endif
return OK;
}
/****************************************************************************
* Function: ftmac100_txtimeout_process
*
* Description:
* Process a TX timeout. Called from the either the watchdog timer
* expiration logic or from the worker thread, depending upon the
* configuration. The timeout means that the last TX never completed.
* Reset the hardware and start again.
*
* Parameters:
* priv - Reference to the driver state structure
*
* Returned Value:
* None
*
****************************************************************************/
static inline void ftmac100_txtimeout_process(FAR struct ftmac100_driver_s *priv)
{
/* Then reset the hardware */
ninfo("TXTIMEOUT\n");
/* Then poll the network for new XMIT data */
(void)devif_poll(&priv->ft_dev, ftmac100_txpoll);
}
/****************************************************************************
* Function: ftmac100_txtimeout_work
*
@@ -1129,19 +1036,21 @@ static inline void ftmac100_txtimeout_process(FAR struct ftmac100_driver_s *priv
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void ftmac100_txtimeout_work(FAR void *arg)
{
FAR struct ftmac100_driver_s *priv = (FAR struct ftmac100_driver_s *)arg;
net_lock_t state;
ninfo("TXTIMEOUT\n");
/* Process pending Ethernet interrupts */
state = net_lock();
ftmac100_txtimeout_process(priv);
net_unlock(state);
net_lock();
/* Then poll the network for new XMIT data */
(void)devif_poll(&priv->ft_dev, ftmac100_txpoll);
net_unlock();
}
#endif
/****************************************************************************
* Function: ftmac100_txtimeout_expiry
@@ -1166,7 +1075,6 @@ static void ftmac100_txtimeout_expiry(int argc, uint32_t arg, ...)
{
FAR struct ftmac100_driver_s *priv = (FAR struct ftmac100_driver_s *)arg;
#ifdef CONFIG_NET_NOINTS
/* Disable further Ethernet interrupts. This will prevent some race
* conditions with interrupt work. There is still a potential race
* condition with interrupt work that is already queued and in progress.
@@ -1183,49 +1091,7 @@ static void ftmac100_txtimeout_expiry(int argc, uint32_t arg, ...)
/* Schedule to perform the TX timeout processing on the worker thread. */
work_queue(FTMAWORK, &priv->ft_work, ftmac100_txtimeout_work, priv, 0);
#else
/* Process the timeout now */
ftmac100_txtimeout_process(priv);
#endif
}
/****************************************************************************
* Function: ftmac100_poll_process
*
* Description:
* Perform the periodic poll. This may be called either from watchdog
* timer logic or from the worker thread, depending upon the configuration.
*
* Parameters:
* priv - Reference to the driver state structure
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
static inline void ftmac100_poll_process(FAR struct ftmac100_driver_s *priv)
{
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
/* If so, update TCP timing states and poll the network for new XMIT data. Hmmm..
* might be bug here. Does this mean if there is a transmit in progress,
* we will missing TCP time state updates?
*/
(void)devif_timer(&priv->ft_dev, ftmac100_txpoll);
/* Setup the watchdog poll timer again */
(void)wd_start(priv->ft_txpoll, FTMAC100_WDDELAY, ftmac100_poll_expiry, 1,
(wdparm_t)priv);
}
/****************************************************************************
* Function: ftmac100_poll_work
*
@@ -1243,19 +1109,31 @@ static inline void ftmac100_poll_process(FAR struct ftmac100_driver_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void ftmac100_poll_work(FAR void *arg)
{
FAR struct ftmac100_driver_s *priv = (FAR struct ftmac100_driver_s *)arg;
net_lock_t state;
/* Perform the poll */
state = net_lock();
ftmac100_poll_process(priv);
net_unlock(state);
net_lock();
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
/* If so, update TCP timing states and poll the network for new XMIT data. Hmmm..
* might be bug here. Does this mean if there is a transmit in progress,
* we will missing TCP time state updates?
*/
(void)devif_timer(&priv->ft_dev, ftmac100_txpoll);
/* Setup the watchdog poll timer again */
(void)wd_start(priv->ft_txpoll, FTMAC100_WDDELAY, ftmac100_poll_expiry, 1,
(wdparm_t)priv);
net_unlock();
}
#endif
/****************************************************************************
* Function: ftmac100_poll_expiry
@@ -1279,7 +1157,6 @@ static void ftmac100_poll_expiry(int argc, uint32_t arg, ...)
{
FAR struct ftmac100_driver_s *priv = (FAR struct ftmac100_driver_s *)arg;
#ifdef CONFIG_NET_NOINTS
/* Is our single work structure available? It may not be if there are
* pending interrupt actions.
*/
@@ -1299,12 +1176,6 @@ static void ftmac100_poll_expiry(int argc, uint32_t arg, ...)
(void)wd_start(priv->ft_txpoll, FTMAC100_WDDELAY, ftmac100_poll_expiry,
1, (wdparm_t)arg);
}
#else
/* Process the interrupt now */
ftmac100_poll_process(priv);
#endif
}
/****************************************************************************
@@ -1414,37 +1285,6 @@ static int ftmac100_ifdown(struct net_driver_s *dev)
return OK;
}
/****************************************************************************
* Function: ftmac100_txavail_process
*
* Description:
* Perform an out-of-cycle poll.
*
* Parameters:
* dev - Reference to the NuttX driver state structure
*
* Returned Value:
* None
*
* Assumptions:
* Called in normal user mode
*
****************************************************************************/
static inline void ftmac100_txavail_process(FAR struct ftmac100_driver_s *priv)
{
/* Ignore the notification if the interface is not yet up */
if (priv->ft_bifup)
{
/* Check if there is room in the hardware to hold another outgoing packet. */
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->ft_dev, ftmac100_txpoll);
}
}
/****************************************************************************
* Function: ftmac100_txavail_work
*
@@ -1462,19 +1302,27 @@ static inline void ftmac100_txavail_process(FAR struct ftmac100_driver_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void ftmac100_txavail_work(FAR void *arg)
{
FAR struct ftmac100_driver_s *priv = (FAR struct ftmac100_driver_s *)arg;
net_lock_t state;
/* Perform the poll */
state = net_lock();
ftmac100_txavail_process(priv);
net_unlock(state);
net_lock();
/* Ignore the notification if the interface is not yet up */
if (priv->ft_bifup)
{
/* Check if there is room in the hardware to hold another outgoing packet. */
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->ft_dev, ftmac100_txpoll);
}
net_unlock();
}
#endif
/****************************************************************************
* Function: ftmac100_txavail
@@ -1499,7 +1347,6 @@ static int ftmac100_txavail(struct net_driver_s *dev)
{
FAR struct ftmac100_driver_s *priv = (FAR struct ftmac100_driver_s *)dev->d_private;
#ifdef CONFIG_NET_NOINTS
/* 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.
@@ -1512,21 +1359,6 @@ static int ftmac100_txavail(struct net_driver_s *dev)
work_queue(FTMAWORK, &priv->ft_work, ftmac100_txavail_work, priv, 0);
}
#else
irqstate_t flags;
/* Disable interrupts because this function may be called from interrupt
* level processing.
*/
flags = enter_critical_section();
/* Perform the out-of-cycle poll now */
ftmac100_txavail_process(priv);
leave_critical_section(flags);
#endif
return OK;
}
+4 -12
View File
@@ -67,12 +67,6 @@
* Pre-processor Definitions
****************************************************************************/
/* Non-network-driven configuration is required */
#ifndef CONFIG_NET_NOINTS
# error CONFIG_NET_NOINTS must be selected
#endif
/* We need to have the work queue to handle SPI interrupts */
#if !defined(CONFIG_SCHED_WORKQUEUE)
@@ -244,11 +238,10 @@ static int lo_txpoll(FAR struct net_driver_s *dev)
static void lo_poll_work(FAR void *arg)
{
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)arg;
net_lock_t state;
/* Perform the poll */
state = net_lock();
net_lock();
priv->lo_txdone = false;
(void)devif_timer(&priv->lo_dev, lo_txpoll);
@@ -265,7 +258,7 @@ static void lo_poll_work(FAR void *arg)
/* Setup the watchdog poll timer again */
(void)wd_start(priv->lo_polldog, LO_WDDELAY, lo_poll_expiry, 1, priv);
net_unlock(state);
net_unlock();
}
/****************************************************************************
@@ -401,11 +394,10 @@ static int lo_ifdown(FAR struct net_driver_s *dev)
static void lo_txavail_work(FAR void *arg)
{
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)arg;
net_lock_t state;
/* Ignore the notification if the interface is not yet up */
state = net_lock();
net_lock();
if (priv->lo_bifup)
{
do
@@ -418,7 +410,7 @@ static void lo_txavail_work(FAR void *arg)
while (priv->lo_txdone);
}
net_unlock(state);
net_unlock();
}
/****************************************************************************
+59 -198
View File
@@ -53,11 +53,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wdog.h>
#ifdef CONFIG_NET_NOINTS
# include <nuttx/wqueue.h>
#endif
#include <nuttx/wqueue.h>
#include <nuttx/net/arp.h>
#include <nuttx/net/netdev.h>
@@ -72,13 +68,12 @@
* is required.
*/
#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE)
#if !defined(CONFIG_SCHED_WORKQUEUE)
# error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE)
#endif
#else
/* Use the low priority work queue if possible */
/* Use the low priority work queue if possible */
#if defined(CONFIG_SCHED_WORKQUEUE)
# if defined(CONFIG_skeleton_HPWORK)
# define ETHWORK HPWORK
# elif defined(CONFIG_skeleton_LPWORK)
@@ -121,9 +116,7 @@ struct skel_driver_s
bool sk_bifup; /* true:ifup false:ifdown */
WDOG_ID sk_txpoll; /* TX poll timer */
WDOG_ID sk_txtimeout; /* TX timeout timer */
#ifdef CONFIG_NET_NOINTS
struct work_s sk_work; /* For deferring work to the work queue */
#endif
/* This holds the information visible to the NuttX network */
@@ -163,24 +156,15 @@ static int skel_txpoll(FAR struct net_driver_s *dev);
static void skel_receive(FAR struct skel_driver_s *priv);
static void skel_txdone(FAR struct skel_driver_s *priv);
static inline void skel_interrupt_process(FAR struct skel_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void skel_interrupt_work(FAR void *arg);
#endif
static int skel_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */
static inline void skel_txtimeout_process(FAR struct skel_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void skel_txtimeout_work(FAR void *arg);
#endif
static void skel_txtimeout_expiry(int argc, wdparm_t arg, ...);
static inline void skel_poll_process(FAR struct skel_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void skel_poll_work(FAR void *arg);
#endif
static void skel_poll_expiry(int argc, wdparm_t arg, ...);
/* NuttX callback functions */
@@ -188,10 +172,7 @@ static void skel_poll_expiry(int argc, wdparm_t arg, ...);
static int skel_ifup(FAR struct net_driver_s *dev);
static int skel_ifdown(FAR struct net_driver_s *dev);
static inline void skel_txavail_process(FAR struct skel_driver_s *priv);
#ifdef CONFIG_NET_NOINTS
static void skel_txavail_work(FAR void *arg);
#endif
static int skel_txavail(FAR struct net_driver_s *dev);
#if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6)
@@ -510,42 +491,6 @@ static void skel_txdone(FAR struct skel_driver_s *priv)
(void)devif_poll(&priv->sk_dev, skel_txpoll);
}
/****************************************************************************
* Function: skel_interrupt_process
*
* Description:
* Interrupt processing. This may be performed either within the interrupt
* handler or on the worker thread, depending upon the configuration
*
* Parameters:
* priv - Reference to the driver state structure
*
* Returned Value:
* None
*
* Assumptions:
* The network is locked.
*
****************************************************************************/
static inline void skel_interrupt_process(FAR struct skel_driver_s *priv)
{
/* Get and clear interrupt status bits */
/* Handle interrupts according to status bit settings */
/* Check if we received an incoming packet, if so, call skel_receive() */
skel_receive(priv);
/* Check if a packet transmission just completed. If so, call skel_txdone.
* This may disable further Tx interrupts if there are no pending
* transmissions.
*/
skel_txdone(priv);
}
/****************************************************************************
* Function: skel_interrupt_work
*
@@ -563,23 +508,33 @@ static inline void skel_interrupt_process(FAR struct skel_driver_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void skel_interrupt_work(FAR void *arg)
{
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)arg;
net_lock_t state;
/* Process pending Ethernet interrupts */
state = net_lock();
skel_interrupt_process(priv);
net_unlock(state);
/* Get and clear interrupt status bits */
/* Handle interrupts according to status bit settings */
/* Check if we received an incoming packet, if so, call skel_receive() */
net_lock();
skel_receive(priv);
/* Check if a packet transmission just completed. If so, call skel_txdone.
* This may disable further Tx interrupts if there are no pending
* transmissions.
*/
skel_txdone(priv);
net_unlock();
/* Re-enable Ethernet interrupts */
up_enable_irq(CONFIG_skeleton_IRQ);
}
#endif
/****************************************************************************
* Function: skel_interrupt
@@ -602,7 +557,6 @@ static int skel_interrupt(int irq, FAR void *context)
{
FAR struct skel_driver_s *priv = &g_skel[0];
#ifdef CONFIG_NET_NOINTS
/* Disable further Ethernet interrupts. Because Ethernet interrupts are
* also disabled if the TX timeout event occurs, there can be no race
* condition here.
@@ -628,46 +582,9 @@ static int skel_interrupt(int irq, FAR void *context)
/* Schedule to perform the interrupt processing on the worker thread. */
work_queue(ETHWORK, &priv->sk_work, skel_interrupt_work, priv, 0);
#else
/* Process the interrupt now */
skel_interrupt_process(priv);
#endif
return OK;
}
/****************************************************************************
* Function: skel_txtimeout_process
*
* Description:
* Process a TX timeout. Called from the either the watchdog timer
* expiration logic or from the worker thread, depending upon the
* configuration. The timeout means that the last TX never completed.
* Reset the hardware and start again.
*
* Parameters:
* priv - Reference to the driver state structure
*
* Returned Value:
* None
*
****************************************************************************/
static inline void skel_txtimeout_process(FAR struct skel_driver_s *priv)
{
/* Increment statistics and dump debug info */
NETDEV_TXTIMEOUTS(priv->sk_dev);
/* Then reset the hardware */
/* Then poll the network for new XMIT data */
(void)devif_poll(&priv->sk_dev, skel_txpoll);
}
/****************************************************************************
* Function: skel_txtimeout_work
*
@@ -685,19 +602,22 @@ static inline void skel_txtimeout_process(FAR struct skel_driver_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void skel_txtimeout_work(FAR void *arg)
{
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)arg;
net_lock_t state;
/* Process pending Ethernet interrupts */
/* Increment statistics and dump debug info */
state = net_lock();
skel_txtimeout_process(priv);
net_unlock(state);
NETDEV_TXTIMEOUTS(priv->sk_dev);
/* Then reset the hardware */
/* Then poll the network for new XMIT data */
net_lock();
(void)devif_poll(&priv->sk_dev, skel_txpoll);
net_unlock();
}
#endif
/****************************************************************************
* Function: skel_txtimeout_expiry
@@ -722,7 +642,6 @@ static void skel_txtimeout_expiry(int argc, wdparm_t arg, ...)
{
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)arg;
#ifdef CONFIG_NET_NOINTS
/* Disable further Ethernet interrupts. This will prevent some race
* conditions with interrupt work. There is still a potential race
* condition with interrupt work that is already queued and in progress.
@@ -739,11 +658,6 @@ static void skel_txtimeout_expiry(int argc, wdparm_t arg, ...)
/* Schedule to perform the TX timeout processing on the worker thread. */
work_queue(ETHWORK, &priv->sk_work, skel_txtimeout_work, priv, 0);
#else
/* Process the timeout now */
skel_txtimeout_process(priv);
#endif
}
/****************************************************************************
@@ -765,21 +679,6 @@ static void skel_txtimeout_expiry(int argc, wdparm_t arg, ...)
static inline void skel_poll_process(FAR struct skel_driver_s *priv)
{
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
/* If so, update TCP timing states and poll the network for new XMIT data.
* Hmmm.. might be bug here. Does this mean if there is a transmit in
* progress, we will missing TCP time state updates?
*/
(void)devif_timer(&priv->sk_dev, skel_txpoll);
/* Setup the watchdog poll timer again */
(void)wd_start(priv->sk_txpoll, skeleton_WDDELAY, skel_poll_expiry, 1,
(wdparm_t)priv);
}
/****************************************************************************
@@ -799,19 +698,30 @@ static inline void skel_poll_process(FAR struct skel_driver_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void skel_poll_work(FAR void *arg)
{
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)arg;
net_lock_t state;
/* Perform the poll */
state = net_lock();
skel_poll_process(priv);
net_unlock(state);
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
/* If so, update TCP timing states and poll the network for new XMIT data.
* Hmmm.. might be bug here. Does this mean if there is a transmit in
* progress, we will missing TCP time state updates?
*/
net_lock();
(void)devif_timer(&priv->sk_dev, skel_txpoll);
/* Setup the watchdog poll timer again */
(void)wd_start(priv->sk_txpoll, skeleton_WDDELAY, skel_poll_expiry, 1,
(wdparm_t)priv);
net_unlock();
}
#endif
/****************************************************************************
* Function: skel_poll_expiry
@@ -835,7 +745,6 @@ static void skel_poll_expiry(int argc, wdparm_t arg, ...)
{
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)arg;
#ifdef CONFIG_NET_NOINTS
/* Is our single work structure available? It may not be if there are
* pending interrupt actions.
*/
@@ -854,12 +763,6 @@ static void skel_poll_expiry(int argc, wdparm_t arg, ...)
(void)wd_start(priv->sk_txpoll, skeleton_WDDELAY, skel_poll_expiry, 1, arg);
}
#else
/* Process the interrupt now */
skel_poll_process(priv);
#endif
}
/****************************************************************************
@@ -960,37 +863,6 @@ static int skel_ifdown(FAR struct net_driver_s *dev)
return OK;
}
/****************************************************************************
* Function: skel_txavail_process
*
* Description:
* Perform an out-of-cycle poll.
*
* Parameters:
* dev - Reference to the NuttX driver state structure
*
* Returned Value:
* None
*
* Assumptions:
* Called in normal user mode
*
****************************************************************************/
static inline void skel_txavail_process(FAR struct skel_driver_s *priv)
{
/* Ignore the notification if the interface is not yet up */
if (priv->sk_bifup)
{
/* Check if there is room in the hardware to hold another outgoing packet. */
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->sk_dev, skel_txpoll);
}
}
/****************************************************************************
* Function: skel_txavail_work
*
@@ -1008,19 +880,24 @@ static inline void skel_txavail_process(FAR struct skel_driver_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void skel_txavail_work(FAR void *arg)
{
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)arg;
net_lock_t state;
/* Perform the poll */
/* Ignore the notification if the interface is not yet up */
state = net_lock();
skel_txavail_process(priv);
net_unlock(state);
net_lock();
if (priv->sk_bifup)
{
/* Check if there is room in the hardware to hold another outgoing packet. */
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->sk_dev, skel_txpoll);
}
net_unlock();
}
#endif
/****************************************************************************
* Function: skel_txavail
@@ -1045,7 +922,6 @@ static int skel_txavail(FAR struct net_driver_s *dev)
{
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)dev->d_private;
#ifdef CONFIG_NET_NOINTS
/* 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.
@@ -1058,21 +934,6 @@ static int skel_txavail(FAR struct net_driver_s *dev)
work_queue(ETHWORK, &priv->sk_work, skel_txavail_work, priv, 0);
}
#else
irqstate_t flags;
/* Disable interrupts because this function may be called from interrupt
* level processing.
*/
flags = enter_critical_section();
/* Perform the out-of-cycle poll now */
skel_txavail_process(priv);
leave_critical_section(flags);
#endif
return OK;
}
+5 -10
View File
@@ -76,10 +76,6 @@
/* Configuration ************************************************************/
#ifndef CONFIG_NET_NOINTS
# warning "CONFIG_NET_NOINTS must be set"
#endif
#ifndef CONFIG_NET_SLIP_STACKSIZE
# define CONFIG_NET_SLIP_STACKSIZE 2048
#endif
@@ -430,7 +426,6 @@ static void slip_txtask(int argc, FAR char *argv[])
{
FAR struct slip_driver_s *priv;
unsigned int index = *(argv[1]) - '0';
net_lock_t flags;
systime_t start_ticks;
systime_t now_ticks;
unsigned int hsec;
@@ -476,7 +471,7 @@ static void slip_txtask(int argc, FAR char *argv[])
/* Poll the networking layer for new XMIT data. */
flags = net_lock();
net_lock();
priv->dev.d_buf = priv->txbuf;
/* Has a half second elapsed since the last timer poll? */
@@ -497,7 +492,7 @@ static void slip_txtask(int argc, FAR char *argv[])
(void)devif_poll(&priv->dev, slip_txpoll);
}
net_unlock(flags);
net_unlock();
slip_semgive(priv);
}
}
@@ -655,7 +650,6 @@ static int slip_rxtask(int argc, FAR char *argv[])
{
FAR struct slip_driver_s *priv;
unsigned int index = *(argv[1]) - '0';
net_lock_t flags;
int ch;
nerr("index: %d\n", index);
@@ -728,7 +722,7 @@ static int slip_rxtask(int argc, FAR char *argv[])
priv->dev.d_buf = priv->rxbuf;
priv->dev.d_len = priv->rxlen;
flags = net_lock();
net_lock();
ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should
@@ -741,7 +735,8 @@ static int slip_rxtask(int argc, FAR char *argv[])
slip_transmit(priv);
kill(priv->txpid, SIGALRM);
}
net_unlock(flags);
net_unlock();
slip_semgive(priv);
}
else
+29 -73
View File
@@ -58,15 +58,12 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wdog.h>
#include <nuttx/wqueue.h>
#include <nuttx/net/arp.h>
#include <nuttx/net/netdev.h>
#include <net/if.h>
#include <nuttx/net/tun.h>
#ifdef CONFIG_NET_NOINTS
# include <nuttx/wqueue.h>
#endif
#include <net/if.h>
#ifdef CONFIG_NET_PKT
# include <nuttx/net/pkt.h>
@@ -79,11 +76,10 @@
* work queue support is required.
*/
#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE)
#if !defined(CONFIG_SCHED_WORKQUEUE)
# error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE)
#endif
#else
#if defined(CONFIG_SCHED_WORKQUEUE)
# if defined(CONFIG_TUN_HPWORK)
# define TUNWORK HPWORK
# elif defined(CONFIG_TUN_LPWORK)
@@ -119,9 +115,7 @@ struct tun_device_s
{
bool bifup; /* true:ifup false:ifdown */
WDOG_ID txpoll; /* TX poll timer */
#ifdef CONFIG_NET_NOINTS
struct work_s work; /* For deferring work to the work queue */
#endif
FAR struct file *filep;
@@ -169,10 +163,7 @@ static void tun_txdone(FAR struct tun_device_s *priv);
/* Watchdog timer expirations */
static inline void tun_poll_process(FAR struct tun_device_s *priv);
#ifdef CONFIG_NET_NOINTS
static void tun_poll_work(FAR void *arg);
#endif
static void tun_poll_expiry(int argc, wdparm_t arg, ...);
/* NuttX callback functions */
@@ -532,42 +523,6 @@ static void tun_txdone(FAR struct tun_device_s *priv)
(void)devif_poll(&priv->dev, tun_txpoll);
}
/****************************************************************************
* Function: tun_poll_process
*
* Description:
* Perform the periodic poll. This may be called either from watchdog
* timer logic or from the worker thread, depending upon the configuration.
*
* Parameters:
* priv - Reference to the driver state structure
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
static void tun_poll_process(FAR struct tun_device_s *priv)
{
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
if (priv->read_d_len == 0)
{
/* If so, poll the network for new XMIT data. */
priv->dev.d_buf = priv->read_buf;
(void)devif_timer(&priv->dev, tun_txpoll);
}
/* Setup the watchdog poll timer again */
(void)wd_start(priv->txpoll, TUN_WDDELAY, tun_poll_expiry, 1, priv);
}
/****************************************************************************
* Function: tun_poll_work
*
@@ -585,23 +540,34 @@ static void tun_poll_process(FAR struct tun_device_s *priv)
*
****************************************************************************/
#ifdef CONFIG_NET_NOINTS
static void tun_poll_work(FAR void *arg)
{
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)arg;
net_lock_t state;
/* Perform the poll */
tun_lock(priv);
state = net_lock();
net_lock();
tun_poll_process(priv);
/* Check if there is room in the send another TX packet. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
net_unlock(state);
if (priv->read_d_len == 0)
{
/* If so, poll the network for new XMIT data. */
priv->dev.d_buf = priv->read_buf;
(void)devif_timer(&priv->dev, tun_txpoll);
}
/* Setup the watchdog poll timer again */
(void)wd_start(priv->txpoll, TUN_WDDELAY, tun_poll_expiry, 1, priv);
net_unlock();
tun_unlock(priv);
}
#endif
/****************************************************************************
* Function: tun_poll_expiry
@@ -625,7 +591,6 @@ static void tun_poll_expiry(int argc, wdparm_t arg, ...)
{
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)arg;
#ifdef CONFIG_NET_NOINTS
/* Is our single work structure available? It may not be if there are
* pending interrupt actions.
*/
@@ -644,12 +609,6 @@ static void tun_poll_expiry(int argc, wdparm_t arg, ...)
(void)wd_start(priv->txpoll, TUN_WDDELAY, tun_poll_expiry, 1, arg);
}
#else
/* Process the interrupt now */
tun_poll_process(priv);
#endif
}
/****************************************************************************
@@ -758,7 +717,6 @@ static int tun_ifdown(struct net_driver_s *dev)
static int tun_txavail(struct net_driver_s *dev)
{
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
net_lock_t state;
tun_lock(priv);
@@ -770,7 +728,7 @@ static int tun_txavail(struct net_driver_s *dev)
return OK;
}
state = net_lock();
net_lock();
if (priv->bifup)
{
@@ -780,7 +738,7 @@ static int tun_txavail(struct net_driver_s *dev)
(void)devif_poll(&priv->dev, tun_txpoll);
}
net_unlock(state);
net_unlock();
tun_unlock(priv);
return OK;
@@ -1005,7 +963,6 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen)
{
FAR struct tun_device_s *priv = filep->f_priv;
net_lock_t state;
ssize_t ret;
if (!priv)
@@ -1021,7 +978,7 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
return -EBUSY;
}
state = net_lock();
net_lock();
if (buflen > CONFIG_NET_TUN_MTU)
{
@@ -1039,7 +996,7 @@ static ssize_t tun_write(FAR struct file *filep, FAR const char *buffer,
ret = (ssize_t)buflen;
}
net_unlock(state);
net_unlock();
tun_unlock(priv);
return ret;
@@ -1053,7 +1010,6 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct tun_device_s *priv = filep->f_priv;
net_lock_t state;
ssize_t ret;
size_t write_d_len;
size_t read_d_len;
@@ -1084,9 +1040,9 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
if (priv->read_d_len == 0)
{
state = net_lock();
net_lock();
tun_txdone(priv);
net_unlock(state);
net_unlock();
}
goto out;
@@ -1106,7 +1062,7 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
tun_lock(priv);
}
state = net_lock();
net_lock();
read_d_len = priv->read_d_len;
if (buflen < read_d_len)
@@ -1122,7 +1078,7 @@ static ssize_t tun_read(FAR struct file *filep, FAR char *buffer,
priv->read_d_len = 0;
tun_txdone(priv);
net_unlock(state);
net_unlock();
out:
tun_unlock(priv);