From fd8fc31a6f403f5e6ccf0cc14978322a648944f1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 8 Feb 2024 20:02:26 +0100 Subject: [PATCH 01/54] Create 5G RFsim FR2 SA test Transform the previous FR2 do-ra test to FR2 RA. Co-authored-by: Luis Pereira --- ...onf => gnb.sa.band261.u3.32prb.rfsim.conf} | 136 ++++++------------ .../container_5g_rfsim_fr2_32prb.xml | 20 +-- .../container_5g_rfsim_fr2_32prb_down.xml | 8 -- .../docker-compose.yaml | 103 +++++++++++-- 4 files changed, 148 insertions(+), 119 deletions(-) rename ci-scripts/conf_files/{gnb.band261.32prb.rfsim.phytest-dora.conf => gnb.sa.band261.u3.32prb.rfsim.conf} (70%) diff --git a/ci-scripts/conf_files/gnb.band261.32prb.rfsim.phytest-dora.conf b/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf similarity index 70% rename from ci-scripts/conf_files/gnb.band261.32prb.rfsim.phytest-dora.conf rename to ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf index 7603148fb7..d027e445ab 100644 --- a/ci-scripts/conf_files/gnb.band261.32prb.rfsim.phytest-dora.conf +++ b/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf @@ -1,41 +1,42 @@ -Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +Active_gNBs = ( "gNB-OAI"); # Asn1_verbosity, choice in: none, info, annoying Asn1_verbosity = "none"; +sa = 1; + gNBs = ( { ////////// Identification parameters: gNB_ID = 0xe00; - - cell_type = "CELL_MACRO_GNB"; - - gNB_name = "gNB-Eurecom-5GNRBox"; + gNB_name = "gNB-OAI"; // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({mcc = 208; mnc = 99; mnc_length = 2;}); + plmn_list = ({ mcc = 208; mnc = 99; mnc_length = 2; snssaiList = ({ sst = 1; }) }); + nr_cellid = 12345678L; tr_s_preference = "local_mac" ////////// Physical parameters: + sib1_tda = 15; min_rxtxtime = 6; servingCellConfigCommon = ( { #spCellConfigCommon - physCellId = 0; + physCellId = 10; # downlinkConfigCommon #frequencyInfoDL - # this is pointA + 23 PRBs@120kHz SCS (same as initial BWP) - absoluteFrequencySSB = 2071241; + # this is pointA + 16 PRBs@120kHz SCS (same as initial BWP) + absoluteFrequencySSB = 2071387; dl_frequencyBand = 261; # this is 27.900 GHz - dl_absoluteFrequencyPointA = 2070833; + dl_absoluteFrequencyPointA = 2071003; #scs-SpecificCarrierList dl_offstToCarrier = 0; # subcarrierSpacing @@ -50,7 +51,7 @@ gNBs = # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 3; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 1; initialDLBWPsearchSpaceZero = 0; #uplinkConfigCommon @@ -85,12 +86,12 @@ gNBs = powerRampingStep = 1; #ra_ReponseWindow #1,2,4,8,10,20,40,80 - ra_ResponseWindow = 7; + ra_ResponseWindow = 5; #ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR -#0=oneeighth,1=onefourth,2=half,3=one,4=two,5=four,6=eight,7=sixteen - ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 3; #oneHalf (0..15) 4,8,12,16,...60,64 - ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 7; + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15; #ra_ContentionResolutionTimer #(0..7) 8,16,24,32,40,48,56,64 ra_ContentionResolutionTimer = 7; @@ -101,8 +102,7 @@ gNBs = prach_RootSequenceIndex = 1; # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex # - msg1_SubcarrierSpacing = 3, - + msg1_SubcarrierSpacing = 3; # restrictedSetConfig # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, @@ -119,7 +119,7 @@ gNBs = # ssb_PositionsInBurs_BitmapPR # 1=short, 2=medium, 3=long ssb_PositionsInBurst_PR = 3; - ssb_PositionsInBurst_Bitmap = 0x0001000100010001L; + ssb_PositionsInBurst_Bitmap = 1; # ssb_periodicityServingCell # 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 @@ -152,7 +152,6 @@ gNBs = ); - # ------- SCTP definitions SCTP : { @@ -162,91 +161,58 @@ gNBs = }; - ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.18.99"; + ////////// AMF parameters: + amf_ip_address = ( { ipv4 = "192.168.71.132"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; } ); - ///X2 - enable_x2 = "no"; - t_reloc_prep = 1000; /* unit: millisecond */ - tx2_reloc_overall = 2000; /* unit: millisecond */ - t_dc_prep = 1000; /* unit: millisecond */ - t_dc_overall = 2000; /* unit: millisecond */ - target_enb_x2_ip_address = ( - { ipv4 = "192.168.18.199"; - ipv6 = "192:168:30::17"; - preference = "ipv4"; - } - ); - NETWORK_INTERFACES : { - - GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.18.198/24"; - GNB_INTERFACE_NAME_FOR_S1U = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1U = "192.168.18.198/24"; + GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.71.140/24"; + GNB_INTERFACE_NAME_FOR_NGU = "eth0"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.71.140/24"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 - GNB_IPV4_ADDRESS_FOR_X2C = "192.168.18.198/24"; - GNB_PORT_FOR_X2C = 36422; # Spec 36422 }; } ); -MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - pusch_TargetSNRx10 = 200; - pucch_TargetSNRx10 = 200; - } -); +MACRLCs = ({ + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + pusch_TargetSNRx10 = 200; + pucch_TargetSNRx10 = 200; +}); L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 + prach_dtx_threshold = 120; + #pucch0_dtx_threshold = 120; } ); -RUs = ( - { - local_rf = "yes" - nb_tx = 1; - nb_rx = 1; - att_tx = 0; - att_rx = 0; - bands = [7]; - sl_ahead = 12; - max_pdschReferenceSignalPower = -27; - max_rxgain = 75; - eNB_instances = [0]; - sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2"; - if_freq = 5124520000L; - clock_src = "external"; - time_src = "external"; - } -); +RUs = ({ + local_rf = "yes" + nb_tx = 1; + nb_rx = 1; + att_tx = 0; + att_rx = 0; + sl_ahead = 12; + bands = [261]; + max_pdschReferenceSignalPower = -27; + eNB_instances = [0]; +}); rfsimulator: { serveraddr = "server"; }; -THREAD_STRUCT = ( - { - #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; - #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" - worker_config = "WORKER_ENABLE"; - } -); - security = { # preferred ciphering algorithms # the first one of the list that an UE supports in chosen @@ -264,14 +230,6 @@ security = { drb_integrity = "no"; }; - log_config : - { - global_log_level ="info"; - hw_log_level ="info"; - phy_log_level ="info"; - mac_log_level ="info"; - rlc_log_level ="info"; - pdcp_log_level ="info"; - rrc_log_level ="info"; - }; - +log_config: { + global_log_level ="info"; +}; diff --git a/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml b/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml index 25ffb4b7b2..2c3625166e 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml @@ -28,7 +28,6 @@ 111111 100001 - 004000 000000 000001 020001 @@ -44,27 +43,20 @@ oai-gnb-asan oai-nr-ue-asan - - Custom_Command - Clean-Up any residual volume - localhost - docker volume rm 5g_rfsimulator_fr2_32prb_rrc.config - - DeployGenObject Deploy OAI gNB yaml_files/5g_rfsimulator_fr2_32prb - oai-gnb - 1 + mysql oai-amf oai-smf oai-upf oai-ext-dn + 5 DeployGenObject Deploy OAI NR-UE yaml_files/5g_rfsimulator_fr2_32prb - oai-nr-ue - 2 + oai-gnb oai-nr-ue + 7 @@ -87,8 +79,8 @@ UndeployGenObject Undeploy all OAI 5G stack yaml_files/5g_rfsimulator_fr2_32prb - 0,0,0,0 - 0,0,0,0 + 10,0,0,0 + 10,0,0,0 diff --git a/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb_down.xml b/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb_down.xml index efd7340b41..6dd65eaa85 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb_down.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb_down.xml @@ -26,7 +26,6 @@ trash 100002 - 004000 222222 @@ -37,13 +36,6 @@ yaml_files/5g_rfsimulator_fr2_32prb - - Custom_Command - Clean-Up any residual volume - localhost - docker volume rm 5g_rfsimulator_fr2_32prb_rrc.config - - Clean_Test_Server_Images Clean Test Images on Test Server diff --git a/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml index 145122d97e..c04680ad58 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml @@ -1,18 +1,99 @@ version: '3.8' services: + mysql: + container_name: "rfsim5g-mysql" + image: mysql:8.0 + volumes: + - ../5g_rfsimulator/oai_db.sql:/docker-entrypoint-initdb.d/oai_db.sql + - ../5g_rfsimulator/mysql-healthcheck.sh:/tmp/mysql-healthcheck.sh + environment: + - TZ=Europe/Paris + - MYSQL_DATABASE=oai_db + - MYSQL_USER=test + - MYSQL_PASSWORD=test + - MYSQL_ROOT_PASSWORD=linux + healthcheck: + test: /bin/bash -c "/tmp/mysql-healthcheck.sh" + interval: 10s + timeout: 5s + retries: 30 + networks: + public_net: + ipv4_address: 192.168.71.131 + oai-amf: + container_name: "rfsim5g-oai-amf" + image: oaisoftwarealliance/oai-amf:v2.0.0 + environment: + - TZ=Europe/paris + volumes: + - ../5g_rfsimulator/mini_nonrf_config.yaml:/openair-amf/etc/config.yaml + depends_on: + - mysql + networks: + public_net: + ipv4_address: 192.168.71.132 + oai-smf: + container_name: "rfsim5g-oai-smf" + image: oaisoftwarealliance/oai-smf:v2.0.0 + environment: + - TZ=Europe/Paris + volumes: + - ../5g_rfsimulator/mini_nonrf_config.yaml:/openair-smf/etc/config.yaml + depends_on: + - oai-amf + networks: + public_net: + ipv4_address: 192.168.71.133 + oai-upf: + container_name: "rfsim5g-oai-upf" + image: oaisoftwarealliance/oai-upf:v2.0.0 + environment: + - TZ=Europe/Paris + volumes: + - ../5g_rfsimulator/mini_nonrf_config.yaml:/openair-upf/etc/config.yaml + depends_on: + - oai-smf + cap_add: + - NET_ADMIN + - SYS_ADMIN + cap_drop: + - ALL + privileged: true + networks: + public_net: + ipv4_address: 192.168.71.134 + traffic_net: + ipv4_address: 192.168.72.134 + oai-ext-dn: + privileged: true + container_name: rfsim5g-oai-ext-dn + image: oaisoftwarealliance/trf-gen-cn5g:focal + entrypoint: /bin/bash -c \ + "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;"\ + "ip route add 12.1.1.0/24 via 192.168.72.134 dev eth0; sleep infinity" + depends_on: + - oai-upf + networks: + traffic_net: + ipv4_address: 192.168.72.135 + healthcheck: + test: /bin/bash -c "ping -c 2 192.168.72.134" + interval: 10s + timeout: 5s + retries: 5 + oai-gnb: image: oaisoftwarealliance/oai-gnb:develop privileged: true container_name: rfsim5g-oai-gnb environment: - USE_ADDITIONAL_OPTIONS: --do-ra --rfsim --rfsimulator.wait_timeout 20 --noS1 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --sa --rfsim --log_config.global_log_options level,nocolor,time ASAN_OPTIONS: detect_leaks=0 networks: public_net: ipv4_address: 192.168.71.140 volumes: - - ../../conf_files/gnb.band261.32prb.rfsim.phytest-dora.conf:/opt/oai-gnb/etc/gnb.conf - - rrc.config:/opt/oai-gnb/ + - ../../conf_files/gnb.sa.band261.u3.32prb.rfsim.conf:/opt/oai-gnb/etc/gnb.conf healthcheck: test: /bin/bash -c "pgrep nr-softmodem" interval: 10s @@ -24,11 +105,12 @@ services: privileged: true container_name: rfsim5g-oai-nr-ue environment: - USE_ADDITIONAL_OPTIONS: --do-ra --rfsim --noS1 --reconfig-file etc/rrc/reconfig.raw --rbconfig-file etc/rrc/rbconfig.raw --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + USE_ADDITIONAL_OPTIONS: --sa --rfsim + --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time + -r 32 --numerology 3 --band 261 -C 27533280000 --ssb 72 ASAN_OPTIONS: detect_leaks=0 volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf - - rrc.config:/opt/oai-nr-ue/etc/rrc/ depends_on: - oai-gnb networks: @@ -40,9 +122,6 @@ services: timeout: 5s retries: 5 -volumes: - rrc.config: - networks: public_net: driver: bridge @@ -52,3 +131,11 @@ networks: - subnet: 192.168.71.128/26 driver_opts: com.docker.network.bridge.name: "rfsim5g-public" + traffic_net: + driver: bridge + name: rfsim5g-oai-traffic-net + ipam: + config: + - subnet: 192.168.72.128/26 + driver_opts: + com.docker.network.bridge.name: "rfsim5g-traffic" From 9f315932d06984e354494d562051b5a8806c07bd Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 9 Feb 2024 11:16:49 +0000 Subject: [PATCH 02/54] Fix CI runtime errors Fix for CI runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Fix for CI runtime error: left shift of 128 by 24 places cannot be represented in type 'int' --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 2c8935f007..a85d5199c3 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -602,7 +602,7 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { rb2 = rb + pucch_pdu->bwp_start + ((symbol < pucch_pdu->start_symbol_index+(pucch_pdu->nr_of_symbols>>1)) || (pucch_pdu->freq_hop_flag == 0) ? pucch_pdu->prb_start : pucch_pdu->second_hop_prb); - gNB->rb_mask_ul[symbol][rb2>>5] |= (1<<(rb2&31)); + gNB->rb_mask_ul[symbol][rb2>>5] |= (((uint32_t)1)<<(rb2&31)); } } } diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 4662a7eab6..c745752159 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -183,7 +183,7 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, else{ for (int i=0; i<8; i++){ if ((scc->ssb_PositionsInBurst.groupPresence->buf[0]>>(7-i))&0x01) - cfg->ssb_table.ssb_mask_list[i>>2].ssb_mask |= scc->ssb_PositionsInBurst.inOneGroup.buf[0]<<(24-8*(i%4)); + cfg->ssb_table.ssb_mask_list[i>>2].ssb_mask |= ((uint32_t)scc->ssb_PositionsInBurst.inOneGroup.buf[0])<<(24-8*(i%4)); } } From be36b2f9bc075c5ff97abc788e194011b788f8c5 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 9 Feb 2024 15:28:25 +0000 Subject: [PATCH 03/54] Fix CI 5G RFsim FR2 SA ping test --- .../xml_files/container_5g_rfsim_fr2_32prb.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml b/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml index 2c3625166e..e6127a766e 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml @@ -22,7 +22,7 @@ --> rfsim-fr2-32prb-5gnr-tdd - Monolithic FR2 do-ra gNB + Monolithic FR2 gNB wrench 1 @@ -61,17 +61,17 @@ Ping - Ping gNB from NR-UE + Ping ext-dn from NR-UE rfsim5g_ue - -c20 -i0.2 10.0.1.1 + -c 20 -i0.2 192.168.72.135 0 Ping - Ping NR-UE from gNB - rfsim5g_gnb_nos1 - -c20 -i0.2 10.0.1.2 + Ping NR-UE from ext-dn + rfsim5g_ext_dn + -c 20 12.1.1.2 -i0.2 0 From c78399ee369619d00dae6318f50cd1019afd6727 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 9 Feb 2024 10:21:24 +0000 Subject: [PATCH 04/54] Update 5G RFsim FR2 SA test to have kSSB different from 0 Enable CI to test kSSB with a value different from 0 for FR2 to prevent regressions on future updates related with kSSB --- ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf | 2 +- .../yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf b/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf index d027e445ab..387bd959ad 100644 --- a/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf +++ b/ci-scripts/conf_files/gnb.sa.band261.u3.32prb.rfsim.conf @@ -36,7 +36,7 @@ gNBs = absoluteFrequencySSB = 2071387; dl_frequencyBand = 261; # this is 27.900 GHz - dl_absoluteFrequencyPointA = 2071003; + dl_absoluteFrequencyPointA = 2071001; #scs-SpecificCarrierList dl_offstToCarrier = 0; # subcarrierSpacing diff --git a/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml b/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml index c04680ad58..0311882efe 100644 --- a/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml +++ b/ci-scripts/yaml_files/5g_rfsimulator_fr2_32prb/docker-compose.yaml @@ -107,7 +107,7 @@ services: environment: USE_ADDITIONAL_OPTIONS: --sa --rfsim --rfsimulator.serveraddr 192.168.71.140 --log_config.global_log_options level,nocolor,time - -r 32 --numerology 3 --band 261 -C 27533280000 --ssb 72 + -r 32 --numerology 3 --band 261 -C 27533160000 --ssb 73 ASAN_OPTIONS: detect_leaks=0 volumes: - ../../conf_files/nrue.uicc.conf:/opt/oai-nr-ue/etc/nr-ue.conf From 3d8b38f7e634d1d8146c0f4523abc7ded9df8d59 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 9 Feb 2024 09:13:53 +0000 Subject: [PATCH 05/54] Fix FR2 SSB start subcarrier and SSB frequency at gNB for FR2 offsetToPointA is expressed in terms of 60 kHz SCS and k_SSB expressed in terms of the subcarrier spacing provided by the higher-layer parameter subCarrierSpacingCommon --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 22 +++++++++++++++++----- openair2/RRC/NR/rrc_gNB.c | 16 ++++++++-------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index a85d5199c3..cfbd8d9c12 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -70,13 +70,25 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_ int ssb_start_symbol_abs = nr_get_ssb_start_symbol(fp,ssb_index); // computing the starting symbol for current ssb ssb_start_symbol = ssb_start_symbol_abs % fp->symbols_per_slot; // start symbol wrt slot - // setting the first subcarrier + // Setting the first subcarrier + // 3GPP TS 38.211 sections 7.4.3.1 and 4.4.4.2 + // for FR1 offsetToPointA and k_SSB are expressed in terms of 15 kHz SCS + // for FR2 offsetToPointA is expressed in terms of 60 kHz SCS and k_SSB expressed in terms of the subcarrier spacing provided + // by the higher-layer parameter subCarrierSpacingCommon const int scs = cfg->ssb_config.scs_common.value; - const int prb_offset = (fp->freq_range == nr_FR1) ? ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA>>scs : ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA>>(scs-2); - const int sc_offset = (fp->freq_range == nr_FR1) ? ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset >> scs - : ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset >> (scs - 2); + const int prb_offset = (fp->freq_range == nr_FR1) ? ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA >> scs + : ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA >> (scs - 2); + const int sc_offset = + (fp->freq_range == nr_FR1) ? ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset >> scs : ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset; fp->ssb_start_subcarrier = (12 * prb_offset + sc_offset); - LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier, prb_offset, sc_offset); + LOG_D(PHY, + "ssbOffsetPointA %d SSB SsbSubcarrierOffset %d prb_offset %d sc_offset %d scs %d ssb_start_subcarrier %d\n", + ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA, + ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset, + prb_offset, + sc_offset, + scs, + fp->ssb_start_subcarrier); LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); nr_generate_pss(&txdataF[0][txdataF_offset], gNB->TX_AMP, ssb_start_symbol, cfg, fp); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 660a427d30..ec01355291 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -197,21 +197,21 @@ static int get_ssb_arfcn(const f1ap_served_cell_info_t *cell_info, const NR_MIB_ uint32_t dl_arfcn = get_dl_arfcn(cell_info); int scs = get_ssb_scs(cell_info); int band = get_dl_band(cell_info); + uint64_t freqpointa = from_nrarfcn(band, scs, dl_arfcn); + uint64_t freqssb = 0; + // 3GPP TS 38.211 sections 7.4.3.1 and 4.4.4.2 + // for FR1 offsetToPointA and k_SSB are expressed in terms of 15 kHz SCS + // for FR2 offsetToPointA is expressed in terms of 60 kHz SCS and k_SSB expressed in terms of the subcarrier spacing provided + // by the higher-layer parameter subCarrierSpacingCommon // FR1 includes frequency bands from 410 MHz (ARFCN 82000) to 7125 MHz (ARFCN 875000) // FR2 includes frequency bands from 24.25 GHz (ARFCN 2016667) to 71.0 GHz (ARFCN 2795832) - uint64_t scaling = 0; if (dl_arfcn >= 82000 && dl_arfcn < 875000) - scaling = 1; + freqssb = freqpointa + 15000 * (offsetToPointA * 12 + kssb) + 10ll * 12 * (1 << scs) * 15000; else if (dl_arfcn >= 2016667 && dl_arfcn < 2795832) - scaling = 4; + freqssb = freqpointa + 60000 * offsetToPointA * 12 + (1 << scs) * 15000 * (kssb + 10ll * 12); else AssertFatal(false, "Invalid absoluteFrequencyPointA: %d\n", dl_arfcn); - - uint64_t freqpointa = from_nrarfcn(band, scs, dl_arfcn); - // offsetToPointA and kSSB are both on 15kHz SCS for FR1 and 60kHz SCS for FR2 (see 38.211 sections 7.4.3.1 and 4.4.4.2) - // SSB uses the SCS of the cell and is 20 RBs wide, so use 10 - uint64_t freqssb = freqpointa + scaling * 15000 * (offsetToPointA * 12 + kssb) + 10ll * 12 * (1 << scs) * 15000; int bw_index = get_supported_band_index(scs, band, get_dl_bw(cell_info)); int band_size_hz = get_supported_bw_mhz(band > 256 ? FR2 : FR1, bw_index) * 1000 * 1000; uint32_t ssb_arfcn = to_nrarfcn(band, freqssb, scs, band_size_hz); From ff7c960b2cd347fdcbd467d3a00679520c7b8acd Mon Sep 17 00:00:00 2001 From: Nuno Domingues Date: Fri, 16 Feb 2024 17:42:01 +0000 Subject: [PATCH 06/54] Harmonize computation of RA-RNTI --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 16 +++++++++++++++ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 ++ openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 -- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 20 ------------------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 5 ++++- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 10 +--------- 6 files changed, 23 insertions(+), 32 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index d4d396199a..b2db504796 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -5325,3 +5325,19 @@ uint16_t compute_PDU_length(uint32_t num_TLV, uint16_t total_length) pdu_length += (num_TLV * 4) + total_length; return pdu_length; } + +// RA-RNTI computation (associated to PRACH occasion in which the RA Preamble is transmitted) +// - this does not apply to contention-free RA Preamble for beam failure recovery request +// - getting star_symb, SFN_nbr from table 6.3.3.2-3 (TDD and FR1 scenario) +// - s_id is starting symbol of the PRACH occasion [0...14] +// - t_id is the first slot of the PRACH occasion in a system frame [0...80] +// - f_id: index of the PRACH occasion in the frequency domain +// - ul_carrier_id: UL carrier used for RA preamble transmission, hardcoded for NUL carrier +rnti_t nr_get_ra_rnti(uint8_t s_id, uint8_t t_id, uint8_t f_id, uint8_t ul_carrier_id) +{ + // 3GPP TS 38.321 Section 5.1.3 + rnti_t ra_rnti = 1 + s_id + 14 * t_id + 1120 * f_id + 8960 * ul_carrier_id; + LOG_D(MAC, "f_id %d t_id %d s_id %d ul_carrier_id %d Computed RA_RNTI is 0x%04X\n", f_id, t_id, s_id, ul_carrier_id, ra_rnti); + + return ra_rnti; +} diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 27373c02d7..820cbfceeb 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -322,4 +322,6 @@ uint16_t nr_get_csi_bitlen(nr_csi_report_t *csi_report_template, uint8_t csi_rep uint16_t compute_PDU_length(uint32_t num_TLV, uint16_t total_length); +rnti_t nr_get_ra_rnti(uint8_t s_id, uint8_t t_id, uint8_t f_id, uint8_t ul_carrier_id); + #endif diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 512c6eb483..6a0b02a144 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -456,8 +456,6 @@ void init_RA(NR_UE_MAC_INST_t *mac, int16_t get_prach_tx_power(NR_UE_MAC_INST_t *mac); -void set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu); - void nr_Msg1_transmitted(NR_UE_MAC_INST_t *mac); void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id); void nr_get_msg3_payload(NR_UE_MAC_INST_t *mac, uint8_t *buf, int TBS_max); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index fa4e07ca5e..6882665cba 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -504,26 +504,6 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t } } -// RA-RNTI computation (associated to PRACH occasion in which the RA Preamble is transmitted) -// - this does not apply to contention-free RA Preamble for beam failure recovery request -// - getting star_symb, SFN_nbr from table 6.3.3.2-3 (TDD and FR1 scenario) -// - ul_carrier_id: UL carrier used for RA preamble transmission, hardcoded for NUL carrier -// - f_id: index of the PRACH occasion in the frequency domain -// - s_id is starting symbol of the PRACH occasion [0...14] -// - t_id is the first slot of the PRACH occasion in a system frame [0...80] -void set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu){ - - RA_config_t *ra = &mac->ra; - uint8_t ul_carrier_id = 0; // NUL - uint8_t f_id = prach_pdu->num_ra; - uint8_t t_id = prach_pdu->prach_slot; - uint8_t s_id = prach_pdu->prach_start_symbol; - - ra->ra_rnti = 1 + s_id + 14 * t_id + 1120 * f_id + 8960 * ul_carrier_id; - - LOG_D(MAC, "Computed ra_RNTI is %x \n", ra->ra_rnti); -} - // This routine implements Section 5.1.2 (UE Random Access Resource Selection) // and Section 5.1.3 (Random Access Preamble Transmission) from 3GPP TS 38.321 // - currently the PRACH preamble is set through RRC configuration for 4-step CFRA mode diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index d135225c1e..c69ffbe5a7 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2607,7 +2607,10 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_fra nr_get_prach_resources(mac, 0, 0, &ra->prach_resources, ra->rach_ConfigDedicated); pdu->prach_config_pdu.ra_PreambleIndex = ra->ra_PreambleIndex; pdu->prach_config_pdu.prach_tx_power = get_prach_tx_power(mac); - set_ra_rnti(mac, &pdu->prach_config_pdu); + mac->ra.ra_rnti = nr_get_ra_rnti(pdu->prach_config_pdu.prach_start_symbol, + pdu->prach_config_pdu.prach_slot, + pdu->prach_config_pdu.num_ra, + 0); release_ul_config(pdu, false); nr_scheduled_response_t scheduled_response = {.ul_config = mac->ul_config_request + slotP, .mac = mac, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index d655fa666b..bac4c0ce64 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -587,15 +587,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, continue; } - uint16_t ra_rnti; - - // ra_rnti from 5.1.3 in 38.321 - // FK: in case of long PRACH the phone seems to expect the subframe number instead of the slot number here. - if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present - == NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839) - ra_rnti = 1 + symbol + (9 /*slotP*/ * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); - else - ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); + rnti_t ra_rnti = nr_get_ra_rnti(symbol, slotP, freq_index, ul_carrier_id); // Configure RA BWP configure_UE_BWP(nr_mac, scc, NULL, ra, NULL, -1, -1); From 563109a88f4fb3fb35ffb1a2eaaf3c4fc766c8fb Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Tue, 20 Feb 2024 15:06:59 +0100 Subject: [PATCH 07/54] Cleanup of unused and outdated legacy RFSIM code - deleted: ../../../executables/rfsim.c - removed unused command line options to set SINR and SNR - removed unused functions to get SINR and SNR - removed unused RFSIM struct members --- executables/lte-softmodem.h | 3 - executables/nr-softmodem.c | 1 - executables/nr-softmodem.h | 1 - executables/rfsim.c | 495 --------------------- openair1/PHY/TOOLS/calibration_test.c | 1 - openair1/PHY/defs_L1_NB_IoT.h | 6 - openair1/PHY/defs_UE.h | 4 - openair1/PHY/defs_eNB.h | 4 - openair1/PHY/defs_nr_UE.h | 4 - openair1/SIMULATION/TOOLS/random_channel.c | 10 - openair1/SIMULATION/TOOLS/sim.h | 9 - radio/rfsimulator/simulator.c | 11 - 12 files changed, 549 deletions(-) delete mode 100644 executables/rfsim.c diff --git a/executables/lte-softmodem.h b/executables/lte-softmodem.h index 4143bce3a4..13d9ba1319 100644 --- a/executables/lte-softmodem.h +++ b/executables/lte-softmodem.h @@ -179,9 +179,6 @@ extern void init_UE(int nb_inst, extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char *name); -extern void init_ocm(void); -extern void init_ue_devices(PHY_VARS_UE *); - PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); void init_eNB_afterRU(void); diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 6192dacb86..eaf017e297 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -118,7 +118,6 @@ unsigned char NB_gNB_INST = 1; char *uecap_file; runmode_t mode = normal_txrx; -static double snr_dB=20; #if MAX_NUM_CCs == 1 rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}}; diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index cc76e9e375..ea02e305e8 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -30,7 +30,6 @@ {"U" , CONFIG_HLP_ULBM_PHYTEST, 0, .u64ptr=&ulsch_slot_bitmap, .defintval=0, TYPE_UINT64, 0}, \ {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, .iptr=&usrp_tx_thread, .defstrval=0, TYPE_INT, 0}, \ {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, .strptr=&uecap_file, .defstrval="./uecap_ports1.xml", TYPE_STRING, 0}, \ - {"s" , CONFIG_HLP_SNR, 0, .dblptr=&snr_dB, .defdblval=25, TYPE_DOUBLE, 0}, \ } // clang-format on diff --git a/executables/rfsim.c b/executables/rfsim.c deleted file mode 100644 index c7ab4ccb66..0000000000 --- a/executables/rfsim.c +++ /dev/null @@ -1,495 +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 rfsim.c -* \brief function for simulated RF device -* \author R. Knopp -* \date 2018 -* \version 1.0 -* \company Eurecom -* \email: openair_tech@eurecom.fr -* \note -* \warning -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "assertions.h" -#include "rfsim.h" -#include "openair1/SIMULATION/TOOLS/sim.h" -#include "enb_config.h" -#include "enb_paramdef.h" -#include "common/platform_constants.h" -#include "common/config/config_paramdesc.h" -#include "common/config/config_userapi.h" -#include "common/ran_context.h" -#include "PHY/defs_UE.h" -#include "PHY/defs_eNB.h" -#include "PHY/defs_RU.h" -#include "common/utils/LOG/vcd_signal_dumper.h" - -RAN_CONTEXT_t RC; -extern PHY_VARS_UE ***PHY_vars_UE_g; - - -// put all of these in a common structure after -sim_t sim; - - -void init_ru_devices(void); - -void init_RU(char *,int send_dmrssync); - -void *rfsim_top(void *n_frames); - -void wait_RUs(void) { - int i; - // wait for all RUs to be configured over fronthaul - pthread_mutex_lock(&RC.ru_mutex); - - while (RC.ru_mask>0) { - pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); - } - - pthread_mutex_unlock(&RC.ru_mutex); - - // copy frame parameters from RU to UEs - for (i=0; iframe_parms->samples_per_tti + RC.ru[0]->frame_parms->ofdm_symbol_size + RC.ru[0]->frame_parms->nb_prefix_samples0; - } - - for (int ru_id=0; ru_idframe_parms->samples_per_tti; - - printf("RUs are ready, let's go\n"); -} - -void wait_eNBs(void) { - return; -} - - -void RCConfig_sim(void) { - paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; - // Get num RU instances - config_getlist( &RUParamList,NULL,0, NULL); - RC.nb_RU = RUParamList.numelt; - AssertFatal(RC.nb_RU>0,"we need at least 1 RU for simulation\n"); - printf("returned with %d rus\n",RC.nb_RU); - init_RU(NULL,0); - printf("Waiting for RUs to get set up\n"); - wait_RUs(); - init_ru_devices(); - static int nframes = 100000; - AssertFatal(0 == pthread_create(&sim.rfsim_thread, - NULL, - rfsim_top, - (void *)&nframes), ""); -} - - - -int ru_trx_start(openair0_device *device) { - return(0); -} - -void ru_trx_end(openair0_device *device) { - return; -} - -int ru_trx_stop(openair0_device *device) { - return(0); -} -int UE_trx_start(openair0_device *device) { - return(0); -} -void UE_trx_end(openair0_device *device) { - return; -} -int UE_trx_stop(openair0_device *device) { - return(0); -} -int ru_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) { - return(0); -} -int ru_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) { - return(0); -} -int UE_trx_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dummy) { - return(0); -} -int UE_trx_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) { - return(0); -} - -extern pthread_mutex_t subframe_mutex; -extern int subframe_ru_mask,subframe_UE_mask; - - -int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { - int ru_id = device->Mod_id; - int CC_id = device->CC_id; - int subframe; - int sample_count=0; - *ptimestamp = sim.last_ru_rx_timestamp[ru_id][CC_id]; - LOG_D(SIM,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, - (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id], - (unsigned long long)sim.last_ru_rx_timestamp[ru_id][CC_id], - (int)((*ptimestamp/RC.ru[ru_id]->frame_parms->samples_per_tti)%10)); - - // if we're at a subframe boundary generate UL signals for this ru - - while (sample_countframe_parms->samples_per_tti)%10; - - if (subframe_select(RC.ru[ru_id]->frame_parms,subframe) != SF_DL || RC.ru[ru_id]->frame_parms->frame_type == FDD) { - LOG_D(SIM,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", - subframe,(unsigned long long)*ptimestamp, - (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id]); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,1); - do_UL_sig(&sim, - subframe, - 0, // abstraction_flag - RC.ru[ru_id]->frame_parms, - 0, // frame is only used for abstraction - ru_id, - CC_id, - 1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,0); - } - - sim.last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms->samples_per_tti; - sample_count += RC.ru[ru_id]->frame_parms->samples_per_tti; - } - - return(nsamps); -} - -int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_UE_TRX_READ,1); - int UE_id = device->Mod_id; - int CC_id = device->CC_id; - int subframe; - int sample_count=0; - int read_size; - int sptti = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti; - *ptimestamp = sim.last_UE_rx_timestamp[UE_id][CC_id]; - LOG_D(PHY,"UE %d DL simulation 0: UE_trx_read nsamps %d TS %llu (%llu, offset %d) antenna %d\n", - UE_id, - nsamps, - (unsigned long long)sim.current_UE_rx_timestamp[UE_id][CC_id], - (unsigned long long)sim.last_UE_rx_timestamp[UE_id][CC_id], - (int)(sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti), - cc); - - if (nsamps < sptti) - read_size = nsamps; - else - read_size = sptti; - - while (sample_countframe_parms, - UE_id, - CC_id); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_DL_SIGNAL,0); - LOG_D(PHY,"UE %d: DL simulation 6: UE_trx_read @ TS %"PRIi64" (%"PRIi64")=> frame %d, subframe %d\n", - UE_id, sim.current_UE_rx_timestamp[UE_id][CC_id], - sim.last_UE_rx_timestamp[UE_id][CC_id], - (int)((sim.last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023), - subframe); - sim.last_UE_rx_timestamp[UE_id][CC_id] += read_size; - sample_count += read_size; - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_UE_TRX_READ,0); - return(nsamps); -} - - -int ru_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - int ru_id = device->Mod_id; - LTE_DL_FRAME_PARMS *frame_parms = RC.ru[ru_id]->frame_parms; - pthread_mutex_lock(&sim.subframe_mutex); - LOG_D(SIM,"[TXPATH] ru_trx_write: RU %d mask %d\n",ru_id,sim.subframe_ru_mask); - pthread_mutex_unlock(&sim.subframe_mutex); - // compute amplitude of TX signal from first symbol in subframe - // note: assumes that the packet is an entire subframe - sim.ru_amp[ru_id] = 0; - - for (int aa=0; aanb_tx; aa++) { - sim.ru_amp[ru_id] += (double)signal_energy((int32_t *)buff[aa],frame_parms->ofdm_symbol_size)/(12*frame_parms->N_RB_DL); - } - - sim.ru_amp[ru_id] = sqrt(sim.ru_amp[ru_id]); - LOG_D(PHY,"Setting amp for RU %d to %f (%d)\n",ru_id,sim.ru_amp[ru_id], dB_fixed((double)signal_energy((int32_t *)buff[0],frame_parms->ofdm_symbol_size))); - // tell top-level we are done - pthread_mutex_lock(&sim.subframe_mutex); - sim.subframe_ru_mask|=(1<rfdevice.Mod_id = ru_id; - ru->rfdevice.CC_id = 0; - ru->rfdevice.trx_start_func = ru_trx_start; - ru->rfdevice.trx_read_func = ru_trx_read; - ru->rfdevice.trx_write_func = ru_trx_write; - ru->rfdevice.trx_end_func = ru_trx_end; - ru->rfdevice.trx_stop_func = ru_trx_stop; - ru->rfdevice.trx_set_freq_func = ru_trx_set_freq; - ru->rfdevice.trx_set_gains_func = ru_trx_set_gains; - sim.last_ru_rx_timestamp[ru_id][0] = 0; - } -} - -void init_ue_devices(PHY_VARS_UE *UE) { - AssertFatal(UE!=NULL,"UE context is not allocated\n"); - printf("Initializing UE %d.%d\n",UE->Mod_id,UE->CC_id); - UE->rfdevice.Mod_id = UE->Mod_id; - UE->rfdevice.CC_id = UE->CC_id; - UE->rfdevice.trx_start_func = UE_trx_start; - UE->rfdevice.trx_read_func = UE_trx_read; - UE->rfdevice.trx_write_func = UE_trx_write; - UE->rfdevice.trx_end_func = UE_trx_end; - UE->rfdevice.trx_stop_func = UE_trx_stop; - UE->rfdevice.trx_set_freq_func = UE_trx_set_freq; - UE->rfdevice.trx_set_gains_func = UE_trx_set_gains; - sim.last_UE_rx_timestamp[UE->Mod_id][UE->CC_id] = 0; -} - -void init_ocm(void) { - module_id_t UE_id, ru_id; - int CC_id; - double DS_TDL = .03; - randominit(0); - set_taus_seed(0); - init_channelmod(); - double snr_dB = channelmod_get_snr_dB(); - double sinr_dB = channelmod_get_sinr_dB(); - init_channel_vars ();//fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); - // initialize channel descriptors - LOG_I(PHY,"Initializing channel descriptors (nb_RU %d, nb_UE %d)\n",RC.nb_RU,NB_UE_INST); - - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - for (CC_id=0; CC_idframe_parms->N_RB_DL); - sim.RU2UE[ru_id][UE_id][CC_id] = - new_channel_desc_scm(RC.ru[ru_id]->nb_tx, - PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL), - DS_TDL, - CORR_LEVEL_LOW, - 0.0, - 0, - 0, - 0); - random_channel(sim.RU2UE[ru_id][UE_id][CC_id],0); - LOG_D(OCM,"[SIM] Initializing channel (%s) from UE %d to ru %d\n", "AWGN", UE_id, ru_id); - - sim.UE2RU[UE_id][ru_id][CC_id] = - new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, - RC.ru[ru_id]->nb_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL), - DS_TDL, - CORR_LEVEL_LOW, - 0.0, - 0, - 0, - 0); - random_channel(sim.UE2RU[UE_id][ru_id][CC_id],0); - // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed. - //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id]; - AssertFatal(sim.RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); - AssertFatal(sim.UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id); - - //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE - if (ru_id == (UE_id % RC.nb_RU)) { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } else { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } - - LOG_I(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower, - snr_dB); - } - } - } -} - - -void update_ocm(double snr_dB,double sinr_dB) { - module_id_t UE_id, ru_id; - int CC_id; - - for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - for (CC_id=0; CC_idpath_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } else { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } - - LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower, - snr_dB); - } - } - } -} - - -void init_channel_vars(void) { - int i; - memset(sim.RU_output_mask,0,sizeof(int)*NUMBER_OF_UE_MAX); - - for (i=0; iframe_parms,(sf+4)%10)!=SF_UL) ? sim.subframe_ru_mask : ((1<frame_parms->frame_type == FDD || subframe_select(RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? sim.subframe_UE_mask : ((1<frame_parms->samples_per_tti; - LOG_D(SIM,"RU %d/%d: TS %"PRIi64"\n",ru_id,CC_id,sim.current_ru_rx_timestamp[ru_id][CC_id]); - } - - for (int UE_inst = 0; UE_instframe_parms.samples_per_tti; - LOG_D(SIM,"UE %d/%d: TS %"PRIi64"\n",UE_inst,CC_id,sim.current_UE_rx_timestamp[UE_inst][CC_id]); - } - - if (oai_exit == 1) return((void *)NULL); - } - } - - return((void *)NULL); -} diff --git a/openair1/PHY/TOOLS/calibration_test.c b/openair1/PHY/TOOLS/calibration_test.c index 0c5f40cffd..46ab22e19a 100644 --- a/openair1/PHY/TOOLS/calibration_test.c +++ b/openair1/PHY/TOOLS/calibration_test.c @@ -14,7 +14,6 @@ int8_t threequarter_fs; uint64_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int opp_enabled; -static double snr_dB=20; THREAD_STRUCT thread_struct; uint32_t target_ul_mcs = 9; uint32_t target_dl_mcs = 9; diff --git a/openair1/PHY/defs_L1_NB_IoT.h b/openair1/PHY/defs_L1_NB_IoT.h index 01143ccf47..f44e62abc2 100644 --- a/openair1/PHY/defs_L1_NB_IoT.h +++ b/openair1/PHY/defs_L1_NB_IoT.h @@ -551,9 +551,6 @@ typedef struct PHY_VARS_eNB_NB_IoT_s { int max_eNB_id, max_sync_pos; /// int N_TA_offset; ///timing offset used in TDD - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// first index: ? [0..N_RB_DL*12[ - double *sinr_dB; /// N0 (used for abstraction) double N0; /// @@ -888,9 +885,6 @@ typedef struct { int mac_enabled; /// Flag to initialize averaging of PHY measurements int init_averaging; - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_dB; /// \brief sinr for all subcarriers of first symbol for the CQI Calculation. /// - first index: ? [0..12*N_RB_DL[ double *sinr_CQI_dB; diff --git a/openair1/PHY/defs_UE.h b/openair1/PHY/defs_UE.h index 7f1858b2c4..0f45196e2c 100644 --- a/openair1/PHY/defs_UE.h +++ b/openair1/PHY/defs_UE.h @@ -739,10 +739,6 @@ typedef struct { /// Flag to initialize averaging of PHY measurements int init_averaging; - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_dB; - /// \brief sinr for all subcarriers of first symbol for the CQI Calculation. /// - first index: ? [0..12*N_RB_DL[ double *sinr_CQI_dB; diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 45abb05c2f..1690a37aff 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -616,10 +616,6 @@ typedef struct PHY_VARS_eNB_s { uint32_t max_peak_val; int max_eNB_id, max_sync_pos; - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// first index: ? [0..N_RB_DL*12[ - double *sinr_dB; - /// N0 (used for abstraction) double N0; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 834163d8ed..bb77dac067 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -512,10 +512,6 @@ typedef struct PHY_VARS_NR_UE_s { /// Flag to initialize averaging of PHY measurements int init_averaging; - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// - first index: ? [0..12*N_RB_DL[ - double *sinr_dB; - /// sinr_effective used for CQI calulcation double sinr_eff; diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 4e28a4ce13..753302fc73 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -72,8 +72,6 @@ static telnetshell_cmddef_t channelmod_cmdarray[] = { static telnetshell_vardef_t channelmod_vardef[] = {{"", 0, 0, NULL}}; -static double snr_dB=25; -static double sinr_dB=0; static unsigned int max_chan; static channel_desc_t **defined_channels; static char *modellist_name; @@ -2261,14 +2259,6 @@ int modelid_fromstrtype(char *modeltype) { return modelid; } -double channelmod_get_snr_dB(void) { - return snr_dB; -} - -double channelmod_get_sinr_dB(void) { - return sinr_dB; -} - void init_channelmod(void) { paramdef_t channelmod_params[] = CHANNELMOD_PARAMS_DESC; int numparams = sizeofArray(channelmod_params); diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 366e9c6c6e..33c3f0f9ee 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -264,8 +264,6 @@ typedef enum { #define CHANNELMOD_HELP_MODELLIST " channel list name in config file describing the model type and its parameters\n" // clang-format off #define CHANNELMOD_PARAMS_DESC { \ - {"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, .dblptr=&snr_dB, .defdblval=25, TYPE_DOUBLE, 0}, \ - {"sinr_dB", NULL, 0, .dblptr=&sinr_dB, .defdblval=0 , TYPE_DOUBLE, 0}, \ {"max_chan", "Max number of runtime models", 0, .uptr=&max_chan, .defintval=10, TYPE_UINT, 0}, \ {CHANNELMOD_MODELLIST_PARANAME, CHANNELMOD_HELP_MODELLIST, 0, .strptr=&modellist_name, .defstrval="DefaultChannelList", TYPE_STRING, 0}, \ } @@ -302,18 +300,11 @@ typedef struct { double r_re_UL[NUMBER_OF_eNB_MAX][2][30720]; double r_im_UL[NUMBER_OF_eNB_MAX][2][30720]; int RU_output_mask[NUMBER_OF_UE_MAX]; - int UE_output_mask[NUMBER_OF_RU_MAX]; pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX]; - pthread_mutex_t subframe_mutex; - int subframe_ru_mask; - int subframe_UE_mask; openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; - openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; double ru_amp[NUMBER_OF_RU_MAX]; - pthread_t rfsim_thread; } sim_t; diff --git a/radio/rfsimulator/simulator.c b/radio/rfsimulator/simulator.c index 44b2864f8c..287a657795 100644 --- a/radio/rfsimulator/simulator.c +++ b/radio/rfsimulator/simulator.c @@ -206,17 +206,6 @@ static int allocCirBuf(rfsimulator_state_t *bridge, int sock) if ( bridge->channelmod > 0) { // create channel simulation model for this mode reception - // snr_dB is pure global, coming from configuration paramter "-s" - // Fixme: referenceSignalPower should come from the right place - // but the datamodel is inconsistant - // legacy: RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower - // (must not come from ru[]->frame_parms as it doesn't belong to ru !!!) - // Legacy sets it as: - // ptr->channel_model->path_loss_dB = -132.24 + snr_dB - RC.ru[0]->frame_parms->pdsch_config_common.referenceSignalPower; - // we use directly the paramter passed on the command line ("-s") - // the value channel_model->path_loss_dB seems only a storage place (new_channel_desc_scm() only copy the passed value) - // Legacy changes directlty the variable channel_model->path_loss_dB place to place - // while calling new_channel_desc_scm() with path losses = 0 static bool init_done=false; if (!init_done) { From 29bc4101cc6de8ef75de2ecfffb7e697108cbcb3 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 22 Feb 2024 17:46:52 -0500 Subject: [PATCH 08/54] NGAP: Fix byte order of NSSAI SD --- openair3/NGAP/ngap_gNB_handlers.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openair3/NGAP/ngap_gNB_handlers.c b/openair3/NGAP/ngap_gNB_handlers.c index b1972a6412..5a639e7305 100644 --- a/openair3/NGAP/ngap_gNB_handlers.c +++ b/openair3/NGAP/ngap_gNB_handlers.c @@ -794,7 +794,8 @@ static int ngap_gNB_handle_initial_context_request(sctp_assoc_t assoc_id, uint32 OCTET_STRING_TO_INT8(&allow_nssai_item_p->s_NSSAI.sST, msg->allowed_nssai[i].sst); if(allow_nssai_item_p->s_NSSAI.sD != NULL) { - memcpy(&msg->allowed_nssai[i].sd, allow_nssai_item_p->s_NSSAI.sD, 3); + msg->allowed_nssai[i].sd = 0; + BUFFER_TO_INT24((uint8_t *)allow_nssai_item_p->s_NSSAI.sD->buf, msg->allowed_nssai[i].sd); } else { msg->allowed_nssai[i].sd = 0xffffff; } @@ -974,10 +975,7 @@ static int ngap_gNB_handle_pdusession_setup_request(sctp_assoc_t assoc_id, uint3 // S-NSSAI OCTET_STRING_TO_INT8(&item_p->s_NSSAI.sST, msg->pdusession_setup_params[i].nssai.sst); if (item_p->s_NSSAI.sD != NULL) { - uint8_t *sd_p = (uint8_t *)&msg->pdusession_setup_params[i].nssai.sd; - sd_p[0] = item_p->s_NSSAI.sD->buf[0]; - sd_p[1] = item_p->s_NSSAI.sD->buf[1]; - sd_p[2] = item_p->s_NSSAI.sD->buf[2]; + BUFFER_TO_INT24((uint8_t *)item_p->s_NSSAI.sD->buf, msg->pdusession_setup_params[i].nssai.sd); } else { msg->pdusession_setup_params[i].nssai.sd = 0xffffff; } From 10a6ce8bdda1453bb903f9e73d326320c08c6e44 Mon Sep 17 00:00:00 2001 From: Ajit Singh Date: Wed, 21 Feb 2024 15:02:02 +0000 Subject: [PATCH 09/54] Bugfix in PDCP when SDAP is enabled. Passing only data for chipering. --- openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index 0bbd294c53..f265e78c85 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -42,6 +42,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, uint32_t rcvd_count; int header_size; int integrity_size; + int sdap_header_size = 0; int rx_deliv_sn; uint32_t rx_deliv_hfn; @@ -62,6 +63,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, entity->stats.rxpdu_pkts++; entity->stats.rxpdu_bytes += size; + if (entity->has_sdap_rx) sdap_header_size = 1; // SDAP Header is one byte if (entity->sn_size == 12) { rcvd_sn = ((buffer[0] & 0xf) << 8) | @@ -82,7 +84,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, integrity_size = 0; } - if (size < header_size + integrity_size + 1) { + if (size < header_size + sdap_header_size + integrity_size + 1) { LOG_E(PDCP, "bad PDU received (size = %d)\n", size); entity->stats.rxpdu_dd_pkts++; @@ -106,7 +108,8 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, if (entity->has_ciphering) entity->cipher(entity->security_context, - buffer+header_size, size-header_size, + buffer + header_size + sdap_header_size, + size - (header_size + sdap_header_size), entity->rb_id, rcvd_count, entity->is_gnb ? 0 : 1); if (entity->has_integrity) { @@ -184,6 +187,7 @@ static int nr_pdcp_entity_process_sdu(nr_pdcp_entity_t *entity, int sn; int header_size; int integrity_size; + int sdap_header_size = 0; char *buf = pdu_buffer; DevAssert(size + 3 + 4 <= pdu_max_size); int dc_bit; @@ -194,6 +198,8 @@ static int nr_pdcp_entity_process_sdu(nr_pdcp_entity_t *entity, count = entity->tx_next; sn = entity->tx_next & entity->sn_max; + if (entity->has_sdap_tx) sdap_header_size = 1; // SDAP header is one byte + /* D/C bit is only to be set for DRBs */ if (entity->type == NR_PDCP_DRB_AM || entity->type == NR_PDCP_DRB_UM) { dc_bit = 0x80; @@ -236,7 +242,8 @@ static int nr_pdcp_entity_process_sdu(nr_pdcp_entity_t *entity, if (entity->has_ciphering && (entity->is_gnb || entity->security_mode_completed)) { entity->cipher(entity->security_context, - (unsigned char *)buf + header_size, size + integrity_size, + (unsigned char *)buf + header_size + sdap_header_size, + size + integrity_size - sdap_header_size, entity->rb_id, count, entity->is_gnb ? 1 : 0); } else { entity->security_mode_completed = true; From 1adcd3fb5aec1f8553e80aff1fbab492118cf54d Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Wed, 21 Feb 2024 09:30:52 +0100 Subject: [PATCH 10/54] Revert "fix(ci): hot-fix for E2-agent build w/ latest version of ASN1C" This reverts commit 2b796874ca974589a94cf98bcf63b63c8bfa8317. --- cmake_targets/tools/build_helper | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 484783af8d..8ff0dcfa8c 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -666,10 +666,7 @@ install_asn1c_from_source(){ # GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c git clone https://github.com/mouse07410/asn1c /tmp/asn1c cd /tmp/asn1c - # 2024-02-06: problem compatibility between E2-agent and 4cfcd4f191c3fa41f6ac1b15cb2ad3acc1520af5 from asn1c - # Reverting to previous commit that works - # TODO : revert to vlm_master once FlexRic and E2-agent are fixed - git checkout -f a6bdcd22658d6b7c3ed218d8c1375907ac532b64 + git checkout vlm_master # Showing which version is used git log -n1 autoreconf -iv From 1b237f6abe24637d1317e47793cbc989fa1d67c5 Mon Sep 17 00:00:00 2001 From: mir Date: Tue, 20 Feb 2024 18:12:08 +0100 Subject: [PATCH 11/54] Fix name clashes between OAI and E2 Agent generated by the linker --- CMakeLists.txt | 15 ++++----------- openair2/E2AP/RAN_FUNCTION/CMakeLists.txt | 4 ++-- openair2/E2AP/RAN_FUNCTION/read_setup_ran.c | 2 +- openair2/E2AP/flexric | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5854dae3d5..b2605c529c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1436,8 +1436,7 @@ target_link_libraries(L2 PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) if(E2_AGENT) target_link_libraries(L2 PUBLIC e2_agent e2_agent_arg e2_ran_func_du_cucp_cuup) - target_compile_definitions(L2 PRIVATE E2_AGENT) - target_compile_definitions(L2 PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) + target_compile_definitions(L2 PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT) endif() @@ -1463,8 +1462,7 @@ target_link_libraries(e1_if PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs asn1_f1ap target_link_libraries(L2_NR PRIVATE f1ap x2ap s1ap ngap nr_rrc e1ap nr_rlc) if(E2_AGENT) target_link_libraries(L2_NR PUBLIC e2_agent e2_agent_arg e2_ran_func_du_cucp_cuup) - target_compile_definitions(L2_NR PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) - target_compile_definitions(L2_NR PRIVATE E2_AGENT) + target_compile_definitions(L2_NR PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT) endif() add_library(L2_LTE_NR @@ -1983,8 +1981,7 @@ target_link_libraries(lte-softmodem PRIVATE ${T_LIB}) target_link_libraries(lte-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) if(E2_AGENT) - target_compile_definitions(lte-softmodem PRIVATE E2_AGENT) - target_compile_definitions(lte-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) + target_compile_definitions(lte-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT) endif() add_executable(oairu @@ -2082,7 +2079,7 @@ target_link_libraries(nr-softmodem PRIVATE ${T_LIB}) target_link_libraries(nr-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) target_link_libraries(nr-softmodem PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) if(E2_AGENT) - target_compile_definitions(nr-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION}) + target_compile_definitions(nr-softmodem PRIVATE ${E2AP_VERSION} ${KPM_VERSION} E2_AGENT) endif() @@ -2095,10 +2092,6 @@ endif() # force the generation of ASN.1 so that we don't need to wait during the build target_link_libraries(nr-softmodem PRIVATE asn1_lte_rrc asn1_nr_rrc asn1_s1ap asn1_ngap asn1_m2ap asn1_m3ap asn1_x2ap asn1_f1ap asn1_lpp) -if(E2_AGENT) - target_compile_definitions(nr-softmodem PRIVATE E2_AGENT) -endif() - add_executable(nr-cuup executables/nr-cuup.c diff --git a/openair2/E2AP/RAN_FUNCTION/CMakeLists.txt b/openair2/E2AP/RAN_FUNCTION/CMakeLists.txt index 47f7ae4154..3cb3d062f4 100644 --- a/openair2/E2AP/RAN_FUNCTION/CMakeLists.txt +++ b/openair2/E2AP/RAN_FUNCTION/CMakeLists.txt @@ -39,5 +39,5 @@ add_library(e2_ran_func_du_cucp_cuup STATIC ../flexric/test/rnd/fill_rnd_data_slice.c ) -target_link_libraries(e2_ran_func_du_cucp_cuup PUBLIC asn1_nr_rrc nr_rrc asn1_nr_rrc_hdrs e2_time_obj kpm_ric_info_common_obj 3gpp_derived_ie_obj e2sm_rc_ir_obj sm_common_ie_obj) -target_compile_definitions(e2_ran_func_du_cucp_cuup PUBLIC ${E2AP_VERSION} ${KPM_VERSION} NGRAN_GNB_DU NGRAN_GNB_CUCP NGRAN_GNB_CUUP) +target_link_libraries(e2_ran_func_du_cucp_cuup PUBLIC asn1_nr_rrc nr_rrc asn1_nr_rrc_hdrs e2_time_obj kpm_ric_info_common_obj 3gpp_derived_ie_obj e2sm_rc_ir_obj sm_common_ie_obj e2_agent) +target_compile_definitions(e2_ran_func_du_cucp_cuup PUBLIC ${E2AP_VERSION} ${KPM_VERSION} NGRAN_GNB_DU NGRAN_GNB_CUCP NGRAN_GNB_CUUP) diff --git a/openair2/E2AP/RAN_FUNCTION/read_setup_ran.c b/openair2/E2AP/RAN_FUNCTION/read_setup_ran.c index 2bc481d527..774ea290d6 100644 --- a/openair2/E2AP/RAN_FUNCTION/read_setup_ran.c +++ b/openair2/E2AP/RAN_FUNCTION/read_setup_ran.c @@ -29,7 +29,7 @@ void read_setup_ran(void* data, const ngran_node_t node_type) { assert(data != NULL); #ifdef E2AP_V1 - + (void)node_type; #elif defined(E2AP_V2) || defined(E2AP_V3) arr_node_component_config_add_t* dst = (arr_node_component_config_add_t*)data; diff --git a/openair2/E2AP/flexric b/openair2/E2AP/flexric index 29af8408af..7c424e882a 160000 --- a/openair2/E2AP/flexric +++ b/openair2/E2AP/flexric @@ -1 +1 @@ -Subproject commit 29af8408afad3da36824bd7912562202023ae924 +Subproject commit 7c424e882adae6ad72a24470d8c3e731189062c0 From 4a8815a41e784ea05d6da381d8f2660eee617bd7 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Thu, 15 Feb 2024 09:45:02 +0100 Subject: [PATCH 12/54] Introduced function to check whether it is a transmitting or a receiving SDAP entity --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 9 ++------ openair2/SDAP/nr_sdap/nr_sdap_entity.c | 28 +++++++++++++++++++++++ openair2/SDAP/nr_sdap/nr_sdap_entity.h | 15 ++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 73e015976d..fdad46c303 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -888,13 +888,8 @@ void add_drb(int is_gnb, exit(-1); } pdusession_id = s->cnAssociation->choice.sdap_Config->pdu_Session; - if (is_gnb) { - has_sdap_rx = s->cnAssociation->choice.sdap_Config->sdap_HeaderUL == NR_SDAP_Config__sdap_HeaderUL_present; - has_sdap_tx = s->cnAssociation->choice.sdap_Config->sdap_HeaderDL == NR_SDAP_Config__sdap_HeaderDL_present; - } else { - has_sdap_tx = s->cnAssociation->choice.sdap_Config->sdap_HeaderUL == NR_SDAP_Config__sdap_HeaderUL_present; - has_sdap_rx = s->cnAssociation->choice.sdap_Config->sdap_HeaderDL == NR_SDAP_Config__sdap_HeaderDL_present; - } + has_sdap_rx = is_sdap_rx(is_gnb, s->cnAssociation->choice.sdap_Config); + has_sdap_tx = is_sdap_tx(is_gnb, s->cnAssociation->choice.sdap_Config); is_sdap_DefaultDRB = s->cnAssociation->choice.sdap_Config->defaultDRB == true ? 1 : 0; mappedQFIs2Add = (NR_QFI_t*)s->cnAssociation->choice.sdap_Config->mappedQoS_FlowsToAdd->list.array[0]; mappedQFIs2AddCount = s->cnAssociation->choice.sdap_Config->mappedQoS_FlowsToAdd->list.count; diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.c b/openair2/SDAP/nr_sdap/nr_sdap_entity.c index e119b2407a..3119175190 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.c +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.c @@ -37,6 +37,34 @@ static nr_sdap_entity_info sdap_info; instance_t *N3GTPUInst = NULL; +/** + * @brief indicates whether it is a receiving SDAP entity + * i.e. for UE, header for DL data is present + * for gNB, header for UL data is present + */ +bool is_sdap_rx(bool is_gnb, NR_SDAP_Config_t *sdap_config) +{ + if (is_gnb) { + return sdap_config->sdap_HeaderUL == NR_SDAP_Config__sdap_HeaderUL_present; + } else { + return sdap_config->sdap_HeaderDL == NR_SDAP_Config__sdap_HeaderDL_present; + } +} + +/** + * @brief indicates whether it is a transmitting SDAP entity + * i.e. for UE, header for UL data is present + * for gNB, header for DL data is present + */ +bool is_sdap_tx(bool is_gnb, NR_SDAP_Config_t *sdap_config) +{ + if (is_gnb) { + return sdap_config->sdap_HeaderDL == NR_SDAP_Config__sdap_HeaderDL_present; + } else { + return sdap_config->sdap_HeaderUL == NR_SDAP_Config__sdap_HeaderUL_present; + } +} + void nr_pdcp_submit_sdap_ctrl_pdu(ue_id_t ue_id, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu) { diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.h b/openair2/SDAP/nr_sdap/nr_sdap_entity.h index 0b4ae82bcb..e2eabb6ccc 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.h +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.h @@ -188,4 +188,19 @@ bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id); * @return True, it deleted at least one entity, false otherwise. */ bool nr_sdap_delete_ue_entities(ue_id_t ue_id); + +/** + * @brief indicates whether it is a receiving SDAP entity + * i.e. for UE, header for DL data is present + * for gNB, header for UL data is present + */ +bool is_sdap_rx(bool is_gnb, NR_SDAP_Config_t *sdap_config); + +/** + * @brief indicates whether it is a transmitting SDAP entity + * i.e. for UE, header for UL data is present + * for gNB, header for DL data is present + */ +bool is_sdap_tx(bool is_gnb, NR_SDAP_Config_t *sdap_config); + #endif From bc0cab7a083befd4771104f380625bed5a9b60b5 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Thu, 15 Feb 2024 09:50:38 +0100 Subject: [PATCH 13/54] Minor fixes and clang formatting in SDAP procedures - added descriptive comments to the code - removed redundant function prototype - removed unused function argument --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 12 +++- openair2/RRC/NR_UE/rrc_UE.c | 12 +++- openair2/SDAP/nr_sdap/nr_sdap_entity.c | 77 +++++++++++++++++++---- openair2/SDAP/nr_sdap/nr_sdap_entity.h | 20 +++--- 4 files changed, 96 insertions(+), 25 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index fdad46c303..345ed424ea 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -921,8 +921,16 @@ void add_drb(int is_gnb, nr_pdcp_ue_add_drb_pdcp_entity(ue, drb_id, pdcp_drb); LOG_I(PDCP, "added drb %d to UE ID %ld\n", drb_id, UEid); - - new_nr_sdap_entity(is_gnb, has_sdap_rx, has_sdap_tx, UEid, pdusession_id, is_sdap_DefaultDRB, drb_id, mappedQFIs2Add, mappedQFIs2AddCount); + /* add new SDAP entity for the PDU session the DRB belongs to */ + new_nr_sdap_entity(is_gnb, + has_sdap_rx, + has_sdap_tx, + UEid, + pdusession_id, + is_sdap_DefaultDRB, + drb_id, + mappedQFIs2Add, + mappedQFIs2AddCount); } nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 8385236ff1..cb4406ecd1 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1158,6 +1158,10 @@ void nr_rrc_ue_process_measConfig(rrcPerNB_t *rrc, NR_MeasConfig_t *const measCo } } +/** + * @brief add, modify and release SRBs and/or DRBs + * @ref 3GPP TS 38.331 + */ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, NR_RadioBearerConfig_t *const radioBearerConfig) { @@ -1216,15 +1220,21 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, } } - // Establish DRBs if present + /** + * Establish/reconfig DRBs if DRB-ToAddMod is present + * according to 3GPP TS 38.331 clause 5.3.5.6.5 DRB addition/modification + */ if (radioBearerConfig->drb_ToAddModList != NULL) { for (int cnt = 0; cnt < radioBearerConfig->drb_ToAddModList->list.count; cnt++) { struct NR_DRB_ToAddMod *drb = radioBearerConfig->drb_ToAddModList->list.array[cnt]; int DRB_id = drb->drb_Identity; + /* DRB is already established and configured */ if (ue_rrc->status_DRBs[DRB_id] == RB_ESTABLISHED) { AssertFatal(drb->reestablishPDCP == NULL, "reestablishPDCP not yet implemented\n"); AssertFatal(drb->recoverPDCP == NULL, "recoverPDCP not yet implemented\n"); + /* sdap-Config is included (SA mode) */ NR_SDAP_Config_t *sdap_Config = drb->cnAssociation ? drb->cnAssociation->choice.sdap_Config : NULL; + /* PDCP and SDAP reconfiguration */ if (drb->pdcp_Config || sdap_Config) nr_pdcp_reconfigure_drb(ue_rrc->ue_id, DRB_id, drb->pdcp_Config, sdap_Config); if (drb->cnAssociation) diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.c b/openair2/SDAP/nr_sdap/nr_sdap_entity.c index 3119175190..5508c5294a 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.c +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.c @@ -110,7 +110,7 @@ static bool nr_sdap_tx_entity(nr_sdap_entity_t *entity, } uint8_t sdap_buf[SDAP_MAX_PDU]; - rb_id_t pdcp_entity = entity->qfi2drb_map(entity, qfi, rb_id); + rb_id_t pdcp_entity = entity->qfi2drb_map(entity, qfi); if(pdcp_entity){ sdap_drb_id = pdcp_entity; @@ -212,7 +212,8 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity, int pdusession_id, ue_id_t ue_id, char *buf, - int size) { + int size) +{ /* The offset of the SDAP header, it might be 0 if has_sdap_rx is not true in the pdcp entity. */ int offset=0; @@ -338,6 +339,9 @@ static void nr_sdap_rx_entity(nr_sdap_entity_t *entity, } } +/** + * @brief update QFI to DRB mapping rules +*/ void nr_sdap_qfi2drb_map_update(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t drb, bool has_sdap_rx, bool has_sdap_tx) { if(qfi < SDAP_MAX_QFI && @@ -358,7 +362,11 @@ void nr_sdap_qfi2drb_map_del(nr_sdap_entity_t *entity, uint8_t qfi){ LOG_D(SDAP, "Deleted mapping for QFI: %u \n", qfi); } -rb_id_t nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t upper_layer_rb_id){ +/** + * @brief maps the QFIs to the default DRB if not mapping rule exists + * @return DRB that is mapped to the QFI, 0 if no mapping and no default DRB exists for that QFI +*/ +rb_id_t nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi){ rb_id_t pdcp_entity; pdcp_entity = entity->qfi2drb_table[qfi].drb_id; @@ -396,12 +404,15 @@ rb_id_t nr_sdap_map_ctrl_pdu(nr_sdap_entity_t *entity, rb_id_t pdcp_entity, int LOG_D(SDAP, "Mapping Control PDU QFI: %u to Default DRB: %ld\n", dl_qfi, drb_of_endmarker); } if(map_type == SDAP_CTRL_PDU_MAP_RULE_DRB){ - drb_of_endmarker = entity->qfi2drb_map(entity, dl_qfi, pdcp_entity); + drb_of_endmarker = entity->qfi2drb_map(entity, dl_qfi); LOG_D(SDAP, "Mapping Control PDU QFI: %u to DRB: %ld\n", dl_qfi, drb_of_endmarker); } return drb_of_endmarker; } +/** + * @brief Submit the end-marker control PDU to PDCP according to TS 37.324, clause 5.3 + */ void nr_sdap_submit_ctrl_pdu(ue_id_t ue_id, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu) { if(sdap_ctrl_pdu_drb){ @@ -410,28 +421,55 @@ void nr_sdap_submit_ctrl_pdu(ue_id_t ue_id, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_u } } -void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity, rb_id_t pdcp_entity, ue_id_t ue_id, NR_QFI_t *mapped_qfi_2_add, uint8_t mappedQFIs2AddCount, uint8_t drb_identity, bool has_sdap_rx, bool has_sdap_tx) +/** + * @brief UL QoS flow to DRB mapping configuration for an existing SDAP entity + * according to TS 37.324, 5.3 QoS flow to DRB Mapping, clause 5.3.1 Configuration Procedures + */ +static void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity, + rb_id_t pdcp_entity, + ue_id_t ue_id, + NR_QFI_t *mapped_qfi_2_add, + uint8_t mappedQFIs2AddCount, + uint8_t drb_identity, + bool has_sdap_rx, + bool has_sdap_tx) { LOG_D(SDAP, "RRC Configuring SDAP Entity\n"); - uint8_t qfi = 0; - for(int i = 0; i < mappedQFIs2AddCount; i++){ - qfi = mapped_qfi_2_add[i]; + uint8_t qfi = mapped_qfi_2_add[i]; + /* a default DRB exists and there is no QFI to DRB mapping rule for the QFI */ if (existing_sdap_entity->default_drb && existing_sdap_entity->qfi2drb_table[qfi].drb_id == SDAP_NO_MAPPING_RULE) { nr_sdap_ul_hdr_t sdap_ctrl_pdu = existing_sdap_entity->sdap_construct_ctrl_pdu(qfi); - rb_id_t sdap_ctrl_pdu_drb = existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_DEF_DRB, qfi); + rb_id_t sdap_ctrl_pdu_drb = + existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_DEF_DRB, qfi); existing_sdap_entity->sdap_submit_ctrl_pdu(ue_id, sdap_ctrl_pdu_drb, sdap_ctrl_pdu); } + /* the stored UL QFI to DRB mapping rule is different from the configured one and has UL SDAP header*/ if (existing_sdap_entity->qfi2drb_table[qfi].drb_id != drb_identity && existing_sdap_entity->qfi2drb_table[qfi].has_sdap_tx) { nr_sdap_ul_hdr_t sdap_ctrl_pdu = existing_sdap_entity->sdap_construct_ctrl_pdu(qfi); - rb_id_t sdap_ctrl_pdu_drb = existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_RULE_DRB, qfi); + rb_id_t sdap_ctrl_pdu_drb = + existing_sdap_entity->sdap_map_ctrl_pdu(existing_sdap_entity, pdcp_entity, SDAP_CTRL_PDU_MAP_RULE_DRB, qfi); existing_sdap_entity->sdap_submit_ctrl_pdu(ue_id, sdap_ctrl_pdu_drb, sdap_ctrl_pdu); } + /* update QFI to DRB mapping rules */ LOG_D(SDAP, "Storing the configured QoS flow to DRB mapping rule\n"); existing_sdap_entity->qfi2drb_map_update(existing_sdap_entity, qfi, drb_identity, has_sdap_rx, has_sdap_tx); } } +/** + * @brief add a new SDAP entity according to 5.1.1. of 3GPP TS 37.324 + * @note there is one SDAP entity per PDU session + * + * @param is_gnb, indicates whether it is for gNB or UE + * @param has_sdap_rx, indicates whether it is a receiving SDAP entity + * @param has_sdap_tx, indicates whether it is a transmitting SDAP entity + * @param ue_id, UE ID + * @param pdusession_id, PDU session ID + * @param is_defaultDRB, indicates whether the entity has a default DRB + * @param mapped_qfi_2_add, list of QoS flows to add/update + * @param mappedQFIs2AddCount, number of QoS flows to add/update + */ nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb, bool has_sdap_rx, bool has_sdap_tx, @@ -442,12 +480,21 @@ nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb, NR_QFI_t *mapped_qfi_2_add, uint8_t mappedQFIs2AddCount) { + /* check whether the SDAP entity already exists and + update QFI to DRB mapping rules in that case */ if (nr_sdap_get_entity(ue_id, pdusession_id)) { LOG_E(SDAP, "SDAP Entity for UE already exists with RNTI/UE ID: %lu and PDU SESSION ID: %d\n", ue_id, pdusession_id); nr_sdap_entity_t *existing_sdap_entity = nr_sdap_get_entity(ue_id, pdusession_id); rb_id_t pdcp_entity = existing_sdap_entity->default_drb; if(!is_gnb) - nr_sdap_ue_qfi2drb_config(existing_sdap_entity, pdcp_entity, ue_id, mapped_qfi_2_add, mappedQFIs2AddCount, drb_identity, has_sdap_rx, has_sdap_tx); + nr_sdap_ue_qfi2drb_config(existing_sdap_entity, + pdcp_entity, + ue_id, + mapped_qfi_2_add, + mappedQFIs2AddCount, + drb_identity, + has_sdap_rx, + has_sdap_tx); return existing_sdap_entity; } @@ -486,6 +533,11 @@ nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb, return sdap_entity; } +/** + * @brief Fetches the SDAP entity for the give PDU session ID. + * @note There is one SDAP entity per PDU session. + * @return The pointer to the SDAP entity if existing, NULL otherwise + */ nr_sdap_entity_t *nr_sdap_get_entity(ue_id_t ue_id, int pdusession_id) { nr_sdap_entity_t *sdap_entity; @@ -515,8 +567,7 @@ void nr_sdap_release_drb(ue_id_t ue_id, int drb_id, int pdusession_id) } } else - LOG_E(SDAP, "Couldn't find a SDAP entity associated with PDU session ID %d\n", - pdusession_id); + LOG_E(SDAP, "Couldn't find a SDAP entity associated with PDU session ID %d\n", pdusession_id); } bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id) diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.h b/openair2/SDAP/nr_sdap/nr_sdap_entity.h index e2eabb6ccc..2e6056748e 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.h +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.h @@ -84,7 +84,7 @@ typedef struct nr_sdap_entity_s { void (*qfi2drb_map_update)(struct nr_sdap_entity_s *entity, uint8_t qfi, rb_id_t drb, bool has_sdap_rx, bool has_sdap_tx); void (*qfi2drb_map_delete)(struct nr_sdap_entity_s *entity, uint8_t qfi); - rb_id_t (*qfi2drb_map)(struct nr_sdap_entity_s *entity, uint8_t qfi, rb_id_t upper_layer_rb_id); + rb_id_t (*qfi2drb_map)(struct nr_sdap_entity_s *entity, uint8_t qfi); nr_sdap_ul_hdr_t (*sdap_construct_ctrl_pdu)(uint8_t qfi); rb_id_t (*sdap_map_ctrl_pdu)(struct nr_sdap_entity_s *entity, rb_id_t pdcp_entity, int map_type, uint8_t dl_qfi); @@ -132,7 +132,7 @@ void nr_sdap_qfi2drb_map_del(nr_sdap_entity_t *entity, uint8_t qfi); * If there is no stored QoS flow to DRB mapping rule for the QoS flow as specified in the subclause 5.3, map the SDAP SDU to the default DRB * else, map the SDAP SDU to the DRB according to the stored QoS flow to DRB mapping rule. */ -rb_id_t nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t upper_layer_rb_id); +rb_id_t nr_sdap_qfi2drb_map(nr_sdap_entity_t *entity, uint8_t qfi); /* * TS 37.324 5.3 QoS flow to DRB Mapping @@ -154,17 +154,19 @@ rb_id_t nr_sdap_map_ctrl_pdu(nr_sdap_entity_t *entity, rb_id_t pdcp_entity, int */ void nr_sdap_submit_ctrl_pdu(ue_id_t ue_id, rb_id_t sdap_ctrl_pdu_drb, nr_sdap_ul_hdr_t ctrl_pdu); -/* - * TS 37.324 5.3 QoS flow to DRB Mapping - * 5.3.1 Configuration Procedures - */ -void nr_sdap_ue_qfi2drb_config(nr_sdap_entity_t *existing_sdap_entity, rb_id_t pdcp_entity, ue_id_t ue_id, NR_QFI_t *mapped_qfi_2_add, uint8_t mappedQFIs2AddCount, uint8_t drb_identity, bool has_sdap_rx, bool has_sdap_tx); - /* * TS 37.324 4.4 5.1.1 SDAP entity establishment * Establish an SDAP entity. */ -nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb, bool has_sdap_rx, bool has_sdap_tx, ue_id_t ue_id, int pdusession_id, bool is_defaultDRB, uint8_t default_DRB, NR_QFI_t *mapped_qfi_2_add, uint8_t mappedQFIs2AddCount); +nr_sdap_entity_t *new_nr_sdap_entity(int is_gnb, + bool has_sdap_rx, + bool has_sdap_tx, + ue_id_t ue_id, + int pdusession_id, + bool is_defaultDRB, + uint8_t default_DRB, + NR_QFI_t *mapped_qfi_2_add, + uint8_t mappedQFIs2AddCount); /* Entity Handling Related Functions */ nr_sdap_entity_t *nr_sdap_get_entity(ue_id_t ue_id, int pdusession_id); From edb2dd7d6d9a01f2321230ec47e42bb829b21d9a Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Fri, 16 Feb 2024 18:20:32 +0100 Subject: [PATCH 14/54] SDAP Entity reconfiguration at UE according to TS 37.324 - triggered by RRC reconfiguration events according to clause 5.3.5.6.5 of TS 38.331 - This procedure does QoS flow to DRB mapping according to clause 5.3.1 of TS 37.324 - QoS flows to DRBs to be released are also handled --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 8 ++--- openair2/RRC/NR_UE/rrc_UE.c | 2 -- openair2/SDAP/nr_sdap/nr_sdap_entity.c | 40 +++++++++++++++++++++++ openair2/SDAP/nr_sdap/nr_sdap_entity.h | 6 ++++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 345ed424ea..9546a2b2bb 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -1166,10 +1166,10 @@ void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, NR_PDCP_Config_t *pdcp_c } } } - if (sdap_config) { - // nr_reconfigure_sdap_entity - AssertFatal(false, "Function to reconfigure SDAP entity not implemented yet\n"); - } + /* SDAP entity reconfiguration */ + if (sdap_config) + nr_reconfigure_sdap_entity(sdap_config, ue_id, sdap_config->pdu_Session, drb_id); + nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index cb4406ecd1..c19fd4e00e 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1237,8 +1237,6 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, /* PDCP and SDAP reconfiguration */ if (drb->pdcp_Config || sdap_Config) nr_pdcp_reconfigure_drb(ue_rrc->ue_id, DRB_id, drb->pdcp_Config, sdap_Config); - if (drb->cnAssociation) - AssertFatal(drb->cnAssociation->choice.sdap_Config == NULL, "SDAP reconfiguration not yet implemented\n"); } else { ue_rrc->status_DRBs[DRB_id] = RB_ESTABLISHED; add_drb(false, diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.c b/openair2/SDAP/nr_sdap/nr_sdap_entity.c index 5508c5294a..1a1d28782f 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.c +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.c @@ -641,3 +641,43 @@ bool nr_sdap_delete_ue_entities(ue_id_t ue_id) } return ret; } + +/** + * @brief SDAP Entity reconfiguration at UE according to TS 37.324 + * and triggered by RRC reconfiguration events according to clause 5.3.5.6.5 of TS 38.331. + * This function performs: + * - QoS flow to DRB mapping according to clause 5.3.1 of TS 37.324 + */ +void nr_reconfigure_sdap_entity(NR_SDAP_Config_t *sdap_config, ue_id_t ue_id, int pdusession_id, int drb_id) +{ + bool is_gnb = false; + /* fetch SDAP entity */ + nr_sdap_entity_t *sdap_entity = nr_sdap_get_entity(ue_id, pdusession_id); + AssertError(sdap_entity != NULL, + return, + "Could not find SDAP Entity for RNTI/UE ID: %lu and PDU SESSION ID: %d\n", + ue_id, + pdusession_id); + /* QFI to DRB mapping */ + NR_QFI_t *mappedQFIs2Add = (NR_QFI_t *)sdap_config->mappedQoS_FlowsToAdd->list.array[0]; + uint8_t mappedQFIs2AddCount = sdap_config->mappedQoS_FlowsToAdd->list.count; + bool has_sdap_rx = is_sdap_rx(is_gnb, sdap_config); + bool has_sdap_tx = is_sdap_tx(is_gnb, sdap_config); + nr_sdap_ue_qfi2drb_config(sdap_entity, + sdap_entity->default_drb, + ue_id, + mappedQFIs2Add, + mappedQFIs2AddCount, + drb_id, + has_sdap_rx, + has_sdap_tx); + /* handle QFIs to DRB mapping rule to release */ + if (sdap_config->mappedQoS_FlowsToRelease) { + NR_QFI_t *mappedQFIs2release = (NR_QFI_t *)sdap_config->mappedQoS_FlowsToRelease->list.array[0]; + uint8_t mappedQFIs2RemoveCount = sdap_config->mappedQoS_FlowsToRelease->list.count; + for(int i = 0; i < mappedQFIs2RemoveCount; i++){ + uint8_t qfi = mappedQFIs2release[i]; + sdap_entity->qfi2drb_map_delete(sdap_entity, qfi); + } + } +} diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.h b/openair2/SDAP/nr_sdap/nr_sdap_entity.h index 2e6056748e..3768d60f6a 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.h +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.h @@ -205,4 +205,10 @@ bool is_sdap_rx(bool is_gnb, NR_SDAP_Config_t *sdap_config); */ bool is_sdap_tx(bool is_gnb, NR_SDAP_Config_t *sdap_config); +/** + * @brief Run the SDAP reconfiguration for the DRB + * @param[in] ue_id Unique identifier for the User Equipment. ID Range [0, 65536]. + */ +void nr_reconfigure_sdap_entity(NR_SDAP_Config_t *sdap_config, ue_id_t ue_id, int pdusession_id, int drb_id); + #endif From 948188b200199ee9beaae406c07a2ca80cebd9a9 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 22 Feb 2024 18:08:55 +0100 Subject: [PATCH 15/54] basic C cleaning of dci decoding --- .../nr_dl_channel_estimation.c | 2 +- openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 523 ++++++++---------- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 22 +- openair1/SCHED_NR_UE/defs.h | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 14 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 9 +- 8 files changed, 242 insertions(+), 334 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index a310e7d127..88dd247780 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -1060,7 +1060,7 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint16_t first_carrier_offset, uint16_t BWPStart, int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t pdcch_dl_ch_estimates[][pdcch_est_size], c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index a313a3a759..14aa39c0a0 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -54,7 +54,7 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, uint16_t first_carrier_offset, uint16_t BWPStart, int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t pdcch_dl_ch_estimates[][pdcch_est_size], c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index b95193e5e9..5b315a463f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -57,25 +57,31 @@ static const char nr_dci_format_string[8][30] = {"NR_DL_DCI_FORMAT_1_0", //#define NR_PDCCH_DCI_DEBUG // activates NR_PDCCH_DCI_DEBUG logs #ifdef NR_PDCCH_DCI_DEBUG #define LOG_DDD(a, ...) printf("<-NR_PDCCH_DCI_DEBUG (%s)-> " a, __func__, ##__VA_ARGS__ ) +#define LOG_DSYMB(b) \ + LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n" b, \ + c_rb, \ + i, \ + j, \ + rxF_ext[j].r, \ + rxF_ext[j].i, \ + i, \ + rxF[i].r, \ + rxF[i].i) #else #define LOG_DDD(a...) +#define LOG_DSYMB(a...) #endif -#define NR_NBR_CORESET_ACT_BWP 3 // The number of CoreSets per BWP is limited to 3 (including initial CORESET: ControlResourceId 0) -#define NR_NBR_SEARCHSPACE_ACT_BWP 10 // The number of SearSpaces per BWP is limited to 10 (including initial SEARCHSPACE: SearchSpaceId 0) - +#define NR_NBR_CORESET_ACT_BWP 3 // The number of CoreSets per BWP is limited to 3 (including initial CORESET: ControlResourceId 0) +#define NR_NBR_SEARCHSPACE_ACT_BWP \ + 10 // The number of SearSpaces per BWP is limited to 10 (including initial SEARCHSPACE: SearchSpaceId 0) #ifdef LOG_I - #undef LOG_I - #define LOG_I(A,B...) printf(B) +#undef LOG_I +#define LOG_I(A, B...) printf(B) #endif - - -//static const int16_t conjugate[8]__attribute__((aligned(32))) = {-1,1,-1,1,-1,1,-1,1}; - - -static void nr_pdcch_demapping_deinterleaving(uint32_t *llr, - uint32_t *e_rx, +static void nr_pdcch_demapping_deinterleaving(c16_t *llr, + c16_t *e_rx, uint8_t coreset_time_dur, uint8_t start_symbol, uint32_t coreset_nbr_rb, @@ -91,7 +97,8 @@ static void nr_pdcch_demapping_deinterleaving(uint32_t *llr, * Demapping will regroup in REG and bundles * Deinterleaving will order the bundles * - * In the following example we can see the process. The llr contains the demodulated IQs, but they are not ordered from REG 0,1,2,.. + * In the following example we can see the process. The llr contains the demodulated IQs, but they are not ordered from + REG 0,1,2,.. * In e_rx (z) we will order the REG ids and group them into bundles. * Then we will put the bundles in the correct order as indicated in subclause 7.3.2.2 * @@ -121,16 +128,14 @@ static void nr_pdcch_demapping_deinterleaving(uint32_t *llr, | REG 0 (bundle 0) bundle 0 bundle 0 */ - int c = 0, r = 0; - uint16_t f_bundle_j = 0; + uint32_t coreset_C = 0; - uint16_t index_z, index_llr; int coreset_interleaved = 0; - int N_regs = coreset_nbr_rb * coreset_time_dur; + const int N_regs = coreset_nbr_rb * coreset_time_dur; if (reg_bundle_size_L != 0) { // interleaving will be done only if reg_bundle_size_L != 0 coreset_interleaved = 1; - coreset_C = (uint32_t) (N_regs / (coreset_interleaver_size_R * reg_bundle_size_L)); + coreset_C = (uint32_t)(N_regs / (coreset_interleaver_size_R * reg_bundle_size_L)); } else { reg_bundle_size_L = 6; } @@ -141,6 +146,7 @@ static void nr_pdcch_demapping_deinterleaving(uint32_t *llr, int max_bundles = n_cce * num_bundles_per_cce; int f_bundle_j_list[max_bundles]; // for each bundle + int c = 0, r = 0, f_bundle_j = 0; for (int nb = 0; nb < max_bundles; nb++) { if (coreset_interleaved == 0) f_bundle_j = nb; @@ -157,16 +163,15 @@ static void nr_pdcch_demapping_deinterleaving(uint32_t *llr, // Get cce_list indices by bundle index in ascending order int f_bundle_j_list_ord[number_of_candidates][max_bundles]; - for (int c_id = 0; c_id < number_of_candidates; c_id++ ) { + for (int c_id = 0; c_id < number_of_candidates; c_id++) { int start_bund_cand = CCE[c_id] * num_bundles_per_cce; int max_bund_per_cand = L[c_id] * num_bundles_per_cce; int f_bundle_j_list_id = 0; - for(int nb = 0; nb < max_bundles; nb++) { - for(int bund_cand = start_bund_cand; bund_cand < start_bund_cand + max_bund_per_cand; bund_cand++){ + for (int nb = 0; nb < max_bundles; nb++) { + for (int bund_cand = start_bund_cand; bund_cand < start_bund_cand + max_bund_per_cand; bund_cand++) { if (f_bundle_j_list[bund_cand] == nb) { f_bundle_j_list_ord[c_id][f_bundle_j_list_id] = nb; f_bundle_j_list_id++; - } } } @@ -174,20 +179,30 @@ static void nr_pdcch_demapping_deinterleaving(uint32_t *llr, int rb_count = 0; int data_sc = 9; // 9 sub-carriers with data per PRB - for (int c_id = 0; c_id < number_of_candidates; c_id++ ) { - for (int symbol_idx = start_symbol; symbol_idx < start_symbol+coreset_time_dur; symbol_idx++) { - for (int cce_count = 0; cce_count < L[c_id]; cce_count ++) { - for (int k=0; k \t llr[%d]=(%d,%d) \n", - c_id,symbol_idx,cce_count,k,f*B_rb + rb,(index_z + i),*(int16_t *) &e_rx[index_z + i],*(1 + (int16_t *) &e_rx[index_z + i]), - (index_llr + i),*(int16_t *) &llr[index_llr + i], *(1 + (int16_t *) &llr[index_llr + i])); + LOG_I(PHY, + "[candidate=%d,symbol_idx=%d,cce=%d,REG bundle=%d,PRB=%d] z[%d]=(%d,%d) <-> \t llr[%d]=(%d,%d) \n", + c_id, + symbol_idx, + cce_count, + k, + f * B_rb + rb, + (index_z + i), + out->r, + out->i, + index_llr + i, + in.r, + in.i); #endif } rb_count++; @@ -198,92 +213,52 @@ static void nr_pdcch_demapping_deinterleaving(uint32_t *llr, } } -int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t rx_size, int32_t rxdataF_comp[][rx_size], - int16_t *pdcch_llr, uint8_t symbol,uint32_t coreset_nbr_rb) { - int16_t *rxF = (int16_t *) &rxdataF_comp[0][(symbol * coreset_nbr_rb * 12)]; - int32_t i; - int16_t *pdcch_llrp; - pdcch_llrp = &pdcch_llr[2 * symbol * coreset_nbr_rb * 9]; +static void nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, + int32_t rx_size, + c16_t rxdataF_comp[][rx_size], + c16_t *pdcch_llr, + uint8_t symbol, + uint32_t coreset_nbr_rb) +{ + c16_t *rxF = &rxdataF_comp[0][(symbol * coreset_nbr_rb * 12)]; + c16_t *pdcch_llrp = &pdcch_llr[symbol * coreset_nbr_rb * 9]; if (!pdcch_llrp) { LOG_E(PHY,"pdcch_qpsk_llr: llr is null, symbol %d\n", symbol); - return (-1); + return; } LOG_DDD("llr logs: pdcch qpsk llr for symbol %d (pos %d), llr offset %ld\n",symbol,(symbol*frame_parms->N_RB_DL*12),pdcch_llrp-pdcch_llr); //for (i = 0; i < (frame_parms->N_RB_DL * ((symbol == 0) ? 16 : 24)); i++) { - for (i = 0; i < (coreset_nbr_rb * ((symbol == 0) ? 18 : 18)); i++) { - if (*rxF > 31) - *pdcch_llrp = 31; - else if (*rxF < -32) - *pdcch_llrp = -32; - else - *pdcch_llrp = (*rxF); - + for (int i = 0; i < (coreset_nbr_rb * ((symbol == 0) ? 9 : 9)); i++) { + // We clip the signal + c16_t res; + res.r = min(rxF->r, 31); + res.r = max(-32, res.r); + res.i = min(rxF->i, 31); + res.i = max(-32, res.i); + *pdcch_llrp = res; LOG_DDD("llr logs: rb=%d i=%d *rxF:%d => *pdcch_llrp:%d\n",i/18,i,*rxF,*pdcch_llrp); rxF++; pdcch_llrp++; } - - return (0); } - -#if 0 -int32_t pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - char *pdcch_llr, - uint8_t symbol) { - int16_t *rxF= (int16_t *) &rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int32_t i; - char *pdcch_llr8; - pdcch_llr8 = &pdcch_llr[2*symbol*frame_parms->N_RB_DL*12]; - - if (!pdcch_llr8) { - LOG_E(PHY,"pdcch_qpsk_llr: llr is null, symbol %d\n",symbol); - return(-1); - } - - // printf("pdcch qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),pdcch_llr8-pdcch_llr); - - for (i=0; i<(frame_parms->N_RB_DL*((symbol==0) ? 16 : 24)); i++) { - if (*rxF>31) - *pdcch_llr8=31; - else if (*rxF<-32) - *pdcch_llr8=-32; - else - *pdcch_llr8 = (char)(*rxF); - - // printf("%d %d => %d\n",i,*rxF,*pdcch_llr8); - rxF++; - pdcch_llr8++; - } - - return(0); -} -#endif - -//__m128i avg128P; - //compute average channel_level on each (TX,RX) antenna pair void nr_pdcch_channel_level(int32_t rx_size, - int32_t dl_ch_estimates_ext[][rx_size], + c16_t dl_ch_estimates_ext[][rx_size], NR_DL_FRAME_PARMS *frame_parms, int32_t *avg, int symbol, - uint8_t nb_rb) { - int16_t rb; - uint8_t aarx; - simde__m128i *dl_ch128; - simde__m128i avg128P; - - for (aarx=0; aarxnb_antennas_rx; aarx++) { + int nb_rb) +{ + for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { //clear average level - avg128P = simde_mm_setzero_si128(); - dl_ch128=(simde__m128i *)&dl_ch_estimates_ext[aarx][symbol*nb_rb*12]; + simde__m128i avg128P = simde_mm_setzero_si128(); + simde__m128i *dl_ch128 = (simde__m128i *)&dl_ch_estimates_ext[aarx][symbol * nb_rb * 12]; - for (rb=0; rb<(nb_rb*3)>>2; rb++) { + for (int rb = 0; rb < (nb_rb * 3) >> 2; rb++) { avg128P = simde_mm_add_epi32(avg128P,simde_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); avg128P = simde_mm_add_epi32(avg128P,simde_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); avg128P = simde_mm_add_epi32(avg128P,simde_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); @@ -304,29 +279,22 @@ void nr_pdcch_channel_level(int32_t rx_size, avg[aarx] += ((int32_t *)&avg128P)[i] / (nb_rb * 9); LOG_DDD("Channel level : %d\n",avg[aarx]); } - - simde_mm_empty(); - simde_m_empty(); } - simde__m128i mmtmpPD0,mmtmpPD1,mmtmpPD2,mmtmpPD3; - - - - // This function will extract the mapped DM-RS PDCCH REs as per 38.211 Section 7.4.1.3.2 (Mapping to physical resources) -void nr_pdcch_extract_rbs_single(uint32_t rxdataF_sz, - c16_t rxdataF[][rxdataF_sz], - int32_t est_size, - int32_t dl_ch_estimates[][est_size], - int32_t rx_size, - int32_t rxdataF_ext[][rx_size], - int32_t dl_ch_estimates_ext[][rx_size], - uint8_t symbol, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t *coreset_freq_dom, - uint32_t coreset_nbr_rb, - uint32_t n_BWP_start) { +static void nr_pdcch_extract_rbs_single(uint32_t rxdataF_sz, + c16_t rxdataF[][rxdataF_sz], + int32_t est_size, + c16_t dl_ch_estimates[][est_size], + int32_t rx_size, + c16_t rxdataF_ext[][rx_size], + c16_t dl_ch_estimates_ext[][rx_size], + int symbol, + NR_DL_FRAME_PARMS *frame_parms, + uint8_t *coreset_freq_dom, + uint32_t coreset_nbr_rb, + uint32_t n_BWP_start) +{ /* * This function is demapping DM-RS PDCCH RE * Implementing 38.211 Section 7.4.1.3.2 Mapping to physical resources @@ -338,24 +306,19 @@ void nr_pdcch_extract_rbs_single(uint32_t rxdataF_sz, * */ -#define NBR_RE_PER_RB_WITH_DMRS 12 +#define NBR_RE_PER_RB_WITH_DMRS 12 // after removing the 3 DMRS RE, the RB contains 9 RE with PDCCH -#define NBR_RE_PER_RB_WITHOUT_DMRS 9 - uint16_t c_rb; - //uint8_t rb_count_bit; - uint8_t i, j, aarx; - int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext; +#define NBR_RE_PER_RB_WITHOUT_DMRS 9 + for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { + const c16_t *dl_ch0 = dl_ch_estimates[aarx] + frame_parms->ofdm_symbol_size * symbol; + c16_t *rxFbase = rxdataF[aarx] + frame_parms->ofdm_symbol_size * symbol; + LOG_DDD("dl_ch0 = &dl_ch_estimates[aarx = (%d)][0]\n", aarx); - for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { - dl_ch0 = &dl_ch_estimates[aarx][frame_parms->ofdm_symbol_size*symbol]; - LOG_DDD("dl_ch0 = &dl_ch_estimates[aarx = (%d)][0]\n",aarx); - - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)]; - LOG_DDD("dl_ch0_ext = &dl_ch_estimates_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", - aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)); - rxF_ext = &rxdataF_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)]; - LOG_DDD("rxF_ext = &rxdataF_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", - aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)); + const int offset = symbol * coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS; + c16_t *dl_ch0_ext = &dl_ch_estimates_ext[aarx][offset]; + LOG_DDD("dl_ch0_ext = &dl_ch_estimates_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", aarx, offset); + c16_t *rxF_ext = &rxdataF_ext[aarx][offset]; + LOG_DDD("rxF_ext = &rxdataF_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", aarx, offset); /* * The following for loop handles treatment of PDCCH contained in table rxdataF (in frequency domain) @@ -368,157 +331,127 @@ void nr_pdcch_extract_rbs_single(uint32_t rxdataF_sz, * 2. Number of RBs in the system bandwidth is odd * (particular case when the RB with DC as it is treated differently: it is situated in symbol borders of rxdataF) * 2.1 The RB is < than the N_RB_DL/2 -> IQ symbols are in the second half of the rxdataF (from first_carrier_offset) - * 2.2 The RB is > than the N_RB_DL/2 -> IQ symbols are in the first half of the rxdataF (from element 0 + 2nd half RB containing DC) - * 2.3 The RB is == N_RB_DL/2 -> IQ symbols are in the upper border of the rxdataF for first 6 IQ element and the lower border of the rxdataF for the last 6 IQ elements - * If the first RB containing PDCCH within the UE BWP and within the CORESET is higher than half of the system bandwidth (N_RB_DL), - * then the IQ symbol is going to be found at the position 0+c_rb-N_RB_DL/2 in rxdataF and - * we have to point the pointer at (1+c_rb-N_RB_DL/2) in rxdataF + * 2.2 The RB is > than the N_RB_DL/2 -> IQ symbols are in the first half of the rxdataF (from element 0 + 2nd half RB + * containing DC) 2.3 The RB is == N_RB_DL/2 -> IQ symbols are in the upper border of the rxdataF for first 6 IQ + * element and the lower border of the rxdataF for the last 6 IQ elements If the first RB containing PDCCH within the UE BWP + * and within the CORESET is higher than half of the system bandwidth (N_RB_DL), then the IQ symbol is going to be found at + * the position 0+c_rb-N_RB_DL/2 in rxdataF and we have to point the pointer at (1+c_rb-N_RB_DL/2) in rxdataF */ - int c_rb_by6; - c_rb = 0; - for (int rb=0;rb>3] & (1<<(7-(c_rb_by6&7)))) == 0) { - c_rb+=6; - c_rb_by6 = c_rb/6; + while ((coreset_freq_dom[c_rb_by6 >> 3] & (1 << (7 - (c_rb_by6 & 7)))) == 0) { + c_rb += 6; + c_rb_by6 = c_rb / 6; } - rxF=NULL; - - // first we set initial conditions for pointer to rxdataF depending on the situation of the first RB within the CORESET (c_rb = n_BWP_start) - if (((c_rb + n_BWP_start) < (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) == 0)) { - //if RB to be treated is lower than middle system bandwidth then rxdataF pointed at (offset + c_br + symbol * ofdm_symbol_size): even case - rxF = (int32_t *)&rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))+n_BWP_start*12]; - LOG_DDD("in even case c_rb (%d) is lower than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", - c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))); - } - - if (((c_rb + n_BWP_start) >= (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) == 0)) { - // number of RBs is even and c_rb is higher than half system bandwidth (we don't skip DC) - // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF - rxF = (int32_t *)&rxdataF[aarx][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol - LOG_DDD("in even case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", - c_rb,aarx,(12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) + symbol * frame_parms->ofdm_symbol_size)); - } - - if (((c_rb + n_BWP_start) < (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { - //if RB to be treated is lower than middle system bandwidth then rxdataF pointed at (offset + c_br + symbol * ofdm_symbol_size): odd case - rxF = (int32_t *)&rxdataF[aarx][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size]; - LOG_DDD("in odd case c_rb (%d) is lower or equal than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", - c_rb,aarx,(frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size)); - } - - if (((c_rb + n_BWP_start) > (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { - // number of RBs is odd and c_rb is higher than half system bandwidth + 1 - // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF just after the first IQ symbols of the RB containing DC - rxF = (int32_t *)&rxdataF[aarx][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol - LOG_DDD("in odd case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", - c_rb,aarx,(12*(c_rb + n_BWP_start - (frame_parms->N_RB_DL>>1)) - 6 + symbol * frame_parms->ofdm_symbol_size)); - } - - if (((c_rb + n_BWP_start) == (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { // treatment of RB containing the DC + // first we set initial conditions for pointer to rxdataF depending on the situation of the first RB within the CORESET + // (c_rb = n_BWP_start) + if ((frame_parms->N_RB_DL & 1) == 1 && (c_rb + n_BWP_start) == (frame_parms->N_RB_DL >> 1)) { + // treatment of RB containing the DC // if odd number RBs in system bandwidth and first RB to be treated is higher than middle system bandwidth (around DC) - // we have to treat the RB in two parts: first part from i=0 to 5, the data is at the end of rxdataF (pointing at the end of the table) - rxF = (int32_t *)&rxdataF[aarx][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size]; - LOG_DDD("in odd case c_rb (%d) is half N_RB_DL + 1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size = (%d)]\n", - c_rb,aarx,(frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start) + symbol * frame_parms->ofdm_symbol_size)); - j = 0; + // we have to treat the RB in two parts: first part from i=0 to 5, the data is at the end of rxdataF (pointing at the + // end of the table) + c16_t *rxF = rxFbase + frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start); - for (i = 0; i < 6; i++) { //treating first part of the RB note that i=5 would correspond to DC. We treat it in NR + int i = 0, j = 0; + for (; i < 6; i++) { // treating first part of the RB note that i=5 would correspond to DC. We treat it in NR if ((i != 1) && (i != 5)) { dl_ch0_ext[j] = dl_ch0[i]; rxF_ext[j] = rxF[i]; - LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n", - c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short *) &rxF_ext[j]), i, - *(short *) &rxF[i], *(1 + (short *) &rxF[i])); + LOG_DSYMB(""); j++; } else { - LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", - c_rb, i, j, *(short *) &rxF_ext[j], *(1 + (short *) &rxF_ext[j]), i, - *(short *) &rxF[i], *(1 + (short *) &rxF[i])); + LOG_DSYMB("\t\t <==> DM-RS PDCCH, this is a pilot symbol\n"); } } // then we point at the begining of the symbol part of rxdataF do process second part of RB - rxF = (int32_t *)&rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size]; // we point at the 1st part of the rxdataF in symbol - LOG_DDD("in odd case c_rb (%d) is half N_RB_DL +1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][symbol * frame_parms->ofdm_symbol_size = (%d)]\n", - c_rb,aarx,(symbol * frame_parms->ofdm_symbol_size)); for (; i < 12; i++) { if ((i != 9)) { dl_ch0_ext[j] = dl_ch0[i]; - rxF_ext[j] = rxF[i - 6]; - LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n", - c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short *) &rxF_ext[j]), i, - *(short *) &rxF[i-6], *(1 + (short *) &rxF[i-6])); + rxF_ext[j] = rxFbase[i - 6]; + LOG_DSYMB(""); j++; } else { - LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", - c_rb, i, j, *(short *) &rxF_ext[j], *(1 + (short *) &rxF_ext[j]), i, - *(short *) &rxF[i-6], *(1 + (short *) &rxF[i-6])); + LOG_DSYMB("\t\t <==> DM-RS PDCCH, this is a pilot symbol\n"); } } - dl_ch0_ext += NBR_RE_PER_RB_WITHOUT_DMRS; - rxF_ext += NBR_RE_PER_RB_WITHOUT_DMRS; - dl_ch0 += 12; } else { // treatment of any RB that does not contain the DC - j = 0; + c16_t *rxF; + if ((frame_parms->N_RB_DL & 1) == 0) { + if ((c_rb + n_BWP_start) < (frame_parms->N_RB_DL >> 1)) + // if RB to be treated is lower than middle system bandwidth then rxdataF pointed + // at (offset + c_br + symbol * ofdm_symbol_size): even case + rxF = rxFbase + (frame_parms->first_carrier_offset + 12 * c_rb) + n_BWP_start * 12; + else + // number of RBs is even and c_rb is higher than half system bandwidth (we don't skip DC) + // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF + // we point at the 1st part of the rxdataF in symbol + rxF = rxFbase + 12 * (c_rb + n_BWP_start - (frame_parms->N_RB_DL >> 1)); + } else { + if ((c_rb + n_BWP_start) < (frame_parms->N_RB_DL >> 1)) + // if RB to be treated is lower than middle system bandwidth then rxdataF pointed + // at (offset + c_br + symbol * ofdm_symbol_size): odd case + rxF = rxFbase + frame_parms->first_carrier_offset + 12 * (c_rb + n_BWP_start); + else if ((c_rb + n_BWP_start) > (frame_parms->N_RB_DL >> 1)) + // number of RBs is odd and c_rb is higher than half system bandwidth + 1 + // if these conditions are true the pointer has to be situated at the 1st part of + // the rxdataF just after the first IQ symbols of the RB containing DC + // we point at the 1st part of the rxdataF in symbol + rxF = rxFbase + 12 * (c_rb + n_BWP_start - (frame_parms->N_RB_DL >> 1)) - 6; + } - for (i = 0; i < 12; i++) { + int j = 0; + + for (int i = 0; i < 12; i++) { if ((i != 1) && (i != 5) && (i != 9)) { rxF_ext[j] = rxF[i]; - LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n", - c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short *) &rxF_ext[j]), i, - *(short *) &rxF[i], *(1 + (short *) &rxF[i])); dl_ch0_ext[j] = dl_ch0[i]; + LOG_DSYMB(""); j++; } else { - LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", - c_rb, i, j, *(short *) &rxF_ext[j], *(1 + (short *) &rxF_ext[j]), i, - *(short *) &rxF[i], *(1 + (short *) &rxF[i])); + LOG_DSYMB("\t\t <==> DM-RS PDCCH, this is a pilot symbol\n"); } } - - dl_ch0_ext += NBR_RE_PER_RB_WITHOUT_DMRS; - rxF_ext += NBR_RE_PER_RB_WITHOUT_DMRS; - dl_ch0 += 12; } + dl_ch0_ext += NBR_RE_PER_RB_WITHOUT_DMRS; + rxF_ext += NBR_RE_PER_RB_WITHOUT_DMRS; + dl_ch0 += 12; } } } #define print_shorts(s,x) printf("%s %d,%d,%d,%d,%d,%d,%d,%d\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7]) -void nr_pdcch_channel_compensation(int32_t rx_size, int32_t rxdataF_ext[][rx_size], - int32_t dl_ch_estimates_ext[][rx_size], - int32_t rxdataF_comp[][rx_size], +void nr_pdcch_channel_compensation(int32_t rx_size, + c16_t rxdataF_ext[][rx_size], + c16_t dl_ch_estimates_ext[][rx_size], + c16_t rxdataF_comp[][rx_size], int32_t **rho, NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint8_t output_shift, - uint32_t coreset_nbr_rb) { - uint16_t rb; //,nb_rb=20; - uint8_t aarx; - simde__m128i mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; - simde__m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; - - for (aarx=0; aarxnb_antennas_rx; aarx++) { - dl_ch128 = (simde__m128i *)&dl_ch_estimates_ext[aarx][symbol*coreset_nbr_rb*12]; - rxdataF128 = (simde__m128i *)&rxdataF_ext[aarx][symbol*coreset_nbr_rb*12]; - rxdataF_comp128 = (simde__m128i *)&rxdataF_comp[aarx][symbol*coreset_nbr_rb*12]; + uint32_t coreset_nbr_rb) +{ + for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { + simde__m128i *dl_ch128 = (simde__m128i *)&dl_ch_estimates_ext[aarx][symbol * coreset_nbr_rb * 12]; + simde__m128i *rxdataF128 = (simde__m128i *)&rxdataF_ext[aarx][symbol * coreset_nbr_rb * 12]; + simde__m128i *rxdataF_comp128 = (simde__m128i *)&rxdataF_comp[aarx][symbol * coreset_nbr_rb * 12]; //printf("ch compensation dl_ch ext addr %p \n", &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]); //printf("rxdataf ext addr %p symbol %d\n", &rxdataF_ext[aarx][symbol*20*12], symbol); //printf("rxdataf_comp addr %p\n",&rxdataF_comp[(aatx<<1)+aarx][symbol*20*12]); - for (rb=0; rb<(coreset_nbr_rb*3)>>2; rb++) { + for (int rb = 0; rb < (coreset_nbr_rb * 3) >> 2; rb++) { // multiply by conjugated channel - mmtmpP0 = simde_mm_madd_epi16(dl_ch128[0],rxdataF128[0]); + simde__m128i mmtmpP0 = simde_mm_madd_epi16(dl_ch128[0], rxdataF128[0]); //print_ints("re",&mmtmpP0); // mmtmpP0 contains real part of 4 consecutive outputs (32-bit) - mmtmpP1 = simde_mm_shufflelo_epi16(dl_ch128[0], SIMDE_MM_SHUFFLE(2,3,0,1)); + simde__m128i mmtmpP1 = simde_mm_shufflelo_epi16(dl_ch128[0], SIMDE_MM_SHUFFLE(2, 3, 0, 1)); mmtmpP1 = simde_mm_shufflehi_epi16(mmtmpP1, SIMDE_MM_SHUFFLE(2,3,0,1)); mmtmpP1 = simde_mm_sign_epi16(mmtmpP1,*(simde__m128i *)&conjugate[0]); //print_ints("im",&mmtmpP1); @@ -528,8 +461,8 @@ void nr_pdcch_channel_compensation(int32_t rx_size, int32_t rxdataF_ext[][rx_siz // print_ints("re(shift)",&mmtmpP0); mmtmpP1 = simde_mm_srai_epi32(mmtmpP1,output_shift); // print_ints("im(shift)",&mmtmpP1); - mmtmpP2 = simde_mm_unpacklo_epi32(mmtmpP0,mmtmpP1); - mmtmpP3 = simde_mm_unpackhi_epi32(mmtmpP0,mmtmpP1); + simde__m128i mmtmpP2 = simde_mm_unpacklo_epi32(mmtmpP0, mmtmpP1); + simde__m128i mmtmpP3 = simde_mm_unpackhi_epi32(mmtmpP0, mmtmpP1); //print_ints("c0",&mmtmpP2); //print_ints("c1",&mmtmpP3); rxdataF_comp128[0] = simde_mm_packs_epi32(mmtmpP2,mmtmpP3); @@ -572,49 +505,43 @@ void nr_pdcch_channel_compensation(int32_t rx_size, int32_t rxdataF_ext[][rx_siz for (int i=0; i<12 ; i++) LOG_DDD("rxdataF128[%d]=(%d,%d) X dlch[%d]=(%d,%d) rxdataF_comp128[%d]=(%d,%d)\n", - (rb*12)+i, ((short *)rxdataF128)[i<<1],((short *)rxdataF128)[1+(i<<1)], - (rb*12)+i, ((short *)dl_ch128)[i<<1],((short *)dl_ch128)[1+(i<<1)], - (rb*12)+i, ((short *)rxdataF_comp128)[i<<1],((short *)rxdataF_comp128)[1+(i<<1)]); + (rb * 12) + i, + ((c16_t *)rxdataF128)[i].r, + ((c16_t *)rxdataF128)[i].i, + (rb * 12) + i, + ((c16_t *)dl_ch128)[i].r, + ((c16_t *)dl_ch128)[i].i, + (rb * 12) + i, + ((c16_t *)rxdataF_comp128)[i].r, + ((c16_t *)rxdataF_comp128)[i].i); dl_ch128+=3; rxdataF128+=3; rxdataF_comp128+=3; } } - - simde_mm_empty(); - simde_m_empty(); } - -void nr_pdcch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, - int32_t rx_size, - int32_t rxdataF_comp[][rx_size], - uint8_t symbol) { - simde__m128i *rxdataF_comp128_0,*rxdataF_comp128_1; - int32_t i; - +static void nr_pdcch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, int32_t rx_size, c16_t rxdataF_comp[][rx_size], int symbol) +{ if (frame_parms->nb_antennas_rx>1) { - rxdataF_comp128_0 = (simde__m128i *)&rxdataF_comp[0][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128_1 = (simde__m128i *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; - + simde__m128i *rxdataF_comp128_0 = (simde__m128i *)&rxdataF_comp[0][symbol * frame_parms->N_RB_DL * 12]; + simde__m128i *rxdataF_comp128_1 = (simde__m128i *)&rxdataF_comp[1][symbol * frame_parms->N_RB_DL * 12]; + const int sz = frame_parms->N_RB_DL * 3; // MRC on each re of rb - for (i=0; iN_RB_DL*3; i++) { + for (int i = 0; i < sz; i++) { rxdataF_comp128_0[i] = simde_mm_adds_epi16(simde_mm_srai_epi16(rxdataF_comp128_0[i],1),simde_mm_srai_epi16(rxdataF_comp128_1[i],1)); } } - - simde_mm_empty(); - simde_m_empty(); } -int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, - const UE_nr_rxtx_proc_t *proc, - int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size], - int16_t *pdcch_e_rx, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +void nr_rx_pdcch(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + int32_t pdcch_est_size, + c16_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t *pdcch_e_rx, + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; @@ -626,15 +553,15 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // Pointers to extracted PDCCH symbols in frequency-domain. int32_t rx_size = ((4 * frame_parms->N_RB_DL * 12 + 31) >> 5) << 5; - __attribute__ ((aligned(32))) int32_t rxdataF_ext[frame_parms->nb_antennas_rx][rx_size]; - __attribute__ ((aligned(32))) int32_t rxdataF_comp[frame_parms->nb_antennas_rx][rx_size]; - __attribute__ ((aligned(32))) int32_t pdcch_dl_ch_estimates_ext[frame_parms->nb_antennas_rx][rx_size]; + __attribute__((aligned(32))) c16_t rxdataF_ext[frame_parms->nb_antennas_rx][rx_size]; + __attribute__((aligned(32))) c16_t rxdataF_comp[frame_parms->nb_antennas_rx][rx_size]; + __attribute__((aligned(32))) c16_t pdcch_dl_ch_estimates_ext[frame_parms->nb_antennas_rx][rx_size]; memset(rxdataF_comp, 0, sizeof(rxdataF_comp)); // Pointer to llrs, 4-bit resolution. - int32_t llr_size = 2*4*n_rb*9; - int16_t llr[llr_size]; + int32_t llr_size = 4 * n_rb * 9; + c16_t llr[llr_size]; memset(llr, 0, sizeof(llr)); @@ -706,23 +633,15 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, s, n_rb); - UEscopeCopy(ue, pdcchLlr, llr, sizeof(int16_t), 1, llr_size, 0); + UEscopeCopy(ue, pdcchLlr, llr, sizeof(c16_t), 1, llr_size, 0); -#if T_TRACER - - // T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), - // T_INT(n_pdcch_symbols), - // T_BUFFER(pdcch_vars[eNB_id]->rxdataF_comp, frame_parms->N_RB_DL*12*n_pdcch_symbols* 4)); - -#endif #ifdef DEBUG_DCI_DECODING printf("demapping: slot %u, mi %d\n",slot,get_mi(frame_parms,slot)); #endif } - LOG_D(PHY,"we enter nr_pdcch_demapping_deinterleaving(), number of candidates %d\n",rel15->number_of_candidates); - nr_pdcch_demapping_deinterleaving((uint32_t *) llr, - (uint32_t *) pdcch_e_rx, + nr_pdcch_demapping_deinterleaving(llr, + pdcch_e_rx, rel15->coreset.duration, rel15->coreset.StartSymbolIndex, n_rb, @@ -732,18 +651,13 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, rel15->number_of_candidates, rel15->CCE, rel15->L); - - LOG_D(PHY,"we end nr_pdcch_demapping_deinterleaving()\n"); - LOG_D(PHY,"Ending nr_rx_pdcch() function\n"); - - return (0); } -void nr_pdcch_unscrambling(int16_t *e_rx, - uint16_t scrambling_RNTI, - uint32_t length, - uint16_t pdcch_DMRS_scrambling_id, - int16_t *z2) +static void nr_pdcch_unscrambling(c16_t *e_rx, + uint16_t scrambling_RNTI, + uint32_t length, + uint16_t pdcch_DMRS_scrambling_id, + int16_t *z2) { int i; uint8_t reset; @@ -756,7 +670,7 @@ void nr_pdcch_unscrambling(int16_t *e_rx, x2 = ((rnti << 16) + n_id) % (1U << 31); // this is c_init in 38.211 v15.1.0 Section 7.3.2.3 LOG_D(PHY,"PDCCH Unscrambling x2 %x : scrambling_RNTI %x\n", x2, rnti); - + int16_t *ptr = &e_rx[0].r; for (i = 0; i < length; i++) { if ((i & 0x1f) == 0) { s = lte_gold_generic(&x1, &x2, reset); @@ -764,9 +678,9 @@ void nr_pdcch_unscrambling(int16_t *e_rx, } if (((s >> (i % 32)) & 1) == 1) - z2[i] = -e_rx[i]; + z2[i] = -ptr[i]; else - z2[i]=e_rx[i]; + z2[i] = ptr[i]; } } @@ -804,7 +718,7 @@ static uint16_t nr_dci_false_detection(uint64_t *dci, uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, - int16_t *pdcch_e_rx, + c16_t *pdcch_e_rx, fapi_nr_dci_indication_t *dci_ind, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { @@ -841,22 +755,21 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, nr_pdcch_unscrambling(&pdcch_e_rx[e_rx_cand_idx], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); -#ifdef DEBUG_DCI_DECODING - uint32_t *z = (uint32_t *) &e_rx[e_rx_cand_idx]; - for (int index_z = 0; index_z < L*6; index_z++){ - for (int i=0; i<9; i++) { - LOG_I(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[9*index_z + i],*(1 + (int16_t *) &z[9*index_z + i])); - } - } -#endif uint16_t crc = polar_decoder_int16(tmp_e, dci_estimation, 1, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L); n_rnti = rel15->rnti; - LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx )\n", - proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length, *(unsigned long long*)dci_estimation); + LOG_D(PHY, + "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx )\n", + proc->frame_rx, + proc->nr_slot_rx, + n_rnti, + nr_dci_format_string[rel15->dci_format_options[k]], + CCEind, + dci_length, + *(unsigned long long *)dci_estimation); if (crc == n_rnti) { LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx)\n", proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length,*(unsigned long long*)dci_estimation); @@ -886,7 +799,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, LOG_D(PHY,"(%i.%i) Decoded crc %x does not match rnti %x for DCI format %d\n", proc->frame_rx, proc->nr_slot_rx, crc, n_rnti, rel15->dci_format_options[k]); } } - e_rx_cand_idx += 9*L*6*2; //e_rx index for next candidate (L CCEs, 6 REGs per CCE and 9 REs per REG and 2 uint16_t per RE) + e_rx_cand_idx += 9 * L * 6; // e_rx index for next candidate (L CCEs, 6 REGs per CCE and 9 REs per REG ) } return(dci_ind->number_of_dcis); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index d673baadda..26156046ef 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -266,13 +266,13 @@ void nr_dlsch_unscrambling(int16_t* llr, uint32_t Nid, uint32_t n_RNTI); -int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, - const UE_nr_rxtx_proc_t *proc, - int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size], - int16_t *pdcch_e_rx, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); +void nr_rx_pdcch(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + int32_t pdcch_est_size, + c16_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t *pdcch_e_rx, + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); /*! \brief Performs detection of SSS to find cell ID and other framing parameters (FDD/TDD, normal/extended prefix) @param phy_vars_ue Pointer to UE variables @@ -361,15 +361,9 @@ void nr_sl_rf_card_config_freq(PHY_VARS_NR_UE *ue, openair0_config_t *openair0_cfg, int freq_offset); -void nr_pdcch_unscrambling(int16_t *z, - uint16_t scrambling_RNTI, - uint32_t length, - uint16_t pdcch_DMRS_scrambling_id, - int16_t *z2); - uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, - int16_t *pdcch_e_rx, + c16_t *pdcch_e_rx, fapi_nr_dci_indication_t *dci_ind, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 2ff16ed18d..b3ce6944bb 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -152,7 +152,7 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t pdcch_dl_ch_estimates[][pdcch_est_size], nr_phy_data_t *phy_data, int n_ss, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 1a2e410071..af7f048bed 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -426,7 +426,7 @@ unsigned int nr_get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t pdcch_dl_ch_estimates[][pdcch_est_size], nr_phy_data_t *phy_data, int n_ss, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) @@ -444,7 +444,7 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, /// PDCCH/DCI e-sequence (input to rate matching). int32_t pdcch_e_rx_size = NR_MAX_PDCCH_SIZE; - int16_t pdcch_e_rx[pdcch_e_rx_size]; + c16_t pdcch_e_rx[pdcch_e_rx_size]; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN); nr_rx_pdcch(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, pdcch_e_rx, rel15, rxdataF); @@ -861,9 +861,7 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr const uint32_t rxdataF_sz = ue->frame_parms.samples_per_slot_wCP; __attribute__ ((aligned(32))) c16_t rxdataF[ue->frame_parms.nb_antennas_rx][rxdataF_sz]; // checking if current frame is compatible with SSB periodicity - if (cfg->ssb_table.ssb_period == 0 || - !(frame_rx%(1<<(cfg->ssb_table.ssb_period-1)))){ - + if (cfg->ssb_table.ssb_period == 0 || !(frame_rx % (1 << (cfg->ssb_table.ssb_period - 1)))) { const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size; // loop over SSB blocks for(int ssb_index=0; ssb_indexLmax; ssb_index++) { @@ -874,9 +872,7 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr int ssb_slot = ssb_start_symbol/fp->symbols_per_slot; int ssb_slot_2 = (cfg->ssb_table.ssb_period == 0) ? ssb_slot+(fp->slots_per_frame>>1) : -1; - if (ssb_slot == nr_slot_rx || - ssb_slot_2 == nr_slot_rx) { - + if (ssb_slot == nr_slot_rx || ssb_slot_2 == nr_slot_rx) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); @@ -990,7 +986,7 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr // Hold the channel estimates in frequency domain. int32_t pdcch_est_size = ((((fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH))+15)/16)*16); - __attribute__ ((aligned(16))) int32_t pdcch_dl_ch_estimates[4*fp->nb_antennas_rx][pdcch_est_size]; + __attribute__((aligned(16))) c16_t pdcch_dl_ch_estimates[4 * fp->nb_antennas_rx][pdcch_est_size]; uint8_t dci_cnt = 0; for(int n_ss = 0; n_ssnb_search_space; n_ss++) { diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 662a59992b..9f084f190c 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -117,7 +117,7 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, - int32_t pdcch_dl_ch_estimates[][pdcch_est_size], + c16_t pdcch_dl_ch_estimates[][pdcch_est_size], nr_phy_data_t *phy_data, int n_ss, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index a5df641f4a..28995e8c24 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -377,8 +377,13 @@ int nr_ue_process_dci_indication_pdu(NR_UE_MAC_INST_t *mac, { dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][dci->dci_format]; - LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", - dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits); + LOG_D(MAC, + "Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", + dci->rnti, + dci->dci_format, + dci->n_CCE, + dci->payloadSize, + *(unsigned long long *)dci->payloadBits); const int ret = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, dci->ss_type, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15, slot); if ((ret & 1) == 1) return -1; From 8666b084d57d9e0f4196446c3289da138bee5901 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Fri, 23 Feb 2024 12:02:34 +0100 Subject: [PATCH 16/54] improve code of dci decoding and add tracing for all dci fields --- common/utils/LOG/log.c | 1 + common/utils/LOG/log.h | 4 +- common/utils/T/T_messages.txt | 21 + openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 68 +- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 10 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 38 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 841 ++++++------------ 8 files changed, 368 insertions(+), 617 deletions(-) diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 2df65b3653..389ce6aede 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -497,6 +497,7 @@ int logInit (void) register_log_component("GNB_APP","log",GNB_APP); register_log_component("NR_RRC","log",NR_RRC); register_log_component("NR_MAC","log",NR_MAC); + register_log_component("NR_DCI", "log", NR_DCI); register_log_component("NR_PHY","log",NR_PHY); register_log_component("NGAP","",NGAP); register_log_component("ITTI","log",ITTI); diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 0004525d3c..4b43ff45d1 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -219,6 +219,7 @@ typedef enum { GNB_APP, NR_RRC, NR_MAC, + NR_DCI, NR_PHY, LOADER, ASN1, @@ -227,8 +228,7 @@ typedef enum { ITTI, UTIL, MAX_LOG_PREDEF_COMPONENTS, -} -comp_name_t; +} comp_name_t; #define MAX_LOG_DYNALLOC_COMPONENTS 20 #define MAX_LOG_COMPONENTS (MAX_LOG_PREDEF_COMPONENTS + MAX_LOG_DYNALLOC_COMPONENTS) diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 71cd8a5486..2dd86fb9b4 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -361,6 +361,27 @@ ID = LEGACY_NR_MAC_TRACE GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_TRACE:LEGACY FORMAT = string,log +ID = LEGACY_NR_DCI_INFO + DESC = NR_MAC legacy logs - info level + GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log +ID = LEGACY_NR_DCI_ERROR + DESC = NR_MAC legacy logs - error level + GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log +ID = LEGACY_NR_DCI_WARNING + DESC = NR_MAC legacy logs - warning level + GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_WARNING:LEGACY + FORMAT = string,log +ID = LEGACY_NR_DCI_DEBUG + DESC = NR_MAC legacy logs - debug level + GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log +ID = LEGACY_NR_DCI_TRACE + DESC = NR_MAC legacy logs - trace level + GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_TRACE:LEGACY + FORMAT = string,log + ID = LEGACY_PHY_INFO DESC = PHY legacy logs - info level GROUP = ALL:LEGACY_PHY:LEGACY_GROUP_INFO:LEGACY diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 5b315a463f..0bc9ea70fe 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -382,7 +382,7 @@ static void nr_pdcch_extract_rbs_single(uint32_t rxdataF_sz, } } else { // treatment of any RB that does not contain the DC - c16_t *rxF; + c16_t *rxF=NULL; if ((frame_parms->N_RB_DL & 1) == 0) { if ((c_rb + n_BWP_start) < (frame_parms->N_RB_DL >> 1)) // if RB to be treated is lower than middle system bandwidth then rxdataF pointed @@ -405,7 +405,7 @@ static void nr_pdcch_extract_rbs_single(uint32_t rxdataF_sz, // we point at the 1st part of the rxdataF in symbol rxF = rxFbase + 12 * (c_rb + n_BWP_start - (frame_parms->N_RB_DL >> 1)) - 6; } - + AssertFatal(rxF, "bug"); int j = 0; for (int i = 0; i < 12; i++) { @@ -716,16 +716,14 @@ static uint16_t nr_dci_false_detection(uint64_t *dci, return x; } -uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, - const UE_nr_rxtx_proc_t *proc, - c16_t *pdcch_e_rx, - fapi_nr_dci_indication_t *dci_ind, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) +void nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + c16_t *pdcch_e_rx, + fapi_nr_dci_indication_t *dci_ind, + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { - //int gNB_id = 0; - int16_t tmp_e[16*108]; - rnti_t n_rnti; int e_rx_cand_idx = 0; + *dci_ind = (fapi_nr_dci_indication_t){.SFN = proc->frame_rx, .slot = proc->nr_slot_rx}; for (int j=0;jnumber_of_candidates;j++) { int CCEind = rel15->CCE[j]; @@ -736,15 +734,13 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, for (int k = 0; k < rel15->num_dci_options; k++) { // skip this candidate if we've already found one with the // same rnti and format at a different aggregation level - int dci_found=0; - for (int ind=0;ind < dci_ind->number_of_dcis ; ind++) { - if (rel15->rnti== dci_ind->dci_list[ind].rnti && - rel15->dci_format_options[k]==dci_ind->dci_list[ind].dci_format) { - dci_found=1; - break; + int ind; + for (ind = 0; ind < dci_ind->number_of_dcis; ind++) { + if (rel15->rnti == dci_ind->dci_list[ind].rnti && rel15->dci_format_options[k] == dci_ind->dci_list[ind].dci_format) { + break; } } - if (dci_found == 1) + if (ind < dci_ind->number_of_dcis) continue; int dci_length = rel15->dci_length_options[k]; uint64_t dci_estimation[2]= {0}; @@ -752,46 +748,47 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, LOG_D(PHY, "(%i.%i) Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n", proc->frame_rx, proc->nr_slot_rx, j, rel15->number_of_candidates, CCEind, e_rx_cand_idx, L, dci_length, nr_dci_format_string[rel15->dci_format_options[k]]); - + int16_t tmp_e[16 * 108]; nr_pdcch_unscrambling(&pdcch_e_rx[e_rx_cand_idx], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); - + // this polar version decodes 64 bits max, dci_estimation[1] will never be filled uint16_t crc = polar_decoder_int16(tmp_e, dci_estimation, 1, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L); - n_rnti = rel15->rnti; + rnti_t n_rnti = rel15->rnti; LOG_D(PHY, - "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx )\n", + "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %lx, is rnti: %d )\n", proc->frame_rx, proc->nr_slot_rx, n_rnti, nr_dci_format_string[rel15->dci_format_options[k]], CCEind, dci_length, - *(unsigned long long *)dci_estimation); + dci_estimation[0], + crc == n_rnti); if (crc == n_rnti) { - LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx)\n", - proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length,*(unsigned long long*)dci_estimation); uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,L*108,n_rnti, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L); ue->dci_thres = (ue->dci_thres + mb) / 2; if (mb > (ue->dci_thres+30)) { LOG_W(PHY,"DCI false positive. Dropping DCI index %d. Mismatched bits: %d/%d. Current DCI threshold: %d\n",j,mb,L*108,ue->dci_thres); continue; } else { - dci_ind->SFN = proc->frame_rx; - dci_ind->slot = proc->nr_slot_rx; - dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti; - dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind; - dci_ind->dci_list[dci_ind->number_of_dcis].N_CCE = L; - dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; - dci_ind->dci_list[dci_ind->number_of_dcis].ss_type = rel15->ss_type_options[k]; - dci_ind->dci_list[dci_ind->number_of_dcis].coreset_type = rel15->coreset.CoreSetType; + AssertFatal(dci_ind->number_of_dcis < sizeofArray(dci_ind->dci_list), "Fix allocation\n"); + fapi_nr_dci_indication_pdu_t *dci = dci_ind->dci_list + dci_ind->number_of_dcis; + *dci = (fapi_nr_dci_indication_pdu_t){ + .rnti = n_rnti, + .n_CCE = CCEind, + .N_CCE = L, + .dci_format = rel15->dci_format_options[k], + .ss_type = rel15->ss_type_options[k], + .coreset_type = rel15->coreset.CoreSetType, + }; int n_rb, rb_offset; get_coreset_rballoc(rel15->coreset.frequency_domain_resource, &n_rb, &rb_offset); - dci_ind->dci_list[dci_ind->number_of_dcis].cset_start = rel15->BWPStart + rb_offset; - dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length; - memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8); + dci->cset_start = rel15->BWPStart + rb_offset; + dci->payloadSize = dci_length; + memcpy(dci->payloadBits, dci_estimation, (dci_length + 7) / 8); dci_ind->number_of_dcis++; break; // If DCI is found, no need to check for remaining DCI lengths } @@ -801,5 +798,4 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, } e_rx_cand_idx += 9 * L * 6; // e_rx index for next candidate (L CCEs, 6 REGs per CCE and 9 REs per REG ) } - return(dci_ind->number_of_dcis); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 26156046ef..69169c1744 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -361,11 +361,11 @@ void nr_sl_rf_card_config_freq(PHY_VARS_NR_UE *ue, openair0_config_t *openair0_cfg, int freq_offset); -uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, - const UE_nr_rxtx_proc_t *proc, - c16_t *pdcch_e_rx, - fapi_nr_dci_indication_t *dci_ind, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); +void nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, + const UE_nr_rxtx_proc_t *proc, + c16_t *pdcch_e_rx, + fapi_nr_dci_indication_t *dci_ind, + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); /** \brief This function is the top-level entry point to PDSCH demodulation, after frequency-domain transformation and channel estimation. It performs diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index af7f048bed..c874cd022e 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -433,9 +433,6 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; - unsigned int dci_cnt=0; - fapi_nr_dci_indication_t dci_ind = {0}; - nr_downlink_indication_t dl_indication; NR_UE_PDCCH_CONFIG *phy_pdcch_config = &phy_data->phy_pdcch_config; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &phy_pdcch_config->pdcch_config[n_ss]; @@ -446,37 +443,24 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, int32_t pdcch_e_rx_size = NR_MAX_PDCCH_SIZE; c16_t pdcch_e_rx[pdcch_e_rx_size]; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN); nr_rx_pdcch(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, pdcch_e_rx, rel15, rxdataF); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT); + fapi_nr_dci_indication_t dci_ind; + nr_dci_decoding_procedure(ue, proc, pdcch_e_rx, &dci_ind, rel15); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_IN); - -#ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure for search space %d)\n", - n_ss); -#endif - - dci_cnt = nr_dci_decoding_procedure(ue, proc, pdcch_e_rx, &dci_ind, rel15); - -#ifdef NR_PDCCH_SCHED_DEBUG - LOG_I(PHY,"<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt); -#endif - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT); - - for (int i=0; i rnti %x : format %d\n", - ue->Mod_id,frame_rx%1024,nr_slot_rx, + for (int i = 0; i < dci_ind.number_of_dcis; i++) { + LOG_D(PHY, + "[UE %d] AbsSubFrame %d.%d: DCI %i of %d total DCIs found --> rnti %x : format %d\n", + ue->Mod_id, + frame_rx % 1024, + nr_slot_rx, i + 1, - dci_cnt, + dci_ind.number_of_dcis, dci_ind.dci_list[i].rnti, dci_ind.dci_list[i].dci_format); } - dci_ind.number_of_dcis = dci_cnt; - + nr_downlink_indication_t dl_indication; // fill dl_indication message nr_fill_dl_indication(&dl_indication, &dci_ind, NULL, proc, ue, phy_data); // send to mac @@ -485,7 +469,7 @@ int nr_ue_pdcch_procedures(PHY_VARS_NR_UE *ue, stop_meas(&ue->dlsch_rx_pdcch_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT); - return(dci_cnt); + return (dci_ind.number_of_dcis); } static int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 57883839d5..fedd8e6bbe 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -500,7 +500,7 @@ int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, int *slot_tx, const long k2); -int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti); +int get_rnti_type(const NR_UE_MAC_INST_t *mac, const uint16_t rnti); // Configuration of Msg3 PDU according to clauses: // - 8.3 of 3GPP TS 38.213 version 16.3.0 Release 16 diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 28995e8c24..4e33ad7aba 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -58,11 +58,9 @@ #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" -//#define DEBUG_MIB -//#define ENABLE_MAC_PAYLOAD_DEBUG 1 -//#define DEBUG_EXTRACT_DCI -//#define DEBUG_RAR - +// #define DEBUG_MIB +// #define ENABLE_MAC_PAYLOAD_DEBUG 1 +// #define DEBUG_RAR extern uint32_t N_RB_DL; /* TS 38.213 9.2.5.2 UE procedure for multiplexing HARQ-ACK/SR and CSI in a PUCCH */ @@ -165,33 +163,32 @@ const initial_pucch_resource_t initial_pucch_resource[16] = { /* 15 */ { 1, 0, 14, 0, 4, { 0, 3, 6, 9 } }, }; static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, - nr_dci_format_t dci_format, - uint8_t dci_size, - uint16_t rnti, - int ss_type, - uint64_t *dci_pdu, + const nr_dci_format_t dci_format, + const uint8_t dci_size, + const uint16_t rnti, + const int ss_type, + const uint8_t *dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, - int slot); + const int slot); -int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti) +int get_rnti_type(const NR_UE_MAC_INST_t *mac, const uint16_t rnti) { + const RA_config_t *ra = &mac->ra; + nr_rnti_type_t rnti_type; - RA_config_t *ra = &mac->ra; - nr_rnti_type_t rnti_type; - - if (rnti == ra->ra_rnti) { - rnti_type = TYPE_RA_RNTI_; - } else if (rnti == ra->t_crnti && (ra->ra_state == WAIT_RAR || ra->ra_state == WAIT_CONTENTION_RESOLUTION) ) { - rnti_type = TYPE_TC_RNTI_; - } else if (rnti == mac->crnti) { - rnti_type = TYPE_C_RNTI_; - } else if (rnti == 0xFFFE) { - rnti_type = TYPE_P_RNTI_; - } else if (rnti == 0xFFFF) { - rnti_type = TYPE_SI_RNTI_; - } else { - AssertFatal(1 == 0, "Not identified/handled rnti %d \n", rnti); - } + if (rnti == ra->ra_rnti) { + rnti_type = TYPE_RA_RNTI_; + } else if (rnti == ra->t_crnti && (ra->ra_state == WAIT_RAR || ra->ra_state == WAIT_CONTENTION_RESOLUTION)) { + rnti_type = TYPE_TC_RNTI_; + } else if (rnti == mac->crnti) { + rnti_type = TYPE_C_RNTI_; + } else if (rnti == 0xFFFE) { + rnti_type = TYPE_P_RNTI_; + } else if (rnti == 0xFFFF) { + rnti_type = TYPE_SI_RNTI_; + } else { + AssertFatal(1 == 0, "Not identified/handled rnti %d \n", rnti); + } LOG_D(MAC, "Returning rnti_type %s \n", rnti_types(rnti_type)); @@ -384,7 +381,14 @@ int nr_ue_process_dci_indication_pdu(NR_UE_MAC_INST_t *mac, dci->n_CCE, dci->payloadSize, *(unsigned long long *)dci->payloadBits); - const int ret = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, dci->ss_type, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15, slot); + const int ret = nr_extract_dci_info(mac, + dci->dci_format, + dci->payloadSize, + dci->rnti, + dci->ss_type, + dci->payloadBits, + def_dci_pdu_rel15, + slot); if ((ret & 1) == 1) return -1; else if (ret == 2) { @@ -1364,10 +1368,11 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, // only for ack/nack if (pucch->initial_pucch_id > -1 && pucch->pucch_resource == NULL) { - int pucch_resourcecommon = *current_UL_BWP->pucch_ConfigCommon->pucch_ResourceCommon; - pucch_pdu->format_type = initial_pucch_resource[pucch_resourcecommon].format; - pucch_pdu->start_symbol_index = initial_pucch_resource[pucch_resourcecommon].startingSymbolIndex; - pucch_pdu->nr_of_symbols = initial_pucch_resource[pucch_resourcecommon].nrofSymbols; + const int idx = *current_UL_BWP->pucch_ConfigCommon->pucch_ResourceCommon; + const initial_pucch_resource_t pucch_resourcecommon = initial_pucch_resource[idx]; + pucch_pdu->format_type = pucch_resourcecommon.format; + pucch_pdu->start_symbol_index = pucch_resourcecommon.startingSymbolIndex; + pucch_pdu->nr_of_symbols = pucch_resourcecommon.nrofSymbols; pucch_pdu->bwp_size = current_UL_BWP->BWPSize; pucch_pdu->bwp_start = current_UL_BWP->BWPStart; @@ -1377,18 +1382,20 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, if (pucch->initial_pucch_id == 15) RB_BWP_offset = pucch_pdu->bwp_size >> 2; else - RB_BWP_offset = initial_pucch_resource[pucch_resourcecommon].PRB_offset; + RB_BWP_offset = pucch_resourcecommon.PRB_offset; - int N_CS = initial_pucch_resource[pucch_resourcecommon].nb_CS_indexes; + int N_CS = pucch_resourcecommon.nb_CS_indexes; if (pucch->initial_pucch_id >> 3 == 0) { - pucch_pdu->prb_start = RB_BWP_offset + (pucch->initial_pucch_id / N_CS); - pucch_pdu->second_hop_prb = pucch_pdu->bwp_size - 1 - RB_BWP_offset - (pucch->initial_pucch_id / N_CS); - pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch_resourcecommon].initial_CS_indexes[pucch->initial_pucch_id % N_CS]; + const int tmp = pucch->initial_pucch_id / N_CS; + pucch_pdu->prb_start = RB_BWP_offset + tmp; + pucch_pdu->second_hop_prb = pucch_pdu->bwp_size - 1 - RB_BWP_offset - tmp; + pucch_pdu->initial_cyclic_shift = pucch_resourcecommon.initial_CS_indexes[pucch->initial_pucch_id % N_CS]; } else { - pucch_pdu->prb_start = pucch_pdu->bwp_size - 1 - RB_BWP_offset - ((pucch->initial_pucch_id - 8) / N_CS); - pucch_pdu->second_hop_prb = RB_BWP_offset + ((pucch->initial_pucch_id - 8) / N_CS); - pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch_resourcecommon].initial_CS_indexes[(pucch->initial_pucch_id - 8) % N_CS]; + const int tmp = (pucch->initial_pucch_id - 8) / N_CS; + pucch_pdu->prb_start = pucch_pdu->bwp_size - 1 - RB_BWP_offset - tmp; + pucch_pdu->second_hop_prb = RB_BWP_offset + tmp; + pucch_pdu->initial_cyclic_shift = pucch_resourcecommon.initial_CS_indexes[(pucch->initial_pucch_id - 8) % N_CS]; } pucch_pdu->freq_hop_flag = 1; pucch_pdu->time_domain_occ_idx = 0; @@ -1413,12 +1420,14 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, NR_PUSCH_Config_t *pusch_Config = current_UL_BWP ? current_UL_BWP->pusch_Config : NULL; if (pusch_Config) { pusch_id = pusch_Config->dataScramblingIdentityPUSCH; - if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL && - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->transformPrecodingDisabled != NULL) - id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->transformPrecodingDisabled->scramblingID0; - else if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB != NULL && - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled != NULL) - id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; + struct NR_SetupRelease_DMRS_UplinkConfig *tmp = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA; + if (tmp && tmp->choice.setup->transformPrecodingDisabled != NULL) + id0 = tmp->choice.setup->transformPrecodingDisabled->scramblingID0; + else { + struct NR_SetupRelease_DMRS_UplinkConfig *tmp = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB; + if (tmp && tmp->choice.setup->transformPrecodingDisabled != NULL) + id0 = tmp->choice.setup->transformPrecodingDisabled->scramblingID0; + } } NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; @@ -2886,21 +2895,33 @@ void nr_ue_send_sdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, in } -static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, - nr_dci_format_t dci_format, - uint8_t dci_size, - uint16_t rnti, - int ss_type, - uint64_t *dci_pdu, - dci_pdu_rel15_t *dci_pdu_rel15, - int slot) +// #define EXTRACT_DCI_ITEM(val,size) val= readBits(dci_pdu, &pos, size); +#define EXTRACT_DCI_ITEM(val, size) \ + val = readBits(dci_pdu, &pos, size); \ + LOG_D(NR_DCI, " " #val ": %d\n", val); + +// Fixme: Intel Endianess only procedure +static inline int readBits(const uint8_t *dci, int *start, int length) { - LOG_D(MAC,"nr_extract_dci_info : dci_pdu %lx, size %d, format %d\n", *dci_pdu, dci_size, dci_format); - int pos = 0; - int fsize = 0; - int rnti_type = get_rnti_type(mac, rnti); - NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; - NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; + const int mask[] = {0, 1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff}; + uint64_t *tmp = (uint64_t *)dci; + *start -= length; + return *tmp >> *start & mask[length]; +} + +static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, + const nr_dci_format_t dci_format, + const uint8_t dci_size, + const uint16_t rnti, + const int ss_type, + const uint8_t *dci_pdu, + dci_pdu_rel15_t *dci_pdu_rel15, + const int slot) +{ + LOG_D(NR_MAC, "nr_extract_dci_info : dci_pdu %lx, size %d, format %d\n", *(uint64_t *)dci_pdu, dci_size, dci_format); + const int rnti_type = get_rnti_type(mac, rnti); + const NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; + const NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; int N_RB; if(current_DL_BWP) N_RB = get_rb_bwp_dci(dci_format, @@ -2917,173 +2938,82 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, LOG_E(MAC, "DCI configuration error! N_RB = 0\n"); return 1; } - + int pos = dci_size; switch(dci_format) { case NR_DL_DCI_FORMAT_1_0: switch(rnti_type) { case TYPE_RA_RNTI_: + LOG_D(NR_DCI, "Received dci 1_0 RA rnti\n"); // Freq domain assignment - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos = fsize; - dci_pdu_rel15->frequency_domain_assignment.val = *dci_pdu >> (dci_size - pos) & ((1 << fsize) - 1); -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment.val,fsize,N_RB,dci_size-pos,*dci_pdu); -#endif - // Time domain assignment - pos+=4; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu >> (dci_size-pos))&0xf; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"time-domain assignment %d (4 bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment.val,dci_size-pos,*dci_pdu); -#endif - // VRB to PRB mapping - - pos++; - dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&0x1; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"vrb to prb mapping %d (1 bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping.val,dci_size-pos,*dci_pdu); -#endif - // MCS - pos+=5; - dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"mcs %d (5 bits)=> %d (0x%lx)\n",dci_pdu_rel15->mcs,dci_size-pos,*dci_pdu); -#endif - // TB scaling - pos+=2; - dci_pdu_rel15->tb_scaling = (*dci_pdu>>(dci_size-pos))&0x3; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"tb_scaling %d (2 bits)=> %d (0x%lx)\n",dci_pdu_rel15->tb_scaling,dci_size-pos,*dci_pdu); -#endif - break; + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, (int)ceil(log2((N_RB * (N_RB + 1)) >> 1))); + // Time domain assignment + EXTRACT_DCI_ITEM(dci_pdu_rel15->time_domain_assignment.val, 4); + // VRB to PRB mapping + EXTRACT_DCI_ITEM(dci_pdu_rel15->vrb_to_prb_mapping.val, 1); + // MCS + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5); + // TB scaling + EXTRACT_DCI_ITEM(dci_pdu_rel15->tb_scaling, 2); + break; case TYPE_C_RNTI_: - + LOG_D(NR_DCI, "Received dci 1_0 C rnti\n"); // Identifier for DCI formats - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); // switch to DCI_0_0 if (dci_pdu_rel15->format_indicator == 0) { dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_UL_DCI_FORMAT_0_0]; + LOG_D(NR_DCI, "received dci 1_0 c_ rnti, switching to dci 0_0\n"); return 2 + nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); } -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu); -#endif - // Freq domain assignment (275rb >> fsize = 16) - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos+=fsize; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1< %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment.val,fsize,dci_size-pos,*dci_pdu); -#endif - - uint16_t is_ra = 1; - for (int i=0; ifrequency_domain_assignment.val>>i)&1)) { - is_ra = 0; - break; - } - if (is_ra) //fsize are all 1 38.212 p86 - { - // ra_preamble_index 6 bits - pos+=6; - dci_pdu_rel15->ra_preamble_index = (*dci_pdu>>(dci_size-pos))&0x3f; - - // UL/SUL indicator 1 bit - pos++; - dci_pdu_rel15->ul_sul_indicator.val = (*dci_pdu>>(dci_size-pos))&1; - - // SS/PBCH index 6 bits - pos+=6; - dci_pdu_rel15->ss_pbch_index = (*dci_pdu>>(dci_size-pos))&0x3f; - - // prach_mask_index 4 bits - pos+=4; - dci_pdu_rel15->prach_mask_index = (*dci_pdu>>(dci_size-pos))&0xf; - - } //end if - else { - - // Time domain assignment 4bit - - pos+=4; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"Time domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment.val,4,dci_size-pos,*dci_pdu); -#endif - - // VRB to PRB mapping 1bit - pos++; - dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&1; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"VRB to PRB %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping.val,1,dci_size-pos,*dci_pdu); -#endif - - // MCS 5bit //bit over 32, so dci_pdu ++ - pos+=5; - dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"MCS %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->mcs,5,dci_size-pos,*dci_pdu); -#endif - - // New data indicator 1bit - pos++; - dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&1; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"NDI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->ndi,1,dci_size-pos,*dci_pdu); -#endif - - // Redundancy version 2bit - pos+=2; - dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&0x3; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"RV %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->rv,2,dci_size-pos,*dci_pdu); -#endif - - // HARQ process number 4bit - pos+=4; - dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"HARQ_PID %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->harq_pid,4,dci_size-pos,*dci_pdu); -#endif - - // Downlink assignment index 2bit - pos+=2; - dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&3; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"DAI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->dai[0].val,2,dci_size-pos,*dci_pdu); -#endif - - // TPC command for scheduled PUCCH 2bit - pos+=2; - dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"TPC %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->tpc,2,dci_size-pos,*dci_pdu); -#endif - - // PUCCH resource indicator 3bit - pos+=3; - dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&0x7; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"PUCCH RI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->pucch_resource_indicator,3,dci_size-pos,*dci_pdu); -#endif - - // PDSCH-to-HARQ_feedback timing indicator 3bit - pos+=3; - dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&0x7; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"PDSCH to HARQ TI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val,3,dci_size-pos,*dci_pdu); -#endif - - } //end else - break; + // Freq domain assignment (275rb >> fsize = 16) + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, (int)ceil(log2((N_RB * (N_RB + 1)) >> 1))); + + bool is_ra = true; + for (int i = 0; i < dci_pdu_rel15->frequency_domain_assignment.val; i++) + if (!((dci_pdu_rel15->frequency_domain_assignment.val >> i) & 1)) { + is_ra = false; + break; + } + if (is_ra) // fsize are all 1 38.212 p86 + { + // ra_preamble_index 6 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->ra_preamble_index, 6); + // UL/SUL indicator 1 bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->ul_sul_indicator.val, 1); + // SS/PBCH index 6 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->ss_pbch_index, 6); + // prach_mask_index 4 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->prach_mask_index, 4); + } else { + // Time domain assignment 4bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->time_domain_assignment.val, 4); + // VRB to PRB mapping 1bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->vrb_to_prb_mapping.val, 1); + // MCS 5bit //bit over 32, so dci_pdu ++ + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5); + // New data indicator 1bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->ndi, 1); + // Redundancy version 2bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->rv, 2); + // HARQ process number 4bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->harq_pid, 4); + // Downlink assignment index 2bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->dai[0].val, 2); + // TPC command for scheduled PUCCH 2bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->tpc, 2); + // PUCCH resource indicator 3bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->pucch_resource_indicator, 3); + // PDSCH-to-HARQ_feedback timing indicator 3bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val, 3); + } + break; case TYPE_P_RNTI_: + LOG_D(NR_DCI, "Received dci 1_0 P rnti\n"); /* // Short Messages Indicator  E2 bits for (int i=0; i<2; i++) @@ -3112,340 +3042,197 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case TYPE_SI_RNTI_: + LOG_D(NR_DCI, "Received dci 1_0 SI rnti\n"); // Freq domain assignment 0-16 bit - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos += fsize; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu >> (dci_size - pos)) & ((1 << fsize) - 1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, (int)ceil(log2((N_RB * (N_RB + 1)) >> 1))); // Time domain assignment 4 bit - pos += 4; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu >> (dci_size - pos)) & 0xf; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->time_domain_assignment.val, 4); // VRB to PRB mapping 1 bit - pos++; - dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu >> (dci_size - pos)) & 0x1; - - // MCS 5bit //bit over 32, so dci_pdu ++ - pos += 5; - dci_pdu_rel15->mcs = (*dci_pdu >> (dci_size - pos)) & 0x1f; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->vrb_to_prb_mapping.val, 1); + // MCS 5bit //bit over 32 + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5); // Redundancy version 2 bit - pos += 2; - dci_pdu_rel15->rv = (*dci_pdu >> (dci_size - pos)) & 3; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->rv, 2); // System information indicator 1 bit - pos++; - dci_pdu_rel15->system_info_indicator = (*dci_pdu >> (dci_size - pos)) & 0x1; - - LOG_D(MAC, "N_RB = %i\n", N_RB); - LOG_D(MAC, "dci_size = %i\n", dci_size); - LOG_D(MAC, "fsize = %i\n", fsize); - LOG_D(MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); - LOG_D(MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); - LOG_D(MAC, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); - LOG_D(MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); - LOG_D(MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); - LOG_D(MAC, "dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->system_info_indicator, 1); break; case TYPE_TC_RNTI_: + LOG_D(NR_DCI, "Received dci 1_0 TC rnti\n"); // indicating a DL DCI format 1bit - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; + EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); // switch to DCI_0_0 if (dci_pdu_rel15->format_indicator == 0) { dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_UL_DCI_FORMAT_0_0]; + LOG_D(NR_DCI, "received dci 1_0 tc_ rnti, switching to dci 0_0\n"); return 2 + nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); } // Freq domain assignment 0-16 bit - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos+=fsize; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf; - - // VRB to PRB mapping - 1 bit - pos++; - dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&1; - - // MCS 5bit //bit over 32, so dci_pdu ++ - pos+=5; - dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f; - - // New data indicator - 1 bit - pos++; - dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&1; - - // Redundancy version - 2 bits - pos+=2; - dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&3; - - // HARQ process number - 4 bits - pos+=4; - dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; - - // Downlink assignment index - 2 bits - pos+=2; - dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&3; - - // TPC command for scheduled PUCCH - 2 bits - pos+=2; - dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3; - - // PUCCH resource indicator - 3 bits - pos+=3; - dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&7; - - // PDSCH-to-HARQ_feedback timing indicator - 3 bits - pos+=3; - dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&7; - - LOG_D(NR_MAC,"N_RB = %i\n", N_RB); - LOG_D(NR_MAC,"dci_size = %i\n", dci_size); - LOG_D(NR_MAC,"fsize = %i\n", fsize); - LOG_D(NR_MAC,"dci_pdu_rel15->format_indicator = %i\n", dci_pdu_rel15->format_indicator); - LOG_D(NR_MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); - LOG_D(NR_MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); - LOG_D(NR_MAC,"dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val); - LOG_D(NR_MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); - LOG_D(NR_MAC,"dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); - LOG_D(NR_MAC,"dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); - LOG_D(NR_MAC,"dci_pdu_rel15->dai[0].val = %i\n", dci_pdu_rel15->dai[0].val); - LOG_D(NR_MAC,"dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); - LOG_D(NR_MAC,"dci_pdu_rel15->pucch_resource_indicator = %i\n", dci_pdu_rel15->pucch_resource_indicator); - LOG_D(NR_MAC,"dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = %i\n", dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val); - - break; + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, (int)ceil(log2((N_RB * (N_RB + 1)) >> 1))); + // Time domain assignment - 4 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->time_domain_assignment.val, 4); + // VRB to PRB mapping - 1 bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->vrb_to_prb_mapping.val, 1); + // MCS 5bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5); + // New data indicator - 1 bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->ndi, 1); + // Redundancy version - 2 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->rv, 2); + // HARQ process number - 4 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->harq_pid, 4); + // Downlink assignment index - 2 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->dai[0].val, 2); + // TPC command for scheduled PUCCH - 2 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->tpc, 2); + // PUCCH resource indicator - 3 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->pucch_resource_indicator, 3); + // PDSCH-to-HARQ_feedback timing indicator - 3 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val, 3); + break; + default: + LOG_W(NR_DCI, "Received dci 1_0 unknown rnti type: %d\n", rnti_type); } break; - + case NR_UL_DCI_FORMAT_0_0: switch(rnti_type) { case TYPE_C_RNTI_: + LOG_D(NR_DCI, "Received dci 0_0 C rnti\n"); // Identifier for DCI formats - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"Format indicator %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,dci_size-pos,*dci_pdu); -#endif + EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); if (dci_pdu_rel15->format_indicator == 1) return 1; // discard dci, format indicator not corresponding to dci_format - fsize = dci_pdu_rel15->frequency_domain_assignment.nbits; - pos+=fsize; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1< %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment.val,fsize,dci_size-pos,*dci_pdu); -#endif - // Time domain assignment 4bit - pos+=4; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"time-domain assignment %d (4 bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment.val,dci_size-pos,*dci_pdu); -#endif - // Frequency hopping flag  E1 bit - pos++; - dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"frequency_hopping %d (1 bit)=> %d (0x%lx)\n",dci_pdu_rel15->frequency_hopping_flag.val,dci_size-pos,*dci_pdu); -#endif - // MCS 5 bit - pos+=5; - dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"mcs %d (5 bits)=> %d (0x%lx)\n",dci_pdu_rel15->mcs,dci_size-pos,*dci_pdu); -#endif - // New data indicator 1bit - pos++; - dci_pdu_rel15->ndi= (*dci_pdu>>(dci_size-pos))&1; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"NDI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->ndi,1,dci_size-pos,*dci_pdu); -#endif - // Redundancy version 2bit - pos+=2; - dci_pdu_rel15->rv= (*dci_pdu>>(dci_size-pos))&3; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"RV %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->rv,2,dci_size-pos,*dci_pdu); -#endif - // HARQ process number 4bit - pos+=4; - dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"HARQ_PID %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->harq_pid,4,dci_size-pos,*dci_pdu); -#endif - // TPC command for scheduled PUSCH  E2 bits - pos+=2; - dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3; -#ifdef DEBUG_EXTRACT_DCI - LOG_D(MAC,"TPC %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->tpc,2,dci_size-pos,*dci_pdu); -#endif - // UL/SUL indicator  E1 bit - /* commented for now (RK): need to get this from BWP descriptor - if (cfg->pucch_config.pucch_GroupHopping.value) - dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)ul_sul_indicator&1)<<(dci_size-pos++); - */ - break; + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, dci_pdu_rel15->frequency_domain_assignment.nbits); + // Time domain assignment 4bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->time_domain_assignment.val, 4); + // Frequency hopping flag  E1 bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_hopping_flag.val, 1); + // MCS 5 bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5); + // New data indicator 1bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->ndi, 1); + // Redundancy version 2bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->rv, 2); + // HARQ process number 4bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->harq_pid, 4); + // TPC command for scheduled PUSCH  E2 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->tpc, 2); + // UL/SUL indicator  E1 bit + /* commented for now (RK): need to get this from BWP descriptor + if (cfg->pucch_config.pucch_GroupHopping.value) + dci_pdu->= ((uint64_t)readBits(dci_pdu,>>(dci_size-pos)ul_sul_indicator&1)<<(dci_size-pos++); + */ + break; case TYPE_TC_RNTI_: + LOG_D(NR_DCI, "Received dci 1_0 TC rnti\n"); // Identifier for DCI formats - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; -#ifdef DEBUG_EXTRACT_DCI - LOG_I(MAC,"Format indicator %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,dci_size-pos,*dci_pdu); -#endif - + EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); //switch to DCI_1_0 if (dci_pdu_rel15->format_indicator == 1) { dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_DL_DCI_FORMAT_1_0]; + LOG_D(NR_DCI, "received dci 0_0 tc_ rnti, switching to dci 0_0\n"); return 2 + nr_extract_dci_info(mac, NR_DL_DCI_FORMAT_1_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); } - fsize = dci_pdu_rel15->frequency_domain_assignment.nbits; - pos+=fsize; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1< %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment.val,fsize,dci_size-pos,*dci_pdu); -#endif - // Time domain assignment 4bit - pos+=4; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf; -#ifdef DEBUG_EXTRACT_DCI - LOG_I(MAC,"time-domain assignment %d (4 bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment.val,dci_size-pos,*dci_pdu); -#endif - // Frequency hopping flag  E1 bit - pos++; - dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1; -#ifdef DEBUG_EXTRACT_DCI - LOG_I(MAC,"frequency_hopping %d (1 bit)=> %d (0x%lx)\n",dci_pdu_rel15->frequency_hopping_flag.val,dci_size-pos,*dci_pdu); -#endif - // MCS 5 bit - pos+=5; - dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f; -#ifdef DEBUG_EXTRACT_DCI - LOG_I(MAC,"mcs %d (5 bits)=> %d (0x%lx)\n",dci_pdu_rel15->mcs,dci_size-pos,*dci_pdu); -#endif - // New data indicator 1bit - pos++; - dci_pdu_rel15->ndi= (*dci_pdu>>(dci_size-pos))&1; -#ifdef DEBUG_EXTRACT_DCI - LOG_I(MAC,"NDI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->ndi,1,dci_size-pos,*dci_pdu); -#endif - // Redundancy version 2bit - pos+=2; - dci_pdu_rel15->rv= (*dci_pdu>>(dci_size-pos))&3; -#ifdef DEBUG_EXTRACT_DCI - LOG_I(MAC,"RV %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->rv,2,dci_size-pos,*dci_pdu); -#endif - // HARQ process number 4bit - pos+=4; - dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; -#ifdef DEBUG_EXTRACT_DCI - LOG_I(MAC,"HARQ_PID %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->harq_pid,4,dci_size-pos,*dci_pdu); -#endif - // TPC command for scheduled PUSCH  E2 bits - pos+=2; - dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3; -#ifdef DEBUG_EXTRACT_DCI - LOG_I(MAC,"TPC %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->tpc,2,dci_size-pos,*dci_pdu); -#endif - break; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, dci_pdu_rel15->frequency_domain_assignment.nbits); + // Time domain assignment 4bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->time_domain_assignment.val, 4); + // Frequency hopping flag  E1 bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_hopping_flag.val, 1); + // MCS 5 bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5); + // New data indicator 1bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->ndi, 1); + // Redundancy version 2bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->rv, 2); + // HARQ process number 4bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->harq_pid, 4); + // TPC command for scheduled PUSCH  E2 bits + EXTRACT_DCI_ITEM(dci_pdu_rel15->tpc, 2); + break; + + default: + LOG_W(NR_DCI, "Received dci 0_0 unknown rnti type: %d\n", rnti_type); } + break; case NR_DL_DCI_FORMAT_1_1: switch(rnti_type) { case TYPE_C_RNTI_: + LOG_D(NR_DCI, "Received dci 1_1 C rnti\n"); + // Identifier for DCI formats - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu >> (dci_size - pos)) & 1; - if (dci_pdu_rel15->format_indicator == 0) + EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); + if (dci_pdu_rel15->format_indicator == 0) { + LOG_W(NR_DCI, "Received dci 1_1 C rnti and format indicator 0, discarding\n"); return 1; // discard dci, format indicator not corresponding to dci_format + } // Carrier indicator - pos+=dci_pdu_rel15->carrier_indicator.nbits; - dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<carrier_indicator.nbits)-1); - // BWP Indicator - pos+=dci_pdu_rel15->bwp_indicator.nbits; - dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1); + + EXTRACT_DCI_ITEM(dci_pdu_rel15->carrier_indicator.val, dci_pdu_rel15->carrier_indicator.nbits); + // BWP Indicator& + EXTRACT_DCI_ITEM(dci_pdu_rel15->bwp_indicator.val, dci_pdu_rel15->bwp_indicator.nbits); // Frequency domain resource assignment - pos+=dci_pdu_rel15->frequency_domain_assignment.nbits; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<frequency_domain_assignment.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, dci_pdu_rel15->frequency_domain_assignment.nbits); // Time domain resource assignment - pos+=dci_pdu_rel15->time_domain_assignment.nbits; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->time_domain_assignment.val, dci_pdu_rel15->time_domain_assignment.nbits); // VRB-to-PRB mapping - pos+=dci_pdu_rel15->vrb_to_prb_mapping.nbits; - dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&((1<vrb_to_prb_mapping.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->vrb_to_prb_mapping.val, dci_pdu_rel15->vrb_to_prb_mapping.nbits); // PRB bundling size indicator - pos+=dci_pdu_rel15->prb_bundling_size_indicator.nbits; - dci_pdu_rel15->prb_bundling_size_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<prb_bundling_size_indicator.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->prb_bundling_size_indicator.val, dci_pdu_rel15->prb_bundling_size_indicator.nbits); // Rate matching indicator - pos+=dci_pdu_rel15->rate_matching_indicator.nbits; - dci_pdu_rel15->rate_matching_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<rate_matching_indicator.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->rate_matching_indicator.val, dci_pdu_rel15->rate_matching_indicator.nbits); // ZP CSI-RS trigger - pos+=dci_pdu_rel15->zp_csi_rs_trigger.nbits; - dci_pdu_rel15->zp_csi_rs_trigger.val = (*dci_pdu>>(dci_size-pos))&((1<zp_csi_rs_trigger.nbits)-1); - //TB1 - // MCS 5bit - pos+=5; - dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f; + EXTRACT_DCI_ITEM(dci_pdu_rel15->zp_csi_rs_trigger.val, dci_pdu_rel15->zp_csi_rs_trigger.nbits); + // TB1 + // MCS 5bit + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5); // New data indicator 1bit - pos+=1; - dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&0x1; + EXTRACT_DCI_ITEM(dci_pdu_rel15->ndi, 1); // Redundancy version 2bit - pos+=2; - dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&0x3; + EXTRACT_DCI_ITEM(dci_pdu_rel15->rv, 2); //TB2 // MCS 5bit - pos+=dci_pdu_rel15->mcs2.nbits; - dci_pdu_rel15->mcs2.val = (*dci_pdu>>(dci_size-pos))&((1<mcs2.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs2.val, dci_pdu_rel15->mcs2.nbits); // New data indicator 1bit - pos+=dci_pdu_rel15->ndi2.nbits; - dci_pdu_rel15->ndi2.val = (*dci_pdu>>(dci_size-pos))&((1<ndi2.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->ndi2.val, dci_pdu_rel15->ndi2.nbits); // Redundancy version 2bit - pos+=dci_pdu_rel15->rv2.nbits; - dci_pdu_rel15->rv2.val = (*dci_pdu>>(dci_size-pos))&((1<rv2.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->rv2.val, dci_pdu_rel15->rv2.nbits); // HARQ process number 4bit - pos+=4; - dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; + EXTRACT_DCI_ITEM(dci_pdu_rel15->harq_pid, 4); // Downlink assignment index - pos+=dci_pdu_rel15->dai[0].nbits; - dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<dai[0].nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->dai[0].val, dci_pdu_rel15->dai[0].nbits); // TPC command for scheduled PUCCH 2bit - pos+=2; - dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&0x3; + EXTRACT_DCI_ITEM(dci_pdu_rel15->tpc, 2); // PUCCH resource indicator 3bit - pos+=3; - dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&0x3; + EXTRACT_DCI_ITEM(dci_pdu_rel15->pucch_resource_indicator, 3); // PDSCH-to-HARQ_feedback timing indicator - pos+=dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits; - dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<pdsch_to_harq_feedback_timing_indicator.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val, + dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits); // Antenna ports - pos+=dci_pdu_rel15->antenna_ports.nbits; - dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<antenna_ports.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->antenna_ports.val, dci_pdu_rel15->antenna_ports.nbits); // TCI - pos+=dci_pdu_rel15->transmission_configuration_indication.nbits; - dci_pdu_rel15->transmission_configuration_indication.val = (*dci_pdu>>(dci_size-pos))&((1<transmission_configuration_indication.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->transmission_configuration_indication.val, + dci_pdu_rel15->transmission_configuration_indication.nbits); // SRS request - pos+=dci_pdu_rel15->srs_request.nbits; - dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<srs_request.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->srs_request.val, dci_pdu_rel15->srs_request.nbits); // CBG transmission information - pos+=dci_pdu_rel15->cbgti.nbits; - dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<cbgti.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->cbgti.val, dci_pdu_rel15->cbgti.nbits); // CBG flushing out information - pos+=dci_pdu_rel15->cbgfi.nbits; - dci_pdu_rel15->cbgfi.val = (*dci_pdu>>(dci_size-pos))&((1<cbgfi.nbits)-1); + EXTRACT_DCI_ITEM(dci_pdu_rel15->cbgfi.val, dci_pdu_rel15->cbgfi.nbits); // DMRS sequence init - pos+=1; - dci_pdu_rel15->dmrs_sequence_initialization.val = (*dci_pdu>>(dci_size-pos))&0x1; + EXTRACT_DCI_ITEM(dci_pdu_rel15->dmrs_sequence_initialization.val, 1); break; + default: + LOG_W(NR_DCI, "Received dci 1_1 unknown rnti type: %d\n", rnti_type); } break; @@ -3453,105 +3240,63 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, switch(rnti_type) { case TYPE_C_RNTI_: + LOG_D(NR_DCI, "Received dci 0_1 C rnti\n"); //Identifier for DCI formats - pos++; - dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; - if (dci_pdu_rel15->format_indicator == 1) + EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); + if (dci_pdu_rel15->format_indicator == 1) { + LOG_W(NR_DCI, "Received dci 0_1 C rnti and format indicator 1, discarding\n"); return 1; // discard dci, format indicator not corresponding to dci_format + } // Carrier indicator - pos+=dci_pdu_rel15->carrier_indicator.nbits; - dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<carrier_indicator.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->carrier_indicator.val, dci_pdu_rel15->carrier_indicator.nbits); // UL/SUL Indicator - pos+=dci_pdu_rel15->ul_sul_indicator.nbits; - dci_pdu_rel15->ul_sul_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<ul_sul_indicator.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->ul_sul_indicator.val, dci_pdu_rel15->ul_sul_indicator.nbits); // BWP Indicator - pos+=dci_pdu_rel15->bwp_indicator.nbits; - dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->bwp_indicator.val, dci_pdu_rel15->bwp_indicator.nbits); // Freq domain assignment max 16 bit - fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - pos+=fsize; - dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<frequency_domain_assignment.val, (int)ceil(log2((N_RB * (N_RB + 1)) >> 1))); // Time domain assignment - //pos+=4; - pos+=dci_pdu_rel15->time_domain_assignment.nbits; - dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<time_domain_assignment.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->time_domain_assignment.val, dci_pdu_rel15->time_domain_assignment.nbits); // Not supported yet - skip for now - // Frequency hopping flag – 1 bit - //pos++; - //dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1; + // Frequency hopping flag – 1 bit + // pos++; + // dci_pdu_rel15->frequency_hopping_flag.val= (readBits(dci_pdu,>>(dci_size-pos))&1; // MCS 5 bit - pos+=5; - dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->mcs, 5); // New data indicator 1bit - pos++; - dci_pdu_rel15->ndi= (*dci_pdu>>(dci_size-pos))&1; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->ndi, 1); // Redundancy version 2bit - pos+=2; - dci_pdu_rel15->rv= (*dci_pdu>>(dci_size-pos))&3; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->rv, 2); // HARQ process number 4bit - pos+=4; - dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; + EXTRACT_DCI_ITEM(dci_pdu_rel15->harq_pid, 4); // 1st Downlink assignment index - pos+=dci_pdu_rel15->dai[0].nbits; - dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<dai[0].nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->dai[0].val, dci_pdu_rel15->dai[0].nbits); // 2nd Downlink assignment index - pos+=dci_pdu_rel15->dai[1].nbits; - dci_pdu_rel15->dai[1].val = (*dci_pdu>>(dci_size-pos))&((1<dai[1].nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->dai[1].val, dci_pdu_rel15->dai[1].nbits); // TPC command for scheduled PUSCH – 2 bits - pos+=2; - dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3; - + EXTRACT_DCI_ITEM(dci_pdu_rel15->tpc, 2); // SRS resource indicator - pos+=dci_pdu_rel15->srs_resource_indicator.nbits; - dci_pdu_rel15->srs_resource_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<srs_resource_indicator.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->srs_resource_indicator.val, dci_pdu_rel15->srs_resource_indicator.nbits); // Precoding info and n. of layers - pos+=dci_pdu_rel15->precoding_information.nbits; - dci_pdu_rel15->precoding_information.val = (*dci_pdu>>(dci_size-pos))&((1<precoding_information.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->precoding_information.val, dci_pdu_rel15->precoding_information.nbits); // Antenna ports - pos+=dci_pdu_rel15->antenna_ports.nbits; - dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<antenna_ports.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->antenna_ports.val, dci_pdu_rel15->antenna_ports.nbits); // SRS request - pos+=dci_pdu_rel15->srs_request.nbits; - dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<srs_request.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->srs_request.val, dci_pdu_rel15->srs_request.nbits); // CSI request - pos+=dci_pdu_rel15->csi_request.nbits; - dci_pdu_rel15->csi_request.val = (*dci_pdu>>(dci_size-pos))&((1<csi_request.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->csi_request.val, dci_pdu_rel15->csi_request.nbits); // CBG transmission information - pos+=dci_pdu_rel15->cbgti.nbits; - dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<cbgti.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->cbgti.val, dci_pdu_rel15->cbgti.nbits); // PTRS DMRS association - pos+=dci_pdu_rel15->ptrs_dmrs_association.nbits; - dci_pdu_rel15->ptrs_dmrs_association.val = (*dci_pdu>>(dci_size-pos))&((1<ptrs_dmrs_association.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->ptrs_dmrs_association.val, dci_pdu_rel15->ptrs_dmrs_association.nbits); // Beta offset indicator - pos+=dci_pdu_rel15->beta_offset_indicator.nbits; - dci_pdu_rel15->beta_offset_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<beta_offset_indicator.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->beta_offset_indicator.val, dci_pdu_rel15->beta_offset_indicator.nbits); // DMRS sequence initialization - pos+=dci_pdu_rel15->dmrs_sequence_initialization.nbits; - dci_pdu_rel15->dmrs_sequence_initialization.val = (*dci_pdu>>(dci_size-pos))&((1<dmrs_sequence_initialization.nbits)-1); - + EXTRACT_DCI_ITEM(dci_pdu_rel15->dmrs_sequence_initialization.val, dci_pdu_rel15->dmrs_sequence_initialization.nbits); // UL-SCH indicator - pos+=1; - dci_pdu_rel15->ulsch_indicator = (*dci_pdu>>(dci_size-pos))&0x1; + EXTRACT_DCI_ITEM(dci_pdu_rel15->ulsch_indicator, 1); // UL/SUL indicator – 1 bit /* commented for now (RK): need to get this from BWP descriptor @@ -3559,10 +3304,14 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)ul_sul_indicator&1)<<(dci_size-pos++); */ break; + default: + LOG_W(NR_DCI, "Received dci 0_1 unknown rnti type: %d\n", rnti_type); } break; default: // other DCI formats + LOG_W(NR_DCI, "Received dci unknown format type: %d\n", dci_format); + break; } From ea0185f84e2e2a2f327f6b3e43a6aaca93f8c685 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Tue, 23 Jan 2024 16:26:33 +0100 Subject: [PATCH 17/54] Introduced define for uint8_t integrity and ciphering keys data structures - the goal is to improve maintanability --- openair2/RRC/NR/nr_rrc_common.h | 1 + openair2/RRC/NR/rrc_gNB.c | 12 ++++++------ openair2/RRC/NR/rrc_gNB_NGAP.c | 6 +++--- openair2/RRC/NR/rrc_gNB_nsa.c | 4 ++-- openair2/RRC/NR_UE/rrc_UE.c | 10 +++++----- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/openair2/RRC/NR/nr_rrc_common.h b/openair2/RRC/NR/nr_rrc_common.h index 69dbb9ff0f..f821d842b6 100644 --- a/openair2/RRC/NR/nr_rrc_common.h +++ b/openair2/RRC/NR/nr_rrc_common.h @@ -29,6 +29,7 @@ #define NR_RRC_HEADER_SIZE_MAX 64 #define NR_RRC_BUFFER_SIZE_MAX 1024 #define NR_NUM_SRB 4 +#define NR_K_KEY_SIZE 16 /* K keys have 128 bits length */ typedef struct { char Payload[NR_RRC_BUFFER_SIZE_MAX]; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 660a427d30..e85eef0685 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -408,8 +408,8 @@ static void activate_srb(gNB_RRC_UE_t *UE, int srb_id) if (srb_id == 1) { nr_pdcp_add_srbs(true, UE->rrc_ue_id, list, 0, NULL, NULL); } else { - uint8_t kRRCenc[16] = {0}; - uint8_t kRRCint[16] = {0}; + uint8_t kRRCenc[NR_K_KEY_SIZE] = {0}; + uint8_t kRRCint[NR_K_KEY_SIZE] = {0}; nr_derive_key(RRC_ENC_ALG, UE->ciphering_algorithm, UE->kgnb, kRRCenc); nr_derive_key(RRC_INT_ALG, UE->integrity_algorithm, UE->kgnb, kRRCint); @@ -904,13 +904,13 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context LOG_I(NR_RRC, "[RAPROC] UE %04x Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n", ue_p->rnti, size); - uint8_t kRRCenc[16] = {0}; - uint8_t kRRCint[16] = {0}; - uint8_t kUPenc[16] = {0}; + /* Ciphering and Integrity according to TS 33.501 */ + uint8_t kRRCenc[NR_K_KEY_SIZE] = {0}; + uint8_t kRRCint[NR_K_KEY_SIZE] = {0}; + uint8_t kUPenc[NR_K_KEY_SIZE] = {0}; /* Derive the keys from kgnb */ if (ue_p->Srb[1].Active) nr_derive_key(UP_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kUPenc); - nr_derive_key(RRC_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kRRCenc); nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, kRRCint); diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index fbd232b1d4..37cc52a007 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -130,9 +130,9 @@ nr_rrc_pdcp_config_security( ) //------------------------------------------------------------------------------ { - uint8_t kRRCenc[16] = {0}; - uint8_t kRRCint[16] = {0}; - uint8_t kUPenc[16] = {0}; + uint8_t kRRCenc[NR_K_KEY_SIZE] = {0}; + uint8_t kRRCint[NR_K_KEY_SIZE] = {0}; + uint8_t kUPenc[NR_K_KEY_SIZE] = {0}; //uint8_t *k_kdf = NULL; static int print_keys= 1; gNB_RRC_UE_t *UE = &ue_context_pP->ue_context; diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 448de0eb95..f48ad83083 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -126,8 +126,8 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a gtpv1u_enb_create_tunnel_req_t create_tunnel_req; gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; protocol_ctxt_t ctxt={0}; - uint8_t kUPenc[16] = {0}; - uint8_t kUPint[16] = {0}; + uint8_t kUPenc[NR_K_KEY_SIZE] = {0}; + uint8_t kUPint[NR_K_KEY_SIZE] = {0}; int i; gNB_RRC_UE_t *UE = &ue_context_p->ue_context; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 8385236ff1..401149d8e8 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -987,9 +987,9 @@ static void nr_rrc_ue_process_securityModeCommand(NR_UE_RRC_INST_t *ue_rrc, c1->present = NR_UL_DCCH_MessageType__c1_PR_securityModeComplete; } - uint8_t kRRCenc[16] = {0}; - uint8_t kUPenc[16] = {0}; - uint8_t kRRCint[16] = {0}; + uint8_t kRRCenc[NR_K_KEY_SIZE] = {0}; + uint8_t kUPenc[NR_K_KEY_SIZE] = {0}; + uint8_t kRRCint[NR_K_KEY_SIZE] = {0}; nr_derive_key(UP_ENC_ALG, ue_rrc->cipheringAlgorithm, ue_rrc->kgnb, kUPenc); nr_derive_key(RRC_ENC_ALG, ue_rrc->cipheringAlgorithm, ue_rrc->kgnb, kRRCenc); nr_derive_key(RRC_INT_ALG, ue_rrc->integrityProtAlgorithm, ue_rrc->kgnb, kRRCint); @@ -1167,8 +1167,8 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, if (radioBearerConfig->srb3_ToRelease) nr_pdcp_release_srb(ue_rrc->ue_id, 3); - uint8_t kRRCenc[16] = {0}; - uint8_t kRRCint[16] = {0}; + uint8_t kRRCenc[NR_K_KEY_SIZE] = {0}; + uint8_t kRRCint[NR_K_KEY_SIZE] = {0}; if (ue_rrc->as_security_activated) { if (radioBearerConfig->securityConfig != NULL) { // When the field is not included, continue to use the currently configured keyToUse From f392158c40ab6c25e6b107ead152c65291349da9 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Tue, 23 Jan 2024 16:07:21 +0100 Subject: [PATCH 18/54] Removed redundant definition for max SRBs number (used in RRC procedures) - according to specs, in NR there are 4 SRBs - in OAI the relevant define is used in the RRC procedures - this commit harmonizes code by removing redundancy --- common/ngran_types.h | 1 - openair2/RRC/NR/nr_rrc_common.h | 2 +- openair2/RRC/NR/nr_rrc_defs.h | 2 +- openair2/RRC/NR/rrc_gNB.c | 5 +++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/ngran_types.h b/common/ngran_types.h index 95ad167961..37a6ea9177 100644 --- a/common/ngran_types.h +++ b/common/ngran_types.h @@ -56,5 +56,4 @@ typedef enum { CPtype = 0, UPtype } E1_t; #define GTPV1_U_PORT_NUMBER (2152) typedef enum { non_dynamic, dynamic } fiveQI_type_t; -#define maxSRBs 4 #endif diff --git a/openair2/RRC/NR/nr_rrc_common.h b/openair2/RRC/NR/nr_rrc_common.h index f821d842b6..e1ff2e703e 100644 --- a/openair2/RRC/NR/nr_rrc_common.h +++ b/openair2/RRC/NR/nr_rrc_common.h @@ -28,7 +28,7 @@ #define NR_RRC_HEADER_SIZE_MAX 64 #define NR_RRC_BUFFER_SIZE_MAX 1024 -#define NR_NUM_SRB 4 +#define NR_NUM_SRB 4 /* Number of Signalling Radio Bearers according to clause 4.2.2 of 3GPP TS 38.331 */ #define NR_K_KEY_SIZE 16 /* K keys have 128 bits length */ typedef struct { diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index b26ff1e50c..f0d4039033 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -241,7 +241,7 @@ typedef struct gNB_RRC_UE_s { drb_t established_drbs[MAX_DRBS_PER_UE]; NR_DRB_ToReleaseList_t *DRB_ReleaseList; - NR_SRB_INFO_TABLE_ENTRY Srb[maxSRBs]; // 3gpp max is 3 SRBs, number 1..3, we waste the entry 0 for code simplicity + NR_SRB_INFO_TABLE_ENTRY Srb[NR_NUM_SRB]; NR_MeasConfig_t *measConfig; NR_HANDOVER_INFO *handover_info; NR_MeasResults_t *measResults; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index e85eef0685..e2062b05ff 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -348,7 +348,7 @@ static NR_SRB_ToAddModList_t *createSRBlist(gNB_RRC_UE_t *ue, bool reestablish) return NULL; } NR_SRB_ToAddModList_t *list = CALLOC(sizeof(*list), 1); - for (int i = 0; i < maxSRBs; i++) + for (int i = 0; i < NR_NUM_SRB; i++) if (ue->Srb[i].Active) { asn1cSequenceAdd(list->list, NR_SRB_ToAddMod_t, srb); srb->srb_Identity = i; @@ -918,7 +918,8 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context uint8_t security_mode = enable_ciphering ? ue_p->ciphering_algorithm | (ue_p->integrity_algorithm << 4) : 0 | (ue_p->integrity_algorithm << 4); - for (int srb_id = 1; srb_id < maxSRBs; srb_id++) { + /* SRBs */ + for (int srb_id = 1; srb_id < NR_NUM_SRB; srb_id++) { if (ue_p->Srb[srb_id].Active) { nr_pdcp_config_set_security(ue_p->rrc_ue_id, srb_id, security_mode, kRRCenc, kRRCint, kUPenc); // TODO: should send E1 UE Bearer Modification with PDCP Reestablishment flag From b6087da1b26ab131d666157d11de5cfab7eaf39a Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Mon, 5 Feb 2024 15:46:41 +0100 Subject: [PATCH 19/54] Separated E1 Bearer Context Setup from Modification procedures - many structs and definitions are overlapping between the two different E1 procedures - introduced naming specific to E1 Bearer Context Modification to improve readability - grouped SDAP and PDCP configuration IEs for better reusability and readability - introduced functions to set and get default PDCP config (DRBs and Bearer Contexts) find_or_next_pdu_session: - find_or_next_pdu_session refers to the E1 Bearer Context Modification Request -- therefore it has to return pdu_session_to_mod_t* and takes in input e1ap_bearer_mod_req_t * see !MR2545 for more context --- openair2/COMMON/e1ap_messages_def.h | 2 +- openair2/COMMON/e1ap_messages_types.h | 64 +++++++++++++++----- openair2/E1AP/e1ap.c | 67 ++++++++++----------- openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c | 26 ++++---- openair2/RRC/NR/cucp_cuup_direct.c | 2 +- openair2/RRC/NR/cucp_cuup_e1ap.c | 4 +- openair2/RRC/NR/rrc_gNB.c | 41 +++++++------ openair2/RRC/NR/rrc_gNB_NGAP.c | 19 +++--- openair2/RRC/NR/rrc_gNB_radio_bearers.c | 39 +++++++----- openair2/RRC/NR/rrc_gNB_radio_bearers.h | 3 + 10 files changed, 150 insertions(+), 117 deletions(-) diff --git a/openair2/COMMON/e1ap_messages_def.h b/openair2/COMMON/e1ap_messages_def.h index df72a99f7f..5001f72885 100644 --- a/openair2/COMMON/e1ap_messages_def.h +++ b/openair2/COMMON/e1ap_messages_def.h @@ -39,7 +39,7 @@ MESSAGE_DEF(E1AP_BEARER_CONTEXT_SETUP_REQ , MESSAGE_PRIORITY_MED , e1ap_bearer_s /* E1AP Bearer Context Setup Response: gNB-CU-UP -> gNB-CU-CP */ MESSAGE_DEF(E1AP_BEARER_CONTEXT_SETUP_RESP , MESSAGE_PRIORITY_MED , e1ap_bearer_setup_resp_t , e1ap_bearer_setup_resp) /* E1AP Bearer Context Modification Request: gNB-CU-CP -> gNB-CU-UP */ -MESSAGE_DEF(E1AP_BEARER_CONTEXT_MODIFICATION_REQ , MESSAGE_PRIORITY_MED , e1ap_bearer_setup_req_t , e1ap_bearer_mod_req) +MESSAGE_DEF(E1AP_BEARER_CONTEXT_MODIFICATION_REQ , MESSAGE_PRIORITY_MED , e1ap_bearer_mod_req_t , e1ap_bearer_mod_req) /* E1AP Bearer Context Modification Response: gNB-CU-UP -> gNB-CU-CP */ MESSAGE_DEF(E1AP_BEARER_CONTEXT_MODIFICATION_RESP, MESSAGE_PRIORITY_MED, e1ap_bearer_modif_resp_t, e1ap_bearer_modif_resp) /* E1AP Bearer Context Release Request: gNB-CU-CP -> gNB-CU-UP */ diff --git a/openair2/COMMON/e1ap_messages_types.h b/openair2/COMMON/e1ap_messages_types.h index 43d63924e0..486f4d3ecd 100644 --- a/openair2/COMMON/e1ap_messages_types.h +++ b/openair2/COMMON/e1ap_messages_types.h @@ -47,7 +47,7 @@ #define E1AP_SETUP_FAIL(mSGpTR) (mSGpTR)->ittiMsg.e1ap_setup_fail #define E1AP_BEARER_CONTEXT_SETUP_REQ(mSGpTR) (mSGpTR)->ittiMsg.e1ap_bearer_setup_req #define E1AP_BEARER_CONTEXT_SETUP_RESP(mSGpTR) (mSGpTR)->ittiMsg.e1ap_bearer_setup_resp -#define E1AP_BEARER_CONTEXT_MODIFICATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.e1ap_bearer_setup_req +#define E1AP_BEARER_CONTEXT_MODIFICATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.e1ap_bearer_mod_req #define E1AP_BEARER_CONTEXT_MODIFICATION_RESP(mSGpTR) (mSGpTR)->ittiMsg.e1ap_bearer_modif_resp #define E1AP_BEARER_CONTEXT_RELEASE_CMD(mSGpTR) (mSGpTR)->ittiMsg.e1ap_bearer_release_cmd #define E1AP_BEARER_CONTEXT_RELEASE_CPLT(mSGpTR) (mSGpTR)->ittiMsg.e1ap_bearer_release_cplt @@ -111,11 +111,26 @@ typedef struct up_params_s { int cell_group_id; } up_params_t; -typedef struct drb_to_setup_s { - long drbId; +/* IE SDAP Configuration (clause 9.3.1.39 of 3GPP TS 38.463) */ +typedef struct bearer_context_sdap_config_s { + long defaultDRB; + long sDAP_Header_UL; + long sDAP_Header_DL; +} bearer_context_sdap_config_t; + +/* IE PDCP Configuration (clause 9.3.1.38 of 3GPP TS 38.463) */ +typedef struct bearer_context_pdcp_config_s { long pDCP_SN_Size_UL; long pDCP_SN_Size_DL; long rLC_Mode; + long reorderingTimer; + long discardTimer; + long pDCP_Reestablishment; +} bearer_context_pdcp_config_t; + +typedef struct drb_to_setup_s { + long drbId; + bearer_context_pdcp_config_t pdcp_config; long qci; long qosPriorityLevel; long pre_emptionCapability; @@ -161,26 +176,38 @@ typedef struct qos_flow_setup_e { qos_flow_level_qos_parameters_t qos_params; } qos_flow_to_setup_t; +/* DRB To Setup List according to 3GPP TS 38.463 */ typedef struct DRB_nGRAN_to_setup_s { + /* DRB ID (clause 9.3.1.16) */ long id; - long defaultDRB; - long sDAP_Header_UL; - long sDAP_Header_DL; - long pDCP_SN_Size_UL; - long pDCP_SN_Size_DL; - long discardTimer; - long reorderingTimer; - long rLC_Mode; + + /* SDAP Configuration (clause 9.3.1.39) */ + bearer_context_sdap_config_t sdap_config; + /* PDCP Configuration (clause 9.3.1.38) */ + bearer_context_pdcp_config_t pdcp_config; + + /* DRB Data Forwarding Information (clause 9.3.2.6) */ + /* Transport Layer Address (clause 9.3.2.4) */ in_addr_t tlAddress; + /* GTP-TEID (clause 9.3.2.3) */ int teId; + /* DL UP Transport Layer Information (clause 9.3.2.1) */ int numDlUpParam; up_params_t DlUpParamList[E1AP_MAX_NUM_UP_PARAM]; + + /* Cell Group Information (clause 9.3.1.11) */ int numCellGroups; cell_group_t cellGroupList[E1AP_MAX_NUM_CELL_GROUPS]; + + /* DRB QoS Flows Parameters (clause 9.3.1.26) */ int numQosFlow2Setup; qos_flow_to_setup_t qosFlows[E1AP_MAX_NUM_QOS_FLOWS]; -} DRB_nGRAN_to_setup_t; +} DRB_nGRAN_to_setup_t, DRB_nGRAN_to_mod_t; +/** + * PDU Session Resource To Setup List (clause 9.3.3.10) + * PDU Session Resource To Modify List (clause 9.3.3.11) +*/ typedef struct pdu_session_to_setup_s { long sessionId; long sessionType; @@ -196,9 +223,14 @@ typedef struct pdu_session_to_setup_s { long numDRB2Setup; DRB_nGRAN_to_setup_t DRBnGRanList[E1AP_MAX_NUM_NGRAN_DRB]; long numDRB2Modify; - DRB_nGRAN_to_setup_t DRBnGRanModList[E1AP_MAX_NUM_NGRAN_DRB]; -} pdu_session_to_setup_t; + DRB_nGRAN_to_mod_t DRBnGRanModList[E1AP_MAX_NUM_NGRAN_DRB]; +} pdu_session_to_setup_t, pdu_session_to_mod_t; +/** + * Bearer Context Setup Request message, clause 9.2.2.1 of 3GPP TS 38.463 + * out of simplicity, this same struct is used for clause 9.2.2.4 + * i.e. Bearer Context Modification Request message + */ typedef struct e1ap_bearer_setup_req_s { uint32_t gNB_cu_cp_ue_id; uint32_t gNB_cu_up_ue_id; @@ -212,8 +244,8 @@ typedef struct e1ap_bearer_setup_req_s { int numPDUSessions; pdu_session_to_setup_t pduSession[E1AP_MAX_NUM_PDU_SESSIONS]; int numPDUSessionsMod; - pdu_session_to_setup_t pduSessionMod[E1AP_MAX_NUM_PDU_SESSIONS]; -} e1ap_bearer_setup_req_t; + pdu_session_to_mod_t pduSessionMod[E1AP_MAX_NUM_PDU_SESSIONS]; +} e1ap_bearer_setup_req_t, e1ap_bearer_mod_req_t; typedef struct e1ap_bearer_release_cmd_s { uint32_t gNB_cu_cp_ue_id; diff --git a/openair2/E1AP/e1ap.c b/openair2/E1AP/e1ap.c index 64ded829ed..8acc43a689 100644 --- a/openair2/E1AP/e1ap.c +++ b/openair2/E1AP/e1ap.c @@ -664,18 +664,18 @@ static int fill_BEARER_CONTEXT_SETUP_REQUEST(e1ap_bearer_setup_req_t *const bear for (DRB_nGRAN_to_setup_t *j = i->DRBnGRanList; j < i->DRBnGRanList + i->numDRB2Setup; j++) { asn1cSequenceAdd(ieC6_1->dRB_To_Setup_List_NG_RAN.list, E1AP_DRB_To_Setup_Item_NG_RAN_t, ieC6_1_1); ieC6_1_1->dRB_ID = j->id; - - ieC6_1_1->sDAP_Configuration.defaultDRB = j->defaultDRB ? E1AP_DefaultDRB_true : E1AP_DefaultDRB_false; - ieC6_1_1->sDAP_Configuration.sDAP_Header_UL = j->sDAP_Header_UL; - ieC6_1_1->sDAP_Configuration.sDAP_Header_DL = j->sDAP_Header_DL; - - ieC6_1_1->pDCP_Configuration.pDCP_SN_Size_UL = j->pDCP_SN_Size_UL; - ieC6_1_1->pDCP_Configuration.pDCP_SN_Size_DL = j->pDCP_SN_Size_DL; - asn1cCallocOne(ieC6_1_1->pDCP_Configuration.discardTimer, j->discardTimer); + /* SDAP config */ + ieC6_1_1->sDAP_Configuration.defaultDRB = j->sdap_config.defaultDRB ? E1AP_DefaultDRB_true : E1AP_DefaultDRB_false; + ieC6_1_1->sDAP_Configuration.sDAP_Header_UL = j->sdap_config.sDAP_Header_UL; + ieC6_1_1->sDAP_Configuration.sDAP_Header_DL = j->sdap_config.sDAP_Header_DL; + /* PDCP Config */ + ieC6_1_1->pDCP_Configuration.pDCP_SN_Size_UL = j->pdcp_config.pDCP_SN_Size_UL; + ieC6_1_1->pDCP_Configuration.pDCP_SN_Size_DL = j->pdcp_config.pDCP_SN_Size_DL; + asn1cCallocOne(ieC6_1_1->pDCP_Configuration.discardTimer, j->pdcp_config.discardTimer); E1AP_T_ReorderingTimer_t *roTimer = calloc(1, sizeof(E1AP_T_ReorderingTimer_t)); ieC6_1_1->pDCP_Configuration.t_ReorderingTimer = roTimer; - roTimer->t_Reordering = j->reorderingTimer; - ieC6_1_1->pDCP_Configuration.rLC_Mode = j->rLC_Mode; + roTimer->t_Reordering = j->pdcp_config.reorderingTimer; + ieC6_1_1->pDCP_Configuration.rLC_Mode = j->pdcp_config.rLC_Mode; for (cell_group_t *k = j->cellGroupList; k < j->cellGroupList + j->numCellGroups; k++) { asn1cSequenceAdd(ieC6_1_1->cell_Group_Information.list, E1AP_Cell_Group_Information_Item_t, ieC6_1_1_1); @@ -871,7 +871,7 @@ int e1apCUUP_send_BEARER_CONTEXT_SETUP_FAILURE(instance_t instance) return -1; } -void extract_BEARER_CONTEXT_SETUP_REQUEST(const E1AP_E1AP_PDU_t *pdu, e1ap_bearer_setup_req_t *bearerCxt) +static void extract_BEARER_CONTEXT_SETUP_REQUEST(const E1AP_E1AP_PDU_t *pdu, e1ap_bearer_setup_req_t *bearerCxt) { const E1AP_BearerContextSetupRequest_t *in = &pdu->choice.initiatingMessage->value.choice.BearerContextSetupRequest; E1AP_BearerContextSetupRequestIEs_t *ie; @@ -970,23 +970,20 @@ void extract_BEARER_CONTEXT_SETUP_REQUEST(const E1AP_E1AP_PDU_t *pdu, e1ap_beare E1AP_DRB_To_Setup_Item_NG_RAN_t *drb2Setup = drb2SetupList->list.array[j]; drb->id = drb2Setup->dRB_ID; - - drb->defaultDRB = drb2Setup->sDAP_Configuration.defaultDRB == E1AP_DefaultDRB_true; - drb->sDAP_Header_UL = drb2Setup->sDAP_Configuration.sDAP_Header_UL; - drb->sDAP_Header_DL = drb2Setup->sDAP_Configuration.sDAP_Header_DL; - - drb->pDCP_SN_Size_UL = drb2Setup->pDCP_Configuration.pDCP_SN_Size_UL; - drb->pDCP_SN_Size_DL = drb2Setup->pDCP_Configuration.pDCP_SN_Size_DL; - + /* SDAP */ + drb->sdap_config.defaultDRB = drb2Setup->sDAP_Configuration.defaultDRB == E1AP_DefaultDRB_true; + drb->sdap_config.sDAP_Header_UL = drb2Setup->sDAP_Configuration.sDAP_Header_UL; + drb->sdap_config.sDAP_Header_DL = drb2Setup->sDAP_Configuration.sDAP_Header_DL; + /* PDCP */ + drb->pdcp_config.pDCP_SN_Size_UL = drb2Setup->pDCP_Configuration.pDCP_SN_Size_UL; + drb->pdcp_config.pDCP_SN_Size_DL = drb2Setup->pDCP_Configuration.pDCP_SN_Size_DL; if (drb2Setup->pDCP_Configuration.discardTimer) { - drb->discardTimer = *drb2Setup->pDCP_Configuration.discardTimer; + drb->pdcp_config.discardTimer = *drb2Setup->pDCP_Configuration.discardTimer; } - if (drb2Setup->pDCP_Configuration.t_ReorderingTimer) { - drb->reorderingTimer = drb2Setup->pDCP_Configuration.t_ReorderingTimer->t_Reordering; + drb->pdcp_config.reorderingTimer = drb2Setup->pDCP_Configuration.t_ReorderingTimer->t_Reordering; } - - drb->rLC_Mode = drb2Setup->pDCP_Configuration.rLC_Mode; + drb->pdcp_config.rLC_Mode = drb2Setup->pDCP_Configuration.rLC_Mode; E1AP_Cell_Group_Information_t *cellGroupList = &drb2Setup->cell_Group_Information; drb->numCellGroups = cellGroupList->list.count; @@ -1210,11 +1207,10 @@ static int fill_BEARER_CONTEXT_MODIFICATION_REQUEST(e1ap_bearer_setup_req_t *con msgNGRAN->criticality = E1AP_Criticality_reject; msgNGRAN->value.present = E1AP_NG_RAN_BearerContextModificationRequest__value_PR_PDU_Session_Resource_To_Modify_List; E1AP_PDU_Session_Resource_To_Modify_List_t *pdu2Setup = &msgNGRAN->value.choice.PDU_Session_Resource_To_Modify_List; - for (pdu_session_to_setup_t *i = bearerCxt->pduSessionMod; i < bearerCxt->pduSessionMod + bearerCxt->numPDUSessionsMod; i++) { + for (pdu_session_to_mod_t *i = bearerCxt->pduSessionMod; i < bearerCxt->pduSessionMod + bearerCxt->numPDUSessionsMod; i++) { asn1cSequenceAdd(pdu2Setup->list, E1AP_PDU_Session_Resource_To_Modify_Item_t, ieC3_1); ieC3_1->pDU_Session_ID = i->sessionId; - - for (DRB_nGRAN_to_setup_t *j = i->DRBnGRanModList; j < i->DRBnGRanModList + i->numDRB2Modify; j++) { + for (DRB_nGRAN_to_mod_t *j = i->DRBnGRanModList; j < i->DRBnGRanModList + i->numDRB2Modify; j++) { asn1cCalloc(ieC3_1->dRB_To_Modify_List_NG_RAN, drb2Mod_List); asn1cSequenceAdd(drb2Mod_List->list, E1AP_DRB_To_Modify_Item_NG_RAN_t, drb2Mod); drb2Mod->dRB_ID = j->id; @@ -1236,7 +1232,7 @@ static int fill_BEARER_CONTEXT_MODIFICATION_REQUEST(e1ap_bearer_setup_req_t *con return 0; } -static void e1apCUCP_send_BEARER_CONTEXT_MODIFICATION_REQUEST(sctp_assoc_t assoc_id, e1ap_bearer_setup_req_t *const bearerCxt) +static void e1apCUCP_send_BEARER_CONTEXT_MODIFICATION_REQUEST(sctp_assoc_t assoc_id, e1ap_bearer_mod_req_t *const bearerCxt) { E1AP_E1AP_PDU_t pdu = {0}; fill_BEARER_CONTEXT_MODIFICATION_REQUEST(bearerCxt, &pdu); @@ -1314,7 +1310,7 @@ int e1apCUUP_send_BEARER_CONTEXT_MODIFICATION_FAILURE(instance_t instance) return -1; } -void extract_BEARER_CONTEXT_MODIFICATION_REQUEST(const E1AP_E1AP_PDU_t *pdu, e1ap_bearer_setup_req_t *bearerCxt) +static void extract_BEARER_CONTEXT_MODIFICATION_REQUEST(const E1AP_E1AP_PDU_t *pdu, e1ap_bearer_mod_req_t *bearerCxt) { const E1AP_BearerContextModificationRequest_t *in = &pdu->choice.initiatingMessage->value.choice.BearerContextModificationRequest; E1AP_BearerContextModificationRequestIEs_t *ie; @@ -1350,20 +1346,19 @@ void extract_BEARER_CONTEXT_MODIFICATION_REQUEST(const E1AP_E1AP_PDU_t *pdu, e1a DevAssert(msgNGRAN->value.present = E1AP_NG_RAN_BearerContextModificationRequest__value_PR_PDU_Session_Resource_To_Modify_List); + /* PDU Sessions to modify */ E1AP_PDU_Session_Resource_To_Modify_List_t *pdu2ModList = &msgNGRAN->value.choice.PDU_Session_Resource_To_Modify_List; bearerCxt->numPDUSessionsMod = pdu2ModList->list.count; for (int i = 0; i < pdu2ModList->list.count; i++) { - pdu_session_to_setup_t *pdu_session = bearerCxt->pduSessionMod + i; + pdu_session_to_mod_t *pdu_session = bearerCxt->pduSessionMod + i; E1AP_PDU_Session_Resource_To_Modify_Item_t *pdu2Mod = pdu2ModList->list.array[i]; - pdu_session->sessionId = pdu2Mod->pDU_Session_ID; - E1AP_DRB_To_Modify_List_NG_RAN_t *drb2ModList = pdu2Mod->dRB_To_Modify_List_NG_RAN; pdu_session->numDRB2Modify = drb2ModList->list.count; + /* DRBs to modify */ for (int j = 0; j < drb2ModList->list.count; j++) { - DRB_nGRAN_to_setup_t *drb = pdu_session->DRBnGRanModList + j; + DRB_nGRAN_to_mod_t *drb = pdu_session->DRBnGRanModList + j; E1AP_DRB_To_Modify_Item_NG_RAN_t *drb2Mod = drb2ModList->list.array[j]; - drb->id = drb2Mod->dRB_ID; E1AP_UP_Parameters_t *dl_up_paramList = drb2Mod->dL_UP_Parameters; @@ -1402,7 +1397,7 @@ int e1apCUUP_handle_BEARER_CONTEXT_MODIFICATION_REQUEST(sctp_assoc_t assoc_id, DevAssert(pdu->choice.initiatingMessage->criticality == E1AP_Criticality_reject); DevAssert(pdu->choice.initiatingMessage->value.present == E1AP_InitiatingMessage__value_PR_BearerContextModificationRequest); - e1ap_bearer_setup_req_t bearerCxt = {0}; + e1ap_bearer_mod_req_t bearerCxt = {0}; extract_BEARER_CONTEXT_MODIFICATION_REQUEST(pdu, &bearerCxt); e1_bearer_context_modif(&bearerCxt); @@ -1960,7 +1955,7 @@ void *E1AP_CUCP_task(void *arg) break; case E1AP_BEARER_CONTEXT_MODIFICATION_REQ: - e1apCUCP_send_BEARER_CONTEXT_MODIFICATION_REQUEST(assoc_id, &E1AP_BEARER_CONTEXT_SETUP_REQ(msg)); + e1apCUCP_send_BEARER_CONTEXT_MODIFICATION_REQUEST(assoc_id, &E1AP_BEARER_CONTEXT_MODIFICATION_REQ(msg)); break; case E1AP_BEARER_CONTEXT_RELEASE_CMD: diff --git a/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c b/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c index 0f1d130cb5..8118af7e0b 100644 --- a/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c +++ b/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c @@ -47,10 +47,10 @@ static void fill_DRB_configList_e1(NR_DRB_ToAddModList_t *DRB_configList, const // sdap_Config asn1cCalloc(ie->cnAssociation->choice.sdap_Config, sdap_config); sdap_config->pdu_Session = pdu->sessionId; - sdap_config->sdap_HeaderDL = drb->sDAP_Header_DL; - sdap_config->sdap_HeaderUL = drb->sDAP_Header_UL; - sdap_config->defaultDRB = drb->defaultDRB; - + /* SDAP */ + sdap_config->sdap_HeaderDL = drb->sdap_config.sDAP_Header_DL; + sdap_config->sdap_HeaderUL = drb->sdap_config.sDAP_Header_UL; + sdap_config->defaultDRB = drb->sdap_config.defaultDRB; asn1cCalloc(sdap_config->mappedQoS_FlowsToAdd, FlowsToAdd); for (int j=0; j < drb->numQosFlow2Setup; j++) { asn1cSequenceAdd(FlowsToAdd->list, NR_QFI_t, qfi); @@ -63,26 +63,22 @@ static void fill_DRB_configList_e1(NR_DRB_ToAddModList_t *DRB_configList, const ie->recoverPDCP = NULL; asn1cCalloc(ie->pdcp_Config, pdcp_config); asn1cCalloc(pdcp_config->drb, drbCfg); - asn1cCallocOne(drbCfg->discardTimer, drb->discardTimer); - asn1cCallocOne(drbCfg->pdcp_SN_SizeUL, drb->pDCP_SN_Size_UL); - asn1cCallocOne(drbCfg->pdcp_SN_SizeDL, drb->pDCP_SN_Size_DL); + asn1cCallocOne(drbCfg->discardTimer, drb->pdcp_config.discardTimer); + asn1cCallocOne(drbCfg->pdcp_SN_SizeUL, drb->pdcp_config.pDCP_SN_Size_UL); + asn1cCallocOne(drbCfg->pdcp_SN_SizeDL, drb->pdcp_config.pDCP_SN_Size_DL); drbCfg->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed; drbCfg->headerCompression.choice.notUsed = 0; - drbCfg->integrityProtection = NULL; drbCfg->statusReportRequired = NULL; drbCfg->outOfOrderDelivery = NULL; pdcp_config->moreThanOneRLC = NULL; - pdcp_config->t_Reordering = calloc(1, sizeof(*pdcp_config->t_Reordering)); - *pdcp_config->t_Reordering = drb->reorderingTimer; + *pdcp_config->t_Reordering = drb->pdcp_config.reorderingTimer; pdcp_config->ext1 = NULL; - if (pdu->integrityProtectionIndication == 0 || // Required pdu->integrityProtectionIndication == 1) { // Preferred - asn1cCallocOne(drbCfg->integrityProtection, NR_PDCP_Config__drb__integrityProtection_enabled); + asn1cCallocOne(drbCfg->integrityProtection, NR_PDCP_Config__drb__integrityProtection_enabled); } - if (pdu->confidentialityProtectionIndication == 2) { // Not Needed asn1cCalloc(pdcp_config->ext1, ext1); asn1cCallocOne(ext1->cipheringDisabled, NR_PDCP_Config__ext1__cipheringDisabled_true); @@ -227,7 +223,7 @@ void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req) get_e1_if()->bearer_setup_response(&resp); } -void e1_bearer_context_modif(const e1ap_bearer_setup_req_t *req) +void e1_bearer_context_modif(const e1ap_bearer_mod_req_t *req) { AssertFatal(req->numPDUSessionsMod > 0, "need at least one PDU session to modify\n"); @@ -249,7 +245,7 @@ void e1_bearer_context_modif(const e1ap_bearer_setup_req_t *req) modif.pduSessionMod[i].id = req->pduSessionMod[i].sessionId; modif.pduSessionMod[i].numDRBModified = req->pduSessionMod[i].numDRB2Modify; for (int j=0; j < req->pduSessionMod[i].numDRB2Modify; j++) { - const DRB_nGRAN_to_setup_t *to_modif = &req->pduSessionMod[i].DRBnGRanModList[j]; + const DRB_nGRAN_to_mod_t *to_modif = &req->pduSessionMod[i].DRBnGRanModList[j]; DRB_nGRAN_modified_t *modified = &modif.pduSessionMod[i].DRBnGRanModList[j]; modified->id = to_modif->id; diff --git a/openair2/RRC/NR/cucp_cuup_direct.c b/openair2/RRC/NR/cucp_cuup_direct.c index ee3555a14b..97763d65d7 100644 --- a/openair2/RRC/NR/cucp_cuup_direct.c +++ b/openair2/RRC/NR/cucp_cuup_direct.c @@ -31,7 +31,7 @@ static void cucp_cuup_bearer_context_setup_direct(sctp_assoc_t assoc_id, const e e1_bearer_context_setup(req); } -static void cucp_cuup_bearer_context_modif_direct(sctp_assoc_t assoc_id, const e1ap_bearer_setup_req_t *req) +static void cucp_cuup_bearer_context_modif_direct(sctp_assoc_t assoc_id, const e1ap_bearer_mod_req_t *req) { AssertFatal(assoc_id == -1, "illegal assoc_id %d, impossible for integrated CU\n", assoc_id); e1_bearer_context_modif(req); diff --git a/openair2/RRC/NR/cucp_cuup_e1ap.c b/openair2/RRC/NR/cucp_cuup_e1ap.c index fb099178d4..b567fd76d4 100644 --- a/openair2/RRC/NR/cucp_cuup_e1ap.c +++ b/openair2/RRC/NR/cucp_cuup_e1ap.c @@ -37,12 +37,12 @@ static void cucp_cuup_bearer_context_setup_e1ap(sctp_assoc_t assoc_id, const e1a itti_send_msg_to_task (TASK_CUCP_E1, 0, msg_p); } -static void cucp_cuup_bearer_context_mod_e1ap(sctp_assoc_t assoc_id, const e1ap_bearer_setup_req_t *req) +static void cucp_cuup_bearer_context_mod_e1ap(sctp_assoc_t assoc_id, const e1ap_bearer_mod_req_t *req) { AssertFatal(assoc_id > 0, "illegal assoc_id %d\n", assoc_id); MessageDef *msg = itti_alloc_new_message(TASK_CUCP_E1, 0, E1AP_BEARER_CONTEXT_MODIFICATION_REQ); msg->ittiMsgHeader.originInstance = assoc_id; - e1ap_bearer_setup_req_t *req_msg = &E1AP_BEARER_CONTEXT_SETUP_REQ(msg); + e1ap_bearer_mod_req_t *req_msg = &E1AP_BEARER_CONTEXT_MODIFICATION_REQ(msg); memcpy(req_msg, req, sizeof(*req)); itti_send_msg_to_task(TASK_CUCP_E1, 0, msg); } diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index e2062b05ff..70a28b738e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -97,6 +97,7 @@ #include "openair2/F1AP/f1ap_common.h" #include "openair2/F1AP/f1ap_ids.h" #include "openair2/SDAP/nr_sdap/nr_sdap_entity.h" +#include "openair2/E1AP/e1ap.h" #include "cucp_cuup_if.h" #include "BIT_STRING.h" @@ -883,6 +884,24 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); } +/* \brief find existing PDU session inside E1AP Bearer Modif message, or + * point to new one. + * \param bearer_modif E1AP Bearer Modification Message + * \param pdu_id PDU session ID + * \return pointer to existing PDU session, or to new/unused one. */ +static pdu_session_to_mod_t *find_or_next_pdu_session(e1ap_bearer_mod_req_t *bearer_modif, int pdu_id) +{ + for (int i = 0; i < bearer_modif->numPDUSessionsMod; ++i) { + if (bearer_modif->pduSessionMod[i].sessionId == pdu_id) + return &bearer_modif->pduSessionMod[i]; + } + /* E1AP Bearer Modification has no PDU session to modify with that ID, create + * new entry */ + DevAssert(bearer_modif->numPDUSessionsMod < E1AP_MAX_NUM_PDU_SESSIONS - 1); + bearer_modif->numPDUSessionsMod += 1; + return &bearer_modif->pduSessionMod[bearer_modif->numPDUSessionsMod - 1]; +} + //----------------------------------------------------------------------------- static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context_pP, const uint8_t *masterCellGroup_from_DU, @@ -1741,30 +1760,12 @@ static void fill_e1_bearer_modif(DRB_nGRAN_to_setup_t *drb_e1, const f1ap_drb_to drb_e1->DlUpParamList[0].teId = drb_f1->up_dl_tnl[0].teid; } -/* \brief find existing PDU session inside E1AP Bearer Modif message, or - * point to new one. - * \param bearer_modif E1AP Bearer Modification Message - * \param pdu_id PDU session ID - * \return pointer to existing PDU session, or to new/unused one. */ -static pdu_session_to_setup_t *find_or_next_pdu_session(e1ap_bearer_setup_req_t *bearer_modif, int pdu_id) -{ - for (int i = 0; i < bearer_modif->numPDUSessionsMod; ++i) { - if (bearer_modif->pduSessionMod[i].sessionId == pdu_id) - return &bearer_modif->pduSessionMod[i]; - } - /* E1AP Bearer Modification has no PDU session to modify with that ID, create - * new entry */ - DevAssert(bearer_modif->numPDUSessionsMod < E1AP_MAX_NUM_PDU_SESSIONS - 1); - bearer_modif->numPDUSessionsMod += 1; - return &bearer_modif->pduSessionMod[bearer_modif->numPDUSessionsMod - 1]; -} - /* \brief use list of DRBs and send the corresponding bearer update message via * E1 to the CU of this UE */ static void e1_send_bearer_updates(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, f1ap_drb_to_be_setup_t *drbs) { // we assume the same UE ID in CU-UP and CU-CP - e1ap_bearer_setup_req_t req = { + e1ap_bearer_mod_req_t req = { .gNB_cu_cp_ue_id = UE->rrc_ue_id, .gNB_cu_up_ue_id = UE->rrc_ue_id, }; @@ -1776,7 +1777,7 @@ static void e1_send_bearer_updates(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, f LOG_E(RRC, "UE %d: UE Context Modif Response: no PDU session for DRB ID %ld\n", UE->rrc_ue_id, drb_f1->drb_id); continue; } - pdu_session_to_setup_t *pdu_e1 = find_or_next_pdu_session(&req, pdu_ue->param.pdusession_id); + pdu_session_to_mod_t *pdu_e1 = find_or_next_pdu_session(&req, pdu_ue->param.pdusession_id); DevAssert(pdu_e1 != NULL); pdu_e1->sessionId = pdu_ue->param.pdusession_id; DRB_nGRAN_to_setup_t *drb_e1 = &pdu_e1->DRBnGRanModList[pdu_e1->numDRB2Modify]; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 37cc52a007..2fafec982a 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -60,6 +60,7 @@ #include "f1ap_messages_types.h" #include "openair2/F1AP/f1ap_ids.h" #include "openair2/E1AP/e1ap_asnc.h" +#include "openair2/E1AP/e1ap.h" #include "NGAP_asn_constant.h" #include "NGAP_PDUSessionResourceSetupRequestTransfer.h" #include "NGAP_PDUSessionResourceModifyRequestTransfer.h" @@ -406,19 +407,13 @@ static void trigger_bearer_setup(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, pdu DRB_nGRAN_to_setup_t *drb = pdu->DRBnGRanList + j; drb->id = rrc_drb->drb_id; - + /* SDAP */ struct sdap_config_s *sdap_config = &rrc_drb->cnAssociation.sdap_config; - drb->defaultDRB = sdap_config->defaultDRB; - drb->sDAP_Header_UL = sdap_config->sdap_HeaderUL; - drb->sDAP_Header_DL = sdap_config->sdap_HeaderDL; - - struct pdcp_config_s *pdcp_config = &rrc_drb->pdcp_config; - drb->pDCP_SN_Size_UL = pdcp_config->pdcp_SN_SizeUL; - drb->pDCP_SN_Size_DL = pdcp_config->pdcp_SN_SizeDL; - drb->discardTimer = pdcp_config->discardTimer; - drb->reorderingTimer = pdcp_config->t_Reordering; - - drb->rLC_Mode = rrc->configuration.um_on_default_drb ? E1AP_RLC_Mode_rlc_um_bidirectional : E1AP_RLC_Mode_rlc_am; + drb->sdap_config.defaultDRB = sdap_config->defaultDRB; + drb->sdap_config.sDAP_Header_UL = sdap_config->sdap_HeaderUL; + drb->sdap_config.sDAP_Header_DL = sdap_config->sdap_HeaderDL; + /* PDCP */ + set_bearer_context_pdcp_config(&drb->pdcp_config, rrc_drb, rrc->configuration.um_on_default_drb); drb->numCellGroups = 1; // assume one cell group associated with a DRB diff --git a/openair2/RRC/NR/rrc_gNB_radio_bearers.c b/openair2/RRC/NR/rrc_gNB_radio_bearers.c index 303c5ae20d..205a58fc36 100644 --- a/openair2/RRC/NR/rrc_gNB_radio_bearers.c +++ b/openair2/RRC/NR/rrc_gNB_radio_bearers.c @@ -21,6 +21,7 @@ #include "rrc_gNB_radio_bearers.h" #include "oai_asn1.h" +#include "openair2/E1AP/e1ap.h" rrc_pdu_session_param_t *find_pduSession(gNB_RRC_UE_t *ue, int id, bool create) { @@ -56,6 +57,29 @@ drb_t *get_drb(gNB_RRC_UE_t *ue, uint8_t drb_id) return &ue->established_drbs[drb_id - 1]; } +void set_default_drb_pdcp_config(struct pdcp_config_s *pdcp_config, int do_drb_integrity, int do_drb_ciphering) +{ + AssertError(pdcp_config != NULL, return, "Failed to set default PDCP configuration for DRB!\n"); + pdcp_config->discardTimer = NR_PDCP_Config__drb__discardTimer_infinity; + pdcp_config->pdcp_SN_SizeDL = NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits; + pdcp_config->pdcp_SN_SizeUL = NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits; + pdcp_config->t_Reordering = NR_PDCP_Config__t_Reordering_ms100; + pdcp_config->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed; + pdcp_config->headerCompression.NotUsed = 0; + pdcp_config->integrityProtection = do_drb_integrity ? NR_PDCP_Config__drb__integrityProtection_enabled : 1; + pdcp_config->ext1.cipheringDisabled = do_drb_ciphering ? 1 : NR_PDCP_Config__ext1__cipheringDisabled_true; +} + +void set_bearer_context_pdcp_config(bearer_context_pdcp_config_t *pdcp_config, drb_t *rrc_drb, bool um_on_default_drb) +{ + AssertError(rrc_drb != NULL && pdcp_config != NULL, return, "Failed to set default bearer context PDCP configuration!\n"); + pdcp_config->pDCP_SN_Size_UL = rrc_drb->pdcp_config.pdcp_SN_SizeUL; + pdcp_config->pDCP_SN_Size_DL = rrc_drb->pdcp_config.pdcp_SN_SizeDL; + pdcp_config->discardTimer = rrc_drb->pdcp_config.discardTimer; + pdcp_config->reorderingTimer = rrc_drb->pdcp_config.t_Reordering; + pdcp_config->rLC_Mode = um_on_default_drb ? E1AP_RLC_Mode_rlc_um_bidirectional : E1AP_RLC_Mode_rlc_am; +} + drb_t *generateDRB(gNB_RRC_UE_t *ue, uint8_t drb_id, const rrc_pdu_session_param_t *pduSession, @@ -95,20 +119,7 @@ drb_t *generateDRB(gNB_RRC_UE_t *ue, est_drb->status = DRB_ACTIVE; } /* PDCP Configuration */ - est_drb->pdcp_config.discardTimer = NR_PDCP_Config__drb__discardTimer_infinity; - est_drb->pdcp_config.pdcp_SN_SizeDL = NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits; - est_drb->pdcp_config.pdcp_SN_SizeUL = NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits; - est_drb->pdcp_config.t_Reordering = NR_PDCP_Config__t_Reordering_ms100; - est_drb->pdcp_config.headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed; - est_drb->pdcp_config.headerCompression.NotUsed = 0; - if (do_drb_integrity) - est_drb->pdcp_config.integrityProtection = NR_PDCP_Config__drb__integrityProtection_enabled; - else - est_drb->pdcp_config.integrityProtection = 1; - if (do_drb_ciphering) - est_drb->pdcp_config.ext1.cipheringDisabled = 1; - else - est_drb->pdcp_config.ext1.cipheringDisabled = NR_PDCP_Config__ext1__cipheringDisabled_true; + set_default_drb_pdcp_config(&est_drb->pdcp_config, do_drb_integrity, do_drb_ciphering); drb_t *rrc_drb = get_drb(ue, drb_id); DevAssert(rrc_drb == est_drb); /* to double check that we create the same which we would retrieve */ diff --git a/openair2/RRC/NR/rrc_gNB_radio_bearers.h b/openair2/RRC/NR/rrc_gNB_radio_bearers.h index d29f3635ab..82502d8669 100644 --- a/openair2/RRC/NR/rrc_gNB_radio_bearers.h +++ b/openair2/RRC/NR/rrc_gNB_radio_bearers.h @@ -71,4 +71,7 @@ rrc_pdu_session_param_t *find_pduSession(gNB_RRC_UE_t *ue, int id, bool create); /// @brief get PDU session of UE ue through the DRB drb_id rrc_pdu_session_param_t *find_pduSession_from_drbId(gNB_RRC_UE_t *ue, int drb_id); +/// @brief set PDCP configuration in a bearer context management message +void set_bearer_context_pdcp_config(bearer_context_pdcp_config_t *pdcp_config, drb_t *rrc_drb, bool um_on_default_drb); + #endif From b1f9e9d57ad062096f966ea9eb3892cb536e901b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 13 Feb 2024 12:16:37 +0100 Subject: [PATCH 20/54] Reestablishment: preserve additional secondaryUE data The previous code removed the "secondary UE" data (about DU association, DU UE ID, associated CU UP), and only filled the F1-related data. In other words, the associated CU-UP was lost. This commit reworks this piece of code to retrieve old data, and update the relevant data without destroying other. --- openair2/RRC/NR/rrc_gNB.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 70a28b738e..acc5233151 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1203,8 +1203,9 @@ static void rrc_handle_RRCReestablishmentRequest(gNB_RRC_INST *rrc, sctp_assoc_t // update with new RNTI, and update secondary UE association UE->rnti = msg->crnti; + f1_ue_data_t ue_data = cu_get_f1_ue_data(UE->rrc_ue_id); + ue_data.secondary_ue = msg->gNB_DU_ue_id; cu_remove_f1_ue_data(UE->rrc_ue_id); - f1_ue_data_t ue_data = {.secondary_ue = msg->gNB_DU_ue_id, .du_assoc_id = assoc_id}; cu_add_f1_ue_data(UE->rrc_ue_id, &ue_data); LOG_I(NR_RRC, "Accept Reestablishment Request UE physCellId %ld cause %s\n", physCellId, scause); From 1f81b3f1a2dedcac4d49cf7c1c7f2804690f23aa Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Wed, 28 Feb 2024 16:19:32 +0100 Subject: [PATCH 21/54] T tracer: textlog: remove GUI code textlog is, well, text log. The GUI part is totally useless. Let's remove it. --- common/utils/T/tracer/CMakeLists.txt | 22 +++---- common/utils/T/tracer/Makefile | 5 +- common/utils/T/tracer/textlog.c | 85 +++++----------------------- 3 files changed, 28 insertions(+), 84 deletions(-) diff --git a/common/utils/T/tracer/CMakeLists.txt b/common/utils/T/tracer/CMakeLists.txt index a587b00243..e1c79ffdf6 100644 --- a/common/utils/T/tracer/CMakeLists.txt +++ b/common/utils/T/tracer/CMakeLists.txt @@ -1,8 +1,6 @@ add_library(tracer_utils OBJECT configuration.c database.c event.c handler.c utils.c) target_link_libraries(tracer_utils PUBLIC m pthread) -add_library(tracer_events OBJECT event_selector.c) - add_executable(record record.c) target_link_libraries(record PRIVATE tracer_utils) @@ -28,10 +26,19 @@ add_executable(multi multi.c) target_link_libraries(multi PRIVATE tracer_utils T) target_include_directories(multi PRIVATE ..) +add_executable(textlog textlog.c) +target_link_libraries(textlog PRIVATE tracer_utils tracer_filter + tracer_logger tracer_view) + +add_subdirectory(filter) +add_subdirectory(logger) +add_subdirectory(view) + add_custom_target(T_tools) add_dependencies(T_tools record replay extract_config extract_input_subframe - extract_output_subframe extract macpdu2wireshark multi) + extract_output_subframe extract macpdu2wireshark multi + textlog) add_dependencies(nr-softmodem T_tools) add_dependencies(nr-uesoftmodem T_tools) add_dependencies(lte-softmodem T_tools) @@ -42,9 +49,7 @@ add_dependencies(lte-uesoftmodem T_tools) # GUI-related tools so they can be added on demand, if necessary. add_boolean_option(T_TRACER_GUI OFF "Compile T tracer GUI tools" OFF) if(T_TRACER_GUI) - add_executable(textlog textlog.c) - target_link_libraries(textlog PRIVATE tracer_utils tracer_filter tracer_gui - tracer_logger tracer_view tracer_events) + add_library(tracer_events OBJECT event_selector.c) find_library(png png REQUIRED) add_executable(enb enb.c) @@ -71,9 +76,6 @@ if(T_TRACER_GUI) tracer_logger tracer_view tracer_events) add_subdirectory(gui) - add_subdirectory(filter) - add_subdirectory(logger) - add_subdirectory(view) - add_dependencies(T_tools textlog enb gnb ue vcd to_vcd) + add_dependencies(T_tools enb gnb ue vcd to_vcd) endif() diff --git a/common/utils/T/tracer/Makefile b/common/utils/T/tracer/Makefile index 74b37457b5..807347f5a4 100644 --- a/common/utils/T/tracer/Makefile +++ b/common/utils/T/tracer/Makefile @@ -31,9 +31,8 @@ extract: extract.o database.o event.o utils.o configuration.o $(CC) $(CFLAGS) -o $@ $^ $(LIBS) textlog: utils.o textlog.o database.o event.o handler.o configuration.o \ - event_selector.o view/view.a gui/gui.a logger/logger.a \ - filter/filter.a - $(CC) $(CFLAGS) -o textlog $^ $(LIBS) $(XLIBS) + view/view.a logger/logger.a filter/filter.a + $(CC) $(CFLAGS) -o textlog $^ $(LIBS) enb: utils.o enb.o database.o event.o handler.o configuration.o \ event_selector.o view/view.a gui/gui.a logger/logger.a \ diff --git a/common/utils/T/tracer/textlog.c b/common/utils/T/tracer/textlog.c index 71a928ce80..60e5092600 100644 --- a/common/utils/T/tracer/textlog.c +++ b/common/utils/T/tracer/textlog.c @@ -1,42 +1,24 @@ #include #include #include -#include #include #include "database.h" #include "event.h" #include "handler.h" #include "logger/logger.h" #include "view/view.h" -#include "gui/gui.h" #include "utils.h" -#include "event_selector.h" #include "configuration.h" -typedef struct { - int socket; - int *is_on; - int nevents; - pthread_mutex_t lock; -} textlog_data; - -void is_on_changed(void *_d) +void activate_traces(int socket, int *is_on, int nevents) { - textlog_data *d = _d; char t; - if (pthread_mutex_lock(&d->lock)) abort(); - - if (d->socket == -1) goto no_connection; - t = 1; - if (socket_send(d->socket, &t, 1) == -1 || - socket_send(d->socket, &d->nevents, sizeof(int)) == -1 || - socket_send(d->socket, d->is_on, d->nevents * sizeof(int)) == -1) + if (socket_send(socket, &t, 1) == -1 || + socket_send(socket, &nevents, sizeof(int)) == -1 || + socket_send(socket, is_on, nevents * sizeof(int)) == -1) abort(); - -no_connection: - if (pthread_mutex_unlock(&d->lock)) abort(); } void usage(void) @@ -54,28 +36,18 @@ void usage(void) " -full also dump buffers' content\n" " -raw-time also prints 'raw time'\n" " -ip connect to given IP address (default %s)\n" -" -p connect to given port (default %d)\n" -" -x GUI output\n" -" -debug-gui activate GUI debug logs\n" -" -no-gui disable GUI entirely\n", +" -p connect to given port (default %d)\n", DEFAULT_REMOTE_IP, DEFAULT_REMOTE_PORT ); exit(1); } -static void *gui_thread(void *_g) -{ - gui *g = _g; - gui_loop(g); - return NULL; -} - int main(int n, char **v) { - extern int volatile gui_logd; char *database_filename = NULL; void *database; + int socket; char *ip = DEFAULT_REMOTE_IP; int port = DEFAULT_REMOTE_PORT; char **on_off_name; @@ -86,11 +58,7 @@ int main(int n, char **v) int i; event_handler *h; logger *textlog; - gui *g = NULL; /* initialization not necessary but gcc is not happy */ - int gui_mode = 0; view *out; - int gui_active = 1; - textlog_data textlog_data; int full = 0; int raw_time = 0; @@ -115,16 +83,11 @@ int main(int n, char **v) { on_off_name[on_off_n]=NULL; on_off_action[on_off_n++]=1; continue; } if (!strcmp(v[i], "-OFF")) { on_off_name[on_off_n]=NULL; on_off_action[on_off_n++]=0; continue; } - if (!strcmp(v[i], "-x")) { gui_mode = 1; continue; } - if (!strcmp(v[i], "-debug-gui")) { gui_logd = 1; continue; } - if (!strcmp(v[i], "-no-gui")) { gui_active = 0; continue; } if (!strcmp(v[i], "-full")) { full = 1; continue; } if (!strcmp(v[i], "-raw-time")) { raw_time = 1; continue; } usage(); } - if (gui_active == 0) gui_mode = 0; - if (database_filename == NULL) { printf("ERROR: provide a database file (-d)\n"); exit(1); @@ -140,29 +103,12 @@ int main(int n, char **v) h = new_handler(database); - if (gui_active) { - g = gui_init(); - new_thread(gui_thread, g); - } - - if (gui_mode) { - widget *w, *win; -// w = new_textlist(g, 600, 20, 0); - w = new_textlist(g, 800, 50, BACKGROUND_COLOR); - win = new_toplevel_window(g, 800, 50*12, "textlog"); - widget_add_child(g, win, w, -1); - out = new_view_textlist(1000, 10, g, w); - //tout = new_view_textlist(7, 4, g, w); - } else { - out = new_view_stdout(); - } + out = new_view_stdout(); for (i = 0; i < number_of_events; i++) { char *name, *desc; database_get_generic_description(database, i, &name, &desc); textlog = new_textlog(h, database, name, desc); -// "ENB_PHY_UL_CHANNEL_ESTIMATE", -// "ev: {} eNB_id [eNB_ID] frame [frame] subframe [subframe]"); logger_add_view(textlog, out); if (full) textlog_dump_buffer(textlog, 1); if (raw_time) textlog_raw_time(textlog, 1); @@ -173,24 +119,21 @@ int main(int n, char **v) for (i = 0; i < on_off_n; i++) on_off(database, on_off_name[i], is_on, on_off_action[i]); - textlog_data.socket = -1; - textlog_data.is_on = is_on; - textlog_data.nevents = number_of_events; - if (pthread_mutex_init(&textlog_data.lock, NULL)) abort(); - if (gui_active) - setup_event_selector(g, database, is_on, is_on_changed, &textlog_data); - - textlog_data.socket = connect_to(ip, port); + socket = connect_to(ip, port); + if (socket == -1) { + printf("fatal: connection failed\n"); + return 1; + } /* send the first message - activate selected traces */ - is_on_changed(&textlog_data); + activate_traces(socket, is_on, number_of_events); OBUF ebuf = { osize: 0, omaxsize: 0, obuf: NULL }; /* read messages */ while (1) { event e; - e = get_event(textlog_data.socket, &ebuf, database); + e = get_event(socket, &ebuf, database); if (e.type == -1) break; handle_event(h, e); } From 3efb5b3657ab3df18aadb60b8abf8c7ed51ecbe7 Mon Sep 17 00:00:00 2001 From: vijay chadachan Date: Wed, 28 Feb 2024 19:19:18 +0100 Subject: [PATCH 22/54] Fixed for the PRB allocation issue assert in DLSCH scheduler The following ASSERT is tirggered while testing 16 UE setup. Assertion (NPRB>0 && (NPRB + RBstart <= BWPsize)) failed! In PRBalloc_to_locationandbandwidth0() /home/ran/common/utils/nr/nr_common.c:286 Illegal NPRB/RBstart Configuration (1,48) for BWPsize 48 Corrected the get_start_stop_allocation calculation to fix the issue. The implementation was wrong. The rbstop shall be the last rb that could be allocated. Also the following two conditions are taken care rbStart needs to be strictly smaller than rbStop rbStart+rbSize needs to be smaller or equal to rbStop The problem was that we confounded both conditions, so rbStart could be equal to rbStop, which then leads to one PRB being allocated at the end. Setting rbStop to BWPsize - 1 and making sure the above two conditions are true does not make it lead to wrong allocations anymore. --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 54a5bd4b6a..97c42c57f0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -392,17 +392,17 @@ static void get_start_stop_allocation(gNB_MAC_INST *mac, // in which case the size of CORESET 0 shall be used if CORESET 0 is configured for the cell // and the size of initial DL bandwidth part shall be used if CORESET 0 is not configured for the cell. // TS 38.214 Section 5.1.2.2.2 - *rbStop = dl_bwp->BWPSize; + *rbStop = dl_bwp->BWPSize - 1; *rbStart = 0; // start wrt BWPstart if (sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_common && dl_bwp->dci_format == NR_DL_DCI_FORMAT_1_0) { if (mac->cset0_bwp_size != 0) { *rbStart = mac->cset0_bwp_start; - *rbStop = *rbStart + mac->cset0_bwp_size; + *rbStop = *rbStart + mac->cset0_bwp_size - 1; } else { *rbStart = UE->sc_info.initial_dl_BWPStart; - *rbStop = *rbStart + UE->sc_info.initial_dl_BWPSize; + *rbStop = *rbStart + UE->sc_info.initial_dl_BWPSize - 1; } } } @@ -476,7 +476,7 @@ static bool allocate_dl_retransmission(module_id_t module_id, return false; } - while (rbStart + rbSize < rbStop && + while (rbStart + rbSize <= rbStop && (rballoc_mask[rbStart + rbSize] & slbitmap) == slbitmap && rbSize < retInfo->rbSize) rbSize++; @@ -493,7 +493,7 @@ static bool allocate_dl_retransmission(module_id_t module_id, while (rbStart < rbStop && (rballoc_mask[rbStart] & slbitmap) != slbitmap) rbStart++; - while (rbStart + rbSize < rbStop && (rballoc_mask[rbStart + rbSize] & slbitmap) == slbitmap) + while (rbStart + rbSize <= rbStop && (rballoc_mask[rbStart + rbSize] & slbitmap) == slbitmap) rbSize++; uint32_t new_tbs; @@ -785,7 +785,7 @@ static void pf_dl(module_id_t module_id, uint16_t max_rbSize = 1; - while (rbStart + max_rbSize < rbStop && (rballoc_mask[rbStart + max_rbSize] & slbitmap) == slbitmap) + while (rbStart + max_rbSize <= rbStop && (rballoc_mask[rbStart + max_rbSize] & slbitmap) == slbitmap) max_rbSize++; sched_pdsch->dmrs_parms = get_dl_dmrs_params(scc, @@ -1166,7 +1166,7 @@ void nr_schedule_ue_spec(module_id_t module_id, get_start_stop_allocation(gNB_mac, UE, &rbStart, &rbStop); dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu->rbSize, pdsch_pdu->rbStart - rbStart, - rbStop - rbStart); + rbStop - rbStart + 1); dci_payload.format_indicator = 1; dci_payload.time_domain_assignment.val = sched_pdsch->time_domain_allocation; dci_payload.mcs = sched_pdsch->mcs; From c83ff4c388c5856c442ca7c5156fc8ddb505b054 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Thu, 22 Feb 2024 12:19:30 +0100 Subject: [PATCH 23/54] Store F1-U downlink TL and TEID - info coming from UE context setup/modification response messages in RRC --- openair2/COMMON/ngap_messages_types.h | 6 ++++-- openair2/RRC/NR/nr_rrc_defs.h | 12 ++++++++++++ openair2/RRC/NR/rrc_gNB.c | 12 ++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/openair2/COMMON/ngap_messages_types.h b/openair2/COMMON/ngap_messages_types.h index caf0bff683..0c9be504ca 100644 --- a/openair2/COMMON/ngap_messages_types.h +++ b/openair2/COMMON/ngap_messages_types.h @@ -276,12 +276,14 @@ typedef struct pdusession_s { /* The transport layer address for the IP packets */ pdu_session_type_t pdu_session_type; transport_layer_addr_t upf_addr; - /* S-GW Tunnel endpoint identifier */ + /* Outgoing (UL) NG-U Tunnel Endpoint Identifier (S-GW/UPF) */ uint32_t gtp_teid; /* Stores the DRB ID of the DRBs used by this PDU Session */ uint8_t used_drbs[MAX_DRBS_PER_UE]; + /* Incoming (DL) NG-U Tunnel Endpoint Identifier (S-GW/UPF) */ uint32_t gNB_teid_N3; transport_layer_addr_t gNB_addr_N3; + /* Incoming (DL) NG-U Tunnel Endpoint Identifier (S-GW/UPF) */ uint32_t UPF_teid_N3; transport_layer_addr_t UPF_addr_N3; nssai_t nssai; @@ -306,7 +308,7 @@ typedef struct pdusession_setup_s { uint8_t pdu_session_type; transport_layer_addr_t gNB_addr; - /* UPF Tunnel endpoint identifier */ + /* Incoming NG-U Tunnel Endpoint Identifier (S-GW/UPF) */ uint32_t gtp_teid; /* qos flow list number */ diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index f0d4039033..4dc17fd493 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -189,6 +189,16 @@ typedef struct pdu_session_param_s { uint8_t cause_value; } rrc_pdu_session_param_t; +/** + * @brief F1-U tunnel configuration +*/ +typedef struct f1u_tunnel_s { + /* Downlink F1-U Tunnel Endpoint Identifier (CU-UP/DU) */ + uint32_t cuup_teid_f1u; + /* DL F1-U Transport Layer */ + transport_layer_addr_t cuup_addr_f1u; +} f1u_tunnel_t; + typedef struct drb_s { int status; int defaultDRBid; @@ -221,6 +231,8 @@ typedef struct drb_s { int cipheringDisabled; } ext1; } pdcp_config; + // F1-U + f1u_tunnel_t f1u_tunnel_config; } drb_t; typedef enum { diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index acc5233151..4e7505bcd0 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1761,6 +1761,16 @@ static void fill_e1_bearer_modif(DRB_nGRAN_to_setup_t *drb_e1, const f1ap_drb_to drb_e1->DlUpParamList[0].teId = drb_f1->up_dl_tnl[0].teid; } +/** + * @brief Store F1-U DL TL and TEID in RRC +*/ +static void f1u_gtp_update(f1u_tunnel_t *f1u, const f1ap_drb_to_be_setup_t *drb_f1) +{ + f1u->cuup_teid_f1u = drb_f1->up_dl_tnl[0].teid; + memcpy(&f1u->cuup_addr_f1u.buffer, &drb_f1->up_dl_tnl[0].tl_address, sizeof(uint8_t) * 4); + f1u->cuup_addr_f1u.length = sizeof(in_addr_t); +} + /* \brief use list of DRBs and send the corresponding bearer update message via * E1 to the CU of this UE */ static void e1_send_bearer_updates(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, f1ap_drb_to_be_setup_t *drbs) @@ -1782,6 +1792,8 @@ static void e1_send_bearer_updates(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, f DevAssert(pdu_e1 != NULL); pdu_e1->sessionId = pdu_ue->param.pdusession_id; DRB_nGRAN_to_setup_t *drb_e1 = &pdu_e1->DRBnGRanModList[pdu_e1->numDRB2Modify]; + f1u_gtp_update(&UE->established_drbs[drb_f1->drb_id].f1u_tunnel_config, drb_f1); + /* Fill E1 bearer context modification */ fill_e1_bearer_modif(drb_e1, drb_f1); pdu_e1->numDRB2Modify += 1; } From 2a078c757b2cfee76023b9479a0afa63c41997bd Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Wed, 31 Jan 2024 10:13:27 +0100 Subject: [PATCH 24/54] E1 Reestablishment - PDCP reestablishment on CUCP (DRBs) triggering Bearer Context Modification procedures over E1 - Performing PDCP reestablishment for requested DRBs on CUUP - Introduced function to notify re-establishment to CU-UP - removed call to PDCP reestablishment for the DRBs on CUCP (it's done on CUUP) cuup_notify_reestablishment: - to fetch PDU session to setup in E1 following logic as in e1_send_bearer_updates - fill bearer context modification request with stored F1-U tunnel information during E1 reestablishment, otherwise it would initialized to 0 by default - update GTP tunnel with the stored configuration after E1 reestablishment --- openair2/COMMON/e1ap_messages_types.h | 2 +- openair2/E1AP/e1ap.c | 40 +++++++----- openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c | 4 ++ openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c | 4 ++ openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 3 +- openair2/RRC/NR/rrc_gNB.c | 68 ++++++++++++++++++--- 6 files changed, 94 insertions(+), 27 deletions(-) diff --git a/openair2/COMMON/e1ap_messages_types.h b/openair2/COMMON/e1ap_messages_types.h index 486f4d3ecd..5b727a3818 100644 --- a/openair2/COMMON/e1ap_messages_types.h +++ b/openair2/COMMON/e1ap_messages_types.h @@ -125,7 +125,7 @@ typedef struct bearer_context_pdcp_config_s { long rLC_Mode; long reorderingTimer; long discardTimer; - long pDCP_Reestablishment; + bool pDCP_Reestablishment; } bearer_context_pdcp_config_t; typedef struct drb_to_setup_s { diff --git a/openair2/E1AP/e1ap.c b/openair2/E1AP/e1ap.c index 8acc43a689..ca1a7e179e 100644 --- a/openair2/E1AP/e1ap.c +++ b/openair2/E1AP/e1ap.c @@ -1214,7 +1214,10 @@ static int fill_BEARER_CONTEXT_MODIFICATION_REQUEST(e1ap_bearer_setup_req_t *con asn1cCalloc(ieC3_1->dRB_To_Modify_List_NG_RAN, drb2Mod_List); asn1cSequenceAdd(drb2Mod_List->list, E1AP_DRB_To_Modify_Item_NG_RAN_t, drb2Mod); drb2Mod->dRB_ID = j->id; - + asn1cCalloc(drb2Mod->pDCP_Configuration, pDCP_Configuration); + if (j->pdcp_config.pDCP_Reestablishment) { + asn1cCallocOne(pDCP_Configuration->pDCP_Reestablishment, E1AP_PDCP_Reestablishment_true); + } if (j->numDlUpParam > 0) { asn1cCalloc(drb2Mod->dL_UP_Parameters, DL_UP_Param_List); for (up_params_t *k = j->DlUpParamList; k < j->DlUpParamList + j->numDlUpParam; k++) { @@ -1360,21 +1363,28 @@ static void extract_BEARER_CONTEXT_MODIFICATION_REQUEST(const E1AP_E1AP_PDU_t *p DRB_nGRAN_to_mod_t *drb = pdu_session->DRBnGRanModList + j; E1AP_DRB_To_Modify_Item_NG_RAN_t *drb2Mod = drb2ModList->list.array[j]; drb->id = drb2Mod->dRB_ID; - - E1AP_UP_Parameters_t *dl_up_paramList = drb2Mod->dL_UP_Parameters; - drb->numDlUpParam = dl_up_paramList->list.count; - for (int k = 0; k < dl_up_paramList->list.count; k++) { - up_params_t *dl_up_param = drb->DlUpParamList + k; - E1AP_UP_Parameters_Item_t *dl_up_param_in = dl_up_paramList->list.array[k]; - if (dl_up_param_in->uP_TNL_Information.choice.gTPTunnel) { // Optional IE - DevAssert(dl_up_param_in->uP_TNL_Information.present = E1AP_UP_TNL_Information_PR_gTPTunnel); - BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&dl_up_param_in->uP_TNL_Information.choice.gTPTunnel->transportLayerAddress, - dl_up_param->tlAddress); - OCTET_STRING_TO_INT32(&dl_up_param_in->uP_TNL_Information.choice.gTPTunnel->gTP_TEID, dl_up_param->teId); - } else { - AssertFatal(false, "gTPTunnel IE is missing. It is mandatory at this point\n"); + if (drb2Mod->pDCP_Configuration != NULL + && drb2Mod->pDCP_Configuration->pDCP_Reestablishment != NULL + && *drb2Mod->pDCP_Configuration->pDCP_Reestablishment == E1AP_PDCP_Reestablishment_true) { + drb->pdcp_config.pDCP_Reestablishment = true; + } + if (drb2Mod->dL_UP_Parameters) { /* Optional IE in the DRB To Modify Item */ + E1AP_UP_Parameters_t *dl_up_paramList = drb2Mod->dL_UP_Parameters; + drb->numDlUpParam = dl_up_paramList->list.count; + for (int k = 0; k < dl_up_paramList->list.count; k++) { + up_params_t *dl_up_param = drb->DlUpParamList + k; + E1AP_UP_Parameters_Item_t *dl_up_param_in = dl_up_paramList->list.array[k]; + if (dl_up_param_in->uP_TNL_Information.choice.gTPTunnel) { // Optional IE + DevAssert(dl_up_param_in->uP_TNL_Information.present = E1AP_UP_TNL_Information_PR_gTPTunnel); + BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4( + &dl_up_param_in->uP_TNL_Information.choice.gTPTunnel->transportLayerAddress, + dl_up_param->tlAddress); + OCTET_STRING_TO_INT32(&dl_up_param_in->uP_TNL_Information.choice.gTPTunnel->gTP_TEID, dl_up_param->teId); + } else { + AssertFatal(false, "gTPTunnel IE is missing. It is mandatory at this point\n"); + } + dl_up_param->cell_group_id = dl_up_param_in->cell_Group_ID; } - dl_up_param->cell_group_id = dl_up_param_in->cell_Group_ID; } } } diff --git a/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c b/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c index 8118af7e0b..7faf9a5b5e 100644 --- a/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c +++ b/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c @@ -249,6 +249,10 @@ void e1_bearer_context_modif(const e1ap_bearer_mod_req_t *req) DRB_nGRAN_modified_t *modified = &modif.pduSessionMod[i].DRBnGRanModList[j]; modified->id = to_modif->id; + if (to_modif->pdcp_config.pDCP_Reestablishment) { + nr_pdcp_reestablishment(req->gNB_cu_up_ue_id, to_modif->id, false); + } + if (f1inst < 0) // no F1-U? continue; // nothing to do diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index 0bbd294c53..381152b5c5 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -409,6 +409,10 @@ static void free_rx_list(nr_pdcp_entity_t *entity) entity->rx_size = 0; } +/** + * @brief PDCP entity re-establishment according to 5.1.2 of 3GPP TS 38.323 + * @todo deal with ciphering/integrity algos and keys for transmitting/receiving entity procedures +*/ static void nr_pdcp_entity_reestablish_drb_am(nr_pdcp_entity_t *entity) { /* transmitting entity procedures */ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 73e015976d..db78c4108b 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -1210,9 +1210,10 @@ void nr_pdcp_reestablishment(ue_id_t ue_id, int rb_id, bool srb_flag) rb = nr_pdcp_get_rb(ue, rb_id, srb_flag); if (rb != NULL) { + LOG_D(PDCP, "UE %4.4lx re-establishment of %sRB %d\n", ue_id, srb_flag ? "S" : "D", rb_id); rb->reestablish_entity(rb); } else { - LOG_W(PDCP, "UE %4.4lx cannot re-establish RB %d (is_srb %d), RB not found\n", ue_id, rb_id, srb_flag); + LOG_W(PDCP, "UE %4.4lx cannot re-establish %sRB %d, RB not found\n", ue_id, srb_flag ? "S" : "D", rb_id); } nr_pdcp_manager_unlock(nr_pdcp_ue_manager); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 4e7505bcd0..6f91b98bb2 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -902,7 +902,60 @@ static pdu_session_to_mod_t *find_or_next_pdu_session(e1ap_bearer_mod_req_t *bea return &bearer_modif->pduSessionMod[bearer_modif->numPDUSessionsMod - 1]; } -//----------------------------------------------------------------------------- +/** + * @brief Notify E1 re-establishment to CU-UP + */ +static void cuup_notify_reestablishment(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue_p) +{ + e1ap_bearer_mod_req_t req = { + .gNB_cu_cp_ue_id = ue_p->rrc_ue_id, + .gNB_cu_up_ue_id = ue_p->rrc_ue_id, + }; + if (!ue_associated_to_cuup(rrc, ue_p)) + return; + /* loop through active DRBs */ + for (int drb_id = 1; drb_id <= MAX_DRBS_PER_UE; drb_id++) { + if (ue_p->established_drbs[drb_id - 1].status == DRB_INACTIVE) + continue; + /* fetch an existing PDU session for this DRB */ + rrc_pdu_session_param_t *pdu = find_pduSession_from_drbId(ue_p, drb_id); + if (pdu == NULL) { + LOG_E(RRC, "UE %d: E1 Bearer Context Modification: no PDU session for DRB ID %d\n", ue_p->rrc_ue_id, drb_id); + continue; + } + /* Get pointer to existing (or new one) PDU session to modify in E1 */ + pdu_session_to_mod_t *pdu_e1 = find_or_next_pdu_session(&req, pdu->param.pdusession_id); + AssertError(pdu != NULL, + continue, + "UE %d: E1 Bearer Context Modification: PDU session %d to setup is null\n", + ue_p->rrc_ue_id, + pdu->param.pdusession_id); + /* Prepare PDU for E1 Bearear Context Modification Request */ + pdu_e1->sessionId = pdu->param.pdusession_id; + /* Fill DRB to setup with ID, DL TL and DL TEID */ + DRB_nGRAN_to_mod_t *drb_e1 = &pdu_e1->DRBnGRanModList[pdu_e1->numDRB2Modify]; + drb_e1->id = drb_id; + drb_e1->numDlUpParam = 1; + drb_t *drbs = &ue_p->established_drbs[drb_id]; + memcpy(&drb_e1->DlUpParamList[0].tlAddress, &drbs->f1u_tunnel_config.cuup_addr_f1u.buffer, sizeof(uint8_t) * 4); + drb_e1->DlUpParamList[0].teId = drbs->f1u_tunnel_config.cuup_teid_f1u; + /* PDCP configuration */ + bearer_context_pdcp_config_t *pdcp_config = &drb_e1->pdcp_config; + drb_t *rrc_drb = get_drb(ue_p, drb_id); + set_bearer_context_pdcp_config(pdcp_config, rrc_drb, rrc->configuration.um_on_default_drb); + pdcp_config->pDCP_Reestablishment = true; + /* increase DRB to modify counter */ + pdu_e1->numDRB2Modify += 1; + } + /* Send E1 Bearer Context Modification Request (3GPP TS 38.463) */ + sctp_assoc_t assoc_id = get_existing_cuup_for_ue(rrc, ue_p); + rrc->cucp_cuup.bearer_context_mod(assoc_id, &req); +} + +/** + * @brief RRCReestablishment message + * Direction: Network to UE + */ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context_pP, const uint8_t *masterCellGroup_from_DU, const rnti_t old_rnti, @@ -941,17 +994,12 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context for (int srb_id = 1; srb_id < NR_NUM_SRB; srb_id++) { if (ue_p->Srb[srb_id].Active) { nr_pdcp_config_set_security(ue_p->rrc_ue_id, srb_id, security_mode, kRRCenc, kRRCint, kUPenc); - // TODO: should send E1 UE Bearer Modification with PDCP Reestablishment flag nr_pdcp_reestablishment(ue_p->rrc_ue_id, srb_id, true); } } - - // TODO: should send E1 UE Bearer Modification with PDCP Reestablishment flag - for (int drb_id = 1; drb_id <= MAX_DRBS_PER_UE; drb_id++) { - if (ue_p->established_drbs[drb_id - 1].status != DRB_INACTIVE) - nr_pdcp_reestablishment(ue_p->rrc_ue_id, drb_id, false); - } - + /* PDCP Reestablishment over E1 */ + cuup_notify_reestablishment(rrc, ue_p); + /* F1AP DL RRC Message Transfer */ f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->rrc_ue_id); RETURN_IF_INVALID_ASSOC_ID(ue_data); uint32_t old_gNB_DU_ue_id = old_rnti; @@ -1788,7 +1836,7 @@ static void e1_send_bearer_updates(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, f LOG_E(RRC, "UE %d: UE Context Modif Response: no PDU session for DRB ID %ld\n", UE->rrc_ue_id, drb_f1->drb_id); continue; } - pdu_session_to_mod_t *pdu_e1 = find_or_next_pdu_session(&req, pdu_ue->param.pdusession_id); + pdu_session_to_setup_t *pdu_e1 = find_or_next_pdu_session(&req, pdu_ue->param.pdusession_id); DevAssert(pdu_e1 != NULL); pdu_e1->sessionId = pdu_ue->param.pdusession_id; DRB_nGRAN_to_setup_t *drb_e1 = &pdu_e1->DRBnGRanModList[pdu_e1->numDRB2Modify]; From 72166d7ae943ca4566b3eca0944df98169cdc129 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Wed, 31 Jan 2024 12:20:54 +0100 Subject: [PATCH 25/54] E1AP procedures documentation - new folder dedicated to E1AP docs - new file to document E1AP procedures --- doc/{ => E1AP}/E1-design.md | 4 +- doc/E1AP/e1ap_procedures.md | 74 +++++++++++++++++++++++++++++++++++++ doc/README.md | 2 +- 3 files changed, 77 insertions(+), 3 deletions(-) rename doc/{ => E1AP}/E1-design.md (97%) create mode 100644 doc/E1AP/e1ap_procedures.md diff --git a/doc/E1-design.md b/doc/E1AP/E1-design.md similarity index 97% rename from doc/E1-design.md rename to doc/E1AP/E1-design.md index 6939e3867e..eb7e373e7b 100644 --- a/doc/E1-design.md +++ b/doc/E1AP/E1-design.md @@ -75,11 +75,11 @@ sequenceDiagram Note over u: E1AP_CUUP_task (SCTP Handler) Note over u: ASN1 decoder ``` - +More details about the E1AP procedures in OAI are available in this document: [E1 Procedures](./e1ap_procedures.md). # 2. Running the E1 Split -The setup is assuming that all modules are running on the same machine. The user can refer to the [F1 design document](./F1-design.md) for local deployment of the DU. +The setup is assuming that all modules are running on the same machine. The user can refer to the [F1 design document](./../F1-design.md) for local deployment of the DU. ## 2.1 Configuration File diff --git a/doc/E1AP/e1ap_procedures.md b/doc/E1AP/e1ap_procedures.md new file mode 100644 index 0000000000..c46c710333 --- /dev/null +++ b/doc/E1AP/e1ap_procedures.md @@ -0,0 +1,74 @@ + + + + + +
+ + + + + + E1AP Procedures +
+ +[[_TOC_]] + +# Introduction +The E1 interface is between the gNB-CU-CP (Central Unit - Control Plane) and gNB-CU-UP (Central Unit - User Plane) nodes. This interface is governed by the E1 Application Protocol (E1AP) outlined in the 3GPP release 16 specifications, specifically in the documents: +* 3GPP TS 38.463 - E1 Application Protocol (E1AP) +* 3GPP TS 38.460 - E1 general aspects and principles +* 3GPP TS 38.461 - E1 interface: layer 1 +* 3GPP TS 38.462 - E1 interface: signaling transport + +The E1AP protocol consists of the following sets of functions: +* E1 Interface Management functions +* E1 Bearer Context Management functions +* TEID allocation function + +## E1 Bearer Context Management function +This function handles the establishment, modification, and release of E1 bearer contexts. +* E1 Bearer Context Establishment: initiation of E1 bearer context is by gNB-CU-CP and acceptance or rejection is determined by gNB-CU-UP based on admission control criteria (e.g., resource availability). +* E1 Bearer Context Modification: can be initiated by either gNB-CU-CP or gNB-CU-UP, with the receiving node having the authority to accept or reject the modification. +* Release of Bearer Context: can be triggered either directly by gNB-CU-CP or following a request from gNB-CU-UP. +* QoS-Flow to DRB Mapping Configuration: responsible for setting up and modifying the QoS-flow to DRB mapping configuration. gNB-CU-CP decides the flow-to-DRB mapping, generates SDAP and PDCP configurations, and provides them to gNB-CU-UP. + +# OAI implementation + +For the E1AP design in OAI, please refer to the [E1 Design](./E1-design.md) document. + +## E1 re-establishment + +The purpose of this procedure is to follow-up the re-establishment of RRC connection over the E1 interface. For all activated DRBs a Bearer Context Modification from CU-CP to CU-UP is necessary, according to clause 9.2.2.4 of 3GPP TS 38.463. If any modification to the bearer context is required, the CU-CP informs the CU-UP with the relevant IEs (e.g. in case of PDCP re-establishment, PDCP Configuration IE clause 9.3.1.38), Current implementation in OAI: + +```mermaid +sequenceDiagram + participant e as UE + participant d as DU + participant c as CUCP + participant u as CUUP + + Note over e,c: RRCReestablishment Procedure + e->>d: RRCReestablishmentRequest + Note over d: initial_ul_rrc_message_transfer_f1ap + d->>+c: Initial UL RRC Message Transfer (CCCH, new C-RNTI) + Note over c: rrc_gNB_process_initial_ul_rrc_message + Note over c: rrc_handle_RRCReestablishmentRequests + c-->>+d: DL RRC Message Transfer + note right of d: fallback to RRC establishment + d-->>-e: RRCSetup + e-->>d: RRCSetupComplete + Note over c: rrc_gNB_generate_RRCReestablishment + Note over c: cuup_notify_reestablishment + Note over c: e1apCUCP_send_BEARER_CONTEXT_MODIFICATION_REQUEST + c->>u: BEARER CONTEXT MODIFICATION REQUEST + Note over u: e1apCUUP_handle_BEARER_CONTEXT_MODIFICATION_REQUEST + Note over u: e1_bearer_context_modif + Note over u: nr_pdcp_reestablishment + c->>-d: DL RRC Message Transfer (old gNB DU F1AP UE ID) + d->>e: RRCReestablishment + Note over d: Fetch UE Context with old gNB DU F1AP UE ID and update C-RNTI + e->>d: RRCReestablishmentComplete + u->>c: BEARER CONTEXT MODIFICATION RESPONSE + Note over c: e1apCUCP_handle_BEARER_CONTEXT_MODIFICATION_RESPONSE +``` diff --git a/doc/README.md b/doc/README.md index 9ff7079f8b..1ceba8f494 100644 --- a/doc/README.md +++ b/doc/README.md @@ -57,7 +57,7 @@ Legacy unmaintained files: # Designs - General software architecture notes: [SW_archi.md](./SW_archi.md) -- [Information on E1](./E1-design.md) +- [Information on E1](./E1AP/E1-design.md) - [Information on F1](./F1-design.md) - [Information on how NR nFAPI works](./NR_NFAPI_archi.md) - [Flow graph of the L1 in gNB](SW-archi-graph.md) From ffd176e9d5164c02cbdbdae9718ef9ab430419dc Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Wed, 31 Jan 2024 10:33:17 +0100 Subject: [PATCH 26/54] Minor fixes, comments, Clang formatting - comments to improve readability of the code - Clang formatting of E1 / RRC (partial) --- openair2/E1AP/e1ap.c | 58 +++++++------ openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c | 13 ++- openair2/RRC/NR/rrc_gNB.c | 93 ++++++++++++++------- 3 files changed, 102 insertions(+), 62 deletions(-) diff --git a/openair2/E1AP/e1ap.c b/openair2/E1AP/e1ap.c index ca1a7e179e..1c9ff19bff 100644 --- a/openair2/E1AP/e1ap.c +++ b/openair2/E1AP/e1ap.c @@ -163,7 +163,6 @@ int e1ap_send_ERROR_INDICATION(instance_t instance, E1AP_ErrorIndication_t *Erro /* E1 Setup: can be sent on both ways, to be refined */ - static void fill_SETUP_REQUEST(e1ap_setup_req_t *setup, E1AP_E1AP_PDU_t *pdu) { /* Create */ @@ -676,16 +675,16 @@ static int fill_BEARER_CONTEXT_SETUP_REQUEST(e1ap_bearer_setup_req_t *const bear ieC6_1_1->pDCP_Configuration.t_ReorderingTimer = roTimer; roTimer->t_Reordering = j->pdcp_config.reorderingTimer; ieC6_1_1->pDCP_Configuration.rLC_Mode = j->pdcp_config.rLC_Mode; - + /* Cell Group config */ for (cell_group_t *k = j->cellGroupList; k < j->cellGroupList + j->numCellGroups; k++) { asn1cSequenceAdd(ieC6_1_1->cell_Group_Information.list, E1AP_Cell_Group_Information_Item_t, ieC6_1_1_1); ieC6_1_1_1->cell_Group_ID = k->id; } - + /* QoS Flows */ for (qos_flow_to_setup_t *k = j->qosFlows; k < j->qosFlows + j->numQosFlow2Setup; k++) { asn1cSequenceAdd(ieC6_1_1->qos_flow_Information_To_Be_Setup, E1AP_QoS_Flow_QoS_Parameter_Item_t, ieC6_1_1_1); ieC6_1_1_1->qoS_Flow_Identifier = k->qfi; - + /* QoS Characteristics */ qos_characteristics_t *qos_char_in = &k->qos_params.qos_characteristics; if (qos_char_in->qos_type == non_dynamic) { // non Dynamic 5QI ieC6_1_1_1->qoSFlowLevelQoSParameters.qoS_Characteristics.present = E1AP_QoS_Characteristics_PR_non_Dynamic_5QI; @@ -699,7 +698,7 @@ static int fill_BEARER_CONTEXT_SETUP_REQUEST(e1ap_bearer_setup_req_t *const bear dynamic_5QI->packetErrorRate.pER_Scalar = qos_char_in->dynamic.packet_error_rate.per_scalar; dynamic_5QI->packetErrorRate.pER_Exponent = qos_char_in->dynamic.packet_error_rate.per_exponent; } - + /* QoS Retention Priority */ ngran_allocation_retention_priority_t *rent_priority_in = &k->qos_params.alloc_reten_priority; ieC6_1_1_1->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.priorityLevel = rent_priority_in->priority_level; ieC6_1_1_1->qoSFlowLevelQoSParameters.nGRANallocationRetentionPriority.pre_emptionCapability = @@ -1002,8 +1001,7 @@ static void extract_BEARER_CONTEXT_SETUP_REQUEST(const E1AP_E1AP_PDU_t *pdu, e1a qos_flow->qfi = qos2Setup->qoS_Flow_Identifier; qos_characteristics_t *qos_char = &qos_flow->qos_params.qos_characteristics; - if (qos2Setup->qoSFlowLevelQoSParameters.qoS_Characteristics.present == - E1AP_QoS_Characteristics_PR_non_Dynamic_5QI) { + if (qos2Setup->qoSFlowLevelQoSParameters.qoS_Characteristics.present == E1AP_QoS_Characteristics_PR_non_Dynamic_5QI) { qos_char->qos_type = non_dynamic; qos_char->non_dynamic.fiveqi = qos2Setup->qoSFlowLevelQoSParameters.qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI; @@ -1075,9 +1073,11 @@ void extract_BEARER_CONTEXT_SETUP_RESPONSE(const E1AP_E1AP_PDU_t *pdu, e1ap_bear case E1AP_ProtocolIE_ID_id_System_BearerContextSetupResponse: DevAssert(ie->criticality == E1AP_Criticality_reject); DevAssert(ie->value.present == E1AP_BearerContextSetupResponseIEs__value_PR_System_BearerContextSetupResponse); - DevAssert(ie->value.choice.System_BearerContextSetupResponse.present == - E1AP_System_BearerContextSetupResponse_PR_nG_RAN_BearerContextSetupResponse); - E1AP_ProtocolIE_Container_4932P22_t *msgNGRAN_list = (E1AP_ProtocolIE_Container_4932P22_t *) ie->value.choice.System_BearerContextSetupResponse.choice.nG_RAN_BearerContextSetupResponse; + DevAssert(ie->value.choice.System_BearerContextSetupResponse.present + == E1AP_System_BearerContextSetupResponse_PR_nG_RAN_BearerContextSetupResponse); + E1AP_ProtocolIE_Container_4932P22_t *msgNGRAN_list = + (E1AP_ProtocolIE_Container_4932P22_t *) + ie->value.choice.System_BearerContextSetupResponse.choice.nG_RAN_BearerContextSetupResponse; DevAssert(msgNGRAN_list->list.count == 1); E1AP_NG_RAN_BearerContextSetupResponse_t *msgNGRAN = msgNGRAN_list->list.array[0]; DevAssert(msgNGRAN->id == E1AP_ProtocolIE_ID_id_PDU_Session_Resource_Setup_List); @@ -1093,10 +1093,10 @@ void extract_BEARER_CONTEXT_SETUP_RESPONSE(const E1AP_E1AP_PDU_t *pdu, e1ap_bear if (pdu_session->nG_DL_UP_TNL_Information.choice.gTPTunnel) { DevAssert(pdu_session->nG_DL_UP_TNL_Information.present == E1AP_UP_TNL_Information_PR_gTPTunnel); - BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&pdu_session->nG_DL_UP_TNL_Information.choice.gTPTunnel->transportLayerAddress, - pduSetup->tlAddress); - OCTET_STRING_TO_INT32(&pdu_session->nG_DL_UP_TNL_Information.choice.gTPTunnel->gTP_TEID, - pduSetup->teId); + BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4( + &pdu_session->nG_DL_UP_TNL_Information.choice.gTPTunnel->transportLayerAddress, + pduSetup->tlAddress); + OCTET_STRING_TO_INT32(&pdu_session->nG_DL_UP_TNL_Information.choice.gTPTunnel->gTP_TEID, pduSetup->teId); } pduSetup->numDRBSetup = pdu_session->dRB_Setup_List_NG_RAN.list.count; @@ -1114,10 +1114,8 @@ void extract_BEARER_CONTEXT_SETUP_RESPONSE(const E1AP_E1AP_PDU_t *pdu, e1ap_bear DevAssert(in_UL_UP_param->uP_TNL_Information.present == E1AP_UP_TNL_Information_PR_gTPTunnel); E1AP_GTPTunnel_t *gTPTunnel = in_UL_UP_param->uP_TNL_Information.choice.gTPTunnel; if (gTPTunnel) { - BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&gTPTunnel->transportLayerAddress, - UL_UP_param->tlAddress); - OCTET_STRING_TO_INT32(&gTPTunnel->gTP_TEID, - UL_UP_param->teId); + BIT_STRING_TO_TRANSPORT_LAYER_ADDRESS_IPv4(&gTPTunnel->transportLayerAddress, UL_UP_param->tlAddress); + OCTET_STRING_TO_INT32(&gTPTunnel->gTP_TEID, UL_UP_param->teId); } else { AssertFatal(false, "gTPTunnel information in required\n"); } @@ -1313,6 +1311,9 @@ int e1apCUUP_send_BEARER_CONTEXT_MODIFICATION_FAILURE(instance_t instance) return -1; } +/** + * @brief Process E1AP PDU and extract Bearer Context Modification Request + */ static void extract_BEARER_CONTEXT_MODIFICATION_REQUEST(const E1AP_E1AP_PDU_t *pdu, e1ap_bearer_mod_req_t *bearerCxt) { const E1AP_BearerContextModificationRequest_t *in = &pdu->choice.initiatingMessage->value.choice.BearerContextModificationRequest; @@ -1347,9 +1348,8 @@ static void extract_BEARER_CONTEXT_MODIFICATION_REQUEST(const E1AP_E1AP_PDU_t *p DevAssert(msgNGRAN_list->list.count == 1); DevAssert(msgNGRAN->id == E1AP_ProtocolIE_ID_id_PDU_Session_Resource_To_Modify_List); DevAssert(msgNGRAN->value.present = - E1AP_NG_RAN_BearerContextModificationRequest__value_PR_PDU_Session_Resource_To_Modify_List); - - /* PDU Sessions to modify */ + E1AP_NG_RAN_BearerContextModificationRequest__value_PR_PDU_Session_Resource_To_Modify_List); + /* PDU Session Resource To Modify List (see 9.3.3.11 of TS 38.463) */ E1AP_PDU_Session_Resource_To_Modify_List_t *pdu2ModList = &msgNGRAN->value.choice.PDU_Session_Resource_To_Modify_List; bearerCxt->numPDUSessionsMod = pdu2ModList->list.count; for (int i = 0; i < pdu2ModList->list.count; i++) { @@ -1397,6 +1397,10 @@ static void extract_BEARER_CONTEXT_MODIFICATION_REQUEST(const E1AP_E1AP_PDU_t *p } } +/** + * @brief Extract Bearer Context Modification Request from E1AP PDU + * and prepare Bearer Context Modification Response + */ int e1apCUUP_handle_BEARER_CONTEXT_MODIFICATION_REQUEST(sctp_assoc_t assoc_id, e1ap_upcp_inst_t *e1_inst, const E1AP_E1AP_PDU_t *pdu) @@ -1406,10 +1410,8 @@ int e1apCUUP_handle_BEARER_CONTEXT_MODIFICATION_REQUEST(sctp_assoc_t assoc_id, DevAssert(pdu->choice.initiatingMessage->procedureCode == E1AP_ProcedureCode_id_bearerContextModification); DevAssert(pdu->choice.initiatingMessage->criticality == E1AP_Criticality_reject); DevAssert(pdu->choice.initiatingMessage->value.present == E1AP_InitiatingMessage__value_PR_BearerContextModificationRequest); - e1ap_bearer_mod_req_t bearerCxt = {0}; extract_BEARER_CONTEXT_MODIFICATION_REQUEST(pdu, &bearerCxt); - e1_bearer_context_modif(&bearerCxt); return 0; } @@ -1417,7 +1419,8 @@ int e1apCUUP_handle_BEARER_CONTEXT_MODIFICATION_REQUEST(sctp_assoc_t assoc_id, static void extract_BEARER_CONTEXT_MODIFICATION_RESPONSE(const E1AP_E1AP_PDU_t *pdu, e1ap_bearer_modif_resp_t *resp) { memset(resp, 0, sizeof(*resp)); - const E1AP_BearerContextModificationResponse_t *in = &pdu->choice.successfulOutcome->value.choice.BearerContextModificationResponse; + const E1AP_BearerContextModificationResponse_t *in = + &pdu->choice.successfulOutcome->value.choice.BearerContextModificationResponse; for (int i = 0; i < in->protocolIEs.list.count; ++i) { E1AP_BearerContextModificationResponseIEs_t *ie = in->protocolIEs.list.array[i]; @@ -1437,7 +1440,8 @@ static void extract_BEARER_CONTEXT_MODIFICATION_RESPONSE(const E1AP_E1AP_PDU_t * case E1AP_ProtocolIE_ID_id_System_BearerContextModificationResponse: DevAssert(ie->criticality == E1AP_Criticality_ignore); - DevAssert(ie->value.present == E1AP_BearerContextModificationResponseIEs__value_PR_System_BearerContextModificationResponse); + DevAssert(ie->value.present + == E1AP_BearerContextModificationResponseIEs__value_PR_System_BearerContextModificationResponse); DevAssert(ie->value.choice.System_BearerContextModificationResponse.present == E1AP_System_BearerContextModificationResponse_PR_nG_RAN_BearerContextModificationResponse); E1AP_ProtocolIE_Container_4932P29_t *msgNGRAN_list = @@ -1447,7 +1451,8 @@ static void extract_BEARER_CONTEXT_MODIFICATION_RESPONSE(const E1AP_E1AP_PDU_t * E1AP_NG_RAN_BearerContextModificationResponse_t *msgNGRAN = msgNGRAN_list->list.array[0]; DevAssert(msgNGRAN->id == E1AP_ProtocolIE_ID_id_PDU_Session_Resource_Modified_List); DevAssert(msgNGRAN->criticality == E1AP_Criticality_reject); - DevAssert(msgNGRAN->value.present == E1AP_NG_RAN_BearerContextModificationResponse__value_PR_PDU_Session_Resource_Modified_List); + DevAssert(msgNGRAN->value.present + == E1AP_NG_RAN_BearerContextModificationResponse__value_PR_PDU_Session_Resource_Modified_List); E1AP_PDU_Session_Resource_Modified_List_t *pduModifiedList = &msgNGRAN->value.choice.PDU_Session_Resource_Modified_List; resp->numPDUSessionsMod = pduModifiedList->list.count; @@ -1490,7 +1495,6 @@ int e1apCUCP_handle_BEARER_CONTEXT_MODIFICATION_RESPONSE(sctp_assoc_t assoc_id, DevAssert(pdu->choice.successfulOutcome->procedureCode == E1AP_ProcedureCode_id_bearerContextModification); DevAssert(pdu->choice.successfulOutcome->criticality == E1AP_Criticality_reject); DevAssert(pdu->choice.successfulOutcome->value.present == E1AP_SuccessfulOutcome__value_PR_BearerContextModificationResponse); - MessageDef *msg = itti_alloc_new_message(TASK_CUUP_E1, 0, E1AP_BEARER_CONTEXT_MODIFICATION_RESP); e1ap_bearer_modif_resp_t *modif = &E1AP_BEARER_CONTEXT_MODIFICATION_RESP(msg); extract_BEARER_CONTEXT_MODIFICATION_RESPONSE(pdu, modif); diff --git a/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c b/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c index 7faf9a5b5e..2b65cf87f9 100644 --- a/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c +++ b/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c @@ -37,7 +37,7 @@ static void fill_DRB_configList_e1(NR_DRB_ToAddModList_t *DRB_configList, const pdu_session_to_setup_t *pdu) { - for (int i=0; i < pdu->numDRB2Setup; i++) { + for (int i = 0; i < pdu->numDRB2Setup; i++) { const DRB_nGRAN_to_setup_t *drb = pdu->DRBnGRanList + i; asn1cSequenceAdd(DRB_configList->list, struct NR_DRB_ToAddMod, ie); ie->drb_Identity = drb->id; @@ -52,7 +52,7 @@ static void fill_DRB_configList_e1(NR_DRB_ToAddModList_t *DRB_configList, const sdap_config->sdap_HeaderUL = drb->sdap_config.sDAP_Header_UL; sdap_config->defaultDRB = drb->sdap_config.defaultDRB; asn1cCalloc(sdap_config->mappedQoS_FlowsToAdd, FlowsToAdd); - for (int j=0; j < drb->numQosFlow2Setup; j++) { + for (int j = 0; j < drb->numQosFlow2Setup; j++) { asn1cSequenceAdd(FlowsToAdd->list, NR_QFI_t, qfi); *qfi = drb->qosFlows[j].qfi; } @@ -223,6 +223,9 @@ void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req) get_e1_if()->bearer_setup_response(&resp); } +/** + * @brief Fill Bearer Context Modification Response and send to callback + */ void e1_bearer_context_modif(const e1ap_bearer_mod_req_t *req) { AssertFatal(req->numPDUSessionsMod > 0, "need at least one PDU session to modify\n"); @@ -235,7 +238,8 @@ void e1_bearer_context_modif(const e1ap_bearer_mod_req_t *req) instance_t f1inst = get_f1_gtp_instance(); - for (int i=0; i < req->numPDUSessionsMod; i++) { + /* PDU Session Resource To Modify List (see 9.3.3.11 of TS 38.463) */ + for (int i = 0; i < req->numPDUSessionsMod; i++) { DevAssert(req->pduSessionMod[i].sessionId > 0); LOG_I(E1AP, "UE %d: updating PDU session ID %ld (%ld bearers)\n", @@ -244,7 +248,8 @@ void e1_bearer_context_modif(const e1ap_bearer_mod_req_t *req) req->pduSessionMod[i].numDRB2Modify); modif.pduSessionMod[i].id = req->pduSessionMod[i].sessionId; modif.pduSessionMod[i].numDRBModified = req->pduSessionMod[i].numDRB2Modify; - for (int j=0; j < req->pduSessionMod[i].numDRB2Modify; j++) { + /* DRBs to modify */ + for (int j = 0; j < req->pduSessionMod[i].numDRB2Modify; j++) { const DRB_nGRAN_to_mod_t *to_modif = &req->pduSessionMod[i].DRBnGRanModList[j]; DRB_nGRAN_modified_t *modified = &modif.pduSessionMod[i].DRBnGRanModList[j]; modified->id = to_modif->id; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 6f91b98bb2..c9ff93065a 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -155,15 +155,24 @@ static void rrc_deliver_dl_rrc_message(void *deliver_pdu_data, ue_id_t ue_id, in data->rrc->mac_rrc.dl_rrc_message_transfer(data->assoc_id, data->dl_rrc); } - -void nr_rrc_transfer_protected_rrc_message(const gNB_RRC_INST *rrc, const gNB_RRC_UE_t *ue_p, uint8_t srb_id, const uint8_t* buffer, int size) +void nr_rrc_transfer_protected_rrc_message(const gNB_RRC_INST *rrc, + const gNB_RRC_UE_t *ue_p, + uint8_t srb_id, + const uint8_t *buffer, + int size) { DevAssert(size > 0); f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_p->rrc_ue_id); RETURN_IF_INVALID_ASSOC_ID(ue_data); f1ap_dl_rrc_message_t dl_rrc = {.gNB_CU_ue_id = ue_p->rrc_ue_id, .gNB_DU_ue_id = ue_data.secondary_ue, .srb_id = srb_id}; - deliver_dl_rrc_message_data_t data = {.rrc = rrc, .dl_rrc = &dl_rrc, .assoc_id = ue_data.du_assoc_id }; - nr_pdcp_data_req_srb(ue_p->rrc_ue_id, srb_id, rrc_gNB_mui++, size, (unsigned char *const)buffer, rrc_deliver_dl_rrc_message, &data); + deliver_dl_rrc_message_data_t data = {.rrc = rrc, .dl_rrc = &dl_rrc, .assoc_id = ue_data.du_assoc_id}; + nr_pdcp_data_req_srb(ue_p->rrc_ue_id, + srb_id, + rrc_gNB_mui++, + size, + (unsigned char *const)buffer, + rrc_deliver_dl_rrc_message, + &data); } static int get_dl_band(const f1ap_served_cell_info_t *cell_info) @@ -189,9 +198,13 @@ static int get_dl_bw(const f1ap_served_cell_info_t *cell_info) static int get_ssb_arfcn(const f1ap_served_cell_info_t *cell_info, const NR_MIB_t *mib, const NR_SIB1_t *sib1) { DevAssert(cell_info != NULL && sib1 != NULL && mib != NULL); - const NR_FrequencyInfoDL_SIB_t* freq_info = &sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL; - AssertFatal(freq_info->scs_SpecificCarrierList.list.count == 1, "cannot handle more than one carrier, but has %d\n", freq_info->scs_SpecificCarrierList.list.count); - AssertFatal(freq_info->scs_SpecificCarrierList.list.array[0]->offsetToCarrier == 0, "cannot handle offsetToCarrier != 0, but is %ld\n", freq_info->scs_SpecificCarrierList.list.array[0]->offsetToCarrier); + const NR_FrequencyInfoDL_SIB_t *freq_info = &sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL; + AssertFatal(freq_info->scs_SpecificCarrierList.list.count == 1, + "cannot handle more than one carrier, but has %d\n", + freq_info->scs_SpecificCarrierList.list.count); + AssertFatal(freq_info->scs_SpecificCarrierList.list.array[0]->offsetToCarrier == 0, + "cannot handle offsetToCarrier != 0, but is %ld\n", + freq_info->scs_SpecificCarrierList.list.array[0]->offsetToCarrier); long offsetToPointA = freq_info->offsetToPointA; long kssb = mib->ssb_SubcarrierOffset; @@ -208,16 +221,25 @@ static int get_ssb_arfcn(const f1ap_served_cell_info_t *cell_info, const NR_MIB_ else AssertFatal(false, "Invalid absoluteFrequencyPointA: %d\n", dl_arfcn); - uint64_t freqpointa = from_nrarfcn(band, scs, dl_arfcn); // offsetToPointA and kSSB are both on 15kHz SCS for FR1 and 60kHz SCS for FR2 (see 38.211 sections 7.4.3.1 and 4.4.4.2) // SSB uses the SCS of the cell and is 20 RBs wide, so use 10 - uint64_t freqssb = freqpointa + scaling * 15000 * (offsetToPointA * 12 + kssb) + 10ll * 12 * (1 << scs) * 15000; + uint64_t freqssb = freqpointa + scaling * 15000 * (offsetToPointA * 12 + kssb) + 10ll * 12 * (1 << scs) * 15000; int bw_index = get_supported_band_index(scs, band, get_dl_bw(cell_info)); int band_size_hz = get_supported_bw_mhz(band > 256 ? FR2 : FR1, bw_index) * 1000 * 1000; uint32_t ssb_arfcn = to_nrarfcn(band, freqssb, scs, band_size_hz); - LOG_D(RRC, "freqpointa %ld Hz/%d offsetToPointA %ld kssb %ld scs %d band %d band_size_hz %d freqssb %ld Hz/%d\n", freqpointa, dl_arfcn, offsetToPointA, kssb, scs, band, band_size_hz, freqssb, ssb_arfcn); + LOG_D(NR_RRC, + "freqpointa %ld Hz/%d offsetToPointA %ld kssb %ld scs %d band %d band_size_hz %d freqssb %ld Hz/%d\n", + freqpointa, + dl_arfcn, + offsetToPointA, + kssb, + scs, + band, + band_size_hz, + freqssb, + ssb_arfcn); if (RC.nrmac) { // debugging: let's test this is the correct ARFCN @@ -228,7 +250,11 @@ static int get_ssb_arfcn(const f1ap_served_cell_info_t *cell_info, const NR_MIB_ // taken out (but the reestablishment will likely not work). const NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; uint32_t scc_ssb_arfcn = *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB; - AssertFatal(ssb_arfcn == scc_ssb_arfcn, "mismatch of SCC SSB ARFCN original %d vs. computed %d! Note: you can remove this Assert, the gNB might run but UE connection instable\n", scc_ssb_arfcn, ssb_arfcn); + AssertFatal(ssb_arfcn == scc_ssb_arfcn, + "mismatch of SCC SSB ARFCN original %d vs. computed %d! Note: you can remove this Assert, the gNB might run but UE " + "connection instable\n", + scc_ssb_arfcn, + ssb_arfcn); } return ssb_arfcn; @@ -960,13 +986,11 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context const uint8_t *masterCellGroup_from_DU, const rnti_t old_rnti, const nr_rrc_du_container_t *du) -//----------------------------------------------------------------------------- { module_id_t module_id = 0; gNB_RRC_INST *rrc = RC.nrrrc[module_id]; int enable_ciphering = 0; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; - uint8_t buffer[RRC_BUF_SIZE] = {0}; uint8_t xid = rrc_gNB_get_next_transaction_identifier(module_id); ue_p->xids[xid] = RRC_REESTABLISH; @@ -985,8 +1009,12 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context nr_derive_key(UP_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kUPenc); nr_derive_key(RRC_ENC_ALG, ue_p->ciphering_algorithm, ue_p->kgnb, kRRCenc); nr_derive_key(RRC_INT_ALG, ue_p->integrity_algorithm, ue_p->kgnb, kRRCint); - - LOG_I(NR_RRC, "Set PDCP security UE %d RNTI %04x nca %ld nia %d in RRCReestablishment\n", ue_p->rrc_ue_id, ue_p->rnti, ue_p->ciphering_algorithm, ue_p->integrity_algorithm); + LOG_I(NR_RRC, + "Set PDCP security UE %d RNTI %04x nca %ld nia %d in RRCReestablishment\n", + ue_p->rrc_ue_id, + ue_p->rnti, + ue_p->ciphering_algorithm, + ue_p->integrity_algorithm); uint8_t security_mode = enable_ciphering ? ue_p->ciphering_algorithm | (ue_p->integrity_algorithm << 4) : 0 | (ue_p->integrity_algorithm << 4); @@ -1085,11 +1113,11 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co } //----------------------------------------------------------------------------- -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(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) +{ uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; ue_p->xids[xid] = RRC_DEDICATED_RECONF; @@ -1112,7 +1140,10 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP return 0; } -static void rrc_handle_RRCSetupRequest(gNB_RRC_INST *rrc, sctp_assoc_t assoc_id, const NR_RRCSetupRequest_IEs_t *rrcSetupRequest, const f1ap_initial_ul_rrc_message_t *msg) +static void rrc_handle_RRCSetupRequest(gNB_RRC_INST *rrc, + sctp_assoc_t assoc_id, + const NR_RRCSetupRequest_IEs_t *rrcSetupRequest, + const f1ap_initial_ul_rrc_message_t *msg) { rrc_gNB_ue_context_t *ue_context_p = NULL; if (NR_InitialUE_Identity_PR_randomValue == rrcSetupRequest->ue_Identity.present) { @@ -1189,7 +1220,10 @@ static const char *get_reestab_cause(NR_ReestablishmentCause_t c) return "UNKNOWN Failure (ASN.1 decoder error?)"; } -static void rrc_handle_RRCReestablishmentRequest(gNB_RRC_INST *rrc, sctp_assoc_t assoc_id, const NR_RRCReestablishmentRequest_IEs_t *req, const f1ap_initial_ul_rrc_message_t *msg) +static void rrc_handle_RRCReestablishmentRequest(gNB_RRC_INST *rrc, + sctp_assoc_t assoc_id, + const NR_RRCReestablishmentRequest_IEs_t *req, + const f1ap_initial_ul_rrc_message_t *msg) { uint64_t random_value = 0; const char *scause = get_reestab_cause(req->reestablishmentCause); @@ -1235,9 +1269,7 @@ static void rrc_handle_RRCReestablishmentRequest(gNB_RRC_INST *rrc, sctp_assoc_t // 3GPP TS 38.321 version 15.13.0 Section 7.1 Table 7.1-1: RNTI values if (req->ue_Identity.c_RNTI < 0x1 || req->ue_Identity.c_RNTI > 0xffef) { /* c_RNTI range error should not happen */ - LOG_E(NR_RRC, - "NR_RRCReestablishmentRequest c_RNTI %04lx range error, fallback to RRC setup\n", - req->ue_Identity.c_RNTI); + LOG_E(NR_RRC, "NR_RRCReestablishmentRequest c_RNTI %04lx range error, fallback to RRC setup\n", req->ue_Identity.c_RNTI); goto fallback_rrc_setup; } @@ -1300,9 +1332,7 @@ static int handle_rrcReestablishmentComplete(const protocol_ctxt_t *const ctxt_p DevAssert(reestablishment_complete->criticalExtensions.present == NR_RRCReestablishmentComplete__criticalExtensions_PR_rrcReestablishmentComplete); - rrc_gNB_process_RRCReestablishmentComplete(ctxt_pP, - ue_context_p, - reestablishment_complete->rrc_TransactionIdentifier); + rrc_gNB_process_RRCReestablishmentComplete(ctxt_pP, ue_context_p, reestablishment_complete->rrc_TransactionIdentifier); UE->ue_reestablishment_counter++; return 0; @@ -2069,7 +2099,7 @@ void rrc_gNB_process_e1_bearer_context_setup_resp(e1ap_bearer_setup_resp_t *resp resp->gNB_cu_up_ue_id); // save the tunnel address for the PDU sessions - for (int i=0; i < resp->numPDUSessions; i++) { + for (int i = 0; i < resp->numPDUSessions; i++) { pdu_session_setup_t *e1_pdu = &resp->pduSession[i]; rrc_pdu_session_param_t *rrc_pdu = find_pduSession(UE, e1_pdu->id, false); if (rrc_pdu == NULL) { @@ -2178,7 +2208,7 @@ void rrc_gNB_process_e1_bearer_context_setup_resp(e1ap_bearer_setup_resp_t *resp /** * @brief E1AP Bearer Context Modification Response processing on CU-CP -*/ + */ void rrc_gNB_process_e1_bearer_context_modif_resp(const e1ap_bearer_modif_resp_t *resp) { gNB_RRC_INST *rrc = RC.nrrrc[0]; @@ -2197,7 +2227,7 @@ void rrc_gNB_process_e1_bearer_context_modif_resp(const e1ap_bearer_modif_resp_t /** * @brief E1AP Bearer Context Release processing -*/ + */ void rrc_gNB_process_e1_bearer_context_release_cplt(const e1ap_bearer_release_cplt_t *cplt) { // there is not really anything to do here as of now @@ -2364,6 +2394,7 @@ void *rrc_gnb_task(void *args_p) { break; /* Messages from PDCP */ + /* From DU -> CU */ case F1AP_UL_RRC_MESSAGE: PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, From 06c2ce1777ef17d7de6383b92f4a5df96ccf8c42 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 8 Feb 2024 20:24:48 +0100 Subject: [PATCH 27/54] E1 Sabox test: shorten ping --- ci-scripts/xml_files/container_sa_e1_b200_quectel.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/xml_files/container_sa_e1_b200_quectel.xml b/ci-scripts/xml_files/container_sa_e1_b200_quectel.xml index 41358c1022..5bed6b88ba 100644 --- a/ci-scripts/xml_files/container_sa_e1_b200_quectel.xml +++ b/ci-scripts/xml_files/container_sa_e1_b200_quectel.xml @@ -114,9 +114,9 @@ Ping - Ping: 20pings in 20sec + Ping: 50pings in 10sec idefix - -c 20 %cn_ip% + -c 20 -i 0.2 %cn_ip% 1 25 From 60447a24a1dff7139e049714f4bd393a696a3b59 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 8 Feb 2024 20:24:37 +0100 Subject: [PATCH 28/54] E1: add reestablishment test --- .../container_sa_e1_b200_quectel.xml | 25 +++++++++++++++++++ .../sa_e1_b200_gnb/docker-compose.yml | 10 ++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ci-scripts/xml_files/container_sa_e1_b200_quectel.xml b/ci-scripts/xml_files/container_sa_e1_b200_quectel.xml index 5bed6b88ba..541edb9172 100644 --- a/ci-scripts/xml_files/container_sa_e1_b200_quectel.xml +++ b/ci-scripts/xml_files/container_sa_e1_b200_quectel.xml @@ -37,6 +37,10 @@ 370001 370000 370002 + 360001 + 100002 + 360002 + 350000 310011 310002 330201 @@ -152,6 +156,27 @@ single-ue
+ + Custom_Command + Trigger Reestablishment (on DU) + ofqot + echo ci force_reestab | nc -N 192.168.68.195 9090 | grep -E 'Reset RLC counters of UE RNTI [0-9a-f]{4} to trigger reestablishment' + yes + + + Custom_Command + Verify Reestablishment (on CU) + ofqot + echo ci get_reestab_count | nc -N 192.168.68.194 9090 | grep -E 'UE RNTI [0-9a-f]{4} reestab 1' + yes + + + + IdleSleep + Sleep + 10 + + Undeploy_Object Undeploy CU-DU diff --git a/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml index 8e353b945e..132f73fb3c 100644 --- a/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml @@ -6,7 +6,7 @@ services: privileged: true container_name: sa-cucp-gnb environment: - USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time,line_num,function + USE_ADDITIONAL_OPTIONS: --sa --telnetsrv --telnetsrv.shrmod ci --log_config.global_log_options level,nocolor,time,line_num,function volumes: - ../../conf_files/gnb-cucp.sa.f1.quectel.conf:/opt/oai-gnb/etc/gnb.conf networks: @@ -43,7 +43,13 @@ services: container_name: sa-du-b200-gnb environment: USE_B2XX: 'yes' - USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx -E --log_config.global_log_options level,nocolor,time,line_num,function --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 1 --RUs.[0].att_rx 18 --RUs.[0].att_tx 18 + USE_ADDITIONAL_OPTIONS: --sa + --RUs.[0].sdr_addrs serial=30C51D4 + --continuous-tx -E + --telnetsrv --telnetsrv.shrmod ci + --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 1 + --RUs.[0].att_rx 18 --RUs.[0].att_tx 18 + --log_config.global_log_options level,nocolor,time,line_num,function volumes: - ../../conf_files/gnb-du.sa.band78.106prb.usrpb200.conf:/opt/oai-gnb/etc/gnb.conf - /dev:/dev From 56c4a6ec07e2093351112314beeda3228beb66f1 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Wed, 28 Feb 2024 16:04:41 +0100 Subject: [PATCH 29/54] change trace to new NR_MAC_DCI and NR_PHY_DCI for DCI processing --- common/utils/LOG/log.c | 3 +- common/utils/LOG/log.h | 7 +- common/utils/T/T_messages.txt | 51 +++++++++----- openair1/PHY/NR_TRANSPORT/nr_dci.c | 33 ++++++--- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 17 +++-- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 67 +++++++++++++------ .../NR_MAC_UE/nr_ue_dci_configuration.c | 23 +++++-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 42 ++++++------ 8 files changed, 160 insertions(+), 83 deletions(-) diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 389ce6aede..d2ef196e55 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -497,7 +497,8 @@ int logInit (void) register_log_component("GNB_APP","log",GNB_APP); register_log_component("NR_RRC","log",NR_RRC); register_log_component("NR_MAC","log",NR_MAC); - register_log_component("NR_DCI", "log", NR_DCI); + register_log_component("NR_MAC_DCI", "log", NR_MAC_DCI); + register_log_component("NR_PHY_DCI", "log", NR_PHY_DCI); register_log_component("NR_PHY","log",NR_PHY); register_log_component("NGAP","",NGAP); register_log_component("ITTI","log",ITTI); diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 4b43ff45d1..56a15ef09c 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -169,8 +169,6 @@ extern "C" { #define SET_LOG_DUMP(B) g_log->dump_mask = (g_log->dump_mask | B) #define CLEAR_LOG_DUMP(B) g_log->dump_mask = (g_log->dump_mask & (~B)) - - typedef enum { MIN_LOG_COMPONENTS = 0, PHY = MIN_LOG_COMPONENTS, @@ -219,7 +217,8 @@ typedef enum { GNB_APP, NR_RRC, NR_MAC, - NR_DCI, + NR_MAC_DCI, + NR_PHY_DCI, NR_PHY, LOADER, ASN1, @@ -252,7 +251,7 @@ typedef struct { log_vprint_func_t vprint; log_print_func_t print; /* SR: make the log buffer component relative */ - char log_buffer[MAX_LOG_TOTAL]; + // char log_buffer[MAX_LOG_TOTAL]; } log_component_t; diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 2dd86fb9b4..de221a0d73 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -361,27 +361,48 @@ ID = LEGACY_NR_MAC_TRACE GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_TRACE:LEGACY FORMAT = string,log -ID = LEGACY_NR_DCI_INFO - DESC = NR_MAC legacy logs - info level - GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_INFO:LEGACY +ID = LEGACY_NR_PHY_DCI_INFO + DESC = NR_PHY_DCI legacy logs - info level + GROUP = ALL:LEGACY_NR_PHY_DCI:LEGACY_GROUP_INFO:LEGACY FORMAT = string,log -ID = LEGACY_NR_DCI_ERROR - DESC = NR_MAC legacy logs - error level - GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_ERROR:LEGACY +ID = LEGACY_NR_PHY_DCI_ERROR + DESC = NR_PHY_DCI legacy logs - error level + GROUP = ALL:LEGACY_NR_PHY_DCI:LEGACY_GROUP_ERROR:LEGACY FORMAT = string,log -ID = LEGACY_NR_DCI_WARNING - DESC = NR_MAC legacy logs - warning level - GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_WARNING:LEGACY +ID = LEGACY_NR_PHY_DCI_WARNING + DESC = NR_PHY_DCI legacy logs - warning level + GROUP = ALL:LEGACY_NR_PHY_DCI:LEGACY_GROUP_WARNING:LEGACY FORMAT = string,log -ID = LEGACY_NR_DCI_DEBUG - DESC = NR_MAC legacy logs - debug level - GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_DEBUG:LEGACY +ID = LEGACY_NR_PHY_DCI_DEBUG + DESC = NR_PHY_DCI legacy logs - debug level + GROUP = ALL:LEGACY_NR_PHY_DCI:LEGACY_GROUP_DEBUG:LEGACY FORMAT = string,log -ID = LEGACY_NR_DCI_TRACE - DESC = NR_MAC legacy logs - trace level - GROUP = ALL:LEGACY_NR_MAC:LEGACY_GROUP_TRACE:LEGACY +ID = LEGACY_NR_PHY_DCI_TRACE + DESC = NR_PHY_DCI legacy logs - trace level + GROUP = ALL:LEGACY_NR_PHY_DCI:LEGACY_GROUP_TRACE:LEGACY FORMAT = string,log +ID = LEGACY_NR_MAC_DCI_INFO + DESC = NR_MAC_DCI legacy logs - info level + GROUP = ALL:LEGACY_NR_MAC_DCI:LEGACY_GROUP_INFO:LEGACY + FORMAT = string,log +ID = LEGACY_NR_MAC_DCI_ERROR + DESC = NR_MAC_DCI legacy logs - error level + GROUP = ALL:LEGACY_NR_MAC_DCI:LEGACY_GROUP_ERROR:LEGACY + FORMAT = string,log +ID = LEGACY_NR_MAC_DCI_WARNING + DESC = NR_MAC_DCI legacy logs - warning level + GROUP = ALL:LEGACY_NR_MAC_DCI:LEGACY_GROUP_WARNING:LEGACY + FORMAT = string,log +ID = LEGACY_NR_MAC_DCI_DEBUG + DESC = NR_MAC_DCI legacy logs - debug level + GROUP = ALL:LEGACY_NR_MAC_DCI:LEGACY_GROUP_DEBUG:LEGACY + FORMAT = string,log +ID = LEGACY_NR_MAC_DCI_TRACE + DESC = NR_MAC_DCI legacy logs - trace level + GROUP = ALL:LEGACY_NR_MAC_DCI:LEGACY_GROUP_TRACE:LEGACY + FORMAT = string,log + ID = LEGACY_PHY_INFO DESC = PHY legacy logs - info level GROUP = ALL:LEGACY_PHY:LEGACY_GROUP_INFO:LEGACY diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 6f1a112669..678a407f9b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -50,7 +50,7 @@ void nr_pdcch_scrambling(uint32_t *in, uint32_t x1 = 0, x2 = 0, s = 0; reset = 1; x2 = (scrambling_RNTI<<16) + Nid; - LOG_D(PHY,"PDCCH Scrambling x2 %x : scrambling_RNTI %x \n", x2, scrambling_RNTI); + LOG_D(NR_PHY_DCI, "PDCCH Scrambling x2 %x : scrambling_RNTI %x \n", x2, scrambling_RNTI); for (int i=0; iStartSymbolIndex; cset_nsymb = pdcch_pdu_rel15->DurationSymbols; dci_idx = 0; - LOG_D(PHY, "pdcch: Coreset rb_offset %d, nb_rb %d BWP Start %d\n",rb_offset,n_rb,pdcch_pdu_rel15->BWPStart); - LOG_D(PHY, "pdcch: Coreset starting subcarrier %d on symbol %d (%d symbols)\n", cset_start_sc, cset_start_symb, cset_nsymb); + LOG_D(NR_PHY_DCI, "pdcch: Coreset rb_offset %d, nb_rb %d BWP Start %d\n", rb_offset, n_rb, pdcch_pdu_rel15->BWPStart); + LOG_D(NR_PHY_DCI, + "pdcch: Coreset starting subcarrier %d on symbol %d (%d symbols)\n", + cset_start_sc, + cset_start_symb, + cset_nsymb); // DMRS length is per OFDM symbol uint32_t dmrs_length = (n_rb+pdcch_pdu_rel15->BWPStart)*6; //2(QPSK)*3(per RB)*6(REG per CCE) uint32_t encoded_length = dci_pdu->AggregationLevel*108; //2(QPSK)*9(per RB)*6(REG per CCE) if (dci_pdu->RNTI != 0xFFFF) - LOG_D(PHY, "DL_DCI : rb_offset %d, nb_rb %d, DMRS length per symbol %d\t DCI encoded length %d (precoder_granularity %d, reg_mapping %d), Scrambling_Id %d, ScramblingRNTI %x, PayloadSizeBits %d\n", - rb_offset, n_rb,dmrs_length, encoded_length,pdcch_pdu_rel15->precoderGranularity,pdcch_pdu_rel15->CceRegMappingType, - dci_pdu->ScramblingId,dci_pdu->ScramblingRNTI,dci_pdu->PayloadSizeBits); + LOG_D(NR_PHY_DCI, + "DL_DCI : rb_offset %d, nb_rb %d, DMRS length per symbol %d\t DCI encoded length %d (precoder_granularity %d, " + "reg_mapping %d), Scrambling_Id %d, ScramblingRNTI %x, PayloadSizeBits %d\n", + rb_offset, + n_rb, + dmrs_length, + encoded_length, + pdcch_pdu_rel15->precoderGranularity, + pdcch_pdu_rel15->CceRegMappingType, + dci_pdu->ScramblingId, + dci_pdu->ScramblingRNTI, + dci_pdu->PayloadSizeBits); dmrs_length += rb_offset*6; // To accommodate more DMRS symbols in case of rb offset /// DMRS QPSK modulation @@ -182,7 +195,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, // allocating rbs per symbol for (int reg_count = 0; reg_count < num_regs; reg_count++) { k = cset_start_sc + reg_list[d][reg_count] * NR_NB_SC_PER_RB; - LOG_D(PHY, "REG %d k %d\n", reg_list[d][reg_count], k); + LOG_D(NR_PHY_DCI, "REG %d k %d\n", reg_list[d][reg_count], k); if (k >= frame_parms->ofdm_symbol_size) k -= frame_parms->ofdm_symbol_size; @@ -202,7 +215,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, ((int16_t *)txdataF)[((l * frame_parms->ofdm_symbol_size + k) << 1) + 1] = (amp * mod_dmrs[l][(dmrs_idx << 1) + 1]) >> 15; #ifdef DEBUG_PDCCH_DMRS - LOG_I(PHY, + LOG_I(NR_PHY_DCI, "PDCCH DMRS %d: l %d position %d => (%d,%d)\n", dmrs_idx, l, @@ -218,7 +231,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, ((int16_t *)txdataF)[(l * frame_parms->ofdm_symbol_size + k) << 1] = (amp * mod_dci[dci_idx << 1]) >> 15; ((int16_t *)txdataF)[((l * frame_parms->ofdm_symbol_size + k) << 1) + 1] = (amp * mod_dci[(dci_idx << 1) + 1]) >> 15; #ifdef DEBUG_DCI - LOG_I(PHY, + LOG_I(NR_PHY_DCI, "PDCCH: l %d position %d => (%d,%d)\n", l, k, @@ -237,7 +250,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, } // reg_count } // symbol_idx - LOG_D(PHY, + LOG_D(NR_PHY_DCI, "DCI: payloadSize = %d | payload = %llx\n", dci_pdu->PayloadSizeBits, *(unsigned long long *)dci_pdu->Payload); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 2558861e78..538b54ac0b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -73,21 +73,30 @@ void nr_fill_reg_list(int reg_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL * NR_ } if (pdcch_pdu_rel15->dci_pdu[d].RNTI != 0xFFFF) - LOG_D(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d CceIndex %d\n", d, bsize, R, pdcch_pdu_rel15->dci_pdu[d].CceIndex); + LOG_D(NR_PHY_DCI, + "CCE list generation for candidate %d: bundle size %d ilv size %d CceIndex %d\n", + d, + bsize, + R, + pdcch_pdu_rel15->dci_pdu[d].CceIndex); int list_idx = 0; for (uint8_t cce_idx=0; cce_idxdci_pdu[d].CceIndex + cce_idx; - LOG_D(PHY, "cce_idx %d\n", cce); + LOG_D(NR_PHY_DCI, "cce_idx %d\n", cce); for (uint8_t bundle_idx=0; bundle_idx \t llr[%d]=(%d,%d) \n", c_id, symbol_idx, @@ -224,14 +224,13 @@ static void nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, c16_t *pdcch_llrp = &pdcch_llr[symbol * coreset_nbr_rb * 9]; if (!pdcch_llrp) { - LOG_E(PHY,"pdcch_qpsk_llr: llr is null, symbol %d\n", symbol); + LOG_E(NR_PHY_DCI, "pdcch_qpsk_llr: llr is null, symbol %d\n", symbol); return; } LOG_DDD("llr logs: pdcch qpsk llr for symbol %d (pos %d), llr offset %ld\n",symbol,(symbol*frame_parms->N_RB_DL*12),pdcch_llrp-pdcch_llr); - //for (i = 0; i < (frame_parms->N_RB_DL * ((symbol == 0) ? 16 : 24)); i++) { - for (int i = 0; i < (coreset_nbr_rb * ((symbol == 0) ? 9 : 9)); i++) { + for (int i = 0; i < coreset_nbr_rb * 9; i++) { // We clip the signal c16_t res; res.r = min(rxF->r, 31); @@ -565,10 +564,13 @@ void nr_rx_pdcch(PHY_VARS_NR_UE *ue, memset(llr, 0, sizeof(llr)); - LOG_D(PHY,"pdcch coreset: freq %x, n_rb %d, rb_offset %d\n", - rel15->coreset.frequency_domain_resource[0],n_rb,rb_offset); + LOG_D(NR_PHY_DCI, + "pdcch coreset: freq %x, n_rb %d, rb_offset %d\n", + rel15->coreset.frequency_domain_resource[0], + n_rb, + rb_offset); for (int s=rel15->coreset.StartSymbolIndex; s<(rel15->coreset.StartSymbolIndex+rel15->coreset.duration); s++) { - LOG_D(PHY,"in nr_pdcch_extract_rbs_single(rxdataF -> rxdataF_ext || dl_ch_estimates -> dl_ch_estimates_ext)\n"); + LOG_D(NR_PHY_DCI, "in nr_pdcch_extract_rbs_single(rxdataF -> rxdataF_ext || dl_ch_estimates -> dl_ch_estimates_ext)\n"); nr_pdcch_extract_rbs_single(ue->frame_parms.samples_per_slot_wCP, rxdataF, @@ -583,8 +585,11 @@ void nr_rx_pdcch(PHY_VARS_NR_UE *ue, n_rb, rel15->BWPStart); - LOG_D(PHY,"we enter nr_pdcch_channel_level(avgP=%d) => compute channel level based on ofdm symbol 0, pdcch_vars[eNB_id]->dl_ch_estimates_ext\n",*avgP); - LOG_D(PHY,"in nr_pdcch_channel_level(dl_ch_estimates_ext -> dl_ch_estimates_ext)\n"); + LOG_D(NR_PHY_DCI, + "we enter nr_pdcch_channel_level(avgP=%d) => compute channel level based on ofdm symbol 0, " + "pdcch_vars[eNB_id]->dl_ch_estimates_ext\n", + *avgP); + LOG_D(NR_PHY_DCI, "in nr_pdcch_channel_level(dl_ch_estimates_ext -> dl_ch_estimates_ext)\n"); // compute channel level based on ofdm symbol 0 nr_pdcch_channel_level(rx_size, pdcch_dl_ch_estimates_ext, @@ -600,13 +605,13 @@ void nr_rx_pdcch(PHY_VARS_NR_UE *ue, log2_maxh = (log2_approx(avgs) / 2) + 5; //+frame_parms->nb_antennas_rx; #ifdef UE_DEBUG_TRACE - LOG_D(PHY, "slot %d: pdcch log2_maxh = %d (%d,%d)\n", proc->nr_slot_rx, log2_maxh, avgP[0], avgs); + LOG_D(NR_PHY_DCI, "slot %d: pdcch log2_maxh = %d (%d,%d)\n", proc->nr_slot_rx, log2_maxh, avgP[0], avgs); #endif #if T_TRACER T(T_UE_PHY_PDCCH_ENERGY, T_INT(0), T_INT(0), T_INT(proc->frame_rx % 1024), T_INT(proc->nr_slot_rx), T_INT(avgP[0]), T_INT(avgP[1]), T_INT(avgP[2]), T_INT(avgP[3])); #endif - LOG_D(PHY,"we enter nr_pdcch_channel_compensation(log2_maxh=%d)\n",log2_maxh); - LOG_D(PHY,"in nr_pdcch_channel_compensation(rxdataF_ext x dl_ch_estimates_ext -> rxdataF_comp)\n"); + LOG_D(NR_PHY_DCI, "we enter nr_pdcch_channel_compensation(log2_maxh=%d)\n", log2_maxh); + LOG_D(NR_PHY_DCI, "in nr_pdcch_channel_compensation(rxdataF_ext x dl_ch_estimates_ext -> rxdataF_comp)\n"); // compute LLRs for ofdm symbol 0 only nr_pdcch_channel_compensation(rx_size, rxdataF_ext, pdcch_dl_ch_estimates_ext, @@ -620,12 +625,12 @@ void nr_rx_pdcch(PHY_VARS_NR_UE *ue, UEscopeCopy(ue, pdcchRxdataF_comp, rxdataF_comp, sizeof(struct complex16), frame_parms->nb_antennas_rx, rx_size, 0); if (frame_parms->nb_antennas_rx > 1) { - LOG_D(PHY,"we enter nr_pdcch_detection_mrc(frame_parms->nb_antennas_rx=%d)\n", frame_parms->nb_antennas_rx); + LOG_D(NR_PHY_DCI, "we enter nr_pdcch_detection_mrc(frame_parms->nb_antennas_rx=%d)\n", frame_parms->nb_antennas_rx); nr_pdcch_detection_mrc(frame_parms, rx_size, rxdataF_comp,s); } - LOG_D(PHY,"we enter nr_pdcch_llr(for symbol %d), pdcch_vars[eNB_id]->rxdataF_comp ---> pdcch_vars[eNB_id]->llr \n",s); - LOG_D(PHY,"in nr_pdcch_llr(rxdataF_comp -> llr)\n"); + LOG_D(NR_PHY_DCI, "we enter nr_pdcch_llr(for symbol %d), pdcch_vars[eNB_id]->rxdataF_comp ---> pdcch_vars[eNB_id]->llr \n", s); + LOG_D(NR_PHY_DCI, "in nr_pdcch_llr(rxdataF_comp -> llr)\n"); nr_pdcch_llr(frame_parms, rx_size, rxdataF_comp, @@ -669,7 +674,7 @@ static void nr_pdcch_unscrambling(c16_t *e_rx, n_id = pdcch_DMRS_scrambling_id; x2 = ((rnti << 16) + n_id) % (1U << 31); // this is c_init in 38.211 v15.1.0 Section 7.3.2.3 - LOG_D(PHY,"PDCCH Unscrambling x2 %x : scrambling_RNTI %x\n", x2, rnti); + LOG_D(NR_PHY_DCI, "PDCCH Unscrambling x2 %x : scrambling_RNTI %x\n", x2, rnti); int16_t *ptr = &e_rx[0].r; for (i = 0; i < length; i++) { if ((i & 0x1f) == 0) { @@ -745,8 +750,17 @@ void nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, int dci_length = rel15->dci_length_options[k]; uint64_t dci_estimation[2]= {0}; - LOG_D(PHY, "(%i.%i) Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n", - proc->frame_rx, proc->nr_slot_rx, j, rel15->number_of_candidates, CCEind, e_rx_cand_idx, L, dci_length, nr_dci_format_string[rel15->dci_format_options[k]]); + LOG_D(NR_PHY_DCI, + "(%i.%i) Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n", + proc->frame_rx, + proc->nr_slot_rx, + j, + rel15->number_of_candidates, + CCEind, + e_rx_cand_idx, + L, + dci_length, + nr_dci_format_string[rel15->dci_format_options[k]]); int16_t tmp_e[16 * 108]; nr_pdcch_unscrambling(&pdcch_e_rx[e_rx_cand_idx], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e); @@ -757,7 +771,7 @@ void nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L); rnti_t n_rnti = rel15->rnti; - LOG_D(PHY, + LOG_D(NR_PHY_DCI, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %lx, is rnti: %d )\n", proc->frame_rx, proc->nr_slot_rx, @@ -771,7 +785,12 @@ void nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,L*108,n_rnti, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L); ue->dci_thres = (ue->dci_thres + mb) / 2; if (mb > (ue->dci_thres+30)) { - LOG_W(PHY,"DCI false positive. Dropping DCI index %d. Mismatched bits: %d/%d. Current DCI threshold: %d\n",j,mb,L*108,ue->dci_thres); + LOG_W(NR_PHY_DCI, + "DCI false positive. Dropping DCI index %d. Mismatched bits: %d/%d. Current DCI threshold: %d\n", + j, + mb, + L * 108, + ue->dci_thres); continue; } else { AssertFatal(dci_ind->number_of_dcis < sizeofArray(dci_ind->dci_list), "Fix allocation\n"); @@ -793,7 +812,13 @@ void nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, break; // If DCI is found, no need to check for remaining DCI lengths } } else { - LOG_D(PHY,"(%i.%i) Decoded crc %x does not match rnti %x for DCI format %d\n", proc->frame_rx, proc->nr_slot_rx, crc, n_rnti, rel15->dci_format_options[k]); + LOG_D(NR_PHY_DCI, + "(%i.%i) Decoded crc %x does not match rnti %x for DCI format %d\n", + proc->frame_rx, + proc->nr_slot_rx, + crc, + n_rnti, + rel15->dci_format_options[k]); } } e_rx_cand_idx += 9 * L * 6; // e_rx index for next candidate (L CCEs, 6 REGs per CCE and 9 REs per REG ) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 5eb895c52e..65e8dd3fc4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -44,7 +44,7 @@ void fill_dci_search_candidates(const NR_SearchSpace_t *ss, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, const uint32_t Y) { - LOG_D(NR_MAC,"Filling search candidates for DCI\n"); + LOG_D(NR_MAC_DCI, "Filling search candidates for DCI\n"); int i = 0; for (int maxL = 16; maxL > 0; maxL >>= 1) { @@ -55,7 +55,7 @@ void fill_dci_search_candidates(const NR_SearchSpace_t *ss, maxL); if (max_number_of_candidates == 0) continue; - LOG_D(NR_MAC,"L %d, max number of candidates %d, aggregation %d\n", maxL, max_number_of_candidates, aggregation); + LOG_D(NR_MAC_DCI, "L %d, max number of candidates %d, aggregation %d\n", maxL, max_number_of_candidates, aggregation); int N_cce_sym = 0; // nb of rbs of coreset per symbol for (int f = 0; f < 6; f++) { for (int t = 0; t < 8; t++) { @@ -67,13 +67,20 @@ void fill_dci_search_candidates(const NR_SearchSpace_t *ss, continue; for (int j = 0; j < max_number_of_candidates; j++) { int first_cce = aggregation * ((Y + ((j * N_cces) / (aggregation * max_number_of_candidates)) + 0) % (N_cces / aggregation)); - LOG_D(NR_MAC,"Candidate %d of %d first_cce %d (L %d N_cces %d Y %d)\n", j, max_number_of_candidates, first_cce, aggregation, N_cces, Y); + LOG_D(NR_MAC_DCI, + "Candidate %d of %d first_cce %d (L %d N_cces %d Y %d)\n", + j, + max_number_of_candidates, + first_cce, + aggregation, + N_cces, + Y); // to avoid storing more than one candidate with the same aggregation and starting CCE (duplicated candidate) bool duplicated = false; for (int k = 0; k < i; k++) { if (rel15->CCE[k] == first_cce && rel15->L[k] == aggregation) { duplicated = true; - LOG_D(NR_MAC, "Candidate %d of %d is duplicated\n", j, max_number_of_candidates); + LOG_D(NR_MAC_DCI, "Candidate %d of %d is duplicated\n", j, max_number_of_candidates); } } if (!duplicated) { @@ -296,7 +303,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, #ifdef DEBUG_DCI for (int i = 0; i < rel15->num_dci_options; i++) { - LOG_D(MAC, "[DCI_CONFIG] Configure DCI PDU: rnti_type %d BWPSize %d BWPStart %d rel15->SubcarrierSpacing %d rel15->dci_format %d rel15->dci_length %d sps %d monitoringSymbolsWithinSlot %d \n", + LOG_D(NR_MAC_DCI, + "[DCI_CONFIG] Configure DCI PDU: rnti_type %d BWPSize %d BWPStart %d rel15->SubcarrierSpacing %d rel15->dci_format %d " + "rel15->dci_length %d sps %d monitoringSymbolsWithinSlot %d \n", rnti_type, rel15->BWPSize, rel15->BWPStart, @@ -490,7 +499,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl fill_coresetZero(mac->coreset0, &mac->type0_PDCCH_CSS_config); fill_searchSpaceZero(mac->search_space_zero, slots_per_frame, &mac->type0_PDCCH_CSS_config); if (is_ss_monitor_occasion(frame, slot, slots_per_frame, mac->search_space_zero)) { - LOG_D(NR_MAC, "Monitoring DCI for SIB1 in frame %d slot %d\n", frame, slot); + LOG_D(NR_MAC_DCI, "Monitoring DCI for SIB1 in frame %d slot %d\n", frame, slot); config_dci_pdu(mac, dl_config, TYPE_SI_RNTI_, slot, mac->search_space_zero); } } @@ -501,7 +510,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl const NR_SearchSpace_t *ss = pdcch_config->otherSI_SS ? pdcch_config->otherSI_SS : mac->search_space_zero; // TODO configure SI-window if (monitior_dci_for_other_SI(mac, ss, slots_per_frame, frame, slot)) { - LOG_D(NR_MAC, "Monitoring DCI for other SIs in frame %d slot %d\n", frame, slot); + LOG_D(NR_MAC_DCI, "Monitoring DCI for other SIs in frame %d slot %d\n", frame, slot); config_dci_pdu(mac, dl_config, TYPE_SI_RNTI_, slot, ss); } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 4e33ad7aba..c169e03ae4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2896,9 +2896,9 @@ void nr_ue_send_sdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, in } // #define EXTRACT_DCI_ITEM(val,size) val= readBits(dci_pdu, &pos, size); -#define EXTRACT_DCI_ITEM(val, size) \ +#define EXTRACT_DCI_ITEM(val, size) \ val = readBits(dci_pdu, &pos, size); \ - LOG_D(NR_DCI, " " #val ": %d\n", val); + LOG_D(NR_MAC_DCI, " " #val ": %d\n", val); // Fixme: Intel Endianess only procedure static inline int readBits(const uint8_t *dci, int *start, int length) @@ -2945,7 +2945,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, switch(rnti_type) { case TYPE_RA_RNTI_: - LOG_D(NR_DCI, "Received dci 1_0 RA rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 1_0 RA rnti\n"); // Freq domain assignment EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, (int)ceil(log2((N_RB * (N_RB + 1)) >> 1))); // Time domain assignment @@ -2959,13 +2959,13 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case TYPE_C_RNTI_: - LOG_D(NR_DCI, "Received dci 1_0 C rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 1_0 C rnti\n"); // Identifier for DCI formats EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); // switch to DCI_0_0 if (dci_pdu_rel15->format_indicator == 0) { dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_UL_DCI_FORMAT_0_0]; - LOG_D(NR_DCI, "received dci 1_0 c_ rnti, switching to dci 0_0\n"); + LOG_D(NR_MAC_DCI, "received dci 1_0 c_ rnti, switching to dci 0_0\n"); return 2 + nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); } @@ -3013,7 +3013,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case TYPE_P_RNTI_: - LOG_D(NR_DCI, "Received dci 1_0 P rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 1_0 P rnti\n"); /* // Short Messages Indicator  E2 bits for (int i=0; i<2; i++) @@ -3042,7 +3042,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case TYPE_SI_RNTI_: - LOG_D(NR_DCI, "Received dci 1_0 SI rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 1_0 SI rnti\n"); // Freq domain assignment 0-16 bit EXTRACT_DCI_ITEM(dci_pdu_rel15->frequency_domain_assignment.val, (int)ceil(log2((N_RB * (N_RB + 1)) >> 1))); // Time domain assignment 4 bit @@ -3058,7 +3058,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case TYPE_TC_RNTI_: - LOG_D(NR_DCI, "Received dci 1_0 TC rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 1_0 TC rnti\n"); // indicating a DL DCI format 1bit EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); @@ -3066,7 +3066,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, // switch to DCI_0_0 if (dci_pdu_rel15->format_indicator == 0) { dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_UL_DCI_FORMAT_0_0]; - LOG_D(NR_DCI, "received dci 1_0 tc_ rnti, switching to dci 0_0\n"); + LOG_D(NR_MAC_DCI, "received dci 1_0 tc_ rnti, switching to dci 0_0\n"); return 2 + nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); } @@ -3094,7 +3094,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, EXTRACT_DCI_ITEM(dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val, 3); break; default: - LOG_W(NR_DCI, "Received dci 1_0 unknown rnti type: %d\n", rnti_type); + LOG_W(NR_MAC_DCI, "Received dci 1_0 unknown rnti type: %d\n", rnti_type); } break; @@ -3102,7 +3102,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, switch(rnti_type) { case TYPE_C_RNTI_: - LOG_D(NR_DCI, "Received dci 0_0 C rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 0_0 C rnti\n"); // Identifier for DCI formats EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); if (dci_pdu_rel15->format_indicator == 1) @@ -3130,13 +3130,13 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case TYPE_TC_RNTI_: - LOG_D(NR_DCI, "Received dci 1_0 TC rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 1_0 TC rnti\n"); // Identifier for DCI formats EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); //switch to DCI_1_0 if (dci_pdu_rel15->format_indicator == 1) { dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][NR_DL_DCI_FORMAT_1_0]; - LOG_D(NR_DCI, "received dci 0_0 tc_ rnti, switching to dci 0_0\n"); + LOG_D(NR_MAC_DCI, "received dci 0_0 tc_ rnti, switching to dci 0_0\n"); return 2 + nr_extract_dci_info(mac, NR_DL_DCI_FORMAT_1_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15, slot); } @@ -3158,7 +3158,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; default: - LOG_W(NR_DCI, "Received dci 0_0 unknown rnti type: %d\n", rnti_type); + LOG_W(NR_MAC_DCI, "Received dci 0_0 unknown rnti type: %d\n", rnti_type); } break; @@ -3167,12 +3167,12 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, switch(rnti_type) { case TYPE_C_RNTI_: - LOG_D(NR_DCI, "Received dci 1_1 C rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 1_1 C rnti\n"); // Identifier for DCI formats EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); if (dci_pdu_rel15->format_indicator == 0) { - LOG_W(NR_DCI, "Received dci 1_1 C rnti and format indicator 0, discarding\n"); + LOG_W(NR_MAC_DCI, "Received dci 1_1 C rnti and format indicator 0, discarding\n"); return 1; // discard dci, format indicator not corresponding to dci_format } // Carrier indicator @@ -3232,7 +3232,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, EXTRACT_DCI_ITEM(dci_pdu_rel15->dmrs_sequence_initialization.val, 1); break; default: - LOG_W(NR_DCI, "Received dci 1_1 unknown rnti type: %d\n", rnti_type); + LOG_W(NR_MAC_DCI, "Received dci 1_1 unknown rnti type: %d\n", rnti_type); } break; @@ -3240,11 +3240,11 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, switch(rnti_type) { case TYPE_C_RNTI_: - LOG_D(NR_DCI, "Received dci 0_1 C rnti\n"); + LOG_D(NR_MAC_DCI, "Received dci 0_1 C rnti\n"); //Identifier for DCI formats EXTRACT_DCI_ITEM(dci_pdu_rel15->format_indicator, 1); if (dci_pdu_rel15->format_indicator == 1) { - LOG_W(NR_DCI, "Received dci 0_1 C rnti and format indicator 1, discarding\n"); + LOG_W(NR_MAC_DCI, "Received dci 0_1 C rnti and format indicator 1, discarding\n"); return 1; // discard dci, format indicator not corresponding to dci_format } // Carrier indicator @@ -3305,12 +3305,12 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, */ break; default: - LOG_W(NR_DCI, "Received dci 0_1 unknown rnti type: %d\n", rnti_type); + LOG_W(NR_MAC_DCI, "Received dci 0_1 unknown rnti type: %d\n", rnti_type); } break; default: // other DCI formats - LOG_W(NR_DCI, "Received dci unknown format type: %d\n", dci_format); + LOG_W(NR_MAC_DCI, "Received dci unknown format type: %d\n", dci_format); break; } From e845a9c3b7e6210237b20c28acc191418157fb5e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 29 Feb 2024 18:56:31 +0100 Subject: [PATCH 30/54] CI: Make RFsim start-up faster Make RFsim start up faster by starting core and RAN start at the same time. This speeds up because we do not wait for "healthy" containers serially, but parallely. For the RAN, it is safe to start gNB and UE at the same time in SA mode (as the UE will only attach once the radio, and hence the full gNB, is ready). We do not start in parallel in do-ra and phytest, as in these modes the gNB first has to write a UE-specific configuration file. If we start both gNB and UE at the same time, the UE might try to read the file before it is written, leading to a failure. --- .../xml_files/container_5g_fdd_rfsim.xml | 24 +++---------------- .../xml_files/container_5g_rfsim_24prb.xml | 24 +++---------------- .../xml_files/container_5g_rfsim_2x2.xml | 24 +++---------------- .../container_5g_rfsim_f1_accelleran.xml | 13 ++-------- .../xml_files/container_5g_rfsim_u0_25prb.xml | 24 +++---------------- 5 files changed, 14 insertions(+), 95 deletions(-) diff --git a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml index cfcf40e69e..463cb3f2e8 100644 --- a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml @@ -28,10 +28,8 @@ 111111 100011 - 000010 000011 000012 - 000013 020011 020012 030011 @@ -47,35 +45,19 @@ oai-gnb-asan oai-nr-ue-asan - - DeployGenObject - Deploy MySql Database - yaml_files/5g_fdd_rfsimulator - mysql - 1 - - DeployGenObject Deploy OAI 5G CoreNetwork yaml_files/5g_fdd_rfsimulator - oai-amf oai-smf oai-upf oai-ext-dn + mysql oai-amf oai-smf oai-upf oai-ext-dn 5 DeployGenObject - Deploy OAI 5G gNB RF sim SA + Deploy OAI 5G gNB+UE RF sim SA yaml_files/5g_fdd_rfsimulator - oai-gnb - 6 - - - - DeployGenObject - Deploy OAI 5G NR-UE RF sim SA - yaml_files/5g_fdd_rfsimulator - oai-nr-ue + oai-gnb oai-nr-ue 7 diff --git a/ci-scripts/xml_files/container_5g_rfsim_24prb.xml b/ci-scripts/xml_files/container_5g_rfsim_24prb.xml index 41f25476c3..4f838658ec 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_24prb.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_24prb.xml @@ -28,10 +28,8 @@ 111111 100001 - 000000 000001 000002 - 000003 020001 020002 030001 @@ -47,35 +45,19 @@ oai-gnb-asan oai-nr-ue-asan - - DeployGenObject - Deploy MySql Database - yaml_files/5g_rfsimulator_24prb - mysql - 1 - - DeployGenObject Deploy OAI 5G CoreNetwork yaml_files/5g_rfsimulator_24prb - oai-amf oai-smf oai-upf oai-ext-dn + mysql oai-amf oai-smf oai-upf oai-ext-dn 5 DeployGenObject - Deploy OAI 5G gNB RF sim SA + Deploy OAI 5G gNB+UE RFsim SA yaml_files/5g_rfsimulator_24prb - oai-gnb - 6 - - - - DeployGenObject - Deploy OAI 5G NR-UE RF sim SA - yaml_files/5g_rfsimulator_24prb - oai-nr-ue + oai-gnb oai-nr-ue 7 diff --git a/ci-scripts/xml_files/container_5g_rfsim_2x2.xml b/ci-scripts/xml_files/container_5g_rfsim_2x2.xml index defe15a1df..45c311fd97 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_2x2.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_2x2.xml @@ -28,10 +28,8 @@ 111111 100001 - 000000 000001 000002 - 000003 020001 020002 030001 @@ -47,35 +45,19 @@ oai-gnb-asan oai-nr-ue-asan - - DeployGenObject - Deploy MySql Database - yaml_files/5g_rfsimulator_2x2 - mysql - 1 - - DeployGenObject Deploy OAI 5G CoreNetwork yaml_files/5g_rfsimulator_2x2 - oai-amf oai-smf oai-upf oai-ext-dn + mysql oai-amf oai-smf oai-upf oai-ext-dn 5 DeployGenObject - Deploy OAI 5G gNB RF sim SA + Deploy OAI 5G gNB+UE RF sim SA yaml_files/5g_rfsimulator_2x2 - oai-gnb - 6 - - - - DeployGenObject - Deploy OAI 5G NR-UE RF sim SA - yaml_files/5g_rfsimulator_2x2 - oai-nr-ue + oai-gnb oai-nr-ue 7 diff --git a/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml b/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml index d1433db738..5baa950549 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml @@ -27,7 +27,6 @@ 111111 000020 - 000021 020021 100021 100022 @@ -43,17 +42,9 @@ DeployGenObject - Deploy OAI-DU + Deploy OAI-DU+nrUE yaml_files/5g_rfsimulator_accelleran - oai-du - 1 - - - - DeployGenObject - Deploy nrUE - yaml_files/5g_rfsimulator_accelleran - oai-nr-ue + oai-du oai-nr-ue 2 diff --git a/ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml b/ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml index f059d69614..c31d6c1843 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml @@ -28,10 +28,8 @@ 111111 100001 - 000000 000001 000002 - 000003 020001 020002 030001 @@ -47,35 +45,19 @@ oai-gnb-asan oai-nr-ue-asan - - DeployGenObject - Deploy MySql Database - yaml_files/5g_rfsimulator_u0_25prb - mysql - 1 - - DeployGenObject Deploy OAI 5G CoreNetwork yaml_files/5g_rfsimulator_u0_25prb - oai-amf oai-smf oai-upf oai-ext-dn + mysql oai-amf oai-smf oai-upf oai-ext-dn 5 DeployGenObject - Deploy OAI 5G gNB RF sim SA + Deploy OAI 5G gNB+nrUE RF sim SA yaml_files/5g_rfsimulator_u0_25prb - oai-gnb - 6 - - - - DeployGenObject - Deploy OAI 5G NR-UE RF sim SA - yaml_files/5g_rfsimulator_u0_25prb - oai-nr-ue + oai-gnb oai-nr-ue 7 From 9af386c761d29e664f66e5464f6dc9dbfe8c7bc5 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 29 Feb 2024 18:57:43 +0100 Subject: [PATCH 31/54] CI: RFsim tests: Wait for IP Ensure that the UE has an IP address before continuing the test. Otherwise, it might happen we ping before the UE is connected. Do not do this in do-ra and phytest, as they use --noS1, which implies statically assigned IP address, so IP address check always succeeds(!). --- ci-scripts/xml_files/container_5g_e1_rfsim.xml | 7 +++++++ ci-scripts/xml_files/container_5g_f1_rfsim.xml | 7 +++++++ ci-scripts/xml_files/container_5g_fdd_rfsim.xml | 7 +++++++ ci-scripts/xml_files/container_5g_rfsim_24prb.xml | 7 +++++++ ci-scripts/xml_files/container_5g_rfsim_2x2.xml | 7 +++++++ ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml | 7 +++++++ ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml | 7 +++++++ 7 files changed, 49 insertions(+) diff --git a/ci-scripts/xml_files/container_5g_e1_rfsim.xml b/ci-scripts/xml_files/container_5g_e1_rfsim.xml index e23cffd0dd..e4ddb9e4d7 100644 --- a/ci-scripts/xml_files/container_5g_e1_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_e1_rfsim.xml @@ -30,6 +30,7 @@ 000021 000022 000023 + 000024 020021 100021 @@ -66,6 +67,12 @@ 14 + + Attach_UE + Attach OAI UE (Wait for IP) + rfsim5g_ue rfsim5g_ue2 rfsim5g_ue3 + + Ping Ping ext-dn from all NR-UEs diff --git a/ci-scripts/xml_files/container_5g_f1_rfsim.xml b/ci-scripts/xml_files/container_5g_f1_rfsim.xml index 769de69e35..09b69730a3 100644 --- a/ci-scripts/xml_files/container_5g_f1_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_f1_rfsim.xml @@ -29,6 +29,7 @@ 100021 000021 000022 + 000023 020021 030021 030022 @@ -59,6 +60,12 @@ 8 + + Attach_UE + Attach OAI UE (Wait for IP) + rfsim5g_ue + + Ping Ping ext-dn from all NR-UEs diff --git a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml index 463cb3f2e8..59be0e3738 100644 --- a/ci-scripts/xml_files/container_5g_fdd_rfsim.xml +++ b/ci-scripts/xml_files/container_5g_fdd_rfsim.xml @@ -30,6 +30,7 @@ 100011 000011 000012 + 000013 020011 020012 030011 @@ -61,6 +62,12 @@ 7 + + Attach_UE + Attach OAI UE (Wait for IP) + rfsim5g_ue + + Ping Ping ext-dn from NR-UE diff --git a/ci-scripts/xml_files/container_5g_rfsim_24prb.xml b/ci-scripts/xml_files/container_5g_rfsim_24prb.xml index 4f838658ec..e90cbc309b 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_24prb.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_24prb.xml @@ -30,6 +30,7 @@ 100001 000001 000002 + 000003 020001 020002 030001 @@ -61,6 +62,12 @@ 7 + + Attach_UE + Attach OAI UE (Wait for IP) + rfsim5g_ue + + Ping Ping ext-dn from NR-UE diff --git a/ci-scripts/xml_files/container_5g_rfsim_2x2.xml b/ci-scripts/xml_files/container_5g_rfsim_2x2.xml index 45c311fd97..2b3f3413db 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_2x2.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_2x2.xml @@ -30,6 +30,7 @@ 100001 000001 000002 + 000003 020001 020002 030001 @@ -61,6 +62,12 @@ 7 + + Attach_UE + Attach OAI UE (Wait for IP) + rfsim5g_ue + + Ping Ping ext-dn from NR-UE diff --git a/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml b/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml index 5baa950549..fe02da00a0 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_f1_accelleran.xml @@ -27,6 +27,7 @@ 111111 000020 + 000021 020021 100021 100022 @@ -48,6 +49,12 @@ 2 + + Attach_UE + Attach OAI UE (Wait for IP) + rfsim5g_ue + + Ping Test Connectivity (ping) diff --git a/ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml b/ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml index c31d6c1843..f2f4d5e78e 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_u0_25prb.xml @@ -30,6 +30,7 @@ 100001 000001 000002 + 000003 020001 020002 030001 @@ -61,6 +62,12 @@ 7 + + Attach_UE + Attach OAI UE (Wait for IP) + rfsim5g_ue + + Ping Ping ext-dn from NR-UE From 4cfba89e6870e3b10f5864d804b980a15d0b651d Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Tue, 20 Feb 2024 17:02:05 +0100 Subject: [PATCH 32/54] Updated and enhanced channel simulation documentation - centralized channel simulation documentation in channel_simulation.md - removed redundant documentation repeated in multipled .md files - updated links - removed obsolete information - introduced mermaid flowchart for rfsim - added missing information about available options and usage - deleted: ../../../openair1/SIMULATION/TOOLS/DOC/devusage.md - deleted: ../../../openair1/SIMULATION/TOOLS/DOC/rtusage.md - deleted: ../../../openair1/SIMULATION/TOOLS/DOC/arch.md related to issue #739 --- common/utils/telnetsrv/DOC/telnetarch.md | 6 +- common/utils/telnetsrv/DOC/telnetusage.md | 2 +- doc/README.md | 1 + openair1/SIMULATION/TOOLS/DOC/arch.md | 9 - .../TOOLS/DOC/channel_simulation.md | 205 +++++++++++++++++- openair1/SIMULATION/TOOLS/DOC/devusage.md | 7 - openair1/SIMULATION/TOOLS/DOC/rtusage.md | 69 ------ radio/rfsimulator/README.md | 136 ++++-------- 8 files changed, 242 insertions(+), 193 deletions(-) delete mode 100644 openair1/SIMULATION/TOOLS/DOC/arch.md delete mode 100644 openair1/SIMULATION/TOOLS/DOC/devusage.md delete mode 100644 openair1/SIMULATION/TOOLS/DOC/rtusage.md diff --git a/common/utils/telnetsrv/DOC/telnetarch.md b/common/utils/telnetsrv/DOC/telnetarch.md index 683b14a1b8..4b738faa35 100644 --- a/common/utils/telnetsrv/DOC/telnetarch.md +++ b/common/utils/telnetsrv/DOC/telnetarch.md @@ -21,11 +21,11 @@ The telnet server provides an API which can be used by any oai component to add telnet server source files are located in [common/utils/telnetsrv](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv) -1. [telnetsrv.c](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv/telnetsrv.c) contains the telnet server implementation, including the implementation of the `telnet` CLI command. This implementation is compatible with all softmodem executables and is in charge of loading any additional `libtelnetsrv_ .so` containing code specific to the running executables. -1. [telnetsrv.h](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv/telnetsrv.h) is the telnet server include file containing both private and public data type definitions. It also contains API prototypes for functions that are used to register a new command in the server. +1. [telnetsrv.c](../telnetsrv.c) contains the telnet server implementation, including the implementation of the `telnet` CLI command. This implementation is compatible with all softmodem executables and is in charge of loading any additional `libtelnetsrv_ .so` containing code specific to the running executables. +1. [telnetsrv.h](../telnetsrv.h) is the telnet server include file containing both private and public data type definitions. It also contains API prototypes for functions that are used to register a new command in the server. 1. `telnetsrv_.c`: implementation of \ CLI command which are delivered with the telnet server and are common to all softmodem executables. 1. `telnetsrv_.h`: include file for the implementation of XXX CLI command. Usually included only in the corresponding `.c`file 1. `telnetsrv__.c`: implementation of \ CLI command specific to the executable identified by \.These sources are used to create `libtelnetsrv_.so` at build time. -1. [telnetsrv_CMakeLists.txt](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/utils/telnetsrv/telnetsrv_CMakeLists.txt): CMakelists file containing the cmake instructions to build the telnet server. this file is included in the [global oai CMakelists](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/cmake_targets/CMakeLists.txt). +1. [telnetsrv_CMakeLists.txt](../CMakeLists.txt): CMakelists file containing the cmake instructions to build the telnet server. this file is included in the [global oai CMakelists](../../../../cmake_targets/CMakeLists.txt). [oai telnet server home](telnetsrv.md) diff --git a/common/utils/telnetsrv/DOC/telnetusage.md b/common/utils/telnetsrv/DOC/telnetusage.md index 8b8b72a698..8c69d247a8 100644 --- a/common/utils/telnetsrv/DOC/telnetusage.md +++ b/common/utils/telnetsrv/DOC/telnetusage.md @@ -26,7 +26,7 @@ Below are examples of telnet sessions: * [measur command](telnetmeasur.md) # telnet server parameters -The telnet server is using the [oai configuration module](Config/Rtusage). Telnet parameters must be specified in the `telnetsrv` section. Some parameters can be modified via the telnet telnet server command, as specified in the last column of the following table. +The telnet server is using the [oai configuration module](../../../../common/config/DOC/config/rtusage.md). Telnet parameters must be specified in the `telnetsrv` section. Some parameters can be modified via the telnet telnet server command, as specified in the last column of the following table. | name | type | default | description | dynamic | |:---:|:---:|:---:|:----|:----:| diff --git a/doc/README.md b/doc/README.md index 9ff7079f8b..a1e5b2851b 100644 --- a/doc/README.md +++ b/doc/README.md @@ -43,6 +43,7 @@ There is some general information in the [OpenAirInterface Gitlab Wiki](https:// - [How to run a 5G-NSA setup](./TESTING_GNB_W_COTS_UE.md) - [How to run a 4G setup using L1 simulator](./L1SIM.md) _Note: we recommend the RFsimulator_ - [How to use the L2 simulator](./L2NFAPI.md) +- [How to use the OAI channel simulator](../openair1/SIMULATION/TOOLS/DOC/channel_simulation.md) - [How to use multiple BWPs](./RUN_NR_multiple_BWPs.md) - [How to run OAI-VNF and OAI-PNF](./RUN_NR_NFAPI.md) _Note: does not work currently_ - [How to use the positioning reference signal (PRS)](./RUN_NR_PRS.md) diff --git a/openair1/SIMULATION/TOOLS/DOC/arch.md b/openair1/SIMULATION/TOOLS/DOC/arch.md deleted file mode 100644 index 30be337829..0000000000 --- a/openair1/SIMULATION/TOOLS/DOC/arch.md +++ /dev/null @@ -1,9 +0,0 @@ -# Channel simulation source files - -1. [random_channel.c](../random_channel.c) -1. [sim.h](../sim.h) - - - -[channel simulation main page](channel_simulation.md) -[oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) \ No newline at end of file diff --git a/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md b/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md index be2b987b40..6d1546b484 100644 --- a/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md +++ b/openair1/SIMULATION/TOOLS/DOC/channel_simulation.md @@ -1,13 +1,206 @@ +[[_TOC_]] + # OAI channel simulation feature -oai includes a channel simulation feature that any component can use to alter time domain samples of a RF channel by applying pre-defined models as defined, for example, in 3GPP TR 36.873 or TR 38.901 +OpenAirInterface RFSimulator incorporates a channel simulation feature. This feature allows any component to modify the time domain samples of a RF channel. It achieves this by applying predefined models, such as those defined in 3GPP TR 36.873 or TR 38.901. -Definition, configuration and run-time modification of a channel model are implemented in common code included in UEs, gNb, eNB and used when running with the rfsimulator or the L1 simulator. Phy simulators are also using channel simulation but configuration is done via dedicated command line options. The rfsimulator is the only option to get access to all the configurations and run-time modifications features of oai channel simulation. +The definition, configuration, and real-time modification of a channel model are implemented in a common code. This code is included in UE, gNB and eNB. It is utilized when operating with the RFSimulator or the L1 simulator. PHY simulators also employ channel simulation, but their configuration is accomplished via dedicated command-line options. -## Documentation +The RFSimulator is the exclusive option that provides access to all the configuration and real-time modification features of OAI's channel simulation. This makes it a comprehensive tool for managing and manipulating channel simulations in OAI. -* [runtime usage](rtusage.md) -* [developer usage](devusage.md) -* [module architecture](arch.md) + +# Implementation +OAI channel simulation is using the [config module](../../../../common/config/DOC/config.md) to get its parameters at init time. The [telnet server](../../../../common/utils/telnetsrv/DOC/telnetsrv.md) includes a set of commands which can be used to dynamically modify some channel model parameters. + +The relevant source files are: + +1. [`radio/rfsimulator/simulator.c`](../../../../radio/rfsimulator/simulator.c) +2. [`radio/rfsimulator/apply_channelmod.c`](../../../../radio/rfsimulator/apply_channelmod.c) +3. [`random_channel.c`](../random_channel.c) +4. [`sim.h`](../sim.h) + +All channel parameters are set depending on the model name via a call to: + +```bash +channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, + uint8_t nb_rx, + SCM_t channel_model, + double sampling_rate, + uint64_t center_freq, + double channel_bandwidth, + double DS_TDL, + double maxDoppler, + const corr_level_t corr_level, + double forgetting_factor, + int32_t channel_offset, + double path_loss_dB, + float noise_power_dB); +``` + +# Channel Model configuration file + +To define and use a channel model for uplink, the gNB configuration file needs to include a channel configuration file. To do this, add `@include "channelmod_rfsimu.conf"` at the end of the gNB configuration file, and place the channel configuration file in the same directory. The same shall be done for downlink by including the channel model configuration file at the end of UE configuration file (e.g. [`ci-scripts/conf_files/nrue.uicc.conf`](../../../../ci-scripts/conf_files/nrue.uicc.conf)). + +All channel simulation parameters are defined in the `channelmod` section. Most parameters are specific to a channel model and are only used by the rfsimulator. An example of the configuration file can be found here: + +* [`ci-scripts/conf_files/channelmod_rfsimu.conf`](../../../../ci-scripts/conf_files/channelmod_rfsimu.conf) + +e.g.: + +```bash +channelmod = { + max_chan = 10; + modellist = "modellist_rfsimu_1"; + modellist_rfsimu_1 = ( + { + model_name = "rfsimu_channel_enB0" + type = "AWGN"; + ploss_dB = 20; + noise_power_dB = -4; + forgetfact = 0; + offset = 0; + ds_tdl = 0; + }, + { + model_name = "rfsimu_channel_ue0" + type = "AWGN"; + ploss_dB = 20; + noise_power_dB = -2; + forgetfact = 0; + offset = 0; + ds_tdl = 0; + } + ); +}; +``` + +where `rfsimu_channel_ue0` will be activated on server side (i.e. eNB/gNB) for uplink and `rfsimu_channel_enB0` will be activated on client side (i.e. UE) for downlink. + +# Run OAI with a channel model + +When the `chanmod` option is enabled, the RF channel simulator with a channel modeling function is called. Add the following options to the command line to enable the channel model: +```bash +--rfsimulator.options chanmod +``` + +Example run of OAI RFSIM on the same machine with activation of the channel model via command line: +gNB: +```bash +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa --rfsimulator.options chanmod --telnetsrv +``` +UE: +```bash +sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --rfsimulator.serveraddr 127.0.0.1 --uicc0.imsi 001010000000001 -O ../../../ci-scripts/conf_files/nrue.uicc.conf --rfsimulator.options chanmod +``` +where `@include "channelmod_rfsimu.conf"` has been added at the end of `ci-scripts/conf_files/channelmod_rfsimu.conf` which has been copied to `targets/PROJECTS/GENERIC-LTE-EPC/CONF/`. + +## Set channel simulation parameters via CL: + +Channel simulation parameters can also be specified on the command line by using the `--channelmod` option: + +### Global parameters +| CL option |type |default | description | +|:--- |:---- |:---- |:----| +|`modellist` |char string |`DefaultChannelList`|select and load the `modellist` from the config file.| +|`max_chan` |integer |10 |set the maximum number of channel models that can be defined in the system. Must be greater than the number of model definitions in the model list loaded at init time.| + +Example usage: +```bash +--channelmod.modellist modellist_rfsimu_2 +``` + +### Model lists +Several model lists can be defined in the OAI channel simulation configuration file. One, defined by the `modellist` parameter is loaded at init time. In the configuration file each model list item describes a channel model using a group of parameters: + +|Parameter name |Type |Default |Description | +|:--- |:---: |---: |:---- | +| `model_name` |char string | mandatory |name of the model, as used in the code to retrieve a model definition.| +| `type` |char string | `AWGN` |name of the channel modelization algorithm applied on RF signal. The list of available models is defined in [`sim.h`](../sim.h]| +| `ploss_dB` |real (float) | 0|total path loss of the channel including shadow fading, in dB | +| `noise_power_dB`|real (double)| -50|Noise power in dB, used to compute the SNR. Its value is proportional to the noise added.| +| `forgetfact` |real (double)| 0|Forgetting factor, allows for simple 1st order temporal variation. 0 means a new channel every call, 1 means keep channel constant all the time| +| `offset` |integer | 0|channel offset for accessing the input signal, in samples| +| `ds_tdl` |real double | 0|delay spread for TDL models| + +`ploss_dB` and `noise_power_dB` are applied to each IQ sample in order to scale the received signal. + +Example usage, set the offset for the selected model of the selected `modellist`: +```bash +--channelmod..[].offset +``` + +e.g. with the softmodem: +```bash +sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --rfsim --sa --rfsimulator.options chanmod --telnetsrv --channelmod.modellist modellist_rfsimu_2 --channelmod.modellist_rfsimu_2.[1].offset 120 +``` + +## Real time control and monitoring with telnet server +Add the `--telnetsrv` option to the command line. Then in a new shell, connect to the telnet server, e.g.: + +```bash +$ telnet 127.0.0.1 9090 +Trying 127.0.0.1... +Connected to 127.0.0.1. +Escape character is '^]' +``` +to enter the command and control of the simulator press any key: `softmodem_enb` will be displayed for the eNB/gNB and `softmodem_5Gue` will be displayed for the UE. Select a different port in order to use both servers on the same machine. + +The telnet server includes two modules to change the RF channel simulation in real-time: + +1. `channelmod` to dynamically modify the channel model configuration parameters +2. `rfsimu` to set a different channel model + +They both have their own help: +```bash +softmodem_enb> help +..................................... + module 4 = channelmod: + channelmod help + channelmod show + channelmod modify + channelmod show params + module 5 = rfsimu: + rfsimu setmodel + rfsimu setdistance + rfsimu getdistance + rfsimu vtime +softmodem_enb> channelmod help +channelmod commands can be used to display or modify channel models parameters +channelmod show predef: display predefined model algorithms available in oai +channelmod show current: display the currently used models in the running executable +channelmod modify : set the specified parameters in a current model to the given value + specifies the model, the show current model command can be used to list the current models indexes + can be one of "riceanf", "aoa", "randaoa", "ploss", "noise_power_dB", "offset", "forgetf" +softmodem_enb> +``` + +### channelmod module +Example usage: + +| Command |Description | +|:--- |:---- | +|`channelmod show current` |Monitor the current status | +|`channelmod show predef` |See the available channel modelss| +|`channelmod modify `|Set parameters specific to the channel model, e.g. pathloss, Ricean factor| + +Where `` in the `channelmod modify` command can be: + +|Parameter |Type |Range |Description | +|:--- |:---: |:---: |:---- | +|`riceanf` |double|0 to 1 |Ricean factor, of first tap w.r.t. other taps (where 0 means AWGN and 1 means Rayleigh channel)| +|`aoa` |double|0 to 2*Pi|Angle of arrival of wavefront (in radians). For Ricean channel only. This assumes that both RX and TX have linear antenna arrays with lambda/2 antenna spacing. Also it is assumed that the arrays are parallel to each other and that they are far enough apart so that we can safely assume plane wave propagation. | +|`randaoa` |bool |0 or 1 |randomized angle of arrival according to a uniform random distribution| +|`ploss` |double|- |same as ploss_dB in [Model lists](#model-lists)| +|`noise_power_dB`|int |- |same as noise_power_dB in [Model lists](#model-lists)| +|`forgetf` |double|0 to 1 |same as forgetfact in [Model lists](#model-lists)| + +Example usage: +```bash +channelmod modify 0 ploss 12 +channelmod modify 0 noise_power_dB 3 +``` + +### rfsimu module +This module can be used to set a different channel model, e.g. `rfsimu setmodel AWGN`. [oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) diff --git a/openair1/SIMULATION/TOOLS/DOC/devusage.md b/openair1/SIMULATION/TOOLS/DOC/devusage.md deleted file mode 100644 index 8fa6b3fe7a..0000000000 --- a/openair1/SIMULATION/TOOLS/DOC/devusage.md +++ /dev/null @@ -1,7 +0,0 @@ -### channel simulation developer usage - - -[Configuring the channel simulation](rtusage.md) - -[channel simulation main page](channel_simulation.md) -[oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) \ No newline at end of file diff --git a/openair1/SIMULATION/TOOLS/DOC/rtusage.md b/openair1/SIMULATION/TOOLS/DOC/rtusage.md deleted file mode 100644 index 5e1bd1b1da..0000000000 --- a/openair1/SIMULATION/TOOLS/DOC/rtusage.md +++ /dev/null @@ -1,69 +0,0 @@ -## configuring the channel simulation -Oai channel simulation is using the [config module](../../../config/config.md) to get its parameters at init time. The [telnet server](../../telnetsrv/DOC/telnetsrv.md) includes a set of commands which can be used to dynamically modify some channel model parameters - -All channel simulation parameters are defined in the `channelmod` section. Most parameters are specific to a channel model and are only used by the rfsimulator. - -### global parameters - -| name | type | default | description | -|:---:|:---:|:---:|:----| -| `max_chan` | integer | `25` | Maximum number of channel model that can be defined in the system. Must be greater than the number of model definitions in the model list loaded at init time. | -| `modellist` | character string | `DefaultChannelList` | Name of the channel models list to load at init time. | - -### Model lists - -Several model lists can be defined in the oai configuration file. One, defined by the `modellist` parameter is loaded at init time. In the configuration file each model list item describes a channel model using a group of parameters: - -| parameter name | type | default | description | -|:---:|:---:|:---:|:----| -| `model name` | character string | mandatory |name of the model, as used in the code to retrieve a model definition| -| `type` | | `AWGN` | name of the channel modelization algorithm applied on rf signal. The list of available model types can be listed via the [telnet server](../../telnetsrv/DOC/telnetsrv.md) or by entering an invalid type name | -| `ploss_dB` | real (float) | | path loss of the channel, in dB | -| `noise_power_dB` | real (double) | | noise of the channel in dB | -| `forgetfact` | real (double) | | | -| `offset` | integer | | | -| `ds_tdl` | real double | | | - -Channel simulation parameters can also be specified on the command line: - -```bash -./lte-softmodem -O ../../../ci-scripts/conf_files/enb.band7.tm1.50prb.usrpb210.conf --noS1 --rfsim --rfsimulator.options chanmod --rfsimulator.serveraddr enb --telnetsrv --channelmod.modellist modellist_rfsimu_2 --channelmod.modellist_rfsimu_2.[1].offset 120 -``` -### Using the telnet server to modify channel simulator parameters -The telnet server includes a `channelmod` command which can be used to dynamically modify some channel model parameters. This command is only available when channel simulation is enabled (via `rfsimulator.options chanmod` option when running the rfsimulator. `channelmod` command has its own help: - -``` -$ telnet 127.0.0.1 9090 -Trying 127.0.0.1... -Connected to 127.0.0.1. -Escape character is '^]'. - -softmodem_enb> help -..................................... - module 6 = channelmod: - channelmod help - channelmod show - channelmod modify - module 7 = rfsimu: - rfsimu setmodel -softmodem_enb> channelmod help -channelmod commands can be used to display or modify channel models parameters -channelmod show predef: display predefined model algorithms available in oai -channelmod show current: display the currently used models in the running executable -channelmod modify : set the specified parameters in a current model to the given value - specifies the model, the show current model command can be used to list the current models indexes - can be one of "riceanf", "aoa", "randaoa", "ploss", "noise_power_dB", "offset", "forgetf" -softmodem_enb> - -``` - - - - - - - -The [rfsimulator documentation](../../../../radio/rfsimulator/README.md ) has also some specific information when using the channel simulation via this tool. - -[channel simulation main page](channel_simulation.md) -[oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home) diff --git a/radio/rfsimulator/README.md b/radio/rfsimulator/README.md index 4b33860809..376255d282 100644 --- a/radio/rfsimulator/README.md +++ b/radio/rfsimulator/README.md @@ -12,6 +12,29 @@ As much as possible, it works like an RF board, but not in real-time: It can run faster than real-time if there is enough CPU, or slower (it is CPU-bound instead of real-time RF sampling-bound). +# Architecture + +High-level flowchart of the RF Simulator, including the channel simulation feature: + +```mermaid +flowchart TD + subgraph ide1 [RX] + RU[ru_thread]-->|FH southbound|FH[rx_rf] + FH-->read + read -->|apply channel model|rxAddInput + end + subgraph ide2 [RFSim initialization] + A[load_lib] -->|load RFSIM lib| B[device_init] + B[device_init] -.-> |set trx_read_func|read[rfsimulator_read] + rxAddInput --> FH + B -->cfg[rfsimulator_readconfig] + cfg -->|read RFSIM CL options|C{rfsimu_params} + C -->|chanmod|loadchannel[load_channellist] + C -->|saviq|E[saveIQfile] + loadchannel-->|new SCM|scm[new_channel_desc_scm] + end +``` + # Build ## From [build_oai](../../../doc/BUILD.md) script @@ -44,46 +67,19 @@ default the RF simulator device will try to connect to host 127.0.0.1, port have to pass `--rfsimulator.serveraddr server` on the command line, or specify the corresponding section in the configuration file. -The RF simulator is using the configuration module, and its parameters are defined in a specific section called "rfsimulator". +The RF simulator is using the configuration module, and its parameters are defined in a specific section called "rfsimulator". Add the following options to the command line in order to enable different RFSim features: -| parameter | usage | default | -|:---------------------|:------------------------------------------------------------------------------------------------------------------|----:| -| serveraddr | ip address to connect to, or `server` to behave as a tcp server | 127.0.0.1 | -| serverport | port number to connect to or to listen on (eNB, which behaves as a tcp server) | 4043 | -| options | list of comma separated run-time options, two are supported: `chanmod` to enable channel modeling and `saviq` to write transmitted iqs to a file | all options disabled | -| modelname | Name of the channel model to apply on received iqs when the `chanmod` option is enabled | AWGN | -| IQfile | Path to the file to be used to store iqs, when the `saviq` option is enabled | /tmp/rfsimulator.iqs | +| CL option | usage | default | +|:--------------------- |:-------------------------------------------------------------------------------|----: | +|`--rfsimulator.serveraddr `| ip address to connect to, or `server` to behave as a tcp server | 127.0.0.1 | +|`--rfsimulator.serverport `| port number to connect to or to listen on (eNB, which behaves as a tcp server) | 4043 | +| `--rfsimulator.options` | list of comma separated run-time options, two are supported: `chanmod`, `saviq`| all options disabled | +| `--rfsimulator.options saviq` | store IQs to a file for future replay | disabled | +|`--rfsimulator.options chanmod` | enable the channel model | disabled | +|`--rfsimulator.IQfile ` | path to a file to store the IQ samples to (only with `saviq`) | `/tmp/rfsimulator.iqs` | +|`--rfsimulator.wait_timeout` | wait timeout when no UE is connected | 1 | -## How to use the RF simulator options - -To define and use a channel model, the configuration file needs to include a -channel configuration file. To do this, add `@include "channelmod_rfsimu.conf"` -to the end of the configuration file, and place the channel configuration file -in the same directory. An example channel configuration file is -[`ci-scripts/conf_files/channelmod_rfsimu.conf`](../../ci-scripts/conf_files/channelmod_rfsimu.conf). - -Add the following options to the command line to enable the channel model and the IQ samples saving for future replay: -```bash ---rfsimulator.options chanmod,saviq -``` -or just: -```bash ---rfsimulator.options chanmod -``` -to enable the channel model. - -set the model with: -```bash ---rfsimulator.modelname AWGN -``` - -Example run: - -```bash -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test --rfsimulator.options chanmod --rfsimulator.modelname AWGN -``` - -where `@include "channelmod_rfsimu.conf"` has been added at the end of the file, and `ci-scripts/conf_files/channelmod_rfsimu.conf` copied to `targets/PROJECTS/GENERIC-LTE-EPC/CONF/`. +Please refer to this document [`SIMULATION/TOOLS/DOC/channel_simulation.md`](../../openair1/SIMULATION/TOOLS/DOC/channel_simulation.md) for information about using the RFSimulator options to run the simulator with a channel model. ## 4G case @@ -133,9 +129,9 @@ sudo ./nr-uesoftmodem --rfsim --phy-test --rfsimulator.serveraddr ` should be the IP interface address of the remote host running the gNB executable, if the gNB and nrUE run on separate hosts, or be omitted if they are on the same host. -3. To enable the noS1 mode, `--noS1` option should be added to the command line, see again [RUNMODEM.md](../../doc/RUNMODEM.md). +3. To enable the noS1 mode, `--noS1` option should be added to the command line, see again [`RUNMODEM.md`](../../doc/RUNMODEM.md). 4. To operate the gNB/UE with a 5GC, start them using the `--sa` option. More information can be found [here](../../../doc/NR_SA_Tutorial_OAI_CN5G.md). ## Store and replay @@ -152,65 +148,9 @@ The file format is successive blocks of a header followed by the I/Q array. If y The format intends to be compatible with the OAI store/replay feature on USRP. -## Channel simulation +## How to use OAI RFSIM with a channel model -When the `chanmod` option is enabled, the RF channel simulator is called. - -In the current version all channel parameters are set depending on the model name via a call to: -```bash -new_channel_desc_scm(bridge->tx_num_channels, - bridge->rx_num_channels, - , - bridge->sample_rate, - bridge->tx_bw, - 0.0, // forgetting_factor - 0, // maybe used for TA - 0); // path_loss in dB -``` -Only the input noise can be changed on command line with the `-s` parameter. - -With path loss = 0 set `-s 5` to see a little noise. `-s` is a shortcut to `channelmod.s`. It is expected to enhance the channel modelization flexibility by the addition of more parameters in the channelmod section. - -Example to add a very small noise: -```bash --s 30 -``` -to add a lot of noise: -```bash --s 5 -``` - -Example run commands: -```bash -sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test --rfsimulator.options chanmod --rfsimulator.modelname AWGN - -``` -# Real time control and monitoring - -Add the `--telnetsrv` option to the command line. Then in a new shell, connect to the telnet server, example: -```bash -telnet 127.0.0.1 9090 -``` -once connected it is possible to monitor the current status: -```bash -channelmod show current -``` - -see the available channel models: -```bash -channelmod show predef -``` - -or modify the channel model, for example setting a new model: -```bash -rfsimu setmodel AWGN -``` -setting the pathloss, etc...: -```bash -channelmod modify -channelmod modify 0 ploss 15 -``` -where `` can be one of `riceanf`, `aoa`, `randaoa`, `ploss`, `offset`, `forgetf`. +Please refer to this document [`channel_simulation.md`](../../openair1/SIMULATION/TOOLS/DOC/channel_simulation.md) to get familiar with channel simulation in RFSIM and to see the list of commands for real-time usage with telnet. # Caveats From b431e1442f1238401cbb0adbdd2042721aed8f6a Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Thu, 22 Feb 2024 14:42:06 +0100 Subject: [PATCH 33/54] Moved nr_reconfigure_sdap_entity to SDAP module - improves code readability and maintainability --- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c | 6 +----- openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 10 +++++++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 9546a2b2bb..0daec6c7a8 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -1130,7 +1130,7 @@ void nr_pdcp_reconfigure_srb(ue_id_t ue_id, int srb_id, long t_Reordering) nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } -void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, NR_PDCP_Config_t *pdcp_config, NR_SDAP_Config_t *sdap_config) +void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, NR_PDCP_Config_t *pdcp_config) { // The enabling/disabling of ciphering or integrity protection // can be changed only by releasing and adding the DRB @@ -1166,10 +1166,6 @@ void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, NR_PDCP_Config_t *pdcp_c } } } - /* SDAP entity reconfiguration */ - if (sdap_config) - nr_reconfigure_sdap_entity(sdap_config, ue_id, sdap_config->pdu_Session, drb_id); - nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h index 97a48b0e6a..be1604dabd 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h @@ -67,7 +67,7 @@ void nr_pdcp_reestablishment(ue_id_t ue_id, int rb_id, bool srb_flag); void nr_pdcp_suspend_srb(ue_id_t ue_id, int srb_id); void nr_pdcp_suspend_drb(ue_id_t ue_id, int drb_id); void nr_pdcp_reconfigure_srb(ue_id_t ue_id, int srb_id, long t_Reordering); -void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, NR_PDCP_Config_t *pdcp_config, NR_SDAP_Config_t *sdap_config); +void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, NR_PDCP_Config_t *pdcp_config); void nr_pdcp_release_srb(ue_id_t ue_id, int srb_id); void nr_pdcp_release_drb(ue_id_t ue_id, int drb_id); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index c19fd4e00e..1d97349871 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -70,6 +70,7 @@ #include "SIMULATION/TOOLS/sim.h" // for taus #include "nr_nas_msg_sim.h" +#include "openair2/SDAP/nr_sdap/nr_sdap_entity.h" static NR_UE_RRC_INST_t *NR_UE_rrc_inst; /* NAS Attach request with IMSI */ @@ -1234,9 +1235,12 @@ static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, AssertFatal(drb->recoverPDCP == NULL, "recoverPDCP not yet implemented\n"); /* sdap-Config is included (SA mode) */ NR_SDAP_Config_t *sdap_Config = drb->cnAssociation ? drb->cnAssociation->choice.sdap_Config : NULL; - /* PDCP and SDAP reconfiguration */ - if (drb->pdcp_Config || sdap_Config) - nr_pdcp_reconfigure_drb(ue_rrc->ue_id, DRB_id, drb->pdcp_Config, sdap_Config); + /* PDCP reconfiguration */ + if (drb->pdcp_Config) + nr_pdcp_reconfigure_drb(ue_rrc->ue_id, DRB_id, drb->pdcp_Config); + /* SDAP entity reconfiguration */ + if (sdap_Config) + nr_reconfigure_sdap_entity(sdap_Config, ue_rrc->ue_id, sdap_Config->pdu_Session, DRB_id); } else { ue_rrc->status_DRBs[DRB_id] = RB_ESTABLISHED; add_drb(false, From d26f0b9196c8f9f3b4c9a44e7321eed4efc082a2 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Fri, 2 Feb 2024 18:45:54 +0100 Subject: [PATCH 34/54] add LOG_DDUMP() to dump a buffer in the regular tracing filter system (like PHY, MAC, ...), use it and do simple cleaning (better format) --- common/utils/LOG/log.h | 191 ++++++++++++++---- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 9 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 29 +-- 3 files changed, 163 insertions(+), 66 deletions(-) diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 0004525d3c..93d8218466 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -161,16 +161,12 @@ extern "C" { {NULL,-1}\ } - - #define SET_LOG_DEBUG(B) g_log->debug_mask = (g_log->debug_mask | B) #define CLEAR_LOG_DEBUG(B) g_log->debug_mask = (g_log->debug_mask & (~B)) #define SET_LOG_DUMP(B) g_log->dump_mask = (g_log->dump_mask | B) #define CLEAR_LOG_DUMP(B) g_log->dump_mask = (g_log->dump_mask & (~B)) - - typedef enum { MIN_LOG_COMPONENTS = 0, PHY = MIN_LOG_COMPONENTS, @@ -233,7 +229,6 @@ comp_name_t; #define MAX_LOG_DYNALLOC_COMPONENTS 20 #define MAX_LOG_COMPONENTS (MAX_LOG_PREDEF_COMPONENTS + MAX_LOG_DYNALLOC_COMPONENTS) - typedef struct { char *name; /*!< \brief string name of item */ int value; /*!< \brief integer value of mapping */ @@ -265,8 +260,6 @@ typedef struct { uint64_t dump_mask; } log_t; - - #ifdef LOG_MAIN log_t *g_log; #else @@ -365,9 +358,6 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int " level: add log level indication in log messages\n"\ " thread: add threads names in log messages\n" - - - /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* LOG global configuration parameters */ /* optname help paramflags XXXptr defXXXval type numelt */ @@ -396,41 +386,166 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int # if T_TRACER #include "T.h" /* per component, level dependent macros */ -# define LOG_E(c, x...) do { T(T_LEGACY_ ## c ## _ERROR, T_PRINTF(x)) ; if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_ERR ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ERR, x) ;} } while (0) -# define LOG_W(c, x...) do { T(T_LEGACY_ ## c ## _WARNING, T_PRINTF(x)); if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_WARNING ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ;} } while (0) -# define LOG_A(c, x...) do { T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) ; if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_ANALYSIS) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ANALYSIS, x);} } while (0) -# define LOG_I(c, x...) do { T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) ; if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} } while (0) -# define LOG_D(c, x...) do { T(T_LEGACY_ ## c ## _DEBUG, T_PRINTF(x)) ; if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} } while (0) -# define LOG_T(c, x...) do { T(T_LEGACY_ ## c ## _TRACE, T_PRINTF(x)) ; if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} } while (0) -# define VLOG(c,l, f, args) do { if (T_stdout) { if( g_log->log_component[c].level >= l ) vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, l, f, args) ;} } while (0) +#define LOG_E(c, x...) \ + do { \ + T(T_LEGACY_##c##_ERROR, T_PRINTF(x)); \ + if (T_stdout) { \ + if (g_log->log_component[c].level >= OAILOG_ERR) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_ERR, x); \ + } \ + } while (0) + +#define LOG_W(c, x...) \ + do { \ + T(T_LEGACY_##c##_WARNING, T_PRINTF(x)); \ + if (T_stdout) { \ + if (g_log->log_component[c].level >= OAILOG_WARNING) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_WARNING, x); \ + } \ + } while (0) + +#define LOG_A(c, x...) \ + do { \ + T(T_LEGACY_##c##_INFO, T_PRINTF(x)); \ + if (T_stdout) { \ + if (g_log->log_component[c].level >= OAILOG_ANALYSIS) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_ANALYSIS, x); \ + } \ + } while (0) + +#define LOG_I(c, x...) \ + do { \ + T(T_LEGACY_##c##_INFO, T_PRINTF(x)); \ + if (T_stdout) { \ + if (g_log->log_component[c].level >= OAILOG_INFO) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_INFO, x); \ + } \ + } while (0) + +#define LOG_D(c, x...) \ + do { \ + T(T_LEGACY_##c##_DEBUG, T_PRINTF(x)); \ + if (T_stdout) { \ + if (g_log->log_component[c].level >= OAILOG_DEBUG) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_DEBUG, x); \ + } \ + } while (0) + +#define LOG_DDUMP(c, b, s, f, x...) \ + do { \ + T(T_LEGACY_##c##_DEBUG, T_PRINTF(x)); \ + if (T_stdout) { \ + if (g_log->log_component[c].level >= OAILOG_DEBUG) \ + log_dump(c, b, s, f, x); \ + } \ + } while (0) + +#define LOG_T(c, x...) \ + do { \ + T(T_LEGACY_##c##_TRACE, T_PRINTF(x)); \ + if (T_stdout) { \ + if (g_log->log_component[c].level >= OAILOG_TRACE) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_TRACE, x); \ + } \ + } while (0) + +#define VLOG(c, l, f, args) \ + do { \ + if (T_stdout) { \ + if (g_log->log_component[c].level >= l) \ + vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, l, f, args); \ + } \ + } while (0) + /* macro used to dump a buffer or a message as in openair2/RRC/LTE/RRC_eNB.c, replaces LOG_F macro */ -# define LOG_DUMPMSG(c, f, b, s, x...) do { if(g_log->dump_mask & f) log_dump(c, b, s, LOG_DUMP_CHAR, x) ;} while (0) /* */ +#define LOG_DUMPMSG(c, f, b, s, x...) \ + do { \ + if (g_log->dump_mask & f) \ + log_dump(c, b, s, LOG_DUMP_CHAR, x); \ + } while (0) + /* bitmask dependent macros, to isolate debugging code */ -# define LOG_DEBUGFLAG(D) (g_log->debug_mask & D) +#define LOG_DEBUGFLAG(D) (g_log->debug_mask & D) /* bitmask dependent macros, to generate debug file such as matlab file or message dump */ -# define LOG_DUMPFLAG(D) (g_log->dump_mask & D) -# define LOG_M(file, vector, data, len, dec, format) do { write_file_matlab(file, vector, data, len, dec, format, 0);} while(0)/* */ +#define LOG_DUMPFLAG(D) (g_log->dump_mask & D) + +#define LOG_M(file, vector, data, len, dec, format) \ + do { \ + write_file_matlab(file, vector, data, len, dec, format, 0); \ + } while (0) + /* define variable only used in LOG macro's */ -# define LOG_VAR(A,B) A B -# else /* T_TRACER */ -# define LOG_E(c, x...) do { if( g_log->log_component[c].level >= OAILOG_ERR ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ERR, x) ;} while (0) -# define LOG_W(c, x...) do { if( g_log->log_component[c].level >= OAILOG_WARNING ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ;} while (0) -# define LOG_A(c, x...) do { if( g_log->log_component[c].level >= OAILOG_ANALYSIS) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ANALYSIS, x);} while (0) -# define LOG_I(c, x...) do { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} while (0) -# define LOG_D(c, x...) do { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} while (0) -# define LOG_T(c, x...) do { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} while (0) -# define VLOG(c,l, f, args) do { if( g_log->log_component[c].level >= l ) vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, l, f, args) ; } while (0) +#define LOG_VAR(A, B) A B -# define nfapi_log(FILE, FNC, LN, COMP, LVL, FMT...) -# define LOG_DEBUGFLAG(D) (g_log->dump_mask & D) -# define LOG_DUMPFLAG(D) (g_log->debug_mask & D) -# define LOG_DUMPMSG(c, f, b, s, x...) do { if(g_log->dump_mask & f) log_dump(c, b, s, LOG_DUMP_CHAR, x) ;} while (0) /* */ +#else /* no T_TRACER */ -# define LOG_M(file, vector, data, len, dec, format) do { write_file_matlab(file, vector, data, len, dec, format, 0);} while(0) -# define LOG_VAR(A,B) A B -# define T_ACTIVE(a) (0) -# endif /* T_TRACER */ +#define LOG_E(c, x...) \ + do { \ + if (g_log->log_component[c].level >= OAILOG_ERR) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_ERR, x); \ + } while (0) + +#define LOG_W(c, x...) \ + do { \ + if (g_log->log_component[c].level >= OAILOG_WARNING) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_WARNING, x); \ + } while (0) + +#define LOG_A(c, x...) \ + do { \ + if (g_log->log_component[c].level >= OAILOG_ANALYSIS) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_ANALYSIS, x); \ + } while (0) + +#define LOG_I(c, x...) \ + do { \ + if (g_log->log_component[c].level >= OAILOG_INFO) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_INFO, x); \ + } while (0) + +#define LOG_D(c, x...) \ + do { \ + if (g_log->log_component[c].level >= OAILOG_DEBUG) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_DEBUG, x); \ + } while (0) + +#define LOG_DDUMP(c, b, s, f, x...) \ + do { \ + if (g_log->log_component[c].level >= OAILOG_DEBUG) \ + log_dump(c, b, s, f, x); \ + } while (0) + +#define LOG_T(c, x...) \ + do { \ + if (g_log->log_component[c].level >= OAILOG_TRACE) \ + logRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, OAILOG_TRACE, x); \ + } while (0) + +#define VLOG(c, l, f, args) \ + do { \ + if (g_log->log_component[c].level >= l) \ + vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__, c, l, f, args); \ + } while (0) + +#define nfapi_log(FILE, FNC, LN, COMP, LVL, FMT...) +#define LOG_DEBUGFLAG(D) (g_log->dump_mask & D) +#define LOG_DUMPFLAG(D) (g_log->debug_mask & D) +#define LOG_DUMPMSG(c, f, b, s, x...) \ + do { \ + if (g_log->dump_mask & f) \ + log_dump(c, b, s, LOG_DUMP_CHAR, x); \ + } while (0) /* */ + +#define LOG_M(file, vector, data, len, dec, format) \ + do { \ + write_file_matlab(file, vector, data, len, dec, format, 0); \ + } while (0) + +#define LOG_VAR(A, B) A B +#define T_ACTIVE(a) (0) + +#endif /* T_TRACER */ /* avoid warnings for variables only used in LOG macro's but set outside debug section */ #define GCC_NOTUSED __attribute__((unused)) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index a5df641f4a..0ac2855c2a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3645,14 +3645,7 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i } if (mac_len > 0) { - LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_len); - for (int i = 0; i < mac_subheader_len; i++) { - LOG_D(NR_MAC, "MAC header %d: 0x%x\n", i, pduP[i]); - } - for (int i = 0; i < mac_len; i++) { - LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]); - } - + LOG_DDUMP(NR_MAC, (void *)pduP, mac_subheader_len + mac_len, LOG_DUMP_CHAR, "DL_SCH_LCID_CCCH (e.g. RRCSetup) payload: "); mac_rlc_data_ind(mac->ue_id, mac->ue_id, gNB_index, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index d655fa666b..99e4ffc06e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -2070,29 +2070,18 @@ static void nr_fill_rar(uint8_t Mod_idP, NR_RA_t *ra, uint8_t *dlsch_buffer, nfa LOG_I(NR_MAC, "rar->TCRNTI_1 = 0x%x\n", rar->TCRNTI_1); LOG_I(NR_MAC, "rar->TCRNTI_2 = 0x%x\n", rar->TCRNTI_2); #endif - - int mcs = (unsigned char) (rar->UL_GRANT_4 >> 4); - // time alloc - int Msg3_t_alloc = (unsigned char) (rar->UL_GRANT_3 & 0x0f); - // frequency alloc - int Msg3_f_alloc = (uint16_t) ((rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12)); - // frequency hopping - int freq_hopping = (unsigned char) (rar->UL_GRANT_1 >> 2); - // TA command - int ta_command = rar->TA2 + (rar->TA1 << 5); - // TC-RNTI - int t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8); - - LOG_D(NR_MAC, "In %s: Transmitted RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d csi_req %d t_crnti %x \n", + LOG_D(NR_MAC, + "In %s: Transmitted RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d csi_req %d t_crnti " + "%x \n", __FUNCTION__, - Msg3_t_alloc, - Msg3_f_alloc, - ta_command, - mcs, - freq_hopping, + rar->UL_GRANT_3 & 0x0f, + (rar->UL_GRANT_3 >> 4) | (rar->UL_GRANT_2 << 4) | ((rar->UL_GRANT_1 & 0x03) << 12), + rar->TA2 + (rar->TA1 << 5), + rar->UL_GRANT_4 >> 4, + rar->UL_GRANT_1 >> 2, tpc_command, csi_req, - t_crnti); + rar->TCRNTI_2 + (rar->TCRNTI_1 << 8)); } void nr_schedule_RA(module_id_t module_idP, From bedc5bea4c3b2da706e4bc9e3112dbc3a3fa2452 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Fri, 2 Feb 2024 18:50:45 +0100 Subject: [PATCH 35/54] remove a gcc warning while making the code a bit simpler --- openair2/LAYER2/NR_MAC_gNB/config.c | 563 +++++++++++++++------------- 1 file changed, 310 insertions(+), 253 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 270441a6dd..9abb5ab748 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -104,263 +104,320 @@ nfapi_nr_pm_list_t init_DL_MIMO_codebook(gNB_MAC_INST *gNB, nr_pdsch_AntennaPort nfapi_nr_pm_pdu_t *pmi_pdu = malloc16(mat.num_pm_idx * sizeof(*pmi_pdu)); AssertFatal(pmi_pdu != NULL, "out of memory\n"); mat.pmi_pdu = pmi_pdu; + AssertFatal(num_antenna_ports < 16, "Max number of antenna ports supported is currently 16\n"); // Generation of codebook Type1 with codebookMode 1 (num_antenna_ports < 16) - if (num_antenna_ports < 16) { - //Generate DFT vertical beams - //ll: index of a vertical beams vector (represented by i1_1 in TS 38.214) - const int max_l = N1 * O1 + (K1 - 1) * O1; - double complex v[max_l][N1]; - for (int ll = 0; ll < max_l; ll++) { //i1_1 - for (int nn = 0; nn < N1; nn++) { - v[ll][nn] = cexp(I * (2 * M_PI * nn * ll) / (N1 * O1)); - LOG_D(PHY,"v[%d][%d] = %f +j %f\n", ll, nn, creal(v[ll][nn]), cimag(v[ll][nn])); - } + // Generate DFT vertical beams + // ll: index of a vertical beams vector (represented by i1_1 in TS 38.214) + const int max_l = N1 * O1 + (K1 - 1) * O1; + double complex v[max_l][N1]; + for (int ll = 0; ll < max_l; ll++) { // i1_1 + for (int nn = 0; nn < N1; nn++) { + v[ll][nn] = cexp(I * (2 * M_PI * nn * ll) / (N1 * O1)); + LOG_D(PHY, "v[%d][%d] = %f +j %f\n", ll, nn, creal(v[ll][nn]), cimag(v[ll][nn])); } - //Generate DFT Horizontal beams - //mm: index of a Horizontal beams vector (represented by i1_2 in TS 38.214) - const int max_m = N2 * O2 + (K2 - 1) * O2; - double complex u[max_m][N2]; - for (int mm = 0; mm < max_m; mm++) { //i1_2 - for (int nn = 0; nn < N2; nn++) { - u[mm][nn] = cexp(I * (2 * M_PI * nn * mm) / (N2 * O2)); - LOG_D(PHY,"u[%d][%d] = %f +j %f\n", mm, nn, creal(u[mm][nn]), cimag(u[mm][nn])); - } - } - //Generate co-phasing angles - //i_2: index of a co-phasing vector - //i1_1, i1_2, and i_2 are reported from UEs - double complex theta_n[4]; - for (int nn = 0; nn < 4; nn++) { - theta_n[nn] = cexp(I * M_PI * nn / 2); - LOG_D(PHY,"theta_n[%d] = %f +j %f\n", nn, creal(theta_n[nn]), cimag(theta_n[nn])); - } - //Kronecker product v_lm - double complex v_lm[max_l][max_m][N2 * N1]; - //v_ll_mm_codebook denotes the elements of a precoding matrix W_i1,1_i_1,2 - for(int ll = 0; ll < max_l; ll++) { //i_1_1 - for (int mm = 0; mm < max_m; mm++) { //i_1_2 - for (int nn1 = 0; nn1 < N1; nn1++) { - for (int nn2 = 0; nn2 < N2; nn2++) { - v_lm[ll][mm][nn1 * N2 + nn2] = v[ll][nn1] * u[mm][nn2]; - LOG_D(PHY,"v_lm[%d][%d][%d] = %f +j %f\n",ll, mm, nn1 * N2 + nn2, creal(v_lm[ll][mm][nn1*N2+nn2]), cimag(v_lm[ll][mm][nn1*N2+nn2])); - } - } - } - } - - double complex res_code; - - //Table 5.2.2.2.1-5: - int pmiq = 0; - //Codebook for 1-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS - for(int ll = 0; ll < N1 * O1; ll++) { //i_1_1 - for (int mm = 0; mm < N2 * O2; mm++) { //i_1_2 - for (int nn = 0; nn < 4; nn++) { - pmiq = ll * N2 * O2 * 4 + mm * 4 + nn; - pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix - pmi_pdu[pmiq].numLayers = 1; - pmi_pdu[pmiq].num_ant_ports = num_antenna_ports; - LOG_D(PHY, "layer 1 Codebook pmiq = %d\n", pmiq); - for (int len = 0; len < N1 * N2; len++) { - nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[0][len]; - res_code = sqrt( 1 /(double)num_antenna_ports) * v_lm[ll][mm][len]; - c16_t precoder_weight = convert_precoder_weight(res_code); - weights->precoder_weight_Re = precoder_weight.r; - weights->precoder_weight_Im = precoder_weight.i; - LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n", - pmiq, len, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im); - } - - for(int len = N1 * N2; len < 2 * N1 * N2; len++) { - nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[0][len]; - res_code = sqrt(1 / (double)num_antenna_ports) * theta_n[nn] * v_lm[ll][mm][len-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; - LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n", - pmiq, len, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im); - } - } - } - } - int llc = 0; - int mmc = 0; - double complex phase_sign = 0; - //Table 5.2.2.2.1-6: - //Codebook for 2-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS - //Compute the code book size for generating 2 layers out of Tx antenna ports - - //pmi=1,...,pmi_size, we construct - for(int ll = 0; ll < N1 * O1; ll++) { //i_1_1 - for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2 - for(int k1 = 0; k1 < K1; k1++) { - for (int k2 = 0; k2 < K2; k2++) { - for (int nn = 0; nn < 2; nn++) { // i_2 - pmiq ++; - pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix - pmi_pdu[pmiq].numLayers = 2; - pmi_pdu[pmiq].num_ant_ports = num_antenna_ports; - LOG_D(PHY, "layer 2 Codebook pmiq = %d\n", pmiq); - for(int j_col = 0; j_col < 2; j_col++) { - if (j_col == 0) { - llc = ll; - mmc = mm; - phase_sign = 1; - } - if (j_col == 1) { - llc = ll + k1 * O1; - mmc = mm + k2 * O2; - phase_sign = -1; - } - for (int i_rows = 0; i_rows < N1 * N2; i_rows++) { - nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; - res_code = sqrt(1 / (double)(2 * num_antenna_ports)) * 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; - LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", - pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im); - } - for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) { - nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; - res_code = sqrt(1 / (double)(2 * num_antenna_ports)) * (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; - LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", - pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im); - } - } - } - } - } - } - } - - if(max_mimo_layers < 3) - return mat; - - //Table 5.2.2.2.1-7: - //Codebook for 3-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS - - //pmi=1,...,pmi_size are computed as follows - for(int ll = 0; ll < N1 * O1; ll++) { //i_1_1 - for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2 - for(int k1 = 0; k1 < K1; k1++) { - for (int k2 = 0; k2 < K2; k2++) { - for (int nn = 0; nn < 2; nn++) { // i_2 - pmiq ++; - pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix - pmi_pdu[pmiq].numLayers = 3; - pmi_pdu[pmiq].num_ant_ports = num_antenna_ports; - LOG_D(PHY, "layer 3 Codebook pmiq = %d\n",pmiq); - for(int j_col = 0; j_col < 3; j_col++) { - if (j_col == 0) { - llc = ll; - mmc = mm; - phase_sign = 1; - } - if (j_col==1) { - llc = ll + k1 * O1; - mmc = mm + k2 * O2; - phase_sign = 1; - } - if (j_col==2) { - llc = ll; - mmc = mm; - phase_sign = -1; - } - for (int i_rows = 0; i_rows < N1 * N2; i_rows++) { - nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; - res_code = sqrt(1 / (double)(3 * num_antenna_ports)) * 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; - LOG_D(PHY, "3 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", - pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im); - } - for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) { - nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; - res_code=sqrt(1 / (double)(3 * num_antenna_ports)) * (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; - LOG_D(PHY, "3 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", - pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im); - } - } - } - } - } - } - } - - if(max_mimo_layers < 4) - return mat; - - //Table 5.2.2.2.1-8: - //Codebook for 4-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS - - for(int ll = 0; ll < N1 * O1; ll++) { //i_1_1 - for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2 - for(int k1 = 0; k1 < K1; k1++) { - for (int k2 = 0; k2 < K2; k2++) { - for (int nn = 0; nn < 2; nn++) { // i_2 - pmiq ++; - pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix - pmi_pdu[pmiq].numLayers = 4; - pmi_pdu[pmiq].num_ant_ports = num_antenna_ports; - LOG_D(PHY, "layer 4 pmiq = %d\n", pmiq); - for(int j_col = 0; j_col < 4; j_col++) { - if (j_col == 0) { - llc = ll; - mmc = mm; - phase_sign = 1; - } - if (j_col == 1) { - llc = ll + k1 * O1; - mmc = mm + k2 * O2; - phase_sign = 1; - } - if (j_col == 2) { - llc = ll; - mmc = mm; - phase_sign = -1; - } - if (j_col == 3) { - llc = ll + k1 * O1; - mmc = mm + k2 * O2; - phase_sign = -1; - } - for (int i_rows = 0; i_rows < N1 * N2; i_rows++) { - nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; - res_code=sqrt(1 / (double)(4 * num_antenna_ports)) * 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; - LOG_D(PHY, "4 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", - pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im); - } - for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) { - nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; - res_code=sqrt(1 / (double)(4 * num_antenna_ports)) * (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; - LOG_D(PHY, "4 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", - pmiq, i_rows, j_col, creal(res_code), cimag(res_code), weights->precoder_weight_Re, weights->precoder_weight_Im); - } - } - } - } - } - } - } - return mat; } - else - AssertFatal(false, "Max number of antenna ports supported is currently 16\n"); + // Generate DFT Horizontal beams + // mm: index of a Horizontal beams vector (represented by i1_2 in TS 38.214) + const int max_m = N2 * O2 + (K2 - 1) * O2; + double complex u[max_m][N2]; + for (int mm = 0; mm < max_m; mm++) { // i1_2 + for (int nn = 0; nn < N2; nn++) { + u[mm][nn] = cexp(I * (2 * M_PI * nn * mm) / (N2 * O2)); + LOG_D(PHY, "u[%d][%d] = %f +j %f\n", mm, nn, creal(u[mm][nn]), cimag(u[mm][nn])); + } + } + // Generate co-phasing angles + // i_2: index of a co-phasing vector + // i1_1, i1_2, and i_2 are reported from UEs + double complex theta_n[4]; + for (int nn = 0; nn < 4; nn++) { + theta_n[nn] = cexp(I * M_PI * nn / 2); + LOG_D(PHY, "theta_n[%d] = %f +j %f\n", nn, creal(theta_n[nn]), cimag(theta_n[nn])); + } + // Kronecker product v_lm + double complex v_lm[max_l][max_m][N2 * N1]; + // v_ll_mm_codebook denotes the elements of a precoding matrix W_i1,1_i_1,2 + for (int ll = 0; ll < max_l; ll++) { // i_1_1 + for (int mm = 0; mm < max_m; mm++) { // i_1_2 + for (int nn1 = 0; nn1 < N1; nn1++) { + for (int nn2 = 0; nn2 < N2; nn2++) { + v_lm[ll][mm][nn1 * N2 + nn2] = v[ll][nn1] * u[mm][nn2]; + LOG_D(PHY, + "v_lm[%d][%d][%d] = %f +j %f\n", + ll, + mm, + nn1 * N2 + nn2, + creal(v_lm[ll][mm][nn1 * N2 + nn2]), + cimag(v_lm[ll][mm][nn1 * N2 + nn2])); + } + } + } + } + + double complex res_code; + + // Table 5.2.2.2.1-5: + int pmiq = 0; + // Codebook for 1-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS + for (int ll = 0; ll < N1 * O1; ll++) { // i_1_1 + for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2 + for (int nn = 0; nn < 4; nn++) { + pmiq = ll * N2 * O2 * 4 + mm * 4 + nn; + pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix + pmi_pdu[pmiq].numLayers = 1; + pmi_pdu[pmiq].num_ant_ports = num_antenna_ports; + LOG_D(PHY, "layer 1 Codebook pmiq = %d\n", pmiq); + for (int len = 0; len < N1 * N2; len++) { + nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[0][len]; + res_code = sqrt(1 / (double)num_antenna_ports) * v_lm[ll][mm][len]; + c16_t precoder_weight = convert_precoder_weight(res_code); + weights->precoder_weight_Re = precoder_weight.r; + weights->precoder_weight_Im = precoder_weight.i; + LOG_D(PHY, + "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, + len, + creal(res_code), + cimag(res_code), + weights->precoder_weight_Re, + weights->precoder_weight_Im); + } + + for (int len = N1 * N2; len < 2 * N1 * N2; len++) { + nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[0][len]; + res_code = sqrt(1 / (double)num_antenna_ports) * theta_n[nn] * v_lm[ll][mm][len - 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; + LOG_D(PHY, + "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, + len, + creal(res_code), + cimag(res_code), + weights->precoder_weight_Re, + weights->precoder_weight_Im); + } + } + } + } + int llc = 0; + int mmc = 0; + double complex phase_sign = 0; + // Table 5.2.2.2.1-6: + // Codebook for 2-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS + // Compute the code book size for generating 2 layers out of Tx antenna ports + + // pmi=1,...,pmi_size, we construct + for (int ll = 0; ll < N1 * O1; ll++) { // i_1_1 + for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2 + for (int k1 = 0; k1 < K1; k1++) { + for (int k2 = 0; k2 < K2; k2++) { + for (int nn = 0; nn < 2; nn++) { // i_2 + pmiq++; + pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix + pmi_pdu[pmiq].numLayers = 2; + pmi_pdu[pmiq].num_ant_ports = num_antenna_ports; + LOG_D(PHY, "layer 2 Codebook pmiq = %d\n", pmiq); + for (int j_col = 0; j_col < 2; j_col++) { + if (j_col == 0) { + llc = ll; + mmc = mm; + phase_sign = 1; + } + if (j_col == 1) { + llc = ll + k1 * O1; + mmc = mm + k2 * O2; + phase_sign = -1; + } + for (int i_rows = 0; i_rows < N1 * N2; i_rows++) { + nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; + res_code = sqrt(1 / (double)(2 * num_antenna_ports)) * 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; + LOG_D(PHY, + "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, + i_rows, + j_col, + creal(res_code), + cimag(res_code), + weights->precoder_weight_Re, + weights->precoder_weight_Im); + } + for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) { + nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; + res_code = sqrt(1 / (double)(2 * num_antenna_ports)) * (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; + LOG_D(PHY, + "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, + i_rows, + j_col, + creal(res_code), + cimag(res_code), + weights->precoder_weight_Re, + weights->precoder_weight_Im); + } + } + } + } + } + } + } + + if (max_mimo_layers < 3) + return mat; + + // Table 5.2.2.2.1-7: + // Codebook for 3-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS + + // pmi=1,...,pmi_size are computed as follows + for (int ll = 0; ll < N1 * O1; ll++) { // i_1_1 + for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2 + for (int k1 = 0; k1 < K1; k1++) { + for (int k2 = 0; k2 < K2; k2++) { + for (int nn = 0; nn < 2; nn++) { // i_2 + pmiq++; + pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix + pmi_pdu[pmiq].numLayers = 3; + pmi_pdu[pmiq].num_ant_ports = num_antenna_ports; + LOG_D(PHY, "layer 3 Codebook pmiq = %d\n", pmiq); + for (int j_col = 0; j_col < 3; j_col++) { + if (j_col == 0) { + llc = ll; + mmc = mm; + phase_sign = 1; + } + if (j_col == 1) { + llc = ll + k1 * O1; + mmc = mm + k2 * O2; + phase_sign = 1; + } + if (j_col == 2) { + llc = ll; + mmc = mm; + phase_sign = -1; + } + for (int i_rows = 0; i_rows < N1 * N2; i_rows++) { + nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; + res_code = sqrt(1 / (double)(3 * num_antenna_ports)) * 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; + LOG_D(PHY, + "3 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, + i_rows, + j_col, + creal(res_code), + cimag(res_code), + weights->precoder_weight_Re, + weights->precoder_weight_Im); + } + for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) { + nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; + res_code = sqrt(1 / (double)(3 * num_antenna_ports)) * (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; + LOG_D(PHY, + "3 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, + i_rows, + j_col, + creal(res_code), + cimag(res_code), + weights->precoder_weight_Re, + weights->precoder_weight_Im); + } + } + } + } + } + } + } + + if (max_mimo_layers < 4) + return mat; + + // Table 5.2.2.2.1-8: + // Codebook for 4-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS + + for (int ll = 0; ll < N1 * O1; ll++) { // i_1_1 + for (int mm = 0; mm < N2 * O2; mm++) { // i_1_2 + for (int k1 = 0; k1 < K1; k1++) { + for (int k2 = 0; k2 < K2; k2++) { + for (int nn = 0; nn < 2; nn++) { // i_2 + pmiq++; + pmi_pdu[pmiq].pm_idx = pmiq + 1; // index 0 is the identity matrix + pmi_pdu[pmiq].numLayers = 4; + pmi_pdu[pmiq].num_ant_ports = num_antenna_ports; + LOG_D(PHY, "layer 4 pmiq = %d\n", pmiq); + for (int j_col = 0; j_col < 4; j_col++) { + if (j_col == 0) { + llc = ll; + mmc = mm; + phase_sign = 1; + } + if (j_col == 1) { + llc = ll + k1 * O1; + mmc = mm + k2 * O2; + phase_sign = 1; + } + if (j_col == 2) { + llc = ll; + mmc = mm; + phase_sign = -1; + } + if (j_col == 3) { + llc = ll + k1 * O1; + mmc = mm + k2 * O2; + phase_sign = -1; + } + for (int i_rows = 0; i_rows < N1 * N2; i_rows++) { + nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; + res_code = sqrt(1 / (double)(4 * num_antenna_ports)) * 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; + LOG_D(PHY, + "4 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, + i_rows, + j_col, + creal(res_code), + cimag(res_code), + weights->precoder_weight_Re, + weights->precoder_weight_Im); + } + for (int i_rows = N1 * N2; i_rows < 2 * N1 * N2; i_rows++) { + nfapi_nr_pm_weights_t *weights = &pmi_pdu[pmiq].weights[j_col][i_rows]; + res_code = sqrt(1 / (double)(4 * num_antenna_ports)) * (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; + LOG_D(PHY, + "4 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n", + pmiq, + i_rows, + j_col, + creal(res_code), + cimag(res_code), + weights->precoder_weight_Re, + weights->precoder_weight_Im); + } + } + } + } + } + } + } + return mat; } static void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list, From 74662975683d3ba506d755f10066041480edd8d5 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Fri, 2 Feb 2024 23:08:43 +0100 Subject: [PATCH 36/54] move command line sample offset and 3/4 sampling option at top level, as it is common option for 4G,5G xNB and UE --- executables/lte-enb.c | 1 - executables/lte-ru.c | 57 ++++++++++--------- executables/lte-softmodem.h | 11 +--- executables/lte-ue.c | 20 +++---- executables/lte-uesoftmodem.c | 5 +- executables/nr-gnb.c | 8 +-- executables/nr-ru.c | 14 ++--- executables/nr-softmodem-common.h | 7 +-- executables/nr-softmodem.c | 13 ----- executables/nr-softmodem.h | 2 - executables/nr-ue.c | 3 +- executables/nr-uesoftmodem.c | 3 +- executables/nr-uesoftmodem.h | 8 +-- executables/softmodem-common.c | 3 + executables/softmodem-common.h | 27 ++++++--- openair1/PHY/INIT/nr_init.c | 3 +- openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c | 8 +-- .../PHY/NR_ESTIMATION/nr_measurements_gNB.c | 4 +- openair1/PHY/defs_L1_NB_IoT.h | 3 - openair1/PHY/defs_UE.h | 3 +- openair1/PHY/defs_eNB.h | 2 - openair1/PHY/defs_nr_common.h | 2 +- openair1/SCHED_UE/phy_procedures_lte_ue.c | 13 +---- openair2/UTIL/OPT/probe.c | 6 +- radio/BLADERF/bladerf_lib.c | 2 +- radio/COMMON/common_lib.c | 2 +- radio/COMMON/common_lib.h | 1 + radio/IRIS/iris_lib.cpp | 5 +- radio/LMSSDR/lms_lib.cpp | 14 ++--- radio/USRP/usrp_lib.cpp | 1 + radio/rfsimulator/simulator.c | 1 + 31 files changed, 102 insertions(+), 150 deletions(-) diff --git a/executables/lte-enb.c b/executables/lte-enb.c index 516fafd336..532d8bcfc0 100644 --- a/executables/lte-enb.c +++ b/executables/lte-enb.c @@ -103,7 +103,6 @@ struct timing_info_t { } timing_info; // Fix per CC openair rf/if device update -// extern openair0_device openair0; extern int oai_exit; diff --git a/executables/lte-ru.c b/executables/lte-ru.c index b9db0348e3..2cee48ffbc 100644 --- a/executables/lte-ru.c +++ b/executables/lte-ru.c @@ -808,26 +808,31 @@ void tx_rf(RU_t *ru, /* add fail safe for late command end */ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); // prepare tx buffer pointers - txs = ru->rfdevice.trx_write_func(&ru->rfdevice, - timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, - txp, - siglen+sf_extension, - ru->nb_tx, - flags); - ru->south_out_cnt++; - LOG_D(PHY,"south_out_cnt %d\n",ru->south_out_cnt); - int se = dB_fixed(signal_energy(txp[0],siglen+sf_extension)); + txs = ru->rfdevice + .trx_write_func(&ru->rfdevice, timestamp + ru->ts_offset - sf_extension, txp, siglen + sf_extension, ru->nb_tx, flags); + ru->south_out_cnt++; + LOG_D(PHY, "south_out_cnt %d\n", ru->south_out_cnt); + int se = dB_fixed(signal_energy(txp[0], siglen + sf_extension)); - if (SF_type == SF_S) LOG_D(PHY,"[TXPATH] RU %d tx_rf (en %d,len %d), writing to TS %llu, frame %d, unwrapped_frame %d, subframe %d\n",ru->idx, se, - siglen+sf_extension, (long long unsigned int)timestamp, frame, proc->frame_tx_unwrap, subframe); + if (SF_type == SF_S) + LOG_D(PHY, + "[TXPATH] RU %d tx_rf (en %d,len %d), writing to TS %llu, frame %d, unwrapped_frame %d, subframe %d\n", + ru->idx, + se, + siglen + sf_extension, + (long long unsigned int)timestamp, + frame, + proc->frame_tx_unwrap, + subframe); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0); - // AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen); - if( usrp_tx_thread == 0 && (txs != siglen+sf_extension) && (late_control==STATE_BURST_NORMAL) ) { /* add fail safe for late command */ - late_control=STATE_BURST_TERMINATE; - LOG_E(PHY,"TX : Timeout (sent %d/%d) state =%d\n",txs, siglen,late_control); - } + // AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen); + if (usrp_tx_thread == 0 && (txs != siglen + sf_extension) + && (late_control == STATE_BURST_NORMAL)) { /* add fail safe for late command */ + late_control = STATE_BURST_TERMINATE; + LOG_E(PHY, "TX : Timeout (sent %d/%d) state =%d\n", txs, siglen, late_control); + } } else if (IS_SOFTMODEM_RFSIM ) { // in case of rfsim, we always enable tx because we need to feed rx of the opposite side // we write 1 single I/Q sample to trigger Rx (rfsim will fill gaps with 0 I/Q) @@ -836,15 +841,15 @@ void tx_rf(RU_t *ru, memset(dummy_tx_data,0,sizeof(dummy_tx_data)); for (int i=0; iframe_parms->nb_antennas_tx; i++) dummy_tx[i]= dummy_tx_data[i]; - - AssertFatal( 1 == - ru->rfdevice.trx_write_func(&ru->rfdevice, - timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, - dummy_tx, - 1, - ru->frame_parms->nb_antennas_tx, - 4),""); - + + AssertFatal(1 + == ru->rfdevice.trx_write_func(&ru->rfdevice, + timestamp + ru->ts_offset - sf_extension, + dummy_tx, + 1, + ru->frame_parms->nb_antennas_tx, + 4), + ""); } } diff --git a/executables/lte-softmodem.h b/executables/lte-softmodem.h index 4143bce3a4..ac403ecfec 100644 --- a/executables/lte-softmodem.h +++ b/executables/lte-softmodem.h @@ -74,15 +74,7 @@ #define CONFIG_HLP_DLSHIFT "dynamic shift for LLR compuation for TM3/4 (default 0)\n" #define CONFIG_HLP_USRP_ARGS "set the arguments to identify USRP (same syntax as in UHD)\n" #define CONFIG_HLP_DMAMAP "use DMA memory mapping\n" -#define CONFIG_HLP_TDD "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n" -#define CONFIG_HLP_TADV "Set timing_advance\n" - - - - - - - +#define CONFIG_HLP_TDD "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n" /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters specific to UE */ @@ -106,7 +98,6 @@ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, .strptr=&usrp_args, .defstrval="type=b200",TYPE_STRING, 0}, \ {"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, .uptr=&mmapped_dma, .defintval=0, TYPE_INT, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, .iptr=&tddflag, .defintval=0, TYPE_INT, 0}, \ - {"A", CONFIG_HLP_TADV, 0, .iptr=&(timingadv), .defintval=0, TYPE_INT, 0}, \ {"ue-idx-standalone", NULL, 0, .u16ptr=&ue_idx_standalone, .defuintval=0xFFFF, TYPE_UINT16, 0}, \ {"node-number", NULL, 0, .u16ptr=&node_number, .defuintval=2, TYPE_UINT16, 0}, \ } diff --git a/executables/lte-ue.c b/executables/lte-ue.c index 60ca068d64..5176533b8e 100644 --- a/executables/lte-ue.c +++ b/executables/lte-ue.c @@ -169,7 +169,6 @@ PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS)); } - ue->hw_timing_advance=get_softmodem_params()->hw_timing_advance; ue->Mod_id = UE_id; ue->mac_enabled = 1; @@ -1940,16 +1939,15 @@ void *UE_thread(void *arg) { rxp, readBlockSize, UE->frame_parms.nb_antennas_rx),""); - AssertFatal( writeBlockSize == - UE->rfdevice.trx_write_func(&UE->rfdevice, - timestamp+ - (2*UE->frame_parms.samples_per_tti) - - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - - openair0_cfg[0].tx_sample_advance, - txp, - writeBlockSize, - UE->frame_parms.nb_antennas_tx, - 1),""); + AssertFatal(writeBlockSize + == UE->rfdevice.trx_write_func(&UE->rfdevice, + timestamp + (2 * UE->frame_parms.samples_per_tti) + - UE->frame_parms.ofdm_symbol_size - UE->frame_parms.nb_prefix_samples0, + txp, + writeBlockSize, + UE->frame_parms.nb_antennas_tx, + 1), + ""); if( sub_frame==9) { // read in first symbol of next frame and adjust for timing drift diff --git a/executables/lte-uesoftmodem.c b/executables/lte-uesoftmodem.c index 95dfdeddf4..e26e10d6ee 100644 --- a/executables/lte-uesoftmodem.c +++ b/executables/lte-uesoftmodem.c @@ -274,8 +274,7 @@ static void get_options(configmodule_interface_t *cfg) { int CC_id=0; int tddflag=0; - int dumpframe=0; - int timingadv=0; + int dumpframe = 0; uint8_t nfapi_mode = NFAPI_MONOLITHIC; set_default_frame_parms(frame_parms); @@ -289,8 +288,6 @@ static void get_options(configmodule_interface_t *cfg) config_process_cmdline(cfg, cmdline_ueparams, sizeofArray(cmdline_ueparams), NULL); nfapi_setmode(nfapi_mode); - get_softmodem_params()->hw_timing_advance = timingadv; - if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med; diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index c66123112f..2a12126d7d 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -90,12 +90,8 @@ #include #include -//#define USRP_DEBUG 1 -// Fix per CC openair rf/if device update -// extern openair0_device openair0; - - -//pthread_t main_gNB_thread; +// #define USRP_DEBUG 1 +// Fix per CC openair rf/if device update time_stats_t softmodem_stats_mt; // main thread time_stats_t softmodem_stats_hw; // hw acquisition diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 3ccc7dacc6..92fdc57e00 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -102,7 +102,6 @@ int attach_rru(RU_t *ru); int connect_rau(RU_t *ru); static void NRRCconfig_RU(configmodule_interface_t *cfg); -extern uint32_t timing_advance; extern int emulate_rf; extern int numerology; @@ -857,22 +856,17 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { for (i = 0; i < ru->nb_tx; i++) txp[i] = (void *)&ru->common.txdata[i][fp->get_samples_slot_timestamp(slot, fp, 0)] - sf_extension * sizeof(int32_t); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, - (timestamp + ru->ts_offset - ru->openair0_cfg.tx_sample_advance - timing_advance) & 0xffffffff); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp + ru->ts_offset) & 0xffffffff); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1); // prepare tx buffer pointers - txs = ru->rfdevice.trx_write_func(&ru->rfdevice, - timestamp + ru->ts_offset - ru->openair0_cfg.tx_sample_advance - timing_advance - sf_extension, - txp, - siglen + sf_extension, - ru->nb_tx, - flags); + txs = ru->rfdevice + .trx_write_func(&ru->rfdevice, timestamp + ru->ts_offset - sf_extension, txp, siglen + sf_extension, ru->nb_tx, flags); LOG_D(PHY, "[TXPATH] RU %d aa %d tx_rf, writing to TS %llu, %d.%d, unwrapped_frame %d, slot %d, flags %d, siglen+sf_extension %d, " "returned %d, E %f\n", ru->idx, i, - (long long unsigned int)(timestamp + ru->ts_offset - ru->openair0_cfg.tx_sample_advance - timing_advance - sf_extension), + (long long unsigned int)(timestamp + ru->ts_offset - sf_extension), frame, slot, proc->frame_tx_unwrap, diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index 19760bdd26..46763d6995 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -56,8 +56,7 @@ #define CONFIG_HLP_DMAMAP "use DMA memory mapping\n" #define CONFIG_HLP_EXCCLK "tells hardware to use a clock reference (0:internal(default), 1:external, 2:gpsdo)\n" #define CONFIG_HLP_USIM "use XOR autentication algo in case of test usim mode\n" -#define CONFIG_HLP_NOSNGLT "Disables single-thread mode in lte-softmodem\n" -#define CONFIG_HLP_TADV "Set timing_advance\n" +#define CONFIG_HLP_NOSNGLT "Disables single-thread mode in lte-softmodem\n" #define CONFIG_HLP_DLF "Set the downlink frequency for all component carriers\n" #define CONFIG_HLP_ULOFF "Set the uplink frequnecy offset for all component carriers\n" #define CONFIG_HLP_CHOFF "Channel id offset\n" @@ -80,8 +79,7 @@ #define CONFIG_HLP_L2MONW "Enable L2 wireshark messages on localhost \n" #define CONFIG_HLP_L2MONP "Enable L2 pcap messages on localhost \n" #define CONFIG_HLP_MAC "Disable the MAC procedures at UE side (default is enabled)\n" -#define CONFIG_HLP_VCD "Enable VCD (generated file will is named openair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n" -#define CONFIG_HLP_TQFS "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n" +#define CONFIG_HLP_VCD "Enable VCD (generated file will is named openair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n" #define CONFIG_HLP_TPORT "tracer port\n" #define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n" #define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" @@ -109,6 +107,7 @@ #define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n" #define CONFIG_HLP_NOS1 "Disable s1 interface\n" #define CONFIG_HLP_NOKRNMOD "(noS1 only): Use tun instead of namesh module \n" + /*--------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters for LOG utility */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 6192dacb86..ee6ad7200e 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -108,8 +108,6 @@ static int wait_for_sync = 0; unsigned int mmapped_dma=0; int single_thread_flag=1; -int8_t threequarter_fs=0; - uint64_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; @@ -145,12 +143,6 @@ int rx_input_level_dBm; int otg_enabled; -//int number_of_cards = 1; - - -//static NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; -//static nfapi_nr_config_request_t *config[MAX_NUM_CCs]; -uint32_t timing_advance = 0; uint64_t num_missed_slots=0; // counter for the number of missed slots #include @@ -171,8 +163,6 @@ static char *worker_config = NULL; /* struct for ethernet specific parameters given in eNB conf file */ eth_params_t *eth_params; -openair0_config_t openair0_cfg[MAX_CARDS]; - double cpuf; /* hack: pdcp_run() is required by 4G scheduler which is compiled into @@ -633,7 +623,6 @@ int main( int argc, char **argv ) { setvbuf(stderr, NULL, _IONBF, 0); #endif mode = normal_txrx; - memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs); logInit(); set_latency_target(); @@ -647,8 +636,6 @@ int main( int argc, char **argv ) { exit(-1); } - openair0_cfg[0].threequarter_fs = threequarter_fs; - if (get_softmodem_params()->do_ra) AssertFatal(get_softmodem_params()->phy_test == 0,"RA and phy_test are mutually exclusive\n"); diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h index cc76e9e375..54bcc0fc5d 100644 --- a/executables/nr-softmodem.h +++ b/executables/nr-softmodem.h @@ -18,8 +18,6 @@ // clang-format off #define CMDLINE_PARAMS_DESC_GNB { \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, .iptr=&single_thread_flag, .defintval=1, TYPE_INT, 0}, \ - {"A" , CONFIG_HLP_TADV, 0, .uptr=&timing_advance, .defintval=0, TYPE_UINT, 0}, \ - {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, .i8ptr=&threequarter_fs, .defintval=0, TYPE_INT8, 0}, \ {"m" , CONFIG_HLP_DLMCS_PHYTEST, 0, .uptr=&target_dl_mcs, .defintval=0, TYPE_UINT, 0}, \ {"l" , CONFIG_HLP_DLNL_PHYTEST, 0, .uptr=&target_dl_Nl, .defintval=0, TYPE_UINT, 0}, \ {"L" , CONFIG_HLP_ULNL_PHYTEST, 0, .uptr=&target_ul_Nl, .defintval=0, TYPE_UINT, 0}, \ diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 1ceb49e0d7..98c0443422 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -933,8 +933,7 @@ void *UE_thread(void *arg) // use previous timing_advance value to compute writeTimestamp writeTimestamp = timestamp + UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX) - - firstSymSamp - openair0_cfg[0].tx_sample_advance - - UE->N_TA_offset - timing_advance; + - firstSymSamp - UE->N_TA_offset - timing_advance; // but use current UE->timing_advance value to compute writeBlockSize if (UE->timing_advance != timing_advance) { diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 24e5b53629..de1c97a07b 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -293,7 +293,6 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ UE->chest_freq = nrUE_params.chest_freq; UE->chest_time = nrUE_params.chest_time; UE->no_timing_correction = nrUE_params.no_timing_correction; - UE->timing_advance = nrUE_params.timing_advance; LOG_I(PHY,"Set UE_fo_compensation %d, UE_scan_carrier %d, UE_no_timing_correction %d \n, chest-freq %d, chest-time %d\n", UE->UE_fo_compensation, UE->UE_scan_carrier, UE->no_timing_correction, UE->chest_freq, UE->chest_time); @@ -307,7 +306,7 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ fp->nb_antennas_rx = nrUE_params.nb_antennas_rx; fp->nb_antennas_tx = nrUE_params.nb_antennas_tx; - fp->threequarter_fs = nrUE_params.threequarter_fs; + fp->threequarter_fs = get_softmodem_params()->threequarter_fs; fp->N_RB_DL = nrUE_params.N_RB_DL; fp->ssb_start_subcarrier = nrUE_params.ssb_start_subcarrier; fp->ofdm_offset_divisor = nrUE_params.ofdm_offset_divisor; diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 7adba3fa97..676a8a4e68 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -52,8 +52,6 @@ {"ue-scan-carrier", CONFIG_HLP_UESCAN, PARAMFLAG_BOOL, .iptr=&(nrUE_params.UE_scan_carrier), .defintval=0, TYPE_INT, 0}, \ {"ue-fo-compensation", CONFIG_HLP_UEFO, PARAMFLAG_BOOL, .iptr=&(nrUE_params.UE_fo_compensation), .defintval=0, TYPE_INT, 0}, \ {"ue-max-power", NULL, 0, .iptr=&(tx_max_power[0]), .defintval=90, TYPE_INT, 0}, \ - {"A" , CONFIG_HLP_TADV, 0, .iptr=&(nrUE_params.timing_advance), .defintval=0, TYPE_INT, 0}, \ - {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, .iptr=&(nrUE_params.threequarter_fs), .defintval=0, TYPE_UINT8, 0}, \ {"r" , CONFIG_HLP_PRB_SA, 0, .iptr=&(nrUE_params.N_RB_DL), .defintval=106, TYPE_UINT, 0}, \ {"ssb", CONFIG_HLP_SSC, 0, .iptr=&(nrUE_params.ssb_start_subcarrier), .defintval=516, TYPE_UINT16, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, .iptr=&tddflag, .defintval=0, TYPE_INT, 0}, \ @@ -72,16 +70,14 @@ typedef struct { int max_ldpc_iterations; // number of maximum LDPC iterations tpool_t Tpool; // thread pool int UE_scan_carrier; - int UE_fo_compensation; - int timing_advance; + int UE_fo_compensation; uint64_t if_freq; int if_freq_off; int chest_freq; int chest_time; int no_timing_correction; int nb_antennas_rx; - int nb_antennas_tx; - int threequarter_fs; + int nb_antennas_tx; int N_RB_DL; int ssb_start_subcarrier; } nrUE_params_t; diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c index 316a5b14c9..b750092a39 100644 --- a/executables/softmodem-common.c +++ b/executables/softmodem-common.c @@ -106,6 +106,7 @@ void get_common_options(configmodule_interface_t *cfg, uint32_t execmask) paramdef_t cmdline_params[] = CMDLINE_PARAMS_DESC; checkedparam_t cmdline_CheckParams[] = CMDLINE_PARAMS_CHECK_DESC; int numparams = sizeofArray(cmdline_params); + AssertFatal(numparams == sizeofArray(cmdline_CheckParams), "Error in arrays size (%d!=%lu)\n", numparams, sizeofArray(cmdline_CheckParams)); config_set_checkfunctions(cmdline_params, cmdline_CheckParams, numparams); config_get(cfg, cmdline_params, numparams, NULL); nfapi_index = config_paramidx_fromname(cmdline_params, numparams, "nfapi"); @@ -115,6 +116,8 @@ void get_common_options(configmodule_interface_t *cfg, uint32_t execmask) paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; checkedparam_t cmdline_log_CheckParams[] = CMDLINE_LOGPARAMS_CHECK_DESC; int numlogparams = sizeofArray(cmdline_logparams); + AssertFatal(numlogparams == sizeofArray(cmdline_log_CheckParams), "Error in arrays size (%d!=%lu)\n", numlogparams, sizeofArray(cmdline_log_CheckParams)); + config_set_checkfunctions(cmdline_logparams, cmdline_log_CheckParams, numlogparams); config_get(cfg, cmdline_logparams, numlogparams, NULL); diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index 9dcc5c8e1b..50aa335efb 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -84,7 +84,9 @@ extern "C" #define CONFIG_HLP_ULMCS "Set the maximum uplink MCS\n" #define CONFIG_HLP_UE "Set the lte softmodem as a UE\n" -#define CONFIG_HLP_TQFS "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n" +#define CONFIG_HLP_TQFS \ + "Apply three-quarter of sampling frequency, (example 23.04 Msps for LTE 20MHz) to reduce the data rate on USB/PCIe transfers " \ + "(only valid for some bandwidths)\n" #define CONFIG_HLP_TPORT "tracer port\n" #define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n" #define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" @@ -108,6 +110,9 @@ extern "C" #define CONFIG_HLP_NOITTI "Do not start itti threads, call queue processing in place, inside the caller thread" #define CONFIG_HLP_LDPC_OFFLOAD "Enable LDPC offload to AMD Xilinx T2 telco card\n" #define CONFIG_HLP_SYNC_REF "UE acts a Sync Reference in Sidelink. 0-none 1-GNB 2-GNSS 4-localtiming\n" +#define CONFIG_HLP_TADV \ + "Set RF board timing_advance to compensate fix delay inside the RF board between Rx and Tx timestamps (RF board internal " \ + "issues)\n" /*-----------------------------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters common to eNodeB and UE */ @@ -187,6 +192,8 @@ extern int usrp_tx_thread; {"no-itti-threads", CONFIG_HLP_NOITTI, PARAMFLAG_BOOL, .iptr=&softmodem_params.no_itti, .defintval=0, TYPE_INT, 0}, \ {"ldpc-offload-enable", CONFIG_HLP_LDPC_OFFLOAD, PARAMFLAG_BOOL, .iptr=&LDPC_OFFLOAD_FLAG, .defstrval=0, TYPE_INT, 0}, \ {"sync-ref", CONFIG_HLP_SYNC_REF, 0, .uptr=&SYNC_REF, .defintval=0, TYPE_UINT, 0}, \ + {"A" , CONFIG_HLP_TADV, 0, .iptr=&softmodem_params.command_line_sample_advance,.defintval=0, TYPE_INT, 0}, \ + {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, .iptr=&softmodem_params.threequarter_fs, .defintval=0, TYPE_INT, 0}, \ } // clang-format on @@ -236,6 +243,7 @@ extern int usrp_tx_thread; { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ + { .s5 = { NULL } }, \ } // clang-format on @@ -332,7 +340,7 @@ typedef struct { uint32_t clock_source; uint32_t timing_source; double tune_offset; - int hw_timing_advance; + int command_line_sample_advance; uint32_t send_dmrs_sync; int use_256qam_table; int chest_time; @@ -346,16 +354,17 @@ typedef struct { uint32_t sync_ref; int no_itti; int ldpc_offload_flag; + int threequarter_fs; } softmodem_params_t; -extern uint64_t get_softmodem_optmask(void); -extern uint64_t set_softmodem_optmask(uint64_t bitmask); -extern uint64_t clear_softmodem_optmask(uint64_t bitmask); -extern softmodem_params_t *get_softmodem_params(void); -extern void get_common_options(configmodule_interface_t *cfg, uint32_t execmask); -extern char *get_softmodem_function(uint64_t *sofmodemfunc_mask_ptr); +uint64_t get_softmodem_optmask(void); +uint64_t set_softmodem_optmask(uint64_t bitmask); +uint64_t clear_softmodem_optmask(uint64_t bitmask); +softmodem_params_t *get_softmodem_params(void); +void get_common_options(configmodule_interface_t *cfg, uint32_t execmask); +char *get_softmodem_function(uint64_t *sofmodemfunc_mask_ptr); #define SOFTMODEM_RTSIGNAL (SIGRTMIN+1) -extern void set_softmodem_sighandler(void); +void set_softmodem_sighandler(void); extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; extern int usrp_tx_thread; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 06c26b6923..c864a0366a 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -19,6 +19,7 @@ * contact@openairinterface.org */ +#include "executables/softmodem-common.h" #include "executables/nr-softmodem-common.h" #include "common/utils/nr/nr_common.h" #include "common/ran_context.h" @@ -540,7 +541,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) LOG_I(PHY, "DL frequency %lu Hz, UL frequency %lu Hz: band %d, uldl offset %d Hz\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq, fp->nr_band, dlul_offset); - fp->threequarter_fs = openair0_cfg[0].threequarter_fs; + fp->threequarter_fs = get_softmodem_params()->threequarter_fs; LOG_A(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", Mod_id, gNB_config->cell_config.phy_cell_id.value, diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c index 5470766827..defca14570 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c @@ -81,13 +81,9 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1 int i, prach_len; uint16_t first_nonzero_root_idx=0; - prach_start = (ue->rx_offset+subframe*ue->frame_parms.samples_per_tti-ue->hw_timing_advance-ue->N_TA_offset); + prach_start = (ue->rx_offset + subframe * ue->frame_parms.samples_per_tti - ue->N_TA_offset); #ifdef PRACH_DEBUG - LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id, - prach_start, - ue->rx_offset, - ue->hw_timing_advance, - ue->N_TA_offset); + LOG_I(PHY, "[UE %d] prach_start %d, rx_offset %d, N_TA_offset %d\n", ue->Mod_id, prach_start, ue->rx_offset, ue->N_TA_offset); #endif if (prach_start<0) diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index 260677890f..a30d88255f 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -207,8 +207,8 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, unsigned short rx_power_avg_dB; unsigned short rx_power_tot_dB; - double rx_gain = openair0_cfg[0].rx_gain[0]; - double rx_gain_offset = openair0_cfg[0].rx_gain_offset[0]; + double rx_gain = gNB->RU_list[0]->rfdevice.openair0_cfg->rx_gain[0]; + double rx_gain_offset = gNB->RU_list[0]->rfdevice.openair0_cfg->rx_gain_offset[0]; PHY_MEASUREMENTS_gNB *meas = &gNB->measurements; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; int ch_offset = fp->ofdm_symbol_size * symbol; diff --git a/openair1/PHY/defs_L1_NB_IoT.h b/openair1/PHY/defs_L1_NB_IoT.h index 01143ccf47..38996e20a0 100644 --- a/openair1/PHY/defs_L1_NB_IoT.h +++ b/openair1/PHY/defs_L1_NB_IoT.h @@ -637,8 +637,6 @@ typedef struct PHY_VARS_eNB_NB_IoT_s { /// uint32_t total_system_throughput; /// - int hw_timing_advance; - /// time_stats_t phy_proc; time_stats_t phy_proc_tx; time_stats_t phy_proc_rx; @@ -873,7 +871,6 @@ typedef struct { int rx_offset; /// Timing offset int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP int timing_advance; ///timing advance signalled from eNB - int hw_timing_advance; int N_TA_offset; ///timing offset used in TDD /// Flag to tell if UE is secondary user (cognitive mode) unsigned char is_secondary_ue; diff --git a/openair1/PHY/defs_UE.h b/openair1/PHY/defs_UE.h index 7f1858b2c4..06eaf4a15d 100644 --- a/openair1/PHY/defs_UE.h +++ b/openair1/PHY/defs_UE.h @@ -721,8 +721,7 @@ typedef struct { int rx_offset; /// Timing offset int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP int time_sync_cell; - int timing_advance; ///timing advance signalled from eNB - int hw_timing_advance; + int timing_advance; /// timing advance signalled from eNB int N_TA_offset; ///timing offset used in TDD /// Flag to tell if UE is secondary user (cognitive mode) unsigned char is_secondary_ue; diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 45abb05c2f..389f15e82b 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -713,8 +713,6 @@ typedef struct PHY_VARS_eNB_s { uint32_t total_transmitted_bits; uint32_t total_system_throughput; - int hw_timing_advance; - time_stats_t phy_proc_tx; time_stats_t phy_proc_rx; time_stats_t rx_prach; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index c4d6e2ff91..72233f58cf 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -175,7 +175,7 @@ struct NR_DL_FRAME_PARMS { /// subcarrier spacing (15,30,60,120) uint32_t subcarrier_spacing; /// 3/4 sampling - uint8_t threequarter_fs; + int threequarter_fs; /// Size of FFT uint16_t ofdm_symbol_size; /// Number of prefix samples in all but first symbol of slot diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c index 61429afc9e..7892857051 100644 --- a/openair1/SCHED_UE/phy_procedures_lte_ue.c +++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c @@ -1151,8 +1151,7 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, nsymb = (frame_parms->Ncp == 0) ? 14 : 12; - ulsch_start = ue->rx_offset + subframe_tx * frame_parms->samples_per_tti - - ue->hw_timing_advance - ue->timing_advance - ue->N_TA_offset + 5; + ulsch_start = ue->rx_offset + subframe_tx * frame_parms->samples_per_tti - ue->timing_advance - ue->N_TA_offset + 5; if(ulsch_start < 0) ulsch_start = ulsch_start + (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); @@ -1210,16 +1209,6 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, ((short *)ue->common_vars.txdata[aa])[2*k] = ((short *)dummy_tx_buffer)[2*l]; ((short *)ue->common_vars.txdata[aa])[2*k+1] = ((short *)dummy_tx_buffer)[2*l+1]; } - - /* - only for debug - LOG_I(PHY,"ul-signal [subframe: %d, ulsch_start %d, TA: %d, rxOffset: %d, timing_advance: %d, hw_timing_advance: %d]\n",subframe_tx, ulsch_start, ue->N_TA_offset, ue->rx_offset, ue->timing_advance, ue->hw_timing_advance); - if( (crash == 1) && (subframe_tx == 0) ) - { - LOG_E(PHY,"***** DUMP TX Signal [ulsch_start %d] *****\n",ulsch_start); - LOG_M("txBuff.m","txSignal",&ue->common_vars.txdata[aa][ulsch_start],frame_parms->samples_per_tti,1,1); - } - */ } //nb_antennas_tx if ( LOG_DEBUGFLAG(UE_TIMING)) { diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index e782453e5a..58ea8764e9 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -542,8 +542,10 @@ void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsign int init_opt(void) { paramdef_t opt_params[] = OPT_PARAMS_DESC ; checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC; - config_set_checkfunctions(opt_params, opt_checkParams, sizeofArray(opt_params)); - config_get(config_get_if(), opt_params, sizeofArray(opt_params), OPT_CONFIGPREFIX); + int sz=sizeofArray(opt_params); + AssertFatal(sz == sizeofArray(opt_checkParams), "Error in arrays size (%d!=%lu)\n", sz, sizeofArray(opt_checkParams)); + config_set_checkfunctions(opt_params, opt_checkParams, sz); + config_get(config_get_if(), opt_params, sz, OPT_CONFIGPREFIX); subframesSinceCaptureStart = 0; int tmptype = config_get_processedint(config_get_if(), &(opt_params[OPTTYPE_IDX])); diff --git a/radio/BLADERF/bladerf_lib.c b/radio/BLADERF/bladerf_lib.c index 9ac15bcd1e..e834f8377e 100644 --- a/radio/BLADERF/bladerf_lib.c +++ b/radio/BLADERF/bladerf_lib.c @@ -138,7 +138,7 @@ static int trx_brf_write(openair0_device *device, brf_state_t *brf = (brf_state_t*)device->priv; /* BRF has only 1 rx/tx chaine : is it correct? */ int16_t *samples = (int16_t*)buff[0]; - + timestamp -= device->openair0_cfg->command_line_sample_advance - device->openair0_cfg->tx_sample_advance; //memset(&brf->meta_tx, 0, sizeof(brf->meta_tx)); // When BLADERF_META_FLAG_TX_NOW is used the timestamp is not used, so one can't schedule a tx if (brf->meta_tx.flags == 0 ) diff --git a/radio/COMMON/common_lib.c b/radio/COMMON/common_lib.c index 087e1bc5d7..a78753fbe9 100644 --- a/radio/COMMON/common_lib.c +++ b/radio/COMMON/common_lib.c @@ -96,7 +96,7 @@ int load_lib(openair0_device *device, loader_shlibfunc_t shlib_fdesc[1]; int ret=0; char *deflibname=OAI_RF_LIBNAME; - + openair0_cfg->command_line_sample_advance = get_softmodem_params()->command_line_sample_advance; openair0_cfg->recplay_mode = read_recplayconfig(&(openair0_cfg->recplay_conf),&(device->recplay_state)); if (openair0_cfg->recplay_mode == RECPLAY_RECORDMODE) { diff --git a/radio/COMMON/common_lib.h b/radio/COMMON/common_lib.h index 3ba6a381dc..ead62cb0c7 100644 --- a/radio/COMMON/common_lib.h +++ b/radio/COMMON/common_lib.h @@ -215,6 +215,7 @@ typedef struct openair0_config { int mmapped_dma; //! offset in samples between TX and RX paths int tx_sample_advance; + int command_line_sample_advance; //! samples per packet on the fronthaul interface int samples_per_packet; //! number of RX channels (=RX antennas) diff --git a/radio/IRIS/iris_lib.cpp b/radio/IRIS/iris_lib.cpp index 13cdfb6a44..47f4d2b4ef 100644 --- a/radio/IRIS/iris_lib.cpp +++ b/radio/IRIS/iris_lib.cpp @@ -137,7 +137,7 @@ trx_iris_write(openair0_device *device, openair0_timestamp timestamp, void **buf using namespace std::chrono; int flag = 0; - + timestamp -= device->openair0_cfg->command_line_sample_advance - device->openair0_cfg->tx_sample_advance; iris_state_t *s = (iris_state_t *) device->priv; int nsamps2; // aligned to upper 32 or 16 byte boundary nsamps2 = (nsamps+7)>>3; @@ -164,8 +164,7 @@ trx_iris_write(openair0_device *device, openair0_timestamp timestamp, void **buf flag |= SOAPY_SDR_END_BURST; } - - long long timeNs = SoapySDR::ticksToTimeNs(timestamp, s->sample_rate / SAMPLE_RATE_DOWN); + long long timeNs = SoapySDR::ticksToTimeNs(timestamp - device.command_line_sample_advance, s->sample_rate / SAMPLE_RATE_DOWN); uint32_t *samps[2]; //= (uint32_t **)buff; int r; int m = s->tx_num_channels; diff --git a/radio/LMSSDR/lms_lib.cpp b/radio/LMSSDR/lms_lib.cpp index df3e0c8a9b..3d0dd78118 100644 --- a/radio/LMSSDR/lms_lib.cpp +++ b/radio/LMSSDR/lms_lib.cpp @@ -73,15 +73,13 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d \returns 0 on success */ int trx_lms_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int antenna_id, int flags) { + timestamp -= device->openair0_cfg->command_line_sample_advance - device->openair0_cfg->tx_sample_advance; + lms_stream_meta_t meta; + meta.waitForTimestamp = true; + meta.flushPartialPacket = false; + meta.timestamp = timestamp; - - lms_stream_meta_t meta; - meta.waitForTimestamp = true; - meta.flushPartialPacket = false; - meta.timestamp = timestamp; - - - return LMS_SendStream(&tx_stream,(const void*)buff[0],nsamps,&meta,30); + return LMS_SendStream(&tx_stream, (const void *)buff[0], nsamps, &meta, 30); } /*! \brief Receive samples from hardware. diff --git a/radio/USRP/usrp_lib.cpp b/radio/USRP/usrp_lib.cpp index 73fdc8032f..9c4b47dc80 100644 --- a/radio/USRP/usrp_lib.cpp +++ b/radio/USRP/usrp_lib.cpp @@ -428,6 +428,7 @@ static int trx_usrp_write(openair0_device *device, int flags) { int ret=0; usrp_state_t *s = (usrp_state_t *)device->priv; + timestamp -= device->openair0_cfg->command_line_sample_advance - device->openair0_cfg->tx_sample_advance; int nsamps2; // aligned to upper 32 or 16 byte boundary radio_tx_burst_flag_t flags_burst = (radio_tx_burst_flag_t) (flags & 0xf); diff --git a/radio/rfsimulator/simulator.c b/radio/rfsimulator/simulator.c index 44b2864f8c..0196f8b1b9 100644 --- a/radio/rfsimulator/simulator.c +++ b/radio/rfsimulator/simulator.c @@ -755,6 +755,7 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp } static int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, void **samplesVoid, int nsamps, int nbAnt, int flags) { + timestamp -= device->openair0_cfg->command_line_sample_advance; return rfsimulator_write_internal(device->priv, timestamp, samplesVoid, nsamps, nbAnt, flags, false); // false = with lock // return rfsimulator_write_internal(device->priv, timestamp, samplesVoid, nsamps, nbAnt, flags, true); } From c92cbe67b5b540e0a206b49441f5a365c63a633b Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Fri, 9 Feb 2024 09:37:20 +0100 Subject: [PATCH 37/54] fix b210 usrp tx sample error compemsation --- radio/USRP/usrp_lib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radio/USRP/usrp_lib.cpp b/radio/USRP/usrp_lib.cpp index 9c4b47dc80..4218ae7748 100644 --- a/radio/USRP/usrp_lib.cpp +++ b/radio/USRP/usrp_lib.cpp @@ -428,7 +428,7 @@ static int trx_usrp_write(openair0_device *device, int flags) { int ret=0; usrp_state_t *s = (usrp_state_t *)device->priv; - timestamp -= device->openair0_cfg->command_line_sample_advance - device->openair0_cfg->tx_sample_advance; + timestamp -= device->openair0_cfg->command_line_sample_advance + device->openair0_cfg->tx_sample_advance; int nsamps2; // aligned to upper 32 or 16 byte boundary radio_tx_burst_flag_t flags_burst = (radio_tx_burst_flag_t) (flags & 0xf); @@ -1317,7 +1317,7 @@ extern "C" { case 46080000: s->usrp->set_master_clock_rate(46.08e6); //openair0_cfg[0].samples_per_packet = 1024; - openair0_cfg[0].tx_sample_advance = 115; + openair0_cfg[0].tx_sample_advance = 164; openair0_cfg[0].tx_bw = 40e6; openair0_cfg[0].rx_bw = 40e6; break; From 50d4d489f74b643e0caff2e15a02175d4f3d4167 Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Tue, 13 Feb 2024 11:48:42 +0100 Subject: [PATCH 38/54] fix timing advance from msg2/rar --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 1 + openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 20 +++++++++----- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 8 +++--- openair1/SIMULATION/NR_PHY/ulsim.c | 2 ++ openair2/LAYER2/NR_MAC_UE/mac_defs.h | 9 +++++-- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 1 - openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 27 ++++++------------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 8 +++--- 8 files changed, 40 insertions(+), 36 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 7364b66308..42090c2e9e 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -547,6 +547,7 @@ typedef struct { int ta_frame; int ta_slot; int ta_command; + bool is_rar; } fapi_nr_ta_command_pdu; typedef struct { diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index fbe04ffb84..0ec735caa0 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -320,7 +320,7 @@ static void configure_dlsch(NR_UE_DLSCH_t *dlsch0, } } -void configure_ta_command(PHY_VARS_NR_UE *ue, fapi_nr_ta_command_pdu *ta_command_pdu) +static void configure_ta_command(PHY_VARS_NR_UE *ue, fapi_nr_ta_command_pdu *ta_command_pdu) { /* Time Alignment procedure @@ -365,13 +365,19 @@ void configure_ta_command(PHY_VARS_NR_UE *ue, fapi_nr_ta_command_pdu *ta_command const double t_subframe = 1.0; // subframe duration of 1 msec const int ul_tx_timing_adjustment = 1 + (int)ceil(slots_per_subframe*(N_t_1 + N_t_2 + N_TA_max + 0.5)/t_subframe); - ue->ta_slot = (ta_command_pdu->ta_slot + ul_tx_timing_adjustment) % slots_per_frame; - if (ta_command_pdu->ta_slot + ul_tx_timing_adjustment > slots_per_frame) - ue->ta_frame = (ta_command_pdu->ta_frame + 1) % 1024; - else + if (ta_command_pdu->is_rar) { + ue->ta_slot = ta_command_pdu->ta_slot; ue->ta_frame = ta_command_pdu->ta_frame; - - ue->ta_command = ta_command_pdu->ta_command; + ue->timing_advance = 0; + ue->ta_command = ta_command_pdu->ta_command + 31; // To use TA adjustment algo in ue_ta_procedures() + } else { + ue->ta_slot = (ta_command_pdu->ta_slot + ul_tx_timing_adjustment) % slots_per_frame; + if (ta_command_pdu->ta_slot + ul_tx_timing_adjustment > slots_per_frame) + ue->ta_frame = (ta_command_pdu->ta_frame + 1) % 1024; + else + ue->ta_frame = ta_command_pdu->ta_frame; + ue->ta_command = ta_command_pdu->ta_command; + } LOG_D(PHY,"TA command received in Frame.Slot %d.%d -- Starting UL time alignment procedures. TA update will be applied at frame %d slot %d\n", ta_command_pdu->ta_frame, ta_command_pdu->ta_slot, ue->ta_frame, ue->ta_slot); } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 1a2e410071..dba954aa71 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -232,15 +232,14 @@ int get_tx_amp_prach(int power_dBm, int power_max_dBm, int N_RB_UL){ // - If the current tx frame and slot match the TA configuration // then timing advance is processed and set to be applied in the next UL transmission // - Application of timing adjustment according to TS 38.213 p4.2 -// todo: // - handle RAR TA application as per ch 4.2 TS 38.213 void ue_ta_procedures(PHY_VARS_NR_UE *ue, int slot_tx, int frame_tx) { if (frame_tx == ue->ta_frame && slot_tx == ue->ta_slot) { - uint16_t ofdm_symbol_size = ue->frame_parms.ofdm_symbol_size; - // convert time factor "16 * 64 * T_c / (2^mu)" in N_TA calculation in TS38.213 section 4.2 to samples by multiplying with samples per second + // convert time factor "16 * 64 * T_c / (2^mu)" in N_TA calculation in TS38.213 section 4.2 to samples by multiplying with + // samples per second // 16 * 64 * T_c / (2^mu) * samples_per_second // = 16 * T_s / (2^mu) * samples_per_second // = 16 * 1 / (15 kHz * 2048) / (2^mu) * (15 kHz * 2^mu * ofdm_symbol_size) @@ -250,7 +249,8 @@ void ue_ta_procedures(PHY_VARS_NR_UE *ue, int slot_tx, int frame_tx) ue->timing_advance += (ue->ta_command - 31) * bw_scaling; - LOG_D(PHY, "[UE %d] [%d.%d] Got timing advance command %u from MAC, new value is %d\n", + LOG_D(PHY, + "[UE %d] [%d.%d] Got timing advance command %u from MAC, new value is %d\n", ue->Mod_id, frame_tx, slot_tx, diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 0e64d837e0..f4f6e891b2 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -552,6 +552,8 @@ int main(int argc, char *argv[]) gNB = RC.gNB[0]; gNB->ofdm_offset_divisor = UINT_MAX; gNB->num_pusch_symbols_per_thread = 1; + gNB->RU_list[0] = calloc(1, sizeof(**gNB->RU_list)); + gNB->RU_list[0]->rfdevice.openair0_cfg = openair0_cfg; initFloatingCoresTpool(threadCnt, &gNB->threadPool, false, "gNB-tpool"); initNotifiedFIFO(&gNB->respDecode); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 4bc3a6df16..1b786af544 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -384,11 +384,16 @@ typedef struct { short ssb_rsrp_dBm; } NR_SSB_meas_t; +typedef enum ta_type { + no_ta = 0, + adjustment_ta, + rar_ta, +} ta_type_t; + typedef struct NR_UL_TIME_ALIGNMENT { /// TA command and TAGID received from the gNB - bool ta_apply; + ta_type_t ta_apply; int ta_command; - int ta_total; uint32_t tag_id; int frame; int slot; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 57883839d5..f345b2ccd5 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -401,7 +401,6 @@ and fills the PRACH PDU per each FD occasion. void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, int slotP, void *phy_data); void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot); void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot); -void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment); /* \brief This function schedules the Msg3 transmission @param diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 0ac2855c2a..6add9f025c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3722,12 +3722,11 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i const int tag = ((NR_MAC_CE_TA *)pduP)[1].TAGID; NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment; - ul_time_alignment->ta_total += ta - 31; ul_time_alignment->tag_id = tag; ul_time_alignment->ta_command = ta; ul_time_alignment->frame = frameP; ul_time_alignment->slot = slot; - ul_time_alignment->ta_apply = true; + ul_time_alignment->ta_apply = adjustment_ta; /* #ifdef DEBUG_HEADER_PARSING LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i, pduP[1]); @@ -3735,21 +3734,9 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i */ if (ta == 31) - LOG_D(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n", - frameP, - slot, - ta, - tag, - CC_id, - ul_time_alignment->ta_total); + LOG_D(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d \n", frameP, slot, ta, tag, CC_id); else - LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n", - frameP, - slot, - ta, - tag, - CC_id, - ul_time_alignment->ta_total); + LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d \n", frameP, slot, ta, tag, CC_id); break; case DL_SCH_LCID_CON_RES_ID: @@ -4129,9 +4116,9 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d // TA command NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment; const int ta = rar->TA2 + (rar->TA1 << 5); - ul_time_alignment->ta_command = 31 + ta; - ul_time_alignment->ta_total = ta; - ul_time_alignment->ta_apply = true; + ul_time_alignment->ta_command = ta; + ul_time_alignment->ta_apply = rar_ta; + LOG_W(MAC, "received TA command %d\n", 31 + ta); #ifdef DEBUG_RAR // CSI @@ -4221,6 +4208,8 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d return; } ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2); + ul_time_alignment->frame = frame_tx; + ul_time_alignment->slot = slot_tx; if (ret != -1) { uint16_t rnti = mac->crnti; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 073143b288..d0c8013873 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -58,6 +58,7 @@ //#define SRS_DEBUG static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_frame_t slotP); +static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment); fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx, uint8_t pdu_type) { @@ -1018,7 +1019,7 @@ void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info ue_dci_configuration(mac, dl_config, rx_frame, rx_slot); - if (mac->ul_time_alignment.ta_apply) + if (mac->ul_time_alignment.ta_apply != no_ta) schedule_ta_command(dl_config, &mac->ul_time_alignment); if (mac->state == UE_CONNECTED) { nr_schedule_csirs_reception(mac, rx_frame, rx_slot); @@ -3354,15 +3355,16 @@ uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac, return num_sdus > 0 ? 1 : 0; } -void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment) +static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment) { fapi_nr_ta_command_pdu *ta = &dl_config->dl_config_list[dl_config->number_pdus].ta_command_pdu; ta->ta_frame = ul_time_alignment->frame; ta->ta_slot = ul_time_alignment->slot; + ta->is_rar = ul_time_alignment->ta_apply == rar_ta; ta->ta_command = ul_time_alignment->ta_command; dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_CONFIG_TA_COMMAND; dl_config->number_pdus += 1; - ul_time_alignment->ta_apply = false; + ul_time_alignment->ta_apply = no_ta; } uint32_t nr_get_pbr(long prioritizedbitrate) From 2962340a8bbb7d49ec2e45c7a9bc87d70a63933a Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Mon, 4 Mar 2024 10:48:13 +0100 Subject: [PATCH 39/54] Add variable pointer to catch the rx gain between redundant strct members rfdevice and ifdevice --- openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index a30d88255f..0f68620048 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -206,9 +206,19 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, int rx_power_tot = 0; unsigned short rx_power_avg_dB; unsigned short rx_power_tot_dB; - - double rx_gain = gNB->RU_list[0]->rfdevice.openair0_cfg->rx_gain[0]; - double rx_gain_offset = gNB->RU_list[0]->rfdevice.openair0_cfg->rx_gain_offset[0]; + RU_t *ru = gNB->RU_list[0]; + double rx_gain, rx_gain_offset; + if (ru && ru->rfdevice.openair0_cfg) { + rx_gain = ru->rfdevice.openair0_cfg->rx_gain[0]; + rx_gain_offset = ru->rfdevice.openair0_cfg->rx_gain_offset[0]; + } else if (ru && ru->ifdevice.openair0_cfg) { + rx_gain = ru->ifdevice.openair0_cfg->rx_gain[0]; + rx_gain_offset = ru->ifdevice.openair0_cfg->rx_gain_offset[0]; + } else { + LOG_W(NR_PHY, "no device for rx gain, take arbitrary gain = 1)\n"); + rx_gain = 1; + rx_gain_offset = 0; + } PHY_MEASUREMENTS_gNB *meas = &gNB->measurements; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; int ch_offset = fp->ofdm_symbol_size * symbol; From ebe1b711ac3e14628c9656f0104d0a2dfa117ed3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 4 Mar 2024 12:17:02 +0100 Subject: [PATCH 40/54] Print core_pattern in all entrypoint scripts --- docker/scripts/enb_entrypoint.sh | 3 +++ docker/scripts/gnb-aw2s_entrypoint.sh | 3 +++ docker/scripts/gnb_entrypoint.sh | 2 ++ docker/scripts/lte_ru_entrypoint.sh | 3 +++ docker/scripts/lte_ue_entrypoint.sh | 3 +++ docker/scripts/nr_ue_entrypoint.sh | 3 +++ 6 files changed, 17 insertions(+) diff --git a/docker/scripts/enb_entrypoint.sh b/docker/scripts/enb_entrypoint.sh index cda5793ab3..42a9bb44cc 100755 --- a/docker/scripts/enb_entrypoint.sh +++ b/docker/scripts/enb_entrypoint.sh @@ -5,6 +5,9 @@ set -uo pipefail PREFIX=/opt/oai-enb CONFIGFILE=$PREFIX/etc/enb.conf +echo "==================================" +echo "/proc/sys/kernel/core_pattern=$(cat /proc/sys/kernel/core_pattern)" + if [ ! -f $CONFIGFILE ]; then echo "No configuration file found: please mount at $CONFIGFILE" exit 255 diff --git a/docker/scripts/gnb-aw2s_entrypoint.sh b/docker/scripts/gnb-aw2s_entrypoint.sh index 752e3005ed..7085800d13 100755 --- a/docker/scripts/gnb-aw2s_entrypoint.sh +++ b/docker/scripts/gnb-aw2s_entrypoint.sh @@ -5,6 +5,9 @@ set -uo pipefail PREFIX=/opt/oai-gnb-aw2s CONFIGFILE=$PREFIX/etc/gnb.conf +echo "==================================" +echo "/proc/sys/kernel/core_pattern=$(cat /proc/sys/kernel/core_pattern)" + if [ ! -f $CONFIGFILE ]; then echo "No configuration file found: please mount at $CONFIGFILE" exit 255 diff --git a/docker/scripts/gnb_entrypoint.sh b/docker/scripts/gnb_entrypoint.sh index 230f3f0f7d..9253d4a3e1 100755 --- a/docker/scripts/gnb_entrypoint.sh +++ b/docker/scripts/gnb_entrypoint.sh @@ -5,6 +5,8 @@ set -uo pipefail PREFIX=/opt/oai-gnb CONFIGFILE=$PREFIX/etc/gnb.conf +echo "==================================" +echo "/proc/sys/kernel/core_pattern=$(cat /proc/sys/kernel/core_pattern)" if [ ! -f $CONFIGFILE ]; then echo "No configuration file found: please mount at $CONFIGFILE" diff --git a/docker/scripts/lte_ru_entrypoint.sh b/docker/scripts/lte_ru_entrypoint.sh index 0305cf27ff..85d99419c0 100755 --- a/docker/scripts/lte_ru_entrypoint.sh +++ b/docker/scripts/lte_ru_entrypoint.sh @@ -5,6 +5,9 @@ set -uo pipefail PREFIX=/opt/oai-lte-ru CONFIGFILE=$PREFIX/etc/rru.conf +echo "==================================" +echo "/proc/sys/kernel/core_pattern=$(cat /proc/sys/kernel/core_pattern)" + if [ ! -f $CONFIGFILE ]; then echo "No configuration file found: please mount at $CONFIGFILE" exit 255 diff --git a/docker/scripts/lte_ue_entrypoint.sh b/docker/scripts/lte_ue_entrypoint.sh index f88692a957..bf3a72b0d2 100755 --- a/docker/scripts/lte_ue_entrypoint.sh +++ b/docker/scripts/lte_ue_entrypoint.sh @@ -5,6 +5,9 @@ set -uo pipefail PREFIX=/opt/oai-lte-ue USIM_CONFIGFILE=$PREFIX/etc/ue_usim.conf +echo "==================================" +echo "/proc/sys/kernel/core_pattern=$(cat /proc/sys/kernel/core_pattern)" + if [ ! -f $USIM_CONFIGFILE ]; then echo "No ue_usim.conf configuration file found: please mount at $USIM_CONFIGFILE" exit 255 diff --git a/docker/scripts/nr_ue_entrypoint.sh b/docker/scripts/nr_ue_entrypoint.sh index e84386276a..31382a9b07 100755 --- a/docker/scripts/nr_ue_entrypoint.sh +++ b/docker/scripts/nr_ue_entrypoint.sh @@ -5,6 +5,9 @@ set -uo pipefail PREFIX=/opt/oai-nr-ue CONFIGFILE=$PREFIX/etc/nr-ue.conf +echo "==================================" +echo "/proc/sys/kernel/core_pattern=$(cat /proc/sys/kernel/core_pattern)" + if [ ! -f $CONFIGFILE ]; then echo "No configuration file found: please mount at $CONFIGFILE" exit 255 From 29ca077b66d88181518256c21be6ebf5e9487a94 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 26 Feb 2024 12:48:57 +0100 Subject: [PATCH 41/54] Increase default max LDPC iter to 8 Doing only 5 LDPC iterations by default leads to a poor reception performance, and correspondingly many retransmissions. Increase to 8 as the new default to improve user experience. --- executables/nr-uesoftmodem.h | 2 +- openair2/GNB_APP/L1_nr_paramdef.h | 2 +- .../GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 1 - .../CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf | 1 - .../CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf | 1 - .../CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf | 1 - 6 files changed, 2 insertions(+), 6 deletions(-) diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 7adba3fa97..d427be0c66 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -36,7 +36,7 @@ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, .iptr=&single_thread_flag, .defintval=1, TYPE_INT, 0}, \ {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, .u8ptr=NULL, .defintval=0, TYPE_UINT8, 0}, \ {"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, .uptr=&nrUE_params.ofdm_offset_divisor, .defuintval=8, TYPE_UINT32, 0}, \ - {"max-ldpc-iterations", CONFIG_HLP_MAX_LDPC_ITERATIONS, 0, .iptr=&nrUE_params.max_ldpc_iterations, .defuintval=5, TYPE_UINT8, 0}, \ + {"max-ldpc-iterations", CONFIG_HLP_MAX_LDPC_ITERATIONS, 0, .iptr=&nrUE_params.max_ldpc_iterations, .defuintval=8, TYPE_UINT8, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, .iptr=(int32_t *)&nr_dlsch_demod_shift, .defintval=0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, .iptr=&vcdflag, .defintval=0, TYPE_INT, 0}, \ {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, .strptr=&uecap_file, .defstrval="./uecap_ports1.xml", TYPE_STRING, 0}, \ diff --git a/openair2/GNB_APP/L1_nr_paramdef.h b/openair2/GNB_APP/L1_nr_paramdef.h index 1b367ec064..b503825c8e 100644 --- a/openair2/GNB_APP/L1_nr_paramdef.h +++ b/openair2/GNB_APP/L1_nr_paramdef.h @@ -81,7 +81,7 @@ {CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=150, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=50, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_SRS_DTX_THRESHOLD, NULL, 0, .uptr=NULL, .defintval=50, TYPE_UINT, 0}, \ - {CONFIG_STRING_L1_MAX_LDPC_ITERATIONS, NULL, 0, .uptr=NULL, .defintval=5, TYPE_UINT, 0}, \ + {CONFIG_STRING_L1_MAX_LDPC_ITERATIONS, NULL, 0, .uptr=NULL, .defintval=8, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_RX_THREAD_CORE, NULL, 0, .uptr=NULL, .defintval=-1, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_TX_THREAD_CORE, NULL, 0, .uptr=NULL, .defintval=-1, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_TX_AMP_BACKOFF_dB, HLP_L1TX_BO,0, .uptr=NULL, .defintval=36, TYPE_UINT, 0}, \ diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 9d4cf054be..41403e00b1 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -191,7 +191,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - max_ldpc_iterations = 5; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf index 91408a8a46..b06e7e9267 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf @@ -213,7 +213,6 @@ L1s = ( prach_dtx_threshold = 130 pucch0_dtx_threshold = 80; pusch_dtx_threshold = -100; - max_ldpc_iterations = 10; #thread_pool_size = 8; tx_amp_backoff_dB = 3; L1_rx_thread_core = 8; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf index 00403229d6..448a582749 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf @@ -211,7 +211,6 @@ L1s = ( prach_dtx_threshold = 100; pucch0_dtx_threshold = 80; pusch_dtx_threshold = 10; - max_ldpc_iterations = 10; tx_amp_backoff_dB = 20; # needs to match O-RU configuration L1_rx_thread_core = 8; L1_tx_thread_core = 10; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf index 3ea78082a8..463b180b73 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf @@ -212,7 +212,6 @@ L1s = ( prach_dtx_threshold = 130 pucch0_dtx_threshold = 80; pusch_dtx_threshold = 10; - max_ldpc_iterations = 10; tx_amp_backoff_dB = 20; # needs to match O-RU configuration L1_rx_thread_core = 8; L1_tx_thread_core = 10; From 9a44d4b88f9a1f23febb21243de76c04b92dd901 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 26 Feb 2024 12:53:45 +0100 Subject: [PATCH 42/54] Increase default UL max MCS to 28 The original UL max MCS of 9 was chosen for performance reasons. In the meantime, machines became faster, and the ULSCH decoding faster. Improve UL max MCS to be 28 by default to use the complete range of possible MCS. --- ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf | 1 - ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml | 2 +- openair2/GNB_APP/MACRLC_nr_paramdef.h | 2 +- .../GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf | 1 - .../CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf | 1 - .../CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf | 1 - .../CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf | 1 - .../CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf | 1 - .../CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf | 1 - 13 files changed, 2 insertions(+), 13 deletions(-) diff --git a/ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf b/ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf index 0a2930aade..1ca3888691 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf @@ -198,7 +198,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 180; pucch_TargetSNRx10 = 200; ulsch_max_frame_inactivity = 1; - ul_max_mcs = 16; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf b/ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf index 802d2b2290..2103379979 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf @@ -193,7 +193,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; ulsch_max_frame_inactivity = 10; - ul_max_mcs = 28; } ); diff --git a/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml index 072461af5c..aae28fe016 100644 --- a/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml @@ -26,7 +26,7 @@ services: container_name: sa-du-b200-gnb environment: USE_B2XX: 'yes' - USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --log_config.global_log_options level,nocolor,time,line_num,function --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 0 --MACRLCs.[0].ul_max_mcs 28 --L1s.[0].max_ldpc_iterations 20 + USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --log_config.global_log_options level,nocolor,time,line_num,function --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 0 --L1s.[0].max_ldpc_iterations 20 volumes: - ../../conf_files/gnb-du.sa.band1.52prb.usrpb210.conf:/opt/oai-gnb/etc/gnb.conf - /dev:/dev diff --git a/openair2/GNB_APP/MACRLC_nr_paramdef.h b/openair2/GNB_APP/MACRLC_nr_paramdef.h index 5d8dbf9239..f33cbf5327 100644 --- a/openair2/GNB_APP/MACRLC_nr_paramdef.h +++ b/openair2/GNB_APP/MACRLC_nr_paramdef.h @@ -119,7 +119,7 @@ {CONFIG_STRING_MACRLC_DL_MAX_MCS, HLP_MACRLC_DL_MAX_MCS, 0, .u8ptr=NULL, .defintval=28, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_UL_BLER_TARGET_UPPER, HLP_MACRLC_UL_BLER_UP, 0, .dblptr=NULL, .defdblval=0.15, TYPE_DOUBLE, 0}, \ {CONFIG_STRING_MACRLC_UL_BLER_TARGET_LOWER, HLP_MACRLC_UL_BLER_LO, 0, .dblptr=NULL, .defdblval=0.05, TYPE_DOUBLE, 0}, \ - {CONFIG_STRING_MACRLC_UL_MAX_MCS, HLP_MACRLC_UL_MAX_MCS, 0, .u8ptr=NULL, .defintval=9, TYPE_UINT8, 0}, \ + {CONFIG_STRING_MACRLC_UL_MAX_MCS, HLP_MACRLC_UL_MAX_MCS, 0, .u8ptr=NULL, .defintval=28, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_DL_HARQ_ROUND_MAX, HLP_MACRLC_DL_HARQ_MAX, 0, .u8ptr=NULL, .defintval=4, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_UL_HARQ_ROUND_MAX, HLP_MACRLC_UL_HARQ_MAX, 0, .u8ptr=NULL, .defintval=4, TYPE_UINT8, 0}, \ {CONFIG_STRING_MACRLC_MIN_GRANT_PRB, HLP_MACRLC_MIN_GRANT_PRB, 0, .u8ptr=NULL, .defintval=5, TYPE_UINT8, 0}, \ diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf index c025ea498d..bf3aa8185c 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band1.u0.52PRB.usrpb210.conf @@ -184,7 +184,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ul_max_mcs = 28; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index 3ecd542a9c..3489a440fa 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -186,7 +186,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; ulsch_max_frame_inactivity = 0; - ul_max_mcs = 10; min_grant_prb = 20; min_grant_mcs = 16; dl_max_mcs = 10; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf index b06e7e9267..099cd4c36e 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf @@ -202,7 +202,6 @@ MACRLCs = ( ul_bler_target_lower=.15; pusch_FailureThres = 100; ulsch_max_frame_inactivity = 0; - ul_max_mcs = 25; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf index ab6c5b7ffb..70a12f6c8e 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf @@ -191,7 +191,6 @@ MACRLCs = ( pucch_TargetSNRx10 = 200; pusch_FailureThres = 1000; ulsch_max_frame_inactivity = 0; - ul_max_mcs = 28; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf index 70bab1c6f7..3f5e125918 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf @@ -191,7 +191,6 @@ MACRLCs = ( pucch_TargetSNRx10 = 200; pusch_FailureThres = 1000; ulsch_max_frame_inactivity = 0; - ul_max_mcs = 28; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf index 448a582749..30bd438e4b 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x2-benetel650.conf @@ -200,7 +200,6 @@ MACRLCs = ( ul_bler_target_upper=.35; ul_bler_target_lower=.15; pusch_FailureThres = 100; - ul_max_mcs = 28; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf index 463b180b73..8fac94bfef 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf @@ -201,7 +201,6 @@ MACRLCs = ( ul_bler_target_lower=.15; pusch_FailureThres = 100; ulsch_max_frame_inactivity = 0; - ul_max_mcs = 25; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index 665771288b..86291dc9be 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -187,7 +187,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; ulsch_max_frame_inactivity = 0; - ul_max_mcs = 28; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf index 0ed70dea8b..4bbd9033df 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf @@ -191,7 +191,6 @@ MACRLCs = ( pucch_TargetSNRx10 = 200; pusch_FailureThres = 1000; ulsch_max_frame_inactivity = 0; - ul_max_mcs = 28; } ); From 6c015f8099e9893b01aaee815be4d94e0225cfb3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 26 Feb 2024 12:56:36 +0100 Subject: [PATCH 43/54] Test: reduce max_ulsch_frame_inactivity, use default of 10 --- ci-scripts/conf_files/gnb-du.sa.band1.52prb.usrpb210.conf | 1 - ci-scripts/conf_files/gnb-du.sa.band78.106prb.usrpb200.conf | 1 - ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpb200.conf | 1 - ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf | 1 - ci-scripts/conf_files/gnb.sa.band66.u0.25prb.rfsim.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.106prb.rfsim.2x2.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.106prb.usrp310.2x2.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.106prb.usrpb200.sc-fdma.conf | 1 - .../conf_files/gnb.sa.band78.106prb.usrpn310.ddsuu-2x2.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.162prb.usrpn310.2x2.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.24prb.rfsim.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf | 1 - ci-scripts/conf_files/gnb.sa.band78.51prb.usrpb200.conf | 1 - .../conf_files/untested/gnb.band78.sa.fr1.106PRB.usrpn310.conf | 1 - .../conf_files/untested/gnb.band78.tm1.fr1.106PRB.usrpb210.conf | 1 - .../conf_files/untested/gnb.sa.band78.fr1.51PRB.usrpb210.conf | 1 - .../CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf | 1 - .../CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpx300.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.24PRB.usrpx300.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf | 1 - .../CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf | 1 - .../CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf | 1 - .../CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf | 1 - .../CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf | 1 - .../CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb0.prs.band78.fr1.106PRB.usrpx310.conf | 1 - .../GENERIC-NR-5GC/CONF/gnb1.prs.band78.fr1.106PRB.usrpx310.conf | 1 - 35 files changed, 35 deletions(-) diff --git a/ci-scripts/conf_files/gnb-du.sa.band1.52prb.usrpb210.conf b/ci-scripts/conf_files/gnb-du.sa.band1.52prb.usrpb210.conf index ed4a1da547..5abf74a828 100644 --- a/ci-scripts/conf_files/gnb-du.sa.band1.52prb.usrpb210.conf +++ b/ci-scripts/conf_files/gnb-du.sa.band1.52prb.usrpb210.conf @@ -171,7 +171,6 @@ MACRLCs = ( remote_n_portd = 2153; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/ci-scripts/conf_files/gnb-du.sa.band78.106prb.usrpb200.conf b/ci-scripts/conf_files/gnb-du.sa.band78.106prb.usrpb200.conf index f773b2dd33..825fcd1c49 100644 --- a/ci-scripts/conf_files/gnb-du.sa.band78.106prb.usrpb200.conf +++ b/ci-scripts/conf_files/gnb-du.sa.band78.106prb.usrpb200.conf @@ -178,7 +178,6 @@ MACRLCs = ( remote_n_portd = 2153; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpb200.conf b/ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpb200.conf index e948a77786..39bf6858f1 100644 --- a/ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpb200.conf +++ b/ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpb200.conf @@ -200,7 +200,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf b/ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf index b8cc0de15e..b08faabb19 100644 --- a/ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf +++ b/ci-scripts/conf_files/gnb.nsa.band78.106prb.usrpn310.2x2.conf @@ -202,7 +202,6 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; - ulsch_max_frame_inactivity = 0; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band66.u0.25prb.rfsim.conf b/ci-scripts/conf_files/gnb.sa.band66.u0.25prb.rfsim.conf index 706cae1e23..940bd210da 100644 --- a/ci-scripts/conf_files/gnb.sa.band66.u0.25prb.rfsim.conf +++ b/ci-scripts/conf_files/gnb.sa.band66.u0.25prb.rfsim.conf @@ -187,7 +187,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf b/ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf index 1ca3888691..75d19c2c43 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.106prb.n310.7ds2u.conf @@ -197,7 +197,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 180; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.106prb.rfsim.2x2.conf b/ci-scripts/conf_files/gnb.sa.band78.106prb.rfsim.2x2.conf index a6d97f67fe..f59ce1bd4c 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.106prb.rfsim.2x2.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.106prb.rfsim.2x2.conf @@ -188,7 +188,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; #pusch_TargetSNRx10 = 150; #pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; dl_max_mcs = 16; # there are retransmissions if more } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.106prb.usrp310.2x2.conf b/ci-scripts/conf_files/gnb.sa.band78.106prb.usrp310.2x2.conf index 480bb45637..e7452878e0 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.106prb.usrp310.2x2.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.106prb.usrp310.2x2.conf @@ -190,7 +190,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 220; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.106prb.usrpb200.sc-fdma.conf b/ci-scripts/conf_files/gnb.sa.band78.106prb.usrpb200.sc-fdma.conf index a22bff5209..3f4a851f2d 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.106prb.usrpb200.sc-fdma.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.106prb.usrpb200.sc-fdma.conf @@ -184,7 +184,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; ul_prbblack_SNR_threshold = 10; - ulsch_max_frame_inactivity = 10; ul_max_mcs = 9; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.106prb.usrpn310.ddsuu-2x2.conf b/ci-scripts/conf_files/gnb.sa.band78.106prb.usrpn310.ddsuu-2x2.conf index c77399bbed..9e148178bb 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.106prb.usrpn310.ddsuu-2x2.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.106prb.usrpn310.ddsuu-2x2.conf @@ -203,7 +203,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 220; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.162prb.usrpn310.2x2.conf b/ci-scripts/conf_files/gnb.sa.band78.162prb.usrpn310.2x2.conf index a24f45f024..9e6dba6169 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.162prb.usrpn310.2x2.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.162prb.usrpn310.2x2.conf @@ -204,7 +204,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; # pusch_TargetSNRx10 = 200; # pucch_TargetSNRx10 = 150; - ulsch_max_frame_inactivity = 0; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.24prb.rfsim.conf b/ci-scripts/conf_files/gnb.sa.band78.24prb.rfsim.conf index 0983b62977..2c9300a2a2 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.24prb.rfsim.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.24prb.rfsim.conf @@ -186,7 +186,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf b/ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf index 2103379979..f9ddfd8460 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.51prb.aw2s.ddsuu.conf @@ -192,7 +192,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 10; } ); diff --git a/ci-scripts/conf_files/gnb.sa.band78.51prb.usrpb200.conf b/ci-scripts/conf_files/gnb.sa.band78.51prb.usrpb200.conf index 75dde393e9..a2e314b3b3 100644 --- a/ci-scripts/conf_files/gnb.sa.band78.51prb.usrpb200.conf +++ b/ci-scripts/conf_files/gnb.sa.band78.51prb.usrpb200.conf @@ -184,7 +184,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; ul_prbblack_SNR_threshold = 10; - ulsch_max_frame_inactivity = 0; } ); diff --git a/ci-scripts/conf_files/untested/gnb.band78.sa.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/untested/gnb.band78.sa.fr1.106PRB.usrpn310.conf index b1abd0024f..05b362d2af 100644 --- a/ci-scripts/conf_files/untested/gnb.band78.sa.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/untested/gnb.band78.sa.fr1.106PRB.usrpn310.conf @@ -208,7 +208,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/ci-scripts/conf_files/untested/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/untested/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index b8d2b8c34a..5ed97c58d5 100644 --- a/ci-scripts/conf_files/untested/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/untested/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -199,7 +199,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/ci-scripts/conf_files/untested/gnb.sa.band78.fr1.51PRB.usrpb210.conf b/ci-scripts/conf_files/untested/gnb.sa.band78.fr1.51PRB.usrpb210.conf index 564bac2c85..319edd2eab 100644 --- a/ci-scripts/conf_files/untested/gnb.sa.band78.fr1.51PRB.usrpb210.conf +++ b/ci-scripts/conf_files/untested/gnb.sa.band78.fr1.51PRB.usrpb210.conf @@ -186,7 +186,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; ul_prbblack_SNR_threshold = 10; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf index 0a61a690cd..eebea7448d 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf @@ -219,7 +219,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; # pusch_TargetSNRx10 = 200; # pucch_TargetSNRx10 = 150; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf index 6533f6e542..2f1218eb2b 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf @@ -223,7 +223,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; #pusch_TargetSNRx10 = 200; #pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index 3489a440fa..4598a8cf90 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -185,7 +185,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; min_grant_prb = 20; min_grant_mcs = 16; dl_max_mcs = 10; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf index 97405a073b..f1f88890fe 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.52PRB.usrpb210.conf @@ -191,7 +191,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpx300.conf index aa0c090395..6a460e039a 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.106PRB.usrpx300.conf @@ -201,7 +201,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.24PRB.usrpx300.conf index f8057be015..8b82cfb39c 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.24PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.24PRB.usrpx300.conf @@ -202,7 +202,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf index f9646c4aed..2a0fec9ce8 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band66.fr1.25PRB.usrpx300.conf @@ -202,7 +202,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf index 099cd4c36e..51b58b7bf7 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.273prb.fhi72.4x4-vvdn.conf @@ -201,7 +201,6 @@ MACRLCs = ( ul_bler_target_upper=.35; ul_bler_target_lower=.15; pusch_FailureThres = 100; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf index 70a12f6c8e..42168839c9 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf @@ -190,7 +190,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 300; pucch_TargetSNRx10 = 200; pusch_FailureThres = 1000; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf index 3f5e125918..9619ddbcdb 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.usrpx300.conf @@ -190,7 +190,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 300; pucch_TargetSNRx10 = 200; pusch_FailureThres = 1000; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf index 8fac94bfef..44295c0551 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.273prb.fhi72.4x4-liteon.conf @@ -200,7 +200,6 @@ MACRLCs = ( ul_bler_target_upper=.35; ul_bler_target_lower=.15; pusch_FailureThres = 100; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf index 1d64c6fedf..b883acbd7e 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.2x2.usrpn300.conf @@ -187,7 +187,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; #pusch_TargetSNRx10 = 150; #pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index 86291dc9be..4f2843c131 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -186,7 +186,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf index 4bbd9033df..6df7390468 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.162PRB.2x2.usrpn300.conf @@ -190,7 +190,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 300; pucch_TargetSNRx10 = 200; pusch_FailureThres = 1000; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf index 31c32a4d1d..fcd7bff5ce 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.217PRB.2x2.usrpn300.conf @@ -189,7 +189,6 @@ MACRLCs = ( pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; pusch_FailureThres = 1000; - ulsch_max_frame_inactivity = 0; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf index 7593d64465..87db51d66c 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.24PRB.usrpb210.conf @@ -186,7 +186,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 150; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb0.prs.band78.fr1.106PRB.usrpx310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb0.prs.band78.fr1.106PRB.usrpx310.conf index d448ad8cbc..5489822423 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb0.prs.band78.fr1.106PRB.usrpx310.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb0.prs.band78.fr1.106PRB.usrpx310.conf @@ -223,7 +223,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb1.prs.band78.fr1.106PRB.usrpx310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb1.prs.band78.fr1.106PRB.usrpx310.conf index 21bb04ed25..9d09ed3936 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb1.prs.band78.fr1.106PRB.usrpx310.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb1.prs.band78.fr1.106PRB.usrpx310.conf @@ -222,7 +222,6 @@ MACRLCs = ( tr_n_preference = "local_RRC"; pusch_TargetSNRx10 = 200; pucch_TargetSNRx10 = 200; - ulsch_max_frame_inactivity = 1; } ); From d60273e200fd1da4e9ef04bb8ea848c3e494cdb7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 1 Mar 2024 14:51:35 +0100 Subject: [PATCH 44/54] Update tutorials after default config setting changes --- doc/NR_SA_Tutorial_COTS_UE.md | 4 ++++ doc/NR_SA_Tutorial_OAI_nrUE.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/doc/NR_SA_Tutorial_COTS_UE.md b/doc/NR_SA_Tutorial_COTS_UE.md index 5f1dd97cec..7feab970a4 100644 --- a/doc/NR_SA_Tutorial_COTS_UE.md +++ b/doc/NR_SA_Tutorial_COTS_UE.md @@ -188,6 +188,10 @@ sudo ethtool -G enp1s0f0 tx 4096 rx 4096 ## 6.2 Real-time performance workarounds - Enable Performance Mode `sudo cpupower idle-set -D 0` - If you get real-time problems on heavy UL traffic, reduce the maximum UL MCS using an additional command-line switch: `--MACRLCs.[0].ul_max_mcs 14`. +- You can also reduce the number of LDPC decoder iterations, which will make the LDPC decoder take less time: `--L1s.[0].max_ldpc_iterations 4`. ## 6.3 Uplink issues related with noise on the DC carriers - There is noise on the DC carriers on N300 and especially the X300 in UL. To avoid their use or shift them away from the center to use more UL spectrum, use the `--tune-offset ` command line switch, where `` is ideally half the bandwidth, or possibly less. + +## 6.4 Lower latency on user plane +- To lower latency on the user plane, you can force the UE to be scheduled constantly in uplink: `--MACRLCs.[0].ulsch_max_frame_inactivity 0` . diff --git a/doc/NR_SA_Tutorial_OAI_nrUE.md b/doc/NR_SA_Tutorial_OAI_nrUE.md index d82343c684..6ba09a7ca8 100644 --- a/doc/NR_SA_Tutorial_OAI_nrUE.md +++ b/doc/NR_SA_Tutorial_OAI_nrUE.md @@ -192,6 +192,7 @@ sudo ethtool -G enp1s0f0 tx 4096 rx 4096 ## 6.2 Real-time performance workarounds - Enable Performance Mode `sudo cpupower idle-set -D 0` - If you get real-time problems on heavy UL traffic, reduce the maximum UL MCS using an additional command-line switch: `--MACRLCs.[0].ul_max_mcs 14`. +- You can also reduce the number of LDPC decoder iterations, which will make the LDPC decoder take less time: `--L1s.[0].max_ldpc_iterations 4`. ## 6.3 Uplink issues related with noise on the DC carriers - There is noise on the DC carriers on N300 and especially the X300 in UL. To avoid their use or shift them away from the center to use more UL spectrum, use the `--tune-offset ` command line switch, where `` is ideally half the bandwidth, or possibly less. @@ -200,3 +201,6 @@ sudo ethtool -G enp1s0f0 tx 4096 rx 4096 - Sometimes, the nrUE would keep repeating RA procedure because of Msg3 failure at the gNB. If it happens, add the `-A` option at the nrUE and/or gNB side, e.g., `-A 45`. This modifies the timing advance (in samples). Adjust +/-5 if the issue persists. - This can be necessary since certain USRPs have larger signal delays than others; it is therefore specific to the used USRP model. - The x310 and B210 are found to work with the default configuration; N310 and x410 can benefit from setting this timing advance. + +## 6.5 Lower latency on user plane +- To lower latency on the user plane, you can force the UE to be scheduled constantly in uplink: `--MACRLCs.[0].ulsch_max_frame_inactivity 0` . From 58c2f04b40c7f0d2a4d950f67ee8f39f9a64053b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 4 Mar 2024 16:19:01 +0100 Subject: [PATCH 45/54] Adapt timing-phytest stats to new LDPC decoder iterations --- ci-scripts/datalog_rt_stats.100.2x2.yaml | 4 ++-- ci-scripts/datalog_rt_stats.1x1.60.yaml | 8 ++++---- ci-scripts/datalog_rt_stats.default.yaml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ci-scripts/datalog_rt_stats.100.2x2.yaml b/ci-scripts/datalog_rt_stats.100.2x2.yaml index 31da78e5ea..c54fb13018 100644 --- a/ci-scripts/datalog_rt_stats.100.2x2.yaml +++ b/ci-scripts/datalog_rt_stats.100.2x2.yaml @@ -12,8 +12,8 @@ Ref : feptx_ofdm : 65.0 feptx_total : 177.0 L1 Tx processing : 700.0 - DLSCH encoding : 179.0 - L1 Rx processing : 526.0 + DLSCH encoding : 226.0 + L1 Rx processing : 640.0 PUSCH inner-receiver : 400.0 Schedule Response : 3.0 DL & UL scheduling timing : 15.0 diff --git a/ci-scripts/datalog_rt_stats.1x1.60.yaml b/ci-scripts/datalog_rt_stats.1x1.60.yaml index 9ad2e848e8..140f3939d7 100644 --- a/ci-scripts/datalog_rt_stats.1x1.60.yaml +++ b/ci-scripts/datalog_rt_stats.1x1.60.yaml @@ -11,10 +11,10 @@ Ref : feptx_prec : 15.0 feptx_ofdm : 35.0 feptx_total : 57.0 - L1 Tx processing : 210.0 - DLSCH encoding : 137.0 - L1 Rx processing : 345.0 - PUSCH inner-receiver : 210.0 + L1 Tx processing : 260.0 + DLSCH encoding : 160.0 + L1 Rx processing : 420.0 + PUSCH inner-receiver : 170.0 Schedule Response : 3.0 DL & UL scheduling timing : 8.0 UL Indication : 3.0 diff --git a/ci-scripts/datalog_rt_stats.default.yaml b/ci-scripts/datalog_rt_stats.default.yaml index a561817cf2..44ae5fbb08 100644 --- a/ci-scripts/datalog_rt_stats.default.yaml +++ b/ci-scripts/datalog_rt_stats.default.yaml @@ -11,9 +11,9 @@ Ref : feptx_prec : 13.0 feptx_ofdm : 33.0 feptx_total : 55.0 - L1 Tx processing : 170.0 - DLSCH encoding : 118.0 - L1 Rx processing : 305.0 + L1 Tx processing : 220.0 + DLSCH encoding : 130.0 + L1 Rx processing : 387.0 PUSCH inner-receiver : 150.0 Schedule Response : 3.0 DL & UL scheduling timing : 6.0 From b7a1b4b405d788aa867091c2fcf45b98e399fcd8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 1 Mar 2024 12:09:40 +0100 Subject: [PATCH 46/54] Always stop Quectel on XML terminate --- .../xml_files/container_nsa_b200_terminate.xml | 13 +++++++++++++ .../xml_files/container_sa_b200_terminate.xml | 13 +++++++++++++ .../xml_files/container_sa_e1_b200_terminate.xml | 13 +++++++++++++ .../xml_files/container_sa_f1_b200_terminate.xml | 13 +++++++++++++ .../xml_files/container_sa_sc_b200_terminate.xml | 13 +++++++++++++ 5 files changed, 65 insertions(+) diff --git a/ci-scripts/xml_files/container_nsa_b200_terminate.xml b/ci-scripts/xml_files/container_nsa_b200_terminate.xml index a766fb7bcb..c76e3c5891 100644 --- a/ci-scripts/xml_files/container_nsa_b200_terminate.xml +++ b/ci-scripts/xml_files/container_nsa_b200_terminate.xml @@ -26,6 +26,8 @@ tasks 1 + 010001 + 010002 030202 030201 222220 @@ -33,6 +35,17 @@ + + Detach_UE + Detach UE + idefix + + + Terminate_UE + Terminate Quectel + idefix + + Undeploy_Object Undeploy eNB diff --git a/ci-scripts/xml_files/container_sa_b200_terminate.xml b/ci-scripts/xml_files/container_sa_b200_terminate.xml index bddc94aedf..26836fb096 100644 --- a/ci-scripts/xml_files/container_sa_b200_terminate.xml +++ b/ci-scripts/xml_files/container_sa_b200_terminate.xml @@ -26,10 +26,23 @@ tasks 1 + 010001 + 010002 030201 + + Detach_UE + Detach UE + idefix + + + Terminate_UE + Terminate Quectel + idefix + + Undeploy_Object Undeploy gNB diff --git a/ci-scripts/xml_files/container_sa_e1_b200_terminate.xml b/ci-scripts/xml_files/container_sa_e1_b200_terminate.xml index ad902e838a..ae61c1b6ce 100644 --- a/ci-scripts/xml_files/container_sa_e1_b200_terminate.xml +++ b/ci-scripts/xml_files/container_sa_e1_b200_terminate.xml @@ -26,11 +26,24 @@ tasks 1 + 010001 + 010002 330201 222222 + + Detach_UE + Detach UE + idefix + + + Terminate_UE + Terminate Quectel + idefix + + Undeploy_Object Undeploy CU-CP/CU-UP/DU diff --git a/ci-scripts/xml_files/container_sa_f1_b200_terminate.xml b/ci-scripts/xml_files/container_sa_f1_b200_terminate.xml index f5b13beaed..df02f63b7f 100644 --- a/ci-scripts/xml_files/container_sa_f1_b200_terminate.xml +++ b/ci-scripts/xml_files/container_sa_f1_b200_terminate.xml @@ -26,10 +26,23 @@ tasks 1 + 010001 + 010002 230201 + + Detach_UE + Detach UE + idefix + + + Terminate_UE + Terminate Quectel + idefix + + Undeploy_Object Undeploy CU-DU diff --git a/ci-scripts/xml_files/container_sa_sc_b200_terminate.xml b/ci-scripts/xml_files/container_sa_sc_b200_terminate.xml index 9a041fed7a..f47c16258f 100644 --- a/ci-scripts/xml_files/container_sa_sc_b200_terminate.xml +++ b/ci-scripts/xml_files/container_sa_sc_b200_terminate.xml @@ -26,10 +26,23 @@ tasks 1 + 010001 + 010002 030201 + + Detach_UE + Detach UE + idefix + + + Terminate_UE + Terminate Quectel + idefix + + Undeploy_Object Undeploy gNB From 961981f45686c8dfc9858f0a29a7eb78530960cc Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 1 Mar 2024 13:01:04 +0100 Subject: [PATCH 47/54] CI: make docker volume always succeed in startup Some CI users (OAI developers) expressed that the warning of the `docker volume prune` before starting RFsim is confusing. To avoid the warning in the HTML, force the removal; if the volume does not exist, no warning is emitted. To still catch possible problems, do not do this in the `terminate.xml` so we might still see if there are other problems. --- ci-scripts/xml_files/container_5g_rfsim_fdd_phytest.xml | 2 +- ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml | 2 +- ci-scripts/xml_files/container_5g_rfsim_tdd_dora.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci-scripts/xml_files/container_5g_rfsim_fdd_phytest.xml b/ci-scripts/xml_files/container_5g_rfsim_fdd_phytest.xml index 7eba071e16..6ed13ceb6e 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_fdd_phytest.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_fdd_phytest.xml @@ -50,7 +50,7 @@ Custom_Command Clean-Up any residual volume localhost - docker volume rm 5g_rfsimulator_fdd_phytest_rrc.config + docker volume rm 5g_rfsimulator_fdd_phytest_rrc.config -f diff --git a/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml b/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml index 25ffb4b7b2..452f2c33f9 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_fr2_32prb.xml @@ -48,7 +48,7 @@ Custom_Command Clean-Up any residual volume localhost - docker volume rm 5g_rfsimulator_fr2_32prb_rrc.config + docker volume rm 5g_rfsimulator_fr2_32prb_rrc.config -f diff --git a/ci-scripts/xml_files/container_5g_rfsim_tdd_dora.xml b/ci-scripts/xml_files/container_5g_rfsim_tdd_dora.xml index 9f0c3bc93a..306b8e4e05 100644 --- a/ci-scripts/xml_files/container_5g_rfsim_tdd_dora.xml +++ b/ci-scripts/xml_files/container_5g_rfsim_tdd_dora.xml @@ -48,7 +48,7 @@ Custom_Command Clean-Up any residual volume localhost - docker volume rm 5g_rfsimulator_tdd_dora_rrc.config + docker volume rm 5g_rfsimulator_tdd_dora_rrc.config -f From e9f0541ad04d8260abb03c32a871404eba8eabb9 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 1 Mar 2024 14:27:14 +0100 Subject: [PATCH 48/54] BuildProxy: report success, correctly print HTML --- ci-scripts/cls_containerize.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 708c2a6f3c..20ce23ce35 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -662,22 +662,26 @@ class Containerize(): collectInfo['proxy'] = files mySSH.command('docker image inspect --format=\'Size = {{.Size}} bytes\' proxy:' + tag, '\$', 5) result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) + # Cleaning any created tmp volume + mySSH.command(self.cli + ' volume prune --force || true','\$', 15) + mySSH.close() + allImagesSize = {} if result is not None: imageSize = float(result.group('size')) / 1000000 logging.debug('\u001B[1m proxy size is ' + ('%.0f' % imageSize) + ' Mbytes\u001B[0m') allImagesSize['proxy'] = str(round(imageSize,1)) + ' Mbytes' + logging.info('\u001B[1m Building L2sim Proxy Image Pass\u001B[0m') + HTML.CreateHtmlTestRow('commit ' + tag, 'OK', CONST.ALL_PROCESSES_OK) + HTML.CreateHtmlNextTabHeaderTestRow(collectInfo, allImagesSize) + return True else: - logging.debug('proxy size is unknown') + logging.error('proxy size is unknown') allImagesSize['proxy'] = 'unknown' - - # Cleaning any created tmp volume - mySSH.command(self.cli + ' volume prune --force || true','\$', 15) - mySSH.close() - - logging.info('\u001B[1m Building L2sim Proxy Image Pass\u001B[0m') - HTML.CreateHtmlTestRow('commit ' + tag, 'OK', CONST.ALL_PROCESSES_OK) - HTML.CreateHtmlNextTabHeaderTestRow(collectInfo, allImagesSize) + logging.error('\u001B[1m Build of L2sim proxy failed\u001B[0m') + HTML.CreateHtmlTestRow('commit ' + tag, 'KO', CONST.ALL_PROCESSES_OK) + HTML.CreateHtmlTabFooter(False) + return False def BuildRunTests(self, HTML): if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': From d5eb5ee0f27ee48f79d9e9a87efe70be8ed2f689 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Thu, 28 Dec 2023 12:00:14 +0100 Subject: [PATCH 49/54] Support for context manager in cls_cmd SSH class --- ci-scripts/cls_cmd.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ci-scripts/cls_cmd.py b/ci-scripts/cls_cmd.py index 30f00cdb02..e2a735fa35 100644 --- a/ci-scripts/cls_cmd.py +++ b/ci-scripts/cls_cmd.py @@ -86,6 +86,12 @@ class Cmd(metaclass=abc.ABCMeta): return class LocalCmd(Cmd): + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, exc_traceback): + self.close() + def __init__(self, d = None): self.cwd = d if self.cwd is not None: @@ -128,6 +134,12 @@ class LocalCmd(Cmd): self.copyin(src, tgt, recursive) class RemoteCmd(Cmd): + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, exc_traceback): + self.close() + def __init__(self, hostname, d=None): cIdx = 0 logging.getLogger('paramiko').setLevel(logging.ERROR) # prevent spamming through Paramiko From 3c1ed92b8060a27a0c2b786b3531417672209f7f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 27 Feb 2024 18:02:42 +0100 Subject: [PATCH 50/54] Return success/failure of copyin()/copyout - Return code says if copying succeeded - Improve handling of the recursive code paths, which copy files or directories recursively into another directory - both for RemoteCmd/LocalCmd --- ci-scripts/cls_cmd.py | 66 +++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/ci-scripts/cls_cmd.py b/ci-scripts/cls_cmd.py index e2a735fa35..4eb64e2abe 100644 --- a/ci-scripts/cls_cmd.py +++ b/ci-scripts/cls_cmd.py @@ -128,10 +128,32 @@ class LocalCmd(Cmd): if src[0] != '/' or tgt[0] != '/': raise Exception('support only absolute file paths!') opt = '-r' if recursive else '' - self.run(f'cp {opt} {src} {tgt}') + return self.run(f'cp {opt} {src} {tgt}').returncode == 0 def copyout(self, src, tgt, recursive=False): - self.copyin(src, tgt, recursive) + return self.copyin(src, tgt, recursive) + +def PutFile(client, src, tgt): + success = True + sftp = client.open_sftp() + try: + sftp.put(src, tgt) + except FileNotFoundError as error: + logging.error(f"error while putting {src}: {error}") + success = False + sftp.close() + return success + +def GetFile(client, src, tgt): + success = True + sftp = client.open_sftp() + try: + sftp.get(src, tgt) + except FileNotFoundError as error: + logging.error(f"error while getting {src}: {error}") + success = False + sftp.close() + return success class RemoteCmd(Cmd): def __enter__(self): @@ -205,36 +227,38 @@ class RemoteCmd(Cmd): def getBefore(self): return self.cp.stdout + # if recursive is True, tgt must be a directory (and src is file or directory) + # if recursive is False, tgt and src must be a file name def copyout(self, src, tgt, recursive=False): logging.debug(f"copyout: local:{src} -> remote:{tgt}") if recursive: tmpfile = f"{uuid.uuid4()}.tar" abstmpfile = f"/tmp/{tmpfile}" - cmd = LocalCmd() - cmd.run(f"tar -cf {abstmpfile} {src}") - sftp = self.client.open_sftp() - sftp.put(abstmpfile, abstmpfile) - sftp.close() - cmd.run(f"rm {abstmpfile}") - self.run(f"mv {abstmpfile} {tgt}; cd {tgt} && tar -xf {tmpfile} && rm {tmpfile}") + with LocalCmd() as cmd: + if cmd.run(f"tar -cf {abstmpfile} {src}").returncode != 0: + return False + if not PutFile(self.client, abstmpfile, abstmpfile): + return False + cmd.run(f"rm {abstmpfile}") + ret = self.run(f"mv {abstmpfile} {tgt}; cd {tgt} && tar -xf {tmpfile} && rm {tmpfile}") + return ret.returncode == 0 else: - sftp = self.client.open_sftp() - sftp.put(src, tgt) - sftp.close() + return PutFile(self.client, src, tgt) + # if recursive is True, tgt must be a directory (and src is file or directory) + # if recursive is False, tgt and src must be a file name def copyin(self, src, tgt, recursive=False): logging.debug(f"copyin: remote:{src} -> local:{tgt}") if recursive: tmpfile = f"{uuid.uuid4()}.tar" abstmpfile = f"/tmp/{tmpfile}" - self.run(f"tar -cf {abstmpfile} {src}") - sftp = self.client.open_sftp() - sftp.get(abstmpfile, abstmpfile) - sftp.close() + if self.run(f"tar -cf {abstmpfile} {src}").returncode != 0: + return False + if not GetFile(self.client, abstmpfile, abstmpfile): + return False self.run(f"rm {abstmpfile}") - cmd = LocalCmd() - cmd.run(f"mv {abstmpfile} {tgt}; cd {tgt} && tar -xf {tmpfile} && rm {tmpfile}") + with LocalCmd() as cmd: + ret = cmd.run(f"mv {abstmpfile} {tgt}; cd {tgt} && tar -xf {tmpfile} && rm {tmpfile}") + return ret.returncode == 0 else: - sftp = self.client.open_sftp() - sftp.get(src, tgt) - sftp.close() + return GetFile(self.client, src, tgt) From d7c3806f13503baa7c5061a02b9b11c29fc3e08c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 4 Mar 2024 12:01:15 +0100 Subject: [PATCH 51/54] Use tini as init in all containers - Print problems, e.g., segfault - Handle signals and zombie processes properly --- docker/Dockerfile.base.rhel9 | 6 ++++++ docker/Dockerfile.base.rocky | 6 ++++++ docker/Dockerfile.base.ubuntu20 | 6 ++++++ docker/Dockerfile.base.ubuntu20.cross-arm64 | 6 ++++++ docker/Dockerfile.eNB.rhel9 | 3 ++- docker/Dockerfile.eNB.rocky | 3 ++- docker/Dockerfile.eNB.ubuntu20 | 3 ++- docker/Dockerfile.gNB.aw2s.rhel9 | 3 ++- docker/Dockerfile.gNB.aw2s.rocky | 3 ++- docker/Dockerfile.gNB.aw2s.ubuntu20 | 3 ++- docker/Dockerfile.gNB.rhel9 | 3 ++- docker/Dockerfile.gNB.rocky | 3 ++- docker/Dockerfile.gNB.ubuntu20 | 3 ++- docker/Dockerfile.lteRU.rhel9 | 3 ++- docker/Dockerfile.lteRU.ubuntu20 | 3 ++- docker/Dockerfile.lteUE.rhel9 | 3 ++- docker/Dockerfile.lteUE.rocky | 3 ++- docker/Dockerfile.lteUE.ubuntu20 | 3 ++- docker/Dockerfile.nr-cuup.rhel9 | 3 ++- docker/Dockerfile.nr-cuup.rocky | 3 ++- docker/Dockerfile.nr-cuup.ubuntu20 | 3 ++- docker/Dockerfile.nrUE.rhel9 | 3 ++- docker/Dockerfile.nrUE.rocky | 3 ++- docker/Dockerfile.nrUE.ubuntu20 | 3 ++- 24 files changed, 64 insertions(+), 20 deletions(-) diff --git a/docker/Dockerfile.base.rhel9 b/docker/Dockerfile.base.rhel9 index 56b1ce7a23..7142b721fa 100644 --- a/docker/Dockerfile.base.rhel9 +++ b/docker/Dockerfile.base.rhel9 @@ -58,6 +58,12 @@ RUN rm -f /etc/rhsm-host && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf +# Add "Tini - A tiny but valid init for containers", https://github.com/krallin/tini +# it will be copied into target containers, to print exit numbers and handle signals properly +ENV TINI_VERSION v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini + # In some network environments, GIT proxy is required RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi" diff --git a/docker/Dockerfile.base.rocky b/docker/Dockerfile.base.rocky index 42267f5d59..41210177b8 100644 --- a/docker/Dockerfile.base.rocky +++ b/docker/Dockerfile.base.rocky @@ -46,6 +46,12 @@ RUN dnf install 'dnf-command(config-manager)' -y && \ python3-pip && \ pip3 install --ignore-installed pyyaml +# Add "Tini - A tiny but valid init for containers", https://github.com/krallin/tini +# it will be copied into target containers, to print exit numbers and handle signals properly +ENV TINI_VERSION v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini + #create the WORKDIR WORKDIR /oai-ran COPY . . diff --git a/docker/Dockerfile.base.ubuntu20 b/docker/Dockerfile.base.ubuntu20 index 73fe0905d9..3434bdaa4b 100644 --- a/docker/Dockerfile.base.ubuntu20 +++ b/docker/Dockerfile.base.ubuntu20 @@ -46,6 +46,12 @@ RUN apt-get update && \ python3-pip && \ pip3 install --ignore-installed pyyaml +# Add "Tini - A tiny but valid init for containers", https://github.com/krallin/tini +# it will be copied into target containers, to print exit numbers and handle signals properly +ENV TINI_VERSION v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini + # In some network environments, GIT proxy is required RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi" diff --git a/docker/Dockerfile.base.ubuntu20.cross-arm64 b/docker/Dockerfile.base.ubuntu20.cross-arm64 index 3f83b751af..bdd6c41774 100644 --- a/docker/Dockerfile.base.ubuntu20.cross-arm64 +++ b/docker/Dockerfile.base.ubuntu20.cross-arm64 @@ -73,6 +73,12 @@ RUN apt-get update && \ g++-9-aarch64-linux-gnu && \ apt-get clean +# Add "Tini - A tiny but valid init for containers", https://github.com/krallin/tini +# it will be copied into target containers, to print exit numbers and handle signals properly +ENV TINI_VERSION v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini + # create the WORKDIR WORKDIR /oai-ran COPY . . diff --git a/docker/Dockerfile.eNB.rhel9 b/docker/Dockerfile.eNB.rhel9 index 7883f8560a..191c8eb2b5 100644 --- a/docker/Dockerfile.eNB.rhel9 +++ b/docker/Dockerfile.eNB.rhel9 @@ -112,5 +112,6 @@ WORKDIR /opt/oai-enb # 36422 --> X2C, SCTP/UDP EXPOSE 2152/udp 36412/udp 36422/udp -ENTRYPOINT ["/opt/oai-enb/bin/entrypoint.sh"] +COPY --from=enb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-enb/bin/entrypoint.sh"] CMD ["/opt/oai-enb/bin/lte-softmodem", "-O", "/opt/oai-enb/etc/enb.conf"] diff --git a/docker/Dockerfile.eNB.rocky b/docker/Dockerfile.eNB.rocky index 5bd3aa8458..51705f0e7b 100644 --- a/docker/Dockerfile.eNB.rocky +++ b/docker/Dockerfile.eNB.rocky @@ -122,5 +122,6 @@ WORKDIR /opt/oai-enb # 36422 --> X2C, SCTP/UDP EXPOSE 2152/udp 36412/udp 36422/udp -ENTRYPOINT ["/opt/oai-enb/bin/entrypoint.sh"] +COPY --from=enb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-enb/bin/entrypoint.sh"] CMD ["/opt/oai-enb/bin/lte-softmodem", "-O", "/opt/oai-enb/etc/enb.conf"] diff --git a/docker/Dockerfile.eNB.ubuntu20 b/docker/Dockerfile.eNB.ubuntu20 index 2f10bda9ef..73a96dac62 100644 --- a/docker/Dockerfile.eNB.ubuntu20 +++ b/docker/Dockerfile.eNB.ubuntu20 @@ -112,5 +112,6 @@ EXPOSE 2152/udp 36412/udp 36422/udp #EXPOSE 50000/udp # IF5 / ORI (control) #EXPOSE 50001/udp # IF5 / ECPRI (data) -ENTRYPOINT ["/opt/oai-enb/bin/entrypoint.sh"] +COPY --from=enb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-enb/bin/entrypoint.sh"] CMD ["/opt/oai-enb/bin/lte-softmodem", "-O", "/opt/oai-enb/etc/enb.conf"] diff --git a/docker/Dockerfile.gNB.aw2s.rhel9 b/docker/Dockerfile.gNB.aw2s.rhel9 index 863f126be6..0885a9962d 100644 --- a/docker/Dockerfile.gNB.aw2s.rhel9 +++ b/docker/Dockerfile.gNB.aw2s.rhel9 @@ -86,5 +86,6 @@ RUN ln -s /usr/local/lib/libaw2sori_transpro.so /usr/local/lib/libthirdparty_tra WORKDIR /opt/oai-gnb-aw2s -ENTRYPOINT ["/opt/oai-gnb-aw2s/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb-aw2s/bin/entrypoint.sh"] CMD ["/opt/oai-gnb-aw2s/bin/nr-softmodem", "-O", "/opt/oai-gnb-aw2s/etc/gnb.conf"] diff --git a/docker/Dockerfile.gNB.aw2s.rocky b/docker/Dockerfile.gNB.aw2s.rocky index 1897bf2720..57b6e8c1b5 100644 --- a/docker/Dockerfile.gNB.aw2s.rocky +++ b/docker/Dockerfile.gNB.aw2s.rocky @@ -95,5 +95,6 @@ RUN ln -s /usr/local/lib/libaw2sori_transpro.so /usr/local/lib/libthirdparty_tra WORKDIR /opt/oai-gnb-aw2s -ENTRYPOINT ["/opt/oai-gnb-aw2s/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb-aw2s/bin/entrypoint.sh"] CMD ["/opt/oai-gnb-aw2s/bin/nr-softmodem", "-O", "/opt/oai-gnb-aw2s/etc/gnb.conf"] diff --git a/docker/Dockerfile.gNB.aw2s.ubuntu20 b/docker/Dockerfile.gNB.aw2s.ubuntu20 index 321876638d..4d28c38707 100644 --- a/docker/Dockerfile.gNB.aw2s.ubuntu20 +++ b/docker/Dockerfile.gNB.aw2s.ubuntu20 @@ -81,5 +81,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/libaw2sori_transpro.so /usr/local/lib/lib WORKDIR /opt/oai-gnb-aw2s -ENTRYPOINT ["/opt/oai-gnb-aw2s/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb-aw2s/bin/entrypoint.sh"] CMD ["/opt/oai-gnb-aw2s/bin/nr-softmodem", "-O", "/opt/oai-gnb-aw2s/etc/gnb.conf"] diff --git a/docker/Dockerfile.gNB.rhel9 b/docker/Dockerfile.gNB.rhel9 index fc6a6c5975..358782519f 100644 --- a/docker/Dockerfile.gNB.rhel9 +++ b/docker/Dockerfile.gNB.rhel9 @@ -111,5 +111,6 @@ WORKDIR /opt/oai-gnb #EXPOSE 50000/udp # IF5 / ORI (control) #EXPOSE 50001/udp # IF5 / ECPRI (data) -ENTRYPOINT ["/opt/oai-gnb/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb/bin/entrypoint.sh"] CMD ["/opt/oai-gnb/bin/nr-softmodem", "-O", "/opt/oai-gnb/etc/gnb.conf"] diff --git a/docker/Dockerfile.gNB.rocky b/docker/Dockerfile.gNB.rocky index 035f1122a5..d4c8504bb8 100644 --- a/docker/Dockerfile.gNB.rocky +++ b/docker/Dockerfile.gNB.rocky @@ -121,5 +121,6 @@ WORKDIR /opt/oai-gnb #EXPOSE 50000/udp # IF5 / ORI (control) #EXPOSE 50001/udp # IF5 / ECPRI (data) -ENTRYPOINT ["/opt/oai-gnb/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb/bin/entrypoint.sh"] CMD ["/opt/oai-gnb/bin/nr-softmodem", "-O", "/opt/oai-gnb/etc/gnb.conf"] diff --git a/docker/Dockerfile.gNB.ubuntu20 b/docker/Dockerfile.gNB.ubuntu20 index 6cc0af8965..16e3795fe8 100644 --- a/docker/Dockerfile.gNB.ubuntu20 +++ b/docker/Dockerfile.gNB.ubuntu20 @@ -108,5 +108,6 @@ WORKDIR /opt/oai-gnb #EXPOSE 50000/udp # IF5 / ORI (control) #EXPOSE 50001/udp # IF5 / ECPRI (data) -ENTRYPOINT ["/opt/oai-gnb/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb/bin/entrypoint.sh"] CMD ["/opt/oai-gnb/bin/nr-softmodem", "-O", "/opt/oai-gnb/etc/gnb.conf"] diff --git a/docker/Dockerfile.lteRU.rhel9 b/docker/Dockerfile.lteRU.rhel9 index 81741441ab..30e996600c 100644 --- a/docker/Dockerfile.lteRU.rhel9 +++ b/docker/Dockerfile.lteRU.rhel9 @@ -95,5 +95,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai WORKDIR /opt/oai-lte-ru -ENTRYPOINT ["/opt/oai-lte-ru/bin/entrypoint.sh"] +COPY --from=ru-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-lte-ru/bin/entrypoint.sh"] CMD ["/opt/oai-lte-ru/bin/oairu", "-O", "/opt/oai-lte-ru/etc/rru.conf"] diff --git a/docker/Dockerfile.lteRU.ubuntu20 b/docker/Dockerfile.lteRU.ubuntu20 index 1a476c5733..6fa2a167b7 100644 --- a/docker/Dockerfile.lteRU.ubuntu20 +++ b/docker/Dockerfile.lteRU.ubuntu20 @@ -88,5 +88,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai WORKDIR /opt/oai-lte-ru -ENTRYPOINT ["/opt/oai-lte-ru/bin/entrypoint.sh"] +COPY --from=ru-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-lte-ru/bin/entrypoint.sh"] CMD ["/opt/oai-lte-ru/bin/oairu", "-O", "/opt/oai-lte-ru/etc/rru.conf"] diff --git a/docker/Dockerfile.lteUE.rhel9 b/docker/Dockerfile.lteUE.rhel9 index 1ba07477c1..a9a95e23a6 100644 --- a/docker/Dockerfile.lteUE.rhel9 +++ b/docker/Dockerfile.lteUE.rhel9 @@ -104,5 +104,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai ldconfig WORKDIR /opt/oai-lte-ue +COPY --from=lte-ue-base /tini /tini CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem"] -ENTRYPOINT ["/opt/oai-lte-ue/bin/entrypoint.sh"] +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-lte-ue/bin/entrypoint.sh"] diff --git a/docker/Dockerfile.lteUE.rocky b/docker/Dockerfile.lteUE.rocky index 9e4043fb9b..95845a0fd4 100644 --- a/docker/Dockerfile.lteUE.rocky +++ b/docker/Dockerfile.lteUE.rocky @@ -116,5 +116,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai echo "ldd on libtelnetsrv.so" && ldd /usr/local/lib/libtelnetsrv.so WORKDIR /opt/oai-lte-ue +COPY --from=lte-ue-base /tini /tini CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem"] -ENTRYPOINT ["/opt/oai-lte-ue/bin/entrypoint.sh"] +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-lte-ue/bin/entrypoint.sh"] diff --git a/docker/Dockerfile.lteUE.ubuntu20 b/docker/Dockerfile.lteUE.ubuntu20 index 89dbd505d5..3320c36bf8 100644 --- a/docker/Dockerfile.lteUE.ubuntu20 +++ b/docker/Dockerfile.lteUE.ubuntu20 @@ -104,5 +104,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai ldd /opt/oai-lte-ue/bin/lte-uesoftmodem WORKDIR /opt/oai-lte-ue +COPY --from=lte-ue-base /tini /tini CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem"] -ENTRYPOINT ["/opt/oai-lte-ue/bin/entrypoint.sh"] +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-lte-ue/bin/entrypoint.sh"] diff --git a/docker/Dockerfile.nr-cuup.rhel9 b/docker/Dockerfile.nr-cuup.rhel9 index 5ae63a0e48..00d6236bfe 100644 --- a/docker/Dockerfile.nr-cuup.rhel9 +++ b/docker/Dockerfile.nr-cuup.rhel9 @@ -75,5 +75,6 @@ WORKDIR /opt/oai-gnb/etc WORKDIR /opt/oai-gnb -ENTRYPOINT ["/opt/oai-gnb/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb/bin/entrypoint.sh"] CMD ["/opt/oai-gnb/bin/nr-cuup", "-O", "/opt/oai-gnb/etc/gnb.conf"] diff --git a/docker/Dockerfile.nr-cuup.rocky b/docker/Dockerfile.nr-cuup.rocky index adeaf053d9..e3dc1bf5be 100644 --- a/docker/Dockerfile.nr-cuup.rocky +++ b/docker/Dockerfile.nr-cuup.rocky @@ -76,5 +76,6 @@ WORKDIR /opt/oai-gnb/etc WORKDIR /opt/oai-gnb -ENTRYPOINT ["/opt/oai-gnb/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb/bin/entrypoint.sh"] CMD ["/opt/oai-gnb/bin/nr-cuup", "-O", "/opt/oai-gnb/etc/gnb.conf"] diff --git a/docker/Dockerfile.nr-cuup.ubuntu20 b/docker/Dockerfile.nr-cuup.ubuntu20 index 365e48a4b8..0a371e669c 100644 --- a/docker/Dockerfile.nr-cuup.ubuntu20 +++ b/docker/Dockerfile.nr-cuup.ubuntu20 @@ -66,5 +66,6 @@ RUN ldconfig && ldd /opt/oai-gnb/bin/nr-cuup WORKDIR /opt/oai-gnb/etc WORKDIR /opt/oai-gnb -ENTRYPOINT ["/opt/oai-gnb/bin/entrypoint.sh"] +COPY --from=gnb-base /tini /tini +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-gnb/bin/entrypoint.sh"] CMD ["/opt/oai-gnb/bin/nr-cuup", "-O", "/opt/oai-gnb/etc/gnb.conf"] diff --git a/docker/Dockerfile.nrUE.rhel9 b/docker/Dockerfile.nrUE.rhel9 index 90d7499dd0..14d9f6c7f7 100644 --- a/docker/Dockerfile.nrUE.rhel9 +++ b/docker/Dockerfile.nrUE.rhel9 @@ -108,5 +108,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai WORKDIR /opt/oai-nr-ue +COPY --from=nr-ue-base /tini /tini CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem", "-O", "/opt/oai-nr-ue/etc/nr-ue.conf"] -ENTRYPOINT ["/opt/oai-nr-ue/bin/entrypoint.sh"] +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-nr-ue/bin/entrypoint.sh"] diff --git a/docker/Dockerfile.nrUE.rocky b/docker/Dockerfile.nrUE.rocky index 638b4406c4..1ffccd60d5 100644 --- a/docker/Dockerfile.nrUE.rocky +++ b/docker/Dockerfile.nrUE.rocky @@ -117,5 +117,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai echo "ldd on libtelnetsrv_5Gue.so" && ldd /usr/local/lib/libtelnetsrv_5Gue.so WORKDIR /opt/oai-nr-ue +COPY --from=nr-ue-base /tini /tini CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem", "-O", "/opt/oai-nr-ue/etc/nr-ue.conf"] -ENTRYPOINT ["/opt/oai-nr-ue/bin/entrypoint.sh"] +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-nr-ue/bin/entrypoint.sh"] diff --git a/docker/Dockerfile.nrUE.ubuntu20 b/docker/Dockerfile.nrUE.ubuntu20 index 30d32b2f31..7418c6ccb9 100644 --- a/docker/Dockerfile.nrUE.ubuntu20 +++ b/docker/Dockerfile.nrUE.ubuntu20 @@ -104,5 +104,6 @@ RUN /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so /usr/local/lib/liboai ldd /opt/oai-nr-ue/bin/nr-uesoftmodem WORKDIR /opt/oai-nr-ue +COPY --from=nr-ue-base /tini /tini CMD ["/opt/oai-nr-ue/bin/nr-uesoftmodem", "-O", "/opt/oai-nr-ue/etc/nr-ue.conf"] -ENTRYPOINT ["/opt/oai-nr-ue/bin/entrypoint.sh"] +ENTRYPOINT ["/tini", "-v", "--", "/opt/oai-nr-ue/bin/entrypoint.sh"] From adbb051bb72d9ee8051d33f5b26ddd1451728d38 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 4 Mar 2024 13:21:18 +0100 Subject: [PATCH 52/54] Set ulimit for core to -1 Set ulimit of core to -1 enable core dumps for file-based core dumping. Note that it is not necessary for e.g., systemd-coredumpd, but put it for completeness. --- ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml | 2 ++ ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml | 2 ++ ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml | 2 ++ ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml | 2 ++ ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml | 2 ++ ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml | 2 ++ ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml | 6 ++++++ ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml | 4 ++++ ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml | 2 ++ 9 files changed, 24 insertions(+) diff --git a/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml index c19400b109..6c67479aec 100644 --- a/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/5g_sa_n310_gnb/docker-compose.yml @@ -5,6 +5,8 @@ services: privileged: true network_mode: "host" container_name: oai-gnb + ulimits: + core: -1 # for core dumps environment: TZ: Europe/Paris USE_ADDITIONAL_OPTIONS: --sa --tune-offset 20000000 -A 45 --log_config.global_log_options level,nocolor,time diff --git a/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml b/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml index 85230d467c..20c6f81b1b 100644 --- a/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml +++ b/ci-scripts/yaml_files/5g_sa_n310_nrue/docker-compose.yml @@ -5,6 +5,8 @@ services: privileged: true network_mode: host container_name: oai-nr-ue + ulimits: + core: -1 # for core dumps #entrypoint: /bin/bash -c "sleep infinity" environment: TZ: Europe/Paris diff --git a/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml index f6e7214659..9959100271 100644 --- a/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml +++ b/ci-scripts/yaml_files/nsa_b200_enb/docker-compose.yml @@ -5,6 +5,8 @@ services: image: oai-enb:latest privileged: true container_name: nsa-b200-enb + ulimits: + core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: --log_config.global_log_options level,nocolor,time,line_num,function diff --git a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml index 67d240d796..530e9c7c25 100644 --- a/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/nsa_b200_gnb/docker-compose.yml @@ -5,6 +5,8 @@ services: image: oai-gnb:latest privileged: true container_name: nsa-b200-gnb + ulimits: + core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: -E -q --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function diff --git a/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml index d3875aa5bc..eefcfac3e5 100644 --- a/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_aw2s_gnb/docker-compose.yml @@ -5,6 +5,8 @@ services: privileged: true network_mode: "host" container_name: oai-gnb-aw2s + ulimits: + core: -1 # for core dumps environment: TZ: Europe/Paris USE_ADDITIONAL_OPTIONS: --sa diff --git a/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml index f46d7b1b0a..72a9ac2831 100644 --- a/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_b200_gnb/docker-compose.yml @@ -5,6 +5,8 @@ services: image: oai-gnb:latest privileged: true container_name: sa-b200-gnb + ulimits: + core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function diff --git a/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml index 8e353b945e..224c28c297 100644 --- a/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_e1_b200_gnb/docker-compose.yml @@ -5,6 +5,8 @@ services: image: oai-gnb:latest privileged: true container_name: sa-cucp-gnb + ulimits: + core: -1 # for core dumps environment: USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time,line_num,function volumes: @@ -23,6 +25,8 @@ services: image: oai-nr-cuup:latest privileged: true container_name: sa-cuup-gnb + ulimits: + core: -1 # for core dumps environment: USE_ADDITIONAL_OPTIONS: --sa --log_config.global_log_options level,nocolor,time,line_num,function volumes: @@ -41,6 +45,8 @@ services: image: oai-gnb:latest privileged: true container_name: sa-du-b200-gnb + ulimits: + core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --continuous-tx -E --log_config.global_log_options level,nocolor,time,line_num,function --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 1 --RUs.[0].att_rx 18 --RUs.[0].att_tx 18 diff --git a/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml index 072461af5c..c4a4d57ff9 100644 --- a/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_f1_b200_gnb/docker-compose.yml @@ -5,6 +5,8 @@ services: image: oai-gnb:latest privileged: true container_name: sa-cu-gnb + ulimits: + core: -1 # for core dumps environment: USE_ADDITIONAL_OPTIONS: --sa --telnetsrv --telnetsrv.shrmod ci --log_config.global_log_options level,nocolor,time,line_num,function volumes: @@ -24,6 +26,8 @@ services: image: oai-gnb:latest privileged: true container_name: sa-du-b200-gnb + ulimits: + core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --log_config.global_log_options level,nocolor,time,line_num,function --gNBs.[0].min_rxtxtime 2 --gNBs.[0].do_CSIRS 1 --gNBs.[0].do_SRS 0 --MACRLCs.[0].ul_max_mcs 28 --L1s.[0].max_ldpc_iterations 20 diff --git a/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml b/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml index 90f8bf2271..60cbf1ccd9 100644 --- a/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml +++ b/ci-scripts/yaml_files/sa_sc_b200_gnb/docker-compose.yml @@ -5,6 +5,8 @@ services: image: oai-gnb:latest privileged: true container_name: sa-b200-gnb + ulimits: + core: -1 # for core dumps environment: USE_B2XX: 'yes' USE_ADDITIONAL_OPTIONS: --sa --RUs.[0].sdr_addrs serial=30C51D4 --telnetsrv --telnetsrv.shrmod ci --continuous-tx --log_config.global_log_options level,nocolor,time,line_num,function -E From 56acd1d6d342f6ca6dc45072fba1c3397be6608a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 4 Mar 2024 13:47:01 +0100 Subject: [PATCH 53/54] Add doc on how to retrieve core dumps --- doc/TESTBenches.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/doc/TESTBenches.md b/doc/TESTBenches.md index 40f410e9c5..fa488a42f7 100644 --- a/doc/TESTBenches.md +++ b/doc/TESTBenches.md @@ -249,3 +249,71 @@ steps](../docker/README.md) and then use the docker-compose file directly. Some tests are run from source (e.g. `ci-scripts/xml_files/gnb_phytest_usrp_run.xml`), which directly give the options they are run with. + +## How to retrieve core dumps (for CI team members) + +The entrypoint scripts of all containers print the core pattern that is used on +the running machine. Search for `core_pattern` at the start of the container +logs to retrieve the possible location. Possible locations might be: + +- a path: the corresponding directory must be mounted in the container to be + writable +- systemd-coredumpd: see [documentation](https://systemd.io/COREDUMP/) +- abrt: see [documentation](https://abrt.readthedocs.io/en/latest/usage.html) +- apport: see [documentation](https://wiki.ubuntu.com/Apport) + +You furthermore have to extract the executable that caused the core dump. +Download the container image, and extract, e.g.: + +``` +docker create --name c1 porcepix.sboai.cs.eurecom.fr/oai-gnb:develop-c99db698 +docker cp c1:/opt/oai-gnb/bin/nr-softmodem /tmp +docker rm c1 +``` + +### Core dump in a file + +**This is not recommended, as files could pile up and fill the system disk +completely!** Prefer systemd or abrt instead. + +If the core pattern is a path: it should at least include the time in the +pattern name (suggested pattern: `/tmp/core.%e.%p.%t`) to correlate the time +the segfault occurred with the CI logs. If you identified the core dump, +copy the core dump from that machine; if identification is difficult, consider +rerunning the pipeline. + +### Core dump via systemd + +Run this command to list all core dumps: + +``` +sudo coredumpctl list +``` + +Scroll to the end and find the core dump of interest (it lists the executables +in the last column; use the time to correlate the segfault and the CI run). +Take the PID of the executable (first column after the time). Dump the core +dump to a location of your choice: + +``` +sudo coredumpctl dump > /tmp/coredump +``` + +### Core dump via abrt (automatic bug reporting tool) + +TBD: use the documentation page for the moment. + +### Core dump via apport + +On Ubuntu machines, apport first needs to be enabled to collect core dumps: + +``` +sudo systemctl enable apport.service +``` + +and [needs to be enabled](https://wiki.ubuntu.com/Apport#How_to_enable_apport). +Then, show a list of core dumps using + +``` +sudo apport-cli +``` From fca1561bf7d6dcb81de378401a3ce4e3c24cbd14 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Tue, 9 Jan 2024 19:29:46 +0100 Subject: [PATCH 54/54] Modifs of cls_containerize - UndeployObject() - use new ssh class - do proper logging from multiple services - use yaml dir - Use splitlines(), minor modifs of syntax - check that services are running - Check all copyin() operations, not only last - switch to docker compose: with the use of the new ssh class, we cannot (easily) use the old docker-compose anymore (which was an alias to docker compose). Switch to "docker compose". Co-authored-by: Robert Schmidt --- ci-scripts/cls_containerize.py | 57 +++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 708c2a6f3c..cf959e8503 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -951,12 +951,12 @@ class Containerize(): if svcName == '': logging.warning('no service name given: starting all services in ci-docker-compose.yml!') - mySSH.command(f'docker-compose --file ci-docker-compose.yml up -d -- {svcName}', '\$', 30) + mySSH.command(f'docker compose --file ci-docker-compose.yml up -d -- {svcName}', '\$', 30) # Checking Status grep = '' if svcName != '': grep = f' | grep -A3 {svcName}' - mySSH.command(f'docker-compose --file ci-docker-compose.yml config {grep}', '\$', 5) + mySSH.command(f'docker compose --file ci-docker-compose.yml config {grep}', '\$', 5) result = re.search('container_name: (?P[a-zA-Z0-9\-\_]+)', mySSH.getBefore()) unhealthyNb = 0 healthyNb = 0 @@ -1058,55 +1058,55 @@ class Containerize(): if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': HELP.GenericHelp(CONST.Version) sys.exit('Insufficient Parameter') - logging.debug('\u001B[1m Undeploying OAI Object from server: ' + lIpAddr + '\u001B[0m') - mySSH = SSH.SSHConnection() - mySSH.open(lIpAddr, lUserName, lPassWord) - - mySSH.command('cd ' + lSourcePath + '/' + self.yamlPath[self.eNB_instance], '\$', 5) - + logging.debug(f'\u001B[1m Undeploying OAI Object from server: {lIpAddr}\u001B[0m') + mySSH = cls_cmd.getConnection(lIpAddr) + yamlDir = f'{lSourcePath}/{self.yamlPath[self.eNB_instance]}' + mySSH.run(f'cd {yamlDir}') svcName = self.services[self.eNB_instance] forceDown = False if svcName != '': logging.warning(f'service name given, but will stop all services in ci-docker-compose.yml!') svcName = '' - mySSH.command(f'docker-compose -f ci-docker-compose.yml config --services', '\$', 5) + ret = mySSH.run(f'docker compose -f {yamlDir}/ci-docker-compose.yml config --services') + if ret.returncode != 0: + HTML.CreateHtmlTestRow(RAN.runtime_stats, 'KO', "cannot enumerate running services") + self.exitStatus = 1 + return # first line has command, last line has next command prompt - allServices = mySSH.getBefore().split('\r\n')[1:-1] + allServices = ret.stdout.splitlines() services = [] for s in allServices: - mySSH.command(f'docker-compose -f ci-docker-compose.yml ps --all -- {s}', '\$', 5, silent=False) - running = mySSH.getBefore().split('\r\n')[2:-1] + # outputs the hash if the container is running + ret = mySSH.run(f'docker compose -f {yamlDir}/ci-docker-compose.yml ps --all --quiet -- {s}') + running = ret.stdout.splitlines() logging.debug(f'running services: {running}') - if len(running) > 0: # something is running for that service + if ret.stdout != "" and ret.returncode == 0: # something is running for that service services.append(s) logging.info(f'stopping services {services}') - mySSH.command(f'docker-compose -f ci-docker-compose.yml stop -t3', '\$', 30) - time.sleep(5) # give some time to running containers to stop + mySSH.run(f'docker compose -f {yamlDir}/ci-docker-compose.yml stop -t3') + copyin_res = True for svcName in services: # head -n -1 suppresses the final "X exited with status code Y" filename = f'{svcName}-{HTML.testCase_id}.log' - mySSH.command(f'docker-compose -f ci-docker-compose.yml logs --no-log-prefix -- {svcName} &> {lSourcePath}/cmake_targets/log/{filename}', '\$', 120) + mySSH.run(f'docker compose -f {yamlDir}/ci-docker-compose.yml logs --no-log-prefix -- {svcName} &> {lSourcePath}/cmake_targets/log/{filename}') + copyin_res = mySSH.copyin(f'{lSourcePath}/cmake_targets/log/{filename}', f'{filename}') and copyin_res + # when nv-cubb container is available, copy L1 pcap, OAI Aerial pipeline + if 'nv-cubb' in allServices: + mySSH.run(f'cp {lSourcePath}/cmake_targets/share/gnb_nvipc.pcap {lSourcePath}/cmake_targets/gnb_nvipc.pcap') - mySSH.command('docker-compose -f ci-docker-compose.yml down -v', '\$', 5) - mySSH.close() + mySSH.run(f'docker compose -f {yamlDir}/ci-docker-compose.yml down -v') # Analyzing log file! - files = ','.join([f'{s}-{HTML.testCase_id}' for s in services]) - if len(services) > 1: - files = '{' + files + '}' - copyin_res = 0 - if len(services) > 0: - copyin_res = mySSH.copyin(lIpAddr, lUserName, lPassWord, f'{lSourcePath}/cmake_targets/log/{files}.log', '.') - if copyin_res == -1: - HTML.htmleNBFailureMsg='Could not copy logfile to analyze it!' + if not copyin_res: + HTML.htmleNBFailureMsg='Could not copy logfile(s) to analyze it!' HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE) self.exitStatus = 1 # use function for UE log analysis, when oai-nr-ue container is used elif 'oai-nr-ue' in services or 'lte_ue0' in services: self.exitStatus == 0 - logging.debug('\u001B[1m Analyzing UE logfile ' + filename + ' \u001B[0m') + logging.debug(f'Analyzing UE logfile {filename}') logStatus = cls_oaicitest.OaiCiTest().AnalyzeLogFile_UE(f'{filename}', HTML, RAN) if (logStatus < 0): fullStatus = False @@ -1125,11 +1125,12 @@ class Containerize(): HTML.CreateHtmlTestRow(RAN.runtime_stats, 'OK', CONST.ALL_PROCESSES_OK) # all the xNB run logs shall be on the server 0 for logCollecting if self.eNB_serverId[self.eNB_instance] != '0': - mySSH.copyout(self.eNBIPAddress, self.eNBUserName, self.eNBPassword, f'./{files}.log', f'{self.eNBSourceCodePath}/cmake_targets/') + mySSH.copyout(f'./*.log', f'{lSourcePath}/cmake_targets/', recursive=True) if self.exitStatus == 0: logging.info('\u001B[1m Undeploying OAI Object Pass\u001B[0m') else: logging.error('\u001B[1m Undeploying OAI Object Failed\u001B[0m') + mySSH.close() def DeployGenObject(self, HTML, RAN, UE): self.exitStatus = 0