Commit b8a38a2d authored by Nick Ho's avatar Nick Ho

Pre-commit for the clear NB-IoT MAC code for integration, still on going (110 warning)

parent 9d8ea63c
......@@ -425,7 +425,7 @@ uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t fra
case 2:
if ((subframe!=2) && (subframe!=7)) {
LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
mac_xface_NB_IoT->macphy_exit("subframe2_harq_pid_NB_IoT, Illegal subframe");
//mac_xface_NB_IoT->macphy_exit("subframe2_harq_pid_NB_IoT, Illegal subframe");
ret = (255);
}
......@@ -468,7 +468,7 @@ uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t fra
if (ret == 255) {
LOG_E(PHY, "invalid harq_pid(%d) at SFN/SF = %d/%d\n", ret, frame, subframe);
mac_xface_NB_IoT->macphy_exit("invalid harq_pid");
//mac_xface_NB_IoT->macphy_exit("invalid harq_pid");
}
return ret;
}
......
......@@ -1045,7 +1045,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ulsch_harq->O_ACK,
G,
subframe);
mac_xface_NB_IoT->macphy_exit("ulsch_decoding.c: FATAL sumKr is 0!");
//mac_xface_NB_IoT->macphy_exit("ulsch_decoding.c: FATAL sumKr is 0!");
return(-1);
}
// Compute Q_ri
......
......@@ -29,35 +29,7 @@
*
*/
#include "assertions.h"
//#include "PHY/defs.h"
/* (commented to remove warnings since this file is not used for the moment)
#include "PHY/defs_NB_IoT.h"
#include "PHY/extern.h"
#include "SCHED/defs.h"
#include "SCHED/extern.h"
#include "LAYER2/MAC/defs.h"
#include "LAYER2/MAC/extern.h"
#include "LAYER2/MAC/proto.h"
#include "LAYER2/MAC/defs_nb_iot.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "PHY_INTERFACE/IF_Module_NB_IoT.h"
#include "RRC/LITE/extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
//#include "LAYER2/MAC/pre_processor.c"
#include "pdcp.h"
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif
*/
......
......@@ -19,268 +19,18 @@
* contact@openairinterface.org
*/
/*! \file eNB_scheduler_RA.c
/*! \file eNB_scheduler_RA_NB_IoT.c
* \brief primitives used for random access
* \author Navid Nikaein and Raymond Knopp
* \date 2010 - 2014
* \email: navid.nikaein@eurecom.fr
* \author TaiwanTech
* \date 2017
* \email:
* \version 1.0
* @ingroup _mac
*/
#include "assertions.h"
#include "platform_types.h"
//#include "PHY/defs.h"
//#include "PHY/extern.h"
#include "msc.h"
//#include "SCHED/defs.h"
#include "SCHED/extern_NB_IoT.h"
//#include "LAYER2/MAC/defs.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
//#include "LAYER2/MAC/proto_NB_IoT.h"
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
//#include "UTIL/OPT/opt.h"
//#include "OCG.h"
//#include "OCG_extern.h"
#include "RRC/LITE/proto_NB_IoT.h"
//#include "RRC/LITE/extern.h"
//#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
//NB-IoT
#include "PHY/defs_NB_IoT.h"
#include "proto_NB_IoT.h"
#include "defs_NB_IoT.h"
#include "math.h"
//#include "openair1/PHY/LTE_TRANSPORT/dci_NB_IoT.h"
//#include "LAYER2/MAC/pre_processor.c"
//#include "pdcp.h"
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif
#include "SIMULATION/TOOLS/defs.h" // for taus
#include "T.h"
void schedule_RA_NB_IoT(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP)
{
int CC_id;
eNB_MAC_INST_NB_IoT *eNB = &eNB_mac_inst_NB_IoT[module_idP];
RA_TEMPLATE_NB_IoT *RA_template;
unsigned char i,harq_pid,round;
int16_t rrc_sdu_length;
int UE_id = -1;
unsigned short TBsize = -1;
unsigned short msg4_header;
// start_meas(&eNB->schedule_ra);
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
for (i=0; i<RA_PROC_MAX_NB_IoT; i++) {
RA_template = (RA_TEMPLATE_NB_IoT *)&eNB->common_channels[CC_id].RA_template[i];
if (RA_template->RA_active == TRUE) {
LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d RA %d is active (generate RAR %d, generate_Msg4 %d, wait_ack_Msg4 %d, rnti %x)\n",
module_idP,CC_id,i,RA_template->generate_rar,RA_template->generate_Msg4,RA_template->wait_ack_Msg4, RA_template->rnti);
if (RA_template->generate_rar == 1) {
LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI (proc %d), RA_active %d format 1A (%d,%d))\n",
module_idP, CC_id, frameP, subframeP,i,
RA_template->RA_active,
RA_template->RA_dci_fmt1,
RA_template->RA_dci_size_bits1);
//directly fill DCI Filed base on DCI Nq for RAR
((DCIFormatN1_RAR_t*)&RA_template->RA_alloc_pdu1[0])->type=1;
((DCIFormatN1_RAR_t*)&RA_template->RA_alloc_pdu1[0])->orderIndicator=0;
((DCIFormatN1_RAR_t*)&RA_template->RA_alloc_pdu1[0])->Scheddly=1;//fixed delay approach?
((DCIFormatN1_RAR_t*)&RA_template->RA_alloc_pdu1[0])->ResAssign=0;
((DCIFormatN1_RAR_t*)&RA_template->RA_alloc_pdu1[0])->mcs=0;//fixes?//fixes? base on CE levels?
((DCIFormatN1_RAR_t*)&RA_template->RA_alloc_pdu1[0])->RepNum=0;//fixes? base on CE levels?
// ((DCIFormatN1_RAR_t*)&RA_template->RA_alloc_pdu1[0])->Reserved=0;
((DCIFormatN1_RAR_t*)&RA_template->RA_alloc_pdu1[0])->DCIRep=0;//fixes?
}
//New appoach for CCE allocaton, delete !CCE_allocation_infeasible..
else if (RA_template->generate_Msg4 == 1) {
// check for Msg4 Message
UE_id = find_UE_id_NB_IoT(module_idP,RA_template->rnti);
if (UE_id == -1) { printf("%s:%d:%s: FATAL ERROR\n", __FILE__, __LINE__, __FUNCTION__); abort(); }
if (Is_rrc_registered == 1) {//Fixed mac_rrc_data_req
// Get RRCConnectionSetup for Piggyback
rrc_sdu_length = mac_rrc_data_req_NB_IoT(module_idP,
CC_id,
frameP,
CCCH_NB_IoT,
1, // 1 transport block
&eNB->common_channels[CC_id].CCCH_pdu.payload[0],
ENB_FLAG_YES,
module_idP,
0); // not used in this case
if (rrc_sdu_length == -1) {
mac_xface_NB_IoT->macphy_exit("[MAC][eNB Scheduler] CCCH not allocated\n");
return; // not reached
} else {
//msg("[MAC][eNB %d] Frame %d, subframeP %d: got %d bytes from RRC\n",module_idP,frameP, subframeP,rrc_sdu_length);
}
}
LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, Is_rrc_registered %d, rrc_sdu_length %d\n",
module_idP, CC_id, frameP, subframeP,UE_id, Is_rrc_registered,rrc_sdu_length);
if (rrc_sdu_length>0) {
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RA proc %d, RNTI %x)\n",
module_idP, CC_id, frameP, subframeP,i,RA_template->rnti);
// Compute MCS for 3 PRB
msg4_header = 1+6+1; // CR header, CR CE, SDU header
//need to fixed ndi & msc base on NB-IoT DCI for Msg4
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->ndi=1;
if ((rrc_sdu_length+msg4_header) <= 22) {
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->mcs=4;
TBsize = 22;
} else if ((rrc_sdu_length+msg4_header) <= 28) {
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->mcs=5;
TBsize = 28;
} else if ((rrc_sdu_length+msg4_header) <= 32) {
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->mcs=6;
TBsize = 32;
} else if ((rrc_sdu_length+msg4_header) <= 41) {
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->mcs=7;
TBsize = 41;
} else if ((rrc_sdu_length+msg4_header) <= 49) {
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->mcs=8;
TBsize = 49;
} else if ((rrc_sdu_length+msg4_header) <= 57) {
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->mcs=9;
TBsize = 57;
}
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->type=1;
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->orderIndicator=0;
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->Scheddly=1;//fixed delay approach?
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->ResAssign=5;//fixed depend on mcs/tbs to Nsf
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->RepNum=1;//fixed base on CE levels
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->HARQackRes=0;//Avoid confict multiple Msg ACk
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->DCIRep=0;//fixed base on CE levels
}
}else if (RA_template->wait_ack_Msg4==1) {
// check HARQ status and retransmit if necessary
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 was acknowledged: \n",
module_idP,CC_id,frameP,subframeP);
// Get candidate harq_pid from PHY
mac_xface_NB_IoT->get_ue_active_harq_pid(module_idP,CC_id,RA_template->rnti,frameP,subframeP,&harq_pid,&round,openair_harq_RA_NB_IoT);
if (round>0) {
//RA_template->wait_ack_Msg4++;
// we have to schedule a retransmission
((DCIFormatN1_t*)&RA_template->RA_alloc_pdu2[0])->ndi=1;
// if (!CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,2,RA_template->rnti)) {
// add_ue_spec_dci(DCI_pdu,
// (void*)&RA_template->RA_alloc_pdu2[0],
// RA_template->rnti,
// RA_template->RA_dci_size_bytes2,
// 2,
// RA_template->RA_dci_size_bits2,
// RA_template->RA_dci_fmt2,
// 0);
// printf("MAC: msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", RA_template->rnti, round, frameP, subframeP);
// }
}else
printf("MAC: msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n", RA_template->rnti, round, frameP, subframeP);
LOG_W(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission)\n",
module_idP,CC_id,frameP,subframeP,RA_template->rnti);
} else {
/* msg4 not received
if ((round == 0) && (RA_template->wait_ack_Msg4>1){
remove UE instance across all the layers: mac_xface->cancel_RA();
}
*/
printf("MAC: msg4 acknowledged for rnti %x fsf %d/%d, let's configure it\n", RA_template->rnti, frameP, subframeP);
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n",module_idP,CC_id,frameP,subframeP);
RA_template->wait_ack_Msg4=0;
RA_template->RA_active=FALSE;
UE_id = find_UE_id_NB_IoT(module_idP,RA_template->rnti);
DevAssert( UE_id != -1 );
eNB_mac_inst_NB_IoT[module_idP].UE_list.UE_template[UE_PCCID_NB_IoT(module_idP,UE_id)][UE_id].configured=TRUE;
}
}// RA_active
} // for i=0 .. N_RA_PROC-1
} // CC_id
// stop_meas(&eNB->schedule_ra);
}
/*This function should loop all over the preamble index*/
void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t preamble_index,int16_t timing_offset,sub_frame_t subframeP)
{
uint8_t i;
uint8_t carrier_id = 0;/*The index of the UL carrier associated with the NPRACH, the carrier_id of the anchor carrier is 0*/
RA_TEMPLATE_NB_IoT *RA_template = (RA_TEMPLATE_NB_IoT *)&eNB_mac_inst_NB_IoT[module_idP].common_channels[CC_id].RA_template[0];
/*preamble index will be a subcarrier index (0-47)*/
LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Initiating RA procedure for preamble index %d\n",module_idP,CC_id,frameP,preamble_index);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC,1);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC,0);
/*May up to 48 RA Procdeure MAX at the moment*/
for (i=0; i<RA_PROC_MAX_NB_IoT; i++) {
if (RA_template[i].RA_active==FALSE &&
RA_template[i].wait_ack_Msg4 == 0) {
int loop = 0;
RA_template[i].RA_active=TRUE;
RA_template[i].generate_rar=1;
RA_template[i].generate_Msg4=0;
RA_template[i].wait_ack_Msg4=0;
RA_template[i].timing_offset=timing_offset;
/* TODO: find better procedure to allocate RNTI */
do {
RA_template[i].rnti = taus();
loop++;
} while (loop != 100 &&
/* TODO: this is not correct, the rnti may be in use without
* being in the MAC yet. To be refined.
*/
!(find_UE_id_NB_IoT(module_idP, RA_template[i].rnti) == -1 &&
/* 1024 and 60000 arbirarily chosen, not coming from standard */
RA_template[i].rnti >= 1024 && RA_template[i].rnti < 60000));
if (loop == 100) { printf("%s:%d:%s: FATAL ERROR! contact the authors\n", __FILE__, __LINE__, __FUNCTION__); abort(); }
//RA_template[i].RA_rnti = 1+subframeP+(10*f_id);
/*for NB-IoT, RA_rnti is counted in 36.321 5.1.4*/
RA_template[i].preamble_index = preamble_index;
RA_template[i].RA_rnti = 1+floor(frameP/4)+256*carrier_id;
LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation for process %d, rnti %x, RA_active %d\n",
module_idP,CC_id,frameP,i,RA_template[i].rnti,
RA_template[i].RA_active);
return;
}
}
LOG_E(MAC,"[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n",module_idP,CC_id,frameP,preamble_index);
}
// initiate_ra_proc here
......@@ -19,88 +19,12 @@
* contact@openairinterface.org
*/
/*! \file eNB_scheduler_dlsch.c
/*! \file eNB_scheduler_dlsch_NB_IoT.c
* \brief procedures related to eNB for the DLSCH transport channel
* \author Navid Nikaein and Raymond Knopp
* \date 2010 - 2014
* \author TaiwanTech
* \date 2017
* \email: navid.nikaein@eurecom.fr
* \version 1.0
* @ingroup _mac
*/
//#include "assertions.h"
//#include "PHY/defs.h"
//#include "PHY/extern_NB_IoT.h"
//#include "SCHED/defs.h"
//#include "SCHED/extern.h"
//#include "SCHED/defs_NB_IoT.h"
//#include "SCHED/extern_NB_IoT.h"
//#include "LAYER2/MAC/defs.h"
//#include "LAYER2/MAC/proto.h"
//#include "LAYER2/MAC/extern.h"
#include "UTIL/LOG/log.h"
//#include "UTIL/LOG/vcd_signal_dumper.h"
//#include "UTIL/OPT/opt.h"
//#include "OCG.h"
//#include "OCG_extern.h"
//NB-IoT
//#include "PHY/defs_NB_IoT.h"
//#include "LAYER2/MAC/defs_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
//#include "RRC/LITE/extern_NB_IoT.h"
//#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
//#include "LAYER2/MAC/pre_processor.c"
//#include "pdcp.h"
//#include "COMMON/platform_types.h"
//#include "SIMULATION/TOOLS/defs.h" // for taus
/*
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif
#include "T.h"
*/
#define ENABLE_MAC_PAYLOAD_DEBUG
//#define DEBUG_eNB_SCHEDULER 1
uint8_t *get_dlsch_sdu_NB_IoT(
module_id_t module_idP,
int CC_id,
frame_t frameP,
rnti_t rntiP,
uint8_t TBindex
)
//------------------------------------------------------------------------------
{
int UE_id;
eNB_MAC_INST_NB_IoT *eNB=&eNB_mac_inst_NB_IoT[module_idP];
/*for SIBs*/
if (rntiP==SI_RNTI) {
LOG_D(MAC,"[eNB %d] CC_id %d Frame %d Get DLSCH sdu for BCCH \n", module_idP, CC_id, frameP);
return((unsigned char *)&eNB->common_channels[CC_id].BCCH_pdu.payload[0]);
}
UE_id = find_UE_id_NB_IoT(module_idP,rntiP);
if (UE_id != -1) {
LOG_D(MAC,"[eNB %d] Frame %d: CC_id %d Get DLSCH sdu for rnti %x => UE_id %d\n",module_idP,frameP,CC_id,rntiP,UE_id);
return((unsigned char *)&eNB->UE_list.DLSCH_pdu[CC_id][TBindex][UE_id].payload[0]);
} else {
LOG_E(MAC,"[eNB %d] Frame %d: CC_id %d UE with RNTI %x does not exist\n", module_idP,frameP,CC_id,rntiP);
return NULL;
}
}
......@@ -28,200 +28,3 @@
* @ingroup _mac
*/
//#include "assertions.h"
//#include "PHY/defs.h"
//#include "PHY/extern.h"
//#include "SCHED/defs.h"
//#include "SCHED/extern.h"
//#include "LAYER2/MAC/defs.h"
//#include "LAYER2/MAC/extern.h"
//#include "LAYER2/MAC/proto.h"
#include "UTIL/LOG/log.h"
//#include "UTIL/LOG/vcd_signal_dumper.h"
//#include "UTIL/OPT/opt.h"
//#include "OCG.h"
//#include "OCG_extern.h"
#include "RRC/LITE/proto_NB_IoT.h"
//#include "RRC/LITE/extern.h"
//#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
//NB-IoT
//#include "PHY/defs_NB_IoT.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
#include "LAYER2/MAC/vars_NB_IoT.h" //////////////////// to comment during test
//#include "openair2/COMMON/platform_types.h"
//#include "LAYER2/MAC/pre_processor.c"
//#include "pdcp.h"
/*
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif
*/
//#define ENABLE_MAC_PAYLOAD_DEBUG
//#define DEBUG_eNB_SCHEDULER 1
/*TODO NB_mac_phy_remove_ue*/
//------------------------------------------------------------------------------
int find_UE_id_NB_IoT(module_id_t mod_idP, rnti_t rntiP)
//------------------------------------------------------------------------------
{
int UE_id;
UE_list_NB_IoT_t *UE_list = &eNB_mac_inst_NB_IoT[mod_idP].UE_list;
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX_NB_IoT; UE_id++) {
if (UE_list->active[UE_id] != TRUE) continue;
if (UE_list->UE_template[UE_PCCID_NB_IoT(mod_idP,UE_id)][UE_id].rnti==rntiP) {
return(UE_id);
}
}
return(-1);
}
//------------------------------------------------------------------------------
int UE_PCCID_NB_IoT(module_id_t mod_idP,int ue_idP)
//------------------------------------------------------------------------------
{
return(eNB_mac_inst_NB_IoT[mod_idP].UE_list.pCC_id[ue_idP]);
}
//------------------------------------------------------------------------------
rnti_t UE_RNTI_NB_IoT(module_id_t mod_idP, int ue_idP)
//------------------------------------------------------------------------------
{
rnti_t rnti = eNB_mac_inst_NB_IoT[mod_idP].UE_list.UE_template[UE_PCCID_NB_IoT(mod_idP,ue_idP)][ue_idP].rnti;
if (rnti>0) {
return (rnti);
}
LOG_D(MAC,"[eNB %d] Couldn't find RNTI for UE %d\n",mod_idP,ue_idP);
//display_backtrace();
return(NOT_A_RNTI);
}
int add_new_ue_NB_IoT(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP)
{
int UE_id;
int i, j;
UE_list_NB_IoT_t *UE_list = &eNB_mac_inst_NB_IoT[mod_idP].UE_list;
LOG_D(MAC,"[eNB %d, CC_id %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",mod_idP,cc_idP,rntiP,UE_list->avail,UE_list->num_UEs);
dump_ue_list_NB_IoT(UE_list,0);
for (i = 0; i < NUMBER_OF_UE_MAX_NB_IoT; i++) {
if (UE_list->active[i] == TRUE) continue;
printf("MAC: new UE id %d rnti %x\n", i, rntiP);
UE_id = i;
UE_list->UE_template[cc_idP][UE_id].rnti = rntiP;
UE_list->UE_template[cc_idP][UE_id].configured = FALSE;
UE_list->numactiveCCs[UE_id] = 1;
UE_list->numactiveULCCs[UE_id] = 1;
UE_list->pCC_id[UE_id] = cc_idP;
UE_list->ordered_CCids[0][UE_id] = cc_idP;
UE_list->ordered_ULCCids[0][UE_id] = cc_idP;
UE_list->num_UEs++;
UE_list->active[UE_id] = TRUE;
memset((void*)&UE_list->UE_sched_ctrl[UE_id],0,sizeof(UE_sched_ctrl_NB_IoT));
for (j=0; j<8; j++) {
UE_list->UE_template[cc_idP][UE_id].oldNDI[j] = (j==0)?1:0; // 1 because first transmission is with format1A (Msg4) for harq_pid 0
UE_list->UE_template[cc_idP][UE_id].oldNDI_UL[j] = (j==harq_pidP)?0:1; // 1st transmission is with Msg3;
}
eNB_ulsch_info_NB_IoT[mod_idP][cc_idP][UE_id].status = S_UL_WAITING_NB_IoT;
eNB_dlsch_info_NB_IoT[mod_idP][cc_idP][UE_id].status = S_DL_WAITING_NB_IoT;
LOG_D(MAC,"[eNB %d] Add UE_id %d on Primary CC_id %d: rnti %x\n",mod_idP,UE_id,cc_idP,rntiP);
dump_ue_list_NB_IoT(UE_list,0);
return(UE_id);
}
printf("MAC: cannot add new UE for rnti %x\n", rntiP);
LOG_E(MAC,"error in add_new_ue(), could not find space in UE_list, Dumping UE list\n");
dump_ue_list_NB_IoT(UE_list,0);
return(-1);
}
//--------------------------------------------------------------------------------------------------------
int rrc_mac_remove_ue_NB_IoT(
module_id_t mod_idP,
rnti_t rntiP)
{
int i;
UE_list_NB_IoT_t *UE_list = &eNB_mac_inst_NB_IoT[mod_idP].UE_list;
int UE_id = find_UE_id_NB_IoT(mod_idP,rntiP); //may should be changed
int pCC_id;
if (UE_id == -1) {
printf("MAC: cannot remove UE rnti %x\n", rntiP);
LOG_W(MAC,"rrc_mac_remove_ue_NB_IoT: UE %x not found\n", rntiP);
//NB_mac_phy_remove_ue(mod_idP, rntiP);
return 0;
}
pCC_id = UE_PCCID_NB_IoT(mod_idP,UE_id);
printf("MAC: remove UE %d rnti %x\n", UE_id, rntiP);
LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP);
//dump_ue_list(UE_list,0); //may should be changed
UE_list->active[UE_id] = FALSE;
UE_list->num_UEs--;
// clear all remaining pending transmissions no lcgid in NB-IoT
/*UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID0] = 0;
UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID1] = 0;
UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID2] = 0;
UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID3] = 0;*/
//UE_list->UE_template[pCC_id][UE_id].ul_SR = 0;
UE_list->UE_template[pCC_id][UE_id].rnti = NOT_A_RNTI;
UE_list->UE_template[pCC_id][UE_id].ul_active = FALSE;
eNB_ulsch_info_NB_IoT[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_ulsch_info_NB_IoT[mod_idP][pCC_id][UE_id].status = S_UL_NONE_NB_IoT;
eNB_dlsch_info_NB_IoT[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_dlsch_info_NB_IoT[mod_idP][pCC_id][UE_id].status = S_DL_NONE_NB_IoT;
//NB_mac_phy_remove_ue(mod_idP,rntiP);
// check if this has an RA process active
RA_TEMPLATE_NB_IoT *RA_template;
for (i=0;i<RA_PROC_MAX_NB_IoT;i++) {
RA_template = (RA_TEMPLATE_NB_IoT *)&eNB_mac_inst_NB_IoT[mod_idP].common_channels[pCC_id].RA_template[i];
if (RA_template->rnti == rntiP){
RA_template->RA_active=FALSE;
RA_template->generate_rar=0;
RA_template->generate_Msg4=0;
RA_template->wait_ack_Msg4=0;
RA_template->timing_offset=0;
RA_template->RRC_timer=20;
RA_template->rnti = 0;
//break;
}
}
return 0;
}
//------------------------------------------------------------------------------
DCI_PDU_NB_IoT *get_dci_sdu_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, sub_frame_t subframeP)
//------------------------------------------------------------------------------
{
return(&eNB_mac_inst_NB_IoT[module_idP].common_channels[CC_id].DCI_pdu);
}
//NB_UL_failure_indication... some of the used primitive haven't defined
......@@ -29,483 +29,4 @@
*/
//#include "assertions.h"
//#include "PHY/defs.h"
//#include "PHY/extern.h"
#include "PHY/extern_NB_IoT.h"
//#include "SCHED/defs.h"
//#include "SCHED/extern.h"
//#include "LAYER2/MAC/defs.h"
//#include "LAYER2/MAC/proto.h"
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h" // for trace_pdu() function , description is in probe.c
//#include "OCG.h"
//#include "OCG_extern.h"
//#include "RRC/LITE/extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
//NB-IoT
//#include "PHY/defs_NB_IoT.h"
//#include "LAYER2/MAC/defs_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
#include "RRC/LITE/defs_NB_IoT.h"
//#include "LAYER2/MAC/pre_processor.c"
//#include "pdcp.h"
//#if defined(ENABLE_ITTI)
//# include "intertask_interface.h"
//#endif
#include "T.h"
#define ENABLE_MAC_PAYLOAD_DEBUG
//#define DEBUG_eNB_SCHEDULER 1
unsigned char *parse_ulsch_header_NB_IoT(unsigned char *mac_header,
unsigned char *num_ce,
unsigned char *num_sdu,
unsigned char *rx_ces,
unsigned char *rx_lcids,
unsigned short *rx_lengths,
unsigned short tb_length)
{
//MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
unsigned char not_done=1,num_ces=0,num_sdus=0,lcid,num_sdu_cnt;
unsigned char *mac_header_ptr = mac_header;
unsigned short length, ce_len=0;
while (not_done==1) {
if (((SCH_SUBHEADER_FIXED_NB_IoT*)mac_header_ptr)->E == 0) {
not_done = 0;
}
lcid = ((SCH_SUBHEADER_FIXED_NB_IoT *)mac_header_ptr)->LCID;
if (lcid < EXTENDED_POWER_HEADROOM_NB_IoT) {
if (not_done==0) { // last MAC SDU, length is implicit
mac_header_ptr++;
length = tb_length-(mac_header_ptr-mac_header)-ce_len;
for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) {
length -= rx_lengths[num_sdu_cnt];
}
} else {
if (((SCH_SUBHEADER_SHORT_NB_IoT *)mac_header_ptr)->F == 0) {
length = ((SCH_SUBHEADER_SHORT_NB_IoT *)mac_header_ptr)->L;
mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT);
} else { // F = 1
length = ((((SCH_SUBHEADER_LONG_NB_IoT *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG_NB_IoT *)mac_header_ptr)->L_LSB & 0xff);
mac_header_ptr += 3;//sizeof(SCH_SUBHEADER_LONG);
}
}
LOG_D(MAC,"[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n",
num_sdus,lcid,tb_length, length,mac_header_ptr-mac_header);
rx_lcids[num_sdus] = lcid;
rx_lengths[num_sdus] = length;
num_sdus++;
} else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI
if (lcid == SHORT_PADDING_NB_IoT) {
mac_header_ptr++;
} else {
rx_ces[num_ces] = lcid;
num_ces++;
mac_header_ptr++;
if (lcid==LONG_BSR_NB_IoT) {
ce_len+=3;
} else if (lcid==CRNTI_NB_IoT) {
ce_len+=2;
} else if ((lcid==POWER_HEADROOM_NB_IoT) || (lcid==TRUNCATED_BSR_NB_IoT)|| (lcid== SHORT_BSR_NB_IoT)) {
ce_len++;
} else {
LOG_E(MAC,"unknown CE %d \n", lcid);
mac_xface_NB_IoT->macphy_exit("unknown CE");
}
}
}
}
*num_ce = num_ces;
*num_sdu = num_sdus;
return(mac_header_ptr);
}
void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
const int CC_idP,
const frame_t frameP,
const sub_frame_t subframeP,
const rnti_t rntiP,
uint8_t *sduP,
const uint16_t sdu_lenP,
const int harq_pidP
)
{
unsigned char rx_ces[MAX_NUM_CE_NB_IoT],num_ce,num_sdu,i,*payload_ptr;
unsigned char rx_lcids[NB_RB_MAX];//for NB-IoT, NB_RB_MAX should be fixed to 5 (2 DRB+ 3SRB)
unsigned short rx_lengths[NB_RB_MAX];
int UE_id = find_UE_id_NB_IoT(enb_mod_idP,rntiP);
int ii,j;
eNB_MAC_INST_NB_IoT *eNB = &eNB_mac_inst_NB_IoT[enb_mod_idP];
UE_list_NB_IoT_t *UE_list= &eNB->UE_list;
int crnti_rx=0;
//int old_buffer_info;
start_meas(&eNB->rx_ulsch_sdu_NB_IoT);
/*if there is an error for UE_id> max or UE_id==-1, set rx_lengths to 0*/
if ((UE_id > NUMBER_OF_UE_MAX_NB_IoT) || (UE_id == -1) )
for(ii=0; ii<NB_RB_MAX; ii++) {
rx_lengths[ii] = 0;
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,1);
if (opt_enabled == 1) {
trace_pdu(0, sduP,sdu_lenP, 0, 3, rntiP, frameP, subframeP, 0,0);
LOG_D(OPT,"[eNB %d][ULSCH] Frame %d rnti %x with size %d\n",
enb_mod_idP, frameP, rntiP, sdu_lenP);
}
LOG_D(MAC,"[eNB %d] CC_id %d Received ULSCH sdu from PHY (rnti %x, UE_id %d), parsing header\n",enb_mod_idP,CC_idP,rntiP,UE_id);
if (sduP==NULL) { // we've got an error after N rounds
UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pidP)); //ul_scheduled: A kind of resource scheduling information
return;
}
if (UE_id!=-1) {
UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer=0;
UE_list->UE_sched_ctrl[UE_id].ul_failure_timer =0;
UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pidP));
/*RLF procedure this part just check UE context is NULL or not, if not, means UL in synch*/
if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) {
UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0;
mac_eNB_rrc_ul_in_sync_NB_IoT(enb_mod_idP,CC_idP,frameP,subframeP,UE_RNTI_NB_IoT(enb_mod_idP,UE_id));
}
}
payload_ptr = parse_ulsch_header_NB_IoT(sduP,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_lenP);
T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu));
T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP));
eNB->eNB_stats[CC_idP].ulsch_bytes_rx=sdu_lenP;
eNB->eNB_stats[CC_idP].total_ulsch_bytes_rx+=sdu_lenP;
eNB->eNB_stats[CC_idP].total_ulsch_pdus_rx+=1;
// control element
for (i=0; i<num_ce; i++) {
T(T_ENB_MAC_UE_UL_CE, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
T_INT(rx_ces[i]));
/*rx_ces = lcid in parse_ulsch_header() if not short padding*/
switch (rx_ces[i]) { // implement and process BSR + CRNTI + PHR
case POWER_HEADROOM_NB_IoT:
if (UE_id != -1) {
UE_list->UE_template[CC_idP][UE_id].phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET_NB_IoT;
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n",
enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].phr_info);
UE_list->UE_template[CC_idP][UE_id].phr_info_configured=1;
UE_list->UE_sched_ctrl[UE_id].phr_received = 1;
}
payload_ptr+=sizeof(POWER_HEADROOM_CMD_NB_IoT);
break;
case CRNTI_NB_IoT:
UE_id = find_UE_id_NB_IoT(enb_mod_idP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]);
LOG_I(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n",
frameP,subframeP,enb_mod_idP, CC_idP, rx_ces[i], i,num_ce,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1],UE_id);
if (UE_id!=-1) {
UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer=0;
UE_list->UE_sched_ctrl[UE_id].ul_failure_timer=0;
if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) {
UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0;
/*In RRC branch*/
//mac_eNB_rrc_ul_in_sync_NB_IoT(enb_mod_idP,CC_idP,frameP,subframeP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]);
}
}
crnti_rx=1;
payload_ptr+=2;
break;
/*For this moment, long bsr is not processed in the case*/
//case TRUNCATED_BSR:
/*DV lcid =???*/
//case DATA_VOLUME_INDICATOR
case SHORT_BSR_NB_IoT: {
uint8_t lcgid;
lcgid = (payload_ptr[0] >> 6);
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n",
enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f);
if (crnti_rx==1)
LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n",
enb_mod_idP, CC_idP, rx_ces[i], lcgid, payload_ptr[0] & 0x3f);
if (UE_id != -1) {
UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid] = (payload_ptr[0] & 0x3f);
// update buffer info
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]=BSR_TABLE_NB_IoT[UE_list->UE_template[CC_idP][UE_id].bsr_info[lcgid]];
UE_list->UE_template[CC_idP][UE_id].ul_total_buffer= UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid];
PHY_vars_eNB_NB_IoT_g[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP] = (payload_ptr[0] & 0x3f);
if (UE_id == UE_list->head)
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR,PHY_vars_eNB_NB_IoT_g[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP*10)+subframeP]);
if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] == 0 ) {
UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid]=frameP;
}
if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI_NB_IoT(enb_mod_idP,UE_id)) < RRC_CONNECTED_NB_IoT)
LOG_I(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : ul_total_buffer = %d (lcg increment %d)\n",
enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].ul_total_buffer,
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]);
}
else {
}
payload_ptr += 1;//sizeof(SHORT_BSR_NB_IoT); // fixme
}
break;
default:
LOG_E(MAC, "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n", enb_mod_idP, CC_idP, rx_ces[i]);
break;
}
for (i=0; i<num_sdu; i++) {
LOG_D(MAC,"SDU Number %d MAC Subheader SDU_LCID %d, length %d\n",i,rx_lcids[i],rx_lengths[i]);
T(T_ENB_MAC_UE_UL_SDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
T_INT(rx_lcids[i]), T_INT(rx_lengths[i]));
T(T_ENB_MAC_UE_UL_SDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
T_INT(rx_lcids[i]), T_INT(rx_lengths[i]), T_BUFFER(payload_ptr, rx_lengths[i]));
switch (rx_lcids[i]) {
case CCCH_NB_IoT :
if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX_NB_IoT) {
LOG_E(MAC, "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d), dropping packet\n",
enb_mod_idP, CC_idP, frameP, rx_lengths[i], CCCH_PAYLOAD_SIZE_MAX_NB_IoT);
break;
}
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n",
enb_mod_idP,CC_idP,frameP,
payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4], payload_ptr[5], rntiP);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,1);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,0);
for (ii=0; ii<RA_PROC_MAX_NB_IoT; ii++) {
LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), active %d\n",
enb_mod_idP, CC_idP, ii,
eNB->common_channels[CC_idP].RA_template[ii].rnti, rntiP,
eNB->common_channels[CC_idP].RA_template[ii].RA_active);
if ((eNB->common_channels[CC_idP].RA_template[ii].rnti==rntiP) &&
(eNB->common_channels[CC_idP].RA_template[ii].RA_active==TRUE)) {
//payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len);
if (UE_id < 0) {
memcpy(&eNB->common_channels[CC_idP].RA_template[ii].cont_res_id[0],payload_ptr,6);
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n",
enb_mod_idP,CC_idP,frameP,rx_lengths[i],payload_ptr-sduP);
if ((UE_id=add_new_ue_NB_IoT(enb_mod_idP,CC_idP,eNB->common_channels[CC_idP].RA_template[ii].rnti,harq_pidP)) == -1 ) {
mac_xface_NB_IoT->macphy_exit("[MAC][eNB] Max user count reached\n");
// kill RA procedure
} else
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n",
enb_mod_idP,CC_idP,frameP,eNB->common_channels[CC_idP].RA_template[ii].rnti,UE_id);
} else {
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n",
enb_mod_idP,CC_idP,frameP,UE_id,rx_lengths[i],payload_ptr-sduP);
// kill RA procedure
}
if (Is_rrc_registered_NB_IoT == 1)
//MP: send directly the information to the RRC in case of CCCH (SRB0)
mac_rrc_data_ind_eNB_NB_IoT(
enb_mod_idP,
CC_idP,
frameP,
subframeP,
rntiP,
CCCH_NB_IoT,
(uint8_t*)payload_ptr,
rx_lengths[i]);
if (num_ce >0) { // handle msg3 which is not RRCConnectionRequest
// process_ra_message(msg3,num_ce,rx_lcids,rx_ces);
}
eNB->common_channels[CC_idP].RA_template[ii].generate_Msg4 = 1;
eNB->common_channels[CC_idP].RA_template[ii].wait_ack_Msg4 = 0;
} // if process is active
} // loop on RA processes
break ;
/*DCCH0 is for SRB1bis, DCCH1 is for SRB1*/
case DCCH0_NB_IoT :
case DCCH1_NB_IoT :
// if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sduP));
for (j=0; j<32; j++) {
LOG_T(MAC,"%x ",payload_ptr[j]);
}
LOG_T(MAC,"\n");
#endif
if (UE_id != -1) {
/*NO lcg in NB-IoT, anyway set to 0*/
// adjust buffer occupancy of the correponding logical channel group
/*if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i])
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i];
else
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0;*/
LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n",
enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]);
mac_rlc_data_ind_NB_IoT(
enb_mod_idP,
rntiP,
enb_mod_idP,
frameP,
ENB_FLAG_YES,
rx_lcids[i],
(char *)payload_ptr,
rx_lengths[i],
1,
NULL);//(unsigned int*)crc_status);*/
UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1;
UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i];
} /* UE_id != -1 */
// }
break;
// all the DRBS
case DTCH0_NB_IoT:
default :
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sduP));
for (j=0; j<32; j++) {
LOG_T(MAC,"%x ",payload_ptr[j]);
}
LOG_T(MAC,"\n");
#endif
if (rx_lcids[i] < NB_RB_MAX ) {
LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n",
enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id, rx_lcids[i]);
if (UE_id != -1) {
// adjust buffer occupancy of the correponding logical channel group
LOG_D(MAC,"[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n",
enb_mod_idP,CC_idP,frameP, rx_lengths[i], UE_id,rx_lcids[i]);
/*if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i])
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i];
else
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0;*/
if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX_NB_IoT) && (rx_lengths[i] > 0) ) { // MAX SIZE OF transport block
mac_rlc_data_ind_NB_IoT(
enb_mod_idP,
rntiP,
enb_mod_idP,
frameP,
ENB_FLAG_YES,
rx_lcids[i],
(char *)payload_ptr,
rx_lengths[i],
1,
NULL);//(unsigned int*)crc_status);*/
UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]]+=1;
UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i];
}
else { /* rx_length[i] */
UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx+=1;
LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ",
enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id);
}
}
else {/*(UE_id != -1*/
LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ",
enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id);
}
}
break;
}
payload_ptr+=rx_lengths[i];
}
/* NN--> FK: we could either check the payload, or use a phy helper to detect a false msg3 */
if ((num_sdu == 0) && (num_ce==0)) {
if (UE_id != -1)
UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_errors_rx+=1;
} else {
if (UE_id != -1) {
UE_list->eNB_UE_stats[CC_idP][UE_id].pdu_bytes_rx=sdu_lenP;
UE_list->eNB_UE_stats[CC_idP][UE_id].total_pdu_bytes_rx+=sdu_lenP;
UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_pdus_rx+=1;
}
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,0);
stop_meas(&eNB->rx_ulsch_sdu_NB_IoT);
}
}
/* This function is called by PHY layer when it schedules some
* uplink for a random access message 3.
* The MAC scheduler has to skip the RBs used by this message 3
* (done below in schedule_ulsch).
*/
void set_msg3_subframe_NB_IoT(module_id_t Mod_id,
int CC_id,
int frame,
int subframe,
int rnti,
int Msg3_frame,
int Msg3_subframe)
{
eNB_MAC_INST_NB_IoT *eNB=&eNB_mac_inst_NB_IoT[Mod_id];
int i;
for (i=0; i<RA_PROC_MAX_NB_IoT; i++) {
if (eNB->common_channels[CC_id].RA_template[i].RA_active == TRUE &&
eNB->common_channels[CC_id].RA_template[i].rnti == rnti) {
eNB->common_channels[CC_id].RA_template[i].Msg3_subframe = Msg3_subframe;
break;
}
}
}
......@@ -39,32 +39,9 @@
int mac_init_global_param_NB_IoT(void)
{
//XXX commented parts are called in the parallel path of OAI
// Mac_rlc_xface = NULL;
// LOG_I(MAC,"[MAIN] CALLING RLC_MODULE_INIT...\n");
//
if (rlc_module_init()!=0) {
return(-1);
}
//
// LOG_I(MAC,"[MAIN] RLC_MODULE_INIT OK, malloc16 for mac_rlc_xface...\n");
//
// Mac_rlc_xface = (MAC_RLC_XFACE*)malloc16(sizeof(MAC_RLC_XFACE));
// bzero(Mac_rlc_xface,sizeof(MAC_RLC_XFACE));
//
// if(Mac_rlc_xface == NULL) {
// LOG_E(MAC,"[MAIN] FATAL EROOR: Could not allocate memory for Mac_rlc_xface !!!\n");
// return (-1);
//
// }
//
// LOG_I(MAC,"[MAIN] malloc16 OK, mac_rlc_xface @ %p\n",(void *)Mac_rlc_xface);
//
// mac_xface->mrbch_phy_sync_failure=mrbch_phy_sync_failure;
// mac_xface->dl_phy_sync_success=dl_phy_sync_success;
// mac_xface->out_of_sync_ind=rrc_out_of_sync_ind;
//
// LOG_I(MAC,"[MAIN] RLC interface (mac_rlc_xface) setup and init (maybe no mre used??)\n");
LOG_I(MAC,"[MAIN] RRC NB-IoT initialization of global params\n");
rrc_init_global_param_NB_IoT();
......@@ -76,116 +53,15 @@ int mac_init_global_param_NB_IoT(void)
#else
pdcp_module_init ();
#endif
//
// LOG_I(MAC,"[MAIN] Init Global Param Done\n");
return 0;
}
// Initial function of the intialization for NB-IoT MAC
int mac_top_init_NB_IoT()
{
module_id_t Mod_id,i,j;
RA_TEMPLATE_NB_IoT *RA_template;
UE_TEMPLATE_NB_IoT *UE_template;
int size_bytes1,size_bytes2,size_bits1,size_bits2;
int CC_id;
int list_el;
UE_list_NB_IoT_t *UE_list; //XXX to review if elements are correct
// delete the part to init the UE_INST
//XXX NB_eNB_INST is global and set in lte-softmodem = 1 always (should be modified???)
LOG_I(MAC,"[MAIN] Init function start:Nb_eNB_INST=%d\n",NB_eNB_INST);
if (NB_eNB_INST>0) {
eNB_mac_inst_NB_IoT = (eNB_MAC_INST_NB_IoT*)malloc16(NB_eNB_INST*sizeof(eNB_MAC_INST_NB_IoT));
if (eNB_mac_inst_NB_IoT == 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_IoT*),NB_eNB_INST,sizeof(eNB_MAC_INST_NB_IoT));
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_IoT),NB_eNB_INST,eNB_mac_inst_NB_IoT);
bzero(eNB_mac_inst_NB_IoT,NB_eNB_INST*sizeof(eNB_MAC_INST_NB_IoT));
}
} else {
LOG_I (MAC, "No instance allocated for the MAC layer (NB-IoT)\n");
eNB_mac_inst_NB_IoT = NULL;
}
// Initialize Linked-List for Active UEs
for(Mod_id=0; Mod_id<NB_eNB_INST; Mod_id++) {
UE_list = &eNB_mac_inst_NB_IoT[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_NB_IoT-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;
}
if (Is_rrc_registered_NB_IoT == 1) {
LOG_I(MAC,"[MAIN] calling RRC NB-IoT\n");
#ifndef CELLULAR //nothing to be done yet for cellular
openair_rrc_top_init_eNB_NB_IoT();
#endif
} else {
LOG_I(MAC,"[MAIN] Running without an RRC\n");
}
// 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 (NB-IoT)\n",i, CC_id);
LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_eNB][MOD %02d][]\n", i);
RA_template = (RA_TEMPLATE_NB_IoT *)&eNB_mac_inst_NB_IoT[i].common_channels[CC_id].RA_template[0];
for (j=0; j<RA_PROC_MAX_NB_IoT; 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; //for MSG4
}
memset (&eNB_mac_inst_NB_IoT[i].eNB_stats,0,sizeof(eNB_STATS_NB_IoT));
UE_template = (UE_TEMPLATE_NB_IoT *)&eNB_mac_inst_NB_IoT[i].UE_list.UE_template[CC_id][0];
for (j=0; j<NUMBER_OF_UE_MAX_NB_IoT; j++) {
UE_template[j].rnti=0;
// initiallize the eNB to UE statistics
memset (&eNB_mac_inst_NB_IoT[i].UE_list.eNB_UE_stats[CC_id][j],0,sizeof(eNB_UE_STATS_NB_IoT));
}
}
//ICIC not used
LOG_I(MAC,"[MAIN][INIT][NB-IoT] Init function finished\n");
return(0);
}
......
......@@ -39,103 +39,4 @@
/*for NB-IoT*/
/* \brief Function to indicate a received SDU on ULSCH for NB-IoT.
*/
void rx_sdu_NB_IoT(const module_id_t module_idP, const int CC_id,const frame_t frameP, const sub_frame_t subframeP, const rnti_t rnti, uint8_t *sdu, const uint16_t sdu_len, const int harq_pid);
/* \brief Function to retrieve result of scheduling (DCI) in current subframe. Can be called an arbitrary numeber of times after eNB_dlsch_ulsch_scheduler
in a given subframe.
*/
DCI_PDU_NB_IoT *get_dci_sdu_NB_IoT(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframe);
/* \brief Function to trigger the eNB scheduling procedure. It is called by PHY at the beginning of each subframe, \f$n$\f
and generates all DLSCH allocations for subframe \f$n\f$ and ULSCH allocations for subframe \f$n+k$\f. The resultant DCI_PDU is
ready after returning from this call.
*/
void eNB_dlsch_ulsch_scheduler_NB_IoT(module_id_t module_idP, uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP);
/* \brief Function to indicate a received preamble on PRACH. It initiates the RA procedure.
In NB-IoT, it indicate preamble using the frequency to indicate the preamble.
*/
void schedule_RA_NB_IoT(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP);
void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t preamble_index,int16_t timing_offset,sub_frame_t subframeP);
uint8_t *get_dlsch_sdu_NB_IoT(module_id_t module_idP,int CC_id,frame_t frameP,rnti_t rnti,uint8_t TBindex);
int rrc_mac_remove_ue_NB_IoT(module_id_t Mod_id, rnti_t rntiP);
int l2_init_eNB_NB_IoT(void);
int mac_init_global_param_NB_IoT(void);
int mac_top_init_NB_IoT(void);
int find_UE_id_NB_IoT (module_id_t module_idP, rnti_t rnti) ;
int UE_PCCID_NB_IoT (module_id_t module_idP, int UE_id);
rnti_t UE_RNTI_NB_IoT (module_id_t module_idP, int UE_id);
/*! \fn UE_L2_state_t ue_scheduler(const module_id_t module_idP,const frame_t frameP, const sub_frame_t subframe, const lte_subframe_t direction,const uint8_t eNB_index)
\brief UE scheduler where all the ue background tasks are done. This function performs the following: 1) Trigger PDCP every 5ms 2) Call RRC for link status return to PHY3) Perform SR/BSR procedures for scheduling feedback 4) Perform PHR procedures.
\param[in] module_idP instance of the UE
\param[in] rxFrame the RX frame number
\param[in] rxSubframe the RX subframe number
\param[in] txFrame the TX frame number
\param[in] txSubframe the TX subframe number
\param[in] direction subframe direction
\param[in] eNB_index instance of eNB
@returns L2 state (CONNETION_OK or CONNECTION_LOST or PHY_RESYNCH)
*/
UE_L2_STATE_NB_IoT_t ue_scheduler_NB_IoT(
const module_id_t module_idP,
const frame_t rxFrameP,
const sub_frame_t rxSubframe,
const frame_t txFrameP,
const sub_frame_t txSubframe,
const NB_IoT_subframe_t direction,
const uint8_t eNB_index,
const int CC_id);
/* \brief Function used by PHY to inform MAC that an uplink is scheduled
for Msg3 in given subframe. This is used so that the MAC
scheduler marks as busy the RBs used by the Msg3.
@param Mod_id Instance ID of eNB
@param CC_id CC ID of eNB
@param frame current frame
@param subframe current subframe
@param rnti UE rnti concerned
@param Msg3_frame frame where scheduling takes place
@param Msg3_subframe subframe where scheduling takes place
*/
void set_msg3_subframe_NB_IoT(module_id_t Mod_id,
int CC_id,
int frame,
int subframe,
int rnti,
int Msg3_frame,
int Msg3_subframe);
/* \brief Parse header for UL-SCH. This function parses the received UL-SCH header as described
in 36-321 MAC layer specifications. It returns the number of bytes used for the header to be used as an offset for the payload
in the ULSCH buffer.
@param mac_header Pointer to the first byte of the MAC header (UL-SCH buffer)
@param num_ces Number of SDUs in the payload
@param num_sdu Number of SDUs in the payload
@param rx_ces Pointer to received CEs in the header
@param rx_lcids Pointer to array of LCIDs (the order must be the same as the SDU length array)
@param rx_lengths Pointer to array of SDU lengths
@returns Pointer to payload following header
*/
uint8_t *parse_ulsch_header_NB_IoT(uint8_t *mac_header,
uint8_t *num_ce,
uint8_t *num_sdu,
uint8_t *rx_ces,
uint8_t *rx_lcids,
uint16_t *rx_lengths,
uint16_t tx_lenght);
int add_new_ue_NB_IoT(module_id_t Mod_id, int CC_id, rnti_t rnti,int harq_pid);
//void dump_ue_list_NB_IoT(UE_list_t *listP, int ul_flag);
#endif
......@@ -54,14 +54,6 @@
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
#include "openair1/SCHED/IF_Module_L1_primitives_NB_IoT.h"
/*
#ifdef PHY_EMUL
#include "SIMULATION/simulation_defs.h"
extern EMULATION_VARS *Emul_vars;
extern eNB_MAC_INST *eNB_mac_inst;
extern UE_MAC_INST *UE_mac_inst;
#endif
*/
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif
......@@ -88,7 +80,7 @@ extern unsigned int pdcp_eNB_UE_instance_to_rnti_index;
extern rnti_t pdcp_eNB_UE_instance_to_rnti[NUMBER_OF_UE_MAX_NB_IoT];
extern list_t pdcp_sdu_list;
//extern struct mac_data_req rlc_am_mac_data_request (const protocol_ctxt_t* const ctxtP,void * const rlc_pP);
//extern eNB_MAC_INST_NB_IoT *eNB;
extern void rlc_tm_init ( const protocol_ctxt_t* const ctxt_pP, rlc_tm_entity_t * const rlcP);
extern void rlc_tm_set_debug_infos(
const protocol_ctxt_t* const ctxt_pP,
......@@ -583,8 +575,8 @@ int rrc_mac_config_req_eNB_NB_IoT(
int UE_id = -1;
//UE_list_NB_IoT_t *UE_list= &eNB_mac_inst_NB_IoT->UE_list;
UE_id = find_UE_id_NB_IoT(Mod_idP, rntiP);
//find ue_id here
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN);
......@@ -604,8 +596,8 @@ int rrc_mac_config_req_eNB_NB_IoT(
//if(eNB_mac_inst == NULL) l2_init_eNB(); //TODO MP: to be included in the MAC/main.c
//mac_top_init_eNB(); //TODO MP: to be included in the MAC/main.c
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].mib_NB_IoT = mib_NB_IoT;
// add common channels parameters
/*eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].mib_NB_IoT = mib_NB_IoT;
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].physCellId = physCellId;
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].p_eNB = p_eNB;
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].p_rx_eNB = p_rx_eNB;
......@@ -613,7 +605,7 @@ int rrc_mac_config_req_eNB_NB_IoT(
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].Ncp_UL = Ncp_UL;
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].eutra_band = eutra_band;
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].dl_CarrierFreq = dl_CarrierFreq;
*/
LOG_I(MAC,
"Configuring MIB for instance %d, CCid %d : (band %ld,Nid_cell %d,TX antenna port (p) %d,DL freq %u\n",
Mod_idP,
......@@ -665,9 +657,9 @@ int rrc_mac_config_req_eNB_NB_IoT(
LOG_I(MAC,"[CONFIG]npusch_ConfigCommon_r13.ul_ReferenceSignalsNPUSCH_r13.groupAssignmentNPUSCH_r13= %ld\n", radioResourceConfigCommon->npusch_ConfigCommon_r13.ul_ReferenceSignalsNPUSCH_r13.groupAssignmentNPUSCH_r13);
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].radioResourceConfigCommon = radioResourceConfigCommon;
//eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].radioResourceConfigCommon = radioResourceConfigCommon;
if (ul_CarrierFreq>0)
eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].ul_CarrierFreq = ul_CarrierFreq;
//eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].ul_CarrierFreq = ul_CarrierFreq;
config_sib2_fapi_NB_IoT(physCellId,radioResourceConfigCommon);
......@@ -712,9 +704,9 @@ int rrc_mac_config_req_eNB_NB_IoT(
}
//Now trigger the phy_config_xxx for configuring PHY through the PHY_config_req
AssertFatal(if_inst->PHY_config_req != NULL, "rrc_mac_config_req_eNB_NB_IoT: PHY_config_req pointer function is NULL\n");
/*AssertFatal(if_inst->PHY_config_req != NULL, "rrc_mac_config_req_eNB_NB_IoT: PHY_config_req pointer function is NULL\n");
if(if_inst->PHY_config_req)
if_inst->PHY_config_req(config_INFO);
if_inst->PHY_config_req(config_INFO);*/
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
......@@ -1100,7 +1092,6 @@ int8_t mac_rrc_data_req_eNB_NB_IoT(
mib_flag_t mib_flag
)
{
//MAC_xface_NB_IoT *mac_xface_NB_IoT;
SRB_INFO_NB_IoT *Srb_info;
uint8_t Sdu_size=0;
......@@ -1112,7 +1103,7 @@ int8_t mac_rrc_data_req_eNB_NB_IoT(
#endif
if((Srb_id & RAB_OFFSET) == BCCH_NB_IoT){
if((Srb_id & RAB_OFFSET) == BCCH0_NB_IoT){
// Requesting for the MIB-NB
......@@ -1121,7 +1112,7 @@ int8_t mac_rrc_data_req_eNB_NB_IoT(
//XXX to be check when MIB-NB should be initialized
if (eNB_rrc_inst_NB_IoT[Mod_idP].carrier[CC_id].sizeof_MIB_NB_IoT == 255) {
LOG_E(RRC,"[eNB %d] MAC Request for MIB-NB and MIB-NB not initialized\n",Mod_idP);
mac_xface_NB_IoT->macphy_exit("mac_rrc_data_req_eNB_NB_IoT: MAC Request for MIB-NB and MIB-NB not initialized");
// exit here
}
memcpy(&buffer_pP[0],
......@@ -1160,12 +1151,12 @@ int8_t mac_rrc_data_req_eNB_NB_IoT(
//FIXME to be check when both are initialize and if make sense to have it
if (eNB_rrc_inst_NB_IoT[Mod_idP].carrier[CC_id].sizeof_SIB1_NB_IoT == 255) {
LOG_E(RRC,"[eNB %d] MAC Request for SIB1-NB and SIB1-NB_IoT not initialized\n",Mod_idP);
mac_xface_NB_IoT->macphy_exit("mac_rrc_data_req_eNB_NB_IoT: MAC Request for SIB1-NB_IoT and SIB1-NB_IoT not initialized");
// exit here
}
if (eNB_rrc_inst_NB_IoT[Mod_idP].carrier[CC_id].sizeof_SIB23_NB_IoT == 255) {
LOG_E(RRC,"[eNB %d] MAC Request for SIB23-NB and SIB23-NB_IoT not initialized\n",Mod_idP);
mac_xface_NB_IoT->macphy_exit("mac_rrc_data_req_eNB_NB_IoT: MAC Request for SIB23-NB_IoT and SIB23-NB_IoT not initialized");
// exit here
}
......@@ -1337,27 +1328,10 @@ void mac_eNB_rrc_ul_failure_NB_IoT(
else {
LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP);
}
rrc_mac_remove_ue_NB_IoT(mod_idP,rntiP);
//rrc_mac_remove_ue_NB_IoT(mod_idP,rntiP);
}
//defined in eNB_scheduler_primitives.c
void dump_ue_list_NB_IoT(UE_list_NB_IoT_t *listP, int ul_flag)
{
int j;
if ( ul_flag == 0 ) {
for (j=listP->head; j>=0; j=listP->next[j]) {
LOG_T(MAC,"node %d => %d\n",j,listP->next[j]);
}
} else {
for (j=listP->head_ul; j>=0; j=listP->next_ul[j]) {
LOG_T(MAC,"node %d => %d\n",j,listP->next_ul[j]);
}
}
}
//------------------------------------------------------------------------------
int8_t mac_rrc_data_req_NB_IoT(
const module_id_t Mod_idP,
......@@ -1384,7 +1358,7 @@ int8_t mac_rrc_data_req_NB_IoT(
if( enb_flagP == ENB_FLAG_YES) {
if((Srb_id & RAB_OFFSET) == BCCH_NB_IoT) {
if((Srb_id & RAB_OFFSET) == BCCH0_NB_IoT) {
if(eNB_rrc_inst_NB_IoT[Mod_idP].carrier[CC_id].SI.Active==0) {
return 0;
}
......@@ -1392,7 +1366,7 @@ int8_t mac_rrc_data_req_NB_IoT(
// All even frames transmit SIB in SF 5
if (eNB_rrc_inst_NB_IoT[Mod_idP].carrier[CC_id].sizeof_SIB1_NB_IoT == 255) {
LOG_E(RRC,"[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP);
mac_xface_NB_IoT->macphy_exit("mac_rrc_data_req: MAC Request for SIB1 and SIB1 not initialized");
//exit here
}
if ((frameP%2) == 0) {
......@@ -1531,11 +1505,6 @@ int8_t mac_rrc_data_req_NB_IoT(
return 0; // this parameter is set in function init_mcch in rrc_eNB.c
}
// this part not needed as it is done in init_mcch
/* if (eNB_rrc_inst[Mod_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area] == 255) {
LOG_E(RRC,"[eNB %d] MAC Request for MCCH MESSAGE and MCCH MESSAGE is not initialized\n",Mod_id);
mac_xface->macphy_exit("");
}*/
#if defined(ENABLE_ITTI)
......@@ -1630,6 +1599,7 @@ int8_t mac_rrc_data_req_NB_IoT(
}
//defined in L2_interface
void mac_eNB_rrc_ul_in_sync_NB_IoT(
const module_id_t mod_idP,
......@@ -2385,8 +2355,6 @@ boolean_t pdcp_data_req_NB_IoT(
const pdcp_transmission_mode_t modeP
)
{
//MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
pdcp_t *pdcp_p = NULL;
uint8_t i = 0;
uint8_t pdcp_header_len = 0;
......@@ -2425,8 +2393,7 @@ boolean_t pdcp_data_req_NB_IoT(
if (sdu_buffer_sizeP > MAX_IP_PACKET_SIZE) {
LOG_E(PDCP, "Requested SDU size (%d) is bigger than that can be handled by PDCP (%u)!\n",
sdu_buffer_sizeP, MAX_IP_PACKET_SIZE);
// XXX What does following call do?
mac_xface_NB_IoT->macphy_exit("PDCP sdu buffer size > MAX_IP_PACKET_SIZE");
// exit here
}
//check for MBMS not needed for NB-IoT*/
......
......@@ -38,6 +38,8 @@
#include "LAYER2/RLC/rlc.h"
#include "LogicalChannelConfig-NB-r13.h"
extern IF_Module_t *if_inst;
//MP: NOTE:XXX some of the parameters defined in vars_nb_iot are called by the extern.h file so not replicated here
extern UE_RRC_INST_NB_IoT *UE_rrc_inst_NB_IoT;
......
......@@ -251,18 +251,14 @@ void openair_rrc_top_init_eNB_NB_IoT(void)//MP: XXX Raymond put this directly th
//not consider UE part
if (NB_eNB_INST > 0) {
eNB_rrc_inst_NB_IoT = (eNB_RRC_INST_NB_IoT*) malloc16(NB_eNB_INST*sizeof(eNB_RRC_INST_NB_IoT));
memset (eNB_rrc_inst_NB_IoT, 0, NB_eNB_INST * sizeof(eNB_RRC_INST_NB_IoT));
LOG_D(RRC, "ALLOCATE %d Bytes for eNB_RRC_INST NB-IoT @ %p\n", (unsigned int)(NB_eNB_INST*sizeof(eNB_RRC_INST_NB_IoT)), eNB_rrc_inst_NB_IoT);
eNB_rrc_inst_NB_IoT = (eNB_RRC_INST_NB_IoT*) malloc16(sizeof(eNB_RRC_INST_NB_IoT));
memset (eNB_rrc_inst_NB_IoT, 0, sizeof(eNB_RRC_INST_NB_IoT));
LOG_D(RRC, "ALLOCATE %d Bytes for eNB_RRC_INST NB-IoT @ %p\n", (unsigned int)(sizeof(eNB_RRC_INST_NB_IoT)), eNB_rrc_inst_NB_IoT);
//no CBA, no LOcalization, no MBMS flag
LOG_D(RRC,
"ALLOCATE %d Bytes for eNB_RRC_INST_NB @ %p\n", (unsigned int)(NB_eNB_INST*sizeof(eNB_RRC_INST_NB_IoT)), eNB_rrc_inst_NB_IoT);
} else {
eNB_rrc_inst_NB_IoT = NULL;
}
"ALLOCATE %d Bytes for eNB_RRC_INST_NB @ %p\n", (unsigned int)(sizeof(eNB_RRC_INST_NB_IoT)), eNB_rrc_inst_NB_IoT);
}
......
......@@ -102,15 +102,12 @@
#ifdef PHY_EMUL
extern EMULATION_VARS *Emul_vars;
#endif
extern eNB_MAC_INST_NB_IoT *eNB_mac_inst;
extern UE_MAC_INST_NB_IoT *UE_mac_inst;
#ifdef BIGPHYSAREA
extern void* bigphys_malloc(int);
#endif
//#include "PHY_INTERFACE/defs_NB_IoT.h"
/*the Message Unit Identifieer (MUI) is an Identity of the RLC SDU, whic is used to indicate which RLC SDU that is confirmed
* with the RLC-AM-Data-conf. e.g. ((struct rlc_am_data_req *) (new_sdu_p->data))->mui (rlc_data_req_NB_IoT)
*/
......@@ -132,8 +129,6 @@ void rrc_eNB_free_UE_NB_IoT(const module_id_t enb_mod_idP,const struct rrc_eNB_u
#endif
rnti_t rnti = ue_context_pP->ue_context.rnti;
AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rnti);
/* ue_context_p = rrc_eNB_get_ue_context(
&eNB_rrc_inst[enb_mod_idP],
rntiP
......@@ -161,7 +156,7 @@ void rrc_eNB_free_UE_NB_IoT(const module_id_t enb_mod_idP,const struct rrc_eNB_u
#endif
#endif
rrc_mac_remove_ue_NB_IoT(enb_mod_idP,rnti);
//rrc_mac_remove_ue_NB_IoT(enb_mod_idP,rnti);
rrc_rlc_remove_ue(&ctxt);
pdcp_remove_UE(&ctxt);
......@@ -490,7 +485,6 @@ void rrc_eNB_generate_RRCConnectionSetup_NB_IoT(
)
//-----------------------------------------------------------------------------
{
//MAC_xface_NB_IoT *mac_xface_NB_IoT;
//connection setup involve the establishment of SRB1 and SRB1bis (but srb1bis is established implicitly)
//XXX: this message should go through SRB0 to see this--> uper_encode
//XXX: they are assuming that 2 RLC-AM entities are used for SRB1 and SRB1bis
......@@ -509,7 +503,7 @@ void rrc_eNB_generate_RRCConnectionSetup_NB_IoT(
//XXX MP:warning due to function still not completed at PHY (get_lte_frame_parms)
//XXX this approach is gone most probably
NB_IoT_DL_FRAME_PARMS *fp = mac_xface_NB_IoT->get_NB_IoT_frame_parms(ctxt_pP->module_id,CC_id);
NB_IoT_DL_FRAME_PARMS *fp = get_NB_IoT_frame_parms(ctxt_pP->module_id,CC_id);
T(T_ENB_RRC_CONNECTION_SETUP, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
......@@ -758,7 +752,6 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete_NB_IoT(
if (oip_ifup == 0) { // interface is up --> send a config the DRB
# ifdef OAI_EMU
oai_emulation.info.oai_ifup[ctxt_pP->module_id] = 1;
dest_ip_offset = NB_eNB_INST;
# else
dest_ip_offset = 8;
# endif
......@@ -1613,8 +1606,6 @@ static void init_SI_NB_IoT(
)
//-----------------------------------------------------------------------------
{
//MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
/*WE should allocate memory for PHY_Config structure
* is declared in vars_nb_iot.c and put also in the extern_nb_iot
* */
......@@ -1652,12 +1643,12 @@ static void init_SI_NB_IoT(
else {
LOG_E(RRC, PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for MIB_NB_IoT allocated\n",
PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
mac_xface_NB_IoT->macphy_exit("[RRC][init_SI] FATAL, no memory for MIB_NB_IoT allocated");
//exit here
}
if (eNB_rrc_inst_NB_IoT[ctxt_pP->module_id].carrier[CC_id].sizeof_MIB_NB_IoT == 255) {
mac_xface_NB_IoT->macphy_exit("[RRC][init_SI] FATAL, eNB_rrc_inst_NB[enb_mod_idP].carrier[CC_id].sizeof_MIB_NB_IoT == 255");
// exit here
}
//SIB1_NB_IoT
......@@ -1675,11 +1666,11 @@ static void init_SI_NB_IoT(
else {
LOG_E(RRC, PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB1_NB_IoT allocated\n",
PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
mac_xface_NB_IoT->macphy_exit("[RRC][init_SI] FATAL, no memory for SIB1_NB_IoT allocated");
//exit here
}
if (eNB_rrc_inst_NB_IoT[ctxt_pP->module_id].carrier[CC_id].sizeof_SIB1_NB_IoT == 255) {
mac_xface_NB_IoT->macphy_exit("[RRC][init_SI] FATAL, eNB_rrc_inst_NB[enb_mod_idP].carrier[CC_id].sizeof_SIB1_NB_IoT == 255");
//exit here
}
//SIB23_NB_IoT
......@@ -1694,7 +1685,7 @@ static void init_SI_NB_IoT(
);
if (eNB_rrc_inst_NB_IoT[ctxt_pP->module_id].carrier[CC_id].sizeof_SIB23_NB_IoT == 255) {
mac_xface_NB_IoT->macphy_exit("[RRC][init_SI] FATAL, eNB_rrc_inst_NB[mod].carrier[CC_id].sizeof_SIB23_NB_IoT == 255");
//exit here
}
LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" SIB2/3 Contents (partial)\n",
......@@ -1748,7 +1739,7 @@ static void init_SI_NB_IoT(
} else {
LOG_E(RRC, PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB2/3_NB allocated\n",
PROTOCOL_RRC_CTXT_ARGS(ctxt_pP));
mac_xface_NB_IoT->macphy_exit("[RRC][init_SI] FATAL, no memory for SIB2/3_NB allocated");
//exit here
}
}
......@@ -1997,7 +1988,7 @@ int rrc_eNB_decode_ccch_NB_IoT(
LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n",
ctxt_pP->rnti, ue_context_p->ue_context.rnti, ctxt_pP->rnti);
rrc_mac_remove_ue_NB_IoT(ctxt_pP->module_id, ctxt_pP->rnti);
//rrc_mac_remove_ue_NB_IoT(ctxt_pP->module_id, ctxt_pP->rnti);
ue_context_p = NULL;
return 0;
} else {
......@@ -2012,7 +2003,7 @@ int rrc_eNB_decode_ccch_NB_IoT(
if ((ue_context_p = rrc_eNB_ue_context_stmsi_exist_NB(ctxt_pP, mme_code, m_tmsi))) {
LOG_I(RRC," S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p,ue_context_p->ue_context.rnti,ctxt_pP->rnti);
rrc_mac_remove_ue_NB_IoT(ctxt_pP->module_id, ue_context_p->ue_context.rnti);
//rrc_mac_remove_ue_NB_IoT(ctxt_pP->module_id, ue_context_p->ue_context.rnti);
stmsi_received=1;
/* replace rnti in the context */
......@@ -2104,7 +2095,7 @@ int rrc_eNB_decode_ccch_NB_IoT(
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Can't create new context for UE random UE identity (0x%" PRIx64 ")\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
random_value);
rrc_mac_remove_ue_NB_IoT(ctxt_pP->module_id,ctxt_pP->rnti);
//rrc_mac_remove_ue_NB_IoT(ctxt_pP->module_id,ctxt_pP->rnti);
return -1;
}
}
......@@ -2341,14 +2332,6 @@ int rrc_eNB_decode_dcch_NB_IoT(
ue_context_p,
ul_dcch_msg_NB_IoT->message.choice.c1.choice.rrcConnectionReconfigurationComplete_r13.rrc_TransactionIdentifier);
#if defined(FLEXRAN_AGENT_SB_IF)
//WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
if (mac_agent_registered[ctxt_pP->module_id]) {
agent_mac_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
ue_context_p->ue_id_rnti,
PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED);
}
#endif
}
//#if defined(ENABLE_ITTI)...
......@@ -2402,7 +2385,7 @@ int rrc_eNB_decode_dcch_NB_IoT(
PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
"(rrcConnectionReestablishmentComplete-NB) ---> RRC_eNB\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
DCCH_NB_IoT,
DCCH0_NB_IoT,
sdu_sizeP);
break;
......@@ -2450,14 +2433,6 @@ int rrc_eNB_decode_dcch_NB_IoT(
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED_NB_IoT \n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
#if defined(FLEXRAN_AGENT_SB_IF)
//WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
if (mac_agent_registered[ctxt_pP->module_id]) {
agent_mac_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
ue_context_p->ue_id_rnti,
PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED);
}
#endif
}
......@@ -2497,7 +2472,7 @@ int rrc_eNB_decode_dcch_NB_IoT(
LOG_I(RRC,
PROTOCOL_RRC_CTXT_UE_FMT" received securityModeComplete-NB on UL-DCCH %d from UE\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
DCCH_NB_IoT);
DCCH0_NB_IoT);
LOG_D(RRC,
PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
"(securityModeComplete-NB) ---> RRC_eNB\n",
......@@ -2743,7 +2718,7 @@ int rrc_eNB_decode_dcch_NB_IoT(
PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
"(rrcConnectionResumeComplete-NB) ---> RRC_eNB\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
DCCH_NB_IoT, //check
DCCH0_NB_IoT, //check
sdu_sizeP);
break;
......
......@@ -614,7 +614,7 @@ static inline int rxtx_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *p
* (on its turn the scheduler will trigger the phy_procedure_eNB_TX through schedule_responce function
*/
if(if_inst->UL_indication) if_inst->UL_indication(UL_INFO);
//if(if_inst->UL_indication) if_inst->UL_indication(UL_INFO);
if (oai_exit) return(-1);
......
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