Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Loopbacka Driver: Configuration to control packet size #248

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/sim/sim/sim/configs/tcploop/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CONFIG_NETDEVICES=y
CONFIG_NET_IPv6=y
CONFIG_NET_IPv6_NCONF_ENTRIES=4
CONFIG_NET_LOOPBACK=y
CONFIG_NET_LOOPBACK_PKTSIZE=1500
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <nuttx/irq.h>
#include <nuttx/wdog.h>
#include <nuttx/wqueue.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/ip.h>
#include <nuttx/net/loopback.h>
Expand Down Expand Up @@ -108,7 +109,7 @@ struct lo_driver_s
****************************************************************************/

static struct lo_driver_s g_loopback;
static uint8_t g_iobuffer[MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE];
static uint8_t g_iobuffer[NET_LO_PKTSIZE + CONFIG_NET_GUARDSIZE];

/****************************************************************************
* Private Function Prototypes
Expand Down
16 changes: 14 additions & 2 deletions include/nuttx/net/netconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,21 @@
#define MIN_NETDEV_PKTSIZE _MIN_6LOWPAN_PKTSIZE
#define MAX_NETDEV_PKTSIZE _MAX_6LOWPAN_PKTSIZE

/* For the loopback device, we will use the largest MTU */
/* The loopback driver packet buffer should be quite large. The larger the
* loopback packet buffer, the better will be TCP performance of the loopback
* transfers. The Linux loopback device historically used packet buffers of
* size 16Kb, but that was increased in recent Linux versions to 64Kb. Those
* sizes may be excessive for resource constrained MCUs, however.
*
* For the loopback driver, we enforce a lower limit that is the maximum
* packet size of all enabled link layer protocols.
*/

#if CONFIG_NET_LOOPBACK_PKTSIZE < MAX_NETDEV_PKTSIZE
# define NET_LO_PKTSIZE MAX_NETDEV_PKTSIZE
#else
# define NET_LO_PKTSIZE CONFIG_NET_LOOPBACK_PKTSIZE
#endif

/* Layer 3/4 Configuration Options ******************************************/

Expand All @@ -206,7 +218,7 @@
* of the timer is 8-bits.
*/

# define CONFIG_NET_TCP_REASS_MAXAGE (20*10) /* 20 seconds */
# define CONFIG_NET_TCP_REASS_MAXAGE (20 * 10) /* 20 seconds */
# endif
#endif

Expand Down
18 changes: 18 additions & 0 deletions net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ config NET_LOOPBACK
---help---
Add support for the local network loopback device, lo.

config NET_LOOPBACK_PKTSIZE
int "Loopback packet buffer size"
default 0
depends on NET_LOOPBACK
range 0 65535
---help---
The loopback driver packet buffer should be quite large. The larger
the loopback packet buffer, the better will be TCP performance of
the loopback transfers. The Linux loopback device historically used
packet buffers of size 16Kb, but that was increased in recent Linux
versions to 64Kb. Those sizes may be excessive for resource
constrained MCUs, however.

The network enforces a lower limit that is the maximum packet size
of all enabled link layer protocols. The default value of
CONFIG_NET_LOOPBACK_PKTSIZE is zero, meaning that this maximum
packet size will be used by loopback driver.

menuconfig NET_SLIP
bool "SLIP support"
select ARCH_HAVE_NETDEV_STATISTICS
Expand Down