Commit 3b80c73f authored by Robert Schmidt's avatar Robert Schmidt

FlexRAN: Loop over UEs using UE_id, not index

parent 9399bed2
......@@ -894,7 +894,6 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
for (j = 0; j < 8; j++) {
if (RC.mac && RC.mac[mod_id] && RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][i].harq_pid == 1) {
available_harq[i] = j;
sf_trigger_msg->n_dl_info++;
break;
}
}
......@@ -903,10 +902,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
// LOG_I(FLEXRAN_AGENT, "Sending subframe trigger for frame %d and subframe %d\n", flexran_get_current_frame(mod_id), (flexran_get_current_subframe(mod_id) + 1) % 10);
/*TODO: Fill in the number of dl HARQ related info, based on the number of currently
*transmitting UEs
*/
// sf_trigger_msg->n_dl_info = flexran_get_num_ues(mod_id);
sf_trigger_msg->n_dl_info = flexran_get_num_ues(mod_id);
Protocol__FlexDlInfo **dl_info = NULL;
......@@ -916,33 +912,31 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
goto error;
i = -1;
//Fill the status of the current HARQ process for each UE
for(UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) {
if (available_harq[UE_id] < 0) {
for(i = 0; i < sf_trigger_msg->n_dl_info; i++) {
if (available_harq[i] < 0)
continue;
} else {
i++;
}
dl_info[i] = malloc(sizeof(Protocol__FlexDlInfo));
if(dl_info[i] == NULL)
goto error;
UE_id = flexran_get_ue_id(mod_id, i);
protocol__flex_dl_info__init(dl_info[i]);
dl_info[i]->rnti = flexran_get_ue_crnti(mod_id, UE_id);
dl_info[i]->has_rnti = 1;
/*Fill in the right id of this round's HARQ process for this UE*/
// uint8_t harq_id;
//uint8_t harq_status;
// flexran_get_harq(mod_id, UE_PCCID(mod_id,i), i, frame, subframe, &harq_id, &harq_status);
// flexran_get_harq(mod_id, UE_PCCID(mod_id, UE_id), i, frame, subframe, &harq_id, &harq_status);
dl_info[i]->harq_process_id = available_harq[UE_id];
if (RC.mac && RC.mac[mod_id])
RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id,i)][UE_id].harq_pid = 0;
RC.mac[mod_id]->UE_list.eNB_UE_stats[UE_PCCID(mod_id, UE_id)][UE_id].harq_pid = 0;
dl_info[i]->has_harq_process_id = 1;
/* Fill in the status of the HARQ process (2 TBs)*/
dl_info[i]->n_harq_status = 2;
dl_info[i]->harq_status = malloc(sizeof(uint32_t) * dl_info[i]->n_harq_status);
for (j = 0; j < dl_info[i]->n_harq_status; j++) {
dl_info[i]->harq_status[j] = RC.mac[mod_id]->UE_list.UE_sched_ctrl[i].round[UE_PCCID(mod_id,i)][j];
dl_info[i]->harq_status[j] = RC.mac[mod_id]->UE_list.UE_sched_ctrl[UE_id].round[UE_PCCID(mod_id, UE_id)][j];
// TODO: This should be different per TB
}
// LOG_I(FLEXRAN_AGENT, "Sending subframe trigger for frame %d and subframe %d and harq %d (round %d)\n", flexran_get_current_frame(mod_id), (flexran_get_current_subframe(mod_id) + 1) % 10, dl_info[i]->harq_process_id, dl_info[i]->harq_status[0]);
......@@ -950,7 +944,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
// LOG_I(FLEXRAN_AGENT, "[Frame %d][Subframe %d]Need to make a retransmission for harq %d (round %d)\n", flexran_get_current_frame(mod_id), flexran_get_current_subframe(mod_id), dl_info[i]->harq_process_id, dl_info[i]->harq_status[0]);
}
/*Fill in the serving cell index for this UE */
dl_info[i]->serv_cell_index = UE_PCCID(mod_id,i);
dl_info[i]->serv_cell_index = UE_PCCID(mod_id, UE_id);
dl_info[i]->has_serv_cell_index = 1;
}
}
......@@ -974,18 +968,21 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
if(ul_info[i] == NULL)
goto error;
protocol__flex_ul_info__init(ul_info[i]);
ul_info[i]->rnti = flexran_get_ue_crnti(mod_id, i);
UE_id = flexran_get_ue_id(mod_id, i);
ul_info[i]->rnti = flexran_get_ue_crnti(mod_id, UE_id);
ul_info[i]->has_rnti = 1;
/* Fill in the Tx power control command for this UE (if available),
* primary carrier */
if(flexran_get_tpc(mod_id, i, 0) != 1){
if(flexran_get_tpc(mod_id, UE_id, 0) != 1){
/* assume primary carrier */
ul_info[i]->tpc = flexran_get_tpc(mod_id, i, 0);
ul_info[i]->tpc = flexran_get_tpc(mod_id, UE_id, 0);
ul_info[i]->has_tpc = 1;
}
else{
/* assume primary carrier */
ul_info[i]->tpc = flexran_get_tpc(mod_id, i, 0);
ul_info[i]->tpc = flexran_get_tpc(mod_id, UE_id, 0);
ul_info[i]->has_tpc = 0;
}
/*TODO: fill in the amount of data in bytes in the MAC SDU received in this subframe for the
......@@ -999,7 +996,7 @@ int flexran_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Fle
ul_info[i]->reception_status = PROTOCOL__FLEX_RECEPTION_STATUS__FLRS_OK;
ul_info[i]->has_reception_status = 1;
/*Fill in the serving cell index for this UE */
ul_info[i]->serv_cell_index = UE_PCCID(mod_id,i);
ul_info[i]->serv_cell_index = UE_PCCID(mod_id, UE_id);
ul_info[i]->has_serv_cell_index = 1;
}
}
......
......@@ -264,27 +264,31 @@ int flexran_agent_destroy_ue_state_change(Protocol__FlexranMessage *msg) {
/* this is called by RRC as a part of rrc xface . The controller previously requested this*/
void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t* measResults) {
int i;
//int i;
// int priority = 0; // Warning Preventing
// void *data;
// int size;
// err_code_t err_code = -100;
triggered_rrc = true;
int num;
//int num;
/* TODO do we need this at the current state? meas_stats is never put into a
* protobuf message?!
num = flexran_get_num_ues (mod_id);
meas_stats = malloc(sizeof(rrc_meas_stats) * num);
for (i = 0; i < num; i++){
meas_stats[i].rnti = flexran_get_ue_crnti(mod_id, i);
meas_stats[i].meas_id = flexran_get_rrc_pcell_measid(mod_id,i);
meas_stats[i].rsrp = flexran_get_rrc_pcell_rsrp(mod_id,i) - 140;
UE_id = flexran_get_ue_id(mod_id, i);
meas_stats[i].rnti = flexran_get_ue_crnti(mod_id, UE_id);
meas_stats[i].meas_id = flexran_get_rrc_pcell_measid(mod_id, UE_id);
meas_stats[i].rsrp = flexran_get_rrc_pcell_rsrp(mod_id, UE_id) - 140;
// measResults->measResultPCell.rsrpResult - 140;
meas_stats[i].rsrq = flexran_get_rrc_pcell_rsrq(mod_id,i)/2 - 20;
meas_stats[i].rsrq = flexran_get_rrc_pcell_rsrq(mod_id, UE_id)/2 - 20;
// (measResults->measResultPCell.rsrqResult)/2 - 20;
}
*/
// repl->neigh_meas = NULL;
// if (meas->measResultNeighCells != NULL) {
......
This diff is collapsed.
......@@ -210,6 +210,7 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr
//TODO: We do not deal with multiple CCs at the moment and eNB id is 0
int enb_id = mod_id;
int UE_id;
//eNB_MAC_INST *eNB = &eNB_mac_inst[enb_id];
//UE_list_t *eNB_UE_list= &eNB->UE_list;
......@@ -249,8 +250,9 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr
goto error;
}
for (i = 0; i < report_config.nr_ue; i++) {
report_config.ue_report_type[i].ue_rnti = flexran_get_ue_crnti(enb_id, i); //eNB_UE_list->eNB_UE_stats[UE_PCCID(enb_id,i)][i].crnti;
report_config.ue_report_type[i].ue_report_flags = ue_flags;
UE_id = flexran_get_ue_id(mod_id, i);
report_config.ue_report_type[i].ue_rnti = flexran_get_ue_crnti(enb_id, UE_id); //eNB_UE_list->eNB_UE_stats[UE_PCCID(enb_id,i)][i].crnti;
report_config.ue_report_type[i].ue_report_flags = ue_flags;
}
//Set the number of CCs and create a list with the cell stats configs
report_config.nr_cc = MAX_NUM_CCs;
......@@ -359,7 +361,8 @@ int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__Flexr
goto error;
}
for (i = 0; i < report_config.nr_ue; i++) {
report_config.ue_report_type[i].ue_rnti = ue_req->rnti[i];
UE_id = flexran_get_ue_id(mod_id, i);
report_config.ue_report_type[i].ue_rnti = ue_req->rnti[UE_id];
report_config.ue_report_type[i].ue_report_flags = ue_req->flags;
}
break;
......
......@@ -113,6 +113,21 @@ int flexran_get_num_ues(mid_t mod_id)
return RC.mac[mod_id]->UE_list.num_UEs;
}
int flexran_get_ue_id(mid_t mod_id, int i)
{
int n;
if (!mac_is_present(mod_id)) return 0;
/* get the (i+1)'th active UE */
for (n = 0; n < MAX_MOBILES_PER_ENB; ++n) {
if (RC.mac[mod_id]->UE_list.active[n] == TRUE) {
if (i == 0)
return n;
--i;
}
}
return 0;
}
rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id)
{
return UE_RNTI(mod_id, ue_id);
......
......@@ -73,6 +73,10 @@ uint16_t flexran_get_future_sfn_sf(mid_t mod_id, int ahead_of_time);
/* Return the number of attached UEs */
int flexran_get_num_ues(mid_t mod_id);
/* Return the UE id of attached UE as opposed to the index [0,NUM UEs] (i.e.,
* the i'th active UE). Returns 0 if the i'th active UE could not be found. */
int flexran_get_ue_id(mid_t mod_id, int i);
/* Get the rnti of a UE with id ue_id */
rnti_t flexran_get_ue_crnti(mid_t mod_id, mid_t ue_id);
......
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