mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
Completes conversion of CONFIG_NET_BUFIZE to CONFIG_NET_ETH/SLIP_MTU
This commit is contained in:
@@ -81,11 +81,29 @@
|
|||||||
* can be found. For Ethernet, this should be set to 14. For SLIP, this
|
* can be found. For Ethernet, this should be set to 14. For SLIP, this
|
||||||
* should be set to 0.
|
* should be set to 0.
|
||||||
*
|
*
|
||||||
* If CONFIG_NET_MULTILINK is defined, then mutliple link protocols are
|
* If CONFIG_NET_MULTILINK is defined, then multiple link protocols are
|
||||||
* supported concurrently. In this case, the size of link layer header
|
* supported concurrently. In this case, the size of link layer header
|
||||||
* varies and is obtained from the network device structure.
|
* varies and is obtained from the network device structure.
|
||||||
|
*
|
||||||
|
* Support is also provided to select different MTU sizes for each different
|
||||||
|
* link layer protocol. A better solution would be to support device-by-
|
||||||
|
* device MTU sizes. This minimum support is require to support the
|
||||||
|
* optimal SLIP MTU of 296 bytes and the standard Ethernet MTU of 1500
|
||||||
|
* bytes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_SLIP
|
||||||
|
# ifndef CONFIG_NET_SLIP_MTU
|
||||||
|
# define CONFIG_NET_SLIP_MTU 590
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_ETHERNET
|
||||||
|
# ifndef CONFIG_NET_ETH_MTU
|
||||||
|
# define CONFIG_NET_ETH_MTU 590
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NET_MULTILINK)
|
#if defined(CONFIG_NET_MULTILINK)
|
||||||
/* We are supporting multiple network devices using different link layer
|
/* We are supporting multiple network devices using different link layer
|
||||||
* protocols. Get the size of the link layer header from the device
|
* protocols. Get the size of the link layer header from the device
|
||||||
@@ -188,7 +206,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The UDP maximum packet size. This is should not be to set to more
|
/* The UDP maximum packet size. This is should not be to set to more
|
||||||
* than CONFIG_NET_BUFSIZE - NET_LL_HDRLEN(dev) - IPUDP_HDRLEN.
|
* than NET_LL_MTU(d) - NET_LL_HDRLEN(dev) - IPUDP_HDRLEN.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define UDP_MSS(d) (CONFIG_NET_ETH_MTU - NET_LL_HDRLEN(d) - IPUDP_HDRLEN)
|
#define UDP_MSS(d) (CONFIG_NET_ETH_MTU - NET_LL_HDRLEN(d) - IPUDP_HDRLEN)
|
||||||
@@ -332,17 +350,6 @@
|
|||||||
|
|
||||||
/* General configuration options */
|
/* General configuration options */
|
||||||
|
|
||||||
/* The size of the uIP packet buffer.
|
|
||||||
*
|
|
||||||
* The uIP packet buffer should not be smaller than 60 bytes, and does
|
|
||||||
* not need to be larger than 1500 bytes. Lower size results in lower
|
|
||||||
* TCP throughput, larger size results in higher TCP throughput.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CONFIG_NET_BUFSIZE
|
|
||||||
# define CONFIG_NET_BUFSIZE 400
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Delay after receive to catch a following packet. No delay should be
|
/* Delay after receive to catch a following packet. No delay should be
|
||||||
* required if TCP/IP read-ahead buffering is enabled.
|
* required if TCP/IP read-ahead buffering is enabled.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ struct net_driver_s
|
|||||||
#ifdef CONFIG_NET_MULTIBUFFER
|
#ifdef CONFIG_NET_MULTIBUFFER
|
||||||
uint8_t *d_buf;
|
uint8_t *d_buf;
|
||||||
#else
|
#else
|
||||||
uint8_t d_buf[CONFIG_NET_BUFSIZE + CONFIG_NET_GUARDSIZE];
|
uint8_t d_buf[MAX_NET_LL_MTU + CONFIG_NET_GUARDSIZE];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* d_appdata points to the location where application data can be read from
|
/* d_appdata points to the location where application data can be read from
|
||||||
|
|||||||
+23
-14
@@ -47,25 +47,38 @@ config NET_PROMISCUOUS
|
|||||||
Force the Ethernet driver to operate in promiscuous mode (if supported
|
Force the Ethernet driver to operate in promiscuous mode (if supported
|
||||||
by the Ethernet driver).
|
by the Ethernet driver).
|
||||||
|
|
||||||
config NET_BUFSIZE
|
config NET_ETH_MTU
|
||||||
int "Network packet buffer size (MTU)"
|
int "Ethernet packet buffer size (MTU)"
|
||||||
default 1294 if !NET_SLIP && NET_IPv6
|
default 1294 if NET_IPv6
|
||||||
default 590 if !NET_SLIP && !NET_IPv6
|
default 590 if !NET_IPv6
|
||||||
default 296 if NET_SLIP && !NET_IPv6
|
depends on NET_ETHERNET
|
||||||
|
range 590 1518
|
||||||
---help---
|
---help---
|
||||||
Packet buffer size. This size includes the TCP/UDP payload plus the
|
Packet buffer size. This size includes the TCP/UDP payload plus the
|
||||||
size of TCP/UDP header, the IP header, and the Ethernet header
|
size of TCP/UDP header, the IP header, and the Ethernet header.
|
||||||
(assuming that the Ethernet transport is used). This value is
|
This value is normally referred to as the MTU (Maximum Transmission
|
||||||
normally referred to as the MTU (Maximum Transmission Unit); the
|
Unit); the payload is the MSS (Maximum Segment Size).
|
||||||
payload is the MSS (Maximum Segment Size).
|
|
||||||
|
|
||||||
IPv4 hosts are required to be able to handle an MSS of at least
|
IPv4 hosts are required to be able to handle an MSS of at least
|
||||||
536 octets, resulting in a minimum buffer size of 536+20+20+14 =
|
536 octets, resulting in a minimum buffer size of 536+20+20+14 =
|
||||||
590 (For SLIP 256+20+20 = 296).
|
590.
|
||||||
|
|
||||||
IPv6 hosts are required to be able to handle an MSS of 1220 octets,
|
IPv6 hosts are required to be able to handle an MSS of 1220 octets,
|
||||||
resulting in a minimum buffer size of of 1220+20+40+14 = 1294
|
resulting in a minimum buffer size of of 1220+20+40+14 = 1294
|
||||||
|
|
||||||
|
config NET_SLIP_MTU
|
||||||
|
int # "SLIP packet buffer size (MTU)"
|
||||||
|
default 296
|
||||||
|
depends on NET_SLIP
|
||||||
|
range 296 1518
|
||||||
|
---help---
|
||||||
|
Packet buffer size. This size includes the TCP/UDP payload plus the
|
||||||
|
size of TCP/UDP header and the IP header. This value is normally
|
||||||
|
referred to as the MTU (Maximum Transmission Unit); the payload
|
||||||
|
payload is the MSS (Maximum Segment Size). SLIP is required to
|
||||||
|
support at lest 256+20+20 = 296. Values other than 296 are not
|
||||||
|
recommended.
|
||||||
|
|
||||||
config NET_RECEIVE_WINDOW
|
config NET_RECEIVE_WINDOW
|
||||||
int "Receive window size"
|
int "Receive window size"
|
||||||
default 1220 if !NET_SLIP && NET_IPv6
|
default 1220 if !NET_SLIP && NET_IPv6
|
||||||
@@ -115,10 +128,6 @@ config NET_SLIP
|
|||||||
at least one IP protocol selected and the following additional
|
at least one IP protocol selected and the following additional
|
||||||
network settings: NET_NOINTS and NET_MULTIBUFFER.
|
network settings: NET_NOINTS and NET_MULTIBUFFER.
|
||||||
|
|
||||||
NET_BUFSIZE *must* be set to 296. Other optional configuration
|
|
||||||
settings that affect the SLIP driver: NET_STATISTICS.
|
|
||||||
Default: Ethernet
|
|
||||||
|
|
||||||
SLIP supports point-to-point IP communications over a serial port.
|
SLIP supports point-to-point IP communications over a serial port.
|
||||||
The default data link layer for uIP is Ethernet. If NET_SLIP is
|
The default data link layer for uIP is Ethernet. If NET_SLIP is
|
||||||
defined in the NuttX configuration file, then SLIP will be supported.
|
defined in the NuttX configuration file, then SLIP will be supported.
|
||||||
|
|||||||
@@ -113,7 +113,7 @@
|
|||||||
/* IP fragment re-assembly */
|
/* IP fragment re-assembly */
|
||||||
|
|
||||||
#define IP_MF 0x20
|
#define IP_MF 0x20
|
||||||
#define TCP_REASS_BUFSIZE (CONFIG_NET_BUFSIZE - NET_LL_HDRLEN(dev))
|
#define TCP_REASS_BUFSIZE (NET_LL_MTU(dev) - NET_LL_HDRLEN(dev))
|
||||||
#define TCP_REASS_LASTFRAG 0x01
|
#define TCP_REASS_LASTFRAG 0x01
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
void devif_iob_send(FAR struct net_driver_s *dev, FAR struct iob_s *iob,
|
void devif_iob_send(FAR struct net_driver_s *dev, FAR struct iob_s *iob,
|
||||||
unsigned int len, unsigned int offset)
|
unsigned int len, unsigned int offset)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(dev && len > 0 && len < CONFIG_NET_BUFSIZE);
|
DEBUGASSERT(dev && len > 0 && len < NET_LL_MTU(dev));
|
||||||
|
|
||||||
/* Copy the data from the I/O buffer chain to the device buffer */
|
/* Copy the data from the I/O buffer chain to the device buffer */
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
void devif_pkt_send(FAR struct net_driver_s *dev, FAR const void *buf,
|
void devif_pkt_send(FAR struct net_driver_s *dev, FAR const void *buf,
|
||||||
unsigned int len)
|
unsigned int len)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(dev && len > 0 && len < CONFIG_NET_BUFSIZE);
|
DEBUGASSERT(dev && len > 0 && len < NET_LL_MTU(dev));
|
||||||
|
|
||||||
/* Copy the data into the device packet buffer */
|
/* Copy the data into the device packet buffer */
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
|
|
||||||
void devif_send(struct net_driver_s *dev, const void *buf, int len)
|
void devif_send(struct net_driver_s *dev, const void *buf, int len)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(dev && len > 0 && len < CONFIG_NET_BUFSIZE);
|
DEBUGASSERT(dev && len > 0 && len < NET_LL_MTU(dev));
|
||||||
|
|
||||||
memcpy(dev->d_snddata, buf, len);
|
memcpy(dev->d_snddata, buf, len);
|
||||||
dev->d_sndlen = len;
|
dev->d_sndlen = len;
|
||||||
|
|||||||
@@ -316,8 +316,12 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd,
|
|||||||
|
|
||||||
case SIOCGIFMTU: /* Get MTU size */
|
case SIOCGIFMTU: /* Get MTU size */
|
||||||
{
|
{
|
||||||
req->ifr_mtu = CONFIG_NET_BUFSIZE;
|
dev = netdev_ifrdev(req);
|
||||||
ret = OK;
|
if (dev)
|
||||||
|
{
|
||||||
|
req->ifr_mtu = NET_LL_MTU(dev);
|
||||||
|
ret = OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ config NET_TCP_REASSEMBLY
|
|||||||
This features requires an additional amount of RAM to hold the
|
This features requires an additional amount of RAM to hold the
|
||||||
reassembly buffer and the reassembly code size is approximately 700
|
reassembly buffer and the reassembly code size is approximately 700
|
||||||
bytes. The reassembly buffer is of the same size as the d_buf buffer
|
bytes. The reassembly buffer is of the same size as the d_buf buffer
|
||||||
(configured by CONFIG_NET_BUFSIZE).
|
(configured by CONFIG_NET_xxx_MTU).
|
||||||
|
|
||||||
Note: IP packet reassembly is not heavily tested (and, hence,
|
Note: IP packet reassembly is not heavily tested (and, hence,
|
||||||
EXPERIMENTAL).
|
EXPERIMENTAL).
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ static uint16_t upper_layer_chksum(FAR struct net_driver_s *dev, uint8_t proto)
|
|||||||
|
|
||||||
/* Verify some minimal assumptions */
|
/* Verify some minimal assumptions */
|
||||||
|
|
||||||
if (upper_layer_len > CONFIG_NET_BUFSIZE)
|
if (upper_layer_len > NET_LL_MTU(dev))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user