Am 22.04.2021 um 09:53 schrieb Tomas Mudrunka:
>>>    p = pbuf_alloc(PBUF_RAW,rx_len,PBUF_POOL);
>>>    pbuf_take(p, rx_buf, rx_len);
>>> + LOCK_TCPIP_CORE();
>>>    if(netif->input(p, netif) != ERR_OK) {
>>>      ESP_LOGE(TAG, "Input failed!");
>>>      pbuf_free(p);
>>>    }
>>> + UNLOCK_TCPIP_CORE();
>>>
>>
>> I'm not sure you even need this. What's the function behind the
>> netif->input pointer?
>
> It is tcpip_input(), but LWIP_TCPIP_CORE_LOCKING is globaly disabled by
> defines.
> Only SYS_LIGHTWEIGHT_PROT is enabled.
>

But you don't need LWIP_TCPIP_CORE_LOCKING. Traditionally, all code runs
inside a single thread. If you want to call lwIP core functions, you'd
set up a message that gets some function called in this thread context.
This way, you don't need locking, as everything is called sequentially
from only one thread.

LWIP_TCPIP_CORE_LOCKING is a different mechanism: instead of queueing a
call to be done in another thread, you grab a global mutex and do the
call right away. Most times, this better fits to realtime requirements
than the traditional mechanism.

However, you don't need a lock when netif->input is tcpip_input.
tcpip_input is a function dedicated to be called from other stacks to
queue input pbufs for the lwIP thread.

Regards,
Simon

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to