Commit db61edd7 authored by Nick Ho's avatar Nick Ho

solve some issue at RX

parent 30bd3fbe
......@@ -1655,7 +1655,7 @@ uint32_t turbo_decoding_NB_IoT(PHY_VARS_eNB *eNB,
} else {
fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0); // indicate NAK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,0);
printf(" NPSUCH NOT OK\n");
printf(" NPUSCH NOT OK\n");
}
} //////////// r loop end ////////////
......@@ -1789,18 +1789,18 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB,
ulsch_NB_IoT->Msg3_frame);
///////////////////////////////// Decision ACK/NACK /////////////////////////////////////
printf("\n\n\n");
//printf("\n\n\n");
if (counter_ack>8) //hard decision
{
//fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1); // indicate ACK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,1);
printf(" decoded ACK of DL Data (include MSG4) \n");
LOG_I(PHY," decoded ACK of DL Data (include MSG4) \n");
} else if (counter_ack<8) { //hard decision
//fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0); // indicate NAK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,0);
printf(" decoded ACK of DL Data (include MSG4) \n");
LOG_I(PHY," decoded ACK of DL Data (include MSG4) \n");
} else { //when equality (8 bits 0 vs 8 bits 1), soft decision
......@@ -1814,14 +1814,14 @@ void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB *eNB,
{
// fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,1); // indicate ACK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,1);
printf(" decoded msg5 (soft): ACK ");
LOG_I(PHY," decoded msg5 (soft): ACK ");
} else {
//fill_crc_indication_NB_IoT(eNB,0,rx_frame,rx_subframe,0); // indicate NAK to MAC
fill_rx_indication_NB_IoT(eNB,proc,npusch_format,0);
printf(" decoded msg5 (soft): NACK ");
LOG_I(PHY," decoded msg5 (soft): NACK ");
}
}
printf("\n\n\n"); // end decision for ACK/NACK
//printf("\n\n\n"); // end decision for ACK/NACK
}
///// if last sf of the word
......
......@@ -345,7 +345,7 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
//LOG_I(PHY, "number_dl_pdu: %d ,dl_config_pdu type: %d\n",number_dl_pdu,dl_config_pdu->pdu_type);
switch (dl_config_pdu->pdu_type)
{
printf("In case schedule_response_NB_IoT****************************************in schedule_response_NB_IoT\n");
//printf("In case schedule_response_NB_IoT****************************************in schedule_response_NB_IoT\n");
case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE:
//printf("NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE***********************\n");
//Remember: there is no DCI for SI information
......@@ -444,8 +444,9 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
///////////////////////////////////////////////////////////////////////////////////////////
//maybe this condition should be replaced by another test ?!
if(nfapi_parameters_rel13->size < 80) // msg3 data
if((nfapi_parameters_rel13->size < 80)&&(nfapi_parameters_rel13->size != 41)) // msg3 data
{
LOG_I(PHY,"MSG3 process at PHY\n");
nulsch = eNB->ulsch_NB_IoT[0];
nulsch_harq = nulsch->harq_process;
......@@ -468,6 +469,8 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
nulsch_harq->new_data_indication = nfapi_parameters_rel13->new_data_indication; // valid only for DCI N0
nulsch_harq->TBS = nfapi_parameters_rel13->size; /// check if needed *8 or /8 or nothing to do
} else{ // other npusch data
LOG_I(PHY,"UL data process at PHY\n");
nulsch = eNB->ulsch_NB_IoT[0];
nulsch_harq = nulsch->harq_process;
......
......@@ -258,7 +258,8 @@ typedef struct{
/*** the value of variable in this structure is able to be changed in Preprocessor**/
typedef struct{
uint8_t resent_flag;
uint16_t TBS;
uint8_t index_tbs;
uint32_t total_sdu_size;
......
......@@ -252,6 +252,8 @@ void schedule_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, u
UE_TEMPLATE_NB_IoT *UE_template_temp;
DCIFormatN1_t *DCI_N1;
DCIFormatN0_t *DCI_N0;
DCIFormatN0_t *DCI_N0_1;
//SCHEDULE_NB_IoT_t *scheduler = &eNB->scheduler;
mac_inst->scheduling_flag.flag_uss[0]=1;
mac_inst->scheduling_flag.flag_uss[1]=0;
......@@ -303,6 +305,14 @@ void schedule_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, u
//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+3, UE_sched_ctrl_info->NPUSCH_sf_end+3,DCI_N0, UE_template_temp->rnti, str22, str23, 0);
if (UE_sched_ctrl_info->resent_flag==1)
{
DCI_N0_1 = (DCIFormatN0_t*)malloc(sizeof(DCIFormatN0_t));
UE_sched_ctrl_info->dci_n0_index_ndi = 1;
fill_DCI_N0(DCI_N0_1, UE_template_temp, UE_sched_ctrl_info);
generate_scheduling_result_UL(UE_sched_ctrl_info->NPDCCH_sf_start+800, UE_sched_ctrl_info->NPDCCH_sf_end+800,UE_sched_ctrl_info->NPUSCH_sf_start+803, UE_sched_ctrl_info->NPUSCH_sf_end+803,DCI_N0_1, UE_template_temp->rnti, str22, str23, 0);
}
//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;
......
......@@ -763,9 +763,9 @@ 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];
msg4_length = fill_msg4_NB_IoT(mac_inst,msg4_nodes);
I_mcs = get_I_mcs(msg4_nodes->ce_level);
//I_mcs = 1;
msg4_length = fill_msg4_NB_IoT_dedicated(mac_inst,msg4_nodes);
//I_mcs = get_I_mcs(msg4_nodes->ce_level);
I_mcs = 5;
I_tbs = I_mcs;
TBS = get_max_tbs(I_tbs);
if(TBS > msg4_length)
......@@ -1018,6 +1018,58 @@ int fill_msg4_NB_IoT(
return length;
}
// Generate MSG4 MAC PDU
int fill_msg4_NB_IoT_dedicated(
eNB_MAC_INST_NB_IoT *inst,
RA_TEMPLATE_NB_IoT *ra_template
)
{
int length = 0;
uint8_t *dlsch_buffer = &ra_template->msg4_buffer[0];
// we have three subheader here: 1 for Control element of Contention resolution, 2 for CCCH
SCH_SUBHEADER_FIXED_NB_IoT *msg4_sub_1 = (SCH_SUBHEADER_FIXED_NB_IoT*)dlsch_buffer;
msg4_sub_1->R = 0;
msg4_sub_1->E = 1;
msg4_sub_1->LCID = UE_CONTENTION_RESOLUTION;
length+=1;
SCH_SUBHEADER_FIXED_NB_IoT *msg4_sub_2 = (SCH_SUBHEADER_FIXED_NB_IoT *) (msg4_sub_1 +1);
msg4_sub_2->R= 0;
msg4_sub_2->E= 0;
msg4_sub_2->LCID = CCCH_NB_IoT;
length+=1;
uint8_t *con_res = (uint8_t *)(dlsch_buffer+2);
con_res[0] = ra_template->ccch_buffer[0];
con_res[1] = ra_template->ccch_buffer[1];
con_res[2] = ra_template->ccch_buffer[2];
con_res[3] = ra_template->ccch_buffer[3];
con_res[4] = ra_template->ccch_buffer[4];
con_res[5] = ra_template->ccch_buffer[5];
length+=6;
uint8_t *msg4_rrc_sdu = (uint8_t *) (dlsch_buffer+8);
msg4_rrc_sdu[0] = ra_template->msg4_rrc_buffer[0];
msg4_rrc_sdu[1] = ra_template->msg4_rrc_buffer[1];
msg4_rrc_sdu[2] = ra_template->msg4_rrc_buffer[2];
msg4_rrc_sdu[3] = ra_template->msg4_rrc_buffer[3];
msg4_rrc_sdu[4] = ra_template->msg4_rrc_buffer[4];
msg4_rrc_sdu[5] = ra_template->msg4_rrc_buffer[5];
msg4_rrc_sdu[6] = ra_template->msg4_rrc_buffer[6];
msg4_rrc_sdu[7] = ra_template->msg4_rrc_buffer[7];
msg4_rrc_sdu[8] = ra_template->msg4_rrc_buffer[8];
msg4_rrc_sdu[9] = ra_template->msg4_rrc_buffer[9];
length+=10;
/*
printf("MSG4 PDU = ");
for(int i=0; i<length;i++)
printf("%02x ",dlsch_buffer[i]);
printf("\n");
*/
return length;
}
// Generate MSG4 MAC PDU
int fill_msg4_NB_IoT_fixed(
eNB_MAC_INST_NB_IoT *inst,
......
......@@ -145,11 +145,25 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
return 0;
*/
//Fill result to Output structure
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;
if(UE_info->ul_total_buffer==39)
{
UE_sched_ctrl_info->NPDCCH_sf_end=NPDCCH_info->sf_end+200;
UE_sched_ctrl_info->NPDCCH_sf_start=NPDCCH_info->sf_start+200;
UE_sched_ctrl_info->NPUSCH_sf_end=NPUSCH_info->sf_end+200;
UE_sched_ctrl_info->NPUSCH_sf_start=NPUSCH_info->sf_start+200;
UE_sched_ctrl_info->resent_flag = 1;
LOG_N(MAC,"Delay sending the DCI, and receive command\n");
UE_sched_ctrl_info->dci_n0_index_ndi=0;
}else
{
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->dci_n0_index_ndi=ndi;
}
UE_sched_ctrl_info->TBS=TBS;
UE_sched_ctrl_info->dci_n0_index_mcs=mcs;
UE_sched_ctrl_info->index_tbs=mcs;
......@@ -157,7 +171,7 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
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_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;
......
......@@ -128,6 +128,8 @@ void fill_rar_NB_IoT(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template,
void receive_msg4_ack_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t rnti);
int fill_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template);
int fill_msg4_NB_IoT_fixed(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template);
int fill_msg4_NB_IoT_dedicated(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template);
//USS
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);
......
......@@ -4,6 +4,7 @@
int tmp = 0;
int block_rach = 0;
int first_msg4 = 0;
void simulate_preamble(UL_IND_NB_IoT_t *UL_INFO, int CE, int sc)
{
......@@ -93,7 +94,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
//for(i=0;i<UL_INFO->nrach_ind.number_of_initial_scs_detected;i++)
for(i=0;i<1;i++)
{
if(block_rach == 0)
if(block_rach == 0 )
{
// initiate_ra here, some useful inforamtion :
LOG_D(MAC,"Init_RA_NB_IoT in, index of sc = %d\n",(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc);
......@@ -140,7 +141,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
{
LOG_I(MAC,"This UE get the response of HARQ DL : ACK, update the UL buffer for next message\n");
ue_info->direction=0;
ue_info->ul_total_buffer = 64;
ue_info->ul_total_buffer = 39;
block_rach = 1;
//LOG_I(MAC,"This UE get the response of HARQ DL : NACK, and will start the next harq round : %d\n",ue_info->HARQ_round);
//ue_info->direction=1;
......@@ -149,7 +150,11 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
}
else
{
receive_msg4_ack_NB_IoT(mac_inst,UL_INFO->nb_harq_ind.nb_harq_indication_body.nb_harq_pdu_list[0].rx_ue_information.rnti);
if(first_msg4 == 0)
{
receive_msg4_ack_NB_IoT(mac_inst,UL_INFO->nb_harq_ind.nb_harq_indication_body.nb_harq_pdu_list[0].rx_ue_information.rnti);
first_msg4 = 1;
}
}
}
......
......@@ -954,7 +954,7 @@ uint8_t do_RRCConnectionSetup_NB_IoT(
long* npusch_repetitions = NULL;
long* group_hopping_disabled = NULL;
long* srpro = NULL;
long* periodicBSR_Timer = NULL;
// At the first moment of MSG4 testing we set NULL to those optional
struct SRB_ToAddMod_NB_r13* SRB1_config_NB_IoT = NULL;
......@@ -965,6 +965,9 @@ uint8_t do_RRCConnectionSetup_NB_IoT(
struct SRB_ToAddMod_NB_r13__rlc_Config_r13* SRB1bis_rlc_config_NB_IoT = NULL;
struct SRB_ToAddMod_NB_r13__logicalChannelConfig_r13* SRB1bis_lchan_config_NB_IoT = NULL;
struct RadioResourceConfigDedicated_NB_r13__mac_MainConfig_r13 *mac_main_config_NB_IoT = NULL;
struct MAC_MainConfig_NB_r13__logicalChannelSR_Config_r13 *logicalChannelSR_Config = NULL;
struct MAC_MainConfig_NB_r13__ul_SCH_Config_r13 *ul_SCH_Config = NULL;
PhysicalConfigDedicated_NB_r13_t* physicalConfigDedicated2_NB_IoT = NULL;
DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
RRCConnectionSetup_NB_t* rrcConnectionSetup_NB_IoT = NULL;
......@@ -1099,6 +1102,35 @@ uint8_t do_RRCConnectionSetup_NB_IoT(
// UplinkPowerControlDedicated
physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13->p0_UE_NPUSCH_r13 = 0;
mac_main_config_NB_IoT = CALLOC(1, sizeof(*mac_main_config_NB_IoT));
mac_main_config_NB_IoT->present = RadioResourceConfigDedicated_NB_r13__mac_MainConfig_r13_PR_explicitValue_r13;
//mac_main_config_NB_IoT->present = RadioResourceConfigDedicated_NB_r13__mac_MainConfig_r13_PR_defaultValue_r13;
//mac_main_config_NB_IoT->choice.explicitValue_r13.ul_SCH_Config_r13 =NULL;
mac_main_config_NB_IoT->choice.explicitValue_r13.ul_SCH_Config_r13 = CALLOC(1,sizeof(*mac_main_config_NB_IoT->choice.explicitValue_r13.ul_SCH_Config_r13));
mac_main_config_NB_IoT->choice.explicitValue_r13.logicalChannelSR_Config_r13 = CALLOC(1,sizeof(* mac_main_config_NB_IoT->choice.explicitValue_r13.logicalChannelSR_Config_r13));
//mac_main_config_NB_IoT->choice.explicitValue_r13.logicalChannelSR_Config_r13 = NULL;
//periodicBSR_Timer = CALLOC(1,sizeof(*periodicBSR_Timer));
//*periodicBSR_Timer = 2; // PeriodicBSR_Timer_NB_r13_pp8
//logicalChannelSR_Config = CALLOC(1,sizeof(*logicalChannelSR_Config));
mac_main_config_NB_IoT->choice.explicitValue_r13.logicalChannelSR_Config_r13->choice.setup.logicalChannelSR_ProhibitTimer_r13 = 6;//MAC_MainConfig_NB_r13__logicalChannelSR_Config_r13__setup__logicalChannelSR_ProhibitTimer_r13_pp8
mac_main_config_NB_IoT->choice.explicitValue_r13.logicalChannelSR_Config_r13->present = MAC_MainConfig_NB_r13__logicalChannelSR_Config_r13_PR_setup;
//ul_SCH_Config = CALLOC(1,sizeof(*ul_SCH_Config));
mac_main_config_NB_IoT->choice.explicitValue_r13.ul_SCH_Config_r13->periodicBSR_Timer_r13 = CALLOC(1,sizeof(*mac_main_config_NB_IoT->choice.explicitValue_r13.ul_SCH_Config_r13->periodicBSR_Timer_r13));
*(mac_main_config_NB_IoT->choice.explicitValue_r13.ul_SCH_Config_r13->periodicBSR_Timer_r13) = 2;
mac_main_config_NB_IoT->choice.explicitValue_r13.ul_SCH_Config_r13->retxBSR_Timer_r13 = 6; // RetxBSR_Timer_NB_r13_pp512, 6 = iffinitiy
//mac_main_config_NB_IoT->present = RadioResourceConfigDedicated_NB_r13__mac_MainConfig_r13_PR_explicitValue_r13;
//mac_main_config_NB_IoT->choice.explicitValue_r13.ul_SCH_Config_r13= NULL; //ul_SCH_Config
//mac_main_config_NB_IoT->choice.explicitValue_r13.timeAlignmentTimerDedicated_r13 = 0;//7= TimeAlignmentTimer_infinity
//mac_main_config_NB_IoT->choice.explicitValue_r13.logicalChannelSR_Config_r13 = logicalChannelSR_Config; // logicalChannelSR_Config
//mac_main_config_NB_IoT->choice.explicitValue_r13.ext1 = NULL;
//mac_main_config_NB_IoT->choice.explicitValue_r13.ext2 = NULL;
//mac_main_config_NB_IoT->choice.explicitValue_r13.drx_Config_r13 = NULL;
//Fill the rrcConnectionSetup-NB message
rrcConnectionSetup_NB_IoT->rrc_TransactionIdentifier = Transaction_id; //input value
......@@ -1110,7 +1142,7 @@ uint8_t do_RRCConnectionSetup_NB_IoT(
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.drb_ToReleaseList_r13 = NULL;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.rlf_TimersAndConstants_r13 = NULL;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.physicalConfigDedicated_r13 = physicalConfigDedicated2_NB_IoT;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.mac_MainConfig_r13 = NULL;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.mac_MainConfig_r13 = mac_main_config_NB_IoT; // mac_main_config_NB_IoT
#ifdef XER_PRINT
xer_fprint(stdout, &asn_DEF_DL_CCCH_Message, (void*)&dl_ccch_msg);
......@@ -1118,15 +1150,22 @@ uint8_t do_RRCConnectionSetup_NB_IoT(
enc_rval = uper_encode_to_buffer(&asn_DEF_DL_CCCH_Message_NB,
(void*)&dl_ccch_msg_NB_IoT,
buffer,
100);
255);
AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
LOG_I(RRC,"[MSG] RRC Connection Setup NB-IoT: ");
#ifdef USER_MODE
LOG_D(RRC,"RRCConnectionSetup-NB Encoded %d bits (%d bytes), ecause %d\n",
int cnt;
for (cnt = 0; cnt <((enc_rval.encoded+7)/8); cnt++)
{
printf("%02x ", buffer[cnt]);
}
printf("\n");
LOG_I(RRC,"RRCConnectionSetup-NB Encoded %d bits (%d bytes), ecause %d\n",
enc_rval.encoded,(enc_rval.encoded+7)/8,ecause);
#endif
return((enc_rval.encoded+7)/8);
}
......
......@@ -155,7 +155,7 @@ uint8_t* generate_msg4_NB_IoT(rrc_eNB_carrier_data_NB_IoT_t *carrier)
for (cnt = 0; cnt < carrier[0].Srb0.Tx_buffer.payload_size; cnt++)
{
printf("%02x ", carrier[0].Srb0.Tx_buffer.Payload[cnt]);
printf("%02x ", (uint8_t)carrier[0].Srb0.Tx_buffer.Payload[cnt]);
}
printf("\n");
......
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