Commit 7abca7a
issue: 4728517 Fix credit prediction mismatch in hw_queue_tx
Fix assertion failure in debug builds and Send Queue waste caused by
mismatch between credit prediction (credits_calculate) and actual WQE
size calculation (fill_wqe).
The bug manifested with multi-SGE packets where total data length was
small enough to be inlined (<= 204 bytes). For example, a packet with
num_sge=2 and total_data_len=142 bytes would:
- credits_calculate(): See num_sge != 1, predict 2 credits (scatter-gather)
- fill_wqe(): See data_len <= 204, use inline path, need 3 wqebbs
- Result: Assertion failure (wqebbs=3 > credits=2)
Additionally, the initial fix using a conservative upper bound (max of 4)
caused severe performance degradation: 2-SGE UDP packets >204 bytes would
reserve 4 WQEBBs but only use 1 WQEBB, wasting 75% of Send Queue capacity
and increasing packet drops in high-PPS scenarios.
The root cause was different branching logic:
- credits_calculate() checked: num_sge == 1 && length <= 204
- fill_wqe() checked: total_data_len <= 204 (regardless of num_sge)
Fix by making credits_calculate() match fill_wqe() logic exactly:
1. Single-SGE fast path: Check length directly, no loop
- If length <= 204: use inline formula
- Else: return 1 credit (non-inline single SGE)
2. Multi-SGE path: Calculate total length to distinguish inline vs
scatter-gather, ensuring accurate predictions
- If total <= 204: use inline formula (up to 4 WQEBBs)
- Else: use scatter-gather formula (typically 1 WQEBB for 2-SGE UDP)
Also fix test synchronization issues:
- Add SO_RCVTIMEO to prevent indefinite blocking
- Add wait_fork() to properly wait for child process
Signed-off-by: Tomer Cabouly <[email protected]>1 parent 7dbaa6c commit 7abca7a
2 files changed
+41
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
143 | 142 | | |
144 | 143 | | |
145 | | - | |
146 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
147 | 152 | | |
148 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
149 | 166 | | |
150 | 167 | | |
151 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
473 | 480 | | |
474 | 481 | | |
475 | 482 | | |
| |||
551 | 558 | | |
552 | 559 | | |
553 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
554 | 564 | | |
555 | 565 | | |
0 commit comments