From 24d75a99af374817aaff201752ec9497705d5432 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Tue, 31 Aug 2021 11:48:21 -0700 Subject: [PATCH 1/3] Only initializing PDCP if using EPC (S1 mode) --- executables/nr-uesoftmodem.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index d7eb37d251..4287a9008b 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -397,17 +397,17 @@ void init_pdcp(int ue_id) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; }*/ - if (IS_SOFTMODEM_NOKRNMOD) + if (IS_SOFTMODEM_NOKRNMOD) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; - if(!IS_SOFTMODEM_NOS1) { - if (rlc_module_init(0) != 0) { - LOG_I(RLC, "Problem at RLC initiation \n"); - } } - pdcp_layer_init(); - nr_pdcp_module_init(pdcp_initmask, ue_id); - //nr_DRB_preconfiguration(); - //pdcp_module_init(pdcp_initmask, 0); + if (rlc_module_init(0) != 0) { + LOG_I(RLC, "Problem at RLC initiation \n"); + } + if(!IS_SOFTMODEM_NOS1) { + pdcp_layer_init(); + nr_pdcp_module_init(pdcp_initmask, ue_id); + } + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); } From 1c248bcf499c426b2364c46c5aef1e93d554ed29 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Tue, 31 Aug 2021 15:53:14 -0700 Subject: [PATCH 2/3] Successfully writing to TUN if and removed usleep --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 17 ++++++++++++----- openair2/RRC/LTE/rrc_UE.c | 2 -- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index a8f3390cde..6e167bd10b 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -450,14 +450,21 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, uint8_t *gtpu_buffer_p; int rb_id; int i; - LOG_I(PDCP, "Melissa Elkadi we got here %s\n", __FUNCTION__); - if(IS_SOFTMODEM_NOS1 || UE_NAS_USE_TUN){ + if (IS_SOFTMODEM_NOS1 || UE_NAS_USE_TUN) { LOG_D(PDCP, "IP packet received, to be sent to TUN interface"); - len = write(nas_sock_fd[0], buf, size); - LOG_D(PDCP, "Writing %d bytes to tunnel interface\n", len); + + /* We are removing the instance ID from the buffer. TUN interfaces + care about the actual data we are sending. If we do not remove + the instance ID from the buffer, it will start with 00, and the + write will fail with errno = 22 (EINVAL) */ + char *data_buffer = buf + 1; + int size_to_write = size - 1; + + len = write(nas_sock_fd[0], data_buffer, size_to_write); + LOG_D(PDCP, "len = %d bytes to tunnel interface %d\n", len, nas_sock_fd[0]); if (len != size) { - LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); + LOG_E(PDCP, "%s:%d:%s: fatal error %d: %s\n", __FILE__, __LINE__, __FUNCTION__, errno, strerror(errno)); } } else{ diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index fb363aa097..bb6364dfbd 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -4627,8 +4627,6 @@ void ue_measurement_report_triggering(protocol_ctxt_t *const ctxt_pP, const uint if (is_state_connected && is_t304_inactive && have_meas_flag) { LOG_I(RRC,"[UE %d] Frame %d: Triggering generation of Meas Report for NR_r15. count = %d\n", ctxt_pP->module_id, ctxt_pP->frame, ue->subframeCount); - if (!SOFTMODEM_NOS1_BIT) - usleep(200000); //Melissa Elkadi come back for EPC if (ue->measReportList[i][j] == NULL) { ue->measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); } From bfa8c8355c39cd562dc6a9d3b67f68719df98ab7 Mon Sep 17 00:00:00 2001 From: Melissa Elkadi Date: Tue, 31 Aug 2021 16:06:45 -0700 Subject: [PATCH 3/3] Updated logic for getting IP data in scheduler Also, the error checking for writing to the TUN interface was incorrect so that was fixed as well. --- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 2 +- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 234f7acc0d..40e314da3e 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1041,7 +1041,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator; mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0; } else { - if (!SOFTMODEM_NOS1_BIT || (mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != + if (!IS_SOFTMODEM_NOS1 && (mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator || mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id]==1)){ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 6e167bd10b..081bc30d39 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -463,7 +463,7 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, len = write(nas_sock_fd[0], data_buffer, size_to_write); LOG_D(PDCP, "len = %d bytes to tunnel interface %d\n", len, nas_sock_fd[0]); - if (len != size) { + if (len != size_to_write) { LOG_E(PDCP, "%s:%d:%s: fatal error %d: %s\n", __FILE__, __LINE__, __FUNCTION__, errno, strerror(errno)); } }