zhhyu7 opened a new pull request, #22230:
URL: https://github.com/apache/nuttx/pull/22230

   ## Summary
   
   netdev_upper_txpoll() stopped polling and dropped the packet on any transmit 
error, with a REVISIT comment asking whether the upper half should keep the 
packet and retry. A lower-half driver that returns 
   -EBUSY because its TX ring is momentarily full therefore lost the frame, 
even though the next completion would have made room.
   
   This series answers that REVISIT:
   
   - An oversize packet returns NETDEV_TX_CONTINUE rather than -EMSGSIZE, so 
one bad frame no longer aborts the whole poll. It is counted in TXERRORS and 
dropped.
   - -EBUSY is treated as transient. The packet goes back to the head of 
upper->txq, which preserves ordering, and the TX quota is restored by hand 
because netpkt_get() has already cleared dev->d_iob. The 
   retry is driven by the lower half's txdone callback.
   - Every other error stays permanent and the packet is dropped, so a hardware 
fault cannot spin forever.
   - netdev_lower_txdone() also runs the TX path when upper->txq is non-empty, 
not only when dev->txdone is set. Without this a re-queued packet could sit in 
the queue until the next unrelated completion. 
   dev->txdone is kept because some drivers free several packets and then call 
txdone once.
   - netdev_upper_tx() releases dev->d_iob after netdev_upper_txpoll(). The txq 
path does not go through devif_poll(), which would otherwise manage the IOB 
lifetime, so the oversize-drop case would leak.
   - netdev_upper_ifdown() drains upper->txq, so a re-queued packet does not 
survive into the next ifup.
   
   iob_add_queue_head() is added for the head insertion; it is the only new API.
   
   ## Impact
   
   Affects every driver built on the netdev upper half. A driver that returns 
-EBUSY from transmit() now gets the frame retried instead of dropped, which 
removes a silent packet loss under TX pressure. 
   Drivers that only ever return OK see no behavioural change.
   
   netdev_lower_txdone() may now schedule TX work in cases where it previously 
returned without doing anything. This is the intended fix for the stall, but it 
is the one change that touches a hot path shared
   by all upper-half drivers.
   
   No Kconfig or configuration change. struct netdev_lowerhalf_s and the 
netdev_ops_s interface are unchanged, so out-of-tree drivers need no 
modification.
   
   ## Testing
   
   sim:dynconns (in tools/ci/testlist/sim-02.dat) with CONFIG_SIM_NET_BRIDGE=y, 
CONFIG_DEBUG_ASSERTIONS=y, CONFIG_NET_IPFRAG=y, tcpecho on port 80 and 
apps/examples/udp with EXAMPLES_UDP_SERVER1=y on port 
   5471. Host bridge nuttx0 10.0.1.1/24, target 10.0.1.2/24.
   
   TCP, 4 concurrent connections echoing 256 KiB each, byte counts compared in 
both directions:
   
   conn0: sent=262144 recv=262144 err=None
   conn1: sent=262144 recv=262144 err=None
   conn2: sent=262144 recv=262144 err=None
   conn3: sent=262144 recv=262144 err=None
   
   
   UDP, 256 datagrams. The target's udpserver validates the sequence byte and 
the payload pattern of every datagram and exits on the first mismatch, so 
corruption would be reported rather than counted as 
   received:
   
   udp client: sent 256 datagrams of 96 bytes (24576 bytes payload)
   datagrams accepted by target: 256
   server error lines: none
   
   
   ICMP, including the queue-heavy paths:
   
   4 packets transmitted, 4 received, 0% packet loss
   500 packets transmitted, 500 received, 0% packet loss    (flood)
   20 packets transmitted, 20 received, 0% packet loss      (-s 4000, 
fragmented)
   10 packets transmitted, 10 received, 0% packet loss      (-s 8000, 
fragmented)
   200 packets transmitted, 200 received, 0% packet loss    (flood, -s 4000)
   
   
   No assertions, no segmentation fault, node alive after every run.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to