diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 997b1973a1da05f37396fa2e4c8c9f08d9b4bc96..d0ff78748ed286a3afb4f868938bb9ed3664edd2 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -928,12 +928,59 @@ void hi_dci0_req_UE_MAC(int sfn, } } +// TODO: Find a way to drop more un-wanted dl_config_reqs & tx_reqs +// In the current state we let alot of unecessary packets through +// during the ra-rnti/pi-rnti/si-rnti in the startup state before a c-rnti is assigned +// Right now we are just accepting all dl_config_req and tx_reqs +// when the c-rnti is 0 - Andrew +static bool is_my_dl_config_req(nfapi_dl_config_request_t *req) +{ + bool is_my_rnti = true; + const rnti_t my_rnti = UE_mac_inst[0].crnti; // 0 for standalone pnf mode. TODO: Make this more clear - Andrew + + for (int i = 0; i < req->dl_config_request_body.number_pdu; i++) + { + nfapi_dl_config_request_pdu_t *pdu = &req->dl_config_request_body.dl_config_pdu_list[i]; + const int pdu_type = pdu->pdu_type; + if (pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) + { + const rnti_t dci_rnti = pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti; + const int rnti_type = pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type; + if (rnti_type == 1 && dci_rnti != my_rnti) + { + is_my_rnti = false; + LOG_I(MAC, "RNTI is not mine for pdu_type: %d my_rnti: 0x%x dci_rnti: 0x%x\n", + pdu_type, my_rnti, dci_rnti); + } + else + { + is_my_rnti = true; + break; + } + } + } + + return is_my_rnti; +} + // The following set of memcpy functions should be getting called as callback // functions from pnf_p7_subframe_ind. int memcpy_dl_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { + if (!is_my_dl_config_req(req)) + { + // TODO: Add in some kind of log or check to identify that what is being removed from the queue is correct. - Andrew + // Need to remove corresponding tx_req (comes before dl_config_req always) + void *p = unqueue(&tx_req_pdu_queue); + if (p) + { + free(p); + } + return 0; + } + nfapi_dl_config_request_t *p = malloc(sizeof(nfapi_dl_config_request_t)); // UE_mac_inst[Mod_id].p->header = req->header; @@ -966,7 +1013,7 @@ int memcpy_dl_config_req(L1_rxtx_proc_t *proc, static bool is_my_ul_config_req(nfapi_ul_config_request_t *req) { bool is_my_rnti = false; - const rnti_t rnti = UE_mac_inst[0].crnti; // 0 for standalone pnf mode - Andrew + const rnti_t rnti = UE_mac_inst[0].crnti; // 0 for standalone pnf mode. TODO: Make this more clear - Andrew for (int i = 0; i < req->ul_config_request_body.number_of_pdus; i++) { nfapi_ul_config_request_pdu_t *pdu = &req->ul_config_request_body.ul_config_pdu_list[i]; diff --git a/openair2/PHY_INTERFACE/queue.c b/openair2/PHY_INTERFACE/queue.c index 3bd35bb35652cfb4ead73b1c6dbd59ae6a6e857a..8f0173939e672f2aa41c32a0376715ab88c45938 100644 --- a/openair2/PHY_INTERFACE/queue.c +++ b/openair2/PHY_INTERFACE/queue.c @@ -46,3 +46,21 @@ void *get_queue(queue_t *q) { pthread_mutex_unlock(&q->mutex); return item; } + +void *unqueue(queue_t *q) +{ + void *item = NULL; + if (pthread_mutex_lock(&q->mutex) != 0) { + LOG_E(PHY, "remove_from_back_of_queue mutex_lock failed\n"); + return NULL; + } + + if (q->num_items > 0) { + q->write_index = (q->write_index + MAX_QUEUE_SIZE - 1) % MAX_QUEUE_SIZE; + item = q->items[q->write_index]; + q->num_items--; + } + + pthread_mutex_unlock(&q->mutex); + return item; +} diff --git a/openair2/PHY_INTERFACE/queue.h b/openair2/PHY_INTERFACE/queue.h index 83de583aceed5e8f92c915a97c11c5b08b2a5738..a8fce7c4c258ba4db690ffbcb31423559ad9445e 100644 --- a/openair2/PHY_INTERFACE/queue.h +++ b/openair2/PHY_INTERFACE/queue.h @@ -43,3 +43,4 @@ typedef struct queue_t { void init_queue(queue_t *q); bool put_queue(queue_t *q, void *item); void *get_queue(queue_t *q); +void *unqueue(queue_t *q); diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 751e9ad7b9c028563688f776e629cd370c7b5b8f..95919cca0deeae1c61806001aa3c901efb87ff79 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -1230,7 +1230,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { UE_mac_inst[ue_Mod_id].UE_mode[0] = PRACH; } - LOG_I(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]); + LOG_D(MAC, "UE_mode: %d\n", UE_mac_inst[ue_Mod_id].UE_mode[0]); if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH) { //&& ue_Mod_id == next_Mod_id) { next_ra_frame++; @@ -1246,7 +1246,7 @@ static void *UE_phy_stub_standalone_pnf_task(void *arg) { LOG_I(MAC, "preamble_received_tar_power: %d\n", prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER); - UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf); // Is this why RACH comes in late to proxy? - Andrew + UE_mac_inst[ue_Mod_id].ra_frame = NFAPI_SFNSF2SFN(sfn_sf); LOG_D(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf)); fill_rach_indication_UE_MAC(ue_Mod_id, NFAPI_SFNSF2SFN(sfn_sf), NFAPI_SFNSF2SF(sfn_sf), UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); sent_any = true;