diff --git a/.gitignore b/.gitignore index ff947966a2b9c7814a8ca64228810130cabe96f6..096b87d4b8bb9f7ab30c03deeb6f1a7021a98fa5 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ GPATH GRTAGS GTAGS tags + +# others +nfapi_nr_interface_scf diff --git a/ci-scripts/conf_files/ue.nfapi.conf b/ci-scripts/conf_files/ue.nfapi.conf index 3f227d573ce08d877303567177ace3a1fb3611b0..2b602cbcf292902e6702f134aeabfaa012956185 100644 --- a/ci-scripts/conf_files/ue.nfapi.conf +++ b/ci-scripts/conf_files/ue.nfapi.conf @@ -20,9 +20,9 @@ L1s = ( { num_cc = 1; tr_n_preference = "nfapi"; - local_n_if_name = "lo"; - remote_n_address = "127.0.0.1"; - local_n_address = "127.0.0.1"; + local_n_if_name = "ens3"; + remote_n_address = "CI_ENB_IP_ADDR"; + local_n_address = "CI_UE_IP_ADDR"; local_n_portc = 50000; remote_n_portc = 50001; local_n_portd = 50010; diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 8ba90fd5759152af693ba98bbeee5c7b8a33cf9f..ae878eb14d14a12cb3e504ce51b7398c226724c8 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -100,6 +100,7 @@ extern "C" { /* .log_format = 0x13 uncolored standard messages * .log_format = 0x93 colored standard messages */ /* keep white space in first position; switching it to 0 allows colors to be disabled*/ +#define LOG_WITH_COLORS 1 #if LOG_WITH_COLORS #define LOG_RED "\033[1;31m" /*!< \brief VT100 sequence for bold red foreground */ #define LOG_GREEN "\033[32m" /*!< \brief VT100 sequence for green foreground */ @@ -327,7 +328,7 @@ void flush_mem_to_file(void); void log_output_memory(const char *file, const char *func, int line, int comp, int level, const char* format,va_list args); int logInit_log_mem(void); void close_log_mem(void); - + typedef struct { char* buf_p; int buf_index; @@ -362,7 +363,7 @@ typedef struct { #define MATLAB_CSHORT_BRACKET1 13 #define MATLAB_CSHORT_BRACKET2 14 #define MATLAB_CSHORT_BRACKET3 15 - + int32_t write_file_matlab(const char *fname, const char *vname, void *data, int length, int dec, unsigned int format); /*----------------macro definitions for reading log configuration from the config module */ diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 71996cfd2989eb113a32acdae7ab2f0603f49d6c..6ffa62dd4d9ea159a4ed6b120ae7900d7dfe3203 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -252,8 +252,25 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t pthread_mutex_unlock(&gNB->UL_INFO_mutex); // RX processing - int tx_slot_type = nr_slot_select(cfg,frame_tx,slot_tx); - int rx_slot_type = nr_slot_select(cfg,frame_rx,slot_rx); + int tx_slot_type; int rx_slot_type; + if(NFAPI_MODE == NFAPI_MODE_VNF) { + if ((slot_tx==8) || (slot_rx==8) || (slot_tx==9) || (slot_rx==9) || (slot_tx==18) || (slot_rx==18) || (slot_tx==19) || (slot_rx==19)) { + tx_slot_type = NR_UPLINK_SLOT; + rx_slot_type = NR_UPLINK_SLOT; + } + else if ((slot_tx==7) || (slot_rx==7) || (slot_tx==17) || (slot_rx==17)) { + tx_slot_type = NR_MIXED_SLOT; + rx_slot_type = NR_MIXED_SLOT; + } + else { + tx_slot_type = NR_DOWNLINK_SLOT; + rx_slot_type = NR_DOWNLINK_SLOT; + } + } + else { + tx_slot_type = nr_slot_select(cfg,frame_tx,slot_tx); + rx_slot_type = nr_slot_select(cfg,frame_rx,slot_rx); + } if (rx_slot_type == NR_UPLINK_SLOT || rx_slot_type == NR_MIXED_SLOT) { // UE-specific RX processing for subframe n @@ -409,6 +426,14 @@ static void *gNB_L1_thread( void *param ) { int frame_tx = L1_proc->frame_tx; int slot_tx = L1_proc->slot_tx; uint64_t timestamp_tx = L1_proc->timestamp_tx; + if(NFAPI_MODE==NFAPI_MODE_VNF) + if (gNB->CC_id==0) { + int next_slot; + next_slot = (slot_rx + 1) % 20; + if (rxtx(gNB,frame_rx,next_slot,frame_tx,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 ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SLOT_NUMBER_TX0_GNB,slot_tx); diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 73421d8ed7c71fa9249bfff51cbc1afcd8bf9416..e768e84179f0bf1d6592e31c3f0a1c409549d91e 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -97,7 +97,8 @@ static int DEFBFW[] = {0x00007fff}; extern volatile int oai_exit; - +extern struct timespec timespec_sub(struct timespec lhs, struct timespec rhs); +extern struct timespec timespec_add(struct timespec lhs, struct timespec rhs); extern void nr_phy_free_RU(RU_t *); extern void nr_phy_config_request(NR_PHY_Config_t *gNB); #include "executables/thread-common.h" @@ -1541,9 +1542,35 @@ void *ru_thread( void *param ) { pthread_cond_signal(&proc->cond_FH1); // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + struct timespec slot_start; + clock_gettime(CLOCK_MONOTONIC, &slot_start); + + struct timespec slot_duration; + slot_duration.tv_sec = 0; + //slot_duration.tv_nsec = 0.5e6; + slot_duration.tv_nsec = 0.5e6; + + + while (!oai_exit) { // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. // They are set on the first rx/tx in the underly FH routines. + slot_start = timespec_add(slot_start,slot_duration); + struct timespec curr_time; + clock_gettime(CLOCK_MONOTONIC, &curr_time); + + struct timespec sleep_time; + + if((slot_start.tv_sec > curr_time.tv_sec) || (slot_start.tv_sec == curr_time.tv_sec && slot_start.tv_nsec > curr_time.tv_nsec)){ + sleep_time = timespec_sub(slot_start,curr_time); + + usleep(sleep_time.tv_nsec * 1e-3); + } + else{//continue + } + + // clock_gettime(CLOCK_MONOTONIC, &curr_time); + //printf("sfn:%d, slot:%d, start time %d.%d slot start %d.%d \n",frame,slot,curr_time.tv_sec,curr_time.tv_nsec,slot_start.tv_sec,slot_start.tv_nsec); if (slot==(fp->slots_per_frame-1)) { slot=0; frame++; diff --git a/nfapi/nrNFAPI.md b/nfapi/nrNFAPI.md index 299a43fd9320c807fcafe5cee6ea1989e75778f8..b78a205e84364727f204005753ee17ded75f21de 100644 --- a/nfapi/nrNFAPI.md +++ b/nfapi/nrNFAPI.md @@ -1,17 +1,24 @@ # Procedure to run nFAPI in 5G NR -## Conributed by 5G Testbed IISC -### Developers: Sudhakar B,Mahesh K,Gokul S,Aniq U.R +## Conributed by 5G Testbed IISc + +### Developers: Mahesh K,Gokul S,Aniq U R, Sai Shruthi N, Sudhakar B ## Procedure to Build gNB and UE The regular commands to build gNB and UE can be used ``` -sudo ./build_oai --gNB --UE +sudo ./build_oai --gNB --nrUE ``` ## Procedure to run NR nFAPI using RF-Simulator +### Bring up another loopback interface + +If running for the first time on your computer, or you have restarted your computer, bring up another loopback interface with this command: + +sudo ifconfig lo: 127.0.0.2 netmask 255.0.0.0 up + ### VNF command ``` sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band78.tm1.106PRB.nfapi.conf --nfapi 2 --noS1 --phy-test @@ -28,8 +35,10 @@ sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --rfsim --phy-test --rrc_config_path ``` ## Procedure to run NR nFAPI using Hardware -Will be updated as we have not yet currently tested on hardware + +To be updated. ## Notes -* In order to acheive the synchronization between VNF and PNF and receive the P7 messages within the timing window the order in which we should run the modules on different terminals is UE->VNF->PNF -* Currently only downlink is functional and working as we are still working on uplink functionality +* If running for the first time on local branch, run in the following order - VNF then PNF. This is so that necessary files are generated for the UE to run. Stop this run (it's ok if it stops on its own due to an error). From every subsequent run follow the next bullet. +* In order to achieve synchronization between the VNF and PNF, and receive P7 messages within the timing window, the order in which we should run the modules on different terminals is UE->VNF->PNF. +* Currently downlink transmission from gNB to UE is partially functional and we are working on improving this. Uplink P7 messages are disabled and we will work on uplink integration after completing downlink. diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 306b3ccb7b400c7bdf6450c830d9d9e40865174b..b313db8e5db533a23fdd1d68e933075f4ccb8896 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -1242,6 +1242,8 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu=&dl_tti_pdu_list[i]; memcpy(dl_tti_pdu,&dl_tti_pdu_list[i],sizeof(nfapi_nr_dl_tti_request_pdu_t)); int SFN=sfn+2; + //if(!&dl_tti_pdu->pdcch_pdu) + printf("interleaversize = %d, coreset_type = %d. \n",dl_tti_pdu->pdcch_pdu.pdcch_pdu_rel15.InterleaverSize,dl_tti_pdu->pdcch_pdu.pdcch_pdu_rel15.CoreSetType); handle_nfapi_nr_pdcch_pdu(gNB, SFN, slot, &dl_tti_pdu->pdcch_pdu); //dl_tti_pdu_list[i].pdcch_pdu.pdcch_pdu_rel15.numDlDci++; // ? // NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() pdcch_vars->num_dci:%d\n", __FUNCTION__, pdcch_vars->num_dci); diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 776eecf513193b9ff58f4863bdb6aa4f7adee47b..cc51dcda87b94c324b41d6bfec205c00fc084dcb 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -241,7 +241,7 @@ void oai_create_gnb(void) { int bodge_counter=0; PHY_VARS_gNB *gNB = RC.gNB[0]; RC.nb_nr_CC = (int *)malloc(sizeof(int)); // TODO: find a better function to place this in - + gNB->Mod_id = bodge_counter; gNB->CC_id = bodge_counter; gNB->abstraction_flag = 0; @@ -251,7 +251,7 @@ void oai_create_gnb(void) { if (gNB->if_inst==0) { gNB->if_inst = NR_IF_Module_init(bodge_counter); } - + // This will cause phy_config_request to be installed. That will result in RRC configuring the PHY // that will result in gNB->configured being set to TRUE. @@ -587,7 +587,7 @@ int phy_sync_indication(struct nfapi_vnf_p7_config *config, uint8_t sync) { printf("[VNF] SYNC %s\n", sync==1 ? "ACHIEVED" : "LOST"); if (sync==1 && nfapi_sync_var!=0) { - + printf("[VNF] Signal to OAI main code that it can go\n"); pthread_mutex_lock(&nfapi_sync_mutex); nfapi_sync_var=0; @@ -1285,7 +1285,7 @@ int nr_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_param_resp req->num_tlv++; } } -//TODO: Assign tag and value for P7 message offsets +//TODO: Assign tag and value for P7 message offsets req->nfapi_config.dl_tti_timing_offset.tl.tag = NFAPI_NR_NFAPI_DL_TTI_TIMING_OFFSET; req->nfapi_config.ul_tti_timing_offset.tl.tag = NFAPI_NR_NFAPI_UL_TTI_TIMING_OFFSET; req->nfapi_config.ul_dci_timing_offset.tl.tag = NFAPI_NR_NFAPI_UL_DCI_TIMING_OFFSET; @@ -1388,7 +1388,7 @@ int start_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_start_response_t pnf_info *pnf = vnf->pnfs; phy_info *phy = pnf->phys; vnf_p7_info *p7_vnf = vnf->p7_vnfs; - nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, phy->remote_port, phy->id); + nfapi_vnf_p7_add_pnf((p7_vnf->config), phy->remote_addr, htons(phy->remote_port), phy->id); return 0; } @@ -1486,7 +1486,7 @@ void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { config->vnf_ipv6 = 0; config->pnf_list = 0; config->phy_list = 0; - + config->pnf_nr_connection_indication = &pnf_nr_connection_indication_cb; config->pnf_disconnect_indication = &pnf_disconnection_indication_cb; @@ -1709,7 +1709,7 @@ int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req) { ul_tti_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! ul_tti_req->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST; - + int retval = nfapi_vnf_p7_ul_tti_req(p7_config, ul_tti_req); if (retval!=0) { diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index 7fbd509786dc0b981051b4b2438c43e90e8113bf..7f2959c39501825b053c50c254052d9f187e824b 100755 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -267,7 +267,7 @@ static uint8_t pack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppWritePac for(uint8_t i = 0; i < MAX_DCI_CORESET; ++i) { - if(!push16(value->dci_pdu[i].RNTI, ppWritePackedMsg, end) && + if(!(push16(value->dci_pdu[i].RNTI, ppWritePackedMsg, end) && push16(value->dci_pdu[i].ScramblingId, ppWritePackedMsg, end) && push16(value->dci_pdu[i].ScramblingRNTI, ppWritePackedMsg, end) && @@ -277,9 +277,9 @@ static uint8_t pack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppWritePac push8(value->dci_pdu[i].powerControlOffsetSS, ppWritePackedMsg, end) && push16(value->dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end) && - pusharray8(value->dci_pdu[i].Payload, DCI_PAYLOAD_BYTE_LEN, value->dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end)); - + pusharray8(value->dci_pdu[i].Payload, value->dci_pdu[i].PayloadSizeBits, value->dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end))) return 0; + } // TODO: resolve the packaging of array (currently sending a single element) @@ -307,6 +307,7 @@ static uint8_t pack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppWritePac static uint8_t pack_dl_tti_pdsch_pdu_rel15_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { + printf("packing pdsch pdu. \n"); nfapi_nr_dl_tti_pdsch_pdu_rel15_t* value = (nfapi_nr_dl_tti_pdsch_pdu_rel15_t*)tlv; // TODO: resolve the packaging of array (currently sending a single element) @@ -360,6 +361,7 @@ static uint8_t pack_dl_tti_pdsch_pdu_rel15_value(void* tlv, uint8_t **ppWritePac static uint8_t pack_dl_tti_ssb_pdu_rel15_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { + printf("Packing ssb. \n"); nfapi_nr_dl_tti_ssb_pdu_rel15_t* value = (nfapi_nr_dl_tti_ssb_pdu_rel15_t*)tlv; return( @@ -2045,7 +2047,7 @@ static uint8_t pack_ul_dci_pdu_list_value(void* tlv, uint8_t **ppWritePackedMsg, for(uint8_t i = 0; i < MAX_DCI_CORESET; ++i) { - if(!push16(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].RNTI, ppWritePackedMsg, end) && + if(!(push16(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].RNTI, ppWritePackedMsg, end) && push16(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].ScramblingId, ppWritePackedMsg, end) && push16(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].ScramblingRNTI, ppWritePackedMsg, end) && @@ -2056,7 +2058,7 @@ static uint8_t pack_ul_dci_pdu_list_value(void* tlv, uint8_t **ppWritePackedMsg, push8(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].powerControlOffsetSS, ppWritePackedMsg, end) && push16(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end) && - pusharray8(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].Payload, DCI_PAYLOAD_BYTE_LEN, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end)); + pusharray8(value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].Payload, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, ppWritePackedMsg, end))) return 0; } @@ -2076,7 +2078,9 @@ static uint8_t pack_ul_dci_pdu_list_value(void* tlv, uint8_t **ppWritePackedMsg, push8(value->pdcch_pdu.pdcch_pdu_rel15.RegBundleSize, ppWritePackedMsg, end) && push8(value->pdcch_pdu.pdcch_pdu_rel15.InterleaverSize, ppWritePackedMsg, end) && push8(value->pdcch_pdu.pdcch_pdu_rel15.CoreSetType, ppWritePackedMsg, end) && - push16(value->pdcch_pdu.pdcch_pdu_rel15.ShiftIndex, ppWritePackedMsg, end)); + push16(value->pdcch_pdu.pdcch_pdu_rel15.ShiftIndex, ppWritePackedMsg, end) && + push8(value->pdcch_pdu.pdcch_pdu_rel15.precoderGranularity, ppWritePackedMsg, end) && + push16(value->pdcch_pdu.pdcch_pdu_rel15.numDlDci, ppWritePackedMsg, end)); } @@ -3394,6 +3398,7 @@ int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packe { case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: result = pack_dl_tti_request(pMessageHeader, &pWritePackedMessage, end, config); + printf("result of pack dl_tti_req is %d. \n",result); break; case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: @@ -3749,12 +3754,12 @@ static uint8_t unpack_dl_tti_csi_rs_pdu_rel15_value(void* tlv, uint8_t **ppReadP static uint8_t unpack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) -{ +{ nfapi_nr_dl_tti_pdcch_pdu_rel15_t* value = (nfapi_nr_dl_tti_pdcch_pdu_rel15_t*)tlv; for(uint8_t i = 0; i < MAX_DCI_CORESET; ++i) { - if(!pull16(ppReadPackedMsg, &value->dci_pdu[i].RNTI, end) && + if(!(pull16(ppReadPackedMsg, &value->dci_pdu[i].RNTI, end) && pull16(ppReadPackedMsg, &value->dci_pdu[i].ScramblingId, end) && pull16(ppReadPackedMsg, &value->dci_pdu[i].ScramblingRNTI, end) && @@ -3765,7 +3770,7 @@ static uint8_t unpack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppReadPa pull8(ppReadPackedMsg, &value->dci_pdu[i].powerControlOffsetSS, end) && pull16(ppReadPackedMsg, &value->dci_pdu[i].PayloadSizeBits, end) && - pullarray8(ppReadPackedMsg, value->dci_pdu[i].Payload, DCI_PAYLOAD_BYTE_LEN, value->dci_pdu[i].PayloadSizeBits, end)); + pullarray8(ppReadPackedMsg, value->dci_pdu[i].Payload, value->dci_pdu[i].PayloadSizeBits, value->dci_pdu[i].PayloadSizeBits, end))) return 0; } @@ -3847,7 +3852,8 @@ static uint8_t unpack_dl_tti_pdsch_pdu_rel15_value(void* tlv, uint8_t **ppReadPa static uint8_t unpack_dl_tti_ssb_pdu_rel15_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) -{ +{ + printf("ssb received and unpacked. \n"); nfapi_nr_dl_tti_ssb_pdu_rel15_t* value = (nfapi_nr_dl_tti_ssb_pdu_rel15_t*)tlv; return( @@ -5830,10 +5836,9 @@ static uint8_t unpack_hi_dci0_request_body_value(void *tlv, uint8_t **ppReadPack static uint8_t unpack_ul_dci_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg) { nfapi_nr_ul_dci_request_pdus_t* value = (nfapi_nr_ul_dci_request_pdus_t*)msg; - for(uint8_t i = 0; i < MAX_DCI_CORESET; ++i) { - if(!pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].RNTI, end) && + if(!(pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].RNTI, end) && pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].ScramblingId, end) && pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].ScramblingRNTI, end) && @@ -5844,7 +5849,7 @@ static uint8_t unpack_ul_dci_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t * pull8(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].powerControlOffsetSS, end) && pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, end) && - pullarray8(ppReadPackedMsg, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].Payload, DCI_PAYLOAD_BYTE_LEN, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, end)); + pullarray8(ppReadPackedMsg, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].Payload, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, value->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[i].PayloadSizeBits, end))) return 0; } @@ -5865,7 +5870,6 @@ static uint8_t unpack_ul_dci_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t * pull8(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.InterleaverSize, end) && pull8(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.CoreSetType, end) && pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.ShiftIndex, end) && - pull8(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.precoderGranularity, end) && pull16(ppReadPackedMsg, &value->pdcch_pdu.pdcch_pdu_rel15.numDlDci, end)); diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7.c b/nfapi/open-nFAPI/pnf/src/pnf_p7.c index 18891cdee955d24928b84f40967f0edb63d769f4..fefd822bb0dbefcf3cffc34b59f8e70ac7c73a40 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7.c @@ -1495,7 +1495,7 @@ uint8_t is_nr_p7_request_in_window(uint16_t sfn,uint16_t slot, const char* name, { uint32_t recv_sfn_slot_dec = NFAPI_SFNSLOT2DEC(sfn,slot); uint32_t current_sfn_slot_dec = NFAPI_SFNSLOT2DEC(phy->sfn,phy->slot); - printf("p7_msg_sfn: %d, p7_msg_slot: %d, phy_sfn:%d , phy_slot:%d \n",sfn,slot,phy->sfn,phy->slot); + //printf("p7_msg_sfn: %d, p7_msg_slot: %d, phy_sfn:%d , phy_slot:%d \n",sfn,slot,phy->sfn,phy->slot); uint8_t in_window = 0; uint8_t timing_window = phy->_public.slot_buffer_size; @@ -1630,7 +1630,6 @@ void pnf_handle_dl_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) NFAPI_TRACE(NFAPI_TRACE_INFO, "%s failed to alloced nfapi_dl_tti_request structure\n"); return; } - int unpack_result = nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_dl_tti_request_t), &(pnf_p7->_public.codec_config)); if(unpack_result == 0) @@ -2010,7 +2009,7 @@ void pnf_handle_ul_dci_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) } else { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack hi_dci0_req\n"); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Failed to unpack UL DCI req\n"); deallocate_nfapi_ul_dci_request(req, pnf_p7); } } @@ -2989,13 +2988,11 @@ void pnf_nr_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_tim struct sockaddr_in remote_addr; socklen_t remote_addr_size = sizeof(remote_addr); remote_addr.sin_family = 2; //hardcoded - do { // peek the header uint8_t header_buffer[NFAPI_P7_HEADER_LENGTH]; recvfrom_result = recvfrom(pnf_p7->p7_sock, header_buffer, NFAPI_P7_HEADER_LENGTH, MSG_DONTWAIT | MSG_PEEK, (struct sockaddr*)&remote_addr, &remote_addr_size); - if(recvfrom_result > 0) { // get the segment size diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c b/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c index efcb60ce9632e366927ca4cb6c4af18bdcc28775..7635f39ed05aa87d0b020c1d5bb92830668cd57e 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c @@ -44,6 +44,7 @@ nfapi_pnf_p7_config_t* nfapi_pnf_p7_config_create() _this->_public.codec_config.allocate = &malloc; _this->_public.codec_config.deallocate = &free; + // cppcheck-suppress memleak return &(_this->_public); } diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c index 9993b10b80ec1d7514a1e157f18be1d51ea22d46..39d250becae7ab067b0d5ce14b8fc837f731b9f9 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c @@ -1,12 +1,12 @@ /* * Copyright 2017 Cisco Systems, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,13 +40,13 @@ nfapi_vnf_p7_config_t* nfapi_vnf_p7_config_create() _this->_public.segment_size = 1400; _this->_public.max_num_segments = 8; _this->_public.checksum_enabled = 1; - + _this->_public.malloc = &malloc; - _this->_public.free = &free; + _this->_public.free = &free; _this->_public.codec_config.allocate = &malloc; _this->_public.codec_config.deallocate = &free; - + return (nfapi_vnf_p7_config_t*)_this; } @@ -76,12 +76,12 @@ struct timespec timespec_add(struct timespec lhs, struct timespec rhs) struct timespec timespec_sub(struct timespec lhs, struct timespec rhs) { struct timespec result; - if ((lhs.tv_nsec-rhs.tv_nsec)<0) + if ((lhs.tv_nsec-rhs.tv_nsec)<0) { result.tv_sec = lhs.tv_sec-rhs.tv_sec-1; result.tv_nsec = 1000000000+lhs.tv_nsec-rhs.tv_nsec; - } - else + } + else { result.tv_sec = lhs.tv_sec-rhs.tv_sec; result.tv_nsec = lhs.tv_nsec-rhs.tv_nsec; @@ -89,7 +89,7 @@ struct timespec timespec_sub(struct timespec lhs, struct timespec rhs) return result; } -// monitor the p7 endpoints and the timing loop and +// monitor the p7 endpoints and the timing loop and // send indications to mac int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) { @@ -100,9 +100,9 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; - // Create p7 receive udp port + // Create p7 receive udp port // todo : this needs updating for Ipv6 - + NFAPI_TRACE(NFAPI_TRACE_INFO, "Initialising VNF P7 port:%u\n", config->port); // open the UDP socket @@ -121,7 +121,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (IP_TOS) errno: %d\n", errno); return -1; } - + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 setsockopt succeeded...\n"); // Create the address structure @@ -160,7 +160,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) // struct timespec sf_duration; //Change to slot_duration? // sf_duration.tv_sec = 0; // sf_duration.tv_nsec = 0.5e6; // We want 1ms pause //We want 0.5 ms pause for NR - struct timespec slot_duration; + struct timespec slot_duration; slot_duration.tv_sec = 0; //slot_duration.tv_nsec = 0.5e6; slot_duration.tv_nsec = 0.5e6; @@ -176,7 +176,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) slot_start = timespec_add(slot_start, slot_duration); NFAPI_TRACE(NFAPI_TRACE_INFO, "next slot will start at %d.%d\n", slot_start.tv_sec, slot_start.tv_nsec); - + while(vnf_p7->terminate == 0) { fd_set rfds; @@ -187,7 +187,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) // Add the p7 socket FD_SET(vnf_p7->socket, &rfds); maxSock = vnf_p7->socket; - + clock_gettime(CLOCK_MONOTONIC, &pselect_start); //long millisecond = pselect_start.tv_nsec / 1e6; @@ -196,7 +196,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) //NFAPI_TRACE(NFAPI_TRACE_INFO, "pselect_start:%d.%d sf_start:%d.%d\n", pselect_start.tv_sec, pselect_start.tv_nsec, sf_start.tv_sec, sf_start.tv_nsec); - //if((pselect_start.tv_sec > sf_start.tv_sec) || + //if((pselect_start.tv_sec > sf_start.tv_sec) || // ((pselect_start.tv_sec == sf_start.tv_sec) && (pselect_start.tv_nsec > sf_start.tv_nsec))) if((pselect_start.tv_sec > slot_start.tv_sec) || ((pselect_start.tv_sec == slot_start.tv_sec) && (pselect_start.tv_nsec > slot_start.tv_nsec))) { @@ -220,7 +220,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) //pselect_timeout.tv_nsec = 1e6 - (pselect_start.tv_nsec % 1000000); //uint8_t underrun_possible =0; - + // if we are not sleeping until the next milisecond due to the // insycn minor adjment flag it so we don't consider it an error //uint8_t underrun_possible =0; @@ -230,7 +230,7 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) if(phy && phy->in_sync && phy->insync_minor_adjustment != 0 && phy->insync_minor_adjustment_duration > 0 && pselect_start.tv_nsec != 0) { NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] Subframe minor adjustment %d (%d->%d)\n", phy->insync_minor_adjustment, - pselect_timeout.tv_nsec, pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000)) + pselect_timeout.tv_nsec, pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000)) if(phy->insync_minor_adjustment > 0) { // todo check we don't go below 0 @@ -246,14 +246,14 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) { // todo check we don't go below 0 pselect_timeout.tv_nsec = pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000); - + //phy->insync_minor_adjustment = 0; phy->insync_minor_adjustment_duration--; } } */ - + //long wraps = pselect_timeout.tv_nsec % 1e9; @@ -267,14 +267,14 @@ int nfapi_nr_vnf_p7_start(nfapi_vnf_p7_config_t* config) if (selectRetval==-1 && errno == 22) { -// NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n", -// pselect_timeout.tv_sec, pselect_timeout.tv_nsec, -// phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, +// NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n", +// pselect_timeout.tv_sec, pselect_timeout.tv_nsec, +// phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, // sf_duration.tv_sec, sf_duration.tv_nsec); -NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n", - pselect_timeout.tv_sec, pselect_timeout.tv_nsec, - phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, +NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n", + pselect_timeout.tv_sec, pselect_timeout.tv_nsec, + phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, slot_duration.tv_sec, slot_duration.tv_nsec); } @@ -303,7 +303,7 @@ NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d] sf_start.tv_sec--; sf_start.tv_nsec+=1e9; }*/ - if (slot_start.tv_nsec > 1e9) + if (slot_start.tv_nsec > 1e9) { slot_start.tv_sec++; slot_start.tv_nsec-=1e9; @@ -345,9 +345,9 @@ NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d] //phy->insync_minor_adjustment = 0; phy->insync_minor_adjustment_duration--; -// NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d duration:%u\n", +// NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d duration:%u\n", // phy->insync_minor_adjustment, sf_start.tv_nsec, phy->insync_minor_adjustment_duration); - // NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Slot minor adjustment %dus slot_start.tv_nsec:%d duration:%u\n", + // NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Slot minor adjustment %dus slot_start.tv_nsec:%d duration:%u\n", // phy->insync_minor_adjustment, slot_start.tv_nsec, phy->insync_minor_adjustment_duration); if (phy->insync_minor_adjustment_duration==0) @@ -371,7 +371,7 @@ NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d] } last_millisecond = millisecond; */ - + //millisecond ++; millisecond = millisecond + 1; @@ -379,7 +379,7 @@ NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d] } else { - // we have overrun the subframe advance to go and collect $200 + // we have overrun the subframe advance to go and collect $200 if((millisecond - last_millisecond) > 3) NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe overrun %ld %ld (%ld)\n", millisecond, last_millisecond, millisecond - last_millisecond + 1); @@ -399,10 +399,10 @@ struct timespec current_time; while(curr != 0) { if (curr->slot == 19) - { //curr->slot = 0; + { //curr->slot = 0; if(curr->sfn == 1023) curr->sfn=0; - else + else curr->sfn++; curr->slot=0; } @@ -410,8 +410,8 @@ struct timespec current_time; { curr->slot++; } - vnf_nr_sync(vnf_p7, curr); - curr = curr->next; + vnf_nr_sync(vnf_p7, curr); + curr = curr->next; } send_mac_slot_indications(vnf_p7); } @@ -420,7 +420,7 @@ struct timespec current_time; // have a p7 message if(FD_ISSET(vnf_p7->socket, &rfds)) { - vnf_nr_p7_read_dispatch_message(vnf_p7); + vnf_nr_p7_read_dispatch_message(vnf_p7); } } else @@ -443,7 +443,7 @@ struct timespec current_time; } - + NFAPI_TRACE(NFAPI_TRACE_INFO, "Closing p7 socket\n"); close(vnf_p7->socket); @@ -462,9 +462,9 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) vnf_p7_t* vnf_p7 = (vnf_p7_t*)config; - // Create p7 receive udp port + // Create p7 receive udp port // todo : this needs updating for Ipv6 - + NFAPI_TRACE(NFAPI_TRACE_INFO, "Initialising VNF P7 port:%u\n", config->port); // open the UDP socket @@ -483,7 +483,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) NFAPI_TRACE(NFAPI_TRACE_ERROR, "After setsockopt (IP_TOS) errno: %d\n", errno); return -1; } - + NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF P7 setsockopt succeeded...\n"); // Create the address structure @@ -539,7 +539,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) // Add the p7 socket FD_SET(vnf_p7->socket, &rfds); maxSock = vnf_p7->socket; - + clock_gettime(CLOCK_MONOTONIC, &pselect_start); //long millisecond = pselect_start.tv_nsec / 1e6; @@ -548,7 +548,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) //NFAPI_TRACE(NFAPI_TRACE_INFO, "pselect_start:%d.%d sf_start:%d.%d\n", pselect_start.tv_sec, pselect_start.tv_nsec, sf_start.tv_sec, sf_start.tv_nsec); - if((pselect_start.tv_sec > sf_start.tv_sec) || + if((pselect_start.tv_sec > sf_start.tv_sec) || ((pselect_start.tv_sec == sf_start.tv_sec) && (pselect_start.tv_nsec > sf_start.tv_nsec))) { // overran the end of the subframe we do not want to wait @@ -571,7 +571,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) //pselect_timeout.tv_nsec = 1e6 - (pselect_start.tv_nsec % 1000000); //uint8_t underrun_possible =0; - + // if we are not sleeping until the next milisecond due to the // insycn minor adjment flag it so we don't consider it an error //uint8_t underrun_possible =0; @@ -581,7 +581,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) if(phy && phy->in_sync && phy->insync_minor_adjustment != 0 && phy->insync_minor_adjustment_duration > 0 && pselect_start.tv_nsec != 0) { NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] Subframe minor adjustment %d (%d->%d)\n", phy->insync_minor_adjustment, - pselect_timeout.tv_nsec, pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000)) + pselect_timeout.tv_nsec, pselect_timeout.tv_nsec - (phy->insync_minor_adjustment * 1000)) if(phy->insync_minor_adjustment > 0) { // todo check we don't go below 0 @@ -604,7 +604,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) } } */ - + //long wraps = pselect_timeout.tv_nsec % 1e9; @@ -617,9 +617,9 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) if (selectRetval==-1 && errno == 22) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n", - pselect_timeout.tv_sec, pselect_timeout.tv_nsec, - phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, + NFAPI_TRACE(NFAPI_TRACE_ERROR, "INVAL: pselect_timeout:%d.%ld adj[dur:%d adj:%d], sf_dur:%d.%ld\n", + pselect_timeout.tv_sec, pselect_timeout.tv_nsec, + phy->insync_minor_adjustment_duration, phy->insync_minor_adjustment, sf_duration.tv_sec, sf_duration.tv_nsec); } if(selectRetval == 0) @@ -677,7 +677,7 @@ if (selectRetval==-1 && errno == 22) //phy->insync_minor_adjustment = 0; phy->insync_minor_adjustment_duration--; - NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d duration:%u\n", + NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] AFTER adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d duration:%u\n", phy->insync_minor_adjustment, sf_start.tv_nsec, phy->insync_minor_adjustment_duration); if (phy->insync_minor_adjustment_duration==0) @@ -701,7 +701,7 @@ if (selectRetval==-1 && errno == 22) } last_millisecond = millisecond; */ - + millisecond ++; } } @@ -760,7 +760,7 @@ if (selectRetval==-1 && errno == 22) } - + NFAPI_TRACE(NFAPI_TRACE_INFO, "Closing p7 socket\n"); close(vnf_p7->socket); @@ -807,7 +807,7 @@ int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, // save the remote endpoint information node->remote_addr.sin_family = AF_INET; - node->remote_addr.sin_port = htons(pnf_p7_port); + node->remote_addr.sin_port = pnf_p7_port;//htons(pnf_p7_port); node->remote_addr.sin_addr.s_addr = inet_addr(pnf_p7_addr); vnf_p7_connection_info_list_add(vnf_p7, node); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c index 05d6c4c112bbe35ccc906425545ca63d25a85989..c2b305b6f3fdf7e41496f9a5d7c81d0455c6122b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c @@ -32,6 +32,7 @@ */ #include "nr_dlsch.h" +#include "../../../nfapi/oai_integration/vendor_ext.h" extern void set_taus_seed(unsigned int seed_type); @@ -284,7 +285,10 @@ void nr_fill_dlsch(PHY_VARS_gNB *gNB, uint8_t *sdu) { nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &pdsch_pdu->pdsch_pdu_rel15; - + if (NFAPI_MODE == NFAPI_MODE_PNF) { + gNB->dlsch[0][0]->harq_mask = 1; + gNB->dlsch[0][0]->rnti = 4660; + } int dlsch_id = find_nr_dlsch(rel15->rnti,gNB,SEARCH_EXIST); AssertFatal( (dlsch_id>=0) && (dlsch_id<NUMBER_OF_NR_DLSCH_MAX), "illegal or no dlsch_id found!!! rnti %04x dlsch_id %d\n",rel15->rnti,dlsch_id); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 429bd9a836857abedbad4d99aec1880ebf60f704..18ab6273923e1e09f37466bfca9e365f3687e2ca 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -577,7 +577,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { - LOG_D(PHY,"Segment %u CRC OK\n\033[0m",r); + LOG_I(PHY,"Segment %u CRC OK\n\033[0m",r); if (r==0) { for (int i=0;i<10;i++) LOG_D(PHY,"byte %d : %x\n",i,((uint8_t*)llrProcBuf)[i]); } @@ -587,7 +587,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ret = no_iteration_ldpc; } else { - LOG_D(PHY,"CRC NOT OK\n\033[0m"); + LOG_I(PHY,"CRC NOT OK\n\033[0m"); ret = 1 + dlsch->max_ldpc_iterations; } diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index d65d3b54bb90ab6d264561e8a3071cd71c280f30..67b6ed48b68d569e81440de1847c2af0bd9f1cd8 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -104,8 +104,6 @@ void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB, nr_fill_dci(gNB,frame,slot,pdcch_pdu); - - } void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB, @@ -182,26 +180,30 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ 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"); - if(NFAPI_MODE != NFAPI_MODE_VNF) + if(NFAPI_MODE != NFAPI_MODE_VNF){ + LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE for %d.%d\n",frame,slot,DL_req->SFN,DL_req->Slot); handle_nfapi_nr_pdcch_pdu(gNB, frame, slot, &dl_tti_pdu->pdcch_pdu); - + } 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); + LOG_I(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; - if(NFAPI_MODE != NFAPI_MODE_VNF) + if(NFAPI_MODE != NFAPI_MODE_VNF){ + 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); handle_nr_nfapi_pdsch_pdu(gNB,frame,slot,&dl_tti_pdu->pdsch_pdu, sdu); + } } } } @@ -248,6 +250,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ { Sched_INFO->DL_req->SFN = frame; Sched_INFO->DL_req->Slot = slot; + printf("DL tti Frame = %d, slot = %d. \n",frame,slot); oai_nfapi_dl_tti_req(Sched_INFO->DL_req); } if (Sched_INFO->TX_req->Number_of_PDUs > 0) @@ -257,4 +260,4 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ } -} \ No newline at end of file +} diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 9d7422745eef7122e9ef501cddda5544cae8ba55..cd419cf8c90086986f41337c3e8e012dcaa8a26e 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -88,14 +88,14 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { } // to set a effective slot number in the half frame where the SSB is supposed to be - rel_slot = (n_hf)? (slot-slots_per_hf) : slot; + rel_slot = (n_hf)? (slot-slots_per_hf) : slot; LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot); if(rel_slot<38 && rel_slot>=0) { // there is no SSB beyond slot 37 for (int i=0; i<2; i++) { // max two SSB per frame - + ssb_index = i + SSB_Table[rel_slot]; // computing the ssb_index if ((ssb_index<64) && ((fp->L_ssb >> (63-ssb_index)) & 0x01)) { // generating the ssb only if the bit of L_ssb at current ssb index is 1 @@ -104,11 +104,11 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { ssb_start_symbol = ssb_start_symbol_abs % fp->symbols_per_slot; // start symbol wrt slot nr_set_ssb_first_subcarrier(cfg, fp); // setting the first subcarrier - + LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); nr_generate_pss(gNB->d_pss, &txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); nr_generate_sss(gNB->d_sss, &txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); - + if (cfg->carrier_config.num_tx_ant.value <= 4) nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index&7],&txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp); else @@ -144,9 +144,9 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, int offset = gNB->CC_id; uint8_t ssb_frame_periodicity = 1; // every how many frames SSB are generated int txdataF_offset = (slot%2)*fp->samples_per_slot_wCP; - - if (cfg->ssb_table.ssb_period.value > 1) - ssb_frame_periodicity = 1 <<(cfg->ssb_table.ssb_period.value -1) ; + + if (cfg->ssb_table.ssb_period.value > 1) + ssb_frame_periodicity = 1 <<(cfg->ssb_table.ssb_period.value -1) ; if ((cfg->cell_config.frame_duplex_type.value == TDD) && (nr_slot_select(cfg,frame,slot) == NR_UPLINK_SLOT)) return; @@ -161,7 +161,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_COMMON_TX,1); - if (NFAPI_MODE == NFAPI_MONOLITHIC || NFAPI_MODE == NFAPI_MODE_PNF) { + if (NFAPI_MODE == NFAPI_MONOLITHIC || NFAPI_MODE == NFAPI_MODE_PNF) { if ((!(frame%ssb_frame_periodicity))) // generate SSB only for given frames according to SSB periodicity nr_common_signal_procedures(gNB,frame, slot); } @@ -178,7 +178,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, gNB->Mod_id, frame, slot, gNB->ul_pdcch_pdu[ul_pdcch_pdu_id].pdcch_pdu.pdcch_pdu.pdcch_pdu_rel15.numDlDci, gNB->pdcch_pdu[pdcch_pdu_id].pdcch_pdu.pdcch_pdu_rel15.numDlDci); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_PDCCH_TX,1); nr_generate_dci_top(gNB, @@ -196,7 +196,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, if (pdcch_pdu_id >= 0) gNB->pdcch_pdu[pdcch_pdu_id].frame = -1; if (ul_pdcch_pdu_id >= 0) gNB->ul_pdcch_pdu[ul_pdcch_pdu_id].frame = -1; } - + for (int i=0; i<gNB->num_pdsch_rnti[slot]; i++) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1); LOG_D(PHY, "PDSCH generation started (%d) in frame %d.%d\n", gNB->num_pdsch_rnti[slot],frame,slot); @@ -208,7 +208,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, //apply the OFDM symbol rotation here apply_nr_rotation(fp,(int16_t*) &gNB->common_vars.txdataF[0][txdataF_offset],slot,0,fp->Ncp==EXTENDED?12:14,fp->ofdm_symbol_size); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_TX+offset,0); } @@ -216,7 +216,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, /* - if ((cfg->subframe_config.duplex_mode.value == TDD) && + if ((cfg->subframe_config.duplex_mode.value == TDD) && ((nr_slot_select(fp,frame,slot)&NR_DOWNLINK_SLOT)==SF_DL)) return; // VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX,1); @@ -235,7 +235,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { rdata->segment_r, ulsch_harq->processedSegments, rdata->nbSegments); gNB->nbDecode--; LOG_D(PHY,"remain to decoded in subframe: %d\n", gNB->nbDecode); - + if (decodeSuccess) { memcpy(ulsch_harq->b+rdata->offset, ulsch_harq->c[r], @@ -254,7 +254,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { } } - // if all segments are done + // if all segments are done if (rdata->nbSegments == ulsch_harq->processedSegments) { if (decodeSuccess) { LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for slot %d TBS %d\n", @@ -290,7 +290,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH { NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->ulsch_pdu; - + uint8_t l, number_dmrs_symbols = 0; uint32_t G; uint16_t start_symbol, number_symbols, nb_re_dmrs; @@ -312,7 +312,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH number_dmrs_symbols, // number of dmrs symbols irrespective of single or double symbol dmrs pusch_pdu->qam_mod_order, pusch_pdu->nrOfLayers); - + AssertFatal(G>0,"G is 0 : rb_size %u, number_symbols %d, nb_re_dmrs %d, number_dmrs_symbols %d, qam_mod_order %u, nrOfLayer %u\n", pusch_pdu->rb_size, number_symbols, @@ -547,6 +547,7 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) LOG_D(PHY,"phy_procedures_gNB_uespec_RX frame %d, slot %d\n",frame_rx,slot_rx); if (gNB->frame_parms.frame_type == TDD) + if(NFAPI_MODE != NFAPI_MODE_VNF) fill_ul_rb_mask(gNB, frame_rx, slot_rx); gNB_I0_measurements(gNB); @@ -651,7 +652,7 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) } #endif -T(T_BENETEL, T_INT(frame_rx), T_INT(slot_rx), T_BUFFER(&gNB->common_vars.rxdataF[0][0], 2048*4*14)); + //T(T_BENETEL, T_INT(frame_rx), T_INT(slot_rx), T_BUFFER(&gNB->common_vars.rxdataF[0][0], 2048*4*14)); uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index; uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols; diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index e70c353589554e45141b51abef271bfa9c1e3ede..bdbfae58e3286bc2e07d6dd1695bbe0ef1b838d6 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -121,6 +121,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ dlsch0_harq->Nl=1; dlsch0_harq->mcs_table=dlsch_config_pdu->mcs_table; dlsch0_harq->harq_ack.rx_status = downlink_harq_process(dlsch0_harq, dlsch0->current_harq_pid, dlsch_config_pdu->ndi, dlsch0->rnti_type); + dlsch0_harq->status = ACTIVE; //Gokul if (dlsch0_harq->status != ACTIVE) { // dlsch0_harq->status not ACTIVE may be due to false retransmission. Reset the // following flag to skip PDSCH procedures in that case. diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index 85f6d90bbedb3a62a07d7671289d5525dcbc24d1..0dcc057867163b4397c7c95c4d4df368d8b05481 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -472,7 +472,7 @@ harq_result_t downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int dl_harq->round = 0; dl_harq->status = ACTIVE; dl_harq->DCINdi = ndi; - dl_harq->first_tx = 0; + //dl_harq->first_tx = 0; result_harq = NEW_TRANSMISSION_HARQ; diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c index 5f8269c513d0608f86f39e8a246f165150cd45aa..47d5375717212e1d3ed6ff1a3ac27ba2c14701aa 100644 --- a/openair1/SCHED_UE/phy_procedures_lte_ue.c +++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c @@ -3686,6 +3686,7 @@ void *UE_thread_slot1_dl_processing(void *arg) { if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.slot1_proc_two != -1 ) CPU_SET(threads.slot1_proc_two, &cpuset); + // cppcheck-suppress moduloAlwaysTrueFalse if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.slot1_proc_three != -1 ) CPU_SET(threads.slot1_proc_three, &cpuset); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index ede68b11efbdf5f8a5a118449a8037e68edbd4ac..4ada9eb9f3a5f70184f3f8a5cf69440867bf1a98 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -104,7 +104,10 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, nfapi_nr_tx_data_request_t *TX_req = &gNB->TX_req[0]; gNB->pdu_index[CC_idP] = 0; - + if (NFAPI_MODE == NFAPI_MODE_VNF) + { + memset(pdcch, 0, sizeof(**pdcch) * MAX_NUM_BWP * MAX_NUM_CORESET); + } if (NFAPI_MODE == NFAPI_MONOLITHIC || NFAPI_MODE == NFAPI_MODE_PNF) { // monolithic or PNF DL_req[CC_idP].SFN = frameP; @@ -303,14 +306,13 @@ 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){ - + gNB_MAC_INST *mac = RC.nrmac[module_idP]; + nfapi_nr_config_request_scf_t *cfg = &mac->config[0]; protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); - int nb_periods_per_frame; const int bwp_id = 1; - gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = gNB->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -356,7 +358,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, int num_slots_per_tdd = (nr_slots_per_frame[*scc->ssbSubcarrierSpacing])/nb_periods_per_frame; const int nr_ulmix_slots = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); - start_meas(&RC.nrmac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN); @@ -395,7 +396,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, const int last_slot = (slot + num_slots - 1) % num_slots; uint16_t *vrb_map_UL = cc[CC_id].vrb_map_UL; memset(&vrb_map_UL[last_slot * MAX_BWP_SIZE], 0, sizeof(uint16_t) * MAX_BWP_SIZE); - clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot); } @@ -440,14 +440,18 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, // This schedules the DCI for Uplink and subsequently PUSCH { + if(NFAPI_MODE == NFAPI_MODE_VNF){ + gNB->UL_tti_req_ahead[0][7].SFN = frame;//Added to set the UL_tti_req_ahead SFN in VNF mode for slot 7 + gNB->UL_tti_req_ahead[0][8].SFN = frame;//Added to set the UL_tti_req_ahead SFN in VNF mode for slot 8 + gNB->UL_tti_req_ahead[0][9].SFN = frame;//Added to set the UL_tti_req_ahead SFN in VNF mode for slot 9 + gNB->UL_tti_req[0] = &gNB->UL_tti_req_ahead[0][slot]; + } nr_schedule_ulsch(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, ulsch_in_slot_bitmap); } - // This schedules the DCI for Downlink and PDSCH if (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot)) nr_schedule_ue_spec(module_idP, frame, slot); - nr_schedule_pucch(module_idP, frame, slot); stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 4d491b28434edd5c2f649e4ad1d9cef42b56b03f..eaec52bf7064b352e00e20b439014bbea073ade1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -47,6 +47,7 @@ /*Softmodem params*/ #include "executables/softmodem-common.h" +#include "../../../nfapi/oai_integration/vendor_ext.h" //////////////////////////////////////////////////////// /////* DLSCH MAC PDU generation (6.1.2 TS 38.321) *///// @@ -56,6 +57,9 @@ #define WORD 32 //#define SIZE_OF_POINTER sizeof (void *) +int harq_rounds = 0; +int harq_pid = 0; + // Compute and write all MAC CEs and subheaders, and return number of written // bytes int nr_write_ce_dlsch_pdu(module_id_t module_idP, @@ -716,6 +720,8 @@ void nr_schedule_ue_spec(module_id_t module_id, int8_t current_harq_pid = sched_ctrl->dl_harq_pid; if (current_harq_pid < 0) { /* PP has not selected a specific HARQ Process, get a new one */ + if (NFAPI_MODE == NFAPI_MODE_VNF) + sched_ctrl->available_dl_harq.head = 0; current_harq_pid = sched_ctrl->available_dl_harq.head; AssertFatal(current_harq_pid >= 0, "no free HARQ process available for UE %d\n", @@ -732,6 +738,9 @@ void nr_schedule_ue_spec(module_id_t module_id, remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid); } NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; + if (NFAPI_MODE == NFAPI_MODE_VNF) { + harq->is_waiting = false; + } DevAssert(!harq->is_waiting); add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid); NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; @@ -765,7 +774,15 @@ void nr_schedule_ue_spec(module_id_t module_id, const int bwpid = sched_ctrl->active_bwp->bwp_Id; const int coresetid = sched_ctrl->coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid]; + //nfapi_nr_dl_tti_pdcch_pdu_rel15_t temp; + // if(NFAPI_MODE == NFAPI_MODE_VNF){ + // memcpy(temp,gNB_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid],sizeof(nfapi_nr_dl_tti_pdcch_pdu_rel15_t)); + // pdcch_pdu = temp; + + // } + if (!pdcch_pdu) { + printf("creating pdcch pdu, pdcch_pdu = NULL. \n"); nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset(dl_tti_pdcch_pdu, 0, sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE; @@ -807,6 +824,14 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->mcsIndex[0] = sched_ctrl->mcs; pdsch_pdu->mcsTable[0] = sched_ctrl->mcsTableIdx; pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round]; + if (NFAPI_MODE == NFAPI_MODE_VNF){ // done since uplink isnt operational yet which means harq structures dont get filled properly + pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq_rounds]; + if (harq_rounds % 5 == 0 && harq_rounds!=0){ + harq_rounds = 0; + harq_pid = (harq_pid + 1) % 16; + } + harq_rounds++; + } pdsch_pdu->TBSize[0] = TBS; pdsch_pdu->dataScramblingId = *scc->physCellId; @@ -918,6 +943,10 @@ void nr_schedule_ue_spec(module_id_t module_id, const int dci_format = f ? NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; const int rnti_type = NR_RNTI_C; + if (NFAPI_MODE == NFAPI_MODE_VNF){ + dci_payload.harq_pid = harq_pid; + dci_payload.tpc = 2; + } fill_dci_pdu_rel15(scc, UE_info->secondaryCellGroup[UE_id], dci_pdu, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 20da8fa30aaa520b3e44a22549de780c03f0043f..e7149c5d657660ddbae41c349a3192afe45a37b3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1666,6 +1666,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *secon const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig->pdsch_ServingCellConfig->choice.setup; const int nrofHARQ = pdsch->nrofHARQ_ProcessesForPDSCH ? get_nrofHARQ_ProcessesForPDSCH(*pdsch->nrofHARQ_ProcessesForPDSCH) : 8; + printf("nrofHARQ = %d\n", nrofHARQ); // add all available DL HARQ processes for this UE create_nr_list(&sched_ctrl->available_dl_harq, nrofHARQ); for (int harq = 0; harq < nrofHARQ; harq++) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 629b4dc7b065972f9923fb2d5d66b98b3b82efac..9842d9137f941eb4b97157a11d2ca865abc3b166 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -235,6 +235,8 @@ void nr_csi_meas_reporting(int Mod_idP, // find free PUCCH that is in order with possibly existing PUCCH // schedulings (other CSI, SR) NR_sched_pucch_t *curr_pucch = &sched_ctrl->sched_pucch[2]; + if(NFAPI_MODE == NFAPI_MODE_VNF) + curr_pucch->csi_bits = 0; AssertFatal(curr_pucch->csi_bits == 0 && !curr_pucch->sr_flag && curr_pucch->dai_c == 0, @@ -458,11 +460,20 @@ bool nr_acknack_scheduling(int mod_id, "illegal number of bits in PUCCH of UE %d\n", UE_id); /* if the currently allocated PUCCH of this UE is full, allocate it */ + if (NFAPI_MODE == NFAPI_MODE_VNF) + pucch->sr_flag = 1; pucch->dai_c = 1; if (pucch->sr_flag + pucch->dai_c == max_acknacks) { /* advance the UL slot information in PUCCH by one so we won't schedule in * the same slot again */ const int f = pucch->frame; const int s = pucch->ul_slot; + if(NFAPI_MODE == NFAPI_MODE_VNF){ + gNB_MAC_INST *gNB = RC.nrmac[mod_id]; + gNB->UL_tti_req_ahead[0][7].SFN = f;//Added to set the UL_tti_req_ahead SFN in VNF mode for slot 7 + gNB->UL_tti_req_ahead[0][8].SFN = f;//Added to set the UL_tti_req_ahead SFN in VNF mode for slot 8 + gNB->UL_tti_req_ahead[0][9].SFN = f;//Added to set the UL_tti_req_ahead SFN in VNF mode for slot 9 + gNB->UL_tti_req[0] = &gNB->UL_tti_req_ahead[0][slot]; + } nr_fill_nfapi_pucch(mod_id, frame, slot, pucch, UE_id); memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; @@ -481,6 +492,7 @@ bool nr_acknack_scheduling(int mod_id, UE_id); nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); pucch->frame = s >= n_slots_frame - 2 ? (f + 1) % 1024 : f; + printf("pucch frame filled. \n"); pucch->ul_slot = (s + 2) % n_slots_frame; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 08736719211a625246a5d9b760653455fe8cfadc..44993bf29406632410d10a423dbca3d5e8f26ae7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -32,6 +32,7 @@ #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "executables/softmodem-common.h" #include "common/utils/nr/nr_common.h" +#include "nfapi/oai_integration/vendor_ext.h" //38.321 Table 6.1.3.1-1 const uint32_t NR_SHORT_BSR_TABLE[32] = { @@ -882,28 +883,38 @@ void nr_schedule_ulsch(module_id_t module_id, uint16_t rnti = UE_info->rnti[UE_id]; 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 */ - harq_id = sched_ctrl->available_ul_harq.head; - AssertFatal(harq_id >= 0, - "no free HARQ process available for UE %d\n", - UE_id); - remove_front_nr_list(&sched_ctrl->available_ul_harq); - 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); - else - remove_nr_list(&sched_ctrl->retrans_ul_harq, harq_id); + if (NFAPI_MODE == NFAPI_MODE_VNF) + harq_id = 1; + else + { + if (harq_id < 0) { + /* PP has not selected a specific HARQ Process, get a new one */ + harq_id = sched_ctrl->available_ul_harq.head; + // if(NFAPI_MODE == NFAPI_MODE_VNF) + // harq_id = 1; + AssertFatal(harq_id >= 0, + "no free HARQ process available for UE %d\n", + UE_id); + remove_front_nr_list(&sched_ctrl->available_ul_harq); + 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); + else + remove_nr_list(&sched_ctrl->retrans_ul_harq, harq_id); + } } 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; + if (NFAPI_MODE == NFAPI_MODE_VNF) + cur_harq->is_waiting = 0; + int rnti_types[2] = { NR_RNTI_C, 0 }; @@ -1133,4 +1144,4 @@ void nr_schedule_ulsch(module_id_t module_id, memset(sched_pusch, 0, sizeof(*sched_pusch)); } -} \ No newline at end of file +} diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index b183b32aab4971c6d58d1b1c70566301bbe5676c..08000aefb5deca4039e63a919d8f014a8dc6ecf9 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -105,7 +105,7 @@ void handle_nr_uci(NR_UL_IND_t *UL_info) } UL_info->uci_ind.num_ucis = 0; - + if(NFAPI_MODE != NFAPI_MODE_PNF) // mark corresponding PUCCH resources as free // NOTE: we just assume it is BWP ID 1, to be revised for multiple BWPs RC.nrmac[mod_id]->pucch_index_used[1][slot] = 0; @@ -181,6 +181,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { NR_Sched_Rsp_t *sched_info = &Sched_INFO[module_id][CC_id]; NR_IF_Module_t *ifi = if_inst[module_id]; gNB_MAC_INST *mac = RC.nrmac[module_id]; + nfapi_nr_config_request_scf_t *cfg = &mac->config[CC_id]; LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rach_pdus:%d rx_ind:%d crcs:%d]\n", UL_info->frame,UL_info->slot, module_id,CC_id, UL_info->rach_ind.number_of_pdus, @@ -199,8 +200,9 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { } handle_nr_rach(UL_info); - + handle_nr_uci(UL_info); + // clear HI prior to handling ULSCH mac->UL_dci_req[CC_id].numPdus = 0; handle_nr_ulsch(UL_info); @@ -217,7 +219,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { gNB_dlsch_ulsch_scheduler(module_id, (UL_info->frame+((UL_info->slot>(spf-1-sl_ahead))?1:0)) % 1024, (UL_info->slot+sl_ahead)%spf); - + ifi->CC_mask = 0; sched_info->module_id = module_id; sched_info->CC_id = CC_id; diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 8cee7558efe486bc80e2078c9f7e59426f264793..c4b91283bf687540f2a3d3789688030cc25716e3 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -640,7 +640,7 @@ int main( int argc, char **argv ) { { init_pdcp(node_number-1); } - + //TTN for D2D printf ("RRC control socket\n"); rrc_control_socket_init(); @@ -684,10 +684,10 @@ int main( int argc, char **argv ) { } cpuf=get_cpu_freq_GHz(); - - + + #if 0 // #ifndef DEADLINE_SCHEDULER - + printf("NO deadline scheduler\n"); /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ cpu_set_t cpuset; @@ -699,7 +699,7 @@ int main( int argc, char **argv ) { if (get_nprocs() > 2) { for (j = 2; j < get_nprocs(); j++) CPU_SET(j, &cpuset); - + s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); if (s != 0) {