Commit ab0e4aad authored by Xenofon Foukas's avatar Xenofon Foukas
Browse files

Reintroduced support for agent scheduler after merge with develop

parent a91a25c9
......@@ -86,7 +86,6 @@ schedule_ue_spec_default(
//TODO
uint8_t CC_id;
int UE_id;
uint16_t nCCE[MAX_NUM_CCs];
int N_RBG[MAX_NUM_CCs];
unsigned char aggregation;
mac_rlc_status_resp_t rlc_status;
......@@ -103,9 +102,8 @@ schedule_ue_spec_default(
// uint8_t dl_pow_off[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
// unsigned char rballoc_sub_UE[MAX_NUM_CCs][NUMBER_OF_UE_MAX][N_RBG_MAX];
// uint16_t pre_nb_available_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
int mcs;
int mcs, mcs_tmp;
uint16_t min_rb_unit[MAX_NUM_CCs];
short ta_update = 0;
eNB_MAC_INST *eNB = &eNB_mac_inst[mod_id];
UE_list_t *UE_list = &eNB->UE_list;
LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs];
......@@ -144,15 +142,18 @@ schedule_ue_spec_default(
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
min_rb_unit[CC_id] = get_min_rb_unit(mod_id, CC_id);
frame_parms[CC_id] = mac_xface->get_lte_frame_parms(mod_id, CC_id);
//total_nb_available_rb[CC_id] = frame_parms[CC_id]->N_RB_DL - nb_rb_used[CC_id];
//nCCE[CC_id] = mac_xface->get_nCCE_max(mod_id, CC_id) - nCCE_used[CC_id];
// get number of PRBs less those used by common channels
total_nb_available_rb[CC_id] = frame_parms[CC_id]->N_RB_DL;
for (i=0;i<frame_parms[CC_id]->N_RB_DL;i++)
if (eNB->common_channels[CC_id].vrb_map[i]!=0)
total_nb_available_rb[CC_id]--;
N_RBG[CC_id] = frame_parms[CC_id]->N_RBG;
// store the global enb stats:
eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs;
eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id];
eNB->eNB_stats[CC_id].total_available_prbs += total_nb_available_rb[CC_id];
eNB->eNB_stats[CC_id].available_ncces = nCCE[CC_id];
eNB->eNB_stats[CC_id].dlsch_bytes_tx=0;
eNB->eNB_stats[CC_id].dlsch_pdus_tx=0;
}
......@@ -192,15 +193,17 @@ schedule_ue_spec_default(
continue_flag=1;
}
if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || (nCCE[CC_id] < (1<<aggregation))) {
// LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n",
// mod_id, frame, UE_id, CC_id, nb_rb_used[CC_id], ue_sched_ctl->pre_nb_available_rbs[CC_id], nCCE[CC_id], aggregation);
if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated
CCE_allocation_infeasible(mod_id, CC_id, 0, subframe, aggregation, rnti)
) {
LOG_D(MAC,"[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n",
mod_id, frame, UE_id, CC_id);
//if(mac_xface->get_transmission_mode(module_idP,rnti)==5)
continue_flag=1; //to next user (there might be rbs availiable for other UEs in TM5
// else
// break;
}
if (frame_parms[CC_id]->frame_type == TDD) {
set_ue_dai (subframe,
frame_parms[CC_id]->tdd_config,
......@@ -233,6 +236,8 @@ schedule_ue_spec_default(
nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id];
harq_pid = ue_sched_ctl->harq_pid[CC_id];
round = ue_sched_ctl->round[CC_id];
/* TODO: Must add these stats (probably in the apply_scheduling function) */
//UE_list->eNB_UE_stats[CC_id][UE_id].crnti= rnti;
//UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status=mac_eNB_get_rrc_status(mod_id, rnti);
//UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid;
......@@ -248,15 +253,18 @@ schedule_ue_spec_default(
*/
mcs = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]];
/*TODO: Must also update these stats*/
//eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]];
//eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs);
#ifdef EXMIMO
// if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)==5) {
// eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1,16);
// }
if (mac_xface->get_transmission_mode(mod_id, CC_id, rnti)==5) {
mcs = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]];
//eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1,16);
}
#endif
......@@ -264,14 +272,13 @@ schedule_ue_spec_default(
//UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->DL_cqi[0];
// initializing the rb allocation indicator for each UE
for(j=0; j<frame_parms[CC_id]->N_RBG; j++) {
for(j = 0; j < frame_parms[CC_id]->N_RBG; j++) {
UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0;
}
LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, ncc %d, rrc %d)\n",
LOG_D(MAC,"[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n",
mod_id, frame, UE_id, CC_id, rnti, harq_pid, round, nb_available_rb,
eNB_UE_stats->DL_cqi[0], mcs,
nCCE[CC_id],
UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status);
dl_dci = (Protocol__PrpDlDci*) malloc(sizeof(Protocol__PrpDlDci));
......@@ -301,14 +308,14 @@ schedule_ue_spec_default(
if (nb_rb <= nb_available_rb) {
if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
for(j=0; j<frame_parms[CC_id]->N_RBG; j++) { // for indicating the rballoc for each sub-band
for(j = 0; j < frame_parms[CC_id]->N_RBG; j++) { // for indicating the rballoc for each sub-band
UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
}
} else {
nb_rb_temp = nb_rb;
j = 0;
while((nb_rb_temp > 0) && (j<frame_parms[CC_id]->N_RBG)) {
while((nb_rb_temp > 0) && (j < frame_parms[CC_id]->N_RBG)) {
if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) {
UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
if((j == frame_parms[CC_id]->N_RBG-1) &&
......@@ -326,8 +333,6 @@ schedule_ue_spec_default(
nb_available_rb -= nb_rb;
aggregation = process_ue_cqi(mod_id, UE_id);
nCCE[CC_id]-=(1<<aggregation); // adjust the remaining nCCE
//nCCE_used[CC_id] += (1<<aggregation);
PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
......@@ -344,7 +349,8 @@ schedule_ue_spec_default(
dl_dci->res_alloc = 0;
dl_dci->n_mcs = 1;
dl_dci->mcs = (uint32_t *)malloc(sizeof(uint32_t));
dl_dci->mcs[0] = mcs; //eNB_UE_stats->dlsch_mcs1;
dl_dci->mcs[0] = mcs;
//TODO:Need to fix tpc for retransmissions
dl_dci->has_tpc = 1;
dl_dci->tpc = 1;
dl_dci->has_vrb_format = 1;
......@@ -352,7 +358,7 @@ schedule_ue_spec_default(
dl_dci->has_format = 1;
dl_dci->format = PROTOCOL__PRP_DCI_FORMAT__PRDCIF_1;
dl_dci->has_rb_bitmap = 1;
dl_dci->rb_bitmap = allocate_prbs_sub(UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid], UE_list->UE_template[CC_id][UE_id].rballoc_subband);
dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, UE_list->UE_template[CC_id][UE_id].rballoc_subband);
dl_dci->has_rb_shift = 1;
dl_dci->rb_shift = 0;
dl_dci->n_ndi = 1;
......@@ -374,29 +380,48 @@ schedule_ue_spec_default(
case 4:
dl_dci->has_res_alloc = 1;
dl_dci->res_alloc = 0;
dl_dci->n_mcs = 2;
dl_dci->mcs = (uint32_t *)malloc(sizeof(uint32_t) * dl_dci->n_mcs);
dl_dci->mcs[0] = mcs;
dl_dci->mcs[1] = mcs;
//TODO:Need to fix tpc for retransmissions
dl_dci->has_tpc = 1;
dl_dci->tpc = 1;
dl_dci->has_vrb_format = 1;
dl_dci->vrb_format = PROTOCOL__PRP_VRB_FORMAT__PRVRBF_LOCALIZED;
dl_dci->has_format = 1;
dl_dci->format = PROTOCOL__PRP_DCI_FORMAT__PRDCIF_2A;
dl_dci->has_rb_bitmap = 1;
dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, UE_list->UE_template[CC_id][UE_id].rballoc_subband);
dl_dci->has_rb_shift = 1;
dl_dci->rb_shift = 0;
dl_dci->n_ndi = 2;
dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi);
dl_dci->ndi[0] = 0;
dl_dci->ndi[1] = 0;
//dl_dci->has_rb_bitmap = 1;
//dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub);
dl_dci->has_rb_shift = 1;
dl_dci->rb_shift = 0;
dl_dci->has_dai = 1;
dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3;
dl_dci->n_rv = 2;
dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv);
dl_dci->rv[0] = round&3;
dl_dci->rv[1] = round&3;
if (frame_parms[CC_id]->frame_type == TDD) {
dl_dci->has_dai = 1;
dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3;
LOG_D(MAC,"[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d\n",
mod_id, CC_id, harq_pid, round,(UE_list->UE_template[CC_id][UE_id].DAI-1));
} else {
LOG_D(MAC,"[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d\n",
mod_id, CC_id, harq_pid, round);
}
break;
case 5:
dl_dci->has_res_alloc = 1;
dl_dci->res_alloc = 0;
dl_dci->n_mcs = 1;
dl_dci->mcs = (uint32_t *)malloc(sizeof(uint32_t));
dl_dci->mcs[0] = mcs;
//TODO:Need to fix tpc for retransmissions
dl_dci->has_tpc = 1;
dl_dci->tpc = 1;
dl_dci->has_vrb_format = 1;
dl_dci->vrb_format = PROTOCOL__PRP_VRB_FORMAT__PRVRBF_LOCALIZED;
dl_dci->has_format = 1;
......@@ -404,8 +429,8 @@ schedule_ue_spec_default(
dl_dci->n_ndi = 1;
dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi);
dl_dci->ndi[0] = 0;
//dl_dci->has_rb_bitmap = 1;
//dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub);
dl_dci->has_rb_bitmap = 1;
dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, UE_list->UE_template[CC_id][UE_id].rballoc_subband);
dl_dci->has_rb_shift = 1;
dl_dci->rb_shift = 0;
dl_dci->has_dai = 1;
......@@ -425,6 +450,12 @@ schedule_ue_spec_default(
case 6:
dl_dci->has_res_alloc = 1;
dl_dci->res_alloc = 0;
dl_dci->n_mcs = 1;
dl_dci->mcs = (uint32_t *)malloc(sizeof(uint32_t));
dl_dci->mcs[0] = mcs;
//TODO:Need to fix tpc for retransmissions
dl_dci->has_tpc = 1;
dl_dci->tpc = 1;
dl_dci->has_vrb_format = 1;
dl_dci->vrb_format = PROTOCOL__PRP_VRB_FORMAT__PRVRBF_LOCALIZED;
dl_dci->has_format = 1;
......@@ -432,8 +463,8 @@ schedule_ue_spec_default(
dl_dci->n_ndi = 1;
dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi);
dl_dci->ndi[0] = 0;
//dl_dci->has_rb_bitmap = 1;
//dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, rballoc_sub);
dl_dci->has_rb_bitmap = 1;
dl_dci->rb_bitmap = allocate_prbs_sub(nb_rb, UE_list->UE_template[CC_id][UE_id].rballoc_subband);
dl_dci->has_rb_shift = 1;
dl_dci->rb_shift = 0;
dl_dci->has_dai = 1;
......@@ -447,17 +478,18 @@ schedule_ue_spec_default(
break;
}
add_ue_dlsch_info(mod_id,
CC_id,
UE_id,
subframe,
S_DL_SCHEDULED);
/*We now probably don't need this*/
/* add_ue_dlsch_info(mod_id, */
/* CC_id, */
/* UE_id, */
/* subframe, */
/* S_DL_SCHEDULED); */
//eNB_UE_stats->dlsch_trials[round]++;
//UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission+=1;
//UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx=nb_rb;
//UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx+=nb_rb;
//UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx=nCCE[CC_id];
//UE_list->eNB_UE_stats[CC_id][UE_id].ncce_used_retx=nCCECC_id];
//UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1;
//UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2=eNB_UE_stats->dlsch_mcs1;
......@@ -475,33 +507,12 @@ schedule_ue_spec_default(
//TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb);
TBS = mac_xface->get_TBS_DL(mcs, nb_available_rb);
dci_tbs = TBS;
// check first for RLC data on DCCH
// add the length for all the control elements (timing adv, drx, etc) : header + payload
//#ifndef EXMIMO_IOT
// to be checked by RK, NN, FK
uint8_t update_TA=4;
switch (frame_parms[CC_id]->N_RB_DL) {
case 6:
update_TA = 1;
break;
case 25:
update_TA = 4;
break;
case 50:
update_TA = 8;
break;
case 100:
update_TA = 16;
break;
}
ta_len = ((eNB_UE_stats->timing_advance_update/update_TA)!=0) ? 2 : 0;
ta_len = (ue_sched_ctl->ta_update!=0) ? 2 : 0;
dl_data[num_ues_added]->n_ce_bitmap = 2;
dl_data[num_ues_added]->ce_bitmap = (uint32_t *) malloc(sizeof(uint32_t) * 2);
......@@ -509,6 +520,7 @@ schedule_ue_spec_default(
ce_flags |= PROTOCOL__PRP_CE_TYPE__PRPCET_TA;
}
/*TODO: Add other flags if DRX and other CE are required*/
// Add the control element flags to the progran message
dl_data[num_ues_added]->ce_bitmap[0] = ce_flags;
......@@ -519,24 +531,22 @@ schedule_ue_spec_default(
// Need to see if we have space for data from this channel
if ( TBS-ta_len-header_len_dcch > 0 ) {
//If we have space, we need to see how much data we can request at most (if any are available)
rlc_status = mac_rlc_status_ind(
mod_id,
rnti,
mod_id,
frame,
ENB_FLAG_YES,
MBMS_FLAG_NO,
DCCH,
(TBS-ta_len-header_len_dcch)); // transport block set size
//If we have space, we need to see how much data we can request at most (if any available)
rlc_status = mac_rlc_status_ind(mod_id,
rnti,
mod_id,
frame,
ENB_FLAG_YES,
MBMS_FLAG_NO,
DCCH,
(dci_tbs-ta_len-header_len_dcch)); // transport block set size
//If data are available in the DCCH
if (rlc_status.bytes_in_buffer > 0) {
// Fill at most 1/3 of the remaining TB
data_to_request = 3;//cmin(3, rlc_status.bytes_in_buffer);
LOG_D(MAC, "[TEST]Have %d bytes in buffer DCCH during first call\n", rlc_status.bytes_in_buffer);
//Fill in as much as possible
data_to_request = cmin(dci_tbs-ta_len-header_len_dcch, rlc_status.bytes_in_buffer) + 1;
LOG_D(MAC, "[TEST]Will request %d \n", data_to_request);
rlc_pdus[0] = (Protocol__PrpRlcPdu *) malloc(sizeof(Protocol__PrpRlcPdu));
protocol__prp_rlc_pdu__init(rlc_pdus[0]);
rlc_pdus[0]->n_rlc_pdu_tb = 2;
......@@ -562,26 +572,25 @@ schedule_ue_spec_default(
}
// check for DCCH1 and update header information (assume 2 byte sub-header)
if (TBS-ta_len-header_len_dcch+2-sdu_length_total > 0 ) {
if (dci_tbs-ta_len-header_len_dcch-sdu_length_total > 0 ) {
//If we have space, we need to see how much data we can request at most (if any are available)
rlc_status = mac_rlc_status_ind(
mod_id,
rlc_status = mac_rlc_status_ind(mod_id,
rnti,
mod_id,
frame,
ENB_FLAG_YES,
MBMS_FLAG_NO,
DCCH+1,
(TBS-ta_len-header_len_dcch+2-sdu_length_total)); // transport block set size less allocations for timing advance and
(dci_tbs-ta_len-header_len_dcch-sdu_length_total)); // transport block set size less allocations for timing advance and
// DCCH SDU
// If data are available in DCCH1
if (rlc_status.bytes_in_buffer > 0) {
header_len_dcch += 2;
//Fill another 1/3 of the remaining TB
data_to_request = 3;//cmin(3, rlc_status.bytes_in_buffer);
//Fill in as much as possible
data_to_request = cmin(dci_tbs-ta_len-header_len_dcch-sdu_length_total, rlc_status.bytes_in_buffer) + 1;
rlc_pdus[1] = (Protocol__PrpRlcPdu *) malloc(sizeof(Protocol__PrpRlcPdu));
protocol__prp_rlc_pdu__init(rlc_pdus[1]);
......@@ -589,7 +598,7 @@ schedule_ue_spec_default(
rlc_pdus[1]->rlc_pdu_tb = (Protocol__PrpRlcPduTb **) malloc(sizeof(Protocol__PrpRlcPduTb *) * 2);
rlc_pdus[1]->rlc_pdu_tb[0] = (Protocol__PrpRlcPduTb *) malloc(sizeof(Protocol__PrpRlcPduTb));
rlc_pdus[1]->rlc_pdu_tb[0]->has_logical_channel_id = 1;
rlc_pdus[1]->rlc_pdu_tb[0]->logical_channel_id = DCCH;
rlc_pdus[1]->rlc_pdu_tb[0]->logical_channel_id = DCCH+1;
rlc_pdus[1]->rlc_pdu_tb[0]->has_size = 1;
rlc_pdus[1]->rlc_pdu_tb[0]->size = data_to_request;
rlc_pdus[1]->rlc_pdu_tb[1] = (Protocol__PrpRlcPduTb *) malloc(sizeof(Protocol__PrpRlcPduTb));
......@@ -610,27 +619,26 @@ schedule_ue_spec_default(
LOG_D(MAC,"[eNB %d], Frame %d, DTCH->DLSCH, CC_id %d, Checking RLC status (rab %d, tbs %d, len %d)\n",
mod_id, frame, CC_id, DTCH, TBS,
TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch);
dci_tbs-ta_len-header_len_dcch-sdu_length_total-header_len_dtch);
if (TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch > 0 ) {
if (dci_tbs-ta_len-header_len_dcch-sdu_length_total-header_len_dtch > 0 ) {
//If we have space, we need to see how much data we can request at most (if any are available)
rlc_status = mac_rlc_status_ind(
mod_id,
rlc_status = mac_rlc_status_ind(mod_id,
rnti,
mod_id,
frame,
ENB_FLAG_YES,
MBMS_FLAG_NO,
DTCH,
TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch);
dci_tbs-ta_len-header_len_dcch-sdu_length_total-header_len_dtch);
// If data are available in DTCH
if (rlc_status.bytes_in_buffer > 0) {
LOG_D(MAC, "[TEST] Have %d bytes in buffer DTCH during first call\n", rlc_status.bytes_in_buffer);
//Fill what remains in the TB
data_to_request = 3;//cmin(3, rlc_status.bytes_in_buffer);
data_to_request = cmin(dci_tbs-ta_len-header_len_dcch-sdu_length_total-header_len_dtch, rlc_status.bytes_in_buffer) + 1;
LOG_D(MAC, "[TEST]Will request %d \n", data_to_request);
rlc_pdus[2] = (Protocol__PrpRlcPdu *) malloc(sizeof(Protocol__PrpRlcPdu));
protocol__prp_rlc_pdu__init(rlc_pdus[2]);
rlc_pdus[2]->n_rlc_pdu_tb = 2;
......@@ -654,14 +662,14 @@ schedule_ue_spec_default(
}
} else {
header_len_dtch = 0;
header_len_dtch = 3;
}
}
// Add rlc_pdus to the dl_data message
dl_data[num_ues_added]->rlc_pdu = (Protocol__PrpRlcPdu **) malloc(sizeof(Protocol__PrpRlcPdu *) *
dl_data[num_ues_added]->n_rlc_pdu);
for (i = 0; i< dl_data[num_ues_added]->n_rlc_pdu; i++) {
for (i = 0; i < dl_data[num_ues_added]->n_rlc_pdu; i++) {
dl_data[num_ues_added]->rlc_pdu[i] = rlc_pdus[i];
}
......@@ -674,51 +682,48 @@ schedule_ue_spec_default(
header_len_dtch_tmp = header_len_dtch;
if (header_len_dtch == 0) {
header_len_dcch = (header_len_dcch >0) ? 1 : header_len_dcch; // remove length field
header_len_dcch = (header_len_dcch > 0) ? 1 : header_len_dcch; // remove length field
} else {
header_len_dtch = (header_len_dtch > 0) ? 1 :header_len_dtch; // remove length field for the last SDU
header_len_dtch = (header_len_dtch > 0) ? 1 : header_len_dtch; // remove length field for the last SDU
}
int mcs2;
mcs2 = mcs;
mcs_tmp = mcs;
// TODO: Need to compute this and not take it from the stats
// mcs = eNB_UE_stats->dlsch_mcs1;
if (mcs2==0) {
if (mcs_tmp == 0) {
nb_rb = 4; // don't let the TBS get too small
} else {
nb_rb=min_rb_unit[CC_id];
}
TBS = mac_xface->get_TBS_DL(mcs2,nb_rb);
TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb);
while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) {
nb_rb += min_rb_unit[CC_id]; //
if (nb_rb>nb_available_rb) { // if we've gone beyond the maximum number of RBs
if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs
// (can happen if N_RB_DL is odd)
TBS = mac_xface->get_TBS_DL(mcs2, nb_available_rb);
TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_available_rb);
nb_rb = nb_available_rb;
break;
}
TBS = mac_xface->get_TBS_DL(mcs, nb_rb);
TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb);
}
if(nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
for(j=0; j<frame_parms[CC_id]->N_RBG; j++) { // for indicating the rballoc for each sub-band
for(j = 0; j < frame_parms[CC_id]->N_RBG; j++) { // for indicating the rballoc for each sub-band
UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
}
} else {
nb_rb_temp = nb_rb;
j = 0;
while((nb_rb_temp > 0) && (j<frame_parms[CC_id]->N_RBG)) {
while((nb_rb_temp > 0) && (j < frame_parms[CC_id]->N_RBG)) {
if(ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) {
UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j];
if ((j == frame_parms[CC_id]->N_RBG-1) &&
((frame_parms[CC_id]->N_RB_DL == 25)||
(frame_parms[CC_id]->N_RB_DL == 50))) {
......@@ -735,44 +740,41 @@ schedule_ue_spec_default(
PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
for(j=0; j<frame_parms[CC_id]->N_RBG; j++) {
for(j = 0; j < frame_parms[CC_id]->N_RBG; j++) {
PHY_vars_eNB_g[mod_id][CC_id]->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j];
}
// decrease mcs until TBS falls below required length
while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs2>0)) {
mcs2--;
TBS = mac_xface->get_TBS_DL(mcs2,nb_rb);
while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs_tmp > 0)) {
mcs_tmp--;
TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb);
}
// if we have decreased too much or we don't have enough RBs, increase MCS
while ((TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && ((( ue_sched_ctl->dl_pow_off[CC_id]>0) && (mcs2<28))
|| ( (ue_sched_ctl->dl_pow_off[CC_id]==0) && (mcs2<=15)))) {
mcs2++;
TBS = mac_xface->get_TBS_DL(mcs2,nb_rb);
while ((TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) &&
((( ue_sched_ctl->dl_pow_off[CC_id] > 0) && (mcs_tmp < 28)) || ( (ue_sched_ctl->dl_pow_off[CC_id]==0) && (mcs_tmp <= 15)))) {
mcs_tmp++;
TBS = mac_xface->get_TBS_DL(mcs_tmp, nb_rb);
}
dl_dci->n_tbs_size = 2;
dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * 2);
dl_dci->tbs_size[0] = TBS;
dl_dci->tbs_size[1] = TBS;
LOG_D(MAC,"dlsch_mcs and TBS before and after the rate matching = (%d, %d) (%d, %d)\n", mcs, mcs_tmp, dci_tbs, TBS);
LOG_D(MAC,"dlsch_mcs before and after the rate matching = (%d, %d)\n", mcs, mcs2);
dci_tbs = TBS;
mcs = mcs_tmp;
aggregation = process_ue_cqi(mod_id,UE_id);
dl_dci->has_aggr_level = 1;
dl_dci->aggr_level = aggregation;
dl_dci->has_cce_index = 1;
// dl_dci->cce_index = nCCE_used[CC_id];
nCCE[CC_id]-=(1<<aggregation); // adjust the remaining nCCE
// nCCE_used[CC_id]+=(1<<aggregation); // adjust the remaining nCCE
UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb;
add_ue_dlsch_info(mod_id,
CC_id,
UE_id,
subframe,
S_DL_SCHEDULED);
/*Deactivate here as well*/
/* add_ue_dlsch_info(mod_id, */
/* CC_id, */
/* UE_id, */
/* subframe, */
/* S_DL_SCHEDULED); */
if (frame_parms[CC_id]->frame_type == TDD) {
UE_list->UE_template[CC_id][UE_id].DAI++;
......@@ -838,8 +840,8 @@ schedule_ue_spec_default(
dl_dci->rb_shift = 0;
dl_dci->n_ndi = 1;
dl_dci->ndi = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_ndi);
dl_dci->ndi[0] = 1; //1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
dl_dci->n_rv = 1;
dl_dci->ndi[0] = 1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
dl_dci->n_rv = 1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
dl_dci->rv = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_rv);
dl_dci->rv[0] = 0;
dl_dci->has_tpc = 1;
......@@ -848,16 +850,11 @@ schedule_ue_spec_default(
dl_dci->mcs = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_mcs);
dl_dci->mcs[0] = mcs;
dl_dci->n_tbs_size = 1;
dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t));
dl_dci->tbs_size = (uint32_t *) malloc(sizeof(uint32_t) * dl_dci->n_tbs_size);
dl_dci->tbs_size[0] = dci_tbs;
if (frame_parms[CC_id]->frame_type == TDD) {
dl_dci->has_dai = 1;
dl_dci->dai = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3;
LOG_D(MAC,"[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d\n",
mod_id, CC_id, harq_pid, round,(UE_list->UE_template[CC_id][UE_id].DAI-1));
} else {
LOG_D(MAC,"[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d\n",