drivers/net: Add option to use low-priority work queue to all drivers in drivers/net. Not yet added to all architecture-specific network drivers.

This commit is contained in:
Gregory Nutt
2016-11-18 09:22:49 -06:00
parent 52560bba37
commit 936b55f608
8 changed files with 172 additions and 45 deletions
+57
View File
@@ -16,6 +16,27 @@ config NETDEV_LOOPBACK
networking devices that are enabled must be compatible with networking devices that are enabled must be compatible with
CONFIG_NET_NOINTS. CONFIG_NET_NOINTS.
if NETDEV_LOOPBACK
choice
prompt "Work queue"
default LOOPBACK_LPWORK if SCHED_LPWORK
default LOOPBACK_HPWORK if !SCHED_LPWORK && SCHED_HPWORK
depends on SCHED_WORKQUEUE
---help---
Work queue support is required to use the LOOPBACK driver. If the low priority work queue is available, then it should be used by the LOOPBACK.
config LOOPBACK_HPWORK
bool "High priority"
depends on SCHED_HPWORK
config LOOPBACK_LPWORK
bool "Low priority"
depends on SCHED_LPWORK
endchoice # Work queue
endif # NETDEV_LOOPBACK
config NETDEV_TELNET config NETDEV_TELNET
bool "Telnet driver" bool "Telnet driver"
default n default n
@@ -305,6 +326,24 @@ config ENCX24J600_NRXDESCR
The ENC has a relative large packet buffer of 24kB which can The ENC has a relative large packet buffer of 24kB which can
be used to buffer multiple packets silmutaneously be used to buffer multiple packets silmutaneously
choice
prompt "Work queue"
default ENCX24J600_LPWORK if SCHED_LPWORK
default ENCX24J600_HPWORK if !SCHED_LPWORK && SCHED_HPWORK
depends on SCHED_WORKQUEUE
---help---
Work queue support is required to use the ENCX24J600 driver. If the low priority work queue is available, then it should be used by the ENCX24J600.
config ENCX24J600_HPWORK
bool "High priority"
depends on SCHED_HPWORK
config ENCX24J600_LPWORK
bool "Low priority"
depends on SCHED_LPWORK
endchoice # Work queue
config ENCX24J600_DUMPPACKET config ENCX24J600_DUMPPACKET
bool "Dump Packets" bool "Dump Packets"
default n default n
@@ -399,6 +438,24 @@ config FTMAC100_MAC0_ENV_ADDR
hex "MAC0 address location" hex "MAC0 address location"
default 0 default 0
choice
prompt "Work queue"
default FTMAC100_LPWORK if SCHED_LPWORK
default FTMAC100_HPWORK if !SCHED_LPWORK && SCHED_HPWORK
depends on SCHED_WORKQUEUE
---help---
Work queue support is required to use the FTMAC100 driver. If the low priority work queue is available, then it should be used by the FTMAC100.
config FTMAC100_HPWORK
bool "High priority"
depends on SCHED_HPWORK
config FTMAC100_LPWORK
bool "Low priority"
depends on SCHED_LPWORK
endchoice # Work queue
endif # NET_FTMAC100 endif # NET_FTMAC100
menuconfig NET_VNET menuconfig NET_VNET
+1 -1
View File
@@ -138,7 +138,7 @@
/* The ENC28J60 will not do interrupt level processing */ /* The ENC28J60 will not do interrupt level processing */
#ifndef CONFIG_NET_NOINTS #ifndef CONFIG_NET_NOINTS
# warrning "CONFIG_NET_NOINTS should be set" # warning "CONFIG_NET_NOINTS should be set"
#endif #endif
/* Low-level register debug */ /* Low-level register debug */
+14 -6
View File
@@ -120,8 +120,16 @@
/* We need to have the work queue to handle SPI interrupts */ /* We need to have the work queue to handle SPI interrupts */
#ifndef CONFIG_SCHED_WORKQUEUE #if !defined(CONFIG_SCHED_WORKQUEUE)
# error "Worker thread support is required (CONFIG_SCHED_WORKQUEUE)" # error "Worker thread support is required (CONFIG_SCHED_WORKQUEUE)"
#else
# if defined(CONFIG_ENCX24J600_HPWORK)
# define ENCWORK HPWORK
# elif defined(CONFIG_ENCX24J600_LPWORK)
# define ENCWORK LPWORK
# else
# error "Neither CONFIG_ENCX24J600_HPWORK nor CONFIG_ENCX24J600_LPWORK defined"
# endif
#endif #endif
/* CONFIG_ENCX24J600_DUMPPACKET will dump the contents of each packet to the console. */ /* CONFIG_ENCX24J600_DUMPPACKET will dump the contents of each packet to the console. */
@@ -482,7 +490,7 @@ static inline void enc_setethrst(FAR struct enc_driver_s *priv)
{ {
DEBUGASSERT(priv && priv->spi); DEBUGASSERT(priv && priv->spi);
/* Select ENC28J60 chip */ /* Select ENCX24J600 chip */
SPI_SELECT(priv->spi, SPIDEV_ETHERNET, true); SPI_SELECT(priv->spi, SPIDEV_ETHERNET, true);
@@ -492,7 +500,7 @@ static inline void enc_setethrst(FAR struct enc_driver_s *priv)
up_udelay(25); up_udelay(25);
/* De-select ENC28J60 chip. */ /* De-select ENCX24J600 chip. */
SPI_SELECT(priv->spi, SPIDEV_ETHERNET, false); SPI_SELECT(priv->spi, SPIDEV_ETHERNET, false);
enc_cmddump(ENC_SETETHRST); enc_cmddump(ENC_SETETHRST);
@@ -2017,7 +2025,7 @@ static int enc_interrupt(int irq, FAR void *context)
*/ */
priv->lower->disable(priv->lower); priv->lower->disable(priv->lower);
return work_queue(HPWORK, &priv->irqwork, enc_irqworker, (FAR void *)priv, 0); return work_queue(ENCWORK, &priv->irqwork, enc_irqworker, (FAR void *)priv, 0);
} }
/**************************************************************************** /****************************************************************************
@@ -2109,7 +2117,7 @@ static void enc_txtimeout(int argc, uint32_t arg, ...)
* can occur until we restart the Tx timeout watchdog. * can occur until we restart the Tx timeout watchdog.
*/ */
ret = work_queue(HPWORK, &priv->towork, enc_toworker, (FAR void *)priv, 0); ret = work_queue(ENCWORK, &priv->towork, enc_toworker, (FAR void *)priv, 0);
(void)ret; (void)ret;
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
} }
@@ -2204,7 +2212,7 @@ static void enc_polltimer(int argc, uint32_t arg, ...)
* occur until we restart the poll timeout watchdog. * occur until we restart the poll timeout watchdog.
*/ */
ret = work_queue(HPWORK, &priv->pollwork, enc_pollworker, (FAR void *)priv, 0); ret = work_queue(ENCWORK, &priv->pollwork, enc_pollworker, (FAR void *)priv, 0);
(void)ret; (void)ret;
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
} }
+22 -10
View File
@@ -72,12 +72,24 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* If processing is not done at the interrupt level, then high priority /* If processing is not done at the interrupt level, then work queue support
* work queue support is required. * is required.
*/ */
#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_HPWORK) #if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE)
# error High priority work queue support is required # error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE)
#endif
/* 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)
# define FTMAWORK LPWORK
# else
# error Neither CONFIG_FTMAC100_HPWORK nor CONFIG_FTMAC100_LPWORK defined
# endif
#endif #endif
/* CONFIG_FTMAC100_NINTERFACES determines the number of physical interfaces /* CONFIG_FTMAC100_NINTERFACES determines the number of physical interfaces
@@ -1049,11 +1061,11 @@ static int ftmac100_interrupt(int irq, FAR void *context)
/* Cancel any pending poll work */ /* Cancel any pending poll work */
work_cancel(HPWORK, &priv->ft_work); work_cancel(FTMAWORK, &priv->ft_work);
/* Schedule to perform the interrupt processing on the worker thread. */ /* Schedule to perform the interrupt processing on the worker thread. */
work_queue(HPWORK, &priv->ft_work, ftmac100_interrupt_work, priv, 0); work_queue(FTMAWORK, &priv->ft_work, ftmac100_interrupt_work, priv, 0);
leave_critical_section(flags); leave_critical_section(flags);
#else #else
@@ -1160,11 +1172,11 @@ static void ftmac100_txtimeout_expiry(int argc, uint32_t arg, ...)
* on work that has already been started. * on work that has already been started.
*/ */
work_cancel(HPWORK, &priv->ft_work); work_cancel(FTMAWORK, &priv->ft_work);
/* Schedule to perform the TX timeout processing on the worker thread. */ /* Schedule to perform the TX timeout processing on the worker thread. */
work_queue(HPWORK, &priv->ft_work, ftmac100_txtimeout_work, priv, 0); work_queue(FTMAWORK, &priv->ft_work, ftmac100_txtimeout_work, priv, 0);
#else #else
/* Process the timeout now */ /* Process the timeout now */
@@ -1270,7 +1282,7 @@ static void ftmac100_poll_expiry(int argc, uint32_t arg, ...)
{ {
/* Schedule to perform the interrupt processing on the worker thread. */ /* Schedule to perform the interrupt processing on the worker thread. */
work_queue(HPWORK, &priv->ft_work, ftmac100_poll_work, priv, 0); work_queue(FTMAWORK, &priv->ft_work, ftmac100_poll_work, priv, 0);
} }
else else
{ {
@@ -1491,7 +1503,7 @@ static int ftmac100_txavail(struct net_driver_s *dev)
{ {
/* Schedule to serialize the poll on the worker thread. */ /* Schedule to serialize the poll on the worker thread. */
work_queue(HPWORK, &priv->ft_work, ftmac100_txavail_work, priv, 0); work_queue(FTMAWORK, &priv->ft_work, ftmac100_txavail_work, priv, 0);
} }
#else #else
+16 -4
View File
@@ -67,12 +67,24 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Non-network-driven configuration is required */
#ifndef CONFIG_NET_NOINTS #ifndef CONFIG_NET_NOINTS
# error CONFIG_NET_NOINTS must be selected # error CONFIG_NET_NOINTS must be selected
#endif #endif
#ifndef CONFIG_SCHED_HPWORK /* We need to have the work queue to handle SPI interrupts */
# error High priority work queue support is required (CONFIG_SCHED_HPWORK)
#if !defined(CONFIG_SCHED_WORKQUEUE)
# error Worker thread support is required (CONFIG_SCHED_WORKQUEUE)
#else
# if defined(CONFIG_LOOPBACK_HPWORK)
# define LPBKWORK HPWORK
# elif defined(CONFIG_LOOPBACK_LPWORK)
# define LPBKWORK LPWORK
# else
# error Neither CONFIG_LOOPBACK_HPWORK nor CONFIG_LOOPBACK_LPWORK defined
# endif
#endif #endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
@@ -289,7 +301,7 @@ static void lo_poll_expiry(int argc, wdparm_t arg, ...)
{ {
/* Schedule to perform the interrupt processing on the worker thread. */ /* Schedule to perform the interrupt processing on the worker thread. */
work_queue(HPWORK, &priv->lo_work, lo_poll_work, priv, 0); work_queue(LPBKWORK, &priv->lo_work, lo_poll_work, priv, 0);
} }
else else
{ {
@@ -444,7 +456,7 @@ static int lo_txavail(FAR struct net_driver_s *dev)
{ {
/* Schedule to serialize the poll on the worker thread. */ /* Schedule to serialize the poll on the worker thread. */
work_queue(HPWORK, &priv->lo_work, lo_txavail_work, priv, 0); work_queue(LPBKWORK, &priv->lo_work, lo_txavail_work, priv, 0);
} }
return OK; return OK;
+21 -9
View File
@@ -67,12 +67,24 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* If processing is not done at the interrupt level, then high priority /* If processing is not done at the interrupt level, then work queue support
* work queue support is required. * is required.
*/ */
#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_HPWORK) #if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE)
# error High priority work queue support is required # error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE)
#endif
/* Use the low priority work queue if possible */
#if defined(CONFIG_SCHED_WORKQUEUE)
# if defined(CONFIG_skeleton_HPWORK)
# define skelWORK HPWORK
# elif defined(CONFIG_skeleton_LPWORK)
# define skelWORK LPWORK
# else
# error Neither CONFIG_skeleton_HPWORK nor CONFIG_skeleton_LPWORK defined
# endif
#endif #endif
/* CONFIG_skeleton_NINTERFACES determines the number of physical interfaces /* CONFIG_skeleton_NINTERFACES determines the number of physical interfaces
@@ -598,7 +610,7 @@ static int skel_interrupt(int irq, FAR void *context)
/* Schedule to perform the interrupt processing on the worker thread. */ /* Schedule to perform the interrupt processing on the worker thread. */
work_queue(HPWORK, &priv->sk_work, skel_interrupt_work, priv, 0); work_queue(skelWORK, &priv->sk_work, skel_interrupt_work, priv, 0);
#else #else
/* Process the interrupt now */ /* Process the interrupt now */
@@ -705,11 +717,11 @@ static void skel_txtimeout_expiry(int argc, wdparm_t arg, ...)
* on work that has already been started. * on work that has already been started.
*/ */
work_cancel(HPWORK, &priv->sk_work); work_cancel(skelWORK, &priv->sk_work);
/* Schedule to perform the TX timeout processing on the worker thread. */ /* Schedule to perform the TX timeout processing on the worker thread. */
work_queue(HPWORK, &priv->sk_work, skel_txtimeout_work, priv, 0); work_queue(skelWORK, &priv->sk_work, skel_txtimeout_work, priv, 0);
#else #else
/* Process the timeout now */ /* Process the timeout now */
@@ -815,7 +827,7 @@ static void skel_poll_expiry(int argc, wdparm_t arg, ...)
{ {
/* Schedule to perform the interrupt processing on the worker thread. */ /* Schedule to perform the interrupt processing on the worker thread. */
work_queue(HPWORK, &priv->sk_work, skel_poll_work, priv, 0); work_queue(skelWORK, &priv->sk_work, skel_poll_work, priv, 0);
} }
else else
{ {
@@ -1026,7 +1038,7 @@ static int skel_txavail(FAR struct net_driver_s *dev)
{ {
/* Schedule to serialize the poll on the worker thread. */ /* Schedule to serialize the poll on the worker thread. */
work_queue(HPWORK, &priv->sk_work, skel_txavail_work, priv, 0); work_queue(skelWORK, &priv->sk_work, skel_txavail_work, priv, 0);
} }
#else #else
+14 -4
View File
@@ -79,8 +79,18 @@
* work queue support is required. * work queue support is required.
*/ */
#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_HPWORK) #if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_WORKQUEUE)
# error High priority work queue support is required # error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE)
#endif
#if defined(CONFIG_SCHED_WORKQUEUE)
# if defined(CONFIG_TUN_HPWORK)
# define TUNWORK HPWORK
# elif defined(CONFIG_TUN_LPWORK)
# define TUNWORK LPWORK
# else
# error "Neither CONFIG_TUN_HPWORK nor CONFIG_TUN_LPWORK defined"
# endif
#endif #endif
/* CONFIG_TUN_NINTERFACES determines the number of physical interfaces /* CONFIG_TUN_NINTERFACES determines the number of physical interfaces
@@ -622,9 +632,9 @@ static void tun_poll_expiry(int argc, wdparm_t arg, ...)
if (work_available(&priv->work)) if (work_available(&priv->work))
{ {
/* Schedule to perform the interrupt processing on the worker thread. */ /* Schedule to perform the timer expiration on the worker thread. */
work_queue(HPWORK, &priv->work, tun_poll_work, priv, 0); work_queue(TUNWORK, &priv->work, tun_poll_work, priv, 0);
} }
else else
{ {
+27 -11
View File
@@ -117,17 +117,6 @@ config NET_SLIP_TCP_RECVWNDO
incoming data, or high (32768 bytes) if the application processes incoming data, or high (32768 bytes) if the application processes
data quickly. data quickly.
config NET_TUN_MTU
int "TUN packet buffer size (MTU)"
default 296
depends on NET_TUN
range 296 1518
config NET_TUN_TCP_RECVWNDO
int "TUN TCP receive window size"
default 256
depends on NET_TUN && NET_TCP
config NET_GUARDSIZE config NET_GUARDSIZE
int "Driver I/O guard size" int "Driver I/O guard size"
default 2 default 2
@@ -242,6 +231,33 @@ config TUN_NINTERFACES
interfaces to support. interfaces to support.
Default: 1 Default: 1
config NET_TUN_MTU
int "TUN packet buffer size (MTU)"
default 296
range 296 1518
config NET_TUN_TCP_RECVWNDO
int "TUN TCP receive window size"
default 256
depends on NET_TCP
choice
prompt "Work queue"
default LOOPBACK_LPWORK if SCHED_LPWORK
default TUN_HPWORK if !SCHED_LPWORK && SCHED_HPWORK
depends on SCHED_WORKQUEUE
---help---
Work queue support is required to use the TUN driver. If the low priority work queue is available, then it should be used by the TUN.
config TUN_HPWORK
bool "High priority"
depends on SCHED_HPWORK
config TUN_LPWORK
bool "Low priority"
depends on SCHED_LPWORK
endchoice # Work queue
endif # NET_TUN endif # NET_TUN
endmenu # Data link support endmenu # Data link support