Default setting of InfinityX TxFIFOs for each Endpoints
IN EP |
TxFIFO size(bytes) |
---|---|
EP1 | 8336 |
EP2 | 8336 |
EP3 | 2096 |
EP4 | 2096 |
EP5 | 2096 |
EP6 | 3136 |
EP7 | 3136 |
According to DWC USB3 databook 2.4.2 Flexible IN Endpoint TxFIFO Allocation :
The USB device design requires each IN endpoint to have its own TxFIFO for data prefetch to meet USB turnaround time.
In your application, if you have six IN endpoints, and at a given time only four are active,
you can choose four TxFIFOs during coreConsultant configuration and software can map the four TxFIFOs to four currently active endpoints.
DWC 規定一個 USB 3.0 裝置的設計對 RAM 的需求為:
其中 RAM 可以為 SoC 提供的 SRAM 空間
對於 TxFIFO 的要求為:
MDWIDTH 定義為(單位為 byte):
根據 TxFIFO 公式,以下程式碼計算一個 IN EP 所需要的大小:
根據上述程式碼,InfinityX TxFIFOs 配置情況如下:
IN EP |
TxFIFO size(bytes) | Packets |
---|---|---|
EP1 | 8 | |
EP2 | 8336 | 8 |
EP3 | 2 | |
EP4 | 2096 | 2 |
EP5 | 2096 | 2 |
EP6 | 3 | |
EP7 | 3136 | 3 |
若不修改 TxFIFO 的預設值,只有 EP1, EP2, EP6 與 EP7 可以支援 Burst (Up to 3 pakcets)
透過適當分配 TxFIFO,可達到每個 IN EP 都可以支援 Burst 如下:
IN EP |
TxFIFO size(bytes) | Packets |
---|---|---|
EP1 | 4 | |
EP2 | 4176 | 4 |
EP3 | 4176 | 4 |
EP4 | 4176 | 4 |
EP5 | 4176 | 4 |
EP6 | 4176 | 4 |
EP7 | 4176 | 4 |
透過以下程式碼,第 47 行的位置,若 IN EP 作為 Isochronous Transfer,則 TxFIFO 一律配置 3 個 packets 以上:
修改預設 TxFIFO 的目的是為了讓 Host 選擇適當的 IN EP 做傳輸,透過實做 match_ep,device 將提供 Host 每個 IN EP 的 TxFIFO
觀察 DWC3 於 Linux device driver 調用,dwc3_gadget_init_in_endpoint
計算每個 IN EP 預設的 TxFIFO 之 maxpacket
,亦即 mult * max_packet
其中 max_packet
為 1024 bytes
原始流程:
dwc3_gadget_init_in_endpoint
→ dwc3_gadget_ep_match
→ dwc3_gadget_ep_enable
→ dwc3_gadget_resize_fifos
其中 dwc3_gadget_ep_match
由 V4L2 層的 uvc_function_bind
調用
然而 dwc3_gadget_resize_tx_fifos
的調用會在 match_ep 之後,也就是 Host 只會取得每個 IN EP 預設的 TxFIFO
流程需修改如下:
dwc3_gadget_init_in_endpoint
→ dwc3_gadget_resize_fifos
→ dwc3_gadget_ep_match
→ dwc3_gadget_ep_enable
上述修改只能將每個 IN EP 的 TxFIFO 重新配置為 3 個 max_packets
,亦即 3x1024 bytes,若需自由調整,可在 dts 中新增