From 9c16a323feb20ca2ba1d3c46765b81d974f1dac9 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 13 Feb 2025 15:32:05 +0100 Subject: [PATCH] function to handle antenna port tables --- openair2/LAYER2/NR_MAC_UE/mac_extern.h | 7 --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_UE/mac_vars.c | 56 ++++++++++++++++++++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 56 +------------------- 4 files changed, 59 insertions(+), 62 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_extern.h b/openair2/LAYER2/NR_MAC_UE/mac_extern.h index 4d834d8b0f..1bc1ad5d10 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_extern.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_extern.h @@ -46,13 +46,6 @@ extern const uint8_t table_7_3_1_1_2_20[28][3]; extern const uint8_t table_7_3_1_1_2_21[19][4]; extern const uint8_t table_7_3_1_1_2_22[6][5]; extern const uint8_t table_7_3_1_1_2_23[5][6]; -extern const uint8_t table_7_3_2_3_3_1[12][5]; -extern const uint8_t table_7_3_2_3_3_2_oneCodeword[31][10]; -extern const uint8_t table_7_3_2_3_3_2_twoCodeword[4][10]; -extern const uint8_t table_7_3_2_3_3_3_oneCodeword[24][7]; -extern const uint8_t table_7_3_2_3_3_3_twoCodeword[2][7]; -extern const uint8_t table_7_3_2_3_3_4_oneCodeword[58][14]; -extern const uint8_t table_7_3_2_3_3_4_twoCodeword[6][14]; extern const uint16_t table_7_2_1[16]; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index c2e8fd5885..f84bcd8756 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -262,7 +262,7 @@ float nr_get_Pcmax(int p_Max, int start_prb); float nr_get_Pcmin(int bandwidth_index); - +void set_antenna_port_parameters(fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu, int n_cw, long *max_length, long *dmrs, int ant); int get_sum_delta_pucch(NR_UE_MAC_INST_t *mac, int slot, frame_t frame); /* Random Access */ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_vars.c b/openair2/LAYER2/NR_MAC_UE/mac_vars.c index 20abda978d..672d2a057d 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_vars.c +++ b/openair2/LAYER2/NR_MAC_UE/mac_vars.c @@ -31,6 +31,7 @@ */ #include +#include "NR_MAC_UE/mac_proto.h" // table_7_3_1_1_2_2_3_4_5 contains values for number of layers and precoding information for tables 7.3.1.1.2-2/3/4/5 from TS 38.212 subclause 7.3.1.1.2 // the first 6 columns contain table 7.3.1.1.2-2: Precoding information and number of layers, for 4 antenna ports, if transformPrecoder=disabled and maxRank = 2 or 3 or 4 @@ -428,3 +429,58 @@ const uint16_t table_7_2_1[16] = { 960, // row index 12 1920, // row index 13 }; + +static inline uint16_t packBits(const uint8_t *toPack, const int nb) +{ + int res = 0; + for (int i = 0; i < nb; i++) + res += (*toPack++) << i; + return res; +} + +void set_antenna_port_parameters(fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu, int n_cw, long *max_length, long *dmrs, int ant) +{ + if (dmrs == NULL) { + if (max_length == NULL) { + // Table 7.3.1.2.2-1: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=1 + dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_1[ant][0]; + dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_1[ant][1], 4); + } else { + // Table 7.3.1.2.2-2: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=2 + if (n_cw == 1) { + dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_2_oneCodeword[ant][0]; + dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_2_oneCodeword[ant][1], 8); + dlsch_pdu->n_front_load_symb = table_7_3_2_3_3_2_oneCodeword[ant][9]; + } + if (n_cw == 2) { + dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_2_twoCodeword[ant][0]; + dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_2_twoCodeword[ant][1], 8); + dlsch_pdu->n_front_load_symb = table_7_3_2_3_3_2_twoCodeword[ant][9]; + } + } + } else { + if (max_length == NULL) { + // Table 7.3.1.2.2-3: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=1 + if (n_cw == 1) { + dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_3_oneCodeword[ant][0]; + dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_3_oneCodeword[ant][1], 6); + } + if (n_cw == 2) { + dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_3_twoCodeword[ant][0]; + dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_3_twoCodeword[ant][1], 6); + } + } else { + // Table 7.3.1.2.2-4: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=2 + if (n_cw == 1) { + dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_4_oneCodeword[ant][0]; + dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_4_oneCodeword[ant][1], 12); + dlsch_pdu->n_front_load_symb = table_7_3_2_3_3_4_oneCodeword[ant][13]; + } + if (n_cw == 2) { + dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_4_twoCodeword[ant][0]; + dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_4_twoCodeword[ant][1], 12); + dlsch_pdu->n_front_load_symb = table_7_3_2_3_3_4_twoCodeword[ant][13]; + } + } + } +} diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 65309ea575..c98cf37846 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -972,14 +972,6 @@ static int nr_ue_process_dci_dl_10(NR_UE_MAC_INST_t *mac, return 0; } -static inline uint16_t packBits(const uint8_t *toPack, const int nb) -{ - int res = 0; - for (int i = 0; i < nb; i++) - res += (*toPack++) << i; - return res; -} - static int nr_ue_process_dci_dl_11(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, @@ -1178,53 +1170,9 @@ static int nr_ue_process_dci_dl_11(NR_UE_MAC_INST_t *mac, long *dmrs_type = dl_dmrs_config->dmrs_Type; dlsch_pdu->n_front_load_symb = 1; // default value - const int ant = dci->antenna_ports.val; + set_antenna_port_parameters(dlsch_pdu, n_codewords, max_length, dmrs_type, dci->antenna_ports.val); - if (dmrs_type == NULL) { - if (max_length == NULL) { - // Table 7.3.1.2.2-1: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=1 - dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_1[ant][0]; - dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_1[ant][1], 4); - } else { - // Table 7.3.1.2.2-2: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=2 - if (n_codewords == 1) { - dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_2_oneCodeword[ant][0]; - dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_2_oneCodeword[ant][1], 8); - dlsch_pdu->n_front_load_symb = table_7_3_2_3_3_2_oneCodeword[ant][9]; - } - if (n_codewords == 2) { - dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_2_twoCodeword[ant][0]; - dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_2_twoCodeword[ant][1], 8); - dlsch_pdu->n_front_load_symb = table_7_3_2_3_3_2_twoCodeword[ant][9]; - } - } - } else { - if (max_length == NULL) { - // Table 7.3.1.2.2-3: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=1 - if (n_codewords == 1) { - dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_3_oneCodeword[ant][0]; - dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_3_oneCodeword[ant][1], 6); - } - if (n_codewords == 2) { - dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_3_twoCodeword[ant][0]; - dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_3_twoCodeword[ant][1], 6); - } - } else { - // Table 7.3.1.2.2-4: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=2 - if (n_codewords == 1) { - dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_4_oneCodeword[ant][0]; - dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_4_oneCodeword[ant][1], 12); - dlsch_pdu->n_front_load_symb = table_7_3_2_3_3_4_oneCodeword[ant][13]; - } - if (n_codewords == 2) { - dlsch_pdu->n_dmrs_cdm_groups = table_7_3_2_3_3_4_twoCodeword[ant][0]; - dlsch_pdu->dmrs_ports = packBits(&table_7_3_2_3_3_4_twoCodeword[ant][1], 12); - dlsch_pdu->n_front_load_symb = table_7_3_2_3_3_4_twoCodeword[ant][13]; - } - } - } - - /* dmrs symbol positions*/ + /* dmrs symbol positions*/ dlsch_pdu->dlDmrsSymbPos = fill_dmrs_mask(pdsch_Config, NR_DL_DCI_FORMAT_1_1, mac->dmrs_TypeA_Position,