From 6c227f4d6b262caac2d3d17277a1939597694e24 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 5 Aug 2021 12:15:09 +0200 Subject: [PATCH] NR_UE: Assure correct padding in nr_ue_get_sdu() In case no MAC CE needs to be transmitted and we filled the buffer with SDUs from RLC, we missed to add padding for the last 3 bytes. --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 21cb0805f7..2357ebae9a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1976,7 +1976,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, for (lcid = UL_SCH_LCID_SRB1; lcid < MAX_LCID; lcid++) { - buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total + MAX_RLC_SDU_SUBHEADER_SIZE); + buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total + sh_size); LOG_D(NR_MAC, "In %s: [UE %d] [%d.%d] UL-DXCH -> ULSCH, RLC with LCID 0x%02x (TBS %d bytes, sdu_length_total %d bytes, MAC header len %d bytes, buflen_remain %d bytes)\n", __FUNCTION__, @@ -2047,7 +2047,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, break; } - buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total + MAX_RLC_SDU_SUBHEADER_SIZE); + buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total + sh_size); } } @@ -2056,7 +2056,6 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, LOG_D(NR_MAC, "In %s copying %d bytes of MAC CEs to the UL PDU \n", __FUNCTION__, tot_mac_ce_len); memcpy((void *) pdu, (void *) mac_header_control_elements, tot_mac_ce_len); - buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total); pdu += (unsigned char) tot_mac_ce_len; #ifdef ENABLE_MAC_PAYLOAD_DEBUG @@ -2066,6 +2065,8 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, } + buflen_remain = buflen - (total_mac_pdu_header_len + sdu_length_total); + // Compute final offset for padding and fill remainder of ULSCH with 0 if (buflen_remain > 0) {