usb: gadget: f_ncm: Fix NTP-32 support (Windows NCM RX)#123
Open
martindue wants to merge 1 commit into
Open
Conversation
When connecting a CDC-NCM gadget to an host that uses the NTP-32 mode, or that relies on the default CRC setting, the current implementation gets confused, and does not expect the correct signature for its packets. Fix this, by ensuring that the ndp_sign member in the f_ncm structure always contain a valid value. Signed-off-by: Romain Izard <romain.izard.pro@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> (cherry picked from commit 550eef0c353030ac4223b9c9479bdf77a05445d6)
Contributor
we use agnos-builder and comma fours. if you can't build and run a kernel, there's something wrong with your setup |
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.
Summary
Backport of mainline commit
550eef0c3530("usb: gadget: f_ncm: Fix NTP-32 support", merged for v5.2). Fixes USB NCM RX from Windows 10/11 hosts.Problem
The AGNOS kernel (4.9.103) advertises both NTB16 and NTB32 datagram formats in
ntb_parameters.bmNtbFormatsSupported. Windows 10/11 (UsbNcm.sys) negotiates NTB32 viaSET_NTB_FORMAT, then sends NDP32 frames carrying signature'NCM1'(0x314D434E).In the buggy code,
ncm->ndp_signis only assigned inside theSET_CRC_MODEcontrol request handler:SET_CRC_MODEis optional and Windows does not send it. As a result, afterSET_NTB_FORMAT(NTB32)switchesncm->parser_optsto&ndp32_opts,ncm->ndp_signis never resynced and still contains the NDP16 sign'NCM0'(0x304D434E) fromncm_reset_values()'s implicit zero-init.In
ncm_unwrap_ntb():→ every IP packet from a Windows host is dropped with
Wrong NDP SIGN. The USB-NCM link comes up electrically but passes zero traffic in the host→device direction.Fix
Recompute
ncm->ndp_signfromparser_opts->ndp_sign(with the CRC bit if applicable) at the bottom of everyncm_setup()call, and seed it correctly inncm_reset_values(). This keepsndp_signin sync with whatever format the host last selected, regardless of whetherSET_CRC_MODEwas sent.This is the upstream commit verbatim — applies cleanly on top of
c368754c(current AGNOS pin), no backport conflicts. The 4.9 file is structurally identical in this region.Cherry-pick details
Diff: 1 file changed, 3 insertions(+), 7 deletions(-) — only
drivers/usb/gadget/function/f_ncm.c.Verification
Builds cleanly via
./build_kernel.shin agnos-builder. Boot.img produced and signed.Hardware verification not yet completed: the resulting boot.img is rejected by ABL on a production comma four (verified-boot signature mismatch —
vble-qti.keyin agnos-builder is not the production root-of-trust). Recovery via the GPT slot-fallback path worked as expected. A maintainer with a dev-keyed unit or signing access can confirm the runtime fix.Expected behavior after flashing on a verified unit, with a Windows 10/11 host connected over USB:
dmesg | grep -i ncmshould be silent under traffic (no moreWrong NDP SIGN)/sys/class/net/usb0/statistics/rx_packetsshould increment when the host pings the deviceReferences