From 54c88a4a4aef77ed16b1a65196a8df0f28744a75 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 9 Jan 2025 15:20:48 +0100 Subject: [PATCH] UE MAC: in phy-test/do-ra, fill TB randomly Commit d641a7619609 ("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: d641a76196096bf1c5d701002e0a877ce0dd444d --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 8e4fbf7154..29434b2473 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -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);