From 86769101a1c96709b45a800e8b136b53de16d6b6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Aug 2015 14:32:12 -0600 Subject: [PATCH] SLIP: Review code, update comments, add missing configuration items --- drivers/net/Kconfig | 59 ++++++++++++++++++++++++++++++++++------ drivers/net/slip.c | 55 +++++++++++++++++++------------------ include/nuttx/net/slip.h | 41 +++++++++++++++++++++++++--- 3 files changed, 116 insertions(+), 39 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index dc9890ee64..f76a228380 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -52,7 +52,7 @@ config NET_DUMPPACKET comment "External Ethernet MAC Device Support" -config NET_DM90x0 +menuconfig NET_DM90x0 bool "Davicom dm9000/dm9010 support" default n ---help--- @@ -132,7 +132,7 @@ config NET_CS89x0 ---help--- Under construction -- do not use -config ENC28J60 +menuconfig ENC28J60 bool "Microchip ENC28J60 support" default n select SPI @@ -142,6 +142,7 @@ config ENC28J60 DS39662C, 2008 Microchip Technology Inc. if ENC28J60 + config ENC28J60_NINTERFACES int "Number of physical ENC28J60" default 1 @@ -192,9 +193,9 @@ config ENC28J60_REGDEBUG ---help--- Enable very low-level register access debug. Depends on DEBUG and DEBUG_NET. -endif +endif # ENC28J60 -config ENCX24J600 +menuconfig ENCX24J600 bool "Microchip ENCX24J600 support" default n select SPI @@ -205,6 +206,7 @@ config ENCX24J600 with SPI or Parallel Interface DS39935B, 2009 Microchip Technology Inc. if ENCX24J600 + config ENC28J60_NINTERFACES int "Number of physical ENCX24J600" default 1 @@ -258,9 +260,9 @@ config ENCX24J600_REGDEBUG ---help--- Enable very low-level register access debug. Depends on DEBUG and DEBUG_NET. -endif +endif # ENCX24J600 -config NET_E1000 +menuconfig NET_E1000 bool "E1000 support" default n @@ -280,13 +282,52 @@ config E1000_BUFF_SIZE endif # NET_E1000 -config NET_SLIP +menuconfig NET_SLIP bool "SLIP (serial line) support" default n ---help--- Reference: RFC 1055 -config NET_FTMAC100 +if NET_SLIP + +config NET_SLIP_STACKSIZE + int "Daemon stack size" + default 2048 + ---help--- + Provides the stack size for SLIP RX and TX. + +config NET_SLIP_DEFPRIO + int "Daemon priority" + default 128 + ---help--- + Provides the priority for SLIP RX and TX threads. + +config NET_SLIP_MTU + int "Packet size (MTU)" + default 296 + ---help--- + Provides the size of the SLIP packet buffers. + + The Linux slip module hard-codes its MTU size to 296 (40 bytes for + the IP+TPC headers plus 256 bytes of data). So you might as well + set CONFIG_NET_SLIP_MTU to 296 as well. + + There may be an issue with this setting, however. I see that Linux + uses a MTU of 296 and window of 256, but actually only sends 168 + bytes of data: 40 + 128. I believe that is to allow for the 2x + worst cast packet expansion. Ideally we would like to advertise the + 256 MSS, but restrict transfers to 128 bytes (possibly by modifying + the tcp_mss() macro). + +config SLIP_NINTERFACES + int "Number of SLIP interfaces" + default 1 + ---help--- + Determines the number of physical interfaces that will be supported. + +endif + +menuconfig NET_FTMAC100 bool "Faraday 10/100 Ethernet" default n ---help--- @@ -316,7 +357,7 @@ config FTMAC100_MAC0_ENV_ADDR endif # NET_FTMAC100 -config NET_VNET +menuconfig NET_VNET bool "VNET support" default n diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 8333017ae8..4b02475b83 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -83,12 +83,12 @@ # warning "CONFIG_NET_MULTIBUFFER must be set" #endif -#ifndef CONFIG_SLIP_STACKSIZE -# define CONFIG_SLIP_STACKSIZE 2048 +#ifndef CONFIG_NET_SLIP_STACKSIZE +# define CONFIG_NET_SLIP_STACKSIZE 2048 #endif -#ifndef CONFIG_SLIP_DEFPRIO -# define CONFIG_SLIP_DEFPRIO 128 +#ifndef CONFIG_NET_SLIP_DEFPRIO +# define CONFIG_NET_SLIP_DEFPRIO 128 #endif /* The Linux slip module hard-codes its MTU size to 296 (40 bytes for the @@ -99,7 +99,7 @@ * a MTU of 296 and window of 256, but actually only sends 168 bytes of data: * 40 + 128. I believe that is to allow for the 2x worst cast packet * expansion. Ideally we would like to advertise the 256 MSS, but restrict - * uIP to 128 bytes (possibly by modifying the tcp_mss() macro). + * transfers to 128 bytes (possibly by modifying the tcp_mss() macro). */ #if CONFIG_NET_SLIP_MTU < 296 @@ -250,7 +250,7 @@ static void slip_semtake(FAR struct slip_driver_s *priv) * Description: * Just an inline wrapper around fwrite with error checking. * - * Parameters: + * Input Parameters: * priv - Reference to the driver state structure * buffer - Buffer data to send * len - Buffer length in bytes @@ -274,7 +274,7 @@ static inline void slip_write(FAR struct slip_driver_s *priv, * Description: * Just an inline wrapper around putc with error checking. * - * Parameters: + * Input Parameters: * priv - Reference to the driver state structure * ch - The character to send * @@ -293,7 +293,7 @@ static inline void slip_putc(FAR struct slip_driver_s *priv, int ch) * Start hardware transmission. Called either from the txdone interrupt * handling or from watchdog based polling. * - * Parameters: + * Input Parameters: * priv - Reference to the driver state structure * * Returned Value: @@ -407,7 +407,7 @@ static int slip_transmit(FAR struct slip_driver_s *priv) * 1. When the preceding TX packet send is complete, or * 2. During normal periodic polling * - * Parameters: + * Input Parameters: * dev - Reference to the NuttX driver state structure * * Returned Value: @@ -444,7 +444,7 @@ static int slip_txpoll(FAR struct net_driver_s *dev) * Description: * Polling and transmission is performed on tx thread. * - * Parameters: + * Input Parameters: * arg - Reference to the NuttX driver state structure * * Returned Value: @@ -535,7 +535,7 @@ static void slip_txtask(int argc, FAR char *argv[]) * Description: * Get one byte from the serial input. * - * Parameters: + * Input Parameters: * priv - Reference to the driver state structure * * Returned Value: @@ -561,7 +561,7 @@ static inline int slip_getc(FAR struct slip_driver_s *priv) * Description: * Read a packet from the serial input * - * Parameters: + * Input Parameters: * priv - Reference to the driver state structure * * Returned Value: @@ -666,7 +666,7 @@ static inline void slip_receive(FAR struct slip_driver_s *priv) * Description: * Wait for incoming data. * - * Parameters: + * Input Parameters: * argc * argv * @@ -786,7 +786,7 @@ static int slip_rxtask(int argc, FAR char *argv[]) * NuttX Callback: Bring up the Ethernet interface when an IP address is * provided * - * Parameters: + * Input Parameters: * dev - Reference to the NuttX driver state structure * * Returned Value: @@ -816,7 +816,7 @@ static int slip_ifup(FAR struct net_driver_s *dev) * Description: * NuttX Callback: Stop the interface. * - * Parameters: + * Input Parameters: * dev - Reference to the NuttX driver state structure * * Returned Value: @@ -844,7 +844,7 @@ static int slip_ifdown(FAR struct net_driver_s *dev) * stimulus perform an out-of-cycle poll and, thereby, reduce the TX * latency. * - * Parameters: + * Input Parameters: * dev - Reference to the NuttX driver state structure * * Returned Value: @@ -876,7 +876,7 @@ static int slip_txavail(FAR struct net_driver_s *dev) * NuttX Callback: Add the specified MAC address to the hardware multicast * address filtering * - * Parameters: + * Input Parameters: * dev - Reference to the NuttX driver state structure * mac - The MAC address to be added * @@ -905,7 +905,7 @@ static int slip_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) * NuttX Callback: Remove the specified MAC address from the hardware multicast * address filtering * - * Parameters: + * Input Parameters: * dev - Reference to the NuttX driver state structure * mac - The MAC address to be removed * @@ -937,9 +937,12 @@ static int slip_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) * Description: * Instantiate a SLIP network interface. * - * Parameters: - * intf - In the case where there are multiple SLIP interfaces, this value - * identifies which is to be initialized. + * Input Parameters: + * intf - In the case where there are multiple SLIP interfaces, this + * value identifies which is to be initialized. The number of + * possible SLIP interfaces is determined by + * devname - This is the path to the serial device that will support SLIP. + * For example, this might be "/dev/ttyS1" * * Returned Value: * OK on success; Negated errno on failure. @@ -996,9 +999,9 @@ int slip_initialize(int intf, FAR const char *devname) argv[0] = buffer; argv[1] = NULL; - priv->rxpid = task_create("rxslip", CONFIG_SLIP_DEFPRIO, - CONFIG_SLIP_STACKSIZE, (main_t)slip_rxtask, - (FAR char * const *)argv); + priv->rxpid = task_create("rxslip", CONFIG_NET_SLIP_DEFPRIO, + CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_rxtask, + (FAR char * const *)argv); if (priv->rxpid < 0) { ndbg("ERROR: Failed to start receiver task\n"); @@ -1011,8 +1014,8 @@ int slip_initialize(int intf, FAR const char *devname) /* Start the SLIP transmitter task */ - priv->txpid = task_create("txslip", CONFIG_SLIP_DEFPRIO, - CONFIG_SLIP_STACKSIZE, (main_t)slip_txtask, + priv->txpid = task_create("txslip", CONFIG_NET_SLIP_DEFPRIO, + CONFIG_NET_SLIP_STACKSIZE, (main_t)slip_txtask, (FAR char * const *)argv); if (priv->txpid < 0) { diff --git a/include/nuttx/net/slip.h b/include/nuttx/net/slip.h index 9baf7a6b3d..cfd1a3c8ad 100644 --- a/include/nuttx/net/slip.h +++ b/include/nuttx/net/slip.h @@ -48,8 +48,38 @@ #ifdef CONFIG_NET_SLIP /**************************************************************************** - * Public Type Definitions + * Pre-processor Definitions ****************************************************************************/ +/* Configuration ***********************************************************/ +/* Dependencies: + * + * CONFIG_NET_NOINTS - Required. + * CONFIG_NET_MULTIBUFFER - Required. + * + * SLIP Configuration: + * + * CONFIG_NET_SLIP - Enables building of the SLIP driver + * CONFIG_SLIP_STACKSIZE - Provides the stack size for SLIP RX and TX + * threads. Default: 2048 + * CONFIG_SLIP_DEFPRIO - Provides the priority for SLIP RX and TX threads. + * Default 128. + * CONFIG_NET_SLIP_MTU - Provides the size of the SLIP packet buffers. + * Default 296 + * + * The Linux slip module hard-codes its MTU size to 296 (40 bytes for the + * IP+TPC headers plus 256 bytes of data). So you might as well set + * CONFIG_NET_SLIP_MTU to 296 as well. + * + * There may be an issue with this setting, however. I see that Linux + * uses a MTU of 296 and window of 256, but actually only sends 168 bytes + * of data: 40 + 128. I believe that is to allow for the 2x worst cast + * packet expansion. Ideally we would like to advertise the 256 MSS, + * but restrict transfers to 128 bytes (possibly by modifying the tcp_mss() + * macro). + * + * CONFIG_SLIP_NINTERFACES determines the number of physical interfaces + * that will be supported. + */ /**************************************************************************** * Public Data @@ -73,9 +103,12 @@ extern "C" * Description: * Instantiate a SLIP network interface. * - * Parameters: - * intf - In the case where there are multiple SLIP interfaces, this value - * identifies which is to be initialized. + * Input Parameters: + * intf - In the case where there are multiple SLIP interfaces, this + * value identifies which is to be initialized. The number of + * possible SLIP interfaces is determined by + * devname - This is the path to the serial device that will support SLIP. + * For example, this might be "/dev/ttyS1" * * Returned Value: * OK on success; Negated errno on failure.