Commit ffed6b71 authored by Stefan's avatar Stefan

SSR 20/12/18 ulsch_scheduler_pre_processor

parent 076d4e12
...@@ -1605,206 +1605,177 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, ...@@ -1605,206 +1605,177 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP,
unsigned char sched_subframeP, unsigned char sched_subframeP,
uint16_t *first_rb) uint16_t *first_rb)
{ {
int16_t i; uint16_t UE_id, n;
uint16_t UE_id, n, r; uint8_t CC_id, harq_pid;
uint8_t CC_id, harq_pid; uint16_t nb_allocated_rbs[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB];
uint16_t nb_allocated_rbs[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; uint16_t total_allocated_rbs[NFAPI_CC_MAX];
uint16_t total_allocated_rbs[NFAPI_CC_MAX]; uint16_t average_rbs_per_user[NFAPI_CC_MAX];
uint16_t average_rbs_per_user[NFAPI_CC_MAX]; int16_t total_remaining_rbs[NFAPI_CC_MAX];
int16_t total_remaining_rbs[NFAPI_CC_MAX]; uint16_t total_ue_count[NFAPI_CC_MAX];
uint16_t total_ue_count[NFAPI_CC_MAX]; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list;
rnti_t rnti = -1; slice_info_t *sli = &RC.mac[module_idP]->slice_info;
UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; UE_TEMPLATE *UE_template = 0;
slice_info_t *sli = &RC.mac[module_idP]->slice_info; UE_sched_ctrl *ue_sched_ctl;
UE_TEMPLATE *UE_template = 0; int N_RB_UL = 0;
UE_sched_ctrl *ue_sched_ctl; uint16_t available_rbs, first_rb_offset;
int N_RB_UL = 0; rnti_t rntiTable[MAX_MOBILES_PER_ENB]; // Rnti array => Add SSR 12-2018
uint16_t available_rbs, first_rb_offset; bool continueTable[MAX_MOBILES_PER_ENB]; // Loop continue flag array => Add SSR 12-2018
rnti_t rntiTable[MAX_MOBILES_PER_ENB]; bool sliceMember; // Slice membership flag => Add SSR 12-2018
bool continueTable[MAX_MOBILES_PER_ENB];
bool sliceMember; LOG_D(MAC, "In ulsch_preprocessor: assign max mcs min rb\n");
// maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB
LOG_D(MAC, "In ulsch_preprocessor: assign max mcs min rb\n"); assign_max_mcs_min_rb(module_idP, slice_idx, frameP, subframeP, first_rb);
// maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB
assign_max_mcs_min_rb(module_idP, slice_idx, frameP, subframeP, first_rb); LOG_D(MAC, "In ulsch_preprocessor: sort ue \n");
// sort ues
LOG_D(MAC, "In ulsch_preprocessor: sort ue \n"); sort_ue_ul(module_idP, frameP, subframeP);
// sort ues
sort_ue_ul(module_idP, frameP, subframeP);
// we need to distribute RBs among UEs
// step1: reset the vars
// we need to distribute RBs among UEs uint8_t CC_nb = (uint8_t) RC.nb_mac_CC[module_idP];
// step1: reset the vars for (CC_id = 0; CC_id < CC_nb; CC_id++) {
for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { total_allocated_rbs[CC_id] = 0;
total_allocated_rbs[CC_id] = 0; total_remaining_rbs[CC_id] = 0;
total_remaining_rbs[CC_id] = 0; average_rbs_per_user[CC_id] = 0;
average_rbs_per_user[CC_id] = 0; total_ue_count[CC_id] = 0;
total_ue_count[CC_id] = 0; }
}
// Step 1.5: Calculate total_ue_count // Step 1.5: Calculate total_ue_count
for (UE_id = UE_list->head_ul; UE_id >= 0; i = UE_list->next_ul[UE_id]) { for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) {
rntiTable[UE_id] = UE_RNTI(module_idP, UE_id); // Calculate continue condition
sliceMember = ue_ul_slice_membership(module_idP, UE_id, slice_idx); /*
continueTable[UE_id] = (rntiTable[UE_id] == NOT_A_RNTI || UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1 || !sliceMember); if (UE_RNTI(module_idP, UE_id) == NOT_A_RNTI)
// This is not the actual CC_id in the list continue;
if (sliceMember) { if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1)
for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { continue;
CC_id = UE_list->ordered_ULCCids[n][UE_id]; if (!ue_ul_slice_membership(module_idP, UE_id, slice_idx))
UE_template = &UE_list->UE_template[CC_id][UE_id]; continue;
if (UE_template->pre_allocated_nb_rb_ul[slice_idx] > 0) { */
total_ue_count[CC_id] += 1; rntiTable[UE_id] = UE_RNTI(module_idP, UE_id);
} sliceMember = ue_ul_slice_membership(module_idP, UE_id, slice_idx);
continueTable[UE_id] = (rntiTable[UE_id] == NOT_A_RNTI || UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1 || !sliceMember);
// This is not the actual CC_id in the list
if (sliceMember) {
for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) {
CC_id = UE_list->ordered_ULCCids[n][UE_id];
UE_template = &UE_list->UE_template[CC_id][UE_id];
if (UE_template->pre_allocated_nb_rb_ul[slice_idx] > 0) {
total_ue_count[CC_id]++;
} }
} }
} }
}
LOG_D(MAC, "In ulsch_preprocessor: step2 \n"); LOG_D(MAC, "In ulsch_preprocessor: step2 \n");
// step 2: calculate the average rb per UE // step 2: calculate the average rb per UE
for (UE_id = UE_list->head_ul; UE_id >= 0; i = UE_list->next_ul[UE_id]) { for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) {
if (continueTable[UE_id]) continue; if (continueTable[UE_id]) continue;
/* LOG_D(MAC, "In ulsch_preprocessor: handling UE %d/%x\n", UE_id,
rnti = UE_RNTI(module_idP, i); rntiTable[UE_id]);
UE_id = i; for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) {
if (rnti == NOT_A_RNTI) // This is the actual CC_id in the list
continue; CC_id = UE_list->ordered_ULCCids[n][UE_id];
if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) LOG_D(MAC, "In ulsch_preprocessor: handling UE %d/%x CCid %d\n", UE_id, rntiTable[UE_id], CC_id);
continue;
if (!ue_ul_slice_membership(module_idP, UE_id, slice_idx))
continue;
*/
LOG_D(MAC, "In ulsch_preprocessor: handling UE %d/%x\n", UE_id,
rntiTable[UE_id]);
for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) {
// This is the actual CC_id in the list
CC_id = UE_list->ordered_ULCCids[n][UE_id];
LOG_D(MAC, "In ulsch_preprocessor: handling UE %d/%x CCid %d\n", UE_id, rntiTable[UE_id], CC_id);
/* /*
if((mac_xface->get_nCCE_max(module_idP,CC_id,3,subframeP) - nCCE_to_be_used[CC_id]) > (1<<aggregation)) { if((mac_xface->get_nCCE_max(module_idP,CC_id,3,subframeP) - nCCE_to_be_used[CC_id]) > (1<<aggregation)) {
nCCE_to_be_used[CC_id] = nCCE_to_be_used[CC_id] + (1<<aggregation); nCCE_to_be_used[CC_id] = nCCE_to_be_used[CC_id] + (1<<aggregation);
max_num_ue_to_be_scheduled+=1; max_num_ue_to_be_scheduled+=1;
} */ } */
N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth); N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth);
ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_idx] = ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_idx] =
nb_rbs_allowed_slice(sli->ul[slice_idx].pct, N_RB_UL); nb_rbs_allowed_slice(sli->ul[slice_idx].pct, N_RB_UL);
first_rb_offset = UE_list->first_rb_offset[CC_id][slice_idx]; first_rb_offset = UE_list->first_rb_offset[CC_id][slice_idx];
available_rbs = cmin(ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_idx], available_rbs = cmin(ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_idx],
N_RB_UL - first_rb[CC_id] - first_rb_offset); N_RB_UL - first_rb[CC_id] - first_rb_offset);
if (available_rbs < 0) if (available_rbs < 0)
available_rbs = 0; available_rbs = 0;
if (total_ue_count[CC_id] == 0) { if (total_ue_count[CC_id] == 0) {
average_rbs_per_user[CC_id] = 0; average_rbs_per_user[CC_id] = 0;
} else if (total_ue_count[CC_id] == 1) { // increase the available RBs, special case, } else if (total_ue_count[CC_id] == 1) { // increase the available RBs, special case,
average_rbs_per_user[CC_id] = (uint16_t) (available_rbs + 1); average_rbs_per_user[CC_id] = (uint16_t) (available_rbs + 1);
} else if (total_ue_count[CC_id] <= available_rbs) { } else if (total_ue_count[CC_id] <= available_rbs) {
average_rbs_per_user[CC_id] = (uint16_t) floor(available_rbs / total_ue_count[CC_id]); average_rbs_per_user[CC_id] = (uint16_t) floor(available_rbs / total_ue_count[CC_id]);
} else { } else {
average_rbs_per_user[CC_id] = 1; average_rbs_per_user[CC_id] = 1;
LOG_W(MAC, LOG_W(MAC,
"[eNB %d] frame %d subframe %d: UE %d CC %d: can't get average rb per user (should not be here)\n", "[eNB %d] frame %d subframe %d: UE %d CC %d: can't get average rb per user (should not be here)\n",
module_idP, frameP, subframeP, UE_id, CC_id); module_idP, frameP, subframeP, UE_id, CC_id);
} }
if (total_ue_count[CC_id] > 0) { if (total_ue_count[CC_id] > 0) {
LOG_D(MAC, "[eNB %d] Frame %d subframe %d: total ue to be scheduled %d\n", LOG_D(MAC, "[eNB %d] Frame %d subframe %d: total ue to be scheduled %d\n",
module_idP, frameP, subframeP, total_ue_count[CC_id]); module_idP, frameP, subframeP, total_ue_count[CC_id]);
}
} }
} }
}
// step 3: assigne RBS // step 3: assigne RBS
for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) { for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) {
if (continueTable[UE_id]) continue; if (continueTable[UE_id]) continue;
/*
rnti = UE_RNTI(module_idP, i);
if (rnti == NOT_A_RNTI)
continue;
if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1)
continue;
if (!ue_ul_slice_membership(module_idP, i, slice_idx))
continue;
UE_id = i;
*/
for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) {
// This is the actual CC_id in the list
CC_id = UE_list->ordered_ULCCids[n][UE_id];
UE_template = &UE_list->UE_template[CC_id][UE_id];
harq_pid = subframe2harqpid(&RC.mac[module_idP]->common_channels[CC_id],
frameP, sched_subframeP);
// mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) {
// This is the actual CC_id in the list
CC_id = UE_list->ordered_ULCCids[n][UE_id];
UE_template = &UE_list->UE_template[CC_id][UE_id];
harq_pid = subframe2harqpid(&RC.mac[module_idP]->common_channels[CC_id],
frameP, sched_subframeP);
if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id] > 0) { // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL);
nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid];
} else {
nb_allocated_rbs[CC_id][UE_id] =
cmin(UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[slice_idx],
average_rbs_per_user[CC_id]);
}
total_allocated_rbs[CC_id] += nb_allocated_rbs[CC_id][UE_id]; if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id] > 0) {
LOG_D(MAC, nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid];
"In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d\n", } else {
nb_allocated_rbs[CC_id][UE_id], UE_id, rntiTable[UE_id], CC_id, nb_allocated_rbs[CC_id][UE_id] =
harq_pid); cmin(UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[slice_idx], average_rbs_per_user[CC_id]);
} }
total_allocated_rbs[CC_id] += nb_allocated_rbs[CC_id][UE_id];
LOG_D(MAC,
"In ulsch_preprocessor: assigning %d RBs for UE %d/%x CCid %d, harq_pid %d\n",
nb_allocated_rbs[CC_id][UE_id], UE_id, rntiTable[UE_id], CC_id,
harq_pid);
} }
}
// step 4: assigne the remaining RBs and set the pre_allocated rbs accordingly // step 4: assigne the remaining RBs and set the pre_allocated rbs accordingly
for (r = 0; r < 2; r++) { for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) {
if (continueTable[UE_id]) continue;
for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) { ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
if (continueTable[UE_id]) continue; for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) {
/* // This is the actual CC_id in the list
rnti = UE_RNTI(module_idP, i); CC_id = UE_list->ordered_ULCCids[n][UE_id];
if (rnti == NOT_A_RNTI) UE_template = &UE_list->UE_template[CC_id][UE_id];
continue; N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth);
if (UE_list->UE_sched_ctrl[i].ul_out_of_sync == 1) first_rb_offset = UE_list->first_rb_offset[CC_id][slice_idx];
continue; available_rbs = cmin(ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_idx], N_RB_UL - first_rb[CC_id] - first_rb_offset);
if (!ue_ul_slice_membership(module_idP, i, slice_idx)) total_remaining_rbs[CC_id] = available_rbs - total_allocated_rbs[CC_id];
continue;
UE_id = i;
*/
ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { if (total_ue_count[CC_id] == 1) {
// This is the actual CC_id in the list total_remaining_rbs[CC_id]++;
CC_id = UE_list->ordered_ULCCids[n][UE_id]; }
UE_template = &UE_list->UE_template[CC_id][UE_id];
if (r == 0) {
N_RB_UL = to_prb(RC.mac[module_idP]->common_channels[CC_id].ul_Bandwidth);
first_rb_offset = UE_list->first_rb_offset[CC_id][slice_idx];
available_rbs = cmin(ue_sched_ctl->max_rbs_allowed_slice_uplink[CC_id][slice_idx],
N_RB_UL - first_rb[CC_id] - first_rb_offset);
total_remaining_rbs[CC_id] = available_rbs - total_allocated_rbs[CC_id];
if (total_ue_count[CC_id] == 1) {
total_remaining_rbs[CC_id] += 1;
}
while ((UE_template->pre_allocated_nb_rb_ul[slice_idx] > 0) while ((UE_template->pre_allocated_nb_rb_ul[slice_idx] > 0)
&& (nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul[slice_idx]) && (nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul[slice_idx])
&& (total_remaining_rbs[CC_id] > 0)) { && (total_remaining_rbs[CC_id] > 0)) {
nb_allocated_rbs[CC_id][UE_id] = nb_allocated_rbs[CC_id][UE_id] = cmin(nb_allocated_rbs[CC_id][UE_id] + 1, UE_template->pre_allocated_nb_rb_ul[slice_idx]);
cmin(nb_allocated_rbs[CC_id][UE_id] + 1, total_remaining_rbs[CC_id]--;
UE_template->pre_allocated_nb_rb_ul[slice_idx]); total_allocated_rbs[CC_id]++;
total_remaining_rbs[CC_id]--;
total_allocated_rbs[CC_id]++;
}
} else {
UE_template->pre_allocated_nb_rb_ul[slice_idx] = nb_allocated_rbs[CC_id][UE_id];
LOG_D(MAC, "******************UL Scheduling Information for UE%d CC_id %d ************************\n",
UE_id, CC_id);
LOG_D(MAC, "[eNB %d] total RB allocated for UE%d CC_id %d = %d\n",
module_idP, UE_id, CC_id, UE_template->pre_allocated_nb_rb_ul[slice_idx]);
}
} }
UE_template->pre_allocated_nb_rb_ul[slice_idx] = nb_allocated_rbs[CC_id][UE_id];
LOG_D(MAC, "******************UL Scheduling Information for UE%d CC_id %d ************************\n",
UE_id, CC_id);
LOG_D(MAC, "[eNB %d] total RB allocated for UE%d CC_id %d = %d\n",
module_idP, UE_id, CC_id, UE_template->pre_allocated_nb_rb_ul[slice_idx]);
} }
} }
return;
} }
void void
......
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