Commit 3a5f22d9 authored by hongzhi wang's avatar hongzhi wang

UE: add MAC and RRC instance initialization

parent 0138886b
......@@ -641,10 +641,10 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue,
nushift = (Lmax==4)? ssb_index&3 : ssb_index&7;
//#ifdef DEBUG_PBCH
if (i<16){
printf("unscrambling demod_pbch_e[%d] r = %2.3f i = %2.3f\n", i<<1 , demod_pbch_e[i<<1], demod_pbch_e[(i<<1)+1]);}
//polar decoding de-rate matching
decoderState = polar_decoder(demod_pbch_e, pbch_a_b, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr);
......@@ -656,10 +656,10 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue,
//printf("pbch_a_b[%d] = %u pbch_a_prime[i/8] 0x%02x \n", i,pbch_a_b[i],pbch_a_prime[i/8]);
//#ifdef DEBUG_PBCH
for (i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS>>3; i++)
printf("pbch_a_prime[%d] = 0x%02x\n", i,pbch_a_prime[i]);
//payload un-scrambling
memset(nr_ue_pbch_vars->pbch_a_interleaved, 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS>>3);
......@@ -675,9 +675,9 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue,
for (int i=0; i<32; i++) {
out |= ((in>>i)&1)<<(pbch_deinterleaving_pattern[i]);
//#ifdef DEBUG_PBCH
printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, in, out, pbch_deinterleaving_pattern[i], (in>>i)&1);
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS>>3; i++)
......@@ -697,7 +697,9 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue,
ue->dl_indication.rx_ind.rx_request_body.pdu_index = FAPI_NR_RX_PDU_BCCH_BCH_TYPE;
ue->dl_indication.rx_ind.rx_request_body.pdu_length = 3;
ue->dl_indication.rx_ind.rx_request_body.pdu = &pbch_a[0];
// ue->dl_indication.rx_ind.rx_request_body.pdu = &pbch_a[0];
ue->dl_indication.rx_ind.rx_request_body.pdu = &decoded_output[0];
......@@ -33,28 +33,13 @@
#ifndef __LAYER2_NR_UE_MAC_DEFS_H__
#define __LAYER2_NR_UE_MAC_DEFS_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/** @defgroup _mac MAC
* @ingroup _oai2
* @{
/*!\brief Values of BCCH logical channel (fake)*/
#define NR_BCCH_DL_SCH 3 // SI
/*!\brief Values of PCCH logical channel (fake) */
#define NR_BCCH_BCH 5 // MIB
/*!\brief UE layer 2 status */
typedef enum {
......@@ -65,10 +50,4 @@ typedef enum {
} UE_L2_STATE_t;
#endif /*__LAYER2_MAC_DEFS_H__ */
......@@ -53,7 +53,6 @@ int8_t nr_ue_decode_mib(
nr_mac_rrc_data_ind_ue( module_id, CC_id, gNB_index,
NR_BCCH_BCH, (uint8_t *) pduP, pdu_len );
uint32_t frame = mac->mib->systemFrameNumber.buf[0];
uint32_t frame_number_4lsb = (uint32_t)(extra_bits & 0xf); // extra bits[0:3]
uint32_t half_frame_bit = (uint32_t)(( extra_bits >> 4 ) & 0x1 ); // extra bits[4]
......@@ -76,6 +75,16 @@ int8_t nr_ue_decode_mib(
printf("subcarrier spacing: %d\n", mac->mib->subCarrierSpacingCommon);
printf("ssb carrier offset: %d\n", ssb_subcarrier_offset);
printf("dmrs type A position: %d\n", mac->mib->dmrs_TypeA_Position);
printf("pdcch config sib1: %d\n", mac->mib->pdcch_ConfigSIB1);
printf("cell barred: %d\n", mac->mib->cellBarred);
printf("intra frequcney reselection: %d\n", mac->mib->intraFreqReselection);
printf("system frame number: %d\n", frame);
printf("half frame bit: %d\n", half_frame_bit);
// fill in the elements in config request inside P5 message
mac->phy_config.config_req.pbch_config.system_frame_number = frame; // after calculation
mac->phy_config.config_req.pbch_config.subcarrier_spacing_common = mac->mib->subCarrierSpacingCommon;
......@@ -38,6 +38,6 @@ int nr_l3_init_ue(void){
return 1;
return 0;
......@@ -299,11 +299,17 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(
SEQUENCE_free( &asn_DEF_NR_BCCH_BCH_Message, (void *)mib, 1 );
for(i=0; i<4; ++i){
printf("[RRC] bcch undecod : %d\n", bufferP[i]);
asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
(void **)&bcch_message,
(const void *)bufferP,
buffer_len );
(const void *)bufferP[1],
if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
......@@ -104,110 +104,4 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, cons
/** @}*/
* 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
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* See the License for the specific language governing permissions and
* limitations under the License.
* For more information about the OpenAirInterface (OAI) Software Alliance:
/*! \file proto.h
* \brief RRC functions prototypes for eNB and UE
* \author Navid Nikaein and Raymond Knopp
* \date 2010 - 2014
* \email
* \version 1.0
/** \addtogroup _rrc
* @{
#ifndef _RRC_PROTO_H_
#define _RRC_PROTO_H_
#include "rrc_defs.h"
#include "NR_RRCReconfiguration.h"
#include "NR_MeasConfig.h"
#include "NR_CellGroupConfig.h"
#include "NR_RadioBearerConfig.h"
// main_rrc.c
/**\brief Layer 3 initialization*/
int nr_l3_init_ue(void);
// UE_rrc.c
/**\brief Initial the top level RRC structure instance*/
int8_t openair_rrc_top_init_ue_nr(void);
/**\brief Decode RRC Connection Reconfiguration, sent from E-UTRA RRC Connection Reconfiguration v1510 carring EN-DC config
\param buffer encoded NR-RRC-Connection-Reconfiguration/Secondary-Cell-Group-Config message.
\param size length of buffer*/
//TODO check to use which one
int8_t nr_rrc_ue_decode_rrcReconfiguration(const uint8_t *buffer, const uint32_t size);
int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const uint8_t *buffer, const uint32_t size);
/**\brief Process NR RRC connection reconfiguration via SRB3
\param rrcReconfiguration decoded rrc connection reconfiguration*/
int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfiguration);
/**\prief Process measurement config from NR RRC connection reconfiguration message
\param meas_config measurement configuration*/
int8_t nr_rrc_ue_process_meas_config(NR_MeasConfig_t *meas_config);
/**\prief Process secondary cell group config from NR RRC connection reconfiguration message or EN-DC primitives
\param cell_group_config secondary cell group configuration*/
//TODO check EN-DC function call flow.
int8_t nr_rrc_ue_process_scg_config(NR_CellGroupConfig_t *cell_group_config);
/**\prief Process radio bearer config from NR RRC connection reconfiguration message
\param radio_bearer_config radio bearer configuration*/
int8_t nr_rrc_ue_process_radio_bearer_config(NR_RadioBearerConfig_t *radio_bearer_config);
/**\brief decode NR BCCH-BCH (MIB) message
\param module_idP module id
\param gNB_index gNB index
\param sduP pointer to buffer of ASN message BCCH-BCH
\param sdu_len length of buffer*/
int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(const module_id_t module_id, const uint8_t gNB_index, uint8_t *const bufferP, const uint8_t buffer_len);
/**\brief Decode NR DCCH from gNB, sent from lower layer through SRB3
\param module_id module id
\param gNB_index gNB index
\param buffer encoded DCCH bytes stream message
\param size length of buffer*/
int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message(const module_id_t module_id, const uint8_t gNB_index, const uint8_t *buffer, const uint32_t size);
/**\brief interface between MAC and RRC thru SRB0 (RLC TM/no PDCP)
\param module_id module id
\param CC_id component carrier id
\param gNB_index gNB index
\param frameP pointer to frame for calculation
\param channel indicator for channel of the pdu
\param pduP pointer to pdu
\param pdu_len data length of pdu*/
int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index, const uint32_t *frameP, const channel_t channel, const uint8_t* pduP, const sdu_size_t pdu_len);
/** @}*/
......@@ -43,6 +43,7 @@
#include "fapi_nr_ue_l1.h"
#include "PHY/phy_extern_nr_ue.h"
#include "LAYER2/NR_MAC_UE/proto.h"
#include "RRC/NR_UE/rrc_proto.h"
#include "SCHED_NR/extern.h"
//#ifndef NO_RAT_NR
......@@ -221,6 +222,8 @@ void init_UE(int nb_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");
UE->if_inst->scheduled_response = nr_ue_scheduled_response;
UE->if_inst->phy_config_request = nr_ue_phy_config_request;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment