diff --git a/openair1/PHY/phy_extern_nr_ue.h b/openair1/PHY/phy_extern_nr_ue.h index a9694ea058d6278fb7b2564d5bc294ee958f5dd2..253c5b7fb90d1a7efe6b039133499c6fb7284131 100644 --- a/openair1/PHY/phy_extern_nr_ue.h +++ b/openair1/PHY/phy_extern_nr_ue.h @@ -23,7 +23,7 @@ #define __PHY_EXTERN_UE__H__ #include "PHY/defs_nr_UE.h" -#include "common/ran_context.h" +//#include "common/ran_context.h" extern char* namepointer_chMag ; extern char* namepointer_log2; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 44123a2479c2ef615391580b16ade0cbda69d3dd..05d26bd8e6a848ccaef98015dc46f27427f2caf4 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -60,7 +60,7 @@ #endif #include "LAYER2/NR_MAC_UE/extern.h" -#include "LAYER2/NR_MAC_UE/defs.h" +#include "LAYER2/NR_MAC_UE/mac_defs.h" #include "UTIL/LOG/log.h" #ifdef EMOS diff --git a/openair2/LAYER2/NR_MAC_UE/mac.h b/openair2/LAYER2/NR_MAC_UE/mac.h index 253c855da82136e9c121055fcc29c3043d666a11..e4935b1fea673dede9defe4c330983eab1d5c70b 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac.h +++ b/openair2/LAYER2/NR_MAC_UE/mac.h @@ -34,8 +34,8 @@ /*@}*/ -#ifndef __LAYER2_MAC_DEFS_H__ -#define __LAYER2_MAC_DEFS_H__ +#ifndef __LAYER2_NR_UE_MAC_DEFS_H__ +#define __LAYER2_NR_UE_MAC_DEFS_H__ @@ -43,40 +43,6 @@ #include #include -#include "COMMON/platform_constants.h" -#include "BCCH-BCH-Message.h" -#include "RadioResourceConfigCommon.h" -#include "RadioResourceConfigCommonSIB.h" -#include "RadioResourceConfigDedicated.h" -#include "MeasGapConfig.h" -#include "SchedulingInfoList.h" -#include "TDD-Config.h" -#include "RACH-ConfigCommon.h" -#include "MeasObjectToAddModList.h" -#include "MobilityControlInfo.h" -#if defined(Rel10) || defined(Rel14) -#include "MBSFN-AreaInfoList-r9.h" -#include "MBSFN-SubframeConfigList.h" -#include "PMCH-InfoList-r9.h" -#include "SCellToAddMod-r10.h" -#endif -#ifdef Rel14 -#include "SystemInformationBlockType1-v1310-IEs.h" -#endif - -#include "nfapi_interface.h" -#include "PHY_INTERFACE/IF_Module.h" - -#include "PHY/TOOLS/time_meas.h" - -#include "PHY/defs_common.h" // for PRACH_RESOURCES_t - -#include "targets/ARCH/COMMON/common_lib.h" - -//solve implicit declaration -#include "PHY/LTE_ESTIMATION/lte_estimation.h" -#include "PHY/LTE_TRANSPORT/transport_proto.h" -#include "PHY/LTE_TRANSPORT/transport_common_proto.h" /** @defgroup _mac MAC * @ingroup _oai2 @@ -89,4 +55,24 @@ /*!\brief Values of PCCH logical channel (fake) */ #define NR_BCCH_BCH 5 // MIB /*@}*/ + + + + + +/*!\brief UE layer 2 status */ +typedef enum { + CONNECTION_OK = 0, + CONNECTION_LOST, + PHY_RESYNCH, + PHY_HO_PRACH +} UE_L2_STATE_t; + + + + + + + + #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h deleted file mode 100644 index b8f18bf950b3a8398a9924c46cd199f9e4c1ecf9..0000000000000000000000000000000000000000 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ /dev/null @@ -1,57 +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 LAYER2/MAC/proto.h - * \brief MAC functions prototypes for eNB and UE - * \author Navid Nikaein and Raymond Knopp - * \date 2010 - 2014 - * \email navid.nikaein@eurecom.fr - * \version 1.0 - */ -#ifndef __LAYER2_MAC_PROTO_H__ -#define __LAYER2_MAC_PROTO_H__ - -#include "mac_defs.h" - -/**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message - \param module_id module id - \param CC_id component carrier id - \param gNB_index gNB index - \param extra_bits extra bits for frame calculation - \param ssb_index SSB index for frame calculation - \param frameP pointer to frame for revising after frame calculation - \param pduP pointer to pdu - \param pdu_length length of pdu*/ -void nr_ue_decode_mib(module_id_t module_id, int CC_id, uint8_t gNB_index, uint8_t extra_bits, uint32_t ssb_index, uint32_t *frameP, void *pduP, uint16_t pdu_len); - - -/**\brief primitive from RRC layer to MAC layer for configuration L1/L2, now supported 4 rrc messages: MIB, cell_group_config for MAC/PHY, spcell_config(serving cell config) - \param module_id module id - \param CC_id component carrier id - \param gNB_index gNB index - \param mibP pointer to RRC message MIB - \param mac_cell_group_configP pointer to RRC message MAC-related in cell group config - \param phy_cell_group_configP pointer to RRC message PHY-related in cell group config - \param spcell_configP pointer to RRC message serving cell config*/ -int nr_rrc_mac_config_req_ue( module_id_t module_id, int CC_id, uint8_t gNB_index, NR_MIB_t *mibP, NR_MAC_CellGroupConfig_t *mac_cell_group_configP, NR_PhysicalCellGroupConfig_t *phy_cell_group_configP, NR_SpCellConfig_t *spcell_configP ){ - -#endif -/** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_vars.c b/openair2/LAYER2/NR_MAC_UE/mac_vars.c index 4ce77e2b93a9755e00e7ba5c21c1e00f86f9fe64..3192d6dcc963779ab6473f82157e332ff905fe83 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_vars.c +++ b/openair2/LAYER2/NR_MAC_UE/mac_vars.c @@ -29,7 +29,7 @@ */ -#include "defs.h" +#include "mac_defs.h" NR_UE_MAC_INST_t UE_mac_inst; //[NB_MODULE_MAX]; diff --git a/openair2/LAYER2/NR_MAC_UE/proto.h b/openair2/LAYER2/NR_MAC_UE/proto.h index ffab06a43f74619fb6f43f3a55d37e3057e874f1..387bbc4e8645259bdfc5e0fc42398943ab8e0a85 100755 --- a/openair2/LAYER2/NR_MAC_UE/proto.h +++ b/openair2/LAYER2/NR_MAC_UE/proto.h @@ -29,7 +29,7 @@ #ifndef __LAYER2_MAC_PROTO_H__ #define __LAYER2_MAC_PROTO_H__ -#include "defs.h" +#include "mac_defs.h" /**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message \param module_id module id diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c index bbb3c0a64e237c618507b7b101d591f168744264..70d1cbb99885e4d7311bedcdad0ee993356938c2 100644 --- a/openair2/RRC/NR_UE/main_ue.c +++ b/openair2/RRC/NR_UE/main_ue.c @@ -4,7 +4,7 @@ #include "rrc_proto.h" int nr_l3_init_ue(void){ - LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n"); + //LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n"); openair_rrc_top_init_ue_nr(); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 846a7a6b2797699bfe6acc9ed76e52a455311868..10f5a0026622d5a69de4bd4696f18e72ddab7809 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -71,21 +71,21 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfig switch(rrcReconfiguration->criticalExtensions.present){ case NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration: - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.radioBearerConfig != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig != NULL){ if(NR_UE_rrc_inst->radio_bearer_config == NULL){ - NR_UE_rrc_inst->radio_bearer_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.radioBearerConfig; + NR_UE_rrc_inst->radio_bearer_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig; }else{ - nr_rrc_ue_process_radio_bearer_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.radioBearerConfig); + nr_rrc_ue_process_radio_bearer_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig); } } - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.secondaryCellGroup != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup != NULL){ NR_CellGroupConfig_t *cellGroupConfig = NULL; uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, //might be added prefix later (void **)&cellGroupConfig, - (uint8_t *)rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.secondaryCellGroup->buf, - rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.secondaryCellGroup->size, 0, 0); + (uint8_t *)rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->buf, + rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->size, 0, 0); if(NR_UE_rrc_inst->cell_group_config == NULL){ // first time receive the configuration, just use the memory allocated from uper_decoder. TODO this is not good implementation, need to maintain RRC_INST own structure every time. @@ -100,21 +100,21 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfig } - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.measConfig != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->measConfig != NULL){ if(NR_UE_rrc_inst->meas_config == NULL){ - NR_UE_rrc_inst->meas_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.measConfig; + NR_UE_rrc_inst->meas_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->measConfig; }else{ // if some element need to be updated - nr_rrc_ue_process_meas_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.measConfig); + nr_rrc_ue_process_meas_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->measConfig); } } - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.lateNonCriticalExtension != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->lateNonCriticalExtension != NULL){ // unuse now } - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.nonCriticalExtension != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->nonCriticalExtension != NULL){ // unuse now } break; @@ -298,10 +298,7 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( buffer_len ); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E( RRC, "[UE %"PRIu8"] Failed to decode BCCH_DLSCH_MESSAGE (%zu bits)\n", - module_id, - dec_rval.consumed ); - + for (i=0; imessage.choice.mib; + mib = bcch_message->message.choice.mib; //memcpy( (void *)mib, // (void *)&bcch_message->message.choice.mib, // sizeof(NR_MIB_t) ); @@ -340,9 +337,6 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message( buffer_len, 0, 0); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E( RRC, "[UE %"PRIu8"] Failed to decode NR_DL_DCCH_Message (%zu bits)\n", - module_id, - dec_rval.consumed ); for (i=0; imessage.present){ case NR_DL_DCCH_MessageType_PR_c1: - switch(nr_dl_dcch_msg->message.choice.c1.present){ + switch(nr_dl_dcch_msg->message.choice.c1->present){ case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration: - nr_rrc_ue_process_rrcReconfiguration(&nr_dl_dcch_msg->message.choice.c1.choice.rrcReconfiguration); + nr_rrc_ue_process_rrcReconfiguration(nr_dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration); break; case NR_DL_DCCH_MessageType__c1_PR_NOTHING: diff --git a/openair2/RRC/NR_UE/rrc_list.h b/openair2/RRC/NR_UE/rrc_list.h new file mode 100644 index 0000000000000000000000000000000000000000..5bad103dd43160e3281134d1c25c6cb2533f6d31 --- /dev/null +++ b/openair2/RRC/NR_UE/rrc_list.h @@ -0,0 +1,82 @@ +#ifndef _RRC_LIST_H_ +#define _RRC_LIST_H_ + + +#define RRC_LIST_TYPE(T, N) \ + struct { \ + T *entries[N]; \ + int next[N]; \ + int prev[N]; \ + int start; \ + int count; \ + } + +// initial function for the certain list, storage number of entry, initial pointer and corresponding links +#define RRC_LIST_INIT(list, c) \ + do { \ + int iterator; \ + (list).count = (c); \ + for(iterator=0; iteratorid_name == (list).entries[iterator]->id_name){ \ + (list).entries[iterator] = (new); \ + break; \ + } \ + } \ + if(iterator==-1){ \ + for(iterator=0; iterator<(list).count; ++iterator){ \ + if((list).entries[iterator] == NULL){ \ + (list).next[iterator] = (list).start; \ + (list).prev[iterator] = -1; \ + if((list).start != -1){ \ + (list).prev[list.start] = iterator; \ + } \ + (list).start = iterator; \ + (list).entries[iterator] = (new); \ + break; \ + } \ + } \ + } \ + }while(0) + +// search entries by id, unlink from the list and output free pointer for upper function to release memory +#define RRC_LIST_MOD_REL(list, id_name, id, free) \ + do{ \ + int iterator; \ + for(iterator=(list).start; iterator!=-1; iterator=(list).next[iterator]){ \ + if(id == (list).entries[iterator]->id_name){ \ + if((list).prev[iterator] == -1){ \ + (list).start = (list).next[iterator]; \ + }else{ \ + (list).next[(list).prev[iterator]] = (list).next[iterator]; \ + } \ + if((list).next[iterator] != -1){ \ + (list).prev[(list).next[iterator]] = (list).prev[iterator]; \ + } \ + (free) = (list).entries[iterator]; \ + (list).entries[iterator] = NULL; \ + break; \ + } \ + } \ + }while(0) + + +#define RRC_LIST_FOREACH(list, i) \ + for((i)=(list).start; (i) != -1; (i)=(list).next[i]) + +#define RRC_LIST_ENTRY(list, i) \ + list.entries[i] + +#endif \ No newline at end of file diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 5c6f25bb8d08daded882c8776151d614b361289e..cb80fede454db208f4b4c7eab68eabf157074894 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -33,16 +33,16 @@ #include "rt_wrapper.h" -#include "LAYER2/MAC/mac.h" -#include "RRC/LTE/rrc_extern.h" +#include "LAYER2/NR_MAC_UE/mac.h" +//#include "RRC/LTE/rrc_extern.h" #include "PHY_INTERFACE/phy_interface_extern.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all #include "PHY/phy_extern_nr_ue.h" -#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/mac_proto.h" +//#include "LAYER2/NR_MAC_UE/extern.h" +#include "LAYER2/NR_MAC_UE/proto.h" #include "SCHED_NR/extern.h" //#ifndef NO_RAT_NR @@ -734,7 +734,7 @@ void *UE_thread(void *arg) { init_UE_threads(UE); #ifdef NAS_UE - MessageDef *message_p; + //MessageDef *message_p; //message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE); //itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p); #endif @@ -1037,6 +1037,7 @@ void init_UE_threads(PHY_VARS_NR_UE *UE) { #ifdef OPENAIR2 +/* void fill_ue_band_info(void) { UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability; @@ -1063,7 +1064,7 @@ void fill_ue_band_info(void) { break; } } -} +}*/ #endif int setup_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg) {