Commit 0fc1cf2e authored by Nick Ho's avatar Nick Ho

Integrate the MAC initial/configuration/SI scheduling

parent cef6d0af
......@@ -1180,12 +1180,15 @@ set (MAC_SRC
${MAC_DIR}/eNB_scheduler_ulsch_NB_IoT.c
${MAC_DIR}/eNB_scheduler_mch.c
${MAC_DIR}/eNB_scheduler_bch.c
${MAC_DIR}/eNB_scheduler_bch_NB_IoT.c
${MAC_DIR}/eNB_scheduler_primitives.c
${MAC_DIR}/eNB_scheduler_primitives_NB_IoT.c
${MAC_DIR}/eNB_scheduler_RA.c
${MAC_DIR}/eNB_scheduler_RA_NB_IoT.c
${MAC_DIR}/pre_processor.c
${MAC_DIR}/config.c
${MAC_DIR}/config_NB_IoT.c
${MAC_DIR}/schedule_tool_NB_IoT.c
)
if (FLEXRAN_AGENT_SB_IF)
......
......@@ -40,22 +40,15 @@
//#include "COMMON/openair_defs.h"
#include "COMMON/platform_constants.h"
#include "COMMON/mac_rrc_primitives.h"
#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
//#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
#include "RadioResourceConfigCommonSIB-NB-r13.h"
#include "RadioResourceConfigDedicated-NB-r13.h"
#include "RACH-ConfigCommon-NB-r13.h"
#include "MasterInformationBlock-NB.h"
#include "BCCH-DL-SCH-Message-NB.h"
#include "RRCConnectionSetup-NB.h"
#include "BCCH-BCH-Message-NB.h"
#include "SIB-Type-NB-r13.h"
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
//#include "defs.h"
//#ifdef PHY_EMUL
//#include "SIMULATION/PHY_EMULATION/impl_defs.h"
//#endif
/** @defgroup _mac MAC
* @ingroup _oai2
* @{
*/
#include "config_NB_IoT.h"
#define sim_end_time 100000
......@@ -267,7 +260,7 @@ typedef struct{
typedef struct {
/// DCI template and MAC connection parameters for UEs
UE_TEMPLATE_NB_IoT UE_template[NUMBER_OF_UE_MAX_NB_IoT];
UE_TEMPLATE_NB_IoT UE_template_NB_IoT[NUMBER_OF_UE_MAX_NB_IoT];
/// NPDCCH Period and searching space info
NPDCCH_config_dedicated_NB_IoT_t NPDCCH_config_dedicated;
......@@ -487,7 +480,7 @@ typedef enum ce_level_e{
/*! \brief eNB template for the Random access information */
typedef struct {
typedef struct RA_TEMPLATE_NB_IoT_s{
boolean_t active;
uint32_t msg3_retransmit_count;
......@@ -497,7 +490,7 @@ typedef struct {
ce_level_t ce_level;
rnti_t ue_rnti;
rnti_t ra_rnti;
struct RA_template_s *next, *prev;
struct RA_TEMPLATE_NB_IoT_s *next, *prev;
boolean_t wait_msg4_ack;
boolean_t wait_msg3_ack;
uint8_t rar_buffer[7];
......@@ -548,7 +541,7 @@ typedef struct {
uint32_t schedule_subframe_DL;
uint32_t schedule_subframe_UL;
//rrc_config_NB_IoT_t rrc_config;
rrc_config_NB_IoT_t rrc_config;
} eNB_MAC_INST_NB_IoT;
......@@ -561,6 +554,7 @@ nprach_parameters_NB_IoT_t nprach_list[3];
/******MAC Global Variable********/
available_resource_tones_UL_t *available_resource_UL;
available_resource_DL_t *available_resource_DL;
available_resource_DL_t *available_resource_DL_last;
/*
schedule_result_t *schedule_result_list_UL;
......@@ -606,19 +600,6 @@ DLSF_INFO_t DLSF_information;
//static uint32_t ack_nack_delay[4]={13,15,17,18};
//static uint32_t R_dl_table[16]={1,2,4,8,16,32,64,128,192,256,384,512,768,1024,1536,2048};
//Prach parameters
//static int rachperiod[8]={40,80,160,240,320,640,1280,2560};
//static int rachstart[8]={8,16,32,64,128,256,512,1024};
//static int rachrepeat[8]={1,2,4,8,16,32,64,128};
//static int rawindow[8]={2,3,4,5,6,7,8,10}; // unit PP
//static int rmax[12]={1,2,4,8,16,32,64,128,256,512,1024,2048};
//static double gvalue[8]={1.5,2,4,8,16,32,48,64};
//static int candidate[4]={1,2,4,8};
//static double pdcchoffset[4]={0,0.125,0.25,0.375};
//static int dlrepeat[16]={1,2,4,8,16,32,64,128,192,256,384,512,768,1024,1536,2048};
//static int rachscofst[7]={0,12,24,36,2,18,34};
//static int rachnumsc[4]={12,24,36,48};
// NB_IoT-IoT------------------
// TBS table for the case not containing SIB1-NB_IoT, Table 16.4.1.5.1-1 in TS 36.213 v14.2
......
......@@ -49,7 +49,7 @@
//NB-IoT
extern IF_Module_t *if_inst;
extern eNB_MAC_INST_NB_IoT *eNB_mac_inst_NB_IoT;
extern eNB_MAC_INST_NB_IoT *mac_inst;
// //extern uint32_t EBSR_Level[63];
// extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE];
......@@ -96,9 +96,17 @@ extern EMULATION_VARS *Emul_vars;
//NB-IoT---------------------------------
extern eNB_MAC_INST_NB_IoT *eNB_mac_inst_NB_IoT;
extern eNB_MAC_INST_NB_IoT *mac_inst;
extern uint8_t Is_rrc_registered_NB_IoT;
extern BCCH_BCH_Message_NB_t MIB;
extern BCCH_DL_SCH_Message_NB_t SIB;
extern RRCConnectionSetup_NB_r13_IEs_t DED_Config;
extern available_resource_DL_t *available_resource_DL;
extern available_resource_tones_UL_t *available_resource_UL;
extern available_resource_DL_t *available_resource_DL_last;
extern schedule_result_t *schedule_result_list_UL;
extern schedule_result_t *schedule_result_list_DL;
#endif //DEF_H
......
......@@ -19,12 +19,12 @@
* contact@openairinterface.org
*/
/*! \file main.c
/*! \file main_nb_iot.c
* \brief top init of Layer 2
* \author Navid Nikaein and Raymond Knopp, Michele Paffetti
* \date 2010 - 2014
* \author
* \date 2017
* \version 1.0
* \email: navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
* \email:
* @ingroup _mac
*/
......@@ -37,6 +37,9 @@
#include "vars_NB_IoT.h"
#include "RRC/LITE/proto_NB_IoT.h"
#define NUM_USS_PP 3
#define USER_NUM_USS 10
int mac_init_global_param_NB_IoT(void)
{
......@@ -60,9 +63,161 @@ int mac_init_global_param_NB_IoT(void)
// Initial function of the intialization for NB-IoT MAC
int mac_top_init_NB_IoT()
void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst)
{
int32_t i, j, k;
for(i=0;i<64;++i)
{
mac_inst->sib1_flag[i] = 0;
mac_inst->sib1_count[i] = 0;
}
rrc_mac_config_req_NB_IoT(&mac_inst->rrc_config, 1, 1, 0, 0);
init_tool_sib1(mac_inst);
// output handler
// RA
mac_inst->RA_msg2_list.head = (RA_TEMPLATE_NB_IoT *)0;
mac_inst->RA_msg3_list.head = (RA_TEMPLATE_NB_IoT *)0;
mac_inst->RA_msg4_list.head = (RA_TEMPLATE_NB_IoT *)0;
mac_inst->RA_msg2_list.tail = (RA_TEMPLATE_NB_IoT *)0;
mac_inst->RA_msg3_list.tail = (RA_TEMPLATE_NB_IoT *)0;
mac_inst->RA_msg4_list.tail = (RA_TEMPLATE_NB_IoT *)0;
sib1_NB_IoT_sched_t *config = &mac_inst->rrc_config.sib1_NB_IoT_sched_config;
// DLSF Table
init_dlsf_info(mac_inst, &DLSF_information);
// init sib1 tool
//int repetition_pattern = 1;// 1:every2frame, 2:every4frame, 3:every8frame, 4:every16frame
for(i=0;i<8;++i){
mac_inst->sib1_flag[(i<<1)+config->starting_rf] = 1;
}
for(i=0, j=0;i<64;++i){
if(mac_inst->sib1_flag[i]==1){
++j;
}
mac_inst->sib1_count[i]=j;
}
//printf("%d", mac_inst->sib1_period);
for(i=0, j=0;i<640;++i){
//printf("*%d", i);
if(is_dlsf(mac_inst, i)){
++j;
}
//printf("-");
if(i%10==9){
mac_inst->dlsf_table[i/10] = j;
}
}
//mac_inst->si_window_length = ms160;
//mac_inst->sibs_NB_IoT_sched[0].si_periodicity = rf64;
for(i=0;i<256;++i){
mac_inst->sibs_table[i] = -1;
}
for(j=0;j<6;++j){
if(0x0 != mac_inst->rrc_config.sibs_NB_IoT_sched[j].sib_mapping_info){
k = mac_inst->rrc_config.sibs_NB_IoT_sched[j].si_periodicity / mac_inst->rrc_config.si_window_length;
for(i=0;i<(256/k);++i){
mac_inst->sibs_table[(i*k)+j] = j;
}
}
}
mac_inst->schedule_subframe_DL = 0;
mac_inst->schedule_subframe_UL = 0;
available_resource_DL = available_resource_DL_last = (available_resource_DL_t *)0;
// init downlink list 0-100
init_dl_list(mac_inst);
for(i=0; i<MAX_NUMBER_OF_UE_MAX_NB_IoT; ++i){
mac_inst->RA_template[i].active = 0;
mac_inst->RA_template[i].msg3_retransmit_count = 0;
mac_inst->RA_template[i].msg4_retransmit_count = 0;
mac_inst->RA_template[i].ta = 0;
mac_inst->RA_template[i].preamble_index = 0;
mac_inst->RA_template[i].ue_rnti = 0x0;
mac_inst->RA_template[i].ra_rnti = 0x0;
mac_inst->RA_template[i].next = (RA_TEMPLATE_NB_IoT *)0;
mac_inst->RA_template[i].prev = (RA_TEMPLATE_NB_IoT *)0;
mac_inst->RA_template[i].wait_msg4_ack = 0;
mac_inst->RA_template[i].wait_msg3_ack = 0;
}
//3 CE level USS list
mac_inst->UE_list_spec = (UE_list_NB_IoT_t*)malloc(NUM_USS_PP*sizeof(UE_list_NB_IoT_t));
//initial UE list
printf("[init_mac_NB_IoT] Initial UE list\n");
mac_inst->num_uss_list = NUM_USS_PP;
for(i=0;i<NUM_USS_PP;++i)
{
rrc_mac_config_req_NB_IoT(&mac_inst->rrc_config, 0, 0, 1, i);
(mac_inst->UE_list_spec+i)->head = -1;
(mac_inst->UE_list_spec+i)->tail = -1;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.R_max = mac_inst->rrc_config.npdcch_ConfigDedicated[i].R_max;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.G = mac_inst->rrc_config.npdcch_ConfigDedicated[i].G;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.a_offset = mac_inst->rrc_config.npdcch_ConfigDedicated[i].a_offset;
//(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.R_max = 8;
//(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.G = 1;
//(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.a_offset = 0;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.T = (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.R_max * (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.G;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.ss_start_uss = (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.T * (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.a_offset;
for(j=0;j<MAX_NUMBER_OF_UE_MAX_NB_IoT;++j)
{
(mac_inst->UE_list_spec+i)->UE_template_NB_IoT[j].active=0;
(mac_inst->UE_list_spec+i)->UE_template_NB_IoT[j].RRC_connected=0;
(mac_inst->UE_list_spec+i)->UE_template_NB_IoT[j].direction = -1;
}
//SCHEDULE_LOG("[%04d][init_mac_NB_IoT] List_number %d R_max %d G %.1f a_offset %.1f T %d SS_start %d\n", mac_inst->current_subframe, i, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.R_max, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.G, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.a_offset, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.T, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.ss_start_uss);
printf("[init_mac_NB_IoT] List_number %d R_max %d G %.1f a_offset %.1f T %d SS_start %d\n", i, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.R_max, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.G, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.a_offset, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.T, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.ss_start_uss);
}
/*
//Initial one UE template
//UE_TEMPLATE_NB_IoT *UE_info=(UE_TEMPLATE_NB_IoT*)malloc(USER_NUM_USS*sizeof(UE_TEMPLATE_NB_IoT));
mac_inst->UE_list_spec->head=0;
mac_inst->UE_list_spec->tail=0;
for(i=0;i<USER_NUM_USS;++i)
{
UE_info_setting(mac_inst->UE_list_spec->UE_template_NB_IoT+i);
if(i==0)
{
(mac_inst->UE_list_spec->UE_template_NB_IoT+i)->prev=-1;
(mac_inst->UE_list_spec->UE_template_NB_IoT+i)->next=1;
//mac_inst->UE_list_spec->next[i]=-1;
}
else if(i>=USER_NUM_USS-1)
{
(mac_inst->UE_list_spec->UE_template_NB_IoT+i)->prev=i-1;
(mac_inst->UE_list_spec->UE_template_NB_IoT+i)->next=-1;
}
else
{
(mac_inst->UE_list_spec->UE_template_NB_IoT+i)->prev=i-1;
(mac_inst->UE_list_spec->UE_template_NB_IoT+i)->next=i+1;
}
//mac_inst->UE_list_spec->UE_template_NB_IoT[i]=UE_info[i];
mac_inst->UE_list_spec->tail=i;
}
*/
//UL initial
//Setting nprach configuration
setting_nprach();
//Initialize uplink resource from nprach configuration
Initialize_Resource();
//add_UL_Resource(mac_inst);
extend_available_resource_DL(mac_inst, mac_inst->current_subframe + 1 + 160);
}
......@@ -73,15 +228,15 @@ int l2_init_eNB_NB_IoT()
LOG_I(MAC,"[MAIN] MAC_INIT_GLOBAL_PARAM NB-IoT IN...\n");
mac_inst = (eNB_MAC_INST_NB_IoT *) malloc (sizeof(eNB_MAC_INST_NB_IoT));
Is_rrc_registered_NB_IoT=0;
mac_init_global_param_NB_IoT();
Is_rrc_registered_NB_IoT=1;
init_mac_NB_IoT(mac_inst);
LOG_D(MAC,"[MAIN][NB-IoT] ALL INIT OK\n");
// mac_xface->macphy_init(eMBMS_active,uecap_xer,cba_group_active,HO_active); (old mac_top_init)
mac_top_init_NB_IoT();
return(1);
}
......
......@@ -39,4 +39,39 @@
/*for NB-IoT*/
void init_tool_sib1(eNB_MAC_INST_NB_IoT *mac_inst);
void init_dlsf_info(eNB_MAC_INST_NB_IoT *mac_inst, DLSF_INFO_t *DLSF_info);
void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst);
int is_dlsf(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void init_dl_list(eNB_MAC_INST_NB_IoT *mac_inst);
void setting_nprach(void);
void init_rrc_NB_IoT(void);
void add_UL_Resource_node(available_resource_UL_t **head, uint32_t *end_subframe, uint32_t ce_level);
void add_UL_Resource(void);
void Initialize_Resource(void);
void extend_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int max_subframe);
void rrc_mac_config_req_NB_IoT(rrc_config_NB_IoT_t *mac_config,
uint8_t mib_flag,
uint8_t sib_flag,
uint8_t ded_flag,
uint8_t ue_list_ded_num);
// schedule functinons
void schedule_sibs_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t sibs_order, int start_subframe1);
void fill_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, available_resource_DL_t *node, int start_subframe, int end_subframe, schedule_result_t *new_node);
available_resource_DL_t *check_sibs_resource(eNB_MAC_INST_NB_IoT *mac_inst, int check_start_subframe, int check_end_subframe, int num_subframe, int *residual_subframe, int *out_last_subframe, int *out_first_subframe);
uint32_t calculate_DLSF(eNB_MAC_INST_NB_IoT *mac_inst, int abs_start_subframe, int abs_end_subframe);
#endif
......@@ -45,7 +45,15 @@
IF_Module_t *if_inst;
//NB-IoT--------------------------------------
eNB_MAC_INST_NB_IoT *eNB_mac_inst_NB_IoT;
eNB_MAC_INST_NB_IoT *mac_inst;
BCCH_BCH_Message_NB_t MIB;
BCCH_DL_SCH_Message_NB_t SIB;
RRCConnectionSetup_NB_r13_IEs_t DED_Config;
schedule_result_t *schedule_result_list_UL;
schedule_result_t *schedule_result_list_DL;
available_resource_DL_t *available_resource_DL;
available_resource_tones_UL_t *available_resource_UL;
//should be utilized in: schedule_RA_NB_IoT,rx_sdu_NB_IoT, mac_top_init_NB_IoT,
uint8_t Is_rrc_registered_NB_IoT;
......
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