From d2ebc356a0c7d054035972934526bd398dad5db7 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 29 Sep 2024 10:17:56 +0200 Subject: [PATCH 01/58] removed division by num_antenna_ports in PDSCH precoding matrix generation. These matrices are defined for CSI reporting in this way but here we are using them for transmission and this results in an unwanted 10*log10(num_antenna_ports) reduction in transmit power --- openair2/LAYER2/NR_MAC_gNB/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index e0e11c5f2f..1f515b9ea6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -136,7 +136,7 @@ int precoding_weigths_generation(nfapi_nr_pm_list_t *mat, double complex res_code; for (int i_rows = 0; i_rows < N1 * N2; i_rows++) { nfapi_nr_pm_weights_t *weights = &mat->pmi_pdu[pmiq].weights[j_col][i_rows]; - res_code = sqrt(1 / (double)(L * num_antenna_ports)) * v_lm[llc][mmc][i_rows]; + res_code = sqrt(1 / (double)L) * v_lm[llc][mmc][i_rows]; c16_t precoder_weight = convert_precoder_weight(res_code); weights->precoder_weight_Re = precoder_weight.r; weights->precoder_weight_Im = precoder_weight.i; @@ -153,7 +153,7 @@ int precoding_weigths_generation(nfapi_nr_pm_list_t *mat, } for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) { nfapi_nr_pm_weights_t *weights = &mat->pmi_pdu[pmiq].weights[j_col][i_rows]; - res_code = sqrt(1 / (double)(L * num_antenna_ports)) * (phase_sign)*theta_n[nn] * v_lm[llc][mmc][i_rows - N1 * N2]; + res_code = sqrt(1 / (double)L) * (phase_sign)*theta_n[nn] * v_lm[llc][mmc][i_rows - N1 * N2]; c16_t precoder_weight = convert_precoder_weight(res_code); weights->precoder_weight_Re = precoder_weight.r; weights->precoder_weight_Im = precoder_weight.i; From a6576db51bf75f7104910257061f3887f3221ac9 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Fri, 27 Sep 2024 14:36:38 +0200 Subject: [PATCH 02/58] websrv regression --- common/utils/websrv/CMakeLists.txt | 2 +- common/utils/websrv/DOC/websrvuse.md | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/common/utils/websrv/CMakeLists.txt b/common/utils/websrv/CMakeLists.txt index 5a54460342..7d7b00b038 100644 --- a/common/utils/websrv/CMakeLists.txt +++ b/common/utils/websrv/CMakeLists.txt @@ -62,7 +62,7 @@ add_library(websrv MODULE websrv_utils.c ../../../openair1/PHY/TOOLS/nr_phy_scope.c ) -target_link_libraries(websrv PRIVATE ulfius jansson) +target_link_libraries(websrv PRIVATE ulfius jansson asn1_nr_rrc_hdrs) target_compile_definitions(websrv PUBLIC WEBSRVSCOPE) # put websrv into build root and not under build/common/utils/websrv/ set_target_properties(websrv PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../../..) diff --git a/common/utils/websrv/DOC/websrvuse.md b/common/utils/websrv/DOC/websrvuse.md index 684f64b104..7f661da2a8 100644 --- a/common/utils/websrv/DOC/websrvuse.md +++ b/common/utils/websrv/DOC/websrvuse.md @@ -38,6 +38,20 @@ $ sudo dnf install -y jansson-devel npm curl wget ulfius has to be installed as explained [here](https://github.com/babelouest/ulfius/blob/master/INSTALL.md#pre-compiled-packages). +## Install from source if needed + +```bash +sudo dnf install -y jansson-devel npm curl wget libmicrohttpd-devel curl curlpp-devel systemd-devel +git clone https://github.com/babelouest/orcania.git +cd orcania; mkdir build; cd build; cmake ..; sudo make install +cd +git clone https://github.com/babelouest/yder.git +cd yder ; mkdir build; cd build; cmake ..; sudo make install +git clone https://github.com/babelouest/ulfius.git +cd ulfius +mkdir build; cd build; cmake ..; sudo make install +``` + ## Additional dependencies for the frontend Currently the web server frontend can run with nodejs 18, you can check the @@ -54,6 +68,16 @@ beyond this doc. For example, to install a specific nodeJS version, you can run the below command, with the typical output printed below for your convenience: + +install method by nvm +```bash +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash +source ~/.bashrc +nvm install 18 +nvm use 18 +``` + +install by apt-get ```bash $ curl -s https://deb.nodesource.com/setup_18.x | sudo bash From 1bf4ca7d9776d8808f2e9944e1fe775c4731c176 Mon Sep 17 00:00:00 2001 From: Raghavendra Dinavahi Date: Fri, 11 Oct 2024 16:41:37 +0200 Subject: [PATCH 03/58] fix for Other SI reception when BWP start != 0 --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 6ba441bad1..d61cbef202 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -735,7 +735,7 @@ static int nr_ue_process_dci_dl_10(NR_UE_MAC_INST_t *mac, return -1; } dlsch_pdu->rb_offset = dlsch_pdu->start_rb + dlsch_pdu->BWPStart; - if (mac->get_sib1) + if (mac->get_sib1 || mac->get_otherSI) dlsch_pdu->rb_offset -= dlsch_pdu->BWPStart; /* TIME_DOM_RESOURCE_ASSIGNMENT */ diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index ed8c47ae5f..7ea7dad968 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -572,17 +572,18 @@ static int nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si) // Dump contents if (si->criticalExtensions.present == NR_SystemInformation__criticalExtensions_PR_systemInformation || si->criticalExtensions.present == NR_SystemInformation__criticalExtensions_PR_criticalExtensionsFuture_r16) { - LOG_D( RRC, "[UE] si->criticalExtensions.choice.NR_SystemInformation_t->sib_TypeAndInfo.list.count %d\n", - si->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.count ); + LOG_D(NR_RRC, + "[UE] si->criticalExtensions.choice.NR_SystemInformation_t->sib_TypeAndInfo.list.count %d\n", + si->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.count); } else { - LOG_D( RRC, "[UE] Unknown criticalExtension version (not Rel16)\n" ); + LOG_D(NR_RRC, "[UE] Unknown criticalExtension version (not Rel16)\n"); return -1; } for (int i = 0; i < si->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.count; i++) { SystemInformation_IEs__sib_TypeAndInfo__Member *typeandinfo; typeandinfo = si->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.array[i]; - LOG_I(RRC, "Found SIB%d\n", typeandinfo->present + 1); + LOG_I(NR_RRC, "Found SIB%d\n", typeandinfo->present + 1); switch(typeandinfo->present) { case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib2: if(!SI_info->sib2) @@ -679,6 +680,8 @@ static int nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si) if(!SI_info->SInfo_r17.sib19) SI_info->SInfo_r17.sib19 = calloc(1, sizeof(*SI_info->SInfo_r17.sib19)); asn_copy(&asn_DEF_NR_SIB19_r17, (void **) &SI_info->SInfo_r17.sib19, typeandinfo->choice.sib19_v1700); + if (g_log->log_component[NR_RRC].level >= OAILOG_DEBUG) + xer_fprint(stdout, &asn_DEF_NR_SIB19_r17, (const void *)SI_info->SInfo_r17.sib19); nr_timer_start(&SI_info->SInfo_r17.sib19_timer); break; default: From d9a5866bcd89d37d811204e750aaca255ff6ba01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Soares=20Silva?= Date: Tue, 15 Oct 2024 16:48:23 +0100 Subject: [PATCH 04/58] Address warning unused variable 'tw512_128p' --- openair1/PHY/TOOLS/oai_dfts_neon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/TOOLS/oai_dfts_neon.c b/openair1/PHY/TOOLS/oai_dfts_neon.c index 5b72359179..b920f6aae4 100644 --- a/openair1/PHY/TOOLS/oai_dfts_neon.c +++ b/openair1/PHY/TOOLS/oai_dfts_neon.c @@ -1549,7 +1549,7 @@ void dft512(int16_t *x,int16_t *y,unsigned char scale) { simdshort_q15_t xtmp[256],*xtmpp,*x64 = (simdshort_q15_t *)x; - simd_q15_t ytmp[128],*tw512_128p=(simd_q15_t*)tw512,*tw512a_128p=(simd_q15_t *)tw512a,*tw512b_128p=(simd_q15_t *)tw512b,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; + simd_q15_t ytmp[128],*tw512a_128p=(simd_q15_t *)tw512a,*tw512b_128p=(simd_q15_t *)tw512b,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y; simd_q15_t *ytmpp = &ytmp[0]; int i; simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15); From 1ff4ff1455fd23c8fded4dfd5e3d4552d26bd650 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Wed, 16 Oct 2024 08:52:50 +0100 Subject: [PATCH 05/58] Tutorials: Update links for the latest Ubuntu 24.04 LTS iso file --- doc/NR_SA_Tutorial_COTS_UE.md | 2 +- doc/NR_SA_Tutorial_OAI_CN5G.md | 2 +- doc/NR_SA_Tutorial_OAI_nrUE.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/NR_SA_Tutorial_COTS_UE.md b/doc/NR_SA_Tutorial_COTS_UE.md index 291dfdd7b4..abf0b29df2 100644 --- a/doc/NR_SA_Tutorial_COTS_UE.md +++ b/doc/NR_SA_Tutorial_COTS_UE.md @@ -21,7 +21,7 @@ In this tutorial we describe how to configure and run a 5G end-to-end setup with Minimum hardware requirements: - Laptop/Desktop/Server for OAI CN5G and OAI gNB - - Operating System: [Ubuntu 22.04 LTS](https://releases.ubuntu.com/22.04/ubuntu-22.04.4-desktop-amd64.iso) + - Operating System: [Ubuntu 24.04 LTS](https://releases.ubuntu.com/24.04/ubuntu-24.04.1-desktop-amd64.iso) - CPU: 8 cores x86_64 @ 3.5 GHz - RAM: 32 GB - Laptop for UE diff --git a/doc/NR_SA_Tutorial_OAI_CN5G.md b/doc/NR_SA_Tutorial_OAI_CN5G.md index 07914b417a..5aeddb49ae 100644 --- a/doc/NR_SA_Tutorial_OAI_CN5G.md +++ b/doc/NR_SA_Tutorial_OAI_CN5G.md @@ -21,7 +21,7 @@ In this tutorial we describe how to configure and run a 5G end-to-end setup with Minimum hardware requirements: - Laptop/Desktop/Server for OAI CN5G and OAI gNB - - Operating System: [Ubuntu 22.04 LTS](https://releases.ubuntu.com/22.04/ubuntu-22.04.4-desktop-amd64.iso) + - Operating System: [Ubuntu 24.04 LTS](https://releases.ubuntu.com/24.04/ubuntu-24.04.1-desktop-amd64.iso) - CPU: 8 cores x86_64 @ 3.5 GHz - RAM: 32 GB diff --git a/doc/NR_SA_Tutorial_OAI_nrUE.md b/doc/NR_SA_Tutorial_OAI_nrUE.md index 043820d11b..c8b513f8b6 100644 --- a/doc/NR_SA_Tutorial_OAI_nrUE.md +++ b/doc/NR_SA_Tutorial_OAI_nrUE.md @@ -21,11 +21,11 @@ In this tutorial we describe how to configure and run a 5G end-to-end setup with Minimum hardware requirements: - Laptop/Desktop/Server for OAI CN5G and OAI gNB - - Operating System: [Ubuntu 22.04 LTS](https://releases.ubuntu.com/22.04/ubuntu-22.04.4-desktop-amd64.iso) + - Operating System: [Ubuntu 24.04 LTS](https://releases.ubuntu.com/24.04/ubuntu-24.04.1-desktop-amd64.iso) - CPU: 8 cores x86_64 @ 3.5 GHz - RAM: 32 GB - Laptop for UE - - Operating System: [Ubuntu 22.04 LTS](https://releases.ubuntu.com/22.04/ubuntu-22.04.4-desktop-amd64.iso) + - Operating System: [Ubuntu 24.04 LTS](https://releases.ubuntu.com/24.04/ubuntu-24.04.1-desktop-amd64.iso) - CPU: 8 cores x86_64 @ 3.5 GHz - RAM: 8 GB - [USRP B210](https://www.ettus.com/all-products/ub210-kit/), [USRP N300](https://www.ettus.com/all-products/USRP-N300/) or [USRP X300](https://www.ettus.com/all-products/x300-kit/) From 156aedb96bfa724d0516049fe7246b0448d401c3 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Wed, 16 Oct 2024 08:53:30 +0100 Subject: [PATCH 06/58] Tutorials: Update docker install to the latest instructions on the official website --- doc/NR_SA_Tutorial_OAI_CN5G.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/NR_SA_Tutorial_OAI_CN5G.md b/doc/NR_SA_Tutorial_OAI_CN5G.md index 5aeddb49ae..eb78972d35 100644 --- a/doc/NR_SA_Tutorial_OAI_CN5G.md +++ b/doc/NR_SA_Tutorial_OAI_CN5G.md @@ -33,11 +33,12 @@ Minimum hardware requirements: sudo apt install -y git net-tools putty # https://docs.docker.com/engine/install/ubuntu/ -sudo apt install -y ca-certificates curl gnupg +sudo apt update +sudo apt install -y ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -sudo chmod a+r /etc/apt/keyrings/docker.gpg -echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc +sudo chmod a+r /etc/apt/keyrings/docker.asc +echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin From 9a3162f049cab590153e54faa14cbd0ccf05db0f Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Wed, 16 Oct 2024 08:54:01 +0100 Subject: [PATCH 07/58] Tutorials: update UHD to v4.7.0.0 and update dependencies for Ubuntu 24.04 --- doc/NR_SA_Tutorial_COTS_UE.md | 4 ++-- doc/NR_SA_Tutorial_OAI_nrUE.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/NR_SA_Tutorial_COTS_UE.md b/doc/NR_SA_Tutorial_COTS_UE.md index abf0b29df2..7fc8b27a9a 100644 --- a/doc/NR_SA_Tutorial_COTS_UE.md +++ b/doc/NR_SA_Tutorial_COTS_UE.md @@ -59,11 +59,11 @@ sudo ./program_uicc --adm 12345678 --imsi 001010000000001 --isdn 00000001 --acc ### Build UHD from source ```bash # https://files.ettus.com/manual/page_build_guide.html -sudo apt install -y autoconf automake build-essential ccache cmake cpufrequtils doxygen ethtool g++ git inetutils-tools libboost-all-dev libncurses5 libncurses5-dev libusb-1.0-0 libusb-1.0-0-dev libusb-dev python3-dev python3-mako python3-numpy python3-requests python3-scipy python3-setuptools python3-ruamel.yaml +sudo apt install -y autoconf automake build-essential ccache cmake cpufrequtils doxygen ethtool g++ git inetutils-tools libboost-all-dev libncurses-dev libusb-1.0-0 libusb-1.0-0-dev libusb-dev python3-dev python3-mako python3-numpy python3-requests python3-scipy python3-setuptools python3-ruamel.yaml git clone https://github.com/EttusResearch/uhd.git ~/uhd cd ~/uhd -git checkout v4.6.0.0 +git checkout v4.7.0.0 cd host mkdir build cd build diff --git a/doc/NR_SA_Tutorial_OAI_nrUE.md b/doc/NR_SA_Tutorial_OAI_nrUE.md index c8b513f8b6..23b50c4ab4 100644 --- a/doc/NR_SA_Tutorial_OAI_nrUE.md +++ b/doc/NR_SA_Tutorial_OAI_nrUE.md @@ -47,11 +47,11 @@ Please install and configure OAI CN5G as described here: ### Build UHD from source ```bash # https://files.ettus.com/manual/page_build_guide.html -sudo apt install -y autoconf automake build-essential ccache cmake cpufrequtils doxygen ethtool g++ git inetutils-tools libboost-all-dev libncurses5 libncurses5-dev libusb-1.0-0 libusb-1.0-0-dev libusb-dev python3-dev python3-mako python3-numpy python3-requests python3-scipy python3-setuptools python3-ruamel.yaml +sudo apt install -y autoconf automake build-essential ccache cmake cpufrequtils doxygen ethtool g++ git inetutils-tools libboost-all-dev libncurses-dev libusb-1.0-0 libusb-1.0-0-dev libusb-dev python3-dev python3-mako python3-numpy python3-requests python3-scipy python3-setuptools python3-ruamel.yaml git clone https://github.com/EttusResearch/uhd.git ~/uhd cd ~/uhd -git checkout v4.6.0.0 +git checkout v4.7.0.0 cd host mkdir build cd build From d2fca6bba4a39799344a269021d73da89fa77feb Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Wed, 16 Oct 2024 11:14:21 +0200 Subject: [PATCH 08/58] Update TESTBenches.md to reflect current testbench --- doc/TESTBenches.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index 77aab0a487..b17a1c1246 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -176,7 +176,7 @@ information on how the images are built. - uses RFsimulator, for FDD 5, 10, 20MHz with core, 5MHz noS1 - [RAN-RF-Sim-Test-5G](https://jenkins-oai.eurecom.fr/job/RAN-RF-Sim-Test-5G/) ~5G-NR - - obelix (gNB, nrUE, OAI 5GC) + - cacofonix (gNB, nrUE, OAI 5GC) - uses RFsimulator, TDD 40MHz, FDD 40MHz, F1 split - [RAN-SA-AW2S-CN5G](https://jenkins-oai.eurecom.fr/job/RAN-SA-AW2S-CN5G/) ~5G-NR From 1e73a95b5832b9b366c61bbbcce2ec30444d31ea Mon Sep 17 00:00:00 2001 From: Reem Bahsoun Date: Wed, 16 Oct 2024 14:40:37 +0200 Subject: [PATCH 09/58] Reduce tested DL throughput from 700 to 600Mbps --- ci-scripts/xml_files/container_sa_aerial_quectel.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/xml_files/container_sa_aerial_quectel.xml b/ci-scripts/xml_files/container_sa_aerial_quectel.xml index 3f49e5fa8d..63f22af51d 100644 --- a/ci-scripts/xml_files/container_sa_aerial_quectel.xml +++ b/ci-scripts/xml_files/container_sa_aerial_quectel.xml @@ -89,7 +89,7 @@ Iperf iperf (DL/UDP/700M)(30 sec)(single-ue profile) - -u -b 700M -t 30 -R + -u -b 600M -t 30 -R porcepix-cn5g up2-aerial 25 From 698b5e3dcf4298f6d9ba98d57cbb57fb78d61fec Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Thu, 11 Jul 2024 15:00:11 +0200 Subject: [PATCH 10/58] A testsuite and a benchmark for RLC AM mode --- openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c | 50 ++-- openair2/LAYER2/nr_rlc/tests/CMakeLists.txt | 10 + .../tests/benchmark_nr_rlc_am_entity.cpp | 112 +++++++++ .../nr_rlc/tests/test_nr_rlc_am_entity.cpp | 226 ++++++++++++++++++ 4 files changed, 379 insertions(+), 19 deletions(-) create mode 100644 openair2/LAYER2/nr_rlc/tests/benchmark_nr_rlc_am_entity.cpp create mode 100644 openair2/LAYER2/nr_rlc/tests/test_nr_rlc_am_entity.cpp diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c index d50f816072..480338fd84 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c @@ -767,8 +767,10 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, nr_rlc_pdu_decoder_init(&decoder, buffer, size); dc = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); - if (dc == 0) + if (dc == 0) { + LOG_D(RLC, "RLC received control PDU\n"); return process_control_pdu(entity, buffer, size); + } /* data PDU */ p = nr_rlc_pdu_decoder_get_bits(&decoder, 1); R(decoder); @@ -839,6 +841,7 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, entity->rx_list, pdu); /* do reception actions (38.322 5.2.3.2.3) */ + LOG_D(RLC, "RLC received PDU sn %d so %d is_first %d is_last %d data_size = %d \n", sn, so, is_first, is_last, data_size); reception_actions(entity, pdu); if (p) { @@ -852,15 +855,14 @@ void nr_rlc_entity_am_recv_pdu(nr_rlc_entity_t *_entity, entity->status_triggered = 1; if (!(sn_compare_rx(entity, sn, entity->rx_highest_status) < 0 || sn_compare_rx(entity, sn, v) >= 0)) { - LOG_D(RLC, "%s:%d:%s: warning: STATUS trigger should be delayed, according to specs\n", - __FILE__, __LINE__, __FUNCTION__); + LOG_D(RLC, "warning: STATUS triggerered but should be delayed according to specs\n"); } } return; err: - LOG_W(RLC, "%s:%d:%s: error decoding PDU, discarding\n", __FILE__, __LINE__, __FUNCTION__); + LOG_W(RLC, "RX error decoding PDU, discarding\n"); goto discard; discard: @@ -978,10 +980,7 @@ static nr_rlc_sdu_segment_t *resegment(nr_rlc_sdu_segment_t *sdu, pdu_header_size = compute_pdu_header_size(entity, sdu); next = calloc(1, sizeof(nr_rlc_sdu_segment_t)); - if (next == NULL) { - LOG_E(RLC, "%s:%d:%s: out of memory\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); - } + AssertFatal(next != NULL, "out of memory\n"); *next = *sdu; over_size = pdu_header_size + sdu->size - pdu_size; @@ -994,7 +993,6 @@ static nr_rlc_sdu_segment_t *resegment(nr_rlc_sdu_segment_t *sdu, next->size = over_size; next->so = sdu->so + sdu->size; next->is_first = 0; - return next; } @@ -1594,6 +1592,8 @@ static int generate_retx_pdu(nr_rlc_entity_am_t *entity, char *buffer, entity->force_poll = 0; } + LOG_D(RLC, "RLC TX: sending sdu sn = %d is_first = %d, is_last = %d size = %d\n", sdu->sdu->sn, sdu->is_first, sdu->is_last, size); + int ret_size = serialize_sdu(entity, sdu, buffer, size, p); entity->common.stats.txpdu_pkts++; entity->common.stats.txpdu_bytes += ret_size; @@ -1612,11 +1612,14 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) int p; /* sn out of window (that is: we have window stalling)? do nothing */ - if (is_window_stalling(entity)) + if (is_window_stalling(entity)) { + LOG_D(RLC, "Abort transmit due to window stall\n"); return 0; + } - if (entity->tx_list == NULL) + if (entity->tx_list == NULL) { return 0; + } sdu = entity->tx_list; @@ -1645,6 +1648,7 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) /* segment if necessary */ if (pdu_size > size) { + LOG_D(RLC, "Segmentation (header %d + data %d) / (%d)\n", pdu_header_size, size - pdu_header_size, pdu_size - pdu_header_size); nr_rlc_sdu_segment_t *next_sdu; next_sdu = resegment(sdu, entity, size); /* put the second SDU back at the head of the TX list */ @@ -1693,7 +1697,7 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) entity->common.stats.txpdu_pkts++; entity->common.stats.txpdu_bytes += ret_size; - /* No need to 'zero' time-of-arrival; + /* No need to 'zero' time-of-arrival; Segmented packets do need to be duplicated in time-sensitive use cases */ if (entity->common.avg_time_is_on) { uint64_t time_now = time_average_now(); @@ -1701,6 +1705,14 @@ static int generate_tx_pdu(nr_rlc_entity_am_t *entity, char *buffer, int size) time_average_add(entity->common.txsdu_avg_time_to_tx, time_now, waited_time); } + LOG_D(RLC, + "RLC TX: sending sdu sn = %d is_first = %d, is_last = %d header size = %d data size = %d\n", + sdu->sdu->sn, + sdu->is_first, + sdu->is_last, + pdu_header_size, + size - pdu_header_size); + return ret_size; // return serialize_sdu(entity, sdu, buffer, size, p); } @@ -1730,14 +1742,18 @@ int nr_rlc_entity_am_generate_pdu(nr_rlc_entity_t *_entity, if (status_to_report(entity)) { ret = generate_status(entity, buffer, size); - if (ret != 0) + if (ret != 0) { + LOG_D(RLC, "RLC transmit status pdu PDU\n"); return ret; + } } if (entity->retransmit_list != NULL) { ret = generate_retx_pdu(entity, buffer, size); - if (ret != 0) + if (ret != 0) { + LOG_D(RLC, "RLC retransmit PDU\n"); return ret; + } } return generate_tx_pdu(entity, buffer, size); @@ -1756,11 +1772,7 @@ void nr_rlc_entity_am_recv_sdu(nr_rlc_entity_t *_entity, entity->common.stats.rxsdu_pkts++; - if (size > NR_SDU_MAX) { - LOG_E(RLC, "%s:%d:%s: fatal: SDU size too big (%d bytes)\n", - __FILE__, __LINE__, __FUNCTION__, size); - exit(1); - } + AssertFatal(size <= NR_SDU_MAX, "Fatal: SDU size too big (%d bytes)\n", size); /* log SDUs rejected, at most once per second */ if (entity->sdu_rejected != 0 diff --git a/openair2/LAYER2/nr_rlc/tests/CMakeLists.txt b/openair2/LAYER2/nr_rlc/tests/CMakeLists.txt index 1f616e7927..c8d365ddf9 100644 --- a/openair2/LAYER2/nr_rlc/tests/CMakeLists.txt +++ b/openair2/LAYER2/nr_rlc/tests/CMakeLists.txt @@ -12,3 +12,13 @@ add_test(NAME nr_rlc_tests COMMAND exec_nr_rlc_test.sh ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +add_executable(test_nr_rlc_am_entity test_nr_rlc_am_entity.cpp) +target_link_libraries(test_nr_rlc_am_entity PRIVATE nr_rlc_core GTest::gtest minimal_lib) +add_dependencies(tests test_nr_rlc_am_entity) +add_test(NAME test_nr_rlc_am_entity COMMAND ./test_nr_rlc_am_entity) + +add_executable(benchmark_nr_rlc_am_entity benchmark_nr_rlc_am_entity.cpp) +target_link_libraries(benchmark_nr_rlc_am_entity PRIVATE benchmark::benchmark nr_rlc_core UTIL ${T_LIB} minimal_lib) +add_dependencies(tests benchmark_nr_rlc_am_entity) +add_test(NAME benchmark_nr_rlc_am_entity + COMMAND ./benchmark_nr_rlc_am_entity) diff --git a/openair2/LAYER2/nr_rlc/tests/benchmark_nr_rlc_am_entity.cpp b/openair2/LAYER2/nr_rlc/tests/benchmark_nr_rlc_am_entity.cpp new file mode 100644 index 0000000000..ac36b79211 --- /dev/null +++ b/openair2/LAYER2/nr_rlc/tests/benchmark_nr_rlc_am_entity.cpp @@ -0,0 +1,112 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ +#include "benchmark/benchmark.h" +extern "C" { +#include "openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h" +#include "openair2/LAYER2/nr_rlc/nr_rlc_entity.h" +#include "common/utils/LOG/log.h" +#include "common/config/config_load_configmodule.h" +extern configmodule_interface_t *uniqCfg; +} +#include + +void deliver_sdu(void *deliver_sdu_data, struct nr_rlc_entity_t *entity, char *buf, int size) +{ +} +void sdu_successful_delivery(void *sdu_successful_delivery_data, struct nr_rlc_entity_t *entity, int sdu_id) +{ +} +void max_retx_reached(void *max_retx_reached_data, struct nr_rlc_entity_t *entity) +{ +} + +static void BM_nr_rlc_am_entity(benchmark::State &state) +{ + nr_rlc_entity_t *tx_entity = new_nr_rlc_entity_am(10000, + 10000, + deliver_sdu, + NULL, + sdu_successful_delivery, + NULL, + max_retx_reached, + NULL, + 5, + 35, + 0, + 4, + -1, + 8, + 12); + + nr_rlc_entity_t *rx_entity = new_nr_rlc_entity_am(10000, + 10000, + deliver_sdu, + NULL, + sdu_successful_delivery, + NULL, + max_retx_reached, + NULL, + 5, + 35, + 0, + 4, + -1, + 8, + 12); + + char message[] = "Message to the other RLC AM entity."; + for (auto _ : state) { + char pdu_buf[40]; + for (int i = 0; i < state.range(0); i++) { + tx_entity->recv_sdu(tx_entity, message, sizeof(message), i); + int size = tx_entity->generate_pdu(tx_entity, pdu_buf, sizeof(pdu_buf)); + if (size != 0) { + // 10% packet loss + if (i % 10 != 0) + rx_entity->recv_pdu(rx_entity, pdu_buf, size); + } + // Allow the lists to build up before sending messages in the other direction + if (i % 100 == 0) { + size = rx_entity->generate_pdu(rx_entity, pdu_buf, sizeof(pdu_buf)); + if (size != 0) { + // No packet lost in the other direction + tx_entity->recv_pdu(tx_entity, pdu_buf, size); + } + } + tx_entity->set_time(tx_entity, i + 1); + rx_entity->set_time(tx_entity, i + 1); + } + } + tx_entity->delete_entity(tx_entity); + rx_entity->delete_entity(rx_entity); +} + +BENCHMARK(BM_nr_rlc_am_entity)->RangeMultiplier(4)->Range(100, 20000); + +int main(int argc, char **argv) +{ + logInit(); + uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY); + g_log->log_component[RLC].level = -1; + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); + return 0; +} diff --git a/openair2/LAYER2/nr_rlc/tests/test_nr_rlc_am_entity.cpp b/openair2/LAYER2/nr_rlc/tests/test_nr_rlc_am_entity.cpp new file mode 100644 index 0000000000..5407f7b2ae --- /dev/null +++ b/openair2/LAYER2/nr_rlc/tests/test_nr_rlc_am_entity.cpp @@ -0,0 +1,226 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "gtest/gtest.h" +extern "C" { +#include "openair2/LAYER2/nr_rlc/nr_rlc_entity_am.h" +#include "openair2/LAYER2/nr_rlc/nr_rlc_entity.h" +#include "common/utils/LOG/log.h" +#include "common/config/config_load_configmodule.h" +extern configmodule_interface_t *uniqCfg; +} +#include + +int sdu_delivered_count = 0; +int sdu_acked_count = 0; +void deliver_sdu(void *deliver_sdu_data, struct nr_rlc_entity_t *entity, char *buf, int size) +{ + sdu_delivered_count++; + char payload[300]; + ASSERT_LE(size, sizeof(payload)); + snprintf(payload, size, "%s", buf); + std::cout << "Delivered sdu: " << payload << std::endl; +} + +void sdu_successful_delivery(void *sdu_successful_delivery_data, struct nr_rlc_entity_t *entity, int sdu_id) +{ + sdu_acked_count++; + std::cout << "SDU " << sdu_id << " acked" << std::endl; +} + +void max_retx_reached(void *max_retx_reached_data, struct nr_rlc_entity_t *entity) +{ +} + +TEST(nr_rlc_am_entity, test_init) +{ + nr_rlc_entity_t *entity = new_nr_rlc_entity_am(100, + 100, + deliver_sdu, + NULL, + sdu_successful_delivery, + NULL, + max_retx_reached, + NULL, + 45, + 35, + 0, + -1, + -1, + 8, + 12); + char buf[30]; + EXPECT_EQ(entity->generate_pdu(entity, buf, sizeof(buf)), 0) << "No PDCP SDU provided to RLC, expected no RLC PDUS"; + + entity->delete_entity(entity); +} + +TEST(nr_rlc_am_entity, test_segmentation_reassembly) +{ + nr_rlc_entity_t *tx_entity = new_nr_rlc_entity_am(100, + 100, + deliver_sdu, + NULL, + sdu_successful_delivery, + NULL, + max_retx_reached, + NULL, + 45, + 35, + 0, + -1, + -1, + 8, + 12); + + nr_rlc_entity_t *rx_entity = new_nr_rlc_entity_am(100, + 100, + deliver_sdu, + NULL, + sdu_successful_delivery, + NULL, + max_retx_reached, + NULL, + 45, + 35, + 0, + -1, + -1, + 8, + 12); + char buf[30] = {0}; + snprintf(buf, sizeof(buf), "%s", "Message"); + EXPECT_EQ(tx_entity->generate_pdu(tx_entity, buf, sizeof(buf)), 0) << "No PDCP SDU provided to RLC, expected no RLC PDUS"; + + // Higher layer IF -> deliver PDCP SDU + tx_entity->recv_sdu(tx_entity, buf, sizeof(buf), 0); + sdu_delivered_count = 0; + for (auto i = 0; i < 10; i++) { + if (sdu_delivered_count == 1) { + break; + } + int size = tx_entity->generate_pdu(tx_entity, buf, 10); + EXPECT_GT(size, 0); + rx_entity->recv_pdu(rx_entity, buf, size); + } + EXPECT_EQ(sdu_delivered_count, 1); + sdu_acked_count = 0; + int size = rx_entity->generate_pdu(rx_entity, buf, 30); + tx_entity->recv_pdu(tx_entity, buf, size); + EXPECT_EQ(sdu_acked_count, 1); + + tx_entity->delete_entity(tx_entity); + rx_entity->delete_entity(rx_entity); +} + +TEST(nr_rlc_am_entity, test_ack_out_of_order) +{ + nr_rlc_entity_t *tx_entity = new_nr_rlc_entity_am(100, + 100, + deliver_sdu, + NULL, + sdu_successful_delivery, + NULL, + max_retx_reached, + NULL, + 5, + 35, + 0, + 4, + -1, + 8, + 12); + + nr_rlc_entity_t *rx_entity = new_nr_rlc_entity_am(100, + 100, + deliver_sdu, + NULL, + sdu_successful_delivery, + NULL, + max_retx_reached, + NULL, + 5, + 35, + 0, + 4, + -1, + 8, + 12); + + char buf[30] = {0}; + EXPECT_EQ(tx_entity->generate_pdu(tx_entity, buf, sizeof(buf)), 0) << "No PDCP SDU provided to RLC, expected no RLC PDUS"; + // Higher layer IF -> deliver PDCP SDU + // Generate 4 PDCP SDUS + snprintf(buf, sizeof(buf), "%s", "Message 1"); + tx_entity->recv_sdu(tx_entity, buf, sizeof(buf), 0); + snprintf(buf, sizeof(buf), "%s", "Message 2"); + tx_entity->recv_sdu(tx_entity, buf, sizeof(buf), 1); + snprintf(buf, sizeof(buf), "%s", "Message 3"); + tx_entity->recv_sdu(tx_entity, buf, sizeof(buf), 2); + + sdu_delivered_count = 0; + sdu_acked_count = 0; + char pdu_buf[40]; + uint64_t time = 0; + for (auto i = 0; i < 3; i++) { + int size = tx_entity->generate_pdu(tx_entity, pdu_buf, sizeof(pdu_buf)); + EXPECT_GT(size, 0); + // Do not deliver PDU 2 to RX entity + if (i != 1) { + rx_entity->recv_pdu(rx_entity, pdu_buf, size); + } + tx_entity->set_time(tx_entity, time); + rx_entity->set_time(tx_entity, time); + time++; + } + EXPECT_EQ(sdu_delivered_count, 2) << "Expected 2 out of 3 SDUs delivered"; + + int size = rx_entity->generate_pdu(rx_entity, pdu_buf, sizeof(pdu_buf)); + EXPECT_GT(size, 0); + tx_entity->recv_pdu(tx_entity, pdu_buf, size); + + // Triggers t-poll-retransmit and retransmission of the lost PDU + for (auto i = 0; i < 5; i++) { + tx_entity->set_time(tx_entity, time); + rx_entity->set_time(tx_entity, time); + size = tx_entity->generate_pdu(tx_entity, pdu_buf, sizeof(pdu_buf)); + if (size != 0) + rx_entity->recv_pdu(rx_entity, pdu_buf, size); + size = rx_entity->generate_pdu(rx_entity, pdu_buf, sizeof(pdu_buf)); + if (size != 0) + tx_entity->recv_pdu(tx_entity, pdu_buf, size); + time++; + } + EXPECT_EQ(sdu_acked_count, 3); + EXPECT_EQ(sdu_delivered_count, 3); + + tx_entity->delete_entity(tx_entity); + rx_entity->delete_entity(rx_entity); +} + +int main(int argc, char **argv) +{ + logInit(); + uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY); + g_log->log_component[RLC].level = OAILOG_TRACE; + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} From 4f5c73394db99f8d6d55ef91679b31066a66b82c Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Wed, 16 Oct 2024 17:08:49 +0200 Subject: [PATCH 11/58] doc: Update TESTBenches.md - remove Sphex UE - not used anymore - remove RAN-L2-Sim-Test-5G from a list of pipelines - currently disabled - 4G RFSim was moved to cacofonix - minor cleanup --- doc/TESTBenches.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index b17a1c1246..7e67e78d41 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -23,7 +23,7 @@ | avra | 172.21.16.124 | CI-Avra-Usage | gNB (n78) | AW2S Jaguar (192.168.80.239) | | orion | 172.21.16.134 | CI-Orion-Build-Sanity-Check-Deploy-Test, CI-Orion-DsTester-Deploy-Test | Build | | | aerial2 | 172.21.16.131 | CI-Aerial2-Usage | gNB (PNF/Nvidia CUBB + VNF) | Foxconn RU, _Nvidia Aerial SDK integrated_ | -| sphex | 172.21.17.54 | CI-Sphex-Usage | COTS UE | Quectel RM520N | +| cacofonix | 172.21.16.150 | CI-Cacofonix-Usage | gNB (n78, FHI7.2) | | | matix | 172.21.19.58 | CI-Matix-Usage | gNB (n77) | N310 | Note: The available resources, and their current usage, is indicated here: @@ -141,10 +141,6 @@ information on how the images are built. ~4G-LTE - obelix (eNB, 1x UE, OAI EPC) - L2simulator: skips physical layer and uses proxy between eNB and UE -- [RAN-L2-Sim-Test-5G](https://jenkins-oai.eurecom.fr/job/RAN-L2-Sim-Test-5G/) - ~5G-NR - - obelix (gNB, 1x UE, OAI 5GC) - - L2simulator: skips physical layer and uses proxy between gNB and UE, currently only ping - [RAN-LTE-FDD-LTEBOX-Container](https://jenkins-oai.eurecom.fr/job/RAN-LTE-FDD-LTEBOX-Container/) ~4G-LTE - hutch + B210, nano w/ ltebox + 2x UE @@ -172,7 +168,7 @@ information on how the images are built. - see [`./physical-simulators.md`](./physical-simulators.md) for an overview - [RAN-RF-Sim-Test-4G](https://jenkins-oai.eurecom.fr/job/RAN-RF-Sim-Test-4G/) ~4G-LTE - - obelix (eNB, lteUE, OAI EPC) + - cacofonix (eNB, lteUE, OAI EPC) - uses RFsimulator, for FDD 5, 10, 20MHz with core, 5MHz noS1 - [RAN-RF-Sim-Test-5G](https://jenkins-oai.eurecom.fr/job/RAN-RF-Sim-Test-5G/) ~5G-NR @@ -180,7 +176,7 @@ information on how the images are built. - uses RFsimulator, TDD 40MHz, FDD 40MHz, F1 split - [RAN-SA-AW2S-CN5G](https://jenkins-oai.eurecom.fr/job/RAN-SA-AW2S-CN5G/) ~5G-NR - - 5G-NR SA test setup: avra(RHEL9.1) + AW2S, amariue, OAI CN5G + - 5G-NR SA test setup: avra + AW2S, amariue, OAI CN5G - uses OpenShift cluster for CN deployment and container images for gNB deployment - multi UE testing using Amarisoft UE simulator - [RAN-SA-B200-Module-SABOX-Container](https://jenkins-oai.eurecom.fr/job/RAN-SA-B200-Module-SABOX-Container/) @@ -189,11 +185,11 @@ information on how the images are built. - basic SA test (20 MHz TDD), F1, reestablishment, ... - [RAN-SA-OAIUE-CN5G](https://jenkins-oai.eurecom.fr/job/RAN-SA-OAIUE-CN5G/) ~5G-NR - - 5G-NR SA test setup: gNB on avra(RHEL9.2) + N310, OAIUE on caracal(RHEL9.1) + N310, OAI CN5G + - 5G-NR SA test setup: gNB on avra + N310, OAIUE on caracal + N310, OAI CN5G - OpenShift cluster for CN deployment and container images for gNB and UE deployment - [RAN-SA-AERIAL-CN5G](https://jenkins-oai.eurecom.fr/job/RAN-SA-AERIAL-CN5G/) ~5G-NR - - 5G-NR SA test setup: OAI VNF + PNF/NVIDIA CUBB on Aerial2 (U22) + Foxconn RU, up2 + COTS UE (Quectel RM520N), OAI CN5G + - 5G-NR SA test setup: OAI VNF + PNF/NVIDIA CUBB on Aerial2 + Foxconn RU, up2 + COTS UE (Quectel RM520N), OAI CN5G - container images for gNB deployment - [RAN-SA-2x2-Module-CN5G](https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-2x2-Module-CN5G/) ~5G-NR @@ -201,7 +197,6 @@ information on how the images are built. - NR performance tests: 2x2 configuration, 60 MHz and 100 MHz bandwidth - [RAN-SA-FHI72-CN5G](https://jenkins-oai.eurecom.fr/view/RAN/job/RAN-SA-FHI72-CN5G/) ~5G-NR - - cacofonix + FHI72 + Benetel550 (gNB), AmariUE, OAI CN5G - cacofonix + FHI72 + VVDN (gNB), up2 (Quectel RM520N UE), OAI CN5G - OpenShift cluster for CN deployment - FHI 7.2 testing with 100 MHz bandwidth, 2 layers in DL From 1d85ae0245daf9bed2c57c8bd0cc38ac50726e53 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 16:34:03 +0200 Subject: [PATCH 12/58] Cleanup nr_rrc_pdcp_config_security() Pass directly pointer to UE context, remove protocol_ctxt_t (which simply is not required, and supposed to be removed anyway). --- openair2/RRC/NR/rrc_gNB.c | 2 +- openair2/RRC/NR/rrc_gNB_NGAP.c | 15 +++------------ openair2/RRC/NR/rrc_gNB_NGAP.h | 7 +------ 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index c1c78943e5..d6844ee54e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1733,7 +1733,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, } /* configure ciphering */ - nr_rrc_pdcp_config_security(ctxt_pP, ue_context_p, 1); + nr_rrc_pdcp_config_security(&ue_context_p->ue_context, true); ue_context_p->ue_context.as_security_active = true; /* trigger UE capability enquiry if we don't have them yet */ diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 6ffb8ad88e..7e614b09b2 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -126,18 +126,9 @@ void process_gNB_security_key ( LOG_I(NR_RRC, "[gNB %d][UE %x] Saved security key %s\n", ctxt_pP->module_id, UE->rnti, ascii_buffer); } -//------------------------------------------------------------------------------ -void -nr_rrc_pdcp_config_security( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - const uint8_t enable_ciphering -) -//------------------------------------------------------------------------------ +void nr_rrc_pdcp_config_security(gNB_RRC_UE_t *UE, bool enable_ciphering) { - //uint8_t *k_kdf = NULL; static int print_keys= 1; - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; /* Derive the keys from kgnb */ nr_pdcp_entity_security_keys_and_algos_t security_parameters; @@ -157,7 +148,7 @@ nr_rrc_pdcp_config_security( } } - nr_pdcp_config_set_security(ctxt_pP->rntiMaybeUEid, DCCH, true, &security_parameters); + nr_pdcp_config_set_security(UE->rrc_ue_id, DCCH, true, &security_parameters); } //------------------------------------------------------------------------------ @@ -478,7 +469,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t process_gNB_security_key(&ctxt, ue_context_p, req->security_key); /* configure only integrity, ciphering comes after receiving SecurityModeComplete */ - nr_rrc_pdcp_config_security(&ctxt, ue_context_p, 0); + nr_rrc_pdcp_config_security(UE, false); rrc_gNB_generate_SecurityModeCommand(&ctxt, ue_context_p); if (req->nb_of_pdusessions > 0) { diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h index 533aa8d15d..ee091b4269 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.h +++ b/openair2/RRC/NR/rrc_gNB_NGAP.h @@ -112,12 +112,7 @@ rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE( uint8_t xid ); -void -nr_rrc_pdcp_config_security( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - const uint8_t send_security_mode_command -); +void nr_rrc_pdcp_config_security(gNB_RRC_UE_t *UE, bool enable_ciphering); int rrc_gNB_process_PAGING_IND(MessageDef *msg_p, instance_t instance); From 4a40efede32b52e557399adea0e62e7ba66bbaa4 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 16:41:05 +0200 Subject: [PATCH 13/58] Clean up rrc_gNB_process_security() and called functions Pass rrc pointer and UE context directly instead of protocol_ctxt_t. --- openair2/RRC/NR/rrc_gNB_NGAP.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 7e614b09b2..38e893bcdc 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -93,7 +93,7 @@ static const uint16_t NGAP_INTEGRITY_NIA3_MASK = 0x2000; #define INTEGRITY_ALGORITHM_NONE NR_IntegrityProtAlgorithm_nia0 -static int rrc_gNB_process_security(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP, ngap_security_capabilities_t *security_capabilities_pP); +static bool rrc_gNB_process_security(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, ngap_security_capabilities_t *security_capabilities_pP); /*! \fn void process_gNB_security_key (const protocol_ctxt_t* const ctxt_pP, eNB_RRC_UE_t * const ue_context_pP, uint8_t *security_key) *\brief save security key. @@ -449,6 +449,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t return (-1); } PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, UE->rrc_ue_id, 0, 0); + gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; UE->amf_ue_ngap_id = req->amf_ue_ngap_id; /* store guami in gNB_RRC_UE_t context; @@ -465,7 +466,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t UE->nas_pdu = req->nas_pdu; /* security */ - rrc_gNB_process_security(&ctxt, ue_context_p, &req->security_capabilities); + rrc_gNB_process_security(rrc, UE, &req->security_capabilities); process_gNB_security_key(&ctxt, ue_context_p, req->security_key); /* configure only integrity, ciphering comes after receiving SecurityModeComplete */ @@ -532,11 +533,8 @@ void rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(const protocol_ctxt_t *const c itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p); } -static NR_CipheringAlgorithm_t rrc_gNB_select_ciphering( - const protocol_ctxt_t *const ctxt_pP, - uint16_t algorithms) +static NR_CipheringAlgorithm_t rrc_gNB_select_ciphering(const gNB_RRC_INST *rrc, uint16_t algorithms) { - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; int i; /* preset nea0 as fallback */ int ret = 0; @@ -568,11 +566,8 @@ static NR_CipheringAlgorithm_t rrc_gNB_select_ciphering( return ret; } -static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity( - const protocol_ctxt_t *const ctxt_pP, - uint16_t algorithms) +static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity(const gNB_RRC_INST *rrc, uint16_t algorithms) { - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; int i; /* preset nia0 as fallback */ int ret = 0; @@ -604,32 +599,30 @@ static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity( return ret; } -static int rrc_gNB_process_security(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP, ngap_security_capabilities_t *security_capabilities_pP) +static bool rrc_gNB_process_security(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, ngap_security_capabilities_t *security_capabilities_pP) { bool changed = false; NR_CipheringAlgorithm_t cipheringAlgorithm; e_NR_IntegrityProtAlgorithm integrityProtAlgorithm; - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; /* Save security parameters */ UE->security_capabilities = *security_capabilities_pP; // translation LOG_D(NR_RRC, - "[gNB %d] NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n", - ctxt_pP->module_id, + "NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n", UE->security_capabilities.nRencryption_algorithms, (unsigned long)UE->ciphering_algorithm, UE->security_capabilities.nRintegrity_algorithms, UE->integrity_algorithm); /* Select relevant algorithms */ - cipheringAlgorithm = rrc_gNB_select_ciphering(ctxt_pP, UE->security_capabilities.nRencryption_algorithms); + cipheringAlgorithm = rrc_gNB_select_ciphering(rrc, UE->security_capabilities.nRencryption_algorithms); if (UE->ciphering_algorithm != cipheringAlgorithm) { UE->ciphering_algorithm = cipheringAlgorithm; changed = true; } - integrityProtAlgorithm = rrc_gNB_select_integrity(ctxt_pP, UE->security_capabilities.nRintegrity_algorithms); + integrityProtAlgorithm = rrc_gNB_select_integrity(rrc, UE->security_capabilities.nRintegrity_algorithms); if (UE->integrity_algorithm != integrityProtAlgorithm) { UE->integrity_algorithm = integrityProtAlgorithm; @@ -637,8 +630,7 @@ static int rrc_gNB_process_security(const protocol_ctxt_t *const ctxt_pP, rrc_gN } LOG_I(NR_RRC, - "[gNB %d][UE %d] Selected security algorithms (%p): ciphering %lx, integrity %x (algorithms %s)\n", - ctxt_pP->module_id, + "[UE %d] Selected security algorithms (%p): ciphering %lx, integrity %x (algorithms %s)\n", UE->rrc_ue_id, security_capabilities_pP, cipheringAlgorithm, From 0cea0395e8732fe5d1dcdff6ce6fe48748dd36a8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 16:50:31 +0200 Subject: [PATCH 14/58] Cleanup and rename process_gNB_security_key() Rename to set_UE_security_key(), as it is for the UE. pass UE context directly. --- openair2/RRC/NR/rrc_gNB_NGAP.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 38e893bcdc..df30feb331 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -95,35 +95,27 @@ static const uint16_t NGAP_INTEGRITY_NIA3_MASK = 0x2000; static bool rrc_gNB_process_security(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, ngap_security_capabilities_t *security_capabilities_pP); -/*! \fn void process_gNB_security_key (const protocol_ctxt_t* const ctxt_pP, eNB_RRC_UE_t * const ue_context_pP, uint8_t *security_key) +/*! *\brief save security key. - *\param ctxt_pP Running context. - *\param ue_context_pP UE context. + *\param UE UE context. *\param security_key_pP The security key received from NGAP. */ -//------------------------------------------------------------------------------ -void process_gNB_security_key ( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t *security_key_pP -) -//------------------------------------------------------------------------------ +static void set_UE_security_key(gNB_RRC_UE_t *UE, uint8_t *security_key_pP) { - char ascii_buffer[65]; - uint8_t i; - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; + int i; /* Saves the security key */ memcpy(UE->kgnb, security_key_pP, SECURITY_KEY_LENGTH); memset(UE->nh, 0, SECURITY_KEY_LENGTH); UE->nh_ncc = -1; + char ascii_buffer[65]; for (i = 0; i < 32; i++) { sprintf(&ascii_buffer[2 * i], "%02X", UE->kgnb[i]); } + ascii_buffer[2 * 1] = '\0'; - ascii_buffer[2 * i] = '\0'; - LOG_I(NR_RRC, "[gNB %d][UE %x] Saved security key %s\n", ctxt_pP->module_id, UE->rnti, ascii_buffer); + LOG_I(NR_RRC, "[UE %x] Saved security key %s\n", UE->rnti, ascii_buffer); } void nr_rrc_pdcp_config_security(gNB_RRC_UE_t *UE, bool enable_ciphering) @@ -467,7 +459,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t /* security */ rrc_gNB_process_security(rrc, UE, &req->security_capabilities); - process_gNB_security_key(&ctxt, ue_context_p, req->security_key); + set_UE_security_key(UE, req->security_key); /* configure only integrity, ciphering comes after receiving SecurityModeComplete */ nr_rrc_pdcp_config_security(UE, false); From 8c14bf492150f3b7c43cbf552f4716d933a0077c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 17:27:33 +0200 Subject: [PATCH 15/58] Simplify rrc_gNB_process_security() rrc_gNB_process_security() does not only set (process) the security algorithms, but also checks for those. However, we don't use the check. Simplify the function, to reintroduce the check later. Rename to set_UE_security_algos() to better reflect what the functions do. --- openair2/RRC/NR/rrc_gNB_NGAP.c | 49 ++++++++++++---------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index df30feb331..c8e1f5918d 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -93,7 +93,7 @@ static const uint16_t NGAP_INTEGRITY_NIA3_MASK = 0x2000; #define INTEGRITY_ALGORITHM_NONE NR_IntegrityProtAlgorithm_nia0 -static bool rrc_gNB_process_security(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, ngap_security_capabilities_t *security_capabilities_pP); +static void set_UE_security_algos(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const ngap_security_capabilities_t *cap); /*! *\brief save security key. @@ -458,7 +458,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t UE->nas_pdu = req->nas_pdu; /* security */ - rrc_gNB_process_security(rrc, UE, &req->security_capabilities); + set_UE_security_algos(rrc, UE, &req->security_capabilities); set_UE_security_key(UE, req->security_key); /* configure only integrity, ciphering comes after receiving SecurityModeComplete */ @@ -591,44 +591,29 @@ static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity(const gNB_RRC_INST * return ret; } -static bool rrc_gNB_process_security(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, ngap_security_capabilities_t *security_capabilities_pP) +/* + * \brief set security algorithms + * \param rrc pointer to RRC context + * \param UE UE context + * \param cap security capabilities for this UE + */ +static void set_UE_security_algos(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const ngap_security_capabilities_t *cap) { - bool changed = false; - NR_CipheringAlgorithm_t cipheringAlgorithm; - e_NR_IntegrityProtAlgorithm integrityProtAlgorithm; - /* Save security parameters */ - UE->security_capabilities = *security_capabilities_pP; - // translation - LOG_D(NR_RRC, - "NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n", - UE->security_capabilities.nRencryption_algorithms, - (unsigned long)UE->ciphering_algorithm, - UE->security_capabilities.nRintegrity_algorithms, - UE->integrity_algorithm); + UE->security_capabilities = *cap; + /* Select relevant algorithms */ - cipheringAlgorithm = rrc_gNB_select_ciphering(rrc, UE->security_capabilities.nRencryption_algorithms); + NR_CipheringAlgorithm_t cipheringAlgorithm = rrc_gNB_select_ciphering(rrc, cap->nRencryption_algorithms); + e_NR_IntegrityProtAlgorithm integrityProtAlgorithm = rrc_gNB_select_integrity(rrc, cap->nRintegrity_algorithms); - if (UE->ciphering_algorithm != cipheringAlgorithm) { - UE->ciphering_algorithm = cipheringAlgorithm; - changed = true; - } - - integrityProtAlgorithm = rrc_gNB_select_integrity(rrc, UE->security_capabilities.nRintegrity_algorithms); - - if (UE->integrity_algorithm != integrityProtAlgorithm) { - UE->integrity_algorithm = integrityProtAlgorithm; - changed = true; - } + UE->ciphering_algorithm = cipheringAlgorithm; + UE->integrity_algorithm = integrityProtAlgorithm; LOG_I(NR_RRC, - "[UE %d] Selected security algorithms (%p): ciphering %lx, integrity %x (algorithms %s)\n", + "[UE %d] Selected security algorithms: ciphering %lx, integrity %x\n", UE->rrc_ue_id, - security_capabilities_pP, cipheringAlgorithm, - integrityProtAlgorithm, - changed ? "changed" : "are the same"); - return changed; + integrityProtAlgorithm); } //------------------------------------------------------------------------------ From 65b9af543a7bccf5a79d3e7a9ea8846de41e148c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 17:19:00 +0200 Subject: [PATCH 16/58] Cleanup rrc_gNB_generate_SecurityModeCommand() Cleanup this function: pass UE context directly, remove protocol_ctxt_t. --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 11 ++++------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 10 ++++------ openair2/RRC/NR/nr_rrc_proto.h | 2 +- openair2/RRC/NR/rrc_gNB.c | 15 ++++----------- openair2/RRC/NR/rrc_gNB_NGAP.c | 2 +- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 25baed610a..2a0ebd736c 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -519,12 +519,10 @@ int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, return ((enc_rval.encoded + 7) / 8); } -int do_NR_SecurityModeCommand( - const protocol_ctxt_t *const ctxt_pP, - uint8_t *const buffer, - const uint8_t Transaction_id, - const uint8_t cipheringAlgorithm, - NR_IntegrityProtAlgorithm_t integrityProtAlgorithm) +int do_NR_SecurityModeCommand(uint8_t *const buffer, + const uint8_t Transaction_id, + const uint8_t cipheringAlgorithm, + NR_IntegrityProtAlgorithm_t integrityProtAlgorithm) //------------------------------------------------------------------------------ { NR_DL_DCCH_Message_t dl_dcch_msg={0}; @@ -555,7 +553,6 @@ int do_NR_SecurityModeCommand( AssertFatal(enc_rval.encoded >0 , "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_DL_DCCH_Message,&dl_dcch_msg); - LOG_D(NR_RRC, "[gNB %d] securityModeCommand for UE %lx Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rntiMaybeUEid, enc_rval.encoded, (enc_rval.encoded + 7) / 8); // rrc_ue_process_ueCapabilityEnquiry(0,1000,&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry,0); // exit(-1); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 623573d24f..871fe08d49 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -81,12 +81,10 @@ int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, const gNB_RrcConfigurationReq *configuration, NR_SRB_ToAddModList_t *SRBs); -int do_NR_SecurityModeCommand( - const protocol_ctxt_t *const ctxt_pP, - uint8_t *const buffer, - const uint8_t Transaction_id, - const uint8_t cipheringAlgorithm, - NR_IntegrityProtAlgorithm_t integrityProtAlgorithm); +int do_NR_SecurityModeCommand(uint8_t *const buffer, + const uint8_t Transaction_id, + const uint8_t cipheringAlgorithm, + NR_IntegrityProtAlgorithm_t integrityProtAlgorithm); int do_NR_SA_UECapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 235b774bde..77202018e9 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -72,7 +72,7 @@ NR_CG_Config_t *generate_CG_Config(const NR_RRCReconfiguration_t *reconfig, cons int parse_CG_ConfigInfo(gNB_RRC_INST *rrc, NR_CG_ConfigInfo_t *CG_ConfigInfo, x2ap_ENDC_sgnb_addition_req_t *m); -void rrc_gNB_generate_SecurityModeCommand(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP); +void rrc_gNB_generate_SecurityModeCommand(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p); unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index d6844ee54e..19b36929f8 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -2585,28 +2585,21 @@ void *rrc_gnb_task(void *args_p) { } //----------------------------------------------------------------------------- -void rrc_gNB_generate_SecurityModeCommand(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP) +void rrc_gNB_generate_SecurityModeCommand(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p) //----------------------------------------------------------------------------- { uint8_t buffer[100]; - gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; AssertFatal(!ue_p->as_security_active, "logic error: security already active\n"); - T(T_ENB_RRC_SECURITY_MODE_COMMAND, - T_INT(ctxt_pP->module_id), - T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), - T_INT(ctxt_pP->rntiMaybeUEid)); + T(T_ENB_RRC_SECURITY_MODE_COMMAND, T_INT(0), T_INT(0), T_INT(0), T_INT(ue_p->rrc_ue_id)); NR_IntegrityProtAlgorithm_t integrity_algorithm = (NR_IntegrityProtAlgorithm_t)ue_p->integrity_algorithm; - int size = do_NR_SecurityModeCommand(ctxt_pP, - buffer, - rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), + int size = do_NR_SecurityModeCommand(buffer, + rrc_gNB_get_next_transaction_identifier(0), ue_p->ciphering_algorithm, integrity_algorithm); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)buffer, size, "[MSG] RRC Security Mode Command\n"); LOG_I(NR_RRC, "UE %u Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n", ue_p->rrc_ue_id, size); - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); } diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index c8e1f5918d..261a16cec3 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -463,8 +463,8 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t /* configure only integrity, ciphering comes after receiving SecurityModeComplete */ nr_rrc_pdcp_config_security(UE, false); + rrc_gNB_generate_SecurityModeCommand(rrc, UE); - rrc_gNB_generate_SecurityModeCommand(&ctxt, ue_context_p); if (req->nb_of_pdusessions > 0) { /* if there are PDU sessions to setup, store them to be created once * security (and UE capabilities) are received */ From eb9cb2f988a97e84f8a8102f97c8d9b1458be4d5 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 17 Oct 2024 10:08:08 +0200 Subject: [PATCH 17/58] added DTX detection in PUCCH 2 receiver. This is detected by MAC already which will drop PUCCH 2 indications that are detected as DTX. For the moment this uses the same pucch0_dtx_threshold value indicated in L1 section of the configuration file. --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index cda49b83d8..3b6209cd82 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -1087,6 +1087,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, pucch2_lev += signal_energy_nodc(rp[aa][symb], nb_re_pucch); } } + int decoderState=2; pucch2_lev /= Prx * Prx * pucch_pdu->nr_of_symbols; int pucch2_levdB = dB_fixed(pucch2_lev); int scaling = 0; @@ -1099,8 +1100,10 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, else if (pucch2_levdB > 54) scaling = 1; + if (pucch2_levdB < gNB->measurements.n0_subband_power_avg_dB + (gNB->pucch0_thres/10)) + decoderState=1; LOG_D(PHY, - "%d.%d Decoding pucch2 for %d symbols, %d PRB, nb_harq %d, nb_sr %d, nb_csi %d/%d, pucch2_lev %d dB (scaling %d)\n", + "%d.%d Decoding pucch2 for %d symbols, %d PRB, nb_harq %d, nb_sr %d, nb_csi %d/%d, pucch2_lev %d dB (scaling %d), n0+thres %d decoderState %d\n", frame, slot, pucch_pdu->nr_of_symbols, @@ -1110,7 +1113,9 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, pucch_pdu->bit_len_csi_part1, pucch_pdu->bit_len_csi_part2, pucch2_levdB, - scaling); + scaling, + gNB->measurements.n0_subband_power_avg_dB+(gNB->pucch0_thres/10), + decoderState); int nc_group_size=1; // 2 PRB int ngroup = prb_size_ext/nc_group_size/2; @@ -1365,7 +1370,6 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, uint64_t decodedPayload[2]; uint8_t corr_dB; - int decoderState=2; if (nb_bit < 12) { // short blocklength case simde__m256i *rp_re[Prx2][2]; simde__m256i *rp2_re[Prx2][2]; From b46e20abb96816bd8c0c98e649bd83d353e8ddc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Soares=20Silva?= Date: Tue, 15 Oct 2024 17:55:03 +0100 Subject: [PATCH 18/58] Address warnings in lte-enb.c by changing oai_cputime_t type. Since long long is the bigger type ( 8 bytes ) of the two used ( long long and uint32_t ), and long long is also available on ARM, change this parameter to always have this type. This allows to always use format specifier '%lld' in the logs that use TICK_TO_US, which would otherwise return long long or uint32_t depending on architecture. --- common/utils/time_meas.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/common/utils/time_meas.h b/common/utils/time_meas.h index bc37104a60..f7c2810b60 100644 --- a/common/utils/time_meas.h +++ b/common/utils/time_meas.h @@ -35,10 +35,8 @@ extern int cpu_meas_enabled; extern double cpu_freq_GHz __attribute__ ((aligned(32)));; // structure to store data to compute cpu measurment -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__) typedef long long oai_cputime_t; -#elif defined(__arm__) || defined(__aarch64__) - typedef uint32_t oai_cputime_t; #else #error "building on unsupported CPU architecture" #endif From 57cccd633f1abe66a9ab9dc135eefd5c8b7076aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Soares=20Silva?= Date: Tue, 15 Oct 2024 19:26:51 +0100 Subject: [PATCH 19/58] Correctly cast qam64_qam64 parameters in dlsch_llr_computation.c Change call to qam64_qam64 to use (short *) parameters as defined in the function declaration --- .../PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c index c3c3f0d006..094b1ef8d5 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c @@ -8010,12 +8010,12 @@ int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, (int32_t *) rho_256i, len); #else // defined(__arm__) || defined(__aarch64__) - qam64_qam64((int32_t *)rxF_256i, - (int32_t *)rxF_i_256i, - (int32_t *)ch_mag_256i, - (int32_t *)ch_mag_i_256i, - (int16_t *)llr16, - (int32_t *) rho_256i, + qam64_qam64((short *)rxF_256i, + (short *)rxF_i_256i, + (short *)ch_mag_256i, + (short *)ch_mag_i_256i, + (short *)llr16, + (short *) rho_256i, len); #endif From 99d251b29df6f701ab7cf45d8af33ac46304e4a3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 16 Oct 2024 20:09:56 +0200 Subject: [PATCH 20/58] Correct pkg-config include path when cross-compiling Prior to this commit, the include path for some libraries found through pkg-config when cross compiling is not correct: $ grep include CMakeCache.txt blas_INCLUDEDIR:INTERNAL=/usr/include/x86_64-linux-gnu ... This is because we did not tell pkg-config to search in the right path. Since for cross-compilation, we install packages in parallel in the system, override the primary directory where the .pc files located, in the cross-compilation toolchain file for cmake. Closes: #746 --- cmake_targets/cross-arm.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake_targets/cross-arm.cmake b/cmake_targets/cross-arm.cmake index 5384c09c5a..9480fc0fe0 100644 --- a/cmake_targets/cross-arm.cmake +++ b/cmake_targets/cross-arm.cmake @@ -4,6 +4,8 @@ set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc-11) set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++-11) +set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/aarch64-linux-gnu/pkgconfig") + set(CROSS_COMPILE 1) set(bnProc_gen_128_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NATIVE_DIR}) # /../build) set(bnProc_gen_avx2_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NATIVE_DIR}) # /../build) From 312f23189a6ee6d2ae660244866fa2490609c594 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 17 Oct 2024 14:14:57 +0200 Subject: [PATCH 21/58] Cross-build: add -Werror for CI build --- docker/Dockerfile.build.ubuntu22.cross-arm64 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile.build.ubuntu22.cross-arm64 b/docker/Dockerfile.build.ubuntu22.cross-arm64 index 16090c87e8..7b145fdc5b 100644 --- a/docker/Dockerfile.build.ubuntu22.cross-arm64 +++ b/docker/Dockerfile.build.ubuntu22.cross-arm64 @@ -43,7 +43,9 @@ RUN /bin/sh oaienv && \ cd ../build-cross/ && \ # install missing libyaml-cpp-dev for arm64 apt install -y libyaml-cpp-dev:arm64 && \ - cmake ../../.. -GNinja -DCMAKE_TOOLCHAIN_FILE=../../../cmake_targets/cross-arm.cmake -DNATIVE_DIR=../build && \ + cmake ../../.. -GNinja \ + -DCMAKE_TOOLCHAIN_FILE=../../../cmake_targets/cross-arm.cmake -DNATIVE_DIR=../build \ + -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" && \ echo "====== Start of log for cross-build executables ======" && \ # making always passing so we can analyze the all.txt file ninja dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim lte-softmodem nr-softmodem nr-cuup oairu lte-uesoftmodem nr-uesoftmodem params_libconfig coding rfsimulator > ../../log/all.txt 2>&1; \ From cd475ca07a219de7a5d0665852878d1938d3f598 Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Thu, 17 Oct 2024 16:11:15 +0200 Subject: [PATCH 22/58] Optimize T_ID() macro This changes the way T_IDs are defined. The T_ID macro was using a integer to pointer cast in order to provide type safety. This trick disables some compiler optimizations, as explained here: https://clang.llvm.org/extra/clang-tidy/checks/performance/no-int-to-ptr.html. Removing the type cast reenables the compiler optimizations. --- common/utils/T/T.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 6d781241a5..07919e843a 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -92,7 +92,11 @@ struct T_header; /* to define message ID */ +#ifdef CHECK_T_TYPE #define T_ID(x) ((struct T_header *)(uintptr_t)(x)) +#else +#define T_ID(x) x +#endif /* T macro tricks */ extern int T_stdout; From 94a3a61e175cad8f22615673364f347e7b9baadd Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 17 Oct 2024 18:45:50 +0200 Subject: [PATCH 23/58] Reuse rrc_forward_ue_nas_message() for DL Information Transfer --- openair2/RRC/NR/nr_rrc_proto.h | 2 ++ openair2/RRC/NR/rrc_gNB.c | 2 +- openair2/RRC/NR/rrc_gNB_NGAP.c | 24 ++++-------------------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 77202018e9..31a86c3144 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -74,6 +74,8 @@ int parse_CG_ConfigInfo(gNB_RRC_INST *rrc, NR_CG_ConfigInfo_t *CG_ConfigInfo, x2 void rrc_gNB_generate_SecurityModeCommand(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p); +void rrc_forward_ue_nas_message(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE); + unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP); void diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 19b36929f8..a4b4a427d7 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1372,7 +1372,7 @@ static int handle_rrcReestablishmentComplete(const protocol_ctxt_t *const ctxt_p return 0; } -static void rrc_forward_ue_nas_message(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE) +void rrc_forward_ue_nas_message(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE) { if (UE->nas_pdu.buffer == NULL || UE->nas_pdu.length == 0) return; // no problem: the UE will re-request a NAS PDU diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 261a16cec3..6afa5a5244 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -620,11 +620,9 @@ static void set_UE_security_algos(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, con int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mui_t *rrc_gNB_mui) //------------------------------------------------------------------------------ { - uint32_t length; - uint8_t buffer[4096]; - protocol_ctxt_t ctxt = {0}; ngap_downlink_nas_t *req = &NGAP_DOWNLINK_NAS(msg_p); - rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], req->gNB_ue_ngap_id); + gNB_RRC_INST *rrc = RC.nrrrc[instance]; + rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, req->gNB_ue_ngap_id); if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to NGAP and discard it! */ @@ -641,22 +639,8 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu } gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, UE->rrc_ue_id, 0, 0); - - /* Create message for PDCP (DLInformationTransfer_t) */ - length = do_NR_DLInformationTransfer(buffer, - sizeof(buffer), - rrc_gNB_get_next_transaction_identifier(instance), - req->nas_pdu.length, - req->nas_pdu.buffer); - LOG_DUMPMSG(NR_RRC, DEBUG_RRC, buffer, length, "[MSG] RRC DL Information Transfer\n"); - /* - * switch UL or DL NAS message without RRC piggybacked to SRB2 if active. - */ - AssertFatal(!NODE_IS_DU(RC.nrrrc[ctxt.module_id]->node_type), "illegal node type DU: receiving NGAP messages at this node\n"); - /* Transfer data to PDCP */ - rb_id_t srb_id = UE->Srb[2].Active ? DCCH1 : DCCH; - nr_rrc_transfer_protected_rrc_message(RC.nrrrc[instance], UE, srb_id, buffer, length); + UE->nas_pdu = req->nas_pdu; + rrc_forward_ue_nas_message(rrc, UE); return 0; } From d71104da5191649069630bc307f8026961f62e0a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 17 Oct 2024 18:59:17 +0200 Subject: [PATCH 24/58] Handle repeated NGAP Initial Context Setup Request Prior to this commit, if we receive an Initial Context Setup Request for a UE that has AS security set up, the gNB asserts with Assertion (!ue_p->as_security_active) failed! In rrc_gNB_generate_SecurityModeCommand() openairinterface5g/openair2/RRC/NR/rrc_gNB.c:2590 logic error: security already activ However, TS 38.413 says: > The AMF may initiate the Initial Context Setup procedure if a > UE-associated logical NG-connection exists for the UE (I interpret this as "it might happen anytime") > store the received Security Key in the UE context and, if the NG-RAN > node is required to activate security for the UE, take this security key > into use. (I interpret this as "do not set up AS security again") In this commit, handle if we receive an Initial Context Setup Request for an existing UE context. As said in the spec, we store the keys. If security is not active, we trigger RRC Security Mode Command. If it is active, we skip Security, and directly set up a PDU session. If there is also no PDU session, we simply forward the NAS message, and acknowledge. If there was no AS security, after security, the gNB would trigger the setup of PDU sessions (if any), and then forward any NAS PDUs, which is stated in the if block if AS security is already active. --- openair2/RRC/NR/rrc_gNB_NGAP.c | 37 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 6afa5a5244..66f0f4fc69 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -457,14 +457,6 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t // this is malloced pointers, we pass it for later free() UE->nas_pdu = req->nas_pdu; - /* security */ - set_UE_security_algos(rrc, UE, &req->security_capabilities); - set_UE_security_key(UE, req->security_key); - - /* configure only integrity, ciphering comes after receiving SecurityModeComplete */ - nr_rrc_pdcp_config_security(UE, false); - rrc_gNB_generate_SecurityModeCommand(rrc, UE); - if (req->nb_of_pdusessions > 0) { /* if there are PDU sessions to setup, store them to be created once * security (and UE capabilities) are received */ @@ -475,6 +467,35 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t UE->initial_pdus[i] = req->pdusession_param[i]; } + /* security */ + set_UE_security_algos(rrc, UE, &req->security_capabilities); + set_UE_security_key(UE, req->security_key); + + /* TS 38.413: "store the received Security Key in the UE context and, if the + * NG-RAN node is required to activate security for the UE, take this + * security key into use.": I interpret this as "if AS security is already + * active, don't do anything" */ + if (!UE->as_security_active) { + /* configure only integrity, ciphering comes after receiving SecurityModeComplete */ + nr_rrc_pdcp_config_security(UE, false); + rrc_gNB_generate_SecurityModeCommand(rrc, UE); + } else { + /* if AS security key is active, we also have the UE capabilities. Then, + * there are two possibilities: we should set up PDU sessions, and/or + * forward the NAS message. */ + if (req->nb_of_pdusessions > 0) { + // do not remove the above allocation which is reused here: this is used + // in handle_rrcReconfigurationComplete() to know that we need to send a + // Initial context setup response message + trigger_bearer_setup(rrc, UE, UE->n_initial_pdu, UE->initial_pdus, 0); + } else { + /* no PDU sesion to setup: acknowledge this message, and forward NAS + * message, if required */ + rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(&ctxt, ue_context_p); + rrc_forward_ue_nas_message(rrc, UE); + } + } + #ifdef E2_AGENT signal_rrc_state_changed_to(UE, RC_SM_RRC_CONNECTED); #endif From 542ef1c1c6622aea7fec31e82aa3e9f959af2634 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 18:15:49 +0200 Subject: [PATCH 25/58] Handle fault rrcReestablishmentComplete gracefully A UE might send a rrcReestablishmentComplete without the actual IEs present (intentionally or not). Check this and handle appropriately to avoid assertion Assertion (reestablishment_complete->criticalExtensions.present == NR_RRCReestablishmentComplete__criticalExtensions_PR_rrcReestablishmentComplete) failed! In handle_rrcReestablishmentComplete() ../../../openair2/RRC/NR/rrc_gNB.c:1364 Closes: #854 --- openair2/RRC/NR/rrc_gNB.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index a4b4a427d7..3dd43b99ce 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1364,8 +1364,11 @@ static int handle_rrcReestablishmentComplete(const protocol_ctxt_t *const ctxt_p DevAssert(ue_context_p != NULL); gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - DevAssert(reestablishment_complete->criticalExtensions.present - == NR_RRCReestablishmentComplete__criticalExtensions_PR_rrcReestablishmentComplete); + NR_RRCReestablishmentComplete__criticalExtensions_PR p = reestablishment_complete->criticalExtensions.present; + if (p != NR_RRCReestablishmentComplete__criticalExtensions_PR_rrcReestablishmentComplete) { + LOG_E(NR_RRC, "UE %d: expected presence of rrcReestablishmentComplete, but message has %d\n", UE->rrc_ue_id, p); + return -1; + } rrc_gNB_process_RRCReestablishmentComplete(ctxt_pP, ue_context_p, reestablishment_complete->rrc_TransactionIdentifier); UE->ue_reestablishment_counter++; From e815972492ec4216565e2ea889eecf7c711b0b68 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 18:22:18 +0200 Subject: [PATCH 26/58] Handle unsolicited UE Capability Information gracefully A UE might send a UE Capability Information without unsolicitatedly (intentionally or not). Check this and handle appropriately to avoid assertion Assertion (UE->xids[xid] == RRC_UECAPABILITY_ENQUIRY) failed! In handle_ueCapabilityInformation() ../../../openair2/RRC/NR/rrc_gNB.c Closes: #858 --- openair2/RRC/NR/rrc_gNB.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 3dd43b99ce..cce409d302 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1399,8 +1399,12 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, gNB_RRC_UE_t *UE = &ue_context_p->ue_context; int xid = ue_cap_info->rrc_TransactionIdentifier; - DevAssert(UE->xids[xid] == RRC_UECAPABILITY_ENQUIRY); + rrc_action_t a = UE->xids[xid]; UE->xids[xid] = RRC_ACTION_NONE; + if (a != RRC_UECAPABILITY_ENQUIRY) { + LOG_E(NR_RRC, "UE %d: received unsolicited UE Capability Information, aborting procedure\n", UE->rrc_ue_id); + return -1; + } LOG_I(NR_RRC, "UE %d: received UE capabilities (xid %d)\n", UE->rrc_ue_id, xid); int eutra_index = -1; From 30054b809e9b77d616d6a19e051334443ba2b0eb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 18:46:37 +0200 Subject: [PATCH 27/58] Handle faulty MeasurementReport gracefully A UE might send a MeasurementReport without the actual IEs present (intentionally or not). Check this and handle appropriately to avoid assertion Assertion (measurementReport->criticalExtensions.present == NR_MeasurementReport__criticalExtensions_PR_measurementReport && measurementReport->criticalExtensions.choice.measurementReport != ((void*)0)) failed! In rrc_gNB_process_MeasurementReport() ../../../openair2/RRC/NR/rrc_gNB.c Closes: #859 --- openair2/RRC/NR/rrc_gNB.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index cce409d302..580977ef90 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1302,17 +1302,20 @@ static void process_Event_Based_Measurement_Report(NR_ReportConfigNR_t *report, static void rrc_gNB_process_MeasurementReport(rrc_gNB_ue_context_t *ue_context, NR_MeasurementReport_t *measurementReport) { - LOG_D(NR_RRC, "Process Measurement Report\n"); + gNB_RRC_UE_t *UE = &ue_context->ue_context; + NR_MeasurementReport__criticalExtensions_PR p = measurementReport->criticalExtensions.present; + if (p != NR_MeasurementReport__criticalExtensions_PR_measurementReport + || measurementReport->criticalExtensions.choice.measurementReport == NULL) { + LOG_E(NR_RRC, "UE %d: expected presence of MeasurementReport, but has %d (%p)\n", UE->rrc_ue_id, p, measurementReport->criticalExtensions.choice.measurementReport); + return; + } + if (LOG_DEBUGFLAG(DEBUG_ASN1)) xer_fprint(stdout, &asn_DEF_NR_MeasurementReport, (void *)measurementReport); - DevAssert(measurementReport->criticalExtensions.present == NR_MeasurementReport__criticalExtensions_PR_measurementReport - && measurementReport->criticalExtensions.choice.measurementReport != NULL); - - gNB_RRC_UE_t *ue_ctxt = &ue_context->ue_context; - NR_MeasConfig_t *meas_config = ue_ctxt->measConfig; + NR_MeasConfig_t *meas_config = UE->measConfig; if (meas_config == NULL) { - LOG_I(NR_RRC, "Unexpected Measurement Report from UE with id: %d\n", ue_ctxt->rrc_ue_id); + LOG_I(NR_RRC, "Unexpected Measurement Report from UE with id: %d\n", UE->rrc_ue_id); return; } From d5274af0ec12c182072c22d3e6d0f320c0c11880 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 15:12:27 +0200 Subject: [PATCH 28/58] Bugfix: correctly check for GTP initialization The existing check for the initialization of GTP is wrong; GTP returns -1 if it could not initialize. Correct this, such that the DU will stop if GTP cannot be initialize. If we continue, the DU is requested to set up a GTP tunnel; because GTP is not initialized, it assumes it is in monolithic/no F1, and does not set up a tunnel. The F1 UE Context setup response encoder then fails with this assertion: Assertion (tnl->teid > 0) failed! In DU_send_UE_CONTEXT_SETUP_RESPONSE() ../../../openair2/F1AP/f1ap_du_ue_context_management.c:415 Exiting execution ../../../openair2/F1AP/f1ap_du_ue_context_management.c:415 DU_send_UE_CONTEXT_SETUP_RESPONSE() Exiting OAI softmodem: _Assert_Exit_ Aborted Closes: #853 --- openair2/F1AP/f1ap_du_task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 6c4f8c3be6..d221d3b35c 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -142,7 +142,7 @@ void *F1AP_DU_task(void *arg) { createF1inst(myInstance, msgSetup, nc); du_task_send_sctp_association_req(myInstance, nc); instance_t gtpInst = du_create_gtpu_instance_to_cu(nc); - AssertFatal(gtpInst != 0, "cannot create DU F1-U GTP module\n"); + AssertFatal(gtpInst > 0, "cannot create DU F1-U GTP module\n"); getCxt(myInstance)->gtpInst = gtpInst; DUuniqInstance = gtpInst; } break; From 0056ac7bc9d64e1c7843e929789feb6d10a7b99d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 18:54:05 +0200 Subject: [PATCH 29/58] Cleanup: Pass UE context into rrc_gNB_process_MeasurementReport() --- openair2/RRC/NR/rrc_gNB.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 580977ef90..e8b3e43b4f 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1207,10 +1207,8 @@ fallback_rrc_setup: return; } -static void process_Periodical_Measurement_Report(rrc_gNB_ue_context_t *ue_context, NR_MeasurementReport_t *measurementReport) +static void process_Periodical_Measurement_Report(gNB_RRC_UE_t *ue_ctxt, NR_MeasurementReport_t *measurementReport) { - // LOG_I(NR_RRC, "Periodical Event Report! Do Nothing for now...\n"); - gNB_RRC_UE_t *ue_ctxt = &ue_context->ue_context; ASN_STRUCT_FREE(asn_DEF_NR_MeasResults, ue_ctxt->measResults); ue_ctxt->measResults = NULL; @@ -1300,9 +1298,8 @@ static void process_Event_Based_Measurement_Report(NR_ReportConfigNR_t *report, } } -static void rrc_gNB_process_MeasurementReport(rrc_gNB_ue_context_t *ue_context, NR_MeasurementReport_t *measurementReport) +static void rrc_gNB_process_MeasurementReport(gNB_RRC_UE_t *UE, NR_MeasurementReport_t *measurementReport) { - gNB_RRC_UE_t *UE = &ue_context->ue_context; NR_MeasurementReport__criticalExtensions_PR p = measurementReport->criticalExtensions.present; if (p != NR_MeasurementReport__criticalExtensions_PR_measurementReport || measurementReport->criticalExtensions.choice.measurementReport == NULL) { @@ -1350,7 +1347,7 @@ static void rrc_gNB_process_MeasurementReport(rrc_gNB_ue_context_t *ue_context, } if (report_config->choice.reportConfigNR->reportType.present == NR_ReportConfigNR__reportType_PR_periodical) - return process_Periodical_Measurement_Report(ue_context, measurementReport); + return process_Periodical_Measurement_Report(UE, measurementReport); if (report_config->choice.reportConfigNR->reportType.present != NR_ReportConfigNR__reportType_PR_eventTriggered) { LOG_D(NR_RRC, "Incoming Report Type: %d is not supported! \n", report_config->choice.reportConfigNR->reportType.present); @@ -1655,6 +1652,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, LOG_E(RRC, "could not find UE context for CU UE ID %lu, aborting transaction\n", ctxt_pP->rntiMaybeUEid); return -1; } + gNB_RRC_UE_t *UE = &ue_context_p->ue_context; if ((Srb_id != 1) && (Srb_id != 2)) { LOG_E(NR_RRC, "Received message on SRB%ld, should not have ...\n", Srb_id); @@ -1662,15 +1660,6 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, LOG_D(NR_RRC, "Received message on SRB%ld\n", Srb_id); } - LOG_D(NR_RRC, "Decoding UL-DCCH Message\n"); - { - for (int i = 0; i < sdu_sizeP; i++) { - LOG_T(NR_RRC, "%x.", Rx_sdu[i]); - } - - LOG_T(NR_RRC, "\n"); - } - NR_UL_DCCH_Message_t *ul_dcch_msg = NULL; asn_dec_rval_t dec_rval = uper_decode(NULL, &asn_DEF_NR_UL_DCCH_Message, (void **)&ul_dcch_msg, Rx_sdu, sdu_sizeP, 0, 0); @@ -1699,11 +1688,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_measurementReport: - DevAssert(ul_dcch_msg != NULL - && ul_dcch_msg->message.present == NR_UL_DCCH_MessageType_PR_c1 - && ul_dcch_msg->message.choice.c1 - && ul_dcch_msg->message.choice.c1->present == NR_UL_DCCH_MessageType__c1_PR_measurementReport); - rrc_gNB_process_MeasurementReport(ue_context_p, ul_dcch_msg->message.choice.c1->choice.measurementReport); + rrc_gNB_process_MeasurementReport(UE, ul_dcch_msg->message.choice.c1->choice.measurementReport); break; case NR_UL_DCCH_MessageType__c1_PR_ulInformationTransfer: From 7836fe5090e37b5d0ea9f83f23656dd23ebb2c46 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 19:00:51 +0200 Subject: [PATCH 30/58] Cleanup: Pass UE context into handle_rrcSetupComplete() Pass UE context, without protocol_ctxt_t, for cleanup. Remove the return from within the switch, as this would lead to memory leaks; nothing is executed after the switch statement (except for freeing memory). --- openair2/RRC/NR/rrc_gNB.c | 42 +++++++++++++--------------------- openair2/RRC/NR/rrc_gNB_NGAP.c | 23 +++++++------------ openair2/RRC/NR/rrc_gNB_NGAP.h | 7 +----- 3 files changed, 25 insertions(+), 47 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index e8b3e43b4f..79668b123d 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -471,15 +471,14 @@ static void rrc_gNB_generate_RRCReject(module_id_t module_id, rrc_gNB_ue_context /* * Process the rrc setup complete message from UE (SRB1 Active) */ -static void rrc_gNB_process_RRCSetupComplete(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP, NR_RRCSetupComplete_IEs_t *rrcSetupComplete) +static void rrc_gNB_process_RRCSetupComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRCSetupComplete_IEs_t *rrcSetupComplete) //----------------------------------------------------------------------------- { - LOG_A(NR_RRC, "UE %d Processing NR_RRCSetupComplete from UE\n", ue_context_pP->ue_context.rrc_ue_id); - ue_context_pP->ue_context.Srb[1].Active = 1; - ue_context_pP->ue_context.Srb[2].Active = 0; - AssertFatal(ctxt_pP->rntiMaybeUEid == ue_context_pP->ue_context.rrc_ue_id, "logic bug: inconsistent IDs, must use CU UE ID!\n"); + LOG_A(NR_RRC, "UE %d Processing NR_RRCSetupComplete from UE\n", UE->rrc_ue_id); + UE->Srb[1].Active = 1; + UE->Srb[2].Active = 0; - rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); + rrc_gNB_send_NGAP_NAS_FIRST_REQ(rrc, UE, rrcSetupComplete); } //----------------------------------------------------------------------------- @@ -1514,21 +1513,14 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, return 0; } -static int handle_rrcSetupComplete(const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_p, - const NR_RRCSetupComplete_t *setup_complete) +static void handle_rrcSetupComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_RRCSetupComplete_t *setup_complete) { - if (!ue_context_p) { - LOG_I(NR_RRC, "Processing NR_RRCSetupComplete UE %lx, ue_context_p is NULL\n", ctxt_pP->rntiMaybeUEid); - return -1; - } - gNB_RRC_UE_t *UE = &ue_context_p->ue_context; uint8_t xid = setup_complete->rrc_TransactionIdentifier; UE->xids[xid] = RRC_ACTION_NONE; if (setup_complete->criticalExtensions.present != NR_RRCSetupComplete__criticalExtensions_PR_rrcSetupComplete) { - LOG_E(NR_RRC, "malformed RRCSetupComplete received from UE %lx\n", ctxt_pP->rntiMaybeUEid); - return -1; + LOG_E(NR_RRC, "malformed RRCSetupComplete received from UE %d\n", UE->rrc_ue_id); + return; } NR_RRCSetupComplete_IEs_t *setup_complete_ies = setup_complete->criticalExtensions.choice.rrcSetupComplete; @@ -1539,7 +1531,7 @@ static int handle_rrcSetupComplete(const protocol_ctxt_t *const ctxt_pP, const BIT_STRING_t *part2 = &setup_complete_ies->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2; if (part2->size != 2) { LOG_E(NR_RRC, "wrong ng_5G_S_TMSI_Part2 size, expected 2, provided %lu", part2->size); - return -1; + return; } if (UE->Initialue_identity_5g_s_TMSI.presence) { @@ -1555,7 +1547,7 @@ static int handle_rrcSetupComplete(const protocol_ctxt_t *const ctxt_pP, const NR_NG_5G_S_TMSI_t *bs_stmsi = &setup_complete_ies->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI; if (bs_stmsi->size != 6) { LOG_E(NR_RRC, "wrong ng_5G_S_TMSI size, expected 6, provided %lu", bs_stmsi->size); - return -1; + return; } fiveg_s_TMSI = BIT_STRING_to_uint64(bs_stmsi); @@ -1583,9 +1575,8 @@ static int handle_rrcSetupComplete(const protocol_ctxt_t *const ctxt_pP, } } - rrc_gNB_process_RRCSetupComplete(ctxt_pP, ue_context_p, setup_complete->criticalExtensions.choice.rrcSetupComplete); - LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " UE State = NR_RRC_CONNECTED \n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); - return 0; + rrc_gNB_process_RRCSetupComplete(rrc, UE, setup_complete->criticalExtensions.choice.rrcSetupComplete); + return; } static void handle_rrcReconfigurationComplete(const protocol_ctxt_t *const ctxt_pP, @@ -1644,10 +1635,10 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, const sdu_size_t sdu_sizeP) //----------------------------------------------------------------------------- { - gNB_RRC_INST *gnb_rrc_inst = RC.nrrrc[ctxt_pP->module_id]; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; /* we look up by CU UE ID! Do NOT change back to RNTI! */ - rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rntiMaybeUEid); + rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, ctxt_pP->rntiMaybeUEid); if (!ue_context_p) { LOG_E(RRC, "could not find UE context for CU UE ID %lu, aborting transaction\n", ctxt_pP->rntiMaybeUEid); return -1; @@ -1683,8 +1674,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_rrcSetupComplete: - if (handle_rrcSetupComplete(ctxt_pP, ue_context_p, ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete) == -1) - return -1; + handle_rrcSetupComplete(rrc, UE, ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete); break; case NR_UL_DCCH_MessageType__c1_PR_measurementReport: @@ -1741,7 +1731,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, * to set up security, so trigger PDU sessions now. The UE NAS * message will be forwarded in the corresponding reconfiguration, * the Initial context setup response after reconfiguration complete. */ - trigger_bearer_setup(gnb_rrc_inst, UE, UE->n_initial_pdu, UE->initial_pdus, 0); + trigger_bearer_setup(rrc, UE, UE->n_initial_pdu, UE->initial_pdus, 0); } else { /* we already have capabilities, and no PDU sessions to setup, ack * this UE */ diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 66f0f4fc69..6a6644c0a0 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -147,26 +147,20 @@ void nr_rrc_pdcp_config_security(gNB_RRC_UE_t *UE, bool enable_ciphering) /* * Initial UE NAS message on S1AP. */ -void -rrc_gNB_send_NGAP_NAS_FIRST_REQ( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP, - NR_RRCSetupComplete_IEs_t *rrcSetupComplete -) +void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRCSetupComplete_IEs_t *rrcSetupComplete) //------------------------------------------------------------------------------ { - // gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; - MessageDef *message_p = NULL; - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; - - message_p = itti_alloc_new_message(TASK_RRC_GNB, 0, NGAP_NAS_FIRST_REQ); + MessageDef *message_p = itti_alloc_new_message(TASK_RRC_GNB, rrc->module_id, NGAP_NAS_FIRST_REQ); ngap_nas_first_req_t *req = &NGAP_NAS_FIRST_REQ(message_p); memset(req, 0, sizeof(*req)); req->gNB_ue_ngap_id = UE->rrc_ue_id; /* Assume that cause is coded in the same way in RRC and NGap, just check that the value is in NGap range */ - AssertFatal(UE->establishment_cause < NGAP_RRC_CAUSE_LAST, "Establishment cause invalid (%jd/%d) for gNB %d!", UE->establishment_cause, NGAP_RRC_CAUSE_LAST, ctxt_pP->module_id); + AssertFatal(UE->establishment_cause < NGAP_RRC_CAUSE_LAST, + "Establishment cause invalid (%jd/%d)!", + UE->establishment_cause, + NGAP_RRC_CAUSE_LAST); req->establishment_cause = UE->establishment_cause; /* Forward NAS message */ @@ -207,8 +201,7 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ( UE->ue_guami.amf_pointer = req->ue_identity.guami.amf_pointer; LOG_I(NGAP, - "[gNB %d] Build NGAP_NAS_FIRST_REQ adding in s_TMSI: GUAMI amf_set_id %u amf_region_id %u ue %x\n", - ctxt_pP->module_id, + "Build NGAP_NAS_FIRST_REQ adding in s_TMSI: GUAMI amf_set_id %u amf_region_id %u ue %x\n", req->ue_identity.guami.amf_set_id, req->ue_identity.guami.amf_region_id, UE->rnti); @@ -216,7 +209,7 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ( req->ue_identity.presenceMask = NGAP_UE_IDENTITIES_NONE; } - itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, message_p); + itti_send_msg_to_task(TASK_NGAP, rrc->module_id, message_p); } static void fill_qos(NGAP_QosFlowSetupRequestList_t *qos, pdusession_t *session) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h index ee091b4269..85745b5adf 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.h +++ b/openair2/RRC/NR/rrc_gNB_NGAP.h @@ -40,12 +40,7 @@ #include "NR_UL-DCCH-Message.h" #include "NGAP_CauseRadioNetwork.h" -void -rrc_gNB_send_NGAP_NAS_FIRST_REQ( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP, - NR_RRCSetupComplete_IEs_t *rrcSetupComplete -); +void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRCSetupComplete_IEs_t *rrcSetupComplete); int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t instance); From 098f45c14d932fbc97f27d57fee37290a7a53fab Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 19:09:45 +0200 Subject: [PATCH 31/58] Cleanup: Pass RRC/UE context directly into handle_rrcReconfigurationComplete() --- openair2/RRC/NR/rrc_gNB.c | 27 ++++++-------- openair2/RRC/NR/rrc_gNB_NGAP.c | 65 ++++++++++------------------------ openair2/RRC/NR/rrc_gNB_NGAP.h | 27 +++----------- 3 files changed, 33 insertions(+), 86 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 79668b123d..34f251b34d 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1498,16 +1498,16 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(ctxt_pP, ue_context_p, ue_cap_info); + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; if (UE->n_initial_pdu > 0) { /* there were PDU sessions with the NG UE Context setup, but we had to set * up security and request capabilities, so trigger PDU sessions now. The * UE NAS message will be forwarded in the corresponding reconfiguration, * the Initial context setup response after reconfiguration complete. */ - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; trigger_bearer_setup(rrc, UE, UE->n_initial_pdu, UE->initial_pdus, 0); } else { - rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, ue_context_p); - rrc_forward_ue_nas_message(RC.nrrrc[ctxt_pP->instance], UE); + rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(rrc, UE); + rrc_forward_ue_nas_message(rrc, UE); } return 0; @@ -1579,13 +1579,8 @@ static void handle_rrcSetupComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const N return; } -static void handle_rrcReconfigurationComplete(const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_p, - const NR_RRCReconfigurationComplete_t *reconfig_complete) +static void handle_rrcReconfigurationComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_RRCReconfigurationComplete_t *reconfig_complete) { - AssertFatal(ue_context_p != NULL, "Processing %s() for UE %lx, ue_context_p is NULL\n", __func__, ctxt_pP->rntiMaybeUEid); - gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - uint8_t xid = reconfig_complete->rrc_TransactionIdentifier; UE->ue_reconfiguration_counter++; LOG_I(NR_RRC, "UE %d: Receive RRC Reconfiguration Complete message (xid %d)\n", UE->rrc_ue_id, xid); @@ -1593,22 +1588,22 @@ static void handle_rrcReconfigurationComplete(const protocol_ctxt_t *const ctxt_ switch (UE->xids[xid]) { case RRC_PDUSESSION_RELEASE: { gtpv1u_gnb_delete_tunnel_req_t req = {0}; - gtpv1u_delete_ngu_tunnel(ctxt_pP->instance, &req); + gtpv1u_delete_ngu_tunnel(rrc->module_id, &req); // NGAP_PDUSESSION_RELEASE_RESPONSE - rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(ctxt_pP, ue_context_p, xid); + rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(rrc, UE, xid); } break; case RRC_PDUSESSION_ESTABLISH: if (UE->n_initial_pdu > 0) { /* PDU sessions through initial UE context setup */ - rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, ue_context_p); + rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(rrc, UE); UE->n_initial_pdu = 0; free(UE->initial_pdus); UE->initial_pdus = NULL; } else if (UE->nb_of_pdusessions > 0) - rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(ctxt_pP, ue_context_p, xid); + rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(rrc, UE, xid); break; case RRC_PDUSESSION_MODIFY: - rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP(ctxt_pP, ue_context_p, xid); + rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP(rrc, UE, xid); break; case RRC_REESTABLISH_COMPLETE: case RRC_DEDICATED_RECONF: @@ -1670,7 +1665,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_rrcReconfigurationComplete: - handle_rrcReconfigurationComplete(ctxt_pP, ue_context_p, ul_dcch_msg->message.choice.c1->choice.rrcReconfigurationComplete); + handle_rrcReconfigurationComplete(rrc, UE, ul_dcch_msg->message.choice.c1->choice.rrcReconfigurationComplete); break; case NR_UL_DCCH_MessageType__c1_PR_rrcSetupComplete: @@ -1735,7 +1730,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, } else { /* we already have capabilities, and no PDU sessions to setup, ack * this UE */ - rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, ue_context_p); + rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(rrc, UE); rrc_forward_ue_nas_message(RC.nrrrc[0], &ue_context_p->ue_context); } break; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 6a6644c0a0..6786d01d99 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -157,10 +157,7 @@ void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRC req->gNB_ue_ngap_id = UE->rrc_ue_id; /* Assume that cause is coded in the same way in RRC and NGap, just check that the value is in NGap range */ - AssertFatal(UE->establishment_cause < NGAP_RRC_CAUSE_LAST, - "Establishment cause invalid (%jd/%d)!", - UE->establishment_cause, - NGAP_RRC_CAUSE_LAST); + AssertFatal(UE->establishment_cause < NGAP_RRC_CAUSE_LAST, "Establishment cause invalid (%jd/%d)!", UE->establishment_cause, NGAP_RRC_CAUSE_LAST); req->establishment_cause = UE->establishment_cause; /* Forward NAS message */ @@ -484,7 +481,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t } else { /* no PDU sesion to setup: acknowledge this message, and forward NAS * message, if required */ - rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(&ctxt, ue_context_p); + rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(rrc, UE); rrc_forward_ue_nas_message(rrc, UE); } } @@ -496,16 +493,13 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t return 0; } -//------------------------------------------------------------------------------ -void rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *const ue_context_pP) -//------------------------------------------------------------------------------ +void rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE) { MessageDef *msg_p = NULL; int pdu_sessions_done = 0; int pdu_sessions_failed = 0; - msg_p = itti_alloc_new_message (TASK_RRC_ENB, 0, NGAP_INITIAL_CONTEXT_SETUP_RESP); + msg_p = itti_alloc_new_message (TASK_RRC_ENB, rrc->module_id, NGAP_INITIAL_CONTEXT_SETUP_RESP); ngap_initial_context_setup_resp_t *resp = &NGAP_INITIAL_CONTEXT_SETUP_RESP(msg_p); - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; resp->gNB_ue_ngap_id = UE->rrc_ue_id; @@ -536,7 +530,7 @@ void rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(const protocol_ctxt_t *const c resp->nb_of_pdusessions = pdu_sessions_done; resp->nb_of_pdusessions_failed = pdu_sessions_failed; - itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p); + itti_send_msg_to_task (TASK_NGAP, rrc->module_id, msg_p); } static NR_CipheringAlgorithm_t rrc_gNB_select_ciphering(const gNB_RRC_INST *rrc, uint16_t algorithms) @@ -688,22 +682,14 @@ rrc_gNB_send_NGAP_UPLINK_NAS( } } -//------------------------------------------------------------------------------ -void -rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t xid -) -//------------------------------------------------------------------------------ +void rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid) { MessageDef *msg_p; int pdu_sessions_done = 0; int pdu_sessions_failed = 0; - msg_p = itti_alloc_new_message (TASK_RRC_GNB, 0, NGAP_PDUSESSION_SETUP_RESP); + msg_p = itti_alloc_new_message (TASK_RRC_GNB, rrc->module_id, NGAP_PDUSESSION_SETUP_RESP); ngap_pdusession_setup_resp_t *resp = &NGAP_PDUSESSION_SETUP_RESP(msg_p); - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; resp->gNB_ue_ngap_id = UE->rrc_ue_id; for (int pdusession = 0; pdusession < UE->nb_of_pdusessions; pdusession++) { @@ -750,7 +736,7 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( if ((pdu_sessions_done > 0 || pdu_sessions_failed)) { LOG_I(NR_RRC, "NGAP_PDUSESSION_SETUP_RESP: sending the message\n"); - itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p); + itti_send_msg_to_task(TASK_NGAP, rrc->module_id, msg_p); } for(int i = 0; i < NB_RB_MAX; i++) { @@ -976,21 +962,13 @@ int rrc_gNB_process_NGAP_PDUSESSION_MODIFY_REQ(MessageDef *msg_p, instance_t ins return (0); } -//------------------------------------------------------------------------------ -int -rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t xid -) -//------------------------------------------------------------------------------ +int rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid) { MessageDef *msg_p = NULL; uint8_t pdu_sessions_failed = 0; uint8_t pdu_sessions_done = 0; - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; - msg_p = itti_alloc_new_message (TASK_RRC_GNB, 0, NGAP_PDUSESSION_MODIFY_RESP); + msg_p = itti_alloc_new_message (TASK_RRC_GNB, rrc->module_id, NGAP_PDUSESSION_MODIFY_RESP); if (msg_p == NULL) { LOG_E(NR_RRC, "itti_alloc_new_message failed, msg_p is NULL \n"); return (-1); @@ -1057,7 +1035,7 @@ rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP( if (pdu_sessions_done > 0 || pdu_sessions_failed > 0) { LOG_D(NR_RRC, "NGAP_PDUSESSION_MODIFY_RESP: sending the message (total pdu session %d)\n", UE->nb_of_pdusessions); - itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p); + itti_send_msg_to_task (TASK_NGAP, rrc->module_id, msg_p); } else { itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); } @@ -1227,19 +1205,11 @@ void rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(const protocol_ctxt_t *const ctxt_pP, LOG_I(NR_RRC,"Send message to ngap: NGAP_UE_CAPABILITIES_IND\n"); } -//------------------------------------------------------------------------------ -void -rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t xid -) -//------------------------------------------------------------------------------ +void rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid) { int pdu_sessions_released = 0; MessageDef *msg_p; - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; - msg_p = itti_alloc_new_message (TASK_RRC_GNB, 0, NGAP_PDUSESSION_RELEASE_RESPONSE); + msg_p = itti_alloc_new_message (TASK_RRC_GNB, rrc->module_id, NGAP_PDUSESSION_RELEASE_RESPONSE); ngap_pdusession_release_resp_t *resp = &NGAP_PDUSESSION_RELEASE_RESPONSE(msg_p); memset(resp, 0, sizeof(*resp)); resp->gNB_ue_ngap_id = UE->rrc_ue_id; @@ -1258,7 +1228,7 @@ rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE( resp->nb_of_pdusessions_released = pdu_sessions_released; resp->nb_of_pdusessions_failed = 0; LOG_I(NR_RRC, "NGAP PDUSESSION RELEASE RESPONSE: rrc_ue_id %u release_pdu_sessions %d\n", resp->gNB_ue_ngap_id, pdu_sessions_released); - itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p); + itti_send_msg_to_task (TASK_NGAP, rrc->module_id, msg_p); } //------------------------------------------------------------------------------ @@ -1273,7 +1243,8 @@ int rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(MessageDef *msg_p, instance_ LOG_E(NR_RRC, "incorrect number of pdu session do release %d\n", cmd->nb_pdusessions_torelease); return -1; } - rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], gNB_ue_ngap_id); + gNB_RRC_INST *rrc = RC.nrrrc[instance]; + rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, gNB_ue_ngap_id); if (!ue_context_p) { LOG_E(NR_RRC, "[gNB %ld] not found ue context gNB_ue_ngap_id %u \n", instance, gNB_ue_ngap_id); @@ -1320,9 +1291,9 @@ int rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(MessageDef *msg_p, instance_ LOG_I(NR_RRC, "gtp tunnel delete all tunnels for UE %04x\n", UE->rnti); gtpv1u_gnb_delete_tunnel_req_t req = {0}; req.ue_id = UE->rnti; - gtpv1u_delete_ngu_tunnel(instance, &req); + gtpv1u_delete_ngu_tunnel(rrc->module_id, &req); // NGAP_PDUSESSION_RELEASE_RESPONSE - rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(&ctxt, ue_context_p, xid); + rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(rrc, UE, xid); LOG_I(NR_RRC, "Send PDU Session Release Response \n"); } return 0; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h index 85745b5adf..d981c7a6a6 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.h +++ b/openair2/RRC/NR/rrc_gNB_NGAP.h @@ -44,11 +44,7 @@ void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRC int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t instance); -void -rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP -); +void rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE); int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mui_t *rrc_gNB_mui); @@ -59,23 +55,13 @@ rrc_gNB_send_NGAP_UPLINK_NAS( NR_UL_DCCH_Message_t *const ul_dcch_msg ); -void -rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t xid -); +void rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid); void rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(MessageDef *msg_p, instance_t instance); int rrc_gNB_process_NGAP_PDUSESSION_MODIFY_REQ(MessageDef *msg_p, instance_t instance); -int -rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t xid -); +int rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid); void rrc_gNB_modify_dedicatedRRCReconfiguration( @@ -100,12 +86,7 @@ void rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(const protocol_ctxt_t *const ctxt_pP, int rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(MessageDef *msg_p, instance_t instance); -void -rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t xid -); +void rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid); void nr_rrc_pdcp_config_security(gNB_RRC_UE_t *UE, bool enable_ciphering); From cec54f1c893c87e5c17a04bc60e7cd9aa4eb7fec Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 19:12:13 +0200 Subject: [PATCH 32/58] Cleanup: Pass UE context directly into rrc_gNB_send_NGAP_UPLINK_NAS() --- openair2/RRC/NR/rrc_gNB.c | 10 +--------- openair2/RRC/NR/rrc_gNB_NGAP.c | 17 +++-------------- openair2/RRC/NR/rrc_gNB_NGAP.h | 7 +------ 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 34f251b34d..b5f97d366e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1677,16 +1677,8 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_ulInformationTransfer: - LOG_D(NR_RRC, "Recived RRC GNB UL Information Transfer \n"); - if (!ue_context_p) { - LOG_W(NR_RRC, "Processing ulInformationTransfer UE %lx, ue_context_p is NULL\n", ctxt_pP->rntiMaybeUEid); - break; - } - - LOG_D(NR_RRC, "[MSG] RRC UL Information Transfer \n"); LOG_DUMPMSG(RRC, DEBUG_RRC, (char *)Rx_sdu, sdu_sizeP, "[MSG] RRC UL Information Transfer \n"); - - rrc_gNB_send_NGAP_UPLINK_NAS(ctxt_pP, ue_context_p, ul_dcch_msg); + rrc_gNB_send_NGAP_UPLINK_NAS(rrc, UE, ul_dcch_msg); break; case NR_UL_DCCH_MessageType__c1_PR_securityModeComplete: diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 6786d01d99..39f38a4054 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -652,32 +652,21 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu return 0; } -//------------------------------------------------------------------------------ -void -rrc_gNB_send_NGAP_UPLINK_NAS( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - NR_UL_DCCH_Message_t *const ul_dcch_msg -) -//------------------------------------------------------------------------------ +void rrc_gNB_send_NGAP_UPLINK_NAS(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_UL_DCCH_Message_t *const ul_dcch_msg) { MessageDef *msg_p; NR_ULInformationTransfer_t *ulInformationTransfer = ul_dcch_msg->message.choice.c1->choice.ulInformationTransfer; - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; if (ulInformationTransfer->criticalExtensions.present == NR_ULInformationTransfer__criticalExtensions_PR_ulInformationTransfer) { NR_DedicatedNAS_Message_t *nas = ulInformationTransfer->criticalExtensions.choice.ulInformationTransfer->dedicatedNAS_Message; uint8_t *buf = malloc(nas->size); AssertFatal(buf != NULL, "out of memory\n"); memcpy(buf, nas->buf, nas->size); - msg_p = itti_alloc_new_message (TASK_RRC_GNB, 0, NGAP_UPLINK_NAS); + msg_p = itti_alloc_new_message (TASK_RRC_GNB, rrc->module_id, NGAP_UPLINK_NAS); NGAP_UPLINK_NAS(msg_p).gNB_ue_ngap_id = UE->rrc_ue_id; NGAP_UPLINK_NAS (msg_p).nas_pdu.length = nas->size; NGAP_UPLINK_NAS (msg_p).nas_pdu.buffer = buf; - // extract_imsi(NGAP_UPLINK_NAS (msg_p).nas_pdu.buffer, - // NGAP_UPLINK_NAS (msg_p).nas_pdu.length, - // ue_context_pP); - itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p); + itti_send_msg_to_task(TASK_NGAP, rrc->module_id, msg_p); LOG_D(NR_RRC,"Send RRC GNB UL Information Transfer \n"); } } diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h index d981c7a6a6..8a0834faba 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.h +++ b/openair2/RRC/NR/rrc_gNB_NGAP.h @@ -48,12 +48,7 @@ void rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mui_t *rrc_gNB_mui); -void -rrc_gNB_send_NGAP_UPLINK_NAS( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - NR_UL_DCCH_Message_t *const ul_dcch_msg -); +void rrc_gNB_send_NGAP_UPLINK_NAS(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_UL_DCCH_Message_t *const ul_dcch_msg); void rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid); From a5a746ee369366363ec7804963499721e1697dfe Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 16 Oct 2024 08:20:50 +0200 Subject: [PATCH 33/58] Cleanup: Pass UE context directly into rrc_gNB_generate_UECapabilityEnquiry() --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 9 +-- openair2/RRC/NR/MESSAGES/asn1_msg.h | 4 +- .../RRC/NR/MESSAGES/tests/test_asn1_msg.cpp | 3 +- openair2/RRC/NR/nr_rrc_proto.h | 6 -- openair2/RRC/NR/rrc_gNB.c | 74 ++++++------------- 5 files changed, 26 insertions(+), 70 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 2a0ebd736c..8025fb2243 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -559,12 +559,7 @@ int do_NR_SecurityModeCommand(uint8_t *const buffer, return((enc_rval.encoded+7)/8); } -/*TODO*/ -//------------------------------------------------------------------------------ -int do_NR_SA_UECapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, - uint8_t *const buffer, - const uint8_t Transaction_id) -//------------------------------------------------------------------------------ +int do_NR_SA_UECapabilityEnquiry(uint8_t *const buffer, const uint8_t Transaction_id) { NR_UE_CapabilityRequestFilterNR_t *sa_band_filter; NR_FreqBandList_t *sa_band_list; @@ -624,7 +619,7 @@ int do_NR_SA_UECapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, enc_rval.failed_type->name, enc_rval.encoded); ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_DL_DCCH_Message, &dl_dcch_msg); - LOG_D(NR_RRC, "[gNB %d] NR UECapabilityRequest for UE %lx Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rntiMaybeUEid, enc_rval.encoded, (enc_rval.encoded + 7) / 8); + LOG_D(NR_RRC, "NR UECapabilityRequestEncoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded + 7) / 8); return((enc_rval.encoded+7)/8); } diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 871fe08d49..8609e20328 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -86,9 +86,7 @@ int do_NR_SecurityModeCommand(uint8_t *const buffer, const uint8_t cipheringAlgorithm, NR_IntegrityProtAlgorithm_t integrityProtAlgorithm); -int do_NR_SA_UECapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, - uint8_t *const buffer, - const uint8_t Transaction_id); +int do_NR_SA_UECapabilityEnquiry(uint8_t *const buffer, const uint8_t Transaction_id); int do_NR_RRCRelease(uint8_t *buffer, size_t buffer_size, uint8_t Transaction_id); diff --git a/openair2/RRC/NR/MESSAGES/tests/test_asn1_msg.cpp b/openair2/RRC/NR/MESSAGES/tests/test_asn1_msg.cpp index 9d1ee71f9c..1b8d5ce4d8 100644 --- a/openair2/RRC/NR/MESSAGES/tests/test_asn1_msg.cpp +++ b/openair2/RRC/NR/MESSAGES/tests/test_asn1_msg.cpp @@ -37,9 +37,8 @@ TEST(nr_asn1, rrc_reject) TEST(nr_asn1, sa_capability_enquiry) { - protocol_ctxt_t ctxt = {0}; unsigned char buf[1000]; - EXPECT_GT(do_NR_SA_UECapabilityEnquiry(&ctxt, buf, 0), 0); + EXPECT_GT(do_NR_SA_UECapabilityEnquiry(buf, 0), 0); } TEST(nr_asn1, rrc_reconfiguration_complete_for_nsa) diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 31a86c3144..009164a80d 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -78,12 +78,6 @@ void rrc_forward_ue_nas_message(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE); unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP); -void -rrc_gNB_generate_UECapabilityEnquiry( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP -); - void rrc_gNB_generate_RRCRelease( const protocol_ctxt_t *const ctxt_pP, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index b5f97d366e..4d409985b2 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1623,7 +1623,22 @@ static void handle_rrcReconfigurationComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *U } } } -//----------------------------------------------------------------------------- + +static void rrc_gNB_generate_UECapabilityEnquiry(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue) +{ + uint8_t buffer[100]; + + T(T_ENB_RRC_UE_CAPABILITY_ENQUIRY, T_INT(rrc->module_id), T_INT(0), T_INT(0), T_INT(ue->rrc_ue_id)); + uint8_t xid = rrc_gNB_get_next_transaction_identifier(rrc->module_id); + ue->xids[xid] = RRC_UECAPABILITY_ENQUIRY; + int size = do_NR_SA_UECapabilityEnquiry(buffer, xid); + LOG_I(NR_RRC, "UE %d: Logical Channel DL-DCCH, Generate NR UECapabilityEnquiry (bytes %d, xid %d)\n", ue->rrc_ue_id, size, xid); + + AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n"); + + nr_rrc_transfer_protected_rrc_message(rrc, ue, DCCH, buffer, size); +} + int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, const uint8_t *const Rx_sdu, @@ -1682,38 +1697,15 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_securityModeComplete: - // to avoid segmentation fault - if (!ue_context_p) { - LOG_I(NR_RRC, "Processing securityModeComplete UE %lx, ue_context_p is NULL\n", ctxt_pP->rntiMaybeUEid); - break; - } - - LOG_I(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT " received securityModeComplete on UL-DCCH %d from UE\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH); - LOG_D(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT - " RLC RB %02d --- RLC_DATA_IND %d bytes " - "(securityModeComplete) ---> RRC_eNB\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH, - sdu_sizeP); - - if (LOG_DEBUGFLAG(DEBUG_ASN1)) { - xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); - } - /* configure ciphering */ - nr_rrc_pdcp_config_security(&ue_context_p->ue_context, true); - ue_context_p->ue_context.as_security_active = true; + nr_rrc_pdcp_config_security(UE, true); + UE->as_security_active = true; /* trigger UE capability enquiry if we don't have them yet */ - if (ue_context_p->ue_context.ue_cap_buffer.len == 0) { - rrc_gNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); + if (UE->ue_cap_buffer.len == 0) { + rrc_gNB_generate_UECapabilityEnquiry(rrc, UE); /* else blocks are executed after receiving UE capability info */ - } else if (ue_context_p->ue_context.n_initial_pdu > 0) { - gNB_RRC_UE_t *UE = &ue_context_p->ue_context; + } else if (UE->n_initial_pdu > 0) { /* there were PDU sessions with the NG UE Context setup, but we had * to set up security, so trigger PDU sessions now. The UE NAS * message will be forwarded in the corresponding reconfiguration, @@ -1723,7 +1715,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, /* we already have capabilities, and no PDU sessions to setup, ack * this UE */ rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(rrc, UE); - rrc_forward_ue_nas_message(RC.nrrrc[0], &ue_context_p->ue_context); + rrc_forward_ue_nas_message(rrc, UE); } break; @@ -2575,28 +2567,6 @@ void rrc_gNB_generate_SecurityModeCommand(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p) nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); } -void -rrc_gNB_generate_UECapabilityEnquiry( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP -) -//----------------------------------------------------------------------------- -{ - uint8_t buffer[100]; - - T(T_ENB_RRC_UE_CAPABILITY_ENQUIRY, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rntiMaybeUEid)); - gNB_RRC_UE_t *ue = &ue_context_pP->ue_context; - uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); - ue->xids[xid] = RRC_UECAPABILITY_ENQUIRY; - int size = do_NR_SA_UECapabilityEnquiry(ctxt_pP, buffer, xid); - LOG_I(NR_RRC, "UE %d: Logical Channel DL-DCCH, Generate NR UECapabilityEnquiry (bytes %d, xid %d)\n", ue->rrc_ue_id, size, xid); - - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; - AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n"); - - nr_rrc_transfer_protected_rrc_message(rrc, ue, DCCH, buffer, size); -} - typedef struct deliver_ue_ctxt_release_data_t { gNB_RRC_INST *rrc; f1ap_ue_context_release_cmd_t *release_cmd; From 88d6117d9998465c5b379c024687498bf3d78dcc Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 19:15:42 +0200 Subject: [PATCH 34/58] Cleanup in securityModeFailure handling The xer_fprintf() call is already present in rrc_gNB_decode_dcch() above. --- openair2/RRC/NR/rrc_gNB.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 4d409985b2..5a52b7dfc0 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1722,11 +1722,6 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, case NR_UL_DCCH_MessageType__c1_PR_securityModeFailure: LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)Rx_sdu, sdu_sizeP, "[MSG] NR RRC Security Mode Failure\n"); LOG_E(NR_RRC, "UE %d: received securityModeFailure\n", ue_context_p->ue_context.rrc_ue_id); - - if (LOG_DEBUGFLAG(DEBUG_ASN1)) { - xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); - } - LOG_W(NR_RRC, "Cannot continue as no AS security is activated (implementation missing)\n"); break; From 118674ae4e4a15b3f02851ee3fd9fb814fdf19a1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 16 Oct 2024 08:33:57 +0200 Subject: [PATCH 35/58] Cleanup handle_ueCapabilityInformation() Pass UE context pointer directly. In the switch, do not return to not create memory leaks (after the switch, memory is freed). Move the function up to make it appear before the use of the function. --- openair2/RRC/NR/rrc_gNB.c | 34 ++++++++++------------------------ openair2/RRC/NR/rrc_gNB_NGAP.c | 11 ++++------- openair2/RRC/NR/rrc_gNB_NGAP.h | 4 +--- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 5a52b7dfc0..9860aff642 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1390,19 +1390,14 @@ void rrc_forward_ue_nas_message(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE) UE->nas_pdu.length = 0; } -static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_p, - const NR_UECapabilityInformation_t *ue_cap_info) +static void handle_ueCapabilityInformation(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_UECapabilityInformation_t *ue_cap_info) { - AssertFatal(ue_context_p != NULL, "Processing %s() for UE %lx, ue_context_p is NULL\n", __func__, ctxt_pP->rntiMaybeUEid); - gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - int xid = ue_cap_info->rrc_TransactionIdentifier; rrc_action_t a = UE->xids[xid]; UE->xids[xid] = RRC_ACTION_NONE; if (a != RRC_UECAPABILITY_ENQUIRY) { LOG_E(NR_RRC, "UE %d: received unsolicited UE Capability Information, aborting procedure\n", UE->rrc_ue_id); - return -1; + return; } LOG_I(NR_RRC, "UE %d: received UE capabilities (xid %d)\n", UE->rrc_ue_id, xid); @@ -1420,7 +1415,7 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, (void **)&UE->ue_cap_buffer.buf); if (UE->ue_cap_buffer.len <= 0) { LOG_E(RRC, "could not encode UE-CapabilityRAT-ContainerList, abort handling capabilities\n"); - return -1; + return; } for (int i = 0; i < ue_CapabilityRAT_ContainerList->list.count; i++) { @@ -1443,10 +1438,7 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, } if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT " Failed to decode nr UE capabilities (%zu bytes)\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - dec_rval.consumed); + LOG_E(NR_RRC, "UE %d: Failed to decode nr UE capabilities (%zu bytes)\n", UE->rrc_ue_id, dec_rval.consumed); ASN_STRUCT_FREE(asn_DEF_NR_UE_NR_Capability, UE->UE_Capability_nr); UE->UE_Capability_nr = 0; } @@ -1454,7 +1446,7 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, UE->UE_Capability_size = ue_cap_container->ue_CapabilityRAT_Container.size; if (eutra_index != -1) { LOG_E(NR_RRC, "fatal: more than 1 eutra capability\n"); - exit(1); + return; } eutra_index = i; } @@ -1477,10 +1469,7 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, } if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(NR_RRC, - PROTOCOL_NR_RRC_CTXT_FMT " Failed to decode nr UE capabilities (%zu bytes)\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - dec_rval.consumed); + LOG_E(NR_RRC, "UE %d: Failed to decode nr UE capabilities (%zu bytes)\n", UE->rrc_ue_id, dec_rval.consumed); ASN_STRUCT_FREE(asn_DEF_NR_UE_MRDC_Capability, UE->UE_Capability_MRDC); UE->UE_Capability_MRDC = 0; } @@ -1493,12 +1482,11 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, } if (eutra_index == -1) - return -1; + return; } - rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(ctxt_pP, ue_context_p, ue_cap_info); + rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(rrc, UE, ue_cap_info); - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; if (UE->n_initial_pdu > 0) { /* there were PDU sessions with the NG UE Context setup, but we had to set * up security and request capabilities, so trigger PDU sessions now. The @@ -1510,7 +1498,7 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP, rrc_forward_ue_nas_message(rrc, UE); } - return 0; + return; } static void handle_rrcSetupComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_RRCSetupComplete_t *setup_complete) @@ -1726,9 +1714,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: - if (handle_ueCapabilityInformation(ctxt_pP, ue_context_p, ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation) - == -1) - return -1; + handle_ueCapabilityInformation(rrc, UE, ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation); break; case NR_UL_DCCH_MessageType__c1_PR_rrcReestablishmentComplete: diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 39f38a4054..53a08e5cb7 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -1151,19 +1151,16 @@ void rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, itti_send_msg_to_task(TASK_NGAP, instance, msg); } -void rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - const NR_UECapabilityInformation_t *const ue_cap_info) +void rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_UECapabilityInformation_t *const ue_cap_info) //------------------------------------------------------------------------------ { NR_UE_CapabilityRAT_ContainerList_t *ueCapabilityRATContainerList = ue_cap_info->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList; void *buf; NR_UERadioAccessCapabilityInformation_t rac = {0}; - gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; if (ueCapabilityRATContainerList->list.count == 0) { - LOG_W(RRC, "[gNB %d][UE %x] bad UE capabilities\n", ctxt_pP->module_id, UE->rnti); + LOG_W(RRC, "[UE %d] bad UE capabilities\n", UE->rrc_ue_id); } int ret = uper_encode_to_new_buffer(&asn_DEF_NR_UE_CapabilityRAT_ContainerList, NULL, ueCapabilityRATContainerList, &buf); @@ -1184,13 +1181,13 @@ void rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(const protocol_ctxt_t *const ctxt_pP, ; ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_UERadioAccessCapabilityInformation, &rac); MessageDef *msg_p; - msg_p = itti_alloc_new_message (TASK_RRC_GNB, 0, NGAP_UE_CAPABILITIES_IND); + msg_p = itti_alloc_new_message (TASK_RRC_GNB, rrc->module_id, NGAP_UE_CAPABILITIES_IND); ngap_ue_cap_info_ind_t *ind = &NGAP_UE_CAPABILITIES_IND(msg_p); memset(ind, 0, sizeof(*ind)); ind->gNB_ue_ngap_id = UE->rrc_ue_id; ind->ue_radio_cap.length = encoded; ind->ue_radio_cap.buffer = buf2; - itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, msg_p); + itti_send_msg_to_task (TASK_NGAP, rrc->module_id, msg_p); LOG_I(NR_RRC,"Send message to ngap: NGAP_UE_CAPABILITIES_IND\n"); } diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h index 8a0834faba..f8cb3fef12 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.h +++ b/openair2/RRC/NR/rrc_gNB_NGAP.h @@ -75,9 +75,7 @@ void rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, int num_pdu, uint32_t pdu_session_id[256]); -void rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - const NR_UECapabilityInformation_t *const ue_cap_info); +void rrc_gNB_send_NGAP_UE_CAPABILITIES_IND(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_UECapabilityInformation_t *const ue_cap_info); int rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(MessageDef *msg_p, instance_t instance); From da9f4cec18f930a7df8f1112a92cfd974a9eaa49 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Oct 2024 19:38:14 +0200 Subject: [PATCH 36/58] Cleanup: pass UE context directly into handle_rrcReestablishmentComplete() --- openair2/RRC/NR/rrc_gNB.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 9860aff642..e4a32d7d5e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -918,15 +918,8 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context } /// @brief Function tha processes RRCReestablishmentComplete message sent by the UE, after RRCReestasblishment request. -/// @param ctxt_pP Protocol context containing information regarding the UE and gNB -/// @param reestablish_rnti is the old C-RNTI -/// @param ue_context_pP UE context container information regarding the UE -/// @param xid Transaction Identifier used in RRC messages -static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP, - const uint8_t xid) +static void rrc_gNB_process_RRCReestablishmentComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p, const uint8_t xid) { - gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; LOG_I(NR_RRC, "UE %d Processing NR_RRCReestablishmentComplete from UE\n", ue_p->rrc_ue_id); int i = 0; @@ -935,7 +928,6 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co ue_p->Srb[1].Active = 1; - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; NR_CellGroupConfig_t *cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); cellGroupConfig->spCellConfig = ue_p->masterCellGroup->spCellConfig; @@ -981,7 +973,7 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co /* Create drb-ToAddModList */ NR_DRB_ToAddModList_t *DRBs = createDRBlist(ue_p, true); - uint8_t new_xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); + uint8_t new_xid = rrc_gNB_get_next_transaction_identifier(rrc->module_id); ue_p->xids[new_xid] = RRC_REESTABLISH_COMPLETE; uint8_t buffer[NR_RRC_BUF_SIZE] = {0}; int size = do_RRCReconfiguration(ue_p, @@ -1356,19 +1348,14 @@ static void rrc_gNB_process_MeasurementReport(gNB_RRC_UE_t *UE, NR_MeasurementRe process_Event_Based_Measurement_Report(report_config->choice.reportConfigNR, measurementReport); } -static int handle_rrcReestablishmentComplete(const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_p, - const NR_RRCReestablishmentComplete_t *reestablishment_complete) +static int handle_rrcReestablishmentComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_RRCReestablishmentComplete_t *cplt) { - DevAssert(ue_context_p != NULL); - gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - - NR_RRCReestablishmentComplete__criticalExtensions_PR p = reestablishment_complete->criticalExtensions.present; + NR_RRCReestablishmentComplete__criticalExtensions_PR p = cplt->criticalExtensions.present; if (p != NR_RRCReestablishmentComplete__criticalExtensions_PR_rrcReestablishmentComplete) { LOG_E(NR_RRC, "UE %d: expected presence of rrcReestablishmentComplete, but message has %d\n", UE->rrc_ue_id, p); return -1; } - rrc_gNB_process_RRCReestablishmentComplete(ctxt_pP, ue_context_p, reestablishment_complete->rrc_TransactionIdentifier); + rrc_gNB_process_RRCReestablishmentComplete(rrc, UE, cplt->rrc_TransactionIdentifier); UE->ue_reestablishment_counter++; return 0; @@ -1718,9 +1705,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_rrcReestablishmentComplete: - if (handle_rrcReestablishmentComplete(ctxt_pP, ue_context_p, ul_dcch_msg->message.choice.c1->choice.rrcReestablishmentComplete) - == -1) - return -1; + handle_rrcReestablishmentComplete(rrc, UE, ul_dcch_msg->message.choice.c1->choice.rrcReestablishmentComplete); break; default: From 788bc623e3f18c3d53c991a0e5dcf8f5512c7673 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 16 Oct 2024 09:08:16 +0200 Subject: [PATCH 37/58] Cleanup rrc_gNB_decode_dcch(): use F1 message type, pass rrc pointer --- openair2/RRC/NR/rrc_gNB.c | 47 ++++++++++----------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index e4a32d7d5e..f0d640b0bd 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1614,33 +1614,29 @@ static void rrc_gNB_generate_UECapabilityEnquiry(gNB_RRC_INST *rrc, gNB_RRC_UE_t nr_rrc_transfer_protected_rrc_message(rrc, ue, DCCH, buffer, size); } -int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, - const rb_id_t Srb_id, - const uint8_t *const Rx_sdu, - const sdu_size_t sdu_sizeP) -//----------------------------------------------------------------------------- +static int rrc_gNB_decode_dcch(gNB_RRC_INST *rrc, const f1ap_ul_rrc_message_t *msg) { - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; - /* we look up by CU UE ID! Do NOT change back to RNTI! */ - rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, ctxt_pP->rntiMaybeUEid); + rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, msg->gNB_CU_ue_id); if (!ue_context_p) { - LOG_E(RRC, "could not find UE context for CU UE ID %lu, aborting transaction\n", ctxt_pP->rntiMaybeUEid); + LOG_E(RRC, "could not find UE context for CU UE ID %u, aborting transaction\n", msg->gNB_CU_ue_id); return -1; } gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - if ((Srb_id != 1) && (Srb_id != 2)) { - LOG_E(NR_RRC, "Received message on SRB%ld, should not have ...\n", Srb_id); - } else { - LOG_D(NR_RRC, "Received message on SRB%ld\n", Srb_id); + if (msg->srb_id < 1 || msg->srb_id > 2) { + LOG_E(NR_RRC, "Received message on SRB %d, discarding message\n", msg->srb_id); + return -1; } + LOG_D(NR_RRC, "UE %d: Decoding DCCH %d size %d\n", UE->rrc_ue_id, msg->srb_id, msg->rrc_container_length); + LOG_DUMPMSG(RRC, DEBUG_RRC, (char *)msg->rrc_container, msg->rrc_container_length, "[MSG] RRC UL Information Transfer \n"); NR_UL_DCCH_Message_t *ul_dcch_msg = NULL; - asn_dec_rval_t dec_rval = uper_decode(NULL, &asn_DEF_NR_UL_DCCH_Message, (void **)&ul_dcch_msg, Rx_sdu, sdu_sizeP, 0, 0); + asn_dec_rval_t dec_rval = + uper_decode(NULL, &asn_DEF_NR_UL_DCCH_Message, (void **)&ul_dcch_msg, msg->rrc_container, msg->rrc_container_length, 0, 0); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(NR_RRC, "Failed to decode UL-DCCH (%zu bytes)\n", dec_rval.consumed); + LOG_E(NR_RRC, "UE %d: Failed to decode UL-DCCH (%zu bytes)\n", UE->rrc_ue_id, dec_rval.consumed); return -1; } @@ -1667,7 +1663,6 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_ulInformationTransfer: - LOG_DUMPMSG(RRC, DEBUG_RRC, (char *)Rx_sdu, sdu_sizeP, "[MSG] RRC UL Information Transfer \n"); rrc_gNB_send_NGAP_UPLINK_NAS(rrc, UE, ul_dcch_msg); break; @@ -1695,7 +1690,6 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP, break; case NR_UL_DCCH_MessageType__c1_PR_securityModeFailure: - LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)Rx_sdu, sdu_sizeP, "[MSG] NR RRC Security Mode Failure\n"); LOG_E(NR_RRC, "UE %d: received securityModeFailure\n", ue_context_p->ue_context.rrc_ue_id); LOG_W(NR_RRC, "Cannot continue as no AS security is activated (implementation missing)\n"); break; @@ -2324,7 +2318,6 @@ void *rrc_gnb_task(void *args_p) { MessageDef *msg_p; instance_t instance; int result; - protocol_ctxt_t ctxt = {.module_id = 0, .enb_flag = 1, .instance = 0, .rntiMaybeUEid = 0, .frame = -1, .subframe = -1, .eNB_index = 0, .brOption = false}; long stats_timer_id = 1; if (!IS_SOFTMODEM_NOSTATS_BIT) { @@ -2371,23 +2364,7 @@ void *rrc_gnb_task(void *args_p) { /* Messages from PDCP */ /* From DU -> CU */ case F1AP_UL_RRC_MESSAGE: - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, - instance, - GNB_FLAG_YES, - F1AP_UL_RRC_MESSAGE(msg_p).gNB_CU_ue_id, - 0, - 0); - LOG_D(NR_RRC, - "Decoding DCCH %d: ue %04lx, inst %ld, ctxt %p, size %d\n", - F1AP_UL_RRC_MESSAGE(msg_p).srb_id, - ctxt.rntiMaybeUEid, - instance, - &ctxt, - F1AP_UL_RRC_MESSAGE(msg_p).rrc_container_length); - rrc_gNB_decode_dcch(&ctxt, - F1AP_UL_RRC_MESSAGE(msg_p).srb_id, - F1AP_UL_RRC_MESSAGE(msg_p).rrc_container, - F1AP_UL_RRC_MESSAGE(msg_p).rrc_container_length); + rrc_gNB_decode_dcch(RC.nrrrc[instance], &F1AP_UL_RRC_MESSAGE(msg_p)); free(F1AP_UL_RRC_MESSAGE(msg_p).rrc_container); break; From e497526543e1b1fb892aeb5495bc934e166eb93d Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 09:50:18 +0200 Subject: [PATCH 38/58] Remove function declaration with non-existant definition --- openair2/RRC/NR/nr_rrc_proto.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 009164a80d..55e6526b76 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -47,10 +47,6 @@ #define NR_MAX_SUPPORTED_DL_LAYERS 4 void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan); -void rrc_gNB_process_SgNBAdditionRequest( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP - ); void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( const protocol_ctxt_t *const ctxt_pP, From fce17f873b7cca6943347fdee8a15a2dc232835c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 09:51:29 +0200 Subject: [PATCH 39/58] Remove nr_rrc_common.c: declared functions are not used --- CMakeLists.txt | 1 - doc/Doxyfile | 2 -- openair2/RRC/NR/nr_rrc_common.c | 56 --------------------------------- openair2/RRC/NR/nr_rrc_common.h | 2 -- openair2/RRC/NR/nr_rrc_proto.h | 2 -- 5 files changed, 63 deletions(-) delete mode 100644 openair2/RRC/NR/nr_rrc_common.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eb40de493..af48eca7b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1260,7 +1260,6 @@ set(L2_NR_SRC ${NR_PDCP_SRC} ${NR_SDAP_SRC} ${NR_RRC_DIR}/rrc_gNB.c - ${NR_RRC_DIR}/nr_rrc_common.c ${NR_RRC_DIR}/mac_rrc_dl_direct.c ${NR_RRC_DIR}/mac_rrc_dl_f1ap.c ${NR_RRC_DIR}/nr_rrc_config.c diff --git a/doc/Doxyfile b/doc/Doxyfile index 0d53026705..360bdd0535 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1886,13 +1886,11 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_radio_bearers.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_NGAP.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/nr_rrc_proto.h \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/nr_rrc_common.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_UE_context.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/MESSAGES/asn1_msg.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/MESSAGES/asn1_msg.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_UE_context.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/cucp_cuup_e1ap.c \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/nr_rrc_common.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/nr_rrc_config.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR/rrc_gNB_radio_bearers.h \ diff --git a/openair2/RRC/NR/nr_rrc_common.c b/openair2/RRC/NR/nr_rrc_common.c deleted file mode 100644 index 7aa281c343..0000000000 --- a/openair2/RRC/NR/nr_rrc_common.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file nr_rrc_common.c - * \brief rrc common procedures for gNB - * \author Navid Nikaein and Raymond Knopp, WEI-TAI CHEN - * \date 2011 - 2014, 2018 - * \version 1.0 - * \company Eurecom, NTUST - * \email: navid.nikaein@eurecom.fr and raymond.knopp@eurecom.fr, kroempa@gmail.com - */ - -#include "nr_rrc_extern.h" -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" -#include "COMMON/openair_defs.h" -#include "common/platform_types.h" -#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "LAYER2/RLC/rlc.h" -#include "COMMON/mac_rrc_primitives.h" -#include "common/utils/LOG/log.h" -#include "asn1_msg.h" -#include "common/utils/LOG/vcd_signal_dumper.h" -#include "common/ran_context.h" - -#define DEBUG_NR_RRC 1 - -extern RAN_CONTEXT_t RC; -extern UE_MAC_INST *UE_mac_inst; -extern mui_t rrc_gNB_mui; - -//----------------------------------------------------------------------------- -void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan) -{ - chan->transport_block_size = 4; - chan->max_transport_blocks = 16; - chan->Delay_class = 1; - return; -} diff --git a/openair2/RRC/NR/nr_rrc_common.h b/openair2/RRC/NR/nr_rrc_common.h index 305013ecf4..f81a57f5ad 100644 --- a/openair2/RRC/NR/nr_rrc_common.h +++ b/openair2/RRC/NR/nr_rrc_common.h @@ -59,6 +59,4 @@ typedef struct SRB_INFO_TABLE_ENTRY_NR_s { uint8_t status; } NR_SRB_INFO_TABLE_ENTRY; -void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan); - #endif diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 55e6526b76..5320b369c9 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -45,8 +45,6 @@ #include "NR_CellGroupConfig.h" #define NR_MAX_SUPPORTED_DL_LAYERS 4 -void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan); - void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( const protocol_ctxt_t *const ctxt_pP, From 145ab259e8f668030df7ffa4d1ee2eff79202a87 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 09:58:03 +0200 Subject: [PATCH 40/58] Cleanup rrc_gNB_generate_RRCRelease(): pass context directly --- common/utils/telnetsrv/telnetsrv_rrc.c | 20 ++++++++------------ openair2/RRC/NR/nr_rrc_proto.h | 13 +------------ openair2/RRC/NR/rrc_gNB.c | 18 ++++-------------- openair2/RRC/NR/rrc_gNB_NGAP.c | 5 +---- 4 files changed, 14 insertions(+), 42 deletions(-) diff --git a/common/utils/telnetsrv/telnetsrv_rrc.c b/common/utils/telnetsrv/telnetsrv_rrc.c index aab85a825f..1c5e3765cb 100644 --- a/common/utils/telnetsrv/telnetsrv_rrc.c +++ b/common/utils/telnetsrv/telnetsrv_rrc.c @@ -68,9 +68,9 @@ static int get_single_ue_id(void) * @param prnt: Print function * @return 0 on success, -1 on failure */ -int rrc_gNB_trigger_release(char *buf, int debug, telnet_printfunc_t prnt) { +int rrc_gNB_trigger_release(char *buf, int debug, telnet_printfunc_t prnt) +{ ue_id_t ue_id = -1; - protocol_ctxt_t ctxt; if (!buf) { ue_id = get_single_ue_id(); @@ -96,10 +96,8 @@ int rrc_gNB_trigger_release(char *buf, int debug, telnet_printfunc_t prnt) { } gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, 0, GNB_FLAG_YES, UE->rrc_ue_id, 0, 0); - ctxt.eNB_index = 0; - rrc_gNB_generate_RRCRelease(&ctxt, ue_context_p); + rrc_gNB_generate_RRCRelease(rrc, UE); prnt("RRC Release triggered for UE %u\n", ue_id); return 0; @@ -108,16 +106,14 @@ int rrc_gNB_trigger_release(char *buf, int debug, telnet_printfunc_t prnt) { /** * @brief Trigger RRC Release for all UEs */ -int rrc_gNB_trigger_release_all(char *buf, int debug, telnet_printfunc_t prnt) { +int rrc_gNB_trigger_release_all(char *buf, int debug, telnet_printfunc_t prnt) +{ rrc_gNB_ue_context_t *ue_context_p = NULL; - protocol_ctxt_t ctxt; /* Not sure what exactly is this */ - RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(RC.nrrrc[0]->rrc_ue_head)) { + gNB_RRC_INST *rrc = RC.nrrrc[0]; + RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &rrc->rrc_ue_head) { gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, 0, GNB_FLAG_YES, UE->rrc_ue_id, 0, 0); - ctxt.eNB_index = 0; - - rrc_gNB_generate_RRCRelease(&ctxt, ue_context_p); + rrc_gNB_generate_RRCRelease(rrc, UE); prnt("RRC Release triggered for UE %u\n", UE->rrc_ue_id); } diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 5320b369c9..c828113793 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -46,13 +46,6 @@ #define NR_MAX_SUPPORTED_DL_LAYERS 4 -void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP - ); - -rrc_gNB_ue_context_t *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance_pP); - void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc,NR_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t * cg_config_info); void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m); @@ -72,11 +65,7 @@ void rrc_forward_ue_nas_message(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE); unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP); -void -rrc_gNB_generate_RRCRelease( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP -); +void rrc_gNB_generate_RRCRelease(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE); /**\brief RRC eNB task. \param args_p Pointer on arguments to start the task. */ diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index f0d640b0bd..3db988367f 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -2529,23 +2529,13 @@ static void rrc_deliver_ue_ctxt_release_cmd(void *deliver_pdu_data, ue_id_t ue_i * Generate the RRC Connection Release to UE. * If received, UE should switch to RRC_IDLE mode. */ -void -rrc_gNB_generate_RRCRelease( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP -) -//----------------------------------------------------------------------------- +void rrc_gNB_generate_RRCRelease(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE) { uint8_t buffer[NR_RRC_BUF_SIZE] = {0}; - int size = do_NR_RRCRelease(buffer, NR_RRC_BUF_SIZE, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id)); + int size = do_NR_RRCRelease(buffer, NR_RRC_BUF_SIZE, rrc_gNB_get_next_transaction_identifier(rrc->module_id)); - LOG_I(NR_RRC, - PROTOCOL_NR_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCRelease (bytes %d)\n", - PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - size); + LOG_I(NR_RRC, "UE %d: Generate RRCRelease (bytes %d)\n", UE->rrc_ue_id, size); - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; - const gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; f1_ue_data_t ue_data = cu_get_f1_ue_data(UE->rrc_ue_id); RETURN_IF_INVALID_ASSOC_ID(ue_data.du_assoc_id); f1ap_ue_context_release_cmd_t ue_context_release_cmd = { @@ -2556,7 +2546,7 @@ rrc_gNB_generate_RRCRelease( .srb_id = DCCH, }; deliver_ue_ctxt_release_data_t data = {.rrc = rrc, .release_cmd = &ue_context_release_cmd, .assoc_id = ue_data.du_assoc_id}; - nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, rrc_deliver_ue_ctxt_release_cmd, &data); + nr_pdcp_data_req_srb(UE->rrc_ue_id, DCCH, rrc_gNB_mui++, size, buffer, rrc_deliver_ue_ctxt_release_cmd, &data); } int rrc_gNB_generate_pcch_msg(sctp_assoc_t assoc_id, const NR_SIB1_t *sib1, uint32_t tmsi, uint8_t paging_drx) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 53a08e5cb7..15bc114dca 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -1091,7 +1091,6 @@ int rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_COMMAND(MessageDef *msg_p, instance_ { gNB_RRC_INST *rrc = RC.nrrrc[0]; uint32_t gNB_ue_ngap_id = 0; - protocol_ctxt_t ctxt; gNB_ue_ngap_id = NGAP_UE_CONTEXT_RELEASE_COMMAND(msg_p).gNB_ue_ngap_id; rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], gNB_ue_ngap_id); @@ -1124,9 +1123,7 @@ int rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_COMMAND(MessageDef *msg_p, instance_ /* special case: the DU might be offline, in which case the f1_ue_data exists * but is set to 0 */ if (cu_exists_f1_ue_data(UE->rrc_ue_id) && cu_get_f1_ue_data(UE->rrc_ue_id).du_assoc_id != 0) { - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, UE->rrc_ue_id, 0, 0); - ctxt.eNB_index = 0; - rrc_gNB_generate_RRCRelease(&ctxt, ue_context_p); + rrc_gNB_generate_RRCRelease(rrc, UE); /* UE will be freed after UE context release complete */ } else { From dbeb1ea6919043843dd8af192db580f5e60bd922 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 10:02:04 +0200 Subject: [PATCH 41/58] Cleanup nr_rrc_reconfiguration_req(): pass UE context directly --- openair2/RRC/NR/nr_rrc_proto.h | 5 +---- openair2/RRC/NR/rrc_gNB.c | 12 +++--------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index c828113793..5f90b554f8 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -79,10 +79,7 @@ void *rrc_gnb_task(void *args_p); \ *reOffset Pointer to RE Offset Value */ void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, long *ptrsNrb, long *ptrsMcs, long *epre_Ratio, long *reOffset); -int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP, - protocol_ctxt_t *const ctxt_pP, - const int dl_bwp_id, - const int ul_bwp_id); +int nr_rrc_reconfiguration_req(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p, const int dl_bwp_id, const int ul_bwp_id); void rrc_gNB_generate_dedicatedRRCReconfiguration_release( diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 3db988367f..57d800d2bc 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1001,13 +1001,9 @@ static void rrc_gNB_process_RRCReestablishmentComplete(gNB_RRC_INST *rrc, gNB_RR } //----------------------------------------------------------------------------- -int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP, - protocol_ctxt_t *const ctxt_pP, - const int dl_bwp_id, - const int ul_bwp_id) +int nr_rrc_reconfiguration_req(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p, const int dl_bwp_id, const int ul_bwp_id) { - uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); - gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; + uint8_t xid = rrc_gNB_get_next_transaction_identifier(rrc->module_id); ue_p->xids[xid] = RRC_DEDICATED_RECONF; NR_CellGroupConfig_t *masterCellGroup = ue_p->masterCellGroup; @@ -1022,7 +1018,6 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP, uint8_t buffer[NR_RRC_BUF_SIZE]; int size = do_RRCReconfiguration(ue_p, buffer, NR_RRC_BUF_SIZE, xid, NULL, NULL, NULL, NULL, NULL, NULL, masterCellGroup); - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); return 0; @@ -2052,8 +2047,7 @@ static void rrc_CU_process_ue_modification_required(MessageDef *msg_p) xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, UE->masterCellGroup); /* trigger reconfiguration */ - nr_rrc_reconfiguration_req(ue_context_p, &ctxt, 0, 0); - //rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p); + nr_rrc_reconfiguration_req(rrc, UE, 0, 0); return; } LOG_W(RRC, From 452ccc3235e0a31b010968716adff42ae23899ee Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 11:26:21 +0200 Subject: [PATCH 42/58] Cleanup rrc_gNB_generate_dedicatedRRCReconfiguration_release() Pass RRC and UE context pointers directly. --- openair2/RRC/NR/nr_rrc_proto.h | 12 +++++------- openair2/RRC/NR/rrc_gNB.c | 27 ++++++--------------------- openair2/RRC/NR/rrc_gNB_NGAP.c | 6 ++---- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 5f90b554f8..4f287b3807 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -81,13 +81,11 @@ void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, long *ptrsNrb, long *ptrs int nr_rrc_reconfiguration_req(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p, const int dl_bwp_id, const int ul_bwp_id); -void -rrc_gNB_generate_dedicatedRRCReconfiguration_release( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t xid, - uint32_t nas_length, - uint8_t *nas_buffer); +void rrc_gNB_generate_dedicatedRRCReconfiguration_release(gNB_RRC_INST *rrc, + gNB_RRC_UE_t *ue_p, + uint8_t xid, + uint32_t nas_length, + uint8_t *nas_buffer); void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 57d800d2bc..597e00896d 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -709,17 +709,13 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( } //----------------------------------------------------------------------------- -void -rrc_gNB_generate_dedicatedRRCReconfiguration_release( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP, - uint8_t xid, - uint32_t nas_length, - uint8_t *nas_buffer) +void rrc_gNB_generate_dedicatedRRCReconfiguration_release(gNB_RRC_INST *rrc, + gNB_RRC_UE_t *ue_p, + uint8_t xid, + uint32_t nas_length, + uint8_t *nas_buffer) //----------------------------------------------------------------------------- { - gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; - NR_DRB_ToReleaseList_t *DRB_Release_configList2 = CALLOC(sizeof(*DRB_Release_configList2), 1); for (int i = 0; i < NB_RB_MAX; i++) { @@ -760,18 +756,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( free(nas_buffer); } - LOG_I(NR_RRC, "[gNB %d] Frame %d, Logical Channel DL-DCCH, Generate NR_RRCReconfiguration (bytes %d, UE RNTI %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_p->rnti); - LOG_D(NR_RRC, - "[FRAME %05d][RRC_gNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", - ctxt_pP->frame, - ctxt_pP->module_id, - size, - ue_p->rnti, - rrc_gNB_mui, - ctxt_pP->module_id, - DCCH); - - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + LOG_I(NR_RRC, "UE %d: Generate NR_RRCReconfiguration (bytes %d)\n", ue_p->rrc_ue_id, size); nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); } diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 15bc114dca..7a4831fd7e 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -1219,7 +1219,6 @@ int rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(MessageDef *msg_p, instance_ //------------------------------------------------------------------------------ { uint32_t gNB_ue_ngap_id; - protocol_ctxt_t ctxt; ngap_pdusession_release_command_t *cmd = &NGAP_PDUSESSION_RELEASE_COMMAND(msg_p); gNB_ue_ngap_id = cmd->gNB_ue_ngap_id; if (cmd->nb_pdusessions_torelease > NGAP_MAX_PDUSESSION) { @@ -1236,11 +1235,10 @@ int rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(MessageDef *msg_p, instance_ LOG_I(NR_RRC, "[gNB %ld] gNB_ue_ngap_id %u \n", instance, gNB_ue_ngap_id); gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, UE->rrc_ue_id, 0, 0); LOG_I( NR_RRC, "PDU Session Release Command: AMF_UE_NGAP_ID %lu rrc_ue_id %u release_pdusessions %d \n", cmd->amf_ue_ngap_id, gNB_ue_ngap_id, cmd->nb_pdusessions_torelease); bool found = false; - uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt.module_id); + uint8_t xid = rrc_gNB_get_next_transaction_identifier(rrc->module_id); UE->xids[xid] = RRC_PDUSESSION_RELEASE; for (int pdusession = 0; pdusession < cmd->nb_pdusessions_torelease; pdusession++) { rrc_pdu_session_param_t *pduSession = find_pduSession(UE, cmd->pdusession_release_params[pdusession].pdusession_id, false); @@ -1268,7 +1266,7 @@ int rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND(MessageDef *msg_p, instance_ if (found) { // TODO RRCReconfiguration To UE LOG_I(NR_RRC, "Send RRCReconfiguration To UE \n"); - rrc_gNB_generate_dedicatedRRCReconfiguration_release(&ctxt, ue_context_p, xid, cmd->nas_pdu.length, cmd->nas_pdu.buffer); + rrc_gNB_generate_dedicatedRRCReconfiguration_release(rrc, UE, xid, cmd->nas_pdu.length, cmd->nas_pdu.buffer); } else { // gtp tunnel delete LOG_I(NR_RRC, "gtp tunnel delete all tunnels for UE %04x\n", UE->rnti); From 01b240ebf17298bcbff7f7626517fee3dc6b9a80 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 11:36:41 +0200 Subject: [PATCH 43/58] Cleanup rrc_gNB_generate_dedicatedRRCReconfiguration(): pass UE context directly --- executables/nr-cuup.c | 5 ----- openair2/RRC/NR/nr_rrc_proto.h | 2 -- openair2/RRC/NR/rrc_gNB.c | 27 +++++---------------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/executables/nr-cuup.c b/executables/nr-cuup.c index 9d6fc20ac3..381e56bd2f 100644 --- a/executables/nr-cuup.c +++ b/executables/nr-cuup.c @@ -123,11 +123,6 @@ int nr_rlc_get_available_tx_space(const rnti_t rntiP, const logical_chan_id_t ch return 0; } -void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP) -{ - abort(); -} - void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig) { abort(); diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 4f287b3807..9c3d276394 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -87,8 +87,6 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration_release(gNB_RRC_INST *rrc, uint32_t nas_length, uint8_t *nas_buffer); -void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP); - bool ue_associated_to_cuup(const gNB_RRC_INST *rrc, const gNB_RRC_UE_t *ue); sctp_assoc_t get_existing_cuup_for_ue(const gNB_RRC_INST *rrc, const gNB_RRC_UE_t *ue); sctp_assoc_t get_new_cuup_for_ue(const gNB_RRC_INST *rrc, const gNB_RRC_UE_t *ue, int sst, int sd); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 597e00896d..668430535e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -481,14 +481,9 @@ static void rrc_gNB_process_RRCSetupComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE rrc_gNB_send_NGAP_NAS_FIRST_REQ(rrc, UE, rrcSetupComplete); } -//----------------------------------------------------------------------------- -void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP) -//----------------------------------------------------------------------------- +static void rrc_gNB_generate_dedicatedRRCReconfiguration(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p) { - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; - - uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); - gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; + uint8_t xid = rrc_gNB_get_next_transaction_identifier(rrc->module_id); ue_p->xids[xid] = RRC_PDUSESSION_ESTABLISH; struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList = CALLOC(1, sizeof(*dedicatedNAS_MessageList)); @@ -569,16 +564,6 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c ue_p->DRB_ReleaseList = NULL; LOG_I(NR_RRC, "UE %d: Generate RRCReconfiguration (bytes %d, xid %d)\n", ue_p->rrc_ue_id, size, xid); - LOG_D(NR_RRC, - "[FRAME %05d][RRC_gNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", - ctxt_pP->frame, - ctxt_pP->module_id, - size, - ue_p->rnti, - rrc_gNB_mui, - ctxt_pP->module_id, - DCCH); - nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); } @@ -1877,8 +1862,7 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, instance e1_send_bearer_updates(rrc, UE, resp->drbs_to_be_setup_length, resp->drbs_to_be_setup); } - protocol_ctxt_t ctxt = {.rntiMaybeUEid = resp->gNB_CU_ue_id, .module_id = instance}; - rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p); + rrc_gNB_generate_dedicatedRRCReconfiguration(rrc, UE); } static void rrc_CU_process_ue_context_release_request(MessageDef *msg_p) @@ -1947,8 +1931,7 @@ static void rrc_CU_process_ue_context_release_complete(MessageDef *msg_p) static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, instance_t instance) { f1ap_ue_context_modif_resp_t *resp = &F1AP_UE_CONTEXT_MODIFICATION_RESP(msg_p); - protocol_ctxt_t ctxt = {.rntiMaybeUEid = resp->gNB_CU_ue_id, .module_id = instance, .instance = instance, .enb_flag = 1, .eNB_index = instance}; - gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; + gNB_RRC_INST *rrc = RC.nrrrc[instance]; rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, resp->gNB_CU_ue_id); if (!ue_context_p) { LOG_E(RRC, "could not find UE context for CU UE ID %u, aborting transaction\n", resp->gNB_CU_ue_id); @@ -1976,7 +1959,7 @@ static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, i } UE->masterCellGroup = cellGroupConfig; - rrc_gNB_generate_dedicatedRRCReconfiguration(&ctxt, ue_context_p); + rrc_gNB_generate_dedicatedRRCReconfiguration(rrc, UE); } } From ff3a14f7f90aa6425eb1ffe3abd0bbbbc8f3808e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 11:41:43 +0200 Subject: [PATCH 44/58] Cleanup rrc_gNB_modify_dedicatedRRCReconfiguration: pass UE context directly --- openair2/RRC/NR/rrc_gNB.c | 23 +++-------------------- openair2/RRC/NR/rrc_gNB_NGAP.c | 9 +++------ openair2/RRC/NR/rrc_gNB_NGAP.h | 6 +----- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 668430535e..34f2bbc645 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -567,16 +567,10 @@ static void rrc_gNB_generate_dedicatedRRCReconfiguration(gNB_RRC_INST *rrc, gNB_ nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); } -//----------------------------------------------------------------------------- -void -rrc_gNB_modify_dedicatedRRCReconfiguration( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP) -//----------------------------------------------------------------------------- +void rrc_gNB_modify_dedicatedRRCReconfiguration(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p) { - gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; int qos_flow_index = 0; - uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); + uint8_t xid = rrc_gNB_get_next_transaction_identifier(rrc->module_id); ue_p->xids[xid] = RRC_PDUSESSION_MODIFY; struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList = @@ -678,18 +672,7 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( for (int i = 0; i < ue_p->nb_of_pdusessions; i++) clear_nas_pdu(&ue_p->pduSession[i].param.nas_pdu); - LOG_I(NR_RRC, "[gNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCReconfiguration (bytes %d, UE RNTI %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_p->rnti); - LOG_D(NR_RRC, - "[FRAME %05d][RRC_gNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", - ctxt_pP->frame, - ctxt_pP->module_id, - size, - ue_p->rnti, - rrc_gNB_mui, - ctxt_pP->module_id, - DCCH); - - gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + LOG_I(NR_RRC, "UE %d: Generate RRCReconfiguration (bytes %d)\n", ue_p->rrc_ue_id, size); nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); } diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 7a4831fd7e..da519e54ed 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -879,18 +879,16 @@ int rrc_gNB_process_NGAP_PDUSESSION_MODIFY_REQ(MessageDef *msg_p, instance_t ins { rrc_gNB_ue_context_t *ue_context_p = NULL; - protocol_ctxt_t ctxt; ngap_pdusession_modify_req_t *req = &NGAP_PDUSESSION_MODIFY_REQ(msg_p); - ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], req->gNB_ue_ngap_id); + gNB_RRC_INST *rrc = RC.nrrrc[instance]; + ue_context_p = rrc_gNB_get_ue_context(rrc, req->gNB_ue_ngap_id); if (ue_context_p == NULL) { LOG_W(NR_RRC, "[gNB %ld] In NGAP_PDUSESSION_MODIFY_REQ: unknown UE from NGAP ids (%u)\n", instance, req->gNB_ue_ngap_id); // TO implement return setup failed return (-1); } gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, UE->rrc_ue_id, 0, 0); - ctxt.eNB_index = 0; bool all_failed = true; for (int i = 0; i < req->nb_pdusessions_tomodify; i++) { rrc_pdu_session_param_t *sess; @@ -925,8 +923,7 @@ int rrc_gNB_process_NGAP_PDUSESSION_MODIFY_REQ(MessageDef *msg_p, instance_t ins } if (!all_failed) { - LOG_D(NR_RRC, "generate RRCReconfiguration \n"); - rrc_gNB_modify_dedicatedRRCReconfiguration(&ctxt, ue_context_p); + rrc_gNB_modify_dedicatedRRCReconfiguration(rrc, UE); } else { LOG_I(NR_RRC, "pdu session modify failed, fill NGAP_PDUSESSION_MODIFY_RESP with the pdu session information that failed to modify \n"); diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h index f8cb3fef12..9d83f28c3c 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.h +++ b/openair2/RRC/NR/rrc_gNB_NGAP.h @@ -58,11 +58,7 @@ int rrc_gNB_process_NGAP_PDUSESSION_MODIFY_REQ(MessageDef *msg_p, instance_t ins int rrc_gNB_send_NGAP_PDUSESSION_MODIFY_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid); -void -rrc_gNB_modify_dedicatedRRCReconfiguration( - const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *ue_context_pP -); +void rrc_gNB_modify_dedicatedRRCReconfiguration(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p); void rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_REQ(const module_id_t gnb_mod_idP, const rrc_gNB_ue_context_t *const ue_context_pP, const ngap_Cause_t causeP, const long cause_valueP); From 759b0ec39e493a13ac706cdbad49fb026cae0968 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 11:43:26 +0200 Subject: [PATCH 45/58] Cleanup rrc_CU_process_ue_modification_required(): remove protocol_ctxt_t --- openair2/RRC/NR/rrc_gNB.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 34f2bbc645..98ead429c9 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1946,11 +1946,10 @@ static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, i } } -static void rrc_CU_process_ue_modification_required(MessageDef *msg_p) +static void rrc_CU_process_ue_modification_required(MessageDef *msg_p, instance_t instance) { + gNB_RRC_INST *rrc = RC.nrrrc[instance]; f1ap_ue_context_modif_required_t *required = &F1AP_UE_CONTEXT_MODIFICATION_REQUIRED(msg_p); - protocol_ctxt_t ctxt = {.rntiMaybeUEid = required->gNB_CU_ue_id, .module_id = 0, .instance = 0, .enb_flag = 1, .eNB_index = 0}; - gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, required->gNB_CU_ue_id); if (ue_context_p == NULL) { LOG_E(RRC, "Could not find UE context for CU UE ID %d, cannot handle UE context modification request\n", required->gNB_CU_ue_id); @@ -2344,7 +2343,7 @@ void *rrc_gnb_task(void *args_p) { break; case F1AP_UE_CONTEXT_MODIFICATION_REQUIRED: - rrc_CU_process_ue_modification_required(msg_p); + rrc_CU_process_ue_modification_required(msg_p, instance); break; case F1AP_UE_CONTEXT_RELEASE_REQ: From 63a07854306d4fbc7a92a763447e0cb233245598 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 11:56:37 +0200 Subject: [PATCH 46/58] Cleanup rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(): pass UE context directly --- openair2/RRC/LTE/rrc_eNB_GTPV1U.h | 7 ------- openair2/RRC/NR/rrc_gNB_GTPV1U.c | 24 ++++++++++-------------- openair2/RRC/NR/rrc_gNB_GTPV1U.h | 10 +++------- openair2/RRC/NR/rrc_gNB_nsa.c | 10 +++------- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/openair2/RRC/LTE/rrc_eNB_GTPV1U.h b/openair2/RRC/LTE/rrc_eNB_GTPV1U.h index aff86729be..7d1ff07e10 100644 --- a/openair2/RRC/LTE/rrc_eNB_GTPV1U.h +++ b/openair2/RRC/LTE/rrc_eNB_GTPV1U.h @@ -44,13 +44,6 @@ rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( uint8_t *inde_list ); -int -rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( - const protocol_ctxt_t *const ctxt_pP, - const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, - uint8_t *inde_list -); - /*! \fn rrc_eNB_send_GTPV1U_ENB_DELETE_TUNNEL_REQ(module_id_t enb_mod_idP, const rrc_eNB_ue_context_t* const ue_context_pP) *\brief Send GTPV1U_ENB_DELETE_TUNNEL_REQ message to GTPV1U to destroy all UE-related tunnels. *\param module_id Instance ID of eNB. diff --git a/openair2/RRC/NR/rrc_gNB_GTPV1U.c b/openair2/RRC/NR/rrc_gNB_GTPV1U.c index 6c8627aa09..e5412778bc 100644 --- a/openair2/RRC/NR/rrc_gNB_GTPV1U.c +++ b/openair2/RRC/NR/rrc_gNB_GTPV1U.c @@ -44,29 +44,25 @@ extern RAN_CONTEXT_t RC; -int rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t *const ctxt_pP, const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, uint8_t *inde_list) +int rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(gNB_RRC_UE_t *ue, + const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, + uint8_t *inde_list) { if (!create_tunnel_resp_pP) { LOG_E(NR_RRC, "create_tunnel_resp_pP error\n"); return -1; } - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT " RX CREATE_TUNNEL_RESP num tunnels %u \n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), create_tunnel_resp_pP->num_tunnels); - /* we look up by CU UE ID! Do NOT change back to RNTI! */ - rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rntiMaybeUEid); - if (!ue_context_p) { - LOG_E(NR_RRC, "UE table error\n"); - return -1; - } for (int i = 0; i < create_tunnel_resp_pP->num_tunnels; i++) { - ue_context_p->ue_context.nsa_gtp_teid[inde_list[i]] = create_tunnel_resp_pP->enb_S1u_teid[i]; - ue_context_p->ue_context.nsa_gtp_addrs[inde_list[i]] = create_tunnel_resp_pP->enb_addr; - ue_context_p->ue_context.nsa_gtp_ebi[inde_list[i]] = create_tunnel_resp_pP->eps_bearer_id[i]; + ue->nsa_gtp_teid[inde_list[i]] = create_tunnel_resp_pP->enb_S1u_teid[i]; + ue->nsa_gtp_addrs[inde_list[i]] = create_tunnel_resp_pP->enb_addr; + ue->nsa_gtp_ebi[inde_list[i]] = create_tunnel_resp_pP->eps_bearer_id[i]; LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT " rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel (%u, %u) bearer UE context index %u, msg index %u, id %u, gtp addr len %d \n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + "UE %d: rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP tunnel (%u, %u) bearer UE context index %u, msg index %u, id %u, gtp " + "addr len %d \n", + ue->rrc_ue_id, create_tunnel_resp_pP->enb_S1u_teid[i], - ue_context_p->ue_context.nsa_gtp_teid[inde_list[i]], + ue->nsa_gtp_teid[inde_list[i]], inde_list[i], i, create_tunnel_resp_pP->eps_bearer_id[i], diff --git a/openair2/RRC/NR/rrc_gNB_GTPV1U.h b/openair2/RRC/NR/rrc_gNB_GTPV1U.h index d7d1013db8..85ad11105e 100644 --- a/openair2/RRC/NR/rrc_gNB_GTPV1U.h +++ b/openair2/RRC/NR/rrc_gNB_GTPV1U.h @@ -30,12 +30,8 @@ #ifndef RRC_GNB_GTPV1U_H_ #define RRC_GNB_GTPV1U_H_ - -int -rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( - const protocol_ctxt_t *const ctxt_pP, - const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, - uint8_t *inde_list -); +int rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(gNB_RRC_UE_t *ue, + const gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP, + uint8_t *inde_list); #endif diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index abe45dbdae..64d9ec3354 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -40,7 +40,7 @@ #include "uper_decoder.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" #include "openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h" -#include "openair2/RRC/LTE/rrc_eNB_GTPV1U.h" +#include "openair2/RRC/NR/rrc_gNB_GTPV1U.h" #include "openair2/F1AP/f1ap_ids.h" #include "executables/softmodem-common.h" #include "executables/nr-softmodem.h" @@ -282,15 +282,11 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a create_tunnel_req.rnti = ue_context_p->ue_context.rrc_ue_id; create_tunnel_req.num_tunnels = m->nb_e_rabs_tobeadded; RB_INSERT(rrc_nr_ue_tree_s, &RC.nrrrc[rrc->module_id]->rrc_ue_head, ue_context_p); - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, rrc->module_id, GNB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0, rrc->module_id); memset(&create_tunnel_resp, 0, sizeof(create_tunnel_resp)); if (!IS_SOFTMODEM_NOS1) { LOG_D(RRC, "Calling gtpv1u_create_s1u_tunnel()\n"); - gtpv1u_create_s1u_tunnel(ctxt.instance, &create_tunnel_req, &create_tunnel_resp, nr_pdcp_data_req_drb); - rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( - &ctxt, - &create_tunnel_resp, - &inde_list[0]); + gtpv1u_create_s1u_tunnel(rrc->module_id, &create_tunnel_req, &create_tunnel_resp, nr_pdcp_data_req_drb); + rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(&ue_context_p->ue_context, &create_tunnel_resp, &inde_list[0]); } X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).nb_e_rabs_admitted_tobeadded = m->nb_e_rabs_tobeadded; X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).target_assoc_id = m->target_assoc_id; From 304372d5e64467e4e57f043abb9c52bef69a8c86 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 15 Oct 2024 12:04:09 +0200 Subject: [PATCH 47/58] Remove unused protocol_ctxt_t --- openair2/RRC/NR/rrc_gNB_NGAP.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index da519e54ed..83473e69a0 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -414,7 +414,6 @@ void trigger_bearer_setup(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, pdusession int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t instance) //------------------------------------------------------------------------------ { - protocol_ctxt_t ctxt = {0}; ngap_initial_context_setup_req_t *req = &NGAP_INITIAL_CONTEXT_SETUP_REQ(msg_p); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], req->gNB_ue_ngap_id); @@ -430,8 +429,7 @@ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t itti_send_msg_to_task(TASK_NGAP, instance, msg_fail_p); return (-1); } - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, UE->rrc_ue_id, 0, 0); - gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; + gNB_RRC_INST *rrc = RC.nrrrc[instance]; UE->amf_ue_ngap_id = req->amf_ue_ngap_id; /* store guami in gNB_RRC_UE_t context; @@ -739,13 +737,11 @@ void rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE void rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ(MessageDef *msg_p, instance_t instance) //------------------------------------------------------------------------------ { - protocol_ctxt_t ctxt={0}; ngap_pdusession_setup_req_t* msg=&NGAP_PDUSESSION_SETUP_REQ(msg_p); rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[instance], msg->gNB_ue_ngap_id); gNB_RRC_UE_t *UE = &ue_context_p->ue_context; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, GNB_FLAG_YES, UE->rnti, 0, 0, 0); - gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id]; + gNB_RRC_INST *rrc = RC.nrrrc[instance]; if (ue_context_p == NULL) { MessageDef *msg_fail_p = NULL; From 132cd64bb02a34e6f7904a3add938bbc96f6d7ae Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 16 Oct 2024 18:01:31 +0200 Subject: [PATCH 48/58] Handle empty RRC ULInformationTransfer A UE might send a ULInformationTransfer without the actual content present (intentionally or not). Check this and handle appropriately to avoid a segfault when reading the empty NAS message. Closes: #862 --- openair2/RRC/NR/rrc_gNB_NGAP.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 83473e69a0..8c45728523 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -652,21 +652,27 @@ int rrc_gNB_process_NGAP_DOWNLINK_NAS(MessageDef *msg_p, instance_t instance, mu void rrc_gNB_send_NGAP_UPLINK_NAS(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_UL_DCCH_Message_t *const ul_dcch_msg) { - MessageDef *msg_p; - NR_ULInformationTransfer_t *ulInformationTransfer = ul_dcch_msg->message.choice.c1->choice.ulInformationTransfer; + NR_ULInformationTransfer_t *ulInformationTransfer = ul_dcch_msg->message.choice.c1->choice.ulInformationTransfer; - if (ulInformationTransfer->criticalExtensions.present == NR_ULInformationTransfer__criticalExtensions_PR_ulInformationTransfer) { - NR_DedicatedNAS_Message_t *nas = ulInformationTransfer->criticalExtensions.choice.ulInformationTransfer->dedicatedNAS_Message; - uint8_t *buf = malloc(nas->size); - AssertFatal(buf != NULL, "out of memory\n"); - memcpy(buf, nas->buf, nas->size); - msg_p = itti_alloc_new_message (TASK_RRC_GNB, rrc->module_id, NGAP_UPLINK_NAS); - NGAP_UPLINK_NAS(msg_p).gNB_ue_ngap_id = UE->rrc_ue_id; - NGAP_UPLINK_NAS (msg_p).nas_pdu.length = nas->size; - NGAP_UPLINK_NAS (msg_p).nas_pdu.buffer = buf; - itti_send_msg_to_task(TASK_NGAP, rrc->module_id, msg_p); - LOG_D(NR_RRC,"Send RRC GNB UL Information Transfer \n"); - } + NR_ULInformationTransfer__criticalExtensions_PR p = ulInformationTransfer->criticalExtensions.present; + if (p != NR_ULInformationTransfer__criticalExtensions_PR_ulInformationTransfer) { + LOG_E(NR_RRC, "UE %d: expected presence of ulInformationTransfer, but message has %d\n", UE->rrc_ue_id, p); + return; + } + + NR_DedicatedNAS_Message_t *nas = ulInformationTransfer->criticalExtensions.choice.ulInformationTransfer->dedicatedNAS_Message; + if (!nas) { + LOG_E(NR_RRC, "UE %d: expected NAS message in ulInformation, but it is NULL\n", UE->rrc_ue_id); + return; + } + + uint8_t *buf = malloc_or_fail(nas->size); + memcpy(buf, nas->buf, nas->size); + MessageDef *msg_p = itti_alloc_new_message(TASK_RRC_GNB, rrc->module_id, NGAP_UPLINK_NAS); + NGAP_UPLINK_NAS(msg_p).gNB_ue_ngap_id = UE->rrc_ue_id; + NGAP_UPLINK_NAS(msg_p).nas_pdu.length = nas->size; + NGAP_UPLINK_NAS(msg_p).nas_pdu.buffer = buf; + itti_send_msg_to_task(TASK_NGAP, rrc->module_id, msg_p); } void rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, uint8_t xid) From c4344f26d1c1963d9b51b5685deefe4d591d1ee3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 16 Oct 2024 12:34:32 +0200 Subject: [PATCH 49/58] Correctly pass ID to rrc_gNB_get_next_transaction_identifier() --- openair2/RRC/NR/rrc_gNB.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 98ead429c9..5ab7c0ba12 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1315,7 +1315,7 @@ void rrc_forward_ue_nas_message(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE) return; // no problem: the UE will re-request a NAS PDU uint8_t buffer[4096]; - unsigned int xid = rrc_gNB_get_next_transaction_identifier(0); + unsigned int xid = rrc_gNB_get_next_transaction_identifier(rrc->module_id); uint32_t length = do_NR_DLInformationTransfer(buffer, sizeof(buffer), xid, UE->nas_pdu.length, UE->nas_pdu.buffer); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, buffer, length, "[MSG] RRC DL Information Transfer\n"); rb_id_t srb_id = UE->Srb[2].Active ? DCCH1 : DCCH; @@ -2445,7 +2445,7 @@ void rrc_gNB_generate_SecurityModeCommand(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p) T(T_ENB_RRC_SECURITY_MODE_COMMAND, T_INT(0), T_INT(0), T_INT(0), T_INT(ue_p->rrc_ue_id)); NR_IntegrityProtAlgorithm_t integrity_algorithm = (NR_IntegrityProtAlgorithm_t)ue_p->integrity_algorithm; int size = do_NR_SecurityModeCommand(buffer, - rrc_gNB_get_next_transaction_identifier(0), + rrc_gNB_get_next_transaction_identifier(rrc->module_id), ue_p->ciphering_algorithm, integrity_algorithm); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)buffer, size, "[MSG] RRC Security Mode Command\n"); From de887a1d2aac36f1f14d5bff0467d9fbf08974a5 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Wed, 16 Oct 2024 22:14:17 +0100 Subject: [PATCH 50/58] Improve PUSCH and PUCCH SNR stability Reset TPC to 0 dB, after sending it to the UE, to not request new gain multiple times before computing new value for SNR --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 10 ++++++++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 ++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index b158942dd5..d6dfa19dd4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -924,6 +924,9 @@ static void nr_generate_Msg3_retransmission(module_id_t module_idP, 1, // Not toggling NDI in msg3 retransmissions ul_bwp); + // Reset TPC to 0 dB to not request new gain multiple times before computing new value for SNR + ra->msg3_TPC = 1; + fill_dci_pdu_rel15(sc_info, &ra->DL_BWP, ul_bwp, @@ -2199,6 +2202,9 @@ static void nr_generate_Msg4_MsgB(module_id_t module_idP, rbStart, rbSize); + // Reset TPC to 0 dB to not request new gain multiple times before computing new value for SNR + sched_ctrl->tpc1 = 1; + // Add padding header and zero rest out if there is space left if (ra->mac_pdu_length < harq->tb_size) { NR_MAC_SUBHEADER_FIXED *padding = (NR_MAC_SUBHEADER_FIXED *) &buf[ra->mac_pdu_length]; @@ -2351,7 +2357,7 @@ static void nr_fill_rar(uint8_t Mod_idP, NR_RA_t *ra, uint8_t *dlsch_buffer, nfa NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 2); unsigned char csi_req = 0, tpc_command; - tpc_command = 3; // this is 0 dB + tpc_command = 3; // This is 0 dB in RAR UL grant /// E/T/R/R/BI subheader /// // E = 1, MAC PDU includes another MAC sub-PDU (RAPID) @@ -2383,7 +2389,7 @@ static void nr_fill_rar(uint8_t Mod_idP, NR_RA_t *ra, uint8_t *dlsch_buffer, nfa // UL grant - ra->msg3_TPC = tpc_command; + ra->msg3_TPC = 1; // This is 0 dB in UL DCI if (pusch_pdu->frequency_hopping) AssertFatal(1==0,"PUSCH with frequency hopping currently not supported"); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index adf3faf227..af2a2b24e7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1227,6 +1227,8 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.ndi = harq->ndi; dci_payload.dai[0].val = pucch ? (pucch->dai_c-1)&3 : 0; dci_payload.tpc = sched_ctrl->tpc1; // TPC for PUCCH: table 7.2.1-1 in 38.213 + // Reset TPC to 0 dB to not request new gain multiple times before computing new value for SNR + sched_ctrl->tpc1 = 1; dci_payload.pucch_resource_indicator = pucch ? pucch->resource_indicator : 0; dci_payload.pdsch_to_harq_feedback_timing_indicator.val = pucch ? pucch->timing_indicator : 0; // PDSCH to HARQ TI dci_payload.antenna_ports.val = dmrs_parms->dmrs_ports_id; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 319d8fec67..4599349a04 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -2620,6 +2620,9 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n cur_harq->ndi, current_BWP); + // Reset TPC to 0 dB to not request new gain multiple times before computing new value for SNR + UE->UE_sched_ctrl.tpc0 = 1; + fill_dci_pdu_rel15(&UE->sc_info, &UE->current_DL_BWP, current_BWP, From af53f35824c6c4c77077e1d9c6e5ed031c627bfe Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 18 Oct 2024 11:17:58 +0200 Subject: [PATCH 51/58] avoid processing PUCCH2 without polar if declared missed detection --- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 23 ++++++++----------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 1 + 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 3b6209cd82..cf322dfc51 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -1087,7 +1087,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, pucch2_lev += signal_energy_nodc(rp[aa][symb], nb_re_pucch); } } - int decoderState=2; + pucch2_lev /= Prx * Prx * pucch_pdu->nr_of_symbols; int pucch2_levdB = dB_fixed(pucch2_lev); int scaling = 0; @@ -1100,10 +1100,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, else if (pucch2_levdB > 54) scaling = 1; - if (pucch2_levdB < gNB->measurements.n0_subband_power_avg_dB + (gNB->pucch0_thres/10)) - decoderState=1; LOG_D(PHY, - "%d.%d Decoding pucch2 for %d symbols, %d PRB, nb_harq %d, nb_sr %d, nb_csi %d/%d, pucch2_lev %d dB (scaling %d), n0+thres %d decoderState %d\n", + "%d.%d Decoding pucch2 for %d symbols, %d PRB, nb_harq %d, nb_sr %d, nb_csi %d/%d, pucch2_lev %d dB (scaling %d)\n", frame, slot, pucch_pdu->nr_of_symbols, @@ -1113,9 +1111,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, pucch_pdu->bit_len_csi_part1, pucch_pdu->bit_len_csi_part2, pucch2_levdB, - scaling, - gNB->measurements.n0_subband_power_avg_dB+(gNB->pucch0_thres/10), - decoderState); + scaling); int nc_group_size=1; // 2 PRB int ngroup = prb_size_ext/nc_group_size/2; @@ -1370,7 +1366,11 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, uint64_t decodedPayload[2]; uint8_t corr_dB; - if (nb_bit < 12) { // short blocklength case + int decoderState = 2; + if (pucch2_levdB < gNB->measurements.n0_subband_power_avg_dB + (gNB->pucch0_thres / 10)) + decoderState = 1; // assuming missed detection, only attempt to decode for polar case (with CRC) + LOG_D(PHY, "n0+thres %d decoderState %d\n", gNB->measurements.n0_subband_power_avg_dB + (gNB->pucch0_thres / 10), decoderState); + if (nb_bit < 12 && decoderState == 2) { // short blocklength case simde__m256i *rp_re[Prx2][2]; simde__m256i *rp2_re[Prx2][2]; simde__m256i *rp_im[Prx2][2]; @@ -1386,8 +1386,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, simde__m256i prod_re[Prx2],prod_im[Prx2]; uint64_t corr=0; int cw_ML=0; - - + for (int cw=0;cw<1<= 12) { // polar coded case simde__m64 *rp_re[Prx2][2]; simde__m64 *rp2_re[Prx2][2]; simde__m64 *rp_im[Prx2][2]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 189f74a0ab..facef09b52 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1119,6 +1119,7 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, } /* phy-test has hardcoded allocation, so no use to handle CSI reports */ if ((uci_234->pduBitmap >> 2) & 0x01 && !get_softmodem_params()->phy_test) { + LOG_D(NR_MAC, "CSI CRC %d\n", uci_234->csi_part1.csi_part1_crc); if (uci_234->csi_part1.csi_part1_crc != 1) { // API to parse the csi report and store it into sched_ctrl extract_pucch_csi_report(csi_MeasConfig, uci_234, frame, slot, UE, nrmac->common_channels->ServingCellConfigCommon); From 03b24c1ee68af985ff7416ed69e1eaa7c8892cfb Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 18 Oct 2024 15:43:08 +0200 Subject: [PATCH 52/58] fixed signal level computation for PUCCH2 and threshold in pucchsim. Threshold allows detection with -9 dB SNR with 8 RX antennas --- openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c | 4 ++-- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 6 +++--- openair1/SIMULATION/NR_PHY/pucchsim.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index c55be480d7..42b0b0b515 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -154,7 +154,7 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB, int slot, int first_symb, int num_sy signal_energy = signal_energy_nodc(ul_ch, 12); } n0_subband_power[aarx][rb] += signal_energy; - LOG_D(PHY,"slot %d symbol %d RB %d aarx %d n0_subband_power %d\n", slot, s, rb, aarx, signal_energy); + LOG_D(NR_PHY,"slot %d symbol %d RB %d aarx %d n0_subband_power %d\n", slot, s, rb, aarx, signal_energy); } //antenna } } //rb @@ -177,7 +177,7 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB, int slot, int first_symb, int num_sy n0_subband_tot_perPRB/=frame_parms->nb_antennas_rx; measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_subband_tot_perPRB); measurements->n0_subband_power_tot_dBm[rb] = measurements->n0_subband_power_tot_dB[rb] - gNB->rx_total_gain_dB - dB_fixed(frame_parms->N_RB_UL); - LOG_D(PHY,"n0_subband_power_tot_dB[%d] => %d, over %d symbols\n",rb,measurements->n0_subband_power_tot_dB[rb],nb_symb[rb]); + LOG_D(NR_PHY,"n0_subband_power_tot_dB[%d] => %d, over %d symbols\n",rb,measurements->n0_subband_power_tot_dB[rb],nb_symb[rb]); n0_subband_tot += n0_subband_tot_perPRB; nb_rb++; } diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index cf322dfc51..084046cc38 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -1088,7 +1088,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, } } - pucch2_lev /= Prx * Prx * pucch_pdu->nr_of_symbols; + pucch2_lev /= Prx * pucch_pdu->nr_of_symbols; int pucch2_levdB = dB_fixed(pucch2_lev); int scaling = 0; if (pucch2_levdB > 72) @@ -1100,7 +1100,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, else if (pucch2_levdB > 54) scaling = 1; - LOG_D(PHY, + LOG_D(NR_PHY, "%d.%d Decoding pucch2 for %d symbols, %d PRB, nb_harq %d, nb_sr %d, nb_csi %d/%d, pucch2_lev %d dB (scaling %d)\n", frame, slot, @@ -1369,7 +1369,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, int decoderState = 2; if (pucch2_levdB < gNB->measurements.n0_subband_power_avg_dB + (gNB->pucch0_thres / 10)) decoderState = 1; // assuming missed detection, only attempt to decode for polar case (with CRC) - LOG_D(PHY, "n0+thres %d decoderState %d\n", gNB->measurements.n0_subband_power_avg_dB + (gNB->pucch0_thres / 10), decoderState); + LOG_D(NR_PHY, "n0+thres %d decoderState %d\n", gNB->measurements.n0_subband_power_avg_dB + (gNB->pucch0_thres / 10), decoderState); if (nb_bit < 12 && decoderState == 2) { // short blocklength case simde__m256i *rp_re[Prx2][2]; simde__m256i *rp2_re[Prx2][2]; diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 9817a0b2bb..359310050c 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -145,7 +145,7 @@ int main(int argc, char **argv) //unsigned char frame_type = 0; int loglvl=OAILOG_WARNING; int sr_flag = 0; - int pucch_DTX_thres = 50; + int pucch_DTX_thres = 0; cpuf = get_cpu_freq_GHz(); if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) { From d156661ce3401c5934b5f4b71b00adfc3d771923 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Fri, 18 Oct 2024 16:25:18 +0200 Subject: [PATCH 53/58] CI: decrease test SNR for nr_pucchsim with 8 antennas --- cmake_targets/autotests/test_case_list.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 5afe683055..90ec5c7f24 100755 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -330,7 +330,7 @@ -R 273 -z8 -i 1 -P 0 -b 1 -s-2 -n1000 -R 273 -z8 -i 1 -P 0 -b 2 -s-2 -n1000 -R 273 -z8 -i 1 -P 0 -b 2 -s-2 -c -n1000 - -R 273 -z8 -i 1 -P 2 -b 4 -s0 -n1000 + -R 273 -z8 -i 1 -P 2 -b 4 -s-10 -n1000 -R 273 -z8 -i 1 -P 2 -b 7 -s3 -n1000 -R 273 -z8 -i 1 -P 2 -b 11 -s6 -n1000 -R 273 -z8 -i 1 -P 2 -q8 -b 12 -s-3 -n1000 From 08972f35cb796963e1236644eec5a2e33e1e7ab5 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Fri, 18 Oct 2024 15:48:02 +0200 Subject: [PATCH 54/58] CI: lower ssPBCH_BlockPower in gNB conf for `RAN-SA-FHI72-CN5G` pipeline Tests showed that a UE connected much faster, and did not fail as often on Msg3. --- ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf b/ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf index 8c7ed99bda..b89b385ad9 100644 --- a/ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf +++ b/ci-scripts/conf_files/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf @@ -152,7 +152,7 @@ gNBs = nrofUplinkSlots = 1; nrofUplinkSymbols = 4; - ssPBCH_BlockPower = 0; + ssPBCH_BlockPower = -10; } ); From da84a7041496dc069b439dcaa27771602565d172 Mon Sep 17 00:00:00 2001 From: "V. Tuan Ngo" Date: Sat, 21 Sep 2024 20:10:45 +0800 Subject: [PATCH 55/58] Allocate and add sD to DRB NSSAI in case sD != 0xffffff --- openair2/F1AP/f1ap_cu_ue_context_management.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 78e0ba02e9..65c34a10c1 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -108,8 +108,12 @@ static void f1ap_write_drb_nssai(const nssai_t *nssai, F1AP_SNSSAI_t *asn1_nssai OCTET_STRING_fromBuf(&asn1_nssai->sST, (char *)&nssai->sst, 1); /* OPTIONAL */ - if (nssai->sd != 0xffffff) - OCTET_STRING_fromBuf(asn1_nssai->sD, (char *)&nssai->sd, 3); + if (nssai->sd != 0xffffff) { + char sd_buffer[3]; + INT24_TO_BUFFER(nssai->sd, sd_buffer); + asn1cCalloc(asn1_nssai->sD, sD); + OCTET_STRING_fromBuf(sD, sd_buffer, 3); + } } static void f1ap_write_flows_mapped(const f1ap_flows_mapped_to_drb_t *flows_mapped, F1AP_Flows_Mapped_To_DRB_List_t *asn1_flows_mapped, int n) From 44616a6a19a8d707dd03fa90f656c9a72aa03549 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Oct 2024 11:01:47 +0200 Subject: [PATCH 56/58] nr_psbchsim: fix segv by providing correct get_nrUE_params() When running, nr_psbchsim, we get this UBsan error: openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c:79:16: runtime error: member access within misaligned address 0x0ff4278c791c for type 'struct nrUE_params_t', which requires 8 byte alignment The problem is that the corresponding definition of get_nrUE_params() in psbchsim.c does not actually return the UE params, but void, so we might or might not get something that resembles valid data in nr_adjust_synch_ue.c. Fix this by including nr-uesoftmodem.h (that provides the correct declaration) and define it correctly. Due to type mismatches, also adapt downlink_frequency, uplink_frequency_offset, and openair_cfg (which might result in the same type of bugs). --- openair1/SIMULATION/NR_PHY/psbchsim.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/psbchsim.c b/openair1/SIMULATION/NR_PHY/psbchsim.c index 684ed6d783..ebec49a139 100644 --- a/openair1/SIMULATION/NR_PHY/psbchsim.c +++ b/openair1/SIMULATION/NR_PHY/psbchsim.c @@ -25,6 +25,7 @@ #include "common/utils/load_module_shlib.h" #include "PHY/MODULATION/nr_modulation.h" #include "NR_SL-SSB-TimeAllocation-r16.h" +#include "nr-uesoftmodem.h" void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req) { @@ -54,12 +55,13 @@ double cpuf; void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu, uint8_t *nb_dmrs_re_per_rb, uint16_t *number_dmrs_symbols) { } -uint64_t downlink_frequency[1][1]; -int32_t uplink_frequency_offset[1][1]; + +uint64_t downlink_frequency[MAX_NUM_CCs][4]; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; instance_t DUuniqInstance = 0; instance_t CUuniqInstance = 0; -openair0_config_t openair0_cfg[1]; +openair0_config_t openair0_cfg[MAX_CARDS]; RAN_CONTEXT_t RC; int oai_exit = 0; @@ -80,9 +82,11 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, return 0; } -void get_nrUE_params(void) +nrUE_params_t nrUE_params = {0}; + +nrUE_params_t *get_nrUE_params(void) { - return; + return &nrUE_params; } uint8_t check_if_ue_is_sl_syncsource() { From 78fc47229b2a46dca1f02d561a47e8b5a2ab1aef Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Oct 2024 11:04:22 +0200 Subject: [PATCH 57/58] psbchsim.c: add license banner --- openair1/SIMULATION/NR_PHY/psbchsim.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/openair1/SIMULATION/NR_PHY/psbchsim.c b/openair1/SIMULATION/NR_PHY/psbchsim.c index ebec49a139..3f461e8666 100644 --- a/openair1/SIMULATION/NR_PHY/psbchsim.c +++ b/openair1/SIMULATION/NR_PHY/psbchsim.c @@ -1,3 +1,23 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ #include #include From 2fe1c2f749b188fd6f9e55e437f7f83b69ca6beb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 21 Oct 2024 14:36:31 +0200 Subject: [PATCH 58/58] Correctly read NSSAI in UE Context Setup Request --- openair2/F1AP/f1ap_du_ue_context_management.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 529c478ac2..ad728d5c89 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -111,8 +111,9 @@ static void f1ap_read_drb_nssai(const F1AP_SNSSAI_t *asn1_nssai, nssai_t *nssai) { OCTET_STRING_TO_INT8(&asn1_nssai->sST, nssai->sst); nssai->sd = 0xffffff; - if (asn1_nssai->sD != NULL) - memcpy((uint8_t *)&nssai->sd, asn1_nssai->sD->buf, 3); + if (asn1_nssai->sD != NULL) { + BUFFER_TO_INT24(asn1_nssai->sD->buf, nssai->sd); + } } int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, sctp_assoc_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu)