diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c index b041574ea57..a163cecaabe 100644 --- a/arch/arm/src/c5471/c5471_ethernet.c +++ b/arch/arm/src/c5471/c5471_ethernet.c @@ -59,11 +59,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include @@ -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_C5471_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_C5471_LPWORK) @@ -317,9 +312,7 @@ struct c5471_driver_s bool c_bifup; /* true:ifup false:ifdown */ WDOG_ID c_txpoll; /* TX poll timer */ WDOG_ID c_txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s c_work; /* For deferring work to the work queue */ -#endif /* Note: According to the C547x documentation: "The software has to maintain * two pointers to the current RX-CPU and TX-CPU descriptors. At init time, @@ -407,25 +400,15 @@ static void c5471_txstatus(struct c5471_driver_s *priv); #endif static void c5471_txdone(struct c5471_driver_s *priv); -static inline void c5471_interrupt_process(FAR struct c5471_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void c5471_interrupt_work(FAR void *arg); -#endif - static int c5471_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static inline void c5471_txtimeout_process(FAR struct c5471_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void c5471_txtimeout_work(FAR void *arg); -#endif static void c5471_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void c5471_poll_process(FAR struct c5471_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void c5471_poll_work(FAR void *arg); -#endif static void c5471_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -433,10 +416,7 @@ static void c5471_poll_expiry(int argc, uint32_t arg, ...); static int c5471_ifup(struct net_driver_s *dev); static int c5471_ifdown(struct net_driver_s *dev); -static inline void c5471_txavail_process(FAR struct c5471_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void c5471_txavail_work(FAR void *arg); -#endif static int c5471_txavail(struct net_driver_s *dev); #ifdef CONFIG_NET_IGMP @@ -1558,25 +1538,30 @@ static void c5471_txdone(struct c5471_driver_s *priv) } /**************************************************************************** - * Function: c5471_interrupt_process + * Function: c5471_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 c5471_interrupt_process(FAR struct c5471_driver_s *priv) +static void c5471_interrupt_work(FAR void *arg) { + FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg; + + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Get and clear interrupt status bits */ priv->c_eimstatus = getreg32(EIM_STATUS); @@ -1624,42 +1609,13 @@ static inline void c5471_interrupt_process(FAR struct c5471_driver_s *priv) c5471_txdone(priv); } -} -/**************************************************************************** - * Function: c5471_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 c5471_interrupt_work(FAR void *arg) -{ - FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - c5471_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ up_enable_irq(C5471_IRQ_ETHER); } -#endif /**************************************************************************** * Function: c5471_interrupt @@ -1686,7 +1642,6 @@ static int c5471_interrupt(int irq, FAR void *context) # error "Additional logic needed to support multiple interfaces" #endif -#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. @@ -1712,52 +1667,9 @@ static int c5471_interrupt(int irq, FAR void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->c_work, c5471_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - c5471_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: c5471_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 c5471_txtimeout_process(FAR struct c5471_driver_s *priv) -{ - /* Increment statistics */ - -#ifdef CONFIG_C5471_NET_STATS - priv->c_txtimeouts++; - ninfo("c_txtimeouts: %d\n", priv->c_txtimeouts); -#endif - - /* Then try to restart the hardware */ - - c5471_ifdown(&priv->c_dev); - c5471_ifup(&priv->c_dev); - - /* Then poll the network for new XMIT data */ - - (void)devif_poll(&priv->c_dev, c5471_txpoll); -} - /**************************************************************************** * Function: c5471_txtimeout_work * @@ -1775,20 +1687,29 @@ static inline void c5471_txtimeout_process(FAR struct c5471_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void c5471_txtimeout_work(FAR void *arg) { FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Increment statistics */ - state = net_lock(); - c5471_txtimeout_process(priv); - net_unlock(state); -} + net_lock(); +#ifdef CONFIG_C5471_NET_STATS + priv->c_txtimeouts++; + ninfo("c_txtimeouts: %d\n", priv->c_txtimeouts); #endif + /* Then try to restart the hardware */ + + c5471_ifdown(&priv->c_dev); + c5471_ifup(&priv->c_dev); + + /* Then poll the network for new XMIT data */ + + (void)devif_poll(&priv->c_dev, c5471_txpoll); + net_unlock(); +} + /**************************************************************************** * Function: c5471_txtimeout_expiry * @@ -1812,7 +1733,6 @@ static void c5471_txtimeout_expiry(int argc, wdparm_t arg, ...) { struct c5471_driver_s *priv = (struct c5471_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. @@ -1829,47 +1749,6 @@ static void c5471_txtimeout_expiry(int argc, wdparm_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->c_work, c5471_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - c5471_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: c5471_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 c5471_poll_process(FAR struct c5471_driver_s *priv) -{ - /* Check if the ESM has let go of the RX descriptor giving us access rights - * to submit another Ethernet frame. - */ - - if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0) - { - /* If so, update TCP timing states and poll the network for new XMIT data */ - - (void)devif_timer(&priv->c_dev, c5471_txpoll); - } - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->c_txpoll, C5471_WDDELAY, c5471_poll_expiry, 1, - (wdparm_t)priv); } /**************************************************************************** @@ -1889,19 +1768,28 @@ static inline void c5471_poll_process(FAR struct c5471_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void c5471_poll_work(FAR void *arg) { FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Check if the ESM has let go of the RX descriptor giving us access rights + * to submit another Ethernet frame. + */ - state = net_lock(); - c5471_poll_process(priv); - net_unlock(state); + net_lock(); + if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0) + { + /* If so, update TCP timing states and poll the network for new XMIT data */ + + (void)devif_timer(&priv->c_dev, c5471_txpoll); + } + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->c_txpoll, C5471_WDDELAY, c5471_poll_expiry, 1, + (wdparm_t)priv); + net_unlock(); } -#endif /**************************************************************************** * Function: c5471_poll_expiry @@ -1925,7 +1813,6 @@ static void c5471_poll_expiry(int argc, wdparm_t arg, ...) { struct c5471_driver_s *priv = (struct c5471_driver_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -1945,12 +1832,6 @@ static void c5471_poll_expiry(int argc, wdparm_t arg, ...) (void)wd_start(priv->c_txpoll, C5471_WDDELAY, c5471_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - c5471_poll_process(priv); -#endif } /**************************************************************************** @@ -2071,44 +1952,6 @@ static int c5471_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: c5471_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 c5471_txavail_process(FAR struct c5471_driver_s *priv) -{ - ninfo("Polling\n"); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->c_bifup) - { - /* Check if the ESM has let go of the RX descriptor giving us access - * rights to submit another Ethernet frame. - */ - - if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0) - { - /* If so, then poll the network for new XMIT data */ - - (void)devif_poll(&priv->c_dev, c5471_txpoll); - } - } -} - /**************************************************************************** * Function: c5471_txavail_work * @@ -2126,19 +1969,31 @@ static inline void c5471_txavail_process(FAR struct c5471_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void c5471_txavail_work(FAR void *arg) { FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("Polling\n"); - state = net_lock(); - c5471_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->c_bifup) + { + /* Check if the ESM has let go of the RX descriptor giving us access + * rights to submit another Ethernet frame. + */ + + if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0) + { + /* If so, then poll the network for new XMIT data */ + + (void)devif_poll(&priv->c_dev, c5471_txpoll); + } + } + + net_unlock(); } -#endif /**************************************************************************** * Function: c5471_txavail @@ -2163,7 +2018,6 @@ static int c5471_txavail(FAR struct net_driver_s *dev) { struct c5471_driver_s *priv = (struct c5471_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. @@ -2176,21 +2030,6 @@ static int c5471_txavail(FAR struct net_driver_s *dev) work_queue(ETHWORK, &priv->c_work, c5471_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 */ - - c5471_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index e83c3fcc944..30707e47ac1 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -53,14 +53,11 @@ #include #include #include +#include #include #include #include -#ifdef CONFIG_NET_NOINTS -# include -#endif - #ifdef CONFIG_NET_PKT # include #endif @@ -84,13 +81,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_KINETIS_EMAC_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_KINETIS_EMAC_LPWORK) @@ -219,9 +215,7 @@ struct kinetis_driver_s uint8_t phyaddr; /* Selected PHY address */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif struct enet_desc_s *txdesc; /* A pointer to the list of TX descriptor */ struct enet_desc_s *rxdesc; /* A pointer to the list of RX descriptors */ @@ -279,24 +273,15 @@ static int kinetis_txpoll(struct net_driver_s *dev); static void kinetis_receive(FAR struct kinetis_driver_s *priv); static void kinetis_txdone(FAR struct kinetis_driver_s *priv); -static inline void kinetis_interrupt_process(FAR struct kinetis_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void kinetis_interrupt_work(FAR void *arg); -#endif static int kinetis_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static inline void kinetis_txtimeout_process(FAR struct kinetis_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void kinetis_txtimeout_work(FAR void *arg); -#endif static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void kinetis_poll_process(FAR struct kinetis_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void kinetis_poll_work(FAR void *arg); -#endif static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -304,10 +289,7 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...); static int kinetis_ifup(struct net_driver_s *dev); static int kinetis_ifdown(struct net_driver_s *dev); -static inline void kinetis_txavail_process(FAR struct kinetis_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void kinetis_txavail_work(FAR void *arg); -#endif static int kinetis_txavail(struct net_driver_s *dev); #ifdef CONFIG_NET_IGMP @@ -824,27 +806,31 @@ static void kinetis_txdone(FAR struct kinetis_driver_s *priv) } /**************************************************************************** - * Function: kinetis_interrupt_process + * Function: kinetis_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 kinetis_interrupt_process(FAR struct kinetis_driver_s *priv) +static void kinetis_interrupt_work(FAR void *arg) { + FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; uint32_t pending; + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Get the set of unmasked, pending interrupt. */ pending = getreg32(KINETIS_ENET_EIR) & getreg32(KINETIS_ENET_EIMR); @@ -892,36 +878,8 @@ static inline void kinetis_interrupt_process(FAR struct kinetis_driver_s *priv) putreg32(ENET_RDAR, KINETIS_ENET_RDAR); } -} -/**************************************************************************** - * Function: kinetis_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 kinetis_interrupt_work(FAR void *arg) -{ - FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - kinetis_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ @@ -932,7 +890,6 @@ static void kinetis_interrupt_work(FAR void *arg) up_enable_irq(KINETIS_IRQ_EMACRX); up_enable_irq(KINETIS_IRQ_EMACMISC); } -#endif /**************************************************************************** * Function: kinetis_interrupt @@ -958,7 +915,6 @@ static int kinetis_interrupt(int irq, FAR void *context) { register FAR struct kinetis_driver_s *priv = &g_enet[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. @@ -987,51 +943,9 @@ static int kinetis_interrupt(int irq, FAR void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->work, kinetis_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - kinetis_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: kinetis_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 kinetis_txtimeout_process(FAR struct kinetis_driver_s *priv) -{ - /* Increment statistics and dump debug info */ - - NETDEV_TXTIMEOUTS(&priv->dev); - - /* Take the interface down and bring it back up. The is the most agressive - * hardware reset. - */ - - (void)kinetis_ifdown(&priv->dev); - (void)kinetis_ifup(&priv->dev); - - /* Then poll the network for new XMIT data */ - - (void)devif_poll(&priv->dev, kinetis_txpoll); -} - /**************************************************************************** * Function: kinetis_txtimeout_work * @@ -1049,19 +963,27 @@ static inline void kinetis_txtimeout_process(FAR struct kinetis_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void kinetis_txtimeout_work(FAR void *arg) { FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Increment statistics and dump debug info */ - state = net_lock(); - kinetis_txtimeout_process(priv); - net_unlock(state); + net_lock(); + NETDEV_TXTIMEOUTS(&priv->dev); + + /* Take the interface down and bring it back up. The is the most agressive + * hardware reset. + */ + + (void)kinetis_ifdown(&priv->dev); + (void)kinetis_ifup(&priv->dev); + + /* Then poll the network for new XMIT data */ + + (void)devif_poll(&priv->dev, kinetis_txpoll); + net_unlock(); } -#endif /**************************************************************************** * Function: kinetis_txtimeout_expiry @@ -1086,7 +1008,6 @@ static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...) { FAR struct kinetis_driver_s *priv = (FAR struct kinetis_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. @@ -1106,50 +1027,6 @@ static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, kinetis_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - kinetis_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: kinetis_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 kinetis_poll_process(FAR struct kinetis_driver_s *priv) -{ - /* Check if there is there is a transmission in progress. We cannot perform - * the TX poll if he are unable to accept another packet for transmission. - */ - - if (!kinetics_txringfull(priv)) - { - /* 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->dev, kinetis_txpoll); - } - - /* Setup the watchdog poll timer again in any case */ - - (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry, - 1, (wdparm_t)priv); } /**************************************************************************** @@ -1169,19 +1046,31 @@ static inline void kinetis_poll_process(FAR struct kinetis_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void kinetis_poll_work(FAR void *arg) { FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Check if there is there is a transmission in progress. We cannot perform + * the TX poll if he are unable to accept another packet for transmission. + */ - state = net_lock(); - kinetis_poll_process(priv); - net_unlock(state); + net_lock(); + if (!kinetics_txringfull(priv)) + { + /* 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->dev, kinetis_txpoll); + } + + /* Setup the watchdog poll timer again in any case */ + + (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry, + 1, (wdparm_t)priv); + net_unlock(); } -#endif /**************************************************************************** * Function: kinetis_polltimer_expiry @@ -1205,7 +1094,6 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...) { FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -1225,12 +1113,6 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry, 1, (wdparm_t)arg); } - -#else - /* Process the interrupt now */ - - kinetis_poll_process(priv); -#endif } /**************************************************************************** @@ -1416,49 +1298,6 @@ static int kinetis_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: kinetis_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 kinetis_txavail_process(FAR struct kinetis_driver_s *priv) -{ - net_lock_t state; - - /* Ignore the notification if the interface is not yet up */ - - state = net_lock(); - if (priv->bifup) - { - /* Check if there is room in the hardware to hold another outgoing - * packet. - */ - - if (!kinetics_txringfull(priv)) - { - /* No, there is space for another transfer. Poll the network for new - * XMIT data. - */ - - (void)devif_poll(&priv->dev, kinetis_txpoll); - } - } - - net_unlock(state); -} - /**************************************************************************** * Function: kinetis_txavail_work * @@ -1476,16 +1315,31 @@ static inline void kinetis_txavail_process(FAR struct kinetis_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void kinetis_txavail_work(FAR void *arg) { FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg; - /* Perform the poll */ + /* Ignore the notification if the interface is not yet up */ - kinetis_txavail_process(priv); + net_lock(); + if (priv->bifup) + { + /* Check if there is room in the hardware to hold another outgoing + * packet. + */ + + if (!kinetics_txringfull(priv)) + { + /* No, there is space for another transfer. Poll the network for new + * XMIT data. + */ + + (void)devif_poll(&priv->dev, kinetis_txpoll); + } + } + + net_unlock(); } -#endif /**************************************************************************** * Function: kinetis_txavail @@ -1511,7 +1365,6 @@ static int kinetis_txavail(struct net_driver_s *dev) FAR struct kinetis_driver_s *priv = (FAR struct kinetis_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. @@ -1524,12 +1377,6 @@ static int kinetis_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, kinetis_txavail_work, priv, 0); } -#else - /* Perform the out-of-cycle poll now */ - - kinetis_txavail_process(priv); -#endif - return OK; } diff --git a/arch/arm/src/lpc17xx/lpc17_ethernet.c b/arch/arm/src/lpc17xx/lpc17_ethernet.c index 545369e055e..1ec3d332e29 100644 --- a/arch/arm/src/lpc17xx/lpc17_ethernet.c +++ b/arch/arm/src/lpc17xx/lpc17_ethernet.c @@ -52,15 +52,12 @@ #include #include #include +#include #include #include #include #include -#ifdef CONFIG_NET_NOINTS -# include -#endif - #ifdef CONFIG_NET_PKT # include #endif @@ -87,13 +84,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_LPC17_ETHERNET_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_LPC17_ETHERNET_LPWORK) @@ -276,12 +272,10 @@ struct lpc17_driver_s WDOG_ID lp_txpoll; /* TX poll timer */ WDOG_ID lp_txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s lp_txwork; /* TX work continuation */ struct work_s lp_rxwork; /* RX work continuation */ struct work_s lp_pollwork; /* Poll work continuation */ uint32_t status; -#endif /* CONFIG_NET_NOINTS */ /* This holds the information visible to the NuttX networking layer */ @@ -338,26 +332,17 @@ static int lpc17_txpoll(struct net_driver_s *dev); /* Interrupt handling */ static void lpc17_response(struct lpc17_driver_s *priv); -static void lpc17_rxdone_process(struct lpc17_driver_s *priv); -static void lpc17_txdone_process(struct lpc17_driver_s *priv); -#ifdef CONFIG_NET_NOINTS + static void lpc17_txdone_work(FAR void *arg); static void lpc17_rxdone_work(FAR void *arg); -#endif /* CONFIG_NET_NOINTS */ static int lpc17_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static void lpc17_txtimeout_process(FAR struct lpc17_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void lpc17_txtimeout_work(FAR void *arg); -#endif /* CONFIG_NET_NOINTS */ static void lpc17_txtimeout_expiry(int argc, uint32_t arg, ...); -static void lpc17_poll_process(FAR struct lpc17_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void lpc17_poll_work(FAR void *arg); -#endif /* CONFIG_NET_NOINTS */ static void lpc17_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -368,11 +353,9 @@ static void lpc17_ipv6multicast(FAR struct lpc17_driver_s *priv); static int lpc17_ifup(struct net_driver_s *dev); static int lpc17_ifdown(struct net_driver_s *dev); -static void lpc17_txavail_process(FAR struct lpc17_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void lpc17_txavail_work(FAR void *arg); -#endif static int lpc17_txavail(struct net_driver_s *dev); + #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) static uint32_t lpc17_calcethcrc(const uint8_t *data, size_t length); static int lpc17_addmac(struct net_driver_s *dev, const uint8_t *mac); @@ -805,30 +788,40 @@ static void lpc17_response(struct lpc17_driver_s *priv) } /**************************************************************************** - * Function: lpc17_rxdone_process + * Function: lpc17_rxdone_work * * Description: - * An interrupt was received indicating the availability of a new RX packet + * Perform Rx interrupt handling logic outside of the interrupt handler (on + * the work queue thread). * * Parameters: - * priv - Reference to the driver state structure + * arg - The reference to the driver structure (case to void*) * * Returned Value: * None * * Assumptions: - * Global interrupts are disabled by interrupt handling logic. * ****************************************************************************/ -static void lpc17_rxdone_process(struct lpc17_driver_s *priv) +static void lpc17_rxdone_work(FAR void *arg) { - uint32_t *rxstat; - bool fragment; + FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)arg; + irqstate_t flags; + uint32_t *rxstat; + bool fragment; unsigned int prodidx; unsigned int considx; unsigned int pktlen; + DEBUGASSERT(priv); + + /* Perform pending RX work. RX interrupts were disabled prior to + * scheduling this work to prevent work queue overruns. + */ + + net_lock(); + /* Get the current producer and consumer indices */ considx = lpc17_getreg(LPC17_ETH_RXCONSIDX) & ETH_RXCONSIDX_MASK; @@ -1042,37 +1035,55 @@ static void lpc17_rxdone_process(struct lpc17_driver_s *priv) lpc17_putreg(considx, LPC17_ETH_RXCONSIDX); prodidx = lpc17_getreg(LPC17_ETH_RXPRODIDX) & ETH_RXPRODIDX_MASK; } + + net_unlock(); + + /* Re-enable RX interrupts (this must be atomic). Skip this step if the + * lp-txpending TX underrun state is in effect. + */ + + flags = enter_critical_section(); + if (!priv->lp_txpending) + { + priv->lp_inten |= ETH_RXINTS; + lpc17_putreg(priv->lp_inten, LPC17_ETH_INTEN); + } + + leave_critical_section(flags); } + /**************************************************************************** - * Function: lpc17_txdone_process + * Function: lpc17_txdone_work * * Description: - * An interrupt was received indicating that the last TX packet(s) is done + * Perform Tx interrupt handling logic outside of the interrupt handler (on + * the work queue thread). * * Parameters: - * priv - Reference to the driver state structure + * arg - The reference to the driver structure (case to void*) * * Returned Value: * None * - * Assumptions: - * Global interrupts are disabled by interrupt handling logic. - * ****************************************************************************/ -static void lpc17_txdone_process(struct lpc17_driver_s *priv) +static void lpc17_txdone_work(FAR void *arg) { + FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)arg; + /* Verify that the hardware is ready to send another packet. Since a Tx * just completed, this must be the case. */ + DEBUGASSERT(priv); DEBUGASSERT(lpc17_txdesc(priv) == OK); /* Check if there is a pending Tx transfer that was scheduled by Rx handling * while the Tx logic was busy. If so, processing that pending Tx now. */ + net_lock(); if (priv->lp_txpending) { /* Clear the pending condition, send the packet, and restore Rx interrupts */ @@ -1091,74 +1102,10 @@ static void lpc17_txdone_process(struct lpc17_driver_s *priv) { (void)devif_poll(&priv->lp_dev, lpc17_txpoll); } + + net_unlock(); } -/**************************************************************************** - * Function: lpc17_txdone_work and lpc17_rxdone_work - * - * Description: - * Perform interrupt handling logic outside of the interrupt handler (on - * the work queue thread). - * - * Parameters: - * arg - The reference to the driver structure (case to void*) - * - * Returned Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -#ifdef CONFIG_NET_NOINTS -static void lpc17_txdone_work(FAR void *arg) -{ - FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)arg; - net_lock_t state; - - DEBUGASSERT(priv); - - /* Perform pending TX work. At this point TX interrupts are disable but - * may be re-enabled again depending on the actions of - * lpc17_txdone_process(). - */ - - state = net_lock(); - lpc17_txdone_process(priv); - net_unlock(state); -} - -static void lpc17_rxdone_work(FAR void *arg) -{ - FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)arg; - irqstate_t flags; - net_lock_t state; - - DEBUGASSERT(priv); - - /* Perform pending RX work. RX interrupts were disabled prior to - * scheduling this work to prevent work queue overruns. - */ - - state = net_lock(); - lpc17_rxdone_process(priv); - net_unlock(state); - - /* Re-enable RX interrupts (this must be atomic). Skip this step if the - * lp-txpending TX underrun state is in effect. - */ - - flags = enter_critical_section(); - if (!priv->lp_txpending) - { - priv->lp_inten |= ETH_RXINTS; - lpc17_putreg(priv->lp_inten, LPC17_ETH_INTEN); - } - - leave_critical_section(flags); -} -#endif /* CONFIG_NET_NOINTS */ - /**************************************************************************** * Function: lpc17_interrupt * @@ -1267,8 +1214,6 @@ static int lpc17_interrupt(int irq, void *context) if ((status & ETH_INT_RXFIN) != 0 || (status & ETH_INT_RXDONE) != 0) { /* We have received at least one new incoming packet. */ - -#ifdef CONFIG_NET_NOINTS /* Disable further TX interrupts for now. TX interrupts will * be re-enabled after the work has been processed. */ @@ -1284,11 +1229,6 @@ static int lpc17_interrupt(int irq, void *context) work_queue(ETHWORK, &priv->lp_rxwork, (worker_t)lpc17_rxdone_work, priv, 0); - -#else /* CONFIG_NET_NOINTS */ - lpc17_rxdone_process(priv); - -#endif /* CONFIG_NET_NOINTS */ } /* Check for Tx events ********************************************/ @@ -1337,7 +1277,6 @@ static int lpc17_interrupt(int irq, void *context) priv->lp_inten &= ~ETH_TXINTS; lpc17_putreg(priv->lp_inten, LPC17_ETH_INTEN); -#ifdef CONFIG_NET_NOINTS /* Cancel any pending TX done work (to prevent overruns and also * to avoid race conditions with the TX timeout work) */ @@ -1357,13 +1296,6 @@ static int lpc17_interrupt(int irq, void *context) work_queue(ETHWORK, &priv->lp_txwork, (worker_t)lpc17_txdone_work, priv, 0); - -#else /* CONFIG_NET_NOINTS */ - /* Perform the TX work at the interrupt level */ - - lpc17_txdone_process(priv); - -#endif /* CONFIG_NET_NOINTS */ } } } @@ -1381,42 +1313,6 @@ static int lpc17_interrupt(int irq, void *context) return OK; } -/**************************************************************************** - * Function: lpc17_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 void lpc17_txtimeout_process(FAR struct lpc17_driver_s *priv) -{ - /* Increment statistics and dump debug info */ - - NETDEV_TXTIMEOUTS(&priv->lp_dev); - if (priv->lp_ifup) - { - /* Then reset the hardware. ifup() will reset the interface, then bring - * it back up. - */ - - (void)lpc17_ifup(&priv->lp_dev); - - /* Then poll the network layer for new XMIT data */ - - (void)devif_poll(&priv->lp_dev, lpc17_txpoll); - } -} - /**************************************************************************** * Function: lpc17_txtimeout_work * @@ -1434,19 +1330,29 @@ static void lpc17_txtimeout_process(FAR struct lpc17_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void lpc17_txtimeout_work(FAR void *arg) { FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Increment statistics and dump debug info */ - state = net_lock(); - lpc17_txtimeout_process(priv); - net_unlock(state); + net_lock(); + NETDEV_TXTIMEOUTS(&priv->lp_dev); + if (priv->lp_ifup) + { + /* Then reset the hardware. ifup() will reset the interface, then bring + * it back up. + */ + + (void)lpc17_ifup(&priv->lp_dev); + + /* Then poll the network layer for new XMIT data */ + + (void)devif_poll(&priv->lp_dev, lpc17_txpoll); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: lpc17_txtimeout_expiry @@ -1478,7 +1384,6 @@ static void lpc17_txtimeout_expiry(int argc, uint32_t arg, ...) priv->lp_inten &= ~ETH_TXINTS; lpc17_putreg(priv->lp_inten, LPC17_ETH_INTEN); -#ifdef CONFIG_NET_NOINTS /* Is the single TX work structure available? If not, then there is * pending TX work to be done this must be a false alarm TX timeout. */ @@ -1489,33 +1394,28 @@ static void lpc17_txtimeout_expiry(int argc, uint32_t arg, ...) work_queue(ETHWORK, &priv->lp_txwork, lpc17_txtimeout_work, priv, 0); } - -#else - /* Process the timeout now */ - - lpc17_txtimeout_process(priv); -#endif } /**************************************************************************** - * Function: lpc17_poll_process + * Function: lpc17_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: + * Ethernet interrupts are disabled * ****************************************************************************/ -static void lpc17_poll_process(FAR struct lpc17_driver_s *priv) +static void lpc17_poll_work(FAR void *arg) { + FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)arg; unsigned int prodidx; unsigned int considx; @@ -1523,6 +1423,7 @@ static void lpc17_poll_process(FAR struct lpc17_driver_s *priv) * the TX poll if he are unable to accept another packet for transmission. */ + net_lock(); if (lpc17_txdesc(priv) == OK) { /* If so, update TCP timing states and poll the network layer for new @@ -1544,54 +1445,17 @@ static void lpc17_poll_process(FAR struct lpc17_driver_s *priv) if (considx != prodidx) { -#ifdef CONFIG_NET_NOINTS work_queue(ETHWORK, &priv->lp_rxwork, (worker_t)lpc17_rxdone_work, priv, 0); - -#else /* CONFIG_NET_NOINTS */ - lpc17_rxdone_process(priv); - -#endif /* CONFIG_NET_NOINTS */ } /* Setup the watchdog poll timer again */ (void)wd_start(priv->lp_txpoll, LPC17_WDDELAY, lpc17_poll_expiry, 1, priv); + net_unlock(); } -/**************************************************************************** - * Function: lpc17_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: - * Ethernet interrupts are disabled - * - ****************************************************************************/ - -#ifdef CONFIG_NET_NOINTS -static void lpc17_poll_work(FAR void *arg) -{ - FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)arg; - net_lock_t state; - - /* Perform the poll */ - - state = net_lock(); - lpc17_poll_process(priv); - net_unlock(state); -} -#endif - - /**************************************************************************** * Function: lpc17_poll_expiry * @@ -1616,7 +1480,6 @@ static void lpc17_poll_expiry(int argc, uint32_t arg, ...) DEBUGASSERT(arg); -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -1635,12 +1498,6 @@ static void lpc17_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->lp_txpoll, LPC17_WDDELAY, lpc17_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - lpc17_poll_process(priv); -#endif } /**************************************************************************** @@ -1931,45 +1788,6 @@ static int lpc17_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: lpc17_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 lpc17_txavail_process(FAR struct lpc17_driver_s *priv) -{ - net_lock_t state; - - /* Ignore the notification if the interface is not yet up */ - - state = net_lock(); - if (priv->lp_ifup) - { - /* Check if there is room in the hardware to hold another outgoing packet. */ - - if (lpc17_txdesc(priv) == OK) - { - /* If so, then poll the network layer for new XMIT data */ - - (void)devif_poll(&priv->lp_dev, lpc17_txpoll); - } - } - - net_unlock(state); -} - /**************************************************************************** * Function: lpc17_txavail_work * @@ -1987,16 +1805,27 @@ static inline void lpc17_txavail_process(FAR struct lpc17_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void lpc17_txavail_work(FAR void *arg) { FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)arg; - /* Perform the poll */ + /* Ignore the notification if the interface is not yet up */ - lpc17_txavail_process(priv); + net_lock(); + if (priv->lp_ifup) + { + /* Check if there is room in the hardware to hold another outgoing packet. */ + + if (lpc17_txdesc(priv) == OK) + { + /* If so, then poll the network layer for new XMIT data */ + + (void)devif_poll(&priv->lp_dev, lpc17_txpoll); + } + } + + net_unlock(); } -#endif /**************************************************************************** * Function: lpc17_txavail @@ -2021,7 +1850,6 @@ static int lpc17_txavail(struct net_driver_s *dev) { FAR struct lpc17_driver_s *priv = (FAR struct lpc17_driver_s *)dev->d_private; -#ifdef CONFIG_NET_NOINTS /* Is our single poll work structure available? It may not be if there * are pending polling actions and we will have to ignore the Tx * availability action (which is okay because all poll actions have, @@ -2035,13 +1863,6 @@ static int lpc17_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->lp_pollwork, lpc17_txavail_work, priv, 0); } -#else - - /* Perform the out-of-cycle poll now */ - - lpc17_txavail_process(priv); -#endif - return OK; } diff --git a/arch/arm/src/lpc43xx/lpc43_ethernet.c b/arch/arm/src/lpc43xx/lpc43_ethernet.c index 35d9926b520..6060c9cb2af 100644 --- a/arch/arm/src/lpc43xx/lpc43_ethernet.c +++ b/arch/arm/src/lpc43xx/lpc43_ethernet.c @@ -53,11 +53,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -87,13 +83,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_LPC43_ETHERNET_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_LPC43_ETHERNET_LPWORK) @@ -524,9 +519,7 @@ struct lpc43_ethmac_s uint8_t fduplex : 1; /* Full (vs. half) duplex */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -599,34 +592,26 @@ static int lpc43_recvframe(FAR struct lpc43_ethmac_s *priv); static void lpc43_receive(FAR struct lpc43_ethmac_s *priv); static void lpc43_freeframe(FAR struct lpc43_ethmac_s *priv); static void lpc43_txdone(FAR struct lpc43_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void lpc43_interrupt_work(FAR void *arg); -#endif static int lpc43_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static inline void lpc43_txtimeout_process(FAR struct lpc43_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void lpc43_txtimeout_work(FAR void *arg); -#endif static void lpc43_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void lpc43_poll_process(FAR struct lpc43_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void lpc43_poll_work(FAR void *arg); -#endif static void lpc43_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ static int lpc43_ifup(struct net_driver_s *dev); static int lpc43_ifdown(struct net_driver_s *dev); -static inline void lpc43_txavail_process(FAR struct lpc43_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void lpc43_txavail_work(FAR void *arg); -#endif static int lpc43_txavail(struct net_driver_s *dev); + #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) static int lpc43_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif @@ -1900,29 +1885,32 @@ static void lpc43_txdone(FAR struct lpc43_ethmac_s *priv) } /**************************************************************************** - * Function: lpc43_interrupt_process + * Function: lpc43_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 lpc43_interrupt_process(FAR struct lpc43_ethmac_s *priv) +static void lpc43_interrupt_work(FAR void *arg) { + FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)arg; uint32_t dmasr; + DEBUGASSERT(priv); + /* Get the DMA interrupt status bits (no MAC interrupts are expected) */ + net_lock(); dmasr = lpc43_getreg(LPC43_ETH_DMASTAT); /* Mask only enabled interrupts. This depends on the fact that the interrupt @@ -1974,7 +1962,6 @@ static inline void lpc43_interrupt_process(FAR struct lpc43_ethmac_s *priv) /* Handle error interrupt only if CONFIG_DEBUG_NET is eanbled */ #ifdef CONFIG_DEBUG_NET - /* Check if there are pending "abnormal" interrupts */ if ((dmasr & ETH_DMAINT_AIS) != 0) @@ -1991,45 +1978,13 @@ static inline void lpc43_interrupt_process(FAR struct lpc43_ethmac_s *priv) lpc43_putreg(ETH_DMAINT_AIS, LPC43_ETH_DMASTAT); } -#endif -} -/**************************************************************************** - * Function: lpc43_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 lpc43_interrupt_work(FAR void *arg) -{ - FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)arg; - net_lock_t state; - - DEBUGASSERT(priv); - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - lpc43_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts at the NVIC */ up_enable_irq(LPC43M4_IRQ_ETHERNET); } -#endif /**************************************************************************** * Function: lpc43_interrupt @@ -2051,8 +2006,6 @@ static void lpc43_interrupt_work(FAR void *arg) static int lpc43_interrupt(int irq, FAR void *context) { FAR struct lpc43_ethmac_s *priv = &g_lpc43ethmac; - -#ifdef CONFIG_NET_NOINTS uint32_t dmasr; /* Get the DMA interrupt status bits (no MAC interrupts are expected) */ @@ -2088,49 +2041,9 @@ static int lpc43_interrupt(int irq, FAR void *context) work_queue(ETHWORK, &priv->work, lpc43_interrupt_work, priv, 0); } -#else - /* Process the interrupt now */ - - lpc43_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: lpc43_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void lpc43_txtimeout_process(FAR struct lpc43_ethmac_s *priv) -{ - /* Then reset the hardware. Just take the interface down, then back - * up again. - */ - - lpc43_ifdown(&priv->dev); - lpc43_ifup(&priv->dev); - - /* Then poll the network for new XMIT data */ - - lpc43_dopoll(priv); -} - /**************************************************************************** * Function: lpc43_txtimeout_work * @@ -2148,19 +2061,23 @@ static inline void lpc43_txtimeout_process(FAR struct lpc43_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void lpc43_txtimeout_work(FAR void *arg) { FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Then reset the hardware. Just take the interface down, then back + * up again. + */ - state = net_lock(); - lpc43_txtimeout_process(priv); - net_unlock(state); + net_lock(); + lpc43_ifdown(&priv->dev); + lpc43_ifup(&priv->dev); + + /* Then poll the network for new XMIT data */ + + lpc43_dopoll(priv); + net_unlock(); } -#endif /**************************************************************************** * Function: lpc43_txtimeout_expiry @@ -2187,7 +2104,6 @@ static void lpc43_txtimeout_expiry(int argc, uint32_t arg, ...) ninfo("Timeout!\n"); -#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. @@ -2206,33 +2122,28 @@ static void lpc43_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, lpc43_txtimeout_work, priv, 0); - -#else - /* Process the timeout now */ - - lpc43_txtimeout_process(priv); -#endif } /**************************************************************************** - * Function: lpc43_poll_process + * Function: lpc43_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: + * Ethernet interrupts are disabled * ****************************************************************************/ -static inline void lpc43_poll_process(FAR struct lpc43_ethmac_s *priv) +static void lpc43_poll_work(FAR void *arg) { + FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)arg; FAR struct net_driver_s *dev = &priv->dev; /* Check if the next TX descriptor is owned by the Ethernet DMA or CPU. We @@ -2246,6 +2157,7 @@ static inline void lpc43_poll_process(FAR struct lpc43_ethmac_s *priv) * CONFIG_LPC43_ETH_NTXDESC). */ + net_lock(); if ((priv->txhead->tdes0 & ETH_TDES0_OWN) == 0 && priv->txhead->tdes2 == 0) { @@ -2281,39 +2193,9 @@ static inline void lpc43_poll_process(FAR struct lpc43_ethmac_s *priv) /* Setup the watchdog poll timer again */ (void)wd_start(priv->txpoll, LPC43_WDDELAY, lpc43_poll_expiry, 1, priv); + net_unlock(); } -/**************************************************************************** - * Function: lpc43_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: - * Ethernet interrupts are disabled - * - ****************************************************************************/ - -#ifdef CONFIG_NET_NOINTS -static void lpc43_poll_work(FAR void *arg) -{ - FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)arg; - net_lock_t state; - - /* Perform the poll */ - - state = net_lock(); - lpc43_poll_process(priv); - net_unlock(state); -} -#endif - /**************************************************************************** * Function: lpc43_poll_expiry * @@ -2336,7 +2218,6 @@ static void lpc43_poll_expiry(int argc, uint32_t arg, ...) { FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2356,12 +2237,6 @@ static void lpc43_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, LPC43_WDDELAY, lpc43_poll_expiry, 1, (uint32_t)priv); } - -#else - /* Process the interrupt now */ - - lpc43_poll_process(priv); -#endif } /**************************************************************************** @@ -2467,37 +2342,6 @@ static int lpc43_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: lpc43_txavail_process - * - * Description: - * Perform an out-of-cycle poll. - * - * Parameters: - * priv - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - * Assumptions: - * Called in normal user mode - * - ****************************************************************************/ - -static inline void lpc43_txavail_process(FAR struct lpc43_ethmac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll for new XMIT data */ - - lpc43_dopoll(priv); - } -} - /**************************************************************************** * Function: lpc43_txavail_work * @@ -2515,19 +2359,23 @@ static inline void lpc43_txavail_process(FAR struct lpc43_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void lpc43_txavail_work(FAR void *arg) { FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Ignore the notification if the interface is not yet up */ - state = net_lock(); - lpc43_txavail_process(priv); - net_unlock(state); + net_lock(); + ninfo("ifup: %d\n", priv->ifup); + if (priv->ifup) + { + /* Poll for new XMIT data */ + + lpc43_dopoll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: lpc43_txavail @@ -2552,7 +2400,6 @@ static int lpc43_txavail(struct net_driver_s *dev) { FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_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. @@ -2565,21 +2412,6 @@ static int lpc43_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, lpc43_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 */ - - lpc43_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index 6f234cebcbd..7ce3b0c3165 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -64,11 +64,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -101,13 +97,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_SAM34_EMAC_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_SAM34_EMAC_LPWORK) @@ -275,9 +270,7 @@ struct sam_emac_s uint8_t ifup : 1; /* true:ifup false:ifdown */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -386,24 +379,16 @@ static void sam_dopoll(struct sam_emac_s *priv); static int sam_recvframe(struct sam_emac_s *priv); static void sam_receive(struct sam_emac_s *priv); static void sam_txdone(struct sam_emac_s *priv); -static inline void sam_interrupt_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void sam_interrupt_work(FAR void *arg); -#endif static int sam_emac_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg); -#endif static void sam_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void sam_poll_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg); -#endif static void sam_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -411,10 +396,7 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...); static int sam_ifup(struct net_driver_s *dev); static int sam_ifdown(struct net_driver_s *dev); -static inline void sam_txavail_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg); -#endif static int sam_txavail(struct net_driver_s *dev); #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) @@ -465,6 +447,7 @@ static int sam_emac_configure(struct sam_emac_s *priv); /**************************************************************************** * Private Functions ****************************************************************************/ + /**************************************************************************** * Name: sam_checkreg * @@ -1421,25 +1404,25 @@ static void sam_txdone(struct sam_emac_s *priv) } /**************************************************************************** - * Function: sam_interrupt_process + * Function: sam_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 sam_interrupt_process(FAR struct sam_emac_s *priv) +static void sam_interrupt_work(FAR void *arg) { + FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; uint32_t isr; uint32_t rsr; uint32_t tsr; @@ -1448,6 +1431,9 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv) uint32_t pending; uint32_t clrbits; + /* Process pending Ethernet interrupts */ + + net_lock(); isr = sam_getreg(priv, SAM_EMAC_ISR); rsr = sam_getreg(priv, SAM_EMAC_RSR); tsr = sam_getreg(priv, SAM_EMAC_TSR); @@ -1603,42 +1589,13 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv) nwarn("WARNING: Pause TO!\n"); } #endif -} -/**************************************************************************** - * Function: sam_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 sam_interrupt_work(FAR void *arg) -{ - FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - sam_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ up_enable_irq(SAM_IRQ_EMAC); } -#endif /**************************************************************************** * Function: sam_emac_interrupt @@ -1661,7 +1618,6 @@ static int sam_emac_interrupt(int irq, void *context) { struct sam_emac_s *priv = &g_emac; -#ifdef CONFIG_NET_NOINTS uint32_t tsr; /* Disable further Ethernet interrupts. Because Ethernet interrupts are @@ -1705,52 +1661,9 @@ static int sam_emac_interrupt(int irq, void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - sam_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: sam_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) -{ - nerr("ERROR: Timeout!\n"); - - /* Then reset the hardware. Just take the interface down, then back - * up again. - */ - - sam_ifdown(&priv->dev); - sam_ifup(&priv->dev); - - /* Then poll the network for new XMIT data */ - - sam_dopoll(priv); -} - /**************************************************************************** * Function: sam_txtimeout_work * @@ -1768,19 +1681,25 @@ static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + nerr("ERROR: Timeout!\n"); - state = net_lock(); - sam_txtimeout_process(priv); - net_unlock(state); + /* Then reset the hardware. Just take the interface down, then back + * up again. + */ + + net_lock(); + sam_ifdown(&priv->dev); + sam_ifup(&priv->dev); + + /* Then poll the network for new XMIT data */ + + sam_dopoll(priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txtimeout_expiry @@ -1805,7 +1724,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_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. @@ -1822,48 +1740,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - sam_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: sam_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 sam_poll_process(FAR struct sam_emac_s *priv) -{ - struct net_driver_s *dev = &priv->dev; - - /* Check if the there are any free TX descriptors. We cannot perform the - * TX poll if we do not have buffering for another packet. - */ - - if (sam_txfree(priv) > 0) - { - /* Update TCP timing states and poll the network for new XMIT data. */ - - (void)devif_timer(dev, sam_txpoll); - } - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); } /**************************************************************************** @@ -1883,19 +1759,28 @@ static inline void sam_poll_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; + struct net_driver_s *dev = &priv->dev; - /* Perform the poll */ + /* Check if the there are any free TX descriptors. We cannot perform the + * TX poll if we do not have buffering for another packet. + */ - state = net_lock(); - sam_poll_process(priv); - net_unlock(state); + net_lock(); + if (sam_txfree(priv) > 0) + { + /* Update TCP timing states and poll the network for new XMIT data. */ + + (void)devif_timer(dev, sam_txpoll); + } + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_poll_expiry @@ -1919,7 +1804,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -1938,12 +1822,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - sam_poll_process(priv); -#endif } /**************************************************************************** @@ -2070,37 +1948,6 @@ static int sam_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: sam_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 sam_txavail_process(FAR struct sam_emac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - sam_dopoll(priv); - } -} - /**************************************************************************** * Function: sam_txavail_work * @@ -2118,19 +1965,24 @@ static inline void sam_txavail_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("ifup: %d\n", priv->ifup); - state = net_lock(); - sam_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->ifup) + { + /* Poll the network for new XMIT data */ + + sam_dopoll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txavail @@ -2155,7 +2007,6 @@ static int sam_txavail(struct net_driver_s *dev) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_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. @@ -2168,21 +2019,6 @@ static int sam_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, sam_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 */ - - sam_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index c31ae128f88..29bd28c5a75 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -65,11 +65,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -103,13 +99,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_SAMA5_EMACA_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_SAMA5_EMACA_LPWORK) @@ -280,9 +275,7 @@ struct sam_emac_s uint8_t ifup : 1; /* true:ifup false:ifdown */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -391,24 +384,16 @@ static void sam_dopoll(struct sam_emac_s *priv); static int sam_recvframe(struct sam_emac_s *priv); static void sam_receive(struct sam_emac_s *priv); static void sam_txdone(struct sam_emac_s *priv); -static inline void sam_interrupt_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void sam_interrupt_work(FAR void *arg); -#endif static int sam_emac_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg); -#endif static void sam_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void sam_poll_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg); -#endif static void sam_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -416,10 +401,7 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...); static int sam_ifup(struct net_driver_s *dev); static int sam_ifdown(struct net_driver_s *dev); -static inline void sam_txavail_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg); -#endif static int sam_txavail(struct net_driver_s *dev); #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) @@ -1462,25 +1444,25 @@ static void sam_txdone(struct sam_emac_s *priv) } /**************************************************************************** - * Function: sam_interrupt_process + * Function: sam_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 sam_interrupt_process(FAR struct sam_emac_s *priv) +static void sam_interrupt_work(FAR void *arg) { + FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; uint32_t isr; uint32_t rsr; uint32_t tsr; @@ -1489,6 +1471,9 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv) uint32_t pending; uint32_t clrbits; + /* Process pending Ethernet interrupts */ + + net_lock(); isr = sam_getreg(priv, SAM_EMAC_ISR); rsr = sam_getreg(priv, SAM_EMAC_RSR); tsr = sam_getreg(priv, SAM_EMAC_TSR); @@ -1643,42 +1628,13 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv) nwarn("WARNING: Pause TO!\n"); } #endif -} -/**************************************************************************** - * Function: sam_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 sam_interrupt_work(FAR void *arg) -{ - FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - sam_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ up_enable_irq(SAM_IRQ_EMAC); } -#endif /**************************************************************************** * Function: sam_emac_interrupt @@ -1700,7 +1656,6 @@ static void sam_interrupt_work(FAR void *arg) static int sam_emac_interrupt(int irq, void *context) { struct sam_emac_s *priv = &g_emac; -#ifdef CONFIG_NET_NOINTS uint32_t tsr; /* Disable further Ethernet interrupts. Because Ethernet interrupts are @@ -1744,50 +1699,9 @@ static int sam_emac_interrupt(int irq, void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - sam_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: sam_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) -{ - nerr("ERROR: Timeout!\n"); - - /* Reset the hardware. Just take the interface down, then back up again. */ - - sam_ifdown(&priv->dev); - sam_ifup(&priv->dev); - - /* Then poll the network for new XMIT data */ - - sam_dopoll(priv); -} - /**************************************************************************** * Function: sam_txtimeout_work * @@ -1805,19 +1719,23 @@ static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + nerr("ERROR: Timeout!\n"); - state = net_lock(); - sam_txtimeout_process(priv); - net_unlock(state); + /* Reset the hardware. Just take the interface down, then back up again. */ + + net_lock(); + sam_ifdown(&priv->dev); + sam_ifup(&priv->dev); + + /* Then poll the network for new XMIT data */ + + sam_dopoll(priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txtimeout_expiry @@ -1842,7 +1760,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_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. @@ -1859,48 +1776,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - sam_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: sam_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 sam_poll_process(FAR struct sam_emac_s *priv) -{ - struct net_driver_s *dev = &priv->dev; - - /* Check if the there are any free TX descriptors. We cannot perform the - * TX poll if we do not have buffering for another packet. - */ - - if (sam_txfree(priv) > 0) - { - /* Update TCP timing states and poll the network for new XMIT data. */ - - (void)devif_timer(dev, sam_txpoll); - } - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); } /**************************************************************************** @@ -1920,19 +1795,28 @@ static inline void sam_poll_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; + struct net_driver_s *dev = &priv->dev; - /* Perform the poll */ + /* Check if the there are any free TX descriptors. We cannot perform the + * TX poll if we do not have buffering for another packet. + */ - state = net_lock(); - sam_poll_process(priv); - net_unlock(state); + net_lock(); + if (sam_txfree(priv) > 0) + { + /* Update TCP timing states and poll the network for new XMIT data. */ + + (void)devif_timer(dev, sam_txpoll); + } + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_poll_expiry @@ -1956,7 +1840,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -1975,12 +1858,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - sam_poll_process(priv); -#endif } /**************************************************************************** @@ -2107,37 +1984,6 @@ static int sam_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: sam_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 sam_txavail_process(FAR struct sam_emac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - sam_dopoll(priv); - } -} - /**************************************************************************** * Function: sam_txavail_work * @@ -2155,19 +2001,24 @@ static inline void sam_txavail_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("ifup: %d\n", priv->ifup); - state = net_lock(); - sam_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->ifup) + { + /* Poll the network for new XMIT data */ + + sam_dopoll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txavail @@ -2192,7 +2043,6 @@ static int sam_txavail(struct net_driver_s *dev) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_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. @@ -2205,21 +2055,6 @@ static int sam_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, sam_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 */ - - sam_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index 6eb3dd2108f..44b477cb7ba 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -79,11 +79,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -117,13 +113,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_SAMA5_EMACB_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_SAMA5_EMACB_LPWORK) @@ -418,9 +413,7 @@ struct sam_emac_s uint8_t ifup : 1; /* true:ifup false:ifdown */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -486,10 +479,8 @@ static void sam_dopoll(struct sam_emac_s *priv); static int sam_recvframe(struct sam_emac_s *priv); static void sam_receive(struct sam_emac_s *priv); static void sam_txdone(struct sam_emac_s *priv); -static inline void sam_interrupt_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void sam_interrupt_work(FAR void *arg); -#endif static int sam_emac_interrupt(struct sam_emac_s *priv); #ifdef CONFIG_SAMA5_EMAC0 static int sam_emac0_interrupt(int irq, void *context); @@ -500,16 +491,10 @@ static int sam_emac1_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg); -#endif static void sam_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void sam_poll_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg); -#endif static void sam_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -517,10 +502,7 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...); static int sam_ifup(struct net_driver_s *dev); static int sam_ifdown(struct net_driver_s *dev); -static inline void sam_txavail_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg); -#endif static int sam_txavail(struct net_driver_s *dev); #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) @@ -1830,25 +1812,25 @@ static void sam_txdone(struct sam_emac_s *priv) } /**************************************************************************** - * Function: sam_interrupt_process + * Function: sam_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 sam_interrupt_process(FAR struct sam_emac_s *priv) +static void sam_interrupt_work(FAR void *arg) { + FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; uint32_t isr; uint32_t rsr; uint32_t tsr; @@ -1857,6 +1839,9 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv) uint32_t pending; uint32_t clrbits; + /* Process pending Ethernet interrupts */ + + net_lock(); isr = sam_getreg(priv, SAM_EMAC_ISR_OFFSET); rsr = sam_getreg(priv, SAM_EMAC_RSR_OFFSET); tsr = sam_getreg(priv, SAM_EMAC_TSR_OFFSET); @@ -2012,42 +1997,13 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv) nwarn("WARNING: Pause TO!\n"); } #endif -} -/**************************************************************************** - * Function: sam_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 sam_interrupt_work(FAR void *arg) -{ - FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - sam_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ up_enable_irq(priv->attr->irq); } -#endif /**************************************************************************** * Function: sam_emac_interrupt @@ -2067,7 +2023,6 @@ static void sam_interrupt_work(FAR void *arg) static int sam_emac_interrupt(struct sam_emac_s *priv) { -#ifdef CONFIG_NET_NOINTS uint32_t tsr; /* Disable further Ethernet interrupts. Because Ethernet interrupts are @@ -2111,13 +2066,6 @@ static int sam_emac_interrupt(struct sam_emac_s *priv) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - sam_interrupt_process(priv); -#endif - return OK; } @@ -2152,40 +2100,6 @@ static int sam_emac1_interrupt(int irq, void *context) } #endif -/**************************************************************************** - * Function: sam_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) -{ - nerr("ERROR: Timeout!\n"); - - /* Reset the hardware. Just take the interface down, then back up again. */ - - sam_ifdown(&priv->dev); - sam_ifup(&priv->dev); - - /* Then poll the network for new XMIT data */ - - sam_dopoll(priv); -} - /**************************************************************************** * Function: sam_txtimeout_work * @@ -2203,19 +2117,23 @@ static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + nerr("ERROR: Timeout!\n"); - state = net_lock(); - sam_txtimeout_process(priv); - net_unlock(state); + /* Reset the hardware. Just take the interface down, then back up again. */ + + net_lock(); + sam_ifdown(&priv->dev); + sam_ifup(&priv->dev); + + /* Then poll the network for new XMIT data */ + + sam_dopoll(priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txtimeout_expiry @@ -2240,7 +2158,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_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. @@ -2257,48 +2174,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - sam_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: sam_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 sam_poll_process(FAR struct sam_emac_s *priv) -{ - struct net_driver_s *dev = &priv->dev; - - /* Check if the there are any free TX descriptors. We cannot perform the - * TX poll if we do not have buffering for another packet. - */ - - if (sam_txfree(priv) > 0) - { - /* Update TCP timing states and poll the network for new XMIT data. */ - - (void)devif_timer(dev, sam_txpoll); - } - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); } /**************************************************************************** @@ -2318,19 +2193,28 @@ static inline void sam_poll_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; + struct net_driver_s *dev = &priv->dev; - /* Perform the poll */ + /* Check if the there are any free TX descriptors. We cannot perform the + * TX poll if we do not have buffering for another packet. + */ - state = net_lock(); - sam_poll_process(priv); - net_unlock(state); + net_lock(); + if (sam_txfree(priv) > 0) + { + /* Update TCP timing states and poll the network for new XMIT data. */ + + (void)devif_timer(dev, sam_txpoll); + } + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_poll_expiry @@ -2354,7 +2238,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2373,12 +2256,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - sam_poll_process(priv); -#endif } /**************************************************************************** @@ -2513,37 +2390,6 @@ static int sam_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: sam_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 sam_txavail_process(FAR struct sam_emac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - sam_dopoll(priv); - } -} - /**************************************************************************** * Function: sam_txavail_work * @@ -2561,19 +2407,24 @@ static inline void sam_txavail_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("ifup: %d\n", priv->ifup); - state = net_lock(); - sam_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->ifup) + { + /* Poll the network for new XMIT data */ + + sam_dopoll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txavail @@ -2598,7 +2449,6 @@ static int sam_txavail(struct net_driver_s *dev) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_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. @@ -2611,21 +2461,6 @@ static int sam_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, sam_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 */ - - sam_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index d3450dc2be7..da6b320d523 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -62,11 +62,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -100,13 +96,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_SAMA5_GMAC_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_SAMA5_GMAC_LPWORK) @@ -206,9 +201,7 @@ struct sam_gmac_s uint8_t ifup : 1; /* true:ifup false:ifdown */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -316,24 +309,16 @@ static void sam_dopoll(struct sam_gmac_s *priv); static int sam_recvframe(struct sam_gmac_s *priv); static void sam_receive(struct sam_gmac_s *priv); static void sam_txdone(struct sam_gmac_s *priv); -static inline void sam_interrupt_process(FAR struct sam_gmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void sam_interrupt_work(FAR void *arg); -#endif static int sam_gmac_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void sam_txtimeout_process(FAR struct sam_gmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg); -#endif static void sam_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void sam_poll_process(FAR struct sam_gmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg); -#endif static void sam_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -341,10 +326,7 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...); static int sam_ifup(struct net_driver_s *dev); static int sam_ifdown(struct net_driver_s *dev); -static inline void sam_txavail_process(FAR struct sam_gmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg); -#endif static int sam_txavail(struct net_driver_s *dev); #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) @@ -1390,25 +1372,25 @@ static void sam_txdone(struct sam_gmac_s *priv) } /**************************************************************************** - * Function: sam_interrupt_process + * Function: sam_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 sam_interrupt_process(FAR struct sam_gmac_s *priv) +static void sam_interrupt_work(FAR void *arg) { + FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_s *)arg; uint32_t isr; uint32_t rsr; uint32_t tsr; @@ -1417,6 +1399,9 @@ static inline void sam_interrupt_process(FAR struct sam_gmac_s *priv) uint32_t pending; uint32_t clrbits; + /* Process pending Ethernet interrupts */ + + net_lock(); isr = sam_getreg(priv, SAM_GMAC_ISR); rsr = sam_getreg(priv, SAM_GMAC_RSR); tsr = sam_getreg(priv, SAM_GMAC_TSR); @@ -1595,42 +1580,13 @@ static inline void sam_interrupt_process(FAR struct sam_gmac_s *priv) nwarn("WARNING: Pause TO!\n"); } #endif -} -/**************************************************************************** - * Function: sam_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 sam_interrupt_work(FAR void *arg) -{ - FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - sam_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ up_enable_irq(SAM_IRQ_GMAC); } -#endif /**************************************************************************** * Function: sam_gmac_interrupt @@ -1652,7 +1608,6 @@ static void sam_interrupt_work(FAR void *arg) static int sam_gmac_interrupt(int irq, void *context) { struct sam_gmac_s *priv = &g_gmac; -#ifdef CONFIG_NET_NOINTS uint32_t tsr; /* Disable further Ethernet interrupts. Because Ethernet interrupts are @@ -1696,50 +1651,9 @@ static int sam_gmac_interrupt(int irq, void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - sam_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: sam_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void sam_txtimeout_process(FAR struct sam_gmac_s *priv) -{ - nerr("ERROR: Timeout!\n"); - - /* Reset the hardware. Just take the interface down, then back up again. */ - - sam_ifdown(&priv->dev); - sam_ifup(&priv->dev); - - /* Then poll the network for new XMIT data */ - - sam_dopoll(priv); -} - /**************************************************************************** * Function: sam_txtimeout_work * @@ -1757,19 +1671,23 @@ static inline void sam_txtimeout_process(FAR struct sam_gmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg) { FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + nerr("ERROR: Timeout!\n"); - state = net_lock(); - sam_txtimeout_process(priv); - net_unlock(state); + /* Reset the hardware. Just take the interface down, then back up again. */ + + net_lock(); + sam_ifdown(&priv->dev); + sam_ifup(&priv->dev); + + /* Then poll the network for new XMIT data */ + + sam_dopoll(priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txtimeout_expiry @@ -1794,7 +1712,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) { FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_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. @@ -1811,48 +1728,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - sam_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: sam_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 sam_poll_process(FAR struct sam_gmac_s *priv) -{ - struct net_driver_s *dev = &priv->dev; - - /* Check if the there are any free TX descriptors. We cannot perform the - * TX poll if we do not have buffering for another packet. - */ - - if (sam_txfree(priv) > 0) - { - /* Update TCP timing states and poll the network for new XMIT data. */ - - (void)devif_timer(dev, sam_txpoll); - } - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); } /**************************************************************************** @@ -1872,19 +1747,28 @@ static inline void sam_poll_process(FAR struct sam_gmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg) { FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_s *)arg; - net_lock_t state; + struct net_driver_s *dev = &priv->dev; - /* Perform the poll */ + /* Check if the there are any free TX descriptors. We cannot perform the + * TX poll if we do not have buffering for another packet. + */ - state = net_lock(); - sam_poll_process(priv); - net_unlock(state); + net_lock(); + if (sam_txfree(priv) > 0) + { + /* Update TCP timing states and poll the network for new XMIT data. */ + + (void)devif_timer(dev, sam_txpoll); + } + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_poll_expiry @@ -1908,7 +1792,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) { FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -1927,12 +1810,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - sam_poll_process(priv); -#endif } /**************************************************************************** @@ -2062,37 +1939,6 @@ static int sam_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: sam_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 sam_txavail_process(FAR struct sam_gmac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - sam_dopoll(priv); - } -} - /**************************************************************************** * Function: sam_txavail_work * @@ -2110,19 +1956,24 @@ static inline void sam_txavail_process(FAR struct sam_gmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg) { FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("ifup: %d\n", priv->ifup); - state = net_lock(); - sam_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->ifup) + { + /* Poll the network for new XMIT data */ + + sam_dopoll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txavail @@ -2147,7 +1998,6 @@ static int sam_txavail(struct net_driver_s *dev) { FAR struct sam_gmac_s *priv = (FAR struct sam_gmac_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. @@ -2160,21 +2010,6 @@ static int sam_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, sam_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 */ - - sam_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index 8c9c9e0827d..271ab994be9 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -69,11 +69,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -107,13 +103,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_SAMV7_EMAC_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_SAMV7_EMAC_LPWORK) @@ -523,9 +518,7 @@ struct sam_emac_s uint8_t ifup : 1; /* true:ifup false:ifdown */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -588,11 +581,8 @@ static int sam_recvframe(struct sam_emac_s *priv, int qid); static void sam_receive(struct sam_emac_s *priv, int qid); static void sam_txdone(struct sam_emac_s *priv, int qid); static void sam_txerr_interrupt(FAR struct sam_emac_s *priv, int qid); -static inline void sam_interrupt_process(FAR struct sam_emac_s *priv, - int qid); -#ifdef CONFIG_NET_NOINTS + static void sam_interrupt_work(FAR void *arg); -#endif static int sam_emac_interrupt(struct sam_emac_s *priv); #ifdef CONFIG_SAMV7_EMAC0 static int sam_emac0_interrupt(int irq, void *context); @@ -603,16 +593,10 @@ static int sam_emac1_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg); -#endif static void sam_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void sam_poll_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg); -#endif static void sam_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -620,10 +604,7 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...); static int sam_ifup(struct net_driver_s *dev); static int sam_ifdown(struct net_driver_s *dev); -static inline void sam_txavail_process(FAR struct sam_emac_s *priv); -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg); -#endif static int sam_txavail(struct net_driver_s *dev); #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) @@ -2272,26 +2253,25 @@ static void sam_txerr_interrupt(FAR struct sam_emac_s *priv, int qid) } /**************************************************************************** - * Function: sam_interrupt_process + * Function: sam_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 - * quid - Index of the transfer queue that generated the interrupt + * arg - The argument passed when work_queue() was called. * * Returned Value: - * None + * OK on success * * Assumptions: * Ethernet interrupts are disabled * ****************************************************************************/ -static inline void sam_interrupt_process(FAR struct sam_emac_s *priv, int qid) +static void sam_interrupt_work(FAR void *arg) { + FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; uint32_t isr; uint32_t rsr; uint32_t tsr; @@ -2300,6 +2280,10 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv, int qid) uint32_t pending; uint32_t clrbits; + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Read the interrupt status, RX status, and TX status registers. * NOTE that the interrupt status register is cleared by this read. */ @@ -2458,42 +2442,13 @@ static inline void sam_interrupt_process(FAR struct sam_emac_s *priv, int qid) ninfo("Pause TO!\n"); } #endif -} -/**************************************************************************** - * Function: sam_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 sam_interrupt_work(FAR void *arg) -{ - FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - sam_interrupt_process(priv, EMAC_QUEUE_0); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ up_enable_irq(priv->attr->irq); } -#endif /**************************************************************************** * Function: sam_emac_interrupt @@ -2513,7 +2468,6 @@ static void sam_interrupt_work(FAR void *arg) static int sam_emac_interrupt(struct sam_emac_s *priv) { -#ifdef CONFIG_NET_NOINTS uint32_t tsr; /* Disable further Ethernet interrupts. Because Ethernet interrupts are @@ -2557,13 +2511,6 @@ static int sam_emac_interrupt(struct sam_emac_s *priv) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - sam_interrupt_process(priv, EMAC_QUEUE_0); -#endif - return OK; } @@ -2598,41 +2545,6 @@ static int sam_emac1_interrupt(int irq, void *context) } #endif -/**************************************************************************** - * Function: sam_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) -{ - nerr("ERROR: Timeout!\n"); - NETDEV_TXTIMEOUTS(&priv->dev); - - /* Reset the hardware. Just take the interface down, then back up again. */ - - sam_ifdown(&priv->dev); - sam_ifup(&priv->dev); - - /* Then poll the network for new XMIT data */ - - sam_dopoll(priv, EMAC_QUEUE_0); -} - /**************************************************************************** * Function: sam_txtimeout_work * @@ -2650,19 +2562,25 @@ static inline void sam_txtimeout_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txtimeout_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + nerr("ERROR: Timeout!\n"); - state = net_lock(); - sam_txtimeout_process(priv); - net_unlock(state); + net_lock(); + NETDEV_TXTIMEOUTS(&priv->dev); + + /* Reset the hardware. Just take the interface down, then back up again. */ + + sam_ifdown(&priv->dev); + sam_ifup(&priv->dev); + + /* Then poll the network for new XMIT data */ + + sam_dopoll(priv, EMAC_QUEUE_0); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txtimeout_expiry @@ -2687,7 +2605,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_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. @@ -2704,48 +2621,6 @@ static void sam_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, sam_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - sam_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: sam_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 sam_poll_process(FAR struct sam_emac_s *priv) -{ - struct net_driver_s *dev = &priv->dev; - - /* Check if the there are any free TX descriptors. We cannot perform the - * TX poll if we do not have buffering for another packet. - */ - - if (sam_txfree(priv, EMAC_QUEUE_0) > 0) - { - /* Update TCP timing states and poll the network for new XMIT data. */ - - (void)devif_timer(dev, sam_txpoll); - } - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); } /**************************************************************************** @@ -2765,19 +2640,28 @@ static inline void sam_poll_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_poll_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; + struct net_driver_s *dev = &priv->dev; - /* Perform the poll */ + /* Check if the there are any free TX descriptors. We cannot perform the + * TX poll if we do not have buffering for another packet. + */ - state = net_lock(); - sam_poll_process(priv); - net_unlock(state); + net_lock(); + if (sam_txfree(priv, EMAC_QUEUE_0) > 0) + { + /* Update TCP timing states and poll the network for new XMIT data. */ + + (void)devif_timer(dev, sam_txpoll); + } + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, priv); + net_unlock(); } -#endif /**************************************************************************** * Function: sam_poll_expiry @@ -2801,7 +2685,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2820,12 +2703,6 @@ static void sam_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, SAM_WDDELAY, sam_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - sam_poll_process(priv); -#endif } /**************************************************************************** @@ -2963,37 +2840,6 @@ static int sam_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: sam_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 sam_txavail_process(FAR struct sam_emac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - sam_dopoll(priv, EMAC_QUEUE_0); - } -} - /**************************************************************************** * Function: sam_txavail_work * @@ -3011,19 +2857,24 @@ static inline void sam_txavail_process(FAR struct sam_emac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void sam_txavail_work(FAR void *arg) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("ifup: %d\n", priv->ifup); - state = net_lock(); - sam_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->ifup) + { + /* Poll the network for new XMIT data */ + + sam_dopoll(priv, EMAC_QUEUE_0); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: sam_txavail @@ -3048,7 +2899,6 @@ static int sam_txavail(struct net_driver_s *dev) { FAR struct sam_emac_s *priv = (FAR struct sam_emac_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. @@ -3061,21 +2911,6 @@ static int sam_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, sam_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 */ - - sam_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 8bb121237aa..52dcaacd728 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/stm32/stm32_eth.c * - * Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -53,14 +53,11 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include + #if defined(CONFIG_NET_PKT) # include #endif @@ -97,13 +94,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_STM32_ETHMAC_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_STM32_ETHMAC_LPWORK) @@ -587,9 +583,7 @@ struct stm32_ethmac_s uint8_t fduplex : 1; /* Full (vs. half) duplex */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -662,34 +656,26 @@ static int stm32_recvframe(FAR struct stm32_ethmac_s *priv); static void stm32_receive(FAR struct stm32_ethmac_s *priv); static void stm32_freeframe(FAR struct stm32_ethmac_s *priv); static void stm32_txdone(FAR struct stm32_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void stm32_interrupt_work(FAR void *arg); -#endif static int stm32_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static inline void stm32_txtimeout_process(FAR struct stm32_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void stm32_txtimeout_work(FAR void *arg); -#endif static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void stm32_poll_process(FAR struct stm32_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void stm32_poll_work(FAR void *arg); -#endif static void stm32_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ static int stm32_ifup(struct net_driver_s *dev); static int stm32_ifdown(struct net_driver_s *dev); -static inline void stm32_txavail_process(FAR struct stm32_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void stm32_txavail_work(FAR void *arg); -#endif static int stm32_txavail(struct net_driver_s *dev); + #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) static int stm32_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif @@ -1964,27 +1950,33 @@ static void stm32_txdone(FAR struct stm32_ethmac_s *priv) } /**************************************************************************** - * Function: stm32_interrupt_process + * Function: stm32_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 stm32_interrupt_process(FAR struct stm32_ethmac_s *priv) +static void stm32_interrupt_work(FAR void *arg) { + FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)arg; uint32_t dmasr; + DEBUGASSERT(priv); + + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Get the DMA interrupt status bits (no MAC interrupts are expected) */ dmasr = stm32_getreg(STM32_ETH_DMASR); @@ -2056,44 +2048,13 @@ static inline void stm32_interrupt_process(FAR struct stm32_ethmac_s *priv) stm32_putreg(ETH_DMAINT_AIS, STM32_ETH_DMASR); } #endif -} -/**************************************************************************** - * Function: stm32_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 stm32_interrupt_work(FAR void *arg) -{ - FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)arg; - net_lock_t state; - - DEBUGASSERT(priv); - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - stm32_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts at the NVIC */ up_enable_irq(STM32_IRQ_ETH); } -#endif /**************************************************************************** * Function: stm32_interrupt @@ -2115,8 +2076,6 @@ static void stm32_interrupt_work(FAR void *arg) static int stm32_interrupt(int irq, FAR void *context) { FAR struct stm32_ethmac_s *priv = &g_stm32ethmac[0]; - -#ifdef CONFIG_NET_NOINTS uint32_t dmasr; /* Get the DMA interrupt status bits (no MAC interrupts are expected) */ @@ -2152,49 +2111,9 @@ static int stm32_interrupt(int irq, FAR void *context) work_queue(ETHWORK, &priv->work, stm32_interrupt_work, priv, 0); } -#else - /* Process the interrupt now */ - - stm32_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: stm32_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void stm32_txtimeout_process(FAR struct stm32_ethmac_s *priv) -{ - /* Then reset the hardware. Just take the interface down, then back - * up again. - */ - - stm32_ifdown(&priv->dev); - stm32_ifup(&priv->dev); - - /* Then poll for new XMIT data */ - - stm32_dopoll(priv); -} - /**************************************************************************** * Function: stm32_txtimeout_work * @@ -2212,19 +2131,21 @@ static inline void stm32_txtimeout_process(FAR struct stm32_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void stm32_txtimeout_work(FAR void *arg) { FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Reset the hardware. Just take the interface down, then back up again. */ - state = net_lock(); - stm32_txtimeout_process(priv); - net_unlock(state); + net_lock(); + stm32_ifdown(&priv->dev); + stm32_ifup(&priv->dev); + + /* Then poll for new XMIT data */ + + stm32_dopoll(priv); + net_unlock(); } -#endif /**************************************************************************** * Function: stm32_txtimeout_expiry @@ -2251,7 +2172,6 @@ static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...) nerr("ERROR: Timeout!\n"); -#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. @@ -2270,33 +2190,28 @@ static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, stm32_txtimeout_work, priv, 0); - -#else - /* Process the timeout now */ - - stm32_txtimeout_process(priv); -#endif } /**************************************************************************** - * Function: stm32_poll_process + * Function: stm32_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: + * Ethernet interrupts are disabled * ****************************************************************************/ -static inline void stm32_poll_process(FAR struct stm32_ethmac_s *priv) +static void stm32_poll_work(FAR void *arg) { + FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)arg; FAR struct net_driver_s *dev = &priv->dev; /* Check if the next TX descriptor is owned by the Ethernet DMA or CPU. We @@ -2310,6 +2225,7 @@ static inline void stm32_poll_process(FAR struct stm32_ethmac_s *priv) * CONFIG_STM32_ETH_NTXDESC). */ + net_lock(); if ((priv->txhead->tdes0 & ETH_TDES0_OWN) == 0 && priv->txhead->tdes2 == 0) { @@ -2345,39 +2261,9 @@ static inline void stm32_poll_process(FAR struct stm32_ethmac_s *priv) /* Setup the watchdog poll timer again */ (void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry, 1, priv); + net_unlock(); } -/**************************************************************************** - * Function: stm32_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: - * Ethernet interrupts are disabled - * - ****************************************************************************/ - -#ifdef CONFIG_NET_NOINTS -static void stm32_poll_work(FAR void *arg) -{ - FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)arg; - net_lock_t state; - - /* Perform the poll */ - - state = net_lock(); - stm32_poll_process(priv); - net_unlock(state); -} -#endif - /**************************************************************************** * Function: stm32_poll_expiry * @@ -2400,7 +2286,6 @@ static void stm32_poll_expiry(int argc, uint32_t arg, ...) { FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2419,12 +2304,6 @@ static void stm32_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry, 1, (uint32_t)priv); } - -#else - /* Process the interrupt now */ - - stm32_poll_process(priv); -#endif } /**************************************************************************** @@ -2529,37 +2408,6 @@ static int stm32_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: stm32_txavail_process - * - * Description: - * Perform an out-of-cycle poll. - * - * Parameters: - * priv - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - * Assumptions: - * Called in normal user mode - * - ****************************************************************************/ - -static inline void stm32_txavail_process(FAR struct stm32_ethmac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - stm32_dopoll(priv); - } -} - /**************************************************************************** * Function: stm32_txavail_work * @@ -2577,19 +2425,24 @@ static inline void stm32_txavail_process(FAR struct stm32_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void stm32_txavail_work(FAR void *arg) { FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("ifup: %d\n", priv->ifup); - state = net_lock(); - stm32_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->ifup) + { + /* Poll the network for new XMIT data */ + + stm32_dopoll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: stm32_txavail @@ -2614,7 +2467,6 @@ static int stm32_txavail(struct net_driver_s *dev) { FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_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. @@ -2627,21 +2479,6 @@ static int stm32_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, stm32_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 */ - - stm32_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/stm32f7/stm32_ethernet.c b/arch/arm/src/stm32f7/stm32_ethernet.c index 8301f80e5bd..b84e8511ac8 100644 --- a/arch/arm/src/stm32f7/stm32_ethernet.c +++ b/arch/arm/src/stm32f7/stm32_ethernet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/stm32f7/stm32_ethernet.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -52,14 +52,11 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include + #if defined(CONFIG_NET_PKT) # include #endif @@ -98,13 +95,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_STM32F7_ETHMAC_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_STM32F7_ETHMAC_LPWORK) @@ -611,9 +607,7 @@ struct stm32_ethmac_s uint8_t intf; /* Ethernet interface number */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -705,35 +699,26 @@ 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 void stm32_txdone(struct stm32_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void stm32_interrupt_work(void *arg); -#endif static int stm32_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void stm32_txtimeout_process(struct stm32_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void stm32_txtimeout_work(void *arg); -#endif static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void stm32_poll_process(struct stm32_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void stm32_poll_work(void *arg); -#endif static void stm32_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ static int stm32_ifup(struct net_driver_s *dev); static int stm32_ifdown(struct net_driver_s *dev); -static int stm32_ifdown(struct net_driver_s *dev); -static inline void stm32_txavail_process(struct stm32_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void stm32_txavail_work(void *arg); -#endif static int stm32_txavail(struct net_driver_s *dev); + #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) static int stm32_addmac(struct net_driver_s *dev, const uint8_t *mac); #endif @@ -2078,27 +2063,33 @@ static void stm32_txdone(struct stm32_ethmac_s *priv) } /**************************************************************************** - * Function: stm32_interrupt_process + * Function: stm32_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 stm32_interrupt_process(struct stm32_ethmac_s *priv) +static void stm32_interrupt_work(void *arg) { + struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg; uint32_t dmasr; + DEBUGASSERT(priv); + + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Get the DMA interrupt status bits (no MAC interrupts are expected) */ dmasr = stm32_getreg(STM32_ETH_DMASR); @@ -2169,44 +2160,13 @@ static inline void stm32_interrupt_process(struct stm32_ethmac_s *priv) stm32_putreg(ETH_DMAINT_AIS, STM32_ETH_DMASR); } #endif -} -/**************************************************************************** - * Function: stm32_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 stm32_interrupt_work(void *arg) -{ - struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg; - net_lock_t state; - - DEBUGASSERT(priv); - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - stm32_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts at the NVIC */ up_enable_irq(STM32_IRQ_ETH); } -#endif /**************************************************************************** * Function: stm32_interrupt @@ -2228,8 +2188,6 @@ static void stm32_interrupt_work(void *arg) static int stm32_interrupt(int irq, void *context) { struct stm32_ethmac_s *priv = &g_stm32ethmac[0]; - -#ifdef CONFIG_NET_NOINTS uint32_t dmasr; /* Get the DMA interrupt status bits (no MAC interrupts are expected) */ @@ -2265,49 +2223,9 @@ static int stm32_interrupt(int irq, void *context) work_queue(ETHWORK, &priv->work, stm32_interrupt_work, priv, 0); } -#else - /* Process the interrupt now */ - - stm32_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: stm32_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void stm32_txtimeout_process(struct stm32_ethmac_s *priv) -{ - /* Then reset the hardware. Just take the interface down, then back - * up again. - */ - - stm32_ifdown(&priv->dev); - stm32_ifup(&priv->dev); - - /* Then poll for new XMIT data */ - - stm32_dopoll(priv); -} - /**************************************************************************** * Function: stm32_txtimeout_work * @@ -2325,19 +2243,21 @@ static inline void stm32_txtimeout_process(struct stm32_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void stm32_txtimeout_work(void *arg) { struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Reset the hardware. Just take the interface down, then back up again. */ - state = net_lock(); - stm32_txtimeout_process(priv); - net_unlock(state); + net_lock(); + stm32_ifdown(&priv->dev); + stm32_ifup(&priv->dev); + + /* Then poll for new XMIT data */ + + stm32_dopoll(priv); + net_unlock(); } -#endif /**************************************************************************** * Function: stm32_txtimeout_expiry @@ -2364,7 +2284,6 @@ static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...) nerr("ERROR: Timeout!\n"); -#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. @@ -2383,33 +2302,28 @@ static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, stm32_txtimeout_work, priv, 0); - -#else - /* Process the timeout now */ - - stm32_txtimeout_process(priv); -#endif } /**************************************************************************** - * Function: stm32_poll_process + * Function: stm32_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: + * Ethernet interrupts are disabled * ****************************************************************************/ -static inline void stm32_poll_process(struct stm32_ethmac_s *priv) +static void stm32_poll_work(void *arg) { + struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg; struct net_driver_s *dev = &priv->dev; /* Check if the next TX descriptor is owned by the Ethernet DMA or CPU. We @@ -2423,6 +2337,7 @@ static inline void stm32_poll_process(struct stm32_ethmac_s *priv) * CONFIG_STM32F7_ETH_NTXDESC). */ + net_lock(); if ((priv->txhead->tdes0 & ETH_TDES0_OWN) == 0 && priv->txhead->tdes2 == 0) { @@ -2458,39 +2373,9 @@ static inline void stm32_poll_process(struct stm32_ethmac_s *priv) /* Setup the watchdog poll timer again */ (void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry, 1, priv); + net_unlock(); } -/**************************************************************************** - * Function: stm32_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: - * Ethernet interrupts are disabled - * - ****************************************************************************/ - -#ifdef CONFIG_NET_NOINTS -static void stm32_poll_work(void *arg) -{ - struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg; - net_lock_t state; - - /* Perform the poll */ - - state = net_lock(); - stm32_poll_process(priv); - net_unlock(state); -} -#endif - /**************************************************************************** * Function: stm32_poll_expiry * @@ -2513,7 +2398,6 @@ static void stm32_poll_expiry(int argc, uint32_t arg, ...) { struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2532,12 +2416,6 @@ static void stm32_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry, 1, (uint32_t)priv); } - -#else - /* Process the interrupt now */ - - stm32_poll_process(priv); -#endif } /**************************************************************************** @@ -2642,38 +2520,6 @@ static int stm32_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: stm32_txavail_process - * - * Description: - * Perform an out-of-cycle poll. - * - * Parameters: - * priv - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - * Assumptions: - * Called in normal user mode - * - ****************************************************************************/ - -static inline void stm32_txavail_process(struct stm32_ethmac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - stm32_dopoll(priv); - } - -} - /**************************************************************************** * Function: stm32_txavail_work * @@ -2691,19 +2537,24 @@ static inline void stm32_txavail_process(struct stm32_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void stm32_txavail_work(void *arg) { struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("ifup: %d\n", priv->ifup); - state = net_lock(); - stm32_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->ifup) + { + /* Poll the network for new XMIT data */ + + stm32_dopoll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: stm32_txavail @@ -2728,7 +2579,6 @@ static int stm32_txavail(struct net_driver_s *dev) { struct stm32_ethmac_s *priv = (struct stm32_ethmac_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. @@ -2741,21 +2591,6 @@ static int stm32_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, stm32_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 */ - - stm32_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/tiva/lm3s_ethernet.c b/arch/arm/src/tiva/lm3s_ethernet.c index 306276f17ec..b7fd2189c58 100644 --- a/arch/arm/src/tiva/lm3s_ethernet.c +++ b/arch/arm/src/tiva/lm3s_ethernet.c @@ -52,10 +52,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif +#include #include #include @@ -80,13 +77,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_TIVA_ETHERNET_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_TIVA_ETHERNET_LPWORK) @@ -206,9 +202,7 @@ struct tiva_driver_s bool ld_bifup; /* true:ifup false:ifdown */ WDOG_ID ld_txpoll; /* TX poll timer */ WDOG_ID ld_txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s ld_work; /* For deferring work to the work queue */ -#endif /* This holds the information visible to the NuttX network */ @@ -256,24 +250,15 @@ static int tiva_txpoll(struct net_driver_s *dev); static void tiva_receive(struct tiva_driver_s *priv); static void tiva_txdone(struct tiva_driver_s *priv); -static inline void tiva_interrupt_process(struct tiva_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void tiva_interrupt_work(void *arg); -#endif static int tiva_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void tiva_txtimeout_process(struct tiva_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void tiva_txtimeout_work(void *arg); -#endif static void tiva_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void tiva_poll_process(struct tiva_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void tiva_poll_work(void *arg); -#endif static void tiva_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -281,11 +266,7 @@ static void tiva_poll_expiry(int argc, uint32_t arg, ...); static int tiva_ifup(struct net_driver_s *dev); static int tiva_ifdown(struct net_driver_s *dev); - -static inline void tiva_txavail_process(struct tiva_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void tiva_txavail_work(void *arg); -#endif static int tiva_txavail(struct net_driver_s *dev); #ifdef CONFIG_NET_IGMP @@ -963,27 +944,31 @@ static void tiva_txdone(struct tiva_driver_s *priv) } /**************************************************************************** - * Function: tiva_interrupt_process + * Function: tiva_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 tiva_interrupt_process(struct tiva_driver_s *priv) +static void tiva_interrupt_work(void *arg) { + struct tiva_driver_s *priv = (struct tiva_driver_s *)arg; uint32_t ris; + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Read the raw interrupt status register */ ris = tiva_ethin(priv, TIVA_MAC_RIS_OFFSET); @@ -1038,36 +1023,8 @@ static inline void tiva_interrupt_process(struct tiva_driver_s *priv) tiva_txdone(priv); } -} -/**************************************************************************** - * Function: tiva_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 tiva_interrupt_work(void *arg) -{ - struct tiva_driver_s *priv = (struct tiva_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - tiva_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ @@ -1077,7 +1034,6 @@ static void tiva_interrupt_work(void *arg) up_disable_irq(TIVA_IRQ_ETHCON); #endif } -#endif /**************************************************************************** * Function: tiva_interrupt @@ -1107,7 +1063,6 @@ static int tiva_interrupt(int irq, void *context) priv = &g_lm3sdev[0]; #endif -#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. @@ -1145,51 +1100,9 @@ static int tiva_interrupt(int irq, void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->ld_work, tiva_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - tiva_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: tiva_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 tiva_txtimeout_process(struct tiva_driver_s *priv) -{ - /* Increment statistics */ - - nerr("ERROR: Tx timeout\n"); - NETDEV_TXTIMEOUTS(&priv->ld_dev); - - /* Then reset the hardware */ - - DEBUGASSERT(priv->ld_bifup); - tiva_ifdown(&priv->ld_dev); - tiva_ifup(&priv->ld_dev); - - /* Then poll the network for new XMIT data */ - - (void)devif_poll(&priv->ld_dev, tiva_txpoll); -} - /**************************************************************************** * Function: tiva_txtimeout_work * @@ -1207,19 +1120,27 @@ static inline void tiva_txtimeout_process(struct tiva_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void tiva_txtimeout_work(void *arg) { struct tiva_driver_s *priv = (struct tiva_driver_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Increment statistics */ - state = net_lock(); - tiva_txtimeout_process(priv); - net_unlock(state); + net_lock(); + nerr("ERROR: Tx timeout\n"); + NETDEV_TXTIMEOUTS(&priv->ld_dev); + + /* Then reset the hardware */ + + DEBUGASSERT(priv->ld_bifup); + tiva_ifdown(&priv->ld_dev); + tiva_ifup(&priv->ld_dev); + + /* Then poll the network for new XMIT data */ + + (void)devif_poll(&priv->ld_dev, tiva_txpoll); + net_unlock(); } -#endif /**************************************************************************** * Function: tiva_txtimeout_expiry @@ -1244,7 +1165,6 @@ static void tiva_txtimeout_expiry(int argc, wdparm_t arg, ...) { struct tiva_driver_s *priv = (struct tiva_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. @@ -1265,53 +1185,6 @@ static void tiva_txtimeout_expiry(int argc, wdparm_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->ld_work, tiva_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - tiva_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: tiva_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 tiva_poll_process(struct tiva_driver_s *priv) -{ - /* Check if we can send another Tx packet now. The NEWTX bit initiates an - * Ethernet transmission once the packet has been placed in the TX FIFO. - * This bit is cleared once the transmission has been completed. - * - * NOTE: This can cause missing poll cycles and, hence, some timing - * inaccuracies. - */ - - if ((tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX) == 0) - { - /* If so, update TCP timing states and poll the network for new XMIT - * data. - */ - - (void)devif_timer(&priv->ld_dev, tiva_txpoll); - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->ld_txpoll, TIVA_WDDELAY, tiva_poll_expiry, - 1, priv); - } } /**************************************************************************** @@ -1331,19 +1204,35 @@ static inline void tiva_poll_process(struct tiva_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void tiva_poll_work(void *arg) { struct tiva_driver_s *priv = (struct tiva_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Check if we can send another Tx packet now. The NEWTX bit initiates an + * Ethernet transmission once the packet has been placed in the TX FIFO. + * This bit is cleared once the transmission has been completed. + * + * NOTE: This can cause missing poll cycles and, hence, some timing + * inaccuracies. + */ - state = net_lock(); - tiva_poll_process(priv); - net_unlock(state); + net_lock(); + if ((tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX) == 0) + { + /* If so, update TCP timing states and poll the network for new XMIT + * data. + */ + + (void)devif_timer(&priv->ld_dev, tiva_txpoll); + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->ld_txpoll, TIVA_WDDELAY, tiva_poll_expiry, + 1, priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: tiva_poll_expiry @@ -1367,7 +1256,6 @@ static void tiva_poll_expiry(int argc, wdparm_t arg, ...) { struct tiva_driver_s *priv = (struct tiva_driver_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -1386,12 +1274,6 @@ static void tiva_poll_expiry(int argc, wdparm_t arg, ...) (void)wd_start(priv->ld_txpoll, TIVA_WDDELAY, tiva_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - tiva_poll_process(priv); -#endif } /**************************************************************************** @@ -1633,43 +1515,6 @@ static int tiva_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: tiva_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 tiva_txavail_process(struct tiva_driver_s *priv) -{ - /* Ignore the notification if the interface is not yet up or if the Tx FIFO - * hardware is not available at this time. The NEWTX bit initiates an - * Ethernet transmission once the packet has been placed in the TX FIFO. - * This bit is cleared once the transmission has been completed. When the - * transmission completes, tiva_txdone() will be called and the Tx polling - * will occur at that time. - */ - - if (priv->ld_bifup && (tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX) == 0) - { - /* If the interface is up and we can use the Tx FIFO, then poll the network - * for new Tx data - */ - - (void)devif_poll(&priv->ld_dev, tiva_txpoll); - } -} - /**************************************************************************** * Function: tiva_txavail_work * @@ -1687,19 +1532,30 @@ static inline void tiva_txavail_process(struct tiva_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void tiva_txavail_work(void *arg) { struct tiva_driver_s *priv = (struct tiva_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Ignore the notification if the interface is not yet up or if the Tx FIFO + * hardware is not available at this time. The NEWTX bit initiates an + * Ethernet transmission once the packet has been placed in the TX FIFO. + * This bit is cleared once the transmission has been completed. When the + * transmission completes, tiva_txdone() will be called and the Tx polling + * will occur at that time. + */ - state = net_lock(); - tiva_txavail_process(priv); - net_unlock(state); + net_lock(); + if (priv->ld_bifup && (tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX) == 0) + { + /* If the interface is up and we can use the Tx FIFO, then poll the network + * for new Tx data + */ + + (void)devif_poll(&priv->ld_dev, tiva_txpoll); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: tiva_txavail @@ -1724,7 +1580,6 @@ static int tiva_txavail(struct net_driver_s *dev) { struct tiva_driver_s *priv = (struct tiva_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. @@ -1737,21 +1592,6 @@ static int tiva_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->ld_work, tiva_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 */ - - tiva_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/arm/src/tiva/tm4c_ethernet.c b/arch/arm/src/tiva/tm4c_ethernet.c index e00bf6ef31f..a04854879d6 100644 --- a/arch/arm/src/tiva/tm4c_ethernet.c +++ b/arch/arm/src/tiva/tm4c_ethernet.c @@ -53,11 +53,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -102,13 +98,12 @@ * is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE) +#if !defined(CONFIG_SCHED_WORKQUEUE) # error Work queue support is required -#endif +#else -/* Select work queue */ + /* Select work queue */ -#if defined(CONFIG_SCHED_WORKQUEUE) # if defined(CONFIG_TIVA_ETHERNET_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_TIVA_ETHERNET_LPWORK) @@ -631,9 +626,7 @@ struct tiva_ethmac_s uint8_t fduplex : 1; /* Full (vs. half) duplex */ WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s work; /* For deferring work to the work queue */ -#endif #ifdef CONFIG_TIVA_PHY_INTERRUPTS xcpt_t handler; /* Attached PHY interrupt handler */ #endif @@ -709,35 +702,26 @@ static int tiva_recvframe(FAR struct tiva_ethmac_s *priv); static void tiva_receive(FAR struct tiva_ethmac_s *priv); static void tiva_freeframe(FAR struct tiva_ethmac_s *priv); static void tiva_txdone(FAR struct tiva_ethmac_s *priv); -static inline void tiva_interrupt_process(FAR struct tiva_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void tiva_interrupt_work(FAR void *arg); -#endif static int tiva_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static inline void tiva_txtimeout_process(FAR struct tiva_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void tiva_txtimeout_work(FAR void *arg); -#endif static void tiva_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void tiva_poll_process(FAR struct tiva_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS static void tiva_poll_work(FAR void *arg); -#endif static void tiva_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ static int tiva_ifup(struct net_driver_s *dev); static int tiva_ifdown(struct net_driver_s *dev); -static inline void tiva_txavail_process(FAR struct tiva_ethmac_s *priv); -#ifdef CONFIG_NET_NOINTS + static void tiva_txavail_work(FAR void *arg); -#endif static int tiva_txavail(struct net_driver_s *dev); + #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) static int tiva_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif @@ -1994,27 +1978,33 @@ static void tiva_txdone(FAR struct tiva_ethmac_s *priv) } /**************************************************************************** - * Function: tiva_interrupt_process + * Function: tiva_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 tiva_interrupt_process(FAR struct tiva_ethmac_s *priv) +static void tiva_interrupt_work(FAR void *arg) { + FAR struct tiva_ethmac_s *priv = (FAR struct tiva_ethmac_s *)arg; uint32_t dmaris; + DEBUGASSERT(priv); + + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Get the DMA interrupt status bits (no MAC interrupts are expected) */ dmaris = tiva_getreg(TIVA_EMAC_DMARIS); @@ -2086,44 +2076,13 @@ static inline void tiva_interrupt_process(FAR struct tiva_ethmac_s *priv) tiva_putreg(EMAC_DMAINT_AIS, TIVA_EMAC_DMARIS); } #endif -} -/**************************************************************************** - * Function: tiva_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 tiva_interrupt_work(FAR void *arg) -{ - FAR struct tiva_ethmac_s *priv = (FAR struct tiva_ethmac_s *)arg; - net_lock_t state; - - DEBUGASSERT(priv); - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - tiva_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts at the NVIC */ up_enable_irq(TIVA_IRQ_ETHCON); } -#endif /**************************************************************************** * Function: tiva_interrupt @@ -2145,8 +2104,6 @@ static void tiva_interrupt_work(FAR void *arg) static int tiva_interrupt(int irq, FAR void *context) { FAR struct tiva_ethmac_s *priv = &g_tiva_ethmac[0]; - -#ifdef CONFIG_NET_NOINTS uint32_t dmaris; /* Get the raw interrupt status. */ @@ -2182,12 +2139,6 @@ static int tiva_interrupt(int irq, FAR void *context) work_queue(ETHWORK, &priv->work, tiva_interrupt_work, priv, 0); } -#else - /* Process the interrupt now */ - - tiva_interrupt_process(priv); -#endif - #ifdef CONFIG_TIVA_PHY_INTERRUPTS /* Check for pending PHY interrupts */ @@ -2209,38 +2160,6 @@ static int tiva_interrupt(int irq, FAR void *context) return OK; } -/**************************************************************************** - * Function: tiva_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 - * - * Assumptions: - * Global interrupts are disabled by the watchdog logic. - * - ****************************************************************************/ - -static inline void tiva_txtimeout_process(FAR struct tiva_ethmac_s *priv) -{ - /* Reset the hardware. Just take the interface down, then back up again. */ - - tiva_ifdown(&priv->dev); - tiva_ifup(&priv->dev); - - /* Then poll the network for new XMIT data */ - - tiva_dopoll(priv); -} - /**************************************************************************** * Function: tiva_txtimeout_work * @@ -2258,19 +2177,21 @@ static inline void tiva_txtimeout_process(FAR struct tiva_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void tiva_txtimeout_work(FAR void *arg) { FAR struct tiva_ethmac_s *priv = (FAR struct tiva_ethmac_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Reset the hardware. Just take the interface down, then back up again. */ - state = net_lock(); - tiva_txtimeout_process(priv); - net_unlock(state); + net_lock(); + tiva_ifdown(&priv->dev); + tiva_ifup(&priv->dev); + + /* Then poll the network for new XMIT data */ + + tiva_dopoll(priv); + net_unlock(); } -#endif /**************************************************************************** * Function: tiva_txtimeout_expiry @@ -2297,7 +2218,6 @@ static void tiva_txtimeout_expiry(int argc, uint32_t arg, ...) nerr("ERROR: Timeout!\n"); -#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. @@ -2316,33 +2236,28 @@ static void tiva_txtimeout_expiry(int argc, uint32_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->work, tiva_txtimeout_work, priv, 0); - -#else - /* Process the timeout now */ - - tiva_txtimeout_process(priv); -#endif } /**************************************************************************** - * Function: tiva_poll_process + * Function: tiva_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: + * Ethernet interrupts are disabled * ****************************************************************************/ -static inline void tiva_poll_process(FAR struct tiva_ethmac_s *priv) +static void tiva_poll_work(FAR void *arg) { + FAR struct tiva_ethmac_s *priv = (FAR struct tiva_ethmac_s *)arg; FAR struct net_driver_s *dev = &priv->dev; /* Check if the next TX descriptor is owned by the Ethernet DMA or CPU. We @@ -2356,6 +2271,7 @@ static inline void tiva_poll_process(FAR struct tiva_ethmac_s *priv) * CONFIG_TIVA_EMAC_NTXDESC). */ + net_lock(); if ((priv->txhead->tdes0 & EMAC_TDES0_OWN) == 0 && priv->txhead->tdes2 == 0) { @@ -2391,39 +2307,9 @@ static inline void tiva_poll_process(FAR struct tiva_ethmac_s *priv) /* Setup the watchdog poll timer again */ (void)wd_start(priv->txpoll, TIVA_WDDELAY, tiva_poll_expiry, 1, (uint32_t)priv); + net_unlock(); } -/**************************************************************************** - * Function: tiva_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: - * Ethernet interrupts are disabled - * - ****************************************************************************/ - -#ifdef CONFIG_NET_NOINTS -static void tiva_poll_work(FAR void *arg) -{ - FAR struct tiva_ethmac_s *priv = (FAR struct tiva_ethmac_s *)arg; - net_lock_t state; - - /* Perform the poll */ - - state = net_lock(); - tiva_poll_process(priv); - net_unlock(state); -} -#endif - /**************************************************************************** * Function: tiva_poll_expiry * @@ -2446,7 +2332,6 @@ static void tiva_poll_expiry(int argc, uint32_t arg, ...) { FAR struct tiva_ethmac_s *priv = (FAR struct tiva_ethmac_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2465,12 +2350,6 @@ static void tiva_poll_expiry(int argc, uint32_t arg, ...) (void)wd_start(priv->txpoll, TIVA_WDDELAY, tiva_poll_expiry, 1, (uint32_t)priv); } - -#else - /* Process the interrupt now */ - - tiva_poll_process(priv); -#endif } /**************************************************************************** @@ -2575,37 +2454,6 @@ static int tiva_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: tiva_txavail_process - * - * Description: - * Perform an out-of-cycle poll. - * - * Parameters: - * priv - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - * Assumptions: - * Called in normal user mode - * - ****************************************************************************/ - -static inline void tiva_txavail_process(FAR struct tiva_ethmac_s *priv) -{ - ninfo("ifup: %d\n", priv->ifup); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - tiva_dopoll(priv); - } -} - /**************************************************************************** * Function: tiva_txavail_work * @@ -2623,19 +2471,24 @@ static inline void tiva_txavail_process(FAR struct tiva_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void tiva_txavail_work(FAR void *arg) { FAR struct tiva_ethmac_s *priv = (FAR struct tiva_ethmac_s *)arg; - net_lock_t state; - /* Perform the poll */ + ninfo("ifup: %d\n", priv->ifup); - state = net_lock(); - tiva_txavail_process(priv); - net_unlock(state); + /* Ignore the notification if the interface is not yet up */ + + net_lock(); + if (priv->ifup) + { + /* Poll the network for new XMIT data */ + + tiva_dopoll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: tiva_txavail @@ -2660,7 +2513,6 @@ static int tiva_txavail(struct net_driver_s *dev) { FAR struct tiva_ethmac_s *priv = (FAR struct tiva_ethmac_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. @@ -2673,21 +2525,6 @@ static int tiva_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->work, tiva_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 */ - - tiva_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/mips/src/pic32mx/pic32mx-ethernet.c b/arch/mips/src/pic32mx/pic32mx-ethernet.c index 2277e090395..3515635f220 100644 --- a/arch/mips/src/pic32mx/pic32mx-ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx-ethernet.c @@ -55,11 +55,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -90,13 +86,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_PIC32MX_ETHERNET_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_PIC32MX_ETHERNET_LPWORK) @@ -326,9 +321,7 @@ struct pic32mx_driver_s uint32_t pd_inten; /* Shadow copy of INTEN register */ WDOG_ID pd_txpoll; /* TX poll timer */ WDOG_ID pd_txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s pd_work; /* For deferring work to the work queue */ -#endif sq_queue_t pd_freebuffers; /* The free buffer list */ @@ -401,24 +394,15 @@ static void pic32mx_response(struct pic32mx_driver_s *priv); static void pic32mx_rxdone(struct pic32mx_driver_s *priv); static void pic32mx_txdone(struct pic32mx_driver_s *priv); -static inline void pic32mx_interrupt_process(struct pic32mx_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void pic32mx_interrupt_work(void *arg); -#endif static int pic32mx_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void pic32mx_txtimeout_process(struct pic32mx_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void pic32mx_txtimeout_work(void *arg); -#endif static void pic32mx_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void pic32mx_poll_process(struct pic32mx_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void pic32mx_poll_work(void *arg); -#endif static void pic32mx_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -426,10 +410,7 @@ static void pic32mx_poll_expiry(int argc, uint32_t arg, ...); static int pic32mx_ifup(struct net_driver_s *dev); static int pic32mx_ifdown(struct net_driver_s *dev); -static inline void pic32mx_txavail_process(struct pic32mx_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void pic32mx_txavail_work(void *arg); -#endif static int pic32mx_txavail(struct net_driver_s *dev); #ifdef CONFIG_NET_IGMP @@ -1682,27 +1663,31 @@ static void pic32mx_txdone(struct pic32mx_driver_s *priv) } /**************************************************************************** - * Function: pic32mx_interrupt_process + * Function: pic32mx_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 pic32mx_interrupt_process(struct pic32mx_driver_s *priv) +static void pic32mx_interrupt_work(void *arg) { + struct pic32mx_driver_s *priv = (struct pic32mx_driver_s *)arg; uint32_t status; + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Get the interrupt status (zero means no interrupts pending). */ status = pic32mx_getreg(PIC32MX_ETH_IRQ); @@ -1840,36 +1825,7 @@ static inline void pic32mx_interrupt_process(struct pic32mx_driver_s *priv) #else up_clrpend_irq(PIC32MX_IRQSRC_ETH); #endif -} - -/**************************************************************************** - * Function: pic32mx_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 pic32mx_interrupt_work(void *arg) -{ - struct pic32mx_driver_s *priv = (struct pic32mx_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - pic32mx_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ @@ -1879,7 +1835,6 @@ static void pic32mx_interrupt_work(void *arg) up_enable_irq(PIC32MX_IRQSRC_ETH); #endif } -#endif /**************************************************************************** * Function: pic32mx_interrupt @@ -1909,7 +1864,6 @@ static int pic32mx_interrupt(int irq, void *context) priv = &g_ethdrvr[0]; #endif -#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. @@ -1944,54 +1898,9 @@ static int pic32mx_interrupt(int irq, void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->pd_work, pic32mx_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - pic32mx_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: pic32mx_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 pic32mx_txtimeout_process(struct pic32mx_driver_s *priv) -{ - /* Increment statistics and dump debug info */ - - NETDEV_TXTIMEOUTS(&priv->pd_dev); - if (priv->pd_ifup) - { - /* Then reset the hardware. ifup() will reset the interface, then bring - * it back up. - */ - - (void)pic32mx_ifup(&priv->pd_dev); - - /* Then poll the network for new XMIT data (We are guaranteed to have - * a free buffer here). - */ - - pic32mx_poll(priv); - } -} - /**************************************************************************** * Function: pic32mx_txtimeout_work * @@ -2009,19 +1918,31 @@ static inline void pic32mx_txtimeout_process(struct pic32mx_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void pic32mx_txtimeout_work(void *arg) { struct pic32mx_driver_s *priv = (struct pic32mx_driver_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Increment statistics and dump debug info */ - state = net_lock(); - pic32mx_txtimeout_process(priv); - net_unlock(state); + net_lock(); + NETDEV_TXTIMEOUTS(&priv->pd_dev); + if (priv->pd_ifup) + { + /* Then reset the hardware. ifup() will reset the interface, then bring + * it back up. + */ + + (void)pic32mx_ifup(&priv->pd_dev); + + /* Then poll the network for new XMIT data (We are guaranteed to have + * a free buffer here). + */ + + pic32mx_poll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: pic32mx_txtimeout_expiry @@ -2046,7 +1967,6 @@ static void pic32mx_txtimeout_expiry(int argc, wdparm_t arg, ...) { struct pic32mx_driver_s *priv = (struct pic32mx_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. @@ -2067,50 +1987,6 @@ static void pic32mx_txtimeout_expiry(int argc, wdparm_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->pd_work, pic32mx_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - pic32mx_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: pic32mx_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 pic32mx_poll_process(struct pic32mx_driver_s *priv) -{ - /* Check if the next Tx descriptor is available. We cannot perform the Tx - * poll if we are unable to accept another packet for transmission. - */ - - if (pic32mx_txdesc(priv) != NULL) - { - /* 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? - */ - - pic32mx_timerpoll(priv); - } - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->pd_txpoll, PIC32MX_WDDELAY, pic32mx_poll_expiry, - 1, priv); } /**************************************************************************** @@ -2130,19 +2006,31 @@ static inline void pic32mx_poll_process(struct pic32mx_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void pic32mx_poll_work(void *arg) { struct pic32mx_driver_s *priv = (struct pic32mx_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Check if the next Tx descriptor is available. We cannot perform the Tx + * poll if we are unable to accept another packet for transmission. + */ - state = net_lock(); - pic32mx_poll_process(priv); - net_unlock(state); + net_lock(); + if (pic32mx_txdesc(priv) != NULL) + { + /* 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? + */ + + pic32mx_timerpoll(priv); + } + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->pd_txpoll, PIC32MX_WDDELAY, pic32mx_poll_expiry, + 1, priv); + net_unlock(); } -#endif /**************************************************************************** * Function: pic32mx_poll_expiry @@ -2166,7 +2054,6 @@ static void pic32mx_poll_expiry(int argc, wdparm_t arg, ...) { struct pic32mx_driver_s *priv = (struct pic32mx_driver_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2186,12 +2073,6 @@ static void pic32mx_poll_expiry(int argc, wdparm_t arg, ...) (void)wd_start(priv->pd_txpoll, PIC32MX_WDDELAY, pic32mx_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - pic32mx_poll_process(priv); -#endif } /**************************************************************************** @@ -2541,42 +2422,6 @@ static int pic32mx_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: pic32mx_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 pic32mx_txavail_process(struct pic32mx_driver_s *priv) -{ - /* Ignore the notification if the interface is not yet up */ - - if (priv->pd_ifup) - { - /* Check if the next Tx descriptor is available. */ - - if (pic32mx_txdesc(priv) != NULL) - { - /* If so, then poll the network for new XMIT data. First allocate a buffer - * to perform the poll - */ - - pic32mx_poll(priv); - } - } -} - /**************************************************************************** * Function: pic32mx_txavail_work * @@ -2594,19 +2439,29 @@ static inline void pic32mx_txavail_process(struct pic32mx_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void pic32mx_txavail_work(void *arg) { struct pic32mx_driver_s *priv = (struct pic32mx_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Ignore the notification if the interface is not yet up */ - state = net_lock(); - pic32mx_txavail_process(priv); - net_unlock(state); + net_lock(); + if (priv->pd_ifup) + { + /* Check if the next Tx descriptor is available. */ + + if (pic32mx_txdesc(priv) != NULL) + { + /* If so, then poll the network for new XMIT data. First allocate a buffer + * to perform the poll + */ + + pic32mx_poll(priv); + } + } + + net_unlock(); } -#endif /**************************************************************************** * Function: pic32mx_txavail @@ -2631,7 +2486,6 @@ static int pic32mx_txavail(struct net_driver_s *dev) { struct pic32mx_driver_s *priv = (struct pic32mx_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. @@ -2644,21 +2498,6 @@ static int pic32mx_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->pd_work, pic32mx_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 */ - - pic32mx_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/mips/src/pic32mz/pic32mz-ethernet.c b/arch/mips/src/pic32mz/pic32mz-ethernet.c index 356edab2d1d..7eb5c4d54cf 100644 --- a/arch/mips/src/pic32mz/pic32mz-ethernet.c +++ b/arch/mips/src/pic32mz/pic32mz-ethernet.c @@ -55,11 +55,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -90,13 +86,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_PIC32MZ_ETHERNET_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_PIC32MZ_ETHERNET_LPWORK) @@ -353,9 +348,7 @@ struct pic32mz_driver_s uint32_t pd_inten; /* Shadow copy of INTEN register */ WDOG_ID pd_txpoll; /* TX poll timer */ WDOG_ID pd_txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s pd_work; /* For deferring work to the work queue */ -#endif sq_queue_t pd_freebuffers; /* The free buffer list */ @@ -428,24 +421,15 @@ static void pic32mz_response(struct pic32mz_driver_s *priv); static void pic32mz_rxdone(struct pic32mz_driver_s *priv); static void pic32mz_txdone(struct pic32mz_driver_s *priv); -static inline void pic32mz_interrupt_process(struct pic32mz_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void pic32mz_interrupt_work(void *arg); -#endif static int pic32mz_interrupt(int irq, void *context); /* Watchdog timer expirations */ -static inline void pic32mz_txtimeout_process(struct pic32mz_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void pic32mz_txtimeout_work(void *arg); -#endif static void pic32mz_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void pic32mz_poll_process(struct pic32mz_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void pic32mz_poll_work(void *arg); -#endif static void pic32mz_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -453,10 +437,7 @@ static void pic32mz_poll_expiry(int argc, uint32_t arg, ...); static int pic32mz_ifup(struct net_driver_s *dev); static int pic32mz_ifdown(struct net_driver_s *dev); -static inline void pic32mz_txavail_process(struct pic32mz_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void pic32mz_txavail_work(void *arg); -#endif static int pic32mz_txavail(struct net_driver_s *dev); #ifdef CONFIG_NET_IGMP @@ -1709,27 +1690,31 @@ static void pic32mz_txdone(struct pic32mz_driver_s *priv) } /**************************************************************************** - * Function: pic32mz_interrupt_process + * Function: pic32mz_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 pic32mz_interrupt_process(struct pic32mz_driver_s *priv) +static void pic32mz_interrupt_work(void *arg) { + struct pic32mz_driver_s *priv = (struct pic32mz_driver_s *)arg; uint32_t status; + /* Process pending Ethernet interrupts */ + + net_lock(); + /* Get the interrupt status (zero means no interrupts pending). */ status = pic32mz_getreg(PIC32MZ_ETH_IRQ); @@ -1867,36 +1852,7 @@ static inline void pic32mz_interrupt_process(struct pic32mz_driver_s *priv) #else up_clrpend_irq(PIC32MZ_IRQ_ETH); #endif -} - -/**************************************************************************** - * Function: pic32mz_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 pic32mz_interrupt_work(void *arg) -{ - struct pic32mz_driver_s *priv = (struct pic32mz_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - pic32mz_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ @@ -1906,7 +1862,6 @@ static void pic32mz_interrupt_work(void *arg) up_enable_irq(PIC32MZ_IRQ_ETH); #endif } -#endif /**************************************************************************** * Function: pic32mz_interrupt @@ -1936,7 +1891,6 @@ static int pic32mz_interrupt(int irq, void *context) priv = &g_ethdrvr[0]; #endif -#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. @@ -1971,54 +1925,9 @@ static int pic32mz_interrupt(int irq, void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->pd_work, pic32mz_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - pic32mz_interrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: pic32mz_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 pic32mz_txtimeout_process(struct pic32mz_driver_s *priv) -{ - /* Increment statistics and dump debug info */ - - NETDEV_TXTIMEOUTS(&priv->pd_dev); - if (priv->pd_ifup) - { - /* Then reset the hardware. ifup() will reset the interface, then bring - * it back up. - */ - - (void)pic32mz_ifup(&priv->pd_dev); - - /* Then poll the network for new XMIT data (We are guaranteed to have a free - * buffer here). - */ - - pic32mz_poll(priv); - } -} - /**************************************************************************** * Function: pic32mz_txtimeout_work * @@ -2036,19 +1945,31 @@ static inline void pic32mz_txtimeout_process(struct pic32mz_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void pic32mz_txtimeout_work(void *arg) { struct pic32mz_driver_s *priv = (struct pic32mz_driver_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Increment statistics and dump debug info */ - state = net_lock(); - pic32mz_txtimeout_process(priv); - net_unlock(state); + net_lock(); + NETDEV_TXTIMEOUTS(&priv->pd_dev); + if (priv->pd_ifup) + { + /* Then reset the hardware. ifup() will reset the interface, then bring + * it back up. + */ + + (void)pic32mz_ifup(&priv->pd_dev); + + /* Then poll the network for new XMIT data (We are guaranteed to have a free + * buffer here). + */ + + pic32mz_poll(priv); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: pic32mz_txtimeout_expiry @@ -2073,7 +1994,6 @@ static void pic32mz_txtimeout_expiry(int argc, wdparm_t arg, ...) { struct pic32mz_driver_s *priv = (struct pic32mz_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. @@ -2094,50 +2014,6 @@ static void pic32mz_txtimeout_expiry(int argc, wdparm_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->pd_work, pic32mz_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - pic32mz_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: pic32mz_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 pic32mz_poll_process(struct pic32mz_driver_s *priv) -{ - /* Check if the next Tx descriptor is available. We cannot perform the Tx - * poll if we are unable to accept another packet for transmission. - */ - - if (pic32mz_txdesc(priv) != NULL) - { - /* 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? - */ - - pic32mz_timerpoll(priv); - } - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->pd_txpoll, PIC32MZ_WDDELAY, pic32mz_poll_expiry, - 1, priv); } /**************************************************************************** @@ -2157,19 +2033,31 @@ static inline void pic32mz_poll_process(struct pic32mz_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void pic32mz_poll_work(void *arg) { struct pic32mz_driver_s *priv = (struct pic32mz_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Check if the next Tx descriptor is available. We cannot perform the Tx + * poll if we are unable to accept another packet for transmission. + */ - state = net_lock(); - pic32mz_poll_process(priv); - net_unlock(state); + net_lock(); + if (pic32mz_txdesc(priv) != NULL) + { + /* 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? + */ + + pic32mz_timerpoll(priv); + } + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->pd_txpoll, PIC32MZ_WDDELAY, pic32mz_poll_expiry, + 1, priv); + net_unlock(); } -#endif /**************************************************************************** * Function: pic32mz_poll_expiry @@ -2193,7 +2081,6 @@ static void pic32mz_poll_expiry(int argc, wdparm_t arg, ...) { struct pic32mz_driver_s *priv = (struct pic32mz_driver_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2212,12 +2099,6 @@ static void pic32mz_poll_expiry(int argc, wdparm_t arg, ...) (void)wd_start(priv->pd_txpoll, PIC32MZ_WDDELAY, pic32mz_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - pic32mz_poll_process(priv); -#endif } /**************************************************************************** @@ -2573,42 +2454,6 @@ static int pic32mz_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: pic32mz_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 pic32mz_txavail_process(struct pic32mz_driver_s *priv) -{ - /* Ignore the notification if the interface is not yet up */ - - if (priv->pd_ifup) - { - /* Check if the next Tx descriptor is available. */ - - if (pic32mz_txdesc(priv) != NULL) - { - /* If so, then poll the network for new XMIT data. First allocate a buffer - * to perform the poll - */ - - pic32mz_poll(priv); - } - } -} - /**************************************************************************** * Function: pic32mz_txavail_work * @@ -2626,19 +2471,29 @@ static inline void pic32mz_txavail_process(struct pic32mz_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void pic32mz_txavail_work(void *arg) { struct pic32mz_driver_s *priv = (struct pic32mz_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Ignore the notification if the interface is not yet up */ - state = net_lock(); - pic32mz_txavail_process(priv); - net_unlock(state); + net_lock(); + if (priv->pd_ifup) + { + /* Check if the next Tx descriptor is available. */ + + if (pic32mz_txdesc(priv) != NULL) + { + /* If so, then poll the network for new XMIT data. First allocate a buffer + * to perform the poll + */ + + pic32mz_poll(priv); + } + } + + net_unlock(); } -#endif /**************************************************************************** * Function: pic32mz_txavail @@ -2663,7 +2518,6 @@ static int pic32mz_txavail(struct net_driver_s *dev) { struct pic32mz_driver_s *priv = (struct pic32mz_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. @@ -2676,21 +2530,6 @@ static int pic32mz_txavail(struct net_driver_s *dev) work_queue(ETHWORK, &priv->pd_work, pic32mz_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 */ - - pic32mz_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/misoc/src/common/misoc_net.c b/arch/misoc/src/common/misoc_net.c index e23689f8698..85d6e60bbf2 100644 --- a/arch/misoc/src/common/misoc_net.c +++ b/arch/misoc/src/common/misoc_net.c @@ -54,20 +54,18 @@ #include #include #include +#include #include #include #include #include + #include "chip.h" #include "hw/flags.h" #include "hw/ethmac_mem.h" #include "misoc.h" -#ifdef CONFIG_NET_NOINTS -# include -#endif - #ifdef CONFIG_NET_PKT # include #endif @@ -80,8 +78,8 @@ * work queue support is required. */ -#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_HPWORK) -/* REVISIT: The low priority work queue would be preferred if it is avaiable */ +#if !defined(CONFIG_SCHED_HPWORK) + /* REVISIT: The low priority work queue would be preferred if it is avaiable */ # error High priority work queue support is required #endif @@ -119,9 +117,7 @@ struct misoc_net_driver_s bool misoc_net_bifup; /* true:ifup false:ifdown */ WDOG_ID misoc_net_txpoll; /* TX poll timer */ WDOG_ID misoc_net_txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s misoc_net_work; /* For deferring work to the work queue */ -#endif uint8_t *rx0_buf; /* 2 RX and 2 TX buffer */ uint8_t *rx1_buf; @@ -163,35 +159,26 @@ static int misoc_net_txpoll(FAR struct net_driver_s *dev); static void misoc_net_receive(FAR struct misoc_net_driver_s *priv); static void misoc_net_txdone(FAR struct misoc_net_driver_s *priv); -static inline void misoc_net_interrupt_process(FAR struct misoc_net_driver_s *priv); -#ifdef CONFIG_NET_NOINTS + static void misoc_net_interrupt_work(FAR void *arg); -#endif static int misoc_net_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static inline void misoc_net_txtimeout_process(FAR struct misoc_net_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void misoc_net_txtimeout_work(FAR void *arg); -#endif static void misoc_net_txtimeout_expiry(int argc, wdparm_t arg, ...); -static inline void misoc_net_poll_process(FAR struct misoc_net_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void misoc_net_poll_work(FAR void *arg); -#endif static void misoc_net_poll_expiry(int argc, wdparm_t arg, ...); /* NuttX callback functions */ static int misoc_net_ifup(FAR struct net_driver_s *dev); static int misoc_net_ifdown(FAR struct net_driver_s *dev); -static inline void misoc_net_txavail_process(FAR struct misoc_net_driver_s *priv); -#ifdef CONFIG_NET_NOINTS + static void misoc_net_txavail_work(FAR void *arg); -#endif static int misoc_net_txavail(FAR struct net_driver_s *dev); + #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) static int misoc_net_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); #ifdef CONFIG_NET_IGMP @@ -586,28 +573,29 @@ static void misoc_net_txdone(FAR struct misoc_net_driver_s *priv) } /**************************************************************************** - * Function: misoc_net_interrupt_process + * Function: misoc_net_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 misoc_net_interrupt_process(FAR struct misoc_net_driver_s *priv) +static void misoc_net_interrupt_work(FAR void *arg) { - /* Get and clear interrupt status bits */ + FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; - /* Handle interrupts according to status bit settings */ + /* Process pending Ethernet interrupts */ + + net_lock(); /* Check if we received an incoming packet, if so, call misoc_net_receive() */ @@ -626,42 +614,13 @@ static inline void misoc_net_interrupt_process(FAR struct misoc_net_driver_s *pr misoc_net_txdone(priv); ethmac_sram_reader_ev_pending_write(1); } -} -/**************************************************************************** - * Function: misoc_net_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 misoc_net_interrupt_work(FAR void *arg) -{ - FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - misoc_net_interrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet interrupts */ up_enable_irq(ETHMAC_INTERRUPT); } -#endif /**************************************************************************** * Function: misoc_net_interrupt @@ -684,7 +643,6 @@ static int misoc_net_interrupt(int irq, FAR void *context) { FAR struct misoc_net_driver_s *priv = &g_misoc_net[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. @@ -709,47 +667,9 @@ static int misoc_net_interrupt(int irq, FAR void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(HPWORK, &priv->misoc_net_work, misoc_net_interrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - misoc_net_interrupt_process(priv); - -#endif - return OK; } -/**************************************************************************** - * Function: misoc_net_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 misoc_net_txtimeout_process(FAR struct misoc_net_driver_s *priv) -{ - /* Increment statistics and dump debug info */ - - NETDEV_TXTIMEOUTS(priv->misoc_net_dev); - - /* Then reset the hardware */ - - /* Then poll the network for new XMIT data */ - - (void)devif_poll(&priv->misoc_net_dev, misoc_net_txpoll); -} - /**************************************************************************** * Function: misoc_net_txtimeout_work * @@ -767,19 +687,22 @@ static inline void misoc_net_txtimeout_process(FAR struct misoc_net_driver_s *pr * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void misoc_net_txtimeout_work(FAR void *arg) { FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; - net_lock_t state; - /* Process pending Ethernet interrupts */ + /* Increment statistics and dump debug info */ - state = net_lock(); - misoc_net_txtimeout_process(priv); - net_unlock(state); + net_lock(); + NETDEV_TXTIMEOUTS(priv->misoc_net_dev); + + /* Then reset the hardware */ + + /* Then poll the network for new XMIT data */ + + (void)devif_poll(&priv->misoc_net_dev, misoc_net_txpoll); + net_unlock(); } -#endif /**************************************************************************** * Function: misoc_net_txtimeout_expiry @@ -804,7 +727,6 @@ static void misoc_net_txtimeout_expiry(int argc, wdparm_t arg, ...) { FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_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. @@ -821,47 +743,6 @@ static void misoc_net_txtimeout_expiry(int argc, wdparm_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(HPWORK, &priv->misoc_net_work, misoc_net_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - misoc_net_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: misoc_net_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 misoc_net_poll_process(FAR struct misoc_net_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->misoc_net_dev, misoc_net_txpoll); - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, misoc_net_poll_expiry, 1, - (wdparm_t)priv); } /**************************************************************************** @@ -881,19 +762,32 @@ static inline void misoc_net_poll_process(FAR struct misoc_net_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void misoc_net_poll_work(FAR void *arg) { FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; - net_lock_t state; /* Perform the poll */ - state = net_lock(); - misoc_net_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->misoc_net_dev, misoc_net_txpoll); + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, misoc_net_poll_expiry, 1, + (wdparm_t)priv); + + net_unlock(); } -#endif /**************************************************************************** * Function: misoc_net_poll_expiry @@ -917,7 +811,6 @@ static void misoc_net_poll_expiry(int argc, wdparm_t arg, ...) { FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -934,14 +827,9 @@ static void misoc_net_poll_expiry(int argc, wdparm_t arg, ...) * cycle. */ - (void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, misoc_net_poll_expiry, 1, arg); + (void)wd_start(priv->misoc_net_txpoll, MISOC_NET_WDDELAY, + misoc_net_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - misoc_net_poll_process(priv); -#endif } /**************************************************************************** @@ -1044,40 +932,6 @@ static int misoc_net_ifdown(FAR struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: misoc_net_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 misoc_net_txavail_process(FAR struct misoc_net_driver_s *priv) -{ - /* Ignore the notification if the interface is not yet up */ - - if (priv->misoc_net_bifup) - { - /* Check if there is room in the hardware to hold another outgoing packet. */ - - if (!ethmac_sram_reader_ready_read()) - { - /* If so, then poll the network for new XMIT data */ - - (void)devif_poll(&priv->misoc_net_dev, misoc_net_txpoll); - } - } -} - /**************************************************************************** * Function: misoc_net_txavail_work * @@ -1095,19 +949,27 @@ static inline void misoc_net_txavail_process(FAR struct misoc_net_driver_s *priv * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void misoc_net_txavail_work(FAR void *arg) { FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Ignore the notification if the interface is not yet up */ - state = net_lock(); - misoc_net_txavail_process(priv); - net_unlock(state); + net_lock(); + if (priv->misoc_net_bifup) + { + /* Check if there is room in the hardware to hold another outgoing packet. */ + + if (!ethmac_sram_reader_ready_read()) + { + /* If so, then poll the network for new XMIT data */ + + (void)devif_poll(&priv->misoc_net_dev, misoc_net_txpoll); + } + } + + net_unlock(); } -#endif /**************************************************************************** * Function: misoc_net_txavail @@ -1132,7 +994,6 @@ static int misoc_net_txavail(FAR struct net_driver_s *dev) { FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_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. @@ -1145,21 +1006,6 @@ static int misoc_net_txavail(FAR struct net_driver_s *dev) work_queue(HPWORK, &priv->misoc_net_work, misoc_net_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 */ - - misoc_net_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/arch/z80/src/ez80/ez80_emac.c b/arch/z80/src/ez80/ez80_emac.c index 1a4e2129d7b..71f1c4ee9c6 100644 --- a/arch/z80/src/ez80/ez80_emac.c +++ b/arch/z80/src/ez80/ez80_emac.c @@ -56,11 +56,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -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_EZ80_EMAC_HPWORK) # define ETHWORK HPWORK # elif defined(CONFIG_EZ80_EMAC_LPWORK) @@ -346,11 +341,9 @@ struct ez80emac_driver_s WDOG_ID txpoll; /* TX poll timer */ WDOG_ID txtimeout; /* TX timeout timer */ -#ifdef CONFIG_NET_NOINTS struct work_s txwork; /* For deferring Tx-related work to the work queue */ struct work_s rxwork; /* For deferring Rx-related work to the work queue */ struct work_s syswork; /* For deferring system work to the work queue */ -#endif #if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_DEBUG_NET) struct ez80mac_statistics_s stat; @@ -406,36 +399,21 @@ static int ez80emac_receive(struct ez80emac_driver_s *priv); /* Interrupt handling */ -static inline void ez80emac_txinterrupt_process(FAR struct ez80emac_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void ez80emac_txinterrupt_work(FAR void *arg); -#endif static int ez80emac_txinterrupt(int irq, FAR void *context); -static inline void ez80emac_rxinterrupt_process(FAR struct ez80emac_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void ez80emac_rxinterrupt_work(FAR void *arg); -#endif static int ez80emac_rxinterrupt(int irq, FAR void *context); -static inline void ez80emac_sysinterrupt_process(FAR struct ez80emac_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void ez80emac_sysinterrupt_work(FAR void *arg); -#endif static int ez80emac_sysinterrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static inline void ez80emac_txtimeout_process(FAR struct ez80emac_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void ez80emac_txtimeout_work(FAR void *arg); -#endif static void ez80emac_txtimeout_expiry(int argc, uint32_t arg, ...); -static inline void ez80emac_poll_process(FAR struct ez80emac_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void ez80emac_poll_work(FAR void *arg); -#endif static void ez80emac_poll_expiry(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -443,10 +421,7 @@ static void ez80emac_poll_expiry(int argc, uint32_t arg, ...); static int ez80emac_ifup(struct net_driver_s *dev); static int ez80emac_ifdown(struct net_driver_s *dev); -static inline void ez80emac_txavail_process(FAR struct ez80emac_driver_s *priv); -#ifdef CONFIG_NET_NOINTS static void ez80emac_txavail_work(FAR void *arg); -#endif static int ez80emac_txavail(struct net_driver_s *dev); #ifdef CONFIG_NET_IGMP @@ -1475,29 +1450,33 @@ static int ez80emac_receive(struct ez80emac_driver_s *priv) } /**************************************************************************** - * Function: ez80emac_txinterrupt_process + * Function: ez80emac_txinterrupt_work * * Description: - * Tx Interrupt processing. This may be performed either within the - * interrupt handler or on the worker thread, depending upon the configuration + * Perform Tx 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 ez80emac_txinterrupt_process(FAR struct ez80emac_driver_s *priv) +static void ez80emac_txinterrupt_work(FAR void *arg) { + FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; FAR struct ez80emac_desc_s *txhead = priv->txhead; uint8_t regval; uint8_t istat; + /* Process pending Ethernet Tx interrupts */ + + net_lock(); + /* EMAC Tx interrupts: * * EMAC_ISTAT_TXDONE - Bit 0: 1=Transmit done interrupt @@ -1577,42 +1556,13 @@ static inline void ez80emac_txinterrupt_process(FAR struct ez80emac_driver_s *pr wd_cancel(priv->txtimeout); } -} -/**************************************************************************** - * Function: ez80emac_txinterrupt_work - * - * Description: - * Perform Tx 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 ez80emac_txinterrupt_work(FAR void *arg) -{ - FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - ez80emac_txinterrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet Tx interrupts */ up_enable_irq(EZ80_EMACRX_IRQ); } -#endif /**************************************************************************** * Function: ez80emac_txinterrupt @@ -1636,7 +1586,6 @@ static int ez80emac_txinterrupt(int irq, FAR void *context) FAR struct ez80emac_driver_s *priv = &g_emac; uint8_t istat; -#ifdef CONFIG_NET_NOINTS /* Disable further Ethernet Tx interrupts. Because Ethernet interrupts are * also disabled if the TX timeout event occurs, there can be no race * condition here. @@ -1661,38 +1610,35 @@ static int ez80emac_txinterrupt(int irq, FAR void *context) work_queue(ETHWORK, &priv->txwork, ez80emac_txinterrupt_work, priv, 0); -#else - /* Process the interrupt now */ - - ez80emac_txinterrupt_process(priv); -#endif - return OK; } /**************************************************************************** - * Function: ez80emac_rxinterrupt_process + * Function: ez80emac_rxinterrupt_work * * Description: - * Rx Interrupt processing. This may be performed either within the - * interrupt handler or on the worker thread, depending upon the - * configuration + * Perform Rx 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 ez80emac_rxinterrupt_process(FAR struct ez80emac_driver_s *priv) +static void ez80emac_rxinterrupt_work(FAR void *arg) { + FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; uint8_t istat; + /* Process pending Ethernet Rx interrupts */ + + net_lock(); + /* EMAC Rx interrupts: * * EMAC_ISTAT_RXDONE - Bit 3: 1=Receive done interrupt @@ -1713,42 +1659,12 @@ static inline void ez80emac_rxinterrupt_process(FAR struct ez80emac_driver_s *pr /* Process any RX packets pending the RX buffer */ (void)ez80emac_receive(priv); -} - -/**************************************************************************** - * Function: ez80emac_rxinterrupt_work - * - * Description: - * Perform Rx 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 ez80emac_rxinterrupt_work(FAR void *arg) -{ - FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - ez80emac_rxinterrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet Rx interrupts */ up_enable_irq(EZ80_EMACRX_IRQ); } -#endif /**************************************************************************** * Function: ez80emac_rxinterrupt @@ -1771,7 +1687,6 @@ static int ez80emac_rxinterrupt(int irq, FAR void *context) { FAR struct ez80emac_driver_s *priv = &g_emac; -#ifdef CONFIG_NET_NOINTS /* Disable further Ethernet Rx interrupts. Because Ethernet interrupts are * also disabled if the TX timeout event occurs, there can be no race * condition here. @@ -1779,54 +1694,39 @@ static int ez80emac_rxinterrupt(int irq, FAR void *context) up_disable_irq(EZ80_EMACRX_IRQ); - /* TODO: Determine if a TX transfer just completed */ - - { - /* If a TX transfer just completed, then cancel the TX timeout so - * there will be no race condition between any subsequent timeout - * expiration and the deferred interrupt processing. - */ - - wd_cancel(priv->txtimeout); - } - - /* Schedule to perform the interrupt processing on the worker thread. */ + /* Schedule to perform the Rx interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->rxwork, ez80emac_rxinterrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - ez80emac_rxinterrupt_process(priv); -#endif - return OK; } /**************************************************************************** - * Function: ez80emac_sysinterrupt_process + * Function: ez80emac_sysinterrupt_work * * Description: - * System interrupt processing. This may be performed either within the - * interrupt handler or on the worker thread, depending upon the - * configuration + * Perform system 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 ez80emac_sysinterrupt_process(FAR struct ez80emac_driver_s *priv) +static void ez80emac_sysinterrupt_work(FAR void *arg) { + FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; uint8_t events; uint8_t istat; + /* Process pending system interrupts */ + + net_lock(); + /* EMAC system interrupts : * * EMAC_ISTAT_TXFSMERR - Bit 7: 1=Transmit state machine error interrupt @@ -1879,42 +1779,13 @@ static inline void ez80emac_sysinterrupt_process(FAR struct ez80emac_driver_s *p EMAC_STAT(priv, rx_errors); EMAC_STAT(priv, rx_ovrerrors); } -} -/**************************************************************************** - * Function: ez80emac_sysinterrupt_work - * - * Description: - * Perform system 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 ez80emac_sysinterrupt_work(FAR void *arg) -{ - FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; - net_lock_t state; - - /* Process pending Ethernet interrupts */ - - state = net_lock(); - ez80emac_sysinterrupt_process(priv); - net_unlock(state); + net_unlock(); /* Re-enable Ethernet system interrupts */ up_enable_irq(EZ80_EMACSYS_IRQ); } -#endif /**************************************************************************** * Function: ez80emac_sysinterrupt @@ -1937,7 +1808,6 @@ static int ez80emac_sysinterrupt(int irq, FAR void *context) { FAR struct ez80emac_driver_s *priv = &g_emac; -#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. @@ -1945,17 +1815,6 @@ static int ez80emac_sysinterrupt(int irq, FAR void *context) up_disable_irq(EZ80_EMACSYS_IRQ); - /* TODO: Determine if a TX transfer just completed */ - - { - /* If a TX transfer just completed, then cancel the TX timeout so - * there will be no race condition between any subsequent timeout - * expiration and the deferred interrupt processing. - */ - - wd_cancel(priv->txtimeout); - } - /* Cancel any pending poll work */ work_cancel(ETHWORK, &priv->syswork); @@ -1963,54 +1822,9 @@ static int ez80emac_sysinterrupt(int irq, FAR void *context) /* Schedule to perform the interrupt processing on the worker thread. */ work_queue(ETHWORK, &priv->syswork, ez80emac_sysinterrupt_work, priv, 0); - -#else - /* Process the interrupt now */ - - ez80emac_sysinterrupt_process(priv); -#endif - return OK; } -/**************************************************************************** - * Function: ez80emac_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 ez80emac_txtimeout_process(FAR struct ez80emac_driver_s *priv) -{ - irqstate_t flags; - - /* Increment statistics and dump debug info */ - - EMAC_STAT(priv, tx_errors); - EMAC_STAT(priv, tx_timeouts); - - /* Then reset the hardware */ - - flags = enter_critical_section(); - ez80emac_ifdown(&priv->dev); - ez80emac_ifup(&priv->dev); - leave_critical_section(flags); - - /* Then poll the network for new XMIT data */ - - (void)devif_poll(&priv->dev, ez80emac_txpoll); -} - /**************************************************************************** * Function: ez80emac_txtimeout_work * @@ -2028,19 +1842,32 @@ static inline void ez80emac_txtimeout_process(FAR struct ez80emac_driver_s *priv * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void ez80emac_txtimeout_work(FAR void *arg) { FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; - net_lock_t state; + irqstate_t flags; /* Process pending Ethernet interrupts */ - state = net_lock(); - ez80emac_txtimeout_process(priv); - net_unlock(state); + net_lock(); + + /* Increment statistics and dump debug info */ + + EMAC_STAT(priv, tx_errors); + EMAC_STAT(priv, tx_timeouts); + + /* Then reset the hardware */ + + flags = enter_critical_section(); + ez80emac_ifdown(&priv->dev); + ez80emac_ifup(&priv->dev); + leave_critical_section(flags); + + /* Then poll the network for new XMIT data */ + + (void)devif_poll(&priv->dev, ez80emac_txpoll); + net_unlock(); } -#endif /**************************************************************************** * Function: ez80emac_txtimeout_expiry @@ -2065,7 +1892,6 @@ static void ez80emac_txtimeout_expiry(int argc, wdparm_t arg, ...) { FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Disable further Ethernet Tx 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. @@ -2082,39 +1908,6 @@ static void ez80emac_txtimeout_expiry(int argc, wdparm_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ work_queue(ETHWORK, &priv->txwork, ez80emac_txtimeout_work, priv, 0); -#else - /* Process the timeout now */ - - ez80emac_txtimeout_process(priv); -#endif -} - -/**************************************************************************** - * Function: ez80emac_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 ez80emac_poll_process(FAR struct ez80emac_driver_s *priv) -{ - /* Poll the network for new XMIT data */ - - (void)devif_timer(&priv->dev, ez80emac_txpoll); - - /* Setup the watchdog poll timer again */ - - (void)wd_start(priv->txpoll, EMAC_WDDELAY, ez80emac_poll_expiry, 1, priv); } /**************************************************************************** @@ -2134,19 +1927,20 @@ static inline void ez80emac_poll_process(FAR struct ez80emac_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void ez80emac_poll_work(FAR void *arg) { FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Poll the network for new XMIT data */ - state = net_lock(); - ez80emac_poll_process(priv); - net_unlock(state); + net_lock(); + (void)devif_timer(&priv->dev, ez80emac_txpoll); + + /* Setup the watchdog poll timer again */ + + (void)wd_start(priv->txpoll, EMAC_WDDELAY, ez80emac_poll_expiry, 1, priv); + net_unlock(); } -#endif /**************************************************************************** * Function: ez80emac_poll_expiry @@ -2170,7 +1964,6 @@ static void ez80emac_poll_expiry(int argc, wdparm_t arg, ...) { FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; -#ifdef CONFIG_NET_NOINTS /* Is our single work structure available? It may not be if there are * pending interrupt actions. */ @@ -2189,12 +1982,6 @@ static void ez80emac_poll_expiry(int argc, wdparm_t arg, ...) (void)wd_start(priv->txpoll, EMAC_WDDELAY, ez80emac_poll_expiry, 1, arg); } - -#else - /* Process the interrupt now */ - - ez80emac_poll_process(priv); -#endif } /**************************************************************************** @@ -2343,37 +2130,6 @@ static int ez80emac_ifdown(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Function: ez80emac_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 ez80emac_txavail_process(FAR struct ez80emac_driver_s *priv) -{ - /* Ignore the notification if the interface is not yet up */ - - if (priv->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->dev, ez80emac_txpoll); - } -} - /**************************************************************************** * Function: ez80emac_txavail_work * @@ -2391,19 +2147,24 @@ static inline void ez80emac_txavail_process(FAR struct ez80emac_driver_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS static void ez80emac_txavail_work(FAR void *arg) { FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)arg; - net_lock_t state; - /* Perform the poll */ + /* Ignore the notification if the interface is not yet up */ - state = net_lock(); - ez80emac_txavail_process(priv); - net_unlock(state); + net_lock(); + if (priv->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->dev, ez80emac_txpoll); + } + + net_unlock(); } -#endif /**************************************************************************** * Function: ez80emac_txavail @@ -2428,7 +2189,6 @@ static int ez80emac_txavail(FAR struct net_driver_s *dev) { FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_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. @@ -2441,21 +2201,6 @@ static int ez80emac_txavail(FAR struct net_driver_s *dev) work_queue(ETHWORK, &priv->syswork, ez80emac_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 */ - - ez80emac_txavail_process(priv); - leave_critical_section(flags); -#endif - return OK; } diff --git a/configs/c5471evm/httpd/defconfig b/configs/c5471evm/httpd/defconfig index a9b069c742d..86eb3afb030 100644 --- a/configs/c5471evm/httpd/defconfig +++ b/configs/c5471evm/httpd/defconfig @@ -477,7 +477,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/c5471evm/nettest/defconfig b/configs/c5471evm/nettest/defconfig index 2e7f35e1fba..ec8f1de7446 100644 --- a/configs/c5471evm/nettest/defconfig +++ b/configs/c5471evm/nettest/defconfig @@ -470,7 +470,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/c5471evm/nsh/defconfig b/configs/c5471evm/nsh/defconfig index 96874ffa0fe..8608b844207 100644 --- a/configs/c5471evm/nsh/defconfig +++ b/configs/c5471evm/nsh/defconfig @@ -478,7 +478,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/cloudctrl/nsh/defconfig b/configs/cloudctrl/nsh/defconfig index 5a0edc77d78..41f4db58a8d 100644 --- a/configs/cloudctrl/nsh/defconfig +++ b/configs/cloudctrl/nsh/defconfig @@ -915,7 +915,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/dk-tm4c129x/README.txt b/configs/dk-tm4c129x/README.txt index 3ef95b3e26d..bf81eb4f73b 100644 --- a/configs/dk-tm4c129x/README.txt +++ b/configs/dk-tm4c129x/README.txt @@ -226,7 +226,6 @@ Networking Support Networking Support CONFIG_NET=y : Enable Neworking CONFIG_NET_ETHERNET=y : Support Ethernet data link - CONFIG_NET_NOINTS=y : Should operative at non-interrupt level CONFIG_NET_SOCKOPTS=y : Enable socket operations CONFIG_NET_ETH_MTU=590 : Maximum packet size (MTU) 1518 is more standard CONFIG_NET_ETH_TCP_RECVWNDO=536 : Should be the same as CONFIG_NET_ETH_MTU diff --git a/configs/dk-tm4c129x/ipv6/defconfig b/configs/dk-tm4c129x/ipv6/defconfig index 8174d2adba4..7e6a993b1d8 100644 --- a/configs/dk-tm4c129x/ipv6/defconfig +++ b/configs/dk-tm4c129x/ipv6/defconfig @@ -676,7 +676,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/dk-tm4c129x/nsh/defconfig b/configs/dk-tm4c129x/nsh/defconfig index 56660ab1f51..741b7af168c 100644 --- a/configs/dk-tm4c129x/nsh/defconfig +++ b/configs/dk-tm4c129x/nsh/defconfig @@ -678,7 +678,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/eagle100/httpd/defconfig b/configs/eagle100/httpd/defconfig index 6ff58e8c7d8..2d955bbcabd 100644 --- a/configs/eagle100/httpd/defconfig +++ b/configs/eagle100/httpd/defconfig @@ -609,7 +609,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/eagle100/nettest/defconfig b/configs/eagle100/nettest/defconfig index a0aa41a4d47..7cf58f403b0 100644 --- a/configs/eagle100/nettest/defconfig +++ b/configs/eagle100/nettest/defconfig @@ -601,7 +601,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/eagle100/nsh/defconfig b/configs/eagle100/nsh/defconfig index ca7b4701fee..af982ff4878 100644 --- a/configs/eagle100/nsh/defconfig +++ b/configs/eagle100/nsh/defconfig @@ -643,7 +643,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/eagle100/thttpd/defconfig b/configs/eagle100/thttpd/defconfig index 9e597ffb4d7..05d4be5f54f 100644 --- a/configs/eagle100/thttpd/defconfig +++ b/configs/eagle100/thttpd/defconfig @@ -597,7 +597,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ekk-lm3s9b96/nsh/defconfig b/configs/ekk-lm3s9b96/nsh/defconfig index 080a0c5680b..fb38935f6e5 100644 --- a/configs/ekk-lm3s9b96/nsh/defconfig +++ b/configs/ekk-lm3s9b96/nsh/defconfig @@ -632,7 +632,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ez80f910200zco/dhcpd/defconfig b/configs/ez80f910200zco/dhcpd/defconfig index 126bf740267..72dcc5ecfae 100644 --- a/configs/ez80f910200zco/dhcpd/defconfig +++ b/configs/ez80f910200zco/dhcpd/defconfig @@ -500,7 +500,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ez80f910200zco/httpd/defconfig b/configs/ez80f910200zco/httpd/defconfig index 4177c0bc9bc..b74d62ba788 100644 --- a/configs/ez80f910200zco/httpd/defconfig +++ b/configs/ez80f910200zco/httpd/defconfig @@ -509,7 +509,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ez80f910200zco/nettest/defconfig b/configs/ez80f910200zco/nettest/defconfig index 99250b29d52..e4fe5af40f8 100644 --- a/configs/ez80f910200zco/nettest/defconfig +++ b/configs/ez80f910200zco/nettest/defconfig @@ -501,7 +501,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ez80f910200zco/nsh/defconfig b/configs/ez80f910200zco/nsh/defconfig index 04dda2443e3..2b235129216 100644 --- a/configs/ez80f910200zco/nsh/defconfig +++ b/configs/ez80f910200zco/nsh/defconfig @@ -512,7 +512,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ez80f910200zco/poll/defconfig b/configs/ez80f910200zco/poll/defconfig index 770d89d9bb5..a7b22914de9 100644 --- a/configs/ez80f910200zco/poll/defconfig +++ b/configs/ez80f910200zco/poll/defconfig @@ -511,7 +511,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/fire-stm32v2/nsh/defconfig b/configs/fire-stm32v2/nsh/defconfig index 8bc46205489..f2c01e8a699 100644 --- a/configs/fire-stm32v2/nsh/defconfig +++ b/configs/fire-stm32v2/nsh/defconfig @@ -971,7 +971,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/freedom-k64f/README.txt b/configs/freedom-k64f/README.txt index 4dd8932aada..3ea647ad580 100644 --- a/configs/freedom-k64f/README.txt +++ b/configs/freedom-k64f/README.txt @@ -193,7 +193,6 @@ Networking Support Networking Support CONFIG_NET=y : Enable Neworking CONFIG_NET_ETHERNET=y : Support Ethernet data link - CONFIG_NET_NOINTS=y : Should operative at non-interrupt level CONFIG_NET_SOCKOPTS=y : Enable socket operations CONFIG_NET_ETH_MTU=590 : Maximum packet size (MTU) 1518 is more standard CONFIG_NET_ETH_TCP_RECVWNDO=536 : Should be the same as CONFIG_NET_ETH_MTU diff --git a/configs/freedom-k64f/netnsh/defconfig b/configs/freedom-k64f/netnsh/defconfig index 94d319b5b7d..d04232162c7 100644 --- a/configs/freedom-k64f/netnsh/defconfig +++ b/configs/freedom-k64f/netnsh/defconfig @@ -644,7 +644,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lincoln60/netnsh/defconfig b/configs/lincoln60/netnsh/defconfig index 137e5f3621d..0d956981f65 100644 --- a/configs/lincoln60/netnsh/defconfig +++ b/configs/lincoln60/netnsh/defconfig @@ -623,7 +623,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lincoln60/thttpd-binfs/defconfig b/configs/lincoln60/thttpd-binfs/defconfig index 8a0a858cd2b..abfe74e5622 100644 --- a/configs/lincoln60/thttpd-binfs/defconfig +++ b/configs/lincoln60/thttpd-binfs/defconfig @@ -602,7 +602,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lm3s6432-s2e/nsh/defconfig b/configs/lm3s6432-s2e/nsh/defconfig index f69161c733a..92f2f689648 100644 --- a/configs/lm3s6432-s2e/nsh/defconfig +++ b/configs/lm3s6432-s2e/nsh/defconfig @@ -623,7 +623,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lm3s6965-ek/discover/defconfig b/configs/lm3s6965-ek/discover/defconfig index f11ccb5d9d4..91a26e61e77 100644 --- a/configs/lm3s6965-ek/discover/defconfig +++ b/configs/lm3s6965-ek/discover/defconfig @@ -637,7 +637,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lm3s6965-ek/nsh/defconfig b/configs/lm3s6965-ek/nsh/defconfig index f11ccb5d9d4..91a26e61e77 100644 --- a/configs/lm3s6965-ek/nsh/defconfig +++ b/configs/lm3s6965-ek/nsh/defconfig @@ -637,7 +637,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lm3s6965-ek/tcpecho/defconfig b/configs/lm3s6965-ek/tcpecho/defconfig index 8a2f08ebc52..6945c7a71f9 100644 --- a/configs/lm3s6965-ek/tcpecho/defconfig +++ b/configs/lm3s6965-ek/tcpecho/defconfig @@ -607,7 +607,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lm3s8962-ek/nsh/defconfig b/configs/lm3s8962-ek/nsh/defconfig index c631ca1bce5..45be5effd88 100644 --- a/configs/lm3s8962-ek/nsh/defconfig +++ b/configs/lm3s8962-ek/nsh/defconfig @@ -647,7 +647,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lpcxpresso-lpc1768/dhcpd/defconfig b/configs/lpcxpresso-lpc1768/dhcpd/defconfig index 7b0c989057a..8df48ef27ef 100644 --- a/configs/lpcxpresso-lpc1768/dhcpd/defconfig +++ b/configs/lpcxpresso-lpc1768/dhcpd/defconfig @@ -591,7 +591,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lpcxpresso-lpc1768/nsh/defconfig b/configs/lpcxpresso-lpc1768/nsh/defconfig index 6cf2f993789..1ebf3b8ae95 100644 --- a/configs/lpcxpresso-lpc1768/nsh/defconfig +++ b/configs/lpcxpresso-lpc1768/nsh/defconfig @@ -663,7 +663,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/lpcxpresso-lpc1768/thttpd/defconfig b/configs/lpcxpresso-lpc1768/thttpd/defconfig index 23256edfa74..4d16ce1734a 100644 --- a/configs/lpcxpresso-lpc1768/thttpd/defconfig +++ b/configs/lpcxpresso-lpc1768/thttpd/defconfig @@ -594,7 +594,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/misoc/hello/defconfig b/configs/misoc/hello/defconfig index 4bda51d0162..b785983a231 100644 --- a/configs/misoc/hello/defconfig +++ b/configs/misoc/hello/defconfig @@ -481,7 +481,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/moxa/nsh/defconfig b/configs/moxa/nsh/defconfig index d57afb29b64..ca520d5eb9d 100644 --- a/configs/moxa/nsh/defconfig +++ b/configs/moxa/nsh/defconfig @@ -514,7 +514,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ntosd-dm320/nettest/defconfig b/configs/ntosd-dm320/nettest/defconfig index b1f9e6730d0..bd68dc951a9 100644 --- a/configs/ntosd-dm320/nettest/defconfig +++ b/configs/ntosd-dm320/nettest/defconfig @@ -509,7 +509,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ntosd-dm320/nsh/defconfig b/configs/ntosd-dm320/nsh/defconfig index 9c16b857f53..a2c9d13163f 100644 --- a/configs/ntosd-dm320/nsh/defconfig +++ b/configs/ntosd-dm320/nsh/defconfig @@ -525,7 +525,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ntosd-dm320/poll/defconfig b/configs/ntosd-dm320/poll/defconfig index 5eac34cfe9f..99ac30997cd 100644 --- a/configs/ntosd-dm320/poll/defconfig +++ b/configs/ntosd-dm320/poll/defconfig @@ -520,7 +520,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ntosd-dm320/thttpd/defconfig b/configs/ntosd-dm320/thttpd/defconfig index d6a53fa9989..b9cc758765c 100644 --- a/configs/ntosd-dm320/thttpd/defconfig +++ b/configs/ntosd-dm320/thttpd/defconfig @@ -513,7 +513,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ntosd-dm320/udp/defconfig b/configs/ntosd-dm320/udp/defconfig index 01d6266cf2e..b34efac745b 100644 --- a/configs/ntosd-dm320/udp/defconfig +++ b/configs/ntosd-dm320/udp/defconfig @@ -508,7 +508,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/ntosd-dm320/webserver/defconfig b/configs/ntosd-dm320/webserver/defconfig index d20b40829f9..40ff3fe1bf7 100644 --- a/configs/ntosd-dm320/webserver/defconfig +++ b/configs/ntosd-dm320/webserver/defconfig @@ -516,7 +516,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-lpc1766stk/ftpc/defconfig b/configs/olimex-lpc1766stk/ftpc/defconfig index 306ef5d70ec..cdb8d28d0ad 100644 --- a/configs/olimex-lpc1766stk/ftpc/defconfig +++ b/configs/olimex-lpc1766stk/ftpc/defconfig @@ -630,7 +630,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-lpc1766stk/hidmouse/defconfig b/configs/olimex-lpc1766stk/hidmouse/defconfig index 93c3572e913..82273f07711 100644 --- a/configs/olimex-lpc1766stk/hidmouse/defconfig +++ b/configs/olimex-lpc1766stk/hidmouse/defconfig @@ -620,7 +620,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-lpc1766stk/nettest/defconfig b/configs/olimex-lpc1766stk/nettest/defconfig index cf81bb61a98..0e78b002597 100644 --- a/configs/olimex-lpc1766stk/nettest/defconfig +++ b/configs/olimex-lpc1766stk/nettest/defconfig @@ -592,7 +592,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-lpc1766stk/nsh/defconfig b/configs/olimex-lpc1766stk/nsh/defconfig index e228e367017..f0989e352b9 100644 --- a/configs/olimex-lpc1766stk/nsh/defconfig +++ b/configs/olimex-lpc1766stk/nsh/defconfig @@ -632,7 +632,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-lpc1766stk/slip-httpd/defconfig b/configs/olimex-lpc1766stk/slip-httpd/defconfig index 1c7e6b2eded..ad62a7308b1 100644 --- a/configs/olimex-lpc1766stk/slip-httpd/defconfig +++ b/configs/olimex-lpc1766stk/slip-httpd/defconfig @@ -558,7 +558,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-lpc1766stk/thttpd-binfs/defconfig b/configs/olimex-lpc1766stk/thttpd-binfs/defconfig index d3135f2794b..61584a923f2 100644 --- a/configs/olimex-lpc1766stk/thttpd-binfs/defconfig +++ b/configs/olimex-lpc1766stk/thttpd-binfs/defconfig @@ -602,7 +602,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig b/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig index d65819e802d..a3f8045c97b 100644 --- a/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig +++ b/configs/olimex-lpc1766stk/thttpd-nxflat/defconfig @@ -595,7 +595,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-lpc1766stk/zmodem/defconfig b/configs/olimex-lpc1766stk/zmodem/defconfig index 4866dca3964..9ce6ae44c06 100644 --- a/configs/olimex-lpc1766stk/zmodem/defconfig +++ b/configs/olimex-lpc1766stk/zmodem/defconfig @@ -647,7 +647,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-stm32-e407/discover/defconfig b/configs/olimex-stm32-e407/discover/defconfig index dd23f1554dd..60f0cc16e59 100644 --- a/configs/olimex-stm32-e407/discover/defconfig +++ b/configs/olimex-stm32-e407/discover/defconfig @@ -897,7 +897,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-stm32-e407/netnsh/defconfig b/configs/olimex-stm32-e407/netnsh/defconfig index 6ae452f562a..72c27015895 100644 --- a/configs/olimex-stm32-e407/netnsh/defconfig +++ b/configs/olimex-stm32-e407/netnsh/defconfig @@ -899,7 +899,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-stm32-e407/telnetd/defconfig b/configs/olimex-stm32-e407/telnetd/defconfig index 6b17db7614a..10a34c4e924 100644 --- a/configs/olimex-stm32-e407/telnetd/defconfig +++ b/configs/olimex-stm32-e407/telnetd/defconfig @@ -899,7 +899,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-stm32-e407/webserver/defconfig b/configs/olimex-stm32-e407/webserver/defconfig index 45d097fc161..2e78b260222 100644 --- a/configs/olimex-stm32-e407/webserver/defconfig +++ b/configs/olimex-stm32-e407/webserver/defconfig @@ -897,7 +897,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-stm32-p107/nsh/defconfig b/configs/olimex-stm32-p107/nsh/defconfig index c5bc04f46dc..962d6ca2d92 100644 --- a/configs/olimex-stm32-p107/nsh/defconfig +++ b/configs/olimex-stm32-p107/nsh/defconfig @@ -905,7 +905,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-stm32-p207/nsh/defconfig b/configs/olimex-stm32-p207/nsh/defconfig index 2b65965724c..86e6c4216da 100644 --- a/configs/olimex-stm32-p207/nsh/defconfig +++ b/configs/olimex-stm32-p207/nsh/defconfig @@ -949,7 +949,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/olimex-strp711/nettest/defconfig b/configs/olimex-strp711/nettest/defconfig index 97e3515f2a1..d89e0bf5d34 100644 --- a/configs/olimex-strp711/nettest/defconfig +++ b/configs/olimex-strp711/nettest/defconfig @@ -551,7 +551,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/pic32mx-starterkit/nsh2/defconfig b/configs/pic32mx-starterkit/nsh2/defconfig index 1805838d321..77681664733 100644 --- a/configs/pic32mx-starterkit/nsh2/defconfig +++ b/configs/pic32mx-starterkit/nsh2/defconfig @@ -673,7 +673,6 @@ CONFIG_RAMLOG_SYSLOG=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/pic32mx7mmb/nsh/defconfig b/configs/pic32mx7mmb/nsh/defconfig index 5f406d3360a..aadcf0e8954 100644 --- a/configs/pic32mx7mmb/nsh/defconfig +++ b/configs/pic32mx7mmb/nsh/defconfig @@ -736,7 +736,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sam4e-ek/nsh/defconfig b/configs/sam4e-ek/nsh/defconfig index a2a5a4e5f83..fc74521d7b0 100644 --- a/configs/sam4e-ek/nsh/defconfig +++ b/configs/sam4e-ek/nsh/defconfig @@ -736,7 +736,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sam4e-ek/nxwm/defconfig b/configs/sam4e-ek/nxwm/defconfig index 734743e820a..e886128820b 100644 --- a/configs/sam4e-ek/nxwm/defconfig +++ b/configs/sam4e-ek/nxwm/defconfig @@ -795,7 +795,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sam4e-ek/usbnsh/defconfig b/configs/sam4e-ek/usbnsh/defconfig index 572206bc8b6..af76f907004 100644 --- a/configs/sam4e-ek/usbnsh/defconfig +++ b/configs/sam4e-ek/usbnsh/defconfig @@ -776,7 +776,6 @@ CONFIG_SYSLOG_DEVPATH="/dev/ttyS0" CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sama5d3-xplained/bridge/defconfig b/configs/sama5d3-xplained/bridge/defconfig index ea5c1c4fc61..51c672c0665 100644 --- a/configs/sama5d3-xplained/bridge/defconfig +++ b/configs/sama5d3-xplained/bridge/defconfig @@ -698,7 +698,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sama5d4-ek/bridge/defconfig b/configs/sama5d4-ek/bridge/defconfig index 8e650abaadc..134be3f6866 100644 --- a/configs/sama5d4-ek/bridge/defconfig +++ b/configs/sama5d4-ek/bridge/defconfig @@ -725,7 +725,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sama5d4-ek/ipv6/defconfig b/configs/sama5d4-ek/ipv6/defconfig index 2d2a202cc5c..9f9c9506bed 100644 --- a/configs/sama5d4-ek/ipv6/defconfig +++ b/configs/sama5d4-ek/ipv6/defconfig @@ -908,7 +908,6 @@ CONFIG_RAMLOG_SYSLOG=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sama5d4-ek/nsh/defconfig b/configs/sama5d4-ek/nsh/defconfig index 9857438af8c..ef3a9884b44 100644 --- a/configs/sama5d4-ek/nsh/defconfig +++ b/configs/sama5d4-ek/nsh/defconfig @@ -910,7 +910,6 @@ CONFIG_RAMLOG_SYSLOG=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sama5d4-ek/nxwm/defconfig b/configs/sama5d4-ek/nxwm/defconfig index 56265b311b7..c13d4c27b0a 100644 --- a/configs/sama5d4-ek/nxwm/defconfig +++ b/configs/sama5d4-ek/nxwm/defconfig @@ -879,7 +879,6 @@ CONFIG_RAMLOG_SYSLOG=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index 7d31d20e9d5..ddd198f68e5 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -388,7 +388,6 @@ Selecting the GMAC peripheral Networking Support CONFIG_NET=y : Enable Neworking - CONFIG_NET_NOINTS=y : Use the work queue, not interrupts for processing CONFIG_NET_SOCKOPTS=y : Enable socket operations CONFIG_NET_ETH_MTU=562 : Maximum packet size (MTU) 1518 is more standard CONFIG_NET_ETH_TCP_RECVWNDO=562 : Should be the same as CONFIG_NET_ETH_MTU diff --git a/configs/same70-xplained/netnsh/defconfig b/configs/same70-xplained/netnsh/defconfig index 57c0c013236..1b1b7be836c 100644 --- a/configs/same70-xplained/netnsh/defconfig +++ b/configs/same70-xplained/netnsh/defconfig @@ -768,7 +768,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index f84223d5b88..e370dabc729 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -704,7 +704,6 @@ Selecting the GMAC peripheral Networking Support CONFIG_NET=y : Enable Neworking - CONFIG_NET_NOINTS=y : Use the work queue, not interrupts for processing CONFIG_NET_SOCKOPTS=y : Enable socket operations CONFIG_NET_ETH_MTU=562 : Maximum packet size (MTU) 1518 is more standard CONFIG_NET_ETH_TCP_RECVWNDO=562 : Should be the same as CONFIG_NET_ETH_MTU diff --git a/configs/samv71-xult/netnsh/defconfig b/configs/samv71-xult/netnsh/defconfig index 24f50e8e686..6a005c6e5d6 100644 --- a/configs/samv71-xult/netnsh/defconfig +++ b/configs/samv71-xult/netnsh/defconfig @@ -771,7 +771,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/samv71-xult/vnc/defconfig b/configs/samv71-xult/vnc/defconfig index a37393cef6b..90d26f16002 100644 --- a/configs/samv71-xult/vnc/defconfig +++ b/configs/samv71-xult/vnc/defconfig @@ -772,7 +772,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/samv71-xult/vnxwm/defconfig b/configs/samv71-xult/vnxwm/defconfig index b3fa15e3060..64ebea05db0 100644 --- a/configs/samv71-xult/vnxwm/defconfig +++ b/configs/samv71-xult/vnxwm/defconfig @@ -775,7 +775,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/shenzhou/nsh/defconfig b/configs/shenzhou/nsh/defconfig index 5247928fbd1..1fc93461f1b 100644 --- a/configs/shenzhou/nsh/defconfig +++ b/configs/shenzhou/nsh/defconfig @@ -900,7 +900,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/shenzhou/nxwm/defconfig b/configs/shenzhou/nxwm/defconfig index 31a95d3293e..093f2bd80c4 100644 --- a/configs/shenzhou/nxwm/defconfig +++ b/configs/shenzhou/nxwm/defconfig @@ -968,7 +968,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/shenzhou/thttpd/defconfig b/configs/shenzhou/thttpd/defconfig index 4c2456192b4..defbcf3cf84 100644 --- a/configs/shenzhou/thttpd/defconfig +++ b/configs/shenzhou/thttpd/defconfig @@ -931,7 +931,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sim/nettest/defconfig b/configs/sim/nettest/defconfig index aebf0775866..7bce3f6cb12 100644 --- a/configs/sim/nettest/defconfig +++ b/configs/sim/nettest/defconfig @@ -388,7 +388,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sim/udgram/defconfig b/configs/sim/udgram/defconfig index ae87965d958..e85867d7cb5 100644 --- a/configs/sim/udgram/defconfig +++ b/configs/sim/udgram/defconfig @@ -402,7 +402,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/sim/ustream/defconfig b/configs/sim/ustream/defconfig index fabbc20ff15..f495bcea50d 100644 --- a/configs/sim/ustream/defconfig +++ b/configs/sim/ustream/defconfig @@ -402,7 +402,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3220g-eval/dhcpd/defconfig b/configs/stm3220g-eval/dhcpd/defconfig index ec11cf50fdd..92d9dac8c85 100644 --- a/configs/stm3220g-eval/dhcpd/defconfig +++ b/configs/stm3220g-eval/dhcpd/defconfig @@ -872,7 +872,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3220g-eval/nettest/defconfig b/configs/stm3220g-eval/nettest/defconfig index 7867ba3f49e..e66a156f925 100644 --- a/configs/stm3220g-eval/nettest/defconfig +++ b/configs/stm3220g-eval/nettest/defconfig @@ -872,7 +872,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3220g-eval/nsh/defconfig b/configs/stm3220g-eval/nsh/defconfig index 7075a4c7359..ce18adbe6d6 100644 --- a/configs/stm3220g-eval/nsh/defconfig +++ b/configs/stm3220g-eval/nsh/defconfig @@ -939,7 +939,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3220g-eval/nsh2/defconfig b/configs/stm3220g-eval/nsh2/defconfig index 1ed45de59e1..69fb3cd8887 100644 --- a/configs/stm3220g-eval/nsh2/defconfig +++ b/configs/stm3220g-eval/nsh2/defconfig @@ -940,7 +940,6 @@ CONFIG_RAMLOG_SYSLOG=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3220g-eval/nxwm/defconfig b/configs/stm3220g-eval/nxwm/defconfig index 226185ff1aa..fa8ab410a4d 100644 --- a/configs/stm3220g-eval/nxwm/defconfig +++ b/configs/stm3220g-eval/nxwm/defconfig @@ -989,7 +989,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3220g-eval/telnetd/defconfig b/configs/stm3220g-eval/telnetd/defconfig index 3b2691aac18..4af8ce18acb 100644 --- a/configs/stm3220g-eval/telnetd/defconfig +++ b/configs/stm3220g-eval/telnetd/defconfig @@ -874,7 +874,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/dhcpd/defconfig b/configs/stm3240g-eval/dhcpd/defconfig index eb100332f91..0f0b7fb1da8 100644 --- a/configs/stm3240g-eval/dhcpd/defconfig +++ b/configs/stm3240g-eval/dhcpd/defconfig @@ -876,7 +876,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/discover/defconfig b/configs/stm3240g-eval/discover/defconfig index df9f2b18eec..18210f6a9d3 100644 --- a/configs/stm3240g-eval/discover/defconfig +++ b/configs/stm3240g-eval/discover/defconfig @@ -899,7 +899,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/nettest/defconfig b/configs/stm3240g-eval/nettest/defconfig index 9f24daa36f0..e64f241e198 100644 --- a/configs/stm3240g-eval/nettest/defconfig +++ b/configs/stm3240g-eval/nettest/defconfig @@ -876,7 +876,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/nsh/defconfig b/configs/stm3240g-eval/nsh/defconfig index 1ced4eac010..0bb15260d3c 100644 --- a/configs/stm3240g-eval/nsh/defconfig +++ b/configs/stm3240g-eval/nsh/defconfig @@ -917,7 +917,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/nsh2/defconfig b/configs/stm3240g-eval/nsh2/defconfig index 446ecdaba87..6656348e267 100644 --- a/configs/stm3240g-eval/nsh2/defconfig +++ b/configs/stm3240g-eval/nsh2/defconfig @@ -944,7 +944,6 @@ CONFIG_RAMLOG_SYSLOG=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/nxterm/defconfig b/configs/stm3240g-eval/nxterm/defconfig index 7d5aa49b059..da3ffd42ab4 100644 --- a/configs/stm3240g-eval/nxterm/defconfig +++ b/configs/stm3240g-eval/nxterm/defconfig @@ -958,7 +958,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/nxwm/defconfig b/configs/stm3240g-eval/nxwm/defconfig index ab92f2b9c3b..eab7420dcf6 100644 --- a/configs/stm3240g-eval/nxwm/defconfig +++ b/configs/stm3240g-eval/nxwm/defconfig @@ -986,7 +986,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/telnetd/defconfig b/configs/stm3240g-eval/telnetd/defconfig index 6882cd6d068..07ad188e921 100644 --- a/configs/stm3240g-eval/telnetd/defconfig +++ b/configs/stm3240g-eval/telnetd/defconfig @@ -878,7 +878,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/webserver/defconfig b/configs/stm3240g-eval/webserver/defconfig index 076059622ca..856364d4158 100644 --- a/configs/stm3240g-eval/webserver/defconfig +++ b/configs/stm3240g-eval/webserver/defconfig @@ -938,7 +938,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm3240g-eval/xmlrpc/defconfig b/configs/stm3240g-eval/xmlrpc/defconfig index 8a45ee19450..4cee1e1d72e 100644 --- a/configs/stm3240g-eval/xmlrpc/defconfig +++ b/configs/stm3240g-eval/xmlrpc/defconfig @@ -895,7 +895,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm32butterfly2/nshnet/defconfig b/configs/stm32butterfly2/nshnet/defconfig index 05b2ab9f0aa..b1321f4ee73 100644 --- a/configs/stm32butterfly2/nshnet/defconfig +++ b/configs/stm32butterfly2/nshnet/defconfig @@ -942,7 +942,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm32f4discovery/ipv6/defconfig b/configs/stm32f4discovery/ipv6/defconfig index be3b59a9281..b2fd121eebb 100644 --- a/configs/stm32f4discovery/ipv6/defconfig +++ b/configs/stm32f4discovery/ipv6/defconfig @@ -946,7 +946,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/stm32f4discovery/netnsh/defconfig b/configs/stm32f4discovery/netnsh/defconfig index ff2ce11f271..61d20ad6575 100644 --- a/configs/stm32f4discovery/netnsh/defconfig +++ b/configs/stm32f4discovery/netnsh/defconfig @@ -948,7 +948,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/tm4c1294-launchpad/ipv6/defconfig b/configs/tm4c1294-launchpad/ipv6/defconfig index 0ec47e40591..936957248bb 100644 --- a/configs/tm4c1294-launchpad/ipv6/defconfig +++ b/configs/tm4c1294-launchpad/ipv6/defconfig @@ -640,7 +640,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/tm4c1294-launchpad/nsh/defconfig b/configs/tm4c1294-launchpad/nsh/defconfig index 25a9cfe8b6a..f2a84e52b8f 100644 --- a/configs/tm4c1294-launchpad/nsh/defconfig +++ b/configs/tm4c1294-launchpad/nsh/defconfig @@ -642,7 +642,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y # CONFIG_ARCH_HAVE_PHY is not set CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/u-blox-c027/nsh/defconfig b/configs/u-blox-c027/nsh/defconfig index 588447e164e..c98cfdac706 100644 --- a/configs/u-blox-c027/nsh/defconfig +++ b/configs/u-blox-c027/nsh/defconfig @@ -679,7 +679,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/viewtool-stm32f107/netnsh/defconfig b/configs/viewtool-stm32f107/netnsh/defconfig index 9fece336b93..466b2d70095 100644 --- a/configs/viewtool-stm32f107/netnsh/defconfig +++ b/configs/viewtool-stm32f107/netnsh/defconfig @@ -874,7 +874,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -# CONFIG_NET_NOINTS is not set # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/zkit-arm-1769/hello/defconfig b/configs/zkit-arm-1769/hello/defconfig index 38855218b92..b6b968fe33e 100644 --- a/configs/zkit-arm-1769/hello/defconfig +++ b/configs/zkit-arm-1769/hello/defconfig @@ -592,7 +592,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/zkit-arm-1769/nsh/defconfig b/configs/zkit-arm-1769/nsh/defconfig index d7480266d0b..481f472b21e 100644 --- a/configs/zkit-arm-1769/nsh/defconfig +++ b/configs/zkit-arm-1769/nsh/defconfig @@ -632,7 +632,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/zkit-arm-1769/nxhello/defconfig b/configs/zkit-arm-1769/nxhello/defconfig index 8af1755ddbe..be2211450ae 100644 --- a/configs/zkit-arm-1769/nxhello/defconfig +++ b/configs/zkit-arm-1769/nxhello/defconfig @@ -670,7 +670,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/configs/zkit-arm-1769/thttpd/defconfig b/configs/zkit-arm-1769/thttpd/defconfig index f251f0a05bc..026d759b453 100644 --- a/configs/zkit-arm-1769/thttpd/defconfig +++ b/configs/zkit-arm-1769/thttpd/defconfig @@ -595,7 +595,6 @@ CONFIG_SYSLOG_CONSOLE=y CONFIG_ARCH_HAVE_NET=y CONFIG_ARCH_HAVE_PHY=y CONFIG_NET=y -CONFIG_NET_NOINTS=y # CONFIG_NET_PROMISCUOUS is not set # diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 96d012a04dd..83213465e43 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -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 diff --git a/drivers/net/dm90x0.c b/drivers/net/dm90x0.c index 6439d7494a4..61c22a929bd 100644 --- a/drivers/net/dm90x0.c +++ b/drivers/net/dm90x0.c @@ -65,11 +65,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include @@ -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; } diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 99b9610685a..e91a5652ce4 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -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 */ diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index 58aacaf603b..e1690680471 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -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 */ diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index c03e05ccb6a..1550d9ad7c5 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -56,11 +56,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include #include @@ -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; } diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 8a703f6a60d..06459d54490 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -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(); } /**************************************************************************** diff --git a/drivers/net/skeleton.c b/drivers/net/skeleton.c index 0a6de715393..59c5a8fac50 100644 --- a/drivers/net/skeleton.c +++ b/drivers/net/skeleton.c @@ -53,11 +53,7 @@ #include #include #include - -#ifdef CONFIG_NET_NOINTS -# include -#endif - +#include #include #include @@ -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; } diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 0470027d572..afd3ca91ae2 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -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 diff --git a/drivers/net/tun.c b/drivers/net/tun.c index aaa411a613c..ebb59587b62 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -58,15 +58,12 @@ #include #include #include +#include #include #include - -#include #include -#ifdef CONFIG_NET_NOINTS -# include -#endif +#include #ifdef CONFIG_NET_PKT # include @@ -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); diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index 74abc0d701c..54f5c83273c 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -49,10 +49,6 @@ #include #include -#ifndef CONFIG_NET_NOINTS -# include -#endif - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -142,24 +138,6 @@ struct socketlist struct net_driver_s; /* Forward reference. Defined in nuttx/net/netdev.h */ typedef int (*netdev_callback_t)(FAR struct net_driver_s *dev, FAR void *arg); -#ifdef CONFIG_NET_NOINTS -/* Semaphore based locking for non-interrupt based logic. - * - * net_lock_t -- Not used. Only for compatibility - */ - -typedef uint8_t net_lock_t; /* Not really used */ - -#else - -/* Enable/disable locking for interrupt based logic: - * - * net_lock_t -- The processor specific representation of interrupt state. - */ - -# define net_lock_t irqstate_t -#endif - /**************************************************************************** * Public Data ****************************************************************************/ @@ -221,27 +199,15 @@ void net_setup(void); void net_initialize(void); /**************************************************************************** - * Critical section management. The NuttX configuration setting - * CONFIG_NET_NOINTS indicates that the network stack not called from the - * interrupt level. If CONFIG_NET_NOINTS is defined, then these will map - * to semaphore controls. Otherwise, it assumed that the stack will be - * called from interrupt level handling and these will map to interrupt - * enable/disable controls. + * Critical section management. * - * - * If CONFIG_NET_NOINTS is defined, then semaphore based locking is used: + * Semaphore based locking is used: * * net_lock() - Takes the semaphore(). Implements a re-entrant mutex. * net_unlock() - Gives the semaphore(). * net_lockedwait() - Like pthread_cond_wait(); releases the semaphore * momentarily to wait on another semaphore() * - * Otherwise, interrupt based locking is used: - * - * net_lock() - Disables interrupts. - * net_unlock() - Conditionally restores interrupts. - * net_lockedwait() - Just wait for the semaphore. - * ****************************************************************************/ /**************************************************************************** @@ -252,11 +218,7 @@ void net_initialize(void); * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS -net_lock_t net_lock(void); -#else -# define net_lock() enter_critical_section() -#endif +void net_lock(void); /**************************************************************************** * Function: net_unlock @@ -266,11 +228,7 @@ net_lock_t net_lock(void); * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS -void net_unlock(net_lock_t flags); -#else -# define net_unlock(f) leave_critical_section(f) -#endif +void net_unlock(void); /**************************************************************************** * Function: net_timedwait @@ -290,12 +248,8 @@ void net_unlock(net_lock_t flags); * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS struct timespec; int net_timedwait(sem_t *sem, FAR const struct timespec *abstime); -#else -# define net_timedwait(s,t) sem_timedwait(s,t) -#endif /**************************************************************************** * Function: net_lockedwait @@ -313,11 +267,7 @@ int net_timedwait(sem_t *sem, FAR const struct timespec *abstime); * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS int net_lockedwait(sem_t *sem); -#else -# define net_lockedwait(s) sem_wait(s) -#endif /**************************************************************************** * Function: net_setipid diff --git a/include/nuttx/net/slip.h b/include/nuttx/net/slip.h index 3818b5083d5..546781f85fd 100644 --- a/include/nuttx/net/slip.h +++ b/include/nuttx/net/slip.h @@ -51,11 +51,7 @@ * Pre-processor Definitions ****************************************************************************/ /* Configuration ***********************************************************/ -/* Dependencies: - * - * CONFIG_NET_NOINTS - Required. - * - * SLIP Configuration: +/* SLIP Configuration: * * CONFIG_NET_SLIP - Enables building of the SLIP driver * CONFIG_NET_SLIP_STACKSIZE - Provides the stack size for SLIP RX and TX diff --git a/net/Kconfig b/net/Kconfig index 1655cb0abf0..2fea54f86fa 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -20,17 +20,6 @@ config NET if NET -config NET_NOINTS - bool "Not interrupt driven" - default n - ---help--- - NET_NOINT indicates that network layer is not called from the - interrupt level. If NET_NOINTS is defined, critical sections - will be managed with semaphores; Otherwise, it assumed that - network layer will be called from interrupt level handling - and critical sections will be managed by enabling and disabling - interrupts. - config NET_PROMISCUOUS bool "Promiscuous mode" default n @@ -149,9 +138,7 @@ config NET_LOOPBACK select NETDEV_MULTINIC if NET_ETHERNET || NET_SLIP || NET_TUN select NET_MULTILINK if NET_ETHERNET || NET_SLIP || NET_TUN ---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. config NET_SLIP bool "SLIP support" @@ -160,7 +147,7 @@ config NET_SLIP select NET_MULTILINK if NET_ETHERNET || NET_LOOPBACK || NET_TUN ---help--- Enables building of the SLIP driver. SLIP requires - at least one IP protocol selected and CONFIG_NET_NOINTS. + at least one IP protocol selected. SLIP supports point-to-point IP communications over a serial port. The default data link layer for network layer is Ethernet. If diff --git a/net/arp/arp_send.c b/net/arp/arp_send.c index 0a525c7d681..e5a1e48221a 100644 --- a/net/arp/arp_send.c +++ b/net/arp/arp_send.c @@ -192,7 +192,6 @@ int arp_send(in_addr_t ipaddr) struct arp_notify_s notify; struct timespec delay; struct arp_send_s state; - net_lock_t save; int ret; /* First check if destination is a local broadcast. */ @@ -282,7 +281,7 @@ int arp_send(in_addr_t ipaddr) * want anything to happen until we are ready. */ - save = net_lock(); + net_lock(); state.snd_cb = arp_callback_alloc(dev); if (!state.snd_cb) { @@ -409,7 +408,7 @@ int arp_send(in_addr_t ipaddr) sem_destroy(&state.snd_sem); arp_callback_free(dev, state.snd_cb); errout_with_lock: - net_unlock(save); + net_unlock(); errout: return ret; } diff --git a/net/devif/devif_callback.c b/net/devif/devif_callback.c index 01986a3a9e8..067b7663d97 100644 --- a/net/devif/devif_callback.c +++ b/net/devif/devif_callback.c @@ -80,11 +80,10 @@ static void devif_callback_free(FAR struct net_driver_s *dev, { FAR struct devif_callback_s *prev; FAR struct devif_callback_s *curr; - net_lock_t save; if (cb) { - save = net_lock(); + net_lock(); #ifdef CONFIG_DEBUG_FEATURES /* Check for double freed callbacks */ @@ -159,7 +158,7 @@ static void devif_callback_free(FAR struct net_driver_s *dev, cb->nxtconn = g_cbfreelist; cb->nxtdev = NULL; g_cbfreelist = cb; - net_unlock(save); + net_unlock(); } } @@ -210,11 +209,10 @@ FAR struct devif_callback_s * FAR struct devif_callback_s **list) { FAR struct devif_callback_s *ret; - net_lock_t save; /* Check the head of the free list */ - save = net_lock(); + net_lock(); ret = g_cbfreelist; if (ret) { @@ -241,7 +239,7 @@ FAR struct devif_callback_s * /* No.. release the callback structure and fail */ devif_callback_free(NULL, NULL, list); - net_unlock(save); + net_unlock(); return NULL; } @@ -264,7 +262,7 @@ FAR struct devif_callback_s * } #endif - net_unlock(save); + net_unlock(); return ret; } @@ -385,13 +383,12 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, void *pvconn, uint16_t flags, FAR struct devif_callback_s *list) { FAR struct devif_callback_s *next; - net_lock_t save; /* Loop for each callback in the list and while there are still events * set in the flags set. */ - save = net_lock(); + net_lock(); while (list && flags) { /* Save the pointer to the next callback in the lists. This is done @@ -419,7 +416,7 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, void *pvconn, list = next; } - net_unlock(save); + net_unlock(); return flags; } @@ -450,13 +447,12 @@ uint16_t devif_dev_event(FAR struct net_driver_s *dev, void *pvconn, { FAR struct devif_callback_s *cb; FAR struct devif_callback_s *next; - net_lock_t save; /* Loop for each callback in the list and while there are still events * set in the flags set. */ - save = net_lock(); + net_lock(); for (cb = dev->d_devcb; cb != NULL && flags != 0; cb = next) { /* Save the pointer to the next callback in the lists. This is done @@ -484,7 +480,7 @@ uint16_t devif_dev_event(FAR struct net_driver_s *dev, void *pvconn, cb = next; } - net_unlock(save); + net_unlock(); return flags; } diff --git a/net/icmp/icmp_ping.c b/net/icmp/icmp_ping.c index 96dd811cce1..e6f8961b480 100644 --- a/net/icmp/icmp_ping.c +++ b/net/icmp/icmp_ping.c @@ -334,7 +334,6 @@ int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen, { FAR struct net_driver_s *dev; struct icmp_ping_s state; - net_lock_t save; #ifdef CONFIG_NET_ARP_SEND int ret; #endif @@ -380,7 +379,7 @@ int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen, state.png_datlen = datalen; /* The length of data to send in the ECHO request */ state.png_sent = false; /* ECHO request not yet sent */ - save = net_lock(); + net_lock(); state.png_time = clock_systimer(); /* Set up the callback */ @@ -410,7 +409,7 @@ int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen, icmp_callback_free(dev, state.png_cb); } - net_unlock(save); + net_unlock(); /* Return the negated error number in the event of a failure, or the * sequence number of the ECHO reply on success. diff --git a/net/icmpv6/icmpv6_autoconfig.c b/net/icmpv6/icmpv6_autoconfig.c index 0e8fc688cd2..05a9c449265 100644 --- a/net/icmpv6/icmpv6_autoconfig.c +++ b/net/icmpv6/icmpv6_autoconfig.c @@ -279,7 +279,6 @@ errout_with_semaphore: * Parameters: * dev - The device to use to send the solicitation * notify - The pre-initialized notification structure - * save - We will need this to temporarily release the net lock * * Returned Value: * Zero (OK) is returned on success; On error a negated errno value is @@ -291,8 +290,7 @@ errout_with_semaphore: ****************************************************************************/ static int icmpv6_wait_radvertise(FAR struct net_driver_s *dev, - FAR struct icmpv6_rnotify_s *notify, - net_lock_t *save) + FAR struct icmpv6_rnotify_s *notify) { struct timespec delay; int ret; @@ -353,7 +351,6 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) #else /* CONFIG_NET_ETHERNET */ struct icmpv6_rnotify_s notify; net_ipv6addr_t lladdr; - net_lock_t save; int retries; int ret; @@ -374,9 +371,9 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) /* The interface should be in the down state */ - save = net_lock(); + net_lock(); netdev_ifdown(dev); - net_unlock(save); + net_unlock(); /* IPv6 Stateless Autoconfiguration * Reference: http://www.tcpipguide.com/free/t_IPv6AutoconfigurationandRenumbering.htm @@ -415,9 +412,9 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) #ifdef CONFIG_NET_ICMPv6_NEIGHBOR /* Bring the interface up with no IP address */ - save = net_lock(); + net_lock(); netdev_ifup(dev); - net_unlock(save); + net_unlock(); /* 2. Link-Local Address Uniqueness Test: The node tests to ensure that * the address it generated isn't for some reason already in use on the @@ -435,9 +432,9 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) /* Take the interface back down */ - save = net_lock(); + net_lock(); netdev_ifdown(dev); - net_unlock(save); + net_unlock(); if (ret == OK) { @@ -456,7 +453,7 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) * on the wider Internet (since link-local addresses are not routed). */ - save = net_lock(); + net_lock(); net_ipv6addr_copy(dev->d_ipv6addr, lladdr); /* Bring the interface up with the new, temporary IP address */ @@ -489,7 +486,7 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) /* Wait to receive the Router Advertisement message */ - ret = icmpv6_wait_radvertise(dev, ¬ify, &save); + ret = icmpv6_wait_radvertise(dev, ¬ify); if (ret != -ETIMEDOUT) { /* ETIMEDOUT is the only expected failure. We will retry on that @@ -534,7 +531,7 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) * work out quite the way we wanted). */ - net_unlock(save); + net_unlock(); return ret; } @@ -557,7 +554,7 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) */ netdev_ifup(dev); - net_unlock(save); + net_unlock(); return OK; #endif /* CONFIG_NET_ETHERNET */ } diff --git a/net/icmpv6/icmpv6_neighbor.c b/net/icmpv6/icmpv6_neighbor.c index 60f63660bd5..de7ba28046a 100644 --- a/net/icmpv6/icmpv6_neighbor.c +++ b/net/icmpv6/icmpv6_neighbor.c @@ -207,7 +207,6 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) struct timespec delay; struct icmpv6_neighbor_s state; FAR const uint16_t *lookup; - net_lock_t save; int ret; /* First check if destination is a local broadcast or a multicast address. @@ -295,7 +294,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) * want anything to happen until we are ready. */ - save = net_lock(); + net_lock(); state.snd_cb = icmpv6_callback_alloc(dev); if (!state.snd_cb) { @@ -404,7 +403,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) sem_destroy(&state.snd_sem); icmpv6_callback_free(dev, state.snd_cb); errout_with_lock: - net_unlock(save); + net_unlock(); errout: return ret; } diff --git a/net/icmpv6/icmpv6_ping.c b/net/icmpv6/icmpv6_ping.c index 839ac06e071..2d37890464e 100644 --- a/net/icmpv6/icmpv6_ping.c +++ b/net/icmpv6/icmpv6_ping.c @@ -408,7 +408,6 @@ int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno, { FAR struct net_driver_s *dev; struct icmpv6_ping_s state; - net_lock_t save; #ifdef CONFIG_NET_ICMPv6_NEIGHBOR int ret; @@ -454,7 +453,7 @@ int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno, net_ipv6addr_copy(state.png_addr, addr); /* Address of the peer to be ping'ed */ - save = net_lock(); + net_lock(); state.png_time = clock_systimer(); /* Set up the callback */ @@ -484,7 +483,7 @@ int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno, icmpv6_callback_free(dev, state.png_cb); } - net_unlock(save); + net_unlock(); /* Return the negated error number in the event of a failure, or the * sequence number of the ECHO reply on success. diff --git a/net/igmp/igmp_group.c b/net/igmp/igmp_group.c index e93a502052a..a1fe865eb5b 100644 --- a/net/igmp/igmp_group.c +++ b/net/igmp/igmp_group.c @@ -213,7 +213,6 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev, FAR const in_addr_t *addr) { FAR struct igmp_group_s *group; - net_lock_t flags; ninfo("addr: %08x dev: %p\n", *addr, dev); if (up_interrupt_context()) @@ -256,12 +255,12 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev, /* Interrupts must be disabled in order to modify the group list */ - flags = net_lock(); + net_lock(); /* Add the group structure to the list in the device structure */ sq_addfirst((FAR sq_entry_t *)group, &dev->grplist); - net_unlock(flags); + net_unlock(); } return group; @@ -282,7 +281,6 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev, FAR const in_addr_t *addr) { FAR struct igmp_group_s *group; - net_lock_t flags; grpinfo("Searching for addr %08x\n", (int)*addr); @@ -290,7 +288,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev, * called from. */ - flags = net_lock(); + net_lock(); for (group = (FAR struct igmp_group_s *)dev->grplist.head; group; group = group->next) @@ -303,7 +301,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev, } } - net_unlock(flags); + net_unlock(); return group; } @@ -347,13 +345,11 @@ FAR struct igmp_group_s *igmp_grpallocfind(FAR struct net_driver_s *dev, void igmp_grpfree(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group) { - net_lock_t flags; - grpinfo("Free: %p flags: %02x\n", group, group->flags); /* Cancel the wdog */ - flags = net_lock(); + net_lock(); wd_cancel(group->wdog); /* Remove the group structure from the group list in the device structure */ @@ -377,7 +373,7 @@ void igmp_grpfree(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group) { grpinfo("Put back on free list\n"); sq_addlast((FAR sq_entry_t *)group, &g_freelist); - net_unlock(flags); + net_unlock(); } else #endif @@ -386,7 +382,7 @@ void igmp_grpfree(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group) * this function is executing within an interrupt handler. */ - net_unlock(flags); + net_unlock(); grpinfo("Call sched_kfree()\n"); sched_kfree(group); } diff --git a/net/igmp/igmp_leave.c b/net/igmp/igmp_leave.c index 8e40451101b..2b7ee654b3f 100644 --- a/net/igmp/igmp_leave.c +++ b/net/igmp/igmp_leave.c @@ -127,7 +127,6 @@ int igmp_leavegroup(struct net_driver_s *dev, FAR const struct in_addr *grpaddr) { struct igmp_group_s *group; - net_lock_t flags; DEBUGASSERT(dev && grpaddr); @@ -143,11 +142,11 @@ int igmp_leavegroup(struct net_driver_s *dev, FAR const struct in_addr *grpaddr) * could interfere with the Leave Group. */ - flags = net_lock(); + net_lock(); wd_cancel(group->wdog); CLR_SCHEDMSG(group->flags); CLR_WAITMSG(group->flags); - net_unlock(flags); + net_unlock(); IGMP_STATINCR(g_netstats.igmp.leaves); diff --git a/net/igmp/igmp_msg.c b/net/igmp/igmp_msg.c index 3fd56fc3814..0b5065f3ec8 100644 --- a/net/igmp/igmp_msg.c +++ b/net/igmp/igmp_msg.c @@ -72,15 +72,13 @@ void igmp_schedmsg(FAR struct igmp_group_s *group, uint8_t msgid) { - net_lock_t flags; - /* The following should be atomic */ - flags = net_lock(); + net_lock(); DEBUGASSERT(!IS_SCHEDMSG(group->flags)); group->msgid = msgid; SET_SCHEDMSG(group->flags); - net_unlock(flags); + net_unlock(); } /**************************************************************************** @@ -98,11 +96,9 @@ void igmp_schedmsg(FAR struct igmp_group_s *group, uint8_t msgid) void igmp_waitmsg(FAR struct igmp_group_s *group, uint8_t msgid) { - net_lock_t flags; - /* Schedule to send the message */ - flags = net_lock(); + net_lock(); DEBUGASSERT(!IS_WAITMSG(group->flags)); SET_WAITMSG(group->flags); igmp_schedmsg(group, msgid); @@ -126,7 +122,7 @@ void igmp_waitmsg(FAR struct igmp_group_s *group, uint8_t msgid) /* The message has been sent and we are no longer waiting */ CLR_WAITMSG(group->flags); - net_unlock(flags); + net_unlock(); } #endif /* CONFIG_NET_IGMP */ diff --git a/net/igmp/igmp_timer.c b/net/igmp/igmp_timer.c index e413eb75fb8..9019376a4e5 100644 --- a/net/igmp/igmp_timer.c +++ b/net/igmp/igmp_timer.c @@ -196,14 +196,13 @@ void igmp_starttimer(FAR struct igmp_group_s *group, uint8_t decisecs) bool igmp_cmptimer(FAR struct igmp_group_s *group, int maxticks) { - net_lock_t flags; int remaining; /* Disable interrupts so that there is no race condition with the actual * timer expiration. */ - flags = net_lock(); + net_lock(); /* Get the timer remaining on the watchdog. A time of <= zero means that * the watchdog was never started. @@ -222,11 +221,11 @@ bool igmp_cmptimer(FAR struct igmp_group_s *group, int maxticks) /* Cancel the watchdog timer and return true */ wd_cancel(group->wdog); - net_unlock(flags); + net_unlock(); return true; } - net_unlock(flags); + net_unlock(); return false; } diff --git a/net/local/local_connect.c b/net/local/local_connect.c index b336b370b3e..a1ae96337c3 100644 --- a/net/local/local_connect.c +++ b/net/local/local_connect.c @@ -123,7 +123,7 @@ static inline void _local_semtake(sem_t *sem) int inline local_stream_connect(FAR struct local_conn_s *client, FAR struct local_conn_s *server, - bool nonblock, net_lock_t state) + bool nonblock) { int ret; @@ -135,7 +135,7 @@ int inline local_stream_connect(FAR struct local_conn_s *client, if (server->lc_state != LOCAL_STATE_LISTENING || server->u.server.lc_pending >= server->u.server.lc_backlog) { - net_unlock(state); + net_unlock(); nerr("ERROR: Server is not listening: lc_state=%d\n", server->lc_state); nerr(" OR: The backlog limit was reached: %d or %d\n", @@ -156,7 +156,7 @@ int inline local_stream_connect(FAR struct local_conn_s *client, nerr("ERROR: Failed to create FIFOs for %s: %d\n", client->lc_path, ret); - net_unlock(state); + net_unlock(); return ret; } @@ -170,7 +170,7 @@ int inline local_stream_connect(FAR struct local_conn_s *client, nerr("ERROR: Failed to open write-only FIFOs for %s: %d\n", client->lc_path, ret); - net_unlock(state); + net_unlock(); goto errout_with_fifos; } @@ -182,7 +182,7 @@ int inline local_stream_connect(FAR struct local_conn_s *client, client->lc_state = LOCAL_STATE_ACCEPT; local_accept_pollnotify(server, POLLIN); _local_semgive(&server->lc_waitsem); - net_unlock(state); + net_unlock(); /* Wait for the server to accept the connections */ @@ -257,7 +257,6 @@ int psock_local_connect(FAR struct socket *psock, FAR struct local_conn_s *client; FAR struct sockaddr_un *unaddr = (FAR struct sockaddr_un *)addr; FAR struct local_conn_s *conn; - net_lock_t state; DEBUGASSERT(psock && psock->s_conn); client = (FAR struct local_conn_s *)psock->s_conn; @@ -270,7 +269,7 @@ int psock_local_connect(FAR struct socket *psock, /* Find the matching server connection */ - state = net_lock(); + net_lock(); for (conn = (FAR struct local_conn_s *)g_local_listeners.head; conn; conn = (FAR struct local_conn_s *)dq_next(&conn->lc_node)) @@ -290,7 +289,7 @@ int psock_local_connect(FAR struct socket *psock, case LOCAL_TYPE_ABSTRACT: /* lc_path is length zero */ { #warning Missing logic - net_unlock(state); + net_unlock(); return OK; } break; @@ -322,7 +321,7 @@ int psock_local_connect(FAR struct socket *psock, } else { - net_unlock(state); + net_unlock(); } return ret; @@ -335,13 +334,13 @@ int psock_local_connect(FAR struct socket *psock, case LOCAL_TYPE_UNTYPED: /* Type is not determined until the socket is bound */ { - net_unlock(state); + net_unlock(); return -EINVAL; } } } - net_unlock(state); + net_unlock(); return -EADDRNOTAVAIL; } diff --git a/net/local/local_listen.c b/net/local/local_listen.c index 712055c9cef..a1020570e77 100644 --- a/net/local/local_listen.c +++ b/net/local/local_listen.c @@ -84,7 +84,6 @@ dq_queue_t g_local_listeners; int local_listen(FAR struct local_conn_s *server, int backlog) { - net_lock_t state; /* Some sanity checks */ @@ -118,9 +117,9 @@ int local_listen(FAR struct local_conn_s *server, int backlog) /* Add the connection structure to the list of listeners */ - state = net_lock(); + net_lock(); dq_addlast(&server->lc_node, &g_local_listeners); - net_unlock(state); + net_unlock(); /* And change the server state to listing */ diff --git a/net/local/local_netpoll.c b/net/local/local_netpoll.c index 9800af3172c..f9e087b36d9 100644 --- a/net/local/local_netpoll.c +++ b/net/local/local_netpoll.c @@ -62,12 +62,11 @@ static int local_accept_pollsetup(FAR struct local_conn_s *conn, FAR struct pollfd *fds, bool setup) { - net_lock_t state; pollevent_t eventset; int ret = OK; int i; - state = net_lock(); + net_lock(); if (setup) { /* This is a request to set up the poll. Find an available @@ -125,7 +124,7 @@ static int local_accept_pollsetup(FAR struct local_conn_s *conn, } errout: - net_unlock(state); + net_unlock(); return ret; } #endif diff --git a/net/local/local_release.c b/net/local/local_release.c index 29ea65f2f3b..0d2bf42f803 100644 --- a/net/local/local_release.c +++ b/net/local/local_release.c @@ -69,12 +69,11 @@ int local_release(FAR struct local_conn_s *conn) { - net_lock_t state; /* There should be no references on this structure */ DEBUGASSERT(conn->lc_crefs == 0); - state = net_lock(); + net_lock(); #ifdef CONFIG_NET_LOCAL_STREAM /* We should not bet here with state LOCAL_STATE_ACCEPT. That is an @@ -126,7 +125,7 @@ int local_release(FAR struct local_conn_s *conn) /* Free the connection structure */ local_free(conn); - net_unlock(state); + net_unlock(); return OK; } diff --git a/net/netdev/netdev_count.c b/net/netdev/netdev_count.c index 73ff960f3d8..171039caf6d 100644 --- a/net/netdev/netdev_count.c +++ b/net/netdev/netdev_count.c @@ -72,12 +72,11 @@ int netdev_count(void) { struct net_driver_s *dev; - net_lock_t save; int ndev; - save = net_lock(); + net_lock(); for (dev = g_netdevices, ndev = 0; dev; dev = dev->flink, ndev++); - net_unlock(save); + net_unlock(); return ndev; } diff --git a/net/netdev/netdev_default.c b/net/netdev/netdev_default.c index 24884259a7d..331f50343d1 100644 --- a/net/netdev/netdev_default.c +++ b/net/netdev/netdev_default.c @@ -76,11 +76,10 @@ FAR struct net_driver_s *netdev_default(void) { FAR struct net_driver_s *dev; - net_lock_t save; /* Examine each registered network device */ - save = net_lock(); + net_lock(); for (dev = g_netdevices; dev; dev = dev->flink) { /* Is the interface in the "up" state? */ @@ -91,12 +90,12 @@ FAR struct net_driver_s *netdev_default(void) * state. */ - net_unlock(save); + net_unlock(); return dev; } } - net_unlock(save); + net_unlock(); return NULL; } diff --git a/net/netdev/netdev_findbyaddr.c b/net/netdev/netdev_findbyaddr.c index 54cf1cee35a..25fbc02b8d1 100644 --- a/net/netdev/netdev_findbyaddr.c +++ b/net/netdev/netdev_findbyaddr.c @@ -82,11 +82,10 @@ static FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr) { FAR struct net_driver_s *dev; - net_lock_t save; /* Examine each registered network device */ - save = net_lock(); + net_lock(); for (dev = g_netdevices; dev; dev = dev->flink) { /* Is the interface in the "up" state? */ @@ -100,7 +99,7 @@ static FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr) { /* Its a match */ - net_unlock(save); + net_unlock(); return dev; } } @@ -108,7 +107,7 @@ static FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr) /* No device with the matching address found */ - net_unlock(save); + net_unlock(); return NULL; } #endif /* CONFIG_NET_IPv4 */ @@ -137,11 +136,10 @@ static FAR struct net_driver_s * netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr) { FAR struct net_driver_s *dev; - net_lock_t save; /* Examine each registered network device */ - save = net_lock(); + net_lock(); for (dev = g_netdevices; dev; dev = dev->flink) { /* Is the interface in the "up" state? */ @@ -155,7 +153,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr) { /* Its a match */ - net_unlock(save); + net_unlock(); return dev; } } @@ -163,7 +161,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr) /* No device with the matching address found */ - net_unlock(save); + net_unlock(); return NULL; } #endif /* CONFIG_NET_IPv6 */ diff --git a/net/netdev/netdev_findbyindex.c b/net/netdev/netdev_findbyindex.c index 74ccba04c84..f17bba0b7c6 100644 --- a/net/netdev/netdev_findbyindex.c +++ b/net/netdev/netdev_findbyindex.c @@ -78,20 +78,19 @@ FAR struct net_driver_s *netdev_findbyindex(int index) { #ifdef CONFIG_NETDEV_MULTINIC FAR struct net_driver_s *dev; - net_lock_t save; int i; - save = net_lock(); + net_lock(); for (i = 0, dev = g_netdevices; dev; i++, dev = dev->flink) { if (i == index) { - net_unlock(save); + net_unlock(); return dev; } } - net_unlock(save); + net_unlock(); return NULL; #else return (index == 0) ? g_netdevices : NULL; diff --git a/net/netdev/netdev_findbyname.c b/net/netdev/netdev_findbyname.c index 04c20b27c8e..944489a2d02 100644 --- a/net/netdev/netdev_findbyname.c +++ b/net/netdev/netdev_findbyname.c @@ -73,21 +73,20 @@ FAR struct net_driver_s *netdev_findbyname(FAR const char *ifname) { FAR struct net_driver_s *dev; - net_lock_t save; if (ifname) { - save = net_lock(); + net_lock(); for (dev = g_netdevices; dev; dev = dev->flink) { if (strcmp(ifname, dev->d_ifname) == 0) { - net_unlock(save); + net_unlock(); return dev; } } - net_unlock(save); + net_unlock(); } return NULL; diff --git a/net/netdev/netdev_foreach.c b/net/netdev/netdev_foreach.c index 99d6a8c061f..11df953902e 100644 --- a/net/netdev/netdev_foreach.c +++ b/net/netdev/netdev_foreach.c @@ -73,12 +73,11 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg) { FAR struct net_driver_s *dev; - net_lock_t save; int ret = 0; if (callback) { - save = net_lock(); + net_lock(); for (dev = g_netdevices; dev; dev = dev->flink) { if (callback(dev, arg) != 0) @@ -88,7 +87,7 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg) } } - net_unlock(save); + net_unlock(); } return ret; diff --git a/net/netdev/netdev_register.c b/net/netdev/netdev_register.c index 81bfe8232b3..a2144d2288b 100644 --- a/net/netdev/netdev_register.c +++ b/net/netdev/netdev_register.c @@ -178,7 +178,6 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype) #ifdef CONFIG_NET_USER_DEVFMT FAR const char devfmt_str[IFNAMSIZ]; #endif - net_lock_t save; int devnum; if (dev) @@ -271,7 +270,7 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype) * the interface */ - save = net_lock(); + net_lock(); #ifdef CONFIG_NET_MULTILINK # ifdef CONFIG_NET_LOOPBACK @@ -316,7 +315,7 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype) #ifdef CONFIG_NET_IGMP igmp_devinit(dev); #endif - net_unlock(save); + net_unlock(); #ifdef CONFIG_NET_ETHERNET ninfo("Registered MAC: %02x:%02x:%02x:%02x:%02x:%02x as dev: %s\n", diff --git a/net/netdev/netdev_unregister.c b/net/netdev/netdev_unregister.c index 405118e308a..6d56ad70f43 100644 --- a/net/netdev/netdev_unregister.c +++ b/net/netdev/netdev_unregister.c @@ -91,11 +91,10 @@ int netdev_unregister(FAR struct net_driver_s *dev) { struct net_driver_s *prev; struct net_driver_s *curr; - net_lock_t save; if (dev) { - save = net_lock(); + net_lock(); /* Find the device in the list of known network devices */ @@ -125,7 +124,7 @@ int netdev_unregister(FAR struct net_driver_s *dev) curr->flink = NULL; } - net_unlock(save); + net_unlock(); #ifdef CONFIG_NET_ETHERNET ninfo("Unregistered MAC: %02x:%02x:%02x:%02x:%02x:%02x as dev: %s\n", diff --git a/net/netdev/netdev_verify.c b/net/netdev/netdev_verify.c index 8fdd42b53a5..ee3031ea783 100644 --- a/net/netdev/netdev_verify.c +++ b/net/netdev/netdev_verify.c @@ -64,12 +64,11 @@ bool netdev_verify(FAR struct net_driver_s *dev) { FAR struct net_driver_s *chkdev; - net_lock_t save; bool valid = false; /* Search the list of registered devices */ - save = net_lock(); + net_lock(); for (chkdev = g_netdevices; chkdev != NULL; chkdev = chkdev->flink) { /* Is the the network device that we are looking for? */ @@ -83,6 +82,6 @@ bool netdev_verify(FAR struct net_driver_s *dev) } } - net_unlock(save); + net_unlock(); return valid; } diff --git a/net/pkt/pkt_send.c b/net/pkt/pkt_send.c index b4dc0d6d451..fa5bda318b1 100644 --- a/net/pkt/pkt_send.c +++ b/net/pkt/pkt_send.c @@ -213,7 +213,6 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, { FAR struct net_driver_s *dev; struct send_s state; - net_lock_t save; int errcode; int ret = OK; @@ -245,7 +244,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, * are ready. */ - save = net_lock(); + net_lock(); memset(&state, 0, sizeof(struct send_s)); /* This semaphore is used for signaling and, hence, should not have @@ -293,7 +292,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, } sem_destroy(&state.snd_sem); - net_unlock(save); + net_unlock(); /* Set the socket state to idle */ diff --git a/net/route/net_addroute.c b/net/route/net_addroute.c index 3451a1691e9..1f75944ec50 100644 --- a/net/route/net_addroute.c +++ b/net/route/net_addroute.c @@ -74,7 +74,6 @@ int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router) { FAR struct net_route_s *route; - net_lock_t save; /* Allocate a route entry */ @@ -93,12 +92,12 @@ int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router) /* Get exclusive address to the networking data structures */ - save = net_lock(); + net_lock(); /* Then add the new entry to the table */ sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_routes); - net_unlock(save); + net_unlock(); return OK; } #endif @@ -107,7 +106,6 @@ int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router) int net_addroute_ipv6(net_ipv6addr_t target, net_ipv6addr_t netmask, net_ipv6addr_t router) { FAR struct net_route_ipv6_s *route; - net_lock_t save; /* Allocate a route entry */ @@ -126,12 +124,12 @@ int net_addroute_ipv6(net_ipv6addr_t target, net_ipv6addr_t netmask, net_ipv6add /* Get exclusive address to the networking data structures */ - save = net_lock(); + net_lock(); /* Then add the new entry to the table */ sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_routes_ipv6); - net_unlock(save); + net_unlock(); return OK; } #endif diff --git a/net/route/net_allocroute.c b/net/route/net_allocroute.c index 5c278a9a039..8c0cfdd02f3 100644 --- a/net/route/net_allocroute.c +++ b/net/route/net_allocroute.c @@ -161,18 +161,17 @@ void net_initroute(void) FAR struct net_route_s *net_allocroute(void) { FAR struct net_route_s *route; - net_lock_t save; /* Get exclusive address to the networking data structures */ - save = net_lock(); + net_lock(); /* Then add the new entry to the table */ route = (FAR struct net_route_s *) sq_remfirst((FAR sq_queue_t *)&g_freeroutes); - net_unlock(save); + net_unlock(); return route; } #endif @@ -181,24 +180,23 @@ FAR struct net_route_s *net_allocroute(void) FAR struct net_route_ipv6_s *net_allocroute_ipv6(void) { FAR struct net_route_ipv6_s *route; - net_lock_t save; /* Get exclusive address to the networking data structures */ - save = net_lock(); + net_lock(); /* Then add the new entry to the table */ route = (FAR struct net_route_ipv6_s *) sq_remfirst((FAR sq_queue_t *)&g_freeroutes_ipv6); - net_unlock(save); + net_unlock(); return route; } #endif /**************************************************************************** - * Function: net_allocroute + * Function: net_freeroute * * Description: * Free one route by adding it from the free list @@ -214,36 +212,32 @@ FAR struct net_route_ipv6_s *net_allocroute_ipv6(void) #ifdef CONFIG_NET_IPv4 void net_freeroute(FAR struct net_route_s *route) { - net_lock_t save; - DEBUGASSERT(route); /* Get exclusive address to the networking data structures */ - save = net_lock(); + net_lock(); /* Then add the new entry to the table */ sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_freeroutes); - net_unlock(save); + net_unlock(); } #endif #ifdef CONFIG_NET_IPv6 void net_freeroute_ipv6(FAR struct net_route_ipv6_s *route) { - net_lock_t save; - DEBUGASSERT(route); /* Get exclusive address to the networking data structures */ - save = net_lock(); + net_lock(); /* Then add the new entry to the table */ sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_freeroutes_ipv6); - net_unlock(save); + net_unlock(); } #endif diff --git a/net/route/net_foreachroute.c b/net/route/net_foreachroute.c index 1c5789dd649..b9e52051afb 100644 --- a/net/route/net_foreachroute.c +++ b/net/route/net_foreachroute.c @@ -72,12 +72,11 @@ int net_foreachroute(route_handler_t handler, FAR void *arg) { FAR struct net_route_s *route; FAR struct net_route_s *next; - net_lock_t save; int ret = 0; /* Prevent concurrent access to the routing table */ - save = net_lock(); + net_lock(); /* Visit each entry in the routing table */ @@ -93,7 +92,7 @@ int net_foreachroute(route_handler_t handler, FAR void *arg) /* Unlock the network */ - net_unlock(save); + net_unlock(); return ret; } #endif @@ -103,12 +102,11 @@ int net_foreachroute_ipv6(route_handler_ipv6_t handler, FAR void *arg) { FAR struct net_route_ipv6_s *route; FAR struct net_route_ipv6_s *next; - net_lock_t save; int ret = 0; /* Prevent concurrent access to the routing table */ - save = net_lock(); + net_lock(); /* Visit each entry in the routing table */ @@ -124,7 +122,7 @@ int net_foreachroute_ipv6(route_handler_ipv6_t handler, FAR void *arg) /* Unlock the network */ - net_unlock(save); + net_unlock(); return ret; } #endif diff --git a/net/socket/accept.c b/net/socket/accept.c index 59fa329bd89..a01f69f6c62 100644 --- a/net/socket/accept.c +++ b/net/socket/accept.c @@ -233,15 +233,13 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, else #endif { - net_lock_t state; - /* Perform the local accept operation (with the network locked) */ - state = net_lock(); + net_lock(); ret = psock_tcp_accept(psock, addr, addrlen, &newsock->s_conn); if (ret < 0) { - net_unlock(state); + net_unlock(); errcode = -ret; goto errout; } @@ -258,12 +256,12 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr, * called. Undo everything we have done and return a failure. */ - net_unlock(state); + net_unlock(); errcode = -ret; goto errout_after_accept; } - net_unlock(state); + net_unlock(); } #endif /* CONFIG_NET_TCP */ diff --git a/net/socket/connect.c b/net/socket/connect.c index 3e174ae0b3a..6b83184fd9c 100644 --- a/net/socket/connect.c +++ b/net/socket/connect.c @@ -346,7 +346,6 @@ static inline int psock_tcp_connect(FAR struct socket *psock, FAR const struct sockaddr *addr) { struct tcp_connect_s state; - net_lock_t flags; int ret = OK; /* Interrupts must be disabled through all of the following because @@ -354,7 +353,7 @@ static inline int psock_tcp_connect(FAR struct socket *psock, * setup. */ - flags = net_lock(); + net_lock(); /* Get the connection reference from the socket */ @@ -431,7 +430,7 @@ static inline int psock_tcp_connect(FAR struct socket *psock, } } - net_unlock(flags); + net_unlock(); return ret; } #endif /* CONFIG_NET_TCP */ diff --git a/net/socket/getsockname.c b/net/socket/getsockname.c index 3b895525ef4..7bf87c29d12 100644 --- a/net/socket/getsockname.c +++ b/net/socket/getsockname.c @@ -99,7 +99,6 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, in_addr_t lipaddr; in_addr_t ripaddr; #endif - net_lock_t save; /* Check if enough space has been provided for the full address */ @@ -152,7 +151,7 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, * a single network device and only the network device knows the IP address. */ - save = net_lock(); + net_lock(); #ifdef CONFIG_NETDEV_MULTINIC /* Find the device matching the IPv4 address in the connection structure */ @@ -166,7 +165,7 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, if (!dev) { - net_unlock(save); + net_unlock(); return -EINVAL; } @@ -177,7 +176,7 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, outaddr->sin_addr.s_addr = dev->d_ipaddr; *addrlen = sizeof(struct sockaddr_in); #endif - net_unlock(save); + net_unlock(); /* Return success */ @@ -223,7 +222,6 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, net_ipv6addr_t *lipaddr; net_ipv6addr_t *ripaddr; #endif - net_lock_t save; /* Check if enough space has been provided for the full address */ @@ -276,7 +274,7 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, * a single network device and only the network device knows the IP address. */ - save = net_lock(); + net_lock(); #ifdef CONFIG_NETDEV_MULTINIC /* Find the device matching the IPv6 address in the connection structure */ @@ -290,7 +288,7 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, if (!dev) { - net_unlock(save); + net_unlock(); return -EINVAL; } @@ -301,7 +299,7 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, memcpy(outaddr->sin6_addr.in6_u.u6_addr8, dev->d_ipv6addr, 16); *addrlen = sizeof(struct sockaddr_in6); #endif - net_unlock(save); + net_unlock(); /* Return success */ diff --git a/net/socket/net_clone.c b/net/socket/net_clone.c index e76f4ed2cee..5398c614fdf 100644 --- a/net/socket/net_clone.c +++ b/net/socket/net_clone.c @@ -66,12 +66,11 @@ int net_clone(FAR struct socket *psock1, FAR struct socket *psock2) { - net_lock_t flags; int ret = OK; /* Parts of this operation need to be atomic */ - flags = net_lock(); + net_lock(); /* Duplicate the socket state */ @@ -120,7 +119,7 @@ int net_clone(FAR struct socket *psock1, FAR struct socket *psock2) ret = -EBADF; } - net_unlock(flags); + net_unlock(); return ret; } diff --git a/net/socket/net_close.c b/net/socket/net_close.c index 3ca53d30de3..ba0fb85dc1d 100644 --- a/net/socket/net_close.c +++ b/net/socket/net_close.c @@ -337,7 +337,6 @@ static inline int netclose_disconnect(FAR struct socket *psock) { struct tcp_close_s state; FAR struct tcp_conn_s *conn; - net_lock_t flags; #ifdef CONFIG_NET_SOLINGER bool linger; #endif @@ -345,7 +344,7 @@ static inline int netclose_disconnect(FAR struct socket *psock) /* Interrupts are disabled here to avoid race conditions */ - flags = net_lock(); + net_lock(); conn = (FAR struct tcp_conn_s *)psock->s_conn; /* If we have a semi-permanent write buffer callback in place, then @@ -449,7 +448,7 @@ static inline int netclose_disconnect(FAR struct socket *psock) tcp_free(conn); } - net_unlock(flags); + net_unlock(); return ret; } #endif /* CONFIG_NET_TCP */ diff --git a/net/socket/net_monitor.c b/net/socket/net_monitor.c index d7d566725ba..cee6a13cd94 100644 --- a/net/socket/net_monitor.c +++ b/net/socket/net_monitor.c @@ -216,7 +216,6 @@ int net_startmonitor(FAR struct socket *psock) { FAR struct tcp_conn_s *conn; FAR struct devif_callback_s *cb; - net_lock_t save; DEBUGASSERT(psock != NULL && psock->s_conn != NULL); conn = (FAR struct tcp_conn_s *)psock->s_conn; @@ -226,7 +225,7 @@ int net_startmonitor(FAR struct socket *psock) * registered the monitoring callback.) */ - save = net_lock(); + net_lock(); if (!(conn->tcpstateflags == TCP_ESTABLISHED || conn->tcpstateflags == TCP_SYN_RCVD)) { @@ -244,7 +243,7 @@ int net_startmonitor(FAR struct socket *psock) * because the socket was already disconnected. */ - net_unlock(save); + net_unlock(); return -ENOTCONN; } @@ -270,7 +269,7 @@ int net_startmonitor(FAR struct socket *psock) conn->connection_private = (FAR void *)psock; conn->connection_event = connection_event; - net_unlock(save); + net_unlock(); return OK; } @@ -294,13 +293,11 @@ int net_startmonitor(FAR struct socket *psock) void net_stopmonitor(FAR struct tcp_conn_s *conn) { - net_lock_t save; - DEBUGASSERT(conn); /* Free any allocated device event callback structure */ - save = net_lock(); + net_lock(); if (conn->connection_devcb) { tcp_monitor_callback_free(conn, conn->connection_devcb); @@ -311,7 +308,7 @@ void net_stopmonitor(FAR struct tcp_conn_s *conn) conn->connection_private = NULL; conn->connection_devcb = NULL; conn->connection_event = NULL; - net_unlock(save); + net_unlock(); } /**************************************************************************** @@ -335,19 +332,17 @@ void net_stopmonitor(FAR struct tcp_conn_s *conn) void net_lostconnection(FAR struct socket *psock, uint16_t flags) { - net_lock_t save; - DEBUGASSERT(psock != NULL && psock->s_conn != NULL); /* Close the connection */ - save = net_lock(); + net_lock(); connection_closed(psock, flags); /* Stop the network monitor */ net_stopmonitor((FAR struct tcp_conn_s *)psock->s_conn); - net_unlock(save); + net_unlock(); } #endif /* CONFIG_NET && CONFIG_NET_TCP */ diff --git a/net/socket/net_sendfile.c b/net/socket/net_sendfile.c index 1efb22d1c8b..617bce53972 100644 --- a/net/socket/net_sendfile.c +++ b/net/socket/net_sendfile.c @@ -604,7 +604,6 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, FAR struct socket *psock = sockfd_socket(outfd); FAR struct tcp_conn_s *conn; struct sendfile_s state; - net_lock_t save; int errcode; /* Verify that the sockfd corresponds to valid, allocated socket */ @@ -673,7 +672,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, * are ready. */ - save = net_lock(); + net_lock(); memset(&state, 0, sizeof(struct sendfile_s)); /* This semaphore is used for signaling and, hence, should not have @@ -757,7 +756,7 @@ errout_datacb: errout_locked: sem_destroy(&state. snd_sem); - net_unlock(save); + net_unlock(); errout: diff --git a/net/socket/net_vfcntl.c b/net/socket/net_vfcntl.c index 977db7833ad..b260edb5b0a 100644 --- a/net/socket/net_vfcntl.c +++ b/net/socket/net_vfcntl.c @@ -76,7 +76,6 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) { FAR struct socket *psock = sockfd_socket(sockfd); - net_lock_t flags; int errcode = 0; int ret = 0; @@ -92,7 +91,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) /* Interrupts must be disabled in order to perform operations on socket structures */ - flags = net_lock(); + net_lock(); switch (cmd) { case F_DUPFD: @@ -271,7 +270,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) break; } - net_unlock(flags); + net_unlock(); errout: if (errcode != 0) diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c index 046860b75fd..e8a029b099a 100644 --- a/net/socket/recvfrom.c +++ b/net/socket/recvfrom.c @@ -1395,7 +1395,6 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, FAR struct pkt_conn_s *conn = (FAR struct pkt_conn_s *)psock->s_conn; FAR struct net_driver_s *dev; struct recvfrom_s state; - net_lock_t save; int ret; /* Perform the packet recvfrom() operation */ @@ -1405,7 +1404,7 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * are ready. */ - save = net_lock(); + net_lock(); recvfrom_init(psock, buf, len, from, fromlen, &state); /* Get the device driver that will service this transfer */ @@ -1463,7 +1462,7 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, } errout_with_state: - net_unlock(save); + net_unlock(); recvfrom_uninit(&state); return ret; } @@ -1496,7 +1495,6 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, FAR struct udp_conn_s *conn = (FAR struct udp_conn_s *)psock->s_conn; FAR struct net_driver_s *dev; struct recvfrom_s state; - net_lock_t save; int ret; /* Perform the UDP recvfrom() operation */ @@ -1506,7 +1504,7 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * are ready. */ - save = net_lock(); + net_lock(); recvfrom_init(psock, buf, len, from, fromlen, &state); /* Setup the UDP remote connection */ @@ -1604,7 +1602,7 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, } errout_with_state: - net_unlock(save); + net_unlock(); recvfrom_uninit(&state); return ret; } @@ -1634,16 +1632,15 @@ errout_with_state: static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, FAR struct sockaddr *from, FAR socklen_t *fromlen) { - struct recvfrom_s state; - net_lock_t save; - int ret; + struct recvfrom_s state; + int ret; /* Initialize the state structure. This is done with interrupts * disabled because we don't want anything to happen until we * are ready. */ - save = net_lock(); + net_lock(); recvfrom_init(psock, buf, len, from, fromlen, &state); /* Handle any any TCP data already buffered in a read-ahead buffer. NOTE @@ -1783,7 +1780,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, } } - net_unlock(save); + net_unlock(); recvfrom_uninit(&state); return (ssize_t)ret; } diff --git a/net/socket/setsockopt.c b/net/socket/setsockopt.c index 2086771b37b..cdcd8d2e851 100644 --- a/net/socket/setsockopt.c +++ b/net/socket/setsockopt.c @@ -105,7 +105,6 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, FAR const void *value, socklen_t value_len) { - net_lock_t flags; int errcode; /* Verify that the socket option if valid (but might not be supported ) */ @@ -153,7 +152,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, * level access to options. */ - flags = net_lock(); + net_lock(); /* Set or clear the option bit */ @@ -166,7 +165,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, _SO_CLROPT(psock->s_options, option); } - net_unlock(flags); + net_unlock(); } break; @@ -235,7 +234,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, * level access to options. */ - flags = net_lock(); + net_lock(); /* Set or clear the linger option bit and linger time (in deciseconds) */ @@ -250,7 +249,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, psock->s_linger = 0; } - net_unlock(flags); + net_unlock(); } break; #endif diff --git a/net/tcp/tcp_backlog.c b/net/tcp/tcp_backlog.c index 6d7122fd3d0..252f04a0f8c 100644 --- a/net/tcp/tcp_backlog.c +++ b/net/tcp/tcp_backlog.c @@ -72,7 +72,6 @@ int tcp_backlogcreate(FAR struct tcp_conn_s *conn, int nblg) { FAR struct tcp_backlog_s *bls = NULL; FAR struct tcp_blcontainer_s *blc; - net_lock_t flags; int size; int offset; int i; @@ -125,7 +124,7 @@ int tcp_backlogcreate(FAR struct tcp_conn_s *conn, int nblg) /* Destroy any existing backlog (shouldn't be any) */ - flags = net_lock(); + net_lock(); tcp_backlogdestroy(conn); /* Now install the backlog tear-off in the connection. NOTE that bls may @@ -135,7 +134,7 @@ int tcp_backlogcreate(FAR struct tcp_conn_s *conn, int nblg) */ conn->backlog = bls; - net_unlock(flags); + net_unlock(); return OK; } diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index 12f7b332ea8..8ca70aed79e 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -514,13 +514,12 @@ static inline FAR struct tcp_conn_s * static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, FAR const struct sockaddr_in *addr) { - net_lock_t flags; int port; int ret; /* Verify or select a local port and address */ - flags = net_lock(); + net_lock(); /* Verify or select a local port (host byte order) */ @@ -565,7 +564,7 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, return ret; } - net_unlock(flags); + net_unlock(); return OK; } #endif /* CONFIG_NET_IPv4 */ @@ -589,13 +588,12 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn, FAR const struct sockaddr_in6 *addr) { - net_lock_t flags; int port; int ret; /* Verify or select a local port and address */ - flags = net_lock(); + net_lock(); /* Verify or select a local port (host byte order) */ @@ -646,7 +644,7 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn, return ret; } - net_unlock(flags); + net_unlock(); return OK; } #endif /* CONFIG_NET_IPv6 */ @@ -700,14 +698,13 @@ void tcp_initialize(void) FAR struct tcp_conn_s *tcp_alloc(uint8_t domain) { FAR struct tcp_conn_s *conn; - net_lock_t flags; /* Because this routine is called from both interrupt level and * and from user level, we have not option but to disable interrupts * while accessing g_free_tcp_connections[]; */ - flags = net_lock(); + net_lock(); /* Return the entry from the head of the free list */ @@ -786,7 +783,7 @@ FAR struct tcp_conn_s *tcp_alloc(uint8_t domain) } #endif - net_unlock(flags); + net_unlock(); /* Mark the connection allocated */ @@ -818,7 +815,6 @@ void tcp_free(FAR struct tcp_conn_s *conn) #ifdef CONFIG_NET_TCP_WRITE_BUFFERS FAR struct tcp_wrbuffer_s *wrbuffer; #endif - net_lock_t flags; /* Because g_free_tcp_connections is accessed from user level and interrupt * level, code, it is necessary to keep interrupts disabled during this @@ -826,7 +822,7 @@ void tcp_free(FAR struct tcp_conn_s *conn) */ DEBUGASSERT(conn->crefs == 0); - flags = net_lock(); + net_lock(); /* Free remaining callbacks, actually there should be only the close callback * left. @@ -891,7 +887,7 @@ void tcp_free(FAR struct tcp_conn_s *conn) conn->tcpstateflags = TCP_CLOSED; dq_addlast(&conn->node, &g_free_tcp_connections); - net_unlock(flags); + net_unlock(); } /**************************************************************************** @@ -1184,7 +1180,6 @@ int tcp_bind(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr) int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr) { - net_lock_t flags; int port; int ret; @@ -1203,7 +1198,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr) * but the port may still be INPORT_ANY. */ - flags = net_lock(); + net_lock(); #ifdef CONFIG_NETDEV_MULTINIC /* If there are multiple network devices, then we need to pass the local, @@ -1373,7 +1368,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr) ret = OK; errout_with_lock: - net_unlock(flags); + net_unlock(); return ret; } diff --git a/net/tcp/tcp_listen.c b/net/tcp/tcp_listen.c index b4990ba1663..8a10fd9b57f 100644 --- a/net/tcp/tcp_listen.c +++ b/net/tcp/tcp_listen.c @@ -141,11 +141,10 @@ void tcp_listen_initialize(void) int tcp_unlisten(FAR struct tcp_conn_s *conn) { - net_lock_t flags; int ndx; int ret = -EINVAL; - flags = net_lock(); + net_lock(); for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++) { if (tcp_listenports[ndx] == conn) @@ -156,7 +155,7 @@ int tcp_unlisten(FAR struct tcp_conn_s *conn) } } - net_unlock(flags); + net_unlock(); return ret; } @@ -173,7 +172,6 @@ int tcp_unlisten(FAR struct tcp_conn_s *conn) int tcp_listen(FAR struct tcp_conn_s *conn) { - net_lock_t flags; int ndx; int ret; @@ -181,7 +179,7 @@ int tcp_listen(FAR struct tcp_conn_s *conn) * is accessed from interrupt level as well. */ - flags = net_lock(); + net_lock(); /* First, check if there is already a socket listening on this port */ @@ -216,7 +214,7 @@ int tcp_listen(FAR struct tcp_conn_s *conn) } } - net_unlock(flags); + net_unlock(); return ret; } diff --git a/net/tcp/tcp_netpoll.c b/net/tcp/tcp_netpoll.c index 41382144c2f..733c8c89e8d 100644 --- a/net/tcp/tcp_netpoll.c +++ b/net/tcp/tcp_netpoll.c @@ -164,7 +164,6 @@ int tcp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) FAR struct tcp_conn_s *conn = psock->s_conn; FAR struct tcp_poll_s *info; FAR struct devif_callback_s *cb; - net_lock_t flags; int ret; /* Sanity check */ @@ -186,7 +185,7 @@ int tcp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) /* Some of the following must be atomic */ - flags = net_lock(); + net_lock(); /* Allocate a TCP/IP callback structure */ @@ -296,12 +295,12 @@ int tcp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) sem_post(fds->sem); } - net_unlock(flags); + net_unlock(); return OK; errout_with_lock: kmm_free(info); - net_unlock(flags); + net_unlock(); return ret; } @@ -325,7 +324,6 @@ int tcp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) { FAR struct tcp_conn_s *conn = psock->s_conn; FAR struct tcp_poll_s *info; - net_lock_t flags; /* Sanity check */ @@ -344,9 +342,9 @@ int tcp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) { /* Release the callback */ - flags = net_lock(); + net_lock(); tcp_callback_free(conn, info->cb); - net_unlock(flags); + net_unlock(); /* Release the poll/select data slot */ diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index 468f90b9dac..dbb2f28087e 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -948,7 +948,6 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, { FAR struct tcp_conn_s *conn; FAR struct tcp_wrbuffer_s *wrb; - net_lock_t save; ssize_t result = 0; int errcode; int ret = OK; @@ -1019,7 +1018,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, * unlocked here. */ - save = net_lock(); + net_lock(); wrb = tcp_wrbuffer_alloc(); if (!wrb) { @@ -1077,7 +1076,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, /* Notify the device driver of the availability of TX data */ send_txnotify(psock, conn); - net_unlock(save); + net_unlock(); } /* Set the socket state to idle */ @@ -1112,7 +1111,7 @@ errout_with_wrb: tcp_wrbuffer_release(wrb); errout_with_lock: - net_unlock(save); + net_unlock(); errout: set_errno(errcode); diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index 4710c41fe70..385c385a29a 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -720,7 +720,6 @@ ssize_t psock_tcp_send(FAR struct socket *psock, { FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)psock->s_conn; struct send_s state; - net_lock_t save; int errcode; int ret = OK; @@ -792,7 +791,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, * are ready. */ - save = net_lock(); + net_lock(); memset(&state, 0, sizeof(struct send_s)); /* This semaphore is used for signaling and, hence, should not have @@ -854,7 +853,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, } sem_destroy(&state.snd_sem); - net_unlock(save); + net_unlock(); /* Set the socket state to idle */ diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 1f5ecd095c6..964846e91de 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -229,7 +229,7 @@ static uint16_t udp_select_port(void) * listen port number that is not being used by any other connection. */ - net_lock_t flags = net_lock(); + net_lock(); do { /* Guess that the next available port number will be the one after @@ -256,7 +256,7 @@ static uint16_t udp_select_port(void) */ portno = g_last_udp_port; - net_unlock(flags); + net_unlock(); return portno; } @@ -576,7 +576,6 @@ FAR struct udp_conn_s *udp_nextconn(FAR struct udp_conn_s *conn) int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) { - net_lock_t flags; uint16_t portno; int ret; @@ -643,7 +642,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) { /* Interrupts must be disabled while access the UDP connection list */ - flags = net_lock(); + net_lock(); /* Is any other UDP connection already bound to this address and port? */ @@ -659,7 +658,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) ret = OK; } - net_unlock(flags); + net_unlock(); } return ret; diff --git a/net/udp/udp_netpoll.c b/net/udp/udp_netpoll.c index eade182fa12..6dd873aaec0 100644 --- a/net/udp/udp_netpoll.c +++ b/net/udp/udp_netpoll.c @@ -161,7 +161,6 @@ int udp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) FAR struct udp_conn_s *conn = psock->s_conn; FAR struct udp_poll_s *info; FAR struct devif_callback_s *cb; - net_lock_t flags; int ret; /* Sanity check */ @@ -183,7 +182,7 @@ int udp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) /* Some of the following must be atomic */ - flags = net_lock(); + net_lock(); /* Get the device that will provide the provide the NETDEV_DOWN event. * NOTE: in the event that the local socket is bound to INADDR_ANY, the @@ -262,12 +261,12 @@ int udp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) sem_post(fds->sem); } - net_unlock(flags); + net_unlock(); return OK; errout_with_lock: kmm_free(info); - net_unlock(flags); + net_unlock(); return ret; } @@ -291,7 +290,6 @@ int udp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) { FAR struct udp_conn_s *conn = psock->s_conn; FAR struct udp_poll_s *info; - net_lock_t flags; /* Sanity check */ @@ -310,9 +308,9 @@ int udp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) { /* Release the callback */ - flags = net_lock(); + net_lock(); udp_callback_free(info->dev, conn, info->cb); - net_unlock(flags); + net_unlock(); /* Release the poll/select data slot */ diff --git a/net/udp/udp_psock_sendto.c b/net/udp/udp_psock_sendto.c index 7ae830c5b78..84564f8a7e2 100644 --- a/net/udp/udp_psock_sendto.c +++ b/net/udp/udp_psock_sendto.c @@ -340,7 +340,6 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, FAR struct udp_conn_s *conn; FAR struct net_driver_s *dev; struct sendto_s state; - net_lock_t save; int ret; #if defined(CONFIG_NET_ARP_SEND) || defined(CONFIG_NET_ICMPv6_NEIGHBOR) @@ -390,7 +389,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, * are ready. */ - save = net_lock(); + net_lock(); memset(&state, 0, sizeof(struct sendto_s)); /* This semaphore is used for signaling and, hence, should not have @@ -484,7 +483,7 @@ errout_with_lock: /* Unlock the network and return the result of the sendto() operation */ - net_unlock(save); + net_unlock(); return ret; } diff --git a/net/utils/Make.defs b/net/utils/Make.defs index 5abcb9226c7..270b80bbbe8 100644 --- a/net/utils/Make.defs +++ b/net/utils/Make.defs @@ -36,7 +36,7 @@ # Common utilities NET_CSRCS += net_dsec2tick.c net_dsec2timeval.c net_timeval2dsec.c -NET_CSRCS += net_chksum.c +NET_CSRCS += net_chksum.c net_lock.c # IPv6 utilities @@ -44,12 +44,6 @@ ifeq ($(CONFIG_NET_IPv6),y) NET_CSRCS += net_ipv6_maskcmp.c net_ipv6_mask2pref.c net_ipv6_pref2mask.c endif -# Non-interrupt level support required? - -ifeq ($(CONFIG_NET_NOINTS),y) -NET_CSRCS += net_lock.c -endif - # Include utility build support DEPPATH += --dep-path utils diff --git a/net/utils/net_lock.c b/net/utils/net_lock.c index 49ce834070f..fbd42342aee 100644 --- a/net/utils/net_lock.c +++ b/net/utils/net_lock.c @@ -51,8 +51,6 @@ #include "utils/utils.h" -#if defined(CONFIG_NET) && defined(CONFIG_NET_NOINTS) - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -116,7 +114,7 @@ void net_lockinitialize(void) * ****************************************************************************/ -net_lock_t net_lock(void) +void net_lock(void) { pid_t me = getpid(); @@ -139,8 +137,6 @@ net_lock_t net_lock(void) g_holder = me; g_count = 1; } - - return 0; } /**************************************************************************** @@ -151,7 +147,7 @@ net_lock_t net_lock(void) * ****************************************************************************/ -void net_unlock(net_lock_t flags) +void net_unlock(void) { DEBUGASSERT(g_holder == getpid() && g_count > 0); @@ -261,4 +257,3 @@ int net_lockedwait(sem_t *sem) return net_timedwait(sem, NULL); } -#endif /* CONFIG_NET */ diff --git a/net/utils/utils.h b/net/utils/utils.h index 355e75e51e7..6e33b72a83b 100644 --- a/net/utils/utils.h +++ b/net/utils/utils.h @@ -84,11 +84,7 @@ struct timeval; /* Forward reference */ * ****************************************************************************/ -#ifdef CONFIG_NET_NOINTS void net_lockinitialize(void); -#else -# define net_lockinitialize() -#endif /**************************************************************************** * Function: net_dsec2timeval