dwc3_gadget_setup_nump(9)
π 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 busRAM2_DEPTH= depth, inMDWIDTH, 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 π
24bytes is for 3x SETUP packets16bytes 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:
dwc3_gadget_set_test_mode(9)dwc3_gadget_get_link_state(9)dwc3_gadget_set_link_state(9)dwc3_ep_inc_trb(9)dwc3_ep_inc_enq(9)dwc3_ep_inc_deq(9)dwc3_gadget_giveback(9)dwc3_send_gadget_generic_command(9)dwc3_send_gadget_ep_cmd(9)dwc3_gadget_start_config(9)dwc3_gadget_calc_tx_fifo_size(9)dwc3_gadget_calc_ram_depth(9)dwc3_gadget_clear_tx_fifos(9)__dwc3_gadget_ep_enable(9)__dwc3_gadget_ep_disable(9)dwc3_ep_prev_trb(9)dwc3_prepare_one_trb(9)dwc3_prepare_last_sg(9)__dwc3_stop_active_transfer(9)dwc3_gadget_start_isoc_quirk(9)dwc3_gadget_check_config(9)dwc3_gadget_init(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms