Re: [PATCH v2] usb: gadget: ncm: Avoid dropping datagrams of properly parsed NTBs

From: Krishna Kurapati PSSNV
Date: Thu Feb 01 2024 - 00:45:14 EST




On 2/1/2024 12:24 AM, Maciej Żenczykowski wrote:


I believe so, yes.

I believe they are trying to avoid having to send ZLPs.
That's determined *purely* by the size of things as they show up on
the usb cable (ie. the size of the usb xfer).
ie. that's where things that are a multiple of 512 (USB2) or 1024
(USB3) need an extra 0 byte sized packet to prevent ZLP.

The actual size of the NTB doesn't matter.

That said... maybe we're overcomplicating this...
Maybe it's enough to just remove this modulo check entirely (I know I
asked for it before).

Ultimately if we just do:

// Windows NCM driver avoids USB ZLPs by adding a 1-byte zero pad as needed
if (to_process == 1 && !*(u8*)(ntb_ptr + block_len)) --to_process;

it'll fix the problem too, and perhaps be easier to understand?

I agree. This will simplify the check and also cover all cases.
To keep diff minimal from tested version (because issue comes up easily with a particular test here), I can remove the second check in the if block in the v2 and push it as v3.

Regards,
Krishna,