dwc3_gadget_setup_nump(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… dwc3_gadget_setup_nump(9) β€” Kernel API Manual, section 9

okay so bestie, welcome to the dwc3_gadget_setup_nump(9) page πŸ’– this is the kernel API manual, section 9, and it's honestly a lil gem.


✨ NAME ✨

dwc3_gadget_setup_nump β€” calculate and initialize the NUMP field of %DWC3_DCFG πŸŽ€


🌸 SYNOPSIS 🌸

void dwc3_gadget_setup_nump (struct dwc3 *dwc );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • dwc β€” pointer to our context structure 🫢 (yes, our context structure, she's ours now)

🧚 DESCRIPTION 🧚

okay so the following looks like it's giving complex but it's actually very simple, i promise πŸ˜­πŸ’…

In order to calculate the number of packets we can burst at once on OUT transfers, we're gonna use RxFIFO size. that's the whole vibe.

And to calculate RxFIFO size we need two numbers:

  • MDWIDTH = size, in bits, of the internal memory bus
  • RAM2_DEPTH = depth, in MDWIDTH, of internal RAM2 (where RxFIFO sits) 🌈

Given these two numbers, the formula is simple:

RxFIFO Size = (RAM2_DEPTH * MDWIDTH / 8) - 24 - 16;

so like, what are those subtracted bytes for? glad you asked πŸ‘‘

  • 24 bytes is for 3x SETUP packets
  • 16 bytes is a clock domain crossing tolerance

and given RxFIFO Size:

NUMP = RxFIFOSize / 1024;

math ate, no cap πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

so there's a whole friend group here, all hanging out in ./drivers/usb/dwc3/gadget.c:

periodt πŸ’œ


aaaand that's the page!! πŸŽ€ sign-off time: this lil slice of kernel lore comes from ./drivers/usb/dwc3, dated October 2026, and it's dwc3_gadget_setup_nump(9) β€” go forth and slay your NUMP field bestie πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from