Commit b76eb194 authored by Thomas Schlichter's avatar Thomas Schlichter

gNB: refactor code to handle end of using a specific HARQ process -...

gNB: refactor code to handle end of using a specific HARQ process - finish_nr_dl_harq() and finish_nr_ul_harq()
parent cd052951
...@@ -1888,12 +1888,7 @@ static void nr_generate_Msg4(module_id_t module_idP, ...@@ -1888,12 +1888,7 @@ static void nr_generate_Msg4(module_id_t module_idP,
NR_sched_pucch_t *pucch = NULL; NR_sched_pucch_t *pucch = NULL;
DevAssert(!harq->is_waiting); DevAssert(!harq->is_waiting);
if (alloc < 0) { if (alloc < 0) {
add_tail_nr_list(&sched_ctrl->available_dl_harq, current_harq_pid); finish_nr_dl_harq(sched_ctrl, current_harq_pid);
harq->feedback_frame = -1;
harq->feedback_slot = -1;
harq->is_waiting = false;
harq->ndi ^= 1;
harq->round = 0;
} else { } else {
pucch = &sched_ctrl->sched_pucch[alloc]; pucch = &sched_ctrl->sched_pucch[alloc];
add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid); add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid);
......
...@@ -371,17 +371,23 @@ static void nr_store_dlsch_buffer(module_id_t module_id, frame_t frame, sub_fram ...@@ -371,17 +371,23 @@ static void nr_store_dlsch_buffer(module_id_t module_id, frame_t frame, sub_fram
} }
} }
void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid) void finish_nr_dl_harq(NR_UE_sched_ctrl_t *sched_ctrl, int harq_pid)
{ {
/* already mutex protected through handle_dl_harq() */
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
NR_UE_harq_t *harq = &sched_ctrl->harq_processes[harq_pid]; NR_UE_harq_t *harq = &sched_ctrl->harq_processes[harq_pid];
harq->ndi ^= 1; harq->ndi ^= 1;
harq->round = 0; harq->round = 0;
UE->mac_stats.dl.errors++;
add_tail_nr_list(&sched_ctrl->available_dl_harq, harq_pid); add_tail_nr_list(&sched_ctrl->available_dl_harq, harq_pid);
}
void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid)
{
/* already mutex protected through handle_dl_harq() */
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
finish_nr_dl_harq(sched_ctrl, harq_pid);
UE->mac_stats.dl.errors++;
} }
static void get_start_stop_allocation(gNB_MAC_INST *mac, static void get_start_stop_allocation(gNB_MAC_INST *mac,
...@@ -1008,12 +1014,7 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -1008,12 +1014,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
NR_sched_pucch_t *pucch = NULL; NR_sched_pucch_t *pucch = NULL;
DevAssert(!harq->is_waiting); DevAssert(!harq->is_waiting);
if (sched_pdsch->pucch_allocation < 0) { if (sched_pdsch->pucch_allocation < 0) {
add_tail_nr_list(&sched_ctrl->available_dl_harq, current_harq_pid); finish_nr_dl_harq(sched_ctrl, current_harq_pid);
harq->feedback_frame = -1;
harq->feedback_slot = -1;
harq->is_waiting = false;
harq->ndi ^= 1;
harq->round = 0;
} else { } else {
pucch = &sched_ctrl->sched_pucch[sched_pdsch->pucch_allocation]; pucch = &sched_ctrl->sched_pucch[sched_pdsch->pucch_allocation];
add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid); add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid);
......
...@@ -385,19 +385,18 @@ static void handle_dl_harq(NR_UE_info_t * UE, ...@@ -385,19 +385,18 @@ static void handle_dl_harq(NR_UE_info_t * UE,
bool success, bool success,
int harq_round_max) int harq_round_max)
{ {
NR_UE_harq_t *harq = &UE->UE_sched_ctrl.harq_processes[harq_pid]; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
NR_UE_harq_t *harq = &sched_ctrl->harq_processes[harq_pid];
harq->feedback_slot = -1; harq->feedback_slot = -1;
harq->is_waiting = false; harq->is_waiting = false;
if (success) { if (success) {
add_tail_nr_list(&UE->UE_sched_ctrl.available_dl_harq, harq_pid); finish_nr_dl_harq(sched_ctrl, harq_pid);
harq->round = 0;
harq->ndi ^= 1;
} else if (harq->round >= harq_round_max - 1) { } else if (harq->round >= harq_round_max - 1) {
abort_nr_dl_harq(UE, harq_pid); abort_nr_dl_harq(UE, harq_pid);
LOG_D(NR_MAC, "retransmission error for UE %04x (total %"PRIu64")\n", UE->rnti, UE->mac_stats.dl.errors); LOG_D(NR_MAC, "retransmission error for UE %04x (total %"PRIu64")\n", UE->rnti, UE->mac_stats.dl.errors);
} else { } else {
LOG_D(PHY,"NACK for: pid %d, ue %04x\n",harq_pid, UE->rnti); LOG_D(PHY,"NACK for: pid %d, ue %04x\n",harq_pid, UE->rnti);
add_tail_nr_list(&UE->UE_sched_ctrl.retrans_dl_harq, harq_pid); add_tail_nr_list(&sched_ctrl->retrans_dl_harq, harq_pid);
harq->round++; harq->round++;
} }
} }
......
...@@ -511,15 +511,23 @@ static int nr_process_mac_pdu(instance_t module_idP, ...@@ -511,15 +511,23 @@ static int nr_process_mac_pdu(instance_t module_idP,
return 0; return 0;
} }
static void abort_nr_ul_harq(NR_UE_info_t *UE, int8_t harq_pid) static void finish_nr_ul_harq(NR_UE_sched_ctrl_t *sched_ctrl, int harq_pid)
{ {
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
NR_UE_ul_harq_t *harq = &sched_ctrl->ul_harq_processes[harq_pid]; NR_UE_ul_harq_t *harq = &sched_ctrl->ul_harq_processes[harq_pid];
harq->ndi ^= 1; harq->ndi ^= 1;
harq->round = 0; harq->round = 0;
UE->mac_stats.ul.errors++;
add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid);
}
static void abort_nr_ul_harq(NR_UE_info_t *UE, int8_t harq_pid)
{
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
NR_UE_ul_harq_t *harq = &sched_ctrl->ul_harq_processes[harq_pid];
finish_nr_ul_harq(sched_ctrl, harq_pid);
UE->mac_stats.ul.errors++;
/* the transmission failed: the UE won't send the data we expected initially, /* the transmission failed: the UE won't send the data we expected initially,
* so retrieve to correctly schedule after next BSR */ * so retrieve to correctly schedule after next BSR */
...@@ -602,13 +610,11 @@ void handle_nr_ul_harq(const int CC_idP, ...@@ -602,13 +610,11 @@ void handle_nr_ul_harq(const int CC_idP,
harq->feedback_slot = -1; harq->feedback_slot = -1;
harq->is_waiting = false; harq->is_waiting = false;
if (!crc_pdu->tb_crc_status) { if (!crc_pdu->tb_crc_status) {
harq->ndi ^= 1; finish_nr_ul_harq(sched_ctrl, harq_pid);
harq->round = 0;
LOG_D(NR_MAC, LOG_D(NR_MAC,
"Ulharq id %d crc passed for RNTI %04x\n", "Ulharq id %d crc passed for RNTI %04x\n",
harq_pid, harq_pid,
crc_pdu->rnti); crc_pdu->rnti);
add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid);
} else if (harq->round >= RC.nrmac[mod_id]->ul_bler.harq_round_max - 1) { } else if (harq->round >= RC.nrmac[mod_id]->ul_bler.harq_round_max - 1) {
abort_nr_ul_harq(UE, harq_pid); abort_nr_ul_harq(UE, harq_pid);
LOG_D(NR_MAC, LOG_D(NR_MAC,
...@@ -2268,11 +2274,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n ...@@ -2268,11 +2274,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n
NR_UE_ul_harq_t *cur_harq = &sched_ctrl->ul_harq_processes[harq_id]; NR_UE_ul_harq_t *cur_harq = &sched_ctrl->ul_harq_processes[harq_id];
DevAssert(!cur_harq->is_waiting); DevAssert(!cur_harq->is_waiting);
if (nr_mac->radio_config.disable_harq) { if (nr_mac->radio_config.disable_harq) {
add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_id); finish_nr_ul_harq(sched_ctrl, harq_id);
cur_harq->feedback_slot = -1;
cur_harq->is_waiting = false;
cur_harq->ndi ^= 1;
cur_harq->round = 0;
} else { } else {
add_tail_nr_list(&sched_ctrl->feedback_ul_harq, harq_id); add_tail_nr_list(&sched_ctrl->feedback_ul_harq, harq_id);
cur_harq->feedback_slot = sched_pusch->slot; cur_harq->feedback_slot = sched_pusch->slot;
......
...@@ -433,6 +433,7 @@ long get_lcid_from_srbid(int srb_id); ...@@ -433,6 +433,7 @@ long get_lcid_from_srbid(int srb_id);
void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE); void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE);
void send_initial_ul_rrc_message(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data); void send_initial_ul_rrc_message(int rnti, const uint8_t *sdu, sdu_size_t sdu_len, void *data);
void finish_nr_dl_harq(NR_UE_sched_ctrl_t *sched_ctrl, int harq_pid);
void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid); void abort_nr_dl_harq(NR_UE_info_t* UE, int8_t harq_pid);
void nr_mac_trigger_release_timer(NR_UE_sched_ctrl_t *sched_ctrl, NR_SubcarrierSpacing_t subcarrier_spacing); void nr_mac_trigger_release_timer(NR_UE_sched_ctrl_t *sched_ctrl, NR_SubcarrierSpacing_t subcarrier_spacing);
......
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