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:
Gregory Nutt
2018-07-04 14:10:40 -06:00
parent daa3fcc781
commit 22cd0d47fa
96 changed files with 275 additions and 271 deletions
+9 -9
View File
@@ -79,7 +79,7 @@
#define CONFIG_RNDIS_NWRREQS (2)
#define RNDIS_PACKET_HDR_SIZE (sizeof(struct rndis_packet_msg))
#define CONFIG_RNDIS_BULKIN_REQLEN (CONFIG_NET_ETH_MTU + RNDIS_PACKET_HDR_SIZE)
#define CONFIG_RNDIS_BULKIN_REQLEN (CONFIG_NET_ETH_PKTSIZE + RNDIS_PACKET_HDR_SIZE)
#define CONFIG_RNDIS_BULKOUT_REQLEN CONFIG_RNDIS_BULKIN_REQLEN
#define RNDIS_NCONFIGS (1)
@@ -100,7 +100,7 @@
#define RNDIS_MAXSTRLEN (RNDIS_MXDESCLEN-2)
#define RNDIS_CTRLREQ_LEN (512)
#define RNDIS_BUFFER_SIZE CONFIG_NET_ETH_MTU
#define RNDIS_BUFFER_SIZE CONFIG_NET_ETH_PKTSIZE
#define RNDIS_BUFFER_COUNT 4
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
@@ -401,14 +401,14 @@ static const uint32_t g_rndis_supported_oids[] =
static const struct rndis_oid_value_s g_rndis_oid_values[] =
{
{RNDIS_OID_GEN_SUPPORTED_LIST, sizeof(g_rndis_supported_oids), 0, g_rndis_supported_oids},
{RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE, 4, CONFIG_NET_ETH_MTU, NULL},
{RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE, 4, CONFIG_NET_ETH_PKTSIZE, NULL},
#ifdef CONFIG_USBDEV_DUALSPEED
{RNDIS_OID_GEN_LINK_SPEED, 4, 100000, NULL},
#else
{RNDIS_OID_GEN_LINK_SPEED, 4, 2000000, NULL},
#endif
{RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE, 4, CONFIG_NET_ETH_MTU, NULL},
{RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE, 4, CONFIG_NET_ETH_MTU, NULL},
{RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE, 4, CONFIG_NET_ETH_PKTSIZE, NULL},
{RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE, 4, CONFIG_NET_ETH_PKTSIZE, NULL},
{RNDIS_OID_GEN_VENDOR_ID, 4, 0x00FFFFFF, NULL},
{RNDIS_OID_GEN_VENDOR_DESCRIPTION, 6, 0, "RNDIS"},
{RNDIS_OID_GEN_CURRENT_PACKET_FILTER, 4, 0, NULL},
@@ -651,7 +651,7 @@ static bool rndis_allocnetreq(FAR struct rndis_dev_s *priv)
if (priv->net_req)
{
priv->netdev.d_buf = &priv->net_req->req->buf[RNDIS_PACKET_HDR_SIZE];
priv->netdev.d_len = CONFIG_NET_ETH_MTU;
priv->netdev.d_len = CONFIG_NET_ETH_PKTSIZE;
}
leave_critical_section(flags);
@@ -761,7 +761,7 @@ static void rndis_giverxreq(FAR struct rndis_dev_s *priv)
priv->net_req = priv->rx_req;
priv->netdev.d_buf = &priv->net_req->req->buf[RNDIS_PACKET_HDR_SIZE];
priv->netdev.d_len = CONFIG_NET_ETH_MTU;
priv->netdev.d_len = CONFIG_NET_ETH_PKTSIZE;
priv->rx_req = NULL;
}
@@ -1247,7 +1247,7 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
/* Check if the received packet exceeds request buffer */
if ((RNDIS_PACKET_HDR_SIZE + index + copysize) <= CONFIG_NET_ETH_MTU)
if ((RNDIS_PACKET_HDR_SIZE + index + copysize) <= CONFIG_NET_ETH_PKTSIZE)
{
memcpy(&priv->rx_req->req->buf[RNDIS_PACKET_HDR_SIZE + index], reqbuf,
copysize);
@@ -1264,7 +1264,7 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
{
/* Check for a usable packet length (4 added for the CRC) */
if (priv->current_rx_datagram_size > (CONFIG_NET_ETH_MTU + 4) ||
if (priv->current_rx_datagram_size > (CONFIG_NET_ETH_PKTSIZE + 4) ||
priv->current_rx_datagram_size <= (ETH_HDRLEN + 4))
{
uerr("ERROR: Bad packet size dropped (%d)\n",