diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 6839906cfd4ef5c565453f53fcedf54fbc9fa200..a11355cee5ebe2ac32d9b33a010c361d66fd302e 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -18,100 +18,6 @@ //UL_IND_t *UL_INFO; -void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id){ - // copy data from eNB L2 interface to UE L2 interface - - int CC_id = Sched_INFO->CC_id; - nfapi_dl_config_request_t *DL_req = Sched_INFO->DL_req; - nfapi_tx_request_t *Tx_req = Sched_INFO->TX_req; - frame_t frame = Sched_INFO->frame; - sub_frame_t subframe = Sched_INFO->subframe; - - uint8_t number_dl_pdu = DL_req->dl_config_request_body.number_pdu; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - nfapi_dl_config_request_pdu_t *dl_config_pdu_tmp; - int i = 0; - - for (i=0; i<number_dl_pdu; i++) - { - dl_config_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[i]; - switch (dl_config_pdu->pdu_type) { - case NFAPI_DL_CONFIG_BCH_PDU_TYPE: - // BCH case - // Last parameter is 1 if first time synchronization and zero otherwise. Not sure which value to put - // for our case. - dl_phy_sync_success(Mod_id,frame,eNB_id, 0); - break; - - case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: - if (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1) { - // C-RNTI (Normal DLSCH case) - dl_config_pdu_tmp = &DL_req->dl_config_request_body.dl_config_pdu_list[i+1]; - if (dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE){ - ue_send_sdu(Mod_id, CC_id, frame, subframe, - Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length, - eNB_id); - i++; - } - else { - LOG_E(MAC,"[UE %d] CCid %d Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI\n",Mod_id, CC_id,frame,subframe); - } - } - else if (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 2) { - dl_config_pdu_tmp = &DL_req->dl_config_request_body.dl_config_pdu_list[i+1]; - if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFF){ - //pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data; - // Question about eNB_index here. How do we obtain it? - ue_decode_si(Mod_id, CC_id, frame, eNB_id, - Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); - i++; - } - else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFE){ - // P_RNTI case - //pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data; - // Question about eNB_index here. How do we obtain it? - ue_decode_p(Mod_id, CC_id, frame, eNB_id, - Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); - i++; - } - else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { - // RA-RNTI case - // ue_process_rar should be called but the problem is that this function currently uses PHY_VARS_UE - // elements. - - // RNTI parameter not actually used. Provided only to comply with existing function definition. - // Not sure about parameters to fill the preamble index. - //rnti_t c_rnti = UE_mac_inst[Mod_id].crnti; - rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI; - if ((UE_mac_inst[Mod_id].UE_mode[0] != PUSCH) && - (UE_mac_inst[Mod_id].RA_prach_resources.Msg3!=NULL)) { - ue_process_rar(Mod_id, CC_id, frame, - ra_rnti, //RA-RNTI - Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - &dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex, - Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data); - UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE; - UE_mac_inst[Mod_id].first_ULSCH_Tx = 1; //Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first ULSCH Txon for the UE) - } - } - else { - LOG_E(MAC,"[UE %d] CCid %d Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI\n",Mod_id, CC_id,frame,subframe); - } - - } - break; - } - - } - - -} - - void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t* UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti) { @@ -817,14 +723,238 @@ int ul_config_req_UE_MAC(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_ } +int tx_req_UE_MAC(nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) +{ + uint16_t sfn = NFAPI_SFNSF2SFN(req->sfn_sf); + uint16_t sf = NFAPI_SFNSF2SF(req->sfn_sf); + + LOG_D(PHY,"%s() SFN/SF:%d/%d PDUs:%d\n", __FUNCTION__, sfn, sf, req->tx_request_body.number_of_pdus); + + if (req->tx_request_body.tl.tag==NFAPI_TX_REQUEST_BODY_TAG) + { + for (int i=0; i<req->tx_request_body.number_of_pdus; i++) + { + LOG_D(PHY,"%s() SFN/SF:%d/%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n", + __FUNCTION__, + sfn, sf, + req->tx_request_body.number_of_pdus, + i, + req->tx_request_body.tx_pdu_list[i].pdu_length, + req->tx_request_body.tx_pdu_list[i].pdu_index, + req->tx_request_body.tx_pdu_list[i].num_segments + ); + + tx_request_pdu_list = req->tx_request_body.tx_pdu_list; + //tx_request_pdu_UE_MAC[sfn][sf][i] = &req->tx_request_body.tx_pdu_list[i]; + } + } + + return 0; +} + + +int dl_config_req_UE_MAC(nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) +{ + + int sfn = NFAPI_SFNSF2SFN(req->sfn_sf); + int sf = NFAPI_SFNSF2SF(req->sfn_sf); + module_id_t Mod_id = 0; //Panos: Currently static (only for one UE) but this should change. + + /*struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; + eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0];*/ + nfapi_dl_config_request_pdu_t* dl_config_pdu_list = req->dl_config_request_body.dl_config_pdu_list; + nfapi_dl_config_request_pdu_t *dl_config_pdu_tmp; + + /*LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[sf&1]; + + pdcch_vars->num_pdcch_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols; + pdcch_vars->num_dci = 0;*/ + + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d sfn_sf:%d DCI:%d PDU:%d\n", __FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, NFAPI_SFNSF2DEC(req->sfn_sf), req->dl_config_request_body.number_dci, req->dl_config_request_body.number_pdu); + + for (int i=0;i<req->dl_config_request_body.number_pdu;i++) + { + //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size); + + if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + { + if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1) { + // C-RNTI (Normal DLSCH case) + dl_config_pdu_tmp = &dl_config_pdu_list[i+1]; + if (dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE){ + if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ + ue_send_sdu(Mod_id, 0, sfn, sf, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length, + 0); + i++; + } + } + else { + LOG_E(MAC,"[UE %d] Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI\n",Mod_id, sfn,sf); + } + } + else if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 2) { + dl_config_pdu_tmp = &dl_config_pdu_list[i+1]; + if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFF){ + //pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data; + if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ + ue_decode_si(Mod_id, 0, sfn, 0, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); + i++; + } + } + else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFE){ + // P_RNTI case + //pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data; + if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){ + ue_decode_p(Mod_id, 0, sfn, 0, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); + i++; + } + } + else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { + // RA-RNTI case + + // RNTI parameter not actually used. Provided only to comply with existing function definition. + // Not sure about parameters to fill the preamble index. + //rnti_t c_rnti = UE_mac_inst[Mod_id].crnti; + rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI; + if ((UE_mac_inst[Mod_id].UE_mode[0] != PUSCH) && + (UE_mac_inst[Mod_id].RA_prach_resources.Msg3!=NULL) && + (tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL)) { + + ue_process_rar(Mod_id, 0, sfn, + ra_rnti, //RA-RNTI + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + &dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti + UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex, + tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data); + UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 1; //Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first ULSCH Txon for the UE) + } + } + else { + LOG_E(MAC,"[UE %d] %d Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI\n",Mod_id, sfn, sf); + } + + } + } + else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE) + { + // BCH case + // Last parameter is 1 if first time synchronization and zero otherwise. Not sure which value to put + // for our case. + dl_phy_sync_success(Mod_id,sfn,0, 0); + + } + + else + { + NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_config_pdu_list[i].pdu_type); + } + } + + if(req->vendor_extension) + free(req->vendor_extension); + + return 0; +} + + +/*void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id){ + // copy data from eNB L2 interface to UE L2 interface + int CC_id = Sched_INFO->CC_id; + nfapi_dl_config_request_t *DL_req = Sched_INFO->DL_req; + nfapi_tx_request_t *Tx_req = Sched_INFO->TX_req; + frame_t frame = Sched_INFO->frame; + sub_frame_t subframe = Sched_INFO->subframe; + uint8_t number_dl_pdu = DL_req->dl_config_request_body.number_pdu; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + nfapi_dl_config_request_pdu_t *dl_config_pdu_tmp; + int i = 0; + for (i=0; i<number_dl_pdu; i++) + { + dl_config_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[i]; + switch (dl_config_pdu->pdu_type) { + case NFAPI_DL_CONFIG_BCH_PDU_TYPE: + // BCH case + // Last parameter is 1 if first time synchronization and zero otherwise. Not sure which value to put + // for our case. + dl_phy_sync_success(Mod_id,frame,eNB_id, 0); + break; + case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: + if (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1) { + // C-RNTI (Normal DLSCH case) + dl_config_pdu_tmp = &DL_req->dl_config_request_body.dl_config_pdu_list[i+1]; + if (dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE){ + ue_send_sdu(Mod_id, CC_id, frame, subframe, + Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length, + eNB_id); + i++; + } + else { + LOG_E(MAC,"[UE %d] CCid %d Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI\n",Mod_id, CC_id,frame,subframe); + } + } + else if (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 2) { + dl_config_pdu_tmp = &DL_req->dl_config_request_body.dl_config_pdu_list[i+1]; + if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFF){ + //pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data; + // Question about eNB_index here. How do we obtain it? + ue_decode_si(Mod_id, CC_id, frame, eNB_id, + Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); + i++; + } + else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFE){ + // P_RNTI case + //pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data; + // Question about eNB_index here. How do we obtain it? + ue_decode_p(Mod_id, CC_id, frame, eNB_id, + Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length); + i++; + } + else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) { + // RA-RNTI case + // ue_process_rar should be called but the problem is that this function currently uses PHY_VARS_UE + // elements. + // RNTI parameter not actually used. Provided only to comply with existing function definition. + // Not sure about parameters to fill the preamble index. + //rnti_t c_rnti = UE_mac_inst[Mod_id].crnti; + rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI; + if ((UE_mac_inst[Mod_id].UE_mode[0] != PUSCH) && + (UE_mac_inst[Mod_id].RA_prach_resources.Msg3!=NULL)) { + ue_process_rar(Mod_id, CC_id, frame, + ra_rnti, //RA-RNTI + Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + &dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti + UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex, + Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data); + UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE; + UE_mac_inst[Mod_id].first_ULSCH_Tx = 1; //Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first ULSCH Txon for the UE) + } + } + else { + LOG_E(MAC,"[UE %d] CCid %d Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI\n",Mod_id, CC_id,frame,subframe); + } + } + break; + } + } +}*/ diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.h b/openair2/PHY_INTERFACE/phy_stub_UE.h index b3b07b60b32e98f29ee5bdcf8569c2a6a3a41f10..a893a7f4cda0aca027a06d845c83bdec8e1d6cbd 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.h +++ b/openair2/PHY_INTERFACE/phy_stub_UE.h @@ -19,6 +19,8 @@ UL_IND_t *UL_INFO; +nfapi_tx_request_pdu_t* tx_request_pdu_list; + // Panos: This function should return all the sched_response config messages which concern a specific UE. Inside this @@ -27,7 +29,7 @@ Sched_Rsp_t get_nfapi_sched_response(uint8_t Mod_id); // This function will be processing DL_config and Tx.requests and trigger all the MAC Rx related calls at the UE side, // namely:ue_send_sdu(), or ue_decode_si(), or ue_decode_p(), or ue_process_rar() based on the rnti type. -void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id); +//void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id); int pnf_ul_config_req_UE_MAC(nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req); @@ -75,6 +77,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id, nfapi_ul_config_request_pdu_t *ul_config_pdu, uint16_t frame,uint8_t subframe,uint8_t srs_present); +int tx_req_UE_MAC(nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req); + #endif /* PHY_STUB_UE_H_ */