Commit 3e77b141 authored by Ahmed.Elias's avatar Ahmed.Elias

adding br parameters

parent ae598b94
......@@ -757,6 +757,8 @@ typedef struct {
uint8_t rach_resource_type;
uint16_t mpdcch_repetition_cnt;
struct PhysicalConfigDedicated *physicalConfigDedicated;
frame_t Msg2_frame;
subframe_t Msg2_subframe;
#endif
} UE_TEMPLATE;
......
......@@ -472,7 +472,6 @@ schedule_ue_spec_br(
)
//------------------------------------------------------------------------------
{
uint8_t CC_id;
int UE_id;
unsigned char aggregation;
......@@ -556,12 +555,12 @@ schedule_ue_spec_br(
//}
//weight = get_ue_weight(module_idP,UE_id);
aggregation = 2;
for (CC_id = 0; CC_id<MAX_NUM_CCs; CC_id++) {
for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth);
min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id);
// get number of PRBs less those used by common channels
total_nb_available_rb[CC_id] = N_RB_DL[CC_id];
for (i = 0; i<N_RB_DL[CC_id]; i++)
for (i = 0; i < N_RB_DL[CC_id]; i++)
if (cc[CC_id].vrb_map[i] != 0)
total_nb_available_rb[CC_id]--;
......@@ -588,7 +587,7 @@ schedule_ue_spec_br(
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_OUT);
for (CC_id = 0; CC_id<MAX_NUM_CCs; CC_id++)
for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++)
{
vrb_map = cc[CC_id].vrb_map;
......@@ -596,7 +595,7 @@ schedule_ue_spec_br(
dl_req = &eNB->DL_req[CC_id].dl_config_request_body;
if (mbsfn_flag[CC_id]>0)
if (mbsfn_flag[CC_id] > 0)
continue;
for (UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id])
......@@ -690,7 +689,7 @@ schedule_ue_spec_br(
// initializing the rb allocation indicator for each UE
//to be checked
for (j = 0; j<N_RBG[CC_id]; j++) {
for (j = 0; j < N_RBG[CC_id]; j++) {
UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = 0;
}
......@@ -703,43 +702,41 @@ schedule_ue_spec_br(
// process retransmission
if (round > 0) {
if (round > 0)
{
// get freq_allocation
nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid];
nb_rb = 6;//UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid];
if (nb_rb <= nb_available_rb) {
if (cc[CC_id].tdd_Config != NULL) {
UE_list->UE_template[CC_id][UE_id].DAI++;
update_ul_dci(module_idP, CC_id, rnti, UE_list->UE_template[CC_id][UE_id].DAI);
LOG_D(MAC, "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", CC_id, subframeP, UE_id, UE_list->UE_template[CC_id][UE_id].DAI);
}
if (nb_rb <= nb_available_rb)
{
if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
for (j = 0; j<N_RBG[CC_id]; 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<N_RBG[CC_id])) {
if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) {
//if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
for (j = 0; j < N_RBG[CC_id]; 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];
if ((j == N_RBG[CC_id] - 1) &&
((N_RB_DL[CC_id] == 25) ||
(N_RB_DL[CC_id] == 50))) {
nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1;
}
else {
nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id];
}
}
//}
//else {
// nb_rb_temp = nb_rb;
// j = 0;
// while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) {
// 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 == N_RBG[CC_id] - 1) &&
// ((N_RB_DL[CC_id] == 25) ||
// (N_RB_DL[CC_id] == 50))) {
// nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1;
// }
// else {
// nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id];
// }
// }
j = j + 1;
}
}
// j = j + 1;
// }
//}
nb_available_rb -= nb_rb;
......@@ -757,26 +754,18 @@ schedule_ue_spec_br(
case 7:
default:
{
unsigned int rmax ;
unsigned int narrowBandindex_index ;
unsigned int rmax;
unsigned int narrowBandindex_index;
unsigned int first_rb, rep, reps;
// rmax from RRC connection setup
getRepetition(&UE_template[CC_id][UE_id],&rmax, &narrowBandindex_index, &first_rb) ;
getRepetition(&UE_template[CC_id][UE_id], &rmax, &narrowBandindex_index, &first_rb);
// choose r3 by default for RAR (Table 9.1.5-5)
rep = 2;
// get actual repetition count from Table 9.1.5-3
reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
// get narrowband according to higher-layer config
num_nb = p[RA_template->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.count;
RA_template->msg2_narrowband = *p[RA_template->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.array[RA_template->preamble_index%num_nb];
first_rb = narrowBandindex_index * 6;
vrb_map[first_rb] = 1;
......@@ -786,8 +775,8 @@ schedule_ue_spec_br(
vrb_map[first_rb + 4] = 1;
vrb_map[first_rb + 5] = 1;
if ((RA_template->mpdcch_repetition_cnt == 0) &&
(mpdcch_sf_condition(eNB, CC_idP, frameP, subframeP, rmax, TYPEUESPEC)>0))
if ((UE_template[CC_id][UE_id].mpdcch_repetition_cnt == 0) &&
(mpdcch_sf_condition(eNB, CC_idP, frameP, subframeP, rmax, TYPEUESPEC) > 0))
{
// MPDCCH configuration for RAR
dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
......@@ -811,11 +800,11 @@ schedule_ue_spec_br(
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6); // Note: still to be checked if it should not be (getRIV(N_RB_DL,first_rb,6)) : Check nFAPI specifications and what is done L1 with this parameter
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]; // adjust according to size of RAR, 208 bits with N1A_PRB=3
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4; // fix to 4 for now
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = (round & 3);
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = harq_pid;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
......@@ -837,38 +826,57 @@ schedule_ue_spec_br(
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
RA_template->msg2_mpdcch_repetition_cnt++;
UE_template[CC_id][UE_id].mpdcch_repetition_cnt++;
dl_req->number_pdu++;
//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].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1;
UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = eNB_UE_stats->dlsch_mcs1;
add_ue_dlsch_info(module_idP,
CC_id,
UE_id,
subframeP,
S_DL_SCHEDULED);
} //repetition_count==0 && SF condition met
else if (RA_template->msg2_mpdcch_repetition_cnt>0) { // we're in a stream of repetitions
RA_template->msg2_mpdcch_repetition_cnt++;
if (RA_template->msg2_mpdcch_repetition_cnt == reps) { // this is the last mpdcch repetition
else if (UE_template[CC_id][UE_id].msg2_mpdcch_repetition_cnt > 0)
{
// we're in a stream of repetitions
UE_template[CC_id][UE_id].mpdcch_repetition_cnt++;
if (UE_template[CC_id][UE_id].mpdcch_repetition_cnt == reps)
{
// this is the last mpdcch repetition
if (cc[CC_idP].tdd_Config == NULL) { // FDD case
// wait 2 subframes for PDSCH transmission
if (subframeP>7) RA_template->Msg2_frame = (frameP + 1) & 1023;
else RA_template->Msg2_frame = frameP;
RA_template->Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11 in 36.213
if (subframeP > 7) UE_template[CC_id][UE_id].Msg2_frame = (frameP + 1) & 1023;
else UE_template[CC_id][UE_id].Msg2_frame = frameP;
UE_template[CC_id][UE_id].Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11 in 36.213
}
else {
AssertFatal(1 == 0, "TDD case not done yet\n");
}
} // mpdcch_repetition_count == reps
if ((RA_template->Msg2_frame == frameP) && (RA_template->Msg2_subframe == subframeP)) {
if ((UE_template[CC_id][UE_id].Msg2_frame == frameP) && (UE_template[CC_id][UE_id].Msg2_subframe == subframeP)) {
// Program PDSCH
RA_template->generate_rar = 0;
dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
dl_config_pdu->pdu_size = (uint8_t)(2 + sizeof(nfapi_dl_config_dlsch_pdu));
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_idP];
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = RA_template->RA_rnti;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = rnti;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 4; // format 6-1A
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 6);
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = (round & 3);
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1;
......@@ -885,26 +893,26 @@ schedule_ue_spec_br(
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
// dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (RA_template->rach_resource_type < 3) ? 1 : 2;;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (UE_template[CC_id][UE_id].rach_resource_type < 3) ? 1 : 2;;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
dl_req->number_pdu++;
// Program UL processing for Msg3, same as regular LTE
get_Msg3alloc(&cc[CC_idP], subframeP, frameP, &RA_template->Msg3_frame, &RA_template->Msg3_subframe);
//get_Msg3alloc(&cc[CC_idP], subframeP, frameP, &RA_template->Msg3_frame, &RA_template->Msg3_subframe);
fill_rar_br(eNB, CC_idP, RA_template, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, RA_template->rach_resource_type - 1);
// DL request
eNB->TX_req[CC_idP].sfn_sf = (frameP << 3) + subframeP;
TX_req = &eNB->TX_req[CC_idP].tx_request_body.tx_pdu_list[eNB->TX_req[CC_idP].tx_request_body.number_of_pdus];
TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble
TX_req->pdu_index = eNB->pdu_index[CC_idP]++;
TX_req->num_segments = 1;
TX_req->segments[0].segment_length = 7;
TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload;
eNB->TX_req[CC_idP].tx_request_body.number_of_pdus++;
//fill_rar_br(eNB, CC_idP, RA_template, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, RA_template->rach_resource_type - 1);
//// DL request
//eNB->TX_req[CC_idP].sfn_sf = (frameP << 3) + subframeP;
//TX_req = &eNB->TX_req[CC_idP].tx_request_body.tx_pdu_list[eNB->TX_req[CC_idP].tx_request_body.number_of_pdus];
//TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble
//TX_req->pdu_index = eNB->pdu_index[CC_idP]++;
//TX_req->num_segments = 1;
//TX_req->segments[0].segment_length = 7;
//TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload;
//eNB->TX_req[CC_idP].tx_request_body.number_of_pdus++;
}
}
......@@ -929,44 +937,26 @@ schedule_ue_spec_br(
// dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = round & 3;
if (!CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP,
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,
rnti)) {
dl_req->number_dci++;
dl_req->number_pdu++;
}
else {
// No TX request for retransmission (check if null request for FAPI)
}
}
add_ue_dlsch_info(module_idP,
CC_id,
UE_id,
subframeP,
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].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1;
UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = eNB_UE_stats->dlsch_mcs1;
}
else {
LOG_D(MAC, "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n",
module_idP, frameP, CC_id, UE_id);
}
}
else {
// This is a potentially new SDU opportunity
else
{
// This is a potentially new SDU opportunity //
rlc_status.bytes_in_buffer = 0;
// Now check RLC information to compute number of required RBs
// get maximum TBS size for RLC request
//to be checked
TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb);
TBS = 408;
// check first for RLC data on DCCH
// add the length for all the control elements (timing adv, drx, etc) : header + payload
......@@ -1014,7 +1004,7 @@ schedule_ue_spec_br(
#ifdef DEBUG_eNB_SCHEDULER
LOG_T(MAC, "[eNB %d][DCCH] CC_id %d Got %d bytes :", module_idP, CC_id, sdu_lengths[0]);
for (j = 0; j<sdu_lengths[0]; j++) {
for (j = 0; j < sdu_lengths[0]; j++) {
LOG_T(MAC, "%x ", dlsch_buffer[j]);
}
......@@ -1068,7 +1058,7 @@ schedule_ue_spec_br(
#ifdef DEBUG_eNB_SCHEDULER
LOG_T(MAC, "[eNB %d][DCCH1] CC_id %d Got %d bytes :", module_idP, CC_id, sdu_lengths[num_sdus]);
for (j = 0; j<sdu_lengths[num_sdus]; j++) {
for (j = 0; j < sdu_lengths[num_sdus]; j++) {
LOG_T(MAC, "%x ", dlsch_buffer[j]);
}
......@@ -1143,7 +1133,7 @@ schedule_ue_spec_br(
header_len_dtch_last = 0;
// there is at least one SDU
// if (num_sdus > 0 ){
if ((sdu_length_total + header_len_dcch + header_len_dtch)> 0) {
if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0) {
// Now compute number of required RBs for total sdu length
// Assume RAH format 2
......@@ -1151,80 +1141,87 @@ schedule_ue_spec_br(
header_len_dcch_tmp = header_len_dcch;
header_len_dtch_tmp = header_len_dtch;
if (header_len_dtch == 0) {
header_len_dcch = (header_len_dcch >0) ? 1 : 0;//header_len_dcch; // remove length field
header_len_dcch = (header_len_dcch > 0) ? 1 : 0;//header_len_dcch; // remove length field
}
else {
header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU
header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU
}
mcs = eNB_UE_stats->dlsch_mcs1;
//mcs = eNB_UE_stats->dlsch_mcs1;
//if (mcs == 0) {
// nb_rb = 4; // don't let the TBS get too small
//}
//else {
// nb_rb = min_rb_unit[CC_id];
//}
mcs = 4;
nb_rb = 6;
if (mcs == 0) {
nb_rb = 4; // don't let the TBS get too small
}
else {
nb_rb = min_rb_unit[CC_id];
}
TBS = get_TBS_DL(mcs, nb_rb);
TBS = 408;//get_TBS_DL(mcs, nb_rb);
while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) {
nb_rb += min_rb_unit[CC_id]; //
//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
// (can happen if N_RB_DL is odd)
TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb);
nb_rb = nb_available_rb;
break;
}
// 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 = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb);
// nb_rb = nb_available_rb;
// break;
// }
TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb);
}
/////////////////////////////////////////////////////////////
// alter the allocation of the emtc UE here
//////////////////////////////////////////////////////////////
if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
for (j = 0; j<N_RBG[CC_id]; 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;
// TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb);
//}
while ((nb_rb_temp > 0) && (j<N_RBG[CC_id])) {
if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) {
//if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) {
for (j = 0; j < N_RBG[CC_id]; 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];
if ((j == N_RBG[CC_id] - 1) &&
((N_RB_DL[CC_id] == 25) ||
(N_RB_DL[CC_id] == 50))) {
nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1;
}
else {
nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id];
}
}
//}
//else
//{
// nb_rb_temp = nb_rb;
// j = 0;
// while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) {
// 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 == N_RBG[CC_id] - 1) &&
// ((N_RB_DL[CC_id] == 25) ||
// (N_RB_DL[CC_id] == 50))) {
// nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id] + 1;
// }
// else {
// nb_rb_temp = nb_rb_temp - min_rb_unit[CC_id];
// }
// }
j = j + 1;
}
}
///////////////////////////////////
// j = j + 1;
// }
//}
//RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb;
//RC.eNB[module_idP][CC_id]->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id];
//for(j=0; j<N_RBG[CC_id]; j++) {
//RC.eNB[module_idP][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)) && (mcs>0)) {
mcs--;
TBS = get_TBS_DL(mcs, nb_rb);
}
//while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs > 0)) {
// mcs--;
// TBS = get_TBS_DL(mcs, 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) && (mcs<28))
|| ((ue_sched_ctl->dl_pow_off[CC_id] == 0) && (mcs <= 15)))) {
mcs++;
TBS = get_TBS_DL(mcs, 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) && (mcs < 28))
// || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) && (mcs <= 15)))) {
// mcs++;
// TBS = get_TBS_DL(mcs, nb_rb);
//}
LOG_D(MAC, "dlsch_mcs before and after the rate matching = (%d, %d)\n", eNB_UE_stats->dlsch_mcs1, mcs);
......@@ -1275,7 +1272,7 @@ schedule_ue_spec_br(
#ifdef DEBUG_eNB_SCHEDULER
LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n");
for (i = 0; i<16; i++) {
for (i = 0; i < 16; i++) {
LOG_T(MAC, "%x.", dlsch_buffer[i]);
}
......@@ -1286,8 +1283,7 @@ schedule_ue_spec_br(
// memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]);
// fill remainder of DLSCH with random data
UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb;
for (j = 0; j<(TBS - sdu_length_total - offset); j++) {
for (j = 0; j < (TBS - sdu_length_total - offset); j++) {
UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = (char)(taus() & 0xff);
}
......@@ -1316,7 +1312,7 @@ schedule_ue_spec_br(
UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb;
UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb;
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_mcs1 = 4;//eNB_UE_stats->dlsch_mcs1;
UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = mcs;
UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS;
......@@ -1335,61 +1331,50 @@ schedule_ue_spec_br(
// this assumes accumulated tpc
// make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe;
if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case
((framex10psubframe>(frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around
if (eNB_UE_stats->Po_PUCCH_update == 1) {
eNB_UE_stats->Po_PUCCH_update = 0;
UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP;
UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP;
if (normalized_rx_power>(target_rx_power + 1)) {
tpc = 0; //-1
tpc_accumulated--;
}
else if (normalized_rx_power<(target_rx_power - 1)) {
tpc = 2; //+1
tpc_accumulated++;
}
else {
tpc = 1; //0
}
} // Po_PUCCH has been updated
else {
tpc = 1; //0
} // time to do TPC update
else {
tpc = 1; //0
}
//int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe;
//if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case
// ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around
// if (eNB_UE_stats->Po_PUCCH_update == 1) {
// eNB_UE_stats->Po_PUCCH_update = 0;
// UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP;
// UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP;
// if (normalized_rx_power > (target_rx_power + 1)) {
// tpc = 0; //-1
// tpc_accumulated--;
// }
// else if (normalized_rx_power < (target_rx_power - 1)) {
// tpc = 2; //+1
// tpc_accumulated++;
// }
// else {
// tpc = 1; //0
// }
//
//
// } // Po_PUCCH has been updated
// else {
// tpc = 1; //0
// } // time to do TPC update
//else {
// tpc = 1; //0
//}
{
unsigned int rmax ;
unsigned int narrowBandindex_index ;
unsigned int rmax;
unsigned int narrowBandindex_index;
unsigned int first_rb, rep, reps;
// rmax from RRC connection setup
getRepetition(&UE_template[CC_id][UE_id],&rmax, &narrowBandindex_index, &first_rb) ;
getRepetition(&UE_template[CC_id][UE_id], &rmax, &narrowBandindex_index, &first_rb);
// choose r3 by default for RAR (Table 9.1.5-5)
rep = 2;
// get actual repetition count from Table 9.1.5-3
reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
// get narrowband according to higher-layer config
num_nb = p[RA_template->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.count;
RA_template->msg2_narrowband = *p[RA_template->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.array[RA_template->preamble_index%num_nb];
first_rb = narrowBandindex_index * 6;
vrb_map[first_rb] = 1;
......@@ -1399,8 +1384,8 @@ schedule_ue_spec_br(
vrb_map[first_rb + 4] = 1;
vrb_map[first_rb + 5] = 1;
if ((RA_template->mpdcch_repetition_cnt == 0) &&
(mpdcch_sf_condition(eNB, CC_idP, frameP, subframeP, rmax, TYPEUESPEC)>0))
if ((UE_template[CC_id][UE_id].mpdcch_repetition_cnt == 0) &&
(mpdcch_sf_condition(eNB, CC_idP, frameP, subframeP, rmax, TYPEUESPEC) > 0))
{
// MPDCCH configuration for RAR
dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
......@@ -1427,8 +1412,8 @@ schedule_ue_spec_br(
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 4; // fix to 4 for now
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = harq_pid;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
......@@ -1450,34 +1435,56 @@ schedule_ue_spec_br(
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
RA_template->msg2_mpdcch_repetition_cnt++;
UE_template[CC_id][UE_id].mpdcch_repetition_cnt++;
dl_req->number_pdu++;
// Toggle NDI for next time
LOG_D(MAC, "CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n",
CC_id, frameP, subframeP, UE_id,
UE_list->UE_template[CC_id][UE_id].rnti, harq_pid, UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]);
UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid] = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs;
UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0;
eNB->TX_req[CC_id].sfn_sf = (frameP << 3) + subframeP;
TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus];
TX_req->pdu_length = TBS;
TX_req->pdu_index = eNB->pdu_index[CC_id]++;
TX_req->num_segments = 1;
TX_req->segments[0].segment_length = TBS;
TX_req->segments[0].segment_data = eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[harq_pid];
eNB->TX_req[CC_id].tx_request_body.number_of_pdus++;
} //repetition_count==0 && SF condition met
else if (RA_template->msg2_mpdcch_repetition_cnt>0) { // we're in a stream of repetitions
RA_template->msg2_mpdcch_repetition_cnt++;
if (RA_template->msg2_mpdcch_repetition_cnt == reps) { // this is the last mpdcch repetition
else if (UE_template[CC_id][UE_id].msg2_mpdcch_repetition_cnt > 0)
{
// we're in a stream of repetitions
UE_template[CC_id][UE_id].mpdcch_repetition_cnt++;
if (UE_template[CC_id][UE_id].mpdcch_repetition_cnt == reps)
{
// this is the last mpdcch repetition
if (cc[CC_idP].tdd_Config == NULL) { // FDD case
// wait 2 subframes for PDSCH transmission
if (subframeP>7) RA_template->Msg2_frame = (frameP + 1) & 1023;
else RA_template->Msg2_frame = frameP;
RA_template->Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11 in 36.213
if (subframeP > 7) UE_template[CC_id][UE_id].Msg2_frame = (frameP + 1) & 1023;
else UE_template[CC_id][UE_id].Msg2_frame = frameP;
UE_template[CC_id][UE_id].Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11 in 36.213
}
else {
AssertFatal(1 == 0, "TDD case not done yet\n");
}
} // mpdcch_repetition_count == reps
if ((RA_template->Msg2_frame == frameP) && (RA_template->Msg2_subframe == subframeP)) {
if ((UE_template[CC_id][UE_id].Msg2_frame == frameP) && (UE_template[CC_id][UE_id].Msg2_subframe == subframeP)) {
// Program PDSCH
RA_template->generate_rar = 0;
dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
dl_config_pdu->pdu_size = (uint8_t)(2 + sizeof(nfapi_dl_config_dlsch_pdu));
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_idP];
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = RA_template->RA_rnti;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = rnti;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 4; // format 6-1A
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 6);
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
......@@ -1498,75 +1505,31 @@ schedule_ue_spec_br(
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
// dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (RA_template->rach_resource_type < 3) ? 1 : 2;;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (UE_template[CC_id][UE_id].rach_resource_type < 3) ? 1 : 2;;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
dl_req->number_pdu++;
// Program UL processing for Msg3, same as regular LTE
get_Msg3alloc(&cc[CC_idP], subframeP, frameP, &RA_template->Msg3_frame, &RA_template->Msg3_subframe);
//get_Msg3alloc(&cc[CC_idP], subframeP, frameP, &RA_template->Msg3_frame, &RA_template->Msg3_subframe);
fill_rar_br(eNB, CC_idP, RA_template, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, RA_template->rach_resource_type - 1);
// DL request
eNB->TX_req[CC_idP].sfn_sf = (frameP << 3) + subframeP;
TX_req = &eNB->TX_req[CC_idP].tx_request_body.tx_pdu_list[eNB->TX_req[CC_idP].tx_request_body.number_of_pdus];
TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble
TX_req->pdu_index = eNB->pdu_index[CC_idP]++;
TX_req->num_segments = 1;
TX_req->segments[0].segment_length = 7;
TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload;
eNB->TX_req[CC_idP].tx_request_body.number_of_pdus++;
//fill_rar_br(eNB, CC_idP, RA_template, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, RA_template->rach_resource_type - 1);
//// DL request
//eNB->TX_req[CC_idP].sfn_sf = (frameP << 3) + subframeP;
//TX_req = &eNB->TX_req[CC_idP].tx_request_body.tx_pdu_list[eNB->TX_req[CC_idP].tx_request_body.number_of_pdus];
//TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble
//TX_req->pdu_index = eNB->pdu_index[CC_idP]++;
//TX_req->num_segments = 1;
//TX_req->segments[0].segment_length = 7;
//TX_req->segments[0].segment_data = cc[CC_idP].RAR_pdu.payload;
//eNB->TX_req[CC_idP].tx_request_body.number_of_pdus++;
}
}
}
//dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
//memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
//dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE;
//dl_config_pdu->pdu_size = (uint8_t)(2 + sizeof(nfapi_dl_config_dci_dl_pdu));
//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1;
//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP, CC_id), eNB_UE_stats->dl_cqi, format1);
// dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti;
//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications
//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power
//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid;
//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // dont adjust power when retransmitting
// dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
// dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid];
// dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = round & 3;
if (!CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP,
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,
rnti)) {
dl_req->number_dci++;
dl_req->number_pdu++;
}
else {
// No TX request for retransmission (check if null request for FAPI)
}
}
//dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
//memset((void*)dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
//dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE;
......@@ -1585,27 +1548,10 @@ schedule_ue_spec_br(
////deactivate second codeword
//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0;
//dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1;
//
dl_req->number_dci++;
dl_req->number_pdu++;
// Toggle NDI for next time
LOG_D(MAC, "CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n",
CC_id, frameP, subframeP, UE_id,
UE_list->UE_template[CC_id][UE_id].rnti, harq_pid, UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]);
UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid] = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid];
UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs;
UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0;
//dl_req->number_dci++;
//dl_req->number_pdu++;
eNB->TX_req[CC_id].sfn_sf = (frameP << 3) + subframeP;
TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus];
TX_req->pdu_length = TBS;
TX_req->pdu_index = eNB->pdu_index[CC_id]++;
TX_req->num_segments = 1;
TX_req->segments[0].segment_length = TBS;
TX_req->segments[0].segment_data = eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[harq_pid];
eNB->TX_req[CC_id].tx_request_body.number_of_pdus++;
}
else { // There is no data from RLC or MAC header, so don't schedule
......@@ -1613,6 +1559,9 @@ schedule_ue_spec_br(
}
}
if (cc[CC_id].tdd_Config != NULL) { // TDD
set_ul_DAI(module_idP, UE_id, CC_id, frameP, subframeP);
}
} // UE_id loop
} // CC_id loop
......@@ -1625,8 +1574,6 @@ schedule_ue_spec_br(
}*/
//------------------------------------------------------------------------------
void
schedule_ue_spec(
......
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