UE MAC: in phy-test/do-ra, fill TB randomly

Commit d641a76196 ("fix BSR report malformed, add SHORT BSR when it
can") removed code to fill the remainder of a TB, if it is not filled
with data from RLC, with random data when using phy-test or do-ra modes.
This random data filling is intentional, as it might prove useful for
demos or when debugging (e.g., to see used spectrum instead of 0, etc.).
Reintroduce the functionality, but unlike the original code, make it
dependent on the mode, not RFsim.

See also discussion in #888.

Fixup: d641a76196
This commit is contained in:
Robert Schmidt
2025-01-09 15:24:23 +01:00
parent f9bff3d6a0
commit 54c88a4a4a
+14 -1
View File
@@ -3588,7 +3588,20 @@ static uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac,
LOG_D(NR_MAC, "Filling remainder %d bytes to the UL PDU \n", remain);
*(NR_MAC_SUBHEADER_FIXED *)mac_ce_info.cur_ptr = (NR_MAC_SUBHEADER_FIXED){.R = 0, .LCID = UL_SCH_LCID_PADDING};
mac_ce_info.cur_ptr++;
memset(mac_ce_info.cur_ptr, 0, mac_ce_info.pdu_end - mac_ce_info.cur_ptr);
if (get_softmodem_params()->phy_test || get_softmodem_params()->do_ra) {
uint8_t *buf = mac_ce_info.cur_ptr;
uint8_t *end = mac_ce_info.pdu_end;
for (; buf < end && ((intptr_t)buf) % 4; buf++)
*buf = lrand48() & 0xff;
for (; buf < end - 3; buf += 4) {
uint32_t *buf32 = (uint32_t *)buf;
*buf32 = lrand48();
}
for (; buf < end; buf++)
*buf = lrand48() & 0xff;
} else {
memset(mac_ce_info.cur_ptr, 0, mac_ce_info.pdu_end - mac_ce_info.cur_ptr);
}
}
#ifdef ENABLE_MAC_PAYLOAD_DEBUG
LOG_I(NR_MAC, "MAC PDU %d bytes \n", mac_ce_p->cur_ptr - ulsch_buffer);