mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
Update drivers/net/skeleton.c
This commit is contained in:
+40
-13
@@ -106,7 +106,7 @@ struct skel_driver_s
|
|||||||
WDOG_ID sk_txpoll; /* TX poll timer */
|
WDOG_ID sk_txpoll; /* TX poll timer */
|
||||||
WDOG_ID sk_txtimeout; /* TX timeout timer */
|
WDOG_ID sk_txtimeout; /* TX timeout timer */
|
||||||
#ifdef CONFIG_NET_NOINTS
|
#ifdef CONFIG_NET_NOINTS
|
||||||
struct work_s work; /* For deferring work to the work queue */
|
struct work_s sk_work; /* For deferring work to the work queue */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This holds the information visible to uIP/NuttX */
|
/* This holds the information visible to uIP/NuttX */
|
||||||
@@ -397,7 +397,7 @@ static inline void skel_interrupt_process(FAR struct skel_driver_s *skel)
|
|||||||
* Perform interrupt related work from the worker thread
|
* Perform interrupt related work from the worker thread
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* arg - The argument passed when work_queue() as called.
|
* arg - The argument passed when work_queue() was called.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success
|
* OK on success
|
||||||
@@ -442,14 +442,18 @@ static int skel_interrupt(int irq, FAR void *context)
|
|||||||
FAR struct skel_driver_s *skel = &g_skel[0];
|
FAR struct skel_driver_s *skel = &g_skel[0];
|
||||||
|
|
||||||
#ifdef CONFIG_NET_NOINTS
|
#ifdef CONFIG_NET_NOINTS
|
||||||
/* TODO: Disable further Ethernet interrupts */
|
/* TODO: Disable further Ethernet interrupts. Because Ethernet interrupts
|
||||||
|
* are also disabled if the TX timeout event occurs, there can be no race
|
||||||
/* Schedule to perform the interrupt processing on the worker thread.
|
* condition here.
|
||||||
* TODO: Assure that no timeouts can occur.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUGASSERT(work_available(&skel->work);
|
/* Cancel any pending poll work */
|
||||||
work_queue(HPWORK, &skel->work, skel_interrupt_work, skel, 0);
|
|
||||||
|
work_cancel(HPWORK, skel->sk_work);
|
||||||
|
|
||||||
|
/* Schedule to perform the interrupt processing on the worker thread. */
|
||||||
|
|
||||||
|
work_queue(HPWORK, &skel->sk_work, skel_interrupt_work, skel, 0);
|
||||||
#else
|
#else
|
||||||
/* Process the interrupt now */
|
/* Process the interrupt now */
|
||||||
|
|
||||||
@@ -542,14 +546,22 @@ static void skel_txtimeout(int argc, uint32_t arg, ...)
|
|||||||
FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)arg;
|
FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)arg;
|
||||||
|
|
||||||
#ifdef CONFIG_NET_NOINTS
|
#ifdef CONFIG_NET_NOINTS
|
||||||
/* TODO: Disable further Ethernet interrupts */
|
/* TODO: 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Cancel any pending poll or interrupt work. This will have not effect
|
||||||
|
* on work that has already been started.
|
||||||
|
*/
|
||||||
|
|
||||||
|
work_cancel(HPWORK, skel->sk_work);
|
||||||
|
|
||||||
/* Schedule to perform the TX timeout processing on the worker thread.
|
/* Schedule to perform the TX timeout processing on the worker thread.
|
||||||
* TODO: Assure that no there is not pending interrupt or poll work.
|
* TODO: Assure that no there is not pending interrupt or poll work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUGASSERT(work_available(&skel->work);
|
work_queue(HPWORK, &skel->sk_work, skel_txtimeout_work, skel, 0);
|
||||||
work_queue(HPWORK, &skel->work, skel_txtimeout_work, skel, 0);
|
|
||||||
#else
|
#else
|
||||||
/* Process the interrupt now */
|
/* Process the interrupt now */
|
||||||
|
|
||||||
@@ -643,12 +655,27 @@ static void skel_polltimer(int argc, uint32_t arg, ...)
|
|||||||
FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)arg;
|
FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)arg;
|
||||||
|
|
||||||
#ifdef CONFIG_NET_NOINTS
|
#ifdef CONFIG_NET_NOINTS
|
||||||
|
/* Is our single work structure available? It may not be if there are
|
||||||
|
* pending interrupt actions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (work_available(&skel->sk_work)
|
||||||
|
{
|
||||||
/* Schedule to perform the interrupt processing on the worker thread.
|
/* Schedule to perform the interrupt processing on the worker thread.
|
||||||
* TODO: Make sure that there can be no pending interrupt work.
|
* TODO: Make sure that there can be no pending interrupt work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUGASSERT(work_available(&skel->work);
|
work_queue(HPWORK, &skel->sk_work, skel_poll_work, skel, 0);
|
||||||
work_queue(HPWORK, &skel->work, skel_poll_work, skel, 0);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* No.. Just re-start the watchdog poll timer, missing one polling
|
||||||
|
* cycle.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(void)wd_start(skel->sk_txpoll, skeleton_WDDELAY, skel_polltimer, 1, arg);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* Process the interrupt now */
|
/* Process the interrupt now */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user