Commit 410da556 authored by Nick Ho's avatar Nick Ho

Fix resource allocation issue at MAC

parent 17fa23d5
......@@ -54,7 +54,7 @@
void add_dci_NB_IoT(DCI_PDU_NB_IoT *DCI_pdu,void *pdu,rnti_t rnti,unsigned char dci_size_bytes,unsigned char aggregation,unsigned char dci_size_bits,unsigned char dci_fmt, uint8_t npdcch_start_symbol)
{
//put the pdu
memcpy(&DCI_pdu->dci_alloc[DCI_pdu->Num_dci].dci_pdu[0],pdu,dci_size_bytes);
memcpy(&DCI_pdu->dci_alloc[0].dci_pdu[0],pdu,dci_size_bytes);
//configure the dci alloc
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].dci_length = dci_size_bits;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].L = aggregation;
......@@ -159,7 +159,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
// NB_IoT_eNB_NPDCCH_t *ndlcch = ;
void *DLSCH_DCI_NB_IoT = NULL;
eNB->DCI_pdu = (DCI_PDU_NB_IoT*) malloc(sizeof(DCI_PDU_NB_IoT));
//eNB->DCI_pdu = (DCI_PDU_NB_IoT*) malloc(sizeof(DCI_PDU_NB_IoT));
//N1 parameters
uint8_t ncce_index = 0;
......@@ -213,6 +213,8 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
HARQackRes = DCI_Content->DCIN1_RAR.HARQackRes;
DCIRep = DCI_Content->DCIN1_RAR.DCIRep;
DLSCH_DCI_NB_IoT = (DCIN1_RAR_t *)malloc(sizeof(DCIN1_RAR_t));
//DCI pdu content
((DCIN1_RAR_t *)DLSCH_DCI_NB_IoT)->type =type;
((DCIN1_RAR_t *)DLSCH_DCI_NB_IoT)->orderIndicator =orderIndicator;
......@@ -266,6 +268,8 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
//ndlsch-> sqrt_rho_a?? set in dlsch_modulation
//ndlsch-> sqrt_rho_b??? set in dlsch_modulation
LOG_D(PHY,"DCI packing for N1RAR done \n");
//set in new_eNB_dlsch (initialization)
/*
* Mlimit
......@@ -288,7 +292,8 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ndi = DCI_Content->DCIN1.ndi;
HARQackRes = DCI_Content->DCIN1.HARQackRes;
DCIRep = DCI_Content->DCIN1.DCIRep;
DLSCH_DCI_NB_IoT = (DCIN1_t *)malloc(sizeof(DCIN1_t));
/*Packed DCI here*/
((DCIN1_t *)DLSCH_DCI_NB_IoT)->type =type;
((DCIN1_t *)DLSCH_DCI_NB_IoT)->orderIndicator =orderIndicator;
......@@ -339,6 +344,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
directIndInf = DCI_Content->DCIN2_Ind.directIndInf;
resInfoBits = DCI_Content->DCIN2_Ind.resInfoBits;
DLSCH_DCI_NB_IoT = (DCIN2_Ind_t *)malloc(sizeof(DCIN2_Ind_t));
/*Packed DCI here*/
((DCIN2_Ind_t *)DLSCH_DCI_NB_IoT)->type =type;
((DCIN2_Ind_t *)DLSCH_DCI_NB_IoT)->directIndInf =directIndInf;
......@@ -359,6 +365,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
RepNum = DCI_Content->DCIN2_Pag.RepNum;
DCIRep = DCI_Content->DCIN2_Pag.DCIRep;
DLSCH_DCI_NB_IoT = (DCIN2_Pag_t *)malloc(sizeof(DCIN2_Pag_t));
/*Packed DCI here*/
((DCIN2_Pag_t *)DLSCH_DCI_NB_IoT)->type =type;
((DCIN2_Pag_t *)DLSCH_DCI_NB_IoT)->ResAssign =ResAssign;
......@@ -381,7 +388,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
// compute DL power control parameters
free(DLSCH_DCI_NB_IoT);
return(0);
}
......
......@@ -188,13 +188,14 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
//Independently if we have the PDU or not (first transmission or repetition) the process is activated for triggering the ndlsch_procedure
//LOG_I(PHY,"ACTIVE_NB_IoT\n");
ndlsch_harq23->status = ACTIVE_NB_IoT;
LOG_D(PHY,"A NB-handle_nfapi_dlsch_pdu_NB_IoT SIB23\n");
//LOG_D(PHY,"A NB-handle_nfapi_dlsch_pdu_NB_IoT SIB23\n");
}
//ue specific data or RAR (we already have received the DCI for this)
else if(rel13->rnti != 65535 && rel13->rnti_type == 1)
{
printf("rel13->rnti: %d, eNB->ndlsch_RAR->rnti: %d\n",rel13->rnti,eNB->ndlsch_RAR->rnti);
//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 && rel13->rnti == eNB->ndlsch_RAR->rnti) //rnti for the RAR should have been set priviously by the DCI
{
......@@ -337,10 +338,9 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
{
case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE:
//Remember: there is no DCI for SI information
LOG_I(PHY,"Generate DL PDU information from scheduelr\n");
//LOG_D(PHY,"Generate DL DCI PDU information from scheduler\n");
//TODO: separate the ndlsch structure configuration from the DCI (here we will encode only the DCI)
generate_eNB_dlsch_params_NB_IoT(eNB,proc,dl_config_pdu);
break;
case NFAPI_DL_CONFIG_NBCH_PDU_TYPE:
......
......@@ -32,6 +32,7 @@
#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
#include "PHY/extern.h"
#include "PHY/LTE_ESTIMATION/defs_NB_IoT.h"
#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
......@@ -722,7 +723,7 @@ void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_t *
NB_IoT_eNB_NDLSCH_t *ndlsch;
NB_IoT_eNB_NPDCCH_t *npdcch;
eNB->DCI_pdu = (DCI_PDU_NB_IoT*)malloc(sizeof(DCI_PDU_NB_IoT));
DCI_Content = (DCI_CONTENT*) malloc(sizeof(DCI_CONTENT));
......@@ -753,10 +754,10 @@ void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_t *
// fill the dlsch_ra_NB structure for RAR, and packed the DCI PDU
ndlsch = eNB->ndlsch_ra;
ndlsch = PHY_vars_eNB_g[0][0]->ndlsch_RAR;
ndlsch->ndlsch_type = RAR;
LOG_I(PHY,"Generating dlsch params for RA_RNTI and packing DCI\n");
//LOG_I(PHY,"Generating dlsch params for RA_RNTI and packing DCI\n");
generate_eNB_dlsch_params_from_dci_NB_IoT(eNB,
frame,
subframe,
......@@ -768,6 +769,7 @@ void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_t *
dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.aggregation_level,
dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.start_symbol);
//printf("PHY_vars_eNB_g[0][0]->ndlsch_RAR->rnti = %d\n",PHY_vars_eNB_g[0][0]->ndlsch_RAR->rnti);
//eNB->dlsch_ra_NB->nCCE[subframe] = eNB->DCI_pdu->dci_alloc.firstCCE;
}
else
......
......@@ -115,14 +115,17 @@ void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
while((RA_TEMPLATE_NB_IoT *)0 != msg2_nodes){
fail=0;
fail=0;
rmax = mac_inst->rrc_config.mac_NPRACH_ConfigSIB[msg2_nodes->ce_level].mac_npdcch_NumRepetitions_RA_NB_IoT;//32;
num_candidate = 8;//rmax / r;
r = rmax/num_candidate;
num_dci_subframe = r;
dci_subframe = abs_subframe;//mac_inst->current_subframe;
LOG_D(MAC,"rmax : %d, num_dci_subframe : %d, dci_subframe: %d\n",rmax,r,dci_subframe);
//LOG_I(MAC,"rmax : %d, num_dci_subframe : %d, dci_subframe: %d\n",rmax,r,dci_subframe);
//print_available_resource_DL(mac_inst);
for(dci_candidate=0; dci_candidate<num_candidate; ++dci_candidate){
......@@ -202,7 +205,7 @@ void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
LOG_D(MAC,"[%04d][RA scheduler][MSG2][CE%d] rnti: %d preamble: %d fail vector %d\n", abs_subframe-1, msg2_nodes->ce_level, msg2_nodes->ra_rnti, msg2_nodes->preamble_index, fail);
msg2_nodes = msg2_nodes->next;
}else{
LOG_I(MAC,"[%04d][RA scheduler][MSG2][CE%d] rnti: %d preamble: %d scheduling success\n", abs_subframe-1, msg2_nodes->ce_level, msg2_nodes->ra_rnti, msg2_nodes->preamble_index);
LOG_D(MAC,"[%04d][RA scheduler][MSG2][CE%d] rnti: %d preamble: %d scheduling success\n", abs_subframe-1, msg2_nodes->ce_level, msg2_nodes->ra_rnti, msg2_nodes->preamble_index);
dci_result = (schedule_result_t *)calloc(1, sizeof(schedule_result_t));
msg2_result = (schedule_result_t *)calloc(1, sizeof(schedule_result_t));
dci_n0 = (DCIFormatN0_t *)malloc(sizeof(DCIFormatN0_t));
......@@ -273,12 +276,16 @@ void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
msg2_nodes->ue_rnti = tc_rnti;
LOG_I(MAC,"[%04d][RA scheduler][MSG2] RARDCI %d-%d RAR %d-%d MSG3 %d-%d\n", abs_subframe-1, dci_first_subframe, dci_end_subframe, msg2_first_subframe, msg2_end_subframe, npusch_info.sf_start, npusch_info.sf_end);
LOG_I(MAC,"[%04d][RA scheduler][MSG2][CE%d] Change RA-RNTI %d->T-CRNTI %d\n", abs_subframe-1, msg2_nodes->ce_level, msg2_nodes->ra_rnti, msg2_nodes->ue_rnti);
LOG_I(MAC,"[%04d][RA scheduler][MSG2][CE%d] RAR DCI %d-%d RAR %d-%d MSG3 %d-%d\n", abs_subframe-1, msg2_nodes->ce_level, dci_first_subframe, dci_end_subframe, msg2_first_subframe, msg2_end_subframe, npusch_info.sf_start, npusch_info.sf_end);
LOG_D(MAC,"[%04d][RA scheduler][MSG2] RARDCI %d-%d RAR %d-%d MSG3 %d-%d\n", abs_subframe-1, dci_first_subframe, dci_end_subframe, msg2_first_subframe, msg2_end_subframe, npusch_info.sf_start, npusch_info.sf_end);
LOG_D(MAC,"[%04d][RA scheduler][MSG2][CE%d] Change RA-RNTI %d->T-CRNTI %d\n", abs_subframe-1, msg2_nodes->ce_level, msg2_nodes->ra_rnti, msg2_nodes->ue_rnti);
LOG_D(MAC,"[%04d][RA scheduler][MSG2][CE%d] RAR DCI %d-%d RAR %d-%d MSG3 %d-%d\n", abs_subframe-1, msg2_nodes->ce_level, dci_first_subframe, dci_end_subframe, msg2_first_subframe, msg2_end_subframe, npusch_info.sf_start, npusch_info.sf_end);
print_available_resource_DL(mac_inst);
//LOG_D(MAC,"dci_node:%p dci_node_prev:%p %3d-%3d\n", dci_node, dci_node->prev,dci_node->start_subframe, dci_node->end_subframe);
// fill dci resource
fill_resource_DL(mac_inst, dci_node, dci_first_subframe, dci_end_subframe, dci_result);
print_available_resource_DL(mac_inst);
//LOG_D(MAC,"msg2_node:%p msg2_node_prev:%p %3d-%3d\n", msg2_node, msg2_node->prev,msg2_node->start_subframe, msg2_node->end_subframe);
// fill msg2 resource
fill_resource_DL(mac_inst, msg2_node, msg2_first_subframe, msg2_end_subframe, msg2_result);
......@@ -323,7 +330,7 @@ void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe){
mac_inst->RA_msg3_list.tail = migrate_node;
}
LOG_I(MAC,"RAR schedule Done\n");
LOG_D(MAC,"RAR schedule Done\n");
}
......
......@@ -175,7 +175,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
if(schedule_result_list_DL->direction == DL)
{
LOG_I(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL_DCI\n",hypersfn,frame,subframe);
LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL_DCI\n",hypersfn,frame,subframe);
//LOG_D(MAC,"Sched Info DL DCI here\n");
//SCHED_info->DL_req = (nfapi_dl_config_request_t*) malloc (sizeof(nfapi_dl_config_request_t));
//SCHED_info->DL_req->dl_config_request_body.number_pdu = 0;
......@@ -183,6 +183,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list;
SCHED_info->DL_req->dl_config_request_body.number_dci = 1;
SCHED_info->DL_req->dl_config_request_body.number_pdu = 1;
DCI_pdu = schedule_result_list_DL->DCI_pdu;
// not consider the case transmitting 2 DCIs for the moment also not consider N2 now
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE;
......@@ -204,7 +205,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number = ((DCIFormatN1_t *)DCI_pdu)->DCIRep;
}else if(schedule_result_list_DL->direction == UL)
{
LOG_I(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL_DCI\n",hypersfn,frame,subframe);
LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL_DCI\n",hypersfn,frame,subframe);
//SCHED_info->HI_DCI0_req = (nfapi_hi_dci0_request_t*)malloc(sizeof(nfapi_hi_dci0_request_t));
//SCHED_info->HI_DCI0_req->hi_dci0_request_body.number_of_dci = 0;
//SCHED_info->HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*)malloc(sizeof(nfapi_hi_dci0_request_pdu_t));
......@@ -227,7 +228,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
}
break;
case NPDSCH:
LOG_I(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL Data\n",hypersfn,frame,subframe);
LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL Data\n",hypersfn,frame,subframe);
//LOG_I(MAC,"NB-IoT fill DL Data\n");
//SCHED_info->DL_req = (nfapi_dl_config_request_t*) malloc (sizeof(nfapi_dl_config_request_t));
//SCHED_info->DL_req->dl_config_request_body.number_pdu = 0;
......
......@@ -1003,7 +1003,7 @@ void extend_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int max_subfram
LOG_D(MAC,"[extend DL] add new node !\n");
new_node = (available_resource_DL_t *)malloc(sizeof(available_resource_DL_t));
new_node->prev= available_resource_DL_last;
available_resource_DL_last->next = new_node;
new_node->start_subframe = mac_inst->schedule_subframe_DL+1;
new_node->end_subframe = max_subframe;
......@@ -1285,9 +1285,10 @@ void fill_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, available_resource_DL_t *no
// divided into two node, always insert before original node, so won't happen that temp is the last node of the list.
// A | node | B
// A | temp | node | B
LOG_D(MAC,"Case 0 [b], node : %p node_prev : %p\n",node,node->prev);
temp = (available_resource_DL_t *)malloc(sizeof(available_resource_DL_t));
if(node->prev){
//LOG_I(MAC,"start_subframe : %d\n",node->prev->start_subframe);
node->prev->next = temp;
}else{
available_resource_DL = temp;
......@@ -1301,9 +1302,10 @@ void fill_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, available_resource_DL_t *no
temp->end_subframe = start_subframe - 1;
node->start_subframe = end_subframe + 1;
LOG_D(MAC,"Case 0 [a], node : %p node_prev : %p\n",node,node->prev);
break;
case 1:
LOG_D(MAC,"Case 1, node : %p node_prev : %p\n",node,node->prev);
// keep one node
if(align_left){
node->start_subframe = end_subframe + 1 ;
......@@ -1313,6 +1315,7 @@ void fill_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, available_resource_DL_t *no
break;
case 2:
LOG_D(MAC,"Case 2 [b], node : %p node_prev : %p\n",node,node->prev);
// delete
if(node->next){
node->next->prev = node->prev;
......@@ -1325,6 +1328,7 @@ void fill_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, available_resource_DL_t *no
}else{
available_resource_DL = node->next;
}
LOG_D(MAC,"Case 2 [a], node : %p node_prev : %p\n",node,node->prev);
free(node);
break;
......@@ -1468,7 +1472,7 @@ void print_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst){
int i=0;
LOG_D(MAC,"=== print available resource === t=%d\nsched subframe: %d, list end: %d-%d\n", mac_inst->current_subframe, mac_inst->schedule_subframe_DL, available_resource_DL_last->start_subframe, available_resource_DL_last->end_subframe);
while(pt){
LOG_D(MAC,"[%2d] %p %3d-%3d\n", i, pt, pt->start_subframe, pt->end_subframe);
LOG_D(MAC,"[%2d] %p %3d-%3d prev:%p\n", i, pt, pt->start_subframe, pt->end_subframe, pt->prev);
pt = pt->next;
}
LOG_D(MAC,"\n");
......
......@@ -14,12 +14,14 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
//If there is a preamble, do the initiate RA procedure
if(UL_INFO->nrach_ind.number_of_initial_scs_detected>0)
{
for(i=0;i<UL_INFO->nrach_ind.number_of_initial_scs_detected;i++)
// only use one preamble now
//for(i=0;i<UL_INFO->nrach_ind.number_of_initial_scs_detected;i++)
for(i=0;i<1;i++)
{
// 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
LOG_I(MAC,"Init_RA_NB_IoT in\n");
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);
init_RA_NB_IoT(mac_inst,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.nrach_ce_level,
......@@ -27,11 +29,11 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
//timing_offset = Timing_advance * 16
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16
);
LOG_I(MAC,"Init_RA_NB_IoT Out\n");
LOG_D(MAC,"Init_RA_NB_IoT Out\n");
}
}
UL_INFO->nrach_ind.number_of_initial_scs_detected = 0;
UL_INFO->nrach_ind.number_of_initial_scs_detected = 0;
/* Disable uplink RX function for now
......
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