Commit cac8ad20 authored by Nick Ho's avatar Nick Ho

Procedure after recieving MSG3

parent 51c66750
......@@ -215,7 +215,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
// NB_IoT_eNB_NPDCCH_t *ndlcch = ;
void *DLSCH_DCI_NB_IoT = NULL;
int tmp = 0;
uint8_t *DCI_tmp = NULL;
uint8_t *DCI_flip = NULL;
......@@ -326,9 +326,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->pdu[ncce_index] = DCI_flip;
int tmp = 0;
printf("DCI PDU content:");
printf("DCI N1 RAR PDU content:");
for (tmp =0;tmp<3;tmp++)
printf("%d ",DCI_flip[tmp]);
printf("\n");
......@@ -389,7 +387,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
//add_dci_NB_IoT(eNB->DCI_pdu,DLSCH_DCI_NB_IoT,rnti,sizeof(DCIN1_t),aggregation,sizeof_DCIN1_t,DCIFormatN1,npdcch_start_symbol);
/*Now configure the npdcch structure*/
ndlcch->A[ncce_index] = sizeof(DCIN1_t); // number of bits in DCI
ndlcch->A[ncce_index] = sizeof_DCIN1_t; // number of bits in DCI
// ndlcch->ncce_index = NCCE_index;
// ndlcch->aggregation_level = aggregation;
......@@ -399,20 +397,33 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->active[ncce_index] = 1;//will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping.
ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,32);
ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,4);
ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlcch->repetition_number[ncce_index] = Irep_to_Nrep[RepNum]; // repetition number for NPDSCH
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,32); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
ndlcch->modulation[ncce_index] = 2; //QPSK
//if(ndlcch->round == 0){ //this should be set from initialization (init-lte)
//ndlcch->status[ncce_index] = ACTIVE_NB_IoT;
ndlcch->mcs[ncce_index] = mcs;
ndlcch->TBS[ncce_index] = TBStable_NB_IoT[mcs][ResAssign]; // this table should be rewritten for nb-iot
ndlcch->pdu[ncce_index] = DLSCH_DCI_NB_IoT;
//ndlcch->pdu[ncce_index] = DLSCH_DCI_NB_IoT;
DCI_tmp = (uint8_t*)DLSCH_DCI_NB_IoT;
DCI_flip = (uint8_t*)malloc(3*sizeof(uint8_t));
DCI_flip[0] = DCI_tmp[2]*2;
DCI_flip[1] = DCI_tmp[1]*2;
DCI_flip[2] = DCI_tmp[0]*2;
ndlcch->pdu[ncce_index] = DCI_flip;
printf("DCI N1 PDU content:");
for (tmp =0;tmp<3;tmp++)
printf("%d ",DCI_flip[tmp]);
printf("\n");
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,32); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//}
//ndlcch->frame[ncce_index] = frame;
//ndlcch->subframe[ncce_index] = subframe;
......
......@@ -247,6 +247,7 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
else
{ //this for ue data
//TODO
LOG_I(PHY,"handling MSG4 or ue-spec data");
//program addition DLSCH parameters not from DCI (for the moment we only pass the pdu)
//int UE_id = find_dlsch(rel13->rnti,eNB,SEARCH_EXIST);
......@@ -436,7 +437,8 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
switch(ul_config_pdu->pdu_type)
{
case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE:
if(nfapi_parameters_rel13->nulsch_format==0)
{
// new condition should be added to identify if this is msg3 3 since the TBS_table is not the same.
// the type of subcarrier spacing should be specified before the call of rx_ulsch since the parameter does not exist in nfapi parameters.
......@@ -477,7 +479,9 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
//nulsch_harq->rep_tmp = ;
////////////////////////////////////////////////////////////////////////////////////////
LOG_I(PHY,"subframe = %d (TX timing), IF module proceed UL config NULSCH pdu, will trigger npusch in next subframe\n",subframe);
LOG_I(PHY,"subframe = %d (TX timing), IF module proceed UL config NULSCH data pdu, will trigger npusch in next subframe\n",subframe);
}else
LOG_I(PHY,"subframe = %d (TX timing), IF module proceed UL config NULSCH ack pdu, will trigger npusch in next subframe\n",subframe);
break;
case NFAPI_UL_CONFIG_NRACH_PDU_TYPE:
//TODO just for update the nprach configuration (given at the beginning through phy_config_sib2)
......
......@@ -812,7 +812,11 @@ void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t * proc,n
}
else
{ //managing data
LOG_I(PHY,"Handling the DCI for ue-spec data or MSG4!\n");
// Temp: Add UE id when Msg4 trigger
eNB->ndlsch[0]= (NB_IoT_eNB_NDLSCH_t*) malloc(sizeof(NB_IoT_eNB_NDLSCH_t));
eNB->ndlsch[0]->harq_process = (NB_IoT_DL_eNB_HARQ_t*)malloc(sizeof(NB_IoT_DL_eNB_HARQ_t));
eNB->ndlsch[0]->rnti=dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.rnti;
//TODO target/SIMU/USER?init_lte/init_lte_eNB we should allocate the ndlsch structures
UE_id = find_ue_NB_IoT(dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.rnti, eNB);
AssertFatal(UE_id != -1, "no ndlsch context available or no ndlsch context corresponding to that rnti\n");
......@@ -833,7 +837,7 @@ void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t * proc,n
DCI_Content->DCIN1.HARQackRes = dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.harq_ack_resource;
DCI_Content->DCIN1.DCIRep = dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number;
eNB->npdcch[(uint8_t)UE_id] = (NB_IoT_eNB_NPDCCH_t *) malloc(sizeof(NB_IoT_eNB_NPDCCH_t));
//set the NPDCCH UE-specific structure (calculate R)
npdcch=eNB->npdcch[(uint8_t)UE_id];
AssertFatal(npdcch != NULL, "NPDCCH structure for UE specific is not exist\n");
......
......@@ -391,8 +391,9 @@ void receive_msg3_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t c_rnti, uint32_t
if((RA_TEMPLATE_NB_IoT *)0 != msg3_nodes)
while((RA_TEMPLATE_NB_IoT *)0 != msg3_nodes){
if(msg3_nodes->ue_rnti == c_rnti){
LOG_I(MAC,"add ue in\n");
add_ue_NB_IoT(mac_inst, c_rnti, msg3_nodes->ce_level, phr, ul_total_buffer);// rnti, ce level
LOG_D(MAC,"[%04d][RA scheduler][MSG3][CE%d] Receive MSG3 T-CRNTI %d Preamble Index %d \n", mac_inst->current_subframe, msg3_nodes->ce_level, msg3_nodes->ue_rnti, msg3_nodes->preamble_index);
LOG_I(MAC,"[%04d][RA scheduler][MSG3][CE%d] Receive MSG3 T-CRNTI %d Preamble Index %d \n", mac_inst->current_subframe, msg3_nodes->ce_level, msg3_nodes->ue_rnti, msg3_nodes->preamble_index);
migrate_node = msg3_nodes;
// maintain list
......@@ -730,10 +731,11 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
fail=0;
// check dci resource
rmax = mac_inst->rrc_config.mac_NPRACH_ConfigSIB[msg4_nodes->ce_level].mac_npdcch_NumRepetitions_RA_NB_IoT;//32;
num_candidate = 8;//rmax / r;
num_candidate = 1;//rmax / r;
r = rmax/num_candidate;
num_dci_subframe = r;
dci_subframe = abs_subframe;//mac_inst->current_subframe;
for(dci_candidate=0; dci_candidate<num_candidate; ++dci_candidate){
while(!is_dlsf(mac_inst, dci_subframe)){
++dci_subframe;
......@@ -757,12 +759,13 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
}
// check msg4 resource
rep = dl_rep[msg4_nodes->ce_level];
num_msg4_subframe = 1*rep; // 8 subframes
num_msg4_subframe = 1*rep; // 4 subframe?
msg4_i_delay = find_suit_i_delay(rmax, r, dci_candidate);
for(i=msg4_i_delay; i<8; ++i){
msg4_i_delay = (msg4_i_delay==8)?0:msg4_i_delay;
msg4_subframe = dci_end_subframe+4+get_scheduling_delay(msg4_i_delay, rmax);
msg4_node = (available_resource_DL_t *)check_resource_DL(mac_inst, msg4_subframe, num_msg4_subframe*rep, &msg4_end_subframe, &msg4_first_subframe);
msg4_node = (available_resource_DL_t *)check_resource_DL(mac_inst, msg4_subframe, num_msg4_subframe, &msg4_end_subframe, &msg4_first_subframe);
if((available_resource_DL_t *)0 != msg4_node){
LOG_D(MAC,"%d msg4 %d - %d\n", abs_subframe, msg4_first_subframe, msg4_end_subframe);
break;
......@@ -796,11 +799,11 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
dci_n1_msg4->orderIndicator = 0;
dci_n1_msg4->Scheddly = msg4_i_delay;
dci_n1_msg4->ResAssign = 0;
dci_n1_msg4->mcs = 0;
dci_n1_msg4->RepNum = 1;
dci_n1_msg4->mcs = 4;
dci_n1_msg4->RepNum = 2;
dci_n1_msg4->ndi = 1;
dci_n1_msg4->HARQackRes = HARQ_info.ACK_NACK_resource_field;
dci_n1_msg4->DCIRep = 1;
dci_n1_msg4->DCIRep = 2;
// for dci
dci_result = (schedule_result_t *)malloc(sizeof(schedule_result_t));
......@@ -811,7 +814,7 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
dci_result->DCI_release = 0;
dci_result->channel = NPDCCH;
dci_result->rnti = msg4_nodes->ue_rnti;
dci_result->rnti_type = 1;
dci_result->rnti_type = 3;
dci_result->npusch_format = 0; //useless
dci_result->R_harq = 0;
dci_result->next = (schedule_result_t *)0;
......@@ -848,12 +851,13 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
harq_result->DLSCH_pdu = NULL;
harq_result->DCI_pdu = (void *)dci_n1_msg4;
harq_result->DCI_release = 1;
harq_result->npusch_format = 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);
LOG_I(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_I(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++;
// fill dci resource
......
......@@ -267,8 +267,10 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
printf("%02x ",payload_ptr[a]);
printf("\n");
rx_lengths[i]-=1;
LOG_I(MAC,"rx_lengths : %d\n", rx_lengths[i]);
mac_rrc_msg3_ind_NB_IoT(payload_ptr,rnti);
LOG_D(MAC,"rx_lengths : %d\n", rx_lengths[i]);
mac_rrc_msg3_ind_NB_IoT(payload_ptr,rnti,rx_lengths[i]);
receive_msg3_NB_IoT(mac_inst,rnti,PHR,DVI_index);
LOG_D(MAC,"recieve msg3 Successfully at MAC!\n");
//NB_IoT_mac_rrc_data_ind(payload_ptr,mac_inst,rnti);
//NB_IoT_receive_msg3(mac_inst,rnti,PHR,ul_total_buffer);
break;
......
......@@ -136,7 +136,37 @@ 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,"[init_mac_NB_IoT] Initial UE list\n");
mac_inst->num_uss_list = NUM_USS_PP;
for(i=0;i<NUM_USS_PP;++i)
{
//rrc_mac_config_req(&mac_inst->rrc_config, 0, 0, 1, i);
(mac_inst->UE_list_spec+i)->head = -1;
(mac_inst->UE_list_spec+i)->tail = -1;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.R_max = mac_inst->rrc_config.npdcch_ConfigDedicated[i].R_max;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.G = mac_inst->rrc_config.npdcch_ConfigDedicated[i].G;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.a_offset = mac_inst->rrc_config.npdcch_ConfigDedicated[i].a_offset;
//(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.R_max = 8;
//(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.G = 1;
//(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.a_offset = 0;
(mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.T = (uint32_t)((double)(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;
//SCHEDULE_LOG("[init_mac_NB_IoT][CE%d] Rmax %d G %d, a_offset %d, PP %d search space 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);
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;
}
LOG_I(MAC,"[init_mac_NB_IoT] List_number %d R_max %d G %.1f a_offset %.1f T %d SS_start %d\n", i, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.R_max, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.G, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.a_offset, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.T, (mac_inst->UE_list_spec+i)->NPDCCH_config_dedicated.ss_start_uss);
}
//UL initial
//Setting nprach configuration
......
......@@ -37,7 +37,9 @@
#include "LAYER2/MAC/defs_NB_IoT.h"
/*NOTE: no static function should be declared in this header file (e.g. init_SI_NB)*/
void mac_rrc_msg3_ind_NB_IoT(uint8_t *payload_ptr,uint16_t rnti);
void generate_msg4_NB_IoT(rrc_eNB_carrier_data_NB_IoT_t *carrier);
void mac_rrc_msg3_ind_NB_IoT(uint8_t *payload_ptr, uint16_t rnti, uint32_t length);
uint8_t *get_NB_IoT_MIB(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
......
......@@ -121,10 +121,57 @@ extern uint16_t two_tier_hexagonal_cellIds[7];
mui_t rrc_eNB_mui = 0;
void mac_rrc_msg3_ind_NB_IoT(uint8_t *payload_ptr, uint16_t rnti)
void generate_msg4_NB_IoT(rrc_eNB_carrier_data_NB_IoT_t *carrier)
{
LOG_I(RRC,"start the RRC connection setup PDU\n");
rrc_eNB_ue_context_NB_IoT_t* ue_context_pP_NB_IoT;
ue_context_pP_NB_IoT = (rrc_eNB_ue_context_NB_IoT_t*)malloc(sizeof(rrc_eNB_ue_context_NB_IoT_t));
SRB_ToAddModList_NB_r13_t **SRB_configList_NB_IoT;
SRB_configList_NB_IoT = &ue_context_pP_NB_IoT->ue_context.SRB_configList;
carrier[0].Srb0.Tx_buffer.payload_size = do_RRCConnectionSetup_NB_IoT(ue_context_pP_NB_IoT,
0,
carrier[0].Srb0.Tx_buffer.Payload,
0,
SRB_configList_NB_IoT,
&ue_context_pP_NB_IoT->ue_context.physicalConfigDedicated_NB_IoT);
LOG_I(RRC,"[MSG] RRC Connection Setup NB-IoT\n");
int cnt;
for (cnt = 0; cnt < carrier[0].Srb0.Tx_buffer.payload_size; cnt++)
{
printf("%02x ", carrier[0].Srb0.Tx_buffer.Payload[cnt]);
}
printf("\n");
}
void mac_rrc_msg3_ind_NB_IoT(uint8_t *payload_ptr, uint16_t rnti, uint32_t length)
{
LOG_I(RRC,"recieve MSG3 CCCH SDU from MAC\n");
asn_dec_rval_t dec_rval;
asn_dec_rval_t dec_rval;
struct rrc_eNB_ue_context_NB_IoT_s *ue_context_p = NULL;
SRB_INFO_NB_IoT *srb_info = NULL;
srb_info = &eNB_rrc_inst_NB_IoT->carrier[0].Srb0;
memcpy(srb_info->Rx_buffer.Payload,payload_ptr,length);
srb_info->Rx_buffer.payload_size = length;
LOG_D(RRC,"Decoding UL CCCH %x.%x.%x.%x.%x.%x.%x.%x.%x (%p)\n",
((uint8_t *) srb_info->Rx_buffer.Payload)[0],
((uint8_t *) srb_info->Rx_buffer.Payload)[1],
((uint8_t *) srb_info->Rx_buffer.Payload)[2],
((uint8_t *) srb_info->Rx_buffer.Payload)[3],
((uint8_t *) srb_info->Rx_buffer.Payload)[4],
((uint8_t *) srb_info->Rx_buffer.Payload)[5],
((uint8_t *) srb_info->Rx_buffer.Payload)[6],
((uint8_t *) srb_info->Rx_buffer.Payload)[7],
((uint8_t *) srb_info->Rx_buffer.Payload)[8],
(uint8_t *) srb_info->Rx_buffer.Payload);
RRCConnectionRequest_NB_r13_IEs_t* rrcConnectionRequest_NB = NULL;
UL_CCCH_Message_NB_t* ul_ccch_msg_NB = NULL;
dec_rval = uper_decode(
......@@ -156,9 +203,14 @@ void mac_rrc_msg3_ind_NB_IoT(uint8_t *payload_ptr, uint16_t rnti)
for(int a = 0; a<length;a++)
printf("%02x ",da[a]);
printf("\n");
}else
LOG_E(RRC,"unknown TMSI or Random Value format in RRC connection request NB\n");
}else
}
else
{
LOG_E(RRC,"unknown TMSI or Random Value format in RRC connection request NB\n");
}
generate_msg4_NB_IoT(&eNB_rrc_inst_NB_IoT->carrier[0]);
}
else
LOG_E(RRC,"unknown MSG3 format for NB-IoT for current test\n");
}
......
......@@ -35,6 +35,7 @@
#include "UTIL/LOG/log.h"
#include "rrc_eNB_UE_context_NB_IoT.h"
#include "proto_NB_IoT.h"
#include "msc.h"
//------------------------------------------------------------------------------
......
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