diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 6eb650939f..55c08cf592 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -1366,10 +1366,10 @@ void set_thread_priority(int priority); void *vnf_nr_p7_thread_start(void *ptr) { set_thread_priority(79); LOG_I(MAC, "Clearing Queues\n"); - reset_queue(&gnb_rach_ind_queue); - reset_queue(&gnb_rx_ind_queue); - reset_queue(&gnb_crc_ind_queue); - reset_queue(&gnb_uci_ind_queue); + init_queue(&gnb_rach_ind_queue); + init_queue(&gnb_rx_ind_queue); + init_queue(&gnb_crc_ind_queue); + init_queue(&gnb_uci_ind_queue); vnf_p7_info *p7_vnf = (vnf_p7_info *)ptr; p7_vnf->config->port = p7_vnf->local_port; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 60e4b48486..82dabfe646 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -82,7 +82,8 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){ } else if (rnti == 0xFFFF) { rnti_type = NR_RNTI_SI; } else { - AssertFatal(1 == 0, "In %s: Not identified/handled rnti %d \n", __FUNCTION__, rnti); + AssertFatal(1 == 0, "In %s: Not identified/handled rnti %x [ra->ra_rnti %x, mac->crnti %x, ra->t_crnti %x]\n", + __FUNCTION__, rnti, ra->ra_rnti, mac->crnti, ra->t_crnti); } LOG_D(MAC, "In %s: returning rnti_type %s \n", __FUNCTION__, rnti_types[rnti_type]); @@ -446,11 +447,22 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", + LOG_D(MAC,"Received dci indication (rnti %4x, dci format %d,n_CCE %d, payloadSize %d, payload %llx)\n\n\n\n", dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits); - - uint32_t dci_format = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15); - return (nr_ue_process_dci(module_id, cc_id, gNB_index, frame, slot, def_dci_pdu_rel15, dci->rnti, dci_format)); + + if ((dci->rnti == mac->crnti) || (dci->rnti == mac->ra.ra_rnti)) + { + LOG_D(MAC,"Received dci indication rnti %4x mac->crnti %4x frame slot %4d.%2d RA state %d\n", + dci->rnti, mac->crnti, frame, slot, mac->ra.ra_state); + uint32_t dci_format = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15); + return (nr_ue_process_dci(module_id, cc_id, gNB_index, frame, slot, def_dci_pdu_rel15, dci->rnti, dci_format)); + } + else + { + LOG_D(MAC,"We skip for the received dci indication rnti %4x != mac->crnti %4x frame slot %4d.%2d\n", + dci->rnti, mac->crnti, frame, slot); + return 0; + } } int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, frame_t frame, int slot, dci_pdu_rel15_t *dci, uint16_t rnti, uint8_t dci_format){ diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 5517bebf77..5d93e027bf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -520,6 +520,8 @@ void config_uldci(const NR_BWP_Uplink_t *ubwp, dci_pdu_rel15->ndi = pusch_pdu->pusch_data.new_data_indicator; dci_pdu_rel15->rv = pusch_pdu->pusch_data.rv_index; dci_pdu_rel15->harq_pid = pusch_pdu->pusch_data.harq_process_id; + LOG_D(MAC,"config_uldci harq id check dci_pdu_rel15->harq_pid %d pusch_pdu->pusch_data.harq_process_id %d\n", + dci_pdu_rel15->harq_pid, pusch_pdu->pusch_data.harq_process_id); dci_pdu_rel15->tpc = tpc; AssertFatal(ubwp->bwp_Dedicated->pusch_Config->choice.setup->resourceAllocation == NR_PUSCH_Config__resourceAllocation_resourceAllocationType1, "Only frequency resource allocation type 1 is currently supported\n"); @@ -1249,10 +1251,12 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, case NR_UL_DCI_FORMAT_0_1: switch (rnti_type) { case NR_RNTI_C: +#if 0 harq_pid_ul = (harq_pid_ul + 1) % 16; if (harq_pid_ul == 0) flag = !flag; dci_pdu_rel15->ndi = flag; +#endif // Indicating a DL DCI format 1bit pos = 1; @@ -1286,8 +1290,11 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv & 0x3) << (dci_size - pos); // HARQ process number 4bit pos += 4; - dci_pdu_rel15->harq_pid = harq_pid_ul; *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid & 0xf) << (dci_size - pos); + LOG_D(MAC,"fill_dci_pdu_rel15 dci_format %d shift %d hard_pid_ul %d\n", + dci_format, dci_size - pos, dci_pdu_rel15->harq_pid ); + LOG_D(MAC,"fill_dci_pdu_rel15 dci_size, pos, shift, harq_id = %u %u %d %lu\n", + dci_size, pos, dci_size - pos, (*dci_pdu >> (dci_size - pos)) & 0xf); // 1st Downlink assignment index pos += dci_pdu_rel15->dai[0].nbits; *dci_pdu |= ((uint64_t)dci_pdu_rel15->dai[0].val & ((1 << dci_pdu_rel15->dai[0].nbits) - 1)) << (dci_size - pos); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index cd01bc3bcf..6bbd22169d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -302,7 +302,7 @@ static void handle_dl_harq(module_id_t mod_id, add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].available_dl_harq, harq_pid); harq->round = 0; harq->ndi ^= 1; - } else if (harq->round == MAX_HARQ_ROUNDS) { + } else if (harq->round >= MAX_HARQ_ROUNDS -1) { add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].available_dl_harq, harq_pid); harq->round = 0; harq->ndi ^= 1; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 48ada17796..7c5e57ae73 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -338,10 +338,12 @@ void handle_nr_ul_harq(module_id_t mod_id, LOG_D(NR_MAC, "Comparing crc_pdu->harq_id vs feedback harq_pid = %d %d\n",crc_pdu->harq_id, harq_pid); while (crc_pdu->harq_id != harq_pid || harq_pid < 0) { LOG_W(MAC, - "Unexpected ULSCH HARQ PID in crc pdu %d (feedback have %d) for RNTI %04x (ignore this warning for RA)\n", + "Unexpected ULSCH HARQ PID in crc pdu %d (feedback have %d) for RNTI %04x SFN/SLOT %4d.%2d (ignore this warning for RA)\n", crc_pdu->harq_id, harq_pid, - crc_pdu->rnti); + crc_pdu->rnti, + frame, slot + ); if (harq_pid < 0) return; @@ -364,7 +366,7 @@ void handle_nr_ul_harq(module_id_t mod_id, harq->ndi ^= 1; harq->round = 0; LOG_D(MAC, - "Ulharq id %d crc passed for RNTI %04x\n", + "Ulharq id %d crc passed for RNTI %4x\n", harq_pid, crc_pdu->rnti); add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); @@ -980,7 +982,11 @@ void nr_schedule_ulsch(module_id_t module_id, * every TTI are pre-populated by the preprocessor and used below */ NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; if (sched_pusch->rbSize <= 0) + { + LOG_D(NR_MAC, "UE id %d was skipped due to sched_pusch->rbSize <= 0\n", UE_id); continue; + } + struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) @@ -1039,8 +1045,11 @@ void nr_schedule_ulsch(module_id_t module_id, } uint16_t rnti = UE_info->rnti[UE_id]; - LOG_D(NR_MAC, "nr_schedule_ulsch UE_id_checking UE_id = %d, rnti = %x \n", UE_id, rnti); + LOG_D(NR_MAC, "nr_schedule_ulsch UE_id_checking UE_id = %d, rnti = %x, sfn slot = %d.%d \n", + UE_id, rnti, frame, slot); + LOG_D(NR_MAC, "Before consume harq id:"); + dump_nr_list(&sched_ctrl->available_ul_harq); int8_t harq_id = sched_pusch->ul_harq_pid; if (harq_id < 0) { /* PP has not selected a specific HARQ Process, get a new one */ @@ -1049,21 +1058,32 @@ void nr_schedule_ulsch(module_id_t module_id, "no free HARQ process available for UE %d\n", UE_id); remove_front_nr_list(&sched_ctrl->available_ul_harq); + LOG_D(NR_MAC, "Consumed harq id -------------------------> %d", harq_id); sched_pusch->ul_harq_pid = harq_id; } else { /* PP selected a specific HARQ process. Check whether it will be a new * transmission or a retransmission, and remove from the corresponding * list */ if (sched_ctrl->ul_harq_processes[harq_id].round == 0) + { remove_nr_list(&sched_ctrl->available_ul_harq, harq_id); + LOG_D(NR_MAC, "Consumed harq id%d", harq_id); + } else + { remove_nr_list(&sched_ctrl->retrans_ul_harq, harq_id); + LOG_D(NR_MAC, "Retran harq id %d for round %d\n", harq_id, sched_ctrl->ul_harq_processes[harq_id].round); + } } + LOG_D(NR_MAC, "After consume harq id:"); + dump_nr_list(&sched_ctrl->available_ul_harq); NR_UE_ul_harq_t *cur_harq = &sched_ctrl->ul_harq_processes[harq_id]; DevAssert(!cur_harq->is_waiting); add_tail_nr_list(&sched_ctrl->feedback_ul_harq, harq_id); cur_harq->feedback_slot = sched_pusch->slot; cur_harq->is_waiting = true; + LOG_D(NR_MAC, "Updated Feedback ul harq id list:"); + dump_nr_list(&sched_ctrl->feedback_ul_harq); int rnti_types[2] = { NR_RNTI_C, 0 }; @@ -1212,7 +1232,7 @@ void nr_schedule_ulsch(module_id_t module_id, pusch_pdu->pusch_data.new_data_indicator = cur_harq->ndi; pusch_pdu->pusch_data.tb_size = sched_pusch->tb_size; pusch_pdu->pusch_data.num_cb = 0; //CBG not supported - LOG_D(NR_MAC,"Setting harq_id pusch_pdu->pusch_data.harq_process_id %d for UE_id(%d), rnti %x\n", harq_id, UE_id, rnti); + LOG_D(NR_MAC,"Setting harq_id pusch_pdu->pusch_data.harq_process_id %2d for UE_id(%d) rnti %4x sfn slot %4d.%2d\n", harq_id, UE_id, rnti, frame, slot); /* TRANSFORM PRECODING --------------------------------------------------------*/ @@ -1268,7 +1288,8 @@ void nr_schedule_ulsch(module_id_t module_id, pdcch_pdu_bwp_coreset[bwpid][coresetid] = pdcch_pdu; } - LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d\n", frame,slot); + LOG_D(NR_MAC,"Configuring ULDCI/PDCCH in %d.%d rnti %x UE id %d pusch harq_id %d sched_pusch->ul_harq_pid %d\n", + frame,slot, rnti, UE_id, pusch_pdu->pusch_data.harq_process_id, sched_pusch->ul_harq_pid); /* Fill PDCCH DL DCI PDU */ nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci]; @@ -1299,6 +1320,9 @@ void nr_schedule_ulsch(module_id_t module_id, UE_info->UE_sched_ctrl[UE_id].tpc0, n_ubwp, sched_ctrl->active_bwp->bwp_Id); + + LOG_D(NR_MAC,"After config_uldci in %d.%d rnti %x UE id %d uldci payload harq_id %d pusch harq_id %d sched_pusch->ul_harq_pid %d\n", + frame,slot, rnti, UE_id, uldci_payload.harq_pid, pusch_pdu->pusch_data.harq_process_id, sched_pusch->ul_harq_pid); fill_dci_pdu_rel15(scc, secondaryCellGroup, dci_pdu, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index c3f55ce655..8c162ea91d 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -316,12 +316,13 @@ static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n abort(); } + NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); for (int i = 0; i < num_pdus; i++) { nfapi_nr_ul_dci_request_pdus_t *pdu_list = &ul_dci_req->ul_dci_pdu_list[i]; AssertFatal(pdu_list->PDUType == 0, "ul_dci_req pdu type != PUCCH"); - if (pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu->RNTI != get_mac_inst(0)->crnti) - continue; + //if (pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu->RNTI != get_mac_inst(0)->crnti) + // continue; LOG_I(NR_PHY, "[%d %d] PUCCH PDU in ul_dci for rnti %x\n", ul_dci_req->SFN, ul_dci_req->Slot, pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu->RNTI); uint16_t num_dci = pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci; if (num_dci > 0) @@ -334,9 +335,20 @@ static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n for (int j = 0; j < num_dci; j++) { nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j]; + if (dci_pdu_list->RNTI != mac->crnti) + { + LOG_I(NR_MAC, "ul_dci_req Skip: dci_pdu_list->RNTI %x != mac->crnti %x\n", dci_pdu_list->RNTI, get_mac_inst(dl_info->module_id)->crnti); + continue; + } int num_bytes = (dci_pdu_list->PayloadSizeBits + 7) / 8; - LOG_I(NR_PHY, "[%d, %d] ul_dci_req PDCCH DCI for rnti %x with PayloadSizeBits %d and num_bytes %d\n", - ul_dci_req->SFN, ul_dci_req->Slot, dci_pdu_list->RNTI, dci_pdu_list->PayloadSizeBits, num_bytes); + uint64_t *dci_pdu_payload = (uint64_t *)dci_pdu_list->Payload; + int harq_pid = (*dci_pdu_payload >> 11) & 0xf; + LOG_I(NR_PHY, "[%d, %d] ul_dci_req PDCCH DCI for rnti %x with PayloadSizeBits %d and num_bytes %d harq_id %lu\n", + ul_dci_req->SFN, ul_dci_req->Slot, + dci_pdu_list->RNTI, + dci_pdu_list->PayloadSizeBits, num_bytes, + harq_pid + ); for (int k = 0; k < num_bytes; k++) { LOG_I(NR_MAC, "PDCCH DCI PDU payload[%d] = %d\n", k, dci_pdu_list->Payload[k]);