Commit 3b00e1dc authored by Nick Ho's avatar Nick Ho

Update main_nb_iot in MAC

parent 44b6e1a3
......@@ -1147,6 +1147,7 @@ set(L2_SRC
set (MAC_SRC
${MAC_DIR}/lte_transport_init.c
${MAC_DIR}/main.c
${MAC_DIR}/main_nb_iot.c
${MAC_DIR}/ue_procedures.c
${MAC_DIR}/ra_procedures.c
${MAC_DIR}/l1_helpers.c
......
......@@ -47,6 +47,7 @@
#include "MasterInformationBlock-NB.h"
#include "BCCH-BCH-Message-NB.h"
#include "openair2/PHY_INTERFACE/IF_Module_nb_iot.h"
#include "defs.h"
//#ifdef PHY_EMUL
//#include "SIMULATION/PHY_EMULATION/impl_defs.h"
//#endif
......@@ -433,7 +434,7 @@ typedef struct {
uint8_t RA_dci_size_bits1;
/// Actual DCI to transmit for RA-Response
uint8_t RA_alloc_pdu1[(MAX_DCI_SIZE_BITS>>3)+1];
/// DCI format for RA-Response (should be 1A)
/// DCI format for RA-Response (should be N1 RAR)
uint8_t RA_dci_fmt1;
/// Size of DCI for Msg4/ContRes (bytes)
uint8_t RA_dci_size_bytes2;
......
......@@ -31,7 +31,9 @@
#include "asn1_constants.h"
#include "defs_nb_iot.h"
#include "proto_nb_iot.h"
#include "extern.h"
int mac_init_global_param_NB(void)
{
......@@ -79,127 +81,135 @@ int mac_init_global_param_NB(void)
return 0;
}
int mac_top_init_NB(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active)
{
module_id_t Mod_id,i,j;
RA_TEMPLATE_NB *RA_template;
UE_TEMPLATE_NB *UE_template;
int size_bytes1,size_bytes2,size_bits1,size_bits2;
int CC_id;
int list_el;
UE_list_NB_t *UE_list;
// delete the part to init the UE_INST
LOG_I(MAC,"[MAIN] Init function start:Nb_eNB_INST=%d\n",NB_eNB_INST);
if (NB_eNB_INST>0) {
eNB_mac_inst_NB = (eNB_MAC_INST_NB*)malloc16(NB_eNB_INST*sizeof(eNB_MAC_INST_NB));
if (eNB_mac_inst_NB == NULL) {
LOG_D(MAC,"[MAIN] can't ALLOCATE %zu Bytes for %d eNB_MAC_INST with size %zu \n",NB_eNB_INST*sizeof(eNB_MAC_INST_NB*),NB_eNB_INST,sizeof(eNB_MAC_INST_NB));
LOG_I(MAC,"[MAC][MAIN] not enough memory for eNB \n");
exit(1);
} else {
LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST),NB_eNB_INST,eNB_mac_inst);
bzero(eNB_mac_inst_NB,NB_eNB_INST*sizeof(eNB_MAC_INST_NB));
}
} else {
eNB_mac_inst_NB = NULL;
}
// Initialize Linked-List for Active UEs
for(Mod_id=0; Mod_id<NB_eNB_INST; Mod_id++) {
UE_list = &eNB_mac_inst_NB[Mod_id].UE_list;
UE_list->num_UEs=0;
UE_list->head=-1;
UE_list->head_ul=-1;
UE_list->avail=0;
for (list_el=0; list_el<NUMBER_OF_UE_MAX-1; list_el++) {
UE_list->next[list_el]=list_el+1;
UE_list->next_ul[list_el]=list_el+1;
}
UE_list->next[list_el]=-1;
UE_list->next_ul[list_el]=-1;
}
// TODO : check the pointer to TX
if (Is_rrc_nb_iot_registered == 1) {
LOG_I(MAC,"[MAIN] calling RRC\n");
#ifndef CELLULAR //nothing to be done yet for cellular
openair_rrc_top_init(eMBMS_active, uecap_xer, cba_group_active,HO_active);
#endif
} else {
LOG_I(MAC,"[MAIN] Running without an RRC\n");
}
#ifndef USER_MODE
#ifndef PHY_EMUL
LOG_I(MAC,"[MAIN] add openair2 proc\n");
//// add_openair2_stats();
#endif
#endif
// initialization for the RA template
for (i=0; i<NB_eNB_INST; i++)
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
LOG_D(MAC,"[MAIN][eNB %d] CC_id %d initializing RA_template\n",i, CC_id);
LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_eNB][MOD %02d][]\n", i);
RA_template = (RA_TEMPLATE *)&eNB_mac_inst[i].common_channels[CC_id].RA_template[0];
for (j=0; j<NB_RA_PROC_MAX; j++) {
size_bytes1 = sizeof(DCIN1_RAR_t);
size_bytes2 = sizeof(DCIN1_t);
size_bits1 = sizeof_DCIN1_RAR_t;
size_bits2 = sizeof_DCIN1_t;
memcpy((void *)&RA_template[j].RA_alloc_pdu1[0],(void *)&RA_alloc_pdu,size_bytes1);
memcpy((void *)&RA_template[j].RA_alloc_pdu2[0],(void *)&DLSCH_alloc_pdu1A,size_bytes2);//DLSCH_alloc_pdu1A global!!!!!!
RA_template[j].RA_dci_size_bytes1 = size_bytes1;
RA_template[j].RA_dci_size_bytes2 = size_bytes2;
RA_template[j].RA_dci_size_bits1 = size_bits1;
RA_template[j].RA_dci_size_bits2 = size_bits2;
RA_template[j].RA_dci_fmt1 = DCIFormatN1_RAR;
RA_template[j].RA_dci_fmt2 = DCIFormatN1;
}
memset (&eNB_mac_inst_NB[i].eNB_stats,0,sizeof(eNB_STATS_NB));
UE_template = (UE_TEMPLATE_NB *)&eNB_mac_inst[i].UE_list.UE_template[CC_id][0];
for (j=0; j<NUMBER_OF_UE_MAX; j++) {
UE_template[j].rnti=0;
// initiallize the eNB to UE statistics
memset (&eNB_mac_inst_NB[i].UE_list.eNB_UE_stats[CC_id][j],0,sizeof(eNB_UE_STATS_NB));
}
}
//ICIC init param
//end ALU's algo
LOG_I(MAC,"[MAIN][INIT] Init function finished\n");
return(0);
}
int l2_init_eNB_NB()
{
LOG_I(MAC,"Mapping L2 IF-Module functions\n");
LOG_I(MAC,"[MAIN] Mapping L2 IF-Module functions\n");
IF_Module_init_L2();
LOG_I(MAC,"[MAIN] MAC_INIT_GLOBAL_PARAM NB-IoT IN...\n");
Is_rrc_nb_iot_registered=0;
NB_mac_init_global_param();
mac_init_global_param_NB();
Is_rrc_nb_iot_registered=1;
//XXX called in the parallel path
// mac_xface->macphy_init = mac_top_init;
// #ifndef USER_MODE
// mac_xface->macphy_exit = openair_sched_exit;
// #else
// mac_xface->macphy_exit=(void (*)(const char*)) exit;
// #endif
// LOG_I(MAC,"[MAIN] init eNB MAC functions \n");
// mac_xface->eNB_dlsch_ulsch_scheduler = eNB_dlsch_ulsch_scheduler;
// mac_xface->get_dci_sdu = get_dci_sdu;
// mac_xface->fill_rar = fill_rar;
// mac_xface->initiate_ra_proc = initiate_ra_proc;
// mac_xface->cancel_ra_proc = cancel_ra_proc;
// mac_xface->set_msg3_subframe = set_msg3_subframe;
// mac_xface->SR_indication = SR_indication;
// mac_xface->UL_failure_indication = UL_failure_indication;
// mac_xface->rx_sdu = rx_sdu;
// mac_xface->get_dlsch_sdu = get_dlsch_sdu;
// mac_xface->get_eNB_UE_stats = get_UE_stats;
// mac_xface->get_transmission_mode = get_transmission_mode;
// mac_xface->get_rballoc = get_rballoc;
// mac_xface->get_nb_rb = conv_nprb;
// mac_xface->get_prb = get_prb;
// // mac_xface->get_SB_size = Get_SB_size;
// mac_xface->get_subframe_direction = get_subframe_direction;
// mac_xface->Msg3_transmitted = Msg3_tx;
// mac_xface->Msg1_transmitted = Msg1_tx;
// mac_xface->ra_failed = ra_failed;
// mac_xface->ra_succeeded = ra_succeeded;
// mac_xface->mac_phy_remove_ue = mac_phy_remove_ue;
//
// LOG_I(MAC,"[MAIN] init UE MAC functions \n");
// mac_xface->ue_decode_si = ue_decode_si;
// mac_xface->ue_decode_p = ue_decode_p;
// mac_xface->ue_send_sdu = ue_send_sdu;
// #if defined(Rel10) || defined(Rel14)
// mac_xface->ue_send_mch_sdu = ue_send_mch_sdu;
// mac_xface->ue_query_mch = ue_query_mch;
// #endif
// mac_xface->ue_get_SR = ue_get_SR;
// mac_xface->ue_get_sdu = ue_get_sdu;
// mac_xface->ue_get_rach = ue_get_rach;
// mac_xface->ue_process_rar = ue_process_rar;
// mac_xface->ue_scheduler = ue_scheduler;
// mac_xface->process_timing_advance = process_timing_advance;
//
//
// LOG_I(MAC,"[MAIN] PHY Frame configuration \n");
// mac_xface->frame_parms = frame_parms;
//
// mac_xface->get_ue_active_harq_pid = get_ue_active_harq_pid;
// mac_xface->get_PL = get_PL;
// mac_xface->get_RSRP = get_RSRP;
// mac_xface->get_RSRQ = get_RSRQ;
// mac_xface->get_RSSI = get_RSSI;
// mac_xface->get_n_adj_cells = get_n_adj_cells;
// mac_xface->get_rx_total_gain_dB = get_rx_total_gain_dB;
// mac_xface->get_Po_NOMINAL_PUSCH = get_Po_NOMINAL_PUSCH;
// mac_xface->get_num_prach_tdd = get_num_prach_tdd;
// mac_xface->get_fid_prach_tdd = get_fid_prach_tdd;
// mac_xface->get_deltaP_rampup = get_deltaP_rampup;
// mac_xface->computeRIV = computeRIV;
// mac_xface->get_TBS_DL = get_TBS_DL;
// mac_xface->get_TBS_UL = get_TBS_UL;
// mac_xface->get_nCCE_max = get_nCCE_mac;
// mac_xface->get_nCCE_offset = get_nCCE_offset;
// mac_xface->get_ue_mode = get_ue_mode;
// mac_xface->phy_config_sib1_eNB = phy_config_sib1_eNB;
// mac_xface->phy_config_sib1_ue = phy_config_sib1_ue;
//
// mac_xface->phy_config_sib2_eNB = phy_config_sib2_eNB;
// mac_xface->phy_config_sib2_ue = phy_config_sib2_ue;
// mac_xface->phy_config_afterHO_ue = phy_config_afterHO_ue;
// #if defined(Rel10) || defined(Rel14)
// mac_xface->phy_config_sib13_eNB = phy_config_sib13_eNB;
// mac_xface->phy_config_sib13_ue = phy_config_sib13_ue;
// #endif
// #ifdef CBA
// mac_xface->phy_config_cba_rnti = phy_config_cba_rnti ;
// #endif
// mac_xface->estimate_ue_tx_power = estimate_ue_tx_power;
// mac_xface->phy_config_meas_ue = phy_config_meas_ue;
// mac_xface->phy_reset_ue = phy_reset_ue;
//
// mac_xface->phy_config_dedicated_eNB = phy_config_dedicated_eNB;
// mac_xface->phy_config_dedicated_ue = phy_config_dedicated_ue;
// mac_xface->phy_config_harq_ue = phy_config_harq_ue;
//
// mac_xface->get_lte_frame_parms = get_lte_frame_parms;
// mac_xface->get_mu_mimo_mode = get_mu_mimo_mode;
//
// mac_xface->get_hundred_times_delta_TF = get_hundred_times_delta_IF_mac;
// mac_xface->get_target_pusch_rx_power = get_target_pusch_rx_power;
// mac_xface->get_target_pucch_rx_power = get_target_pucch_rx_power;
//
// mac_xface->get_prach_prb_offset = get_prach_prb_offset;
// mac_xface->is_prach_subframe = is_prach_subframe;
//
// #if defined(Rel10) || defined(Rel14)
// mac_xface->get_mch_sdu = get_mch_sdu;
// mac_xface->phy_config_dedicated_scell_eNB= phy_config_dedicated_scell_eNB;
// mac_xface->phy_config_dedicated_scell_ue= phy_config_dedicated_scell_ue;
//
// #endif
//
// mac_xface->get_PHR = get_PHR;
// LOG_D(MAC,"[MAIN] ALL INIT OK\n");
LOG_D(MAC,"[MAIN] ALL INIT OK\n");
//
// mac_xface->macphy_init(eMBMS_active,uecap_xer,cba_group_active,HO_active);
......
......@@ -51,6 +51,7 @@
#include "LAYER2/MAC/proto.h"
#include "RRC/LITE/vars.h"
#include "PHY_INTERFACE/vars.h"
#include "PHY_INTERFACE/defs_nb_iot.h"
#ifdef SMBV
#include "PHY/TOOLS/smbv.h"
......@@ -1862,6 +1863,10 @@ int main( int argc, char **argv ) {
PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset;
}
} else {
printf("Initializing IF Module in PHY layer\n");
IF_Module_init_L1();
printf("Initializing eNB threads\n");
init_eNB(node_function,node_timing,1,eth_params,single_thread_flag,wait_for_sync);
......
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