mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
This commit attempts remove some long standard confusion in naming and some actual problems that result from the naming confusion. The basic problem is the standard MTU does not include the size of the Ethernet header. For clarity, I changed the naming of most things called MTU to PKTSIZE. For example, CONFIG_NET_ETH_MTU is now CONFIG_NET_ETH_PKTSIZE.
This makes the user interface a little hostile. People thing of an MTU of 1500 bytes, but the corresponding packet is really 1514 bytes (including the 14 byte Ethernet header). A more friendly solution would configure the MTU (as before), but then derive the packet buffer size by adding the MAC header length. Instead, we define the packet buffer size then derive the MTU.
The MTU is not common currency in networking. On the wire, the only real issue is the MSS which is derived from MTU by subtracting the IP header and TCP header sizes (for the case of TCP). Now it is derived for the PKTSIZE by subtracting the IP header, the TCP header, and the MAC header sizes. So we should be all good and without the recurring 14 byte error in MTU's and MSS's.
Squashed commit of the following:
Trivial update to fix some spacing issues.
net/: Rename several macros containing _MTU to _PKTSIZE.
net/: Rename CONFIG_NET_SLIP_MTU to CONFIG_NET_SLIP_PKTSIZE and similarly for CONFIG_NET_TUN_MTU. These are not the MTU which does not include the size of the link layer header. These are the full size of the packet buffer memory (minus any GUARD bytes).
net/: Rename CONFIG_NET_6LOWPAN_MTU to CONFIG_NET_6LOWPAN_PKTSIZE and similarly for CONFIG_NET_TUN_MTU. These are not the MTU which does not include the size of the link layer header. These are the full size of the packet buffer memory (minus any GUARD bytes).
net/: Rename CONFIG_NET_ETH_MTU to CONFIG_NET_ETH_PKTSIZE. This is not the MTU which does not include the size of the link layer header. This is the full size of the packet buffer memory (minus any GUARD bytes).
net/: Rename the file d_mtu in the network driver structure to d_pktsize. That value saved there is not the MTU. The packetsize is the memory large enough to hold the maximum packet PLUS the size of the link layer header. The MTU does not include the link layer header.
This commit is contained in:
@@ -107,10 +107,10 @@
|
||||
# define CONFIG_ENC28J60_NINTERFACES 1
|
||||
#endif
|
||||
|
||||
/* CONFIG_NET_ETH_MTU must always be defined */
|
||||
/* CONFIG_NET_ETH_PKTSIZE must always be defined */
|
||||
|
||||
#if !defined(CONFIG_NET_ETH_MTU) && (CONFIG_NET_ETH_MTU <= MAX_FRAMELEN)
|
||||
# error "CONFIG_NET_ETH_MTU is not valid for the ENC28J60"
|
||||
#if !defined(CONFIG_NET_ETH_PKTSIZE) && (CONFIG_NET_ETH_PKTSIZE <= MAX_FRAMELEN)
|
||||
# error "CONFIG_NET_ETH_PKTSIZE is not valid for the ENC28J60"
|
||||
#endif
|
||||
|
||||
/* We need to have the work queue to handle SPI interrupts */
|
||||
@@ -159,7 +159,7 @@
|
||||
|
||||
/* Packet memory layout */
|
||||
|
||||
#define ALIGNED_BUFSIZE ((CONFIG_NET_ETH_MTU + 255) & ~255)
|
||||
#define ALIGNED_BUFSIZE ((CONFIG_NET_ETH_PKTSIZE + 255) & ~255)
|
||||
|
||||
/* Work around Errata #5 (spurious reset of ERXWRPT to 0) by placing the RX
|
||||
* FIFO at the beginning of packet memory.
|
||||
@@ -265,7 +265,7 @@ struct enc_driver_s
|
||||
|
||||
/* A single packet buffer is used */
|
||||
|
||||
static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
|
||||
static uint8_t g_pktbuf[MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE];
|
||||
|
||||
/* Driver status structure */
|
||||
|
||||
@@ -1555,7 +1555,7 @@ static void enc_pktif(FAR struct enc_driver_s *priv)
|
||||
|
||||
/* Check for a usable packet length (4 added for the CRC) */
|
||||
|
||||
else if (pktlen > (CONFIG_NET_ETH_MTU + 4) || pktlen <= (ETH_HDRLEN + 4))
|
||||
else if (pktlen > (CONFIG_NET_ETH_PKTSIZE + 4) || pktlen <= (ETH_HDRLEN + 4))
|
||||
{
|
||||
nerr("ERROR: Bad packet size dropped (%d)\n", pktlen);
|
||||
NETDEV_RXERRORS(&priv->dev);
|
||||
@@ -2568,8 +2568,8 @@ static int enc_reset(FAR struct enc_driver_s *priv)
|
||||
|
||||
/* Set the maximum packet size which the controller will accept */
|
||||
|
||||
enc_wrbreg(priv, ENC_MAMXFLL, CONFIG_NET_ETH_MTU & 0xff);
|
||||
enc_wrbreg(priv, ENC_MAMXFLH, CONFIG_NET_ETH_MTU >> 8);
|
||||
enc_wrbreg(priv, ENC_MAMXFLL, CONFIG_NET_ETH_PKTSIZE & 0xff);
|
||||
enc_wrbreg(priv, ENC_MAMXFLH, CONFIG_NET_ETH_PKTSIZE >> 8);
|
||||
|
||||
/* Configure LEDs (No, just use the defaults for now) */
|
||||
/* enc_wrphy(priv, ENC_PHLCON, ??); */
|
||||
|
||||
Reference in New Issue
Block a user