Skip to content

Commit

Permalink
pkg/lwip: adapt to API change of netdev_new_api
Browse files Browse the repository at this point in the history
Since #21012 a netdev in the new API
can return > 0 directly in netdev_driver_t::send() to indicate the
driver is naturally synchronous and has already completed the
transmission.

This adapts lwIP to handle this case explicitly. With it, lwIP will
work again on `native`, rather than blocking for a signal that TX has
completed that never arrives.
  • Loading branch information
maribu committed Dec 16, 2024
1 parent 4044c85 commit 0fb00bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/lwip/contrib/netdev/lwip_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,16 @@ static err_t _common_link_output(struct netif *netif, netdev_t *netdev, iolist_t
return ERR_IF;
}

/* block until TX completion is signaled from IRQ */
thread_flags_wait_any(THREAD_FLAG_LWIP_TX_DONE);
/* `res > 0` means transmission already completed according to API contract.
* ==> only waiting when res == 0 */
if (res == 0) {
/* block until TX completion is signaled from IRQ */
thread_flags_wait_any(THREAD_FLAG_LWIP_TX_DONE);

irq_state = irq_disable();
compat_netif->thread_doing_tx = NULL;
irq_restore(irq_state);
irq_state = irq_disable();
compat_netif->thread_doing_tx = NULL;
irq_restore(irq_state);

if (res == 0) {
/* async send */
while (-EAGAIN == (res = netdev->driver->confirm_send(netdev, NULL))) {
/* this should not happen, as the driver really only should emit the
Expand Down

0 comments on commit 0fb00bd

Please sign in to comment.