diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 1f85e9fee4..a66bd8b2a1 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -44,7 +44,7 @@ #include "../utils/LOG/log.h" #define CONFIG_SHAREDLIBFORMAT "libparams_%s.so" -extern uint8_t nfapi_mode; +extern uint8_t nfapi_mode=0; int load_config_sharedlib(configmodule_interface_t *cfgptr) { void *lib_handle; diff --git a/nfapi/README.md b/nfapi/README.md index e5290c284a..7d077e3187 100644 --- a/nfapi/README.md +++ b/nfapi/README.md @@ -81,7 +81,7 @@ sudo /cmake_targets/ran_build/build/nr-softmodem -O * Change the `vnf_handle_timing_info()` function that calls p7 message unpack fn and initializes the sfn and slot in `vnf_p7.c` file [x] * Change pack and unpack functions `pack_timing_info()` and `unpack_timing_info()` [x] * Change `nfapi_timing_info_t` structure to support P7 in NR [x] -* Change packing functions to support NR P7 procedures. [x] +* Change packing functions for timing info to support NR P7 procedures. [x] ### Testing diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 4c4b8e88ca..429e0c8583 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -60,6 +60,7 @@ extern RAN_CONTEXT_t RC; #include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" #include "openair1/PHY/defs_gNB.h" + #define NUM_P5_PHY 2 #define _GNU_SOURCE @@ -299,7 +300,7 @@ int pnf_param_request(nfapi_pnf_config_t *config, nfapi_pnf_param_request_t *req resp.pnf_phy.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j]; } } - +/* resp.pnf_rf.tl.tag = NFAPI_PNF_RF_TAG; resp.pnf_rf.number_of_rfs = 2; @@ -400,7 +401,7 @@ int pnf_param_request(nfapi_pnf_config_t *config, nfapi_pnf_param_request_t *req resp.pnf_phy_rel13_nb_iot.phy[i].nmm_modes_supported = pnf->phys[i].nmm_modes_supported; } } - +*/ nfapi_pnf_pnf_param_resp(config, &resp); return 0; } @@ -642,7 +643,7 @@ int param_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi nfapi_resp.nfapi_config.p7_pnf_port.tl.tag = NFAPI_NR_NFAPI_P7_PNF_PORT_TAG; nfapi_resp.num_tlv++; - +/* nfapi_resp.nfapi_config.dl_ue_per_sf.tl.tag = NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG; nfapi_resp.num_tlv++; @@ -651,7 +652,9 @@ int param_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi nfapi_resp.nfapi_config.rf_bands.tl.tag = NFAPI_NR_NFAPI_RF_BANDS_TAG; nfapi_resp.num_tlv++; - + nfapi_resp.nfapi_config.max_transmit_power.tl.tag = NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG; + nfapi_resp.num_tlv++; +*/ nfapi_resp.nfapi_config.timing_window.tl.tag = NFAPI_NR_NFAPI_TIMING_WINDOW_TAG; nfapi_resp.num_tlv++; @@ -660,9 +663,6 @@ int param_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi nfapi_resp.nfapi_config.timing_info_period.tl.tag = NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG; nfapi_resp.num_tlv++; - - nfapi_resp.nfapi_config.max_transmit_power.tl.tag = NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG; - nfapi_resp.num_tlv++; } nfapi_resp.nfapi_config.p7_pnf_port.value = pnf->phys[0].local_port; // 32123; // DJP - hard code alert!!!! FIXME TODO @@ -713,7 +713,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap phy_info->timing_info_mode = 0; printf("NO timing info mode provided\n"); } - + //TODO: Read the P7 message offset values if(req->nfapi_config.timing_info_period.tl.tag == NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG) { printf("timing info period provided value:%d\n", req->nfapi_config.timing_info_period.value); phy_info->timing_info_period = req->nfapi_config.timing_info_period.value; @@ -737,7 +737,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap num_tlv++; } - +/* if(req->nfapi_config.rf_bands.tl.tag == NFAPI_NR_NFAPI_RF_BANDS_TAG) { pnf->rfs[0].band = req->nfapi_config.rf_bands.rf_band[0]; fp->nr_band = req->nfapi_config.rf_bands.rf_band[0]; @@ -754,6 +754,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() nrarfcn:%u dl_carrierFreq:%u ul_CarrierFreq:%u band:%u N_RB_DL:%u\n", __FUNCTION__, req->nfapi_config.nrarfcn.value, fp->dl_CarrierFreq, fp->ul_CarrierFreq, pnf->rfs[0].band, fp->N_RB_DL); } + */ #if SUBFRAME // TODO: add subframe struct to nr config request struct if (req->subframe_config.duplex_mode.tl.tag == NFAPI_NR_SUBFRAME_CONFIG_DUPLEX_MODE_TAG) { fp->frame_type = req->subframe_config.duplex_mode.value==0 ? TDD : FDD; @@ -994,7 +995,7 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, struct PHY_VARS_gNB_s *gNB = RC.gNB[0]; if (proc==NULL) proc = &gNB->proc.L1_proc; - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu_list = req->dl_tti_request_body.dl_tti_pdu_list; + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu_list = req->dl_tti_pdu_list; // TODO: NR_gNB_PDCCH not defined yet (check later) #if 0 @@ -1003,25 +1004,23 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, pdcch_vars->num_dci = 0; #endif - if (req->dl_tti_request_body.nPDUs) + if (req->nPDUs) NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d; sfn:%d, slot:%d, nGroup:%u, nPDUs: %u, nUE: %u, PduIdx: %u,\n", __FUNCTION__, proc->frame_tx, proc->slot_tx, proc->frame_rx, proc->slot_rx, // TODO: change subframes to slot req->SFN, req->Slot, - req->dl_tti_request_body.nGroup, - req->dl_tti_request_body.nPDUs, - req->dl_tti_request_body.nUe, - req->dl_tti_request_body.PduIdx); + req->nGroup, + req->nPDUs, + req->nUe, + req->PduIdx); - for (int i=0; idl_tti_request_body.nPDUs; i++) { + for (int i=0; inPDUs; i++) { // TODO: enable after adding gNB PDCCH: // NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d pdcch_vars->num_dci:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size,pdcch_vars->num_dci); if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE) { - //handle_nfapi_dci_dl_pdu(eNB,NFAPI_SFNSF2SFN(req->sfn_sf),NFAPI_SFNSF2SF(req->sfn_sf),proc,&dl_config_pdu_list[i]); handle_nfapi_nr_pdcch_pdu(gNB, sfn, slot, &dl_tti_pdu_list[i].pdcch_pdu); - dl_tti_pdu_list[i].pdcch_pdu.pdcch_pdu_rel15.numDlDci++; // ? - // pdcch_vars->num_dci++; // Is actually number of DCI PDUs + //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); } else if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) { // nfapi_dl_config_bch_pdu *bch_pdu = &dl_config_pdu_list[i].bch_pdu; @@ -1029,14 +1028,13 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, // uint16_t pdu_index = bch_pdu->bch_pdu_rel8.pdu_index; uint16_t pdu_index = ssb_pdu->ssb_pdu_rel15.SsbBlockIndex; - if (tx_data_request[sfn][slot][pdu_index] != NULL) { + // if (tx_data_request[sfn][slot][pdu_index] != NULL) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PDU:%d BCH: pdu_index:%u pdu_length:%d sdu_length:%d BCH_SDU:%x,%x,%x\n", __FUNCTION__, i, pdu_index, bch_pdu->bch_pdu_rel8.length, tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_length, sdu[0], sdu[1], sdu[2]); - // handle_nfapi_bch_pdu(eNB, proc, &dl_config_pdu_list[i], tx_request_pdu[sfn][sf][pdu_index]->segments[0].segment_data); handle_nr_nfapi_ssb_pdu(gNB, sfn, slot, &dl_tti_pdu_list[i]); gNB->pbch_configured=1;\ - } else { + //} else { // NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() BCH NULL TX PDU SFN/SF:%d PDU_INDEX:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), pdu_index); - } + //} } else if (dl_tti_pdu_list[i].PDUType == NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE) { nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu = &dl_tti_pdu_list[i].pdsch_pdu; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15_pdu = &pdsch_pdu->pdsch_pdu_rel15; @@ -1046,9 +1044,7 @@ int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, int UE_id = find_nr_dlsch(rel15_pdu->rnti,gNB,SEARCH_EXIST_OR_FREE); AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); AssertFatal(UE_id= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); - //LTE_eNB_DLSCH_t *dlsch0 = eNB->dlsch[UE_id][0]; NR_gNB_DLSCH_t *dlsch0 = gNB->dlsch[UE_id][0]; - //LTE_eNB_DLSCH_t *dlsch1 = eNB->dlsch[UE_id][1]; int harq_pid = dlsch0->harq_ids[sfn%2][slot]; if(harq_pid >= dlsch0->Mdlharq) { diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 91740a15a1..c6520d66da 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -312,7 +312,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_re pnf->phys[0] = phy; } - +/* for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) { rf_info rf; memset(&rf,0,sizeof(rf)); @@ -320,7 +320,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_param_re printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index); pnf->rfs[0] = rf; } - +*/ nfapi_pnf_config_request_t req; memset(&req, 0, sizeof(req)); req.header.message_id = NFAPI_PNF_CONFIG_REQUEST; @@ -364,6 +364,8 @@ int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_ } int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { + + //printf("\n wake_gNB_rxtx before assignment sfn:%d slot:%d",sfn,slot); gNB_L1_proc_t *proc=&gNB->proc; gNB_L1_rxtx_proc_t *L1_proc= (slot&1)? &proc->L1_proc : &proc->L1_proc_tx; @@ -371,9 +373,10 @@ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { //printf("%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf); //int i; struct timespec wait; - wait.tv_sec=0; - wait.tv_nsec=5000000L; - + clock_gettime(CLOCK_REALTIME, &wait); + wait.tv_sec = 0; + wait.tv_nsec +=5000000L; + //wait.tv_nsec = 0; // wake up TX for subframe n+sf_ahead // lock the TX mutex and make sure the thread is ready if (pthread_mutex_timedlock(&L1_proc->mutex,&wait) != 0) { @@ -390,7 +393,7 @@ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { // Try to be 1 frame back old_slot = slot; old_sfn = sfn; - + //printf("\n wake_gNB_rxtx after assignment sfn:%d slot:%d",proc->frame_rx,proc->slot_rx); if (old_slot == 0 && old_sfn % 100 == 0) LOG_W( PHY,"[gNB] sfn/slot:%d%d old_sfn/slot:%d%d proc[rx:%d%d]\n", sfn, slot, old_sfn, old_slot, proc->frame_rx, proc->slot_rx); } @@ -405,15 +408,15 @@ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) { L1_proc->timestamp_tx = proc->timestamp_rx + (slot_ahead *fp->samples_per_tti); L1_proc->frame_rx = proc->frame_rx; L1_proc->slot_rx = proc->slot_rx; - L1_proc->frame_tx = (L1_proc->slot_rx > (9-slot_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; + L1_proc->frame_tx = (L1_proc->slot_rx > (19-slot_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx; L1_proc->slot_tx = (L1_proc->slot_rx + slot_ahead)%20; //LOG_D(PHY, "sfn/sf:%d%d proc[rx:%d%d] L1_proc[instance_cnt_rxtx:%d rx:%d%d] About to wake rxtx thread\n\n", sfn, sf, proc->frame_rx, proc->subframe_rx, L1_proc->instance_cnt_rxtx, L1_proc->frame_rx, L1_proc->subframe_rx); - + //printf("\nEntering wake_gNB_rxtx sfn %d slot %d\n",L1_proc->frame_rx,L1_proc->slot_rx); // the thread can now be woken up if (pthread_cond_signal(&L1_proc->cond) != 0) { LOG_E( PHY, "[gNB] ERROR pthread_cond_signal for gNB RXn-TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); + exit_fun( "ERROR pthread_clond_signal" ); return(-1); } @@ -512,7 +515,7 @@ int phy_slot_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uin if (RC.gNB && RC.gNB[0]->configured) { // uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf); // uint16_t sf = NFAPI_SFNSF2SF(sfn_sf); - //LOG_D(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf); + LOG_D(PHY,"[VNF] slot indication sfn:%d sf:%d\n", sfn, slot); wake_gNB_rxtx(RC.gNB[0], sfn, slot); // DONE: find NR equivalent } else { printf("[VNF] %s() RC.gNB:%p\n", __FUNCTION__, RC.gNB); @@ -1119,7 +1122,7 @@ int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_param_respons req->header.message_id = NFAPI_CONFIG_REQUEST; req->header.phy_id = phy->id; printf("[VNF] Send NFAPI_CONFIG_REQUEST\n"); - printf("\n NR bandP =%d\n",req->nfapi_config.rf_bands.rf_band[0]); + //printf("\n NR bandP =%d\n",req->nfapi_config.rf_bands.rf_band[0]); req->nfapi_config.p7_vnf_port.tl.tag = NFAPI_NR_NFAPI_P7_VNF_PORT_TAG; req->nfapi_config.p7_vnf_port.value = p7_vnf->local_port; @@ -1147,7 +1150,12 @@ int param_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_nr_param_respons req->num_tlv++; } } - +//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; +req->nfapi_config.tx_data_timing_offset.tl.tag = NFAPI_NR_NFAPI_TX_DATA_TIMING_OFFSET; + vendor_ext_tlv_2 ve2; memset(&ve2, 0, sizeof(ve2)); ve2.tl.tag = VENDOR_EXT_TLV_2_TAG; @@ -1249,7 +1257,8 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { vnf.p7_vnfs[0].config = nfapi_vnf_p7_config_create(); NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() vnf.p7_vnfs[0].config:%p VNF ADDRESS:%s:%d\n", __FUNCTION__, vnf.p7_vnfs[0].config, vnf_addr, vnf_p5_port); strcpy(vnf.p7_vnfs[0].local_addr, vnf_addr); - vnf.p7_vnfs[0].local_port = vnf.p7_vnfs[0].local_port; // 50001; // TODO: remove hardcode + //vnf.p7_vnfs[0].local_port = vnf.p7_vnfs[0].local_port; // 50001; // TODO: remove hardcode + vnf.p7_vnfs[0].local_port = 32123; vnf.p7_vnfs[0].mac = (mac_t *)malloc(sizeof(mac_t)); nfapi_vnf_config_t *config = nfapi_vnf_config_create(); config->malloc = malloc; @@ -1304,14 +1313,15 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_tti_request_t *dl_config_req) { + //printf("\nEntering oai_nfapi_nr_dl_config_req sfn:%d,slot:%d\n",dl_config_req->SFN,dl_config_req->Slot); nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config; dl_config_req->header.message_id= NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST; dl_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!! int retval = nfapi_vnf_p7_nr_dl_config_req(p7_config, dl_config_req); - dl_config_req->dl_tti_request_body.nPDUs = 0; - dl_config_req->dl_tti_request_body.nGroup = 0; + dl_config_req->nPDUs = 0; + dl_config_req->nGroup = 0; if (retval!=0) { diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index 7cd07f8071..bdb4f2ac01 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h @@ -126,6 +126,8 @@ typedef struct { #define NFAPI_SFNSLOT2SFN(_sfnslot) ((_sfnslot) >> 6) #define NFAPI_SFNSLOT2SLOT(_sfnslot) ((_sfnslot) & 0x3F) +#define NFAPI_SFNSLOTDEC2SFN(_sfnslot_dec) ((_sfnslot_dec) / 20) +#define NFAPI_SFNSLOTDEC2SLOT(_sfnslot_dec) ((_sfnslot_dec) % 20) #define NFAPI_MAX_SFNSLOTDEC 1024*20 // 20 is for numerology 1 @@ -1123,6 +1125,7 @@ typedef struct { uint32_t error_code; nfapi_pnf_param_general_t pnf_param_general; nfapi_pnf_phy_t pnf_phy; + /* nfapi_pnf_rf_t pnf_rf; nfapi_pnf_phy_rel10_t pnf_phy_rel10; nfapi_pnf_phy_rel11_t pnf_phy_rel11; @@ -1130,11 +1133,13 @@ typedef struct { nfapi_pnf_phy_rel13_t pnf_phy_rel13; nfapi_pnf_phy_rel13_nb_iot_t pnf_phy_rel13_nb_iot; nfapi_pnf_phy_rel15_t pnf_phy_rel15; + */ nfapi_vendor_extension_tlv_t vendor_extension; } nfapi_pnf_param_response_t; typedef struct { nfapi_p4_p5_message_header_t header; + uint8_t num_tlvs; nfapi_pnf_phy_rf_config_t pnf_phy_rf_config; nfapi_vendor_extension_tlv_t vendor_extension; } nfapi_pnf_config_request_t; @@ -2495,7 +2500,8 @@ typedef struct { typedef struct { nfapi_p7_message_header_t header; uint32_t t1; - int32_t delta_sfn_sf; + //int32_t delta_sfn_sf; + int32_t delta_sfn_slot; nfapi_vendor_extension_tlv_t vendor_extension; } nfapi_dl_node_sync_t; @@ -3708,22 +3714,30 @@ typedef struct nfapi_ipv4_address_t p7_pnf_address_ipv4; nfapi_ipv6_address_t p7_pnf_address_ipv6; nfapi_uint16_tlv_t p7_pnf_port; + + nfapi_uint8_tlv_t timing_window; //Value: 0 → 30,000 microseconds + nfapi_uint8_tlv_t timing_info_mode; + nfapi_uint8_tlv_t timing_info_period; + + nfapi_uint32_tlv_t dl_tti_timing_offset; + nfapi_uint32_tlv_t ul_tti_timing_offset; + nfapi_uint32_tlv_t ul_dci_timing_offset; + nfapi_uint32_tlv_t tx_data_timing_offset; - // // These TLVs are used to setup the transport connection between VNF and PNF + // These TLVs are used to setup the transport connection between VNF and PNF + /* nfapi_uint8_tlv_t dl_ue_per_sf; nfapi_uint8_tlv_t ul_ue_per_sf; // These TLVs are used by PNF to report its RF capabilities to the VNF software nfapi_rf_bands_t rf_bands; - +*/ // These TLVs are used by the VNF to configure the synchronization with the PNF. - nfapi_uint8_tlv_t timing_window; - nfapi_uint8_tlv_t timing_info_mode; - nfapi_uint8_tlv_t timing_info_period; + // These TLVs are used by the VNF to configure the RF in the PNF - nfapi_uint16_tlv_t max_transmit_power; - nfapi_uint32_tlv_t nrarfcn; + //nfapi_uint16_tlv_t max_transmit_power; + //nfapi_uint32_tlv_t nrarfcn; // nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands; // nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands; diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index 4e29787333..fbe7a0e170 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -23,28 +23,31 @@ //These TLVs are used exclusively by nFAPI +#define NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG 0x0100 +#define NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG 0x0101 +#define NFAPI_NR_NFAPI_P7_VNF_PORT_TAG 0x0102 +#define NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG 0x0103 +#define NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG 0x0104 +#define NFAPI_NR_NFAPI_P7_PNF_PORT_TAG 0x0105 +#define NFAPI_NR_NFAPI_DL_TTI_TIMING_OFFSET 0x0106 +#define NFAPI_NR_NFAPI_UL_TTI_TIMING_OFFSET 0x0107 +#define NFAPI_NR_NFAPI_UL_DCI_TIMING_OFFSET 0x0108 +#define NFAPI_NR_NFAPI_TX_DATA_TIMING_OFFSET 0x0109 +#define NFAPI_NR_NFAPI_TIMING_WINDOW_TAG 0x011E +#define NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG 0x011F +#define NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG 0x0120 - -#define NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG 0x5100 -#define NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG 0x5101 -#define NFAPI_NR_NFAPI_P7_VNF_PORT_TAG 0x5102 -#define NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG 0x5103 -#define NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG 0x5104 -#define NFAPI_NR_NFAPI_P7_PNF_PORT_TAG 0x5105 - +/* #define NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG 0x510A #define NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG 0x510B #define NFAPI_NR_NFAPI_RF_BANDS_TAG 0x5114 -#define NFAPI_NR_NFAPI_TIMING_WINDOW_TAG 0x511E -#define NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG 0x511F -#define NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG 0x5120 #define NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG 0x5128 #define NFAPI_NR_NFAPI_NRARFCN_TAG 0x5129 #define NFAPI_NR_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG 0x5130 #define NFAPI_NR_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG 0x5131 #define NFAPI_NR_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG 0x5132 #define NFAPI_NR_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG 0x5133 - +*/ // P5 Message Structures typedef struct { @@ -290,7 +293,7 @@ typedef enum { typedef enum { NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED=0, - NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED + NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED=1 } nfapi_nr_cce_reg_mapping_type_e; typedef enum { diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index 3daa538f75..8e88112ff0 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -24,13 +24,6 @@ #define NFAPI_MAX_NUM_GROUPS 8 #define NFAPI_MAX_NUM_CB 8 -#define NFAPI_NR_DL_TTI_CSI_RS_REL_IISC 0x5551 -#define NFAPI_NR_DL_TTI_PDCCH_REL_IISC 0x5552 -#define NFAPI_NR_DL_TTI_PDSCH_REL_IISC 0x5553 -#define NFAPI_NR_DL_TTI_SSB_REL_IISC 0x5554 -#define NFAPI_NR_UL_TTI_PDU_LIST_REL_IISC 0x5555 -#define NFAPI_NR_UL_TTI_GROUP_LIST_REL_IISC 0x5555 - // Extension to the generic structures for single tlv values @@ -730,7 +723,7 @@ typedef struct { ///Granularity of precoding [TS38.211 sec 7.3.2.2] Field Type Description 0: sameAsRegBundle 1: allContiguousRBs uint8_t precoderGranularity; ///Number of DCIs in this CORESET.Value: 0->MaxDciPerSlot - uint16_t numDlDci; + volatile uint16_t numDlDci; ///The RNTI used for identifying the UE when receiving the PDU Value: 1 -> 65535. uint16_t RNTI[MAX_DCI_CORESET]; ///For a UE-specific search space it equals the higher-layer parameter PDCCH-DMRSScrambling-ID if configured, otherwise it should be set to the phy cell ID. [TS38.211, sec 7.3.2.3] Value: 0->65535 @@ -993,6 +986,7 @@ typedef struct { } nfapi_nr_dl_tti_request_pdu_t; #define NFAPI_NR_MAX_DL_TTI_PDUS 32 +/* typedef struct { /// Number of PDUs that are included in this message. All PDUs in the message are numbered in order. Value 0 -> 255 uint8_t nPDUs; @@ -1005,14 +999,25 @@ typedef struct { /// This value is an index for number of PDU identified by nPDU in this message Value: 0 -> 255 uint8_t PduIdx[256][12]; } nfapi_nr_dl_tti_request_body_t; +*/ typedef struct { nfapi_p7_message_header_t header; /// System Frame Number (0-1023) uint16_t SFN; - /// Slot number (0-319) + /// Slot number (0-19) uint16_t Slot; - nfapi_nr_dl_tti_request_body_t dl_tti_request_body; + /// Number of PDUs that are included in this message. All PDUs in the message are numbered in order. Value 0 -> 255 + uint8_t nPDUs; + /// Number of UEs in the Group included in this message. Value 0 -> 255 + uint8_t nGroup; + /// List containing PDUs + nfapi_nr_dl_tti_request_pdu_t dl_tti_pdu_list[NFAPI_NR_MAX_DL_TTI_PDUS]; + //nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu_list; + /// Number of UE in this group. For SU-MIMO, one group includes one UE only. For MU-MIMO, one group includes up to 12 UEs. Value 1 -> 12 + uint8_t nUe[256]; + /// This value is an index for number of PDU identified by nPDU in this message Value: 0 -> 255 + uint8_t PduIdx[256][12]; nfapi_vendor_extension_tlv_t vendor_extension; } nfapi_nr_dl_tti_request_t; diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c index c804b569d8..aaa239bbbd 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p5.c @@ -244,12 +244,14 @@ static uint8_t pack_pnf_param_response(void *msg, uint8_t **ppWritePackedMsg, ui return (push32(pNfapiMsg->error_code, ppWritePackedMsg, end) && pack_tlv(NFAPI_PNF_PARAM_GENERAL_TAG, &pNfapiMsg->pnf_param_general, ppWritePackedMsg, end, &pack_pnf_param_general_value) && pack_tlv(NFAPI_PNF_PHY_TAG, &pNfapiMsg->pnf_phy, ppWritePackedMsg, end, &pack_pnf_phy_value) && + /* pack_tlv(NFAPI_PNF_RF_TAG, &pNfapiMsg->pnf_rf, ppWritePackedMsg, end, &pack_pnf_rf_value) && pack_tlv(NFAPI_PNF_PHY_REL10_TAG, &pNfapiMsg->pnf_phy_rel10, ppWritePackedMsg, end, &pack_pnf_phy_rel10_value) && pack_tlv(NFAPI_PNF_PHY_REL11_TAG, &pNfapiMsg->pnf_phy_rel11, ppWritePackedMsg, end, &pack_pnf_phy_rel11_value) && pack_tlv(NFAPI_PNF_PHY_REL12_TAG, &pNfapiMsg->pnf_phy_rel12, ppWritePackedMsg, end, &pack_pnf_phy_rel12_value) && pack_tlv(NFAPI_PNF_PHY_REL13_TAG, &pNfapiMsg->pnf_phy_rel13, ppWritePackedMsg, end, &pack_pnf_phy_rel13_value) && pack_tlv(NFAPI_PNF_PHY_REL13_NB_IOT_TAG, &pNfapiMsg->pnf_phy_rel13_nb_iot, ppWritePackedMsg, end, &pack_pnf_phy_rel13_nb_iot_value) && + */ pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); } @@ -275,8 +277,9 @@ static uint8_t pack_pnf_phy_rf_config_value(void *tlv, uint8_t **ppWritePackedMs static uint8_t pack_pnf_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config) { nfapi_pnf_config_request_t *pNfapiMsg = (nfapi_pnf_config_request_t*)msg; - return ( pack_tlv(NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, ppWritePackedMsg, end, &pack_pnf_phy_rf_config_value) && - pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end , config)); + return (pack_tlv(NFAPI_PNF_PHY_RF_TAG, &pNfapiMsg->pnf_phy_rf_config, ppWritePackedMsg, end, &pack_pnf_phy_rf_config_value) && + //push8(pNfapiMsg->num_tlvs,ppWritePackedMsg,end) && + pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end , config)); } @@ -574,18 +577,16 @@ static uint8_t pack_param_response(void *msg, uint8_t **ppWritePackedMsg, uint8_ pack_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && pack_tlv(NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && - + pack_tlv(NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + /* pack_tlv(NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.dl_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.ul_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_NFAPI_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), ppWritePackedMsg, end, &pack_rf_bands_value) && - - pack_tlv(NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &(pNfapiMsg->nfapi_config.max_transmit_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && - + */ // vendor extension: pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); @@ -750,20 +751,20 @@ static uint8_t pack_config_request(void *msg, uint8_t **ppWritePackedMsg, uint8_ pack_tlv(NFAPI_NR_CONFIG_TDD_PERIOD_TAG, &(pNfapiMsg->tdd_table.tdd_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_CONFIG_SLOT_CONFIG_TAG, &(pNfapiMsg->tdd_table.max_tdd_periodicity_list[0].max_num_of_symbol_per_slot_list[0].slot_config), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.dl_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &(pNfapiMsg->nfapi_config.max_transmit_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_NRARFCN_TAG, &(pNfapiMsg->nfapi_config.nrarfcn), ppWritePackedMsg, end, &pack_uint32_tlv_value) && + //pack_tlv(NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.dl_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + //pack_tlv(NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &(pNfapiMsg->nfapi_config.max_transmit_power), ppWritePackedMsg, end, &pack_uint16_tlv_value) && + //pack_tlv(NFAPI_NR_NFAPI_NRARFCN_TAG, &(pNfapiMsg->nfapi_config.nrarfcn), ppWritePackedMsg, end, &pack_uint32_tlv_value) && pack_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && pack_tlv(NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && pack_tlv(NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && pack_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), ppWritePackedMsg, end, &pack_ipv4_address_value) && pack_tlv(NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6), ppWritePackedMsg, end, &pack_ipv6_address_value) && pack_tlv(NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_port), ppWritePackedMsg, end, &pack_uint16_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), ppWritePackedMsg, end, &pack_rf_bands_value) && + //pack_tlv(NFAPI_NR_NFAPI_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), ppWritePackedMsg, end, &pack_rf_bands_value) && pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_tlv(NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), ppWritePackedMsg, end, &pack_uint8_tlv_value) && - pack_tlv(NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.ul_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && + //pack_tlv(NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.ul_ue_per_sf), ppWritePackedMsg, end, &pack_uint8_tlv_value) && pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) ); @@ -1350,12 +1351,14 @@ static uint8_t unpack_pnf_param_response(uint8_t **ppReadPackedMsg, uint8_t *end { { NFAPI_PNF_PARAM_GENERAL_TAG, &pNfapiMsg->pnf_param_general, &unpack_pnf_param_general_value}, { NFAPI_PNF_PHY_TAG, &pNfapiMsg->pnf_phy, &unpack_pnf_phy_value}, + /* { NFAPI_PNF_RF_TAG, &pNfapiMsg->pnf_rf, &unpack_pnf_rf_value}, { NFAPI_PNF_PHY_REL10_TAG, &pNfapiMsg->pnf_phy_rel10, &unpack_pnf_phy_rel10_value}, { NFAPI_PNF_PHY_REL11_TAG, &pNfapiMsg->pnf_phy_rel11, &unpack_pnf_phy_rel11_value}, { NFAPI_PNF_PHY_REL12_TAG, &pNfapiMsg->pnf_phy_rel12, &unpack_pnf_phy_rel12_value}, { NFAPI_PNF_PHY_REL13_TAG, &pNfapiMsg->pnf_phy_rel13, &unpack_pnf_phy_rel13_value}, { NFAPI_PNF_PHY_REL13_NB_IOT_TAG, &pNfapiMsg->pnf_phy_rel13_nb_iot, &unpack_pnf_phy_rel13_nb_iot_value}, + */ }; return ( pull32(ppReadPackedMsg, &pNfapiMsg->error_code, end) && @@ -1538,13 +1541,15 @@ static uint8_t unpack_param_response(uint8_t **ppReadPackedMsg, uint8_t *end, vo { NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv4, &unpack_ipv4_address_value}, { NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &pNfapiMsg->nfapi_config.p7_pnf_address_ipv6, &unpack_ipv6_address_value}, { NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &pNfapiMsg->nfapi_config.p7_pnf_port, &unpack_uint16_tlv_value}, - { NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &pNfapiMsg->nfapi_config.dl_ue_per_sf, &unpack_uint8_tlv_value}, - { NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &pNfapiMsg->nfapi_config.ul_ue_per_sf, &unpack_uint8_tlv_value}, - { NFAPI_NR_NFAPI_RF_BANDS_TAG, &pNfapiMsg->nfapi_config.rf_bands, &unpack_rf_bands_value}, { NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &pNfapiMsg->nfapi_config.timing_window, &unpack_uint8_tlv_value}, { NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &pNfapiMsg->nfapi_config.timing_info_mode, &unpack_uint8_tlv_value}, { NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &pNfapiMsg->nfapi_config.timing_info_period, &unpack_uint8_tlv_value}, +/* + { NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &pNfapiMsg->nfapi_config.dl_ue_per_sf, &unpack_uint8_tlv_value}, + { NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &pNfapiMsg->nfapi_config.ul_ue_per_sf, &unpack_uint8_tlv_value}, + { NFAPI_NR_NFAPI_RF_BANDS_TAG, &pNfapiMsg->nfapi_config.rf_bands, &unpack_rf_bands_value}, { NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &pNfapiMsg->nfapi_config.max_transmit_power, &unpack_uint16_tlv_value} +*/ }; #if LTE { NFAPI_L1_STATUS_PHY_STATE_TAG, &pNfapiMsg->l1_status.phy_state, &unpack_uint16_tlv_value}, @@ -1695,20 +1700,20 @@ static uint8_t unpack_config_request(uint8_t **ppReadPackedMsg, uint8_t *end, vo { NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG, &(pNfapiMsg->ssb_table.ssb_subcarrier_offset), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_TDD_PERIOD_TAG, &(pNfapiMsg->tdd_table.tdd_period), &unpack_uint8_tlv_value}, { NFAPI_NR_CONFIG_SLOT_CONFIG_TAG, &(pNfapiMsg->tdd_table.max_tdd_periodicity_list[0].max_num_of_symbol_per_slot_list[0].slot_config), &unpack_uint8_tlv_value}, - { NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.dl_ue_per_sf), &unpack_uint8_tlv_value}, - { NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &(pNfapiMsg->nfapi_config.max_transmit_power), &unpack_uint16_tlv_value}, - { NFAPI_NR_NFAPI_NRARFCN_TAG, &(pNfapiMsg->nfapi_config.nrarfcn), &unpack_uint32_tlv_value}, + //{ NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.dl_ue_per_sf), &unpack_uint8_tlv_value}, + //{ NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG, &(pNfapiMsg->nfapi_config.max_transmit_power), &unpack_uint16_tlv_value}, + //{ NFAPI_NR_NFAPI_NRARFCN_TAG, &(pNfapiMsg->nfapi_config.nrarfcn), &unpack_uint32_tlv_value}, { NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv4), &unpack_ipv4_address_value}, { NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_address_ipv6), &unpack_ipv6_address_value}, { NFAPI_NR_NFAPI_P7_PNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_pnf_port), &unpack_uint16_tlv_value}, { NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV4_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), &unpack_ipv4_address_value}, { NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv6), &unpack_ipv6_address_value}, { NFAPI_NR_NFAPI_P7_VNF_PORT_TAG, &(pNfapiMsg->nfapi_config.p7_vnf_port), &unpack_uint16_tlv_value}, - { NFAPI_NR_NFAPI_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), &unpack_rf_bands_value}, + //{ NFAPI_NR_NFAPI_RF_BANDS_TAG, &(pNfapiMsg->nfapi_config.rf_bands), &unpack_rf_bands_value}, { NFAPI_NR_NFAPI_TIMING_INFO_MODE_TAG, &(pNfapiMsg->nfapi_config.timing_info_mode), &unpack_uint8_tlv_value}, { NFAPI_NR_NFAPI_TIMING_INFO_PERIOD_TAG, &(pNfapiMsg->nfapi_config.timing_info_period), &unpack_uint8_tlv_value}, { NFAPI_NR_NFAPI_TIMING_WINDOW_TAG, &(pNfapiMsg->nfapi_config.timing_window), &unpack_uint8_tlv_value}, - { NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.ul_ue_per_sf), &unpack_uint8_tlv_value}, + //{ NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG, &(pNfapiMsg->nfapi_config.ul_ue_per_sf), &unpack_uint8_tlv_value}, }; #if LTE { diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index 0ac76d00b4..65f67ef501 100755 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -284,17 +284,17 @@ static uint8_t pack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppWritePac push8(value->precoderGranularity, ppWritePackedMsg, end) && push16(value->numDlDci, ppWritePackedMsg, end) && - pusharray16(value->RNTI, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pusharray16(value->ScramblingId, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && + pusharray16(value->RNTI, MAX_DCI_CORESET, value->numDlDci, ppWritePackedMsg, end) && + pusharray16(value->ScramblingId, MAX_DCI_CORESET, value->numDlDci, ppWritePackedMsg, end) && - pusharray16(value->ScramblingRNTI, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pusharray8(value->CceIndex, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pusharray8(value->AggregationLevel, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pusharray8(value->beta_PDCCH_1_0, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && + pusharray16(value->ScramblingRNTI, MAX_DCI_CORESET, value->numDlDci, ppWritePackedMsg, end) && + pusharray8(value->CceIndex, MAX_DCI_CORESET, value->numDlDci, ppWritePackedMsg, end) && + pusharray8(value->AggregationLevel, MAX_DCI_CORESET, value->numDlDci, ppWritePackedMsg, end) && + pusharray8(value->beta_PDCCH_1_0, MAX_DCI_CORESET, value->numDlDci, ppWritePackedMsg, end) && - pusharray8(value->powerControlOffsetSS, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pusharray16(value->PayloadSizeBits, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pusharray8(value->Payload[0], MAX_DCI_CORESET*DCI_PAYLOAD_BYTE_LEN, 1, ppWritePackedMsg, end) + pusharray8(value->powerControlOffsetSS, MAX_DCI_CORESET, value->numDlDci, ppWritePackedMsg, end) && + pusharray16(value->PayloadSizeBits, MAX_DCI_CORESET, value->numDlDci, ppWritePackedMsg, end) && + pusharray8(value->Payload[0], MAX_DCI_CORESET*DCI_PAYLOAD_BYTE_LEN, value->numDlDci, ppWritePackedMsg, end) ); } @@ -701,116 +701,50 @@ static uint8_t pack_dl_config_ndlsch_pdu_rel13_value(void* tlv, uint8_t **ppWrit static uint8_t pack_dl_tti_request_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { - nfapi_nr_dl_tti_request_body_t* value = (nfapi_nr_dl_tti_request_body_t*)tlv; + nfapi_nr_dl_tti_request_pdu_t* value = (nfapi_nr_dl_tti_request_pdu_t*)tlv; - //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() dci:%u pdu:%u pdsch:%u rnti:%u pcfich:%u\n", __FUNCTION__, value->number_dci, value->number_pdu, value->number_pdsch_rnti, value->transmission_power_pcfich); + if(!(push8(value->PDUSize, ppWritePackedMsg, end) && + push8(value->PDUType, ppWritePackedMsg, end) )) + return 0; - if(!(push8(value->nGroup, ppWritePackedMsg, end) && - push8(value->nPDUs, ppWritePackedMsg, end) && - push8(value->nUe, ppWritePackedMsg, end) && - push8(value->PduIdx, ppWritePackedMsg, end))) + + // first match the pdu type, then call the respective function + switch(value->PDUType) { - return 0; - } - - uint16_t i = 0; - uint16_t total_number_of_pdus = value->nPDUs; - for(; i < total_number_of_pdus; ++i) - { - nfapi_nr_dl_tti_request_pdu_t* pdu = &(value->dl_tti_pdu_list[i]); - - if(push8(pdu->PDUType, ppWritePackedMsg, end) == 0) - return 0; - - // Put a 0 size in and then determine the size after the pdu - // has been writen and write the calculated size - uint8_t* pWritePackedMsgPduSize = *ppWritePackedMsg; - pdu->PDUSize = 0; - if(push8(pdu->PDUSize, ppWritePackedMsg, end) == 0) - return 0; - - // TODO: cannot find appropriate TAGs, so using DUMMY_TAG for all the tlvs here - switch(pdu->PDUType) + case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: { - case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: - { - if( - !( pack_tlv( - NFAPI_NR_DL_TTI_CSI_RS_REL_IISC, - &pdu->csi_rs_pdu.csi_rs_pdu_rel15, - ppWritePackedMsg, end, - &pack_dl_tti_csi_rs_pdu_rel15_value) - ) - ) - { - return 0; - } - } - break; - - case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: - { - if( - !( pack_tlv( - NFAPI_NR_DL_TTI_PDCCH_REL_IISC, - &pdu->pdcch_pdu.pdcch_pdu_rel15, - ppWritePackedMsg, end, - &pack_dl_tti_pdcch_pdu_rel15_value) - ) - ) - { - return 0; - } - } - break; - - case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE: - { - if( - !( pack_tlv( - NFAPI_NR_DL_TTI_PDSCH_REL_IISC, - &pdu->pdsch_pdu.pdsch_pdu_rel15, - ppWritePackedMsg, end, - &pack_dl_tti_pdsch_pdu_rel15_value) - ) - ) - { - return 0; - } - } - break; - - case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: - { - if( - !( pack_tlv( - NFAPI_NR_DL_TTI_SSB_REL_IISC, - &pdu->ssb_pdu.ssb_pdu_rel15, - ppWritePackedMsg, end, - &pack_dl_tti_ssb_pdu_rel15_value) - ) - ) - { - return 0; - } - } - break; - - default: - { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid pdu type %d \n", pdu->PDUType ); - } - break; - + if(!(pack_dl_tti_csi_rs_pdu_rel15_value(&value->csi_rs_pdu.csi_rs_pdu_rel15,ppWritePackedMsg,end))) + return 0; } + break; - // add 1 for the pdu_type. The delta will include the pdu_size - pdu->PDUSize = 1 + (*ppWritePackedMsg - pWritePackedMsgPduSize); - push8(pdu->PDUSize, &pWritePackedMsgPduSize, end); + case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: + { + if(!(pack_dl_tti_pdcch_pdu_rel15_value(&value->pdcch_pdu.pdcch_pdu_rel15,ppWritePackedMsg,end))) + return 0; + } + break; + case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE: + { + if(!(pack_dl_tti_pdsch_pdu_rel15_value(&value->pdsch_pdu.pdsch_pdu_rel15,ppWritePackedMsg,end))) + return 0; + } + break; + case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: + { + if(!(pack_dl_tti_ssb_pdu_rel15_value(&value->ssb_pdu.ssb_pdu_rel15,ppWritePackedMsg,end))) + return 0; + } + break; + + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid DL_TTI pdu type %d \n", value->PDUType ); + } + break; } return 1; - } static uint8_t pack_dl_config_request_body_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) @@ -962,22 +896,34 @@ static uint8_t pack_dl_config_request_body_value(void* tlv, uint8_t **ppWritePac static uint8_t pack_dl_tti_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) { nfapi_nr_dl_tti_request_t *pNfapiMsg = (nfapi_nr_dl_tti_request_t*)msg; - - //return ( push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end) && - //pack_tlv(NFAPI_DL_CONFIG_REQUEST_BODY_TAG, &pNfapiMsg->dl_config_request_body, ppWritePackedMsg, end, &pack_dl_config_request_body_value) && - //pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); - { uint8_t w = push16(pNfapiMsg->SFN, ppWritePackedMsg, end); - uint8_t x = push16(pNfapiMsg->Slot, ppWritePackedMsg, end); - uint8_t y = pack_tlv(NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST, &pNfapiMsg->dl_tti_request_body, ppWritePackedMsg, end, &pack_dl_tti_request_body_value); - uint8_t z = pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config); - if (!w || !x || !y || !z) - { - NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() NFAPI_DL_CONFIG_REQUEST w:%u x:%u y:%u z:%u \n", __FUNCTION__,w,x,y,z); - } + if (!(push16(pNfapiMsg->SFN , ppWritePackedMsg, end) && + push16(pNfapiMsg->Slot , ppWritePackedMsg, end) && + push8(pNfapiMsg->nGroup , ppWritePackedMsg, end) && + push8(pNfapiMsg->nPDUs , ppWritePackedMsg, end) && + pusharray8(pNfapiMsg->nUe ,256,pNfapiMsg->nGroup, ppWritePackedMsg, end) + //pusharray8(pNfapiMsg->PduIdx[0] ,256,256, ppWritePackedMsg, end) + )) + return 0; - return w && x && y && z; - } + int arr[12]; + for(int i=0;inGroup;i++) + { + for(int j=0;jnUe[i];j++) + { + arr[j] = pNfapiMsg->PduIdx[i][j]; + } + if(!(pusharray8(arr,12,pNfapiMsg->nUe[i],ppWritePackedMsg, end))) + return 0; + } + + for(int i=0;inPDUs;i++) + { + if(!pack_dl_tti_request_body_value(&pNfapiMsg->dl_tti_pdu_list[i],ppWritePackedMsg,end)) + return 0; + } + +return 1; } @@ -1613,7 +1559,7 @@ static uint8_t pack_ul_tti_pdu_list_value(void* tlv, uint8_t **ppWritePackedMsg, return 0; - // first natch the pdu type, then call the respective function + // first match the pdu type, then call the respective function switch(value->pdu_type) { case NFAPI_NR_UL_CONFIG_PRACH_PDU_TYPE: @@ -3318,7 +3264,7 @@ static uint8_t pack_dl_node_sync(void *msg, uint8_t **ppWritePackedMsg, uint8_t nfapi_dl_node_sync_t *pNfapiMsg = (nfapi_dl_node_sync_t*)msg; return ( push32(pNfapiMsg->t1, ppWritePackedMsg, end) && - pushs32(pNfapiMsg->delta_sfn_sf, ppWritePackedMsg, end) && + pushs32(pNfapiMsg->delta_sfn_slot, ppWritePackedMsg, end) && pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config)); } @@ -3387,13 +3333,13 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack supplied pointers are null\n"); return -1; } -/* + /* printf("\n P7 MESSAGE SENT: \n"); for(int i=0; i< packedBufLen; i++){ printf("%d", *(uint8_t *)(pMessageBuf + i)); } printf("\n"); -*/ + */ // process the header if(!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) && push16(pMessageHeader->message_id, &pWritePackedMessage, end) && @@ -3575,144 +3521,144 @@ int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBu // Unpack routines // NR: -static uint8_t unpack_dl_tti_csi_rs_pdu_rel15_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +static uint8_t unpack_dl_tti_csi_rs_pdu_rel15_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { nfapi_nr_dl_tti_csi_rs_pdu_rel15_t* value = (nfapi_nr_dl_tti_csi_rs_pdu_rel15_t*)tlv; return( - pull16(value->bwp_size, ppWritePackedMsg, end) && - pull16(value->bwp_start, ppWritePackedMsg, end) && + pull16(ppReadPackedMsg, &value->bwp_size, end) && + pull16(ppReadPackedMsg, &value->bwp_start, end) && - pull8(value->subcarrier_spacing, ppWritePackedMsg, end) && - pull8(value->cyclic_prefix, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->subcarrier_spacing, end) && + pull8(ppReadPackedMsg, &value->cyclic_prefix, end) && - pull16(value->start_rb, ppWritePackedMsg, end) && - pull16(value->nr_of_rbs, ppWritePackedMsg, end) && + pull16(ppReadPackedMsg, &value->start_rb, end) && + pull16(ppReadPackedMsg, &value->nr_of_rbs, end) && - pull8(value->csi_type, ppWritePackedMsg, end) && - pull8(value->row, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->csi_type, end) && + pull8(ppReadPackedMsg, &value->row, end) && - pull16(value->freq_domain, ppWritePackedMsg, end) && - pull8(value->symb_l0, ppWritePackedMsg, end) && + pull16(ppReadPackedMsg, &value->freq_domain, end) && + pull8(ppReadPackedMsg, &value->symb_l0, end) && - push8(value->symb_l1, ppWritePackedMsg, end) && - pull8(value->cdm_type, ppWritePackedMsg, end) && + push8(ppReadPackedMsg, &value->symb_l1, end) && + pull8(ppReadPackedMsg, &value->cdm_type, end) && - pull8(value->freq_density, ppWritePackedMsg, end) && - pull16(value->scramb_id, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->freq_density, end) && + pull16(ppReadPackedMsg, &value->scramb_id, end) && - pull8(value->power_control_offset, ppWritePackedMsg, end) && - pull8(value->power_control_offset_ss, ppWritePackedMsg, end) + pull8(ppReadPackedMsg, &value->power_control_offset, end) && + pull8(ppReadPackedMsg, &value->power_control_offset_ss, end) ); } -static uint8_t unpack_dl_tti_pdcch_pdu_rel15_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +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; // TODO: resolve the packaging of array (currently sending a single element) return( - pull16(value->BWPSize, ppWritePackedMsg, end) && - pull16(value->BWPStart, ppWritePackedMsg, end) && - pull8(value->SubcarrierSpacing, ppWritePackedMsg, end) && - pull8(value->CyclicPrefix, ppWritePackedMsg, end) && + pull16(ppReadPackedMsg, &value->BWPSize, end) && + pull16(ppReadPackedMsg, &value->BWPStart, end) && + pull8(ppReadPackedMsg, &value->SubcarrierSpacing, end) && + pull8(ppReadPackedMsg, &value->CyclicPrefix, end) && - pull8(value->StartSymbolIndex, ppWritePackedMsg, end) && - pull8(value->DurationSymbols, ppWritePackedMsg, end) && - pullarray16(value->FreqDomainResource, 6, 1, ppWritePackedMsg, end) && - pull8(value->CceRegMappingType, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->StartSymbolIndex, end) && + pull8(ppReadPackedMsg, &value->DurationSymbols, end) && + pullarray16(ppReadPackedMsg, &value->FreqDomainResource, 6, 1, end) && + pull8(ppReadPackedMsg, &value->CceRegMappingType, end) && - pull8(value->RegBundleSize, ppWritePackedMsg, end) && - pull8(value->InterleaverSize, ppWritePackedMsg, end) && - pull8(value->CoreSetType, ppWritePackedMsg, end) && - pull16(value->ShiftIndex, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->RegBundleSize, end) && + pull8(ppReadPackedMsg, &value->InterleaverSize, end) && + pull8(ppReadPackedMsg, &value->CoreSetType, end) && + pull16(ppReadPackedMsg, &value->ShiftIndex, end) && - pull8(value->precoderGranularity, ppWritePackedMsg, end) && - pull16(value->numDlDci, ppWritePackedMsg, end) && - pullarray16(value->RNTI, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pullarray16(value->ScramblingId, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->precoderGranularity, end) && + pull16(ppReadPackedMsg, &value->numDlDci, end) && + pullarray16(ppReadPackedMsg, &value->RNTI, MAX_DCI_CORESET, value->numDlDci, end) && + pullarray16(ppReadPackedMsg, &value->ScramblingId, MAX_DCI_CORESET, value->numDlDci, end) && - pullarray16(value->ScramblingRNTI, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pullarray8(value->CceIndex, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pullarray8(value->AggregationLevel, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pullarray8(value->beta_PDCCH_1_0, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && + pullarray16(ppReadPackedMsg, &value->ScramblingRNTI, MAX_DCI_CORESET, value->numDlDci, end) && + pullarray8(ppReadPackedMsg, &value->CceIndex, MAX_DCI_CORESET, value->numDlDci, end) && + pullarray8(ppReadPackedMsg, &value->AggregationLevel, MAX_DCI_CORESET,value->numDlDci, end) && + pullarray8(ppReadPackedMsg, &value->beta_PDCCH_1_0, MAX_DCI_CORESET, value->numDlDci, end) && - pullarray8(value->powerControlOffsetSS, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pullarray16(value->PayloadSizeBits, MAX_DCI_CORESET, 1, ppWritePackedMsg, end) && - pullarray8(value->Payload[0], MAX_DCI_CORESET*DCI_PAYLOAD_BYTE_LEN, 1, ppWritePackedMsg, end) + pullarray8(ppReadPackedMsg, &value->powerControlOffsetSS, MAX_DCI_CORESET, value->numDlDci, end) && + pullarray16(ppReadPackedMsg, &value->PayloadSizeBits, MAX_DCI_CORESET, value->numDlDci, end) && + pullarray8(ppReadPackedMsg, &value->Payload[0], MAX_DCI_CORESET*DCI_PAYLOAD_BYTE_LEN, value->numDlDci, end) ); } -static uint8_t unpack_dl_tti_pdsch_pdu_rel15_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +static uint8_t unpack_dl_tti_pdsch_pdu_rel15_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { 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) return( - pull16(value->pduBitmap, ppWritePackedMsg, end) && - pull16(value->rnti, ppWritePackedMsg, end) && - pull16(value->pduIndex, ppWritePackedMsg, end) && - pull16(value->BWPSize, ppWritePackedMsg, end) && + pull16(ppReadPackedMsg, &value->pduBitmap, end) && + pull16(ppReadPackedMsg, &value->rnti, end) && + pull16(ppReadPackedMsg, &value->pduIndex, end) && + pull16(ppReadPackedMsg, &value->BWPSize, end) && - pull16(value->BWPStart, ppWritePackedMsg, end) && - pull8(value->SubcarrierSpacing, ppWritePackedMsg, end) && - pull8(value->CyclicPrefix, ppWritePackedMsg, end) && - pull8(value->NrOfCodewords, ppWritePackedMsg, end) && + pull16(ppReadPackedMsg, &value->BWPStart, end) && + pull8(ppReadPackedMsg, &value->SubcarrierSpacing, end) && + pull8(ppReadPackedMsg, &value->CyclicPrefix, end) && + pull8(ppReadPackedMsg, &value->NrOfCodewords, end) && - pullarray16(value->targetCodeRate, 2, 1, ppWritePackedMsg, end) && - pullarray8(value->qamModOrder, 2, 1, ppWritePackedMsg, end) && - pullarray8(value->mcsIndex, 2, 1, ppWritePackedMsg, end) && - pullarray8(value->mcsTable, 2, 1, ppWritePackedMsg, end) && + pullarray16(ppReadPackedMsg, &value->targetCodeRate, 2, 1, end) && + pullarray8(ppReadPackedMsg, &value->qamModOrder, 2, 1, end) && + pullarray8(ppReadPackedMsg, &value->mcsIndex, 2, 1, end) && + pullarray8(ppReadPackedMsg, &value->mcsTable, 2, 1, end) && - pullarray8(value->rvIndex, 2, 1, ppWritePackedMsg, end) && - pullarray32(value->TBSize, 2, 1, ppWritePackedMsg, end) && - pull16(value->dataScramblingId, ppWritePackedMsg, end) && - pull8(value->nrOfLayers, ppWritePackedMsg, end) && + pullarray8(ppReadPackedMsg, &value->rvIndex, 2, 1, end) && + pullarray32(ppReadPackedMsg, &value->TBSize, 2, 1, end) && + pull16(ppReadPackedMsg, &value->dataScramblingId, end) && + pull8(ppReadPackedMsg, &value->nrOfLayers, end) && - pull8(value->transmissionScheme, ppWritePackedMsg, end) && - pull8(value->refPoint, ppWritePackedMsg, end) && - pull16(value->dlDmrsSymbPos, ppWritePackedMsg, end) && - pull8(value->dmrsConfigType, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->transmissionScheme, end) && + pull8(ppReadPackedMsg, &value->refPoint, end) && + pull16(ppReadPackedMsg, &value->dlDmrsSymbPos, end) && + pull8(ppReadPackedMsg, &value->dmrsConfigType, end) && - pull16(value->dlDmrsScramblingId, ppWritePackedMsg, end) && - pull8(value->SCID, ppWritePackedMsg, end) && - pull8(value->numDmrsCdmGrpsNoData, ppWritePackedMsg, end) && - pull16(value->dmrsPorts, ppWritePackedMsg, end) && + pull16(ppReadPackedMsg, &value->dlDmrsScramblingId, end) && + pull8(ppReadPackedMsg, &value->SCID, end) && + pull8(ppReadPackedMsg, &value->numDmrsCdmGrpsNoData, end) && + pull16(ppReadPackedMsg, &value->dmrsPorts, end) && - pull8(value->resourceAlloc, ppWritePackedMsg, end) && - pullarray8(value->rbBitmap, 36, 1, ppWritePackedMsg, end) && - pull16(value->rbStart, ppWritePackedMsg, end) && - pull16(value->rbSize, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->resourceAlloc, end) && + pullarray8(ppReadPackedMsg, &value->rbBitmap, 36, 1, end) && + pull16(ppReadPackedMsg, &value->rbStart, end) && + pull16(ppReadPackedMsg, &value->rbSize, end) && - pull8(value->VRBtoPRBMapping, ppWritePackedMsg, end) && - pull8(value->StartSymbolIndex, ppWritePackedMsg, end) && - pull8(value->NrOfSymbols, ppWritePackedMsg, end) && - pull8(value->PTRSPortIndex, ppWritePackedMsg, end) && + pull8(ppReadPackedMsg, &value->VRBtoPRBMapping, end) && + pull8(ppReadPackedMsg, &value->StartSymbolIndex, end) && + pull8(ppReadPackedMsg, &value->NrOfSymbols, end) && + pull8(ppReadPackedMsg, &value->PTRSPortIndex, end) && - pull8(value->PTRSTimeDensity, ppWritePackedMsg, end) && - pull8(value->PTRSFreqDensity, ppWritePackedMsg, end) && - pull8(value->PTRSReOffset, ppWritePackedMsg, end) + pull8(ppReadPackedMsg, &value->PTRSTimeDensity, end) && + pull8(ppReadPackedMsg, &value->PTRSFreqDensity, end) && + pull8(ppReadPackedMsg, &value->PTRSReOffset, end) ); } -static uint8_t unpack_dl_tti_ssb_pdu_rel15_value(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end) +static uint8_t unpack_dl_tti_ssb_pdu_rel15_value(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end) { nfapi_nr_dl_tti_ssb_pdu_rel15_t* value = (nfapi_nr_dl_tti_ssb_pdu_rel15_t*)tlv; return( - pull16(value->PhysCellId, ppWritePackedMsg, end) && - pull8(value->BetaPss, ppWritePackedMsg, end) && - pull8(value->SsbBlockIndex, ppWritePackedMsg, end) && - pull8(value->SsbSubcarrierOffset, ppWritePackedMsg, end) && - pull16(value->ssbOffsetPointA, ppWritePackedMsg, end) && - pull8(value->bchPayloadFlag, ppWritePackedMsg, end) && - pull32(value->bchPayload, ppWritePackedMsg, end) + pull16(ppReadPackedMsg, &value->PhysCellId, end) && + pull8(ppReadPackedMsg, &value->BetaPss, end) && + pull8(ppReadPackedMsg, &value->SsbBlockIndex, end) && + pull8(ppReadPackedMsg, &value->SsbSubcarrierOffset, end) && + pull16(ppReadPackedMsg, &value->ssbOffsetPointA, end) && + pull8(ppReadPackedMsg, &value->bchPayloadFlag, end) && + pull32(ppReadPackedMsg, &value->bchPayload, end) // TODO: pack precoding_and_beamforming too ); @@ -4164,258 +4110,51 @@ static uint8_t unpack_dl_config_ndlsch_pdu_rel13_value(void *tlv, uint8_t **ppRe } -static uint8_t unpack_dl_tti_request_body_value(void *tlv, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config) +static uint8_t unpack_dl_tti_request_body_value(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg) { - nfapi_nr_dl_tti_request_body_t* value = (nfapi_nr_dl_tti_request_body_t*)tlv; + nfapi_nr_dl_tti_request_pdu_t* value = (nfapi_nr_dl_tti_request_pdu_t*)msg; - if(!(pull8(ppReadPackedMsg, &value->nGroup, end) && - pull8(ppReadPackedMsg, &value->nPDUs, end) && - pull8(ppReadPackedMsg, &value->nUe, end) && - pull8(ppReadPackedMsg, &value->PduIdx, end) - )) - return 0; + if(!(pull8(ppReadPackedMsg, &value->PDUSize, end) && + pull8(ppReadPackedMsg, &value->PDUType, end) )) + return 0; - if(value->nPDUs > NFAPI_NR_MAX_DL_TTI_PDUS) + + // first match the pdu type, then call the respective function + switch(value->PDUType) { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s number of dl tti pdu's exceed maxium (count:%d max:%d)\n", __FUNCTION__, value->nPDUs, NFAPI_NR_MAX_DL_TTI_PDUS); - return 0; - } - - if(value->nPDUs) - { - // value->dl_tti_pdu_list = (nfapi_nr_dl_tti_request_pdu_t*)nfapi_p7_allocate(sizeof(nfapi_nr_dl_tti_request_pdu_t) * value->nPDUs, config); - if(value->dl_tti_pdu_list == NULL) + case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: { - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s failed to allocate dl config pdu list (count:%d)\n", __FUNCTION__, value->nPDUs); - return 0; + if(!(unpack_dl_tti_csi_rs_pdu_rel15_value(&value->csi_rs_pdu.csi_rs_pdu_rel15,ppReadPackedMsg,end))) + return 0; } - } - else - { - //value->dl_tti_pdu_list = 0; - } + break; - uint16_t i; - uint16_t total_number_of_pdus = value->nPDUs; - for(i = 0; i < total_number_of_pdus; ++i) - { - nfapi_nr_dl_tti_request_pdu_t* pdu = &(value->dl_tti_pdu_list[i]); - - if(!(pull8(ppReadPackedMsg, &pdu->PDUType, end) && - pull8(ppReadPackedMsg, &pdu->PDUSize, end))) - return 0; - - uint8_t *packedPduEnd = (*ppReadPackedMsg) + pdu->PDUSize - 2; - - if(packedPduEnd > end) + case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: { - // pdu end of beyond buffer end - return 0; + if(!(unpack_dl_tti_pdcch_pdu_rel15_value(&value->pdcch_pdu.pdcch_pdu_rel15,ppReadPackedMsg,end))) + return 0; } - switch(pdu->PDUSize) + break; + case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE: { - case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_NR_DL_TTI_CSI_RS_REL_IISC, &pdu->csi_rs_pdu.csi_rs_pdu_rel15, &unpack_dl_tti_csi_rs_pdu_rel15_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - - case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_NR_DL_TTI_PDCCH_REL_IISC, &pdu->pdcch_pdu.pdcch_pdu_rel15, &unpack_dl_tti_pdcch_pdu_rel15_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - - case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_NR_DL_TTI_PDSCH_REL_IISC, &pdu->pdsch_pdu.pdsch_pdu_rel15, &unpack_dl_tti_pdsch_pdu_rel15_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - - case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_NR_DL_TTI_SSB_REL_IISC, &pdu->ssb_pdu.ssb_pdu_rel15, &unpack_dl_tti_ssb_pdu_rel15_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - - - default: - // Need to log an error - break; + if(!(unpack_dl_tti_pdsch_pdu_rel15_value(&value->pdsch_pdu.pdsch_pdu_rel15,ppReadPackedMsg,end))) + return 0; } + break; + case NFAPI_NR_DL_TTI_SSB_PDU_TYPE: + { + if(!(unpack_dl_tti_ssb_pdu_rel15_value(&value->ssb_pdu.ssb_pdu_rel15,ppReadPackedMsg,end))) + return 0; + } + break; + + default: + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "FIXME : Invalid DL_TTI pdu type %d \n", value->PDUType ); + } + break; } - -#if 0 - switch(pdu->PDUSize) - { - case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel8, &unpack_dl_config_dci_dl_pdu_rel8_value}, - { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel9, &unpack_dl_config_dci_dl_pdu_rel9_value}, - { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel10, &unpack_dl_config_dci_dl_pdu_rel10_value}, - { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel11, &unpack_dl_config_dci_dl_pdu_rel11_value}, - { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel12, &unpack_dl_config_dci_dl_pdu_rel12_value}, - { NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG, &pdu->dci_dl_pdu.dci_dl_pdu_rel13, &unpack_dl_config_dci_dl_pdu_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_BCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG, &pdu->bch_pdu.bch_pdu_rel8, &unpack_dl_config_bch_pdu_rel8_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_MCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG, &pdu->mch_pdu.mch_pdu_rel8, &unpack_dl_config_mch_pdu_rel8_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel8, &unpack_dl_config_dlsch_pdu_rel8_value}, - { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel9, &unpack_dl_config_dlsch_pdu_rel9_value}, - { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel10, &unpack_dl_config_dlsch_pdu_rel10_value}, - { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel11, &unpack_dl_config_dlsch_pdu_rel11_value}, - { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel12, &unpack_dl_config_dlsch_pdu_rel12_value}, - { NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG, &pdu->dlsch_pdu.dlsch_pdu_rel13, &unpack_dl_config_dlsch_pdu_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_PCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG, &pdu->pch_pdu.pch_pdu_rel8, &unpack_dl_config_pch_pdu_rel8_value}, - { NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG, &pdu->pch_pdu.pch_pdu_rel13, &unpack_dl_config_pch_pdu_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_PRS_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG, &pdu->prs_pdu.prs_pdu_rel9, &unpack_dl_config_prs_pdu_rel9_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG, &pdu->csi_rs_pdu.csi_rs_pdu_rel10, &unpack_dl_config_csi_rs_pdu_rel10_value}, - { NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG, &pdu->csi_rs_pdu.csi_rs_pdu_rel13, &unpack_dl_config_csi_rs_pdu_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel8, &unpack_dl_config_dci_dl_pdu_rel8_value}, - { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel9, &unpack_dl_config_dci_dl_pdu_rel9_value}, - { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel10, &unpack_dl_config_dci_dl_pdu_rel10_value}, - { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel11, &unpack_dl_config_dci_dl_pdu_rel11_value}, - { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel12, &unpack_dl_config_dci_dl_pdu_rel12_value}, - { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG, &pdu->epdcch_pdu.epdcch_pdu_rel13, &unpack_dl_config_dci_dl_pdu_rel13_value}, - { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG, &pdu->epdcch_pdu.epdcch_params_rel11, &unpack_dl_config_epdcch_params_rel11_value}, - { NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG, &pdu->epdcch_pdu.epdcch_params_rel13, &unpack_dl_config_epdcch_params_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG, &pdu->mpdcch_pdu.mpdcch_pdu_rel13, &unpack_dl_config_mpdcch_pdu_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG, &pdu->nbch_pdu.nbch_pdu_rel13, &unpack_dl_config_nbch_pdu_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - } - break; - case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG, &pdu->npdcch_pdu.npdcch_pdu_rel13, &unpack_dl_config_npdcch_pdu_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - - } - break; - case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: - { - unpack_tlv_t unpack_fns[] = - { - { NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG, &pdu->ndlsch_pdu.ndlsch_pdu_rel13, &unpack_dl_config_ndlsch_pdu_rel13_value}, - }; - - unpack_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, packedPduEnd, 0, 0); - - } - break; - default: - // Need to log an error - break; - } - } -#endif return 1; } @@ -4627,15 +4366,37 @@ static uint8_t unpack_dl_config_request_body_value(void *tlv, uint8_t **ppReadPa static uint8_t unpack_dl_tti_request(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t* config) { nfapi_nr_dl_tti_request_t *pNfapiMsg = (nfapi_nr_dl_tti_request_t*)msg; - //TODO: Check if we need to add a seperate tag for dl_tti_request_body - unpack_p7_tlv_t unpack_fns[] = - { - { NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST, &pNfapiMsg->dl_tti_request_body, &unpack_dl_tti_request_body_value}, - }; - return ( pull16(ppReadPackedMsg, &pNfapiMsg->SFN, end) && - pull16(ppReadPackedMsg, &pNfapiMsg->Slot, end) && - unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); + if (!(pull16(ppReadPackedMsg,&pNfapiMsg->SFN, end) && + pull16(ppReadPackedMsg, &pNfapiMsg->Slot, end) && + pull8(ppReadPackedMsg, &pNfapiMsg->nGroup, end) && + pull8(ppReadPackedMsg, &pNfapiMsg->nPDUs, end) && + pullarray8(ppReadPackedMsg,&pNfapiMsg->nUe ,256,pNfapiMsg->nGroup, end) + //pusharray8(pNfapiMsg->PduIdx[0] ,256,256, ppWritePackedMsg, end) + )) + return 0; + if(pNfapiMsg->Slot % 2 != 0){ + printf("\nEntering unpack_dl_tti_request Odd sfn=%d,slot=%d\n",pNfapiMsg->SFN,pNfapiMsg->Slot); + } + + int arr[12]; + for(int i=0;inGroup;i++) + { + for(int j=0;jnUe[i];j++) + { + arr[j] = pNfapiMsg->PduIdx[i][j]; + } + if(!(pullarray8(ppReadPackedMsg,arr,12,pNfapiMsg->nUe[i], end))) + return 0; + } + + for(int i=0;inPDUs;i++) + { + if(!unpack_dl_tti_request_body_value(ppReadPackedMsg, end, &pNfapiMsg->dl_tti_pdu_list[i])) + return 0; + } + +return 1; } @@ -4645,11 +4406,11 @@ static uint8_t unpack_ul_tti_request_prach_pdu(void *tlv, uint8_t **ppReadPacked return( pull16(ppReadPackedMsg, &prach_pdu->phys_cell_id, end) && - pull8(ppReadPackedMsg, prach_pdu->num_prach_ocas, end) && - pull8(ppReadPackedMsg, prach_pdu->prach_format, end) && - pull8(ppReadPackedMsg, prach_pdu->num_ra, end) && - pull8(ppReadPackedMsg, prach_pdu->prach_start_symbol, end) && - pull16(ppReadPackedMsg, prach_pdu->num_cs, end) + pull8(ppReadPackedMsg, &prach_pdu->num_prach_ocas, end) && + pull8(ppReadPackedMsg, &prach_pdu->prach_format, end) && + pull8(ppReadPackedMsg, &prach_pdu->num_ra, end) && + pull8(ppReadPackedMsg, &prach_pdu->prach_start_symbol, end) && + pull16(ppReadPackedMsg, &prach_pdu->num_cs, end) // TODO: ignoring beamforming tlv for now ); } @@ -7475,7 +7236,7 @@ static uint8_t unpack_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void }; return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) && - pulls32(ppReadPackedMsg, &pNfapiMsg->delta_sfn_sf, end) && + pulls32(ppReadPackedMsg, &pNfapiMsg->delta_sfn_slot, end) && unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension)); } @@ -7710,7 +7471,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack supplied message buffer is too small %d, %d\n", messageBufLen, unpackedBufLen); return -1; } - + /* uint8_t *ptr = pMessageBuf; printf("\n Read P7 message unpack: "); while(ptr < end){ @@ -7718,7 +7479,7 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn ptr++; } printf("\n"); - +*/ // clean the supplied buffer for - tag value blanking (void)memset(pUnpackedBuf, 0, unpackedBufLen); diff --git a/nfapi/open-nFAPI/pnf/inc/pnf_p7.h b/nfapi/open-nFAPI/pnf/inc/pnf_p7.h index e8142f86c8..9af412976d 100644 --- a/nfapi/open-nFAPI/pnf/inc/pnf_p7.h +++ b/nfapi/open-nFAPI/pnf/inc/pnf_p7.h @@ -116,7 +116,7 @@ typedef struct { uint16_t sfn_sf; uint32_t sf_start_time_hr; int32_t sfn_sf_shift; - + uint16_t sfn; uint16_t slot; uint16_t sfn_slot; diff --git a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h index 0b3f9dd441..fbc8462b25 100644 --- a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h +++ b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h @@ -568,8 +568,8 @@ typedef struct nfapi_nr_tx_data_request_t* tx_data_req;//nfapi_tx_request_t* tx_req; //TODO: check these two later - nfapi_lbt_dl_config_request_t* lbt_dl_config_req; - nfapi_ue_release_request_t* ue_release_req; + //nfapi_lbt_dl_config_request_t* lbt_dl_config_req; + //nfapi_ue_release_request_t* ue_release_req; } nfapi_pnf_p7_slot_buffer_t; typedef struct nfapi_pnf_p7_config nfapi_pnf_p7_config_t; diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7.c b/nfapi/open-nFAPI/pnf/src/pnf_p7.c index b8f85787b8..c80cc7c2b7 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7.c @@ -156,15 +156,17 @@ nfapi_dl_config_request_t* allocate_nfapi_dl_config_request(pnf_p7_t* pnf_p7) void deallocate_nfapi_dl_tti_request(nfapi_nr_dl_tti_request_t* req, pnf_p7_t* pnf_p7) { //printf("%s() SFN/SF:%d %s req:%p pdu_list:%p\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), pnf_p7->_public.codec_config.deallocate ? "DEALLOCATE" : "FREE", req, req->dl_config_request_body.dl_config_pdu_list); + /* if(pnf_p7->_public.codec_config.deallocate) - { - (pnf_p7->_public.codec_config.deallocate)(req->dl_tti_request_body.dl_tti_pdu_list); + { + //nfapi_nr_dl_tti_request_pdu_t *temp = &req->dl_tti_pdu_list; + (pnf_p7->_public.codec_config.deallocate)(req); } else { - free(req->dl_tti_request_body.dl_tti_pdu_list); + free(req); } - +*/ pnf_p7_free(pnf_p7, req); } @@ -285,7 +287,7 @@ nfapi_tx_request_t* allocate_nfapi_tx_request(pnf_p7_t* pnf_p7) //TODO: Check if deallocate_nfapi_tx_data_request defn is proper void deallocate_nfapi_tx_data_request(nfapi_nr_tx_data_request_t* req, pnf_p7_t* pnf_p7) { - +/* if(pnf_p7->_public.codec_config.deallocate) { (pnf_p7->_public.codec_config.deallocate)(req->pdu_list); @@ -294,7 +296,7 @@ void deallocate_nfapi_tx_data_request(nfapi_nr_tx_data_request_t* req, pnf_p7_t* { free(req->pdu_list); } - +*/ pnf_p7_free(pnf_p7, req); } @@ -497,9 +499,9 @@ void pnf_p7_rx_reassembly_queue_remove_old_msgs(pnf_p7_t* pnf_p7, pnf_p7_rx_reas } -static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr) +static uint32_t get_slot_time(uint32_t now_hr, uint32_t slot_start_hr) { - if(now_hr < sf_start_hr) + if(now_hr < slot_start_hr) { //NFAPI_TRACE(NFAPI_TRACE_INFO, "now is earlier than start of subframe now_hr:%u sf_start_hr:%u\n", now_hr, sf_start_hr); return 0; @@ -507,15 +509,15 @@ static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr) else { uint32_t now_us = TIMEHR_USEC(now_hr); - uint32_t sf_start_us = TIMEHR_USEC(sf_start_hr); + uint32_t slot_start_us = TIMEHR_USEC(slot_start_hr); // if the us have wrapped adjust for it - if(now_hr < sf_start_us) + if(now_hr < slot_start_us) { - now_us += 1000000; + now_us += 500000; // changed from 1e6 - gokul } - return now_us - sf_start_us; + return now_us - slot_start_us; } } @@ -525,9 +527,9 @@ int pnf_p7_send_message(pnf_p7_t* pnf_p7, uint8_t* msg, uint32_t len) struct sockaddr_in remote_addr; memset((char*)&remote_addr, 0, sizeof(struct sockaddr_in)); remote_addr.sin_family = AF_INET; - remote_addr.sin_port = 32123;//htons(pnf_p7->_public.remote_p7_port); //hardcoding for now - //remote_addr.sin_addr.s_addr = inet_addr(pnf_p7->_public.remote_p7_addr); - + remote_addr.sin_port = htons(32123);//htons(pnf_p7->_public.remote_p7_port); //hardcoding for now + //remote_addr.sin_addr.s_addr = inet_addr(pnf_p7->_public.remote_p7_addr); + //remote_addr.sin_port = 0; // hardcoded by Gokul if(inet_aton(pnf_p7->_public.remote_p7_addr, &remote_addr.sin_addr) == -1) { @@ -538,7 +540,9 @@ int pnf_p7_send_message(pnf_p7_t* pnf_p7, uint8_t* msg, uint32_t len) socklen_t remote_addr_len = sizeof(struct sockaddr_in); int sendto_result; + if ((sendto_result = sendto((int)pnf_p7->p7_sock, (const char*)msg, len, 0, (const struct sockaddr*)&remote_addr, remote_addr_len)) < 0) +//if ((sendto_result = sendto((int)pnf_p7->p7_sock,"hello", 6, 0, (const struct sockaddr*)&remote_addr, remote_addr_len)) < 0) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s %s:%d sendto(%d, %p, %d) %d failed errno: %d\n", __FUNCTION__, pnf_p7->_public.remote_p7_addr, pnf_p7->_public.remote_p7_port, (int)pnf_p7->p7_sock, (const char*)msg, len, remote_addr_len, errno); return -1; @@ -731,12 +735,14 @@ void send_dummy_slot(pnf_p7_t* pnf_p7, uint16_t sfn, uint16_t slot) NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy hi_dci0 - enter\n"); (pnf_p7->_public.ul_dci_req_fn)(NULL, &pnf_p7->_public, pnf_p7->_public.dummy_slot.ul_dci_req); } + #if 0 if(pnf_p7->_public.lbt_dl_config_req && pnf_p7->_public.dummy_subframe.lbt_dl_config_req) // TODO: Change later { pnf_p7->_public.dummy_slot.lbt_dl_config_req->sfn_sf = sfn; NFAPI_TRACE(NFAPI_TRACE_INFO, "Dummy lbt - enter\n"); (pnf_p7->_public.lbt_dl_config_req)(&pnf_p7->_public, pnf_p7->_public.dummy_slot.lbt_dl_config_req); } + #endif } @@ -935,7 +941,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl (pnf_p7->_public.ul_dci_req_fn)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_slot.ul_dci_req); } } - + #if 0 if(tx_slot_buffer->ue_release_req != 0) // TODO: check later if needed { if(pnf_p7->_public.ue_release_req) @@ -951,7 +957,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl (pnf_p7->_public.ue_release_req)(&(pnf_p7->_public), pnf_p7->_public.dummy_slot.ue_release_req); } } - + #endif // TODO: add deallocate fns for the new structs if(tx_slot_buffer->dl_tti_req != 0) { @@ -970,12 +976,12 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl deallocate_nfapi_ul_dci_request(tx_slot_buffer->ul_dci_req, pnf_p7); tx_slot_buffer->ul_dci_req = 0; } - + #if 0 if(tx_slot_buffer->ue_release_req != 0){ deallocate_nfapi_ue_release_request(tx_slot_buffer->ue_release_req, pnf_p7); tx_slot_buffer->ue_release_req = 0; } - + #endif else { // If we ever need to "send" a dummy ul_config this won't work!!! @@ -1006,7 +1012,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl (pnf_p7->_public.ul_tti_req_fn)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_slot.ul_tti_req); } } - + #if 0 if(slot_buffer->lbt_dl_config_req != 0) { if(pnf_p7->_public.lbt_dl_config_req) @@ -1024,7 +1030,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl } //Change later } - + #endif //if(subframe_buffer->dl_config_req != 0) //deallocate_nfapi_dl_config_request(subframe_buffer->dl_config_req, pnf_p7); //if(subframe_buffer->tx_req != 0) @@ -1035,21 +1041,21 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl slot_buffer->ul_tti_req = 0; } - //if(subframe_buffer->hi_dci0_req != 0) - //deallocate_nfapi_hi_dci0_request(subframe_buffer->hi_dci0_req, pnf_p7); + #if 0 if(slot_buffer->lbt_dl_config_req != 0) { deallocate_nfapi_lbt_dl_config_request(slot_buffer->lbt_dl_config_req, pnf_p7); slot_buffer->lbt_dl_config_req = 0; } - } // sfn_sf match + #endif + } // sfn_slot match if ( slot_buffer->dl_tti_req == 0 && slot_buffer->tx_data_req == 0 && - slot_buffer->ul_tti_req == 0 && - slot_buffer->lbt_dl_config_req == 0 && - slot_buffer->ue_release_req == 0) + slot_buffer->ul_tti_req == 0) + //slot_buffer->lbt_dl_config_req == 0 && + //slot_buffer->ue_release_req == 0) { memset(&(pnf_p7->slot_buffer[buffer_index]), 0, sizeof(nfapi_pnf_p7_slot_buffer_t)); pnf_p7->slot_buffer[buffer_index].sfn = -1; @@ -1548,6 +1554,7 @@ void pnf_handle_dl_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) req->dl_config_request_body.transmission_power_pcfich ); #endif + if(is_nr_p7_request_in_window(req->SFN,req->Slot, "dl_tti_request", pnf_p7)) { uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(req->SFN,req->Slot); @@ -1556,7 +1563,7 @@ void pnf_handle_dl_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); - NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE DL_TTI_REQ sfn_sf:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_slot_dec, buffer_index); + NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE DL_TTI_REQ sfn_slot:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_slot_dec, buffer_index); // if there is already an dl_config_req make sure we free it. if(pnf_p7->slot_buffer[buffer_index].dl_tti_req != 0) @@ -2022,7 +2029,7 @@ void pnf_handle_tx_data_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7 // pMyPhyInfo->sfnSf, bufferIdx, // SFNSF2SFN(dreq->sfn_sf), SFNSF2SF(dreq->sfn_sf)); - deallocate_nfapi_tx_request(pnf_p7->subframe_buffer[buffer_index].tx_req, pnf_p7); + deallocate_nfapi_tx_data_request(pnf_p7->slot_buffer[buffer_index].tx_data_req, pnf_p7); } pnf_p7->slot_buffer[buffer_index].sfn = req->SFN; @@ -2297,7 +2304,8 @@ void pnf_handle_ue_release_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf deallocate_nfapi_ue_release_request(req, pnf_p7); } } - +/* +#if 0 uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr) { uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); @@ -2320,20 +2328,46 @@ uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_t return t2; } +#endif +*/ +uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn,uint16_t slot, uint32_t slot_start_time_hr) +{ + uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); + uint32_t t2 = (NFAPI_SFNSLOT2DEC(sfn, slot) * 500) + slot_time_us; -uint32_t calculate_t3(uint16_t sfn_sf, uint32_t sf_start_time_hr) + if (0) + { + static uint32_t prev_t2 = 0; + + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s(now_time_hr:%u sfn:%d slot:%d slot_start_time_Hr:%u) slot_time_us:%u t2:%u prev_t2:%u diff:%u\n", + __FUNCTION__, + now_time_hr, NFAPI_SFNSLOT2DEC(sfn, slot), slot_start_time_hr, + slot_time_us, + t2, + prev_t2, + t2-prev_t2); + + prev_t2 = t2; + } + + return t2; +} + +uint32_t calculate_t3(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) { uint32_t now_time_hr = pnf_get_current_time_hr(); - uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); + uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); - uint32_t t3 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us; + uint32_t t3 = (NFAPI_SFNSLOT2DEC(sfn, slot) * 500) + slot_time_us; return t3; } void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time) -{ +{ + //printf("Received DL node sync"); + nfapi_dl_node_sync_t dl_node_sync; //NFAPI_TRACE(NFAPI_TRACE_INFO, "DL_NODE_SYNC Received\n"); @@ -2358,11 +2392,11 @@ void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, u } - if (dl_node_sync.delta_sfn_sf != 0) + if (dl_node_sync.delta_sfn_slot != 0) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "Will shift SF timing by %d on next subframe\n", dl_node_sync.delta_sfn_sf); + NFAPI_TRACE(NFAPI_TRACE_INFO, "Will shift Slot timing by %d on next slot\n", dl_node_sync.delta_sfn_slot); - pnf_p7->sfn_sf_shift = dl_node_sync.delta_sfn_sf; + pnf_p7->slot_shift = dl_node_sync.delta_sfn_slot; } nfapi_ul_node_sync_t ul_node_sync; @@ -2370,8 +2404,10 @@ void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, u ul_node_sync.header.message_id = NFAPI_UL_NODE_SYNC; ul_node_sync.header.phy_id = dl_node_sync.header.phy_id; ul_node_sync.t1 = dl_node_sync.t1; - ul_node_sync.t2 = calculate_t2(rx_hr_time, pnf_p7->sfn_sf, pnf_p7->sf_start_time_hr); - ul_node_sync.t3 = calculate_t3(pnf_p7->sfn_sf, pnf_p7->sf_start_time_hr); + ul_node_sync.t2 = calculate_t2(rx_hr_time, pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr); + ul_node_sync.t3 = calculate_t3(pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr); +// ul_node_sync.t2 = ul_node_sync.t1 + 10; +// ul_node_sync.t3 = ul_node_sync.t2 + 10; // hardcoded - gokul if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) { @@ -2380,6 +2416,7 @@ void pnf_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, u } pnf_p7_pack_and_send_p7_message(pnf_p7, &(ul_node_sync.header), sizeof(ul_node_sync)); + //printf("\nSSent UL Node Sync sfn:%d,slot:%d\n",pnf_p7->sfn,pnf_p7->slot); } void pnf_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, uint32_t rx_hr_time) @@ -2414,6 +2451,7 @@ void pnf_dispatch_p7_message(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7, break; case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: + printf("\nEntering pnf_handle_dl_tti_request sfn=%d,slot=%d \n",pnf_p7->sfn,pnf_p7->slot); pnf_handle_dl_tti_request(pRecvMsg, recvMsgLen, pnf_p7); break; case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: @@ -2576,6 +2614,7 @@ void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time) int recvfrom_result = 0; struct sockaddr_in remote_addr; socklen_t remote_addr_size = sizeof(remote_addr); + remote_addr.sin_family = 2; // Gokul - hardcoded do { @@ -2605,6 +2644,7 @@ void pnf_nfapi_p7_read_dispatch_message(pnf_p7_t* pnf_p7, uint32_t now_hr_time) if(recvfrom_result > 0) { pnf_handle_p7_message(pnf_p7->rx_message_buffer, recvfrom_result, pnf_p7, now_hr_time); + printf("\npnf_handle_p7_message sfn=%d,slot=%d\n",pnf_p7->sfn,pnf_p7->slot); } } else if(recvfrom_result == 0) @@ -2683,7 +2723,8 @@ int pnf_p7_message_pump(pnf_p7_t* pnf_p7) struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; - addr.sin_port = htons(pnf_p7->_public.local_p7_port); + //addr.sin_port = htons(pnf_p7->_public.local_p7_port); Gokul + addr.sin_port = pnf_p7->_public.local_p7_port; if(pnf_p7->_public.local_p7_addr == 0) { @@ -2724,6 +2765,9 @@ int pnf_p7_message_pump(pnf_p7_t* pnf_p7) uint32_t now_hr_time = pnf_get_current_time_hr(); + + + if(selectRetval == 0) { // timeout @@ -2742,7 +2786,8 @@ int pnf_p7_message_pump(pnf_p7_t* pnf_p7) continue; } - if(FD_ISSET(pnf_p7->p7_sock, &rfds)) + if(FD_ISSET(pnf_p7->p7_sock, &rfds)) + { pnf_nfapi_p7_read_dispatch_message(pnf_p7, now_hr_time); } diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c b/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c index 0b77754a2f..8173027115 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c @@ -31,7 +31,7 @@ nfapi_pnf_p7_config_t* nfapi_pnf_p7_config_create() _this->_public.segment_size = 1400; _this->max_num_segments = 8; - _this->_public.subframe_buffer_size = 8; + _this->_public.subframe_buffer_size = 8;// TODO: Initialize the slot_buffer size _this->_public.timing_info_mode_periodic = 1; _this->_public.timing_info_period = 32; _this->_public.timing_info_mode_aperiodic = 1; diff --git a/nfapi/open-nFAPI/vnf/inc/vnf_p7.h b/nfapi/open-nFAPI/vnf/inc/vnf_p7.h index 6744053ec2..79991483f1 100644 --- a/nfapi/open-nFAPI/vnf/inc/vnf_p7.h +++ b/nfapi/open-nFAPI/vnf/inc/vnf_p7.h @@ -74,9 +74,12 @@ typedef struct nfapi_vnf_p7_connection_info { uint16_t min_sync_cycle_count; uint32_t latency[8]; uint32_t average_latency; - int32_t sf_offset_filtered; - int32_t sf_offset_trend; - int32_t sf_offset; + //int32_t sf_offset_filtered; + //int32_t sf_offset_trend; + //int32_t sf_offset; + int32_t slot_offset; + int32_t slot_offset_trend; + int32_t slot_offset_filtered; uint16_t zero_count; int32_t adjustment; int32_t insync_minor_adjustment; @@ -84,8 +87,8 @@ typedef struct nfapi_vnf_p7_connection_info { uint32_t previous_t1; uint32_t previous_t2; - int32_t previous_sf_offset_filtered; - + //int32_t previous_sf_offset_filtered; + int32_t previous_slot_offset_filtered; int sfn_sf; int sfn; int slot; @@ -112,7 +115,8 @@ typedef struct { uint8_t terminate; nfapi_vnf_p7_connection_info_t* p7_connections; int socket; - uint32_t sf_start_time_hr; +// uint32_t sf_start_time_hr; + uint32_t slot_start_time_hr; uint8_t* rx_message_buffer; // would this be better put in the p7 conenction info? uint16_t rx_message_buffer_size; diff --git a/nfapi/open-nFAPI/vnf/src/vnf.c b/nfapi/open-nFAPI/vnf/src/vnf.c index 06cb7a354e..a5998c9266 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf.c +++ b/nfapi/open-nFAPI/vnf/src/vnf.c @@ -802,7 +802,7 @@ void vnf_handle_vendor_extension(void* pRecvMsg, int recvMsgLen, nfapi_vnf_confi if(msg) { if(nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, msg, msg_size, &config->codec_config) >= 0) - {ṭ + { if(config->vendor_ext) config->vendor_ext(config, p5_idx, msg); } diff --git a/nfapi/open-nFAPI/vnf/src/vnf_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_interface.c index 2ceb9c1e8f..cb2083b6cf 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_interface.c @@ -664,7 +664,7 @@ int nfapi_vnf_allocate_phy(nfapi_vnf_config_t* config, int p5_idx, uint16_t* phy info->p5_idx = p5_idx; info->phy_id = vnf->next_phy_id++; - info->timing_window = 30; // This seems to override what gets set by the user - why??? + info->timing_window = 30; // This seems to override what gets set by the user - why??? //TODO: Change in NR in terms of microsecends,what should be the value? info->timing_info_mode = 0x03; info->timing_info_period = 128; diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c index e72b878af5..fd15fa99cc 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -299,11 +299,11 @@ struct timespec timespec_delta(struct timespec start, struct timespec end) return temp; } -static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr) +/*static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr) { if(now_hr < sf_start_hr) { - NFAPI_TRACE(NFAPI_TRACE_INFO, "now is earlier that start of subframe\n"); + NFAPI_TRACE(NFAPI_TRACE_INFO, "now is earlier than start of subframe\n"); return 0; } else @@ -319,9 +319,31 @@ static uint32_t get_sf_time(uint32_t now_hr, uint32_t sf_start_hr) return now_us - sf_start_us; } +}*/ + +static uint32_t get_slot_time(uint32_t now_hr, uint32_t slot_start_hr) +{ + if(now_hr < slot_start_hr) + { + NFAPI_TRACE(NFAPI_TRACE_INFO, "now is earlier than start of slot\n"); + return 0; + } + else + { + uint32_t now_us = TIMEHR_USEC(now_hr); + uint32_t slot_start_us = TIMEHR_USEC(slot_start_hr); + + // if the us have wrapped adjust for it + if(now_hr < slot_start_us) + { + now_us += 1000000; + } + + return now_us - slot_start_us; + } } -uint32_t calculate_t1(uint16_t sfn_sf, uint32_t sf_start_time_hr) +/*uint32_t calculate_t1(uint16_t sfn_sf, uint32_t sf_start_time_hr) { uint32_t now_time_hr = vnf_get_current_time_hr(); @@ -329,11 +351,22 @@ uint32_t calculate_t1(uint16_t sfn_sf, uint32_t sf_start_time_hr) uint32_t t1 = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us; + return t1; +}*/ + +uint32_t calculate_t1(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) +{ + uint32_t now_time_hr = vnf_get_current_time_hr(); + + uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); + + uint32_t t1 = (NFAPI_SFNSLOT2DEC(sfn,slot) * 500) + slot_time_us; + return t1; } -uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr) +/*uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_time_hr) { uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); @@ -341,16 +374,26 @@ uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_t return t4; +}*/ + +uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) +{ + uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); + + uint32_t t4 = (NFAPI_SFNSLOT2DEC(sfn,slot) * 500) + slot_time_us; + + return t4; + } -uint32_t calculate_transmit_timestamp(uint16_t sfn_sf, uint32_t sf_start_time_hr) +uint32_t calculate_transmit_timestamp(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) { uint32_t now_time_hr = vnf_get_current_time_hr(); - uint32_t sf_time_us = get_sf_time(now_time_hr, sf_start_time_hr); + uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); - uint32_t tt = (NFAPI_SFNSF2DEC(sfn_sf) * 1000) + sf_time_us; + uint32_t tt = (NFAPI_SFNSLOT2DEC(sfn, slot) * 500) + slot_time_us; return tt; } @@ -379,6 +422,7 @@ int send_mac_slot_indications(vnf_p7_t* vnf_p7) //vnf_p7->_public.subframe_indication(&(vnf_p7->_public), curr->phy_id, sfn_sf_adv); // suggestion fix by Haruki NAOI + //printf("\nsfn:%d, slot:%d\n",curr->sfn,curr->slot); vnf_p7->_public.slot_indication(&(vnf_p7->_public), curr->phy_id, curr->sfn,curr->slot); } @@ -412,7 +456,7 @@ int send_mac_subframe_indications(vnf_p7_t* vnf_p7) int vnf_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info, uint8_t* msg, const uint32_t len) { int sendto_result = sendto(vnf_p7->socket, msg, len, 0, (struct sockaddr*)&(p7_info->remote_addr), sizeof(p7_info->remote_addr)); - + //printf("\nSending p7 message sfn=%d,slot=%d\n",vnf_p7->p7_connections->sfn,vnf_p7->p7_connections->slot); if(sendto_result != len) { NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sendto_result %d %d\n", __FUNCTION__, sendto_result, errno); @@ -486,7 +530,7 @@ int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* hea nfapi_p7_update_checksum(tx_buffer, segment_size); } - nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn_sf, vnf_p7->sf_start_time_hr)); + nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &tx_buffer[0], segment_size); } @@ -498,7 +542,7 @@ int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* hea nfapi_p7_update_checksum(buffer, len); } - nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn_sf, vnf_p7->sf_start_time_hr)); + nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); // simple case that the message fits in a single segement send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &buffer[0], len); @@ -516,14 +560,16 @@ int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* hea } int vnf_build_send_dl_node_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info) -{ +{ + nfapi_dl_node_sync_t dl_node_sync; memset(&dl_node_sync, 0, sizeof(dl_node_sync)); dl_node_sync.header.phy_id = p7_info->phy_id; dl_node_sync.header.message_id = NFAPI_DL_NODE_SYNC; - dl_node_sync.t1 = calculate_t1(p7_info->sfn_sf, vnf_p7->sf_start_time_hr); - dl_node_sync.delta_sfn_sf = 0; + //dl_node_sync.t1 = calculate_t1(p7_info->sfn_sf, vnf_p7->sf_start_time_hr); + dl_node_sync.t1 = calculate_t1(p7_info->sfn,p7_info->slot, vnf_p7->slot_start_time_hr); + dl_node_sync.delta_sfn_slot = 0; return vnf_p7_pack_and_send_p7_msg(vnf_p7, &dl_node_sync.header); } @@ -534,9 +580,11 @@ int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info) if(p7_info->in_sync == 1) { uint16_t dl_sync_period_mask = p7_info->dl_in_sync_period-1; - uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf); + // uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf); + uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->sfn,p7_info->slot); - if ((((sfn_sf_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0) + //if ((((sfn_sf_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0) + if ((((sfn_slot_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSLOTDEC) & dl_sync_period_mask) == 0) { vnf_build_send_dl_node_sync(vnf_p7, p7_info); } @@ -544,9 +592,11 @@ int vnf_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info) else { uint16_t dl_sync_period_mask = p7_info->dl_out_sync_period-1; - uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf); + //uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf); + uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->sfn, p7_info->slot); - if ((((sfn_sf_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0) + //if ((((sfn_sf_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0) + if ((((sfn_slot_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSLOTDEC) & dl_sync_period_mask) == 0) { vnf_build_send_dl_node_sync(vnf_p7, p7_info); } @@ -899,7 +949,9 @@ void vnf_handle_p7_vendor_extension(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vn void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) -{ +{ + //printf("received UL Node sync"); + uint32_t now_time_hr = vnf_get_current_time_hr(); if (pRecvMsg == NULL || vnf_p7 == NULL) @@ -918,9 +970,9 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) //NFAPI_TRACE(NFAPI_TRACE_INFO, "Received UL_NODE_SYNC phy_id:%d t1:%d t2:%d t3:%d\n", ind.header.phy_id, ind.t1, ind.t2, ind.t3); nfapi_vnf_p7_connection_info_t* phy = vnf_p7_connection_info_list_find(vnf_p7, ind.header.phy_id); - uint32_t t4 = calculate_t4(now_time_hr, phy->sfn_sf, vnf_p7->sf_start_time_hr); + uint32_t t4 = calculate_t4(now_time_hr, phy->sfn, phy->slot, vnf_p7->slot_start_time_hr); - uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSFDEC - ind.t1 ; + uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSLOTDEC - ind.t1 ; //time taken to receive ul node sync - time taken to send dl node sync uint32_t pnf_proc_time = ind.t3 - ind.t2; // divide by 2 using shift operator @@ -931,7 +983,7 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) phy->latency[phy->min_sync_cycle_count] = latency; NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) PNF to VNF !sync phy_id:%d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d\n", - NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, ind.t1, ind.t2, ind.t3, t4, + phy->sfn, phy->slot, ind.header.phy_id, ind.t1, ind.t2, ind.t3, t4, tx_2_rx, pnf_proc_time, latency); } else @@ -943,30 +995,30 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) if (ind.t2 < phy->previous_t2 && ind.t1 > phy->previous_t1) { // Only t2 wrap has occurred!!! - phy->sf_offset = (NFAPI_MAX_SFNSFDEC + ind.t2) - ind.t1 - latency; + phy->slot_offset = (NFAPI_MAX_SFNSLOTDEC + ind.t2) - ind.t1 - latency; } else if (ind.t2 > phy->previous_t2 && ind.t1 < phy->previous_t1) { // Only t1 wrap has occurred - phy->sf_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSFDEC) - latency; + phy->slot_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSLOTDEC) - latency; } else { // Either no wrap or both have wrapped - phy->sf_offset = ind.t2 - ind.t1 - latency; + phy->slot_offset = ind.t2 - ind.t1 - latency; } - if (phy->sf_offset_filtered == 0) + if (phy->slot_offset_filtered == 0) { - phy->sf_offset_filtered = phy->sf_offset; + phy->slot_offset_filtered = phy->slot_offset; } else { - int32_t oldFilteredValueShifted = phy->sf_offset_filtered << 5; - int32_t newOffsetShifted = phy->sf_offset << 5; + int32_t oldFilteredValueShifted = phy->slot_offset_filtered << 5; + int32_t newOffsetShifted = phy->slot_offset << 5; // 1/8 of new and 7/8 of old - phy->sf_offset_filtered = ((newOffsetShifted >> 3) + ((oldFilteredValueShifted * 7) >> 3)) >> 5; + phy->slot_offset_filtered = ((newOffsetShifted >> 3) + ((oldFilteredValueShifted * 7) >> 3)) >> 5; } } @@ -976,21 +1028,21 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) clock_gettime(CLOCK_MONOTONIC, &ts); NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%1d) %d.%d PNF to VNF phy_id:%2d (t1/2/3/4:%8u, %8u, %8u, %8u) txrx:%4u procT:%3u latency(us):%4d(avg:%4d) offset(us):%8d filtered(us):%8d wrap[t1:%u t2:%u]\n", - NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ts.tv_sec, ts.tv_nsec, ind.header.phy_id, + phy->sfn, phy->slot, ts.tv_sec, ts.tv_nsec, ind.header.phy_id, ind.t1, ind.t2, ind.t3, t4, - tx_2_rx, pnf_proc_time, latency, phy->average_latency, phy->sf_offset, phy->sf_offset_filtered, + tx_2_rx, pnf_proc_time, latency, phy->average_latency, phy->slot_offset, phy->slot_offset_filtered, (ind.t1previous_t1), (ind.t2previous_t2)); } } - if (phy->filtered_adjust && (phy->sf_offset_filtered > 1e6 || phy->sf_offset_filtered < -1e6)) + if (phy->filtered_adjust && (phy->slot_offset_filtered > 1e6 || phy->slot_offset_filtered < -1e6)) { phy->filtered_adjust = 0; phy->zero_count=0; phy->min_sync_cycle_count = 2; phy->in_sync = 0; - NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s - ADJUST TOO BAD - go out of filtered phy->sf_offset_filtered:%d\n", __FUNCTION__, phy->sf_offset_filtered); + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s - ADJUST TOO BAD - go out of filtered phy->slot_offset_filtered:%d\n", __FUNCTION__, phy->slot_offset_filtered); } if(phy->min_sync_cycle_count) @@ -998,8 +1050,9 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) if(phy->min_sync_cycle_count == 0) { - uint32_t curr_sfn_sf = phy->sfn_sf; - int32_t sfn_sf_dec = NFAPI_SFNSF2DEC(phy->sfn_sf); + uint32_t curr_sfn = phy->sfn; + uint32_t curr_slot = phy->slot; + int32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(phy->sfn,phy->slot); if(!phy->filtered_adjust) { @@ -1012,55 +1065,56 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) } phy->average_latency /= SYNC_CYCLE_COUNT; - phy->sf_offset = ind.t2 - (ind.t1 - phy->average_latency); + phy->slot_offset = ind.t2 - (ind.t1 - phy->average_latency); - sfn_sf_dec += (phy->sf_offset / 1000); + sfn_slot_dec += (phy->slot_offset / 500); } else { - sfn_sf_dec += ((phy->sf_offset_filtered + 500) / 1000); //Round up go from microsecond to subframe(1ms) + sfn_slot_dec += ((phy->slot_offset_filtered + 250) / 500); //Round up to go from microsecond to slot } - if(sfn_sf_dec < 0) + if(sfn_slot_dec < 0) { - sfn_sf_dec += NFAPI_MAX_SFNSFDEC; + sfn_slot_dec += NFAPI_MAX_SFNSLOTDEC; } - else if( sfn_sf_dec >= NFAPI_MAX_SFNSFDEC) + else if( sfn_slot_dec >= NFAPI_MAX_SFNSLOTDEC) { - sfn_sf_dec -= NFAPI_MAX_SFNSFDEC; + sfn_slot_dec -= NFAPI_MAX_SFNSLOTDEC; } - uint16_t new_sfn_sf = NFAPI_SFNSFDEC2SFNSF(sfn_sf_dec); - - + + uint16_t new_sfn = NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec); + uint16_t new_slot = NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec); + { - phy->adjustment = NFAPI_SFNSF2DEC(new_sfn_sf) - NFAPI_SFNSF2DEC(curr_sfn_sf); + phy->adjustment = NFAPI_SFNSLOT2DEC(new_sfn, new_slot) - NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot); - NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF phy_id:%d adjustment%d phy->previous_sf_offset_filtered:%d phy->previous_sf_offset_filtered:%d phy->sf_offset_trend:%d\n", ind.header.phy_id, phy->adjustment, phy->previous_sf_offset_filtered, phy->previous_sf_offset_filtered, phy->sf_offset_trend); + NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF phy_id:%d adjustment%d phy->previous_slot_offset_filtered:%d phy->previous_slot_offset_filtered:%d phy->slot_offset_trend:%d\n", ind.header.phy_id, phy->adjustment, phy->previous_slot_offset_filtered, phy->previous_slot_offset_filtered, phy->slot_offset_trend); phy->previous_t1 = 0; phy->previous_t2 = 0; - if(phy->previous_sf_offset_filtered > 0) + if(phy->previous_slot_offset_filtered > 0) { - if( phy->sf_offset_filtered > phy->previous_sf_offset_filtered) + if( phy->slot_offset_filtered > phy->previous_slot_offset_filtered) { // pnf is getting futher ahead of vnf //phy->sf_offset_trend = phy->sf_offset_filtered - phy->previous_sf_offset_filtered; - phy->sf_offset_trend = (phy->sf_offset_filtered + phy->previous_sf_offset_filtered)/2; + phy->slot_offset_trend = (phy->slot_offset_filtered + phy->previous_slot_offset_filtered)/2; } else { // pnf is getting back in sync } } - else if(phy->previous_sf_offset_filtered < 0) + else if(phy->previous_slot_offset_filtered < 0) { - if(phy->sf_offset_filtered < phy->previous_sf_offset_filtered) + if(phy->slot_offset_filtered < phy->previous_slot_offset_filtered) { // vnf is getting future ahead of pnf //phy->sf_offset_trend = -(phy->sf_offset_filtered - phy->previous_sf_offset_filtered); - phy->sf_offset_trend = (-(phy->sf_offset_filtered + phy->previous_sf_offset_filtered)) /2; + phy->slot_offset_trend = (-(phy->slot_offset_filtered + phy->previous_slot_offset_filtered)) /2; } else { @@ -1069,8 +1123,8 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) } - int insync_minor_adjustment_1 = phy->sf_offset_trend / 6; - int insync_minor_adjustment_2 = phy->sf_offset_trend / 2; + int insync_minor_adjustment_1 = phy->slot_offset_trend / 6; + int insync_minor_adjustment_2 = phy->slot_offset_trend / 2; if(insync_minor_adjustment_1 == 0) @@ -1123,17 +1177,17 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) if(phy->in_sync) { // in sync - if(phy->sf_offset_filtered > 250) + if(phy->slot_offset_filtered > 250) { // VNF is slow phy->insync_minor_adjustment = insync_minor_adjustment_1; //25; - phy->insync_minor_adjustment_duration = ((phy->sf_offset_filtered) / insync_minor_adjustment_1); + phy->insync_minor_adjustment_duration = ((phy->slot_offset_filtered) / insync_minor_adjustment_1); } - else if(phy->sf_offset_filtered < -250) + else if(phy->slot_offset_filtered < -250) { // VNF is fast phy->insync_minor_adjustment = -(insync_minor_adjustment_1); //25; - phy->insync_minor_adjustment_duration = (((phy->sf_offset_filtered) / -(insync_minor_adjustment_1))); + phy->insync_minor_adjustment_duration = (((phy->slot_offset_filtered) / -(insync_minor_adjustment_1))); } else { @@ -1142,13 +1196,13 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) if(phy->insync_minor_adjustment != 0) { - NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (sf_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adjustment:%d\n", - NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, + NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (slot_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adjustment:%d\n", + phy->sfn, phy->slot, ind.header.phy_id, phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, - phy->sf_offset_filtered, - insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend, - NFAPI_SFNSF2DEC(new_sfn_sf), - NFAPI_SFNSF2DEC(curr_sfn_sf), + phy->slot_offset_filtered, + insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend, + NFAPI_SFNSLOT2DEC(new_sfn, new_slot), + NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot), phy->adjustment); } } @@ -1166,17 +1220,17 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) //if(phy->adjustment == 1) { // - if(phy->sf_offset_filtered > 250) + if(phy->slot_offset_filtered > 250) { // VNF is slow phy->insync_minor_adjustment = insync_minor_adjustment_2; - phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered - 250) / insync_minor_adjustment_2); + phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered - 250) / insync_minor_adjustment_2); } - else if(phy->sf_offset_filtered < -250) + else if(phy->slot_offset_filtered < -250) { // VNF is fast phy->insync_minor_adjustment = -(insync_minor_adjustment_2); - phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered + 250) / -(insync_minor_adjustment_2)); + phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered + 250) / -(insync_minor_adjustment_2)); } } @@ -1185,12 +1239,12 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) // out of sync? } - NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (adjustment:%d sf_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adj:%d\n", - NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, - phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->sf_offset_filtered, - insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend, - NFAPI_SFNSF2DEC(new_sfn_sf), - NFAPI_SFNSF2DEC(curr_sfn_sf), + NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%4d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (adjustment:%d slot_offset_filtered:%d) %d %d %d NEW:%d CURR:%d adj:%d\n", + phy->sfn, phy->slot, ind.header.phy_id, + phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->slot_offset_filtered, + insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend, + NFAPI_SFNSLOT2DEC(new_sfn, new_slot), + NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot), phy->adjustment); } @@ -1200,17 +1254,17 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) //if(phy->adjustment == -1) { // - if(phy->sf_offset_filtered > 250) + if(phy->slot_offset_filtered > 250) { // VNF is slow phy->insync_minor_adjustment = insync_minor_adjustment_2; - phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered - 250) / insync_minor_adjustment_2); + phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered - 250) / insync_minor_adjustment_2); } - else if(phy->sf_offset_filtered < -250) + else if(phy->slot_offset_filtered < -250) { // VNF is fast phy->insync_minor_adjustment = -(insync_minor_adjustment_2); - phy->insync_minor_adjustment_duration = 2 * ((phy->sf_offset_filtered + 250) / -(insync_minor_adjustment_2)); + phy->insync_minor_adjustment_duration = 2 * ((phy->slot_offset_filtered + 250) / -(insync_minor_adjustment_2)); } } //else @@ -1218,10 +1272,10 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) // out of sync? } - NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d subframes (adjustment:%d sf_offset_filtered:%d) %d %d %d\n", - NFAPI_SFNSF2SFN(phy->sfn_sf), NFAPI_SFNSF2SF(phy->sfn_sf), ind.header.phy_id, - phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->sf_offset_filtered, - insync_minor_adjustment_1, insync_minor_adjustment_2, phy->sf_offset_trend); + NFAPI_TRACE(NFAPI_TRACE_NOTE, "(%d/%d) VNF phy_id:%d Apply minor insync adjustment %dus for %d slots (adjustment:%d slot_offset_filtered:%d) %d %d %d\n", + phy->sfn, phy->slot, ind.header.phy_id, + phy->insync_minor_adjustment, phy->insync_minor_adjustment_duration, phy->adjustment, phy->slot_offset_filtered, + insync_minor_adjustment_1, insync_minor_adjustment_2, phy->slot_offset_trend); } /* @@ -1254,15 +1308,16 @@ void vnf_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) phy->zero_count, phy->in_sync ? "IN_SYNC" : "OUT_OF_SYNC");*/ - phy->sfn_sf = new_sfn_sf; + phy->sfn = new_sfn; + phy->slot = new_slot; } } // reset for next cycle - phy->previous_sf_offset_filtered = phy->sf_offset_filtered; + phy->previous_slot_offset_filtered = phy->slot_offset_filtered; phy->min_sync_cycle_count = 2; - phy->sf_offset_filtered = 0; - phy->sf_offset = 0; + phy->slot_offset_filtered = 0; + phy->slot_offset = 0; } else { diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c index 56c7e50723..fdeed0dabd 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c @@ -145,8 +145,8 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) //struct timespec original_pselect_timeout; struct timespec pselect_timeout; pselect_timeout.tv_sec = 0; - pselect_timeout.tv_nsec = 1000000; // ns in a 1 us - + pselect_timeout.tv_nsec = 500000; // ns in a 1 ms (Change?) + //pselect_timeout.tv_nsec = 500000; struct timespec pselect_start; struct timespec pselect_stop; @@ -156,15 +156,25 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) long last_millisecond = -1; - struct timespec sf_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 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; + slot_duration.tv_sec = 0; + slot_duration.tv_nsec = 0.5e6; + - struct timespec sf_start; - clock_gettime(CLOCK_MONOTONIC, &sf_start); - long millisecond = sf_start.tv_nsec / 1e6; //Check if we have to change - sf_start = timespec_add(sf_start, sf_duration); - NFAPI_TRACE(NFAPI_TRACE_INFO, "next slot will start at %d.%d\n", sf_start.tv_sec, sf_start.tv_nsec); + +// struct timespec sf_start; //Change to slot_start? + struct timespec slot_start; +// clock_gettime(CLOCK_MONOTONIC, &sf_start); + clock_gettime(CLOCK_MONOTONIC, &slot_start); +// long millisecond = sf_start.tv_nsec / 1e6; //Check if we have to change + long millisecond = slot_start.tv_nsec / 1e6; +// sf_start = timespec_add(sf_start, sf_duration); + 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) { @@ -185,8 +195,9 @@ 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) || - ((pselect_start.tv_sec == sf_start.tv_sec) && (pselect_start.tv_nsec > sf_start.tv_nsec))) + //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))) { // overran the end of the subframe we do not want to wait pselect_timeout.tv_sec = 0; @@ -198,8 +209,8 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) else { // still time before the end of the subframe wait - pselect_timeout = timespec_sub(sf_start, pselect_start); - + //pselect_timeout = timespec_sub(sf_start, pselect_start); + pselect_timeout = timespec_sub(slot_start, pselect_start); } //original_pselect_timeout = pselect_timeout; @@ -234,7 +245,7 @@ int nfapi_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--; @@ -247,6 +258,7 @@ int nfapi_vnf_p7_start(nfapi_vnf_p7_config_t* config) selectRetval = pselect(maxSock+1, &rfds, NULL, NULL, &pselect_timeout, NULL); + // selectRetval = pselect(120, &rfds, NULL, NULL, &pselect_timeout, NULL); clock_gettime(CLOCK_MONOTONIC, &pselect_stop); @@ -254,25 +266,33 @@ 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", +// 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, - sf_duration.tv_sec, sf_duration.tv_nsec); + slot_duration.tv_sec, slot_duration.tv_nsec); + } if(selectRetval == 0) { - // calculate the start of the next subframe - sf_start = timespec_add(sf_start, sf_duration); + // calculate the start of the next slot + //sf_start = timespec_add(sf_start, sf_duration); + slot_start = timespec_add(slot_start, slot_duration); //NFAPI_TRACE(NFAPI_TRACE_INFO, "next subframe will start at %d.%d\n", sf_start.tv_sec, sf_start.tv_nsec); if(phy && phy->in_sync && phy->insync_minor_adjustment != 0 && phy->insync_minor_adjustment_duration > 0) { long insync_minor_adjustment_ns = (phy->insync_minor_adjustment * 1000); - sf_start.tv_nsec -= insync_minor_adjustment_ns; + //sf_start.tv_nsec -= insync_minor_adjustment_ns; + slot_start.tv_nsec -= insync_minor_adjustment_ns; #if 1 - if (sf_start.tv_nsec > 1e9) +/* if (sf_start.tv_nsec > 1e9) //Change to 0.5e6? { sf_start.tv_sec++; sf_start.tv_nsec-=1e9; @@ -281,6 +301,16 @@ if (selectRetval==-1 && errno == 22) { sf_start.tv_sec--; sf_start.tv_nsec+=1e9; + }*/ + if (slot_start.tv_nsec > 1e9) + { + slot_start.tv_sec++; + slot_start.tv_nsec-=1e9; + } + else if (slot_start.tv_nsec < 0) + { + slot_start.tv_sec--; + slot_start.tv_nsec+=1e9; } #else //NFAPI_TRACE(NFAPI_TRACE_NOTE, "[VNF] BEFORE adjustment - Subframe minor adjustment %dus sf_start.tv_nsec:%d\n", phy->insync_minor_adjustment, sf_start.tv_nsec); @@ -314,8 +344,10 @@ 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", - phy->insync_minor_adjustment, sf_start.tv_nsec, 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", +// 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", + phy->insync_minor_adjustment, slot_start.tv_nsec, phy->insync_minor_adjustment_duration); if (phy->insync_minor_adjustment_duration==0) { @@ -339,12 +371,15 @@ if (selectRetval==-1 && errno == 22) last_millisecond = millisecond; */ - millisecond ++; + //millisecond ++; + millisecond = millisecond + 1; + } } else { - // we have overrun the subframe advance to go and collect $200 + // we have overrun the subframe advance to go and collect $200 + // CHANGE - gokul if((millisecond - last_millisecond) > 3) NFAPI_TRACE(NFAPI_TRACE_WARN, "subframe overrun %ld %ld (%ld)\n", millisecond, last_millisecond, millisecond - last_millisecond + 1); @@ -354,7 +389,8 @@ if (selectRetval==-1 && errno == 22) if(selectRetval == 0) { - vnf_p7->sf_start_time_hr = vnf_get_current_time_hr(); + //vnf_p7->sf_start_time_hr = vnf_get_current_time_hr(); + vnf_p7->slot_start_time_hr = vnf_get_current_time_hr(); // pselect timed out nfapi_vnf_p7_connection_info_t* curr = vnf_p7->p7_connections; @@ -365,6 +401,7 @@ if (selectRetval==-1 && errno == 22) if (curr->slot == 19) { curr->sfn++; + curr->slot = 0; //Correct? - gokul } else if(curr->slot > 19) { @@ -377,10 +414,11 @@ if (selectRetval==-1 && errno == 22) //curr->sfn_sf = increment_sfn_sf(curr->sfn_sf); vnf_sync(vnf_p7, curr); - + //printf("sfn:%d, slot:%d",curr->sfn,curr->slot); //remove later - gokul curr = curr->next; + } - + //send_mac_subframe_indications(vnf_p7); send_mac_slot_indications(vnf_p7); @@ -390,7 +428,7 @@ if (selectRetval==-1 && errno == 22) // have a p7 message if(FD_ISSET(vnf_p7->socket, &rfds)) { - vnf_p7_read_dispatch_message(vnf_p7); + vnf_p7_read_dispatch_message(vnf_p7); } } else @@ -448,12 +486,13 @@ int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, memset(node, 0, sizeof(nfapi_vnf_p7_connection_info_t)); node->phy_id = phy_id; node->in_sync = 0; - node->dl_out_sync_offset = 30; + node->dl_out_sync_offset = 30;//TODO: Values need to be changed for NR,How to set the values node->dl_out_sync_period = 10; node->dl_in_sync_offset = 30; node->dl_in_sync_period = 512; - node->sfn_sf = 0; - + //node->sfn_sf = 0; + node->sfn = 0; + node->slot = 0; node->min_sync_cycle_count = 8; // save the remote endpoint information diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index d62687bd9c..dca8857c15 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -152,7 +152,7 @@ void nr_pdcch_scrambling(uint32_t *in, } } - +/* uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, nfapi_nr_ul_dci_request_pdus_t *ul_dci_pdu, uint32_t **gold_pdcch_dmrs, @@ -164,7 +164,7 @@ uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, uint16_t cset_start_sc; uint8_t cset_start_symb, cset_nsymb; int k,l,k_prime,dci_idx, dmrs_idx; - /*First iteration: single DCI*/ + //First iteration: single DCI nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15=NULL; @@ -191,11 +191,12 @@ uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, } else cset_start_sc = frame_parms.first_carrier_offset + rb_offset*NR_NB_SC_PER_RB; - for (int d=0;dnumDlDci;d++) { - /*The coreset is initialised - * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset for coreset 0 - * or the rb_offset for other coresets - * in time: by its first slot and its first symbol*/ + volatile int temp = pdcch_pdu_rel15->numDlDci; + for (volatile int d=0;d < temp;d++) { + //The coreset is initialised + //in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset for coreset 0 + //or the rb_offset for other coresets + //in time: by its first slot and its first symbol cset_start_symb = pdcch_pdu_rel15->StartSymbolIndex; cset_nsymb = pdcch_pdu_rel15->DurationSymbols; @@ -271,11 +272,11 @@ uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, if (cset_start_sc >= frame_parms.ofdm_symbol_size) cset_start_sc -= frame_parms.ofdm_symbol_size; - /*Reorder REG list for a freq first mapping*/ + //Reorder REG list for a freq first mapping uint8_t nb_regs = pdcch_pdu_rel15->AggregationLevel[d]*NR_NB_REG_PER_CCE; uint8_t reg_idx0 = pdcch_pdu_rel15->CceIndex[d]*NR_NB_REG_PER_CCE; - /*Mapping the encoded DCI along with the DMRS */ + //Mapping the encoded DCI along with the DMRS for (int reg_idx=reg_idx0; reg_idx<(nb_regs+reg_idx0); reg_idx++) { k = cset_start_sc + (12*reg_idx/cset_nsymb); @@ -324,4 +325,180 @@ uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, } // for (int d=0;dnumDlDci;d++) return 0; } +*/ + +uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu, + nfapi_nr_ul_dci_request_pdus_t *ul_dci_pdu, + uint32_t **gold_pdcch_dmrs, + int32_t *txdataF, + int16_t amp, + NR_DL_FRAME_PARMS frame_parms) { + + int16_t mod_dmrs[NR_MAX_CSET_DURATION][NR_MAX_PDCCH_DMRS_LENGTH>>1]; // 3 for the max coreset duration + uint16_t cset_start_sc; + uint8_t cset_start_symb, cset_nsymb; + int k,l,k_prime,dci_idx, dmrs_idx; + /*First iteration: single DCI*/ + + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15=NULL; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *temp; + temp = (nfapi_nr_dl_tti_pdcch_pdu_rel15_t *)malloc(sizeof(nfapi_nr_dl_tti_pdcch_pdu_rel15_t)); + int s = sizeof(nfapi_nr_dl_tti_pdcch_pdu_rel15_t); + + // find coreset descriptor + + int rb_offset; + int n_rb; + + AssertFatal(pdcch_pdu!=NULL || ul_dci_pdu!=NULL,"At least one pointer has to be !NULL\n"); + AssertFatal(pdcch_pdu==NULL || ul_dci_pdu==NULL,"Can't handle both DL and UL DCI in same slot\n"); + + + if (pdcch_pdu) pdcch_pdu_rel15 = &pdcch_pdu->pdcch_pdu_rel15; + else if (ul_dci_pdu) pdcch_pdu_rel15 = &ul_dci_pdu->pdcch_pdu.pdcch_pdu_rel15; + + get_coreset_rballoc(pdcch_pdu_rel15->FreqDomainResource,&n_rb,&rb_offset); + + // compute rb_offset and n_prb based on frequency allocation + + if (pdcch_pdu_rel15->CoreSetType == NFAPI_NR_CSET_CONFIG_MIB_SIB1) { + cset_start_sc = frame_parms.first_carrier_offset + (frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB + + rb_offset)*NR_NB_SC_PER_RB; + } else + cset_start_sc = frame_parms.first_carrier_offset + rb_offset*NR_NB_SC_PER_RB; + + memcpy(temp, pdcch_pdu_rel15,sizeof(nfapi_nr_dl_tti_pdcch_pdu_rel15_t)); + for (volatile int d=0;d < temp->numDlDci;d++) { + /*The coreset is initialised + * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset for coreset 0 + * or the rb_offset for other coresets + * in time: by its first slot and its first symbol*/ + + cset_start_symb = temp->StartSymbolIndex; + cset_nsymb = temp->DurationSymbols; + dci_idx = 0; + LOG_D(PHY, "Coreset rb_offset %d, nb_rb %d\n",rb_offset,n_rb); + LOG_D(PHY, "Coreset starting subcarrier %d on symbol %d (%d symbols)\n", cset_start_sc, cset_start_symb, cset_nsymb); + // DMRS length is per OFDM symbol + AssertFatal(temp->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED, + "Interleaved CCE REG MAPPING not supported\n"); + uint32_t dmrs_length = (temp->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED)? + (n_rb*6) : (temp->AggregationLevel[d]*36/cset_nsymb); //2(QPSK)*3(per RB)*6(REG per CCE) + uint32_t encoded_length = temp->AggregationLevel[d]*108; //2(QPSK)*9(per RB)*6(REG per CCE) + LOG_D(PHY, "DMRS length per symbol %d\t DCI encoded length %d (precoder_granularity %d,reg_mapping %d)\n", dmrs_length, encoded_length,temp->precoderGranularity,temp->CceRegMappingType); + dmrs_length += rb_offset*6; // To accommodate more DMRS symbols in case of rb offset + + /// DMRS QPSK modulation + for (int symb=cset_start_symb; symbDurationSymbols; symb++) { + + nr_modulation(gold_pdcch_dmrs[symb], dmrs_length, DMRS_MOD_ORDER, mod_dmrs[symb]); //Qm = 2 as DMRS is QPSK modulated + +#ifdef DEBUG_PDCCH_DMRS + + for (int i=0; i>1; i++) + printf("symb %d i %d gold seq 0x%08x mod_dmrs %d %d\n", symb, i, + gold_pdcch_dmrs[symb][i>>5], mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] ); + +#endif + } + + /// DCI payload processing + // CRC attachment + Scrambling + Channel coding + Rate matching + uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; + uint16_t n_RNTI = temp->RNTI[d]; + uint16_t Nid = temp->ScramblingId[d]; + + t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, + temp->PayloadSizeBits[d], + temp->AggregationLevel[d], + 0,NULL); + polar_encoder_fast((uint64_t*)temp->Payload[d], encoder_output, n_RNTI,1,currentPtr); +#ifdef DEBUG_CHANNEL_CODING + printf("polar rnti %x,length %d, L %d\n",n_RNTI, temp->PayloadSizeBits[d],temp->AggregationLevel[d]); + printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n", + ((uint64_t*)temp->Payload[d])[0], ((uint64_t*)temp->Payload[d])[1]); + printf("Encoded Payload (length:%d dwords):\n", encoded_length>>5); + + for (int i=0; i>5; i++) + printf("[%d]->0x%08x \t", i,encoder_output[i]); + + printf("\n"); +#endif + /// Scrambling + uint32_t scrambled_output[NR_MAX_DCI_SIZE_DWORD]= {0}; + nr_pdcch_scrambling(encoder_output, encoded_length, Nid, n_RNTI, scrambled_output); +#ifdef DEBUG_CHANNEL_CODING + printf("scrambled output: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\t [4]->0x%08x\t [5]->0x%08x\t \ +[6]->0x%08x \t [7]->0x%08x \t [8]->0x%08x \t [9]->0x%08x\t [10]->0x%08x\t [11]->0x%08x\n", + scrambled_output[0], scrambled_output[1], scrambled_output[2], scrambled_output[3], scrambled_output[4],scrambled_output[5], + scrambled_output[6], scrambled_output[7], scrambled_output[8], scrambled_output[9], scrambled_output[10],scrambled_output[11] ); +#endif + /// QPSK modulation + int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; + nr_modulation(scrambled_output, encoded_length, DMRS_MOD_ORDER, mod_dci); //Qm = 2 as DMRS is QPSK modulated +#ifdef DEBUG_DCI + + for (int i=0; i>1; i++) + printf("i %d mod_dci %d %d\n", i, mod_dci[i<<1], mod_dci[(i<<1)+1] ); + +#endif + + /// Resource mapping + + if (cset_start_sc >= frame_parms.ofdm_symbol_size) + cset_start_sc -= frame_parms.ofdm_symbol_size; + + /*Reorder REG list for a freq first mapping*/ + uint8_t nb_regs = temp->AggregationLevel[d]*NR_NB_REG_PER_CCE; + uint8_t reg_idx0 = temp->CceIndex[d]*NR_NB_REG_PER_CCE; + + /*Mapping the encoded DCI along with the DMRS */ + for (int reg_idx=reg_idx0; reg_idx<(nb_regs+reg_idx0); reg_idx++) { + k = cset_start_sc + (12*reg_idx/cset_nsymb); + + if (k >= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; + + l = cset_start_symb + ((reg_idx/cset_nsymb)%cset_nsymb); + + // dmrs index depends on reference point for k according to 38.211 7.4.1.3.2 + if (temp->CoreSetType == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG) + dmrs_idx = (reg_idx/cset_nsymb)*3; + else + dmrs_idx = ((reg_idx/cset_nsymb)+rb_offset)*3; + + k_prime = 0; + + for (int m=0; mCceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED) { + ((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1] = (2*amp * mod_dmrs[l][dmrs_idx<<1]) >> 15; + ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (2*amp * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15; +#ifdef DEBUG_PDCCH_DMRS + printf("PDCCH DMRS: l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1], + ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1)+1]); +#endif + dmrs_idx++; + } + + k_prime++; + } else { // DCI payload + ((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1] = (amp * mod_dci[dci_idx<<1]) >> 15; + ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (amp * mod_dci[(dci_idx<<1) + 1]) >> 15; +#ifdef DEBUG_DCI + printf("PDCCH: l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1], + ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1)+1]); +#endif + dci_idx++; + } + + k++; + + if (k >= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; + } // m + } // reg_idx + } // for (int d=0;dnumDlDci;d++) + return 0; +} \ No newline at end of file diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 42b162d4c0..2337b23c96 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -36,6 +36,9 @@ #include "nfapi/oai_integration/vendor_ext.h" int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_tti_request_t *dl_config_req); +int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req); +int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req); + extern uint8_t nfapi_mode; @@ -130,7 +133,7 @@ void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, } void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ - + PHY_VARS_gNB *gNB; // copy data from L2 interface into L1 structures module_id_t Mod_id = Sched_INFO->module_id; @@ -141,12 +144,23 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ frame_t frame = Sched_INFO->frame; sub_frame_t slot = Sched_INFO->slot; + //Gokul + if(slot%2!=0) + { + printf("\n Odd Slot %d \n,slot"); + } + else + { + printf("\n Even Slot \n"); + } + + AssertFatal(RC.gNB!=NULL,"RC.gNB is null\n"); AssertFatal(RC.gNB[Mod_id]!=NULL,"RC.gNB[%d] is null\n",Mod_id); gNB = RC.gNB[Mod_id]; - uint8_t number_dl_pdu = DL_req->dl_tti_request_body.nPDUs; + uint8_t number_dl_pdu = DL_req->nPDUs; // uint8_t number_ul_pdu = 0; uint8_t number_ul_dci_pdu = (UL_dci_req==NULL) ? 0 : UL_dci_req->numPdus; @@ -163,12 +177,12 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ gNB->pbch_configured=0; for (int i=0;idl_tti_request_body.dl_tti_pdu_list[i]; + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu = &DL_req->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: gNB->pbch_configured=1; - // if (NFAPI_MODE!=NFAPI_MODE_VNF) ? + if(nfapi_mode != 2) handle_nr_nfapi_ssb_pdu(gNB,frame,slot, dl_tti_pdu); @@ -176,7 +190,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ 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 != 2) handle_nfapi_nr_pdcch_pdu(gNB, frame, slot, &dl_tti_pdu->pdcch_pdu); @@ -192,7 +206,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ 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 != 2) handle_nr_nfapi_pdsch_pdu(gNB,frame,slot,&dl_tti_pdu->pdsch_pdu, sdu); } } @@ -201,15 +215,32 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ if (UL_tti_req!=NULL) memcpy(&gNB->UL_tti_req,UL_tti_req,sizeof(nfapi_nr_ul_tti_request_t)); - // if (NFAPI_MODE!=NFAPI_MODE_VNF) //should we enclose the for in this? + if(nfapi_mode != 2) for (int i=0;iul_dci_pdu_list[i]); } - - if (NFAPI_MODE!=NFAPI_MONOLITHIC) { - oai_nfapi_nr_dl_config_req(Sched_INFO->DL_req); + if (nfapi_mode != 0 ) + { + if (Sched_INFO->TX_req->Number_of_PDUs > 0) + { + Sched_INFO->TX_req->SFN = frame; + Sched_INFO->TX_req->Slot = slot; + oai_nfapi_tx_data_req(Sched_INFO->TX_req); + } + //if(Sched_INFO->DL_req->nPDUs > 0) + { + Sched_INFO->DL_req->SFN = frame; + Sched_INFO->DL_req->Slot = slot; + oai_nfapi_nr_dl_config_req(Sched_INFO->DL_req); + } + } + + if (nfapi_mode != 0 && Sched_INFO->UL_dci_req->numPdus!=0) + { + Sched_INFO->UL_dci_req->SFN=frame; + Sched_INFO->UL_dci_req->Slot=slot; + oai_nfapi_ul_dci_req(Sched_INFO->UL_dci_req); } - } diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 60f9d4747a..5eb629e222 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -160,7 +160,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_COMMON_TX,0); - if (gNB->pdcch_pdu || gNB->ul_dci_pdu) { + if (gNB->pdcch_pdu || gNB->ul_dci_pdu) { LOG_D(PHY, "[gNB %d] Frame %d slot %d Calling nr_generate_dci_top (number of UL/DL DCI %d/%d)\n", gNB->Mod_id, frame, slot, gNB->ul_dci_pdu==NULL?0:gNB->ul_dci_pdu->pdcch_pdu.pdcch_pdu_rel15.numDlDci, diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 5dba82f95a..ba1352347d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -337,41 +337,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm cfg->ssb_table.ssb_beam_id_list[0].beam_id->tl.tag = NFAPI_NR_CONFIG_BEAM_ID_TAG; cfg->num_tlv++; } - - // TODO: assign values to nfapi_config struct - - cfg->nfapi_config.dl_ue_per_sf.tl.tag = NFAPI_NR_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG; - cfg->num_tlv++; - - cfg->nfapi_config.max_transmit_power.tl.tag = NFAPI_NR_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG; - cfg->num_tlv++; - - cfg->nfapi_config.nrarfcn.tl.tag = NFAPI_NR_NFAPI_NRARFCN_TAG; - cfg->nfapi_config.nrarfcn.value = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA; - cfg->num_tlv++; - - cfg->nfapi_config.p7_pnf_address_ipv4.tl.tag = NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV4_TAG; - cfg->num_tlv++; - - cfg->nfapi_config.p7_pnf_address_ipv6.tl.tag = NFAPI_NR_NFAPI_P7_PNF_ADDRESS_IPV6_TAG; - cfg->num_tlv++; - - cfg->nfapi_config.p7_pnf_port.tl.tag = NFAPI_NR_NFAPI_P7_PNF_PORT_TAG; - cfg->num_tlv++; - - cfg->nfapi_config.p7_vnf_address_ipv6.tl.tag = NFAPI_NR_NFAPI_P7_VNF_ADDRESS_IPV6_TAG; - cfg->num_tlv++; - - cfg->nfapi_config.rf_bands.tl.tag = NFAPI_NR_NFAPI_RF_BANDS_TAG; - cfg->num_tlv++; - cfg->nfapi_config.rf_bands.rf_band[0] = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - - - cfg->nfapi_config.ul_ue_per_sf.tl.tag = NFAPI_NR_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG; - cfg->num_tlv++; - - - + } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 702b034809..a0e4ae9bd4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -79,8 +79,8 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, DL_req[CC_idP].SFN = frameP; DL_req[CC_idP].Slot = slotP; - DL_req[CC_idP].dl_tti_request_body.nPDUs = 0; - DL_req[CC_idP].dl_tti_request_body.nGroup = 0; + DL_req[CC_idP].nPDUs = 0; + DL_req[CC_idP].nGroup = 0; //DL_req[CC_idP].dl_tti_request_body.transmission_power_pcfich = 6000; UL_dci_req[CC_idP].SFN = frameP; @@ -439,7 +439,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, #endif // Phytest scheduling - if (get_softmodem_params()->phy_test && slot_txP==1){ + if (get_softmodem_params()->phy_test && slot_txP==3 ){ nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP, pucch_sched, NULL); // resetting ta flag gNB->ta_len = 0; @@ -452,12 +452,13 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, */ } //is_nr_DL_slot - +/* if (is_nr_UL_slot(cc->ServingCellConfigCommon,slot_rxP)) { if (get_softmodem_params()->phy_test && slot_rxP==8){ nr_schedule_uss_ulsch_phytest(module_idP, frame_rxP, slot_rxP); } } + */ //Testing only DL for now stop_meas(&RC.nrmac[module_idP]->eNB_scheduler); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 2a36425fae..cedae99d52 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -61,7 +61,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ NR_COMMON_channels_t *cc; nfapi_nr_dl_tti_request_t *dl_tti_request; - nfapi_nr_dl_tti_request_body_t *dl_req; + nfapi_nr_dl_tti_request_pdu_t *dl_config_pdu; int mib_sdu_length; @@ -73,7 +73,6 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { dl_tti_request = &gNB->DL_req[CC_id]; - dl_req = &dl_tti_request->dl_tti_request_body; cc = &gNB->common_channels[CC_id]; mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]); // not used in this case @@ -82,16 +81,16 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ if (mib_sdu_length > 0) { - LOG_I(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length); + LOG_I(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_tti_request->nPDUs, mib_sdu_length); if ((frameP & 1023) < 80){ LOG_I(MAC,"[gNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes\n",module_idP, frameP, CC_id, mib_sdu_length); } - dl_config_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; + dl_config_pdu = &dl_tti_request->dl_tti_pdu_list[dl_tti_request->nPDUs]; memset((void *) dl_config_pdu, 0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_config_pdu->PDUType = NFAPI_NR_DL_TTI_SSB_PDU_TYPE; - dl_config_pdu->PDUSize =2 + sizeof(nfapi_nr_dl_tti_ssb_pdu_rel15_t); + dl_config_pdu->PDUSize = 2 + sizeof(nfapi_nr_dl_tti_ssb_pdu_rel15_t); AssertFatal(cc->ServingCellConfigCommon->physCellId!=NULL,"cc->ServingCellConfigCommon->physCellId is null\n"); dl_config_pdu->ssb_pdu.ssb_pdu_rel15.PhysCellId = *cc->ServingCellConfigCommon->physCellId; @@ -136,7 +135,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){ dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA = ssb_offset0/(ratio*12) - 10; // absoluteFrequencySSB is the center of SSB dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag = 1; dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload = (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1); - dl_req->nPDUs++; + dl_tti_request->nPDUs++; } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 050f07ba67..ebe2afeeaf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -66,7 +66,6 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, uint8_t CC_id; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[0]; - nfapi_nr_dl_tti_request_body_t *dl_req; nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu; nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu; nfapi_nr_pdu_t *TX_req; @@ -92,15 +91,13 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, LOG_D(MAC, "Scheduling common search space DCI type 1 dlBWP BW.firstRB %d.%d\n", dlBWP_carrier_bandwidth, NRRIV2PRBOFFSET(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,275)); - - - dl_req = &nr_mac->DL_req[CC_id].dl_tti_request_body; - dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; + + dl_tti_pdcch_pdu = &nr_mac->DL_req[CC_id].dl_tti_pdu_list[nr_mac->DL_req[CC_id].nPDUs]; memset((void*)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; dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); - dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1]; + dl_tti_pdsch_pdu = &nr_mac->DL_req[CC_id].dl_tti_pdu_list[nr_mac->DL_req[CC_id].nPDUs+1]; memset((void *)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE; dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu)); @@ -235,7 +232,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, pdsch_pdu_rel15->mcsIndex[0]); */ - dl_req->nPDUs+=2; + nr_mac->DL_req[CC_id].nPDUs+=2; TX_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; TX_req->PDU_length = 6; @@ -255,7 +252,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, int configure_fapi_dl_pdu(int Mod_idP, int *CCEIndex, - nfapi_nr_dl_tti_request_body_t *dl_req, + nfapi_nr_dl_tti_request_t *dl_tti_req, NR_sched_pucch *pucch_sched, uint8_t *mcsIndex, uint16_t *rbSize, @@ -278,12 +275,12 @@ int configure_fapi_dl_pdu(int Mod_idP, NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; - dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; + dl_tti_pdcch_pdu = &dl_tti_req->dl_tti_pdu_list[dl_tti_req->nPDUs]; memset((void*)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; dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); - dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1]; + dl_tti_pdsch_pdu = &dl_tti_req->dl_tti_pdu_list[dl_tti_req->nPDUs+1]; memset((void*)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE; dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu)); @@ -456,14 +453,14 @@ void config_uldci(NR_BWP_Uplink_t *ubwp,nfapi_nr_pusch_pdu_t *pusch_pdu,nfapi_nr void configure_fapi_dl_Tx(module_id_t Mod_idP, frame_t frameP, sub_frame_t slotP, - nfapi_nr_dl_tti_request_body_t *dl_req, + nfapi_nr_dl_tti_request_t *dl_tti_req, nfapi_nr_pdu_t *tx_req, int tbs_bytes, int16_t pdu_index){ int CC_id = 0; - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1]; + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_tti_req->dl_tti_pdu_list[dl_tti_req->nPDUs+1]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; @@ -477,7 +474,7 @@ void configure_fapi_dl_Tx(module_id_t Mod_idP, pdsch_pdu_rel15->mcsIndex[0], tbs_bytes); - dl_req->nPDUs+=2; + dl_tti_req->nPDUs+=2; tx_req->PDU_length = pdsch_pdu_rel15->TBSize[0]; tx_req->PDU_index = nr_mac->pdu_index[0]++; @@ -506,7 +503,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP]; //NR_COMMON_channels_t *cc = nr_mac->common_channels; //NR_ServingCellConfigCommon_t *scc=cc->ServingCellConfigCommon; - nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; + nfapi_nr_dl_tti_request_t *dl_tti_req = &gNB_mac->DL_req[CC_id]; nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs]; mac_rlc_status_resp_t rlc_status; @@ -541,7 +538,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, TBS_bytes = configure_fapi_dl_pdu(module_idP, CCEIndices, - dl_req, + dl_tti_req, pucch_sched, dlsch_config!=NULL ? dlsch_config->mcsIndex : NULL, dlsch_config!=NULL ? &dlsch_config->rbSize : NULL, @@ -666,7 +663,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; // mac_pdu[offset + j] = 0; } - configure_fapi_dl_Tx(module_idP, frameP, slotP, dl_req, tx_req, TBS_bytes, gNB_mac->pdu_index[CC_id]); + configure_fapi_dl_Tx(module_idP, frameP, slotP, dl_tti_req, tx_req, TBS_bytes, gNB_mac->pdu_index[CC_id]); if(IS_SOFTMODEM_NOS1){ #if defined(ENABLE_MAC_PAYLOAD_DEBUG) diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index c0f4053c03..54604a8ccc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -84,7 +84,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, int configure_fapi_dl_pdu(int Mod_id, int *CCEIndeces, - nfapi_nr_dl_tti_request_body_t *dl_req, + nfapi_nr_dl_tti_request_t *dl_tti_req, NR_sched_pucch *pucch_sched, uint8_t *mcsIndex, uint16_t *rbSize, @@ -95,7 +95,7 @@ void config_uldci(NR_BWP_Uplink_t *ubwp,nfapi_nr_pusch_pdu_t *pusch_pdu,nfapi_nr void configure_fapi_dl_Tx(module_id_t Mod_idP, frame_t frameP, sub_frame_t slotP, - nfapi_nr_dl_tti_request_body_t *dl_req, + nfapi_nr_dl_tti_request_t *dl_tti_req, nfapi_nr_pdu_t *tx_req, int tbs_bytes, int16_t pdu_index); diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 4dacef3dbb..b19f46e299 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -298,7 +298,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { LOG_D(PHY,"NR_Schedule_response: SFN_SF:%d%d dl_pdus:%d\n", sched_info->frame, sched_info->slot, - sched_info->DL_req->dl_tti_request_body.nPDUs); + sched_info->DL_req->nPDUs); } } } diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 41fb3ddc3a..1cc505b794 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -30,6 +30,10 @@ #include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "common/config/config_load_configmodule.h" #include "common/config/config_userapi.h" +#include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" +#include "openair1/PHY/defs_gNB.h" +#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h" +#include "openair1/PHY/LTE_TRANSPORT/transport_common.h" extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); void configure_nfapi_pnf(char *vnf_ip_addr, @@ -1120,3 +1124,23 @@ int l1_north_init_eNB(void) { void init_eNB_afterRU(void) { } + +void nr_phy_config_request(NR_PHY_Config_t *gNB){} + +void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB, + int frame, int slot, + nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu){} + +void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB, + int frame, int slot, + nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu){} + +void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot, + nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu){} + +int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type){} +void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, + nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu, + uint8_t *sdu){ + } +int l1_north_init_gNB(void){} \ No newline at end of file