Commit c10d87dd authored by AlanLi's avatar AlanLi

fix sib23 transmission in MAC layer, need to check with PHY's timing

parent 27d7bdf4
......@@ -428,17 +428,21 @@ void rrc_mac_config_req_NB_IoT(
mac_config->sib1_NB_IoT_sched_config.starting_rf = *(sib1_NB_IoT->si_RadioFrameOffset_r13);
mac_config->si_window_length = sib1_NB_IoT->si_WindowLength_r13;
//mac_config->sib1_NB_IoT_sched_config.starting_rf = *(sib1_NB_IoT->si_RadioFrameOffset_r13);
mac_config->sib1_NB_IoT_sched_config.starting_rf = 2;
mac_config->si_window_length = ms160;
///OAI only supports SIB2/3-NB for the sibs
mac_config->sibs_NB_IoT_sched[0].si_periodicity = si_Periodicity_rf4096 ;
mac_config->sibs_NB_IoT_sched[0].si_periodicity = si_Periodicity_rf64 ;
mac_config->sibs_NB_IoT_sched[0].si_repetition_pattern = si_RepetitionPattern_every2ndRF;
mac_config->sibs_NB_IoT_sched[0].sib_mapping_info = sib3_v;
mac_config->sibs_NB_IoT_sched[0].si_tb = si_TB_680;
LOG_I(MAC,"si_periodicity:%d, siw: %d, start rf: %d\n",mac_config->sibs_NB_IoT_sched[0].si_periodicity, mac_config->si_window_length,mac_config->sib1_NB_IoT_sched_config.starting_rf);
/*
/// Thiese value is setting for different SIB set
if ( sib1_NB_IoT->schedulingInfoList_r13.list.array[1] != NULL) {
......@@ -500,6 +504,10 @@ void rrc_mac_config_req_NB_IoT(
mac_config->mac_NPRACH_ConfigSIB[0].mac_npdcch_NumRepetitions_RA_NB_IoT = nprach_parameter->npdcch_NumRepetitions_RA_r13;
mac_config->mac_NPRACH_ConfigSIB[0].mac_npdcch_StartSF_CSS_RA_NB_IoT = nprach_parameter->npdcch_StartSF_CSS_RA_r13;
mac_config->mac_NPRACH_ConfigSIB[0].mac_npdcch_Offset_RA_NB_IoT = nprach_parameter->npdcch_Offset_RA_r13;
mac_inst->npdcch_config_common[0].R_max = rmax[nprach_parameter->npdcch_NumRepetitions_RA_r13];
mac_inst->npdcch_config_common[0].G = gvalue[nprach_parameter->npdcch_StartSF_CSS_RA_r13];
mac_inst->npdcch_config_common[0].a_offset = pdcchoffset[nprach_parameter->npdcch_Offset_RA_r13];
LOG_I(MAC,"NPRACH 0 setting: Rmax: %ld G: %lf a: %lf\n",mac_inst->npdcch_config_common[0].R_max,mac_inst->npdcch_config_common[0].G,mac_inst->npdcch_config_common[0].a_offset);
}
///CE level 1
......@@ -510,6 +518,10 @@ void rrc_mac_config_req_NB_IoT(
mac_config->mac_NPRACH_ConfigSIB[1].mac_npdcch_NumRepetitions_RA_NB_IoT = nprach_parameter->npdcch_NumRepetitions_RA_r13;
mac_config->mac_NPRACH_ConfigSIB[1].mac_npdcch_StartSF_CSS_RA_NB_IoT = nprach_parameter->npdcch_StartSF_CSS_RA_r13;
mac_config->mac_NPRACH_ConfigSIB[1].mac_npdcch_Offset_RA_NB_IoT = nprach_parameter->npdcch_Offset_RA_r13;
mac_inst->npdcch_config_common[1].R_max = rmax[nprach_parameter->npdcch_NumRepetitions_RA_r13];
mac_inst->npdcch_config_common[1].G = gvalue[nprach_parameter->npdcch_StartSF_CSS_RA_r13];
mac_inst->npdcch_config_common[1].a_offset = pdcchoffset[nprach_parameter->npdcch_Offset_RA_r13];
LOG_I(MAC,"NPRACH 1 setting: Rmax: %ld G: %lf a: %lf\n",mac_inst->npdcch_config_common[1].R_max,mac_inst->npdcch_config_common[1].G,mac_inst->npdcch_config_common[1].a_offset);
}
///CE level 2
if ( radioResourceConfigCommon->nprach_Config_r13.nprach_ParametersList_r13.list.array[2] != NULL) {
......@@ -519,6 +531,10 @@ void rrc_mac_config_req_NB_IoT(
mac_config->mac_NPRACH_ConfigSIB[2].mac_npdcch_NumRepetitions_RA_NB_IoT = nprach_parameter->npdcch_NumRepetitions_RA_r13;
mac_config->mac_NPRACH_ConfigSIB[2].mac_npdcch_StartSF_CSS_RA_NB_IoT = nprach_parameter->npdcch_StartSF_CSS_RA_r13;
mac_config->mac_NPRACH_ConfigSIB[2].mac_npdcch_Offset_RA_NB_IoT = nprach_parameter->npdcch_Offset_RA_r13;
mac_inst->npdcch_config_common[2].R_max = rmax[nprach_parameter->npdcch_NumRepetitions_RA_r13];
mac_inst->npdcch_config_common[2].G = gvalue[nprach_parameter->npdcch_StartSF_CSS_RA_r13];
mac_inst->npdcch_config_common[2].a_offset = pdcchoffset[nprach_parameter->npdcch_Offset_RA_r13];
LOG_I(MAC,"NPRACH 2 setting: Rmax: %ld G: %lf a: %lf\n",mac_inst->npdcch_config_common[2].R_max,mac_inst->npdcch_config_common[2].G,mac_inst->npdcch_config_common[2].a_offset);
}
......@@ -584,16 +600,17 @@ void rrc_mac_config_req_NB_IoT(
LOG_I(MAC,"[NB-IoT] Init_MAC done\n");
/*
//for sacheduler testing
/*for(int i =0;i<30;i++)
for(int i =0;i<30;i++)
{
LOG_I(MAC,"[NB-IoT] scheduler testing start %d\n",i);
eNB_dlsch_ulsch_scheduler_NB_IoT(RC.nb_iot_mac[Mod_idP], i);
eNB_dlsch_ulsch_scheduler_NB_IoT(mac_inst, i);
LOG_I(MAC,"[NB-IoT] scheduler testing done %d\n",i);
}*/
}
*/
// RC.L1_NB_IoT[Mod_idP]->configured=1;
......
......@@ -44,13 +44,14 @@
#include "config_NB_IoT.h"
// MAC definition
#define MAX_FRAME 0xfffff
#define NUM_FRAME 0x100000
#define MAX_SUBFRAME 10485760
#define MAX_FRAME 0xfff
#define MAX_SUBFRAME 40960
#define MAX(a, b) (((a)>(b))?(a):(b))
// RNTI
//#define P_RNTI 0xffee
//#define SI_RNTI 0xffff
// RA-RNTI: 1+SFN_id>>2
#define RA_RNTI_LOW 0x0001 // SFN_id = 0
#define RA_RNTI_HIGH 0x0100 // SFN_id = 1023
......@@ -130,7 +131,6 @@ typedef enum{
#define BCCH1_NB_IoT 12 // SI-SIB-NB_IoTs
/*!\brief Values of PCCH logical channel */
#define PCCH_NB_IoT 13 // Paging XXX not used for the moment
#define MCCH_NB_IoT 14
/*!\brief Value of CCCH / SRB0 logical channel */
#define CCCH_NB_IoT 0 // srb0 ---> XXX exactly the same as in LTE (commented for compilation purposes)
/*!\brief DCCH0 / SRB1bis logical channel */
......@@ -231,11 +231,109 @@ typedef struct {
int prev;
// MSG4 complete
int RRC_connected;
uint8_t flag_schedule_success;
// UE active flag
boolean_t active;
uint8_t allocated_data_size_ul;
} UE_TEMPLATE_NB_IoT;
typedef struct available_resource_UL_s{
///Resource start subframe
uint32_t start_subframe;
///Resource end subframe
uint32_t end_subframe;
// pointer to next node
struct available_resource_UL_s *next, *prev;
}available_resource_UL_t;
typedef struct available_resource_DL_s{
uint32_t start_subframe;
uint32_t end_subframe;
//uint32_t DLSF_num;
struct available_resource_DL_s *next, *prev;
}available_resource_DL_t;
/*Structure used for scheduling*/
typedef struct{
//resource position info.
uint32_t sf_end,sf_start;
//resource position info. separate by HyperSF, Frame, Subframe
uint32_t start_h, end_h;
uint32_t start_f, end_f;
uint32_t start_sf, end_sf;
//whcih available resource node is used
available_resource_DL_t *node;
}sched_temp_DL_NB_IoT_t;
/*Structure used for UL scheduling*/
typedef struct{
//resource position info.
uint32_t sf_end, sf_start;
//resource position info. separate by HyperSF, Frame, Subframe
//uint32_t start_h, end_h;
//uint32_t start_f, end_f;
//uint32_t start_sf, end_sf;
// information for allocating the resource
int tone;
int scheduling_delay;
int subcarrier_indication;
int ACK_NACK_resource_field;
available_resource_UL_t *node;
}sched_temp_UL_NB_IoT_t;
/******Update******/
/*** the value of variable in this structure is able to be changed in Preprocessor**/
typedef struct{
uint16_t TBS;
uint8_t index_tbs;
uint32_t total_sdu_size;
//Repetition
uint16_t R_dci;
uint16_t R_dl_data;
uint16_t R_dl_harq;
uint16_t R_ul_data;
//DL relative
uint8_t dci_n1_index_R_dci;
uint8_t dci_n1_index_R_data;
uint8_t dci_n1_index_mcs;
uint8_t dci_n1_index_sf;
uint8_t dci_n1_index_delay;
uint8_t dci_n1_index_ack_nack;
uint32_t dci_n1_n_sf;
//UL relative
uint8_t dci_n0_index_R_dci;
uint8_t dci_n0_index_R_data;
uint8_t dci_n0_index_mcs;
uint8_t dci_n0_index_ru;
uint8_t dci_n0_index_delay;
uint8_t dci_n0_index_subcarrier;
uint32_t dci_n0_n_ru;
uint8_t dci_n0_index_rv;
uint8_t dci_n0_index_ndi;
// byte
uint16_t total_data_size_dl;
// byte
uint16_t total_data_size_ul;
//0:UL 1:DL 2:both
uint16_t transmit_direction;
/*resource allocation*/
// scheduling result for NPDCCH
uint32_t NPDCCH_sf_end, NPDCCH_sf_start;
// scheduling result for USS DL
uint32_t NPDSCH_sf_end, NPDSCH_sf_start;
uint32_t HARQ_sf_end, HARQ_sf_start;
// scheduling result for USS UL
uint32_t NPUSCH_sf_end, NPUSCH_sf_start;
// schedule success 1 failure 0
uint8_t flag_schedule_success;
}UE_SCHED_CTRL_NB_IoT_t;
/*36331 NPDCCH-ConfigDedicated-NB_IoT*/
typedef struct{
//npdcch-NumRepetitions-r13
......@@ -257,6 +355,8 @@ typedef struct {
/// DCI template and MAC connection parameters for UEs
UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_NUMBER_OF_UE_MAX_NB_IoT];
UE_SCHED_CTRL_NB_IoT_t UE_sched_ctrl_NB_IoT[MAX_NUMBER_OF_UE_MAX_NB_IoT];
/// NPDCCH Period and searching space info
NPDCCH_config_dedicated_NB_IoT_t NPDCCH_config_dedicated;
//int next[MAX_NUMBER_OF_UE_MAX_NB_IoT];
......@@ -295,36 +395,6 @@ typedef struct{
}scheduling_flag_t;
typedef struct available_resource_UL_s{
///Resource start subframe
uint32_t start_subframe;
///Resource end subframe
uint32_t end_subframe;
// pointer to next node
struct available_resource_UL_s *next, *prev;
}available_resource_UL_t;
typedef struct available_resource_DL_s{
uint32_t start_subframe;
uint32_t end_subframe;
struct available_resource_DL_s *next, *prev;
}available_resource_DL_t;
/*Structure used for scheduling*/
typedef struct{
//resource position info.
uint32_t sf_end,sf_start;
//resource position info. separate by HyperSF, Frame, Subframe
uint32_t start_h, end_h;
uint32_t start_f, end_f;
uint32_t start_sf, end_sf;
//whcih available resource node is used
available_resource_DL_t *node;
}sched_temp_DL_NB_IoT_t;
/*!\brief MAC subheader short with 7bit Length field */
typedef struct {
uint8_t LCID:5; // octet 1 LSB
......@@ -377,21 +447,6 @@ typedef struct {
uint8_t E:1;
} __attribute__((__packed__))RA_HEADER_RAPID_NB_IoT;
/*Structure used for UL scheduling*/
typedef struct{
//resource position info.
uint32_t sf_end, sf_start;
//resource position info. separate by HyperSF, Frame, Subframe
//uint32_t start_h, end_h;
//uint32_t start_f, end_f;
//uint32_t start_sf, end_sf;
// information for allocating the resource
int tone;
int scheduling_delay;
int subcarrier_indication;
int ACK_NACK_resource_field;
available_resource_UL_t *node;
}sched_temp_UL_NB_IoT_t;
typedef struct Available_available_resource_DL{
......@@ -442,6 +497,14 @@ typedef struct schedule_result{
uint32_t end_subframe;
uint8_t *rar_buffer;
int16_t dl_sdly;
int16_t ul_sdly;
int16_t num_sf;
//-----clare
int16_t harq_round;
//-----clare
}schedule_result_t;
......@@ -495,8 +558,23 @@ typedef struct RA_template_list_s{
}RA_template_list_t;
/*36331 NPDCCH-ConfigDedicated-NB_IoT*/
typedef struct{
//npdcch-NumRepetitions-r13
uint32_t R_max;
//npdcch-StartSF-CSS-r13
double G;
//npdcch-Offset-USS-r13
double a_offset;
//NPDCCH period
uint32_t T;
//Starting subfrane of Search Space which is mod T
uint32_t ss_start_css;
}NPDCCH_config_common_NB_IoT_t;
/*! \brief top level eNB MAC structure */
typedef struct {
typedef struct mac_NB_IoT_s{
uint8_t Mod_id;
......@@ -533,7 +611,8 @@ typedef struct {
scheduling_flag_t scheduling_flag;
uint32_t schedule_subframe_DL;
uint32_t schedule_subframe_UL;
//uint32_t schedule_subframe_UL;
NPDCCH_config_common_NB_IoT_t npdcch_config_common[3];
rrc_config_NB_IoT_t rrc_config;
......
......@@ -26,6 +26,9 @@
#define flag_nsss 0x8
unsigned char str22[] = "UL_Data";
unsigned char str23[] = "DCI_N0";
//extern BCCH_DL_SCH_Message_NB_IoT_t SIB;
void eNB_scheduler_computing_flag_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe, uint32_t *scheduler_flags, uint32_t *common_flags, uint32_t *max_subframe){
......@@ -48,25 +51,27 @@ void eNB_scheduler_computing_flag_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t
}
/* uint32_t type2_css_pp[3] = { type2_css_info[0]->npdcch_NumRepetitions_RA_r13*type2_css_info[0]->npdcch_StartSF_CSS_RA_r13, type2_css_info[1]->npdcch_NumRepetitions_RA_r13*type2_css_info[1]->npdcch_StartSF_CSS_RA_r13, type2_css_info[2]->npdcch_NumRepetitions_RA_r13*type2_css_info[2]->npdcch_StartSF_CSS_RA_r13 };*/
uint32_t type2_css_pp[3] = {256, 256, 256}; // TODO RRC config should get from structure
uint32_t type2_css_pp[3] = { mac_inst->npdcch_config_common[0].R_max*mac_inst->npdcch_config_common[0].G,
mac_inst->npdcch_config_common[1].R_max*mac_inst->npdcch_config_common[1].G,
mac_inst->npdcch_config_common[2].R_max*mac_inst->npdcch_config_common[2].G };
uint32_t start_subframe;
for(i=0; i<1; ++i){ // only CE0
start_subframe = 0;
/*switch(type2_css_info[i]->npdcch_Offset_RA_r13){
case NPRACH_Parameters_NB_IoT_r13__npdcch_Offset_RA_r13_zero:
start_subframe = 0;
break;
case NPRACH_Parameters_NB_IoT_r13__npdcch_Offset_RA_r13_oneEighth:
start_subframe = type2_css_pp[i]>>3;
break;
case NPRACH_Parameters_NB_IoT_r13__npdcch_Offset_RA_r13_oneFourth:
start_subframe = type2_css_pp[i]>>2;
break;
case NPRACH_Parameters_NB_IoT_r13__npdcch_Offset_RA_r13_threeEighth:
start_subframe = (type2_css_pp[i]>>3)+(type2_css_pp[i]>>2);
break;
default: break;
}*/
if(mac_inst->npdcch_config_common[i].a_offset==0)
{
start_subframe = 0;
}
else if(mac_inst->npdcch_config_common[i].a_offset==1/8)
{
start_subframe = type2_css_pp[i]>>3;
}
else if(mac_inst->npdcch_config_common[i].a_offset==1/4)
{
start_subframe = type2_css_pp[i]>>2;
}
else if(mac_inst->npdcch_config_common[i].a_offset==3/8)
{
start_subframe = (type2_css_pp[i]>>3)+(type2_css_pp[i]>>2);
}
if(((abs_subframe+1)%type2_css_pp[i])==start_subframe){
*scheduler_flags |= flag_css_type2;
......@@ -74,7 +79,7 @@ void eNB_scheduler_computing_flag_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t
LOG_D(MAC,"[%d][computing flags] common searching space: %d, num subframe: %d\n", mac_inst->current_subframe, i, extend_space[i]);
}
}
/*
//USS trigger flag
for(i=0;i<mac_inst->num_uss_list;++i)
{
......@@ -85,7 +90,7 @@ void eNB_scheduler_computing_flag_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t
LOG_D(MAC,"[%d][computing flags] UE-spec searching space: %d, num subframe: %d\n", mac_inst->current_subframe, i, mac_inst->UE_list_spec[i].NPDCCH_config_dedicated.T);
}
}
*/
*max_subframe = max; // the maximum subframe to be extend
}
......@@ -96,13 +101,13 @@ void eNB_scheduler_computing_flag_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t
void eNB_dlsch_ulsch_scheduler_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe){
int i;
uint8_t tx_mib=0, tx_sib1=0;
uint8_t MIB_flag = 0, SIB1_flag = 0;
uint32_t scheduler_flags, max_subframe, common_flags;
/*Check this subframe should schedule something, set the flag*/
scheduler_flags = 0;
common_flags = 0;
uint32_t h,f,sf;
uint32_t h,f,sf,a;
mac_inst->current_subframe = abs_subframe;
eNB_scheduler_computing_flag_NB_IoT(mac_inst, abs_subframe, &scheduler_flags, &common_flags, &max_subframe);
if(scheduler_flags > 0){
......@@ -133,82 +138,281 @@ void eNB_dlsch_ulsch_scheduler_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t ab
for(i=0;i<mac_inst->num_uss_list;++i)
{
if((scheduler_flags&(flag_uss_v<<i))>0){
LOG_D(MAC,"--------------[%04d][SchedulerUSS] Schedule USS list %d------------\n", mac_inst->current_subframe, (scheduler_flags&(flag_uss_v<<i))>>3);
LOG_I(MAC,"--------------[%04d][SchedulerUSS] Schedule USS list %d------------\n", mac_inst->current_subframe, (scheduler_flags&(flag_uss_v<<i))>>3);
schedule_uss_NB_IoT(0, mac_inst,sf, f, h, i);
LOG_D(MAC,"--------------[%04d][SchedulerUSS] Schedule USS list %d end------------\n", mac_inst->current_subframe, (scheduler_flags&(flag_uss_v<<i))>>3);
LOG_I(MAC,"--------------[%04d][SchedulerUSS] Schedule USS list %d end------------\n", mac_inst->current_subframe, (scheduler_flags&(flag_uss_v<<i))>>3);
scheduler_flags &= ~(flag_uss_v<<i);
}
}
if(common_flags&flag_mib){
tx_mib = 1;
}
if(common_flags&flag_sib1){
tx_sib1 = 1;
}
if(common_flags == flag_mib)
MIB_flag = 1;
if(common_flags == flag_sib1)
SIB1_flag = 1;
convert_system_number(abs_subframe, &h, &f, &sf);
if(0 != output_handler(mac_inst, (module_id_t)0, 0, h, f, sf, tx_mib, tx_sib1, abs_subframe)){
LOG_D(MAC,"output handler error\n");
}
a = output_handler(mac_inst, 0,0,h,f,sf,MIB_flag,SIB1_flag, abs_subframe);
if(a==-1)
LOG_I(MAC,"[%04d][SchedulerUSS] schedule result is empty------------\n", mac_inst->current_subframe);
}
void schedule_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, uint32_t subframe, uint32_t frame, uint32_t hypersfn, int index_ss)
void USS_scheduling_module(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe, uint8_t total_num_UE_list)
{
int i, max_subframe,MIB_flag,SIB1_flag;
/*Check this subframe should schedule something, set the flag*/
MIB_flag = 0;
SIB1_flag = 0;
max_subframe=0;
uint32_t h,f,sf;
int a;
int UE_list_index;
// how many scheduling is triggered this sunframe
uint8_t num_sched_UE_list=0;
uint8_t *UE_list_flag=(uint8_t*)malloc(total_num_UE_list*sizeof(uint8_t));
//DEBUG("[%04d][USS_scheduling_module] check scheduling trigger\n", mac_inst->current_subframe);
//eNB_scheduler_computing_flag_NB_IoT(mac_inst, abs_subframe, &scheduler_flags, &common_flags, &max_subframe);
// Check which scheduling period of UE_list is triggered
for(i=0;i<total_num_UE_list;++i)
{
if(((abs_subframe+1)%mac_inst->UE_list_spec[i].NPDCCH_config_dedicated.T)==mac_inst->UE_list_spec[i].NPDCCH_config_dedicated.ss_start_uss)
//if((abs_subframe+1)%16==0)
{
if(mac_inst->UE_list_spec[i].NPDCCH_config_dedicated.T>max_subframe)
{
max_subframe=mac_inst->UE_list_spec[i].NPDCCH_config_dedicated.T;
}
UE_list_flag[i]=1;
num_sched_UE_list++;
//*scheduler_flags |= (flag_uss_v<<i);
//max = MAX(max, mac_inst->UE_list_spec[i].NPDCCH_config_dedicated.T);
LOG_D(MAC,"[%d][USS_scheduling_module] UE_list num: %d, num subframe: %d\n", mac_inst->current_subframe, i, mac_inst->UE_list_spec[i].NPDCCH_config_dedicated.T);
}
else
{
UE_list_flag[i]=0;
}
}
// Update available resource
if(num_sched_UE_list > 0)
{
LOG_D(MAC,"[%d][USS_scheduling_module] extend resource\n", mac_inst->current_subframe);
//DEBUG("[%04d][USS_scheduling_module] In extend_available_resource_DL\n", mac_inst->current_subframe);
extend_available_resource_DL(mac_inst, mac_inst->current_subframe +1 + max_subframe);
}
maintain_available_resource(mac_inst);
// reserve resource for NPRACH
if((abs_subframe % rachperiod[4]) == rachstart[0])
{
//DEBUG("[%04d][USS_scheduling_module] In add_UL_Resource\n", mac_inst->current_subframe);
add_UL_Resource();
}
//The scheduling time is current subframe + 1
convert_system_number(abs_subframe+1, &h, &f, &sf);
// loop all USS period
for(UE_list_index=0;UE_list_index<total_num_UE_list;++UE_list_index)
{
//if((scheduler_flags&(flag_uss_v<<i))>0){
if(UE_list_flag[UE_list_index]==1)
{
LOG_D(MAC,"--------------[%04d][USS_scheduling_module] Schedule USS list %d------------\n", mac_inst->current_subframe, UE_list_index);
//USS Scheduling for corresponding index
schedule_uss_NB_IoT(0, mac_inst,sf, f, h, UE_list_index);
LOG_D(MAC,"--------------[%04d][USS_scheduling_module] Schedule USS list %d end------------\n", mac_inst->current_subframe, UE_list_index);
//scheduler_flags &= ~(flag_uss_v<<i);
}
}
// flag for generating SIB1 and MIB message
if(abs_subframe%10 == 0)
MIB_flag = 1;
if(abs_subframe%10 == 4 && mac_inst->sib1_flag[abs_subframe/10%mac_inst->sib1_period])
SIB1_flag = 1;
// handling output to L1
a = output_handler(mac_inst, 0,0,h,f,sf,MIB_flag,SIB1_flag, abs_subframe);
if(a==-1)
LOG_D(MAC,"[%04d][USS_scheduling_module] schedule result is empty------------\n", mac_inst->current_subframe);
}
void schedule_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, uint32_t subframe, uint32_t frame, uint32_t hypersfn, int UE_list_index)
{
UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info;
UE_TEMPLATE_NB_IoT *UE_template_temp;
DCIFormatN1_t *DCI_N1;
DCIFormatN0_t *DCI_N0;
//SCHEDULE_NB_IoT_t *scheduler = &eNB->scheduler;
mac_inst->scheduling_flag.flag_uss[0]=1;
mac_inst->scheduling_flag.flag_uss[1]=0;
mac_inst->scheduling_flag.flag_uss[2]=0;
mac_inst->scheduling_flag.num_uss_run = 0;
int UE_ID;
//search space index
//int index_ss=0;
int UE_ID;
UE_TEMPLATE_NB_IoT *UE_template_temp;
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT] Start processing preprocessor\n", mac_inst->current_subframe);
/***algorithm for USS scheduling***/
preprocessor_uss_NB_IoT(module_id, mac_inst, subframe, frame, hypersfn, UE_list_index);
if(mac_inst->scheduling_flag.num_uss_run > 1)
{
//spectial case
}
else
{
//general case
}
UE_ID = mac_inst->UE_list_spec[index_ss].head;
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT] Finish processing preprocessor\n", mac_inst->current_subframe);
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT] Do USS Final Scheduling\n", mac_inst->current_subframe);
UE_ID = mac_inst->UE_list_spec[UE_list_index].head;
while(UE_ID>-1)
{
UE_template_temp = &(mac_inst->UE_list_spec[index_ss].UE_template_NB_IoT[UE_ID]);
UE_template_temp = &(mac_inst->UE_list_spec[UE_list_index].UE_template_NB_IoT[UE_ID]);
UE_sched_ctrl_info = &(mac_inst->UE_list_spec[UE_list_index].UE_sched_ctrl_NB_IoT[UE_ID]);
LOG_D(MAC,"------Start Scheduling USS UE RNTI %d------\n", UE_template_temp->rnti);
if(UE_template_temp->RRC_connected!=1)
if((UE_template_temp->RRC_connected==1)&&(UE_sched_ctrl_info->flag_schedule_success==1))
{
LOG_D(MAC,"[%04d][USS scheduler][UE%d] rrc not connected\n", mac_inst->current_subframe, UE_template_temp->rnti);
switch(UE_template_temp->direction)
{
case 1: // Downlink Scheduling
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT][UE%d] USS DL Final scheduling\n", mac_inst->current_subframe, UE_template_temp->rnti);
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT][UE%d] UE_sched_ctrl NPDCCH information:sf_start %d sf end %d\n", mac_inst->current_subframe, UE_template_temp->rnti, UE_sched_ctrl_info->NPDCCH_sf_start, UE_sched_ctrl_info->NPDCCH_sf_end);
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT][UE%d] UE_sched_ctrl NPDSCH information:sf_start %d sf end %d\n", mac_inst->current_subframe, UE_template_temp->rnti, UE_sched_ctrl_info->NPDSCH_sf_start, UE_sched_ctrl_info->NPDSCH_sf_end);
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT][UE%d] UE_sched_ctrl HARQ information:sf_start %d sf end %d\n", mac_inst->current_subframe, UE_template_temp->rnti, UE_sched_ctrl_info->HARQ_sf_start, UE_sched_ctrl_info->HARQ_sf_end);
DCI_N1 = (DCIFormatN1_t*)malloc(sizeof(DCIFormatN1_t));
fill_DCI_N1(DCI_N1, UE_template_temp, UE_sched_ctrl_info);
generate_scheduling_result_DL(UE_sched_ctrl_info->NPDCCH_sf_end, UE_sched_ctrl_info->NPDCCH_sf_start, UE_sched_ctrl_info->NPDSCH_sf_end, UE_sched_ctrl_info->NPDSCH_sf_start, UE_sched_ctrl_info->HARQ_sf_end, UE_sched_ctrl_info->HARQ_sf_start, DCI_N1, UE_template_temp->rnti, UE_sched_ctrl_info->TBS, UE_template_temp->DLSCH_pdu.payload);
UE_template_temp->R_dci=UE_sched_ctrl_info->R_dci;
UE_template_temp->R_dl=UE_sched_ctrl_info->R_dl_data;
UE_template_temp->I_mcs_dl=UE_sched_ctrl_info->dci_n1_index_mcs;
UE_template_temp->DLSCH_pdu_size=UE_sched_ctrl_info->TBS;
if(UE_template_temp->HARQ_round==0)
UE_template_temp->oldNDI_DL=(UE_template_temp->oldNDI_DL+1)%2;
break;
case 0: // Uplink
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT][UE%d] USS UL Final scheduling\n", mac_inst->current_subframe, UE_template_temp->rnti);
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT][UE%d] UE_sched_ctrl NPDCCH information:sf_start %d sf end %d\n", mac_inst->current_subframe, UE_template_temp->rnti, UE_sched_ctrl_info->NPDCCH_sf_start, UE_sched_ctrl_info->NPDCCH_sf_end);
LOG_D(MAC,"[%04d][schedule_uss_NB_IoT][UE%d] UE_sched_ctrl NPUSCH information:sf_start %d sf end %d\n", mac_inst->current_subframe, UE_template_temp->rnti, UE_sched_ctrl_info->NPUSCH_sf_start, UE_sched_ctrl_info->NPUSCH_sf_end);
DCI_N0 = (DCIFormatN0_t*)malloc(sizeof(DCIFormatN0_t));
//generate DCI-N0 content
//fill_DCI_N0(DCI_N0, UE_template_temp, UE_sched_ctrl_info);
generate_scheduling_result_UL(UE_sched_ctrl_info->NPDCCH_sf_start, UE_sched_ctrl_info->NPDCCH_sf_end,UE_sched_ctrl_info->NPUSCH_sf_start, UE_sched_ctrl_info->NPUSCH_sf_end,DCI_N0, UE_template_temp->rnti, str22, str23);
//sotre UE_template
UE_template_temp->R_dci=UE_sched_ctrl_info->R_dci;
UE_template_temp->R_ul=UE_sched_ctrl_info->R_ul_data;
if(UE_template_temp->HARQ_round == 0)
{
UE_template_temp->oldNDI_UL=1-UE_template_temp->oldNDI_UL;
}
break;
case -1: // Idle
//DEBUG("current idle.. \n");
break;
default:
break;
}
}
else
UE_sched_ctrl_info -> flag_schedule_success = 0;
}
UE_ID = UE_template_temp->next;
}
void preprocessor_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, uint32_t subframe, uint32_t frame, uint32_t hypersfn, int UE_list_index)
{
int ue_id;
UE_TEMPLATE_NB_IoT *UE_template_temp;
UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info;
ue_id = mac_inst->UE_list_spec[UE_list_index].head;
while(ue_id>-1)
{
UE_template_temp = &(mac_inst->UE_list_spec[UE_list_index].UE_template_NB_IoT[ue_id]);
UE_sched_ctrl_info = &(mac_inst->UE_list_spec[UE_list_index].UE_sched_ctrl_NB_IoT[ue_id]);
//determine index of MCS, TBS, R, R_max, R_dci, R_harq
UE_sched_ctrl_info->R_dci=UE_template_temp->R_dci;
//Set repetition number of downlink transmission
if(UE_template_temp->direction==1)
{
UE_sched_ctrl_info->R_dl_data=UE_template_temp->R_dl;
UE_sched_ctrl_info->R_dl_harq=UE_template_temp->R_harq;
UE_sched_ctrl_info->dci_n1_index_mcs=UE_template_temp->I_mcs_dl;
LOG_D(MAC,"[%04d][preprocessor_uss_NB_IoT][UE%d] Initialze R_dci %d R_data_dl %d R_harq %d \n", mac_inst->current_subframe, UE_template_temp->rnti, UE_sched_ctrl_info->R_dci=UE_template_temp->R_dci, UE_sched_ctrl_info->R_dl_data, UE_sched_ctrl_info->R_dl_harq=UE_template_temp->R_harq);
//determine how many SF for data transmission
//store_rlc_logical_channel_info_dl();
}
//Set repetition number of UL transmission
else
{
UE_sched_ctrl_info->R_ul_data=UE_template_temp->R_ul;
}
ue_id = UE_template_temp->next;
}
//sort all UE regardless DL or UL UEs
sort_UEs_uss();
ue_id = mac_inst->UE_list_spec[UE_list_index].head;
//Resource scheduling algorithm
while(ue_id>-1)
{
UE_template_temp = &(mac_inst->UE_list_spec[UE_list_index].UE_template_NB_IoT[ue_id]);
UE_sched_ctrl_info = &(mac_inst->UE_list_spec[UE_list_index].UE_sched_ctrl_NB_IoT[ue_id]);
// UE not finish RA or finish transmission
if(UE_template_temp->RRC_connected!=1)
{
LOG_D(MAC,"[%04d][USS scheduler][UE%d] ", mac_inst->current_subframe, UE_template_temp->rnti);
switch(UE_template_temp->direction)
LOG_D(MAC,"[%04d][preprocessor_uss_NB_IoT][UE%d] rrc not connected\n", mac_inst->current_subframe, UE_template_temp->rnti);
}
// Finish RA
else
{
//DEBUG("[%04d][preprocessor_uss_NB_IoT][UE%d] ", mac_inst->current_subframe, UE_template_temp->rnti);
//DEBUG("[%04d][preprocessor_uss_NB_IoT][UE%d] Start scheduling\n", mac_inst->current_subframe, UE_template_temp->rnti);
switch(UE_template_temp->direction)
{
case 1: // Downlink Scheduling
case 1: // Downlink resource allocation algorithm
LOG_D(MAC,"uss downlink scheduling.. \n");
schedule_DL_NB_IoT((module_id_t)0, mac_inst, UE_template_temp, hypersfn, frame, subframe);
break;
case 0: // Uplink Scheduling
//schedule_DL_NB_IoT(0, mac_inst, UE_template_temp, hypersfn, frame, subframe);
if(0==schedule_DL_NB_IoT(0, mac_inst, UE_template_temp, hypersfn, frame, subframe, UE_sched_ctrl_info))
{
LOG_D(MAC,"[%04d][preprocessor_uss_NB_IoT][UE%d] DL scheduling USS is successful\n", mac_inst->current_subframe, UE_template_temp->rnti);
UE_sched_ctrl_info->flag_schedule_success=1;
}
else
{
LOG_D(MAC,"[%04d][preprocessor_uss_NB_IoT][UE%d] DL scheduling USS is failed\n", mac_inst->current_subframe, UE_template_temp->rnti);
}
break;
case 0: // Uplink resource allocation algorithm
LOG_D(MAC,"uss uplink scheduling.. \n");
schedule_UL_NB_IoT(mac_inst, UE_template_temp, subframe, frame, hypersfn);
if(0==schedule_UL_NB_IoT(mac_inst, UE_template_temp, subframe, frame, hypersfn, UE_sched_ctrl_info))
{
LOG_D(MAC,"[%04d][preprocessor_uss_NB_IoT][UE%d] UL scheduling USS is successful\n", mac_inst->current_subframe, UE_template_temp->rnti);
UE_sched_ctrl_info->flag_schedule_success=1;
}
else
{
LOG_D(MAC,"[%04d][preprocessor_uss_NB_IoT][UE%d] UL scheduling USS is failed\n", mac_inst->current_subframe, UE_template_temp->rnti);
}
break;
//schedule_UL_NB_IoT(mac_inst, UE_template_temp, subframe, frame, hypersfn);
break;
case -1: // Idle
LOG_D(MAC,"current idle.. \n");
case -1: // Idle state, no data wait to send
//sDEBUG("current idle.. \n");
default:
break;
}
}
UE_ID = UE_template_temp->next;
ue_id = UE_template_temp->next;
}
}
void sort_UEs_uss()
{
//loop all UE
}
\ No newline at end of file
......@@ -113,9 +113,7 @@ void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
int fail_num = 0;
int flag=0;
while((RA_TEMPLATE_NB_IoT *)0 != msg2_nodes){
if(flag==0)
flag=1;
fail=0;
fail=0;
rmax = mac_inst->rrc_config.mac_NPRACH_ConfigSIB[msg2_nodes->ce_level].mac_npdcch_NumRepetitions_RA_NB_IoT;//32;
num_candidate = 8;//rmax / r;
r = rmax/num_candidate;
......@@ -227,6 +225,11 @@ void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
dci_result->R_harq = 0;
dci_result->next = (schedule_result_t *)0;
dci_result->DCI_pdu = (void *)dci_n1_rar;
//----------clare
dci_result->dl_sdly = msg2_subframe - dci_end_subframe;
dci_result->ul_sdly = msg3_subframe - msg2_end_subframe;
dci_result->num_sf = msg2_end_subframe - msg2_subframe+1;
//----------clare
// for msg2
msg2_result->output_subframe = msg2_first_subframe;//msg2_subframe;
msg2_result->end_subframe = msg2_end_subframe;
......@@ -242,6 +245,10 @@ void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
msg2_result->next = (schedule_result_t *)0;
msg2_result->DCI_pdu = (void *)dci_n1_rar;
msg2_result->rar_buffer = msg2_nodes->rar_buffer;
//----------clare
msg2_result->dl_sdly = -1;
msg2_result->ul_sdly = -1;
//----------clare
// for msg3(fake DCI N0)
dci_n0->type = 0;
......@@ -542,6 +549,12 @@ void schedule_msg3_retransimission_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs
dci_result->R_harq = 0;
dci_result->next = (schedule_result_t *)0;
dci_result->DCI_pdu = (void *)dci_n0_msg3;
//----------clare
dci_result->dl_sdly = msg3_subframe - dci_end_subframe + 1;
dci_result->ul_sdly = -1;
dci_result->num_sf = -1;
dci_result->harq_round = msg3_nodes->msg3_retransmit_count;
//----------clare
// fill dci resource
fill_resource_DL(mac_inst, dci_node, dci_first_subframe, dci_end_subframe, dci_result);
......@@ -632,7 +645,7 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
available_resource_DL_t *dci_node, *msg4_node;
int rmax, fail, r;
int dci_subframe, dci_end_subframe, dci_first_subframe, num_dci_subframe;
int msg4_subframe, msg4_end_subframe, msg4_first_subframe, num_msg4_subframe;
int msg4_subframe = 0, msg4_end_subframe, msg4_first_subframe, num_msg4_subframe;
int harq_subframe, harq_end_subframe;
int dci_candidate, num_candidate;
......@@ -776,6 +789,12 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
dci_result->R_harq = 0;
dci_result->next = (schedule_result_t *)0;
dci_result->DCI_pdu = (void *)dci_n1_msg4;
//-------clare
dci_result->dl_sdly = msg4_subframe - dci_end_subframe;
dci_result->ul_sdly = harq_subframe - msg4_end_subframe;
dci_result->num_sf = msg4_end_subframe - msg4_subframe+1;
dci_result->harq_round = msg4_nodes->msg4_retransmit_count;
//-------clare
// for msg4
msg4_result = (schedule_result_t *)malloc(sizeof(schedule_result_t));
......@@ -804,7 +823,8 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
harq_result->DCI_release = 1;
harq_result->channel = NPUSCH;
harq_result->next = (schedule_result_t *)0;
LOG_D(MAC,"[%04d][RA scheduler][MSG4] UE:%x MSG4DCI %d-%d MSG4 %d-%d HARQ %d-%d\n", abs_subframe-1, msg4_nodes->ue_rnti, dci_first_subframe, dci_end_subframe, msg4_first_subframe, msg4_end_subframe, HARQ_info.sf_start, HARQ_info.sf_end);
LOG_D(MAC,"[%04d][RA scheduler][MSG4][CE%d] MSG4 DCI %d-%d MSG4 %d-%d HARQ %d-%d\n", abs_subframe-1, msg4_nodes->ce_level, dci_first_subframe, dci_end_subframe, msg4_first_subframe, msg4_end_subframe, HARQ_info.sf_start, HARQ_info.sf_end);
msg4_nodes->msg4_retransmit_count++;
......
......@@ -27,8 +27,10 @@ void schedule_sibs(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t sibs_order, int start
schedule_result_t *new_node;
DCIFormatN1_t *sibs_dci;
uint32_t j, i, k;
uint8_t SIB23_size = 0;
uint8_t *SIB23_pdu = get_NB_IoT_SIB23();
//------clare
//uint8_t SIB23_size = 0;
//uint8_t *SIB23_pdu = get_NB_IoT_SIB23();
//------clare
int residual_subframe, num_subframe, last_subframe;
num_subframe = mac_inst->rrc_config.sibs_NB_IoT_sched[sibs_order].si_tb;
......@@ -75,15 +77,17 @@ void schedule_sibs(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t sibs_order, int start
sibs_dci->DCIRep = 0;
for(k=0, j=start_subframe1;j<=i;++k, j+=si_repetition_pattern[mac_inst->rrc_config.sibs_NB_IoT_sched[sibs_order].si_repetition_pattern]){
LOG_D(MAC,"for1 k=%d j=%d i=%d rep=%d\n", k, j, i, si_repetition_pattern[mac_inst->rrc_config.sibs_NB_IoT_sched[sibs_order].si_repetition_pattern]);
LOG_D(MAC,"for1 k=%d j=%d i=%d rep=%d\n", k, j, i, si_repetition_pattern[mac_inst->rrc_config.sibs_NB_IoT_sched[sibs_order].si_repetition_pattern]);
if((available_resource_DL_t *)0 != pt[k]){
new_node = (schedule_result_t *)malloc(sizeof(schedule_result_t));
// fill new node
SIB23_size = get_NB_IoT_SIB23_size();
//SIB23_size = get_NB_IoT_SIB23_size();
new_node->output_subframe = first_subframe[k];
new_node->end_subframe = (j==i)?last_subframe:j+9;
new_node->sdu_length = SIB23_size;
new_node->DLSCH_pdu = SIB23_pdu;
//------clare
new_node->sdu_length = 0;
//new_node->DLSCH_pdu = SIB23_pdu;
//------clare
new_node->direction = DL;
new_node->DCI_release = (j==i);
new_node->channel = NPDSCH;
......@@ -94,11 +98,11 @@ LOG_D(MAC,"for1 k=%d j=%d i=%d rep=%d\n", k, j, i, si_repetition_pattern[mac_ins
new_node->next = (schedule_result_t *)0;
new_node->DCI_pdu = (void *)sibs_dci;
//new_node->debug_str = str[sibs_order];
LOG_D(MAC,"for*1 %d %d %d %p\n", pt[k]->start_subframe, first_subframe[k], (j==i)?last_subframe:j+9, new_node);
LOG_D(MAC,"for*1 %d %d %d %p\n", pt[k]->start_subframe, first_subframe[k], (j==i)?last_subframe:j+9, new_node);
fill_resource_DL(mac_inst, pt[k], first_subframe[k], (j==i)?last_subframe:j+9, new_node);
LOG_D(MAC,"for*2\n");
LOG_D(MAC,"for*2\n");
}
LOG_D(MAC,"for2\n");
LOG_D(MAC,"for2\n");
}
return ;
......
......@@ -29,10 +29,11 @@
#include "defs_NB_IoT.h"
#include "proto_NB_IoT.h"
#include "extern_NB_IoT.h"
#include "extern_NB_IoT.h"
/*DL scheduler*/
void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_TEMPLATE_NB_IoT *UE_info, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start)
int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_TEMPLATE_NB_IoT *UE_info, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info)
{
//number of candidate
int cdd_num;
......@@ -42,10 +43,16 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
sched_temp_DL_NB_IoT_t *NPDCCH_info = (sched_temp_DL_NB_IoT_t*)malloc(sizeof(sched_temp_DL_NB_IoT_t));
sched_temp_DL_NB_IoT_t *NPDSCH_info = (sched_temp_DL_NB_IoT_t*)malloc(sizeof(sched_temp_DL_NB_IoT_t));
sched_temp_UL_NB_IoT_t *HARQ_info = (sched_temp_UL_NB_IoT_t*)malloc(sizeof(sched_temp_UL_NB_IoT_t));
//Eric current remove it
//DCI N1
DCIFormatN1_t *DCI_N1 = (DCIFormatN1_t*)malloc(sizeof(DCIFormatN1_t));
//DCIFormatN1_t *DCI_N1 = (DCIFormatN1_t*)malloc(sizeof(DCIFormatN1_t));
//RLC Status
//mac_rlc_status_resp_t rlc_status;
//Eric
//mac_rlc_status_resp_NB_IoT_t rlc_status;
/*Index in DCI_N1*/
uint32_t I_mcs, I_tbs, I_delay, I_sf;
/*value for corresponding index*/
......@@ -62,10 +69,15 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
//uint32_t mac_sdu_size;
//uint8_t sdu_temp[SCH_PAYLOAD_SIZE_MAX_NB_IoT];
//Eric
//logical_chan_id_t logical_channel;
//Eric
uint32_t subheader_length=2;
//uint32_t payload_offset;
uint32_t search_space_end_sf, h_temp, f_temp, sf_temp;
......@@ -74,6 +86,19 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
//get max TBS
TBS = get_max_tbs(I_tbs);
//Eric
if(UE_info->HARQ_round==0)
{
flag_retransmission=0;
data_size=UE_sched_ctrl_info->total_sdu_size;
}
else
{
flag_retransmission=1;
data_size=UE_info->DLSCH_pdu_size;
}
//Eric
LOG_D(MAC,"[%04d][DLSchedulerUSS] Max TBS %d MCS index %d TBS index %d\n", mac_inst->current_subframe, TBS, I_mcs, I_tbs);
/*set UE data information*/
/*New transmission*/
......@@ -139,9 +164,11 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
LOG_D(MAC,"[%04d][DLSchedulerUSS] Search_space_start_sf %d Search_space_end_sf %d\n", convert_system_number_sf(hyperSF_start, frame_start, subframe_start), mac_inst->current_subframe, search_space_end_sf);
//LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] Search_space_start_sf %d Search_space_end_sf %d\n", mac_inst->current_subframe, UE_info->rnti, mac_inst->current_subframe, convert_system_number_sf(hyperSF_start, frame_start, subframe_start), search_space_end_sf);
/*Loop all NPDCCH candidate position*/
for(cdd_num=0;cdd_num<UE_info->R_max/UE_info->R_dci;++cdd_num)
//Eric
for(cdd_num=0;cdd_num<UE_info->R_max/UE_sched_ctrl_info->R_dci;++cdd_num)
//Eric
{
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Candidate num %d DCI Rep %d\n", cdd_num, UE_info->R_dci);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Candidate num %d DCI Rep %d\n",mac_inst->current_subframe, cdd_num, UE_sched_ctrl_info->R_dci);
/*Check NPDCCH Resource*/
end_flagCCH = check_resource_NPDCCH_NB_IoT(mac_inst, hyperSF_start, frame_start, subframe_start, NPDCCH_info, cdd_num, UE_info->R_dci);
......@@ -149,27 +176,30 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
/*Check NPDSCH Resource*/
if(end_flagCCH!=-1)
{
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Candidate num %d allocate success\n", cdd_num);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Candidate num %d allocate success\n",mac_inst->current_subframe, cdd_num);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Allocate NPDCCH subframe %d to subframe %d cdd index %d\n", mac_inst->current_subframe, NPDCCH_info->sf_start, NPDCCH_info->sf_end, cdd_num);
/*
//Max DL TBS
if(TBS > data_size+subheader_length)
{
TBS = get_tbs(data_size, I_tbs, &I_sf);
LOG_D(MAC,"[%04d][DLSchedulerUSS] TBS change to %d because data size is smaller than previous TBS\n", mac_inst->current_subframe, TBS);
//Eric
LOG_D(MAC,"[%04d][DLSchedulerUSS] [%d] data_size %d TBS change to %d \n", mac_inst->current_subframe,UE_info->rnti, data_size, TBS);
//Eric
}
*/
//Get number of subframe this UE need per repetition
n_sf = get_num_sf(I_sf);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Number SF %d index SF %d\n", n_sf, I_sf);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Require total %d DL SF Rep %d\n", n_sf*UE_info->R_dl, UE_info->R_dl);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Number SF %d index SF %d\n",mac_inst->current_subframe, n_sf, I_sf);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Require total %d DL SF Rep %d\n", n_sf*UE_sched_ctrl_info->R_dl, UE_sched_ctrl_info->R_dl);
//Check have enough NPDSCH resource or not
//loop 8 scheduling delay index
for(I_delay=0;I_delay<8;++I_delay)
{
if(search_space_end_sf<NPDCCH_info->sf_end+get_scheduling_delay(I_delay, UE_info->R_max)+5)
{
end_flagSCH = check_resource_NPDSCH_NB_IoT(mac_inst, NPDSCH_info, NPDCCH_info->sf_end, I_delay, UE_info->R_max, UE_info->R_dl, n_sf);
end_flagSCH = check_resource_NPDSCH_NB_IoT(mac_inst, NPDSCH_info, NPDCCH_info->sf_end, I_delay, UE_info->R_max, UE_sched_ctrl_info->R_dl_data, n_sf);
//Have available resource
/*Check HARQ resource*/
if(end_flagSCH!=-1)
......@@ -179,7 +209,7 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
for(HARQ_delay=0;HARQ_delay<4;++HARQ_delay)
{
//LOG_D(MAC,"[%04d][DLSchedulerUSS] HARQ delay %d\n", mac_inst->current_subframe,get_HARQ_delay(1, HARQ_delay) );
end_flagHARQ=Check_UL_resource(NPDSCH_info->sf_end+get_HARQ_delay(1, HARQ_delay), UE_info->R_harq, HARQ_info, 0, 1);
end_flagHARQ=Check_UL_resource(NPDSCH_info->sf_end+get_HARQ_delay(1, HARQ_delay), UE_sched_ctrl_info->R_dl_harq, HARQ_info, 0, 1);
if(end_flagHARQ!=-1)
{
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Allocate HARQ feedback subframe %d to subframe %d\n", mac_inst->current_subframe, HARQ_info->sf_start, HARQ_info->sf_end);
......@@ -190,7 +220,7 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
UE_info->oldNDI_DL=(UE_info->oldNDI_DL+1)%2;
//New transmission need to request data from RLC and generate new MAC PDU
UE_info->I_mcs_dl = I_mcs;
/*
/*.......
//Request data from RLC layer
rlc_status = mac_rlc_status_ind_NB_IoT(
module_id,
......@@ -204,12 +234,33 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
TBS-subheader_length);
*/
//mac_sdu_size = mac_rlc_data_req_eNB_NB_IoT(module_id, UE_info->rnti, 0, frame_start, 0, DCCH0_NB_IoT, sdu_temp);
//logical_channel=DCCH0_NB_IoT;
//Eric
//channel=DCCH0_NB_IoT;
//Eric
//Generate header
//payload_offset = generate_dlsch_header_NB_IoT(UE_info->DLSCH_pdu.payload, 1, &logical_channel, &mac_sdu_size, 0, 0, TBS);
//Complete MAC PDU
//memcpy(UE_info->DLSCH_pdu.payload+payload_offset, sdu_temp, mac_sdu_size);
UE_info->DLSCH_pdu.pdu_size=TBS;
//Eric
//UE_info->DLSCH_pdu.pdu_size=TBS;
UE_sched_ctrl_info->NPDCCH_sf_end=NPDCCH_info->sf_end;
UE_sched_ctrl_info->NPDCCH_sf_start=NPDCCH_info->sf_start;
UE_sched_ctrl_info->NPDSCH_sf_end=NPDSCH_info->sf_end;
UE_sched_ctrl_info->NPDSCH_sf_start=NPDSCH_info->sf_start;
UE_sched_ctrl_info->HARQ_sf_end=HARQ_info->sf_end;
UE_sched_ctrl_info->HARQ_sf_start=HARQ_info->sf_start;
UE_sched_ctrl_info->TBS=TBS;
UE_sched_ctrl_info->dci_n1_index_mcs=I_mcs;
UE_sched_ctrl_info->index_tbs=I_tbs;
UE_sched_ctrl_info->dci_n1_index_sf=I_sf;
UE_sched_ctrl_info->dci_n1_n_sf=n_sf;
UE_sched_ctrl_info->dci_n1_index_delay=I_delay;
UE_sched_ctrl_info->dci_n1_index_ack_nack=HARQ_info->ACK_NACK_resource_field;
UE_sched_ctrl_info->total_data_size_dl=data_size;
//Eric
}
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d][Success] Complete scheduling with data size %d\n", mac_inst->current_subframe, UE_info->rnti, data_size);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] RNTI %d\n", mac_inst->current_subframe, UE_info->rnti);
......@@ -222,12 +273,17 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] Allocate NPDSCH subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, NPDSCH_info->sf_start, NPDSCH_info->sf_end);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] Allocate HARQ feedback subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, HARQ_info->sf_start, HARQ_info->sf_end);
//Store PDU in UE template for retransmission
fill_DCI_N1(DCI_N1, UE_info, I_delay, I_sf, HARQ_info->ACK_NACK_resource_field);
//fill_DCI_N1(DCI_N1, UE_info, I_delay, I_sf, HARQ_info->ACK_NACK_resource_field);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] HARQ index %d\n", HARQ_info->ACK_NACK_resource_field);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] DCI N1 type:%d order:%d MCS:%d HARQ index:%d R:%d RscAssign:%d scheddly:%d DCI_R:%d\n", mac_inst->current_subframe, UE_info->rnti, DCI_N1->type, DCI_N1->orderIndicator, DCI_N1->mcs, DCI_N1->HARQackRes, DCI_N1->RepNum, DCI_N1->ResAssign, DCI_N1->Scheddly, DCI_N1->DCIRep);
//Eric
//LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] DCI N1 type:%d order:%d MCS:%d HARQ index:%d R:%d RscAssign:%d scheddly:%d DCI_R:%d\n", mac_inst->current_subframe, UE_info->rnti, DCI_N1->type, DCI_N1->orderIndicator, DCI_N1->mcs, DCI_N1->HARQackRes, DCI_N1->RepNum, DCI_N1->ResAssign, DCI_N1->Scheddly, DCI_N1->DCIRep);
//Eric
//Generate Scheduling result for this UE
//generate_scheduling_result_DL(NPDCCH_info->sf_start, NPDSCH_info->sf_start, HARQ_info->sf_start, DCI_N1, UE_info->rnti, TBS, UE_info->DLSCH_pdu.payload);
generate_scheduling_result_DL(NPDCCH_info, NPDSCH_info, HARQ_info, DCI_N1, UE_info->rnti, TBS, UE_info->DLSCH_pdu.payload);
//generate_scheduling_result_DL(NPDCCH_info, NPDSCH_info, HARQ_info, DCI_N1, UE_info->rnti, TBS, UE_info->DLSCH_pdu.payload);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] finish generate scheduling result\n");
//matain DL avialable resource
maintain_resource_DL(mac_inst, NPDCCH_info, NPDSCH_info);
......@@ -268,12 +324,19 @@ void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Candidate %d no resource\n", mac_inst->current_subframe, cdd_num);
}
//Eric
UE_sched_ctrl_info->flag_schedule_success=0;
//Eric
/*Resource allocate fail*/
if((end_flagCCH==-1)||(end_flagSCH==-1)||(end_flagHARQ==-1))
{
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d][Fail] Resource allocate fail\n", mac_inst->current_subframe, UE_info->rnti);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d][Fail] Resource allocate fail\n", mac_inst->current_subframe, UE_info->rnti);
}
//Eric
return -1;
//Eric
}
int check_resource_NPDCCH_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, sched_temp_DL_NB_IoT_t *NPDCCH_info, uint32_t cdd_num, uint32_t dci_rep)
......@@ -359,7 +422,9 @@ uint32_t generate_dlsch_header_NB_IoT(uint8_t *pdu, uint32_t num_sdu, logical_ch
uint32_t num_sdu_L_15;
int32_t padding_size;
uint8_t flag_end_padding=0;
//Eric
SCH_SUBHEADER_FIXED_NB_IoT *mac_header=(SCH_SUBHEADER_FIXED_NB_IoT*)pdu;
//Eric
uint32_t offset=0;
for(i=0;i<num_sdu;++i)
......@@ -428,7 +493,8 @@ uint32_t generate_dlsch_header_NB_IoT(uint8_t *pdu, uint32_t num_sdu, logical_ch
LOG_D(MAC,"last sdu\n");
}
else
{
{
//Eric
if(sdu_length[i]<128)
{
((SCH_SUBHEADER_SHORT_NB_IoT*)mac_header)->LCID = logical_channel[i];
......@@ -454,6 +520,7 @@ uint32_t generate_dlsch_header_NB_IoT(uint8_t *pdu, uint32_t num_sdu, logical_ch
num_subheader--;
offset+=3;
}
//Eric
}
}
if(flag_end_padding==1)
......@@ -467,20 +534,24 @@ uint32_t generate_dlsch_header_NB_IoT(uint8_t *pdu, uint32_t num_sdu, logical_ch
}
return offset;
}
void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, uint32_t scheddly, uint32_t I_sf, uint32_t I_harq)
void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info)
{
DCI_N1->type=1;
DCI_N1->orderIndicator = 0;
DCI_N1->Scheddly = scheddly;
DCI_N1->ResAssign = I_sf;
DCI_N1->mcs = UE_info->I_mcs_dl;
DCI_N1->RepNum = get_index_Rep_dl(UE_info->R_dl);
DCI_N1->HARQackRes = I_harq;
DCI_N1->Scheddly = UE_sched_ctrl_info->dci_n1_index_delay;
DCI_N1->ResAssign =UE_sched_ctrl_info->dci_n1_index_sf;
DCI_N1->mcs = UE_sched_ctrl_info->dci_n1_index_mcs;
DCI_N1->RepNum = UE_sched_ctrl_info->dci_n1_index_sf;
DCI_N1->HARQackRes = UE_sched_ctrl_info->dci_n1_index_ack_nack;
//DCI_N1->DCIRep = 3-UE_info->R_max/UE_info->R_dci/2;
DCI_N1->DCIRep = UE_info->R_dci;
DCI_N1->DCIRep=get_DCI_REP(UE_sched_ctrl_info->R_dci, UE_info->R_max);
// Eric
LOG_D(MAC,"[fill_DCI_N1] Type %d order %d I_delay %d I_SF %d I_mcs %d I_rep %d I_harq %d I_dci %d\n", DCI_N1->type, DCI_N1->orderIndicator, DCI_N1->Scheddly, DCI_N1->ResAssign, DCI_N1->mcs, DCI_N1->RepNum, DCI_N1->HARQackRes, DCI_N1->DCIRep);
// Eric
}
void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_DL_NB_IoT_t* NPDSCH_info, sched_temp_UL_NB_IoT_t* HARQ_info, DCIFormatN1_t *DCI_inst, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu)
void generate_scheduling_result_DL(uint32_t NPDCCH_sf_end, uint32_t NPDCCH_sf_start, uint32_t NPDSCH_sf_end, uint32_t NPDSCH_sf_start, uint32_t HARQ_sf_end, uint32_t HARQ_sf_start, DCIFormatN1_t *DCI_pdu, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu)
{
// create the schedule result node for this time transmission
schedule_result_t *NPDCCH_result = (schedule_result_t*)malloc(sizeof(schedule_result_t));
......@@ -490,75 +561,75 @@ void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_
schedule_result_t *tmp, *tmp1;
/*fill NPDCCH result*/
NPDCCH_result->rnti=rnti;
NPDCCH_result->output_subframe = DCI_info->sf_start;
NPDCCH_result->end_subframe = DCI_info->sf_end;
NPDCCH_result->output_subframe = NPDCCH_sf_start;
NPDCCH_result->end_subframe = NPDCCH_sf_end;
NPDCCH_result->sdu_length = TBS;
NPDCCH_result->direction = 1;
NPDCCH_result->rnti_type = 3;
NPDCCH_result->DLSCH_pdu = NULL;
NPDCCH_result->DCI_pdu = DCI;
NPDCCH_result->DCI_pdu = (void*)DCI_pdu;
NPDCCH_result->DCI_release = 0;
NPDCCH_result->channel = NPDCCH;
// NPDCCH_result->printf_str = dl_str1;
//NPDCCH_result->debug_str = (uint8_t*)malloc(6*sizeof(uint8_t));
//NPDCCH_result->debug_str = dl_str1;
NPDCCH_result->next = NULL;
/*fill NPDSCH result*/
NPDSCH_result->rnti=rnti;
//NPDSCH_result->output_subframe = NPDSCH_subframe;
NPDSCH_result->output_subframe = NPDSCH_info->sf_start;
NPDSCH_result->end_subframe = NPDSCH_info->sf_end;
NPDSCH_result->output_subframe = NPDSCH_sf_start;
NPDSCH_result->end_subframe = NPDSCH_sf_end;
NPDSCH_result->sdu_length = TBS;
//NPDSCH_result->DLSCH_pdu = DLSCH_pdu;
NPDSCH_result->DLSCH_pdu = NULL;
NPDSCH_result->direction = 1;
NPDSCH_result->rnti_type = 3;
NPDSCH_result->DCI_pdu = DCI;
NPDSCH_result->DCI_pdu = (void*)DCI_pdu;
NPDSCH_result->DCI_release = 0;
NPDSCH_result->channel = NPDSCH;
//NPDSCH_result->printf_str = dl_str2;
//NPDSCH_result->debug_str = (uint8_t*)malloc(7*sizeof(uint8_t));
//NPDSCH_result->debug_str = dl_str2;
NPDSCH_result->next = NULL;
/*fill HARQ result*/
HARQ_result->rnti=rnti;
//HARQ_result->output_subframe = HARQ_subframe;
HARQ_result->output_subframe = HARQ_info->sf_start;
HARQ_result->end_subframe = HARQ_info->sf_end;
HARQ_result->output_subframe = HARQ_sf_start;
HARQ_result->end_subframe = HARQ_sf_end;
HARQ_result->sdu_length = 0;
HARQ_result->direction = 0;
HARQ_result->rnti_type = 3;
HARQ_result->DLSCH_pdu = NULL;
HARQ_result->DCI_pdu = DCI;
HARQ_result->DCI_pdu = (void*)DCI_pdu;
HARQ_result->DCI_release = 1;
HARQ_result->channel = NPUSCH;
HARQ_result->npusch_format = 1;
// HARQ_result->printf_str = dl_str3;
//HARQ_result->debug_str = (uint8_t*)malloc(7*sizeof(uint8_t));
//HARQ_result->debug_str = dl_str3;
HARQ_result->next = NULL;
//LOG_D(MAC,"[generate_scheduling_result_DL] Generate NPDCCH node\n");
//DEBUG("[generate_scheduling_result_DL] Generate NPDCCH node\n");
/*NPDCCH scheduling result*/
// be the first node of the DL scheduling result
tmp = NULL;
tmp1 = NULL;
if(schedule_result_list_DL == NULL)
{
//schedule_result_list_DL = (schedule_result_t*)malloc(sizeof(schedule_result_t));
schedule_result_list_DL = NPDCCH_result;
LOG_D(MAC,"[generate_scheduling_result_DL] Generate NPDCCH node at head\n");
//DEBUG("[generate_scheduling_result_DL] Generate NPDCCH node at head\n");
}
else
{
tmp = schedule_result_list_DL;
while(tmp!=NULL)
{
if(DCI_info->sf_start < tmp->output_subframe)
if(NPDCCH_sf_start < tmp->output_subframe)
{
break;
}
tmp1 = tmp;
tmp = tmp->next;
//LOG_D(MAC,"[generate_scheduling_result_DL] node output subframe %d at NPDCCH part\n", tmp->output_subframe);
//DEBUG("[generate_scheduling_result_DL] node output subframe %d at NPDCCH part\n", tmp->output_subframe);
}
/*tail*/
if(tmp==NULL)
......@@ -578,17 +649,18 @@ void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_
}
}
}
//LOG_D(MAC,"[generate_scheduling_result_DL] Generate NPDCSH node\n");
//DEBUG("[generate_scheduling_result_DL] Generate NPDCSH node\n");
/*NPDSCH scheduling result*/
tmp1 = NULL;
tmp = schedule_result_list_DL;
while(tmp!=NULL)
{
if(NPDSCH_info->sf_start < tmp->output_subframe)
if(NPDSCH_sf_start < tmp->output_subframe)
{
break;
}
//LOG_D(MAC,"[generate_scheduling_result_DL] node output subframe %d at NPDSCH part\n", tmp->output_subframe);
//DEBUG("[generate_scheduling_result_DL] node output subframe %d at NPDSCH part\n", tmp->output_subframe);
tmp1 = tmp;
tmp = tmp->next;
}
......@@ -608,14 +680,18 @@ void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_
schedule_result_list_DL = NPDSCH_result;
}
}
//LOG_D(MAC,"[generate_scheduling_result_DL] Generate HARQ node\n");
//DEBUG("[generate_scheduling_result_DL] Generate HARQ node\n");
/*HARQ scheduling result*/
// be the first node of UL
// be the first node of UL
// Eric
#if 1
// Eric
tmp1 = NULL;
tmp = NULL;
if(schedule_result_list_UL == NULL)
{
//DEBUG("[generate_scheduling_result_DL] LIST NULL, Generate HARQ at HEAD\n");
//schedule_result_list_UL = (schedule_result_t*)malloc(sizeof(schedule_result_t));
schedule_result_list_UL = HARQ_result;
}
......@@ -624,17 +700,17 @@ void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_
tmp = schedule_result_list_UL;
while(tmp!=NULL)
{
if(HARQ_info->sf_start < tmp->output_subframe)
if(HARQ_sf_start < tmp->output_subframe)
{
break;
}
//LOG_D(MAC,"[generate_scheduling_result_DL] node output subframe %d at HARQ part\n", tmp->output_subframe);
//DEBUG("[generate_scheduling_result_DL] node output subframe %d at HARQ part\n", tmp->output_subframe);
tmp1 = tmp;
tmp = tmp->next;
}
if(tmp==NULL)
{
//DEBUG("[generate_scheduling_result_DL] Generate HARQ at Tail\n");
tmp1->next = HARQ_result;
}
else
......@@ -642,23 +718,20 @@ void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_
HARQ_result->next = tmp;
if(tmp1)
{
//DEBUG("[generate_scheduling_result_DL] Generate HARQ in normal\n");
tmp1->next = HARQ_result;
}else
{
//DEBUG("[generate_scheduling_result_DL] Generate HARQ at Head\n");
schedule_result_list_UL = HARQ_result;
}
}
}
/*
LOG_D(MAC,"---[generate_scheduling_result_DL] schedule result after generate---\n");
tmp = schedule_result_list_DL;
while(tmp!=NULL)
{
LOG_D(MAC,"[generate_scheduling_result_DL] node output subframe %d\n", tmp->output_subframe);
tmp = tmp->next;
}
*/
// Eric
#endif
// Eric
}
void maintain_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, sched_temp_DL_NB_IoT_t *NPDCCH_info, sched_temp_DL_NB_IoT_t *NPDSCH_info)
{
available_resource_DL_t *temp;
......@@ -917,13 +990,17 @@ uint32_t get_I_mcs(int CE_level)
uint32_t get_max_tbs(uint32_t I_tbs)
{
//Eric
return MAC_TBStable_NB_IoT[I_tbs][7]/8;
//Eric
}
uint32_t get_tbs(uint32_t data_size, uint32_t I_tbs, uint32_t *I_sf)
{
//Eric
for((*I_sf)=0;(*I_sf)<8;++(*I_sf))
{
//LOG_D(MAC,"[get_tbs]TBS %d SF index %d\n", TBStable_NB_IoT[I_tbs][(*I_sf)], *I_sf);
if(MAC_TBStable_NB_IoT[I_tbs][(*I_sf)]>=data_size*8)
{
......@@ -932,6 +1009,7 @@ uint32_t get_tbs(uint32_t data_size, uint32_t I_tbs, uint32_t *I_sf)
}
LOG_D(MAC,"error\n");
return 0;
//Eric
}
uint32_t get_num_sf(uint32_t I_sf)
......
......@@ -35,14 +35,16 @@ unsigned char str20[] = "DCI_uss";
unsigned char str21[] = "DATA_uss";
// scheduling UL
int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info,uint32_t subframe, uint32_t frame, uint32_t H_SFN){
//-------Daniel
int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info,uint32_t subframe, uint32_t frame, uint32_t H_SFN, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info){
//-------Daniel
int i,ndi = 0,check_DCI_result = 0,check_UL_result = 0,candidate;
uint32_t DL_end;
//Scheduling resource temp buffer
sched_temp_DL_NB_IoT_t *NPDCCH_info = (sched_temp_DL_NB_IoT_t*)malloc(sizeof(sched_temp_DL_NB_IoT_t));
candidate = UE_info->R_max/UE_info->R_dci;
//-------Daniel
candidate = UE_info->R_max/UE_sched_ctrl_info->R_dci;
//-------Daniel
uint32_t mcs = max_mcs[UE_info->multi_tone];
uint32_t mappedMcsIndex=UE_info->PHR+(4 * UE_info->multi_tone);
int TBS = 0;
......@@ -51,35 +53,46 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
if(UE_info->ul_total_buffer<=0)
{
LOG_D(MAC,"[%04d][UL scheduler][UE:%05d] No UL data in buffer\n", mac_inst->current_subframe, UE_info->rnti);
//------Daniel
LOG_D(MAC,"[%04d][ULSchedulerUSS][UE:%05d] No UL data in buffer\n", mac_inst->current_subframe, UE_info->rnti);
//------Daniel
return -1;
}
TBS=get_TBS_UL_NB_IoT(mcs,UE_info->multi_tone,Iru);
//-------Daniel
LOG_D(MAC,"Initial TBS : %d UL_buffer: %d\n", TBS, UE_info->ul_total_buffer);
//-------Daneil
sched_temp_UL_NB_IoT_t *NPUSCH_info = (sched_temp_UL_NB_IoT_t*)malloc(sizeof(sched_temp_UL_NB_IoT_t));
DCIFormatN0_t *DCI_N0 = (DCIFormatN0_t*)malloc(sizeof(DCIFormatN0_t));
//-------Daniel
//DCIFormatN0_t *DCI_N0 = (DCIFormatN0_t*)malloc(sizeof(DCIFormatN0_t));
//-------Daniel
//available_resource_DL_t *node;
// setting of the NDI
//-------Daniel
/*
if(UE_info->HARQ_round == 0)
{
ndi = 1-UE_info->oldNDI_UL;
UE_info->oldNDI_UL=ndi;
}
*/
//-------Daniel
for (i = 0; i < candidate; i++)
{
/*step 1 : Check DL resource is available for DCI N0 or not*/
check_DCI_result = check_resource_NPDCCH_NB_IoT(mac_inst,H_SFN, frame, subframe, NPDCCH_info, i, UE_info->R_dci);
check_DCI_result = check_resource_NPDCCH_NB_IoT(mac_inst,H_SFN, frame, subframe, NPDCCH_info, i, UE_sched_ctrl_info->R_dci);
//node = check_resource_DL(mac_inst,);
//just use to check when there is no DL function
//NPDCCH_info->sf_start = H_SFN*10240+frame*10 +subframe + i * UE_info->R_dci;
//NPDCCH_info->sf_end = NPDCCH_info->sf_start + (i+1) * UE_info->R_dci;
//NPDCCH_info->sf_start = H_SFN*10240+frame*10 +subframe + i * UE_sched_ctrl_info->R_dci;
//NPDCCH_info->sf_end = NPDCCH_info->sf_start + (i+1) * UE_sched_ctrl_info->R_dci;
//LOG_D(MAC,"UE : %5d, NPDCCH result: %d ,NPDCCH start: %d,NPDCCH end : %d\n",UE_info->rnti,check_DCI_result,NPDCCH_info->sf_start,NPDCCH_info->sf_end);
if( check_DCI_result != -1)
......@@ -93,13 +106,26 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
mcs = mapped_mcs[UE_info->CE_level][mappedMcsIndex];
//--------Daniel
if(UE_info->HARQ_round==0)
{
while((TBS<UE_info->ul_total_buffer)&&(Iru<=7))
{
Iru++;
TBS=get_TBS_UL_NB_IoT(mcs,UE_info->multi_tone,Iru);
}
//LOG_D(MAC,"TBS : %d UL_buffer: %d\n", TBS, UE_info->ul_total_buffer);
}
else
{
while((TBS<UE_info->allocated_data_size_ul)&&(Iru<7))
{
Iru++;
TBS=get_TBS_UL_NB_IoT(mcs,UE_info->multi_tone,Iru);
}
}
//--------Daniel
//LOG_D(MAC,"TBS : %d MCS %d I_RU %d\n", TBS, UE_info->ul_total_buffer, mcs, Iru);
Nru = RU_table[Iru];
DL_end = NPDCCH_info->sf_end;
......@@ -107,39 +133,66 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
I_rep = get_I_REP(N_rep);
total_ru = Nru * N_rep;
LOG_D(MAC,"[%04d][UL scheduler][UE:%05d] Multi-tone:%d,MCS:%d,TBS:%d,UL_buffer:%d,DL_start:%d,DL_end:%d,N_rep:%d,N_ru:%d,Total_ru:%d\n", mac_inst->current_subframe,UE_info->rnti,UE_info->multi_tone,mcs,TBS,UE_info->ul_total_buffer,NPDCCH_info->sf_start,DL_end,N_rep,Nru,total_ru);
LOG_D(MAC,"[%04d][ULSchedulerUSS][UE:%05d] Multi-tone:%d,MCS:%d,TBS:%d,UL_buffer:%d,DL_start:%d,DL_end:%d,N_rep:%d,N_ru:%d,Total_ru:%d\n", mac_inst->current_subframe,UE_info->rnti,UE_info->multi_tone,mcs,TBS,UE_info->ul_total_buffer,NPDCCH_info->sf_start,DL_end,N_rep,Nru,total_ru);
/*step 3 Check UL resource for Uplink data*/
// we will loop the scheduling delay here
// we will loop the scheduling delay here
for(dly=0;dly<4;dly++)
{
uplink_time = DL_end +scheduling_delay[dly];
uplink_time = DL_end +scheduling_delay[dly]+1;
check_UL_result = Check_UL_resource(uplink_time,total_ru, NPUSCH_info, UE_info->multi_tone, 0);
if (check_UL_result != -1)
{
// step 4 : generate DCI content
DCI_N0->type = 0;
DCI_N0->scind = NPUSCH_info->subcarrier_indication;
DCI_N0->ResAssign = Iru;
DCI_N0->mcs = mcs;
DCI_N0->ndi = ndi;
DCI_N0->Scheddly = dly;
DCI_N0->RepNum = I_rep;
DCI_N0->rv = (UE_info->HARQ_round%2==0)?0:1; // rv will loop 0 & 2
DCI_N0->DCIRep = get_DCI_REP(UE_info->R_dci,UE_info->R_max);
LOG_D(MAC,"[%04d][UL scheduler][UE:%05d] DCI content = scind : %d ResAssign : %d mcs : %d ndi : %d scheddly : %d RepNum : %d rv : %d DCIRep : %d\n", mac_inst->current_subframe,UE_info->rnti,DCI_N0->scind,DCI_N0->ResAssign,DCI_N0->mcs,DCI_N0->ndi,DCI_N0->Scheddly,DCI_N0->RepNum,DCI_N0->rv,DCI_N0->DCIRep);
//----Daniel
//----Daniel
//----Daniel
//LOG_D(MAC,"[%04d][UL scheduler][UE:%05d] DCI content = scind : %d ResAssign : %d mcs : %d ndi : %d scheddly : %d RepNum : %d rv : %d DCIRep : %d\n", mac_inst->current_subframe,UE_info->rnti,DCI_N0->scind,DCI_N0->ResAssign,DCI_N0->mcs,DCI_N0->ndi,DCI_N0->Scheddly,DCI_N0->RepNum,DCI_N0->rv,DCI_N0->DCIRep);
LOG_D(MAC,"[%04d][ULSchedulerUSS][%d][Success] complete scheduling with data size %d\n", mac_inst->current_subframe, UE_info->rnti, UE_info->ul_total_buffer);
LOG_D(MAC,"[%04d][ULSchedulerUSS][%d][Success] DCI content = scind : %d ResAssign : %d mcs : %d ndi : %d scheddly : %d RepNum : %d rv : %d DCIRep : %d\n", mac_inst->current_subframe, UE_info->rnti, DCI_N0->scind,DCI_N0->ResAssign,DCI_N0->mcs,DCI_N0->ndi,DCI_N0->Scheddly,DCI_N0->RepNum,DCI_N0->rv,DCI_N0->DCIRep);
LOG_D(MAC,"[%04d][ULSchedulerUSS][%d] Multi-tone:%d,MCS:%d,TBS:%d,UL_buffer:%d,DL_start:%d,DL_end:%d,N_rep:%d,N_ru:%d,Total_ru:%d\n", mac_inst->current_subframe,UE_info->rnti,UE_info->multi_tone,mcs,TBS,UE_info->ul_total_buffer,NPDCCH_info->sf_start,DL_end,N_rep,Nru,total_ru);
//LOG_D(MAC,"[%04d][ULSchedulerUSS][%d][Success] DCI content = scind : %d ResAssign : %d mcs : %d ndi : %d scheddly : %d RepNum : %d rv : %d DCIRep : %d\n", mac_inst->current_subframe, UE_info->rnti, DCI_N0->scind,DCI_N0->ResAssign,DCI_N0->mcs,DCI_N0->ndi,DCI_N0->Scheddly,DCI_N0->RepNum,DCI_N0->rv,DCI_N0->DCIRep);
//----Daniel
// step 5 resource allocation and generate scheduling result
generate_scheduling_result_UL(NPDCCH_info->sf_start, NPDCCH_info->sf_end,NPUSCH_info->sf_start, NPUSCH_info->sf_end,DCI_N0,UE_info->rnti, str20, str21);
//----Daniel
LOG_D(MAC,"[%04d][ULSchedulerUSS][UE:%05d] Generate result\n", mac_inst->current_subframe, UE_info->rnti);
//generate_scheduling_result_UL(NPDCCH_info->sf_start, NPDCCH_info->sf_end,NPUSCH_info->sf_start, NPUSCH_info->sf_end,DCI_N0,UE_info->rnti, str20, str21);
LOG_D(MAC,"[%04d][ULSchedulerUSS][UE:%05d] Maintain resource\n", mac_inst->current_subframe, UE_info->rnti);
//fill_resource_DL();
maintain_resource_DL(mac_inst,NPDCCH_info,NULL);
//----Daniel
adjust_UL_resource_list(NPUSCH_info);
//----Daniel
/*
//Change the UE state to idle
UE_info->direction = -1;
return 0;
*/
//----Daneil
//Fill result to Output structure
//----Daneil
UE_sched_ctrl_info->NPDCCH_sf_end=NPDCCH_info->sf_end;
UE_sched_ctrl_info->NPDCCH_sf_start=NPDCCH_info->sf_start;
UE_sched_ctrl_info->NPUSCH_sf_end=NPUSCH_info->sf_end;
UE_sched_ctrl_info->NPUSCH_sf_start=NPUSCH_info->sf_start;
UE_sched_ctrl_info->TBS=TBS;
UE_sched_ctrl_info->dci_n0_index_mcs=mcs;
UE_sched_ctrl_info->index_tbs=mcs;
UE_sched_ctrl_info->dci_n0_index_ru=Iru;
UE_sched_ctrl_info->dci_n0_n_ru=Nru;
UE_sched_ctrl_info->dci_n0_index_delay=dly;
UE_sched_ctrl_info->dci_n0_index_subcarrier=NPUSCH_info->subcarrier_indication;
UE_sched_ctrl_info->dci_n0_index_ndi=ndi;
//UE_sched_ctrl_info->dci_n0_index_R_dci=get_DCI_REP(UE_sched_ctrl_info->R_dci->R_dci,UE_info->R_max);
UE_sched_ctrl_info->dci_n0_index_R_data=I_rep;
//----Daniel
//----Daniel
LOG_D(MAC,"[%04d][ULSchedulerUSS][%d][Success] Finish UL USS scheduling \n", mac_inst->current_subframe, UE_info->rnti);
return 0;
//----Daniel
}
}
......@@ -147,7 +200,10 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
/*break now, we only loop one candidiate*/
//break;
}
LOG_D(MAC,"[%04d][ULSchedulerUSS][%d][Fail] UL scheduling USS fail\n", mac_inst->current_subframe, UE_info->rnti);
//----Daniel
UE_sched_ctrl_info->flag_schedule_success=0;
//----Daniel
LOG_D(MAC,"[%04d][ULSchedulerUSS][%d][Fail] UL scheduling USS fail\n", mac_inst->current_subframe, UE_info->rnti);
LOG_D(MAC,"[%04d][UL scheduler][UE:%05d] there is no available UL resource\n", mac_inst->current_subframe, UE_info->rnti);
return -1;
}
......@@ -297,3 +353,19 @@ uint16_t length, ce_len=0;
return(mac_header_ptr);
}
//------Daniel
void fill_DCI_N0(DCIFormatN0_t *DCI_N0, UE_TEMPLATE_NB_IoT *UE_info, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info)
{
DCI_N0->type = 0;
DCI_N0->scind = UE_sched_ctrl_info->dci_n0_index_subcarrier;
DCI_N0->ResAssign = UE_sched_ctrl_info->dci_n0_index_ru;
DCI_N0->mcs = UE_sched_ctrl_info->dci_n0_index_mcs;
DCI_N0->ndi = UE_sched_ctrl_info->dci_n0_index_ndi;
DCI_N0->Scheddly = UE_sched_ctrl_info->dci_n0_index_delay;
DCI_N0->RepNum = UE_sched_ctrl_info->dci_n0_index_R_data;
DCI_N0->rv = (UE_info->HARQ_round%2==0)?0:1; // rv will loop 0 & 2
DCI_N0->DCIRep = get_DCI_REP(UE_sched_ctrl_info->R_dci,UE_info->R_max);
//DCI_N0->DCIRep = UE_sched_ctrl_info->dci_n0_index_R_dci;
LOG_D(MAC,"[fill_DCI_N0] Type %d scind %d I_ru %d I_mcs %d ndi %d I_delay %d I_rep %d RV %d I_dci %d\n", DCI_N0->type, DCI_N0->scind, DCI_N0->ResAssign, DCI_N0->mcs, DCI_N0->ndi, DCI_N0->Scheddly, DCI_N0->RepNum, DCI_N0->rv, DCI_N0->DCIRep);
}
//-----Daniel
......@@ -105,6 +105,11 @@ extern const int rachstart[8];
extern const int rachrepeat[8];
extern const int rachscofst[7];
extern const int rachnumsc[4];
extern const int rmax[12];
extern const double gvalue[8];
extern const double pdcchoffset[4];
extern const uint32_t RU_table[8];
......
......@@ -57,10 +57,11 @@ void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst)
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;
......@@ -86,25 +87,25 @@ void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst)
}
mac_inst->sib1_count[i]=j;
}
//LOG_D(MAC,"%d", mac_inst->sib1_period);
//printf("%d", mac_inst->sib1_period);
for(i=0, j=0;i<640;++i){
//LOG_D(MAC,"*%d", i);
//printf("*%d", i);
if(is_dlsf(mac_inst, i)){
++j;
}
//LOG_D(MAC,"-");
//printf("-");
if(i%10==9){
mac_inst->dlsf_table[i/10] = j;
}
}
mac_inst->rrc_config.si_window_length = ms160;
mac_inst->rrc_config.sibs_NB_IoT_sched[0].si_periodicity = rf64;
mac_inst->rrc_config.si_radio_frame_offset = 1;
for(i=0;i<256;++i){
mac_inst->sibs_table[i] = -1;
}
mac_inst->rrc_config.si_window_length = ms160;
mac_inst->rrc_config.sibs_NB_IoT_sched[0].si_periodicity = rf64;
// mac_inst->rrc_config.si_radio_frame_offset = 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;
......@@ -115,7 +116,7 @@ void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst)
}
mac_inst->schedule_subframe_DL = 0;
mac_inst->schedule_subframe_UL = 0;
//mac_inst->schedule_subframe_UL = 0;
available_resource_DL = available_resource_DL_last = (available_resource_DL_t *)0;
......@@ -135,36 +136,7 @@ void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst)
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
LOG_I(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(0,0,0,NULL,NULL,NULL,NULL,NULL,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);
LOG_I(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);
}
//UL initial
//Setting nprach configuration
......@@ -172,7 +144,7 @@ void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst)
//Initialize uplink resource from nprach configuration
Initialize_Resource();
//add_UL_Resource(mac_inst);
extend_available_resource_DL(mac_inst, mac_inst->current_subframe + 1 + mac_inst->rrc_config.si_window_length);
extend_available_resource_DL(mac_inst, mac_inst->current_subframe + 1 + 160);
}
......
......@@ -115,7 +115,8 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
//LOG_I(MAC,"NB-IoT fill MIB\n");
//dl_scheduled(mac_inst->current_subframe, _NPBCH, 0, "MIB");
}
else if((subframe == 4) && (frame%2==0) && (frame%32<16) /*SIB1_flag == 1*/) // TODO back to SIB1_flag
else if(SIB1_flag==1)
//else if((subframe == 4) && (frame%2==0) && (frame%32<16) /*SIB1_flag == 1*/) // TODO back to SIB1_flag
{
uint8_t *SIB1_pdu = get_NB_IoT_SIB1(0,0,carrier,208,92,1,3584,28,2,subframe,frame,hypersfn);
//SIB1_size = mac_rrc_data_req_eNB_NB_IoT(*SIB1);
......@@ -140,7 +141,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
//LOG_D(MAC,"A NB-IoT SIB1 pdu : %d \n",SIB1_pdu);
SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index].segments[0].segment_data = SIB1_pdu;
LOG_D(MAC,"NB-IoT fill SIB1\n");
LOG_I(MAC,"NB-IoT fill SIB1\n");
//LOG_I(MAC,"NB-IoT fill SIB1\n");
//start symbol, Resource assignment, Repetition number, Number of subframe Resource assignment lost for now
//dl_scheduled(mac_inst->current_subframe, _NPDSCH, SI_RNTI, "SIB1");
......@@ -227,6 +228,8 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
break;
case NPDSCH:
LOG_D(MAC,"NB-IoT fill DL Data\n");
if(schedule_result_list_DL->rnti==SI_RNTI)
LOG_I(MAC,"NB-IoT fill SIB23\n");
//LOG_I(MAC,"NB-IoT fill DL Data\n");
//SCHED_info->DL_req = (nfapi_dl_config_request_t*) malloc (sizeof(nfapi_dl_config_request_t));
//SCHED_info->DL_req->dl_config_request_body.number_pdu = 0;
......
......@@ -145,7 +145,8 @@ void print_available_UL_resource(void);
/*set nprach configuration at intial time*/
void setting_nprach(void);
/*Uplink main scheduler*/
int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info, uint32_t subframe, uint32_t frame, uint32_t H_SFN);
//int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info, uint32_t subframe, uint32_t frame, uint32_t H_SFN);
int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info, uint32_t subframe, uint32_t frame, uint32_t H_SFN, UE_SCHED_CTRL_NB_IoT_t *UE_sched_info);
/*Check available uplink resource list, if there is available uplink resource, return 0, otherwise, return 1*/
int Check_UL_resource(uint32_t DL_end, int total_ru, sched_temp_UL_NB_IoT_t *NPUSCH_info, int multi_tone, int fmt2_flag);
/*Get I Repetition number in DCI*/
......@@ -177,7 +178,7 @@ int get_resource_field_value(int subcarrier, int k0);
uint8_t get_index_Rep_dl(uint16_t R);
/*******DL Scheduler********/
void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_TEMPLATE_NB_IoT *UE_info, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start);
//void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_TEMPLATE_NB_IoT *UE_info, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start);
int check_resource_NPDCCH_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, sched_temp_DL_NB_IoT_t *NPDCCH_info, uint32_t cdd_num, uint32_t dci_rep);
int check_resource_NPDSCH_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, sched_temp_DL_NB_IoT_t *NPDSCH_info, uint32_t sf_end, uint32_t I_delay, uint32_t R_max, uint32_t R_dl, uint32_t n_sf);
int check_resource_DL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, uint32_t dlsf_require, sched_temp_DL_NB_IoT_t *schedule_info);
......@@ -188,8 +189,9 @@ uint32_t get_num_sf(uint32_t I_sf);
uint32_t get_scheduling_delay(uint32_t I_delay, uint32_t R_max);
uint32_t get_HARQ_delay(int subcarrier_spacing, uint32_t HARQ_delay_index);
//void generate_scheduling_result_DL(uint32_t DCI_subframe, uint32_t NPDSCH_subframe, uint32_t HARQ_subframe, DCIFormatN1_t *DCI, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_DL_NB_IoT_t* NPDSCH_info, sched_temp_UL_NB_IoT_t* HARQ_info, DCIFormatN1_t *DCI_inst, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, uint32_t scheddly, uint32_t I_sf, uint32_t I_harq);
//void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_DL_NB_IoT_t* NPDSCH_info, sched_temp_UL_NB_IoT_t* HARQ_info, DCIFormatN1_t *DCI_inst, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
void generate_scheduling_result_DL(uint32_t NPDCCH_sf_end, uint32_t NPDCCH_sf_start, uint32_t NPDSCH_sf_end, uint32_t NPDSCH_sf_start, uint32_t HARQ_sf_end, uint32_t HARQ_sf_start, DCIFormatN1_t *DCI_pdu, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
//void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, uint32_t scheddly, uint32_t I_sf, uint32_t I_harq);
//Transfrom source into hyperSF, Frame, Subframe format
void convert_system_number(uint32_t source_sf,uint32_t *hyperSF, uint32_t *frame, uint32_t *subframe);
//Trnasform hyperSF, Frame, Subframe format into subframe unit
......@@ -221,4 +223,13 @@ uint32_t from_earfcn_NB_IoT(int eutra_bandP,uint32_t dl_earfcn, float m_dl);
int32_t get_uldl_offset_NB_IoT(int eutra_band);
/***Preprocessor***/
void preprocessor_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, uint32_t subframe, uint32_t frame, uint32_t hypersfn, int UE_list_index);
void sort_UEs_uss(void);
int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_TEMPLATE_NB_IoT *UE_info, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info);
void fill_DCI_N0(DCIFormatN0_t *DCI_N0, UE_TEMPLATE_NB_IoT *UE_info, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info);
void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info);
void USS_scheduling_module(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe, uint8_t number_UE_list);
#endif
......@@ -165,7 +165,8 @@ void Initialize_Resource_node(available_resource_UL_t *tone_head, available_reso
/*when there is SIB-2 configuration coming to MAC, filled the uplink resource grid*/
void Initialize_Resource(void){
int i;
available_resource_UL_t *new_node;
///memory allocate to Head
available_resource_UL = (available_resource_tones_UL_t*)malloc(sizeof(available_resource_tones_UL_t));
......@@ -180,7 +181,54 @@ void Initialize_Resource(void){
available_resource_UL->singletone1_end_subframe = 0;
available_resource_UL->singletone2_end_subframe = 0;
available_resource_UL->singletone3_end_subframe = 0;
//initialize first node
if((nprach_list+2)->nprach_StartTime!=0)
{
new_node = (available_resource_UL_t *)malloc(sizeof(available_resource_UL_t));
new_node->next = (available_resource_UL_t *)0;
new_node->prev = (available_resource_UL_t *)0;
new_node->start_subframe = 0;
new_node->end_subframe = (nprach_list+2)->nprach_StartTime-1;
if( (available_resource_UL_t *)0 == available_resource_UL->sixtone_Head){
available_resource_UL->sixtone_Head = new_node;
new_node->prev = (available_resource_UL_t *)0;
}
}
if((nprach_list+1)->nprach_StartTime!=0)
{
new_node = (available_resource_UL_t *)malloc(sizeof(available_resource_UL_t));
new_node->next = (available_resource_UL_t *)0;
new_node->prev = (available_resource_UL_t *)0;
new_node->start_subframe = 0;
new_node->end_subframe = (nprach_list+1)->nprach_StartTime-1;
if( (available_resource_UL_t *)0 == available_resource_UL->threetone_Head){
available_resource_UL->threetone_Head = new_node;
new_node->prev = (available_resource_UL_t *)0;
}
}
for(i=0;i<3;++i)
{
if(nprach_list->nprach_StartTime!=0)
{
new_node = (available_resource_UL_t *)malloc(sizeof(available_resource_UL_t));
new_node->next = (available_resource_UL_t *)0;
new_node->prev = (available_resource_UL_t *)0;
new_node->start_subframe = 0;
new_node->end_subframe = nprach_list->nprach_StartTime-1;
if( (available_resource_UL_t *)0 == available_resource_UL->threetone_Head){
if(i==0)
available_resource_UL->singletone1_Head = new_node;
else if(i==1)
available_resource_UL->singletone2_Head = new_node;
else
available_resource_UL->singletone3_Head = new_node;
new_node->prev = (available_resource_UL_t *)0;
}
}
}
add_UL_Resource();
add_UL_Resource();
......@@ -932,7 +980,7 @@ void init_dl_list(eNB_MAC_INST_NB_IoT *mac_inst){
//schedule_sibs(mac_inst, 0, 0); // TODO, check init
}
#if 0
// extend subframe align to si-period
void extend_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int max_subframe){
......@@ -976,21 +1024,76 @@ void extend_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int max_subfram
mac_inst->schedule_subframe_DL = max_subframe;
}
}
#endif
#if 1
// extend subframe align to si-period
void extend_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int max_subframe){ // assume max_subframe is found.
available_resource_DL_t *new_node;
//int temp;
uint32_t i, i_div_si_window;
//uint32_t si_period_div_window;
//pt = available_resource_DL;
LOG_D(MAC,"[extend DL] max_subframe: %d, current schedule subframe: %d\n", max_subframe, mac_inst->schedule_subframe_DL);
print_available_resource_DL(mac_inst);
if(max_subframe > mac_inst->schedule_subframe_DL){
// align to si-period
max_subframe = ((max_subframe%mac_inst->rrc_config.si_window_length)==0)? max_subframe : (((max_subframe/mac_inst->rrc_config.si_window_length)+1)*mac_inst->rrc_config.si_window_length);
if(mac_inst->schedule_subframe_DL == available_resource_DL_last->end_subframe){
LOG_D(MAC,"[extend DL] last node is align to schedule_sf_dl\n");
available_resource_DL_last->end_subframe = max_subframe;
}else{
LOG_D(MAC,"[extend DL] add new node !\n");
new_node = (available_resource_DL_t *)malloc(sizeof(available_resource_DL_t));
available_resource_DL_last->next = new_node;
new_node->start_subframe = mac_inst->schedule_subframe_DL+1;
new_node->end_subframe = max_subframe;
new_node->next = (available_resource_DL_t *)0;
available_resource_DL_last = new_node;
}
LOG_I(MAC,"sf_dl:%d max:%d siw:%d\n",mac_inst->schedule_subframe_DL,max_subframe,mac_inst->rrc_config.si_window_length);
// do schedule sibs after extend.
for(i=mac_inst->schedule_subframe_DL;i<max_subframe;i+=mac_inst->rrc_config.si_window_length){
i_div_si_window = (i / mac_inst->rrc_config.si_window_length)%256;
LOG_D(MAC,"[sibs out:%d] schedule_DL:%d i_div_si_window:%d\n", mac_inst->sibs_table[i_div_si_window], i, i_div_si_window);
if(-1 != mac_inst->sibs_table[i_div_si_window]){
LOG_D(MAC,"[sibs%d] %d\n", mac_inst->sibs_table[i_div_si_window], i);
schedule_sibs(mac_inst, mac_inst->sibs_table[i_div_si_window], i);
}
}
mac_inst->schedule_subframe_DL = max_subframe;
}
return ;
}
#endif
void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst){
available_resource_DL_t *pfree, *iterator;
available_resource_UL_t *pfree2, *iterator2;
schedule_result_t *iterator1;
if(available_resource_DL != (available_resource_DL_t *)0){
if(mac_inst->current_subframe >= available_resource_DL->end_subframe){
if(mac_inst->current_subframe >= available_resource_DL->end_subframe){
pfree = available_resource_DL;
if(available_resource_DL->next == (available_resource_DL_t *)0){
LOG_D(MAC,"[maintain_available_resource]=====t:%d=====dl resource list next is NULL %d\n", mac_inst->current_subframe, available_resource_DL->end_subframe);
//DEBUG("[maintain_available_resource]=====t:%d=====dl resource list next is NULL %d\n", mac_inst->current_subframe, available_resource_DL->end_subframe);
available_resource_DL = (available_resource_DL_t *)0;
}else{
LOG_D(MAC,"[maintain_available_resource]=====t:%d=====dl resource list remove next:%d-%d\n", mac_inst->current_subframe, available_resource_DL->next->start_subframe, available_resource_DL->next->end_subframe);
//DEBUG("[maintain_available_resource]=====t:%d=====dl resource list remove next:%d-%d\n", mac_inst->current_subframe, available_resource_DL->next->start_subframe, available_resource_DL->next->end_subframe);
available_resource_DL = available_resource_DL->next;
available_resource_DL->prev = (available_resource_DL_t *)0;
}
......@@ -999,11 +1102,11 @@ void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst){
}else{
available_resource_DL->start_subframe = mac_inst->current_subframe;
}
}
// UL
iterator2 = available_resource_UL->singletone1_Head;
if(iterator2 != (available_resource_UL_t *)0){
if(mac_inst->current_subframe >= iterator2->end_subframe){
if(mac_inst->current_subframe > iterator2->end_subframe){
pfree2 = iterator2;
available_resource_UL->singletone1_Head = iterator2->next;
......@@ -1012,12 +1115,13 @@ void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst){
free((available_resource_UL_t *)pfree2);
}else{
if(iterator2->start_subframe<mac_inst->current_subframe)
iterator2->start_subframe = mac_inst->current_subframe;
}
}
iterator2 = available_resource_UL->singletone2_Head;
if(iterator2 != (available_resource_UL_t *)0){
if(mac_inst->current_subframe >= iterator2->end_subframe){
if(mac_inst->current_subframe > iterator2->end_subframe){
pfree2 = iterator2;
available_resource_UL->singletone2_Head = iterator2->next;
......@@ -1026,12 +1130,13 @@ void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst){
free((available_resource_UL_t *)pfree2);
}else{
if(iterator2->start_subframe<mac_inst->current_subframe)
iterator2->start_subframe = mac_inst->current_subframe;
}
}
iterator2 = available_resource_UL->singletone3_Head;
if(iterator2 != (available_resource_UL_t *)0){
if(mac_inst->current_subframe >= iterator2->end_subframe){
if(mac_inst->current_subframe > iterator2->end_subframe){
pfree2 = iterator2;
available_resource_UL->singletone3_Head = iterator2->next;
......@@ -1040,12 +1145,13 @@ void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst){
free((available_resource_UL_t *)pfree2);
}else{
if(iterator2->start_subframe<mac_inst->current_subframe)
iterator2->start_subframe = mac_inst->current_subframe;
}
}
iterator2 = available_resource_UL->sixtone_Head;
if(iterator2 != (available_resource_UL_t *)0){
if(mac_inst->current_subframe >= iterator2->end_subframe){
if(mac_inst->current_subframe > iterator2->end_subframe){
pfree2 = iterator2;
available_resource_UL->sixtone_Head = iterator2->next;
......@@ -1053,13 +1159,15 @@ void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst){
free((available_resource_UL_t *)pfree2);
}else{
}
else{
if(iterator2->start_subframe<mac_inst->current_subframe)
iterator2->start_subframe = mac_inst->current_subframe;
}
}
iterator2 = available_resource_UL->threetone_Head;
if(iterator2 != (available_resource_UL_t *)0){
if(mac_inst->current_subframe >= iterator2->end_subframe){
if(mac_inst->current_subframe > iterator2->end_subframe){
pfree2 = iterator2;
available_resource_UL->threetone_Head = iterator2->next;
......@@ -1068,10 +1176,10 @@ void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst){
free((available_resource_UL_t *)pfree2);
}else{
if(iterator2->start_subframe<mac_inst->current_subframe)
iterator2->start_subframe = mac_inst->current_subframe;
}
}
}
if(mac_inst->current_subframe == 0){
// DL available cross zero
iterator = available_resource_DL;
......@@ -1155,10 +1263,8 @@ void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst){
iterator1 = iterator1->next;
}
}
}
//printf_FUNCTION_OUT("[MAINTAIN]");
return ;
}
......@@ -1505,7 +1611,7 @@ uint32_t get_scheduling_delay(uint32_t I_delay, uint32_t R_max)
}
}
#if 0
/*
uint8_t *parse_ulsch_header( uint8_t *mac_header,
uint8_t *num_ce,
uint8_t *num_sdu,
......@@ -1520,11 +1626,11 @@ uint16_t length, ce_len=0;
while(not_done==1){
if(((SCH_SUBHEADER_FIXED*)mac_header_ptr)->E == 0){
if(((SCH_SUBHEADER_FIXED_NB_IoT*)mac_header_ptr)->E == 0){
not_done = 0;
}
lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID;
lcid = ((SCH_SUBHEADER_FIXED_NB_IoT *)mac_header_ptr)->LCID;
if(lcid < EXTENDED_POWER_HEADROOM){
if (not_done==0) { // last MAC SDU, length is implicit
......@@ -1535,11 +1641,11 @@ uint16_t length, ce_len=0;
length -= rx_lengths[num_sdu_cnt];
}
}else{
if(((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0){
length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L;
mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT);
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_NB_IoT);
}else{ // F = 1
length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff);
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);
}
}
......@@ -1573,7 +1679,7 @@ uint16_t length, ce_len=0;
return(mac_header_ptr);
}
#endif
*/
// calvin
// maybe we can try to use hash table to enhance searching time.
......
......@@ -464,7 +464,7 @@ int8_t mac_rrc_data_req_NB_IoT(
return (Sdu_size);
}
/*
#if defined(Rel10) || defined(Rel14)
if((Srb_id & RAB_OFFSET) == MCCH_NB_IoT) {
......@@ -520,6 +520,8 @@ int8_t mac_rrc_data_req_NB_IoT(
}
#endif //Rel10 || Rel14
*/
} else { //This is an UE
LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_id);
......
......@@ -662,6 +662,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
eNB->UL_INFO.subframe = proc->subframe_rx;
eNB->UL_INFO.module_id = eNB->Mod_id;
eNB->UL_INFO.CC_id = eNB->CC_id;
eNB->UL_INFO.hypersfn = proc->HFN;
eNB->if_inst->UL_indication(&eNB->UL_INFO);
......
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