From dc88ca3b6d56ab16cd221dec6849464f7cedf479 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 24 Oct 2023 12:02:49 +0200 Subject: [PATCH] Read DMRS_UplinkConfig from BWP info when needed Before this commit, the DMRS_UplinkConfig was stored in a separate DMRS-related structure, although it is always referenced in the PUSCHConfig of the current UL BWP. Through certain code paths (e.g., retransmission), it could happen that an old DMRS_UplinkConfig was accessed that was freed (through new CellGroupConfig). In this commit, we always look up the DMRS_UplinkConfig in the current PUSCH config, which should always be up to date. --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 11 +++++++++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 ++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 1 - 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 1e5de41ab3..e76773961c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -586,6 +586,15 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } +const NR_DMRS_UplinkConfig_t *get_DMRS_UplinkConfig(const NR_PUSCH_Config_t *pusch_Config, const NR_tda_info_t *tda_info) +{ + if (pusch_Config == NULL) + return NULL; + + return tda_info->mapping_type == typeA ? pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup + : pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; +} + NR_pusch_dmrs_t get_ul_dmrs_params(const NR_ServingCellConfigCommon_t *scc, const NR_UE_UL_BWP_t *ul_bwp, const NR_tda_info_t *tda_info, @@ -623,8 +632,6 @@ NR_pusch_dmrs_t get_ul_dmrs_params(const NR_ServingCellConfigCommon_t *scc, num_dmrs_symb += (dmrs.ul_dmrs_symb_pos >> i) & 1; dmrs.num_dmrs_symb = num_dmrs_symb; dmrs.N_PRB_DMRS = dmrs.num_dmrs_cdm_grps_no_data * (dmrs.dmrs_config_type == 0 ? 6 : 4); - - dmrs.NR_DMRS_UplinkConfig = NR_DMRS_UplinkConfig; return dmrs; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 2dc0bc89db..761bbf6535 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -2234,7 +2234,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n /* FAPI: DMRS */ pusch_pdu->ul_dmrs_symb_pos = sched_pusch->dmrs_info.ul_dmrs_symb_pos; pusch_pdu->dmrs_config_type = sched_pusch->dmrs_info.dmrs_config_type; - const NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = sched_pusch->dmrs_info.NR_DMRS_UplinkConfig; + const NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = get_DMRS_UplinkConfig(current_BWP->pusch_Config, &sched_pusch->tda_info); if (pusch_pdu->transform_precoding) { // transform precoding disabled long *scramblingid=NULL; if (NR_DMRS_UplinkConfig && pusch_pdu->scid == 0) diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index cc649a28f3..9f96a0d106 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -269,6 +269,8 @@ long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu); +const NR_DMRS_UplinkConfig_t *get_DMRS_UplinkConfig(const NR_PUSCH_Config_t *pusch_Config, const NR_tda_info_t *tda_info); + NR_pusch_dmrs_t get_ul_dmrs_params(const NR_ServingCellConfigCommon_t *scc, const NR_UE_UL_BWP_t *ul_bwp, const NR_tda_info_t *tda_info, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index d051d93528..c73c566374 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -378,7 +378,6 @@ typedef struct NR_pusch_dmrs { uint16_t ul_dmrs_symb_pos; uint8_t num_dmrs_cdm_grps_no_data; nfapi_nr_dmrs_type_e dmrs_config_type; - NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig; } NR_pusch_dmrs_t; typedef struct NR_sched_pusch {