CONFIG_L2_TO_L3_COPY and CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE

gobbio
Posts: 6
Joined: Wed Jun 21, 2017 2:39 am

CONFIG_L2_TO_L3_COPY and CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE

Postby gobbio » Mon Jun 26, 2017 11:55 am

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

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: CONFIG_L2_TO_L3_COPY and CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE

Postby ESP_igrr » Mon Jun 26, 2017 12:10 pm

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.

gobbio
Posts: 6
Joined: Wed Jun 21, 2017 2:39 am

Re: CONFIG_L2_TO_L3_COPY and CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE

Postby gobbio » Mon Jun 26, 2017 12:14 pm

Very informative. Thanks!

Who is online

Users browsing this forum: No registered users and 116 guests