diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 02f8a63ba76c03f1002bc53edf00ad5bce6eef53..ca3808e16bc91bfed8c902e4fd45cfc13f2ae8c1 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1912,6 +1912,8 @@ set (MAC_NR_SRC ${NR_GNB_MAC_DIR}/gNB_scheduler_srs.c ${NR_GNB_MAC_DIR}/gNB_scheduler_RA.c ${NR_GNB_MAC_DIR}/mac_rrc_dl_handler.c + ${NR_GNB_MAC_DIR}/mac_rrc_ul_direct.c + ${NR_GNB_MAC_DIR}/mac_rrc_ul_f1ap.c ) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index eff65fa6069c98d38ad106242c4e34e5ed77f4a9..1dce30d5055c4d288c762207ac105f2d57be3c8a 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -731,7 +731,7 @@ int main(int argc, char **argv) RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); for (i = 0; i < RC.nb_nr_macrlc_inst; i++) RC.nb_nr_mac_CC[i] = 1; - mac_top_init_gNB(); + mac_top_init_gNB(ngran_gNB); gNB_mac = RC.nrmac[0]; gNB_RRC_INST rrc; memset((void*)&rrc,0,sizeof(rrc)); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index e70d08bdb3bcf5a77193d1fb75fc2ec12a1eff20..9fe132ca52c76baa7c09e7ca7058a8f57baa4e29 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -719,7 +719,7 @@ int main(int argc, char **argv) RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); for (i = 0; i < RC.nb_nr_macrlc_inst; i++) RC.nb_nr_mac_CC[i] = 1; - mac_top_init_gNB(); + mac_top_init_gNB(ngran_gNB); //gNB_MAC_INST* gNB_mac = RC.nrmac[0]; gNB_RRC_INST rrc; memset((void*)&rrc,0,sizeof(rrc)); diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 62dc72a857ae796e5493c5877bd9fcabcc437ce1..f8e043fd72ed262e4c6bd10e747d8dd38cbb5fa7 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -85,7 +85,8 @@ extern uint16_t sf_ahead; int macrlc_has_f1 = 0; -extern ngran_node_t node_type; + +static ngran_node_t get_node_type(void); extern int config_check_band_frequencies(int ind, int16_t band, uint64_t downlink_frequency, int32_t uplink_frequency_offset, uint32_t frame_type); @@ -737,6 +738,7 @@ void RCconfig_nr_macrlc() { paramdef_t GNBParams[] = GNBPARAMS_DESC; paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; + ngran_node_t node_type = get_node_type(); config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); int num_gnbs = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; @@ -763,7 +765,7 @@ void RCconfig_nr_macrlc() { if ( MacRLC_ParamList.numelt > 0) { RC.nb_nr_macrlc_inst=MacRLC_ParamList.numelt; - mac_top_init_gNB(); + mac_top_init_gNB(node_type); RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); for (j=0;j<RC.nb_nr_macrlc_inst;j++) { @@ -2161,8 +2163,8 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up return(ret); } -void set_node_type(void) { - int j; +static ngran_node_t get_node_type(void) +{ paramdef_t MacRLC_Params[] = MACRLCPARAMS_DESC; paramlist_def_t MacRLC_ParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0}; paramdef_t GNBParams[] = GNBPARAMS_DESC; @@ -2173,24 +2175,19 @@ void set_node_type(void) { if ( MacRLC_ParamList.numelt > 0) { RC.nb_nr_macrlc_inst = MacRLC_ParamList.numelt; - for (j=0;j<RC.nb_nr_macrlc_inst;j++) { + for (int j = 0; j < RC.nb_nr_macrlc_inst; j++) { if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "f1") == 0) { macrlc_has_f1 = 1; } } } - if (strcmp(*(GNBParamList.paramarray[0][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "f1") == 0) { - node_type = ngran_gNB_CU; - } else { - if (macrlc_has_f1 == 0) { - node_type = ngran_gNB; - LOG_I(NR_RRC,"Setting node_type to ngran_gNB\n"); - } else { - node_type = ngran_gNB_DU; - LOG_I(NR_RRC,"Setting node_type to ngran_gNB_DU\n"); - } - } + if (strcmp(*(GNBParamList.paramarray[0][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "f1") == 0) + return ngran_gNB_CU; + else if (macrlc_has_f1 == 0) + return ngran_gNB; + else + return ngran_gNB_DU; } void nr_read_config_and_init(void) { @@ -2199,7 +2196,6 @@ void nr_read_config_and_init(void) { uint32_t gnb_nb = RC.nb_nr_inst; RCconfig_NR_L1(); - set_node_type(); RCconfig_nr_macrlc(); LOG_I(PHY, "%s() RC.nb_nr_L1_inst:%d\n", __FUNCTION__, RC.nb_nr_L1_inst); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 9dff368cccd60fa2c2f40943cba26fc65d1cabc0..c0a269108a4edbf4462854d3215d546f627ad7bd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -51,7 +51,6 @@ extern RAN_CONTEXT_t RC; //extern int l2_init_gNB(void); -extern void mac_top_init_gNB(void); extern uint8_t nfapi_mode; void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 9cb4dd88b275084b2f6b9af97f64ff98eb11c567..49850c9ac8c101283e38b25adeb95d0492a46c84 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -36,7 +36,7 @@ void set_cset_offset(uint16_t); -void mac_top_init_gNB(void); +void mac_top_init_gNB(ngran_node_t node_type); void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul.h b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul.h new file mode 100644 index 0000000000000000000000000000000000000000..cb80ba4fa55c1f5c3a6ba9df5e6a41b546a3a850 --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul.h @@ -0,0 +1,34 @@ +/* + * 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: + * conmnc_digit_lengtht@openairinterface.org + */ + +#ifndef MAC_RRC_UL_H +#define MAC_RRC_UL_H + +#include "platform_types.h" +#include "f1ap_messages_types.h" + +typedef void (*initial_ul_rrc_message_transfer_func_t)(module_id_t module_id, const f1ap_initial_ul_rrc_message_t *ul_rrc); + +struct nr_mac_rrc_ul_if_s; +void mac_rrc_ul_direct_init(struct nr_mac_rrc_ul_if_s *mac_rrc); +void mac_rrc_ul_f1ap_init(struct nr_mac_rrc_ul_if_s *mac_rrc); + +#endif /* MAC_RRC_UL_H */ diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c new file mode 100644 index 0000000000000000000000000000000000000000..f290e0d2680606da19123ce902fc2021560a499e --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c @@ -0,0 +1,35 @@ +/* + * 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: + * conmnc_digit_lengtht@openairinterface.org + */ + +#include "nr_mac_gNB.h" + +#include "mac_rrc_ul.h" + +static void initial_ul_rrc_message_transfer_direct(module_id_t module_id, const f1ap_initial_ul_rrc_message_t *ul_rrc) +{ + /* TODO ITTI message for NR_RRC_MAC_IND? */ + AssertFatal(0 == 1, "not implemented\n"); +} + +void mac_rrc_ul_direct_init(struct nr_mac_rrc_ul_if_s *mac_rrc) +{ + mac_rrc->initial_ul_rrc_message_transfer = initial_ul_rrc_message_transfer_direct; +} diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c new file mode 100644 index 0000000000000000000000000000000000000000..ed67fb91193fc84ab5ef720ea0621e8538aaf5bc --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c @@ -0,0 +1,35 @@ +/* + * 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: + * conmnc_digit_lengtht@openairinterface.org + */ + +#include "nr_mac_gNB.h" + +#include "mac_rrc_ul.h" + +static void initial_ul_rrc_message_transfer_f1ap(module_id_t module_id, const f1ap_initial_ul_rrc_message_t *ul_rrc) +{ + AssertFatal(0 == 1, "not implemented\n"); +} + +void mac_rrc_ul_f1ap_init(struct nr_mac_rrc_ul_if_s *mac_rrc) +{ + mac_rrc->initial_ul_rrc_message_transfer = initial_ul_rrc_message_transfer_f1ap; +} + diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index e047494b5296666e55510465702e5f7a72429f68..8a4c5f1ea467bf2657a20d4292771d207536acb0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -140,8 +140,25 @@ void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp print_meas(&gNB->rlc_status_ind,"rlc_status_ind",NULL,NULL); } +static void mac_rrc_init(gNB_MAC_INST *mac, ngran_node_t node_type) +{ + switch (node_type) { + case ngran_gNB_CU: + AssertFatal(1 == 0, "nothing to do for CU\n"); + break; + case ngran_gNB_DU: + mac_rrc_ul_f1ap_init(&mac->mac_rrc); + break; + case ngran_gNB: + mac_rrc_ul_direct_init(&mac->mac_rrc); + break; + default: + AssertFatal(0 == 1, "Unknown node type %d\n", node_type); + break; + } +} -void mac_top_init_gNB(void) +void mac_top_init_gNB(ngran_node_t node_type) { module_id_t i; int list_el; @@ -188,6 +205,7 @@ void mac_top_init_gNB(void) } pthread_create(&RC.nrmac[i]->stats_thread,NULL,nrmac_stats_thread,(void*)RC.nrmac[i]); + mac_rrc_init(RC.nrmac[i], node_type); }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) AssertFatal(rlc_module_init(1) == 0,"Could not initialize RLC layer\n"); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index a2c77234c0c329c2b43376785e399dfe9d8a5a0d..ffdbca276c4e14eccf4fd7f42440918c63d519a3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -60,6 +60,7 @@ /* Interface */ #include "nfapi_nr_interface_scf.h" #include "NR_PHY_INTERFACE/NR_IF_Module.h" +#include "mac_rrc_ul.h" /* MAC */ #include "LAYER2/MAC/mac.h" @@ -676,6 +677,10 @@ typedef struct { uint8_t num_rsrp_meas; } NR_mac_stats_t; +typedef struct nr_mac_rrc_ul_if_s { + /* TODO add other message types as necessary */ + initial_ul_rrc_message_transfer_func_t initial_ul_rrc_message_transfer; +} nr_mac_rrc_ul_if_t; /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ #define MAX_CSI_REPORTCONFIG 48 @@ -822,6 +827,8 @@ typedef struct gNB_MAC_INST_s { uint8_t harq_round_max; uint8_t min_grant_prb; uint8_t min_grant_mcs; + + nr_mac_rrc_ul_if_t mac_rrc; } gNB_MAC_INST; #endif /*__LAYER2_NR_MAC_GNB_H__ */