Sat 01 Apr 2017 07:28:36 PM UTC, original submission:
Depending on the configuration, lwIP allows some operations to be executed from interrupt context. E.g. the static callback mechanism is intended to allow posting messages to the TCP/IP thread via tcpip_trycallback() directly from an interrupt handler.
However, I noticed that tcpip_trycallback() calls into the same sys_arch function -- sys_mbox_trypost() -- as tcpip_callback_with_block() does. Unfortunately, this makes it impossible to use this feature on systems which have separate API calls for user context and interrupt context, such as FreeRTOS.
Thus I think the sys_arch API needs to be extended with a new function, say sys_mbox_trypost_from_isr(). It would be optional and simply alias to sys_mbox_trypost() by default. On the public API side, a corresponding tcpip_trycallback_from_isr() would need to be added. Alternatively, tcpip_trycallback() could be changed to use the new function and documented as being callable from interrupt context only.
In order to support LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT, there would also have to be separate versions of SYS_ARCH_(UN)PROTECT for use from interrupt context, as some FreeRTOS ports also require different calls for these. This would in turn also require separate ISR variants of memp_free() and pbuf_free(), so it may not be worth the effort.
Caveat: In my own design I delegate most interrupt work to high-priority threads which then in turn post messages to the lwIP thread. So I personally don't have any immediate need for this, and wouldn't be eating my own dog food if I contribute a patch.
|