diff --git a/CMakeLists.txt b/CMakeLists.txt index b4ea5a77eb..d608d99c53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1250,7 +1250,7 @@ set (MAC_NR_SRC_UE ${NR_UE_PHY_INTERFACE_DIR}/NR_Packet_Drop.c ${NR_UE_MAC_DIR}/config_ue.c ${NR_UE_MAC_DIR}/config_ue_sl.c - ${NR_UE_MAC_DIR}/mac_vars.c + ${NR_UE_MAC_DIR}/mac_tables.c ${NR_UE_MAC_DIR}/main_ue_nr.c ${NR_UE_MAC_DIR}/nr_ue_procedures.c ${NR_UE_MAC_DIR}/nr_ue_procedures_sl.c diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index a3e0dcd580..1d1e683dce 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -726,12 +726,12 @@ int get_slot_idx_in_period(const int slot, const frame_structure_t *fs) int get_dmrs_port(int nl, uint16_t dmrs_ports) { - - if (dmrs_ports == 0) return 0; // dci 1_0 + if (dmrs_ports == 0) + return 0; // dci 1_0 int p = -1; int found = -1; - for (int i=0; i<12; i++) { // loop over dmrs ports - if((dmrs_ports>>i)&0x01) { // check if current bit is 1 + for (int i = 0; i < 12; i++) { // loop over dmrs ports + if((dmrs_ports >> i) & 0x01) { // check if current bit is 1 found++; if (found == nl) { // found antenna port number corresponding to current layer p = i; @@ -739,7 +739,7 @@ int get_dmrs_port(int nl, uint16_t dmrs_ports) } } } - AssertFatal(p>-1,"No dmrs port corresponding to layer %d found\n",nl); + AssertFatal(p > -1, "No dmrs port corresponding to layer %d found\n", nl); return p; } diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index 5d5c6a363c..ce71500eb0 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -204,11 +204,10 @@ bool nr_timer_is_active(const NR_timer_t *timer); uint32_t nr_timer_elapsed_time(const NR_timer_t *timer); int set_default_nta_offset(frequency_range_t freq_range, uint32_t samples_per_subframe); -extern const nr_bandentry_t nr_bandtable[]; extern simde__m128i byte2bit16_lut[256]; void init_byte2bit16(void); -void init_byte2m128i(void); +void init_byte2m128i(void); static inline simde__m128i byte2bit16(uint8_t b) { diff --git a/doc/Doxyfile b/doc/Doxyfile index 59a984e79f..e4fcaa0fe8 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1619,7 +1619,6 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/NETWORK_DRIVER/MESH/ioctl.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/NETWORK_DRIVER/MESH/constant.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/NETWORK_DRIVER/MESH/rrc_nas_primitives.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h \ @@ -1690,13 +1689,12 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/openair2_proc.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/RLC/rlc.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/mac_vars.c \ +@CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/mac_tables.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/mac_defs.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/mac_proto.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/config_ue.c \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/mac_extern.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/main_ue_nr.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c \ @@ -1864,7 +1862,6 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/nr_rrc_config.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_radio_bearers.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/nr_rrc_extern.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_reconfig.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_NGAP.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/mac_rrc_dl_f1ap.c \ diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 6acd649ab6..4766481364 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -48,7 +48,6 @@ #include "PHY/MODULATION/nr_modulation.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "openair2/NR_PHY_INTERFACE/nr_sched_response.h" -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "radio/COMMON/common_lib.h" diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 5a2e49937b..4dabe78b15 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -47,7 +47,6 @@ unsigned short config_frames[4] = {2,9,11,13}; #include #include #include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_PHY_INTERFACE/NR_IF_Module.h" #include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "PHY/INIT/nr_phy_init.h" diff --git a/openair1/SIMULATION/NR_PHY/psbchsim.c b/openair1/SIMULATION/NR_PHY/psbchsim.c index 23803e133f..a4353bae14 100644 --- a/openair1/SIMULATION/NR_PHY/psbchsim.c +++ b/openair1/SIMULATION/NR_PHY/psbchsim.c @@ -37,7 +37,6 @@ #include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h" #include "openair1/SIMULATION/TOOLS/sim.h" #include "common/utils/nr/nr_common.h" -#include "openair2/RRC/NR/nr_rrc_extern.h" #include "openair2/RRC/LTE/rrc_vars.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/INIT/nr_phy_init.h" diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 946274a7bd..b45ca38254 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -1021,7 +1021,7 @@ int main(int argc, char *argv[]) while (round < max_rounds && crc_status) { round_trials[round]++; - rv_index = nr_rv_round_map[round % 4]; + rv_index = nr_get_rv(round % 4); /// gNB UL PDUs diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 2ff5ec0da6..df80941a09 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -44,7 +44,6 @@ #include "PHY/defs_gNB.h" #include "PHY/defs_nr_common.h" #include "RRC/NR/nr_rrc_config.h" -#include "RRC/NR/nr_rrc_extern.h" #include "RRC_nr_paramsvalues.h" #include "T.h" #include "asn_SEQUENCE_OF.h" diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index f9f6269f43..0d086e6f6a 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -36,7 +36,6 @@ #include "LAYER2/MAC/mac.h" #include "LAYER2/MAC/mac_proto.h" #include "LAYER2/MAC/mac_extern.h" -#include #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 2c9a2b02c0..d33ccbb22a 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -45,6 +45,12 @@ const uint32_t NR_SHORT_BSR_TABLE[NR_SHORT_BSR_TABLE_SIZE] = { 20516, 28581, 39818, 55474, 77284, 107669, 150000, 300000 }; +uint32_t get_short_bsr_value(int idx) +{ + AssertFatal(idx < NR_SHORT_BSR_TABLE_SIZE, "Short BSR table index %d exceeding its size\n", idx); + return NR_SHORT_BSR_TABLE[idx]; +} + //38.321 Table 6.1.3.1-2 const uint32_t NR_LONG_BSR_TABLE[NR_LONG_BSR_TABLE_SIZE] ={ 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 25, 26, @@ -65,6 +71,12 @@ const uint32_t NR_LONG_BSR_TABLE[NR_LONG_BSR_TABLE_SIZE] ={ 35910462, 38241455, 40723756, 43367187, 46182206, 49179951, 52372284, 55771835, 59392055, 63247269, 67352729, 71724679, 76380419, 81338368, 162676736, 4294967295 }; +uint32_t get_long_bsr_value(int idx) +{ + AssertFatal(idx < NR_LONG_BSR_TABLE_SIZE, "Short BSR table index %d exceeding its size\n", idx); + return NR_LONG_BSR_TABLE[idx]; +} + // start symbols for SSB types A,B,C,D,E static const uint16_t symbol_ssb_AC[8] = {2, 8, 16, 22, 30, 36, 44, 50}; static const uint16_t symbol_ssb_BD[64] = {4, 8, 16, 20, 32, 36, 44, 48, 60, 64, 72, 76, 88, 92, 100, 104, @@ -305,113 +317,6 @@ const uint8_t table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos3[16][4]={ {1,0,2,6} // row index 16 }; -// TS 38.211 - Table 6.3.1.5-1: Precoding matrix W for single-layer transmission using two antenna ports, 'n' = -1 and 'o' = -j -const char table_38211_6_3_1_5_1[6][2][1] = { - {{'1'}, {'0'}}, // tpmi 0 - {{'0'}, {'1'}}, // tpmi 1 - {{'1'}, {'1'}}, // tpmi 2 - {{'1'}, {'n'}}, // tpmi 3 - {{'1'}, {'j'}}, // tpmi 4 - {{'1'}, {'o'}} // tpmi 5 -}; - -// TS 38.211 - Table 6.3.1.5-2: Precoding matrix W for single-layer transmission using four antenna ports with transform precoding enabled, 'n' = -1 and 'o' = -j -const char table_38211_6_3_1_5_2[28][4][1] = { - {{'1'}, {'0'}, {'0'}, {'0'}}, // tpmi 0 - {{'0'}, {'1'}, {'0'}, {'0'}}, // tpmi 1 - {{'0'}, {'0'}, {'1'}, {'0'}}, // tpmi 2 - {{'0'}, {'0'}, {'0'}, {'1'}}, // tpmi 3 - {{'1'}, {'0'}, {'1'}, {'0'}}, // tpmi 4 - {{'1'}, {'0'}, {'n'}, {'0'}}, // tpmi 5 - {{'1'}, {'0'}, {'j'}, {'0'}}, // tpmi 6 - {{'1'}, {'0'}, {'o'}, {'0'}}, // tpmi 7 - {{'0'}, {'1'}, {'0'}, {'1'}}, // tpmi 8 - {{'0'}, {'1'}, {'0'}, {'n'}}, // tpmi 9 - {{'0'}, {'1'}, {'0'}, {'j'}}, // tpmi 10 - {{'0'}, {'1'}, {'0'}, {'o'}}, // tpmi 11 - {{'1'}, {'1'}, {'1'}, {'n'}}, // tpmi 12 - {{'1'}, {'1'}, {'j'}, {'j'}}, // tpmi 13 - {{'1'}, {'1'}, {'n'}, {'1'}}, // tpmi 14 - {{'1'}, {'1'}, {'o'}, {'o'}}, // tpmi 15 - {{'1'}, {'j'}, {'1'}, {'j'}}, // tpmi 16 - {{'1'}, {'j'}, {'j'}, {'1'}}, // tpmi 17 - {{'1'}, {'j'}, {'n'}, {'o'}}, // tpmi 18 - {{'1'}, {'j'}, {'o'}, {'n'}}, // tpmi 19 - {{'1'}, {'n'}, {'1'}, {'1'}}, // tpmi 20 - {{'1'}, {'n'}, {'j'}, {'o'}}, // tpmi 21 - {{'1'}, {'n'}, {'n'}, {'n'}}, // tpmi 22 - {{'1'}, {'n'}, {'o'}, {'j'}}, // tpmi 23 - {{'1'}, {'o'}, {'1'}, {'o'}}, // tpmi 24 - {{'1'}, {'o'}, {'j'}, {'n'}}, // tpmi 25 - {{'1'}, {'o'}, {'n'}, {'j'}}, // tpmi 26 - {{'1'}, {'o'}, {'o'}, {'1'}} // tpmi 27 -}; - -// TS 38.211 - Table 6.3.1.5-3: Precoding matrix W for single-layer transmission using four antenna ports with transform precoding disabled, 'n' = -1 and 'o' = -j -const char table_38211_6_3_1_5_3[28][4][1] = { - {{'1'}, {'0'}, {'0'}, {'0'}}, // tpmi 0 - {{'0'}, {'1'}, {'0'}, {'0'}}, // tpmi 1 - {{'0'}, {'0'}, {'1'}, {'0'}}, // tpmi 2 - {{'0'}, {'0'}, {'0'}, {'1'}}, // tpmi 3 - {{'1'}, {'0'}, {'1'}, {'0'}}, // tpmi 4 - {{'1'}, {'0'}, {'n'}, {'0'}}, // tpmi 5 - {{'1'}, {'0'}, {'j'}, {'0'}}, // tpmi 6 - {{'1'}, {'0'}, {'o'}, {'0'}}, // tpmi 7 - {{'0'}, {'1'}, {'0'}, {'1'}}, // tpmi 8 - {{'0'}, {'1'}, {'0'}, {'n'}}, // tpmi 9 - {{'0'}, {'1'}, {'0'}, {'j'}}, // tpmi 10 - {{'0'}, {'1'}, {'0'}, {'o'}}, // tpmi 11 - {{'1'}, {'1'}, {'1'}, {'1'}}, // tpmi 12 - {{'1'}, {'1'}, {'j'}, {'j'}}, // tpmi 13 - {{'1'}, {'1'}, {'n'}, {'n'}}, // tpmi 14 - {{'1'}, {'1'}, {'o'}, {'o'}}, // tpmi 15 - {{'1'}, {'j'}, {'1'}, {'j'}}, // tpmi 16 - {{'1'}, {'j'}, {'j'}, {'n'}}, // tpmi 17 - {{'1'}, {'j'}, {'n'}, {'o'}}, // tpmi 18 - {{'1'}, {'j'}, {'o'}, {'1'}}, // tpmi 19 - {{'1'}, {'n'}, {'1'}, {'n'}}, // tpmi 20 - {{'1'}, {'n'}, {'j'}, {'o'}}, // tpmi 21 - {{'1'}, {'n'}, {'n'}, {'1'}}, // tpmi 22 - {{'1'}, {'n'}, {'o'}, {'j'}}, // tpmi 23 - {{'1'}, {'o'}, {'1'}, {'o'}}, // tpmi 24 - {{'1'}, {'o'}, {'j'}, {'1'}}, // tpmi 25 - {{'1'}, {'o'}, {'n'}, {'j'}}, // tpmi 26 - {{'1'}, {'o'}, {'o'}, {'n'}} // tpmi 27 -}; - -// TS 38.211 - Table 6.3.1.5-4: Precoding matrix W for two-layer transmission using two antenna ports, 'n' = -1 and 'o' = -j -const char table_38211_6_3_1_5_4[3][2][2] = { - {{'1', '0'}, {'0', '1'}}, // tpmi 0 - {{'1', '1'}, {'1', 'n'}}, // tpmi 1 - {{'1', '1'}, {'j', 'o'}} // tpmi 2 -}; - -// TS 38.211 - Table 6.3.1.5-5: Precoding matrix W for two-layer transmission using four antenna ports, 'n' = -1 and 'o' = -j -const char table_38211_6_3_1_5_5[22][4][2] = { - {{'1', '0'}, {'0', '1'}, {'0', '0'}, {'0', '0'}}, // tpmi 0 - {{'1', '0'}, {'0', '0'}, {'0', '1'}, {'0', '0'}}, // tpmi 1 - {{'1', '0'}, {'0', '0'}, {'0', '0'}, {'0', '1'}}, // tpmi 2 - {{'0', '0'}, {'1', '0'}, {'0', '1'}, {'0', '0'}}, // tpmi 3 - {{'0', '0'}, {'1', '0'}, {'0', '0'}, {'0', '1'}}, // tpmi 4 - {{'0', '0'}, {'0', '0'}, {'1', '0'}, {'0', '1'}}, // tpmi 5 - {{'1', '0'}, {'0', '1'}, {'1', '0'}, {'0', 'o'}}, // tpmi 6 - {{'1', '0'}, {'0', '1'}, {'1', '0'}, {'0', 'j'}}, // tpmi 7 - {{'1', '0'}, {'0', '1'}, {'o', '0'}, {'0', '1'}}, // tpmi 8 - {{'1', '0'}, {'0', '1'}, {'o', '0'}, {'0', 'n'}}, // tpmi 9 - {{'1', '0'}, {'0', '1'}, {'n', '0'}, {'0', 'o'}}, // tpmi 10 - {{'1', '0'}, {'0', '1'}, {'n', '0'}, {'0', 'j'}}, // tpmi 11 - {{'1', '0'}, {'0', '1'}, {'j', '0'}, {'0', '1'}}, // tpmi 12 - {{'1', '0'}, {'0', '1'}, {'j', '0'}, {'0', 'n'}}, // tpmi 13 - {{'1', '1'}, {'1', '1'}, {'1', 'n'}, {'1', 'n'}}, // tpmi 14 - {{'1', '1'}, {'1', '1'}, {'j', 'o'}, {'j', 'o'}}, // tpmi 15 - {{'1', '1'}, {'j', 'j'}, {'1', 'n'}, {'j', 'o'}}, // tpmi 16 - {{'1', '1'}, {'j', 'j'}, {'j', 'o'}, {'n', '1'}}, // tpmi 17 - {{'1', '1'}, {'n', 'n'}, {'1', 'n'}, {'n', '1'}}, // tpmi 18 - {{'1', '1'}, {'n', 'n'}, {'j', 'o'}, {'o', 'j'}}, // tpmi 19 - {{'1', '1'}, {'o', 'o'}, {'1', 'n'}, {'o', 'j'}}, // tpmi 20 - {{'1', '1'}, {'o', 'o'}, {'j', 'o'}, {'1', 'n'}} // tpmi 21 -}; - // Default PUSCH time domain resource allocation tables from 38.214 const uint8_t table_6_1_2_1_1_2[16][4] = { {0, 0, 0, 14}, // row index 1 diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index dced6f465a..e5f7fb4fcf 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -55,7 +55,8 @@ typedef enum { uint32_t get_Y(const NR_SearchSpace_t *ss, int slot, rnti_t rnti); uint8_t get_BG(uint32_t A, uint16_t R); - +uint32_t get_short_bsr_value(int idx); +uint32_t get_long_bsr_value(int idx); int16_t fill_dmrs_mask(const NR_PDSCH_Config_t *pdsch_Config, int dci_format, int dmrs_TypeA_Position, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h deleted file mode 100644 index f2f070bf23..0000000000 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nr_mac_extern.h -* \brief NR mac externs -* \author Navid Nikaein, Raymond Knopp, Guido Casati -* \date 2019 -* \version 1.0 -* \email navid.nikaein@eurecom.fr, guido.casati@iis.fraunhofer.de -* @ingroup _mac - -*/ - -#ifndef __NR_MAC_EXTERN_H__ -#define __NR_MAC_EXTERN_H__ - -#include "common/ran_context.h" -#include "nr_mac.h" - -/*#include "PHY/defs_common.h"*/ - -/* Scheduler */ -extern RAN_CONTEXT_t RC; -extern uint8_t nfapi_mode; - -extern const uint32_t NR_SHORT_BSR_TABLE[NR_SHORT_BSR_TABLE_SIZE]; -extern const uint32_t NR_LONG_BSR_TABLE[NR_LONG_BSR_TABLE_SIZE]; - -// Type0-PDCCH search space -extern const int32_t table_38213_13_1_c1[16]; -extern const int32_t table_38213_13_1_c2[16]; -extern const int32_t table_38213_13_1_c3[16]; -extern const int32_t table_38213_13_1_c4[16]; - -extern const int32_t table_38213_13_2_c1[16]; -extern const int32_t table_38213_13_2_c2[16]; -extern const int32_t table_38213_13_2_c3[16]; -extern const int32_t table_38213_13_2_c4[16]; - -extern const int32_t table_38213_13_3_c1[16]; -extern const int32_t table_38213_13_3_c2[16]; -extern const int32_t table_38213_13_3_c3[16]; -extern const int32_t table_38213_13_3_c4[16]; - -extern const int32_t table_38213_13_4_c1[16]; -extern const int32_t table_38213_13_4_c2[16]; -extern const int32_t table_38213_13_4_c3[16]; -extern const int32_t table_38213_13_4_c4[16]; - -extern const int32_t table_38213_13_5_c1[16]; -extern const int32_t table_38213_13_5_c2[16]; -extern const int32_t table_38213_13_5_c3[16]; -extern const int32_t table_38213_13_5_c4[16]; - -extern const int32_t table_38213_13_6_c1[16]; -extern const int32_t table_38213_13_6_c2[16]; -extern const int32_t table_38213_13_6_c3[16]; -extern const int32_t table_38213_13_6_c4[16]; - -extern const int32_t table_38213_13_7_c1[16]; -extern const int32_t table_38213_13_7_c2[16]; -extern const int32_t table_38213_13_7_c3[16]; -extern const int32_t table_38213_13_7_c4[16]; - -extern const int32_t table_38213_13_8_c1[16]; -extern const int32_t table_38213_13_8_c2[16]; -extern const int32_t table_38213_13_8_c3[16]; -extern const int32_t table_38213_13_8_c4[16]; - -extern const int32_t table_38213_13_9_c1[16]; -extern const int32_t table_38213_13_9_c2[16]; -extern const int32_t table_38213_13_9_c3[16]; -extern const int32_t table_38213_13_9_c4[16]; - -extern const int32_t table_38213_13_10_c1[16]; -extern const int32_t table_38213_13_10_c2[16]; -extern const int32_t table_38213_13_10_c3[16]; -extern const int32_t table_38213_13_10_c4[16]; - -extern const float table_38213_13_11_c1[16]; -extern const int32_t table_38213_13_11_c2[16]; -extern const float table_38213_13_11_c3[16]; -extern const int32_t table_38213_13_11_c4[16]; - -extern const float table_38213_13_12_c1[16]; -extern const int32_t table_38213_13_12_c2[16]; -extern const float table_38213_13_12_c3[16]; - -extern const int32_t table_38213_10_1_1_c2[5]; - -extern const char table_38211_6_3_1_5_1[6][2][1]; -extern const char table_38211_6_3_1_5_2[28][4][1]; -extern const char table_38211_6_3_1_5_3[28][4][1]; -extern const char table_38211_6_3_1_5_4[3][2][2]; -extern const char table_38211_6_3_1_5_5[22][4][2]; -#endif //DEF_H diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 2ba5f992d4..fbd96532f9 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -45,7 +45,6 @@ /* MAC */ #include "LAYER2/NR_MAC_COMMON/nr_mac.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "mac_defs_sl.h" /* RRC */ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_extern.h b/openair2/LAYER2/NR_MAC_UE/mac_extern.h deleted file mode 100644 index ae8d5091fa..0000000000 --- a/openair2/LAYER2/NR_MAC_UE/mac_extern.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* \file extern.h - * \brief extern variables for MAC layer - * \author R. Knopp, K.H. HSU - * \date 2018 - * \version 0.1 - * \company Eurecom / NTUST - * \email: knopp@eurecom.fr, kai-hsiang.hsu@eurecom.fr - * \note - * \warning - */ - -#include "mac_defs.h" - -//extern NR_UE_MAC_INST_t *UE_mac_inst; - -// DCI extraction -// for PUSCH from TS 38.214 subclause 6.1.2.1.1 -extern uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3]; -// for PDSCH from TS 38.214 subclause 5.1.2.1.1 -extern uint8_t table_5_1_2_1_1_2_time_dom_res_alloc_A[16][3]; - -extern int64_t table_6_3_3_2_3_prachConfig_Index [256][9]; - -// DCI -extern const uint8_t table_7_3_1_1_2_2_3_4_5[64][20]; -extern const uint8_t table_7_3_1_1_2_12[14][3]; -extern const uint8_t table_7_3_1_1_2_13[10][4]; -extern const uint8_t table_7_3_1_1_2_14[3][5]; -extern const uint8_t table_7_3_1_1_2_15[4][6]; -extern const uint8_t table_7_3_1_1_2_16[12][2]; -extern const uint8_t table_7_3_1_1_2_17[7][3]; -extern const uint8_t table_7_3_1_1_2_18[3][4]; -extern const uint8_t table_7_3_1_1_2_19[2][5]; -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]; - -extern void mac_rlc_data_ind(const module_id_t module_idP, - const rnti_t rntiP, - const eNB_index_t eNB_index, - const frame_t frameP, - const eNB_flag_t enb_flagP, - const MBMS_flag_t MBMS_flagP, - const logical_chan_id_t channel_idP, - char *buffer_pP, - const tb_size_t tb_sizeP, - num_tb_t num_tbP, - crc_t *crcs_pP); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index c2e8fd5885..981ad21a20 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -192,7 +192,11 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, const NR_SearchSpace_t *ss); void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, const frame_t frame, const int slot); - +void set_precoding_information_parameters(nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, + int n_antenna_port, + long transformPrecoder, + int precoding_information, + NR_PUSCH_Config_t *pusch_Config); void set_harq_status(NR_UE_MAC_INST_t *mac, uint8_t pucch_id, uint8_t harq_id, @@ -207,7 +211,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, bool get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sched_t *pucch); initial_pucch_resource_t get_initial_pucch_resource(const int idx); void multiplex_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int num_res); - +uint32_t get_backoff_indicator(int idx); int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, int scs, NR_PUCCH_Config_t *pucch_Config, @@ -262,11 +266,15 @@ 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); +void ul_ports_config(NR_UE_MAC_INST_t *mac, + int *n_front_load_symb, + nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, + dci_pdu_rel15_t *dci, + nr_dci_format_t dci_format); /* Random Access */ - /* \brief This function schedules the PRACH according to prach_ConfigurationIndex and TS 38.211 tables 6.3.3.2.x and fills the PRACH PDU per each FD occasion. @param mac pointer to MAC instance diff --git a/openair2/LAYER2/NR_MAC_UE/mac_tables.c b/openair2/LAYER2/NR_MAC_UE/mac_tables.c new file mode 100644 index 0000000000..bd4cc6d8f3 --- /dev/null +++ b/openair2/LAYER2/NR_MAC_UE/mac_tables.c @@ -0,0 +1,703 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/* \file vars.h + * \brief MAC Layer variables + * \author R. Knopp, K.H. HSU + * \date 2018 + * \version 0.1 + * \company Eurecom / NTUST + * \email: knopp@eurecom.fr, kai-hsiang.hsu@eurecom.fr + * \note + * \warning + */ + +#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 +// next six columns contain table 7.3.1.1.2-3: Precoding information and number of layers for 4 antenna ports, if transformPrecoder= enabled, or if transformPrecoder=disabled and maxRank = 1 +// next four columns contain table 7.3.1.1.2-4: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder=disabled and maxRank = 2 +// next four columns contain table 7.3.1.1.2-5: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder= enabled, or if transformPrecoder= disabled and maxRank = 1 +static const uint8_t table_7_3_1_1_2_2_3_4_5[64][20] = { + {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}, + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + {1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 0, 2, 0, 1, 2, 0, 0}, + {1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2, 0, 0, 1, 3, 0, 0}, + {2, 0, 2, 0, 2, 0, 1, 4, 1, 4, 0, 0, 1, 3, 0, 0, 1, 4, 0, 0}, + {2, 1, 2, 1, 2, 1, 1, 5, 1, 5, 0, 0, 1, 4, 0, 0, 1, 5, 0, 0}, + {2, 2, 2, 2, 2, 2, 1, 6, 1, 6, 0, 0, 1, 5, 0, 0, 0, 0, 0, 0}, + {2, 3, 2, 3, 2, 3, 1, 7, 1, 7, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0}, + {2, 4, 2, 4, 2, 4, 1, 8, 1, 8, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0}, + {2, 5, 2, 5, 2, 5, 1, 9, 1, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {3, 0, 3, 0, 3, 0, 1, 10, 1, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {4, 0, 4, 0, 4, 0, 1, 11, 1, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {1, 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, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +}; + +static const uint8_t table_7_3_1_1_2_12[14][3] = { + {1,0,1}, + {1,1,1}, + {2,0,1}, + {2,1,1}, + {2,2,1}, + {2,3,1}, + {2,0,2}, + {2,1,2}, + {2,2,2}, + {2,3,2}, + {2,4,2}, + {2,5,2}, + {2,6,2}, + {2,7,2} +}; + +static const uint8_t table_7_3_1_1_2_13[10][4] = { + {1,0,1,1}, + {2,0,1,1}, + {2,2,3,1}, + {2,0,2,1}, + {2,0,1,2}, + {2,2,3,2}, + {2,4,5,2}, + {2,6,7,2}, + {2,0,4,2}, + {2,2,6,2} +}; + +static const uint8_t table_7_3_1_1_2_14[3][5] = { + {2,0,1,2,1}, + {2,0,1,4,2}, + {2,2,3,6,2} +}; + +static const uint8_t table_7_3_1_1_2_15[4][6] = { + {2,0,1,2,3,1}, + {2,0,1,4,5,2}, + {2,2,3,6,7,2}, + {2,0,2,4,6,2} +}; + +static const uint8_t table_7_3_1_1_2_16[12][2] = { + {1,0}, + {1,1}, + {2,0}, + {2,1}, + {2,2}, + {2,3}, + {3,0}, + {3,1}, + {3,2}, + {3,3}, + {3,4}, + {3,5} +}; + +static const uint8_t table_7_3_1_1_2_17[7][3] = { + {1,0,1}, + {2,0,1}, + {2,2,3}, + {3,0,1}, + {3,2,3}, + {3,4,5}, + {2,0,2} +}; + +static const uint8_t table_7_3_1_1_2_18[3][4] = { + {2,0,1,2}, + {3,0,1,2}, + {3,3,4,5} +}; + +static const uint8_t table_7_3_1_1_2_19[2][5] = { + {2,0,1,2,3}, + {3,0,1,2,3} +}; + +static const uint8_t table_7_3_1_1_2_20[28][3] = { + {1,0,1}, + {1,1,1}, + {2,0,1}, + {2,1,1}, + {2,2,1}, + {2,3,1}, + {3,0,1}, + {3,1,1}, + {3,2,1}, + {3,3,1}, + {3,4,1}, + {3,5,1}, + {3,0,2}, + {3,1,2}, + {3,2,2}, + {3,3,2}, + {3,4,2}, + {3,5,2}, + {3,6,2}, + {3,7,2}, + {3,8,2}, + {3,9,2}, + {3,10,2}, + {3,11,2}, + {1,0,2}, + {1,1,2}, + {1,6,2}, + {1,7,2} +}; + +static const uint8_t table_7_3_1_1_2_21[19][4] = { + {1,0,1,1}, + {2,0,1,1}, + {2,2,3,1}, + {3,0,1,1}, + {3,2,3,1}, + {3,4,5,1}, + {2,0,2,1}, + {3,0,1,2}, + {3,2,3,2}, + {3,4,5,2}, + {3,6,7,2}, + {3,8,9,2}, + {3,10,11,2}, + {1,0,1,2}, + {1,6,7,2}, + {2,0,1,2}, + {2,2,3,2}, + {2,6,7,2}, + {2,8,9,2} +}; + +static const uint8_t table_7_3_1_1_2_22[6][5] = { + {2,0,1,2,1}, + {3,0,1,2,1}, + {3,3,4,5,1}, + {3,0,1,6,2}, + {3,2,3,8,2}, + {3,4,5,10,2} +}; + +static const uint8_t table_7_3_1_1_2_23[5][6] = { + {2,0,1,2,3,1}, + {3,0,1,2,3,1}, + {3,0,1,6,7,2}, + {3,2,3,8,9,2}, + {3,4,5,10,11,2} +}; + +static const uint8_t table_7_3_2_3_3_1[12][5] = { + {1,1,0,0,0}, + {1,0,1,0,0}, + {1,1,1,0,0}, + {2,1,0,0,0}, + {2,0,1,0,0}, + {2,0,0,1,0}, + {2,0,0,0,1}, + {2,1,1,0,0}, + {2,0,0,1,1}, + {2,1,1,1,0}, + {2,1,1,1,1}, + {2,1,0,1,0} +}; + +static const uint8_t table_7_3_2_3_3_2_oneCodeword[31][10] = { + {1,1,0,0,0,0,0,0,0,1}, + {1,0,1,0,0,0,0,0,0,1}, + {1,1,1,0,0,0,0,0,0,1}, + {2,1,0,0,0,0,0,0,0,1}, + {2,0,1,0,0,0,0,0,0,1}, + {2,0,0,1,0,0,0,0,0,1}, + {2,0,0,0,1,0,0,0,0,1}, + {2,1,1,0,0,0,0,0,0,1}, + {2,0,0,1,1,0,0,0,0,1}, + {2,1,1,1,0,0,0,0,0,1}, + {2,1,1,1,1,0,0,0,0,1}, + {2,1,0,1,0,0,0,0,0,1}, + {2,1,0,0,0,0,0,0,0,2}, + {2,0,1,0,0,0,0,0,0,2}, + {2,0,0,1,0,0,0,0,0,2}, + {2,0,0,0,1,0,0,0,0,2}, + {2,0,0,0,0,1,0,0,0,2}, + {2,0,0,0,0,0,1,0,0,2}, + {2,0,0,0,0,0,0,1,0,2}, + {2,0,0,0,0,0,0,0,1,2}, + {2,1,1,0,0,0,0,0,0,2}, + {2,0,0,1,1,0,0,0,0,2}, + {2,0,0,0,0,1,1,0,0,2}, + {2,0,0,0,0,0,0,1,1,2}, + {2,1,0,0,0,1,0,0,0,2}, + {2,0,0,1,0,0,0,1,0,2}, + {2,1,1,0,0,1,0,0,0,2}, + {2,0,0,1,1,0,0,1,0,2}, + {2,1,1,0,0,1,1,0,0,2}, + {2,0,0,1,1,0,0,1,1,2}, + {2,1,0,1,0,1,0,1,0,2} +}; + +static const uint8_t table_7_3_2_3_3_2_twoCodeword[4][10] = { + {2,1,1,1,1,1,0,0,0,2}, + {2,1,1,1,1,1,0,1,0,2}, + {2,1,1,1,1,1,1,1,0,2}, + {2,1,1,1,1,1,1,1,1,2} +}; + +static const uint8_t table_7_3_2_3_3_3_oneCodeword[24][7] = { + {1,1,0,0,0,0,0}, + {1,0,1,0,0,0,0}, + {1,1,1,0,0,0,0}, + {2,1,0,0,0,0,0}, + {2,0,1,0,0,0,0}, + {2,0,0,1,0,0,0}, + {2,0,0,0,1,0,0}, + {2,1,1,0,0,0,0}, + {2,0,0,1,1,0,0}, + {2,1,1,1,0,0,0}, + {2,1,1,1,1,0,0}, + {3,1,0,0,0,0,0}, + {3,0,1,0,0,0,0}, + {3,0,0,1,0,0,0}, + {3,0,0,0,1,0,0}, + {3,0,0,0,0,1,0}, + {3,0,0,0,0,0,1}, + {3,1,1,0,0,0,0}, + {3,0,0,1,1,0,0}, + {3,0,0,0,0,1,1}, + {3,1,1,1,0,0,0}, + {3,0,0,0,1,1,1}, + {3,1,1,1,1,0,0}, + {3,1,0,1,0,0,0} +}; + +static const uint8_t table_7_3_2_3_3_3_twoCodeword[2][7] = { + {3,1,1,1,1,1,0}, + {3,1,1,1,1,1,1} +}; + +static const uint8_t table_7_3_2_3_3_4_oneCodeword[58][14] = { + {1,1,0,0,0,0,0,0,0,0,0,0,0,1}, + {1,0,1,0,0,0,0,0,0,0,0,0,0,1}, + {1,1,1,0,0,0,0,0,0,0,0,0,0,1}, + {2,1,0,0,0,0,0,0,0,0,0,0,0,1}, + {2,0,1,0,0,0,0,0,0,0,0,0,0,1}, + {2,0,0,1,0,0,0,0,0,0,0,0,0,1}, + {2,0,0,0,1,0,0,0,0,0,0,0,0,1}, + {2,1,1,0,0,0,0,0,0,0,0,0,0,1}, + {2,0,0,1,1,0,0,0,0,0,0,0,0,1}, + {2,1,1,1,0,0,0,0,0,0,0,0,0,1}, + {2,1,1,1,1,0,0,0,0,0,0,0,0,1}, + {3,1,0,0,0,0,0,0,0,0,0,0,0,1}, + {3,0,1,0,0,0,0,0,0,0,0,0,0,1}, + {3,0,0,1,0,0,0,0,0,0,0,0,0,1}, + {3,0,0,0,1,0,0,0,0,0,0,0,0,1}, + {3,0,0,0,0,1,0,0,0,0,0,0,0,1}, + {3,0,0,0,0,0,1,0,0,0,0,0,0,1}, + {3,1,1,0,0,0,0,0,0,0,0,0,0,1}, + {3,0,0,1,1,0,0,0,0,0,0,0,0,1}, + {3,0,0,0,0,1,1,0,0,0,0,0,0,1}, + {3,1,1,1,0,0,0,0,0,0,0,0,0,1}, + {3,0,0,0,1,1,1,0,0,0,0,0,0,1}, + {3,1,1,1,1,0,0,0,0,0,0,0,0,1}, + {2,1,0,1,0,0,0,0,0,0,0,0,0,1}, + {3,1,0,0,0,0,0,0,0,0,0,0,0,2}, + {3,0,1,0,0,0,0,0,0,0,0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_twoCodeword[6][14] = { + {3,1,1,1,1,1,0,0,0,0,0,0,0,1}, + {3,1,1,1,1,1,1,0,0,0,0,0,0,1}, + {2,1,1,1,1,0,0,1,0,0,0,0,0,2}, + {2,1,1,1,1,0,0,1,0,1,0,0,0,2}, + {2,1,1,1,1,0,0,1,1,1,0,0,0,2}, + {2,1,1,1,1,0,0,1,1,1,1,0,0,2}, +}; + +// table 7.2-1 TS 38.321 +static const uint32_t table_7_2_1[16] = { + 5, // row index 0 + 10, // row index 1 + 20, // row index 2 + 30, // row index 3 + 40, // row index 4 + 60, // row index 5 + 80, // row index 6 + 120, // row index 7 + 160, // row index 8 + 240, // row index 9 + 320, // row index 10 + 480, // row index 11 + 960, // row index 12 + 1920, // row index 13 +}; + +uint32_t get_backoff_indicator(int idx) +{ + AssertFatal(idx < 16, "Backoff indicator index %d exeeding table size\n", idx); + return table_7_2_1[idx]; +} + +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]; + } + } + } +} + +void ul_ports_config(NR_UE_MAC_INST_t *mac, + int *n_front_load_symb, + nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, + dci_pdu_rel15_t *dci, + nr_dci_format_t dci_format) +{ + uint8_t rank = pusch_config_pdu->nrOfLayers; + NR_PUSCH_Config_t *pusch_Config = mac->current_UL_BWP->pusch_Config; + AssertFatal(pusch_Config != NULL, "pusch_Config shouldn't be null\n"); + + long transformPrecoder = pusch_config_pdu->transform_precoding; + LOG_D(NR_MAC, + "transformPrecoder %s\n", + transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled ? "disabled" : "enabled"); + + long *max_length = NULL; + long *dmrs_type = NULL; + if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA) { + max_length = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->maxLength; + dmrs_type = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->dmrs_Type; + } else { + max_length = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->maxLength; + dmrs_type = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->dmrs_Type; + } + + int val = dci->antenna_ports.val; + LOG_D(NR_MAC, + "MappingType%s max_length %s, dmrs_type %s, antenna_ports %d\n", + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA ? "A" : "B", + max_length ? "len2" : "len1", + dmrs_type ? "type2" : "type1", + val); + + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) + && (dmrs_type == NULL) + && (max_length == NULL)) { // tables 7.3.1.1.2-6 + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; + pusch_config_pdu->dmrs_ports = 1 << val; + } + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) + && (dmrs_type == NULL) + && (max_length != NULL)) { // tables 7.3.1.1.2-7 + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC + pusch_config_pdu->dmrs_ports = 1 << ((val > 3) ? (val - 4) : (val)); + *n_front_load_symb = (val > 3) ? 2 : 1; + } + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) + && (dmrs_type == NULL) + && (max_length == NULL)) { // tables 7.3.1.1.2-8/9/10/11 + if (rank == 1) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = (val > 1) ? 2 : 1; + pusch_config_pdu->dmrs_ports = 1 << ((val > 1) ? (val - 2) : (val)); + } + if (rank == 2) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = (val > 0) ? 2 : 1; + pusch_config_pdu->dmrs_ports = (val > 1) ? ((val > 2) ? 0x5 : 0xc) : 0x3; + } + if (rank == 3) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; + pusch_config_pdu->dmrs_ports = 0x7; // ports 0-2 + } + if (rank == 4) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; + pusch_config_pdu->dmrs_ports = 0xf; // ports 0-3 + } + } + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) + && (dmrs_type == NULL) + && (max_length != NULL)) { // tables 7.3.1.1.2-12/13/14/15 + if (rank == 1) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_12[val][0]; + pusch_config_pdu->dmrs_ports = 1 << table_7_3_1_1_2_12[val][1]; + *n_front_load_symb = table_7_3_1_1_2_12[val][2]; + } + if (rank == 2) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_13[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_13[val][1], 2); + *n_front_load_symb = table_7_3_1_1_2_13[val][3]; + } + if (rank == 3) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_14[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_14[val][1], 3); + *n_front_load_symb = table_7_3_1_1_2_14[val][4]; + } + if (rank == 4) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_15[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_15[val][1], 4); + *n_front_load_symb = table_7_3_1_1_2_15[val][5]; + } + } + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) + && (dmrs_type != NULL) + && (max_length == NULL)) { // tables 7.3.1.1.2-16/17/18/19 + if (rank == 1) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_16[val][0]; + pusch_config_pdu->dmrs_ports = 1 << table_7_3_1_1_2_16[val][1]; + } + if (rank == 2) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_17[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_17[val][1], 2); + } + if (rank == 3) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_18[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_18[val][1], 3); + } + if (rank == 4) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_19[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_19[val][1], 4); + } + } + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) + && (dmrs_type != NULL) + && (max_length != NULL)) { // tables 7.3.1.1.2-20/21/22/23 + if (rank == 1) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_20[val][0]; + pusch_config_pdu->dmrs_ports = 1 << table_7_3_1_1_2_20[val][1]; + *n_front_load_symb = table_7_3_1_1_2_20[val][2]; + } + if (rank == 2) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_21[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_21[val][1], 2); + *n_front_load_symb = table_7_3_1_1_2_21[val][3]; + } + if (rank == 3) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_22[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_22[val][1], 3); + *n_front_load_symb = table_7_3_1_1_2_22[val][4]; + } + if (rank == 4) { + pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_23[val][0]; + pusch_config_pdu->dmrs_ports = packBits(&table_7_3_1_1_2_23[val][1], 4); + *n_front_load_symb = table_7_3_1_1_2_23[val][5]; + } + } + LOG_D(NR_MAC, + "num_dmrs_cdm_grps_no_data %d, dmrs_ports %d\n", + pusch_config_pdu->num_dmrs_cdm_grps_no_data, + pusch_config_pdu->dmrs_ports); +} + +void set_precoding_information_parameters(nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, + int n_antenna_port, + long transformPrecoder, + int precoding_information, + NR_PUSCH_Config_t *pusch_Config) +{ + // 1 antenna port and the higher layer parameter txConfig = codebook 0 bits + if (n_antenna_port == 4) { // 4 antenna port and the higher layer parameter txConfig = codebook + // Table 7.3.1.1.2-2: transformPrecoder=disabled and maxRank = 2 or 3 or 4 + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) + && ((*pusch_Config->maxRank == 2) || (*pusch_Config->maxRank == 3) || (*pusch_Config->maxRank == 4))) { + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][0]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][1]; + } + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_partialAndNonCoherent){ + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][2]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][3]; + } + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][4]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][5]; + } + } + // Table 7.3.1.1.2-3: transformPrecoder= enabled, or transformPrecoder=disabled and maxRank = 1 + if (((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) + || (transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled)) + && (*pusch_Config->maxRank == 1)) { + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][6]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][7]; + } + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_partialAndNonCoherent){ + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][8]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][9]; + } + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][10]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][11]; + } + } + } + if (n_antenna_port == 2) { + // 2 antenna port and the higher layer parameter txConfig = codebook + // Table 7.3.1.1.2-4: transformPrecoder=disabled and maxRank = 2 + if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (*pusch_Config->maxRank == 2)) { + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][12]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][13]; + } + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][14]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][15]; + } + } + // Table 7.3.1.1.2-5: transformPrecoder= enabled, or transformPrecoder= disabled and maxRank = 1 + if (((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) + || (transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled)) + && (*pusch_Config->maxRank == 1)) { + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][16]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][17]; + } + if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ + pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[precoding_information][18]; + pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[precoding_information][19]; + } + } + } +} diff --git a/openair2/LAYER2/NR_MAC_UE/mac_vars.c b/openair2/LAYER2/NR_MAC_UE/mac_vars.c deleted file mode 100644 index 20abda978d..0000000000 --- a/openair2/LAYER2/NR_MAC_UE/mac_vars.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/* \file vars.h - * \brief MAC Layer variables - * \author R. Knopp, K.H. HSU - * \date 2018 - * \version 0.1 - * \company Eurecom / NTUST - * \email: knopp@eurecom.fr, kai-hsiang.hsu@eurecom.fr - * \note - * \warning - */ - -#include - -// 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 -// next six columns contain table 7.3.1.1.2-3: Precoding information and number of layers for 4 antenna ports, if transformPrecoder= enabled, or if transformPrecoder=disabled and maxRank = 1 -// next four columns contain table 7.3.1.1.2-4: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder=disabled and maxRank = 2 -// next four columns contain table 7.3.1.1.2-5: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder= enabled, or if transformPrecoder= disabled and maxRank = 1 -const uint8_t table_7_3_1_1_2_2_3_4_5[64][20] = { - {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - {1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 0, 2, 0, 1, 2, 0, 0}, - {1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2, 0, 0, 1, 3, 0, 0}, - {2, 0, 2, 0, 2, 0, 1, 4, 1, 4, 0, 0, 1, 3, 0, 0, 1, 4, 0, 0}, - {2, 1, 2, 1, 2, 1, 1, 5, 1, 5, 0, 0, 1, 4, 0, 0, 1, 5, 0, 0}, - {2, 2, 2, 2, 2, 2, 1, 6, 1, 6, 0, 0, 1, 5, 0, 0, 0, 0, 0, 0}, - {2, 3, 2, 3, 2, 3, 1, 7, 1, 7, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0}, - {2, 4, 2, 4, 2, 4, 1, 8, 1, 8, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0}, - {2, 5, 2, 5, 2, 5, 1, 9, 1, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {3, 0, 3, 0, 3, 0, 1, 10, 1, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {4, 0, 4, 0, 4, 0, 1, 11, 1, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {1, 4, 1, 4, 0, 0, 1, 12, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -}; - -const uint8_t table_7_3_1_1_2_12[14][3] = { - {1,0,1}, - {1,1,1}, - {2,0,1}, - {2,1,1}, - {2,2,1}, - {2,3,1}, - {2,0,2}, - {2,1,2}, - {2,2,2}, - {2,3,2}, - {2,4,2}, - {2,5,2}, - {2,6,2}, - {2,7,2} -}; - -const uint8_t table_7_3_1_1_2_13[10][4] = { - {1,0,1,1}, - {2,0,1,1}, - {2,2,3,1}, - {2,0,2,1}, - {2,0,1,2}, - {2,2,3,2}, - {2,4,5,2}, - {2,6,7,2}, - {2,0,4,2}, - {2,2,6,2} -}; - -const uint8_t table_7_3_1_1_2_14[3][5] = { - {2,0,1,2,1}, - {2,0,1,4,2}, - {2,2,3,6,2} -}; - -const uint8_t table_7_3_1_1_2_15[4][6] = { - {2,0,1,2,3,1}, - {2,0,1,4,5,2}, - {2,2,3,6,7,2}, - {2,0,2,4,6,2} -}; - -const uint8_t table_7_3_1_1_2_16[12][2] = { - {1,0}, - {1,1}, - {2,0}, - {2,1}, - {2,2}, - {2,3}, - {3,0}, - {3,1}, - {3,2}, - {3,3}, - {3,4}, - {3,5} -}; - -const uint8_t table_7_3_1_1_2_17[7][3] = { - {1,0,1}, - {2,0,1}, - {2,2,3}, - {3,0,1}, - {3,2,3}, - {3,4,5}, - {2,0,2} -}; - -const uint8_t table_7_3_1_1_2_18[3][4] = { - {2,0,1,2}, - {3,0,1,2}, - {3,3,4,5} -}; - -const uint8_t table_7_3_1_1_2_19[2][5] = { - {2,0,1,2,3}, - {3,0,1,2,3} -}; - -const uint8_t table_7_3_1_1_2_20[28][3] = { - {1,0,1}, - {1,1,1}, - {2,0,1}, - {2,1,1}, - {2,2,1}, - {2,3,1}, - {3,0,1}, - {3,1,1}, - {3,2,1}, - {3,3,1}, - {3,4,1}, - {3,5,1}, - {3,0,2}, - {3,1,2}, - {3,2,2}, - {3,3,2}, - {3,4,2}, - {3,5,2}, - {3,6,2}, - {3,7,2}, - {3,8,2}, - {3,9,2}, - {3,10,2}, - {3,11,2}, - {1,0,2}, - {1,1,2}, - {1,6,2}, - {1,7,2} -}; - -const uint8_t table_7_3_1_1_2_21[19][4] = { - {1,0,1,1}, - {2,0,1,1}, - {2,2,3,1}, - {3,0,1,1}, - {3,2,3,1}, - {3,4,5,1}, - {2,0,2,1}, - {3,0,1,2}, - {3,2,3,2}, - {3,4,5,2}, - {3,6,7,2}, - {3,8,9,2}, - {3,10,11,2}, - {1,0,1,2}, - {1,6,7,2}, - {2,0,1,2}, - {2,2,3,2}, - {2,6,7,2}, - {2,8,9,2} -}; - -const uint8_t table_7_3_1_1_2_22[6][5] = { - {2,0,1,2,1}, - {3,0,1,2,1}, - {3,3,4,5,1}, - {3,0,1,6,2}, - {3,2,3,8,2}, - {3,4,5,10,2} -}; - -const uint8_t table_7_3_1_1_2_23[5][6] = { - {2,0,1,2,3,1}, - {3,0,1,2,3,1}, - {3,0,1,6,7,2}, - {3,2,3,8,9,2}, - {3,4,5,10,11,2} -}; - -const uint8_t table_7_3_2_3_3_1[12][5] = { - {1,1,0,0,0}, - {1,0,1,0,0}, - {1,1,1,0,0}, - {2,1,0,0,0}, - {2,0,1,0,0}, - {2,0,0,1,0}, - {2,0,0,0,1}, - {2,1,1,0,0}, - {2,0,0,1,1}, - {2,1,1,1,0}, - {2,1,1,1,1}, - {2,1,0,1,0} -}; - -const uint8_t table_7_3_2_3_3_2_oneCodeword[31][10] = { - {1,1,0,0,0,0,0,0,0,1}, - {1,0,1,0,0,0,0,0,0,1}, - {1,1,1,0,0,0,0,0,0,1}, - {2,1,0,0,0,0,0,0,0,1}, - {2,0,1,0,0,0,0,0,0,1}, - {2,0,0,1,0,0,0,0,0,1}, - {2,0,0,0,1,0,0,0,0,1}, - {2,1,1,0,0,0,0,0,0,1}, - {2,0,0,1,1,0,0,0,0,1}, - {2,1,1,1,0,0,0,0,0,1}, - {2,1,1,1,1,0,0,0,0,1}, - {2,1,0,1,0,0,0,0,0,1}, - {2,1,0,0,0,0,0,0,0,2}, - {2,0,1,0,0,0,0,0,0,2}, - {2,0,0,1,0,0,0,0,0,2}, - {2,0,0,0,1,0,0,0,0,2}, - {2,0,0,0,0,1,0,0,0,2}, - {2,0,0,0,0,0,1,0,0,2}, - {2,0,0,0,0,0,0,1,0,2}, - {2,0,0,0,0,0,0,0,1,2}, - {2,1,1,0,0,0,0,0,0,2}, - {2,0,0,1,1,0,0,0,0,2}, - {2,0,0,0,0,1,1,0,0,2}, - {2,0,0,0,0,0,0,1,1,2}, - {2,1,0,0,0,1,0,0,0,2}, - {2,0,0,1,0,0,0,1,0,2}, - {2,1,1,0,0,1,0,0,0,2}, - {2,0,0,1,1,0,0,1,0,2}, - {2,1,1,0,0,1,1,0,0,2}, - {2,0,0,1,1,0,0,1,1,2}, - {2,1,0,1,0,1,0,1,0,2} -}; - -const uint8_t table_7_3_2_3_3_2_twoCodeword[4][10] = { - {2,1,1,1,1,1,0,0,0,2}, - {2,1,1,1,1,1,0,1,0,2}, - {2,1,1,1,1,1,1,1,0,2}, - {2,1,1,1,1,1,1,1,1,2} -}; - -const uint8_t table_7_3_2_3_3_3_oneCodeword[24][7] = { - {1,1,0,0,0,0,0}, - {1,0,1,0,0,0,0}, - {1,1,1,0,0,0,0}, - {2,1,0,0,0,0,0}, - {2,0,1,0,0,0,0}, - {2,0,0,1,0,0,0}, - {2,0,0,0,1,0,0}, - {2,1,1,0,0,0,0}, - {2,0,0,1,1,0,0}, - {2,1,1,1,0,0,0}, - {2,1,1,1,1,0,0}, - {3,1,0,0,0,0,0}, - {3,0,1,0,0,0,0}, - {3,0,0,1,0,0,0}, - {3,0,0,0,1,0,0}, - {3,0,0,0,0,1,0}, - {3,0,0,0,0,0,1}, - {3,1,1,0,0,0,0}, - {3,0,0,1,1,0,0}, - {3,0,0,0,0,1,1}, - {3,1,1,1,0,0,0}, - {3,0,0,0,1,1,1}, - {3,1,1,1,1,0,0}, - {3,1,0,1,0,0,0} -}; - -const uint8_t table_7_3_2_3_3_3_twoCodeword[2][7] = { - {3,1,1,1,1,1,0}, - {3,1,1,1,1,1,1} -}; - -const uint8_t table_7_3_2_3_3_4_oneCodeword[58][14] = { - {1,1,0,0,0,0,0,0,0,0,0,0,0,1}, - {1,0,1,0,0,0,0,0,0,0,0,0,0,1}, - {1,1,1,0,0,0,0,0,0,0,0,0,0,1}, - {2,1,0,0,0,0,0,0,0,0,0,0,0,1}, - {2,0,1,0,0,0,0,0,0,0,0,0,0,1}, - {2,0,0,1,0,0,0,0,0,0,0,0,0,1}, - {2,0,0,0,1,0,0,0,0,0,0,0,0,1}, - {2,1,1,0,0,0,0,0,0,0,0,0,0,1}, - {2,0,0,1,1,0,0,0,0,0,0,0,0,1}, - {2,1,1,1,0,0,0,0,0,0,0,0,0,1}, - {2,1,1,1,1,0,0,0,0,0,0,0,0,1}, - {3,1,0,0,0,0,0,0,0,0,0,0,0,1}, - {3,0,1,0,0,0,0,0,0,0,0,0,0,1}, - {3,0,0,1,0,0,0,0,0,0,0,0,0,1}, - {3,0,0,0,1,0,0,0,0,0,0,0,0,1}, - {3,0,0,0,0,1,0,0,0,0,0,0,0,1}, - {3,0,0,0,0,0,1,0,0,0,0,0,0,1}, - {3,1,1,0,0,0,0,0,0,0,0,0,0,1}, - {3,0,0,1,1,0,0,0,0,0,0,0,0,1}, - {3,0,0,0,0,1,1,0,0,0,0,0,0,1}, - {3,1,1,1,0,0,0,0,0,0,0,0,0,1}, - {3,0,0,0,1,1,1,0,0,0,0,0,0,1}, - {3,1,1,1,1,0,0,0,0,0,0,0,0,1}, - {2,1,0,1,0,0,0,0,0,0,0,0,0,1}, - {3,1,0,0,0,0,0,0,0,0,0,0,0,2}, - {3,0,1,0,0,0,0,0,0,0,0,0,0,2}, - {3,0,0,1,0,0,0,0,0,0,0,0,0,2}, - {3,0,0,0,1,0,0,0,0,0,0,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,0,0,0,0,1}, - {2,1,1,1,1,0,0,1,0,0,0,0,0,2}, - {2,1,1,1,1,0,0,1,0,1,0,0,0,2}, - {2,1,1,1,1,0,0,1,1,1,0,0,0,2}, - {2,1,1,1,1,0,0,1,1,1,1,0,0,2}, -}; - -// table 7.2-1 TS 38.321 -const uint16_t table_7_2_1[16] = { - 5, // row index 0 - 10, // row index 1 - 20, // row index 2 - 30, // row index 3 - 40, // row index 4 - 60, // row index 5 - 80, // row index 6 - 120, // row index 7 - 160, // row index 8 - 240, // row index 9 - 320, // row index 10 - 480, // row index 11 - 960, // row index 12 - 1920, // row index 13 -}; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 2740e1d3c7..51a3ad8c9d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -34,10 +34,8 @@ #include "RRC/NR_UE/L2_interface_ue.h" /* MAC */ -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_COMMON/nr_mac.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" - #include #include "openair2/LAYER2/RLC/rlc.h" #include "openair2/LAYER2/NR_MAC_UE/mac_defs.h" diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 77319d2013..aeeab40b74 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -33,7 +33,6 @@ #include "mac_proto.h" #include "mac_defs.h" #include "assertions.h" -#include "LAYER2/NR_MAC_UE/mac_extern.h" #include "mac_defs.h" #include "common/utils/nr/nr_common.h" #include "executables/softmodem-common.h" diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 4748a65c3d..c150cc29cd 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -43,8 +43,6 @@ /* MAC */ #include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_UE/mac_proto.h" -#include "NR_MAC_UE/mac_extern.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "common/utils/nr/nr_common.h" #include "openair2/NR_UE_PHY_INTERFACE/NR_Packet_Drop.h" @@ -56,6 +54,7 @@ #include "oai_asn1.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#include "openair2/LAYER2/RLC/rlc.h" // #define DEBUG_MIB // #define ENABLE_MAC_PAYLOAD_DEBUG 1 @@ -973,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, @@ -1179,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, @@ -3968,7 +3915,7 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d n_subPDUs++; LOG_I(NR_MAC, "[UE %d][RAPROC][RA-RNTI %04x] Got RAPID RAR subPDU\n", mac->ue_id, rnti); } else { - ra->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI]; + ra->RA_backoff_indicator = get_backoff_indicator(((NR_RA_HEADER_BI *)rarh)->BI); ra->RA_BI_found = 1; LOG_I(NR_MAC, "[UE %d][RAPROC][RA-RNTI %04x] Got BI RAR subPDU %d ms\n", mac->ue_id, ra->RA_backoff_indicator, rnti); if ( ((NR_RA_HEADER_BI *)rarh)->E == 1) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 846d344584..d14df8c9c4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -39,7 +39,6 @@ #include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_COMMON/nr_mac_common.h" #include "NR_MAC_UE/mac_proto.h" -#include "NR_MAC_UE/mac_extern.h" /* utils */ #include "assertions.h" @@ -48,8 +47,6 @@ #include "utils.h" #include - -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/RLC/rlc.h" #include "RRC/NR_UE/L2_interface_ue.h" @@ -305,269 +302,18 @@ void ul_layers_config(NR_UE_MAC_INST_t *mac, nfapi_nr_ue_pusch_pdu_t *pusch_conf NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; NR_SRS_Config_t *srs_config = current_UL_BWP->srs_Config; NR_PUSCH_Config_t *pusch_Config = current_UL_BWP->pusch_Config; - long transformPrecoder = pusch_config_pdu->transform_precoding; /* PRECOD_NBR_LAYERS */ // 0 bits if the higher layer parameter txConfig = nonCodeBook - if (*pusch_Config->txConfig == NR_PUSCH_Config__txConfig_codebook){ - // The UE shall transmit PUSCH using the same antenna port(s) as the SRS port(s) in the SRS resource indicated by the DCI format 0_1 // 38.214 Section 6.1.1 - - uint8_t n_antenna_port = get_pusch_nb_antenna_ports(pusch_Config, srs_config, dci->srs_resource_indicator); - - // 1 antenna port and the higher layer parameter txConfig = codebook 0 bits - - if (n_antenna_port == 4) { // 4 antenna port and the higher layer parameter txConfig = codebook - - // Table 7.3.1.1.2-2: transformPrecoder=disabled and maxRank = 2 or 3 or 4 - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) - && ((*pusch_Config->maxRank == 2) || (*pusch_Config->maxRank == 3) || (*pusch_Config->maxRank == 4))) { - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][0]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][1]; - } - - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_partialAndNonCoherent){ - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][2]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][3]; - } - - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][4]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][5]; - } - } - - // Table 7.3.1.1.2-3: transformPrecoder= enabled, or transformPrecoder=disabled and maxRank = 1 - if (((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) - || (transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled)) - && (*pusch_Config->maxRank == 1)) { - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][6]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][7]; - } - - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_partialAndNonCoherent){ - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][8]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][9]; - } - - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][10]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][11]; - } - } - } - - if (n_antenna_port == 2) { - // 2 antenna port and the higher layer parameter txConfig = codebook - // Table 7.3.1.1.2-4: transformPrecoder=disabled and maxRank = 2 - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (*pusch_Config->maxRank == 2)) { - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][12]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][13]; - } - - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][14]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][15]; - } - - } - - // Table 7.3.1.1.2-5: transformPrecoder= enabled, or transformPrecoder= disabled and maxRank = 1 - if (((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) - || (transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled)) - && (*pusch_Config->maxRank == 1)) { - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_fullyAndPartialAndNonCoherent) { - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][16]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][17]; - } - - if (*pusch_Config->codebookSubset == NR_PUSCH_Config__codebookSubset_nonCoherent){ - pusch_config_pdu->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][18]; - pusch_config_pdu->Tpmi = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][19]; - } - } - } + uint8_t n = get_pusch_nb_antenna_ports(pusch_Config, srs_config, dci->srs_resource_indicator); + set_precoding_information_parameters(pusch_config_pdu, n, transformPrecoder, dci->precoding_information.val, pusch_Config); } } -// todo: this function shall be reviewed completely because of the many comments left by the author -void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, nr_dci_format_t dci_format) -{ - uint8_t rank = pusch_config_pdu->nrOfLayers; - - NR_PUSCH_Config_t *pusch_Config = mac->current_UL_BWP->pusch_Config; - AssertFatal(pusch_Config!=NULL,"pusch_Config shouldn't be null\n"); - - long transformPrecoder = pusch_config_pdu->transform_precoding; - LOG_D(NR_MAC,"transformPrecoder %s\n", transformPrecoder==NR_PUSCH_Config__transformPrecoder_disabled ? "disabled" : "enabled"); - - long *max_length = NULL; - long *dmrs_type = NULL; - if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA) { - max_length = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->maxLength; - dmrs_type = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->dmrs_Type; - } - else { - max_length = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->maxLength; - dmrs_type = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->dmrs_Type; - } - - LOG_D(NR_MAC,"MappingType%s max_length %s, dmrs_type %s, antenna_ports %d\n", - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA?"A":"B",max_length?"len2":"len1",dmrs_type?"type2":"type1",dci->antenna_ports.val); - - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) && - (dmrs_type == NULL) && (max_length == NULL)) { // tables 7.3.1.1.2-6 - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; - pusch_config_pdu->dmrs_ports = 1 << dci->antenna_ports.val; - } - - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_enabled) && - (dmrs_type == NULL) && (max_length != NULL)) { // tables 7.3.1.1.2-7 - - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC - pusch_config_pdu->dmrs_ports = 1<<((dci->antenna_ports.val > 3)?(dci->antenna_ports.val-4):(dci->antenna_ports.val)); - *n_front_load_symb = (dci->antenna_ports.val > 3)?2:1; - } - - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (dmrs_type == NULL) - && (max_length == NULL)) { // tables 7.3.1.1.2-8/9/10/11 - - if (rank == 1) { - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?2:1; - pusch_config_pdu->dmrs_ports =1<<((dci->antenna_ports.val > 1)?(dci->antenna_ports.val-2):(dci->antenna_ports.val)); - } - - if (rank == 2){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?2:1; - pusch_config_pdu->dmrs_ports = (dci->antenna_ports.val > 1)?((dci->antenna_ports.val> 2)?0x5:0xc):0x3; - } - - if (rank == 3){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; - pusch_config_pdu->dmrs_ports = 0x7; // ports 0-2 - } - - if (rank == 4){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; - pusch_config_pdu->dmrs_ports = 0xf; // ports 0-3 - } - } - - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (dmrs_type == NULL) - && (max_length != NULL)) { // tables 7.3.1.1.2-12/13/14/15 - - if (rank == 1){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?2:1; //TBC - pusch_config_pdu->dmrs_ports = 1<<((dci->antenna_ports.val > 1)?(dci->antenna_ports.val > 5 ?(dci->antenna_ports.val-6):(dci->antenna_ports.val-2)):dci->antenna_ports.val); - *n_front_load_symb = (dci->antenna_ports.val > 6)?2:1; - } - - if (rank == 2){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?2:1; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_13[dci->antenna_ports.val][1]; - //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_13[dci->antenna_ports.val][2]; - //n_front_load_symb = (dci->antenna_ports.val > 3)?2:1; // FIXME - } - - if (rank == 3){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_14[dci->antenna_ports.val][1]; - //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_14[dci->antenna_ports.val][2]; - //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_14[dci->antenna_ports.val][3]; - //n_front_load_symb = (dci->antenna_ports.val > 1)?2:1; //FIXME - } - - if (rank == 4){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_15[dci->antenna_ports.val][1]; - //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_15[dci->antenna_ports.val][2]; - //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_15[dci->antenna_ports.val][3]; - //pusch_config_pdu->dmrs_ports[3] = table_7_3_1_1_2_15[dci->antenna_ports.val][4]; - //n_front_load_symb = (dci->antenna_ports.val > 1)?2:1; //FIXME - } - } - - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (dmrs_type != NULL) - && (max_length == NULL)) { // tables 7.3.1.1.2-16/17/18/19 - - if (rank == 1){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?((dci->antenna_ports.val > 5)?3:2):1; //TBC - pusch_config_pdu->dmrs_ports = (dci->antenna_ports.val > 1)?(dci->antenna_ports.val > 5 ?(dci->antenna_ports.val-6):(dci->antenna_ports.val-2)):dci->antenna_ports.val; //TBC - } - - if (rank == 2){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?((dci->antenna_ports.val > 2)?3:2):1; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_17[dci->antenna_ports.val][1]; - //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_17[dci->antenna_ports.val][2]; - } - - if (rank == 3){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?3:2; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_18[dci->antenna_ports.val][1]; - //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_18[dci->antenna_ports.val][2]; - //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_18[dci->antenna_ports.val][3]; - } - - if (rank == 4){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = dci->antenna_ports.val + 2; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = 0; - //pusch_config_pdu->dmrs_ports[1] = 1; - //pusch_config_pdu->dmrs_ports[2] = 2; - //pusch_config_pdu->dmrs_ports[3] = 3; - } - } - - if ((transformPrecoder == NR_PUSCH_Config__transformPrecoder_disabled) && (dmrs_type != NULL) - && (max_length != NULL)) { // tables 7.3.1.1.2-20/21/22/23 - - if (rank == 1){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_20[dci->antenna_ports.val][0]; //TBC - pusch_config_pdu->dmrs_ports = table_7_3_1_1_2_20[dci->antenna_ports.val][1]; //TBC - //n_front_load_symb = table_7_3_1_1_2_20[dci->antenna_ports.val][2]; //FIXME - } - - if (rank == 2){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_21[dci->antenna_ports.val][0]; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_21[dci->antenna_ports.val][1]; - //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_21[dci->antenna_ports.val][2]; - //n_front_load_symb = table_7_3_1_1_2_21[dci->antenna_ports.val][3]; //FIXME - } - - if (rank == 3){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_22[dci->antenna_ports.val][0]; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_22[dci->antenna_ports.val][1]; - //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_22[dci->antenna_ports.val][2]; - //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_22[dci->antenna_ports.val][3]; - //n_front_load_symb = table_7_3_1_1_2_22[dci->antenna_ports.val][4]; //FIXME - } - - if (rank == 4){ - pusch_config_pdu->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_23[dci->antenna_ports.val][0]; //TBC - pusch_config_pdu->dmrs_ports = 0; //FIXME - //pusch_config_pdu->dmrs_ports[0] = table_7_3_1_1_2_23[dci->antenna_ports.val][1]; - //pusch_config_pdu->dmrs_ports[1] = table_7_3_1_1_2_23[dci->antenna_ports.val][2]; - //pusch_config_pdu->dmrs_ports[2] = table_7_3_1_1_2_23[dci->antenna_ports.val][3]; - //pusch_config_pdu->dmrs_ports[3] = table_7_3_1_1_2_23[dci->antenna_ports.val][4]; - //n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports.val][5]; //FIXME - } - } - LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, dmrs_ports %d\n",pusch_config_pdu->num_dmrs_cdm_grps_no_data,pusch_config_pdu->dmrs_ports); -} - // Configuration of Msg3 PDU according to clauses: // - 8.3 of 3GPP TS 38.213 version 16.3.0 Release 16 // - 6.1.2.2 of TS 38.214 @@ -1701,28 +1447,38 @@ void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info) } } -static uint8_t nr_locate_BsrIndexByBufferSize(const uint32_t *table, int size, int value) +static uint8_t nr_locate_BsrIndexByBufferSize(int size, int value) { if (value == 0) { return 0; //elseif (value > 150000) return 63; } + uint32_t (*get_bsr_value)(int); + if (size == NR_SHORT_BSR_TABLE_SIZE) + get_bsr_value = &get_short_bsr_value; + else + get_bsr_value = &get_long_bsr_value; + int jl = 0; // lower bound int ju = size - 1; // upper bound - bool ascend = table[ju] >= table[jl] ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise + // determine the order of the the table: 1 if ascending order of table, 0 otherwise + bool ascend = (*get_bsr_value)(ju) >= (*get_bsr_value)(jl) ? 1 : 0; while (ju - jl > 1) { //If we are not yet done, int jm = (ju + jl) / 2; // compute a midpoint, - if ((value >= table[jm]) == ascend) { + if ((value >= (*get_bsr_value)(jm)) == ascend) { jl = jm; // replace the lower limit } else { ju = jm; //replace the upper limit } - LOG_T(NR_MAC, "[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", - jm, table[jm], value); + LOG_T(NR_MAC, + "[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", + jm, + (*get_bsr_value)(jm), + value); } - if (value == table[jl]) { + if (value == (*get_bsr_value)(jl)) { return jl; } else { return jl + 1; //equally ju @@ -3151,7 +2907,7 @@ static void nr_ue_get_sdu_mac_ce_post(NR_UE_MAC_INST_t *mac, mac_ce_p->bsr.type_bsr = b_short; mac_ce_p->bsr.bsr.s.LcgID = lcg_id_bsr_max; mac_ce_p->bsr.bsr.s.Buffer_size = - nr_locate_BsrIndexByBufferSize(NR_SHORT_BSR_TABLE, NR_SHORT_BSR_TABLE_SIZE, LCG_bytes[lcg_id_bsr_max]); + nr_locate_BsrIndexByBufferSize(NR_SHORT_BSR_TABLE_SIZE, LCG_bytes[lcg_id_bsr_max]); LOG_D(NR_MAC, "[UE %d] sfn %d.%d BSR Trigger=0x%x report SHORT BSR with level %d for LCGID %d\n", mac->ue_id, @@ -3166,7 +2922,7 @@ static void nr_ue_get_sdu_mac_ce_post(NR_UE_MAC_INST_t *mac, mac_ce_p->bsr.type_bsr = b_long; uint8_t *tmp = mac_ce_p->bsr.bsr.lcg_bsr; for (int lcg_id = 0; lcg_id < 8; lcg_id++) { - tmp[lcg_id] = nr_locate_BsrIndexByBufferSize(NR_LONG_BSR_TABLE, NR_LONG_BSR_TABLE_SIZE, LCG_bytes[lcg_id]); + tmp[lcg_id] = nr_locate_BsrIndexByBufferSize(NR_LONG_BSR_TABLE_SIZE, LCG_bytes[lcg_id]); } LOG_D(NR_MAC, "[UE %d] sfn %d.%d BSR Trig=0x%x report LONG BSR (level LCGID %d %d %d %d %d %d %d %d)\n", @@ -3186,7 +2942,7 @@ static void nr_ue_get_sdu_mac_ce_post(NR_UE_MAC_INST_t *mac, mac_ce_p->bsr.type_bsr = b_short_trunc; mac_ce_p->bsr.bsr.s.LcgID = lcg_id_bsr_max; mac_ce_p->bsr.bsr.s.Buffer_size = - nr_locate_BsrIndexByBufferSize(NR_SHORT_BSR_TABLE, NR_SHORT_BSR_TABLE_SIZE, LCG_bytes[lcg_id_bsr_max]); + nr_locate_BsrIndexByBufferSize(NR_SHORT_BSR_TABLE_SIZE, LCG_bytes[lcg_id_bsr_max]); } else if (padding_len >= sizeof(NR_BSR_LONG) + sizeof(NR_MAC_SUBHEADER_SHORT)) { mac_ce_p->bsr.type_bsr = b_long_trunc; // Fixme: this should be sorted by (TS 38.321, 5.4.5) @@ -3195,7 +2951,7 @@ static void nr_ue_get_sdu_mac_ce_post(NR_UE_MAC_INST_t *mac, // available for transmission) in each of these LCG(s), and in case of equal priority, in increasing order of LCGID uint8_t *tmp = mac_ce_p->bsr.bsr.lcg_bsr; for (int lcg_id = 0; lcg_id < 8; lcg_id++) { - tmp[lcg_id] = nr_locate_BsrIndexByBufferSize(NR_LONG_BSR_TABLE, NR_LONG_BSR_TABLE_SIZE, LCG_bytes[lcg_id]); + tmp[lcg_id] = nr_locate_BsrIndexByBufferSize(NR_LONG_BSR_TABLE_SIZE, LCG_bytes[lcg_id]); } } else LOG_D(NR_MAC, "Can't add any BSR, not enough padding\n"); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 218226eb2c..d7b9b5e129 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -39,7 +39,6 @@ #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "NR_MIB.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_gNB/nr_mac_gNB.h" #include "NR_BCCH-BCH-Message.h" #include "NR_ServingCellConfigCommon.h" diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index d3455ad8e8..80e00ea673 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -32,7 +32,6 @@ #include "assertions.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_gNB/mac_proto.h" #include "common/utils/LOG/log.h" @@ -53,7 +52,12 @@ #include #include -const uint8_t nr_rv_round_map[4] = {0, 2, 3, 1}; +uint8_t nr_get_rv(int rel_round) +{ + const uint8_t nr_rv_round_map[4] = {0, 2, 3, 1}; + AssertFatal(rel_round < 4, "Invalid index %d for rv\n", rel_round); + return nr_rv_round_map[rel_round]; +} void clear_nr_nfapi_information(gNB_MAC_INST *gNB, int CC_idP, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 6e776b123a..48a1ab1032 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -33,7 +33,6 @@ /* MAC */ #include "nr_mac_gNB.h" #include "NR_MAC_gNB/mac_proto.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" /* Utils */ #include "common/utils/LOG/log.h" @@ -1192,7 +1191,7 @@ static void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, pusch_pdu->start_symbol_index = start_symbol_index; pusch_pdu->nr_of_symbols = nr_of_symbols; //Optional Data only included if indicated in pduBitmap - pusch_pdu->pusch_data.rv_index = nr_rv_round_map[ra->msg3_round % 4]; + pusch_pdu->pusch_data.rv_index = nr_get_rv(ra->msg3_round % 4); pusch_pdu->pusch_data.harq_process_id = 0; pusch_pdu->pusch_data.new_data_indicator = (ra->msg3_round == 0) ? 1 : 0;; pusch_pdu->pusch_data.num_cb = 0; @@ -1872,7 +1871,7 @@ static void prepare_dl_pdus(gNB_MAC_INST *nr_mac, pdsch_pdu_rel15->qamModOrder[0] = Qm; pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; - pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[round % 4]; + pdsch_pdu_rel15->rvIndex[0] = nr_get_rv(round % 4); pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; pdsch_pdu_rel15->nrOfLayers = 1; pdsch_pdu_rel15->transmissionScheme = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 3987a04a54..c235696c54 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -33,7 +33,6 @@ #include "assertions.h" #include "NR_MAC_gNB/nr_mac_gNB.h" #include "NR_MAC_gNB/mac_proto.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" @@ -549,7 +548,7 @@ static void nr_fill_nfapi_dl_SIB_pdu(int Mod_idP, pdsch_pdu_rel15->qamModOrder[0] = nr_get_Qm_dl(pdsch->mcs, mcsTableIdx); pdsch_pdu_rel15->mcsIndex[0] = pdsch->mcs; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; - pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[0]; + pdsch_pdu_rel15->rvIndex[0] = nr_get_rv(0); pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; pdsch_pdu_rel15->nrOfLayers = 1; pdsch_pdu_rel15->transmissionScheme = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index ad6ac974a7..44d742e9de 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -33,7 +33,6 @@ /*MAC*/ #include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_gNB/nr_mac_gNB.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "LAYER2/RLC/rlc.h" @@ -1031,7 +1030,7 @@ void nr_schedule_ue_spec(module_id_t module_id, TBS, current_harq_pid, harq->round, - nr_rv_round_map[harq->round%4], + nr_get_rv(harq->round % 4), harq->ndi, pucch->timing_indicator, pucch->frame, @@ -1091,7 +1090,7 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->mcsTable[0] = 0; } AssertFatal(harq->round < gNB_mac->dl_bler.harq_round_max,"%d", harq->round); - pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round % 4]; + pdsch_pdu->rvIndex[0] = nr_get_rv(harq->round % 4); pdsch_pdu->TBSize[0] = TBS; pdsch_pdu->dataScramblingId = *scc->physCellId; pdsch_pdu->nrOfLayers = nrOfLayers; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index e8acad7902..8654bd5f05 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -33,8 +33,6 @@ #include "assertions.h" #include "NR_MAC_gNB/nr_mac_gNB.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" - #include "NR_MAC_gNB/mac_proto.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index aac5ac4dfd..2f6313de96 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -27,7 +27,6 @@ #include #include "NR_MAC_gNB/nr_mac_gNB.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_gNB/mac_proto.h" #include "common/ran_context.h" #include "nfapi/oai_integration/vendor_ext.h" diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index e541fdfc68..52ceceedfe 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -28,7 +28,6 @@ #include #include "NR_MAC_gNB/nr_mac_gNB.h" -#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_gNB/mac_proto.h" #include "common/ran_context.h" #include "common/utils/nr/nr_common.h" diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index dcb7bb2cb1..0c7af52f92 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -34,7 +34,6 @@ #include "common/utils/nr/nr_common.h" #include "utils.h" #include -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/nr_rlc/nr_rlc_oai_api.h" #include "LAYER2/RLC/rlc.h" @@ -112,9 +111,9 @@ static int estimate_ul_buffer_short_bsr(const NR_BSR_SHORT *bsr) * differentiate them */ int rep_idx = bsr->Buffer_size; int estim_idx = overestim_bsr_index(rep_idx); - int max = sizeofArray(NR_SHORT_BSR_TABLE) - 1; + int max = NR_SHORT_BSR_TABLE_SIZE - 1; int idx = min(estim_idx, max); - int estim_size = NR_SHORT_BSR_TABLE[idx]; + int estim_size = get_short_bsr_value(idx); LOG_D(NR_MAC, "short BSR LCGID %d index %d estim index %d size %d\n", bsr->LcgID, rep_idx, estim_idx, estim_size); return estim_size; } @@ -134,7 +133,7 @@ static int estimate_ul_buffer_long_bsr(const NR_BSR_LONG *bsr) bool bsr_active[8] = {bsr->LcgID0 != 0, bsr->LcgID1 != 0, bsr->LcgID2 != 0, bsr->LcgID3 != 0, bsr->LcgID4 != 0, bsr->LcgID5 != 0, bsr->LcgID6 != 0, bsr->LcgID7 != 0}; int estim_size = 0; - int max = sizeofArray(NR_LONG_BSR_TABLE) - 1; + int max = NR_LONG_BSR_TABLE_SIZE - 1; uint8_t *payload = ((uint8_t*) bsr) + 1; int m = 0; const int total_lcgids = 8; /* see 38.321 6.1.3.1 */ @@ -144,7 +143,7 @@ static int estimate_ul_buffer_long_bsr(const NR_BSR_LONG *bsr) int rep_idx = payload[m]; int estim_idx = overestim_bsr_index(rep_idx); int idx = min(estim_idx, max); - estim_size += NR_LONG_BSR_TABLE[idx]; + estim_size += get_long_bsr_value(idx); LOG_D(NR_MAC, "LONG BSR LCGID/m %d/%d Index %d estim index %d size %d", n, m, rep_idx, estim_idx, estim_size); m++; @@ -1237,6 +1236,113 @@ static uint8_t get_max_tpmi(const NR_PUSCH_Config_t *pusch_Config, return max_tpmi; } +// TS 38.211 - Table 6.3.1.5-1: Precoding matrix W for single-layer transmission using two antenna ports, 'n' = -1 and 'o' = -j +const char table_38211_6_3_1_5_1[6][2][1] = { + {{'1'}, {'0'}}, // tpmi 0 + {{'0'}, {'1'}}, // tpmi 1 + {{'1'}, {'1'}}, // tpmi 2 + {{'1'}, {'n'}}, // tpmi 3 + {{'1'}, {'j'}}, // tpmi 4 + {{'1'}, {'o'}} // tpmi 5 +}; + +// TS 38.211 - Table 6.3.1.5-2: Precoding matrix W for single-layer transmission using four antenna ports with transform precoding enabled, 'n' = -1 and 'o' = -j +const char table_38211_6_3_1_5_2[28][4][1] = { + {{'1'}, {'0'}, {'0'}, {'0'}}, // tpmi 0 + {{'0'}, {'1'}, {'0'}, {'0'}}, // tpmi 1 + {{'0'}, {'0'}, {'1'}, {'0'}}, // tpmi 2 + {{'0'}, {'0'}, {'0'}, {'1'}}, // tpmi 3 + {{'1'}, {'0'}, {'1'}, {'0'}}, // tpmi 4 + {{'1'}, {'0'}, {'n'}, {'0'}}, // tpmi 5 + {{'1'}, {'0'}, {'j'}, {'0'}}, // tpmi 6 + {{'1'}, {'0'}, {'o'}, {'0'}}, // tpmi 7 + {{'0'}, {'1'}, {'0'}, {'1'}}, // tpmi 8 + {{'0'}, {'1'}, {'0'}, {'n'}}, // tpmi 9 + {{'0'}, {'1'}, {'0'}, {'j'}}, // tpmi 10 + {{'0'}, {'1'}, {'0'}, {'o'}}, // tpmi 11 + {{'1'}, {'1'}, {'1'}, {'n'}}, // tpmi 12 + {{'1'}, {'1'}, {'j'}, {'j'}}, // tpmi 13 + {{'1'}, {'1'}, {'n'}, {'1'}}, // tpmi 14 + {{'1'}, {'1'}, {'o'}, {'o'}}, // tpmi 15 + {{'1'}, {'j'}, {'1'}, {'j'}}, // tpmi 16 + {{'1'}, {'j'}, {'j'}, {'1'}}, // tpmi 17 + {{'1'}, {'j'}, {'n'}, {'o'}}, // tpmi 18 + {{'1'}, {'j'}, {'o'}, {'n'}}, // tpmi 19 + {{'1'}, {'n'}, {'1'}, {'1'}}, // tpmi 20 + {{'1'}, {'n'}, {'j'}, {'o'}}, // tpmi 21 + {{'1'}, {'n'}, {'n'}, {'n'}}, // tpmi 22 + {{'1'}, {'n'}, {'o'}, {'j'}}, // tpmi 23 + {{'1'}, {'o'}, {'1'}, {'o'}}, // tpmi 24 + {{'1'}, {'o'}, {'j'}, {'n'}}, // tpmi 25 + {{'1'}, {'o'}, {'n'}, {'j'}}, // tpmi 26 + {{'1'}, {'o'}, {'o'}, {'1'}} // tpmi 27 +}; + +// TS 38.211 - Table 6.3.1.5-3: Precoding matrix W for single-layer transmission using four antenna ports with transform precoding disabled, 'n' = -1 and 'o' = -j +const char table_38211_6_3_1_5_3[28][4][1] = { + {{'1'}, {'0'}, {'0'}, {'0'}}, // tpmi 0 + {{'0'}, {'1'}, {'0'}, {'0'}}, // tpmi 1 + {{'0'}, {'0'}, {'1'}, {'0'}}, // tpmi 2 + {{'0'}, {'0'}, {'0'}, {'1'}}, // tpmi 3 + {{'1'}, {'0'}, {'1'}, {'0'}}, // tpmi 4 + {{'1'}, {'0'}, {'n'}, {'0'}}, // tpmi 5 + {{'1'}, {'0'}, {'j'}, {'0'}}, // tpmi 6 + {{'1'}, {'0'}, {'o'}, {'0'}}, // tpmi 7 + {{'0'}, {'1'}, {'0'}, {'1'}}, // tpmi 8 + {{'0'}, {'1'}, {'0'}, {'n'}}, // tpmi 9 + {{'0'}, {'1'}, {'0'}, {'j'}}, // tpmi 10 + {{'0'}, {'1'}, {'0'}, {'o'}}, // tpmi 11 + {{'1'}, {'1'}, {'1'}, {'1'}}, // tpmi 12 + {{'1'}, {'1'}, {'j'}, {'j'}}, // tpmi 13 + {{'1'}, {'1'}, {'n'}, {'n'}}, // tpmi 14 + {{'1'}, {'1'}, {'o'}, {'o'}}, // tpmi 15 + {{'1'}, {'j'}, {'1'}, {'j'}}, // tpmi 16 + {{'1'}, {'j'}, {'j'}, {'n'}}, // tpmi 17 + {{'1'}, {'j'}, {'n'}, {'o'}}, // tpmi 18 + {{'1'}, {'j'}, {'o'}, {'1'}}, // tpmi 19 + {{'1'}, {'n'}, {'1'}, {'n'}}, // tpmi 20 + {{'1'}, {'n'}, {'j'}, {'o'}}, // tpmi 21 + {{'1'}, {'n'}, {'n'}, {'1'}}, // tpmi 22 + {{'1'}, {'n'}, {'o'}, {'j'}}, // tpmi 23 + {{'1'}, {'o'}, {'1'}, {'o'}}, // tpmi 24 + {{'1'}, {'o'}, {'j'}, {'1'}}, // tpmi 25 + {{'1'}, {'o'}, {'n'}, {'j'}}, // tpmi 26 + {{'1'}, {'o'}, {'o'}, {'n'}} // tpmi 27 +}; + +// TS 38.211 - Table 6.3.1.5-4: Precoding matrix W for two-layer transmission using two antenna ports, 'n' = -1 and 'o' = -j +const char table_38211_6_3_1_5_4[3][2][2] = { + {{'1', '0'}, {'0', '1'}}, // tpmi 0 + {{'1', '1'}, {'1', 'n'}}, // tpmi 1 + {{'1', '1'}, {'j', 'o'}} // tpmi 2 +}; + +// TS 38.211 - Table 6.3.1.5-5: Precoding matrix W for two-layer transmission using four antenna ports, 'n' = -1 and 'o' = -j +const char table_38211_6_3_1_5_5[22][4][2] = { + {{'1', '0'}, {'0', '1'}, {'0', '0'}, {'0', '0'}}, // tpmi 0 + {{'1', '0'}, {'0', '0'}, {'0', '1'}, {'0', '0'}}, // tpmi 1 + {{'1', '0'}, {'0', '0'}, {'0', '0'}, {'0', '1'}}, // tpmi 2 + {{'0', '0'}, {'1', '0'}, {'0', '1'}, {'0', '0'}}, // tpmi 3 + {{'0', '0'}, {'1', '0'}, {'0', '0'}, {'0', '1'}}, // tpmi 4 + {{'0', '0'}, {'0', '0'}, {'1', '0'}, {'0', '1'}}, // tpmi 5 + {{'1', '0'}, {'0', '1'}, {'1', '0'}, {'0', 'o'}}, // tpmi 6 + {{'1', '0'}, {'0', '1'}, {'1', '0'}, {'0', 'j'}}, // tpmi 7 + {{'1', '0'}, {'0', '1'}, {'o', '0'}, {'0', '1'}}, // tpmi 8 + {{'1', '0'}, {'0', '1'}, {'o', '0'}, {'0', 'n'}}, // tpmi 9 + {{'1', '0'}, {'0', '1'}, {'n', '0'}, {'0', 'o'}}, // tpmi 10 + {{'1', '0'}, {'0', '1'}, {'n', '0'}, {'0', 'j'}}, // tpmi 11 + {{'1', '0'}, {'0', '1'}, {'j', '0'}, {'0', '1'}}, // tpmi 12 + {{'1', '0'}, {'0', '1'}, {'j', '0'}, {'0', 'n'}}, // tpmi 13 + {{'1', '1'}, {'1', '1'}, {'1', 'n'}, {'1', 'n'}}, // tpmi 14 + {{'1', '1'}, {'1', '1'}, {'j', 'o'}, {'j', 'o'}}, // tpmi 15 + {{'1', '1'}, {'j', 'j'}, {'1', 'n'}, {'j', 'o'}}, // tpmi 16 + {{'1', '1'}, {'j', 'j'}, {'j', 'o'}, {'n', '1'}}, // tpmi 17 + {{'1', '1'}, {'n', 'n'}, {'1', 'n'}, {'n', '1'}}, // tpmi 18 + {{'1', '1'}, {'n', 'n'}, {'j', 'o'}, {'o', 'j'}}, // tpmi 19 + {{'1', '1'}, {'o', 'o'}, {'1', 'n'}, {'o', 'j'}}, // tpmi 20 + {{'1', '1'}, {'o', 'o'}, {'j', 'o'}, {'1', 'n'}} // tpmi 21 +}; + static void get_precoder_matrix_coef(char *w, const uint8_t ul_ri, const uint16_t num_ue_srs_ports, @@ -2395,7 +2501,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n sched_pusch->tb_size, harq_id, cur_harq->round, - nr_rv_round_map[cur_harq->round%4], + nr_get_rv(cur_harq->round % 4), cur_harq->ndi, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, @@ -2509,8 +2615,10 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n pusch_pdu->nr_of_symbols = sched_pusch->tda_info.nrOfSymbols; /* PUSCH PDU */ - AssertFatal(cur_harq->round < nr_mac->ul_bler.harq_round_max, "Indexing nr_rv_round_map[%d] is out of bounds\n", cur_harq->round%4); - pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round%4]; + AssertFatal(cur_harq->round < nr_mac->ul_bler.harq_round_max, + "RV index %d is out of bounds\n", + cur_harq->round % 4); + pusch_pdu->pusch_data.rv_index = nr_get_rv(cur_harq->round % 4); pusch_pdu->pusch_data.harq_process_id = harq_id; pusch_pdu->pusch_data.new_data_indicator = (cur_harq->round == 0) ? 1 : 0; // not NDI but indicator for new transmission pusch_pdu->pusch_data.tb_size = sched_pusch->tb_size; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 218831d8c3..fb36ba9160 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -86,7 +86,6 @@ #include "mac_rrc_ul.h" /* MAC */ -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h" #include "NR_TAG.h" @@ -103,7 +102,7 @@ #define MAX_NUM_NR_PRACH_PREAMBLES 64 #define MIN_NUM_PRBS_TO_SCHEDULE 5 -extern const uint8_t nr_rv_round_map[4]; +uint8_t nr_get_rv(int rel_round); /*! \brief NR_list_t is a "list" (of users, HARQ processes, slices, ...). * Especially useful in the scheduler and to keep "classes" of users. */ diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 537086a06d..9e7310cf40 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -38,7 +38,6 @@ #include "NR_IF_Module.h" #include "NR_MAC_UE/mac_proto.h" #include "assertions.h" -#include "NR_MAC_UE/mac_extern.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" #include "executables/softmodem-common.h" #include "openair2/RRC/NR_UE/L2_interface_ue.h" diff --git a/openair2/RRC/LTE/rrc_vars.h b/openair2/RRC/LTE/rrc_vars.h index 5574708e44..75c56d2273 100644 --- a/openair2/RRC/LTE/rrc_vars.h +++ b/openair2/RRC/LTE/rrc_vars.h @@ -35,7 +35,6 @@ #include "LAYER2/RLC/rlc.h" #include "COMMON/mac_rrc_primitives.h" #include "LAYER2/MAC/mac.h" -#include "openair2/RRC/NR/nr_rrc_extern.h" UE_PF_PO_t UE_PF_PO[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; pthread_mutex_t ue_pf_po_mutex; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index e3df557d3d..8b30f4b0ea 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -49,7 +49,6 @@ #include "openair3/SECU/key_nas_deriver.h" -#include "RRC/NR/nr_rrc_extern.h" #include "NR_DL-CCCH-Message.h" #include "NR_UL-CCCH-Message.h" #include "NR_DL-DCCH-Message.h" diff --git a/openair2/RRC/NR/nr_rrc_extern.h b/openair2/RRC/NR/nr_rrc_extern.h deleted file mode 100644 index 66483214a7..0000000000 --- a/openair2/RRC/NR/nr_rrc_extern.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nr_rrc_extern.h -* \brief rrc external vars -* \author Navid Nikaein and Raymond Knopp, WEI-TAI CHEN -* \date 2011, 2018 -* \version 1.0 -* \company Eurecom, NTUST -* \email: navid.nikaein@eurecom.fr, kroempa@gmail.com -*/ - -#ifndef __OPENAIR_NR_RRC_EXTERN_H__ -#define __OPENAIR_NR_RRC_EXTERN_H__ -#include "nr_rrc_defs.h" -#include "COMMON/mac_rrc_primitives.h" -#include "LAYER2/RLC/rlc.h" -#include "openair2/RRC/common.h" -void openair_rrc_gNB_configuration(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration); -#endif diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index e874e29bfb..7dd2fff8a3 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -129,5 +129,5 @@ void rrc_gNB_generate_UeContextModificationRequest(const gNB_RRC_INST *rrc, pdusession_level_qos_parameter_t *get_qos_characteristics(const int qfi, rrc_pdu_session_param_t *pduSession); f1ap_qos_characteristics_t get_qos_char_from_qos_flow_param(const pdusession_level_qos_parameter_t *qos_param); - +void openair_rrc_gNB_configuration(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration); #endif diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 281af514fa..4e150365aa 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -76,7 +76,6 @@ #include "nr_pdcp/nr_pdcp_entity.h" #include "nr_pdcp/nr_pdcp_oai_api.h" #include "nr_rrc_defs.h" -#include "nr_rrc_extern.h" #include "oai_asn1.h" #include "openair2/F1AP/f1ap_common.h" #include "openair2/F1AP/f1ap_ids.h" @@ -270,8 +269,7 @@ void openair_rrc_gNB_configuration(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *c rrc->configuration = *configuration; /// System Information INIT init_NR_SI(rrc); - return; -} // END openair_rrc_gNB_configuration +} static void rrc_gNB_process_AdditionRequestInformation(const module_id_t gnb_mod_idP, x2ap_ENDC_sgnb_addition_req_t *m) { @@ -421,12 +419,13 @@ static void rrc_gNB_generate_RRCSetup(instance_t instance, freeSRBlist(SRBs); f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->rrc_ue_id); RETURN_IF_INVALID_ASSOC_ID(ue_data.du_assoc_id); + int srbid = 0; f1ap_dl_rrc_message_t dl_rrc = { .gNB_CU_ue_id = ue_p->rrc_ue_id, .gNB_DU_ue_id = ue_data.secondary_ue, .rrc_container = buf, .rrc_container_length = size, - .srb_id = CCCH + .srb_id = srbid }; rrc->mac_rrc.dl_rrc_message_transfer(ue_data.du_assoc_id, &dl_rrc); } @@ -451,12 +450,13 @@ static void rrc_gNB_generate_RRCReject(module_id_t module_id, rrc_gNB_ue_context f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->rrc_ue_id); RETURN_IF_INVALID_ASSOC_ID(ue_data.du_assoc_id); + int srbid = 0; f1ap_dl_rrc_message_t dl_rrc = { .gNB_CU_ue_id = ue_p->rrc_ue_id, .gNB_DU_ue_id = ue_data.secondary_ue, .rrc_container = buf, .rrc_container_length = size, - .srb_id = CCCH, + .srb_id = srbid, .execute_duplication = 1, .RAT_frequency_priority_information.en_dc = 0 }; @@ -2026,19 +2026,20 @@ static void rrc_CU_process_ue_context_release_request(MessageDef *msg_p, sctp_as gNB_RRC_INST *rrc = RC.nrrrc[instance]; rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, req->gNB_CU_ue_id); // TODO what happens if no AMF connected? should also handle, set an_release true + int srbid = 1; if (!ue_context_p) { LOG_W(RRC, "could not find UE context for CU UE ID %u: auto-generate release command\n", req->gNB_CU_ue_id); - uint8_t buffer[RRC_BUF_SIZE] = {0}; - int size = do_NR_RRCRelease(buffer, RRC_BUF_SIZE, rrc_gNB_get_next_transaction_identifier(0)); + uint8_t buffer[NR_RRC_BUF_SIZE] = {0}; + int size = do_NR_RRCRelease(buffer, NR_RRC_BUF_SIZE, rrc_gNB_get_next_transaction_identifier(0)); f1ap_ue_context_release_cmd_t ue_context_release_cmd = { .gNB_CU_ue_id = req->gNB_CU_ue_id, .gNB_DU_ue_id = req->gNB_DU_ue_id, .cause = F1AP_CAUSE_RADIO_NETWORK, .cause_value = 10, // 10 = F1AP_CauseRadioNetwork_normal_release - .srb_id = DCCH, + .srb_id = srbid, }; deliver_ue_ctxt_release_data_t data = {.rrc = rrc, .release_cmd = &ue_context_release_cmd}; - nr_pdcp_data_req_srb(req->gNB_CU_ue_id, DCCH, rrc_gNB_mui++, size, buffer, rrc_deliver_ue_ctxt_release_cmd, &data); + nr_pdcp_data_req_srb(req->gNB_CU_ue_id, srbid, rrc_gNB_mui++, size, buffer, rrc_deliver_ue_ctxt_release_cmd, &data); return; }