Commit 25f8a1bb authored by Nick Ho's avatar Nick Ho

commit remaining files

parent 0fc1cf2e
This diff is collapsed.
#ifndef _CONFIG_H_
#define _CONFIG_H_
//#include "NB_IoT_Message_definitions.h"
#define NUMBER_OF_SIBS_MAX_NB_IoT 6
///MIB
typedef enum operationModeInf{
iNB_IoTand_SamePCI_r13 = 1,
iNB_IoTand_DifferentPCI_r13 = 2,
guardband_r13 = 3,
standalone_r13 = 4
}operationModeInf_t;
///SIB1_SchedulingInfo_NB_IoT_r13
typedef enum si_Periodicity{
si_Periodicity_rf64=640,
si_Periodicity_rf128=1280,
si_Periodicity_rf256=2560,
si_Periodicity_rf512=5120,
si_Periodicity_rf1024=10240,
si_Periodicity_rf2048=20480,
si_Periodicity_rf4096=40960
}si_Periodicity_NB_IoT;
typedef enum si_RepetitionPattern{
si_RepetitionPattern_every2ndRF=20,
si_RepetitionPattern_every4thRF=40,
si_RepetitionPattern_every8thRF=80,
si_RepetitionPattern_every16thRF=160
}si_RepetitionPattern_NB_IoT;
typedef enum sib_MappingInfo{
sib2_v=0x1,
sib3_v=0x2,
sib4_v=0x4,
sib5_v=0x8,
sib14_v=0x10,
sib16_v=0x20
}sib_MappingInfo_NB_IoT;
typedef enum si_TB{
si_TB_56=56,
si_TB_120=120,
si_TB_208=208,
si_TB_256=256,
si_TB_328=328,
si_TB_440=440,
si_TB_552=552,
si_TB_680=680
}si_TB_NB_IoT;
///RACH_ConfigCommon configuration
typedef enum ra_ResponseWindowSize{
ra_ResponseWindowSize_pp2=2,
ra_ResponseWindowSize_pp3=3,
ra_ResponseWindowSize_pp4=4,
ra_ResponseWindowSize_pp5=5,
ra_ResponseWindowSize_pp6=6,
ra_ResponseWindowSize_pp7=7,
ra_ResponseWindowSize_pp8=8,
ra_ResponseWindowSize_pp10=10
}ra_ResponseWindowSize_NB_IoT;
typedef enum mac_ContentionResolutionTimer{
mac_ContentionResolutionTimer_pp1=1,
mac_ContentionResolutionTimer_pp2=2,
mac_ContentionResolutionTimer_pp3=3,
mac_ContentionResolutionTimer_pp4=4,
mac_ContentionResolutionTimer_pp8=8,
mac_ContentionResolutionTimer_pp16=16,
mac_ContentionResolutionTimer_pp32=32,
mac_ContentionResolutionTimer_pp64=64
}mac_ContentionResolutionTimer_NB_IoT;
///NPRACH_ConfigSIB configuration
typedef enum nprach_Periodicity{
nprach_Periodicity_ms40=40,
nprach_Periodicity_ms80=80,
nprach_Periodicity_ms160=160,
nprach_Periodicity_ms240=240,
nprach_Periodicity_ms320=320,
nprach_Periodicity_ms640=640,
nprach_Periodicity_ms1280=1280,
nprach_Periodicity_ms2560=2560
}nprach_Periodicity_NB_IoT;
typedef enum nprach_StartTime{
nprach_StartTime_ms8=8,
nprach_StartTime_ms16=16,
nprach_StartTime_ms32=32,
nprach_StartTime_ms64=64,
nprach_StartTime_ms128=128,
nprach_StartTime_ms256=256,
nprach_StartTime_ms512=512,
nprach_StartTime_ms1024=1024
}nprach_StartTime_NB_IoT;
typedef enum nprach_SubcarrierOffset{
nprach_SubcarrierOffset_n0=0,
nprach_SubcarrierOffset_n12=12,
nprach_SubcarrierOffset_n24=24,
nprach_SubcarrierOffset_n36=36,
nprach_SubcarrierOffset_n2=2,
nprach_SubcarrierOffset_n18=18,
nprach_SubcarrierOffset_n34=34
}nprach_SubcarrierOffset_NB_IoT;
typedef enum nprach_NumSubcarriers{
nprach_NumSubcarriers_n12=12,
nprach_NumSubcarriers_n24=24,
nprach_NumSubcarriers_n36=36,
nprach_NumSubcarriers_n48=48
}nprach_NumSubcarriers_NB_IoT;
typedef enum nprach_SubcarrierMSG3_RangeStart{
nprach_SubcarrierMSG3_RangeStart_zero=0,
nprach_SubcarrierMSG3_RangeStart_oneThird=1/3,
nprach_SubcarrierMSG3_RangeStart_twoThird=2/3,
nprach_SubcarrierMSG3_RangeStart_one=1
}nprach_SubcarrierMSG3_RangeStart_NB_IoT;
typedef enum maxNumPreambleAttemptCE{
maxNumPreambleAttemptCE_n3=3,
maxNumPreambleAttemptCE_n4=4,
maxNumPreambleAttemptCE_n5=5,
maxNumPreambleAttemptCE_n6=6,
maxNumPreambleAttemptCE_n7=7,
maxNumPreambleAttemptCE_n8=8,
maxNumPreambleAttemptCE_n10=10
}maxNumPreambleAttemptCE_NB_IoT;
typedef enum numRepetitionsPerPreambleAttempt{
numRepetitionsPerPreambleAttempt_n1=1,
numRepetitionsPerPreambleAttempt_n2=2,
numRepetitionsPerPreambleAttempt_n4=4,
numRepetitionsPerPreambleAttempt_n8=8,
numRepetitionsPerPreambleAttempt_n16=16,
numRepetitionsPerPreambleAttempt_n32=32,
numRepetitionsPerPreambleAttempt_n64=64,
numRepetitionsPerPreambleAttempt_n128=128
}numRepetitionsPerPreambleAttempt_NB_IoT;
typedef enum npdcch_NumRepetitions_RA{
npdcch_NumRepetitions_RA_r1=1,
npdcch_NumRepetitions_RA_r2=2,
npdcch_NumRepetitions_RA_r4=4,
npdcch_NumRepetitions_RA_r8=8,
npdcch_NumRepetitions_RA_r16=16,
npdcch_NumRepetitions_RA_r32=32,
npdcch_NumRepetitions_RA_r64=64,
npdcch_NumRepetitions_RA_r128=128,
npdcch_NumRepetitions_RA_r256=256,
npdcch_NumRepetitions_RA_r512=512,
npdcch_NumRepetitions_RA_r1024=1024,
npdcch_NumRepetitions_RA_r2048=2048
}npdcch_NumRepetitions_RA_NB_IoT;
typedef enum npdcch_StartSF_CSS_RA{
npdcch_StartSF_CSS_RA_v1dot5=3/2,
npdcch_StartSF_CSS_RA_v2=2,
npdcch_StartSF_CSS_RA_v4=4,
npdcch_StartSF_CSS_RA_v8=8,
npdcch_StartSF_CSS_RA_v16=16,
npdcch_StartSF_CSS_RA_v32=32,
npdcch_StartSF_CSS_RA_v48=48,
npdcch_StartSF_CSS_RA_v64=64
}npdcch_StartSF_CSS_RA_NB_IoT;
typedef enum npdcch_Offset_RA{
zero=0,
oneEighth=1/8,
oneFourth=1/4,
threeEighth=3/8
}npdcch_Offset_RA_NB_IoT;
typedef enum si_window_length_e{
ms160=160,
ms320=320,
ms480=480,
ms640=640,
ms960=960,
ms1280=1280,
ms1600=1600
}si_window_length_t;
typedef enum si_periodicity_e{
rf64=640,
rf128=1280,
rf256=2560,
rf512=5120,
rf1024=10240,
rf2048=20480,
rf4096=40960
}si_periodicity_t;
typedef enum si_repetition_pattern_e{
every2ndRF=20,
every4thRF=40,
every8thRF=80,
every16thRF=160
}si_repetition_pattern_t;
typedef enum si_tb_e{
b56=2,
b120=2,
b208=8,
b256=8,
b328=8,
b440=8,
b552=8,
b680=8
}si_tb_t;
typedef struct sibs_NB_IoT_sched_s{
si_periodicity_t si_periodicity;
si_repetition_pattern_t si_repetition_pattern;
sib_MappingInfo_NB_IoT sib_mapping_info; //bit vector
si_tb_t si_tb;
}sibs_NB_IoT_sched_t;
///-------------------------------------------------------MAC--------------------------------------------------------------------///
typedef struct sib1_NB_IoT_sched_s{
int repetitions; // 4, 8, 16
int starting_rf;
}sib1_NB_IoT_sched_t;
typedef struct {
uint32_t mac_ra_ResponseWindowSize_NB_IoT;
uint32_t mac_ContentionResolutionTimer_NB_IoT;
}mac_RACH_ConfigCommon_NB_IoT;
typedef struct {
uint32_t mac_nprach_Periodicity_NB_IoT;
uint32_t mac_nprach_StartTime_NB_IoT;
uint32_t mac_nprach_SubcarrierOffset_NB_IoT;
uint32_t mac_nprach_NumSubcarriers_NB_IoT;
uint32_t mac_nprach_SubcarrierMSG3_RangeStart_NB_IoT;
uint32_t mac_maxNumPreambleAttemptCE_NB_IoT;
uint32_t mac_numRepetitionsPerPreambleAttempt_NB_IoT;
// css
uint32_t mac_npdcch_NumRepetitions_RA_NB_IoT; // rmax
uint32_t mac_npdcch_StartSF_CSS_RA_NB_IoT; // G
uint32_t mac_npdcch_Offset_RA_NB_IoT; // alpha offset
}mac_NPRACH_ConfigSIB_NB_IoT;
typedef struct{
//npdcch-NumRepetitions-r13
uint32_t R_max;
//npdcch-StartSF-USS-r13
double G;
//npdcch-Offset-USS-r13
double a_offset;
}npdcch_ConfigDedicated_NB_IoT;
typedef struct rrc_config_NB_IoT_s{
///MIB
uint16_t schedulingInfoSIB1_NB_IoT;
///SIB1
uint32_t cellIdentity_NB_IoT;
sib1_NB_IoT_sched_t sib1_NB_IoT_sched_config;
///SIBS
sibs_NB_IoT_sched_t sibs_NB_IoT_sched[NUMBER_OF_SIBS_MAX_NB_IoT];
si_window_length_t si_window_length;
uint32_t si_radio_frame_offset;
///SIB2 mac_RACH_ConfigCommon_NB_IoT
mac_RACH_ConfigCommon_NB_IoT mac_RACH_ConfigCommon[3];
///SIB2 mac_NPRACH_ConfigSIB_NB_IoT
mac_NPRACH_ConfigSIB_NB_IoT mac_NPRACH_ConfigSIB[3];
///NPDCCH Dedicated config
npdcch_ConfigDedicated_NB_IoT npdcch_ConfigDedicated[3];
}rrc_config_NB_IoT_t;
#endif
// function for schedule SI
#include "defs_NB_IoT.h"
#include "proto_NB_IoT.h"
#include "extern_NB_IoT.h"
char str[6][7] = { "SIBs_1", "SIBs_2", "SIBs_3", "SIBs_4", "SIBs_5", "SIBs_6" };
void schedule_sibs_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t sibs_order, int start_subframe1){
available_resource_DL_t *pt[8] = { (available_resource_DL_t *)0 };
uint32_t first_subframe[8] = { -1 };
//uint32_t end_subframe[8] = { -1 };
schedule_result_t *new_node;
DCIFormatN1_t *sibs_dci;
uint32_t j, i, k, num_subframe, last_subframe, residual_subframe;
num_subframe = mac_inst->rrc_config.sibs_NB_IoT_sched[sibs_order].si_tb;
for(k=0, i=start_subframe1;i<(start_subframe1+mac_inst->rrc_config.si_window_length);i+=mac_inst->rrc_config.sibs_NB_IoT_sched[sibs_order].si_repetition_pattern, ++k){
//printf("[debug][sibs%d] subframe: %d, check %d", sibs_order, i, num_subframe);
pt[k] = (available_resource_DL_t *)check_sibs_resource(mac_inst, i, i+9, num_subframe, &residual_subframe, &last_subframe, &first_subframe[k]);
num_subframe = residual_subframe;
//printf("-- rest: %d, last: %d start: %d\n", num_subframe, last_subframe, start_subframe1);
if(0==residual_subframe){
sibs_dci = (DCIFormatN1_t *)malloc(sizeof(DCIFormatN1_t));
sibs_dci->type = 1;
sibs_dci->orderIndicator = 0;
sibs_dci->Scheddly = 0;
sibs_dci->ResAssign = mac_inst->rrc_config.sibs_NB_IoT_sched[sibs_order].si_tb;
sibs_dci->mcs = 2;
sibs_dci->RepNum = 0;
sibs_dci->ndi = 0;
sibs_dci->HARQackRes = 0;
sibs_dci->DCIRep = 0;
for(k=0, j=start_subframe1;j<=i;++k, j+=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
new_node->output_subframe = first_subframe[k];
new_node->end_subframe = (j==i)?last_subframe:j+9;
new_node->sdu_length = 0;
new_node->direction = DL;
new_node->DCI_release = (j==i);
new_node->channel = NPDSCH;
new_node->rnti = SI_RNTI;
new_node->rnti_type = 3;
new_node->npusch_format = 0; // useless
new_node->R_harq = 0; // useless
new_node->next = (schedule_result_t *)0;
new_node->DCI_pdu = (void *)sibs_dci;
new_node->debug_str = str[sibs_order];
fill_resource_DL(mac_inst, pt[k], first_subframe[k], (j==i)?last_subframe:j+9, new_node);
}
}
return ;
}
}
return ;
}
This diff is collapsed.
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