fix(PHY): rate matching guard rejects valid RV2/RV3 retransmissions

The guard `if (Foffset > E)` in nr_rate_matching_ldpc() and
nr_rate_matching_ldpc_rx() incorrectly rejects non-zero redundancy
versions where the circular buffer starting index `ind` is well past
the filler bit region (ind >> Foffset). The guard exists to prevent
the first memcpy from overflowing E when ind < Foffset, but for
RV2/RV3 the starting index is far beyond the filler bits, so the
filler-skip logic is never triggered and the guard is not needed.

Add `ind < Foffset &&` to both TX and RX paths so the guard only
fires when the starting index actually falls within the filler region
and Foffset would overflow the output buffer.

Validated with rfsim TWO-TAP fading channel: rate matching errors
drop from 55 to 0, DL goodput improves from 3.37 to 3.69 Mbps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maxime
2026-05-17 07:45:47 -04:00
parent 6fc2d06077
commit 4ca2e23b4c

View File

@@ -535,13 +535,13 @@ int nr_rate_matching_ldpc(uint32_t Tbslbrm,
Tbslbrm);
#endif
if (Foffset > E) {
if (ind < Foffset && Foffset > E) {
LOG_E(PHY,
"nr_rate_matching: invalid parameters (Foffset %d > E %d) F %d, k0 %d, Ncb %d, rvidx %d, Tbslbrm %d\n",
"nr_rate_matching: invalid parameters (ind %d < Foffset %d > E %d) F %d, Ncb %d, rvidx %d, Tbslbrm %d\n",
ind,
Foffset,
E,
F,
ind,
Ncb,
rvidx,
Tbslbrm);
@@ -625,8 +625,8 @@ int nr_rate_matching_ldpc_rx(uint32_t Tbslbrm,
}
uint32_t ind = (index_k0[BG - 1][rvidx] * Ncb / N) * Z;
if (Foffset > E) {
LOG_E(PHY, "nr_rate_matching: invalid parameters (Foffset %d > E %d)\n", Foffset, E);
if (ind < Foffset && Foffset > E) {
LOG_E(PHY, "nr_rate_matching_rx: invalid parameters (ind %d < Foffset %d > E %d)\n", ind, Foffset, E);
return -1;
}
if (Foffset > Ncb) {