This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 4b73433756313e2f0124115545c51d0545d3e6ca
Author: zhanghongyu <[email protected]>
AuthorDate: Thu Dec 18 15:15:22 2025 +0800

    netdev_upperhalf: txpoll is triggered only when TX quota has ever dropped 
to 0
    
    Only when the quota has dropped to 0 can the protocol stack have pending
    packets waiting for the network card driver to actively retrieve them,
    otherwise, relying solely on the txavail of the business thread itself
    is sufficient to send out the packets. Therefore, in scenarios where the
    quota has not dropped to 0, only the count of txdone needs to be
    calculated in txdone.
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 drivers/net/netdev_upperhalf.c       | 38 +++++++++++++++++++++++-------------
 include/nuttx/net/netdev_lowerhalf.h |  1 +
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/drivers/net/netdev_upperhalf.c b/drivers/net/netdev_upperhalf.c
index 29aac7ba5ec..bb782997621 100644
--- a/drivers/net/netdev_upperhalf.c
+++ b/drivers/net/netdev_upperhalf.c
@@ -267,6 +267,11 @@ static inline bool netdev_upper_can_tx(FAR struct 
netdev_upperhalf_s *upper)
       quota = netdev_lower_quota_load(lower, NETPKT_TX);
     }
 
+  if (quota <= 0)
+    {
+      lower->txdone = true;
+    }
+
   return quota > 0;
 }
 
@@ -1725,30 +1730,35 @@ void netdev_lower_rxready(FAR struct netdev_lowerhalf_s 
*dev)
 
 void netdev_lower_txdone(FAR struct netdev_lowerhalf_s *dev)
 {
+  if (dev->txdone)
+    {
 #if defined(CONFIG_NET_VLAN) || defined(CONFIG_NET_BRIDGE)
-  FAR struct netdev_upperhalf_s *upper = dev->netdev.d_private;
+      FAR struct netdev_upperhalf_s *upper = dev->netdev.d_private;
 #endif
 
+      dev->txdone = false;
+
 #ifdef CONFIG_NET_VLAN
-  netdev_upper_vlan_foreach(upper, netdev_lower_txdone);
+      netdev_upper_vlan_foreach(upper, netdev_lower_txdone);
 #endif
 
 #ifdef CONFIG_NET_BRIDGE
-  /* The bridge device may wait for room on its ports */
+      /* The bridge device may wait for room on its ports */
 
-  if (upper->bridge != NULL)
-    {
-      bridge_txdone(upper->bridge);
-    }
+      if (upper->bridge != NULL)
+        {
+          bridge_txdone(upper->bridge);
+        }
 #endif
 
-  if (dev->rxtype == NETDEV_RX_DIRECT)
-    {
-      netdev_upper_txavail_work(dev->netdev.d_private);
-    }
-  else
-    {
-      netdev_upper_queue_work(&dev->netdev);
+      if (dev->rxtype == NETDEV_RX_DIRECT)
+        {
+          netdev_upper_txavail_work(dev->netdev.d_private);
+        }
+      else
+        {
+          netdev_upper_queue_work(&dev->netdev);
+        }
     }
 
   NETDEV_TXDONE(&dev->netdev);
diff --git a/include/nuttx/net/netdev_lowerhalf.h 
b/include/nuttx/net/netdev_lowerhalf.h
index 1cea1133422..c471eee2f01 100644
--- a/include/nuttx/net/netdev_lowerhalf.h
+++ b/include/nuttx/net/netdev_lowerhalf.h
@@ -127,6 +127,7 @@ struct netdev_lowerhalf_s
 
   FAR atomic_t *quota_ptr; /* Shared quota, ignore `quota` if ptr is set */
   atomic_t quota[NETPKT_TYPENUM];
+  bool txdone;
 
   uint8_t rxtype;
   uint8_t priority;

Reply via email to