Commit c917352d authored by Melissa Elkadi's avatar Melissa Elkadi

Resolving issues in MR:

Adding error checking before indexing in mac layer harq array
Adding error checking before writing ul_harq_sfn_slot
Added comments
Made a "static" free_uci_inds() actually static
parent e5ddd558
...@@ -313,6 +313,13 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -313,6 +313,13 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
int last_sfn_slot = -1; int last_sfn_slot = -1;
uint16_t sfn_slot = 0; uint16_t sfn_slot = 0;
module_id_t mod_id = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) {
mac->nr_ue_emul_l1.harq[i].active = false;
mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot = -1;
}
while (!oai_exit) while (!oai_exit)
{ {
if (sem_wait(&sfn_slot_semaphore) != 0) if (sem_wait(&sfn_slot_semaphore) != 0)
...@@ -347,8 +354,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -347,8 +354,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n", LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n",
frame, slot); frame, slot);
module_id_t mod_id = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
if (get_softmodem_params()->sa && mac->mib == NULL) if (get_softmodem_params()->sa && mac->mib == NULL)
{ {
LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n"); LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n");
......
...@@ -74,6 +74,38 @@ static void fill_uci_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4, ...@@ -74,6 +74,38 @@ static void fill_uci_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4,
pdu_2_3_4->csi_part1.csi_part1_crc = 0; pdu_2_3_4->csi_part1.csi_part1_crc = 0;
} }
static void free_uci_inds(nfapi_nr_uci_indication_t *uci_ind)
{
for (int k = 0; k < uci_ind->num_ucis; k++)
{
if (uci_ind->uci_list[k].pdu_type == NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE)
{
nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[k].pucch_pdu_format_0_1;
free(pdu_0_1->sr);
pdu_0_1->sr = NULL;
if (pdu_0_1->harq)
{
free(pdu_0_1->harq->harq_list);
pdu_0_1->harq->harq_list = NULL;
}
free(pdu_0_1->harq);
pdu_0_1->harq = NULL;
}
if (uci_ind->uci_list[k].pdu_type == NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE)
{
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[k].pucch_pdu_format_2_3_4;
free(pdu_2_3_4->sr.sr_payload);
pdu_2_3_4->sr.sr_payload = NULL;
free(pdu_2_3_4->harq.harq_payload);
pdu_2_3_4->harq.harq_payload = NULL;
}
}
free(uci_ind->uci_list);
uci_ind->uci_list = NULL;
free(uci_ind);
uci_ind = NULL;
}
int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) {
NR_UE_MAC_INST_t *mac = get_mac_inst(0); NR_UE_MAC_INST_t *mac = get_mac_inst(0);
if(scheduled_response != NULL) if(scheduled_response != NULL)
...@@ -136,6 +168,8 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response ...@@ -136,6 +168,8 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
crc_ind->crc_list[j].tb_crc_status = 0; crc_ind->crc_list[j].tb_crc_status = 0;
crc_ind->crc_list[j].timing_advance = 31; crc_ind->crc_list[j].timing_advance = 31;
crc_ind->crc_list[j].ul_cqi = 255; crc_ind->crc_list[j].ul_cqi = 255;
AssertFatal(mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot == -1,
"We did not send an active CRC when we should have!\n");
mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot = NFAPI_SFNSLOT2HEX(crc_ind->sfn, crc_ind->slot); mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id].active_ul_harq_sfn_slot = NFAPI_SFNSLOT2HEX(crc_ind->sfn, crc_ind->slot);
LOG_D(NR_MAC, "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d] with mcs_index in ul_cqi -> %d\n", LOG_D(NR_MAC, "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d] with mcs_index in ul_cqi -> %d\n",
scheduled_response->frame, scheduled_response->slot, crc_ind->sfn, crc_ind->slot,pusch_config_pdu->mcs_index); scheduled_response->frame, scheduled_response->slot, crc_ind->sfn, crc_ind->slot,pusch_config_pdu->mcs_index);
...@@ -218,6 +252,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response ...@@ -218,6 +252,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
{ {
mac->nr_ue_emul_l1.harq[k].active = false; mac->nr_ue_emul_l1.harq[k].active = false;
harq_pid = k; harq_pid = k;
AssertFatal(harq_index < pdu_0_1->harq->num_harq, "Invalid harq_index %d\n", harq_index);
pdu_0_1->harq->harq_list[harq_index].harq_value = !mac->dl_harq_info[k].ack; pdu_0_1->harq->harq_list[harq_index].harq_value = !mac->dl_harq_info[k].ack;
harq_index++; harq_index++;
} }
......
...@@ -1336,10 +1336,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, ...@@ -1336,10 +1336,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac,
current_harq->dl_slot = slot; current_harq->dl_slot = slot;
if (get_softmodem_params()->emulate_l1) { if (get_softmodem_params()->emulate_l1) {
if (data_toul_fb + slot > 19) { if (data_toul_fb + slot > 19) {
if (frame + 1 < 1024) frame = (frame + 1) % 1024;
frame++;
else
frame = 0;
slot = (data_toul_fb + slot) - 20; slot = (data_toul_fb + slot) - 20;
} }
else { else {
...@@ -2028,15 +2025,13 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, ...@@ -2028,15 +2025,13 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac,
if (current_harq->active) { if (current_harq->active) {
sched_frame = current_harq->dl_frame; sched_frame = current_harq->dl_frame;
if (current_harq->feedback_to_ul + current_harq->dl_slot > 19) { if (current_harq->feedback_to_ul + current_harq->dl_slot > 19) {
if (sched_frame + 1 < 1024) sched_frame = (sched_frame + 1) % 1024;
sched_frame++;
else
sched_frame = 0;
sched_slot = (current_harq->feedback_to_ul + current_harq->dl_slot) - slots_per_frame; sched_slot = (current_harq->feedback_to_ul + current_harq->dl_slot) - slots_per_frame;
} }
else { else {
sched_slot = current_harq->feedback_to_ul + current_harq->dl_slot; sched_slot = current_harq->feedback_to_ul + current_harq->dl_slot;
} }
AssertFatal(sched_slot < slots_per_frame, "sched_slot was calculated incorrect %d\n", sched_slot);
LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d, is_common %d\n",dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul,current_harq->is_common); LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d, is_common %d\n",dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul,current_harq->is_common);
/* check if current tx slot should transmit downlink acknowlegment */ /* check if current tx slot should transmit downlink acknowlegment */
if (sched_frame == frame && sched_slot == slot) { if (sched_frame == frame && sched_slot == slot) {
......
...@@ -540,38 +540,6 @@ static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi ...@@ -540,38 +540,6 @@ static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi
dl_info->rx_ind->number_pdus = pdu_idx; dl_info->rx_ind->number_pdus = pdu_idx;
} }
void free_uci_inds(nfapi_nr_uci_indication_t *uci_ind)
{
for (int k = 0; k < uci_ind->num_ucis; k++)
{
if (uci_ind->uci_list[k].pdu_type == NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE)
{
nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[k].pucch_pdu_format_0_1;
free(pdu_0_1->sr);
pdu_0_1->sr = NULL;
if (pdu_0_1->harq)
{
free(pdu_0_1->harq->harq_list);
pdu_0_1->harq->harq_list = NULL;
}
free(pdu_0_1->harq);
pdu_0_1->harq = NULL;
}
if (uci_ind->uci_list[k].pdu_type == NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE)
{
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[k].pucch_pdu_format_2_3_4;
free(pdu_2_3_4->sr.sr_payload);
pdu_2_3_4->sr.sr_payload = NULL;
free(pdu_2_3_4->harq.harq_payload);
pdu_2_3_4->harq.harq_payload = NULL;
}
}
free(uci_ind->uci_list);
uci_ind->uci_list = NULL;
free(uci_ind);
uci_ind = NULL;
}
static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_ul_dci_request_t *ul_dci_req) static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_ul_dci_request_t *ul_dci_req)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id);
...@@ -624,6 +592,12 @@ static bool send_crc_ind_and_rx_ind(int sfn_slot) ...@@ -624,6 +592,12 @@ static bool send_crc_ind_and_rx_ind(int sfn_slot)
if (crc_ind && crc_ind->number_crcs > 0) if (crc_ind && crc_ind->number_crcs > 0)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
for (int i = 0; i < crc_ind->number_crcs; i++) {
int harq_pid = crc_ind->crc_list[i].harq_id;
LOG_D(NR_MAC, "Resetting harq_pid %d active_ul_harq_sfn_slot\n", harq_pid);
mac->nr_ue_emul_l1.harq[harq_pid].active_ul_harq_sfn_slot = -1;
}
NR_UL_IND_t UL_INFO = { NR_UL_IND_t UL_INFO = {
.crc_ind = *crc_ind, .crc_ind = *crc_ind,
}; };
...@@ -912,7 +886,10 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea ...@@ -912,7 +886,10 @@ static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_hea
LOG_E(NR_PHY, "Message ul_tti_request failed to unpack\n"); LOG_E(NR_PHY, "Message ul_tti_request failed to unpack\n");
break; break;
} }
/* We are filtering UL_TTI_REQs below. We only care about UL_TTI_REQs that
will trigger sending a ul_harq (CRC/RX pair). This UL_TTI_REQ will have
NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE. If we have not yet completed the CBRA/
CFRA procedure, we need to queue all UL_TTI_REQs. */
for (int i = 0; i < ul_tti_request->n_pdus; i++) { for (int i = 0; i < ul_tti_request->n_pdus; i++) {
if (ul_tti_request->pdus_list[i].pdu_type == NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE && if (ul_tti_request->pdus_list[i].pdu_type == NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE &&
mac->ra.ra_state >= RA_SUCCEEDED) { mac->ra.ra_state >= RA_SUCCEEDED) {
......
...@@ -268,8 +268,6 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -268,8 +268,6 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
bool sfn_slot_matcher(void *wanted, void *candidate); bool sfn_slot_matcher(void *wanted, void *candidate);
void free_uci_inds(nfapi_nr_uci_indication_t *uci_ind);
/**\brief done free of memory allocation by module_id and release to pointer pool. /**\brief done free of memory allocation by module_id and release to pointer pool.
\param module_id module id*/ \param module_id module id*/
int nr_ue_if_module_kill(uint32_t module_id); int nr_ue_if_module_kill(uint32_t module_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