From a4ee72dbaffbf281a330d3a04faa4aa21074fb0a Mon Sep 17 00:00:00 2001 From: Calvin HSU Date: Wed, 25 Jul 2018 15:22:22 +0200 Subject: [PATCH] UE: Add UL_IND message in IF module, for trigger L2 scheduler per TTI(slot). Add Type0-PDCCH search space & coreset right after decode MIB and storage corresponding parameters in L2. --- openair1/PHY/defs_nr_UE.h | 1 + openair2/LAYER2/NR_MAC_UE/config_ue.c | 2 +- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 24 ++- openair2/LAYER2/NR_MAC_UE/mac_extern.h | 81 +++++++ openair2/LAYER2/NR_MAC_UE/mac_vars.c | 55 ++++- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 209 +++++++++++++++++++ openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 37 +++- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h | 39 +++- targets/RT/USER/nr-ue.c | 55 +++-- 9 files changed, 465 insertions(+), 38 deletions(-) create mode 100644 openair2/LAYER2/NR_MAC_UE/mac_extern.h diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index f3ff1a5100..50ed02ac28 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -998,6 +998,7 @@ typedef struct { nr_ue_if_module_t *if_inst; nr_downlink_indication_t dl_indication; + nr_uplink_indication_t ul_indication; // point to the current rxTx thread index uint8_t current_thread_id[10]; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 5c3ba3d414..cd9785f7fe 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -/* \file config.c +/* \file config_ue.c * \brief UE and eNB configuration performed by RRC or as a consequence of RRC procedures * \author R. Knopp, K.H. HSU * \date 2018 diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index b5278ffacb..5640c45b82 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -63,15 +63,22 @@ typedef struct { //// MAC config - NR_DRX_Config_t *drx_Config; /* OPTIONAL */ - NR_SchedulingRequestConfig_t *schedulingRequestConfig; /* OPTIONAL */ - NR_BSR_Config_t *bsr_Config; /* OPTIONAL */ - NR_TAG_Config_t *tag_Config; /* OPTIONAL */ - NR_PHR_Config_t *phr_Config; /* OPTIONAL */ + NR_DRX_Config_t *drx_Config; + NR_SchedulingRequestConfig_t *schedulingRequestConfig; + NR_BSR_Config_t *bsr_Config; + NR_TAG_Config_t *tag_Config; + NR_PHR_Config_t *phr_Config; + NR_RNTI_Value_t *cs_RNTI; + NR_MIB_t *mib; + + /// Type0-PDCCH seach space coreset + uint32_t num_rbs; + uint32_t num_symbols; + uint32_t rb_offset; - NR_RNTI_Value_t *cs_RNTI; /* OPTIONAL */ + + /// Type0-PDCCH seach space - NR_MIB_t *mib; //// FAPI-like interface fapi_nr_tx_request_t tx_request; @@ -80,9 +87,12 @@ typedef struct { fapi_nr_dci_indication_t dci_indication; fapi_nr_rx_indication_t rx_indication; + /// Interface module instances nr_ue_if_module_t *if_module; nr_scheduled_response_t scheduled_response; nr_phy_config_t phy_config; + + } NR_UE_MAC_INST_t; /*@}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_extern.h b/openair2/LAYER2/NR_MAC_UE/mac_extern.h new file mode 100644 index 0000000000..4539b85cfe --- /dev/null +++ b/openair2/LAYER2/NR_MAC_UE/mac_extern.h @@ -0,0 +1,81 @@ +/* + * 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 + */ + + +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_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_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_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_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_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_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_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_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_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]; \ No newline at end of file diff --git a/openair2/LAYER2/NR_MAC_UE/mac_vars.c b/openair2/LAYER2/NR_MAC_UE/mac_vars.c index d995bdb2d0..228a599b56 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_vars.c +++ b/openair2/LAYER2/NR_MAC_UE/mac_vars.c @@ -32,6 +32,59 @@ #include "mac_defs.h" -NR_UE_MAC_INST_t UE_mac_inst; //[NB_MODULE_MAX]; +#define reserved 0xffff +// specification mapping talbe, table_38$x_$y_$z_c$a +// - $x: specification +// - $y: subclause-major +// - $z: subclause-minor +// - $a: ($a)th of column in table, start from zero +const int32_t table_38213_13_1_c2[16] = {24, 24, 24, 24, 24, 24, 48, 48, 48, 48, 48, 48, 96, 96, 96, reserved}; // index 15 reserved +const int32_t table_38213_13_1_c3[16] = { 2, 2, 2, 3, 3, 3, 1, 1, 2, 2, 3, 3, 1, 2, 3, reserved}; // index 15 reserved +const int32_t table_38213_13_1_c4[16] = { 0, 2, 4, 0, 2, 4, 12, 16, 12, 16, 12, 16, 38, 38, 38, reserved}; // index 15 reserved + +const int32_t table_38213_13_2_c2[16] = {24, 24, 24, 24, 24, 24, 24, 24, 48, 48, 48, 48, 48, 48, reserved, reserved}; // index 14-15 reserved +const int32_t table_38213_13_2_c3[16] = { 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, reserved, reserved}; // index 14-15 reserved +const int32_t table_38213_13_2_c4[16] = { 5, 6, 7, 8, 5, 6, 7, 8, 18, 20, 18, 20, 18, 20, reserved, reserved}; // index 14-15 reserved + +const int32_t table_38213_13_3_c2[16] = {48, 48, 48, 48, 48, 48, 96, 96, 96, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 09-15 reserved +const int32_t table_38213_13_3_c3[16] = { 1, 1, 2, 2, 3, 3, 1, 2, 3, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 09-15 reserved +const int32_t table_38213_13_3_c4[16] = { 2, 6, 2, 6, 2, 6, 28, 28, 28, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 09-15 reserved + +const int32_t table_38213_13_4_c2[16] = {24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 48, 48, 48, 48, 48, 48}; +const int32_t table_38213_13_4_c3[16] = { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2}; +const int32_t table_38213_13_4_c4[16] = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 12, 14, 16, 12, 14, 16}; + +const int32_t table_38213_13_5_c2[16] = {48, 48, 48, 96, 96, 96, 96, 96, 96, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 09-15 reserved +const int32_t table_38213_13_5_c3[16] = { 1, 2, 3, 1, 1, 2, 2, 3, 3, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 09-15 reserved +const int32_t table_38213_13_5_c4[16] = { 4, 4, 4, 0, 56, 0, 56, 0, 56, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 09-15 reserved + +const int32_t table_38213_13_6_c2[16] = {24, 24, 24, 24, 48, 48, 48, 48, 48, 48, reserved, reserved, reserved, reserved, reserved, reserved}; // index 10-15 reserved +const int32_t table_38213_13_6_c3[16] = { 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, reserved, reserved, reserved, reserved, reserved, reserved}; // index 10-15 reserved +const int32_t table_38213_13_6_c4[16] = { 0, 4, 0, 4, 0, 28, 0, 28, 0, 28, reserved, reserved, reserved, reserved, reserved, reserved}; // index 10-15 reserved + +const int32_t table_38213_13_7_c2[16] = {48, 48, 48, 48, 48, 48, 96, 96, 48, 48, 96, 96, reserved, reserved, reserved, reserved}; // index 12-15 reserved +const int32_t table_38213_13_7_c3[16] = { 1, 1, 2, 2, 3, 3, 1, 2, 1, 1, 1, 1, reserved, reserved, reserved, reserved}; // index 12-15 reserved +const int32_t table_38213_13_7_c4[16] = { 0, 8, 0, 8, 0, 8, 28, 28,-41, 49,-41, 97, reserved, reserved, reserved, reserved}; // index 12-15 reserved, condition A as default + +const int32_t table_38213_13_8_c2[16] = { 1, 1, 1, 1, 3, 3, 3, 3, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 15 reserved +const int32_t table_38213_13_8_c3[16] = {24, 24, 48, 48, 24, 24, 48, 48, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 15 reserved +const int32_t table_38213_13_8_c4[16] = { 0, 4, 14, 14,-20, 24,-20, 48, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 15 reserved, condition A as default + +const int32_t table_38213_13_9_c2[16] = {96, 96, 96, 96, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 04-15 reserved +const int32_t table_38213_13_9_c3[16] = { 1, 1, 2, 2, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 04-15 reserved +const int32_t table_38213_13_9_c4[16] = { 0, 16, 0, 16, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 04-15 reserved + +const int32_t table_38213_13_10_c2[16] = {48, 48, 48, 48, 24, 24, 48, 48, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 08-15 reserved +const int32_t table_38213_13_10_c3[16] = { 1, 1, 2, 2, 1, 1, 1, 1, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 08-15 reserved +const int32_t table_38213_13_10_c4[16] = { 0, 8, 0, 8,-41, 25,-41, 49, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved}; // index 08-15 reserved, condition A as default + +const float table_38213_13_11_c1[16] = { 0, 0, 2, 2, 5, 5, 7, 7, 0, 5, 0, 0, 2, 2, 5, 5}; +const int32_t table_38213_13_11_c2[16] = { 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1}; +const float table_38213_13_11_c3[16] = { 1, 0.5f, 1, 0.5f, 1, 0.5f, 1, 0.5f, 1, 1, 1, 1, 1, 1, 1, 1}; +const int32_t table_38213_13_11_c4[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2}; // i is even as default + +const float table_38213_13_12_c1[16] = { 0, 0, 2.5f, 2.5f, 5, 5, 0, 2.5f, 5, 7.5f, 7.5f, 7.5f, 0, 5, reserved, reserved}; // index 14-15 reserved +const int32_t table_38213_13_12_c2[16] = { 1, 2, 1, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 1, reserved, reserved}; // index 14-15 reserved +const float table_38213_13_12_c3[16] = { 1, 0.5f, 1, 0.5f, 1, 0.5f, 0.5f, 0.5f, 0.5f, 1, 0.5f, 0.5f, 1, 1, reserved, reserved}; // index 14-15 reserved diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index d742132ca0..ae3818f35d 100755 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -31,10 +31,34 @@ */ #include "mac_proto.h" +#include "mac_extern.h" #include "RRC/NR_UE/rrc_proto.h" +#include "assertions.h" #include +typedef enum subcarrier_spacing_e { + scs_15kHz = 0x1, + scs_30kHz = 0x2, + scs_60kHz = 0x4, + scs_120kHz = 0x8, + scs_240kHz = 0x16 +} subcarrier_spacing_t; + +typedef enum channel_bandwidth_e { + bw_5MHz = 0x1, + bw_10MHz = 0x2, + bw_20MHz = 0x4, + bw_40MHz = 0x8, + bw_80MHz = 0x16, + bw_100MHz = 0x32 +} channel_bandwidth_t; + +typedef enum frequency_range_e { + FR1 = 0, + FR2 +} frequency_range_t; + int8_t nr_ue_decode_mib( module_id_t module_id, int cc_id, @@ -75,6 +99,7 @@ int8_t nr_ue_decode_mib( } } +#if 0 printf("system frame number(6 MSB bits): %d\n", mac->mib->systemFrameNumber.buf[0]); printf("system frame number(with LSB): %d\n", (int)frame); printf("subcarrier spacing: %d\n", (int)mac->mib->subCarrierSpacingCommon); @@ -85,6 +110,190 @@ int8_t nr_ue_decode_mib( printf("intra frequcney reselection: %d\n", (int)mac->mib->intraFreqReselection); printf("half frame bit(extra bits): %d\n", (int)half_frame_bit); printf("ssb index(extra bits): %d\n", (int)ssb_index); +#endif + + subcarrier_spacing_t scs_ssb = scs_15kHz; // default for testing + subcarrier_spacing_t scs_pdcch = scs_15kHz; // default for testing + channel_bandwidth_t min_channel_bw = bw_5MHz; // deafult for testing + uint32_t ssb_coreset_multiplexing_pattern; + uint32_t is_condition_A = 1; + frequency_range_t frequency_range = FR1; + uint32_t index_4msb = (mac->mib->pdcch_ConfigSIB1 >> 4) & 0xf; + uint32_t index_4lsb = (mac->mib->pdcch_ConfigSIB1 & 0xf); + + // type0-pdcch coreset + switch( (scs_ssb << 5)|scs_pdcch ){ + case (scs_15kHz << 5) | scs_15kHz : + AssertFatal(index_4msb < 15, "38.213 Table 13-1 4 MSB out of range\n"); + ssb_coreset_multiplexing_pattern = 1; + mac->num_rbs = table_38213_13_1_c2[index_4msb]; + mac->num_symbols = table_38213_13_1_c3[index_4msb]; + mac->rb_offset = table_38213_13_1_c4[index_4msb]; + break; + + case (scs_15kHz << 5) | scs_30kHz: + AssertFatal(index_4msb < 14, "38.213 Table 13-2 4 MSB out of range\n"); + ssb_coreset_multiplexing_pattern = 1; + mac->num_rbs = table_38213_13_2_c2[index_4msb]; + mac->num_symbols = table_38213_13_2_c3[index_4msb]; + mac->rb_offset = table_38213_13_2_c4[index_4msb]; + break; + + case (scs_30kHz << 5) | scs_15kHz: + if((min_channel_bw & bw_5MHz) | (min_channel_bw & bw_10MHz)){ + AssertFatal(index_4msb < 9, "38.213 Table 13-3 4 MSB out of range\n"); + ssb_coreset_multiplexing_pattern = 1; + mac->num_rbs = table_38213_13_3_c2[index_4msb]; + mac->num_symbols = table_38213_13_3_c3[index_4msb]; + mac->rb_offset = table_38213_13_3_c4[index_4msb]; + }else if(min_channel_bw & bw_40MHz){ + AssertFatal(index_4msb < 9, "38.213 Table 13-5 4 MSB out of range\n"); + ssb_coreset_multiplexing_pattern = 1; + mac->num_rbs = table_38213_13_5_c2[index_4msb]; + mac->num_symbols = table_38213_13_5_c3[index_4msb]; + mac->rb_offset = table_38213_13_5_c4[index_4msb]; + }else{ ; } + + break; + + case (scs_30kHz << 5) | scs_30kHz: + if((min_channel_bw & bw_5MHz) | (min_channel_bw & bw_10MHz)){ + ssb_coreset_multiplexing_pattern = 1; + mac->num_rbs = table_38213_13_4_c2[index_4msb]; + mac->num_symbols = table_38213_13_4_c3[index_4msb]; + mac->rb_offset = table_38213_13_4_c4[index_4msb]; + }else if(min_channel_bw & bw_40MHz){ + AssertFatal(index_4msb < 10, "38.213 Table 13-6 4 MSB out of range\n"); + ssb_coreset_multiplexing_pattern = 1; + mac->num_rbs = table_38213_13_6_c2[index_4msb]; + mac->num_symbols = table_38213_13_6_c3[index_4msb]; + mac->rb_offset = table_38213_13_6_c4[index_4msb]; + }else{ ; } + break; + + case (scs_120kHz << 5) | scs_60kHz: + AssertFatal(index_4msb < 12, "38.213 Table 13-7 4 MSB out of range\n"); + if(index_4msb & 0x7){ + ssb_coreset_multiplexing_pattern = 1; + }else if(index_4msb & 0x18){ + ssb_coreset_multiplexing_pattern = 2; + }else{ ; } + + mac->num_rbs = table_38213_13_7_c2[index_4msb]; + mac->num_symbols = table_38213_13_7_c3[index_4msb]; + if(!is_condition_A && (index_4msb == 8 || index_4msb == 10)){ + mac->rb_offset = table_38213_13_7_c4[index_4msb] - 1; + }else{ + mac->rb_offset = table_38213_13_7_c4[index_4msb]; + } + break; + + case (scs_120kHz << 5) | scs_120kHz: + AssertFatal(index_4msb < 8, "38.213 Table 13-8 4 MSB out of range\n"); + if(index_4msb & 0x3){ + ssb_coreset_multiplexing_pattern = 1; + }else if(index_4msb & 0x0c){ + ssb_coreset_multiplexing_pattern = 3; + } + + mac->num_rbs = table_38213_13_8_c2[index_4msb]; + mac->num_symbols = table_38213_13_8_c3[index_4msb]; + if(!is_condition_A && (index_4msb == 4 || index_4msb == 6)){ + mac->rb_offset = table_38213_13_8_c4[index_4msb] - 1; + }else{ + mac->rb_offset = table_38213_13_8_c4[index_4msb]; + } + break; + + case (scs_240kHz << 5) | scs_60kHz: + AssertFatal(index_4msb < 4, "38.213 Table 13-9 4 MSB out of range\n"); + ssb_coreset_multiplexing_pattern = 1; + mac->num_rbs = table_38213_13_9_c2[index_4msb]; + mac->num_symbols = table_38213_13_9_c3[index_4msb]; + mac->rb_offset = table_38213_13_9_c4[index_4msb]; + break; + + case (scs_240kHz << 5) | scs_120kHz: + AssertFatal(index_4msb < 8, "38.213 Table 13-10 4 MSB out of range\n"); + if(index_4msb & 0x3){ + ssb_coreset_multiplexing_pattern = 1; + }else if(index_4msb & 0x0c){ + ssb_coreset_multiplexing_pattern = 2; + } + mac->num_rbs = table_38213_13_10_c2[index_4msb]; + mac->num_symbols = table_38213_13_10_c3[index_4msb]; + if(!is_condition_A && (index_4msb == 4 || index_4msb == 6)){ + mac->rb_offset = table_38213_13_10_c4[index_4msb]-1; + }else{ + mac->rb_offset = table_38213_13_10_c4[index_4msb]; + } + + break; + + default: + break; + } + + // type0-pdcch search space + float big_o; + uint32_t number_of_search_space_per_slot; + float big_m; + uint32_t first_symbol_index; + + const uint32_t num_symbols_coreset = 0; // check after + uint32_t ii = 0; // check later + uint32_t kk = 0; + if(ssb_coreset_multiplexing_pattern == 1 && frequency_range == FR1){ + big_o = table_38213_13_11_c1[index_4lsb]; + number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb]; + big_m = table_38213_13_11_c3[index_4lsb]; + + if((index_4lsb == 1 || index_4lsb == 3 || index_4lsb == 5 || index_4lsb == 7) && (ii&1)){ + first_symbol_index = num_symbols_coreset; + }else{ + first_symbol_index = table_38213_13_11_c4[index_4lsb]; + } + } + + if(ssb_coreset_multiplexing_pattern == 1 && frequency_range == FR2){ + big_o = table_38213_13_12_c1[index_4lsb]; + number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb]; + big_m = table_38213_13_12_c3[index_4lsb]; + + if((index_4lsb == 1 || index_4lsb == 3 || index_4lsb == 5 || index_4lsb == 10) && (ii&1)){ + first_symbol_index = 7; + }else if((index_4lsb == 6 || index_4lsb == 7 || index_4lsb == 8 || index_4lsb == 11) && (ii&1)){ + first_symbol_index = num_symbols_coreset; + }else{ + first_symbol_index = 0; + } + } + + if(ssb_coreset_multiplexing_pattern == 2){ + if((scs_ssb == scs_120kHz) && (scs_pdcch == scs_60kHz)){ + // 38.213 Table 13-13 + AssertFatal(index_4lsb == 0, "38.213 Table 13-13 4 LSB out of range\n"); + // TODO check PDCCH monitoring occasions (SFN and slot number) + // TODO check first symbol index + //first_symbol_index = + }else if((scs_ssb == scs_240kHz) && (scs_pdcch == scs_120kHz)){ + // 38.213 Table 13-14 + AssertFatal(index_4lsb == 0, "38.213 Table 13-14 4 LSB out of range\n"); + // TODO check PDCCH monitoring occasions (SFN and slot number) + // TODO check first symbol index + //first_symbol_index = + }else{ ; } + } + + if(ssb_coreset_multiplexing_pattern == 3){ + if((scs_ssb == scs_120kHz) && (scs_pdcch == scs_120kHz)){ + // 38.213 Table 13-15 + AssertFatal(index_4lsb == 0, "38.213 Table 13-15 4 LSB out of range\n"); + // TODO check PDCCH monitoring occasions (SFN and slot number) + // TODO check first symbol index + //first_symbol_index = + }else{ ; } + } // fill in the elements in config request inside P5 message mac->phy_config.config_req.pbch_config.system_frame_number = frame; // after calculation diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index eb4e9919d9..c3298a8482 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -62,6 +62,34 @@ int8_t handle_bcch_dlsch(uint32_t pdu_len, uint8_t *pduP){ return 0; } +int8_t nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ + + NR_UE_L2_STATE_t ret; + + ret = nr_ue_scheduler( + ul_info->module_id, + ul_info->gNB_index, + ul_info->cc_id, + ul_info->frame, + ul_info->slot, + 0, 0); // TODO check tx/rx frame/slot is need for NR version + + switch(ret){ + case CONNECTION_OK: + break; + case CONNECTION_LOST: + break; + case PHY_RESYNCH: + break; + case PHY_HO_PRACH: + break; + default: + break; + } + + return 0; +} + int8_t nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ module_id_t module_id = dl_info->module_id; @@ -99,11 +127,16 @@ int8_t nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id){ if (nr_ue_if_module_inst[module_id] == NULL) { - nr_ue_if_module_inst[module_id] = (nr_ue_if_module_t*)malloc(sizeof(nr_ue_if_module_t)); + nr_ue_if_module_inst[module_id] = (nr_ue_if_module_t *)malloc(sizeof(nr_ue_if_module_t)); memset((void*)nr_ue_if_module_inst[module_id],0,sizeof(nr_ue_if_module_t)); - nr_ue_if_module_inst[module_id]->CC_mask=0; + nr_ue_if_module_inst[module_id]->cc_mask=0; + nr_ue_if_module_inst[module_id]->current_frame = 0; + nr_ue_if_module_inst[module_id]->current_slot = 0; + nr_ue_if_module_inst[module_id]->phy_config_request = NULL; + nr_ue_if_module_inst[module_id]->scheduled_response = NULL; nr_ue_if_module_inst[module_id]->dl_indication = nr_ue_dl_indication; + nr_ue_if_module_inst[module_id]->ul_indication = nr_ue_ul_indication; } return nr_ue_if_module_inst[module_id]; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 426255e9f3..677e494ce6 100755 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -40,11 +40,9 @@ typedef struct { /// module id module_id_t module_id; /// component carrier id - int CC_id; + int cc_id; /// frame frame_t frame; - /// subframe - sub_frame_t subframe; /// slot uint8_t slot; @@ -57,6 +55,20 @@ typedef struct { } nr_downlink_indication_t; + +typedef struct { + /// module id + module_id_t module_id; + /// gNB index + uint32_t gNB_index; + /// component carrier id + int cc_id; + /// frame + frame_t frame; + /// slot + uint32_t slot; +} nr_uplink_indication_t; + // Downlink subframe P7 @@ -104,7 +116,7 @@ typedef struct { * -1: Failed to consume bytes. Abort the mission. * Non-negative return values indicate success, and ignored. */ -typedef int8_t(nr_ue_scheduled_response_f)(nr_scheduled_response_t *scheduled_response); +typedef int8_t (nr_ue_scheduled_response_f)(nr_scheduled_response_t *scheduled_response); /* @@ -114,7 +126,7 @@ typedef int8_t(nr_ue_scheduled_response_f)(nr_scheduled_response_t *scheduled_re * -1: Failed to consume bytes. Abort the mission. * Non-negative return values indicate success, and ignored. */ -typedef int8_t(nr_ue_phy_config_request_f)(nr_phy_config_t *phy_config); +typedef int8_t (nr_ue_phy_config_request_f)(nr_phy_config_t *phy_config); /* @@ -124,18 +136,27 @@ typedef int8_t(nr_ue_phy_config_request_f)(nr_phy_config_t *phy_config); * -1: Failed to consume bytes. Abort the mission. * Non-negative return values indicate success, and ignored. */ -typedef int8_t(nr_ue_dl_indication_f)(nr_downlink_indication_t *dl_info); +typedef int8_t (nr_ue_dl_indication_f)(nr_downlink_indication_t *dl_info); +/* + * Generic type of an application-defined callback to return various + * types of data to the application. + * EXPECTED RETURN VALUES: + * -1: Failed to consume bytes. Abort the mission. + * Non-negative return values indicate success, and ignored. + */ +typedef int8_t (nr_ue_ul_indication_f)(nr_uplink_indication_t *ul_info); // TODO check this stuff can be reuse of need modification typedef struct nr_ue_if_module_s { nr_ue_scheduled_response_f *scheduled_response; nr_ue_phy_config_request_f *phy_config_request; nr_ue_dl_indication_f *dl_indication; + nr_ue_ul_indication_f *ul_indication; - uint32_t CC_mask; - uint16_t current_frame; - uint8_t current_subframe; + uint32_t cc_mask; + uint32_t current_frame; + uint32_t current_slot; //pthread_mutex_t nr_if_mutex; } nr_ue_if_module_t; diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 3c8f073f6b..4056de2a37 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -214,26 +214,28 @@ void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_ void init_UE(int nb_inst) { - int inst; - for (inst=0; inst < nb_inst; inst++) { - // UE->rfdevice.type = NONE_DEV; - PHY_VARS_NR_UE *UE = PHY_vars_UE_g[inst][0]; - LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]); - PHY_vars_UE_g[inst][0] = init_nr_ue_vars(NULL,inst,0); + int inst; + NR_UE_MAC_INST_t *mac_inst; + for (inst=0; inst < nb_inst; inst++) { + // UE->rfdevice.type = NONE_DEV; + PHY_VARS_NR_UE *UE = PHY_vars_UE_g[inst][0]; + LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]); + PHY_vars_UE_g[inst][0] = init_nr_ue_vars(NULL,inst,0); - AssertFatal((UE->if_inst = nr_ue_if_module_init(inst)) != NULL,"Can't register interface module\n"); -nr_l3_init_ue(); -nr_l2_init_ue(); -NR_UE_MAC_INST_t *UE_MAC_INST = get_mac_inst(0); -UE_MAC_INST->if_module = UE->if_inst; - UE->if_inst->scheduled_response = nr_ue_scheduled_response; - UE->if_inst->phy_config_request = nr_ue_phy_config_request; + AssertFatal((UE->if_inst = nr_ue_if_module_init(inst)) != NULL, "can not initial IF module\n"); + nr_l3_init_ue(); + nr_l2_init_ue(); + + mac_inst = get_mac_inst(0); + mac_inst->if_module = UE->if_inst; + UE->if_inst->scheduled_response = nr_ue_scheduled_response; + UE->if_inst->phy_config_request = nr_ue_phy_config_request; - AssertFatal(0 == pthread_create(&UE->proc.pthread_ue, - &UE->proc.attr_ue, - UE_thread, - (void*)UE), ""); - } + AssertFatal(0 == pthread_create(&UE->proc.pthread_ue, + &UE->proc.attr_ue, + UE_thread, + (void*)UE), ""); + } printf("UE threads created by %ld\n", gettid()); #if 0 @@ -621,6 +623,23 @@ static void *UE_thread_rxn_txnp4(void *arg) { #endif if (UE->mac_enabled==1) { + // trigger L2 to run ue_scheduler thru IF module + // [TODO] mapping right after NR initial sync + if(1) + if(UE->if_inst != NULL && UE->if_inst->ul_indication != NULL){ + UE->ul_indication.module_id = 0; + UE->ul_indication.gNB_index = 0; + UE->ul_indication.cc_id = 0; + + // [TODO] mapping right after NR initial sync + //UE->ul_indication.frame = ; + //UE->ul_indication.slot = ; + + UE->if_inst->ul_indication(&UE->ul_indication); + } + + + #ifdef NEW_MAC ret = mac_xface->ue_scheduler(UE->Mod_id, proc->frame_rx,