netdev_upperhalf: modify txavail to be sent directly in the current thread

avoid packet processing delays caused by task switching,
to support those applications that are extremely time-sensitive.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-06-30 20:00:25 +08:00
committed by Xiang Xiao
parent 7c96537a58
commit 16947ddacd
+7 -3
View File
@@ -380,12 +380,15 @@ static void netdev_upper_txavail_work(FAR struct netdev_upperhalf_s *upper)
/* Ignore the notification if the interface is not yet up */
net_lock();
if (IFF_IS_UP(dev->d_flags))
{
DEBUGASSERT(dev->d_buf == NULL); /* Make sure: IOB only. */
while (netdev_upper_can_tx(upper) &&
netdev_upper_tx(dev) == NETDEV_TX_CONTINUE);
}
net_unlock();
}
/****************************************************************************
@@ -701,6 +704,7 @@ static void netdev_upper_rxpoll_work(FAR struct netdev_upperhalf_s *upper)
/* Loop while receive() successfully retrieves valid Ethernet frames. */
net_lock();
while ((pkt = lower->ops->receive(lower)) != NULL)
{
if (!IFF_IS_UP(dev->d_flags))
@@ -754,6 +758,8 @@ static void netdev_upper_rxpoll_work(FAR struct netdev_upperhalf_s *upper)
break;
}
}
net_unlock();
}
/****************************************************************************
@@ -773,10 +779,8 @@ static void netdev_upper_work(FAR void *arg)
/* RX may release quota and driver buffer, so do RX first. */
net_lock();
netdev_upper_rxpoll_work(upper);
netdev_upper_txavail_work(upper);
net_unlock();
}
/****************************************************************************
@@ -872,7 +876,7 @@ static inline void netdev_upper_queue_work(FAR struct net_driver_s *dev)
static int netdev_upper_txavail(FAR struct net_driver_s *dev)
{
netdev_upper_queue_work(dev);
netdev_upper_txavail_work(dev->d_private);
return OK;
}