CONFIG_L2_TO_L3_COPY and CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
Posted: Mon Jun 26, 2017 11:55 am
by gobbio
Hi
I see that if CONFIG_L2_TO_L3_COPY is set, wlanif_input() copies from the buffer to p->payload. Similarly, if CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE is set, ethernetif_input makes a copy. What's the purpose of setting these constants? In what situation is setting them desirable?
Thanks
Re: CONFIG_L2_TO_L3_COPY and CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
Posted: Mon Jun 26, 2017 12:10 pm
by ESP_igrr
If the application is not processing received data quickly enough, and this option is disabled, L2 buffers (used by the wifi driver) may be all used up, preventing wifi driver from receiving more packets. This will likely cause issues, for example when TCP ACKs are dropped.
On the other hand, if this option is enabled, new L3 buffer will be allocated for each packet, freeing up L2 buffer. This way wifi driver will always have enough RX buffers. But if the application doesn't process input data quickly enough, it may run out of heap memory due to many L3 buffers allocated.
Such overflow is normally not an issue for TCP connections (if there is a limited number of them) because of TCP flow control. This may be an issue in case of a large number of incoming UDP packets, or if an unbounded number of TCP clients is expected.
Re: CONFIG_L2_TO_L3_COPY and CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
Posted: Mon Jun 26, 2017 12:14 pm
by gobbio
Very informative. Thanks!