Commit 50797cc9 authored by Nick Ho's avatar Nick Ho

Update IF Module

parent 270e0067
......@@ -535,17 +535,6 @@ typedef struct {
nprach_parameters_NB_IoT_t nprach_list[3];
//SCHEDULE_NB_IoT_t *NB_IoT_schedule;
/******MAC Global Variable********/
//available_resource_tones_UL_t *available_resource_UL;
//available_resource_DL_t *available_resource_DL;
//available_resource_DL_t *available_resource_DL_last;
/*
schedule_result_t *schedule_result_list_UL;
schedule_result_t *schedule_result_list_DL;
*/
//DLSF Table
DLSF_INFO_t DLSF_information;
......
......@@ -25,6 +25,47 @@ unsigned char str10[] = "ack_msg4(retransmit)";
unsigned char str11[] = "msg3";
unsigned char str12[] = "msg3(retransmit)";
/*void init_RA_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint8_t preamble_index, ce_level_t ce_level, uint32_t sfn_id, uint16_t ta){
int i;
RA_TEMPLATE_NB_IoT *msg2_list_tail = mac_inst->RA_msg2_list.tail;
RA_TEMPLATE_NB_IoT *migrate_node;
static int static_count=0;
printf("[%04d][RA scheduler][MSG1] RX %d\n", mac_inst->current_subframe, static_count++);
for(i=0; i<MAX_NUMBER_OF_UE_MAX_NB_IoT; ++i){
if(0 == mac_inst->RA_template[i].active){
migrate_node = &mac_inst->RA_template[i];
break;
}
}
if(i==MAX_NUMBER_OF_UE_MAX_NB_IoT){
printf("[%04d][RA scheduler][MSG1] number of RA procedures is up to maximum..\n", mac_inst->current_subframe);
return ;
}
migrate_node->active = 1;
migrate_node->preamble_index = preamble_index;
migrate_node->ce_level = ce_level;
migrate_node->ra_rnti = (sfn_id>>2) + 1;
migrate_node->ta = ta;
migrate_node->next = (RA_template_NB_IoT *)0;
migrate_node->prev = (RA_template_NB_IoT *)0;
// insert to end of list
if((RA_template_NB_IoT *)0 == mac_inst->RA_msg2_list.head){
mac_inst->RA_msg2_list.head = migrate_node;
}else{
// not empty
mac_inst->RA_msg2_list.tail->next = migrate_node;
migrate_node->prev = mac_inst->RA_msg2_list.tail;
}
mac_inst->RA_msg2_list.tail = migrate_node;
}*/
// 7bytes
void fill_rar_NB_IoT(
eNB_MAC_INST_NB_IoT *inst,
......
......@@ -413,4 +413,150 @@ void adjust_UL_resource_list(sched_temp_UL_NB_IoT_t *NPUSCH_info)
}
// free(NPUSCH_info);
}
uint8_t *parse_ulsch_header_NB_IoT( uint8_t *mac_header,
uint8_t *num_ce,
uint8_t *num_sdu,
uint8_t *rx_ces,
uint8_t *rx_lcids,
uint16_t *rx_lengths,
uint16_t tb_length ){
uint8_t not_done=1, num_ces=0, num_sdus=0, lcid,num_sdu_cnt;
uint8_t *mac_header_ptr = mac_header;
uint16_t length, ce_len=0;
while(not_done==1){
if(((SCH_SUBHEADER_FIXED_NB_IoT*)mac_header_ptr)->E == 0){
not_done = 0;
}
lcid = ((SCH_SUBHEADER_FIXED_NB_IoT*)mac_header_ptr)->LCID;
if(lcid < EXTENDED_POWER_HEADROOM){
if (not_done==0) { // last MAC SDU, length is implicit
mac_header_ptr++;
length = tb_length-(mac_header_ptr-mac_header)-ce_len;
for(num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++){
length -= rx_lengths[num_sdu_cnt];
}
}else{
if(((SCH_SUBHEADER_SHORT_NB_IoT *)mac_header_ptr)->F == 0){
length = ((SCH_SUBHEADER_SHORT_NB_IoT *)mac_header_ptr)->L;
mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT);
}else{ // F = 1
length = ((((SCH_SUBHEADER_LONG_NB_IoT *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG_NB_IoT *)mac_header_ptr)->L_LSB & 0xff);
mac_header_ptr += 3;//sizeof(SCH_SUBHEADER_LONG);
}
}
rx_lcids[num_sdus] = lcid;
rx_lengths[num_sdus] = length;
num_sdus++;
}else{ // This is a control element subheader POWER_HEADROOM, BSR and CRNTI
if(lcid == SHORT_PADDING){
mac_header_ptr++;
}else{
rx_ces[num_ces] = lcid;
num_ces++;
mac_header_ptr++;
if(lcid==LONG_BSR){
ce_len+=3;
}else if(lcid==CRNTI){
ce_len+=2;
}else if((lcid==POWER_HEADROOM) || (lcid==TRUNCATED_BSR)|| (lcid== SHORT_BSR)) {
ce_len++;
}else{
// wrong lcid
}
}
}
}
*num_ce = num_ces;
*num_sdu = num_sdus;
return(mac_header_ptr);
}
void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t subframe, uint16_t rnti, uint8_t *sdu, uint16_t length)
{
unsigned char rx_ces[5], num_ce = 0, num_sdu = 0, *payload_ptr, i; // MAX Control element
unsigned char rx_lcids[5];//for NB_IoT-IoT, NB_IoT_RB_MAX should be fixed to 5 (2 DRB+ 3SRB)
unsigned short rx_lengths[5];
int UE_id = 0;
int BSR_index=0;
int DVI_index = 0;
int PHR = 0;
int ul_total_buffer = 0;
//mac_NB_IoT_t *mac_inst;
UE_TEMPLATE_NB_IoT *UE_info;
//mac_inst = get_mac_inst(module_id);
// note: if lcid < 25 this is sdu, otherwise this is CE
payload_ptr = parse_ulsch_header_NB_IoT(sdu, &num_ce, &num_sdu,rx_ces, rx_lcids, rx_lengths, length);
//printf("num_CE= %d, num_sdu= %d, rx_ces[0] = %d, rx_lcids = %d, rx_lengths[0] = %d, length = %d\n",num_ce,num_sdu,rx_ces[0],rx_lcids[0],rx_lengths[0],length);
for (i = 0; i < num_ce; i++)
{
switch(rx_ces[i])
{
case CRNTI:
// find UE id again, confirm the UE, intial some ue specific parameters
payload_ptr+=2;
break;
case SHORT_BSR:
// update BSR here
UE_info = get_ue_from_rnti(mac_inst, rnti);
BSR_index = payload_ptr[0] & 0x3f;
UE_info->ul_total_buffer = BSR_table[BSR_index];
payload_ptr+=1;
break;
default:
printf("Received unknown MAC header (0x%02x)\n", rx_ces[i]);
break;
}
}
for (i = 0; i < num_sdu; i++)
{
switch(rx_lcids[i])
{
case CCCH_NB_IoT:
// MSG3 content: |R|R|PHR|PHR|DVI|DVI|DVI|DVI|CCCH payload
PHR = ((payload_ptr[0] >> 5) & 0x01)*2+((payload_ptr[0]>>4) & 0x01);
DVI_index = (payload_ptr[0] >>3 & 0x01)*8+ (payload_ptr[0] >>2 & 0x01)*4 + (payload_ptr[0] >>1 & 0x01)*2 +(payload_ptr[0] >>0 & 0x01);
//printf("DVI_index= %d\n",DVI_index);
ul_total_buffer = DV_table[DVI_index];
printf("PHR = %d, ul_total_buffer = %d\n",PHR,ul_total_buffer);
// go to payload
payload_ptr+=1;
rx_lengths[i]-=1;
printf("rx_lengths : %d\n", rx_lengths[i]);
//NB_IoT_mac_rrc_data_ind(payload_ptr,mac_inst,rnti);
//NB_IoT_receive_msg3(mac_inst,rnti,PHR,ul_total_buffer);
break;
case DCCH0_NB_IoT:
case DCCH1_NB_IoT:
// UE specific here
//NB_IoT_mac_rlc_data_ind(payload_ptr,mac_inst,rnti);
break;
// all the DRBS
case DTCH0_NB_IoT:
default:
//NB_IoT_mac_rlc_data_ind(payload_ptr,mac_inst,rnti);
break;
}
payload_ptr+=rx_lengths[i];
}
}
\ No newline at end of file
......@@ -119,13 +119,8 @@ extern const uint32_t MAC_TBStable_NB_IoT[14][8];
//mapping ITBS to SIB1-NB_IoT
extern const unsigned int MAC_TBStable_NB_IoT_SIB1[16];
//static int DV_table[16]={0,10,14,19,26,36,49,67,91,125,171,234,321,768,1500,1500};
/*static int BSR_table[64]= {0,10,12,14,17,19,22,26,31,36,42,49,57,67,78,91,
105,125,146,171,200,234,274,321,376,440,515,603,706,826,967,1132,
1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099,
16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439,128125,150000,300000
};*/
extern const int DV_table[16];
extern const int BSR_table[64];
extern const int dl_rep[3];
extern const uint32_t dci_rep[3];
......
......@@ -174,10 +174,18 @@ int get_I_TBS_NB_IoT(int x,int y);
uint8_t get_index_Rep_dl(uint16_t R);
UE_TEMPLATE_NB_IoT *get_ue_from_rnti(eNB_MAC_INST_NB_IoT *inst, rnti_t rnti);
//debug function
void print_available_resource_DL(void);
void print_available_UL_resource(void);
//interface with IF
uint8_t *parse_ulsch_header_NB_IoT( uint8_t *mac_header, uint8_t *num_ce, uint8_t *num_sdu, uint8_t *rx_ces, uint8_t *rx_lcids, uint16_t *rx_lengths, uint16_t tb_length);
void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t subframe, uint16_t rnti, uint8_t *sdu, uint16_t length);
#endif
......@@ -883,4 +883,17 @@ void print_available_UL_resource(void){
available_resource = available_resource->next;
}
}
// maybe we can try to use hash table to enhance searching time.
UE_TEMPLATE_NB_IoT *get_ue_from_rnti(eNB_MAC_INST_NB_IoT *inst, rnti_t rnti){
uint32_t i;
for(i=0; i<MAX_NUMBER_OF_UE_MAX_NB_IoT; ++i){
if(inst->UE_list_spec->UE_template_NB_IoT[i].active == 1){
if(inst->UE_list_spec->UE_template_NB_IoT[i].rnti == rnti){
return &inst->UE_list_spec->UE_template_NB_IoT[i];
}
}
}
return (UE_TEMPLATE_NB_IoT *)0;
}
\ No newline at end of file
......@@ -102,13 +102,13 @@ const uint32_t MAC_TBStable_NB_IoT[14][8] ={ //[ITBS][ISF]
//mapping ITBS to SIB1-NB_IoT
const unsigned int MAC_TBStable_NB_IoT_SIB1[16] = {208,208,208,328,328,328,440,440,440,680,680,680};
//static int DV_table[16]={0,10,14,19,26,36,49,67,91,125,171,234,321,768,1500,1500};
const int DV_table[16]={0,10,14,19,26,36,49,67,91,125,171,234,321,768,1500,1500};
/*static int BSR_table[64]= {0,10,12,14,17,19,22,26,31,36,42,49,57,67,78,91,
const int BSR_table[64]= {0,10,12,14,17,19,22,26,31,36,42,49,57,67,78,91,
105,125,146,171,200,234,274,321,376,440,515,603,706,826,967,1132,
1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099,
16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439,128125,150000,300000
};*/
};
const int dl_rep[3] = {1, 2, 4};
const uint32_t dci_rep[3] = {1, 2, 4};
......
#include "IF_Module_L2_primitives_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
// Sched_INFO as a input for the scheduler
void UL_indication(UL_IND_t *UL_INFO)
{
int i=0;
UE_TEMPLATE_NB_IoT *UE_info;
//mac_NB_IoT_t *mac_inst;
/*If there is a preamble, do the initiate RA procedure*/
//If there is a preamble, do the initiate RA procedure
if(UL_INFO->NRACH.number_of_initial_scs_detected>0)
{
for(i=0;i<UL_INFO->NRACH.number_of_initial_scs_detected;i++)
{
/*
initiate_ra_proc_NB_IoT(UL_INFO->module_id,
// initiate_ra here, some useful inforamtion :
//(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc
//(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance
/*init_RA_NB_IoT(UL_INFO->module_id,
UL_INFO->CC_id,
UL_INFO->frame,
(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc,
......@@ -19,28 +25,46 @@ void UL_indication(UL_IND_t *UL_INFO)
(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance * 16,
UL_INFO->subframe
);*/
}
}
// crc indication if there is error for this round UL transmission
if(UL_INFO->crc_ind.number_of_crcs>0)
{
for(i=0;i<UL_INFO->crc_ind.number_of_crcs;i++)
{
if((UL_INFO->crc_ind.crc_pdu_list+i)->crc_indication_rel8.crc_flag == 0)
{
//unsuccessfully received this UE PDU
//UE_info = get_ue_from_rnti(mac_inst,((UL_INFO->crc_ind.crc_pdu_list)+i)->rx_ue_information.rnti);
UE_info->HARQ_round++;
}
}
}
/*If there is a Uplink SDU which needs to send to MAC*/
if(UL_INFO->RX_NPUSCH.number_of_pdus>0)
{
/*If there is a Uplink SDU (even MSG3, NAK) need to send to MAC*/
for(i=0;i<UL_INFO->RX_NPUSCH.number_of_pdus;i++)
{
/*For MSG3, Normal Uplink Data, NAK
/*For MSG3, Normal Uplink Data, NAK*/
rx_sdu_NB_IoT(UL_INFO->module_id,
UL_INFO->CC_id,
UL_INFO->frame,
UL_INFO->subframe,
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.rnti,
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->data,
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length,
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.harq_pid
);*/
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length
);
}
}
//eNB_dlsch_ulsch_scheduler_NB_IoT(UL_INFO.module_id,0,UL_INFO.frame,UL_INFO.subframe); TODO: to be implemented
}
//scheduler here
printf("Enter scheduler\n");
//eNB_dlsch_ulsch_scheduler_NB_IoT(mac_inst,abs_subframe);
}
\ No newline at end of file
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