From 1af5a89dd15b7fe4cfb40bcd811101aaab102b47 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Sun, 5 Dec 2021 10:48:16 +0530 Subject: [PATCH 01/13] Removed active waiting loop which could block threads. Instead used a separate thread to reorder the finished the job messages --- executables/nr-gnb.c | 122 +++++++++++++++++++----------- executables/nr-ru.c | 4 +- nfapi/oai_integration/nfapi_pnf.c | 40 ++-------- openair1/PHY/defs_gNB.h | 7 +- openair1/SCHED_NR/fapi_nr_l1.c | 90 +++++++++++----------- 5 files changed, 136 insertions(+), 127 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index f83fac2737..dfea55e325 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -87,7 +87,7 @@ #include #include #include -//#define DEBUG_THREADS 1 +#define DEBUG_THREADS 0 //#define USRP_DEBUG 1 // Fix per CC openair rf/if device update @@ -114,7 +114,6 @@ time_stats_t softmodem_stats_rx_sf; // total rx time void tx_func(void *param) { processingData_L1tx_t *info = (processingData_L1tx_t *) param; - PHY_VARS_gNB *gNB = info->gNB; int frame_tx = info->frame; int slot_tx = info->slot; @@ -122,31 +121,6 @@ void tx_func(void *param) { frame_tx, slot_tx, 1); - info->slot = -1; - //if ((frame_tx&127) == 0) dump_pdsch_stats(fd,gNB); - - // If the later of the 2 L1 tx thread finishes first, - // we wait for the earlier one to finish and start the RU thread - // to avoid realtime issues with USRP - - // Start RU TX processing. - notifiedFIFO_elt_t *res; - res = pullTpool(gNB->resp_RU_tx, gNB->threadPool); - processingData_RU_t *syncMsg = (processingData_RU_t *)NotifiedFifoData(res); - LOG_D(PHY,"waiting for previous tx to finish, next slot %d,%d\n",syncMsg->next_slot,slot_tx); - while (syncMsg->next_slot != slot_tx) { - pushNotifiedFIFO(gNB->resp_RU_tx, res); - res = pullTpool(gNB->resp_RU_tx, gNB->threadPool); - syncMsg = (processingData_RU_t *)NotifiedFifoData(res); - } - LOG_D(PHY,"previous tx finished, next slot %d,%d\n",syncMsg->next_slot,slot_tx); - syncMsg->frame_tx = frame_tx; - syncMsg->slot_tx = slot_tx; - syncMsg->next_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, frame_tx, slot_tx); - syncMsg->timestamp_tx = info->timestamp_tx; - syncMsg->ru = gNB->RU_list[0]; - res->key = slot_tx; - pushTpool(gNB->threadPool, res); } void rx_func(void *param) { @@ -276,15 +250,12 @@ void rx_func(void *param) { if (tx_slot_type == NR_DOWNLINK_SLOT || tx_slot_type == NR_MIXED_SLOT) { notifiedFIFO_elt_t *res; - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - processingData_L1tx_t *syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); - while (syncMsg->slot != slot_tx) { - pushNotifiedFIFO(gNB->resp_L1_tx, res); - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); - } + processingData_L1tx_t *syncMsg; + // Its a FIFO so it maitains the order in which the MAC fills the messages + // so no need for checking for right slot + res = pullTpool(gNB->L1_tx_filled, gNB->threadPool); + syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; - AssertFatal(syncMsg->slot == slot_tx, "Thread message slot and logical slot number do not match\n"); syncMsg->timestamp_tx = info->timestamp_tx; res->key = slot_tx; pushTpool(gNB->threadPool, res); @@ -390,6 +361,64 @@ void *nrL1_stats_thread(void *param) { return(NULL); } +// This thread reads the finished L1 tx jobs from threaPool +// and pushes RU tx thread in the right order. It works only +// two parallel L1 tx threads. +void *tx_reorder_thread(void* param) { + PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param; + notifiedFIFO_elt_t *resL1; + notifiedFIFO_elt_t *resL1Reserve = NULL; + notifiedFIFO_elt_t *resRU; + processingData_L1tx_t *syncMsgL1; + processingData_RU_t *syncMsgRU; + + while (!oai_exit) { + // check if there is a message in reserve + if (resL1Reserve) { + syncMsgL1 = (processingData_L1tx_t *)NotifiedFifoData(resL1Reserve); + if (syncMsgL1->slot == gNB->next_tx_slot) { + resRU = pullTpool(gNB->resp_RU_tx, gNB->threadPool); + // processing of last ru_tx_func finished + syncMsgRU = (processingData_RU_t *)NotifiedFifoData(resRU); + syncMsgRU->frame_tx = syncMsgL1->frame; + syncMsgRU->slot_tx = syncMsgL1->slot; + syncMsgRU->timestamp_tx = syncMsgL1->timestamp_tx; + syncMsgRU->ru = gNB->RU_list[0]; + resRU->key = syncMsgL1->slot; + gNB->next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU->frame_tx, syncMsgRU->slot_tx); + pushNotifiedFIFO(gNB->L1_tx_free, resL1Reserve); + pushTpool(gNB->threadPool, resRU); + resL1Reserve = NULL; + } else { +#if DEBUG_THREADS + printf("Waiting for reserve L1 Tx message to be sent to RU for slot %d\n", syncMsgL1->slot); +#endif + } + } + // pull message from output FIFO of tx_func + resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + syncMsgL1 = (processingData_L1tx_t *)NotifiedFifoData(resL1); + + if (syncMsgL1->slot == gNB->next_tx_slot) { + resRU = pullTpool(gNB->resp_RU_tx, gNB->threadPool); + // processing of last ru_tx_func finished + syncMsgRU = (processingData_RU_t *)NotifiedFifoData(resRU); + syncMsgRU->frame_tx = syncMsgL1->frame; + syncMsgRU->slot_tx = syncMsgL1->slot; + syncMsgRU->timestamp_tx = syncMsgL1->timestamp_tx; + syncMsgRU->ru = gNB->RU_list[0]; + resRU->key = syncMsgL1->slot; + gNB->next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU->frame_tx, syncMsgRU->slot_tx); + pushNotifiedFIFO(gNB->L1_tx_free, resL1); + pushTpool(gNB->threadPool, resRU); + } else { + AssertFatal(resL1Reserve == NULL, "Error! There is already a waiting message\n"); + resL1Reserve = resL1; + } + } + return(NULL); +} + void init_gNB_Tpool(int inst) { PHY_VARS_gNB *gNB; gNB = RC.gNB[inst]; @@ -421,38 +450,39 @@ void init_gNB_Tpool(int inst) { pushNotifiedFIFO(gNB->resp_L1,msg); // to unblock the process in the beginning // L1 TX result FIFO - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); + gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->L1_tx_free); + initNotifiedFIFO(gNB->L1_tx_filled); + initNotifiedFIFO(gNB->L1_tx_out); // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,tx_func); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); init_DLSCH_struct(gNB, msgDataTx); - msgDataTx->slot = -1; memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); reset_meas(&msgDataTx->phy_proc_tx); gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; - pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning - msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,tx_func); + msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); init_DLSCH_struct(gNB, msgDataTx); - msgDataTx->slot = -1; memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); reset_meas(&msgDataTx->phy_proc_tx); gNB->phy_proc_tx_1 = &msgDataTx->phy_proc_tx; - pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning // RU TX result FIFO gNB->resp_RU_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); initNotifiedFIFO(gNB->resp_RU_tx); notifiedFIFO_elt_t *msgRUTx = newNotifiedFIFO_elt(sizeof(processingData_RU_t),0,gNB->resp_RU_tx,ru_tx_func); - processingData_RU_t *msgData = (processingData_RU_t*)msgRUTx->msgData; int first_tx_slot = sf_ahead*gNB->frame_parms.slots_per_subframe; - msgData->next_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, 0, first_tx_slot-1); pushNotifiedFIFO(gNB->resp_RU_tx,msgRUTx); // to unblock the process in the beginning + gNB->next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, 0, first_tx_slot-1); threadCreate(&proc->L1_stats_thread,nrL1_stats_thread,(void*)gNB,"L1_stats",-1,OAI_PRIORITY_RT_LOW); - + threadCreate(&proc->pthread_tx_reorder, tx_reorder_thread, (void *)gNB, "thread_tx_reorder", -1, OAI_PRIORITY_RT_MAX); } diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 3a2589632b..b749928b37 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1445,9 +1445,9 @@ void *ru_thread( void *param ) { res = pullNotifiedFIFO(gNB->resp_L1); delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(gNB->resp_L1_tx); + res = pullNotifiedFIFO(gNB->L1_tx_free); delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(gNB->resp_L1_tx); + res = pullNotifiedFIFO(gNB->L1_tx_free); delNotifiedFIFO_elt(res); res = pullNotifiedFIFO(gNB->resp_RU_tx); delNotifiedFIFO_elt(res); diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 4edbeee342..3d8fee7615 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -1108,39 +1108,9 @@ notifiedFIFO_elt_t *l1tx_message_extract(PHY_VARS_gNB *gNB, int frame, int slot) notifiedFIFO_elt_t *res; notifiedFIFO_elt_t *freeRes = NULL; - // check first message - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); - if (msgTx->slot == slot) { - return res; - } - if (msgTx->slot == -1) { - freeRes = res; - } - - // check second message - pushNotifiedFIFO(gNB->resp_L1_tx,res); - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); - if (msgTx->slot == slot) { - return res; - } - if (msgTx->slot == -1) { - freeRes = res; - } - - if (freeRes) { - msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); - msgTx->num_pdsch_slot=0; - msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; - msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; - msgTx->slot = slot; - msgTx->frame = frame; - return freeRes; - } - pushNotifiedFIFO(gNB->resp_L1_tx,res); - AssertFatal(1==0, "It means both L1 Tx messages are still waiting to be processed. This happens when L1 Tx processing is too slow. Message slot %d, scheduled slot %d\n", - msgTx->slot, slot); + //TODO: This needs to be reworked for nfapi to work + res = pullTpool(gNB->L1_tx_free, gNB->threadPool); + return res; } int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_dci_request_t *req) { @@ -1166,7 +1136,7 @@ int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, } } - pushNotifiedFIFO(gNB->resp_L1_tx,res); + pushNotifiedFIFO(gNB->L1_tx_filled,res); return 0; } @@ -1274,7 +1244,7 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, else { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_tti_pdu_list[i].PDUType); } - pushNotifiedFIFO(gNB->resp_L1_tx,res); + pushNotifiedFIFO(gNB->L1_tx_filled,res); } if(req->vendor_extension) diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 11b5112a6c..d309990ed0 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -608,6 +608,8 @@ typedef struct gNB_L1_proc_t_s { pthread_t L1_stats_thread; /// pthread structure for printing time meas pthread_t process_stats_thread; + /// pthread structure for reordering L1 tx thread messages + pthread_t pthread_tx_reorder; /// flag to indicate first RX acquisition int first_rx; /// flag to indicate first TX transmission @@ -897,11 +899,14 @@ typedef struct PHY_VARS_gNB_s { */ notifiedFIFO_t *respDecode; notifiedFIFO_t *resp_L1; - notifiedFIFO_t *resp_L1_tx; + notifiedFIFO_t *L1_tx_free; + notifiedFIFO_t *L1_tx_filled; + notifiedFIFO_t *L1_tx_out; notifiedFIFO_t *resp_RU_tx; tpool_t *threadPool; int nbDecode; uint8_t pusch_proc_threads; + int next_tx_slot; int number_of_nr_dlsch_max; int number_of_nr_ulsch_max; void * scopeData; diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 8f315ba214..54534eee0f 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -148,11 +148,9 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ AssertFatal(RC.gNB[Mod_id]!=NULL,"RC.gNB[%d] is null\n",Mod_id); gNB = RC.gNB[Mod_id]; + nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; - notifiedFIFO_elt_t *res; - res = pullTpool(gNB->resp_L1_tx, gNB->threadPool); - processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); - + int slot_type = nr_slot_select(cfg,frame,slot); uint8_t number_dl_pdu = (DL_req==NULL) ? 0 : DL_req->dl_tti_request_body.nPDUs; uint8_t number_ul_dci_pdu = (UL_dci_req==NULL) ? 0 : UL_dci_req->numPdus; uint8_t number_ul_tti_pdu = (UL_tti_req==NULL) ? 0 : UL_tti_req->n_pdus; @@ -166,53 +164,59 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ TX_req->SFN,TX_req->Slot,TX_req->Number_of_PDUs, number_ul_dci_pdu,number_ul_tti_pdu); - int pdcch_received=0; - msgTx->num_pdsch_slot=0; - msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; - msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; - msgTx->slot = slot; - msgTx->frame = frame; + if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT) { + notifiedFIFO_elt_t *res; + res = pullTpool(gNB->L1_tx_free, gNB->threadPool); + processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); - for (int i=0;idl_tti_request_body.dl_tti_pdu_list[i]; - LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_tti_pdu->PDUType); - switch (dl_tti_pdu->PDUType) { - case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: - handle_nr_nfapi_ssb_pdu(msgTx,frame,slot, - dl_tti_pdu); - break; + int pdcch_received=0; + msgTx->num_pdsch_slot=0; + msgTx->pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; + msgTx->ul_pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci = 0; + msgTx->slot = slot; + msgTx->frame = frame; - case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: - AssertFatal(pdcch_received == 0, "pdcch_received is not 0, we can only handle one PDCCH PDU per slot\n"); - msgTx->pdcch_pdu = dl_tti_pdu->pdcch_pdu; + for (int i=0;idl_tti_request_body.dl_tti_pdu_list[i]; + LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_tti_pdu->PDUType); + switch (dl_tti_pdu->PDUType) { + case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: + handle_nr_nfapi_ssb_pdu(msgTx,frame,slot, + dl_tti_pdu); + break; - pdcch_received = 1; - break; + case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: + AssertFatal(pdcch_received == 0, "pdcch_received is not 0, we can only handle one PDCCH PDU per slot\n"); + msgTx->pdcch_pdu = dl_tti_pdu->pdcch_pdu; - case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: - LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); - handle_nfapi_nr_csirs_pdu(msgTx,frame,slot, - &dl_tti_pdu->csi_rs_pdu); - break; + pdcch_received = 1; + break; - case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE: - LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdu->pdsch_pdu.pdsch_pdu_rel15; - uint16_t pduIndex = pdsch_pdu_rel15->pduIndex; - AssertFatal(TX_req->pdu_list[pduIndex].num_TLV == 1, "TX_req->pdu_list[%d].num_TLV %d != 1\n", - pduIndex,TX_req->pdu_list[pduIndex].num_TLV); - uint8_t *sdu = (uint8_t *)TX_req->pdu_list[pduIndex].TLVs[0].value.direct; - AssertFatal(msgTx->num_pdsch_slot < gNB->number_of_nr_dlsch_max,"Number of PDSCH PDUs %d exceeded the limit %d\n", - msgTx->num_pdsch_slot,gNB->number_of_nr_dlsch_max); - handle_nr_nfapi_pdsch_pdu(msgTx,&dl_tti_pdu->pdsch_pdu, sdu); + case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: + LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); + handle_nfapi_nr_csirs_pdu(msgTx,frame,slot, + &dl_tti_pdu->csi_rs_pdu); + break; + + case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE: + LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); + nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdu->pdsch_pdu.pdsch_pdu_rel15; + uint16_t pduIndex = pdsch_pdu_rel15->pduIndex; + AssertFatal(TX_req->pdu_list[pduIndex].num_TLV == 1, "TX_req->pdu_list[%d].num_TLV %d != 1\n", + pduIndex,TX_req->pdu_list[pduIndex].num_TLV); + uint8_t *sdu = (uint8_t *)TX_req->pdu_list[pduIndex].TLVs[0].value.direct; + AssertFatal(msgTx->num_pdsch_slot < gNB->number_of_nr_dlsch_max,"Number of PDSCH PDUs %d exceeded the limit %d\n", + msgTx->num_pdsch_slot,gNB->number_of_nr_dlsch_max); + handle_nr_nfapi_pdsch_pdu(msgTx,&dl_tti_pdu->pdsch_pdu, sdu); + } } + + if (number_ul_dci_pdu > 0) + msgTx->ul_pdcch_pdu = UL_dci_req->ul_dci_pdu_list[number_ul_dci_pdu-1]; // copy the last pdu + + pushNotifiedFIFO(gNB->L1_tx_filled,res); } - if (number_ul_dci_pdu > 0) - msgTx->ul_pdcch_pdu = UL_dci_req->ul_dci_pdu_list[number_ul_dci_pdu-1]; // copy the last pdu - - pushNotifiedFIFO(gNB->resp_L1_tx,res); - for (int i = 0; i < number_ul_tti_pdu; i++) { switch (UL_tti_req->pdus_list[i].pdu_type) { case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE: From 348c4ed36f6974ec90fa7c9ea8a4ad87815c3e47 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Sun, 5 Dec 2021 20:26:24 +0530 Subject: [PATCH 02/13] Changing a log msg to debug --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 1685e206ae..04366d40b2 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -263,7 +263,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0,0); //dumpsig=1; } else { - LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, ndi %d, status %d, round %d, RV %d, prb_start %d, prb_size %d, TBS %d) r %d\n", + LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, ndi %d, status %d, round %d, RV %d, prb_start %d, prb_size %d, TBS %d) r %d\n", gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, rdata->harq_pid, pusch_pdu->pusch_data.new_data_indicator, ulsch_harq->status, ulsch_harq->round, From 951d1242d7eabe1777e106a33b29f6f51ad05dbf Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Wed, 8 Dec 2021 16:40:46 +0100 Subject: [PATCH 03/13] remove async ru_tx_func and simplify --- executables/nr-gnb.c | 86 ++++++++++++++++------------------------- executables/nr-ru.c | 2 - openair1/PHY/defs_gNB.h | 1 - 3 files changed, 33 insertions(+), 56 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index dfea55e325..c2906617b0 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -366,55 +366,43 @@ void *nrL1_stats_thread(void *param) { // two parallel L1 tx threads. void *tx_reorder_thread(void* param) { PHY_VARS_gNB *gNB = (PHY_VARS_gNB *)param; - notifiedFIFO_elt_t *resL1; - notifiedFIFO_elt_t *resL1Reserve = NULL; - notifiedFIFO_elt_t *resRU; - processingData_L1tx_t *syncMsgL1; - processingData_RU_t *syncMsgRU; + notifiedFIFO_elt_t *resL1Reserve = NULL; + + resL1Reserve=pullTpool(gNB->L1_tx_out, gNB->threadPool); + int next_tx_slot=((processingData_L1tx_t *)NotifiedFifoData(resL1Reserve))->slot; + while (!oai_exit) { - // check if there is a message in reserve + notifiedFIFO_elt_t *resL1; if (resL1Reserve) { - syncMsgL1 = (processingData_L1tx_t *)NotifiedFifoData(resL1Reserve); - if (syncMsgL1->slot == gNB->next_tx_slot) { - resRU = pullTpool(gNB->resp_RU_tx, gNB->threadPool); - // processing of last ru_tx_func finished - syncMsgRU = (processingData_RU_t *)NotifiedFifoData(resRU); - syncMsgRU->frame_tx = syncMsgL1->frame; - syncMsgRU->slot_tx = syncMsgL1->slot; - syncMsgRU->timestamp_tx = syncMsgL1->timestamp_tx; - syncMsgRU->ru = gNB->RU_list[0]; - resRU->key = syncMsgL1->slot; - gNB->next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU->frame_tx, syncMsgRU->slot_tx); - pushNotifiedFIFO(gNB->L1_tx_free, resL1Reserve); - pushTpool(gNB->threadPool, resRU); - resL1Reserve = NULL; - } else { -#if DEBUG_THREADS - printf("Waiting for reserve L1 Tx message to be sent to RU for slot %d\n", syncMsgL1->slot); -#endif - } - } - // pull message from output FIFO of tx_func - resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); - syncMsgL1 = (processingData_L1tx_t *)NotifiedFifoData(resL1); - - if (syncMsgL1->slot == gNB->next_tx_slot) { - resRU = pullTpool(gNB->resp_RU_tx, gNB->threadPool); - // processing of last ru_tx_func finished - syncMsgRU = (processingData_RU_t *)NotifiedFifoData(resRU); - syncMsgRU->frame_tx = syncMsgL1->frame; - syncMsgRU->slot_tx = syncMsgL1->slot; - syncMsgRU->timestamp_tx = syncMsgL1->timestamp_tx; - syncMsgRU->ru = gNB->RU_list[0]; - resRU->key = syncMsgL1->slot; - gNB->next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU->frame_tx, syncMsgRU->slot_tx); - pushNotifiedFIFO(gNB->L1_tx_free, resL1); - pushTpool(gNB->threadPool, resRU); - } else { - AssertFatal(resL1Reserve == NULL, "Error! There is already a waiting message\n"); - resL1Reserve = resL1; + resL1=resL1Reserve; + if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { + LOG_E(PHY,"order mistake"); + resL1Reserve=NULL; + resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + } + } else { + resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { + if (resL1Reserve) + LOG_E(PHY,"error, have a stored packet, then a second one\n"); + resL1Reserve=resL1; + resL1 = pullTpool(gNB->L1_tx_out, gNB->threadPool); + if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) + LOG_E(PHY,"error, pull two msg, none is good\n"); + } } + processingData_L1tx_t *syncMsgL1= (processingData_L1tx_t *)NotifiedFifoData(resL1); + processingData_RU_t syncMsgRU; + syncMsgRU.frame_tx = syncMsgL1->frame; + syncMsgRU.slot_tx = syncMsgL1->slot; + syncMsgRU.timestamp_tx = syncMsgL1->timestamp_tx; + syncMsgRU.ru = gNB->RU_list[0]; + next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, syncMsgRU.frame_tx, syncMsgRU.slot_tx); + pushNotifiedFIFO(gNB->L1_tx_free, resL1); + if (resL1==resL1Reserve) + resL1Reserve=NULL; + ru_tx_func((void*)&syncMsgRU); } return(NULL); } @@ -473,14 +461,6 @@ void init_gNB_Tpool(int inst) { gNB->phy_proc_tx_1 = &msgDataTx->phy_proc_tx; pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning - // RU TX result FIFO - gNB->resp_RU_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_RU_tx); - notifiedFIFO_elt_t *msgRUTx = newNotifiedFIFO_elt(sizeof(processingData_RU_t),0,gNB->resp_RU_tx,ru_tx_func); - int first_tx_slot = sf_ahead*gNB->frame_parms.slots_per_subframe; - pushNotifiedFIFO(gNB->resp_RU_tx,msgRUTx); // to unblock the process in the beginning - gNB->next_tx_slot = get_next_downlink_slot(gNB, &gNB->gNB_config, 0, first_tx_slot-1); - threadCreate(&proc->L1_stats_thread,nrL1_stats_thread,(void*)gNB,"L1_stats",-1,OAI_PRIORITY_RT_LOW); threadCreate(&proc->pthread_tx_reorder, tx_reorder_thread, (void *)gNB, "thread_tx_reorder", -1, OAI_PRIORITY_RT_MAX); } diff --git a/executables/nr-ru.c b/executables/nr-ru.c index b749928b37..76051945e7 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1449,8 +1449,6 @@ void *ru_thread( void *param ) { delNotifiedFIFO_elt(res); res = pullNotifiedFIFO(gNB->L1_tx_free); delNotifiedFIFO_elt(res); - res = pullNotifiedFIFO(gNB->resp_RU_tx); - delNotifiedFIFO_elt(res); ru_thread_status = 0; return &ru_thread_status; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index d309990ed0..6202cc72cd 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -906,7 +906,6 @@ typedef struct PHY_VARS_gNB_s { tpool_t *threadPool; int nbDecode; uint8_t pusch_proc_threads; - int next_tx_slot; int number_of_nr_dlsch_max; int number_of_nr_ulsch_max; void * scopeData; From c33c8aa836d5d2aa1a14ba9bd0b5b2dda0fd20f6 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 14 Dec 2021 12:52:22 +0100 Subject: [PATCH 04/13] merge develop, some minor code review updates --- common/config/config_load_configmodule.c | 2 +- openair1/PHY/TOOLS/nr_phy_scope.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 740c6e240b..8559a5da8a 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -249,7 +249,7 @@ configmodule_interface_t *load_configmodule(int argc, } cfgptr = calloc(sizeof(configmodule_interface_t),1); - cfgptr->argv_info = calloc(sizeof(int32_t), argc); + cfgptr->argv_info = calloc(sizeof(int32_t), argc+10); cfgptr->argv_info[0] |= CONFIG_CMDLINEOPT_PROCESSED; if (OoptIdx >= 0) { diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 3440e4f28c..bf58c660c8 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -33,7 +33,6 @@ #define ScaleZone 4 #define localBuff(NaMe,SiZe) float NaMe[SiZe]; memset(NaMe,0,sizeof(NaMe)); -int otg_enabled; const FL_COLOR rx_antenna_colors[4] = {FL_RED,FL_BLUE,FL_GREEN,FL_YELLOW}; const FL_COLOR water_colors[4] = {FL_BLUE,FL_GREEN,FL_YELLOW,FL_RED}; From b1b6c1862463612113ea02787cb11010e18f51d7 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 14 Dec 2021 17:28:27 +0100 Subject: [PATCH 05/13] add doc --- doc/SW_archi.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/doc/SW_archi.md b/doc/SW_archi.md index e5856d63bc..7242c5c0a3 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -18,6 +18,69 @@ body { +flowchart TB + A[ru_thread] --> RFin>block rx_rf] --> feprx + feprx --> half-slot --> end_feprx + feprx --> second-thread -- block_end_feprx --> end_feprx>feprx] + end_feprx --> rx_nr_prach_ru +rx_nr_prach_ru -- block_queue --> resp_L1>resp L1] +resp_L1 -- async launch --> rx_func +resp_L1 -- immediate return --> RFin + +subgraph rxfunc +rx_func_implem[rx_func] + subgraph rxfuncbeg + handle_nr_slot_ind + --> rnti_to_remove-mgmt + --> L1_nr_prach_procedures + --> apply_nr_rotation_ul + end + subgraph phy_procedures_gNB_uespec_RX + fill_ul_rb_mask + --> pucch(decode each gNB->pucch) + -->nr_fill_ul_indication + --> nr_ulsch_procedures + --> nr_ulsch_decoding + --> segInParallel[[all segments decode in parallel]] + --> barrier_end_of_ulsch_decoding + end + subgraph NR_UL_indication + handle_nr_rach + --> handle_nr_uci + --> handle_nr_ulsch + --> gNB_dlsch_ulsch_scheduler + --> NR_Schedule_response + end + rx_func_implem --> rxfuncbeg + rxfuncbeg --> phy_procedures_gNB_uespec_RX +phy_procedures_gNB_uespec_RX --> NR_UL_indication +-- block_queue --> L1_tx_free2>L1 tx free] +-- async launch --> tx_func +L1_tx_free2 -- send_msg --> rsp((resp_L1)) +end +rx_func --> rxfunc + + +subgraph tx + direction LR + subgraph tx_func2 + phy_procedures_gNB_TX + --> dcitop[nr_generate dci top] + --> nr_generate_csi_rs + --> apply_nr_rotation + -- send_msg --> end_tx_func((L1_tx_out)) + end + subgraph tx_reorder_thread + L1_tx_out>L1_tx_out] + --> reorder{re order} --> reorder + reorder --> ru_tx_func + reorder --> L1_tx_free((L1_tx_free)) + ru_tx_func --> feptx_prec + --> feptx_ofdm + end + tx_func2 --> tx_reorder_thread +end + This tuto for 5G gNB design, with Open Cells main {: .text-center} From f522cf2b4e9da7ade0074f6bce8f5d569a7bf011 Mon Sep 17 00:00:00 2001 From: Thomas Laurent Date: Tue, 14 Dec 2021 16:30:18 +0000 Subject: [PATCH 06/13] Update SW_archi.md --- doc/SW_archi.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/SW_archi.md b/doc/SW_archi.md index 7242c5c0a3..2a015c1aef 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -17,7 +17,7 @@ body { - +```mermaid flowchart TB A[ru_thread] --> RFin>block rx_rf] --> feprx feprx --> half-slot --> end_feprx @@ -80,6 +80,7 @@ subgraph tx end tx_func2 --> tx_reorder_thread end +``` This tuto for 5G gNB design, with Open Cells main {: .text-center} From f3fb44f703b78770439f1a67d3ab5ff96c36d937 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 14 Dec 2021 17:35:19 +0100 Subject: [PATCH 07/13] add sw graph --- doc/SW-archi-graph.md | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 doc/SW-archi-graph.md diff --git a/doc/SW-archi-graph.md b/doc/SW-archi-graph.md new file mode 100644 index 0000000000..8a14c38cfa --- /dev/null +++ b/doc/SW-archi-graph.md @@ -0,0 +1,64 @@ +```mermaid +flowchart TB + A[ru_thread] --> RFin>block rx_rf] --> feprx + feprx --> half-slot --> end_feprx + feprx --> second-thread -- block_end_feprx --> end_feprx>feprx] + end_feprx --> rx_nr_prach_ru +rx_nr_prach_ru -- block_queue --> resp_L1>resp L1] +resp_L1 -- async launch --> rx_func +resp_L1 -- immediate return --> RFin + +subgraph rxfunc +rx_func_implem[rx_func] + subgraph rxfuncbeg + handle_nr_slot_ind + --> rnti_to_remove-mgmt + --> L1_nr_prach_procedures + --> apply_nr_rotation_ul + end + subgraph phy_procedures_gNB_uespec_RX + fill_ul_rb_mask + --> pucch(decode each gNB->pucch) + -->nr_fill_ul_indication + --> nr_ulsch_procedures + --> nr_ulsch_decoding + --> segInParallel[[all segments decode in parallel]] + --> barrier_end_of_ulsch_decoding + end + subgraph NR_UL_indication + handle_nr_rach + --> handle_nr_uci + --> handle_nr_ulsch + --> gNB_dlsch_ulsch_scheduler + --> NR_Schedule_response + end + rx_func_implem --> rxfuncbeg + rxfuncbeg --> phy_procedures_gNB_uespec_RX +phy_procedures_gNB_uespec_RX --> NR_UL_indication +-- block_queue --> L1_tx_free2>L1 tx free] +-- async launch --> tx_func +L1_tx_free2 -- send_msg --> rsp((resp_L1)) +end +rx_func --> rxfunc + + +subgraph tx + direction LR + subgraph tx_func2 + phy_procedures_gNB_TX + --> dcitop[nr_generate dci top] + --> nr_generate_csi_rs + --> apply_nr_rotation + -- send_msg --> end_tx_func((L1_tx_out)) + end + subgraph tx_reorder_thread + L1_tx_out>L1_tx_out] + --> reorder{re order} --> reorder + reorder --> ru_tx_func + reorder --> L1_tx_free((L1_tx_free)) + ru_tx_func --> feptx_prec + --> feptx_ofdm + end + tx_func2 --> tx_reorder_thread +end +``` From b2b3dd1331ed7821c6d0972035bd511e37b31f66 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 16 Dec 2021 12:59:17 +0100 Subject: [PATCH 08/13] gNBthread flow update --- doc/SW-archi-graph.md | 29 +++++++++++----- executables/nr-gnb.c | 33 ++++++++----------- .../nfapi/public_inc/fapi_nr_ue_interface.h | 4 +-- openair1/PHY/defs_gNB.h | 3 +- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 4 +-- openair1/SIMULATION/NR_PHY/dlsim.c | 4 +-- openair1/SIMULATION/NR_PHY/ulsim.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 14 ++++---- 8 files changed, 49 insertions(+), 44 deletions(-) diff --git a/doc/SW-archi-graph.md b/doc/SW-archi-graph.md index 8a14c38cfa..e8b0cdc0d7 100644 --- a/doc/SW-archi-graph.md +++ b/doc/SW-archi-graph.md @@ -4,7 +4,7 @@ flowchart TB feprx --> half-slot --> end_feprx feprx --> second-thread -- block_end_feprx --> end_feprx>feprx] end_feprx --> rx_nr_prach_ru -rx_nr_prach_ru -- block_queue --> resp_L1>resp L1] +rx_nr_prach_ru -- block_queue_singleton --> resp_L1>resp L1] resp_L1 -- async launch --> rx_func resp_L1 -- immediate return --> RFin @@ -29,24 +29,35 @@ rx_func_implem[rx_func] handle_nr_rach --> handle_nr_uci --> handle_nr_ulsch - --> gNB_dlsch_ulsch_scheduler - --> NR_Schedule_response + subgraph gNB_dlsch_ulsch_scheduler + run_pdcp + --> nr_rrc_trigger + --> schedule_xxxx + end + handle_nr_ulsch --> gNB_dlsch_ulsch_scheduler + subgraph NR_Schedule_response + L1_tx_free3>L1_tx_free] + --> handle_dl_fapi + --> sendTxFilled((L1_tx_filled)) + --> handle_ul_nfapi + + end + gNB_dlsch_ulsch_scheduler --> NR_Schedule_response end rx_func_implem --> rxfuncbeg rxfuncbeg --> phy_procedures_gNB_uespec_RX phy_procedures_gNB_uespec_RX --> NR_UL_indication --- block_queue --> L1_tx_free2>L1 tx free] +-- block_queue_block_PNF_monolithic --> L1_tx_free2>L1 tx filled] -- async launch --> tx_func L1_tx_free2 -- send_msg --> rsp((resp_L1)) end rx_func --> rxfunc -subgraph tx +subgraph tx_func direction LR - subgraph tx_func2 - phy_procedures_gNB_TX - --> dcitop[nr_generate dci top] + subgraph phy_procedures_gNB_TX + dcitop[nr_generate dci top] --> nr_generate_csi_rs --> apply_nr_rotation -- send_msg --> end_tx_func((L1_tx_out)) @@ -59,6 +70,6 @@ subgraph tx ru_tx_func --> feptx_prec --> feptx_ofdm end - tx_func2 --> tx_reorder_thread end + ``` diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 60239576e4..ff018b5452 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -303,8 +303,8 @@ void rx_func(void *param) { } static void dump_L1_meas_stats(PHY_VARS_gNB *gNB, RU_t *ru, char *output) { int stroff = 0; - stroff += print_meas_log(gNB->phy_proc_tx_0, "L1 Tx processing thread 0", NULL, NULL, output); - stroff += print_meas_log(gNB->phy_proc_tx_1, "L1 Tx processing thread 1", NULL, NULL, output+stroff); + stroff += print_meas_log(gNB->phy_proc_tx[0], "L1 Tx processing thread 0", NULL, NULL, output); + stroff += print_meas_log(gNB->phy_proc_tx[1], "L1 Tx processing thread 1", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->dlsch_encoding_stats, "DLSCH encoding", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->phy_proc_rx, "L1 Rx processing", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->ul_indication_stats, "UL Indication", NULL, NULL, output+stroff); @@ -339,8 +339,8 @@ void *nrL1_stats_thread(void *param) { fd=fopen("nrL1_stats.log","w"); AssertFatal(fd!=NULL,"Cannot open nrL1_stats.log\n"); - reset_meas(gNB->phy_proc_tx_0); - reset_meas(gNB->phy_proc_tx_1); + reset_meas(gNB->phy_proc_tx[0]); + reset_meas(gNB->phy_proc_tx[1]); reset_meas(&gNB->dlsch_encoding_stats); reset_meas(&gNB->phy_proc_rx); reset_meas(&gNB->ul_indication_stats); @@ -444,22 +444,17 @@ void init_gNB_Tpool(int inst) { initNotifiedFIFO(gNB->L1_tx_free); initNotifiedFIFO(gNB->L1_tx_filled); initNotifiedFIFO(gNB->L1_tx_out); + // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); - processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); - init_DLSCH_struct(gNB, msgDataTx); - memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); - reset_meas(&msgDataTx->phy_proc_tx); - gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; - pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning - - msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); - msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); - init_DLSCH_struct(gNB, msgDataTx); - memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); - reset_meas(&msgDataTx->phy_proc_tx); - gNB->phy_proc_tx_1 = &msgDataTx->phy_proc_tx; - pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning + for (int i=0; i < 2; i++) { + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); + processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); + init_DLSCH_struct(gNB, msgDataTx); + memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); + reset_meas(&msgDataTx->phy_proc_tx); + gNB->phy_proc_tx[i] = &msgDataTx->phy_proc_tx; + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning + } threadCreate(&proc->L1_stats_thread,nrL1_stats_thread,(void*)gNB,"L1_stats",-1,OAI_PRIORITY_RT_LOW); threadCreate(&proc->pthread_tx_reorder, tx_reorder_thread, (void *)gNB, "thread_tx_reorder", -1, OAI_PRIORITY_RT_MAX); diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 0e923931ad..798141f9ca 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -346,8 +346,8 @@ typedef struct { } fapi_nr_ul_config_request_pdu_t; typedef struct { - uint16_t sfn; - uint16_t slot; + //uint16_t sfn; + //uint16_t slot; uint8_t number_pdus; fapi_nr_ul_config_request_pdu_t ul_config_list[FAPI_NR_UL_CONFIG_LIST_NUM]; pthread_mutex_t mutex_ul_config; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 6202cc72cd..a259a0a008 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -860,8 +860,7 @@ typedef struct PHY_VARS_gNB_s { /* time_stats_t phy_proc; */ - time_stats_t *phy_proc_tx_0; - time_stats_t *phy_proc_tx_1; + time_stats_t *phy_proc_tx[2]; time_stats_t phy_proc_rx; time_stats_t rx_prach; /* diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 7cf22db1a9..1df5c84efa 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -235,8 +235,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ } if (scheduled_response->tx_request) scheduled_response->tx_request->number_of_pdus = 0; - ul_config->sfn = 0; - ul_config->slot = 0; + //ul_config->sfn = 0; + //ul_config->slot = 0; ul_config->number_pdus = 0; memset(ul_config->ul_config_list, 0, sizeof(ul_config->ul_config_list)); pthread_mutex_unlock(&ul_config->mutex_ul_config); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 50e21ac02b..df07d8b7d3 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -978,7 +978,7 @@ int main(int argc, char **argv) msgDataTx->frame = frame; memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); reset_meas(&msgDataTx->phy_proc_tx); - gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; + gNB->phy_proc_tx[0] = &msgDataTx->phy_proc_tx; pushTpool(gNB->threadPool,msgL1Tx); for (SNR = snr0; SNR < snr1; SNR += .2) { @@ -1294,7 +1294,7 @@ int main(int argc, char **argv) msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3, msgDataTx->dlsch[0][0]->harq_process.K, msgDataTx->dlsch[0][0]->harq_process.K/((msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10)); - printDistribution(gNB->phy_proc_tx_0,table_tx,"PHY proc tx"); + printDistribution(gNB->phy_proc_tx[0],table_tx,"PHY proc tx"); printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time"); printStatIndent3(&gNB->dlsch_segmentation_stats,"DLSCH segmentation time"); printStatIndent3(&gNB->tinput,"DLSCH LDPC input processing time"); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index a7075eb218..2237f2db2b 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -670,7 +670,7 @@ int main(int argc, char **argv) notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,NULL); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); msgDataTx->slot = -1; - gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx; + gNB->phy_proc_tx[0] = &msgDataTx->phy_proc_tx; pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning //gNB_config = &gNB->gNB_config; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 911d051ed5..9a880ecbd8 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -61,11 +61,11 @@ static ssb_list_info_t ssb_list; void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx, uint8_t pdu_type){ ul_config->ul_config_list[ul_config->number_pdus].pdu_type = pdu_type; - ul_config->slot = slot_tx; - ul_config->sfn = frame_tx; + //ul_config->slot = slot_tx; + //ul_config->sfn = frame_tx; ul_config->number_pdus++; - LOG_D(NR_MAC, "In %s: Set config request for UL transmission in [%d.%d], number of UL PDUs: %d\n", __FUNCTION__, ul_config->sfn, ul_config->slot, ul_config->number_pdus); + LOG_D(NR_MAC, "In %s: Set config request for UL transmission in [%d.%d], number of UL PDUs: %d\n", __FUNCTION__, frame_tx, slot_tx, ul_config->number_pdus); } @@ -947,15 +947,15 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in // AND if a UL grant (UL DCI or Msg3) has been received (as indicated by num_pdus) if (ul_config){ pthread_mutex_lock(&ul_config->mutex_ul_config); - if ((ul_info->slot_tx == ul_config->slot && ul_info->frame_tx == ul_config->sfn) && ul_config->number_pdus > 0){ + if (/*(ul_info->slot_tx == ul_config->slot && ul_info->frame_tx == ul_config->sfn) && */ ul_config->number_pdus > 0){ - LOG_D(NR_MAC, "In %s:[%d.%d]: number of UL PDUs: %d with UL transmission in [%d.%d]\n", __FUNCTION__, frame_tx, slot_tx, ul_config->number_pdus, ul_config->sfn, ul_config->slot); + LOG_D(NR_MAC, "In %s:[%d.%d]: number of UL PDUs: %d with UL transmission\n", __FUNCTION__, frame_tx, slot_tx, ul_config->number_pdus); uint8_t ulsch_input_buffer_array[NFAPI_MAX_NUM_UL_PDU][MAX_ULSCH_PAYLOAD_BYTES]; nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; - tx_req.slot = slot_tx; - tx_req.sfn = frame_tx; + //tx_req.slot = slot_tx; + //tx_req.sfn = frame_tx; tx_req.number_of_pdus = 0; for (int j = 0; j < ul_config->number_pdus; j++) { From e0776377c4fb1142dff594cb25c2258b451e1d29 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 16 Dec 2021 17:18:50 +0100 Subject: [PATCH 09/13] fix phy simulators with updated threads synchro --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 2 ++ openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 2 ++ openair1/SIMULATION/NR_PHY/dlsim.c | 14 +++++++++----- openair1/SIMULATION/NR_PHY/ulsim.c | 12 ++++++++---- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 10 +++++++--- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 798141f9ca..4140c714a2 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -348,6 +348,8 @@ typedef struct { typedef struct { //uint16_t sfn; //uint16_t slot; + uint16_t sfn; + uint16_t slot; uint8_t number_pdus; fapi_nr_ul_config_request_pdu_t ul_config_list[FAPI_NR_UL_CONFIG_LIST_NUM]; pthread_mutex_t mutex_ul_config; diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 1df5c84efa..9e81531c42 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -237,6 +237,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ scheduled_response->tx_request->number_of_pdus = 0; //ul_config->sfn = 0; //ul_config->slot = 0; + ul_config->sfn = 0; + ul_config->slot = 0; ul_config->number_pdus = 0; memset(ul_config->ul_config_list, 0, sizeof(ul_config->ul_config_list)); pthread_mutex_unlock(&ul_config->mutex_ul_config); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index df07d8b7d3..054d7d2b21 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -968,10 +968,14 @@ int main(int argc, char **argv) gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); char tp_param[] = "n"; initTpool(tp_param, gNB->threadPool, true); - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); - // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,processSlotTX); + gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->L1_tx_free); + initNotifiedFIFO(gNB->L1_tx_filled); + initNotifiedFIFO(gNB->L1_tx_out); + // we create 1 single msg for L1 tx processing (instead of 2 in full gNB) + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_free,processSlotTX); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); init_DLSCH_struct(gNB, msgDataTx); msgDataTx->slot = slot; @@ -979,7 +983,6 @@ int main(int argc, char **argv) memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); reset_meas(&msgDataTx->phy_proc_tx); gNB->phy_proc_tx[0] = &msgDataTx->phy_proc_tx; - pushTpool(gNB->threadPool,msgL1Tx); for (SNR = snr0; SNR < snr1; SNR += .2) { @@ -1058,6 +1061,7 @@ int main(int argc, char **argv) Sched_INFO.UL_tti_req = gNB_mac->UL_tti_req_ahead[slot]; Sched_INFO.UL_dci_req = NULL; Sched_INFO.TX_req = &gNB_mac->TX_req[0]; + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); nr_schedule_response(&Sched_INFO); /* PTRS values for DLSIM calculations */ diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 2237f2db2b..43cdb2a068 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -665,13 +665,16 @@ int main(int argc, char **argv) char tp_param[] = "n"; initTpool(tp_param, gNB->threadPool, false); initNotifiedFIFO(gNB->respDecode); - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,NULL); + gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->L1_tx_free); + initNotifiedFIFO(gNB->L1_tx_filled); + initNotifiedFIFO(gNB->L1_tx_out); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_free,NULL); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); msgDataTx->slot = -1; gNB->phy_proc_tx[0] = &msgDataTx->phy_proc_tx; - pushNotifiedFIFO(gNB->resp_L1_tx,msgL1Tx); // to unblock the process in the beginning //gNB_config = &gNB->gNB_config; //memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO)); @@ -1117,6 +1120,7 @@ int main(int argc, char **argv) } // prepare ULSCH/PUSCH reception + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); // to unblock the process in the beginning nr_schedule_response(Sched_INFO); // --------- setting parameters for UE -------- diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 9a880ecbd8..6707a6cd80 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -63,9 +63,11 @@ void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, in ul_config->ul_config_list[ul_config->number_pdus].pdu_type = pdu_type; //ul_config->slot = slot_tx; //ul_config->sfn = frame_tx; + ul_config->slot = slot_tx; + ul_config->sfn = frame_tx; ul_config->number_pdus++; - LOG_D(NR_MAC, "In %s: Set config request for UL transmission in [%d.%d], number of UL PDUs: %d\n", __FUNCTION__, frame_tx, slot_tx, ul_config->number_pdus); + LOG_D(NR_MAC, "In %s: Set config request for UL transmission in [%d.%d], number of UL PDUs: %d\n", __FUNCTION__, ul_config->sfn, ul_config->slot, ul_config->number_pdus); } @@ -947,15 +949,17 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in // AND if a UL grant (UL DCI or Msg3) has been received (as indicated by num_pdus) if (ul_config){ pthread_mutex_lock(&ul_config->mutex_ul_config); - if (/*(ul_info->slot_tx == ul_config->slot && ul_info->frame_tx == ul_config->sfn) && */ ul_config->number_pdus > 0){ + if ((ul_info->slot_tx == ul_config->slot && ul_info->frame_tx == ul_config->sfn) && ul_config->number_pdus > 0){ - LOG_D(NR_MAC, "In %s:[%d.%d]: number of UL PDUs: %d with UL transmission\n", __FUNCTION__, frame_tx, slot_tx, ul_config->number_pdus); + LOG_D(NR_MAC, "In %s:[%d.%d]: number of UL PDUs: %d with UL transmission in [%d.%d]\n", __FUNCTION__, frame_tx, slot_tx, ul_config->number_pdus, ul_config->sfn, ul_config->slot); uint8_t ulsch_input_buffer_array[NFAPI_MAX_NUM_UL_PDU][MAX_ULSCH_PAYLOAD_BYTES]; nr_scheduled_response_t scheduled_response; fapi_nr_tx_request_t tx_req; //tx_req.slot = slot_tx; //tx_req.sfn = frame_tx; + tx_req.slot = slot_tx; + tx_req.sfn = frame_tx; tx_req.number_of_pdus = 0; for (int j = 0; j < ul_config->number_pdus; j++) { From bd8c2013de2f2f8932f8b07f457f4bb6c6001056 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Sat, 25 Dec 2021 12:29:02 +0100 Subject: [PATCH 10/13] fix typo --- openair2/GNB_APP/L1_nr_paramdef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/GNB_APP/L1_nr_paramdef.h b/openair2/GNB_APP/L1_nr_paramdef.h index 197b2a023b..6545408b9b 100644 --- a/openair2/GNB_APP/L1_nr_paramdef.h +++ b/openair2/GNB_APP/L1_nr_paramdef.h @@ -65,7 +65,7 @@ {CONFIG_STRING_L1_REMOTE_N_PORTC, NULL, 0, uptr:NULL, defintval:50030, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_LOCAL_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_REMOTE_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ -{CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:r43, TYPE_UINT, 0}, \ +{CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:4, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_OFDM_OFFSET_DIVISOR, NULL, 0, uptr:NULL, defuintval:8, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:100, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:150, TYPE_UINT, 0}, \ From 370af7bc1054404c459651fb05d1ca6a602280bf Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 6 Jan 2022 16:20:16 +0100 Subject: [PATCH 11/13] remove L1_tx_free queue pair of threads for a single one --- doc/SW-archi-graph.md | 6 +++--- executables/nr-gnb.c | 7 +++---- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 3 +++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/SW-archi-graph.md b/doc/SW-archi-graph.md index e8b0cdc0d7..8f8a6f6e5c 100644 --- a/doc/SW-archi-graph.md +++ b/doc/SW-archi-graph.md @@ -37,10 +37,10 @@ rx_func_implem[rx_func] handle_nr_ulsch --> gNB_dlsch_ulsch_scheduler subgraph NR_Schedule_response L1_tx_free3>L1_tx_free] - --> handle_dl_fapi + --> handle_nr_nfapi_xxx_pdu --> sendTxFilled((L1_tx_filled)) - --> handle_ul_nfapi - + --> nr_fill_ul_xxx + --> nr_fill_prach end gNB_dlsch_ulsch_scheduler --> NR_Schedule_response end diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index c630771599..0319f7f7a3 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -123,7 +123,6 @@ void tx_func(void *param) { } void rx_func(void *param) { - processingData_L1_t *info = (processingData_L1_t *) param; PHY_VARS_gNB *gNB = info->gNB; int frame_rx = info->frame_rx; @@ -303,7 +302,7 @@ void rx_func(void *param) { static void dump_L1_meas_stats(PHY_VARS_gNB *gNB, RU_t *ru, char *output) { int stroff = 0; stroff += print_meas_log(gNB->phy_proc_tx[0], "L1 Tx processing thread 0", NULL, NULL, output); - stroff += print_meas_log(gNB->phy_proc_tx[1], "L1 Tx processing thread 1", NULL, NULL, output+stroff); + //stroff += print_meas_log(gNB->phy_proc_tx[1], "L1 Tx processing thread 1", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->dlsch_encoding_stats, "DLSCH encoding", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->phy_proc_rx, "L1 Rx processing", NULL, NULL, output+stroff); stroff += print_meas_log(&gNB->ul_indication_stats, "UL Indication", NULL, NULL, output+stroff); @@ -339,7 +338,7 @@ void *nrL1_stats_thread(void *param) { AssertFatal(fd!=NULL,"Cannot open nrL1_stats.log\n"); reset_meas(gNB->phy_proc_tx[0]); - reset_meas(gNB->phy_proc_tx[1]); + //reset_meas(gNB->phy_proc_tx[1]); reset_meas(&gNB->dlsch_encoding_stats); reset_meas(&gNB->phy_proc_rx); reset_meas(&gNB->ul_indication_stats); @@ -445,7 +444,7 @@ void init_gNB_Tpool(int inst) { initNotifiedFIFO(gNB->L1_tx_out); // we create 2 threads for L1 tx processing - for (int i=0; i < 2; i++) { + for (int i=0; i < 1; i++) { notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,tx_func); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); init_DLSCH_struct(gNB, msgDataTx); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 792667d510..3154233243 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -128,6 +128,7 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, int frame, int slot, int do_meas) { + int aa; PHY_VARS_gNB *gNB = msgTx->gNB; NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; @@ -204,6 +205,8 @@ void phy_procedures_gNB_TX(processingData_L1tx_t *msgTx, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_TX+offset,0); + //pthread_mutex_unlock(&mutextest); + } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index ae52f8cc60..87c1dee1e5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -272,6 +272,7 @@ bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot) { void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frame, sub_frame_t slot){ + //pthread_mutex_lock(&mutextest); protocol_ctxt_t ctxt={0}; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); From 23b3a18fe8c9db7c2c3a767d3fa270d7d7e09bfa Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Tue, 11 Jan 2022 14:14:44 +0530 Subject: [PATCH 12/13] Removed conflict header and fixed dlsim --- openair1/SIMULATION/NR_PHY/dlsim.c | 31 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 9c0772bf48..6dc8dcfa4a 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -982,17 +982,21 @@ int main(int argc, char **argv) gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); initTpool(gNBthreads, gNB->threadPool, true); - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); - // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,processSlotTX); - processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); + gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->L1_tx_free); + initNotifiedFIFO(gNB->L1_tx_filled); + initNotifiedFIFO(gNB->L1_tx_out); + // we create 1 threads for L1 tx processing + processingData_L1tx_t *msgDataTx; + notifiedFIFO_elt_t *msgL1Tx; + msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_out,NULL); + msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); init_DLSCH_struct(gNB, msgDataTx); - msgDataTx->slot = slot; - msgDataTx->frame = frame; memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t)); reset_meas(&msgDataTx->phy_proc_tx); - gNB->phy_proc_tx[0] = &msgDataTx->phy_proc_tx; + gNB->phy_proc_tx[i] = &msgDataTx->phy_proc_tx; for (SNR = snr0; SNR < snr1; SNR += .2) { @@ -1071,7 +1075,7 @@ int main(int argc, char **argv) Sched_INFO.UL_tti_req = gNB_mac->UL_tti_req_ahead[slot]; Sched_INFO.UL_dci_req = NULL; Sched_INFO.TX_req = &gNB_mac->TX_req[0]; - pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); + pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx); nr_schedule_response(&Sched_INFO); /* PTRS values for DLSIM calculations */ @@ -1307,15 +1311,8 @@ int main(int argc, char **argv) if (print_perf==1) { printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d)\n", 1000>>*scc->ssbSubcarrierSpacing, g_rbSize, g_mcsIndex, -<<<<<<< HEAD - msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3, - msgDataTx->dlsch[0][0]->harq_process.K, - msgDataTx->dlsch[0][0]->harq_process.K/((msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10)); - printDistribution(gNB->phy_proc_tx[0],table_tx,"PHY proc tx"); -======= msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3); - printDistribution(gNB->phy_proc_tx_0,table_tx,"PHY proc tx"); ->>>>>>> 264e829922fc68e4caa3611b70d921c131e7ca68 + printDistribution(gNB->phy_proc_tx[0],table_tx,"PHY proc tx"); printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time"); printStatIndent3(&gNB->dlsch_segmentation_stats,"DLSCH segmentation time"); printStatIndent3(&gNB->tinput,"DLSCH LDPC input processing time"); From 2ccc7188e50a3efc73d693d418109ecd50ca2018 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 13 Jan 2022 14:39:56 +0100 Subject: [PATCH 13/13] fix regression in merge develop and some warnings --- .../install_external_packages.ubuntu20 | 3 ++- openair1/PHY/INIT/nr_init_ue.c | 1 + openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 4 ++-- openair1/SIMULATION/NR_PHY/dlsim.c | 22 +++++++++---------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cmake_targets/install_external_packages.ubuntu20 b/cmake_targets/install_external_packages.ubuntu20 index f0314ca575..f8b64980f6 100755 --- a/cmake_targets/install_external_packages.ubuntu20 +++ b/cmake_targets/install_external_packages.ubuntu20 @@ -24,6 +24,7 @@ # authors Laurent Thomas # ####################################### + if [ ! -f /etc/os-release ]; then echo "No /etc/os-release file found. You're likely on an unsupported distro." exit 1 @@ -483,7 +484,7 @@ if ! check_supported_distribution; then echo_error "Your distribution $(get_distribution_release) is not supported by oai !" exit 1 fi - +set_openair_env echo_info "Installing packages" check_install_ubuntu_packages diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index f664a03ba0..c193733aef 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -41,6 +41,7 @@ #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_REFSIG/nr_refsig.h" +#include #if 0 void phy_config_harq_ue(module_id_t Mod_id, diff --git a/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c index 82bb0a2659..e0cf694fff 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/pcfich_ue.c @@ -46,7 +46,7 @@ void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, uint32_t i; uint8_t reset; - uint32_t x1, x2, s=0; + uint32_t x1=0, x2=0, s=0; reset = 1; // x1 is set in lte_gold_generic diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index afd1fc6e0d..819fccc588 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -294,8 +294,8 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN); uint32_t A = rel15->TBSize[0]<<3; - if ( dlsch->rnti != SI_RNTI ) - trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, dlsch->rnti, frame, slot,0, 0); + if ( rel15->rnti != SI_RNTI) + trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, rel15->rnti, frame, slot,0, 0); NR_gNB_SCH_STATS_t *stats=NULL; int first_free=-1; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 9c0772bf48..5c64affd14 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -982,10 +982,15 @@ int main(int argc, char **argv) gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); initTpool(gNBthreads, gNB->threadPool, true); - gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - initNotifiedFIFO(gNB->resp_L1_tx); + // L1 TX result FIFO + gNB->L1_tx_free = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_filled = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + gNB->L1_tx_out = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); + initNotifiedFIFO(gNB->L1_tx_free); + initNotifiedFIFO(gNB->L1_tx_filled); + initNotifiedFIFO(gNB->L1_tx_out); // we create 2 threads for L1 tx processing - notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,processSlotTX); + notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->L1_tx_free,processSlotTX); processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx); init_DLSCH_struct(gNB, msgDataTx); msgDataTx->slot = slot; @@ -1305,17 +1310,10 @@ int main(int argc, char **argv) printf("\n"); if (print_perf==1) { - printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d)\n", + printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, block %d)\n", 1000>>*scc->ssbSubcarrierSpacing, g_rbSize, g_mcsIndex, -<<<<<<< HEAD - msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3, - msgDataTx->dlsch[0][0]->harq_process.K, - msgDataTx->dlsch[0][0]->harq_process.K/((msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10)); - printDistribution(gNB->phy_proc_tx[0],table_tx,"PHY proc tx"); -======= msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3); - printDistribution(gNB->phy_proc_tx_0,table_tx,"PHY proc tx"); ->>>>>>> 264e829922fc68e4caa3611b70d921c131e7ca68 + printDistribution(gNB->phy_proc_tx[0],table_tx,"PHY proc tx"); printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time"); printStatIndent3(&gNB->dlsch_segmentation_stats,"DLSCH segmentation time"); printStatIndent3(&gNB->tinput,"DLSCH LDPC input processing time");