|
| 1 | +==================== |
| 2 | +CONFIG_NET_GUARDSIZE |
| 3 | +==================== |
| 4 | + |
| 5 | +Global Option for All Drivers |
| 6 | +============================= |
| 7 | + |
| 8 | +``CONFIG_NET_GUARD_SIZE`` is global option. It is added to the allocated size of |
| 9 | +each driver packet buffer. Currently it is a very small value, defaulting to only |
| 10 | +two bytes. So it is not a memory hog and should be added to the packetsize for |
| 11 | +all drivers for commonality. But why? |
| 12 | + |
| 13 | +It should (eventually) be larger and common for all drivers. We need to look at |
| 14 | +how it is used today and how it might be used tomorrow. There is a probably a lot |
| 15 | +more involved than you might be initially considering. |
| 16 | + |
| 17 | +Packet Receipt |
| 18 | +============== |
| 19 | + |
| 20 | +For packet receipt, it is necessary for some hardware, but not for others. Often |
| 21 | +the hardware will DMA a 2 byte FCS at the end of the packet or possibly other |
| 22 | +hardware-specific info. But that is only part of the whole story. |
| 23 | +``CONFIG_NET_GUARDSIZE`` is not just for hardware packet receipt. |
| 24 | + |
| 25 | +Packet Transmission |
| 26 | +=================== |
| 27 | + |
| 28 | +There are several issues for packet transmission. These are less well defined |
| 29 | +and need further study, but we need to keep all of the driver packet definitions |
| 30 | +in place until we understand how we are going to handle these things: |
| 31 | + |
| 32 | +* Memory Overrun Bugs |
| 33 | + |
| 34 | + There was in the past, a bug that caused write past the end of the buffer by |
| 35 | + a couple of bytes during TX message formatting. I don't know if that bug still |
| 36 | + exists, but the minimum, two-byte ``CONFIG_NET_GUARDSIZE`` was sufficient to |
| 37 | + eliminate the bug. That is why it has the name GUARD: Its primary purpose is |
| 38 | + to protect from overrunning the packet buffer and corrupting the following memory. |
| 39 | + |
| 40 | + I do no know if we have any such bugs today. Perhaps they still do? |
| 41 | + Perhaps they do not? Having such a guard is a good thing for reliability in |
| 42 | + any case. |
| 43 | + |
| 44 | +* Variable size IP/TCP headers |
| 45 | + |
| 46 | + There is a limitation in the way IP packets are formatted now. Basically they |
| 47 | + are formatted like this: |
| 48 | + |
| 49 | + #. When the packet is received a pointer to the location of the payload is |
| 50 | + set (d_appdata). This is an offset into the packet buffer For TCP, that |
| 51 | + accounts for the MAC/Ethernet header, the minimum IPv4/IPv6 header size, |
| 52 | + and the minimum TCP header size. |
| 53 | + |
| 54 | + #. The TCP payload is written at that location, |
| 55 | + #. The correctly sized IPv4/IPv6 headers and the correctly sized TCP header |
| 56 | + are added below the payload, and finally |
| 57 | + #. The MAC/Ethernet header as added. |
| 58 | + |
| 59 | + The start offset of the packet in the packet is no longer zero, but some |
| 60 | + variable offset into the packet buffer. That new start offset would have |
| 61 | + to be passed to driver in order to send the packet. |
| 62 | + |
| 63 | + The key to making this all work is: |
| 64 | + |
| 65 | + * Keep ``CONFIG_NET_GUARDSIZE`` in all driver buffers, and |
| 66 | + * Set the ``CONFIG_NET_GUARDSIZE`` to the maximum size of IPv4/IPv6 and TCP options |
| 67 | + (depending on which IP version is enabled and if TCP is enabled) |
| 68 | + * Extend the driver interface to accept data offset into the driver's packet buffer. |
| 69 | + |
| 70 | +* Variable MSS |
| 71 | + |
| 72 | + Closely related to this is the MSS which is the maximum size of the payload. |
| 73 | + Currently that is a constant because it assumes the minimum header lengths. |
| 74 | + It should be variable, depending on the actual header sizes. |
0 commit comments