From 38e5415f34c1267f8fa63f5ff9f92082cb46d735 Mon Sep 17 00:00:00 2001 From: David Kim Date: Tue, 27 Jul 2021 20:31:48 -0700 Subject: [PATCH] Fixing "Unexpected ULSCH HARQ PID" issue. 1. If VNF is slower than PNF, next scheduling will be done after resync. 2. If VNF is unstable in slot progress, next scheduling will be done in next stable status. 3. SFN/SLOT indications are queued in nrUE. 4. get_queue is used instead of unquque for FIFO operation. --- cmake_targets/CMakeLists.txt | 8 +- executables/nr-gnb.c | 4 +- executables/nr-ue.c | 19 ++++- executables/softmodem-common.h | 1 + nfapi/oai_integration/nfapi_vnf.c | 8 +- nfapi/open-nFAPI/vnf/src/vnf_interface.c | 2 +- nfapi/open-nFAPI/vnf/src/vnf_p7.c | 5 +- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 13 +-- openair2/COMMON/platform_constants.h | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 5 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 5 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 82 ++++++++++++++++++- openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 8 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 30 ++++++- openair2/RRC/NR/rrc_gNB_reconfig.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 1 + openair2/RRC/NR_UE/rrc_proto.h | 1 + 17 files changed, 163 insertions(+), 33 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index f9fc1bda3f..9d60631bc3 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -306,7 +306,7 @@ endif() # set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -pipe -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing -rdynamic -funroll-loops -Wno-packed-bitfield-compat -fPIC") + "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -pipe -std=gnu99 -Wall -Werror -Wstrict-prototypes -fno-strict-aliasing -rdynamic -funroll-loops -Wno-packed-bitfield-compat -fPIC") # add autotools definitions that were maybe used! if (CUDA_FOUND) set(MKVER "'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'") @@ -314,14 +314,14 @@ if (CUDA_FOUND) "${CMAKE_C_FLAGS} -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP -D CUDA_FLAG" ) set(CUDA_CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} -Wno-packed-bitfield-compat -fPIC -Wall -fno-strict-aliasing -rdynamic -std=c++11 -D CUDA_FLAG" + "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} -Wno-packed-bitfield-compat -fPIC -Wall -Werror -fno-strict-aliasing -rdynamic -std=c++11 -D CUDA_FLAG" ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP -D${MKVER} -D CUDA_FLAG" ) set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} -Wno-packed-bitfield-compat -fPIC -Wall -fno-strict-aliasing -rdynamic -std=c++11 -D${MKVER} -D CUDA_FLAG" + "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} -Wno-packed-bitfield-compat -fPIC -Wall -Werror -fno-strict-aliasing -rdynamic -std=c++11 -D${MKVER} -D CUDA_FLAG" ) else (CUDA_FOUND) set(MKVER "'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'") @@ -329,7 +329,7 @@ else (CUDA_FOUND) "${CMAKE_C_FLAGS} -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP -D${MKVER}" ) set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} -Wno-packed-bitfield-compat -fPIC -Wall -fno-strict-aliasing -rdynamic -std=c++11 -D${MKVER}" + "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} -Wno-packed-bitfield-compat -fPIC -Wall -Werror -fno-strict-aliasing -rdynamic -std=c++11 -D${MKVER}" ) endif () diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index df2f647855..69b2292c08 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -443,8 +443,7 @@ static void *gNB_L1_thread( void *param ) { if (gNB->CC_id==0) { int next_slot; next_slot = (slot_rx + 1) % 20; - LOG_I(PHY, "Calling rxtx1\n"); - if (rxtx(gNB,frame_rx,next_slot,frame_tx,next_slot,thread_name) < 0) break; + if (rxtx(gNB,(frame_rx + ((slot_rx + 1) % 20 == 0))%1024,next_slot,(frame_tx + ((slot_rx + 1) % 20 == 0)) % 1024,next_slot,thread_name) < 0) break; } if (wait_on_condition(&L1_proc->mutex,&L1_proc->cond,&L1_proc->instance_cnt,thread_name)<0) break; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PROC_RXTX0, 1 ); @@ -458,7 +457,6 @@ static void *gNB_L1_thread( void *param ) { if (oai_exit) break; if (gNB->CC_id==0) { - LOG_I(PHY, "Calling rxtx2\n"); if (rxtx(gNB,frame_rx,slot_rx,frame_tx,slot_tx,thread_name) < 0) break; } diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 2154230013..0816bc6d16 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -224,12 +224,15 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) reset_queue(&nr_rx_ind_queue); reset_queue(&nr_crc_ind_queue); reset_queue(&nr_uci_ind_queue); + reset_queue(&nr_sfn_slot_queue); NR_PRACH_RESOURCES_t prach_resources; memset(&prach_resources, 0, sizeof(prach_resources)); NR_UL_TIME_ALIGNMENT_t ul_time_alignment; memset(&ul_time_alignment, 0, sizeof(ul_time_alignment)); int last_sfn_slot = -1; + uint16_t *sfn_slot_p; + int sfn_slot; while (!oai_exit) { @@ -238,8 +241,14 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) LOG_E(NR_MAC, "sem_wait() error\n"); abort(); } + sfn_slot_p = get_queue(&nr_sfn_slot_queue); + if (sfn_slot_p == NULL) + continue; + + sfn_slot = *sfn_slot_p; + LOG_D(NR_MAC, "We have successfully dequeued snf slot = %d.%d, qsize = %zu\n", + NFAPI_SFNSLOT2SFN(sfn_slot), NFAPI_SFNSLOT2SLOT(sfn_slot), nr_sfn_slot_queue.num_items); - int sfn_slot = current_sfn_slot; if (sfn_slot == last_sfn_slot) { LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n", @@ -320,7 +329,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); nfapi_nr_rx_data_indication_t *rx_ind = unqueue_matching(&nr_rx_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&nr_crc_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); - + LOG_D(NR_MAC, "Checking queues with crc_ind = %p\n", crc_ind); if (rach_ind && rach_ind->number_of_pdus > 0) { NR_UL_IND_t UL_INFO = { @@ -347,9 +356,15 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) NR_UL_IND_t UL_INFO = { .crc_ind = *crc_ind, }; + for (int j = 0; j < crc_ind->number_crcs; j++) + { + LOG_I(NR_PHY, "Sending crc_ind.harq_id = %d for %d index SFN SLot %u %u with rnti %x\n", + crc_ind->crc_list[j].harq_id, j, crc_ind->sfn, crc_ind->slot, crc_ind->crc_list[j].rnti); + } send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id); free(crc_ind->crc_list); } + LOG_D(NR_MAC, "Ready for handling next SFN SLOT\n"); } return NULL; } diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index 003636c379..198d6fa499 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -251,6 +251,7 @@ extern void set_softmodem_sighandler(void); extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; extern uint8_t nfapi_mode; +extern int16_t vnf_pnf_sfnslot_delta; #ifdef __cplusplus } #endif diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index e6f528cd38..c552879d30 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -604,6 +604,8 @@ int phy_sync_indication(struct nfapi_vnf_p7_config *config, uint8_t sync) { return(0); } +uint16_t pnf_frame; +uint16_t pnf_slot; int phy_slot_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn, uint16_t slot) { static uint8_t first_time = 1; @@ -616,7 +618,9 @@ int phy_slot_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uin if (RC.gNB && RC.gNB[0]->configured) { // uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf); // uint16_t sf = NFAPI_SFNSF2SF(sfn_sf); - LOG_D(PHY,"[VNF] slot indication sfn:%d sf:%d\n", sfn, slot); + pnf_frame = sfn; + pnf_slot = slot; + LOG_D(PHY,"[VNF] slot indication sfn:%d slot:%d\n", sfn, slot); wake_gNB_rxtx(RC.gNB[0], sfn, slot); // DONE: find NR equivalent } else { printf("[VNF] %s() RC.gNB:%p\n", __FUNCTION__, RC.gNB); @@ -978,6 +982,8 @@ int phy_nr_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_nr_crc_indic crc_ind->crc_list[j].tb_crc_status = ind->crc_list[j].tb_crc_status; crc_ind->crc_list[j].timing_advance = ind->crc_list[j].timing_advance; crc_ind->crc_list[j].ul_cqi = ind->crc_list[j].ul_cqi; + LOG_I(NR_MAC, "Received crc_ind.harq_id = %d for %d index SFN SLot %u %u with rnti %x\n", + ind->crc_list[j].harq_id, j, ind->sfn, ind->slot, ind->crc_list[j].rnti); } if (!put_queue(&gnb_crc_ind_queue, crc_ind)) { diff --git a/nfapi/open-nFAPI/vnf/src/vnf_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_interface.c index 5d0d085b58..41a357ab34 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_interface.c @@ -1154,7 +1154,7 @@ int nfapi_vnf_allocate_phy(nfapi_vnf_config_t* config, int p5_idx, uint16_t* phy info->timing_window = 30; // This seems to override what gets set by the user - why??? //TODO: Change in NR in terms of microsecends,what should be the value? info->timing_info_mode = 0x03; - info->timing_info_period = 128; // Melissa come back to this + info->timing_info_period = 10; // Melissa come back to this nfapi_vnf_phy_info_list_add(config, info); diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c index 3c7f0d1056..ffac2c5049 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -1997,6 +1997,7 @@ void vnf_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) } } +int16_t vnf_pnf_sfnslot_delta; void vnf_nr_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) { @@ -2016,7 +2017,7 @@ void vnf_nr_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) if (vnf_p7 && vnf_p7->p7_connections) { //int16_t vnf_pnf_sfnsf_delta = NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf) - NFAPI_SFNSF2DEC(ind.last_sfn_sf); - int16_t vnf_pnf_sfnslot_delta = NFAPI_SFNSLOT2DEC(vnf_p7->p7_connections[0].sfn,vnf_p7->p7_connections[0].slot) - NFAPI_SFNSLOT2DEC(ind.last_sfn,ind.last_slot); + vnf_pnf_sfnslot_delta = NFAPI_SFNSLOT2DEC(vnf_p7->p7_connections[0].sfn,vnf_p7->p7_connections[0].slot) - NFAPI_SFNSLOT2DEC(ind.last_sfn,ind.last_slot); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PNF:SFN/SF:%d VNF:SFN/SF:%d deltaSFNSF:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind.last_sfn_sf), NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), vnf_pnf_sfnsf_delta); // Panos: Careful here!!! Modification of the original nfapi-code @@ -2024,7 +2025,7 @@ void vnf_nr_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) //printf("VNF-PNF delta - %d", vnf_pnf_sfnslot_delta); if (vnf_pnf_sfnslot_delta != 0) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() LARGE SFN/SF DELTA between PNF and VNF. Delta %d. PNF:%d.%d VNF:%d.%d\n\n\n\n\n\n\n\n\n", + NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() LARGE SFN/SLOT DELTA between PNF and VNF. Delta %d. PNF:%d.%d VNF:%d.%d\n\n\n\n\n\n\n\n\n", __FUNCTION__, vnf_pnf_sfnslot_delta, ind.last_sfn, ind.last_slot, vnf_p7->p7_connections[0].sfn, vnf_p7->p7_connections[0].slot); diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 3c8d40568a..b74a3434a5 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -47,6 +47,7 @@ const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"}; queue_t nr_rx_ind_queue; queue_t nr_crc_ind_queue; queue_t nr_uci_ind_queue; +queue_t nr_sfn_slot_queue; int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { @@ -101,18 +102,17 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response { crc_ind->crc_list[j].handle = pusch_config_pdu->handle; crc_ind->crc_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id; - LOG_I(NR_MAC, "This is the harq pid %d for crc_list[%d]\n", crc_ind->crc_list[j].harq_id, j); - LOG_I(NR_MAC, "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d]\n", - scheduled_response->frame, scheduled_response->slot, crc_ind->sfn, crc_ind->slot); crc_ind->crc_list[j].num_cb = pusch_config_pdu->pusch_data.num_cb; crc_ind->crc_list[j].rnti = pusch_config_pdu->rnti; crc_ind->crc_list[j].tb_crc_status = 0; crc_ind->crc_list[j].timing_advance = scheduled_response->tx_request->tx_config.timing_advance; crc_ind->crc_list[j].ul_cqi = scheduled_response->tx_request->tx_config.ul_cqi; + LOG_D(NR_MAC, "This is the harq pid %d for crc_list[%d] rnti %x " + "sched sfn/sl [%d %d] and crc sfn/sl [%d %d]\n", + crc_ind->crc_list[j].harq_id, j, pusch_config_pdu->rnti, + scheduled_response->frame, scheduled_response->slot, crc_ind->sfn, crc_ind->slot); } - LOG_I(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__); - if (!put_queue(&nr_rx_ind_queue, rx_ind)) { LOG_E(NR_MAC, "Put_queue failed for rx_ind\n"); @@ -125,6 +125,9 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response free(crc_ind->crc_list); free(crc_ind); } + + LOG_I(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__); + scheduled_response->tx_request->number_of_pdus = 0; } break; diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h index 68ad7906d5..80f01900aa 100644 --- a/openair2/COMMON/platform_constants.h +++ b/openair2/COMMON/platform_constants.h @@ -75,7 +75,7 @@ #else #define MAX_MOBILES_PER_ENB 40 #define MAX_MOBILES_PER_ENB_NB_IoT 40 - #define MAX_MOBILES_PER_GNB 2//16 + #define MAX_MOBILES_PER_GNB 16 #define MAX_eNB 2 #define MAX_gNB 2 #endif diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index fcb1785955..68523c29fb 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -471,7 +471,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr const uint16_t n_RB_DLBWP = (ra->ra_state == WAIT_RAR) ? NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - LOG_I(MAC, "In %s: Processing received DCI format %s (DL BWP %d)\n", __FUNCTION__, dci_formats[dci_format], n_RB_DLBWP); + LOG_I(MAC, "In %s: Processing received DCI format %s (DL BWP %d) harq_pid %d\n", + __FUNCTION__, dci_formats[dci_format], n_RB_DLBWP, dci->harq_pid); + + switch(dci_format){ case NR_UL_DCI_FORMAT_0_0: { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 0583cebdfb..74d4ea5e13 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -928,14 +928,13 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_req->nPDUs+=1; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; - LOG_I(MAC,"[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RAR DCI, state %d, rnti %x, new rnti %x\n", + LOG_I(MAC,"[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RAR DCI, state %d, rnti %x\n", module_idP, CC_id, frameP, slotP, ra->state, - ra->rnti, - ra->secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity + ra->rnti ); NR_BWP_Uplink_t *ubwp=ra->secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 273c38dade..d75a585fcd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -338,9 +338,10 @@ void handle_nr_ul_harq(module_id_t mod_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; int8_t harq_pid = sched_ctrl->feedback_ul_harq.head; + 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 %d (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 (ignore this warning for RA)\n", crc_pdu->harq_id, harq_pid, crc_pdu->rnti); @@ -931,6 +932,23 @@ bool nr_simple_ulsch_preprocessor(module_id_t module_id, return true; } +static inline int timespec_diff_in_milliseconds(struct timespec *a, struct timespec *b) +{ + int diff_in_ms = (a->tv_sec - b->tv_sec) * 1000 + a->tv_nsec /1000000 - b->tv_nsec / 1000000; + return diff_in_ms; +} + +typedef struct _sched_info +{ + uint16_t rnti; + uint16_t sfn; + uint16_t slot; + int8_t harq_id; + struct timespec ts; +} sched_info; + +sched_info prev_sched[MAX_MOBILES_PER_GNB]; + void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, @@ -969,6 +987,62 @@ void nr_schedule_ulsch(module_id_t module_id, if (sched_pusch->rbSize <= 0) continue; + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) + abort(); + + if (prev_sched[UE_id].rnti != 0) + { + uint16_t prev_frame = prev_sched[UE_id].sfn; + uint16_t prev_slot = prev_sched[UE_id].slot; + int sfnslot_delta = NFAPI_SFNSLOT2DEC(frame, slot) - NFAPI_SFNSLOT2DEC(prev_frame, prev_slot); + if (sfnslot_delta < 0) + { + sfnslot_delta += NFAPI_SFNSLOT2DEC(1024,0); + } + // If diff is more than half of maximum frame: we ignore it. + if (sfnslot_delta > NFAPI_SFNSLOT2DEC(512, 0)) + { + LOG_D(PHY, "%s() SFN/SLOT DELTA between Sched and Previous. UEID %d, rnti %x Delta %d. " + "Current:%d.%d Prev(%d):%d.%d --> Skip\n\n\n\n\n\n\n\n\n", + __FUNCTION__, UE_id, UE_info->rnti[UE_id], sfnslot_delta - NFAPI_SFNSLOT2DEC(1024,0), + frame, slot, + prev_sched[UE_id].harq_id, prev_frame, prev_slot); + continue; + } + else + { + LOG_D(PHY, "%s() SFN/SLOT DELTA between Sched and Previous. UEID %d, rnti %x Delta %d. " + "Current:%d.%d Prev(%d):%d.%d\n\n\n\n\n\n\n\n\n", + __FUNCTION__, UE_id, UE_info->rnti[UE_id], sfnslot_delta, + frame, slot, + prev_sched[UE_id].harq_id, prev_frame, prev_slot); + } + + int time_diff_in_ms = timespec_diff_in_milliseconds (&ts, &prev_sched[UE_id].ts); + + // The sched tx duration between ul dci req is assumed between 4 ms to 6 ms. + if (vnf_pnf_sfnslot_delta < 0 || time_diff_in_ms < 4 * (sfnslot_delta / 10) + || time_diff_in_ms > 6 * (sfnslot_delta / 10)) + { + LOG_D(PHY, "%s() SFN/SLOT DELTA between Proxy and gNB. UEID %d, rnti %x Delta %3d. gNB:%4d.%-2d " + "slot_diff %4d time_diff %d : %lu.%06lu vs %lu.%06lu --> Skip\n\n\n\n\n\n\n\n\n", + __FUNCTION__, UE_id, UE_info->rnti[UE_id], + vnf_pnf_sfnslot_delta, + frame, slot, sfnslot_delta, time_diff_in_ms, + ts.tv_sec, ts.tv_nsec / 1000, + prev_sched[UE_id].ts.tv_sec, prev_sched[UE_id].ts.tv_nsec / 1000); + continue; + } + else + { + LOG_D(PHY, "%s() SFN/SLOT DELTA between Proxy and gNB. UEID %d, rnti %x Delta %3d. " + "gNB:%4d.%-2d slot_diff %4d time_diff %d\n\n\n\n\n\n\n\n\n", + __FUNCTION__, UE_id, UE_info->rnti[UE_id], vnf_pnf_sfnslot_delta, + frame, slot, sfnslot_delta, time_diff_in_ms); + } + } + 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); @@ -1049,6 +1123,11 @@ void nr_schedule_ulsch(module_id_t module_id, } gNB->handled_frame = frame; gNB->handled_slot = slot; + prev_sched[UE_id].rnti = rnti; + prev_sched[UE_id].sfn = frame; + prev_sched[UE_id].slot = slot; + prev_sched[UE_id].harq_id = harq_id; + prev_sched[UE_id].ts = ts; /* PUSCH in a later slot, but corresponding DCI now! */ nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_id]->UL_tti_req_ahead[0][sched_pusch->slot]; @@ -1138,6 +1217,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(MAC,"Setting harq_id pusch_pdu->pusch_data.harq_process_id %d for UE_id(%d), rnti %x\n", harq_id, UE_id, rnti); /* TRANSFORM PRECODING --------------------------------------------------------*/ diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index f0b58a66ce..d163a59fbf 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -65,7 +65,7 @@ void handle_nr_rach(NR_UL_IND_t *UL_info) if (gnb_rach_ind_queue.num_items ==0) return; LOG_I(NR_MAC, "gnb_rach_ind_queue size = %zu\n", gnb_rach_ind_queue.num_items); - nfapi_nr_rach_indication_t *rach_ind = unqueue(&gnb_rach_ind_queue); + nfapi_nr_rach_indication_t *rach_ind = get_queue(&gnb_rach_ind_queue); NR_UL_IND_t UL_INFO; UL_INFO.rach_ind = *rach_ind; UL_INFO.frame = rach_ind->sfn; @@ -108,7 +108,7 @@ void handle_nr_uci(NR_UL_IND_t *UL_info) if (gnb_uci_ind_queue.num_items ==0) return; LOG_I(NR_MAC, "gnb_uci_ind_queue size = %zu\n", gnb_uci_ind_queue.num_items); - nfapi_nr_uci_indication_t *uci_ind = unqueue(&gnb_uci_ind_queue); + nfapi_nr_uci_indication_t *uci_ind = get_queue(&gnb_uci_ind_queue); NR_UL_IND_t UL_INFO; UL_INFO.uci_ind = *uci_ind; @@ -191,7 +191,7 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) gnb_rx_ind_queue.num_items, gnb_crc_ind_queue.num_items ); - nfapi_nr_rx_data_indication_t *rx_ind = unqueue(&gnb_rx_ind_queue); + nfapi_nr_rx_data_indication_t *rx_ind = get_queue(&gnb_rx_ind_queue); int sfn_slot = NFAPI_SFNSLOT2HEX(rx_ind->sfn, rx_ind->slot); nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&gnb_crc_ind_queue, @@ -354,7 +354,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { ifi->NR_Schedule_response(sched_info); } - LOG_D(PHY,"NR_Schedule_response: SFN_SF:%d%d dl_pdus:%d\n", + LOG_D(PHY,"NR_Schedule_response: SFN SLOT:%d %d dl_pdus:%d\n", sched_info->frame, sched_info->slot, sched_info->DL_req->dl_tti_request_body.nPDUs); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index ddd186a271..9e232a5298 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -370,14 +370,14 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n LOG_D(NR_PHY, "This is the pdu type %d in ul_tti_req\n", pdu_list->pdu_type); if (pdu_list->pdu_type == NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE) { - nfapi_nr_uci_indication_t *uci_ind = unqueue(&nr_uci_ind_queue); + nfapi_nr_uci_indication_t *uci_ind = get_queue(&nr_uci_ind_queue); if (uci_ind) { if (uci_ind->num_ucis > 0) { uci_ind->sfn = ul_tti_req->SFN; uci_ind->slot = ul_tti_req->Slot; - LOG_I(NR_MAC, "We have unqueued the previously filled uci_ind and updated the snf/slot to %d/%d.\n", + LOG_I(NR_MAC, "We have dequeued the previously filled uci_ind and updated the snf/slot to %d/%d.\n", uci_ind->sfn, uci_ind->slot); NR_UL_IND_t UL_INFO = { .uci_ind = *uci_ind, @@ -554,12 +554,15 @@ static void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request) nsa_sendmsg_to_lte_ue(buffer, pack_len, NR_UE_RRC_MEASUREMENT); LOG_A(NR_RRC, "Populated NR_UE_RRC_MEASUREMENT information and sent to LTE UE\n"); } +uint16_t sfn_slot_pool[512]; +uint16_t sfn_slot_id ; void *nrue_standalone_pnf_task(void *context) { struct sockaddr_in server_address; socklen_t addr_len = sizeof(server_address); char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + int sfn, slot, delta; int sd = ue_rx_sock_descriptor; assert(sd > 0); LOG_I(NR_RRC, "Sucessfully started %s.\n", __FUNCTION__); @@ -583,13 +586,25 @@ void *nrue_standalone_pnf_task(void *context) memcpy((void *)&sfn_slot, buffer, sizeof(sfn_slot)); current_sfn_slot = sfn_slot; + sfn_slot_pool[sfn_slot_id] = sfn_slot; + + if (!put_queue(&nr_sfn_slot_queue, &sfn_slot_pool[sfn_slot_id])) + { + LOG_I(NR_MAC, "put_queue failed for sfn slot.\n"); + } + LOG_D(NR_MAC, "We have successfully queued snf slot %d.%d, with id %u, qsize %zu\n", + sfn_slot_pool[sfn_slot_id]>> 6, sfn_slot_pool[sfn_slot_id] & 0x3F, + sfn_slot_id, nr_sfn_slot_queue.num_items); + + sfn_slot_id = (sfn_slot_id + 1) % 512; + if (sem_post(&sfn_slot_semaphore) != 0) { LOG_E(NR_PHY, "sem_post() error\n"); abort(); } - int sfn = NFAPI_SFNSLOT2SFN(sfn_slot); - int slot = NFAPI_SFNSLOT2SLOT(sfn_slot); + sfn = NFAPI_SFNSLOT2SFN(sfn_slot); + slot = NFAPI_SFNSLOT2SLOT(sfn_slot); LOG_I(NR_PHY, "Received from proxy sfn %d slot %d\n", sfn, slot); } else if (len == sizeof(nr_phy_channel_params_t)) @@ -652,6 +667,13 @@ void *nrue_standalone_pnf_task(void *context) } LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message in SFN/slot %d %d. \n", ul_dci_request.SFN, ul_dci_request.Slot); + delta = NFAPI_SFNSLOT2DEC(sfn, slot) - NFAPI_SFNSLOT2DEC(ul_dci_request.SFN, ul_dci_request.Slot); + if (delta < -NFAPI_SFNSLOT2DEC(512, 0)) + { + delta += NFAPI_SFNSLOT2DEC(1024, 0); + } + AssertFatal(delta < 6, "Slot delta %d < 6 is required. sfn slot %u %u vs ul_dci_request sfn slot %u %u\n", + delta, sfn, slot, ul_dci_request.SFN, ul_dci_request.Slot); check_and_process_dci(NULL, NULL, &ul_dci_request, NULL); break; case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 99a2505e74..ab3f192276 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -141,7 +141,7 @@ void fill_default_searchSpaceZero(NR_SearchSpace_t *ss0) { ss0->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common; } -static int unique_preamble_index_gNB; + void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_CellGroupConfig_t *secondaryCellGroup, int scg_id, diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 111bab4c91..df535cddf7 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -2969,6 +2969,7 @@ static void start_oai_nrue_threads() init_queue(&nr_rx_ind_queue); init_queue(&nr_crc_ind_queue); init_queue(&nr_uci_ind_queue); + init_queue(&nr_sfn_slot_queue); if (sem_init(&sfn_slot_semaphore, 0, 0) != 0) { diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 3aa01948e2..cb2a01698f 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -45,6 +45,7 @@ extern queue_t nr_rach_ind_queue; extern queue_t nr_rx_ind_queue; extern queue_t nr_crc_ind_queue; extern queue_t nr_uci_ind_queue; +extern queue_t nr_sfn_slot_queue; // // main_rrc.c //