Commit a6ba4ad1 authored by Robert Schmidt's avatar Robert Schmidt

DLSCH scheduler allocation for multiple UEs

parent 1bf19af7
...@@ -247,29 +247,27 @@ void nr_dlsch_pre_processor(module_id_t Mod_id, frame_t f, sub_frame_t s) { ...@@ -247,29 +247,27 @@ void nr_dlsch_pre_processor(module_id_t Mod_id, frame_t f, sub_frame_t s) {
} }
void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){
NR_UE_list_t *UE_list = &RC.nrmac[module_idP]->UE_list; const int bwp_id = 1;
const int CC_id = 0;
gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP];
NR_UE_list_t *UE_list = &gNB_mac->UE_list;
if (UE_list->num_UEs == 0) if (UE_list->num_UEs == 0)
return; return;
nr_dlsch_buffer_update(module_idP, frameP, slotP); nr_dlsch_buffer_update(module_idP, frameP, slotP);
// for every user, defines frequency allocation, MCS, etc /* the preprocessor determines resource block allocation, MCS, etc. for all
* UEs. Currently, these values are kept in the (LTE) UE_sched_ctrl_t
* structure */
nr_dlsch_pre_processor(module_idP, frameP, slotP); nr_dlsch_pre_processor(module_idP, frameP, slotP);
const int bwp_id = 1;
const int CC_id = 0;
gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP];
nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body;
nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs];
LOG_D(MAC, "Scheduling UE specific search space DCI type 1\n"); LOG_D(MAC, "Scheduling UE specific search space DCI type 1\n");
int rbStart = 0; int rbStart = 0;
int UE_id = 0; for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; UE_sched_ctrl_t *sched_ctrl = &UE_list->UE_sched_ctrl[UE_id];
if (sched_ctrl->pre_nb_available_rbs[CC_id] == 0) if (sched_ctrl->pre_nb_available_rbs[CC_id] == 0)
return; continue;
int CCEIndex = allocate_nr_CCEs(gNB_mac, int CCEIndex = allocate_nr_CCEs(gNB_mac,
bwp_id, // bwp_id bwp_id, // bwp_id
...@@ -280,9 +278,15 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo ...@@ -280,9 +278,15 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo
0); // m 0); // m
if (CCEIndex < 0) { if (CCEIndex < 0) {
LOG_E(MAC, "%d.%d can not allocate CCE for UE %d\n", frameP, slotP, UE_id); LOG_E(MAC, "%d.%d can not allocate CCE for UE %d\n", frameP, slotP, UE_id);
return; continue;
} }
/* this pre-fills the PDCCH and PDSCH PDUs of FAPI. At the same time, it
* calculates the TBS. We could do the latter in a separate step first, but
* this involves multiple variables (like code rate, etc) that we'd need to
* carry along the TBS so we avoid this for the moment since at this point
* we can be sure that (a) resource blocks have been allocated and (b) this
* UE's CCEs can be allocated, hence this will run until the end */
int TBS_bytes = configure_fapi_dl_pdu(gNB_mac, int TBS_bytes = configure_fapi_dl_pdu(gNB_mac,
CC_id, CC_id,
UE_id, UE_id,
...@@ -295,12 +299,11 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo ...@@ -295,12 +299,11 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo
unsigned char sdu_lcids[NB_RB_MAX] = {0}; unsigned char sdu_lcids[NB_RB_MAX] = {0};
uint16_t sdu_lengths[NB_RB_MAX] = {0}; uint16_t sdu_lengths[NB_RB_MAX] = {0};
uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES]; uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES];
uint16_t rnti = UE_list->rnti[UE_id]; const uint16_t rnti = UE_list->rnti[UE_id];
int ta_len = gNB_mac->ta_len; int ta_len = gNB_mac->ta_len; /* TODO needs to be UE specific? */
int header_length_total = 0; int header_length_total = 0;
int sdu_length_total = 0; int sdu_length_total = 0;
int num_sdus = 0; int num_sdus = 0;
int header_length_last;
for (int i = 0; i < sched_ctrl->dl_lc_num; i++) { for (int i = 0; i < sched_ctrl->dl_lc_num; i++) {
int lcid = sched_ctrl->dl_lc_ids[i]; int lcid = sched_ctrl->dl_lc_ids[i];
// if nothing is allocated for this RB, continue // if nothing is allocated for this RB, continue
...@@ -340,8 +343,7 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo ...@@ -340,8 +343,7 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo
sdu_lcids[num_sdus] = lcid; sdu_lcids[num_sdus] = lcid;
sdu_length_total += sdu_lengths[num_sdus]; sdu_length_total += sdu_lengths[num_sdus];
header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); header_length_total += 1 + 1 + (sdu_lengths[num_sdus] >= 128);
header_length_total += header_length_last;
num_sdus++; num_sdus++;
...@@ -351,17 +353,20 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo ...@@ -351,17 +353,20 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo
break; break;
} }
// check if there is at least one SDU or TA command /* check if there is at least one SDU or TA command. Actually this should
* never be true (a UE is only allocated resource blocks if it has data to
* transmit), but leave it as a final check */
if (ta_len + sdu_length_total + header_length_total <= 0) if (ta_len + sdu_length_total + header_length_total <= 0)
return; continue;
// Check if we have to consider padding // Check if we have to consider padding
int post_padding = TBS_bytes >= 2 + header_length_total + sdu_length_total + ta_len; int post_padding = TBS_bytes >= 2 + header_length_total + sdu_length_total + ta_len;
int offset = nr_generate_dlsch_pdu(module_idP, int offset = nr_generate_dlsch_pdu(
(unsigned char *) mac_sdus, module_idP,
(unsigned char *) gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0], //(unsigned char *) mac_pdu, (unsigned char *)mac_sdus,
num_sdus, //num_sdus (unsigned char *)UE_list->DLSCH_pdu[0][UE_id].payload[0],
num_sdus, // num_sdus
sdu_lengths, sdu_lengths,
sdu_lcids, sdu_lcids,
255, // no drx 255, // no drx
...@@ -371,15 +376,20 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo ...@@ -371,15 +376,20 @@ void nr_schedule_ue_spec(module_id_t module_idP, frame_t frameP, sub_frame_t slo
// Padding: fill remainder of DLSCH with 0 // Padding: fill remainder of DLSCH with 0
if (post_padding > 0) if (post_padding > 0)
for (int j = 0; j < (TBS_bytes - offset); j++) for (int j = 0; j < (TBS_bytes - offset); j++)
gNB_mac->UE_list.DLSCH_pdu[0][UE_id].payload[0][offset + j] = 0; UE_list->DLSCH_pdu[0][UE_id].payload[0][offset + j] = 0;
configure_fapi_dl_Tx( configure_fapi_dl_Tx(gNB_mac,
gNB_mac, CC_id, frameP, slotP, TBS_bytes, UE_list->DLSCH_pdu[0][0].payload[0]); CC_id,
frameP,
slotP,
TBS_bytes,
UE_list->DLSCH_pdu[0][UE_id].payload[0]);
#if defined(ENABLE_MAC_PAYLOAD_DEBUG) #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
LOG_I(MAC, "%d.%d first 10 payload bytes UE %d TBSsize %d:", frameP, slotP, UE_id, TBS_bytes); LOG_I(MAC, "%d.%d first 10 payload bytes UE %d TBSsize %d:", frameP, slotP, UE_id, TBS_bytes);
for(int i = 0; i < 10; i++) for(int i = 0; i < 10; i++)
printf(" %02x.", gNB_mac->UE_list.DLSCH_pdu[0][UE_id].payload[0][i]); printf(" %02x.", UE_list->DLSCH_pdu[0][UE_id].payload[0][i]);
prinf("..\n"); prinf("..\n");
#endif #endif
}
} }
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