Commit f31174ee authored by Nick Ho's avatar Nick Ho

Fill Msg4 DCI and Data information in order to transmit at PHY

parent d9d73306
......@@ -199,8 +199,8 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
//printf("rel13->rnti: %d, eNB->ndlsch_RAR->rnti: %d\n",rel13->rnti,eNB->ndlsch_RAR->rnti);
//eNB->ndlsch_RAR->rnti = rel13->rnti;
//check if the PDU is for RAR
if(eNB->ndlsch_RAR != NULL && eNB->ndlsch_RAR->ndlsch_type == RAR) //rnti for the RAR should have been set priviously by the DCI
//if(eNB->ndlsch_RAR != NULL && rel13->rnti == eNB->ndlsch_RAR->rnti) //rnti for the RAR should have been set priviously by the DCI
//if(eNB->ndlsch_RAR != NULL && eNB->ndlsch_RAR->ndlsch_type == RAR) //rnti for the RAR should have been set priviously by the DCI
if(eNB->ndlsch_RAR != NULL && rel13->rnti == eNB->ndlsch_RAR->rnti) //rnti for the RAR should have been set priviously by the DCI
{
eNB->ndlsch_RAR->active = 1;
......@@ -226,13 +226,13 @@ 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");
LOG_I(PHY,"handling MSG4 or ue-spec data\n");
//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);
UE_id = find_ue_NB_IoT(rel13->rnti,eNB);
AssertFatal(UE_id==-1,"no existing ue specific dlsch_context\n");
UE_id = 0;
//UE_id = find_ue_NB_IoT(rel13->rnti,eNB);
//AssertFatal(UE_id==-1,"no existing ue specific dlsch_context\n");
ndlsch = eNB->ndlsch[(uint8_t)UE_id];
ndlsch_harq = eNB->ndlsch[(uint8_t)UE_id]->harq_process;
......
......@@ -677,7 +677,7 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
int dci_subframe, dci_end_subframe, dci_first_subframe, num_dci_subframe;
int msg4_subframe = 0, msg4_end_subframe, msg4_first_subframe, num_msg4_subframe;
int harq_subframe, harq_end_subframe;
int msg4_length = 0; // return value of msg4 pdu (bits)
int dci_candidate, num_candidate;
int msg4_i_delay, i, res, rep;
int end_flagHARQ, HARQ_delay;
......@@ -685,6 +685,11 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
schedule_result_t *dci_result;
schedule_result_t *msg4_result;
schedule_result_t *harq_result;
uint32_t I_tbs, I_sf,I_mcs;
//Transport block size
int TBS;
int n_sf;
#if 0
// msg4 pre-processor
......@@ -761,8 +766,22 @@ 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_tbs = I_mcs;
TBS = get_max_tbs(I_tbs);
if(TBS > msg4_length)
{
TBS = get_tbs(msg4_length, I_tbs, &I_sf);
LOG_D(MAC,"TBS change to %d because data size is smaller than previous TBS\n", TBS);
}else
LOG_E(MAC,"the size of MSG4 is bigger than max TBS\n");
num_msg4_subframe = 1*rep; // 4 subframe?
//Get number of subframe this UE need per repetition
n_sf = get_num_sf(I_sf);
LOG_D(MAC,"n_sf = %d\n", n_sf);
num_msg4_subframe = n_sf*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;
......@@ -794,7 +813,6 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
if(0==fail){
LOG_D(MAC,"[%04d][RA scheduler][MSG4][CE%d] rnti: %d scheduling success\n", abs_subframe-1, msg4_nodes->ce_level, msg4_nodes->ue_rnti);
fill_msg4_NB_IoT(mac_inst,msg4_nodes);
msg4_nodes->wait_msg4_ack = 1;
DCIFormatN1_t *dci_n1_msg4 = (DCIFormatN1_t *)malloc(sizeof(DCIFormatN1_t));
// dci entity
......@@ -833,7 +851,7 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
msg4_result = (schedule_result_t *)malloc(sizeof(schedule_result_t));
msg4_result->output_subframe = msg4_first_subframe;// msg4_subframe;
msg4_result->end_subframe = msg4_end_subframe;
msg4_result->sdu_length = 0;
msg4_result->sdu_length = TBS*8;
msg4_result->direction = DL;
msg4_result->DCI_release = 0;
msg4_result->channel = NPDSCH;
......@@ -860,7 +878,7 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
harq_result->next = (schedule_result_t *)0;
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] UE:%x MSG4DCI %d-%d MSG4 %d-%d HARQ %d-%d, TBS = %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, TBS*8);
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++;
......@@ -958,27 +976,31 @@ void fill_rar_NB_IoT(
// Generate MSG4 MAC PDU
void fill_msg4_NB_IoT(
int fill_msg4_NB_IoT(
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 padding, 2 for Control element of Contention resolution, 3 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 = PADDING;
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 = 1;
msg4_sub_2->LCID = UE_CONTENTION_RESOLUTION;
length+=1;
SCH_SUBHEADER_FIXED_NB_IoT *msg4_sub_3 = (SCH_SUBHEADER_FIXED_NB_IoT *) (msg4_sub_2 +1);
msg4_sub_3->R= 0;
msg4_sub_3->E= 0;
msg4_sub_3->LCID = CCCH_NB_IoT;
length+=1;
uint8_t *con_res = (uint8_t *)(dlsch_buffer+3);
......@@ -988,6 +1010,7 @@ void fill_msg4_NB_IoT(
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+9);
......@@ -998,9 +1021,12 @@ void fill_msg4_NB_IoT(
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];
length+=7;
/*
printf("MSG4 PDU = ");
for(int i=0; i<16;i++)
for(int i=0; i<length;i++)
printf("%02x ",dlsch_buffer[i]);
printf("\n");
*/
return length;
}
\ No newline at end of file
......@@ -260,14 +260,14 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
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);
ul_total_buffer = DV_table[DVI_index];
LOG_I(MAC,"PHR = %d, ul_total_buffer = %d\n",PHR,ul_total_buffer);
LOG_D(MAC,"PHR = %d, ul_total_buffer = %d\n",PHR,ul_total_buffer);
// go to payload
payload_ptr+=1;
// Note that the first 6 byte (48 bits) of this CCCH SDU should be encoded in the MSG4 for contention resolution
printf("CCCH SDU content: ");
/*printf("CCCH SDU content: ");
for(int a = 0; a<9;a++)
printf("%02x ",payload_ptr[a]);
printf("\n");
printf("\n");*/
rx_lengths[i]-=1;
LOG_D(MAC,"rx_lengths : %d\n", rx_lengths[i]);
msg4_rrc_pdu = mac_rrc_msg3_ind_NB_IoT(payload_ptr,rnti,rx_lengths[i]);
......
......@@ -126,7 +126,7 @@ void schedule_msg3_retransimission_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs
void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void fill_rar_NB_IoT(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template, uint8_t msg3_schedule_delay, uint8_t msg3_rep, sched_temp_UL_NB_IoT_t *schedule_template);
void receive_msg4_ack_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t rnti);
void fill_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template);
int fill_msg4_NB_IoT(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);
......
......@@ -155,7 +155,7 @@ uint8_t* generate_msg4_NB_IoT(rrc_eNB_carrier_data_NB_IoT_t *carrier)
uint8_t* 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");
LOG_D(RRC,"recieve MSG3 CCCH SDU from MAC\n");
asn_dec_rval_t dec_rval;
struct rrc_eNB_ue_context_NB_IoT_s *ue_context_p = NULL;
uint8_t* msg4_rrc_sdu = NULL;
......
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