From 6a7fe60266b7b7f65145dbc86077262a3f4afc75 Mon Sep 17 00:00:00 2001 From: "Deokseong \"David\" Kim" Date: Tue, 21 Sep 2021 22:38:29 +0000 Subject: [PATCH] Episys/david/sync between dl tti req and tx data req --- openair1/SCHED_NR/fapi_nr_l1.c | 6 +-- .../SIMULATION/ETH_TRANSPORT/netlink_init.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 6 +++ openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 47 ++++++++++++++++++- 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index fa762fa5b8..73d32a6f02 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -266,13 +266,13 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ if (number_ul_dci_pdu>0) oai_nfapi_ul_dci_req(UL_dci_req); - - if (number_dl_pdu>0) - oai_nfapi_dl_tti_req(DL_req); if (number_tx_data_pdu>0) oai_nfapi_tx_data_req(TX_req); + if (number_dl_pdu>0) + oai_nfapi_dl_tti_req(DL_req); + } } diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 17ce2ecd5e..150165203e 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -56,7 +56,7 @@ struct nlmsghdr *nas_nlh_rx = NULL; struct iovec nas_iov_tx; struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)}; -int nas_sock_fd[MAX_MOBILES_PER_ENB]; +int nas_sock_fd[MAX_MOBILES_PER_ENB*2]; //Allocated for both LTE UE and NR UE. int nas_sock_mbms_fd; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index eef84814ca..ad2627e1bc 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -501,6 +501,12 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dci->dci_format]; + if ((dci->rnti != mac->crnti) && (dci->rnti != mac->ra.ra_rnti)) { + LOG_D(MAC,"We skip for the received dci indication rnti %4x != mac->crnti %4x frame slot %4d.%2d RA state %d\n", + dci->rnti, mac->crnti, frame, slot, mac->ra.ra_state); + return 0; + } + LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits); int8_t ret = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index b61e8447a5..318efebfd7 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -262,9 +262,11 @@ static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_ for (int j = 0; j < num_dcis; j++) { nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j]; - if (dci_pdu_list->RNTI != mac->crnti) + if ((dci_pdu_list->RNTI != mac->crnti) && + ((dci_pdu_list->RNTI != mac->ra.ra_rnti) || mac->ra.RA_RAPID_found)) { LOG_D(NR_MAC, "We are filtering PDCCH DCI pdu because RNTI doesnt match!\n"); + LOG_D(NR_MAC, "dci_pdu_list->RNTI (%x) != mac->crnti (%x)\n", dci_pdu_list->RNTI, mac->crnti); continue; } fill_dl_info_with_pdcch(dl_info->dci_ind, dci_pdu_list, pdu_idx); @@ -600,9 +602,16 @@ uint16_t sfn_slot_id; void *nrue_standalone_pnf_task(void *context) { + NR_UE_MAC_INST_t *mac = get_mac_inst(0); struct sockaddr_in server_address; socklen_t addr_len = sizeof(server_address); char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + char buffer_for_tx_data_req[NFAPI_MAX_PACKED_MESSAGE_SIZE]; + ssize_t len_of_tx_data_req = 0; + int sfn_of_tx_data_req = 0; + int slot_of_tx_data_req = 0; + int sfn_of_dl_tti_req = 0; + int slot_of_dl_tti_req = 0; int sfn = 0; int slot = 0; int delta = 0; @@ -698,6 +707,26 @@ void *nrue_standalone_pnf_task(void *context) dl_tti_request.SFN, dl_tti_request.Slot); save_nr_measurement_info(&dl_tti_request); check_and_process_dci(&dl_tti_request, NULL, NULL, NULL); + if (mac->expected_dci) + { + sfn_of_dl_tti_req = dl_tti_request.SFN; + slot_of_dl_tti_req = dl_tti_request.Slot; + } + if (len_of_tx_data_req > 0 + && sfn_of_dl_tti_req == sfn_of_tx_data_req + && slot_of_dl_tti_req == slot_of_tx_data_req) + { + if (nfapi_nr_p7_message_unpack((void *)buffer_for_tx_data_req, len_of_tx_data_req, &tx_data_request, + sizeof(tx_data_request), NULL) < 0) + { + LOG_E(NR_PHY, "Message tx_data_request failed to unpack\n"); + break; + } + LOG_I(NR_PHY, "Processing an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", + tx_data_request.SFN, tx_data_request.Slot); + check_and_process_dci(NULL, &tx_data_request, NULL, NULL); + len_of_tx_data_req = 0; + } break; case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST: if (nfapi_nr_p7_message_unpack((void *)buffer, len, &tx_data_request, @@ -708,7 +737,21 @@ void *nrue_standalone_pnf_task(void *context) } LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", tx_data_request.SFN, tx_data_request.Slot); - check_and_process_dci(NULL, &tx_data_request, NULL, NULL); + + if (tx_data_request.SFN == sfn_of_dl_tti_req && tx_data_request.Slot == slot_of_dl_tti_req + && (mac->expected_dci || mac->ra.ra_state <= WAIT_RAR)) + { + check_and_process_dci(NULL, &tx_data_request, NULL, NULL); + } + else + { + len_of_tx_data_req = len; + sfn_of_tx_data_req = tx_data_request.SFN; + slot_of_tx_data_req = tx_data_request.Slot; + memcpy(buffer_for_tx_data_req, buffer, len); + LOG_I(NR_PHY, "Saved an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", + tx_data_request.SFN, tx_data_request.Slot); + } break; case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: if (nfapi_nr_p7_message_unpack((void *)buffer, len, &ul_dci_request,