Repository navigation
Conversation
USBX had no device class for the USB Network Control Model (CDC NCM 1.1). Devices that need a network interface with built-in host drivers had to use RNDIS or CDC ECM. The new class carries Ethernet frames in NTB16 transfer blocks and connects to NetX Duo through the USBX network driver, like the CDC ECM class. It handles the NCM class requests and sends the network connection and speed change notifications. Small datagrams are aggregated into one NTB. Datagrams longer than UX_DEVICE_CLASS_CDC_NCM_NTB_IN_AGGREGATE_MAX_LENGTH are sent in their own NTB, because a host may coalesce the TCP segments of one NTB and delay its ACKs. The new regression tests usbx_device_class_cdc_ncm_basic_test and usbx_device_class_cdc_ncm_ntb16_test cover 94 % of the lines and 76 % of the branches of the class. All 17 regression configurations pass. The class was also tested on a Renesas RX64M (full speed) with Windows 11, Ubuntu and macOS hosts. Compared with the RNDIS class on the same device, the MQTT throughput to a Windows 11 host rose by 29 %. Assisted-by: Copilot (Claude Opus 5.5) <[email protected]>
This was referenced Dec 3, 2026
spir6s
marked this pull request as draft
December 3, 2026 19:08
The NTB parser accepted datagrams up to the NTB size, although the class advertises a maximum segment size of 1514 bytes, and a looping NDP chain returned the datagrams of an NDP up to 128 times before it was detected. If no USBX network driver instance was free, the class ignored the failed activation and later passed a null network handle to _ux_network_driver_link_up when the host selected the data alternate setting. Datagrams longer than an Ethernet frame plus the optional CRC are now treated as a malformed NTB, and chained NDPs must follow each other forward in the block. A failed network driver activation fails the data interface activation, and alternate setting 1 is refused without a network handle. The CDC NCM regression tests cover these cases and pass in the default, error check and device buffer owner configurations. Assisted-by: Copilot (Claude Opus 5.5) <[email protected]>
spir6s
force-pushed
the
device-class-cdc-ncm
branch
from
December 3, 2026 19:13
2ab12db to
3257a60
Compare
spir6s
marked this pull request as ready for review
December 4, 2026 07:44
Author
|
The failing Could a maintainer re-run the failed job? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
USBX had no device class for the USB Network Control Model (CDC NCM 1.1). NCM is the network class with built-in host drivers on Windows 11 (UsbNcm), Linux (cdc_ncm) and macOS; RNDIS is deprecated on several hosts and CDC ECM has no built-in Windows driver. Closes #93.
The new class
ux_device_class_cdc_ncmfollows the structure of the CDC ECM device class (entry, activate/change/deactivate, control requests, bulk IN, bulk OUT and interrupt threads) and connects to NetX Duo through the USBX network driver. It implements the NCM 1.0 function behaviour that every NCM 1.0 and 1.1 host driver supports: NTB16 only, no CRC on IN datagrams, and the requests GET_NTB_PARAMETERS, GET/SET_NTB_FORMAT, GET/SET_NTB_INPUT_SIZE, SET_ETHERNET_PACKET_FILTER and SET_ETHERNET_MULTICAST_FILTERS. NETWORK_CONNECTION and CONNECTION_SPEED_CHANGE are sent on link changes.Small datagrams are aggregated into one NTB. Datagrams longer than
UX_DEVICE_CLASS_CDC_NCM_NTB_IN_AGGREGATE_MAX_LENGTH(default: no limit) are sent in their own NTB, because Windows delivers the TCP segments of one NTB together and then acknowledges them only after its delayed ACK timer (about 40 ms per ACK); with a limit of 512 bytes, HTTP transfers to Windows are about as fast as with RNDIS while small frames are still aggregated. Received datagrams longer than an Ethernet frame (plus the optional CRC) are treated as a malformed NTB and dropped, and chained NDPs must follow each other forward in the block, so a looping chain cannot return datagrams more than once. If no USBX network driver instance is free, the data interface activation fails and alternate setting 1 is refused, so the class never passes a null network handle to the network driver. The class is not available in standalone mode, like CDC ECM.The code was written from the NCM 1.1 specification and the existing USBX CDC ECM class; no code was taken from another NCM implementation.
Verification: the regression suite ran on Linux with GCC 14.2 and gcovr 8.6 (
TX_COVERAGE=ON scripts/build.sh allandscripts/test.sh all): all 17 configurations pass and the build has no new warnings. The new testsusbx_device_class_cdc_ncm_basic_test(class requests, alternate settings, notifications, frames in both directions, entry and initialization failures, write with the link down, receive with an empty packet pool, no free network driver instance) andusbx_device_class_cdc_ncm_ntb16_test(NTB16 build and parse, malformed and oversized datagrams, NDP chains) cover 94 % of the lines and 77 % of the branches of the class. The uncovered parts are mainly USB transfer failures inside the class threads and corrupted descriptors. The Windows simulator was not run.Hardware: Renesas RX64M (USB full speed, r_usb_basic) with the built-in NCM drivers of Windows 11 and Ubuntu (ping, HTTP and continuous MQTT traffic in both directions) and macOS (ping and HTTP). Compared with the USBX RNDIS class on the same firmware and a Windows 11 host, MQTT throughput from the device rose from about 2,600 to 3,360 messages/s (+29 %) and small HTTP requests from 83 to 95 requests/s; ping latency and a 34 KB HTTP download are about the same.
The second commit addresses findings of an internal review: oversized datagrams, looping NDP chains and the failed network driver activation described above. With it, the device was tested again on the RX64M with a Windows 11 host: ping, HTTP and 3 × 40 s of MQTT traffic with 600 incoming messages/s, without loss.
Documentation: eclipse-threadx/rtos-docs-asciidoc#124 documents the class in chapter 5 of the USBX device stack guide.
The class was written with AI assistance (GitHub Copilot with Claude Opus 5.5). I reviewed and tested it; the new files carry the AI disclosure header and both commits the Assisted-by trailer.